aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Saab <ps@FreeBSD.org>2000-05-22 09:53:22 +0000
committerPaul Saab <ps@FreeBSD.org>2000-05-22 09:53:22 +0000
commita5f0fb151d90effe79714de0fa059954725fe57f (patch)
tree27b16fc210b9a302c9e74f90e36a9b5ed21e6300
downloadsrc-a5f0fb151d90effe79714de0fa059954725fe57f.tar.gz
src-a5f0fb151d90effe79714de0fa059954725fe57f.zip
Import the [now] dual licensed version 3.5.4 of less. It isvendor/less/v354
distributed under your choice of the GPL or a BSD style license. Reviewed by: peter Obtained from: http://home.flash.net/~marknu/less/
Notes
Notes: svn path=/vendor/less/dist/; revision=60786 svn path=/vendor/less/v354/; revision=60788; tag=vendor/less/v354
-rw-r--r--contrib/less/COPYING340
-rw-r--r--contrib/less/INSTALL186
-rw-r--r--contrib/less/LICENSE27
-rw-r--r--contrib/less/Makefile.aut118
-rw-r--r--contrib/less/Makefile.dsb50
-rw-r--r--contrib/less/Makefile.dsg74
-rw-r--r--contrib/less/Makefile.dsm58
-rw-r--r--contrib/less/Makefile.in110
-rw-r--r--contrib/less/Makefile.o2e39
-rw-r--r--contrib/less/Makefile.o9c46
-rw-r--r--contrib/less/Makefile.o9u42
-rw-r--r--contrib/less/Makefile.wnb49
-rw-r--r--contrib/less/Makefile.wnm55
-rw-r--r--contrib/less/NEWS485
-rw-r--r--contrib/less/README226
-rw-r--r--contrib/less/acconfig.h70
-rw-r--r--contrib/less/brac.c101
-rw-r--r--contrib/less/ch.c794
-rw-r--r--contrib/less/charset.c294
-rw-r--r--contrib/less/cmd.h128
-rw-r--r--contrib/less/cmdbuf.c1022
-rw-r--r--contrib/less/command.c1543
-rwxr-xr-xcontrib/less/configure2737
-rw-r--r--contrib/less/configure.in302
-rw-r--r--contrib/less/decode.c817
-rw-r--r--contrib/less/defines.ds377
-rw-r--r--contrib/less/defines.h.in326
-rw-r--r--contrib/less/defines.h.top172
-rw-r--r--contrib/less/defines.o2302
-rw-r--r--contrib/less/defines.o9323
-rw-r--r--contrib/less/defines.wn310
-rw-r--r--contrib/less/edit.c761
-rw-r--r--contrib/less/filename.c1011
-rw-r--r--contrib/less/forwback.c412
-rw-r--r--contrib/less/funcs.h240
-rw-r--r--contrib/less/help.c214
-rw-r--r--contrib/less/ifile.c346
-rw-r--r--contrib/less/input.c342
-rwxr-xr-xcontrib/less/install.sh119
-rw-r--r--contrib/less/jump.c287
-rw-r--r--contrib/less/less.h382
-rw-r--r--contrib/less/less.hlp209
-rw-r--r--contrib/less/less.man1914
-rw-r--r--contrib/less/less.nro1502
-rw-r--r--contrib/less/lessecho.c226
-rw-r--r--contrib/less/lesskey.c858
-rw-r--r--contrib/less/lesskey.h40
-rw-r--r--contrib/less/lesskey.man462
-rw-r--r--contrib/less/lesskey.nro369
-rw-r--r--contrib/less/lglob.h95
-rw-r--r--contrib/less/line.c696
-rw-r--r--contrib/less/linenum.c454
-rw-r--r--contrib/less/lsystem.c510
-rw-r--r--contrib/less/main.c370
-rw-r--r--contrib/less/mark.c258
-rw-r--r--contrib/less/mkfuncs.awk9
-rw-r--r--contrib/less/mkhelp.c69
-rwxr-xr-xcontrib/less/mkinstalldirs32
-rw-r--r--contrib/less/optfunc.c530
-rw-r--r--contrib/less/option.c610
-rw-r--r--contrib/less/option.h62
-rw-r--r--contrib/less/opttbl.c436
-rw-r--r--contrib/less/os.c312
-rw-r--r--contrib/less/output.c461
-rw-r--r--contrib/less/pckeys.h34
-rw-r--r--contrib/less/position.c232
-rw-r--r--contrib/less/position.h19
-rw-r--r--contrib/less/prompt.c521
-rw-r--r--contrib/less/regexp.c1250
-rw-r--r--contrib/less/regexp.h34
-rw-r--r--contrib/less/screen.c2286
-rw-r--r--contrib/less/search.c1359
-rw-r--r--contrib/less/signal.c270
-rw-r--r--contrib/less/tags.c231
-rw-r--r--contrib/less/ttyin.c161
-rw-r--r--contrib/less/version.c599
76 files changed, 33117 insertions, 0 deletions
diff --git a/contrib/less/COPYING b/contrib/less/COPYING
new file mode 100644
index 000000000000..d10474644415
--- /dev/null
+++ b/contrib/less/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/contrib/less/INSTALL b/contrib/less/INSTALL
new file mode 100644
index 000000000000..c2ab230e4470
--- /dev/null
+++ b/contrib/less/INSTALL
@@ -0,0 +1,186 @@
+ This file describes how to build and install less using
+the "configure" script. This only works on Unix systems.
+To install on other systems, read the README file.
+
+
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+ The file `configure.in' is used to create `configure' by a program
+called `autoconf'. You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. You can give `configure'
+initial values for variables by setting them in the environment. Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+ CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+ env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+ CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+ Use and save the results of the tests in FILE instead of
+ `./config.cache'. Set FILE to `/dev/null' to disable caching, for
+ debugging `configure'.
+
+`--help'
+ Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made.
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--version'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/contrib/less/LICENSE b/contrib/less/LICENSE
new file mode 100644
index 000000000000..e48693d19818
--- /dev/null
+++ b/contrib/less/LICENSE
@@ -0,0 +1,27 @@
+ Less License
+ ------------
+
+Less
+Copyright (C) 1984-2000 Mark Nudelman
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice in the documentation and/or other materials provided with
+ the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/contrib/less/Makefile.aut b/contrib/less/Makefile.aut
new file mode 100644
index 000000000000..0f2a09bdacc0
--- /dev/null
+++ b/contrib/less/Makefile.aut
@@ -0,0 +1,118 @@
+# Makefile for authoring less.
+
+EMAIL = marknu@flash.net
+HOMEPAGE = http://www.flash.net/~marknu/less
+SHELL = /bin/sh
+RCS = rcs
+NROFF = nroff -man
+
+srcdir = .
+
+SRC = \
+ main.c screen.c brac.c ch.c charset.c cmdbuf.c \
+ command.c decode.c edit.c filename.c forwback.c \
+ help.c ifile.c input.c jump.c line.c linenum.c \
+ lsystem.c mark.c optfunc.c option.c opttbl.c os.c \
+ output.c position.c prompt.c search.c signal.c \
+ tags.c ttyin.c version.c
+DISTFILES_W = \
+ defines.ds Makefile.dsb Makefile.dsg Makefile.dsm \
+ defines.o2 Makefile.o2e \
+ defines.o9 Makefile.o9c Makefile.o9u \
+ defines.wn Makefile.wnm Makefile.wnb
+DISTFILES = \
+ ${SRC} regexp.c regexp.h \
+ COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
+ configure configure.in acconfig.h lesskey.c lessecho.c \
+ cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
+ install.sh defines.h.in defines.h.top mkinstalldirs \
+ less.nro lesskey.nro less.man lesskey.man less.hlp \
+ mkfuncs.awk mkhelp.c \
+ ${DISTFILES_W}
+
+all: help.c funcs.h ${srcdir}/configure
+
+help.c: less.hlp mkhelp
+ -mv -f ${srcdir}/help.c ${srcdir}/help.c.old
+ rm -rf help.c
+ ./mkhelp < less.hlp > help.c
+ if cmp -s help.c help.c.old; then mv help.c.old help.c; fi
+
+mkhelp: mkhelp.c
+ ${CC} -o mkhelp mkhelp.c
+
+${srcdir}/configure: ${srcdir}/configure.in \
+ ${srcdir}/Makefile.in \
+ ${srcdir}/defines.h.top \
+ ${srcdir}/acconfig.h
+ cd ${srcdir}; autoheader; autoconf
+
+funcs.h: ${SRC:%=${srcdir}/%}
+ -mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old
+ awk -f ${srcdir}/mkfuncs.awk ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h
+ if cmp -s funcs.h funcs.h.old; then mv funcs.h.old funcs.h; fi
+
+lint:
+ lint -I. ${CPPFLAGS} ${SRC}
+
+clean:
+ rm -f Makefile config.status config.log config.cache defines.h stamp-h \
+ README NEWS less.nro lesskey.nro less.man lesskey.man
+
+distclean: clean
+realclean: clean
+
+REPLACE_VERSION = \
+ @REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q ${srcdir}/version.c`; \
+ DT=`date '+%d %h %Y'`; \
+ echo "Stuffing version number $$REL into $@"; \
+ sed \
+ -e "s;@@VERSION@@;$$REL;" \
+ -e "s;@@DATE@@;$$DT;" \
+ -e "s;@@EMAIL@@;${EMAIL};" \
+ -e "s;@@HOMEPAGE@@;${HOMEPAGE};" >$@
+
+${srcdir}/README: ${srcdir}/README.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/README.VER
+${srcdir}/NEWS: ${srcdir}/NEWS.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/NEWS.VER
+${srcdir}/less.nro: ${srcdir}/less.nro.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/less.nro.VER
+${srcdir}/lesskey.nro: ${srcdir}/lesskey.nro.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/lesskey.nro.VER
+${srcdir}/less.hlp: ${srcdir}/less.hlp.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/less.hlp.VER
+
+${srcdir}/less.man: ${srcdir}/less.nro
+ ${NROFF} ${srcdir}/less.nro >${srcdir}/less.man
+${srcdir}/lesskey.man: ${srcdir}/lesskey.nro
+ ${NROFF} ${srcdir}/lesskey.nro >${srcdir}/lesskey.man
+
+
+distfiles: ${DISTFILES}
+
+dist: ${DISTFILES}
+ if [ ! -d ${srcdir}/release ]; then mkdir ${srcdir}/release; fi
+ @cd ${srcdir}; \
+ REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/less-\1/' -e q version.c`; \
+ rm -rf release/$$REL; mkdir release/$$REL; \
+ echo "Preparing $$REL"; \
+ rm -rf $$REL; mkdir $$REL; \
+ for file in ${DISTFILES}; do \
+ cp -p $$file $$REL; \
+ chmod -w $$REL/$$file; \
+ done; \
+ cd $$REL; chmod +w ${DISTFILES_W}; cd ..; \
+ echo "Creating release/$$REL/$$REL.tar.gz"; \
+ tar -cf - $$REL | gzip -c >release/$$REL/$$REL.tar.gz; \
+ echo "Creating release/$$REL/$$REL.zip"; \
+ zip -rq release/$$REL/$$REL.zip $$REL; \
+ rm -rf $$REL
+
+tagall:
+ @REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/v\1/' -e q ${srcdir}/version.c`; \
+ echo "tagging $$REL"; \
+ for f in ${srcdir}/RCS/*,v; do \
+ REV=`co -p $$f 2>&1 | sed -e '1d' -e '3,$$d' -e 's/revision //'`; \
+ ${RCS} -N$$REL:$$REV $$f; \
+ done
diff --git a/contrib/less/Makefile.dsb b/contrib/less/Makefile.dsb
new file mode 100644
index 000000000000..f9fb0f552b6e
--- /dev/null
+++ b/contrib/less/Makefile.dsb
@@ -0,0 +1,50 @@
+# Makefile for less.
+# MS-DOS version (Borland C/C++ 4.02)
+
+#### Start of system configuration section. ####
+
+CC = bcc
+LIBDIR = \bc\lib
+
+CFLAGS = -A- -mm -O2 -w- -1- -2- -a -d -Z
+LDFLAGS = -mm
+LIBS =
+EXT = .EXE
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) -c -I. $(CPPFLAGS) $(CFLAGS) $<
+
+OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \
+ decode.obj edit.obj filename.obj forwback.obj help.obj ifile.obj \
+ input.obj jump.obj line.obj linenum.obj lsystem.obj \
+ mark.obj optfunc.obj option.obj opttbl.obj os.obj output.obj \
+ position.obj prompt.obj search.obj signal.obj tags.obj \
+ ttyin.obj version.obj
+
+all: less$(EXT) lesskey$(EXT)
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link $(OBJ).
+less$(EXT): $(OBJ)
+ ren lesskey.obj lesskey.obo
+ $(CC) $(LDFLAGS) -e$@ *.obj $(LIBS)
+ ren lesskey.obo lesskey.obj
+
+lesskey$(EXT): lesskey.obj version.obj
+ $(CC) $(LDFLAGS) -e$@ lesskey.obj version.obj $(LIBS)
+
+defines.h: defines.ds
+ -del defines.h
+ -copy defines.ds defines.h
+
+$(OBJ): less.h defines.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
diff --git a/contrib/less/Makefile.dsg b/contrib/less/Makefile.dsg
new file mode 100644
index 000000000000..c29ac883711f
--- /dev/null
+++ b/contrib/less/Makefile.dsg
@@ -0,0 +1,74 @@
+# Makefile for less under DJGPP v2.0 or later.
+
+#### Start of system configuration section. ####
+
+srcdir = .
+VPATH = .
+
+CC = gcc
+AWK = gawk
+
+CFLAGS = -O2 -g
+CFLAGS_COMPILE_ONLY = -c
+#LDFLAGS = -s
+LDFLAGS = -g
+O=o
+
+LIBS =
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.o:
+ ${CC} -I. ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O}
+
+all: less lesskey lessecho
+
+less: ${OBJ}
+ ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
+
+lessecho: lessecho.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O}
+
+defines.h: defines.ds
+ command.com /c copy $< $@
+
+${OBJ}: less.h defines.h funcs.h
+
+info:
+install-info:
+dvi:
+check:
+installcheck:
+
+TAGS:
+ etags *.c *.h
+
+newfuncs:
+ command.com /c if exist funcs.h del funcs.h
+ ${AWK} -f mkfuncs.awk ${OBJ:.${O}=.c} > funcs.h
+
+clean:
+ command.com /c for %f in (*.${O} less lesskey lessecho *.exe) do if exist %f del %f
+
+mostlyclean: clean
+
+distclean: clean
+ command.com /c if not exist Makefile.dsg ren Makefile Makefile.dsg
+ command.com /c if not exist defines.ds ren defines.h defines.ds
+ command.com /c for %f in (Makefile defines.h) do if exist %f del %f
+
+realclean: distclean
+ command.com /c if exist TAGS del TAGS
+
diff --git a/contrib/less/Makefile.dsm b/contrib/less/Makefile.dsm
new file mode 100644
index 000000000000..5bc52820681d
--- /dev/null
+++ b/contrib/less/Makefile.dsm
@@ -0,0 +1,58 @@
+# Makefile for less.
+# MS-DOS version
+
+#### Start of system configuration section. ####
+
+CC = cl
+# Change the following directories to match your installation.
+LIBDIR = c:\msvc\lib
+INCDIR = c:\msvc\include
+
+# CFLAGS are compile-time options and LDFLAGS are link-time options. They are
+# customized for MSVC 1.0 (MSC 8.0). If you have a different version of the
+# compiler, you may need to change some of the options to their equivalents.
+# -Ot optimize for speed
+# -AL large memory model
+# -Za ANSI C conformance
+# -nologo suppress MSVC banners
+# -onerror:noexe no .EXE file if link errors occur
+CFLAGS = -Ot -AL -Za -nologo
+LDFLAGS = -onerror:noexe -nologo
+LIBS = $(LIBDIR)\llibce.lib $(LIBDIR)\graphics.lib
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) -c -I. -I$(INCDIR) $(CPPFLAGS) $(CFLAGS) $<
+
+OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \
+ decode.obj edit.obj filename.obj forwback.obj help.obj ifile.obj \
+ input.obj jump.obj line.obj linenum.obj lsystem.obj \
+ mark.obj optfunc.obj option.obj opttbl.obj os.obj output.obj \
+ position.obj prompt.obj search.obj signal.obj tags.obj \
+ ttyin.obj version.obj
+
+all: less lesskey
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link $(OBJ).
+less: $(OBJ)
+ -if exist lesskey.obj del lesskey.obj
+ $(CC) $(LDFLAGS) -o $@ *.obj $(LIBS)
+
+lesskey: lesskey.obj version.obj
+ $(CC) $(LDFLAGS) -o $@ lesskey.obj version.obj $(LIBS)
+
+defines.h: defines.ds
+ -del defines.h
+ -copy defines.ds defines.h
+
+$(OBJ): less.h defines.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
diff --git a/contrib/less/Makefile.in b/contrib/less/Makefile.in
new file mode 100644
index 000000000000..32b858d5945f
--- /dev/null
+++ b/contrib/less/Makefile.in
@@ -0,0 +1,110 @@
+# Makefile for less.
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC = @CC@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+CFLAGS = @CFLAGS@
+CFLAGS_COMPILE_ONLY = -c
+LDFLAGS = @LDFLAGS@
+O=o
+
+LIBS = @LIBS@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+# Where the installed binary goes.
+bindir = @bindir@
+binprefix =
+
+mandir = @mandir@
+manext = 1
+manprefix =
+
+#### End of system configuration section. ####
+
+SHELL = /bin/sh
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.o:
+ ${CC} -I. ${CFLAGS_COMPILE_ONLY} -DSYSDIR=\"${bindir}\" ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} @REGEX_O@
+
+all: less lesskey lessecho
+
+less: ${OBJ}
+ ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
+
+lessecho: lessecho.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O}
+
+${OBJ}: ${srcdir}/less.h ${srcdir}/funcs.h defines.h
+
+install: all ${srcdir}/less.nro ${srcdir}/lesskey.nro installdirs
+ ${INSTALL_PROGRAM} less ${bindir}/${binprefix}less
+ ${INSTALL_PROGRAM} lesskey ${bindir}/${binprefix}lesskey
+ ${INSTALL_PROGRAM} lessecho ${bindir}/${binprefix}lessecho
+ ${INSTALL_DATA} ${srcdir}/less.nro ${mandir}/man${manext}/${manprefix}less.${manext}
+ ${INSTALL_DATA} ${srcdir}/lesskey.nro ${mandir}/man${manext}/${manprefix}lesskey.${manext}
+
+install-strip:
+ ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install
+
+installdirs: mkinstalldirs
+ ${srcdir}/mkinstalldirs ${bindir} ${mandir}/man${manext}
+
+uninstall:
+ rm -f ${bindir}/${binprefix}less ${bindir}/${binprefix}lesskey ${bindir}/${binprefix}lessecho
+ rm -f ${mandir}/man${manext}/${manprefix}less.${manext} ${mandir}/man${manext}/${manprefix}lesskey.${manext}
+
+info:
+install-info:
+dvi:
+check:
+installcheck:
+
+TAGS:
+ cd ${srcdir} && etags *.c *.h
+
+# config.status might not change defines.h
+# Don't rerun config.status if we just configured (so there's no stamp-h).
+defines.h: stamp-h
+stamp-h: defines.h.in config.status
+ test ! -f stamp-h || CONFIG_FILES= CONFIG_HEADERS=defines.h ./config.status
+ touch stamp-h
+Makefile: ${srcdir}/Makefile.in config.status
+ CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
+config.status: ${srcdir}/configure
+ ./config.status --recheck
+
+${srcdir}/configure: ${srcdir}/configure.in
+ cd ${srcdir}; autoheader; autoconf
+
+clean:
+ rm -f *.${O} core less lesskey lessecho
+
+mostlyclean: clean
+
+distclean: clean
+ rm -f Makefile config.status config.log config.cache defines.h stamp-h
+
+realclean: distclean
+ rm -f TAGS
+
diff --git a/contrib/less/Makefile.o2e b/contrib/less/Makefile.o2e
new file mode 100644
index 000000000000..4fc3eef0bb9a
--- /dev/null
+++ b/contrib/less/Makefile.o2e
@@ -0,0 +1,39 @@
+# Makefile for less.
+# OS/2 version, for emx+gcc compiler
+
+#### Start of system configuration section. ####
+
+CC = gcc -Zomf
+CFLAGS = -I. -O
+LDFLAGS = -s -Zcrtdll -Zstack 512
+LIBS = -ltermcap
+O = obj
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.${O}:
+ ${CC} -c ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less.exe lesskey.exe
+
+less.exe: ${OBJ}
+ ${CC} ${OBJ} -o $@ ${LDFLAGS} ${LIBS}
+
+lesskey.exe: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -o $@ ${LDFLAGS}
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o2
+ copy defines.o2 defines.h
diff --git a/contrib/less/Makefile.o9c b/contrib/less/Makefile.o9c
new file mode 100644
index 000000000000..0a1b50360501
--- /dev/null
+++ b/contrib/less/Makefile.o9c
@@ -0,0 +1,46 @@
+# Makefile for less.
+# OS-9 version for Microware C 3.2.
+
+#### Start of system configuration section. ####
+
+CC = cc
+CPPFLAGS = -D_OSK_MWC32 -DDEBUG=0 -DSTRCSPN
+CFLAGS = -k=0 -v=.
+CFLAGS_COMPILE_ONLY = -r
+LDFLAGS = -igm=8
+LIBS = -l=/dd/lib/termlib.l
+O = r
+
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+
+.c.${O}:
+ ${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less lessecho lesskey
+
+less: ${OBJ}
+ ${CC} ${OBJ} -f=$@ ${LDFLAGS} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -f=$@ ${LDFLAGS}
+
+lessecho: lessecho.${O} version.${O}
+ ${CC} lessecho.${O} version.${O} -f=$@ ${LDFLAGS}
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o9
+ copy defines.o9 defines.h -rf
diff --git a/contrib/less/Makefile.o9u b/contrib/less/Makefile.o9u
new file mode 100644
index 000000000000..2dec7ccb4712
--- /dev/null
+++ b/contrib/less/Makefile.o9u
@@ -0,0 +1,42 @@
+# Makefile for less.
+# OS-9 version for Ultra C.
+
+#### Start of system configuration section. ####
+
+CC = cc
+CPPFLAGS =
+CFLAGS = -v=.
+CFLAGS_COMPILE_ONLY = -eas
+LDFLAGS = -olM=24k
+LIBS = -ltermlib.l -lsys_clib.l -lunix.l
+O = r
+
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.${O}:
+ ${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less lesskey
+
+less: ${OBJ}
+ ${CC} ${OBJ} -f=$@ ${LDFLAGS} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -f=$@ ${LDFLAGS}
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o9
+ copy defines.o9 defines.h -rf
diff --git a/contrib/less/Makefile.wnb b/contrib/less/Makefile.wnb
new file mode 100644
index 000000000000..4da10fcbe253
--- /dev/null
+++ b/contrib/less/Makefile.wnb
@@ -0,0 +1,49 @@
+# Makefile for less.
+# Windows version
+
+#### Start of system configuration section. ####
+
+CC = bcc32
+LIBDIR = d:\bc45\lib
+
+CFLAGS = -O2 -w-pro -TWC -P-c -v- -d -f- -ff- -vi
+LDFLAGS = /Tpe /v- /ap /c /x
+LD = tlink32
+LIBS = ${LIBDIR}\import32.lib ${LIBDIR}\cw32.lib
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ ${CC} -c -I. ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \
+ decode.obj edit.obj filename.obj forwback.obj help.obj ifile.obj \
+ input.obj jump.obj line.obj linenum.obj lsystem.obj \
+ mark.obj optfunc.obj option.obj opttbl.obj os.obj output.obj \
+ position.obj prompt.obj search.obj signal.obj tags.obj \
+ ttyin.obj version.obj regexp.obj
+
+all: less lesskey
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link ${OBJ}.
+less: ${OBJ}
+ -del lesskey.obj
+ ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj *.obj, $@,,${LIBS}
+
+lesskey: lesskey.obj version.obj
+ ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj lesskey.obj version.obj, $@,,${LIBS}
+
+defines.h: defines.wn
+ -del defines.h
+ -copy defines.wn defines.h
+
+${OBJ}: less.h defines.h funcs.h cmd.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
diff --git a/contrib/less/Makefile.wnm b/contrib/less/Makefile.wnm
new file mode 100644
index 000000000000..972090ac61c5
--- /dev/null
+++ b/contrib/less/Makefile.wnm
@@ -0,0 +1,55 @@
+# Makefile for less.
+# Windows 32 Visual C++ version
+
+#### Start of system configuration section. ####
+
+CC = cl
+
+# Normal flags
+CFLAGS = /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
+LDFLAGS = /subsystem:console /incremental:no /machine:I386
+
+# Debugging flags
+#CFLAGS = /nologo /MDd /W3 /GX /Od /Gm /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
+#LDFLAGS = /subsystem:console /incremental:yes /debug /machine:I386
+
+LD = link
+LIBS = user32.lib
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) $(CFLAGS) $<
+
+OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \
+ decode.obj edit.obj filename.obj forwback.obj help.obj ifile.obj \
+ input.obj jump.obj line.obj linenum.obj lsystem.obj \
+ mark.obj optfunc.obj option.obj opttbl.obj os.obj output.obj \
+ position.obj prompt.obj search.obj signal.obj tags.obj \
+ ttyin.obj version.obj regexp.obj
+
+all: less.exe lesskey.exe
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link ${OBJ}.
+less.exe: $(OBJ)
+ -del lesskey.obj
+ $(LD) $(LDFLAGS) *.obj $(LIBS) /out:$@
+
+lesskey.exe: lesskey.obj version.obj
+ $(LD) $(LDFLAGS) lesskey.obj version.obj $(LIBS) /out:$@
+
+defines.h: defines.wn
+ -del defines.h
+ -copy defines.wn defines.h
+
+$(OBJ): less.h defines.h funcs.h cmd.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
+
diff --git a/contrib/less/NEWS b/contrib/less/NEWS
new file mode 100644
index 000000000000..f453731a6b2a
--- /dev/null
+++ b/contrib/less/NEWS
@@ -0,0 +1,485 @@
+
+ NEWS about less
+
+======================================================================
+
+ For the latest news about less, see the "less" Web page:
+ http://www.flash.net/~marknu/less
+ You can also download the latest version of less from there.
+
+ To report bugs, suggestions or comments, send email to
+ bug-less@gnu.org or marknu@flash.net.
+
+======================================================================
+
+
+ Major changes between "less" versions 352 and 354
+
+* Allow space after numeric-valued command line options.
+
+* Fix problem with configuring terminal libraries on some systems.
+
+* Add support for PCRE regular expression library.
+
+* Add --with-regex option to configure to allow manually selecting
+ a regular expression library.
+
+* Fix bug compiling with SECURE = 1.
+
+======================================================================
+
+
+ Major changes between "less" versions 346 and 352
+
+* Enable UTF-8 if "UTF-8" appears in locale-related environment variables.
+
+* Add --with-editor option to configure script.
+
+* The -M prompt and = message now show the top and bottom line number.
+
+* Fix bug in running the editor on a file whose name contains quotes, etc.
+
+* Fix bug in horizontal scrolling of long lines.
+
+* Fix bug in doing :d on a file which contains marks.
+
+* Fix bug causing cleared lines to sometimes be filled with standout,
+ bold, underline, etc. on certain terminals.
+
+* Fixes for MS-DOS (DJGPP) version.
+
+======================================================================
+
+
+ Major changes between "less" versions 340 and 346
+
+* The UTF-8 character set is now supported.
+
+* The default character set is now latin1 rather than ascii.
+
+* New option -R (--RAW-CONTROL-CHARS) is like -r but handles
+ long (wrapped) lines correctly, as long as the input contains only
+ normal text and ANSI color escape sequences.
+
+* New option -F (--quit-if-one-screen) quits if the text fits on
+ the first screen.
+
+* The -w option now highlights the target line of a g or p command.
+
+* A system-wide lesskey file is supported (LESSKEY_SYSTEM).
+
+* New escape for prompt strings: %c is replaced by column number.
+
+* New escape for prompt strings: %P is replaced by percentage into
+ file, based on line number rather than byte offset.
+
+* HOME and END keys now jump to beginning of file or end of file.
+
+======================================================================
+
+
+ Major changes between "less" versions 337 and 340
+
+* Command line options for less may now be given in either the old
+ single-letter form, or a new long name form (--option-name).
+ See the less man page or "less --help" for the list of long option names.
+
+* Command line options for lesskey may now be given in a new long name
+ form. See the lesskey man page for the list of long option names.
+
+* New command -- toggles an option using the long option name.
+
+* New command __ queries an option using the long option name.
+
+* The old -- command is renamed as -!.
+
+* If a ^P is entered between the dash and the option letter of the -
+ command, the message describing the new setting is suppressed.
+
+* Lesskey files may now contain \k escape sequences to represent the
+ "special" keys (arrows, PAGE-UP/PAGE-DOWN, HOME, END, INSERT, DELETE).
+
+* New command :d removes the current file from the list of files.
+
+* New option -~ (like -w before version 335)
+ suppresses tildes after end-of-file.
+
+* Less is now released under the GNU General Public License.
+
+======================================================================
+
+
+ Major changes between "less" versions 335 and 337
+
+* Fixed bugs in "make install".
+
+======================================================================
+
+
+ Major changes between "less" versions 332 and 335
+
+* The old -w flag (suppress tildes after end-of-file) has been removed.
+
+* New -w flag highlights the first new line after a forward-screen.
+
+* New -W flag highlights the first new line after any forward movement.
+
+* Window resize works even if LINES and/or COLUMNS environment
+ variables are incorrect.
+
+* New percent escapes for prompt strings:
+ %d is replaced by the page number, and
+ %D is replaced by the number of pages in the file.
+
+* Added charsets "iso8859" and "ebcdic".
+
+* In Windows version, uses HOMEDRIVE and HOMEPATH if HOME is not defined.
+
+* Fixed some bugs causing incorrect display on DOS/Windows.
+
+======================================================================
+
+
+ Major changes between "less" versions 330 and 332
+
+* Filenames from the command line are entered into the command history,
+ so UPARROW/DOWNARROW can be used to retrieve them from the :e command.
+
+* Now works correctly on Windows when using a scrolling terminal
+ window (buffer larger than display window).
+
+* On Windows, now restores the console screen on exit.
+ Use -X to get the old behavior.
+
+* Fixed bug on Windows when CAPS-LOCK or NUM-LOCK is pressed.
+
+* Fixed bug on Windows when piping output of an interactive program.
+
+* Fixed bug in tags file processing when tags file has DOS-style
+ line terminators (CR/LF).
+
+* Fixed compilation problem on OS/2.
+
+======================================================================
+
+
+ Major changes between "less" versions 321 and 330
+
+* Now supports filenames containing spaces (in double quotes).
+ New option -" can be used to change the quoting characters.
+
+* In filename completion, a slash is appended to a directory name.
+ If the environment variable LESSSEPARATOR is set, the value of
+ that variable, rather than a slash, is appended.
+
+* LeftArrow and RightArrow are same as ESC-[ and ESC-].
+
+* Added commands ESC-( and ESC-), same as ESC-[ and ESC-].
+
+* A "quit" command defined in a lesskey file may now have an "extra"
+ string, which is used to return an exit code from less when it quits.
+
+* New environment variables LESSMETACHARS and LESSMETAESCAPE provide
+ more control over how less interfaces to the shell.
+
+* Ported to Microsoft Visual C compiler for Windows.
+
+* Ported to DJGPP compiler for MS-DOS.
+
+* Bug fixes.
+
+======================================================================
+
+
+ Major changes between "less" versions 291 and 321
+
+* Command line at bottom of screen now scrolls, so it can be longer
+ than the screen width.
+
+* New commands ESC-] and ESC-[ scroll the display horizontally.
+
+* New command ESC-SPACE scrolls forward a full screen, even if it
+ hits end-of-file.
+
+* Alternate modifiers for search commands: ^N is same as !,
+ ^F is same as @, and ^E is same as *.
+
+* New modifier for search commands: ^K means highlight the matches
+ currently on-screen, but don't move to the first match.
+
+* New modifier for search commands: ^R means don't use regular
+ expressions in the search.
+
+* Environment variable LESSKEY gives name of default lesskey file.
+
+* Environment variable LESSSECURE will force less to run in
+ "secure" mode.
+
+* Command line argument "--" signals that the rest of the arguments
+ are files (not option flags).
+
+* Help file (less.hlp) is no longer installed. Help text is now
+ embedded in the less executable itself.
+
+* Added -Ph to change the prompt for the help text.
+ Added -Ps to change the default short prompt (same as plain -P).
+
+* Ported to the Borland C compiler for MS-DOS.
+
+* Ported to Windows 95 & Windows NT.
+
+* Ported to OS-9.
+
+* Ported to GNU Hurd.
+
+======================================================================
+
+
+ Major changes between "less" versions 290 and 291
+
+* Less environment variables can be specified in lesskey files.
+
+* Fixed MS-DOS build.
+
+======================================================================
+
+
+ Major changes between "less" versions 278 and 290
+
+* Accepts GNU-style options "--help" and "--version".
+
+* OS/2 version looks for less.ini in $HOME before $INIT and $PATH.
+
+* Bug fixes
+
+======================================================================
+
+
+ Major changes between "less" versions 252 and 278
+
+* A LESSOPEN preprocessor may now pipe the converted file data to less,
+ rather than writing it to a temporary file.
+
+* Search pattern highlighting has been fixed. It now highlights
+ reliably, even if a string is split across two screen lines,
+ contains TABs, etc.
+
+* The -F flag (which suppress search highlighting) has been changed
+ to -G. A new flag, -g, changes search highlighting to highlight
+ only the string found by the last search command, instead of all
+ strings which match the last search command.
+
+* New flag -I acts like -i, but ignores case even if the search
+ pattern contains uppercase letters.
+
+* Less now checks for the environment variable VISUAL before EDITOR.
+
+* Ported to OS/2.
+
+======================================================================
+
+
+ Major changes between "less" versions 237 and 252
+
+* Changes in line-editing keys:
+ The literal key is now ^V or ^A rather than \ (backslash).
+ Filename completion commands (TAB and ^L) are disabled
+ when typing a search pattern.
+
+* Line-editing command keys can be redefined using lesskey.
+
+* Lesskey with no input file defaults to $HOME/.lesskey
+ rather than standard input.
+
+* New option -V displays version number of less.
+
+* New option -V displays version number of lesskey.
+
+* Help file less.hlp is now installed by default in /usr/local/share
+ rather than /usr/local/lib.
+
+
+======================================================================
+
+
+ Major changes between "less" versions 170 and 237
+
+* By popular demand, text which matches the current search pattern
+ is highlighted. New -F flag disables this feature.
+
+* Henry Spencer's regexp.c is now included, for systems which do not
+ have a regular expression library.
+ regexp.c is Copyright (c) 1986 by University of Toronto.
+
+* New line-editing keys, including command history (arrow keys) and
+ filename completion (TAB).
+
+* Input preprocessor allows modification of input files (e.g. uncompress)
+ via LESSOPEN/LESSCLOSE environment variables.
+
+* New -X flag disables sending termcap "ti" and "te" (initialize and
+ deinitialize) strings to the terminal.
+
+* Changing -i from within less now correctly affects a subsequent
+ repeated search.
+
+* Searching for underlined or overstruck text now works when the -u
+ flag is in effect, rather than the -i flag.
+
+* Use setlocale (LANG and LC_CTYPE environment variables) to determine
+ the character set if LESSCHARSET/LESSCHARDEF are not set.
+
+* The default format for displaying binary characters is now standout
+ (reverse video) rather than blinking. This can still be changed by
+ setting the LESSBINFMT environment variable.
+
+* Use autoconf installation technology.
+
+* Ported to MS-DOS.
+
+ ********************************
+ Things that may surprise you
+ ********************************
+
+* When you enter text at the bottom of the screen (search string,
+ filename, etc.), some keys act different than previously.
+ Specifically, \ (backslash), ESC, TAB, BACKTAB, and control-L
+ now have line editing functions.
+
+* Some previous unofficial versions of less were able to display
+ compressed files. The new LESSOPEN/LESSCLOSE feature now provides
+ this functionality in a different way.
+
+* Some previous unofficial versions of less provided a -Z flag to
+ set the number of lines of text to retain between full screen scrolls.
+ The -z-n flag (that is, -z with a negative number) provides this
+ functionality.
+
+
+======================================================================
+
+
+ Major changes between "less" versions 123 and 170
+
+* New option -j allows target lines to be positioned anywhere on screen.
+
+* New option -S truncates displayed line at the screen width,
+ rather than wrapping onto the next line.
+
+* New option -y limits amount of forward scroll.
+
+* New option -T specifies a "tags" file.
+
+* Non-printable, non-control characters are displayed in octal.
+ Such characters, as well as control characters, are displayed
+ in blinking mode.
+
+* New command -+ sets an option to its default.
+* New command -- sets an option to the opposite of its default.
+
+* Lesskey file may have a string appended to a key's action,
+ which acts as though typed in after the command.
+
+* New commands ESC-^F and ESC-^B match arbitrary types of brackets.
+
+* New command F monitors a growing file (like "tail -f").
+
+* New command | pipes a section of the input file into a shell command.
+
+* New command :x directly jumps to a file in the command line list.
+
+* Search commands have been enhanced and reorganized:
+ n Repeat search, same direction.
+ N Repeat search, opposite direction.
+ ESC-/ Search forward thru file boundaries
+ ESC-? Search backward thru file boundaries
+ ESC-n Repeat search thru file boundaries, same direction.
+ ESC-N Repeat search thru file boundaries, opposite direction.
+ Special character * causes search to search thru file boundaries.
+ Special character @ causes search to begin at start/end of file list.
+
+* Examining a new file adds it to the command line list.
+ A list of files, or an expression which matches more than one file,
+ may be examined; all of them are added to the command line list.
+
+* Environment variables LESSCHARSET and LESSCHARDEF can define
+ a non-ASCII character set.
+
+* Partial support for MSDOS, including options -R for repainting screen
+ on quit, -v/-V to select video mode, and -W to change window size.
+
+
+======================================================================
+
+
+ Major changes between "less" versions 97 and 123
+
+* New option (-N) causes line numbers to be displayed in the
+ text of the file (like vi "set nu").
+
+* New option (-?) prints help message immediately.
+
+* New option (-r) displays "raw" control characters, without
+ mapping them to ^X notation.
+
+* New option (-f) forces less to open non-regular files
+ (directories, etc).
+
+* New option (-k) can be used to specify lesskey files by name.
+
+* New option (-y) can be used to set a forward scroll limit
+ (like -h sets a backward scroll limit).
+
+* File marks (set by the m command) are now preserved when a new
+ file is edited. The ' command can thus be used to switch files.
+
+* New command ESC-/ searches all files (on the command line)
+ for a pattern.
+
+* New command ESC-n repeats previous search, spanning files.
+
+* The N command has been changed to repeat the previous search
+ in the reverse direction. The old N command is still available
+ via :n.
+
+* New command ESC-N repeats previous search in the reverse
+ direction and spanning files.
+
+* 8 bit characters are now supported. A new option (-g) can be
+ used to strip off the eighth bit (the previous behavior).
+
+* Options which take a following string (like -t) may now
+ optionally have a space between the option letter and the string.
+
+* Six new commands { } ( ) [ and ] can be used to match
+ brackets of specific types, similar to vi % command.
+
+* New commands z and w move forward/backward one window and
+ simultaneously set the window size.
+
+* Prompt string expansion now has %L for line number of the last
+ line in the file, and %E for the name of the editor.
+ Also, % escapes which refer to a line (b=bottom, t=top, etc.)
+ can use j for the jump target line.
+
+* New environment variable LESSEDIT can be used to tailor the
+ command string passed to the editor by the v command.
+
+* Examining a file which was previously examined will return
+ to the same position in the file.
+
+* A "%" is expanded to the current filename and a "#" to the
+ previous filename, in both shell commands and the E command.
+ (Previously % worked only in shell commands and # worked
+ only in the E command.)
+
+* New command ":ta" is equivalent to "-t".
+
+* New command "s" is equivalent to "-l".
+
+* The - command may be followed by "+X" to revert to the default
+ for option X, or "-X" to get the opposite of the default.
+
+* Lesskey files may now include characters after the action as
+ extra input to be parsed after the action; for example:
+ "toggle-option X" to toggle a specific option X.
diff --git a/contrib/less/README b/contrib/less/README
new file mode 100644
index 000000000000..ee742241575c
--- /dev/null
+++ b/contrib/less/README
@@ -0,0 +1,226 @@
+
+ Less, version 354
+
+ This is the distribution of less, version 354, released 23 Mar 2000.
+ This program is part of the GNU project (http://www.gnu.org).
+
+ This program is free software. You may redistribute it and/or
+ modify it under the terms of either:
+
+ 1. The GNU General Public License, as published by the Free
+ Software Foundation; either version 2, or (at your option) any
+ later version. A copy of this license is in the file COPYING.
+ or
+ 2. The Less License, in the file LICENSE.
+
+ Please report any problems to bug-less@gnu.org or marknu@flash.net.
+ See http://www.flash.net/~marknu/less for the latest info.
+ You may also contact the author at:
+ Mark Nudelman
+ Greenwood Software
+ PO Box 2402
+ El Granada, CA 94018
+ USA
+
+=========================================================================
+
+This is the distribution of "less", a paginator similar to "more" or "pg".
+
+The formatted manual page is in less.man.
+The manual page nroff source is in less.nro.
+Major changes made since the last posted version are in NEWS.
+
+=======================================================================
+INSTALLATION (Unix systems only):
+
+1. Move the distributed source to its own directory and unpack it,
+ if you have not already done so.
+
+2. Type "sh configure".
+ This will generate a Makefile and a defines.h.
+ Warning: if you have a GNU sed, make sure it is version 2.05 or later.
+
+ The file INSTALL describes the usage of the configure program in
+ general. In addition, these options to configure are supported:
+
+ --with-editor=program
+ Specifies the default editor program used by the "v" command.
+ The default is "vi".
+ --with-regex=lib
+ Specifies the regular expression library used by less for pattern
+ matching. The default is "auto", which means the configure program
+ finds a regular expression library automatically. Other values are:
+ posix Use the POSIX-compatible regcomp.
+ pcre Use the PCRE library.
+ regcmp Use the regcmp library.
+ re_comp Use the re_comp library.
+ regcomp Use the V8-compatible regcomp.
+ regcomp-local Use Henry Spencer's V8-compatible regcomp
+ (source is supplied with less).
+
+3. It is a good idea to look over the generated Makefile and defines.h
+ and make sure they look ok. If you know of any peculiarities of
+ your system that configure might not have detected, you may fix the
+ Makefile now. Take particular notice of the list of "terminal"
+ libraries in the LIBS definition in the Makefile; these may need
+ to be edited. The terminal libraries will be some subset of
+ -lncurses -lcurses -ltermcap -ltermlib
+
+ If you wish, you may edit defines.h to remove some optional features.
+ If you wish to build a "secure" version of less (which disables all
+ features which might allow a user to do unintended things to the system
+ on which less is running), edit defines.h and define SECURE to 1.
+ If you choose not to include some features in your version, you may
+ wish to edit the manual page "less.nro" and the help page "less.hlp"
+ to remove the descriptions of the features which you are removing.
+ If you edit less.hlp, you should run "make -f Makefile.aut help.c".
+
+4. Type "make" and watch the fun.
+
+5. If the make succeeds, it will generate the programs "less",
+ "lesskey" and "lessecho" in your current directory. Test the
+ generated programs.
+
+6. When satisfied that it works, if you wish to install it
+ in a public place, type "make install".
+
+ The default install destinations are:
+ Executables (less, lesskey, lessecho) in /usr/local/bin
+ Documentation (less.nro, lesskey.nro) in /usr/local/man/man1
+ If you want to install any of these files elsewhere, define
+ bindir and/or mandir to the appropriate directories.
+
+If you have any problems building or running "less", suggestions,
+complaints, etc., you may mail to the author at marknu@flash.net.
+
+Note to hackers: comments noting possible improvements are enclosed
+in double curly brackets {{ like this }}.
+
+
+
+=======================================================================
+INSTALLATION (MS-DOS systems only,
+ with Microsoft C, Borland C, or DJGPP)
+
+1. Move the distributed source to its own directory.
+ Depending on your compiler, you may need to convert the source
+ to have CR-LF rather than LF as line terminators.
+
+2. If you are using Microsoft C, rename MAKEFILE.DSM to MAKEFILE.
+ If you are using Borland C, rename MAKEFILE.DSB to MAKEFILE.
+ If you are using DJGPP, rename MAKEFILE.DSG to MAKEFILE.
+
+3. Look at MAKEFILE to make sure that the definitions for CC and LIBDIR
+ are correct. CC should be the name of your C compiler and
+ LIBDIR should be the directory where the C libraries reside (for
+ Microsoft C only). If these definitions need to be changed, you can
+ either modify the definitions directly in MAKEFILE, or set your
+ environment variables CC and/or LIBDIR to override the definitions
+ in MAKEFILE.
+
+4. If you wish, you may edit DEFINES.DS to remove some optional features.
+ If you choose not to include some features in your version, you may
+ wish to edit the manual page LESS.MAN and the help page HELP.C
+ to remove the descriptions of the features which you are removing.
+
+5. Run your "make" program and watch the fun.
+ If your "make" requires a flag to import environment variables,
+ you should use that flag.
+ If your compiler runs out of memory, try running "make -n >cmds.bat"
+ and then run cmds.bat.
+
+6. If the make succeeds, it will generate the programs "LESS.EXE" and
+ "LESSKEY.EXE" in your current directory. Test the generated programs.
+
+7. When satisfied that it works, you may wish to install LESS.EXE and
+ LESSKEY.EXE in a directory which is included in your PATH.
+
+
+
+=======================================================================
+INSTALLATION (Windows-95, Windows-98 and Windows-NT systems only,
+ with Borland C or Microsoft Visual C++)
+
+1. Move the distributed source to its own directory.
+
+2. If you are using Borland C, rename Makefile.wnb to Makefile.
+ If you are using Microsoft Visual C++, rename Makefile.wnm to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.wn to remove some optional features.
+ If you choose not to include some features in your version, you may
+ wish to edit the manual page less.man and the help page help.c
+ to remove the descriptions of the features which you are removing.
+
+5. Type "make" and watch the fun.
+
+6. If the make succeeds, it will generate the programs "less.exe" and
+ "lesskey.exe" in your current directory. Test the generated programs.
+
+7. When satisfied that it works, if you wish to install it
+ in a public place, type "make install".
+ See step 6 of the Unix installation instructions for details
+ on how to change the default installation directories.
+
+
+
+=======================================================================
+INSTALLATION (OS/2 systems only,
+ with EMX C)
+
+1. Move the distributed source to its own directory.
+
+2. Rename Makefile.o2e to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.o2 to remove some optional features.
+ If you choose not to include some features in your version, you may
+ wish to edit the manual page less.man and the help page help.c
+ to remove the descriptions of the features which you are removing.
+
+5. Type "make" and watch the fun.
+
+6. If the make succeeds, it will generate the programs "less.exe" and
+ "lesskey.exe" in your current directory. Test the generated programs.
+
+7. Make sure you have the emx runtime installed. You need the emx DLLs
+ emx.dll and emxlibcs.dll and also the termcap database, termcap.dat.
+ Make sure you have termcap.dat either in the default location or
+ somewhere in a directory listed in the PATH or INIT environment
+ variables.
+
+8. When satisfied that it works, you may wish to install less.exe and
+ lesskey.exe in a directory which is included in your PATH.
+
+
+
+=======================================================================
+INSTALLATION (OS-9 systems only,
+ with Microware C or Ultra C)
+
+1. Move the distributed source to its own directory.
+
+2. If you are using Microware C, rename Makefile.o9c to Makefile.
+ If you are using Ultra C, rename Makefile.o9u to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.o9 to remove some optional features.
+ If you choose not to include some features in your version, you may
+ wish to edit the manual page less.man and the help page help.c
+ to remove the descriptions of the features which you are removing.
+
+5. Type "dmake" and watch the fun.
+ The standard OS-9 "make" will probably not work. If you don't
+ have dmake, you can get a copy from os9archive.rtsi.com.
+
+6. If the make succeeds, it will generate the programs "less" and
+ "lesskey" in your current directory. Test the generated programs.
+
+7. When satisfied that it works, if you wish to install it
+ in a public place, type "dmake install".
+ See step 6 of the Unix installation instructions for details
+ on how to change the default installation directories.
+
diff --git a/contrib/less/acconfig.h b/contrib/less/acconfig.h
new file mode 100644
index 000000000000..985efabf9d4b
--- /dev/null
+++ b/contrib/less/acconfig.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_PCRE: PCRE (Perl-compatible regular expression) library
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+#undef HAVE_POSIX_REGCOMP
+#undef HAVE_PCRE
+#undef HAVE_RE_COMP
+#undef HAVE_REGCMP
+#undef HAVE_V8_REGCOMP
+#undef NO_REGEX
+#undef HAVE_REGEXEC2
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#undef HAVE_VOID
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#undef HAVE_CONST
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#undef HAVE_TIME_T
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#undef HAVE_STRERROR
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#undef HAVE_FILENO
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
+ * in errno.h */
+#undef HAVE_ERRNO
+#undef MUST_DEFINE_ERRNO
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#undef HAVE_SYS_ERRLIST
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#undef HAVE_OSPEED
+#undef MUST_DEFINE_OSPEED
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#undef HAVE_LOCALE
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#undef HAVE_TERMIOS_FUNCS
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#undef HAVE_UPPER_LOWER
+
+/* Define EDIT_PGM to your editor. */
+#define EDIT_PGM "vi"
diff --git a/contrib/less/brac.c b/contrib/less/brac.c
new file mode 100644
index 000000000000..4fee6441f9f6
--- /dev/null
+++ b/contrib/less/brac.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to perform bracket matching functions.
+ */
+
+#include "less.h"
+#include "position.h"
+
+/*
+ * Try to match the n-th open bracket
+ * which appears in the top displayed line (forwdir),
+ * or the n-th close bracket
+ * which appears in the bottom displayed line (!forwdir).
+ * The characters which serve as "open bracket" and
+ * "close bracket" are given.
+ */
+ public void
+match_brac(obrac, cbrac, forwdir, n)
+ register int obrac;
+ register int cbrac;
+ int forwdir;
+ int n;
+{
+ register int c;
+ register int nest;
+ POSITION pos;
+ int (*chget)();
+
+ extern int ch_forw_get(), ch_back_get();
+
+ /*
+ * Seek to the line containing the open bracket.
+ * This is either the top or bottom line on the screen,
+ * depending on the type of bracket.
+ */
+ pos = position((forwdir) ? TOP : BOTTOM);
+ if (pos == NULL_POSITION || ch_seek(pos))
+ {
+ if (forwdir)
+ error("Nothing in top line", NULL_PARG);
+ else
+ error("Nothing in bottom line", NULL_PARG);
+ return;
+ }
+
+ /*
+ * Look thru the line to find the open bracket to match.
+ */
+ do
+ {
+ if ((c = ch_forw_get()) == '\n' || c == EOI)
+ {
+ if (forwdir)
+ error("No bracket in top line", NULL_PARG);
+ else
+ error("No bracket in bottom line", NULL_PARG);
+ return;
+ }
+ } while (c != obrac || --n > 0);
+
+ /*
+ * Position the file just "after" the open bracket
+ * (in the direction in which we will be searching).
+ * If searching forward, we are already after the bracket.
+ * If searching backward, skip back over the open bracket.
+ */
+ if (!forwdir)
+ (void) ch_back_get();
+
+ /*
+ * Search the file for the matching bracket.
+ */
+ chget = (forwdir) ? ch_forw_get : ch_back_get;
+ nest = 0;
+ while ((c = (*chget)()) != EOI)
+ {
+ if (c == obrac)
+ nest++;
+ else if (c == cbrac && --nest < 0)
+ {
+ /*
+ * Found the matching bracket.
+ * If searching backward, put it on the top line.
+ * If searching forward, put it on the bottom line.
+ */
+ jump_line_loc(ch_tell(), forwdir ? -1 : 1);
+ return;
+ }
+ }
+ error("No matching bracket", NULL_PARG);
+}
diff --git a/contrib/less/ch.c b/contrib/less/ch.c
new file mode 100644
index 000000000000..ad85be049401
--- /dev/null
+++ b/contrib/less/ch.c
@@ -0,0 +1,794 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Low level character input from the input file.
+ * We use these special purpose routines which optimize moving
+ * both forward and backward from the current read pointer.
+ */
+
+#include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <errno.h>
+#include <windows.h>
+#endif
+
+public int ignore_eoi;
+
+/*
+ * Pool of buffers holding the most recently used blocks of the input file.
+ * The buffer pool is kept as a doubly-linked circular list,
+ * in order from most- to least-recently used.
+ * The circular list is anchored by the file state "thisfile".
+ */
+#define LBUFSIZE 1024
+struct buf {
+ struct buf *next, *prev; /* Must be first to match struct filestate */
+ long block;
+ unsigned int datasize;
+ unsigned char data[LBUFSIZE];
+};
+
+/*
+ * The file state is maintained in a filestate structure.
+ * A pointer to the filestate is kept in the ifile structure.
+ */
+struct filestate {
+ /* -- Following members must match struct buf */
+ struct buf *buf_next, *buf_prev;
+ long buf_block;
+ /* -- End of struct buf copy */
+ int file;
+ int flags;
+ POSITION fpos;
+ int nbufs;
+ long block;
+ unsigned int offset;
+ POSITION fsize;
+};
+
+
+#define END_OF_CHAIN ((struct buf *)thisfile)
+#define ch_bufhead thisfile->buf_next
+#define ch_buftail thisfile->buf_prev
+#define ch_nbufs thisfile->nbufs
+#define ch_block thisfile->block
+#define ch_offset thisfile->offset
+#define ch_fpos thisfile->fpos
+#define ch_fsize thisfile->fsize
+#define ch_flags thisfile->flags
+#define ch_file thisfile->file
+
+static struct filestate *thisfile;
+static int ch_ungotchar = -1;
+
+extern int autobuf;
+extern int sigs;
+extern int cbufs;
+extern int secure;
+extern constant char helpdata[];
+extern constant int size_helpdata;
+extern IFILE curr_ifile;
+#if LOGFILE
+extern int logfile;
+extern char *namelogfile;
+#endif
+
+static int ch_addbuf();
+
+
+/*
+ * Get the character pointed to by the read pointer.
+ * ch_get() is a macro which is more efficient to call
+ * than fch_get (the function), in the usual case
+ * that the block desired is at the head of the chain.
+ */
+#define ch_get() ((ch_block == ch_bufhead->block && \
+ ch_offset < ch_bufhead->datasize) ? \
+ ch_bufhead->data[ch_offset] : fch_get())
+ int
+fch_get()
+{
+ register struct buf *bp;
+ register int n;
+ register int slept;
+ POSITION pos;
+ POSITION len;
+
+ slept = FALSE;
+
+ /*
+ * Look for a buffer holding the desired block.
+ */
+ for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next)
+ if (bp->block == ch_block)
+ {
+ if (ch_offset >= bp->datasize)
+ /*
+ * Need more data in this buffer.
+ */
+ goto read_more;
+ goto found;
+ }
+ /*
+ * Block is not in a buffer.
+ * Take the least recently used buffer
+ * and read the desired block into it.
+ * If the LRU buffer has data in it,
+ * then maybe allocate a new buffer.
+ */
+ if (ch_buftail == END_OF_CHAIN || ch_buftail->block != (long)(-1))
+ {
+ /*
+ * There is no empty buffer to use.
+ * Allocate a new buffer if:
+ * 1. We can't seek on this file and -b is not in effect; or
+ * 2. We haven't allocated the max buffers for this file yet.
+ */
+ if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
+ (cbufs == -1 || ch_nbufs < cbufs))
+ if (ch_addbuf())
+ /*
+ * Allocation failed: turn off autobuf.
+ */
+ autobuf = OPT_OFF;
+ }
+ bp = ch_buftail;
+ bp->block = ch_block;
+ bp->datasize = 0;
+
+ read_more:
+ pos = (ch_block * LBUFSIZE) + bp->datasize;
+ if ((len = ch_length()) != NULL_POSITION && pos >= len)
+ /*
+ * At end of file.
+ */
+ return (EOI);
+
+ if (pos != ch_fpos)
+ {
+ /*
+ * Not at the correct position: must seek.
+ * If input is a pipe, we're in trouble (can't seek on a pipe).
+ * Some data has been lost: just return "?".
+ */
+ if (!(ch_flags & CH_CANSEEK))
+ return ('?');
+ if (lseek(ch_file, (off_t)pos, 0) == BAD_LSEEK)
+ {
+ error("seek error", NULL_PARG);
+ clear_eol();
+ return (EOI);
+ }
+ ch_fpos = pos;
+ }
+
+ /*
+ * Read the block.
+ * If we read less than a full block, that's ok.
+ * We use partial block and pick up the rest next time.
+ */
+ if (ch_ungotchar != -1)
+ {
+ bp->data[bp->datasize] = ch_ungotchar;
+ n = 1;
+ ch_ungotchar = -1;
+ } else if (ch_flags & CH_HELPFILE)
+ {
+ bp->data[bp->datasize] = helpdata[ch_fpos];
+ n = 1;
+ } else
+ {
+ n = iread(ch_file, &bp->data[bp->datasize],
+ (unsigned int)(LBUFSIZE - bp->datasize));
+ }
+
+ if (n == READ_INTR)
+ return (EOI);
+ if (n < 0)
+ {
+#if MSDOS_COMPILER==WIN32C
+ if (errno != EPIPE)
+#endif
+ {
+ error("read error", NULL_PARG);
+ clear_eol();
+ }
+ n = 0;
+ }
+
+#if LOGFILE
+ /*
+ * If we have a log file, write the new data to it.
+ */
+ if (!secure && logfile >= 0 && n > 0)
+ write(logfile, (char *) &bp->data[bp->datasize], n);
+#endif
+
+ ch_fpos += n;
+ bp->datasize += n;
+
+ /*
+ * If we have read to end of file, set ch_fsize to indicate
+ * the position of the end of file.
+ */
+ if (n == 0)
+ {
+ ch_fsize = pos;
+ if (ignore_eoi)
+ {
+ /*
+ * We are ignoring EOF.
+ * Wait a while, then try again.
+ */
+ if (!slept)
+ ierror("Waiting for data", NULL_PARG);
+#if !MSDOS_COMPILER
+ sleep(1);
+#else
+#if MSDOS_COMPILER==WIN32C
+ Sleep(1000);
+#endif
+#endif
+ slept = TRUE;
+ }
+ if (sigs)
+ return (EOI);
+ }
+
+ found:
+ if (ch_bufhead != bp)
+ {
+ /*
+ * Move the buffer to the head of the buffer chain.
+ * This orders the buffer chain, most- to least-recently used.
+ */
+ bp->next->prev = bp->prev;
+ bp->prev->next = bp->next;
+
+ bp->next = ch_bufhead;
+ bp->prev = END_OF_CHAIN;
+ ch_bufhead->prev = bp;
+ ch_bufhead = bp;
+ }
+
+ if (ch_offset >= bp->datasize)
+ /*
+ * After all that, we still don't have enough data.
+ * Go back and try again.
+ */
+ goto read_more;
+
+ return (bp->data[ch_offset]);
+}
+
+/*
+ * ch_ungetchar is a rather kludgy and limited way to push
+ * a single char onto an input file descriptor.
+ */
+ public void
+ch_ungetchar(c)
+ int c;
+{
+ if (c != -1 && ch_ungotchar != -1)
+ error("ch_ungetchar overrun", NULL_PARG);
+ ch_ungotchar = c;
+}
+
+#if LOGFILE
+/*
+ * Close the logfile.
+ * If we haven't read all of standard input into it, do that now.
+ */
+ public void
+end_logfile()
+{
+ static int tried = FALSE;
+
+ if (logfile < 0)
+ return;
+ if (!tried && ch_fsize == NULL_POSITION)
+ {
+ tried = TRUE;
+ ierror("Finishing logfile", NULL_PARG);
+ while (ch_forw_get() != EOI)
+ if (ABORT_SIGS())
+ break;
+ }
+ close(logfile);
+ logfile = -1;
+ namelogfile = NULL;
+}
+
+/*
+ * Start a log file AFTER less has already been running.
+ * Invoked from the - command; see toggle_option().
+ * Write all the existing buffered data to the log file.
+ */
+ public void
+sync_logfile()
+{
+ register struct buf *bp;
+ int warned = FALSE;
+ long block;
+ long nblocks;
+
+ nblocks = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE;
+ for (block = 0; block < nblocks; block++)
+ {
+ for (bp = ch_bufhead; ; bp = bp->next)
+ {
+ if (bp == END_OF_CHAIN)
+ {
+ if (!warned)
+ {
+ error("Warning: log file is incomplete",
+ NULL_PARG);
+ warned = TRUE;
+ }
+ break;
+ }
+ if (bp->block == block)
+ {
+ write(logfile, (char *) bp->data, bp->datasize);
+ break;
+ }
+ }
+ }
+}
+
+#endif
+
+/*
+ * Determine if a specific block is currently in one of the buffers.
+ */
+ static int
+buffered(block)
+ long block;
+{
+ register struct buf *bp;
+
+ for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next)
+ if (bp->block == block)
+ return (TRUE);
+ return (FALSE);
+}
+
+/*
+ * Seek to a specified position in the file.
+ * Return 0 if successful, non-zero if can't seek there.
+ */
+ public int
+ch_seek(pos)
+ register POSITION pos;
+{
+ long new_block;
+ POSITION len;
+
+ len = ch_length();
+ if (pos < ch_zero() || (len != NULL_POSITION && pos > len))
+ return (1);
+
+ new_block = pos / LBUFSIZE;
+ if (!(ch_flags & CH_CANSEEK) && pos != ch_fpos && !buffered(new_block))
+ {
+ if (ch_fpos > pos)
+ return (1);
+ while (ch_fpos < pos)
+ {
+ if (ch_forw_get() == EOI)
+ return (1);
+ if (ABORT_SIGS())
+ return (1);
+ }
+ return (0);
+ }
+ /*
+ * Set read pointer.
+ */
+ ch_block = new_block;
+ ch_offset = pos % LBUFSIZE;
+ return (0);
+}
+
+/*
+ * Seek to the end of the file.
+ */
+ public int
+ch_end_seek()
+{
+ POSITION len;
+
+ if (ch_flags & CH_CANSEEK)
+ ch_fsize = filesize(ch_file);
+
+ len = ch_length();
+ if (len != NULL_POSITION)
+ return (ch_seek(len));
+
+ /*
+ * Do it the slow way: read till end of data.
+ */
+ while (ch_forw_get() != EOI)
+ if (ABORT_SIGS())
+ return (1);
+ return (0);
+}
+
+/*
+ * Seek to the beginning of the file, or as close to it as we can get.
+ * We may not be able to seek there if input is a pipe and the
+ * beginning of the pipe is no longer buffered.
+ */
+ public int
+ch_beg_seek()
+{
+ register struct buf *bp, *firstbp;
+
+ /*
+ * Try a plain ch_seek first.
+ */
+ if (ch_seek(ch_zero()) == 0)
+ return (0);
+
+ /*
+ * Can't get to position 0.
+ * Look thru the buffers for the one closest to position 0.
+ */
+ firstbp = bp = ch_bufhead;
+ if (bp == END_OF_CHAIN)
+ return (1);
+ while ((bp = bp->next) != END_OF_CHAIN)
+ if (bp->block < firstbp->block)
+ firstbp = bp;
+ ch_block = firstbp->block;
+ ch_offset = 0;
+ return (0);
+}
+
+/*
+ * Return the length of the file, if known.
+ */
+ public POSITION
+ch_length()
+{
+ if (ignore_eoi)
+ return (NULL_POSITION);
+ if (ch_flags & CH_HELPFILE)
+ return (size_helpdata);
+ return (ch_fsize);
+}
+
+/*
+ * Return the current position in the file.
+ */
+#define tellpos(blk,off) ((POSITION)((((long)(blk)) * LBUFSIZE) + (off)))
+
+ public POSITION
+ch_tell()
+{
+ return (tellpos(ch_block, ch_offset));
+}
+
+/*
+ * Get the current char and post-increment the read pointer.
+ */
+ public int
+ch_forw_get()
+{
+ register int c;
+
+ c = ch_get();
+ if (c == EOI)
+ return (EOI);
+ if (ch_offset < LBUFSIZE-1)
+ ch_offset++;
+ else
+ {
+ ch_block ++;
+ ch_offset = 0;
+ }
+ return (c);
+}
+
+/*
+ * Pre-decrement the read pointer and get the new current char.
+ */
+ public int
+ch_back_get()
+{
+ if (ch_offset > 0)
+ ch_offset --;
+ else
+ {
+ if (ch_block <= 0)
+ return (EOI);
+ if (!(ch_flags & CH_CANSEEK) && !buffered(ch_block-1))
+ return (EOI);
+ ch_block--;
+ ch_offset = LBUFSIZE-1;
+ }
+ return (ch_get());
+}
+
+/*
+ * Allocate buffers.
+ * Caller wants us to have a total of at least want_nbufs buffers.
+ */
+ public int
+ch_nbuf(want_nbufs)
+ int want_nbufs;
+{
+ PARG parg;
+
+ while (ch_nbufs < want_nbufs)
+ {
+ if (ch_addbuf())
+ {
+ /*
+ * Cannot allocate enough buffers.
+ * If we don't have ANY, then quit.
+ * Otherwise, just report the error and return.
+ */
+ parg.p_int = want_nbufs - ch_nbufs;
+ error("Cannot allocate %d buffers", &parg);
+ if (ch_nbufs == 0)
+ quit(QUIT_ERROR);
+ break;
+ }
+ }
+ return (ch_nbufs);
+}
+
+/*
+ * Flush (discard) any saved file state, including buffer contents.
+ */
+ public void
+ch_flush()
+{
+ register struct buf *bp;
+
+ if (!(ch_flags & CH_CANSEEK))
+ {
+ /*
+ * If input is a pipe, we don't flush buffer contents,
+ * since the contents can't be recovered.
+ */
+ ch_fsize = NULL_POSITION;
+ return;
+ }
+
+ /*
+ * Initialize all the buffers.
+ */
+ for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next)
+ bp->block = (long)(-1);
+
+ /*
+ * Figure out the size of the file, if we can.
+ */
+ ch_fsize = filesize(ch_file);
+
+ /*
+ * Seek to a known position: the beginning of the file.
+ */
+ ch_fpos = 0;
+ ch_block = 0; /* ch_fpos / LBUFSIZE; */
+ ch_offset = 0; /* ch_fpos % LBUFSIZE; */
+
+#if 1
+ /*
+ * This is a kludge to workaround a Linux kernel bug: files in
+ * /proc have a size of 0 according to fstat() but have readable
+ * data. They are sometimes, but not always, seekable.
+ * Force them to be non-seekable here.
+ */
+ if (ch_fsize == 0)
+ {
+ ch_fsize = NULL_POSITION;
+ ch_flags &= ~CH_CANSEEK;
+ }
+#endif
+
+ if (lseek(ch_file, (off_t)0, 0) == BAD_LSEEK)
+ {
+ /*
+ * Warning only; even if the seek fails for some reason,
+ * there's a good chance we're at the beginning anyway.
+ * {{ I think this is bogus reasoning. }}
+ */
+ error("seek error to 0", NULL_PARG);
+ }
+}
+
+/*
+ * Allocate a new buffer.
+ * The buffer is added to the tail of the buffer chain.
+ */
+ static int
+ch_addbuf()
+{
+ register struct buf *bp;
+
+ /*
+ * Allocate and initialize a new buffer and link it
+ * onto the tail of the buffer list.
+ */
+ bp = (struct buf *) calloc(1, sizeof(struct buf));
+ if (bp == NULL)
+ return (1);
+ ch_nbufs++;
+ bp->block = (long)(-1);
+ bp->next = END_OF_CHAIN;
+ bp->prev = ch_buftail;
+ ch_buftail->next = bp;
+ ch_buftail = bp;
+ return (0);
+}
+
+/*
+ * Delete all buffers for this file.
+ */
+ static void
+ch_delbufs()
+{
+ register struct buf *bp;
+
+ while (ch_bufhead != END_OF_CHAIN)
+ {
+ bp = ch_bufhead;
+ bp->next->prev = bp->prev;;
+ bp->prev->next = bp->next;
+ free(bp);
+ }
+ ch_nbufs = 0;
+}
+
+/*
+ * Is it possible to seek on a file descriptor?
+ */
+ public int
+seekable(f)
+ int f;
+{
+#if MSDOS_COMPILER
+ extern int fd0;
+ if (f == fd0 && !isatty(fd0))
+ {
+ /*
+ * In MS-DOS, pipes are seekable. Check for
+ * standard input, and pretend it is not seekable.
+ */
+ return (0);
+ }
+#endif
+ return (lseek(f, (off_t)1, 0) != BAD_LSEEK);
+}
+
+/*
+ * Initialize file state for a new file.
+ */
+ public void
+ch_init(f, flags)
+ int f;
+ int flags;
+{
+ /*
+ * See if we already have a filestate for this file.
+ */
+ thisfile = (struct filestate *) get_filestate(curr_ifile);
+ if (thisfile == NULL)
+ {
+ /*
+ * Allocate and initialize a new filestate.
+ */
+ thisfile = (struct filestate *)
+ calloc(1, sizeof(struct filestate));
+ thisfile->buf_next = thisfile->buf_prev = END_OF_CHAIN;
+ thisfile->buf_block = (long)(-1);
+ thisfile->nbufs = 0;
+ thisfile->flags = 0;
+ thisfile->fpos = 0;
+ thisfile->block = 0;
+ thisfile->offset = 0;
+ thisfile->file = -1;
+ thisfile->fsize = NULL_POSITION;
+ ch_flags = flags;
+ /*
+ * Try to seek; set CH_CANSEEK if it works.
+ */
+ if ((flags & CH_CANSEEK) && !seekable(f))
+ ch_flags &= ~CH_CANSEEK;
+ set_filestate(curr_ifile, (void *) thisfile);
+ }
+ if (thisfile->file == -1)
+ thisfile->file = f;
+ ch_flush();
+}
+
+/*
+ * Close a filestate.
+ */
+ public void
+ch_close()
+{
+ int keepstate = FALSE;
+
+ if (ch_flags & (CH_CANSEEK|CH_POPENED|CH_HELPFILE))
+ {
+ /*
+ * We can seek or re-open, so we don't need to keep buffers.
+ */
+ ch_delbufs();
+ } else
+ keepstate = TRUE;
+ if (!(ch_flags & CH_KEEPOPEN))
+ {
+ /*
+ * We don't need to keep the file descriptor open
+ * (because we can re-open it.)
+ * But don't really close it if it was opened via popen(),
+ * because pclose() wants to close it.
+ */
+ if (!(ch_flags & (CH_POPENED|CH_HELPFILE)))
+ close(ch_file);
+ ch_file = -1;
+ } else
+ keepstate = TRUE;
+ if (!keepstate)
+ {
+ /*
+ * We don't even need to keep the filestate structure.
+ */
+ free(thisfile);
+ thisfile = NULL;
+ set_filestate(curr_ifile, (void *) NULL);
+ }
+}
+
+/*
+ * Return ch_flags for the current file.
+ */
+ public int
+ch_getflags()
+{
+ return (ch_flags);
+}
+
+#if 0
+ public void
+ch_dump(struct filestate *fs)
+{
+ struct buf *bp;
+ unsigned char *s;
+
+ if (fs == NULL)
+ {
+ printf(" --no filestate\n");
+ return;
+ }
+ printf(" file %d, flags %x, fpos %x, fsize %x, blk/off %x/%x\n",
+ fs->file, fs->flags, fs->fpos,
+ fs->fsize, fs->block, fs->offset);
+ printf(" %d bufs:\n", fs->nbufs);
+ for (bp = fs->buf_next; bp != (struct buf *)fs; bp = bp->next)
+ {
+ printf("%x: blk %x, size %x \"",
+ bp, bp->block, bp->datasize);
+ for (s = bp->data; s < bp->data + 30; s++)
+ if (*s >= ' ' && *s < 0x7F)
+ printf("%c", *s);
+ else
+ printf(".");
+ printf("\"\n");
+ }
+}
+#endif
diff --git a/contrib/less/charset.c b/contrib/less/charset.c
new file mode 100644
index 000000000000..efb26a87bd10
--- /dev/null
+++ b/contrib/less/charset.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Functions to define the character set
+ * and do things specific to the character set.
+ */
+
+#include "less.h"
+#if HAVE_LOCALE
+#include <locale.h>
+#include <ctype.h>
+#endif
+
+public int utf_mode = 0;
+
+/*
+ * Predefined character sets,
+ * selected by the LESSCHARSET environment variable.
+ */
+struct charset {
+ char *name;
+ int *p_flag;
+ char *desc;
+} charsets[] = {
+ { "ascii", NULL, "8bcccbcc18b95.b" },
+ { "dos", NULL, "8bcccbcc12bc5b95.b." },
+ { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
+ { "iso8859", NULL, "8bcccbcc18b95.33b." },
+ { "koi8-r", NULL, "8bcccbcc18b95.b128." },
+ { "latin1", NULL, "8bcccbcc18b95.33b." },
+ { "next", NULL, "8bcccbcc18b95.bb125.bb" },
+ { "utf-8", &utf_mode, "8bcccbcc18b." },
+ { NULL, NULL, NULL }
+};
+
+#define IS_BINARY_CHAR 01
+#define IS_CONTROL_CHAR 02
+
+static char chardef[256];
+static char *binfmt = NULL;
+public int binattr = AT_STANDOUT;
+
+
+/*
+ * Define a charset, given a description string.
+ * The string consists of 256 letters,
+ * one for each character in the charset.
+ * If the string is shorter than 256 letters, missing letters
+ * are taken to be identical to the last one.
+ * A decimal number followed by a letter is taken to be a
+ * repetition of the letter.
+ *
+ * Each letter is one of:
+ * . normal character
+ * b binary character
+ * c control character
+ */
+ static void
+ichardef(s)
+ char *s;
+{
+ register char *cp;
+ register int n;
+ register char v;
+
+ n = 0;
+ v = 0;
+ cp = chardef;
+ while (*s != '\0')
+ {
+ switch (*s++)
+ {
+ case '.':
+ v = 0;
+ break;
+ case 'c':
+ v = IS_CONTROL_CHAR;
+ break;
+ case 'b':
+ v = IS_BINARY_CHAR|IS_CONTROL_CHAR;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ n = (10 * n) + (s[-1] - '0');
+ continue;
+
+ default:
+ error("invalid chardef", NULL_PARG);
+ quit(QUIT_ERROR);
+ /*NOTREACHED*/
+ }
+
+ do
+ {
+ if (cp >= chardef + sizeof(chardef))
+ {
+ error("chardef longer than 256", NULL_PARG);
+ quit(QUIT_ERROR);
+ /*NOTREACHED*/
+ }
+ *cp++ = v;
+ } while (--n > 0);
+ n = 0;
+ }
+
+ while (cp < chardef + sizeof(chardef))
+ *cp++ = v;
+}
+
+/*
+ * Define a charset, given a charset name.
+ * The valid charset names are listed in the "charsets" array.
+ */
+ static int
+icharset(name)
+ register char *name;
+{
+ register struct charset *p;
+
+ if (name == NULL || *name == '\0')
+ return (0);
+
+ for (p = charsets; p->name != NULL; p++)
+ {
+ if (strcmp(name, p->name) == 0)
+ {
+ ichardef(p->desc);
+ if (p->p_flag != NULL)
+ *(p->p_flag) = 1;
+ return (1);
+ }
+ }
+
+ error("invalid charset name", NULL_PARG);
+ quit(QUIT_ERROR);
+ /*NOTREACHED*/
+}
+
+#if HAVE_LOCALE
+/*
+ * Define a charset, given a locale name.
+ */
+ static void
+ilocale()
+{
+ register int c;
+
+ setlocale(LC_ALL, "");
+ for (c = 0; c < (int) sizeof(chardef); c++)
+ {
+ if (isprint(c))
+ chardef[c] = 0;
+ else if (iscntrl(c))
+ chardef[c] = IS_CONTROL_CHAR;
+ else
+ chardef[c] = IS_BINARY_CHAR|IS_CONTROL_CHAR;
+ }
+}
+#endif
+
+/*
+ * Define the printing format for control chars.
+ */
+ public void
+setbinfmt(s)
+ char *s;
+{
+ if (s == NULL || *s == '\0')
+ s = "*s<%X>";
+ /*
+ * Select the attributes if it starts with "*".
+ */
+ if (*s == '*')
+ {
+ switch (s[1])
+ {
+ case 'd': binattr = AT_BOLD; break;
+ case 'k': binattr = AT_BLINK; break;
+ case 's': binattr = AT_STANDOUT; break;
+ case 'u': binattr = AT_UNDERLINE; break;
+ default: binattr = AT_NORMAL; break;
+ }
+ s += 2;
+ }
+ binfmt = s;
+}
+
+/*
+ * Initialize charset data structures.
+ */
+ public void
+init_charset()
+{
+ register char *s;
+
+ s = lgetenv("LESSBINFMT");
+ setbinfmt(s);
+
+ /*
+ * See if environment variable LESSCHARSET is defined.
+ */
+ s = lgetenv("LESSCHARSET");
+ if (icharset(s))
+ return;
+ /*
+ * LESSCHARSET is not defined: try LESSCHARDEF.
+ */
+ s = lgetenv("LESSCHARDEF");
+ if (s != NULL && *s != '\0')
+ {
+ ichardef(s);
+ return;
+ }
+
+#if HAVE_STRSTR
+ /*
+ * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
+ */
+ if ((s = lgetenv("LC_ALL")) != NULL ||
+ (s = lgetenv("LC_CTYPE")) != NULL ||
+ (s = lgetenv("LANG")) != NULL)
+ {
+ if (strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL)
+ if (icharset("utf-8"))
+ return;
+ }
+#endif
+
+#if HAVE_LOCALE
+ /*
+ * Use setlocale.
+ */
+ ilocale();
+#else
+ /*
+ * Default to "latin1".
+ */
+ (void) icharset("latin1");
+#endif
+}
+
+/*
+ * Is a given character a "binary" character?
+ */
+ public int
+binary_char(c)
+ unsigned char c;
+{
+ c &= 0377;
+ return (chardef[c] & IS_BINARY_CHAR);
+}
+
+/*
+ * Is a given character a "control" character?
+ */
+ public int
+control_char(c)
+ int c;
+{
+ c &= 0377;
+ return (chardef[c] & IS_CONTROL_CHAR);
+}
+
+/*
+ * Return the printable form of a character.
+ * For example, in the "ascii" charset '\3' is printed as "^C".
+ */
+ public char *
+prchar(c)
+ int c;
+{
+ static char buf[8];
+
+ c &= 0377;
+ if (!control_char(c))
+ sprintf(buf, "%c", c);
+ else if (c == ESC)
+ sprintf(buf, "ESC");
+ else if (c < 128 && !control_char(c ^ 0100))
+ sprintf(buf, "^%c", c ^ 0100);
+ else
+ sprintf(buf, binfmt, c);
+ return (buf);
+}
diff --git a/contrib/less/cmd.h b/contrib/less/cmd.h
new file mode 100644
index 000000000000..1619b80ec5d1
--- /dev/null
+++ b/contrib/less/cmd.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+#define MAX_USERCMD 500
+#define MAX_CMDLEN 16
+
+#define A_B_LINE 2
+#define A_B_SCREEN 3
+#define A_B_SCROLL 4
+#define A_B_SEARCH 5
+#define A_DIGIT 6
+#define A_DISP_OPTION 7
+#define A_DEBUG 8
+#define A_EXAMINE 9
+#define A_FIRSTCMD 10
+#define A_FREPAINT 11
+#define A_F_LINE 12
+#define A_F_SCREEN 13
+#define A_F_SCROLL 14
+#define A_F_SEARCH 15
+#define A_GOEND 16
+#define A_GOLINE 17
+#define A_GOMARK 18
+#define A_HELP 19
+#define A_NEXT_FILE 20
+#define A_PERCENT 21
+#define A_PREFIX 22
+#define A_PREV_FILE 23
+#define A_QUIT 24
+#define A_REPAINT 25
+#define A_SETMARK 26
+#define A_SHELL 27
+#define A_STAT 28
+#define A_FF_LINE 29
+#define A_BF_LINE 30
+#define A_VERSION 31
+#define A_VISUAL 32
+#define A_F_WINDOW 33
+#define A_B_WINDOW 34
+#define A_F_BRACKET 35
+#define A_B_BRACKET 36
+#define A_PIPE 37
+#define A_INDEX_FILE 38
+#define A_UNDO_SEARCH 39
+#define A_FF_SCREEN 40
+#define A_LSHIFT 41
+#define A_RSHIFT 42
+#define A_AGAIN_SEARCH 43
+#define A_T_AGAIN_SEARCH 44
+#define A_REVERSE_SEARCH 45
+#define A_T_REVERSE_SEARCH 46
+#define A_OPT_TOGGLE 47
+#define A_OPT_SET 48
+#define A_OPT_UNSET 49
+#define A_F_FOREVER 50
+#define A_GOPOS 51
+#define A_REMOVE_FILE 52
+
+#define A_INVALID 100
+#define A_NOACTION 101
+#define A_UINVALID 102
+#define A_END_LIST 103
+#define A_SPECIAL_KEY 104
+
+#define A_SKIP 127
+
+#define A_EXTRA 0200
+
+
+/* Line editting characters */
+
+#define EC_BACKSPACE 1
+#define EC_LINEKILL 2
+#define EC_RIGHT 3
+#define EC_LEFT 4
+#define EC_W_LEFT 5
+#define EC_W_RIGHT 6
+#define EC_INSERT 7
+#define EC_DELETE 8
+#define EC_HOME 9
+#define EC_END 10
+#define EC_W_BACKSPACE 11
+#define EC_W_DELETE 12
+#define EC_UP 13
+#define EC_DOWN 14
+#define EC_EXPAND 15
+#define EC_F_COMPLETE 17
+#define EC_B_COMPLETE 18
+#define EC_LITERAL 19
+
+#define EC_NOACTION 101
+#define EC_UINVALID 102
+
+/* Flags for editchar() */
+#define EC_PEEK 01
+#define EC_NOHISTORY 02
+#define EC_NOCOMPLETE 04
+
+/* Environment variable stuff */
+#define EV_OK 01
+
+/* Special keys (keys which output different strings on different terminals) */
+#define SK_SPECIAL_KEY CONTROL('K')
+#define SK_RIGHT_ARROW 1
+#define SK_LEFT_ARROW 2
+#define SK_UP_ARROW 3
+#define SK_DOWN_ARROW 4
+#define SK_PAGE_UP 5
+#define SK_PAGE_DOWN 6
+#define SK_HOME 7
+#define SK_END 8
+#define SK_DELETE 9
+#define SK_INSERT 10
+#define SK_CTL_LEFT_ARROW 11
+#define SK_CTL_RIGHT_ARROW 12
+#define SK_CTL_DELETE 13
+#define SK_F1 14
+#define SK_BACKTAB 15
+#define SK_CTL_BACKSPACE 16
+#define SK_CONTROL_K 40
diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c
new file mode 100644
index 000000000000..3aed8aefd03b
--- /dev/null
+++ b/contrib/less/cmdbuf.c
@@ -0,0 +1,1022 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Functions which manipulate the command buffer.
+ * Used only by command() and related functions.
+ */
+
+#include "less.h"
+#include "cmd.h"
+
+extern int sc_width;
+
+static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
+static int cmd_col; /* Current column of the cursor */
+static int prompt_col; /* Column of cursor just after prompt */
+static char *cp; /* Pointer into cmdbuf */
+static int cmd_offset; /* Index into cmdbuf of first displayed char */
+static int literal; /* Next input char should not be interpreted */
+
+#if TAB_COMPLETE_FILENAME
+static int cmd_complete();
+/*
+ * These variables are statics used by cmd_complete.
+ */
+static int in_completion = 0;
+static char *tk_text;
+static char *tk_original;
+static char *tk_ipoint;
+static char *tk_trial;
+static struct textlist tk_tlist;
+#endif
+
+static int cmd_left();
+static int cmd_right();
+
+#if SPACES_IN_FILENAMES
+public char openquote = '"';
+public char closequote = '"';
+#endif
+
+#if CMD_HISTORY
+/*
+ * A mlist structure represents a command history.
+ */
+struct mlist
+{
+ struct mlist *next;
+ struct mlist *prev;
+ struct mlist *curr_mp;
+ char *string;
+};
+
+/*
+ * These are the various command histories that exist.
+ */
+struct mlist mlist_search =
+ { &mlist_search, &mlist_search, &mlist_search, NULL };
+public void constant *ml_search = (void *) &mlist_search;
+
+struct mlist mlist_examine =
+ { &mlist_examine, &mlist_examine, &mlist_examine, NULL };
+public void constant *ml_examine = (void *) &mlist_examine;
+
+#if SHELL_ESCAPE || PIPEC
+struct mlist mlist_shell =
+ { &mlist_shell, &mlist_shell, &mlist_shell, NULL };
+public void constant *ml_shell = (void *) &mlist_shell;
+#endif
+
+#else /* CMD_HISTORY */
+
+/* If CMD_HISTORY is off, these are just flags. */
+public void constant *ml_search = (void *)1;
+public void constant *ml_examine = (void *)2;
+#if SHELL_ESCAPE || PIPEC
+public void constant *ml_shell = (void *)3;
+#endif
+
+#endif /* CMD_HISTORY */
+
+/*
+ * History for the current command.
+ */
+static struct mlist *curr_mlist = NULL;
+static int curr_cmdflags;
+
+
+/*
+ * Reset command buffer (to empty).
+ */
+ public void
+cmd_reset()
+{
+ cp = cmdbuf;
+ *cp = '\0';
+ cmd_col = 0;
+ cmd_offset = 0;
+ literal = 0;
+}
+
+/*
+ * Clear command line on display.
+ */
+ public void
+clear_cmd()
+{
+ clear_bot();
+ cmd_col = prompt_col = 0;
+}
+
+/*
+ * Display a string, usually as a prompt for input into the command buffer.
+ */
+ public void
+cmd_putstr(s)
+ char *s;
+{
+ putstr(s);
+ cmd_col += strlen(s);
+ prompt_col += strlen(s);
+}
+
+/*
+ * How many characters are in the command buffer?
+ */
+ public int
+len_cmdbuf()
+{
+ return (strlen(cmdbuf));
+}
+
+/*
+ * Repaint the line from cp onwards.
+ * Then position the cursor just after the char old_cp (a pointer into cmdbuf).
+ */
+ static void
+cmd_repaint(old_cp)
+ char *old_cp;
+{
+ char *p;
+
+ /*
+ * Repaint the line from the current position.
+ */
+ clear_eol();
+ for ( ; *cp != '\0'; cp++)
+ {
+ p = prchar(*cp);
+ if (cmd_col + strlen(p) >= sc_width)
+ break;
+ putstr(p);
+ cmd_col += strlen(p);
+ }
+
+ /*
+ * Back up the cursor to the correct position.
+ */
+ while (cp > old_cp)
+ cmd_left();
+}
+
+/*
+ * Put the cursor at "home" (just after the prompt),
+ * and set cp to the corresponding char in cmdbuf.
+ */
+ static void
+cmd_home()
+{
+ while (cmd_col > prompt_col)
+ {
+ putbs();
+ cmd_col--;
+ }
+
+ cp = &cmdbuf[cmd_offset];
+}
+
+/*
+ * Shift the cmdbuf display left a half-screen.
+ */
+ static void
+cmd_lshift()
+{
+ char *s;
+ char *save_cp;
+ int cols;
+
+ /*
+ * Start at the first displayed char, count how far to the
+ * right we'd have to move to reach the center of the screen.
+ */
+ s = cmdbuf + cmd_offset;
+ cols = 0;
+ while (cols < (sc_width - prompt_col) / 2 && *s != '\0')
+ cols += strlen(prchar(*s++));
+
+ cmd_offset = s - cmdbuf;
+ save_cp = cp;
+ cmd_home();
+ cmd_repaint(save_cp);
+}
+
+/*
+ * Shift the cmdbuf display right a half-screen.
+ */
+ static void
+cmd_rshift()
+{
+ char *s;
+ char *p;
+ char *save_cp;
+ int cols;
+
+ /*
+ * Start at the first displayed char, count how far to the
+ * left we'd have to move to traverse a half-screen width
+ * of displayed characters.
+ */
+ s = cmdbuf + cmd_offset;
+ cols = 0;
+ while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf)
+ {
+ p = prchar(*--s);
+ cols += strlen(p);
+ }
+
+ cmd_offset = s - cmdbuf;
+ save_cp = cp;
+ cmd_home();
+ cmd_repaint(save_cp);
+}
+
+/*
+ * Move cursor right one character.
+ */
+ static int
+cmd_right()
+{
+ char *p;
+
+ if (*cp == '\0')
+ {
+ /*
+ * Already at the end of the line.
+ */
+ return (CC_OK);
+ }
+ p = prchar(*cp);
+ if (cmd_col + strlen(p) >= sc_width)
+ cmd_lshift();
+ else if (cmd_col + strlen(p) == sc_width - 1 && cp[1] != '\0')
+ cmd_lshift();
+ cp++;
+ putstr(p);
+ cmd_col += strlen(p);
+ return (CC_OK);
+}
+
+/*
+ * Move cursor left one character.
+ */
+ static int
+cmd_left()
+{
+ char *p;
+
+ if (cp <= cmdbuf)
+ {
+ /* Already at the beginning of the line */
+ return (CC_OK);
+ }
+ p = prchar(cp[-1]);
+ if (cmd_col < prompt_col + strlen(p))
+ cmd_rshift();
+ cp--;
+ cmd_col -= strlen(p);
+ while (*p++ != '\0')
+ putbs();
+ return (CC_OK);
+}
+
+/*
+ * Insert a char into the command buffer, at the current position.
+ */
+ static int
+cmd_ichar(c)
+ int c;
+{
+ char *s;
+
+ if (strlen(cmdbuf) >= sizeof(cmdbuf)-2)
+ {
+ /*
+ * No room in the command buffer for another char.
+ */
+ bell();
+ return (CC_ERROR);
+ }
+
+ /*
+ * Insert the character into the buffer.
+ */
+ for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--)
+ s[1] = s[0];
+ *cp = c;
+ /*
+ * Reprint the tail of the line from the inserted char.
+ */
+ cmd_repaint(cp);
+ cmd_right();
+ return (CC_OK);
+}
+
+/*
+ * Backspace in the command buffer.
+ * Delete the char to the left of the cursor.
+ */
+ static int
+cmd_erase()
+{
+ register char *s;
+
+ if (cp == cmdbuf)
+ {
+ /*
+ * Backspace past beginning of the buffer:
+ * this usually means abort the command.
+ */
+ return (CC_QUIT);
+ }
+ /*
+ * Move cursor left (to the char being erased).
+ */
+ cmd_left();
+ /*
+ * Remove the char from the buffer (shift the buffer left).
+ */
+ for (s = cp; *s != '\0'; s++)
+ s[0] = s[1];
+ /*
+ * Repaint the buffer after the erased char.
+ */
+ cmd_repaint(cp);
+
+ /*
+ * We say that erasing the entire command string causes us
+ * to abort the current command, if CF_QUIT_ON_ERASE is set.
+ */
+ if ((curr_cmdflags & CF_QUIT_ON_ERASE) && cp == cmdbuf && *cp == '\0')
+ return (CC_QUIT);
+ return (CC_OK);
+}
+
+/*
+ * Delete the char under the cursor.
+ */
+ static int
+cmd_delete()
+{
+ if (*cp == '\0')
+ {
+ /*
+ * At end of string; there is no char under the cursor.
+ */
+ return (CC_OK);
+ }
+ /*
+ * Move right, then use cmd_erase.
+ */
+ cmd_right();
+ cmd_erase();
+ return (CC_OK);
+}
+
+/*
+ * Delete the "word" to the left of the cursor.
+ */
+ static int
+cmd_werase()
+{
+ if (cp > cmdbuf && cp[-1] == ' ')
+ {
+ /*
+ * If the char left of cursor is a space,
+ * erase all the spaces left of cursor (to the first non-space).
+ */
+ while (cp > cmdbuf && cp[-1] == ' ')
+ (void) cmd_erase();
+ } else
+ {
+ /*
+ * If the char left of cursor is not a space,
+ * erase all the nonspaces left of cursor (the whole "word").
+ */
+ while (cp > cmdbuf && cp[-1] != ' ')
+ (void) cmd_erase();
+ }
+ return (CC_OK);
+}
+
+/*
+ * Delete the "word" under the cursor.
+ */
+ static int
+cmd_wdelete()
+{
+ if (*cp == ' ')
+ {
+ /*
+ * If the char under the cursor is a space,
+ * delete it and all the spaces right of cursor.
+ */
+ while (*cp == ' ')
+ (void) cmd_delete();
+ } else
+ {
+ /*
+ * If the char under the cursor is not a space,
+ * delete it and all nonspaces right of cursor (the whole word).
+ */
+ while (*cp != ' ' && *cp != '\0')
+ (void) cmd_delete();
+ }
+ return (CC_OK);
+}
+
+/*
+ * Delete all chars in the command buffer.
+ */
+ static int
+cmd_kill()
+{
+ if (cmdbuf[0] == '\0')
+ {
+ /*
+ * Buffer is already empty; abort the current command.
+ */
+ return (CC_QUIT);
+ }
+ cmd_offset = 0;
+ cmd_home();
+ *cp = '\0';
+ cmd_repaint(cp);
+
+ /*
+ * We say that erasing the entire command string causes us
+ * to abort the current command, if CF_QUIT_ON_ERASE is set.
+ */
+ if (curr_cmdflags & CF_QUIT_ON_ERASE)
+ return (CC_QUIT);
+ return (CC_OK);
+}
+
+/*
+ * Select an mlist structure to be the current command history.
+ */
+ public void
+set_mlist(mlist, cmdflags)
+ void *mlist;
+ int cmdflags;
+{
+ curr_mlist = (struct mlist *) mlist;
+ curr_cmdflags = cmdflags;
+}
+
+#if CMD_HISTORY
+/*
+ * Move up or down in the currently selected command history list.
+ */
+ static int
+cmd_updown(action)
+ int action;
+{
+ char *s;
+
+ if (curr_mlist == NULL)
+ {
+ /*
+ * The current command has no history list.
+ */
+ bell();
+ return (CC_OK);
+ }
+ cmd_home();
+ clear_eol();
+ /*
+ * Move curr_mp to the next/prev entry.
+ */
+ if (action == EC_UP)
+ curr_mlist->curr_mp = curr_mlist->curr_mp->prev;
+ else
+ curr_mlist->curr_mp = curr_mlist->curr_mp->next;
+ /*
+ * Copy the entry into cmdbuf and echo it on the screen.
+ */
+ s = curr_mlist->curr_mp->string;
+ if (s == NULL)
+ s = "";
+ for (cp = cmdbuf; *s != '\0'; s++)
+ {
+ *cp = *s;
+ cmd_right();
+ }
+ *cp = '\0';
+ return (CC_OK);
+}
+#endif
+
+/*
+ * Add a string to a history list.
+ */
+ public void
+cmd_addhist(mlist, cmd)
+ struct mlist *mlist;
+ char *cmd;
+{
+#if CMD_HISTORY
+ struct mlist *ml;
+
+ /*
+ * Don't save a trivial command.
+ */
+ if (strlen(cmd) == 0)
+ return;
+ /*
+ * Don't save if a duplicate of a command which is already
+ * in the history.
+ * But select the one already in the history to be current.
+ */
+ for (ml = mlist->next; ml != mlist; ml = ml->next)
+ {
+ if (strcmp(ml->string, cmd) == 0)
+ break;
+ }
+ if (ml == mlist)
+ {
+ /*
+ * Did not find command in history.
+ * Save the command and put it at the end of the history list.
+ */
+ ml = (struct mlist *) ecalloc(1, sizeof(struct mlist));
+ ml->string = save(cmd);
+ ml->next = mlist;
+ ml->prev = mlist->prev;
+ mlist->prev->next = ml;
+ mlist->prev = ml;
+ }
+ /*
+ * Point to the cmd just after the just-accepted command.
+ * Thus, an UPARROW will always retrieve the previous command.
+ */
+ mlist->curr_mp = ml->next;
+#endif
+}
+
+/*
+ * Accept the command in the command buffer.
+ * Add it to the currently selected history list.
+ */
+ public void
+cmd_accept()
+{
+#if CMD_HISTORY
+ /*
+ * Nothing to do if there is no currently selected history list.
+ */
+ if (curr_mlist == NULL)
+ return;
+ cmd_addhist(curr_mlist, cmdbuf);
+#endif
+}
+
+/*
+ * Try to perform a line-edit function on the command buffer,
+ * using a specified char as a line-editing command.
+ * Returns:
+ * CC_PASS The char does not invoke a line edit function.
+ * CC_OK Line edit function done.
+ * CC_QUIT The char requests the current command to be aborted.
+ */
+ static int
+cmd_edit(c)
+ int c;
+{
+ int action;
+ int flags;
+
+#if TAB_COMPLETE_FILENAME
+#define not_in_completion() in_completion = 0
+#else
+#define not_in_completion()
+#endif
+
+ /*
+ * See if the char is indeed a line-editing command.
+ */
+ flags = 0;
+#if CMD_HISTORY
+ if (curr_mlist == NULL)
+ /*
+ * No current history; don't accept history manipulation cmds.
+ */
+ flags |= EC_NOHISTORY;
+#endif
+#if TAB_COMPLETE_FILENAME
+ if (curr_mlist == ml_search)
+ /*
+ * In a search command; don't accept file-completion cmds.
+ */
+ flags |= EC_NOCOMPLETE;
+#endif
+
+ action = editchar(c, flags);
+
+ switch (action)
+ {
+ case EC_RIGHT:
+ not_in_completion();
+ return (cmd_right());
+ case EC_LEFT:
+ not_in_completion();
+ return (cmd_left());
+ case EC_W_RIGHT:
+ not_in_completion();
+ while (*cp != '\0' && *cp != ' ')
+ cmd_right();
+ while (*cp == ' ')
+ cmd_right();
+ return (CC_OK);
+ case EC_W_LEFT:
+ not_in_completion();
+ while (cp > cmdbuf && cp[-1] == ' ')
+ cmd_left();
+ while (cp > cmdbuf && cp[-1] != ' ')
+ cmd_left();
+ return (CC_OK);
+ case EC_HOME:
+ not_in_completion();
+ cmd_offset = 0;
+ cmd_home();
+ cmd_repaint(cp);
+ return (CC_OK);
+ case EC_END:
+ not_in_completion();
+ while (*cp != '\0')
+ cmd_right();
+ return (CC_OK);
+ case EC_INSERT:
+ not_in_completion();
+ return (CC_OK);
+ case EC_BACKSPACE:
+ not_in_completion();
+ return (cmd_erase());
+ case EC_LINEKILL:
+ not_in_completion();
+ return (cmd_kill());
+ case EC_W_BACKSPACE:
+ not_in_completion();
+ return (cmd_werase());
+ case EC_DELETE:
+ not_in_completion();
+ return (cmd_delete());
+ case EC_W_DELETE:
+ not_in_completion();
+ return (cmd_wdelete());
+ case EC_LITERAL:
+ literal = 1;
+ return (CC_OK);
+#if CMD_HISTORY
+ case EC_UP:
+ case EC_DOWN:
+ not_in_completion();
+ return (cmd_updown(action));
+#endif
+#if TAB_COMPLETE_FILENAME
+ case EC_F_COMPLETE:
+ case EC_B_COMPLETE:
+ case EC_EXPAND:
+ return (cmd_complete(action));
+#endif
+ case EC_NOACTION:
+ return (CC_OK);
+ default:
+ not_in_completion();
+ return (CC_PASS);
+ }
+}
+
+#if TAB_COMPLETE_FILENAME
+/*
+ * Insert a string into the command buffer, at the current position.
+ */
+ static int
+cmd_istr(str)
+ char *str;
+{
+ char *s;
+ int action;
+
+ for (s = str; *s != '\0'; s++)
+ {
+ action = cmd_ichar(*s);
+ if (action != CC_OK)
+ {
+ bell();
+ return (action);
+ }
+ }
+ return (CC_OK);
+}
+
+/*
+ * Find the beginning and end of the "current" word.
+ * This is the word which the cursor (cp) is inside or at the end of.
+ * Return pointer to the beginning of the word and put the
+ * cursor at the end of the word.
+ */
+ static char *
+delimit_word()
+{
+ char *word;
+#if SPACES_IN_FILENAMES
+ char *p;
+ int quoted;
+#endif
+
+ /*
+ * Move cursor to end of word.
+ */
+ if (*cp != ' ' && *cp != '\0')
+ {
+ /*
+ * Cursor is on a nonspace.
+ * Move cursor right to the next space.
+ */
+ while (*cp != ' ' && *cp != '\0')
+ cmd_right();
+ } else if (cp > cmdbuf && cp[-1] != ' ')
+ {
+ /*
+ * Cursor is on a space, and char to the left is a nonspace.
+ * We're already at the end of the word.
+ */
+ ;
+ } else
+ {
+ /*
+ * Cursor is on a space and char to the left is a space.
+ * Huh? There's no word here.
+ */
+ return (NULL);
+ }
+ /*
+ * Search backwards for beginning of the word.
+ */
+ if (cp == cmdbuf)
+ return (NULL);
+#if SPACES_IN_FILENAMES
+ /*
+ * If we have an unbalanced quote (that is, an open quote
+ * without a corresponding close quote), we return everything
+ * from the open quote, including spaces.
+ */
+ quoted = 0;
+ for (p = cmdbuf; p < cp; p++)
+ {
+ if (!quoted && *p == openquote)
+ {
+ quoted = 1;
+ word = p;
+ } else if (quoted && *p == closequote)
+ {
+ quoted = 0;
+ }
+ }
+ if (quoted)
+ return (word);
+#endif
+ for (word = cp-1; word > cmdbuf; word--)
+ if (word[-1] == ' ')
+ break;
+ return (word);
+}
+
+/*
+ * Set things up to enter completion mode.
+ * Expand the word under the cursor into a list of filenames
+ * which start with that word, and set tk_text to that list.
+ */
+ static void
+init_compl()
+{
+ char *word;
+ char c;
+
+ /*
+ * Get rid of any previous tk_text.
+ */
+ if (tk_text != NULL)
+ {
+ free(tk_text);
+ tk_text = NULL;
+ }
+ /*
+ * Find the original (uncompleted) word in the command buffer.
+ */
+ word = delimit_word();
+ if (word == NULL)
+ return;
+ /*
+ * Set the insertion point to the point in the command buffer
+ * where the original (uncompleted) word now sits.
+ */
+ tk_ipoint = word;
+ /*
+ * Save the original (uncompleted) word
+ */
+ if (tk_original != NULL)
+ free(tk_original);
+ tk_original = (char *) ecalloc(cp-word+1, sizeof(char));
+ strncpy(tk_original, word, cp-word);
+ /*
+ * Get the expanded filename.
+ * This may result in a single filename, or
+ * a blank-separated list of filenames.
+ */
+ c = *cp;
+ *cp = '\0';
+#if SPACES_IN_FILENAMES
+ if (*word == openquote)
+ word++;
+#endif
+ tk_text = fcomplete(word);
+ *cp = c;
+}
+
+/*
+ * Return the next word in the current completion list.
+ */
+ static char *
+next_compl(action, prev)
+ int action;
+ char *prev;
+{
+ switch (action)
+ {
+ case EC_F_COMPLETE:
+ return (forw_textlist(&tk_tlist, prev));
+ case EC_B_COMPLETE:
+ return (back_textlist(&tk_tlist, prev));
+ }
+ /* Cannot happen */
+ return ("?");
+}
+
+/*
+ * Complete the filename before (or under) the cursor.
+ * cmd_complete may be called multiple times. The global in_completion
+ * remembers whether this call is the first time (create the list),
+ * or a subsequent time (step thru the list).
+ */
+ static int
+cmd_complete(action)
+ int action;
+{
+ char *s;
+
+ if (!in_completion || action == EC_EXPAND)
+ {
+ /*
+ * Expand the word under the cursor and
+ * use the first word in the expansion
+ * (or the entire expansion if we're doing EC_EXPAND).
+ */
+ init_compl();
+ if (tk_text == NULL)
+ {
+ bell();
+ return (CC_OK);
+ }
+ if (action == EC_EXPAND)
+ {
+ /*
+ * Use the whole list.
+ */
+ tk_trial = tk_text;
+ } else
+ {
+ /*
+ * Use the first filename in the list.
+ */
+ in_completion = 1;
+ init_textlist(&tk_tlist, tk_text);
+ tk_trial = next_compl(action, (char*)NULL);
+ }
+ } else
+ {
+ /*
+ * We already have a completion list.
+ * Use the next/previous filename from the list.
+ */
+ tk_trial = next_compl(action, tk_trial);
+ }
+
+ /*
+ * Remove the original word, or the previous trial completion.
+ */
+ while (cp > tk_ipoint)
+ (void) cmd_erase();
+
+ if (tk_trial == NULL)
+ {
+ /*
+ * There are no more trial completions.
+ * Insert the original (uncompleted) filename.
+ */
+ in_completion = 0;
+ if (cmd_istr(tk_original) != CC_OK)
+ goto fail;
+ } else
+ {
+ /*
+ * Insert trial completion.
+ */
+ if (cmd_istr(tk_trial) != CC_OK)
+ goto fail;
+ /*
+ * If it is a directory, append a slash.
+ */
+ if (is_dir(tk_trial))
+ {
+ if (cp > cmdbuf && cp[-1] == closequote)
+ (void) cmd_erase();
+ s = lgetenv("LESSSEPARATOR");
+ if (s == NULL)
+ s = PATHNAME_SEP;
+ if (cmd_istr(s) != CC_OK)
+ goto fail;
+ }
+ }
+
+ return (CC_OK);
+
+fail:
+ in_completion = 0;
+ bell();
+ return (CC_OK);
+}
+
+#endif /* TAB_COMPLETE_FILENAME */
+
+/*
+ * Process a single character of a multi-character command, such as
+ * a number, or the pattern of a search command.
+ * Returns:
+ * CC_OK The char was accepted.
+ * CC_QUIT The char requests the command to be aborted.
+ * CC_ERROR The char could not be accepted due to an error.
+ */
+ public int
+cmd_char(c)
+ int c;
+{
+ int action;
+
+ if (literal)
+ {
+ /*
+ * Insert the char, even if it is a line-editing char.
+ */
+ literal = 0;
+ return (cmd_ichar(c));
+ }
+
+ /*
+ * See if it is a special line-editing character.
+ */
+ if (in_mca())
+ {
+ action = cmd_edit(c);
+ switch (action)
+ {
+ case CC_OK:
+ case CC_QUIT:
+ return (action);
+ case CC_PASS:
+ break;
+ }
+ }
+
+ /*
+ * Insert the char into the command buffer.
+ */
+ return (cmd_ichar(c));
+}
+
+/*
+ * Return the number currently in the command buffer.
+ */
+ public int
+cmd_int()
+{
+ return (atoi(cmdbuf));
+}
+
+/*
+ * Return a pointer to the command buffer.
+ */
+ public char *
+get_cmdbuf()
+{
+ return (cmdbuf);
+}
diff --git a/contrib/less/command.c b/contrib/less/command.c
new file mode 100644
index 000000000000..95c529f758c8
--- /dev/null
+++ b/contrib/less/command.c
@@ -0,0 +1,1543 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * User-level command processor.
+ */
+
+#include "less.h"
+#include "position.h"
+#include "option.h"
+#include "cmd.h"
+
+extern int erase_char, kill_char;
+extern int sigs;
+extern int quit_at_eof;
+extern int quit_if_one_screen;
+extern int squished;
+extern int hit_eof;
+extern int sc_width;
+extern int sc_height;
+extern int swindow;
+extern int jump_sline;
+extern int quitting;
+extern int wscroll;
+extern int top_scroll;
+extern int ignore_eoi;
+extern int secure;
+extern int hshift;
+extern int show_attn;
+extern char *every_first_cmd;
+extern char *curr_altfilename;
+extern char version[];
+extern struct scrpos initial_scrpos;
+extern IFILE curr_ifile;
+extern void constant *ml_search;
+extern void constant *ml_examine;
+#if SHELL_ESCAPE || PIPEC
+extern void constant *ml_shell;
+#endif
+#if EDITOR
+extern char *editor;
+extern char *editproto;
+#endif
+extern int screen_trashed; /* The screen has been overwritten */
+
+static char ungot[UNGOT_SIZE];
+static char *ungotp = NULL;
+#if SHELL_ESCAPE
+static char *shellcmd = NULL; /* For holding last shell command for "!!" */
+#endif
+static int mca; /* The multicharacter command (action) */
+static int search_type; /* The previous type of search */
+static int number; /* The number typed by the user */
+static char optchar;
+static int optflag;
+static int optgetname;
+static POSITION bottompos;
+#if PIPEC
+static char pipec;
+#endif
+
+static void multi_search();
+
+/*
+ * Move the cursor to lower left before executing a command.
+ * This looks nicer if the command takes a long time before
+ * updating the screen.
+ */
+ static void
+cmd_exec()
+{
+ clear_attn();
+ lower_left();
+ flush();
+}
+
+/*
+ * Set up the display to start a new multi-character command.
+ */
+ static void
+start_mca(action, prompt, mlist, cmdflags)
+ int action;
+ char *prompt;
+ void *mlist;
+ int cmdflags;
+{
+ mca = action;
+ clear_cmd();
+ cmd_putstr(prompt);
+ set_mlist(mlist, cmdflags);
+}
+
+ public int
+in_mca()
+{
+ return (mca != 0 && mca != A_PREFIX);
+}
+
+/*
+ * Set up the display to start a new search command.
+ */
+ static void
+mca_search()
+{
+ if (search_type & SRCH_FORW)
+ mca = A_F_SEARCH;
+ else
+ mca = A_B_SEARCH;
+
+ clear_cmd();
+
+ if (search_type & SRCH_NO_MATCH)
+ cmd_putstr("Non-match ");
+ if (search_type & SRCH_FIRST_FILE)
+ cmd_putstr("First-file ");
+ if (search_type & SRCH_PAST_EOF)
+ cmd_putstr("EOF-ignore ");
+ if (search_type & SRCH_NO_MOVE)
+ cmd_putstr("Keep-pos ");
+ if (search_type & SRCH_NO_REGEX)
+ cmd_putstr("Regex-off ");
+
+ if (search_type & SRCH_FORW)
+ cmd_putstr("/");
+ else
+ cmd_putstr("?");
+ set_mlist(ml_search, 0);
+}
+
+/*
+ * Set up the display to start a new toggle-option command.
+ */
+ static void
+mca_opt_toggle()
+{
+ int no_prompt;
+ int flag;
+ char *dash;
+
+ no_prompt = (optflag & OPT_NO_PROMPT);
+ flag = (optflag & ~OPT_NO_PROMPT);
+ dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
+
+ mca = A_OPT_TOGGLE;
+ clear_cmd();
+ cmd_putstr(dash);
+ if (optgetname)
+ cmd_putstr(dash);
+ if (no_prompt)
+ cmd_putstr("(P)");
+ switch (flag)
+ {
+ case OPT_UNSET:
+ cmd_putstr("+");
+ break;
+ case OPT_SET:
+ cmd_putstr("!");
+ break;
+ }
+ set_mlist(NULL, 0);
+}
+
+/*
+ * Execute a multicharacter command.
+ */
+ static void
+exec_mca()
+{
+ register char *cbuf;
+
+ cmd_exec();
+ cbuf = get_cmdbuf();
+
+ switch (mca)
+ {
+ case A_F_SEARCH:
+ case A_B_SEARCH:
+ multi_search(cbuf, number);
+ break;
+ case A_FIRSTCMD:
+ /*
+ * Skip leading spaces or + signs in the string.
+ */
+ while (*cbuf == '+' || *cbuf == ' ')
+ cbuf++;
+ if (every_first_cmd != NULL)
+ free(every_first_cmd);
+ if (*cbuf == '\0')
+ every_first_cmd = NULL;
+ else
+ every_first_cmd = save(cbuf);
+ break;
+ case A_OPT_TOGGLE:
+ toggle_option(optchar, cbuf, optflag);
+ optchar = '\0';
+ break;
+ case A_F_BRACKET:
+ match_brac(cbuf[0], cbuf[1], 1, number);
+ break;
+ case A_B_BRACKET:
+ match_brac(cbuf[1], cbuf[0], 0, number);
+ break;
+#if EXAMINE
+ case A_EXAMINE:
+ if (secure)
+ break;
+ edit_list(cbuf);
+ break;
+#endif
+#if SHELL_ESCAPE
+ case A_SHELL:
+ /*
+ * !! just uses whatever is in shellcmd.
+ * Otherwise, copy cmdbuf to shellcmd,
+ * expanding any special characters ("%" or "#").
+ */
+ if (*cbuf != '!')
+ {
+ if (shellcmd != NULL)
+ free(shellcmd);
+ shellcmd = fexpand(cbuf);
+ }
+
+ if (secure)
+ break;
+ if (shellcmd == NULL)
+ lsystem("", "!done");
+ else
+ lsystem(shellcmd, "!done");
+ break;
+#endif
+#if PIPEC
+ case A_PIPE:
+ if (secure)
+ break;
+ (void) pipe_mark(pipec, cbuf);
+ error("|done", NULL_PARG);
+ break;
+#endif
+ }
+}
+
+/*
+ * Add a character to a multi-character command.
+ */
+ static int
+mca_char(c)
+ int c;
+{
+ char *p;
+ int flag;
+ char buf[3];
+ PARG parg;
+
+ switch (mca)
+ {
+ case 0:
+ /*
+ * Not in a multicharacter command.
+ */
+ return (NO_MCA);
+
+ case A_PREFIX:
+ /*
+ * In the prefix of a command.
+ * This not considered a multichar command
+ * (even tho it uses cmdbuf, etc.).
+ * It is handled in the commands() switch.
+ */
+ return (NO_MCA);
+
+ case A_DIGIT:
+ /*
+ * Entering digits of a number.
+ * Terminated by a non-digit.
+ */
+ if ((c < '0' || c > '9') &&
+ editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE) == A_INVALID)
+ {
+ /*
+ * Not part of the number.
+ * Treat as a normal command character.
+ */
+ number = cmd_int();
+ mca = 0;
+ cmd_accept();
+ return (NO_MCA);
+ }
+ break;
+
+ case A_OPT_TOGGLE:
+ /*
+ * Special case for the TOGGLE_OPTION command.
+ * If the option letter which was entered is a
+ * single-char option, execute the command immediately,
+ * so user doesn't have to hit RETURN.
+ * If the first char is + or -, this indicates
+ * OPT_UNSET or OPT_SET respectively, instead of OPT_TOGGLE.
+ * "--" begins inputting a long option name.
+ */
+ if (optchar == '\0' && len_cmdbuf() == 0)
+ {
+ flag = (optflag & ~OPT_NO_PROMPT);
+ if (flag == OPT_NO_TOGGLE)
+ {
+ switch (c)
+ {
+ case '_':
+ /* "__" = long option name. */
+ optgetname = TRUE;
+ mca_opt_toggle();
+ return (MCA_MORE);
+ }
+ } else
+ {
+ switch (c)
+ {
+ case '+':
+ /* "-+" = UNSET. */
+ optflag = (flag == OPT_UNSET) ?
+ OPT_TOGGLE : OPT_UNSET;
+ mca_opt_toggle();
+ return (MCA_MORE);
+ case '!':
+ /* "-!" = SET */
+ optflag = (flag == OPT_SET) ?
+ OPT_TOGGLE : OPT_SET;
+ mca_opt_toggle();
+ return (MCA_MORE);
+ case CONTROL('P'):
+ optflag ^= OPT_NO_PROMPT;
+ mca_opt_toggle();
+ return (MCA_MORE);
+ case '-':
+ /* "--" = long option name. */
+ optgetname = TRUE;
+ mca_opt_toggle();
+ return (MCA_MORE);
+ }
+ }
+ }
+ if (optgetname)
+ {
+ /*
+ * We're getting a long option name.
+ * See if we've matched an option name yet.
+ * If so, display the complete name and stop
+ * accepting chars until user hits RETURN.
+ */
+ struct option *o;
+ char *oname;
+ int lc;
+
+ if (c == '\n' || c == '\r')
+ {
+ /*
+ * When the user hits RETURN, make sure
+ * we've matched an option name, then
+ * pretend he just entered the equivalent
+ * option letter.
+ */
+ if (optchar == '\0')
+ {
+ parg.p_string = get_cmdbuf();
+ error("There is no --%s option", &parg);
+ return (MCA_DONE);
+ }
+ optgetname = FALSE;
+ cmd_reset();
+ c = optchar;
+ } else
+ {
+ if (optchar != '\0')
+ {
+ /*
+ * Already have a match for the name.
+ * Don't accept anything but erase/kill.
+ */
+ if (c == erase_char || c == kill_char)
+ return (MCA_DONE);
+ return (MCA_MORE);
+ }
+ /*
+ * Add char to cmd buffer and try to match
+ * the option name.
+ */
+ if (cmd_char(c) == CC_QUIT)
+ return (MCA_DONE);
+ p = get_cmdbuf();
+ lc = islower(p[0]);
+ o = findopt_name(&p, &oname, NULL);
+ if (o != NULL)
+ {
+ /*
+ * Got a match.
+ * Remember the option letter and
+ * display the full option name.
+ */
+ optchar = o->oletter;
+ if (!lc && islower(optchar))
+ optchar = toupper(optchar);
+ cmd_reset();
+ mca_opt_toggle();
+ for (p = oname; *p != '\0'; p++)
+ {
+ c = *p;
+ if (!lc && islower(c))
+ c = toupper(c);
+ if (cmd_char(c) != CC_OK)
+ return (MCA_DONE);
+ }
+ }
+ return (MCA_MORE);
+ }
+ } else
+ {
+ if (c == erase_char || c == kill_char)
+ break;
+ if (optchar != '\0')
+ /* We already have the option letter. */
+ break;
+ }
+
+ optchar = c;
+ if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE ||
+ single_char_option(c))
+ {
+ toggle_option(c, "", optflag);
+ return (MCA_DONE);
+ }
+ /*
+ * Display a prompt appropriate for the option letter.
+ */
+ if ((p = opt_prompt(c)) == NULL)
+ {
+ buf[0] = '-';
+ buf[1] = c;
+ buf[2] = '\0';
+ p = buf;
+ }
+ start_mca(A_OPT_TOGGLE, p, (void*)NULL, 0);
+ return (MCA_MORE);
+
+ case A_F_SEARCH:
+ case A_B_SEARCH:
+ /*
+ * Special case for search commands.
+ * Certain characters as the first char of
+ * the pattern have special meaning:
+ * ! Toggle the NO_MATCH flag
+ * * Toggle the PAST_EOF flag
+ * @ Toggle the FIRST_FILE flag
+ */
+ if (len_cmdbuf() > 0)
+ /*
+ * Only works for the first char of the pattern.
+ */
+ break;
+
+ flag = 0;
+ switch (c)
+ {
+ case CONTROL('E'): /* ignore END of file */
+ case '*':
+ flag = SRCH_PAST_EOF;
+ break;
+ case CONTROL('F'): /* FIRST file */
+ case '@':
+ flag = SRCH_FIRST_FILE;
+ break;
+ case CONTROL('K'): /* KEEP position */
+ flag = SRCH_NO_MOVE;
+ break;
+ case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */
+ flag = SRCH_NO_REGEX;
+ break;
+ case CONTROL('N'): /* NOT match */
+ case '!':
+ flag = SRCH_NO_MATCH;
+ break;
+ }
+ if (flag != 0)
+ {
+ search_type ^= flag;
+ mca_search();
+ return (MCA_MORE);
+ }
+ break;
+ }
+
+ /*
+ * Any other multicharacter command
+ * is terminated by a newline.
+ */
+ if (c == '\n' || c == '\r')
+ {
+ /*
+ * Execute the command.
+ */
+ exec_mca();
+ return (MCA_DONE);
+ }
+
+ /*
+ * Append the char to the command buffer.
+ */
+ if (cmd_char(c) == CC_QUIT)
+ /*
+ * Abort the multi-char command.
+ */
+ return (MCA_DONE);
+
+ if ((mca == A_F_BRACKET || mca == A_B_BRACKET) && len_cmdbuf() >= 2)
+ {
+ /*
+ * Special case for the bracket-matching commands.
+ * Execute the command after getting exactly two
+ * characters from the user.
+ */
+ exec_mca();
+ return (MCA_DONE);
+ }
+
+ /*
+ * Need another character.
+ */
+ return (MCA_MORE);
+}
+
+/*
+ * Make sure the screen is displayed.
+ */
+ static void
+make_display()
+{
+ /*
+ * If nothing is displayed yet, display starting from initial_scrpos.
+ */
+ if (empty_screen())
+ {
+ if (initial_scrpos.pos == NULL_POSITION)
+ /*
+ * {{ Maybe this should be:
+ * jump_loc(ch_zero(), jump_sline);
+ * but this behavior seems rather unexpected
+ * on the first screen. }}
+ */
+ jump_loc(ch_zero(), 1);
+ else
+ jump_loc(initial_scrpos.pos, initial_scrpos.ln);
+ } else if (screen_trashed)
+ {
+ int save_top_scroll;
+ save_top_scroll = top_scroll;
+ top_scroll = 1;
+ repaint();
+ top_scroll = save_top_scroll;
+ }
+}
+
+/*
+ * Display the appropriate prompt.
+ */
+ static void
+prompt()
+{
+ register char *p;
+
+ if (ungotp != NULL && ungotp > ungot)
+ {
+ /*
+ * No prompt necessary if commands are from
+ * ungotten chars rather than from the user.
+ */
+ return;
+ }
+
+ /*
+ * Make sure the screen is displayed.
+ */
+ make_display();
+ bottompos = position(BOTTOM_PLUS_ONE);
+
+ /*
+ * If the -E flag is set and we've hit EOF on the last file, quit.
+ */
+ if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) &&
+ hit_eof && !(ch_getflags() & CH_HELPFILE) &&
+ next_ifile(curr_ifile) == NULL_IFILE)
+ quit(QUIT_OK);
+ quit_if_one_screen = FALSE;
+#if 0 /* This doesn't work well because some "te"s clear the screen. */
+ /*
+ * If the -e flag is set and we've hit EOF on the last file,
+ * and the file is squished (shorter than the screen), quit.
+ */
+ if (quit_at_eof && squished &&
+ next_ifile(curr_ifile) == NULL_IFILE)
+ quit(QUIT_OK);
+#endif
+
+ /*
+ * Select the proper prompt and display it.
+ */
+ clear_cmd();
+ p = pr_string();
+ if (p == NULL)
+ putchr(':');
+ else
+ {
+ so_enter();
+ putstr(p);
+ so_exit();
+ }
+}
+
+/*
+ * Display the less version message.
+ */
+ public void
+dispversion()
+{
+ PARG parg;
+
+ parg.p_string = version;
+ error("less %s", &parg);
+}
+
+/*
+ * Get command character.
+ * The character normally comes from the keyboard,
+ * but may come from ungotten characters
+ * (characters previously given to ungetcc or ungetsc).
+ */
+ public int
+getcc()
+{
+ if (ungotp == NULL)
+ /*
+ * Normal case: no ungotten chars, so get one from the user.
+ */
+ return (getchr());
+
+ if (ungotp > ungot)
+ /*
+ * Return the next ungotten char.
+ */
+ return (*--ungotp);
+
+ /*
+ * We have just run out of ungotten chars.
+ */
+ ungotp = NULL;
+ if (len_cmdbuf() == 0 || !empty_screen())
+ return (getchr());
+ /*
+ * Command is incomplete, so try to complete it.
+ */
+ switch (mca)
+ {
+ case A_DIGIT:
+ /*
+ * We have a number but no command. Treat as #g.
+ */
+ return ('g');
+
+ case A_F_SEARCH:
+ case A_B_SEARCH:
+ /*
+ * We have "/string" but no newline. Add the \n.
+ */
+ return ('\n');
+
+ default:
+ /*
+ * Some other incomplete command. Let user complete it.
+ */
+ return (getchr());
+ }
+}
+
+/*
+ * "Unget" a command character.
+ * The next getcc() will return this character.
+ */
+ public void
+ungetcc(c)
+ int c;
+{
+ if (ungotp == NULL)
+ ungotp = ungot;
+ if (ungotp >= ungot + sizeof(ungot))
+ {
+ error("ungetcc overflow", NULL_PARG);
+ quit(QUIT_ERROR);
+ }
+ *ungotp++ = c;
+}
+
+/*
+ * Unget a whole string of command characters.
+ * The next sequence of getcc()'s will return this string.
+ */
+ public void
+ungetsc(s)
+ char *s;
+{
+ register char *p;
+
+ for (p = s + strlen(s) - 1; p >= s; p--)
+ ungetcc(*p);
+}
+
+/*
+ * Search for a pattern, possibly in multiple files.
+ * If SRCH_FIRST_FILE is set, begin searching at the first file.
+ * If SRCH_PAST_EOF is set, continue the search thru multiple files.
+ */
+ static void
+multi_search(pattern, n)
+ char *pattern;
+ int n;
+{
+ register int nomore;
+ IFILE save_ifile;
+ int changed_file;
+
+ changed_file = 0;
+ save_ifile = save_curr_ifile();
+
+ if (search_type & SRCH_FIRST_FILE)
+ {
+ /*
+ * Start at the first (or last) file
+ * in the command line list.
+ */
+ if (search_type & SRCH_FORW)
+ nomore = edit_first();
+ else
+ nomore = edit_last();
+ if (nomore)
+ {
+ unsave_ifile(save_ifile);
+ return;
+ }
+ changed_file = 1;
+ search_type &= ~SRCH_FIRST_FILE;
+ }
+
+ for (;;)
+ {
+ n = search(search_type, pattern, n);
+ /*
+ * The SRCH_NO_MOVE flag doesn't "stick": it gets cleared
+ * after being used once. This allows "n" to work after
+ * using a /@@ search.
+ */
+ search_type &= ~SRCH_NO_MOVE;
+ if (n == 0)
+ {
+ /*
+ * Found it.
+ */
+ unsave_ifile(save_ifile);
+ return;
+ }
+
+ if (n < 0)
+ /*
+ * Some kind of error in the search.
+ * Error message has been printed by search().
+ */
+ break;
+
+ if ((search_type & SRCH_PAST_EOF) == 0)
+ /*
+ * We didn't find a match, but we're
+ * supposed to search only one file.
+ */
+ break;
+ /*
+ * Move on to the next file.
+ */
+ if (search_type & SRCH_FORW)
+ nomore = edit_next(1);
+ else
+ nomore = edit_prev(1);
+ if (nomore)
+ break;
+ changed_file = 1;
+ }
+
+ /*
+ * Didn't find it.
+ * Print an error message if we haven't already.
+ */
+ if (n > 0)
+ error("Pattern not found", NULL_PARG);
+
+ if (changed_file)
+ {
+ /*
+ * Restore the file we were originally viewing.
+ */
+ reedit_ifile(save_ifile);
+ }
+}
+
+/*
+ * Main command processor.
+ * Accept and execute commands until a quit command.
+ */
+ public void
+commands()
+{
+ register int c;
+ register int action;
+ register char *cbuf;
+ int newaction;
+ int save_search_type;
+ char *extra;
+ char tbuf[2];
+ PARG parg;
+ IFILE old_ifile;
+ IFILE new_ifile;
+
+ search_type = SRCH_FORW;
+ wscroll = (sc_height + 1) / 2;
+ newaction = A_NOACTION;
+
+ for (;;)
+ {
+ mca = 0;
+ cmd_accept();
+ number = 0;
+ optchar = '\0';
+
+ /*
+ * See if any signals need processing.
+ */
+ if (sigs)
+ {
+ psignals();
+ if (quitting)
+ quit(QUIT_SAVED_STATUS);
+ }
+
+ /*
+ * See if window size changed, for systems that don't
+ * generate SIGWINCH.
+ */
+ check_winch();
+
+ /*
+ * Display prompt and accept a character.
+ */
+ cmd_reset();
+ prompt();
+ if (sigs)
+ continue;
+ if (newaction == A_NOACTION)
+ c = getcc();
+
+ again:
+ if (sigs)
+ continue;
+
+ if (newaction != A_NOACTION)
+ {
+ action = newaction;
+ newaction = A_NOACTION;
+ } else
+ {
+ /*
+ * If we are in a multicharacter command, call mca_char.
+ * Otherwise we call fcmd_decode to determine the
+ * action to be performed.
+ */
+ if (mca)
+ switch (mca_char(c))
+ {
+ case MCA_MORE:
+ /*
+ * Need another character.
+ */
+ c = getcc();
+ goto again;
+ case MCA_DONE:
+ /*
+ * Command has been handled by mca_char.
+ * Start clean with a prompt.
+ */
+ continue;
+ case NO_MCA:
+ /*
+ * Not a multi-char command
+ * (at least, not anymore).
+ */
+ break;
+ }
+
+ /*
+ * Decode the command character and decide what to do.
+ */
+ if (mca)
+ {
+ /*
+ * We're in a multichar command.
+ * Add the character to the command buffer
+ * and display it on the screen.
+ * If the user backspaces past the start
+ * of the line, abort the command.
+ */
+ if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0)
+ continue;
+ cbuf = get_cmdbuf();
+ } else
+ {
+ /*
+ * Don't use cmd_char if we're starting fresh
+ * at the beginning of a command, because we
+ * don't want to echo the command until we know
+ * it is a multichar command. We also don't
+ * want erase_char/kill_char to be treated
+ * as line editing characters.
+ */
+ tbuf[0] = c;
+ tbuf[1] = '\0';
+ cbuf = tbuf;
+ }
+ extra = NULL;
+ action = fcmd_decode(cbuf, &extra);
+ /*
+ * If an "extra" string was returned,
+ * process it as a string of command characters.
+ */
+ if (extra != NULL)
+ ungetsc(extra);
+ }
+ /*
+ * Clear the cmdbuf string.
+ * (But not if we're in the prefix of a command,
+ * because the partial command string is kept there.)
+ */
+ if (action != A_PREFIX)
+ cmd_reset();
+
+ switch (action)
+ {
+ case A_DIGIT:
+ /*
+ * First digit of a number.
+ */
+ start_mca(A_DIGIT, ":", (void*)NULL, CF_QUIT_ON_ERASE);
+ goto again;
+
+ case A_F_WINDOW:
+ /*
+ * Forward one window (and set the window size).
+ */
+ if (number > 0)
+ swindow = number;
+ /* FALLTHRU */
+ case A_F_SCREEN:
+ /*
+ * Forward one screen.
+ */
+ if (number <= 0)
+ number = get_swindow();
+ cmd_exec();
+ if (show_attn)
+ set_attnpos(bottompos);
+ forward(number, 0, 1);
+ break;
+
+ case A_B_WINDOW:
+ /*
+ * Backward one window (and set the window size).
+ */
+ if (number > 0)
+ swindow = number;
+ /* FALLTHRU */
+ case A_B_SCREEN:
+ /*
+ * Backward one screen.
+ */
+ if (number <= 0)
+ number = get_swindow();
+ cmd_exec();
+ backward(number, 0, 1);
+ break;
+
+ case A_F_LINE:
+ /*
+ * Forward N (default 1) line.
+ */
+ if (number <= 0)
+ number = 1;
+ cmd_exec();
+ if (show_attn == OPT_ONPLUS && number > 1)
+ set_attnpos(bottompos);
+ forward(number, 0, 0);
+ break;
+
+ case A_B_LINE:
+ /*
+ * Backward N (default 1) line.
+ */
+ if (number <= 0)
+ number = 1;
+ cmd_exec();
+ backward(number, 0, 0);
+ break;
+
+ case A_FF_LINE:
+ /*
+ * Force forward N (default 1) line.
+ */
+ if (number <= 0)
+ number = 1;
+ cmd_exec();
+ if (show_attn == OPT_ONPLUS && number > 1)
+ set_attnpos(bottompos);
+ forward(number, 1, 0);
+ break;
+
+ case A_BF_LINE:
+ /*
+ * Force backward N (default 1) line.
+ */
+ if (number <= 0)
+ number = 1;
+ cmd_exec();
+ backward(number, 1, 0);
+ break;
+
+ case A_FF_SCREEN:
+ /*
+ * Force forward one screen.
+ */
+ if (number <= 0)
+ number = get_swindow();
+ cmd_exec();
+ if (show_attn == OPT_ONPLUS)
+ set_attnpos(bottompos);
+ forward(number, 1, 0);
+ break;
+
+ case A_F_FOREVER:
+ /*
+ * Forward forever, ignoring EOF.
+ */
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ cmd_exec();
+ jump_forw();
+ ignore_eoi = 1;
+ hit_eof = 0;
+ while (!sigs)
+ forward(1, 0, 0);
+ ignore_eoi = 0;
+ /*
+ * This gets us back in "F mode" after processing
+ * a non-abort signal (e.g. window-change).
+ */
+ if (sigs && !ABORT_SIGS())
+ newaction = A_F_FOREVER;
+ break;
+
+ case A_F_SCROLL:
+ /*
+ * Forward N lines
+ * (default same as last 'd' or 'u' command).
+ */
+ if (number > 0)
+ wscroll = number;
+ cmd_exec();
+ if (show_attn == OPT_ONPLUS)
+ set_attnpos(bottompos);
+ forward(wscroll, 0, 0);
+ break;
+
+ case A_B_SCROLL:
+ /*
+ * Forward N lines
+ * (default same as last 'd' or 'u' command).
+ */
+ if (number > 0)
+ wscroll = number;
+ cmd_exec();
+ backward(wscroll, 0, 0);
+ break;
+
+ case A_FREPAINT:
+ /*
+ * Flush buffers, then repaint screen.
+ * Don't flush the buffers on a pipe!
+ */
+ if (ch_getflags() & CH_CANSEEK)
+ {
+ ch_flush();
+ clr_linenum();
+#if HILITE_SEARCH
+ clr_hilite();
+#endif
+ }
+ /* FALLTHRU */
+ case A_REPAINT:
+ /*
+ * Repaint screen.
+ */
+ cmd_exec();
+ repaint();
+ break;
+
+ case A_GOLINE:
+ /*
+ * Go to line N, default beginning of file.
+ */
+ if (number <= 0)
+ number = 1;
+ cmd_exec();
+ jump_back(number);
+ break;
+
+ case A_PERCENT:
+ /*
+ * Go to a specified percentage into the file.
+ */
+ if (number < 0)
+ number = 0;
+ if (number > 100)
+ number = 100;
+ cmd_exec();
+ jump_percent(number);
+ break;
+
+ case A_GOEND:
+ /*
+ * Go to line N, default end of file.
+ */
+ cmd_exec();
+ if (number <= 0)
+ jump_forw();
+ else
+ jump_back(number);
+ break;
+
+ case A_GOPOS:
+ /*
+ * Go to a specified byte position in the file.
+ */
+ cmd_exec();
+ if (number < 0)
+ number = 0;
+ jump_line_loc((POSITION)number, jump_sline);
+ break;
+
+ case A_STAT:
+ /*
+ * Print file name, etc.
+ */
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ cmd_exec();
+ parg.p_string = eq_message();
+ error("%s", &parg);
+ break;
+
+ case A_VERSION:
+ /*
+ * Print version number, without the "@(#)".
+ */
+ cmd_exec();
+ dispversion();
+ break;
+
+ case A_QUIT:
+ /*
+ * Exit.
+ */
+ if (curr_ifile != NULL_IFILE &&
+ ch_getflags() & CH_HELPFILE)
+ {
+ /*
+ * Quit while viewing the help file
+ * just means return to viewing the
+ * previous file.
+ */
+ if (edit_prev(1) == 0)
+ break;
+ }
+ if (extra != NULL)
+ quit(*extra);
+ quit(QUIT_OK);
+ break;
+
+/*
+ * Define abbreviation for a commonly used sequence below.
+ */
+#define DO_SEARCH() if (number <= 0) number = 1; \
+ mca_search(); \
+ cmd_exec(); \
+ multi_search((char *)NULL, number);
+
+
+ case A_F_SEARCH:
+ /*
+ * Search forward for a pattern.
+ * Get the first char of the pattern.
+ */
+ search_type = SRCH_FORW;
+ if (number <= 0)
+ number = 1;
+ mca_search();
+ c = getcc();
+ goto again;
+
+ case A_B_SEARCH:
+ /*
+ * Search backward for a pattern.
+ * Get the first char of the pattern.
+ */
+ search_type = SRCH_BACK;
+ if (number <= 0)
+ number = 1;
+ mca_search();
+ c = getcc();
+ goto again;
+
+ case A_AGAIN_SEARCH:
+ /*
+ * Repeat previous search.
+ */
+ DO_SEARCH();
+ break;
+
+ case A_T_AGAIN_SEARCH:
+ /*
+ * Repeat previous search, multiple files.
+ */
+ search_type |= SRCH_PAST_EOF;
+ DO_SEARCH();
+ break;
+
+ case A_REVERSE_SEARCH:
+ /*
+ * Repeat previous search, in reverse direction.
+ */
+ save_search_type = search_type;
+ search_type = SRCH_REVERSE(search_type);
+ DO_SEARCH();
+ search_type = save_search_type;
+ break;
+
+ case A_T_REVERSE_SEARCH:
+ /*
+ * Repeat previous search,
+ * multiple files in reverse direction.
+ */
+ save_search_type = search_type;
+ search_type = SRCH_REVERSE(search_type);
+ search_type |= SRCH_PAST_EOF;
+ DO_SEARCH();
+ search_type = save_search_type;
+ break;
+
+ case A_UNDO_SEARCH:
+ undo_search();
+ break;
+
+ case A_HELP:
+ /*
+ * Help.
+ */
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ cmd_exec();
+ (void) edit(FAKE_HELPFILE);
+ break;
+
+ case A_EXAMINE:
+#if EXAMINE
+ /*
+ * Edit a new file. Get the filename.
+ */
+ if (secure)
+ {
+ error("Command not available", NULL_PARG);
+ break;
+ }
+ start_mca(A_EXAMINE, "Examine: ", ml_examine, 0);
+ c = getcc();
+ goto again;
+#else
+ error("Command not available", NULL_PARG);
+ break;
+#endif
+
+ case A_VISUAL:
+ /*
+ * Invoke an editor on the input file.
+ */
+#if EDITOR
+ if (secure)
+ {
+ error("Command not available", NULL_PARG);
+ break;
+ }
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ if (strcmp(get_filename(curr_ifile), "-") == 0)
+ {
+ error("Cannot edit standard input", NULL_PARG);
+ break;
+ }
+ if (curr_altfilename != NULL)
+ {
+ error("Cannot edit file processed with LESSOPEN",
+ NULL_PARG);
+ break;
+ }
+ start_mca(A_SHELL, "!", ml_shell, 0);
+ /*
+ * Expand the editor prototype string
+ * and pass it to the system to execute.
+ * (Make sure the screen is displayed so the
+ * expansion of "+%lm" works.)
+ */
+ make_display();
+ cmd_exec();
+ lsystem(pr_expand(editproto, 0), (char*)NULL);
+ break;
+#else
+ error("Command not available", NULL_PARG);
+ break;
+#endif
+
+ case A_NEXT_FILE:
+ /*
+ * Examine next file.
+ */
+ if (number <= 0)
+ number = 1;
+ if (edit_next(number))
+ {
+ if (quit_at_eof && hit_eof &&
+ !(ch_getflags() & CH_HELPFILE))
+ quit(QUIT_OK);
+ parg.p_string = (number > 1) ? "(N-th) " : "";
+ error("No %snext file", &parg);
+ }
+ break;
+
+ case A_PREV_FILE:
+ /*
+ * Examine previous file.
+ */
+ if (number <= 0)
+ number = 1;
+ if (edit_prev(number))
+ {
+ parg.p_string = (number > 1) ? "(N-th) " : "";
+ error("No %sprevious file", &parg);
+ }
+ break;
+
+ case A_INDEX_FILE:
+ /*
+ * Examine a particular file.
+ */
+ if (number <= 0)
+ number = 1;
+ if (edit_index(number))
+ error("No such file", NULL_PARG);
+ break;
+
+ case A_REMOVE_FILE:
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ old_ifile = curr_ifile;
+ new_ifile = getoff_ifile(curr_ifile);
+ if (new_ifile == NULL_IFILE)
+ {
+ bell();
+ break;
+ }
+ if (edit_ifile(new_ifile) != 0)
+ {
+ reedit_ifile(old_ifile);
+ break;
+ }
+ del_ifile(old_ifile);
+ break;
+
+ case A_OPT_TOGGLE:
+ optflag = OPT_TOGGLE;
+ optgetname = FALSE;
+ mca_opt_toggle();
+ c = getcc();
+ goto again;
+
+ case A_DISP_OPTION:
+ /*
+ * Report a flag setting.
+ */
+ optflag = OPT_NO_TOGGLE;
+ optgetname = FALSE;
+ mca_opt_toggle();
+ c = getcc();
+ goto again;
+
+ case A_FIRSTCMD:
+ /*
+ * Set an initial command for new files.
+ */
+ start_mca(A_FIRSTCMD, "+", (void*)NULL, 0);
+ c = getcc();
+ goto again;
+
+ case A_SHELL:
+ /*
+ * Shell escape.
+ */
+#if SHELL_ESCAPE
+ if (secure)
+ {
+ error("Command not available", NULL_PARG);
+ break;
+ }
+ start_mca(A_SHELL, "!", ml_shell, 0);
+ c = getcc();
+ goto again;
+#else
+ error("Command not available", NULL_PARG);
+ break;
+#endif
+
+ case A_SETMARK:
+ /*
+ * Set a mark.
+ */
+ if (ch_getflags() & CH_HELPFILE)
+ break;
+ start_mca(A_SETMARK, "mark: ", (void*)NULL, 0);
+ c = getcc();
+ if (c == erase_char || c == kill_char ||
+ c == '\n' || c == '\r')
+ break;
+ setmark(c);
+ break;
+
+ case A_GOMARK:
+ /*
+ * Go to a mark.
+ */
+ start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
+ c = getcc();
+ if (c == erase_char || c == kill_char ||
+ c == '\n' || c == '\r')
+ break;
+ gomark(c);
+ break;
+
+ case A_PIPE:
+#if PIPEC
+ if (secure)
+ {
+ error("Command not available", NULL_PARG);
+ break;
+ }
+ start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
+ c = getcc();
+ if (c == erase_char || c == kill_char)
+ break;
+ if (c == '\n' || c == '\r')
+ c = '.';
+ if (badmark(c))
+ break;
+ pipec = c;
+ start_mca(A_PIPE, "!", ml_shell, 0);
+ c = getcc();
+ goto again;
+#else
+ error("Command not available", NULL_PARG);
+ break;
+#endif
+
+ case A_B_BRACKET:
+ case A_F_BRACKET:
+ start_mca(action, "Brackets: ", (void*)NULL, 0);
+ c = getcc();
+ goto again;
+
+ case A_LSHIFT:
+ if (number <= 0)
+ number = 8;
+ if (number > hshift)
+ number = hshift;
+ hshift -= number;
+ screen_trashed = 1;
+ break;
+
+ case A_RSHIFT:
+ if (number <= 0)
+ number = 8;
+ hshift += number;
+ screen_trashed = 1;
+ break;
+
+ case A_PREFIX:
+ /*
+ * The command is incomplete (more chars are needed).
+ * Display the current char, so the user knows
+ * what's going on, and get another character.
+ */
+ if (mca != A_PREFIX)
+ {
+ cmd_reset();
+ start_mca(A_PREFIX, " ", (void*)NULL,
+ CF_QUIT_ON_ERASE);
+ (void) cmd_char(c);
+ }
+ c = getcc();
+ goto again;
+
+ case A_NOACTION:
+ break;
+
+ default:
+ bell();
+ break;
+ }
+ }
+}
diff --git a/contrib/less/configure b/contrib/less/configure
new file mode 100755
index 000000000000..a32eddf23ef0
--- /dev/null
+++ b/contrib/less/configure
@@ -0,0 +1,2737 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]"
+ac_help="$ac_help
+ --with-editor=PROGRAM use PROGRAM as the default editor [vi]"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.12"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=forwback.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:531: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:560: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ ac_prog_rejected=no
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:608: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext <<EOF
+#line 618 "configure"
+#include "confdefs.h"
+main(){return(0);}
+EOF
+if { (eval echo configure:622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:647: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:656: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:671: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ elif test $ac_cv_prog_cc_g = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-O2"
+ fi
+else
+ GCC=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:699: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:720: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 735 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:741: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 752 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:758: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
+echo "configure:782: checking whether ${CC-cc} needs -traditional" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_pattern="Autoconf.*'x'"
+ cat > conftest.$ac_ext <<EOF
+#line 788 "configure"
+#include "confdefs.h"
+#include <sgtty.h>
+Autoconf TIOCGETP
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "$ac_pattern" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=yes
+else
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=no
+fi
+rm -f conftest*
+
+
+ if test $ac_cv_prog_gcc_traditional = no; then
+ cat > conftest.$ac_ext <<EOF
+#line 806 "configure"
+#include "confdefs.h"
+#include <termio.h>
+Autoconf TCGETA
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "$ac_pattern" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=yes
+fi
+rm -f conftest*
+
+ fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
+ if test $ac_cv_prog_gcc_traditional = yes; then
+ CC="$CC -traditional"
+ fi
+fi
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:857: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ for ac_prog in ginstall installbsd scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ # OSF/1 installbsd also uses dspmsg, but is usable.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+echo $ac_n "checking for initscr in -lxcurses""... $ac_c" 1>&6
+echo "configure:908: checking for initscr in -lxcurses" >&5
+ac_lib_var=`echo xcurses'_'initscr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lxcurses $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 916 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char initscr();
+
+int main() {
+initscr()
+; return 0; }
+EOF
+if { (eval echo configure:927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ have_xcurses=yes
+else
+ echo "$ac_t""no" 1>&6
+have_xcurses=no
+fi
+
+echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
+echo "configure:949: checking for initscr in -lncurses" >&5
+ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lncurses $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 957 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char initscr();
+
+int main() {
+initscr()
+; return 0; }
+EOF
+if { (eval echo configure:968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ have_ncurses=yes
+else
+ echo "$ac_t""no" 1>&6
+have_ncurses=no
+fi
+
+echo $ac_n "checking for initscr in -lcurses""... $ac_c" 1>&6
+echo "configure:990: checking for initscr in -lcurses" >&5
+ac_lib_var=`echo curses'_'initscr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lcurses $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 998 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char initscr();
+
+int main() {
+initscr()
+; return 0; }
+EOF
+if { (eval echo configure:1009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ have_curses=yes
+else
+ echo "$ac_t""no" 1>&6
+have_curses=no
+fi
+
+echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
+echo "configure:1031: checking for tgetent in -ltermcap" >&5
+ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ltermcap $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1039 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tgetent();
+
+int main() {
+tgetent()
+; return 0; }
+EOF
+if { (eval echo configure:1050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ have_termcap=yes
+else
+ echo "$ac_t""no" 1>&6
+have_termcap=no
+fi
+
+echo $ac_n "checking for tgetent in -ltermlib""... $ac_c" 1>&6
+echo "configure:1072: checking for tgetent in -ltermlib" >&5
+ac_lib_var=`echo termlib'_'tgetent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ltermlib $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1080 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tgetent();
+
+int main() {
+tgetent()
+; return 0; }
+EOF
+if { (eval echo configure:1091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ have_termlib=yes
+else
+ echo "$ac_t""no" 1>&6
+have_termlib=no
+fi
+
+echo $ac_n "checking for regcmp in -lgen""... $ac_c" 1>&6
+echo "configure:1113: checking for regcmp in -lgen" >&5
+ac_lib_var=`echo gen'_'regcmp | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lgen $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1121 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char regcmp();
+
+int main() {
+regcmp()
+; return 0; }
+EOF
+if { (eval echo configure:1132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo gen | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lgen $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for regcmp in -lintl""... $ac_c" 1>&6
+echo "configure:1160: checking for regcmp in -lintl" >&5
+ac_lib_var=`echo intl'_'regcmp | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lintl $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1168 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char regcmp();
+
+int main() {
+regcmp()
+; return 0; }
+EOF
+if { (eval echo configure:1179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo intl | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lintl $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for regcmp in -lPW""... $ac_c" 1>&6
+echo "configure:1207: checking for regcmp in -lPW" >&5
+ac_lib_var=`echo PW'_'regcmp | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lPW $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1215 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char regcmp();
+
+int main() {
+regcmp()
+; return 0; }
+EOF
+if { (eval echo configure:1226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo PW | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lPW $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+echo $ac_n "checking for working terminal libraries""... $ac_c" 1>&6
+echo "configure:1255: checking for working terminal libraries" >&5
+TERMLIBS=
+
+curses_broken=0
+if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
+if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
+ curses_broken=1
+fi
+fi
+
+if test $curses_broken = 0; then
+if test "x$TERMLIBS" = x; then
+ if test $have_xcurses = yes; then
+ TERMLIBS="-lxcurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1272 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ if test $have_ncurses = yes; then
+ TERMLIBS="-lncurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1300 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ if test $have_curses = yes; then
+ TERMLIBS="-lcurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1328 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1335: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ if test $have_curses = yes; then
+ if test $have_termcap = yes; then
+ TERMLIBS="-lcurses -ltermcap"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1357 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+ fi
+fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ if test $have_termcap = yes; then
+ TERMLIBS="-ltermcap"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1387 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ if test $have_termlib = yes; then
+ TERMLIBS="-lcurses -ltermlib"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ cat > conftest.$ac_ext <<EOF
+#line 1415 "configure"
+#include "confdefs.h"
+
+int main() {
+tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:1422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ termok=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ termok=no
+fi
+rm -f conftest*
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ echo "$ac_t""Cannot find terminal libraries - configure failed" 1>&6
+ exit 1
+fi
+echo "$ac_t""using $TERMLIBS" 1>&6
+LIBS="$LIBS $TERMLIBS"
+
+
+for ac_hdr in ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1449: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1454 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1459: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1487: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1492 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1500: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1517 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1535 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1556 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:1591: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1596 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for void""... $ac_c" 1>&6
+echo "configure:1624: checking for void" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1626 "configure"
+#include "confdefs.h"
+
+int main() {
+void *foo = 0;
+; return 0; }
+EOF
+if { (eval echo configure:1633: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_VOID 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+echo $ac_n "checking for const""... $ac_c" 1>&6
+echo "configure:1647: checking for const" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1649 "configure"
+#include "confdefs.h"
+
+int main() {
+const int foo = 0;
+; return 0; }
+EOF
+if { (eval echo configure:1656: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_CONST 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+echo $ac_n "checking for time_t""... $ac_c" 1>&6
+echo "configure:1670: checking for time_t" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1672 "configure"
+#include "confdefs.h"
+#include <time.h>
+int main() {
+time_t t = 0;
+; return 0; }
+EOF
+if { (eval echo configure:1679: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_TIME_T 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+echo "configure:1694: checking return type of signal handlers" >&5
+if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1699 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
+int main() {
+int i;
+; return 0; }
+EOF
+if { (eval echo configure:1716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_type_signal=void
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_type_signal=int
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_type_signal" 1>&6
+cat >> confdefs.h <<EOF
+#define RETSIGTYPE $ac_cv_type_signal
+EOF
+
+
+for ac_func in memcpy popen _setjmp sigsetmask stat strchr strstr system
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1737: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1742 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking for tcgetattr""... $ac_c" 1>&6
+echo "configure:1791: checking for tcgetattr" >&5
+if eval "test \"`echo '$''{'ac_cv_func_tcgetattr'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1796 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char tcgetattr(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tcgetattr();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_tcgetattr) || defined (__stub___tcgetattr)
+choke me
+#else
+tcgetattr();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_tcgetattr=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_tcgetattr=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'tcgetattr`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_TERMIOS_FUNCS 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+echo $ac_n "checking for fileno""... $ac_c" 1>&6
+echo "configure:1843: checking for fileno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1845 "configure"
+#include "confdefs.h"
+
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+int main() {
+static int x; x = fileno(stdin);
+; return 0; }
+EOF
+if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_FILENO 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking for strerror""... $ac_c" 1>&6
+echo "configure:1870: checking for strerror" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1872 "configure"
+#include "confdefs.h"
+
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+int main() {
+static char *x; x = strerror(0);
+; return 0; }
+EOF
+if { (eval echo configure:1888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_STRERROR 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking for sys_errlist""... $ac_c" 1>&6
+echo "configure:1903: checking for sys_errlist" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1905 "configure"
+#include "confdefs.h"
+
+int main() {
+extern char *sys_errlist[]; static char **x; x = sys_errlist;
+; return 0; }
+EOF
+if { (eval echo configure:1912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_SYS_ERRLIST 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+have_errno=no
+echo $ac_n "checking for errno""... $ac_c" 1>&6
+echo "configure:1928: checking for errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1930 "configure"
+#include "confdefs.h"
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+int main() {
+static int x; x = errno;
+; return 0; }
+EOF
+if { (eval echo configure:1940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes - in errno.h" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_ERRNO 1
+EOF
+ have_errno=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test $have_errno = no; then
+cat > conftest.$ac_ext <<EOF
+#line 1953 "configure"
+#include "confdefs.h"
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+int main() {
+extern int errno; static int x; x = errno;
+; return 0; }
+EOF
+if { (eval echo configure:1963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes - must define" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_ERRNO 1
+EOF
+ cat >> confdefs.h <<\EOF
+#define MUST_DEFINE_ERRNO 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+fi
+
+echo $ac_n "checking for locale""... $ac_c" 1>&6
+echo "configure:1982: checking for locale" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1984 "configure"
+#include "confdefs.h"
+#include <locale.h>
+#include <ctype.h>
+int main() {
+setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);
+; return 0; }
+EOF
+if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_LOCALE 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+echo $ac_n "checking for ctype functions""... $ac_c" 1>&6
+echo "configure:2006: checking for ctype functions" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2008 "configure"
+#include "confdefs.h"
+
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+int main() {
+static int x; x = isupper(x); x = tolower(x); x = toupper(x);
+; return 0; }
+EOF
+if { (eval echo configure:2018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_UPPER_LOWER 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+have_ospeed=no
+echo $ac_n "checking termcap for ospeed""... $ac_c" 1>&6
+echo "configure:2034: checking termcap for ospeed" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2036 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#if HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+#if HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+int main() {
+ospeed = 0;
+; return 0; }
+EOF
+if { (eval echo configure:2050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes - in termcap.h" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_OSPEED 1
+EOF
+ have_ospeed=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test $have_ospeed = no; then
+cat > conftest.$ac_ext <<EOF
+#line 2063 "configure"
+#include "confdefs.h"
+
+int main() {
+extern short ospeed; ospeed = 0;
+; return 0; }
+EOF
+if { (eval echo configure:2070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""yes - must define" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_OSPEED 1
+EOF
+ cat >> confdefs.h <<\EOF
+#define MUST_DEFINE_OSPEED 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+fi
+
+have_regex=no
+have_posix_regex=unknown
+echo $ac_n "checking for regcomp""... $ac_c" 1>&6
+echo "configure:2091: checking for regcomp" >&5
+
+WANT_REGEX=auto
+# Check whether --with-regex or --without-regex was given.
+if test "${with_regex+set}" = set; then
+ withval="$with_regex"
+ WANT_REGEX="$withval"
+fi
+
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
+if test "$cross_compiling" = yes; then
+ have_posix_regex=unknown
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2107 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <regex.h>
+main() { regex_t r; regmatch_t rm; char *text = "xabcy";
+if (regcomp(&r, "abc", 0)) exit(1);
+if (regexec(&r, text, 1, &rm, 0)) exit(1);
+#ifndef __WATCOMC__
+if (rm.rm_so != 1) exit(1); /* check for correct offset */
+#else
+if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
+#endif
+exit(0); }
+EOF
+if { (eval echo configure:2122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ have_posix_regex=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ have_posix_regex=no
+fi
+rm -fr conftest*
+fi
+
+if test $have_posix_regex = yes; then
+ echo "$ac_t""using POSIX regcomp" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_POSIX_REGCOMP 1
+EOF
+
+ have_regex=yes
+elif test $have_posix_regex = unknown; then
+ cat > conftest.$ac_ext <<EOF
+#line 2143 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <regex.h>
+int main() {
+regex_t *r; regfree(r);
+; return 0; }
+EOF
+if { (eval echo configure:2152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""using POSIX regcomp" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_POSIX_REGCOMP 1
+EOF
+ have_regex=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+else
+ echo "$ac_t""no" 1>&6
+fi
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
+echo $ac_n "checking for pcre_compile in -lpcre""... $ac_c" 1>&6
+echo "configure:2173: checking for pcre_compile in -lpcre" >&5
+ac_lib_var=`echo pcre'_'pcre_compile | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lpcre $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2181 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pcre_compile();
+
+int main() {
+pcre_compile()
+; return 0; }
+EOF
+if { (eval echo configure:2192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo "$ac_t""using pcre" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_PCRE 1
+EOF
+ LIBS="$LIBS -lpcre" have_regex=yes
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
+echo $ac_n "checking for regcmp""... $ac_c" 1>&6
+echo "configure:2221: checking for regcmp" >&5
+if eval "test \"`echo '$''{'ac_cv_func_regcmp'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2226 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char regcmp(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char regcmp();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_regcmp) || defined (__stub___regcmp)
+choke me
+#else
+regcmp();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_regcmp=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_regcmp=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'regcmp`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo "$ac_t""using regcmp" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_REGCMP 1
+EOF
+ have_regex=yes
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
+cat > conftest.$ac_ext <<EOF
+#line 2277 "configure"
+#include "confdefs.h"
+
+#include "regexp.h"
+int main() {
+regcomp("");
+; return 0; }
+EOF
+if { (eval echo configure:2285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ echo "$ac_t""using V8 regcomp" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_V8_REGCOMP 1
+EOF
+ have_regex=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+fi
+fi
+
+if test $have_regex = no && test -f ${srcdir}/regexp.c; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
+echo "$ac_t""using V8 regcomp -- local source" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_V8_REGCOMP 1
+EOF
+ cat >> confdefs.h <<\EOF
+#define HAVE_REGEXEC2 1
+EOF
+ REGEX_O='regexp.$(O)' have_regex=yes
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
+echo "$ac_t""using re_comp" 1>&6; echo $ac_n "checking for re_comp""... $ac_c" 1>&6
+echo "configure:2314: checking for re_comp" >&5
+if eval "test \"`echo '$''{'ac_cv_func_re_comp'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2319 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char re_comp(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char re_comp();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_re_comp) || defined (__stub___re_comp)
+choke me
+#else
+re_comp();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_re_comp=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_re_comp=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'re_comp`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_RE_COMP 1
+EOF
+ have_regex=yes
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+fi
+
+if test $have_regex = no; then
+echo "$ac_t""cannot find regular expression library" 1>&6; cat >> confdefs.h <<\EOF
+#define NO_REGEX 1
+EOF
+
+fi
+
+# Check whether --with-editor or --without-editor was given.
+if test "${with_editor+set}" = set; then
+ withval="$with_editor"
+ cat >> confdefs.h <<EOF
+#define EDIT_PGM "$withval"
+EOF
+
+fi
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile defines.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@CPP@%$CPP%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@REGEX_O@%$REGEX_O%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="defines.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/contrib/less/configure.in b/contrib/less/configure.in
new file mode 100644
index 000000000000..28936d5c5e75
--- /dev/null
+++ b/contrib/less/configure.in
@@ -0,0 +1,302 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(forwback.c)
+AC_CONFIG_HEADER(defines.h)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_ISC_POSIX
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_INSTALL
+
+dnl Checks for libraries.
+AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
+AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
+AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
+AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
+AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
+dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
+dnl and in -lintl on SCO Unix.
+AC_CHECK_LIB(gen, regcmp)
+AC_CHECK_LIB(intl, regcmp)
+AC_CHECK_LIB(PW, regcmp)
+dnl Checks for terminal libraries
+
+AC_MSG_CHECKING(for working terminal libraries)
+TERMLIBS=
+
+dnl Check for systems where curses is broken.
+curses_broken=0
+if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
+if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
+ curses_broken=1
+fi
+fi
+
+if test $curses_broken = 0; then
+dnl -- Try xcurses.
+if test "x$TERMLIBS" = x; then
+ if test $have_xcurses = yes; then
+ TERMLIBS="-lxcurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+dnl -- Try ncurses.
+if test "x$TERMLIBS" = x; then
+ if test $have_ncurses = yes; then
+ TERMLIBS="-lncurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+dnl -- Try curses.
+if test "x$TERMLIBS" = x; then
+ if test $have_curses = yes; then
+ TERMLIBS="-lcurses"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+dnl -- Try curses & termcap.
+if test "x$TERMLIBS" = x; then
+ if test $have_curses = yes; then
+ if test $have_termcap = yes; then
+ TERMLIBS="-lcurses -ltermcap"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+ fi
+fi
+fi
+
+dnl -- Try termcap.
+if test "x$TERMLIBS" = x; then
+ if test $have_termcap = yes; then
+ TERMLIBS="-ltermcap"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+dnl -- Try termlib.
+if test "x$TERMLIBS" = x; then
+ if test $have_termlib = yes; then
+ TERMLIBS="-lcurses -ltermlib"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
+if test "x$TERMLIBS" = x; then
+ AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
+ exit 1
+fi
+AC_MSG_RESULT(using $TERMLIBS)
+LIBS="$LIBS $TERMLIBS"
+
+
+dnl Checks for header files.
+AC_CHECK_HEADERS(ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)
+
+dnl Checks for identifiers.
+AC_TYPE_OFF_T
+AC_MSG_CHECKING(for void)
+AC_TRY_COMPILE(, [void *foo = 0;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
+AC_MSG_CHECKING(for const)
+AC_TRY_COMPILE(, [const int foo = 0;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
+AC_MSG_CHECKING(for time_t)
+AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
+
+dnl Checks for functions and external variables.
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS(memcpy popen _setjmp sigsetmask stat strchr strstr system)
+
+dnl Some systems have termios.h but not the corresponding functions.
+AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
+
+AC_MSG_CHECKING(for fileno)
+AC_TRY_LINK([
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif], [static int x; x = fileno(stdin);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for strerror)
+AC_TRY_LINK([
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif], [static char *x; x = strerror(0);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for sys_errlist)
+AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
+
+have_errno=no
+AC_MSG_CHECKING(for errno)
+AC_TRY_LINK([
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif], [static int x; x = errno;],
+ [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
+if test $have_errno = no; then
+AC_TRY_LINK([
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif], [extern int errno; static int x; x = errno;],
+ [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
+ [AC_MSG_RESULT(no)])
+fi
+
+AC_MSG_CHECKING(for locale)
+AC_TRY_LINK([#include <locale.h>
+#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
+AC_MSG_CHECKING(for ctype functions)
+AC_TRY_LINK([
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
+
+dnl Checks for external variable ospeed in the termcap library.
+have_ospeed=no
+AC_MSG_CHECKING(termcap for ospeed)
+AC_TRY_LINK([
+#include <sys/types.h>
+#if HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+#if HAVE_TERMCAP_H
+#include <termcap.h>
+#endif], [ospeed = 0;],
+[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
+if test $have_ospeed = no; then
+AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
+ [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
+ [AC_MSG_RESULT(no)])
+fi
+
+dnl Checks for regular expression functions.
+have_regex=no
+have_posix_regex=unknown
+AC_MSG_CHECKING(for regcomp)
+
+WANT_REGEX=auto
+AC_ARG_WITH(regex,
+ [ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
+ WANT_REGEX="$withval")
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
+dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
+dnl So we run a test program. If we're cross-compiling, do it the old way.
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <regex.h>
+main() { regex_t r; regmatch_t rm; char *text = "xabcy";
+if (regcomp(&r, "abc", 0)) exit(1);
+if (regexec(&r, text, 1, &rm, 0)) exit(1);
+#ifndef __WATCOMC__
+if (rm.rm_so != 1) exit(1); /* check for correct offset */
+#else
+if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
+#endif
+exit(0); }],
+ have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
+if test $have_posix_regex = yes; then
+ AC_MSG_RESULT(using POSIX regcomp)
+ AC_DEFINE(HAVE_POSIX_REGCOMP)
+ have_regex=yes
+elif test $have_posix_regex = unknown; then
+ AC_TRY_LINK([
+#include <sys/types.h>
+#include <regex.h>],
+ [regex_t *r; regfree(r);],
+ AC_MSG_RESULT(using POSIX regcomp)
+ AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
+else
+ AC_MSG_RESULT(no)
+fi
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
+AC_CHECK_LIB(pcre, pcre_compile,
+[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
+AC_CHECK_FUNC(regcmp,
+AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
+AC_TRY_LINK([
+#include "regexp.h"], [regcomp("");],
+AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
+fi
+fi
+
+if test $have_regex = no && test -f ${srcdir}/regexp.c; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
+AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
+fi
+fi
+
+if test $have_regex = no; then
+if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
+AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
+fi
+fi
+
+if test $have_regex = no; then
+AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
+fi
+
+AC_ARG_WITH(editor,
+ [ --with-editor=PROGRAM use PROGRAM as the default editor [vi]],
+ AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"))
+
+AC_OUTPUT(Makefile)
diff --git a/contrib/less/decode.c b/contrib/less/decode.c
new file mode 100644
index 000000000000..7fb03dfeb7d7
--- /dev/null
+++ b/contrib/less/decode.c
@@ -0,0 +1,817 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to decode user commands.
+ *
+ * This is all table driven.
+ * A command table is a sequence of command descriptors.
+ * Each command descriptor is a sequence of bytes with the following format:
+ * <c1><c2>...<cN><0><action>
+ * The characters c1,c2,...,cN are the command string; that is,
+ * the characters which the user must type.
+ * It is terminated by a null <0> byte.
+ * The byte after the null byte is the action code associated
+ * with the command string.
+ * If an action byte is OR-ed with A_EXTRA, this indicates
+ * that the option byte is followed by an extra string.
+ *
+ * There may be many command tables.
+ * The first (default) table is built-in.
+ * Other tables are read in from "lesskey" files.
+ * All the tables are linked together and are searched in order.
+ */
+
+#include "less.h"
+#include "cmd.h"
+#include "lesskey.h"
+
+extern int erase_char, kill_char;
+extern int secure;
+
+#define SK(k) \
+ SK_SPECIAL_KEY, (k), 6, 1, 1, 1
+/*
+ * Command table is ordered roughly according to expected
+ * frequency of use, so the common commands are near the beginning.
+ */
+
+static unsigned char cmdtable[] =
+{
+ '\r',0, A_F_LINE,
+ '\n',0, A_F_LINE,
+ 'e',0, A_F_LINE,
+ 'j',0, A_F_LINE,
+ SK(SK_DOWN_ARROW),0, A_F_LINE,
+ CONTROL('E'),0, A_F_LINE,
+ CONTROL('N'),0, A_F_LINE,
+ 'k',0, A_B_LINE,
+ 'y',0, A_B_LINE,
+ CONTROL('Y'),0, A_B_LINE,
+ SK(SK_CONTROL_K),0, A_B_LINE,
+ CONTROL('P'),0, A_B_LINE,
+ SK(SK_UP_ARROW),0, A_B_LINE,
+ 'J',0, A_FF_LINE,
+ 'K',0, A_BF_LINE,
+ 'Y',0, A_BF_LINE,
+ 'd',0, A_F_SCROLL,
+ CONTROL('D'),0, A_F_SCROLL,
+ 'u',0, A_B_SCROLL,
+ CONTROL('U'),0, A_B_SCROLL,
+ ' ',0, A_F_SCREEN,
+ 'f',0, A_F_SCREEN,
+ CONTROL('F'),0, A_F_SCREEN,
+ CONTROL('V'),0, A_F_SCREEN,
+ SK(SK_PAGE_DOWN),0, A_F_SCREEN,
+ 'b',0, A_B_SCREEN,
+ CONTROL('B'),0, A_B_SCREEN,
+ ESC,'v',0, A_B_SCREEN,
+ SK(SK_PAGE_UP),0, A_B_SCREEN,
+ 'z',0, A_F_WINDOW,
+ 'w',0, A_B_WINDOW,
+ ESC,' ',0, A_FF_SCREEN,
+ 'F',0, A_F_FOREVER,
+ 'R',0, A_FREPAINT,
+ 'r',0, A_REPAINT,
+ CONTROL('R'),0, A_REPAINT,
+ CONTROL('L'),0, A_REPAINT,
+ ESC,'u',0, A_UNDO_SEARCH,
+ 'g',0, A_GOLINE,
+ SK(SK_HOME),0, A_GOLINE,
+ '<',0, A_GOLINE,
+ ESC,'<',0, A_GOLINE,
+ 'p',0, A_PERCENT,
+ '%',0, A_PERCENT,
+ ESC,'[',0, A_LSHIFT,
+ ESC,']',0, A_RSHIFT,
+ ESC,'(',0, A_LSHIFT,
+ ESC,')',0, A_RSHIFT,
+ SK(SK_RIGHT_ARROW),0, A_RSHIFT,
+ SK(SK_LEFT_ARROW),0, A_LSHIFT,
+ '{',0, A_F_BRACKET|A_EXTRA, '{','}',0,
+ '}',0, A_B_BRACKET|A_EXTRA, '{','}',0,
+ '(',0, A_F_BRACKET|A_EXTRA, '(',')',0,
+ ')',0, A_B_BRACKET|A_EXTRA, '(',')',0,
+ '[',0, A_F_BRACKET|A_EXTRA, '[',']',0,
+ ']',0, A_B_BRACKET|A_EXTRA, '[',']',0,
+ ESC,CONTROL('F'),0, A_F_BRACKET,
+ ESC,CONTROL('B'),0, A_B_BRACKET,
+ 'G',0, A_GOEND,
+ ESC,'>',0, A_GOEND,
+ '>',0, A_GOEND,
+ SK(SK_END),0, A_GOEND,
+ 'P',0, A_GOPOS,
+
+ '0',0, A_DIGIT,
+ '1',0, A_DIGIT,
+ '2',0, A_DIGIT,
+ '3',0, A_DIGIT,
+ '4',0, A_DIGIT,
+ '5',0, A_DIGIT,
+ '6',0, A_DIGIT,
+ '7',0, A_DIGIT,
+ '8',0, A_DIGIT,
+ '9',0, A_DIGIT,
+
+ '=',0, A_STAT,
+ CONTROL('G'),0, A_STAT,
+ ':','f',0, A_STAT,
+ '/',0, A_F_SEARCH,
+ '?',0, A_B_SEARCH,
+ ESC,'/',0, A_F_SEARCH|A_EXTRA, '*',0,
+ ESC,'?',0, A_B_SEARCH|A_EXTRA, '*',0,
+ 'n',0, A_AGAIN_SEARCH,
+ ESC,'n',0, A_T_AGAIN_SEARCH,
+ 'N',0, A_REVERSE_SEARCH,
+ ESC,'N',0, A_T_REVERSE_SEARCH,
+ 'm',0, A_SETMARK,
+ '\'',0, A_GOMARK,
+ CONTROL('X'),CONTROL('X'),0, A_GOMARK,
+ 'E',0, A_EXAMINE,
+ ':','e',0, A_EXAMINE,
+ CONTROL('X'),CONTROL('V'),0, A_EXAMINE,
+ ':','n',0, A_NEXT_FILE,
+ ':','p',0, A_PREV_FILE,
+ ':','x',0, A_INDEX_FILE,
+ ':','d',0, A_REMOVE_FILE,
+ '-',0, A_OPT_TOGGLE,
+ ':','t',0, A_OPT_TOGGLE|A_EXTRA, 't',0,
+ 's',0, A_OPT_TOGGLE|A_EXTRA, 'o',0,
+ '_',0, A_DISP_OPTION,
+ '|',0, A_PIPE,
+ 'v',0, A_VISUAL,
+ '!',0, A_SHELL,
+ '+',0, A_FIRSTCMD,
+
+ 'H',0, A_HELP,
+ 'h',0, A_HELP,
+ SK(SK_F1),0, A_HELP,
+ 'V',0, A_VERSION,
+ 'q',0, A_QUIT,
+ 'Q',0, A_QUIT,
+ ':','q',0, A_QUIT,
+ ':','Q',0, A_QUIT,
+ 'Z','Z',0, A_QUIT
+};
+
+static unsigned char edittable[] =
+{
+ '\t',0, EC_F_COMPLETE, /* TAB */
+ '\17',0, EC_B_COMPLETE, /* BACKTAB */
+ SK(SK_BACKTAB),0, EC_B_COMPLETE, /* BACKTAB */
+ ESC,'\t',0, EC_B_COMPLETE, /* ESC TAB */
+ CONTROL('L'),0, EC_EXPAND, /* CTRL-L */
+ CONTROL('V'),0, EC_LITERAL, /* BACKSLASH */
+ CONTROL('A'),0, EC_LITERAL, /* BACKSLASH */
+ ESC,'l',0, EC_RIGHT, /* ESC l */
+ SK(SK_RIGHT_ARROW),0, EC_RIGHT, /* RIGHTARROW */
+ ESC,'h',0, EC_LEFT, /* ESC h */
+ SK(SK_LEFT_ARROW),0, EC_LEFT, /* LEFTARROW */
+ ESC,'b',0, EC_W_LEFT, /* ESC b */
+ ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
+ SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
+ ESC,'w',0, EC_W_RIGHT, /* ESC w */
+ ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
+ SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */
+ ESC,'i',0, EC_INSERT, /* ESC i */
+ SK(SK_INSERT),0, EC_INSERT, /* INSERT */
+ ESC,'x',0, EC_DELETE, /* ESC x */
+ SK(SK_DELETE),0, EC_DELETE, /* DELETE */
+ ESC,'X',0, EC_W_DELETE, /* ESC X */
+ ESC,SK(SK_DELETE),0, EC_W_DELETE, /* ESC DELETE */
+ SK(SK_CTL_DELETE),0, EC_W_DELETE, /* CTRL-DELETE */
+ SK(SK_CTL_BACKSPACE),0, EC_W_BACKSPACE, /* CTRL-BACKSPACE */
+ ESC,'\b',0, EC_W_BACKSPACE, /* ESC BACKSPACE */
+ ESC,'0',0, EC_HOME, /* ESC 0 */
+ SK(SK_HOME),0, EC_HOME, /* HOME */
+ ESC,'$',0, EC_END, /* ESC $ */
+ SK(SK_END),0, EC_END, /* END */
+ ESC,'k',0, EC_UP, /* ESC k */
+ SK(SK_UP_ARROW),0, EC_UP, /* UPARROW */
+ ESC,'j',0, EC_DOWN, /* ESC j */
+ SK(SK_DOWN_ARROW),0, EC_DOWN, /* DOWNARROW */
+};
+
+/*
+ * Structure to support a list of command tables.
+ */
+struct tablelist
+{
+ struct tablelist *t_next;
+ char *t_start;
+ char *t_end;
+};
+
+/*
+ * List of command tables and list of line-edit tables.
+ */
+static struct tablelist *list_fcmd_tables = NULL;
+static struct tablelist *list_ecmd_tables = NULL;
+static struct tablelist *list_var_tables = NULL;
+static struct tablelist *list_sysvar_tables = NULL;
+
+
+/*
+ * Expand special key abbreviations in a command table.
+ */
+ static void
+expand_special_keys(table, len)
+ char *table;
+ int len;
+{
+ register char *fm;
+ register char *to;
+ register int a;
+ char *repl;
+ int klen;
+
+ for (fm = table; fm < table + len; )
+ {
+ /*
+ * Rewrite each command in the table with any
+ * special key abbreviations expanded.
+ */
+ for (to = fm; *fm != '\0'; )
+ {
+ if (*fm != SK_SPECIAL_KEY)
+ {
+ *to++ = *fm++;
+ continue;
+ }
+ /*
+ * After SK_SPECIAL_KEY, next byte is the type
+ * of special key (one of the SK_* contants),
+ * and the byte after that is the number of bytes,
+ * N, reserved by the abbreviation (including the
+ * SK_SPECIAL_KEY and key type bytes).
+ * Replace all N bytes with the actual bytes
+ * output by the special key on this terminal.
+ */
+ repl = special_key_str(fm[1]);
+ klen = fm[2] & 0377;
+ fm += klen;
+ if (repl == NULL || strlen(repl) > klen)
+ repl = "\377";
+ while (*repl != '\0')
+ *to++ = *repl++;
+ }
+ *to++ = '\0';
+ /*
+ * Fill any unused bytes between end of command and
+ * the action byte with A_SKIP.
+ */
+ while (to <= fm)
+ *to++ = A_SKIP;
+ fm++;
+ a = *fm++ & 0377;
+ if (a & A_EXTRA)
+ {
+ while (*fm++ != '\0')
+ continue;
+ }
+ }
+}
+
+/*
+ * Initialize the command lists.
+ */
+ public void
+init_cmds()
+{
+ /*
+ * Add the default command tables.
+ */
+ add_fcmd_table((char*)cmdtable, sizeof(cmdtable));
+ add_ecmd_table((char*)edittable, sizeof(edittable));
+#if USERFILE
+ /*
+ * Try to add the tables in the system lesskey file.
+ */
+ add_hometable("LESSKEY_SYSTEM", LESSKEYFILE_SYS, 1);
+ /*
+ * Try to add the tables in the standard lesskey file "$HOME/.less".
+ */
+ add_hometable("LESSKEY", LESSKEYFILE, 0);
+#endif
+}
+
+/*
+ * Add a command table.
+ */
+ static int
+add_cmd_table(tlist, buf, len)
+ struct tablelist **tlist;
+ char *buf;
+ int len;
+{
+ register struct tablelist *t;
+
+ if (len == 0)
+ return (0);
+ /*
+ * Allocate a tablelist structure, initialize it,
+ * and link it into the list of tables.
+ */
+ if ((t = (struct tablelist *)
+ calloc(1, sizeof(struct tablelist))) == NULL)
+ {
+ return (-1);
+ }
+ expand_special_keys(buf, len);
+ t->t_start = buf;
+ t->t_end = buf + len;
+ t->t_next = *tlist;
+ *tlist = t;
+ return (0);
+}
+
+/*
+ * Add a command table.
+ */
+ public void
+add_fcmd_table(buf, len)
+ char *buf;
+ int len;
+{
+ if (add_cmd_table(&list_fcmd_tables, buf, len) < 0)
+ error("Warning: some commands disabled", NULL_PARG);
+}
+
+/*
+ * Add an editing command table.
+ */
+ public void
+add_ecmd_table(buf, len)
+ char *buf;
+ int len;
+{
+ if (add_cmd_table(&list_ecmd_tables, buf, len) < 0)
+ error("Warning: some edit commands disabled", NULL_PARG);
+}
+
+/*
+ * Add an environment variable table.
+ */
+ static void
+add_var_table(tlist, buf, len)
+ struct tablelist **tlist;
+ char *buf;
+ int len;
+{
+ if (add_cmd_table(tlist, buf, len) < 0)
+ error("Warning: environment variables from lesskey file unavailable", NULL_PARG);
+}
+
+/*
+ * Search a single command table for the command string in cmd.
+ */
+ public int
+cmd_search(cmd, table, endtable, sp)
+ char *cmd;
+ char *table;
+ char *endtable;
+ char **sp;
+{
+ register char *p;
+ register char *q;
+ register int a;
+
+ for (p = table, q = cmd; p < endtable; p++, q++)
+ {
+ if (*p == *q)
+ {
+ /*
+ * Current characters match.
+ * If we're at the end of the string, we've found it.
+ * Return the action code, which is the character
+ * after the null at the end of the string
+ * in the command table.
+ */
+ if (*p == '\0')
+ {
+ a = *++p & 0377;
+ while (a == A_SKIP)
+ a = *++p & 0377;
+ if (a == A_END_LIST)
+ {
+ /*
+ * We get here only if the original
+ * cmd string passed in was empty ("").
+ * I don't think that can happen,
+ * but just in case ...
+ */
+ return (A_UINVALID);
+ }
+ /*
+ * Check for an "extra" string.
+ */
+ if (a & A_EXTRA)
+ {
+ *sp = ++p;
+ a &= ~A_EXTRA;
+ } else
+ *sp = NULL;
+ return (a);
+ }
+ } else if (*q == '\0')
+ {
+ /*
+ * Hit the end of the user's command,
+ * but not the end of the string in the command table.
+ * The user's command is incomplete.
+ */
+ return (A_PREFIX);
+ } else
+ {
+ /*
+ * Not a match.
+ * Skip ahead to the next command in the
+ * command table, and reset the pointer
+ * to the beginning of the user's command.
+ */
+ if (*p == '\0' && p[1] == A_END_LIST)
+ {
+ /*
+ * A_END_LIST is a special marker that tells
+ * us to abort the cmd search.
+ */
+ return (A_UINVALID);
+ }
+ while (*p++ != '\0')
+ continue;
+ while (*p == A_SKIP)
+ p++;
+ if (*p & A_EXTRA)
+ while (*++p != '\0')
+ continue;
+ q = cmd-1;
+ }
+ }
+ /*
+ * No match found in the entire command table.
+ */
+ return (A_INVALID);
+}
+
+/*
+ * Decode a command character and return the associated action.
+ * The "extra" string, if any, is returned in sp.
+ */
+ static int
+cmd_decode(tlist, cmd, sp)
+ struct tablelist *tlist;
+ char *cmd;
+ char **sp;
+{
+ register struct tablelist *t;
+ register int action = A_INVALID;
+
+ /*
+ * Search thru all the command tables.
+ * Stop when we find an action which is not A_INVALID.
+ */
+ for (t = tlist; t != NULL; t = t->t_next)
+ {
+ action = cmd_search(cmd, t->t_start, t->t_end, sp);
+ if (action != A_INVALID)
+ break;
+ }
+ return (action);
+}
+
+/*
+ * Decode a command from the cmdtables list.
+ */
+ public int
+fcmd_decode(cmd, sp)
+ char *cmd;
+ char **sp;
+{
+ return (cmd_decode(list_fcmd_tables, cmd, sp));
+}
+
+/*
+ * Decode a command from the edittables list.
+ */
+ public int
+ecmd_decode(cmd, sp)
+ char *cmd;
+ char **sp;
+{
+ return (cmd_decode(list_ecmd_tables, cmd, sp));
+}
+
+/*
+ * Get the value of an environment variable.
+ * Looks first in the lesskey file, then in the real environment.
+ */
+ public char *
+lgetenv(var)
+ char *var;
+{
+ int a;
+ char *s;
+
+ a = cmd_decode(list_var_tables, var, &s);
+ if (a == EV_OK)
+ return (s);
+ s = getenv(var);
+ if (s != NULL && *s != '\0')
+ return (s);
+ a = cmd_decode(list_sysvar_tables, var, &s);
+ if (a == EV_OK)
+ return (s);
+ return (NULL);
+}
+
+#if USERFILE
+/*
+ * Get an "integer" from a lesskey file.
+ * Integers are stored in a funny format:
+ * two bytes, low order first, in radix KRADIX.
+ */
+ static int
+gint(sp)
+ char **sp;
+{
+ int n;
+
+ n = *(*sp)++;
+ n += *(*sp)++ * KRADIX;
+ return (n);
+}
+
+/*
+ * Process an old (pre-v241) lesskey file.
+ */
+ static int
+old_lesskey(buf, len)
+ char *buf;
+ int len;
+{
+ /*
+ * Old-style lesskey file.
+ * The file must end with either
+ * ...,cmd,0,action
+ * or ...,cmd,0,action|A_EXTRA,string,0
+ * So the last byte or the second to last byte must be zero.
+ */
+ if (buf[len-1] != '\0' && buf[len-2] != '\0')
+ return (-1);
+ add_fcmd_table(buf, len);
+ return (0);
+}
+
+/*
+ * Process a new (post-v241) lesskey file.
+ */
+ static int
+new_lesskey(buf, len, sysvar)
+ char *buf;
+ int len;
+ int sysvar;
+{
+ char *p;
+ register int c;
+ register int n;
+
+ /*
+ * New-style lesskey file.
+ * Extract the pieces.
+ */
+ if (buf[len-3] != C0_END_LESSKEY_MAGIC ||
+ buf[len-2] != C1_END_LESSKEY_MAGIC ||
+ buf[len-1] != C2_END_LESSKEY_MAGIC)
+ return (-1);
+ p = buf + 4;
+ for (;;)
+ {
+ c = *p++;
+ switch (c)
+ {
+ case CMD_SECTION:
+ n = gint(&p);
+ add_fcmd_table(p, n);
+ p += n;
+ break;
+ case EDIT_SECTION:
+ n = gint(&p);
+ add_ecmd_table(p, n);
+ p += n;
+ break;
+ case VAR_SECTION:
+ n = gint(&p);
+ add_var_table((sysvar) ?
+ &list_sysvar_tables : &list_var_tables, p, n);
+ p += n;
+ break;
+ case END_SECTION:
+ return (0);
+ default:
+ /*
+ * Unrecognized section type.
+ */
+ return (-1);
+ }
+ }
+}
+
+/*
+ * Set up a user command table, based on a "lesskey" file.
+ */
+ public int
+lesskey(filename, sysvar)
+ char *filename;
+ int sysvar;
+{
+ register char *buf;
+ register POSITION len;
+ register long n;
+ register int f;
+
+ if (secure)
+ return (1);
+ /*
+ * Try to open the lesskey file.
+ */
+ filename = unquote_file(filename);
+ f = open(filename, OPEN_READ);
+ free(filename);
+ if (f < 0)
+ return (1);
+
+ /*
+ * Read the file into a buffer.
+ * We first figure out the size of the file and allocate space for it.
+ * {{ Minimal error checking is done here.
+ * A garbage .less file will produce strange results.
+ * To avoid a large amount of error checking code here, we
+ * rely on the lesskey program to generate a good .less file. }}
+ */
+ len = filesize(f);
+ if (len == NULL_POSITION || len < 3)
+ {
+ /*
+ * Bad file (valid file must have at least 3 chars).
+ */
+ close(f);
+ return (-1);
+ }
+ if ((buf = (char *) calloc((int)len, sizeof(char))) == NULL)
+ {
+ close(f);
+ return (-1);
+ }
+ if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
+ {
+ free(buf);
+ close(f);
+ return (-1);
+ }
+ n = read(f, buf, (unsigned int) len);
+ close(f);
+ if (n != len)
+ {
+ free(buf);
+ return (-1);
+ }
+
+ /*
+ * Figure out if this is an old-style (before version 241)
+ * or new-style lesskey file format.
+ */
+ if (buf[0] != C0_LESSKEY_MAGIC || buf[1] != C1_LESSKEY_MAGIC ||
+ buf[2] != C2_LESSKEY_MAGIC || buf[3] != C3_LESSKEY_MAGIC)
+ return (old_lesskey(buf, (int)len));
+ return (new_lesskey(buf, (int)len, sysvar));
+}
+
+/*
+ * Add the standard lesskey file "$HOME/.less"
+ */
+ public void
+add_hometable(envname, def_filename, sysvar)
+ char *envname;
+ char *def_filename;
+ int sysvar;
+{
+ char *filename;
+ PARG parg;
+
+ if ((filename = lgetenv(envname)) != NULL)
+ filename = save(filename);
+ else if (sysvar)
+ filename = save(def_filename);
+ else
+ filename = homefile(def_filename);
+ if (filename == NULL)
+ return;
+ if (lesskey(filename, sysvar) < 0)
+ {
+ parg.p_string = filename;
+ error("Cannot use lesskey file \"%s\"", &parg);
+ }
+ free(filename);
+}
+#endif
+
+/*
+ * See if a char is a special line-editing command.
+ */
+ public int
+editchar(c, flags)
+ int c;
+ int flags;
+{
+ int action;
+ int nch;
+ char *s;
+ char usercmd[MAX_CMDLEN+1];
+
+ /*
+ * An editing character could actually be a sequence of characters;
+ * for example, an escape sequence sent by pressing the uparrow key.
+ * To match the editing string, we use the command decoder
+ * but give it the edit-commands command table
+ * This table is constructed to match the user's keyboard.
+ */
+ if (c == erase_char)
+ return (EC_BACKSPACE);
+ if (c == kill_char)
+ return (EC_LINEKILL);
+
+ /*
+ * Collect characters in a buffer.
+ * Start with the one we have, and get more if we need them.
+ */
+ nch = 0;
+ do {
+ if (nch > 0)
+ c = getcc();
+ usercmd[nch] = c;
+ usercmd[nch+1] = '\0';
+ nch++;
+ action = ecmd_decode(usercmd, &s);
+ } while (action == A_PREFIX);
+
+#if CMD_HISTORY
+ if (flags & EC_NOHISTORY)
+ {
+ /*
+ * The caller says there is no history list.
+ * Reject any history-manipulation action.
+ */
+ switch (action)
+ {
+ case EC_UP:
+ case EC_DOWN:
+ action = A_INVALID;
+ break;
+ }
+ }
+#endif
+#if TAB_COMPLETE_FILENAME
+ if (flags & EC_NOCOMPLETE)
+ {
+ /*
+ * The caller says we don't want any filename completion cmds.
+ * Reject them.
+ */
+ switch (action)
+ {
+ case EC_F_COMPLETE:
+ case EC_B_COMPLETE:
+ case EC_EXPAND:
+ action = A_INVALID;
+ break;
+ }
+ }
+#endif
+ if ((flags & EC_PEEK) || action == A_INVALID)
+ {
+ /*
+ * We're just peeking, or we didn't understand the command.
+ * Unget all the characters we read in the loop above.
+ * This does NOT include the original character that was
+ * passed in as a parameter.
+ */
+ while (nch > 1)
+ {
+ ungetcc(usercmd[--nch]);
+ }
+ } else
+ {
+ if (s != NULL)
+ ungetsc(s);
+ }
+ return action;
+}
+
diff --git a/contrib/less/defines.ds b/contrib/less/defines.ds
new file mode 100644
index 000000000000..08b2cb448ecc
--- /dev/null
+++ b/contrib/less/defines.ds
@@ -0,0 +1,377 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/* DOS definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for MS-DOS systems.
+ */
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+#define EDIT_PGM "vi"
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#ifdef __DJGPP__
+#define GLOB (!SECURE)
+#else
+#define GLOB 0
+#endif
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#ifdef __DJGPP__
+#define PIPEC (!SECURE)
+#else
+#define PIPEC 0
+#endif
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "_less"
+#define LESSKEYFILE_SYS "c:\\_sysless"
+#define DEF_LESSKEYINFILE "_lesskey"
+
+
+/* Settings always true for MS-DOS systems. */
+
+/*
+ * Define MSDOS_COMPILER if compiling for MS-DOS.
+ */
+#ifdef __DJGPP__
+#define MSDOS_COMPILER DJGPPC
+#else
+#ifdef __BORLANDC__
+#define MSDOS_COMPILER BORLANDC
+#else
+#define MSDOS_COMPILER MSOFTC
+#endif
+#endif
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "\\"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define HAVE_PERROR 1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 0
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#if MSDOS_COMPILER==BORLANDC
+#define off_t long
+#endif
+
+/* Define if you need to in order for stat and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+/* #undef HAVE_POSIX_REGCOMP */
+/* #undef HAVE_RE_COMP */
+/* #undef HAVE_REGCMP */
+/* #undef HAVE_V8_REGCOMP */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_POSIX_REGCOMP 1
+#else
+#define NO_REGEX 1
+#endif
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined
+ * in errno.h */
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 0
+#else
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 1
+#endif
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define HAVE_OSPEED 0
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 1
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
+#define HAVE__SETJMP 0
+#else
+#define HAVE__SETJMP 1
+#endif
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_POPEN 1
+#else
+#define HAVE_POPEN 0
+#endif
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_UNISTD_H 1
+#else
+#define HAVE_UNISTD_H 0
+#endif
+
+/* Define if you have the <values.h> header file. */
+#if MSDOS_COMPILER==MSOFTC
+#define HAVE_VALUES_H 0
+#else
+#define HAVE_VALUES_H 1
+#endif
+
+#if MSDOS_COMPILER == MSOFTC && _MSC_VER >= 700
+/*
+ * The names of these things changed in Microsoft C version 7.0.
+ */
+#define videoconfig _videoconfig
+#define rccoord _rccoord
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_APPEND _O_APPEND
+#define O_BINARY _O_BINARY
+#define O_TEXT _O_TEXT
+#define find_t _find_t
+#define stat _stat
+#define S_IFMT _S_IFMT
+#define S_IFDIR _S_IFDIR
+#define S_IFREG _S_IFREG
+#define dup _dup
+#define open _open
+#define lseek _lseek
+#define write _write
+#define creat _creat
+#define fstat _fstat
+#define isatty _isatty
+#define close _close
+#define read _read
+#define ungetch _ungetch
+#define kbhit _kbhit
+#define getch _getch
+#endif
diff --git a/contrib/less/defines.h.in b/contrib/less/defines.h.in
new file mode 100644
index 000000000000..70ec1c2c19ed
--- /dev/null
+++ b/contrib/less/defines.h.in
@@ -0,0 +1,326 @@
+/* defines.h.in. Generated automatically from configure.in by autoheader. */
+/* Unix definition file for less. -*- C -*-
+ *
+ * This file has 3 sections:
+ * User preferences.
+ * Settings always true on Unix.
+ * Settings automatically determined by configure.
+ *
+ * * * * * * WARNING * * * * * *
+ * If you edit defines.h by hand, do "touch stamp-h" before you run make
+ * so config.status doesn't overwrite your changes.
+ */
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define GLOB (!SECURE)
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC (!SECURE)
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE ".less"
+#define LESSKEYFILE_SYS SYSDIR "/.sysless"
+#define DEF_LESSKEYINFILE ".lesskey"
+
+
+/* Settings always true on Unix. */
+
+/*
+ * Define MSDOS_COMPILER if compiling under Microsoft C.
+ */
+#define MSDOS_COMPILER 0
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "/"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#undef HAVE_SGSTAT_H
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define HAVE_PERROR 1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 1
+
+/*
+ * Default shell metacharacters and meta-escape character.
+ */
+#define DEF_METACHARS "; \t\n'\"()<>|&^`\\"
+#define DEF_METAESCAPE "\\"
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Settings automatically determined by configure. */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define as the return type of signal handlers (int or void). */
+#undef RETSIGTYPE
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_PCRE: PCRE (Perl-compatible regular expression) library
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+#undef HAVE_POSIX_REGCOMP
+#undef HAVE_PCRE
+#undef HAVE_RE_COMP
+#undef HAVE_REGCMP
+#undef HAVE_V8_REGCOMP
+#undef NO_REGEX
+#undef HAVE_REGEXEC2
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#undef HAVE_VOID
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#undef HAVE_CONST
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#undef HAVE_TIME_T
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#undef HAVE_STRERROR
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#undef HAVE_FILENO
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
+ * in errno.h */
+#undef HAVE_ERRNO
+#undef MUST_DEFINE_ERRNO
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#undef HAVE_SYS_ERRLIST
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#undef HAVE_OSPEED
+#undef MUST_DEFINE_OSPEED
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#undef HAVE_LOCALE
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#undef HAVE_TERMIOS_FUNCS
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#undef HAVE_UPPER_LOWER
+
+/* Define EDIT_PGM to your editor. */
+#define EDIT_PGM "vi"
+
+/* Define if you have the _setjmp function. */
+#undef HAVE__SETJMP
+
+/* Define if you have the memcpy function. */
+#undef HAVE_MEMCPY
+
+/* Define if you have the popen function. */
+#undef HAVE_POPEN
+
+/* Define if you have the sigsetmask function. */
+#undef HAVE_SIGSETMASK
+
+/* Define if you have the stat function. */
+#undef HAVE_STAT
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the strstr function. */
+#undef HAVE_STRSTR
+
+/* Define if you have the system function. */
+#undef HAVE_SYSTEM
+
+/* Define if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define if you have the <sys/ptem.h> header file. */
+#undef HAVE_SYS_PTEM_H
+
+/* Define if you have the <sys/stream.h> header file. */
+#undef HAVE_SYS_STREAM_H
+
+/* Define if you have the <termcap.h> header file. */
+#undef HAVE_TERMCAP_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define if you have the PW library (-lPW). */
+#undef HAVE_LIBPW
+
+/* Define if you have the gen library (-lgen). */
+#undef HAVE_LIBGEN
+
+/* Define if you have the intl library (-lintl). */
+#undef HAVE_LIBINTL
diff --git a/contrib/less/defines.h.top b/contrib/less/defines.h.top
new file mode 100644
index 000000000000..e14d1ea52f0b
--- /dev/null
+++ b/contrib/less/defines.h.top
@@ -0,0 +1,172 @@
+/* Unix definition file for less. -*- C -*-
+ *
+ * This file has 3 sections:
+ * User preferences.
+ * Settings always true on Unix.
+ * Settings automatically determined by configure.
+ *
+ * * * * * * WARNING * * * * * *
+ * If you edit defines.h by hand, do "touch stamp-h" before you run make
+ * so config.status doesn't overwrite your changes.
+ */
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define GLOB (!SECURE)
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC (!SECURE)
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE ".less"
+#define LESSKEYFILE_SYS SYSDIR "/.sysless"
+#define DEF_LESSKEYINFILE ".lesskey"
+
+
+/* Settings always true on Unix. */
+
+/*
+ * Define MSDOS_COMPILER if compiling under Microsoft C.
+ */
+#define MSDOS_COMPILER 0
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "/"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#undef HAVE_SGSTAT_H
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define HAVE_PERROR 1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 1
+
+/*
+ * Default shell metacharacters and meta-escape character.
+ */
+#define DEF_METACHARS "; \t\n'\"()<>|&^`\\"
+#define DEF_METAESCAPE "\\"
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Settings automatically determined by configure. */
diff --git a/contrib/less/defines.o2 b/contrib/less/defines.o2
new file mode 100644
index 000000000000..b167d6a0441f
--- /dev/null
+++ b/contrib/less/defines.o2
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/* OS/2 definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for the emx compiler for OS/2 systems.
+ */
+
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+#define EDIT_PGM "me"
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define GLOB (!SECURE)
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC (!SECURE)
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "less.ini"
+#define LESSKEYFILE_SYS "\\sysless.ini"
+#define DEF_LESSKEYINFILE "lesskey.ini"
+
+
+/* Settings always true for the emx compiler for OS/2 systems. */
+#define OS2 1
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "\\"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define HAVE_PERROR 1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 0
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #define off_t long */
+
+/* Define if you need to in order for stat and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+/* #undef HAVE_POSIX_REGCOMP */
+/* #undef HAVE_RE_COMP */
+/* #undef HAVE_REGCMP */
+#define HAVE_V8_REGCOMP 1
+/* #undef NO_REGEX */
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 0
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
+ * in errno.h */
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 1
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+#define HAVE_OSPEED 0
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 0
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 0
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 0
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 0
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <values.h> header file. */
+#define HAVE_VALUES_H 0
diff --git a/contrib/less/defines.o9 b/contrib/less/defines.o9
new file mode 100644
index 000000000000..e966c25c990b
--- /dev/null
+++ b/contrib/less/defines.o9
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/* OS/9 definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for OS-9 systems.
+ */
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME 1
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+#define EDIT_PGM "umacs"
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define GLOB (!SECURE)
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC (!SECURE)
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE ".less"
+#define LESSKEYFILE_SYS "/.sysless"
+#define DEF_LESSKEYINFILE ".lesskey"
+
+
+/* Settings always true for OS-9. */
+
+/* This is not needed; it is defined by the compiler. */
+/* #define _OSK 1 */
+#define OS2 0
+#define MSDOS_COMPILER 0
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "/"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 0
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H 1
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#if _OSK_MWC32
+#define HAVE_PERROR 0
+#else
+#define HAVE_PERROR 1
+#endif
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 0
+
+/*
+ * Default shell metacharacters and meta-escape character.
+ */
+#define DEF_METACHARS "; \t\n'\"()<>|&^`#\\"
+#define DEF_METAESCAPE "\\"
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 0
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#define off_t long
+
+/* Define if you need to in order for stat and other things to work. */
+#define _POSIX_SOURCE 0
+
+/* Define as the return type of signal handlers (int or void). */
+#if _OSK_MWC32
+#define RETSIGTYPE int
+#else
+#define RETSIGTYPE void
+#endif
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+#define HAVE_POSIX_REGCOMP 0
+#define HAVE_RE_COMP 0
+#define HAVE_REGCMP 0
+#define HAVE_V8_REGCOMP 1
+#define NO_REGEX 0
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 0
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 0
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
+ * in errno.h */
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 0
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 0
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define HAVE_OSPEED 0
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 1
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 1
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 0
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 0
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 0
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 0
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <stdlib> header file. */
+#if _OSK_MWC32
+#define HAVE_STDLIB_H 0
+#else
+#define HAVE_STDLIB_H 1
+#endif
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 1
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 0
+
+/* Define if you have the <values.h> header file. */
+#define HAVE_VALUES_H 0
diff --git a/contrib/less/defines.wn b/contrib/less/defines.wn
new file mode 100644
index 000000000000..c69cb9d6af61
--- /dev/null
+++ b/contrib/less/defines.wn
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/* Windows definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for Windows systems.
+ */
+
+
+/* User preferences. */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define SECURE 0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define SHELL_ESCAPE (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define EXAMINE (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define TAB_COMPLETE_FILENAME (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define CMD_HISTORY 1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be
+ * displayed in standout mode.
+ */
+#define HILITE_SEARCH 1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define EDITOR (!SECURE)
+#define EDIT_PGM "edit"
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define TAGS (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify
+ * user-defined key bindings.
+ */
+#define USERFILE (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define GLOB 0
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC 1
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define LOGFILE (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define GNU_OPTIONS 1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define ONLY_RETURN 0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "_less"
+#define LESSKEYFILE_SYS "c:\\_sysless"
+#define DEF_LESSKEYINFILE "_lesskey"
+
+
+/* Settings always true for Windows systems. */
+
+#define MSDOS_COMPILER WIN32C
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP "\\"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H 1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define HAVE_PERROR 1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define HAVE_TIME 1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define HAVE_SHELL 0
+
+/*
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define HAVE_DUP 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
+#define UNGOT_SIZE 100 /* Max chars to unget() */
+#define LINEBUF_SIZE 1024 /* Max size of line in input file */
+#define OUTBUF_SIZE 1024 /* Output buffer */
+#define PROMPT_SIZE 200 /* Max size of prompt string */
+#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
+#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
+#define TAGLINE_SIZE 512 /* Max size of line in tags file */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #define off_t long */
+
+/* Define if you need to in order for stat and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+/* #undef HAVE_POSIX_REGCOMP */
+/* #undef HAVE_RE_COMP */
+/* #undef HAVE_REGCMP */
+#define HAVE_V8_REGCOMP 1
+/* #undef NO_REGEX */
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
+ * in errno.h */
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 1
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+#define HAVE_OSPEED 0
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 1
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 1
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 0
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 0
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 0
+
+/* Define if you have the <values.h> header file. */
+#ifdef _MSC_VER
+#define HAVE_VALUES_H 0
+#else
+#define HAVE_VALUES_H 1
+#endif
+
+#define popen _popen
+#define pclose _pclose
diff --git a/contrib/less/edit.c b/contrib/less/edit.c
new file mode 100644
index 000000000000..1b3c35d6a040
--- /dev/null
+++ b/contrib/less/edit.c
@@ -0,0 +1,761 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+#include "less.h"
+
+public int fd0 = 0;
+
+extern int new_file;
+extern int errmsgs;
+extern int cbufs;
+extern char *every_first_cmd;
+extern int any_display;
+extern int force_open;
+extern int is_tty;
+extern int sigs;
+extern IFILE curr_ifile;
+extern IFILE old_ifile;
+extern struct scrpos initial_scrpos;
+extern void constant *ml_examine;
+#if SPACES_IN_FILENAMES
+extern char openquote;
+extern char closequote;
+#endif
+
+#if LOGFILE
+extern int logfile;
+extern int force_logfile;
+extern char *namelogfile;
+#endif
+
+char *curr_altfilename = NULL;
+static void *curr_altpipe;
+
+
+/*
+ * Textlist functions deal with a list of words separated by spaces.
+ * init_textlist sets up a textlist structure.
+ * forw_textlist uses that structure to iterate thru the list of
+ * words, returning each one as a standard null-terminated string.
+ * back_textlist does the same, but runs thru the list backwards.
+ */
+ public void
+init_textlist(tlist, str)
+ struct textlist *tlist;
+ char *str;
+{
+ char *s;
+#if SPACES_IN_FILENAMES
+ int quoted = 0;
+#endif
+
+ tlist->string = skipsp(str);
+ tlist->endstring = tlist->string + strlen(tlist->string);
+ for (s = str; s < tlist->endstring; s++)
+ {
+#if SPACES_IN_FILENAMES
+ if (*s == ' ' && !quoted)
+ *s = '\0';
+ if (!quoted && *s == openquote)
+ quoted = 1;
+ else if (quoted && *s == closequote)
+ quoted = 0;
+#else
+ if (*s == ' ')
+ *s = '\0';
+#endif
+ }
+}
+
+ public char *
+forw_textlist(tlist, prev)
+ struct textlist *tlist;
+ char *prev;
+{
+ char *s;
+
+ /*
+ * prev == NULL means return the first word in the list.
+ * Otherwise, return the word after "prev".
+ */
+ if (prev == NULL)
+ s = tlist->string;
+ else
+ s = prev + strlen(prev);
+ if (s >= tlist->endstring)
+ return (NULL);
+ while (*s == '\0')
+ s++;
+ if (s >= tlist->endstring)
+ return (NULL);
+ return (s);
+}
+
+ public char *
+back_textlist(tlist, prev)
+ struct textlist *tlist;
+ char *prev;
+{
+ char *s;
+
+ /*
+ * prev == NULL means return the last word in the list.
+ * Otherwise, return the word before "prev".
+ */
+ if (prev == NULL)
+ s = tlist->endstring;
+ else if (prev <= tlist->string)
+ return (NULL);
+ else
+ s = prev - 1;
+ while (*s == '\0')
+ s--;
+ if (s <= tlist->string)
+ return (NULL);
+ while (s[-1] != '\0' && s > tlist->string)
+ s--;
+ return (s);
+}
+
+/*
+ * Close the current input file.
+ */
+ static void
+close_file()
+{
+ struct scrpos scrpos;
+ char *filename;
+
+ if (curr_ifile == NULL_IFILE)
+ return;
+
+ /*
+ * Save the current position so that we can return to
+ * the same position if we edit this file again.
+ */
+ get_scrpos(&scrpos);
+ if (scrpos.pos != NULL_POSITION)
+ {
+ store_pos(curr_ifile, &scrpos);
+ lastmark();
+ }
+ /*
+ * Close the file descriptor, unless it is a pipe.
+ */
+ ch_close();
+ /*
+ * If we opened a file using an alternate name,
+ * do special stuff to close it.
+ */
+ if (curr_altfilename != NULL)
+ {
+ filename = unquote_file(get_filename(curr_ifile));
+ close_altfile(curr_altfilename, filename, curr_altpipe);
+ free(filename);
+ free(curr_altfilename);
+ curr_altfilename = NULL;
+ }
+ curr_ifile = NULL_IFILE;
+}
+
+/*
+ * Edit a new file (given its name).
+ * Filename == "-" means standard input.
+ * Filename == NULL means just close the current file.
+ */
+ public int
+edit(filename)
+ char *filename;
+{
+ if (filename == NULL)
+ return (edit_ifile(NULL_IFILE));
+ return (edit_ifile(get_ifile(filename, curr_ifile)));
+}
+
+/*
+ * Edit a new file (given its IFILE).
+ * ifile == NULL means just close the current file.
+ */
+ public int
+edit_ifile(ifile)
+ IFILE ifile;
+{
+ int f;
+ int answer;
+ int no_display;
+ int chflags;
+ char *filename;
+ char *open_filename;
+ char *alt_filename;
+ void *alt_pipe;
+ IFILE was_curr_ifile;
+ PARG parg;
+
+ if (ifile == curr_ifile)
+ {
+ /*
+ * Already have the correct file open.
+ */
+ return (0);
+ }
+
+ /*
+ * We must close the currently open file now.
+ * This is necessary to make the open_altfile/close_altfile pairs
+ * nest properly (or rather to avoid nesting at all).
+ * {{ Some stupid implementations of popen() mess up if you do:
+ * fA = popen("A"); fB = popen("B"); pclose(fA); pclose(fB); }}
+ */
+#if LOGFILE
+ end_logfile();
+#endif
+ was_curr_ifile = save_curr_ifile();
+ if (curr_ifile != NULL_IFILE)
+ {
+ chflags = ch_getflags();
+ close_file();
+ if ((chflags & CH_HELPFILE) && held_ifile(was_curr_ifile) <= 1)
+ {
+ /*
+ * Don't keep the help file in the ifile list.
+ */
+ del_ifile(was_curr_ifile);
+ was_curr_ifile = old_ifile;
+ }
+ }
+
+ if (ifile == NULL_IFILE)
+ {
+ /*
+ * No new file to open.
+ * (Don't set old_ifile, because if you call edit_ifile(NULL),
+ * you're supposed to have saved curr_ifile yourself,
+ * and you'll restore it if necessary.)
+ */
+ unsave_ifile(was_curr_ifile);
+ return (0);
+ }
+
+ filename = unquote_file(get_filename(ifile));
+ /*
+ * See if LESSOPEN specifies an "alternate" file to open.
+ */
+ alt_pipe = NULL;
+ alt_filename = open_altfile(filename, &f, &alt_pipe);
+ open_filename = (alt_filename != NULL) ? alt_filename : filename;
+
+ chflags = 0;
+ if (alt_pipe != NULL)
+ {
+ /*
+ * The alternate "file" is actually a pipe.
+ * f has already been set to the file descriptor of the pipe
+ * in the call to open_altfile above.
+ * Keep the file descriptor open because it was opened
+ * via popen(), and pclose() wants to close it.
+ */
+ chflags |= CH_POPENED;
+ } else if (strcmp(open_filename, "-") == 0)
+ {
+ /*
+ * Use standard input.
+ * Keep the file descriptor open because we can't reopen it.
+ */
+ f = fd0;
+ chflags |= CH_KEEPOPEN;
+ /*
+ * Must switch stdin to BINARY mode.
+ */
+ SET_BINARY(f);
+#if MSDOS_COMPILER==DJGPPC
+ /*
+ * Setting stdin to binary by default causes
+ * Ctrl-C to not raise SIGINT. We must undo
+ * that side-effect.
+ */
+ __djgpp_set_ctrl_c(1);
+#endif
+ } else if (strcmp(open_filename, FAKE_HELPFILE) == 0)
+ {
+ f = -1;
+ chflags |= CH_HELPFILE;
+ } else if ((parg.p_string = bad_file(open_filename)) != NULL)
+ {
+ /*
+ * It looks like a bad file. Don't try to open it.
+ */
+ error("%s", &parg);
+ free(parg.p_string);
+ err1:
+ if (alt_filename != NULL)
+ {
+ close_altfile(alt_filename, filename, alt_pipe);
+ free(alt_filename);
+ }
+ del_ifile(ifile);
+ free(filename);
+ /*
+ * Re-open the current file.
+ */
+ reedit_ifile(was_curr_ifile);
+ return (1);
+ } else if ((f = open(open_filename, OPEN_READ)) < 0)
+ {
+ /*
+ * Got an error trying to open it.
+ */
+ parg.p_string = errno_message(filename);
+ error("%s", &parg);
+ free(parg.p_string);
+ goto err1;
+ } else
+ {
+ chflags |= CH_CANSEEK;
+ if (!force_open && !opened(ifile) && bin_file(f))
+ {
+ /*
+ * Looks like a binary file.
+ * Ask user if we should proceed.
+ */
+ parg.p_string = filename;
+ answer = query("\"%s\" may be a binary file. See it anyway? ",
+ &parg);
+ if (answer != 'y' && answer != 'Y')
+ {
+ close(f);
+ goto err1;
+ }
+ }
+ }
+
+ /*
+ * Get the new ifile.
+ * Get the saved position for the file.
+ */
+ if (was_curr_ifile != NULL_IFILE)
+ {
+ old_ifile = was_curr_ifile;
+ unsave_ifile(was_curr_ifile);
+ }
+ curr_ifile = ifile;
+ curr_altfilename = alt_filename;
+ curr_altpipe = alt_pipe;
+ set_open(curr_ifile); /* File has been opened */
+ get_pos(curr_ifile, &initial_scrpos);
+ new_file = TRUE;
+ ch_init(f, chflags);
+
+ if (!(chflags & CH_HELPFILE))
+ {
+#if LOGFILE
+ if (namelogfile != NULL && is_tty)
+ use_logfile(namelogfile);
+#endif
+ if (every_first_cmd != NULL)
+ ungetsc(every_first_cmd);
+ }
+
+ no_display = !any_display;
+ flush();
+ any_display = TRUE;
+
+ if (is_tty)
+ {
+ /*
+ * Output is to a real tty.
+ */
+
+ /*
+ * Indicate there is nothing displayed yet.
+ */
+ pos_clear();
+ clr_linenum();
+#if HILITE_SEARCH
+ clr_hilite();
+#endif
+ cmd_addhist(ml_examine, filename);
+ if (no_display && errmsgs > 0)
+ {
+ /*
+ * We displayed some messages on error output
+ * (file descriptor 2; see error() function).
+ * Before erasing the screen contents,
+ * display the file name and wait for a keystroke.
+ */
+ parg.p_string = filename;
+ error("%s", &parg);
+ }
+ }
+ free(filename);
+ return (0);
+}
+
+/*
+ * Edit a space-separated list of files.
+ * For each filename in the list, enter it into the ifile list.
+ * Then edit the first one.
+ */
+ public int
+edit_list(filelist)
+ char *filelist;
+{
+ IFILE save_ifile;
+ char *good_filename;
+ char *filename;
+ char *gfilelist;
+ char *gfilename;
+ struct textlist tl_files;
+ struct textlist tl_gfiles;
+
+ save_ifile = save_curr_ifile();
+ good_filename = NULL;
+
+ /*
+ * Run thru each filename in the list.
+ * Try to glob the filename.
+ * If it doesn't expand, just try to open the filename.
+ * If it does expand, try to open each name in that list.
+ */
+ init_textlist(&tl_files, filelist);
+ filename = NULL;
+ while ((filename = forw_textlist(&tl_files, filename)) != NULL)
+ {
+ gfilelist = lglob(filename);
+ init_textlist(&tl_gfiles, gfilelist);
+ gfilename = NULL;
+ while ((gfilename = forw_textlist(&tl_gfiles, gfilename)) != NULL)
+ {
+ if (edit(gfilename) == 0 && good_filename == NULL)
+ good_filename = get_filename(curr_ifile);
+ }
+ free(gfilelist);
+ }
+ /*
+ * Edit the first valid filename in the list.
+ */
+ if (good_filename == NULL)
+ {
+ unsave_ifile(save_ifile);
+ return (1);
+ }
+ if (get_ifile(good_filename, curr_ifile) == curr_ifile)
+ {
+ /*
+ * Trying to edit the current file; don't reopen it.
+ */
+ unsave_ifile(save_ifile);
+ return (0);
+ }
+ reedit_ifile(save_ifile);
+ return (edit(good_filename));
+}
+
+/*
+ * Edit the first file in the command line (ifile) list.
+ */
+ public int
+edit_first()
+{
+ curr_ifile = NULL_IFILE;
+ return (edit_next(1));
+}
+
+/*
+ * Edit the last file in the command line (ifile) list.
+ */
+ public int
+edit_last()
+{
+ curr_ifile = NULL_IFILE;
+ return (edit_prev(1));
+}
+
+
+/*
+ * Edit the next or previous file in the command line (ifile) list.
+ */
+ static int
+edit_istep(h, n, dir)
+ IFILE h;
+ int n;
+ int dir;
+{
+ IFILE next;
+
+ /*
+ * Skip n filenames, then try to edit each filename.
+ */
+ for (;;)
+ {
+ next = (dir > 0) ? next_ifile(h) : prev_ifile(h);
+ if (--n < 0)
+ {
+ if (edit_ifile(h) == 0)
+ break;
+ }
+ if (next == NULL_IFILE)
+ {
+ /*
+ * Reached end of the ifile list.
+ */
+ return (1);
+ }
+ if (ABORT_SIGS())
+ {
+ /*
+ * Interrupt breaks out, if we're in a long
+ * list of files that can't be opened.
+ */
+ return (1);
+ }
+ h = next;
+ }
+ /*
+ * Found a file that we can edit.
+ */
+ return (0);
+}
+
+ static int
+edit_inext(h, n)
+ IFILE h;
+ int n;
+{
+ return (edit_istep(h, n, 1));
+}
+
+ public int
+edit_next(n)
+ int n;
+{
+ return edit_istep(curr_ifile, n, 1);
+}
+
+ static int
+edit_iprev(h, n)
+ IFILE h;
+ int n;
+{
+ return (edit_istep(h, n, -1));
+}
+
+ public int
+edit_prev(n)
+ int n;
+{
+ return edit_istep(curr_ifile, n, -1);
+}
+
+/*
+ * Edit a specific file in the command line (ifile) list.
+ */
+ public int
+edit_index(n)
+ int n;
+{
+ IFILE h;
+
+ h = NULL_IFILE;
+ do
+ {
+ if ((h = next_ifile(h)) == NULL_IFILE)
+ {
+ /*
+ * Reached end of the list without finding it.
+ */
+ return (1);
+ }
+ } while (get_index(h) != n);
+
+ return (edit_ifile(h));
+}
+
+ public IFILE
+save_curr_ifile()
+{
+ if (curr_ifile != NULL_IFILE)
+ hold_ifile(curr_ifile, 1);
+ return (curr_ifile);
+}
+
+ public void
+unsave_ifile(save_ifile)
+ IFILE save_ifile;
+{
+ if (save_ifile != NULL_IFILE)
+ hold_ifile(save_ifile, -1);
+}
+
+/*
+ * Reedit the ifile which was previously open.
+ */
+ public void
+reedit_ifile(save_ifile)
+ IFILE save_ifile;
+{
+ IFILE next;
+ IFILE prev;
+
+ /*
+ * Try to reopen the ifile.
+ * Note that opening it may fail (maybe the file was removed),
+ * in which case the ifile will be deleted from the list.
+ * So save the next and prev ifiles first.
+ */
+ unsave_ifile(save_ifile);
+ next = next_ifile(save_ifile);
+ prev = prev_ifile(save_ifile);
+ if (edit_ifile(save_ifile) == 0)
+ return;
+ /*
+ * If can't reopen it, open the next input file in the list.
+ */
+ if (next != NULL_IFILE && edit_inext(next, 0) == 0)
+ return;
+ /*
+ * If can't open THAT one, open the previous input file in the list.
+ */
+ if (prev != NULL_IFILE && edit_iprev(prev, 0) == 0)
+ return;
+ /*
+ * If can't even open that, we're stuck. Just quit.
+ */
+ quit(QUIT_ERROR);
+}
+
+/*
+ * Edit standard input.
+ */
+ public int
+edit_stdin()
+{
+ if (isatty(fd0))
+ {
+ error("Missing filename (\"less --help\" for help)", NULL_PARG);
+ quit(QUIT_OK);
+ }
+ return (edit("-"));
+}
+
+/*
+ * Copy a file directly to standard output.
+ * Used if standard output is not a tty.
+ */
+ public void
+cat_file()
+{
+ register int c;
+
+ while ((c = ch_forw_get()) != EOI)
+ putchr(c);
+ flush();
+}
+
+#if LOGFILE
+
+/*
+ * If the user asked for a log file and our input file
+ * is standard input, create the log file.
+ * We take care not to blindly overwrite an existing file.
+ */
+ public void
+use_logfile(filename)
+ char *filename;
+{
+ register int exists;
+ register int answer;
+ PARG parg;
+
+ if (ch_getflags() & CH_CANSEEK)
+ /*
+ * Can't currently use a log file on a file that can seek.
+ */
+ return;
+
+ /*
+ * {{ We could use access() here. }}
+ */
+ filename = unquote_file(filename);
+ exists = open(filename, OPEN_READ);
+ close(exists);
+ exists = (exists >= 0);
+
+ /*
+ * Decide whether to overwrite the log file or append to it.
+ * If it doesn't exist we "overwrite" it.
+ */
+ if (!exists || force_logfile)
+ {
+ /*
+ * Overwrite (or create) the log file.
+ */
+ answer = 'O';
+ } else
+ {
+ /*
+ * Ask user what to do.
+ */
+ parg.p_string = filename;
+ answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
+ }
+
+loop:
+ switch (answer)
+ {
+ case 'O': case 'o':
+ /*
+ * Overwrite: create the file.
+ */
+ logfile = creat(filename, 0644);
+ break;
+ case 'A': case 'a':
+ /*
+ * Append: open the file and seek to the end.
+ */
+ logfile = open(filename, OPEN_APPEND);
+ if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)
+ {
+ close(logfile);
+ logfile = -1;
+ }
+ break;
+ case 'D': case 'd':
+ /*
+ * Don't do anything.
+ */
+ free(filename);
+ return;
+ case 'q':
+ quit(QUIT_OK);
+ /*NOTREACHED*/
+ default:
+ /*
+ * Eh?
+ */
+ answer = query("Overwrite, Append, or Don't log? (Type \"O\", \"A\", \"D\" or \"q\") ", NULL_PARG);
+ goto loop;
+ }
+
+ if (logfile < 0)
+ {
+ /*
+ * Error in opening logfile.
+ */
+ parg.p_string = filename;
+ error("Cannot write to \"%s\"", &parg);
+ free(filename);
+ return;
+ }
+ free(filename);
+ SET_BINARY(logfile);
+}
+
+#endif
diff --git a/contrib/less/filename.c b/contrib/less/filename.c
new file mode 100644
index 000000000000..189ad87f6e91
--- /dev/null
+++ b/contrib/less/filename.c
@@ -0,0 +1,1011 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to mess around with filenames (and files).
+ * Much of this is very OS dependent.
+ */
+
+#include "less.h"
+#include "lglob.h"
+#if MSDOS_COMPILER
+#include <dos.h>
+#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER)
+#include <dir.h>
+#endif
+#if MSDOS_COMPILER==DJGPPC
+#include <glob.h>
+#include <dir.h>
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+#endif
+#ifdef _OSK
+#include <rbf.h>
+#ifndef _OSK_MWC32
+#include <modes.h>
+#endif
+#endif
+
+#if HAVE_STAT
+#include <sys/stat.h>
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#endif
+
+
+extern int force_open;
+extern int secure;
+extern IFILE curr_ifile;
+extern IFILE old_ifile;
+#if SPACES_IN_FILENAMES
+extern char openquote;
+extern char closequote;
+#endif
+
+/*
+ * Remove quotes around a filename.
+ */
+ public char *
+unquote_file(str)
+ char *str;
+{
+#if SPACES_IN_FILENAMES
+ char *name;
+ char *p;
+
+ if (*str != openquote)
+ return (save(str));
+ name = (char *) ecalloc(strlen(str), sizeof(char));
+ strcpy(name, str+1);
+ p = name + strlen(name) - 1;
+ if (*p == closequote)
+ *p = '\0';
+ return (name);
+#else
+ return (save(str));
+#endif
+}
+
+/*
+ * Return a pathname that points to a specified file in a specified directory.
+ * Return NULL if the file does not exist in the directory.
+ */
+ static char *
+dirfile(dirname, filename)
+ char *dirname;
+ char *filename;
+{
+ char *pathname;
+ char *qpathname;
+ int f;
+
+ if (dirname == NULL || *dirname == '\0')
+ return (NULL);
+ /*
+ * Construct the full pathname.
+ */
+ pathname = (char *) calloc(strlen(dirname) + strlen(filename) + 2,
+ sizeof(char));
+ if (pathname == NULL)
+ return (NULL);
+ sprintf(pathname, "%s%s%s", dirname, PATHNAME_SEP, filename);
+ /*
+ * Make sure the file exists.
+ */
+ qpathname = unquote_file(pathname);
+ f = open(qpathname, OPEN_READ);
+ if (f < 0)
+ {
+ free(pathname);
+ pathname = NULL;
+ } else
+ {
+ close(f);
+ }
+ free(qpathname);
+ return (pathname);
+}
+
+/*
+ * Return the full pathname of the given file in the "home directory".
+ */
+ public char *
+homefile(filename)
+ char *filename;
+{
+ register char *pathname;
+
+ /*
+ * Try $HOME/filename.
+ */
+ pathname = dirfile(lgetenv("HOME"), filename);
+ if (pathname != NULL)
+ return (pathname);
+#if OS2
+ /*
+ * Try $INIT/filename.
+ */
+ pathname = dirfile(lgetenv("INIT"), filename);
+ if (pathname != NULL)
+ return (pathname);
+#endif
+#if MSDOS_COMPILER || OS2
+ /*
+ * Look for the file anywhere on search path.
+ */
+ pathname = (char *) calloc(_MAX_PATH, sizeof(char));
+#if MSDOS_COMPILER==DJGPPC
+ {
+ char *res = searchpath(filename);
+ if (res == 0)
+ *pathname = '\0';
+ else
+ strcpy(pathname, res);
+ }
+#else
+ _searchenv(filename, "PATH", pathname);
+#endif
+ if (*pathname != '\0')
+ return (pathname);
+ free(pathname);
+#endif
+ return (NULL);
+}
+
+/*
+ * Expand a string, substituting any "%" with the current filename,
+ * and any "#" with the previous filename.
+ * But a string of N "%"s is just replaced with N-1 "%"s.
+ * Likewise for a string of N "#"s.
+ * {{ This is a lot of work just to support % and #. }}
+ */
+ public char *
+fexpand(s)
+ char *s;
+{
+ register char *fr, *to;
+ register int n;
+ register char *e;
+ IFILE ifile;
+
+#define fchar_ifile(c) \
+ ((c) == '%' ? curr_ifile : \
+ (c) == '#' ? old_ifile : NULL_IFILE)
+
+ /*
+ * Make one pass to see how big a buffer we
+ * need to allocate for the expanded string.
+ */
+ n = 0;
+ for (fr = s; *fr != '\0'; fr++)
+ {
+ switch (*fr)
+ {
+ case '%':
+ case '#':
+ if (fr > s && fr[-1] == *fr)
+ {
+ /*
+ * Second (or later) char in a string
+ * of identical chars. Treat as normal.
+ */
+ n++;
+ } else if (fr[1] != *fr)
+ {
+ /*
+ * Single char (not repeated). Treat specially.
+ */
+ ifile = fchar_ifile(*fr);
+ if (ifile == NULL_IFILE)
+ n++;
+ else
+ n += strlen(get_filename(ifile));
+ }
+ /*
+ * Else it is the first char in a string of
+ * identical chars. Just discard it.
+ */
+ break;
+ default:
+ n++;
+ break;
+ }
+ }
+
+ e = (char *) ecalloc(n+1, sizeof(char));
+
+ /*
+ * Now copy the string, expanding any "%" or "#".
+ */
+ to = e;
+ for (fr = s; *fr != '\0'; fr++)
+ {
+ switch (*fr)
+ {
+ case '%':
+ case '#':
+ if (fr > s && fr[-1] == *fr)
+ {
+ *to++ = *fr;
+ } else if (fr[1] != *fr)
+ {
+ ifile = fchar_ifile(*fr);
+ if (ifile == NULL_IFILE)
+ *to++ = *fr;
+ else
+ {
+ strcpy(to, get_filename(ifile));
+ to += strlen(to);
+ }
+ }
+ break;
+ default:
+ *to++ = *fr;
+ break;
+ }
+ }
+ *to = '\0';
+ return (e);
+}
+
+#if TAB_COMPLETE_FILENAME
+
+/*
+ * Return a blank-separated list of filenames which "complete"
+ * the given string.
+ */
+ public char *
+fcomplete(s)
+ char *s;
+{
+ char *fpat;
+
+ if (secure)
+ return (NULL);
+ /*
+ * Complete the filename "s" by globbing "s*".
+ */
+#if MSDOS_COMPILER && (MSDOS_COMPILER == MSOFTC || MSDOS_COMPILER == BORLANDC)
+ /*
+ * But in DOS, we have to glob "s*.*".
+ * But if the final component of the filename already has
+ * a dot in it, just do "s*".
+ * (Thus, "FILE" is globbed as "FILE*.*",
+ * but "FILE.A" is globbed as "FILE.A*").
+ */
+ {
+ char *slash;
+ for (slash = s+strlen(s)-1; slash > s; slash--)
+ if (*slash == *PATHNAME_SEP || *slash == '/')
+ break;
+ fpat = (char *) ecalloc(strlen(s)+4, sizeof(char));
+ if (strchr(slash, '.') == NULL)
+ sprintf(fpat, "%s*.*", s);
+ else
+ sprintf(fpat, "%s*", s);
+ }
+#else
+ fpat = (char *) ecalloc(strlen(s)+2, sizeof(char));
+ sprintf(fpat, "%s*", s);
+#endif
+ s = lglob(fpat);
+ if (strcmp(s,fpat) == 0)
+ {
+ /*
+ * The filename didn't expand.
+ */
+ free(s);
+ s = NULL;
+ }
+ free(fpat);
+ return (s);
+}
+#endif
+
+/*
+ * Try to determine if a file is "binary".
+ * This is just a guess, and we need not try too hard to make it accurate.
+ */
+ public int
+bin_file(f)
+ int f;
+{
+ int i;
+ int n;
+ unsigned char data[64];
+
+ if (!seekable(f))
+ return (0);
+ if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
+ return (0);
+ n = read(f, data, sizeof(data));
+ for (i = 0; i < n; i++)
+ if (binary_char(data[i]))
+ return (1);
+ return (0);
+}
+
+/*
+ * Try to determine the size of a file by seeking to the end.
+ */
+ static POSITION
+seek_filesize(f)
+ int f;
+{
+ off_t spos;
+
+ spos = lseek(f, (off_t)0, 2);
+ if (spos == BAD_LSEEK)
+ return (NULL_POSITION);
+ return ((POSITION) spos);
+}
+
+/*
+ * Read a string from a file.
+ * Return a pointer to the string in memory.
+ */
+ static char *
+readfd(fd)
+ FILE *fd;
+{
+ int len;
+ int ch;
+ char *buf;
+ char *p;
+
+ /*
+ * Make a guess about how many chars in the string
+ * and allocate a buffer to hold it.
+ */
+ len = 100;
+ buf = (char *) ecalloc(len, sizeof(char));
+ for (p = buf; ; p++)
+ {
+ if ((ch = getc(fd)) == '\n' || ch == EOF)
+ break;
+ if (p - buf >= len-1)
+ {
+ /*
+ * The string is too big to fit in the buffer we have.
+ * Allocate a new buffer, twice as big.
+ */
+ len *= 2;
+ *p = '\0';
+ p = (char *) ecalloc(len, sizeof(char));
+ strcpy(p, buf);
+ free(buf);
+ buf = p;
+ p = buf + strlen(buf);
+ }
+ *p = ch;
+ }
+ *p = '\0';
+ return (buf);
+}
+
+#if HAVE_SHELL
+
+/*
+ * Get the shell's escape character.
+ */
+ static char *
+get_meta_escape()
+{
+ char *s;
+
+ s = lgetenv("LESSMETAESCAPE");
+ if (s == NULL)
+ s = DEF_METAESCAPE;
+ return (s);
+}
+
+/*
+ * Is this a shell metacharacter?
+ */
+ static int
+metachar(c)
+ char c;
+{
+ static char *metachars = NULL;
+
+ if (metachars == NULL)
+ {
+ metachars = lgetenv("LESSMETACHARS");
+ if (metachars == NULL)
+ metachars = DEF_METACHARS;
+ }
+ return (strchr(metachars, c) != NULL);
+}
+
+/*
+ * Insert a backslash before each metacharacter in a string.
+ */
+ public char *
+esc_metachars(s)
+ char *s;
+{
+ char *p;
+ char *newstr;
+ int len;
+ char *esc;
+ int esclen;
+
+ /*
+ * Determine how big a string we need to allocate.
+ */
+ esc = get_meta_escape();
+ esclen = strlen(esc);
+ len = 1; /* Trailing null byte */
+ for (p = s; *p != '\0'; p++)
+ {
+ len++;
+ if (metachar(*p))
+ {
+ if (*esc == '\0')
+ {
+ /*
+ * We've got a metachar, but this shell
+ * doesn't support escape chars. Give up.
+ */
+ return (NULL);
+ }
+ /*
+ * Allow space for the escape char.
+ */
+ len += esclen;
+ }
+ }
+ /*
+ * Allocate and construct the new string.
+ */
+ newstr = p = (char *) ecalloc(len, sizeof(char));
+ while (*s != '\0')
+ {
+ if (metachar(*s))
+ {
+ /*
+ * Add the escape char.
+ */
+ strcpy(p, esc);
+ p += esclen;
+ }
+ *p++ = *s++;
+ }
+ *p = '\0';
+ return (newstr);
+}
+
+#else /* HAVE_SHELL */
+
+ public char *
+esc_metachars(s)
+ char *s;
+{
+ return (save(s));
+}
+
+#endif /* HAVE_SHELL */
+
+
+#if HAVE_POPEN
+
+FILE *popen();
+
+/*
+ * Execute a shell command.
+ * Return a pointer to a pipe connected to the shell command's standard output.
+ */
+ static FILE *
+shellcmd(cmd)
+ char *cmd;
+{
+ FILE *fd;
+
+#if HAVE_SHELL
+ char *shell;
+
+ shell = lgetenv("SHELL");
+ if (shell != NULL && *shell != '\0')
+ {
+ char *scmd;
+ char *esccmd;
+
+ /*
+ * Try to escape any metacharacters in the command.
+ * If we can't do that, just put the command in quotes.
+ * (But that doesn't work well if the command itself
+ * contains quotes.)
+ */
+ if ((esccmd = esc_metachars(cmd)) == NULL)
+ {
+ /*
+ * Cannot escape the metacharacters, so use quotes.
+ * Read the output of <$SHELL -c "cmd">.
+ */
+ scmd = (char *) ecalloc(strlen(shell) + strlen(cmd) + 7,
+ sizeof(char));
+ sprintf(scmd, "%s -c \"%s\"", shell, cmd);
+ } else
+ {
+ /*
+ * Read the output of <$SHELL -c cmd>.
+ * No quotes; use the escaped cmd.
+ */
+ scmd = (char *) ecalloc(strlen(shell) + strlen(esccmd) + 5,
+ sizeof(char));
+ sprintf(scmd, "%s -c %s", shell, esccmd);
+ free(esccmd);
+ }
+ fd = popen(scmd, "r");
+ free(scmd);
+ } else
+#endif
+ {
+ fd = popen(cmd, "r");
+ /*
+ * Redirection in `popen' might have messed with the
+ * standard devices. Restore binary input mode.
+ */
+ SET_BINARY(0);
+ }
+ return (fd);
+}
+
+#endif /* HAVE_POPEN */
+
+
+/*
+ * Expand a filename, doing any system-specific metacharacter substitutions.
+ */
+ public char *
+lglob(filename)
+ char *filename;
+{
+ char *gfilename;
+ char *ofilename;
+
+ ofilename = fexpand(filename);
+ if (secure)
+ return (ofilename);
+ filename = unquote_file(ofilename);
+
+#ifdef DECL_GLOB_LIST
+{
+ /*
+ * The globbing function returns a list of names.
+ */
+ int length;
+ char *p;
+ DECL_GLOB_LIST(list)
+
+ GLOB_LIST(filename, list);
+ if (GLOB_LIST_FAILED(list))
+ {
+ free(filename);
+ return (ofilename);
+ }
+ length = 1; /* Room for trailing null byte */
+ for (SCAN_GLOB_LIST(list, p))
+ {
+ INIT_GLOB_LIST(list, p);
+ length += strlen(p) + 1;
+#if SPACES_IN_FILENAMES
+ if (strchr(p, ' ') != NULL)
+ length += 2; /* Allow for quotes */
+#endif
+ }
+ gfilename = (char *) ecalloc(length, sizeof(char));
+ for (SCAN_GLOB_LIST(list, p))
+ {
+ INIT_GLOB_LIST(list, p);
+#if SPACES_IN_FILENAMES
+ if (strchr(p, ' ') != NULL)
+ sprintf(gfilename + strlen(gfilename), "%c%s%c ",
+ openquote, p, closequote);
+ else
+#endif
+ sprintf(gfilename + strlen(gfilename), "%s ", p);
+ }
+ /*
+ * Overwrite the final trailing space with a null terminator.
+ */
+ *--p = '\0';
+ GLOB_LIST_DONE(list);
+}
+#else
+#ifdef DECL_GLOB_NAME
+{
+ /*
+ * The globbing function returns a single name, and
+ * is called multiple times to walk thru all names.
+ */
+ register char *p;
+ register int len;
+ register int n;
+#if SPACES_IN_FILENAMES
+ register int spaces_in_file;
+#endif
+ DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle)
+
+ GLOB_FIRST_NAME(filename, &fnd, handle);
+ if (GLOB_FIRST_FAILED(handle))
+ {
+ free(filename);
+ return (ofilename);
+ }
+
+ _splitpath(filename, drive, dir, fname, ext);
+ len = 100;
+ gfilename = (char *) ecalloc(len, sizeof(char));
+ p = gfilename;
+ do {
+ n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1;
+#if SPACES_IN_FILENAMES
+ spaces_in_file = 0;
+ if (strchr(fnd.GLOB_NAME, ' ') != NULL ||
+ strchr(filename, ' ') != NULL)
+ {
+ spaces_in_file = 1;
+ n += 2;
+ }
+#endif
+ while (p - gfilename + n+2 >= len)
+ {
+ /*
+ * No room in current buffer. Allocate a bigger one.
+ */
+ len *= 2;
+ *p = '\0';
+ p = (char *) ecalloc(len, sizeof(char));
+ strcpy(p, gfilename);
+ free(gfilename);
+ gfilename = p;
+ p = gfilename + strlen(gfilename);
+ }
+#if SPACES_IN_FILENAMES
+ if (spaces_in_file)
+ sprintf(p, "%c%s%s%s%c ", openquote,
+ drive, dir, fnd.GLOB_NAME, closequote);
+ else
+#endif
+ sprintf(p, "%s%s%s ", drive, dir, fnd.GLOB_NAME);
+ p += n;
+ } while (GLOB_NEXT_NAME(handle, &fnd) == 0);
+
+ /*
+ * Overwrite the final trailing space with a null terminator.
+ */
+ *--p = '\0';
+ GLOB_NAME_DONE(handle);
+}
+#else
+#if HAVE_POPEN
+{
+ /*
+ * We get the shell to glob the filename for us by passing
+ * an "echo" command to the shell and reading its output.
+ */
+ FILE *fd;
+ char *s;
+ char *lessecho;
+ char *cmd;
+
+ lessecho = lgetenv("LESSECHO");
+ if (lessecho == NULL || *lessecho == '\0')
+ lessecho = "lessecho";
+ s = esc_metachars(filename);
+ if (s == NULL)
+ {
+ /*
+ * There may be dangerous metachars in this name.
+ * We can't risk passing it to the shell.
+ * {{ For example, do "!;TAB" when the first file
+ * in the dir is named "rm". }}
+ */
+ free(filename);
+ return (ofilename);
+ }
+ /*
+ * Invoke lessecho, and read its output (a globbed list of filenames).
+ */
+ cmd = (char *) ecalloc(strlen(lessecho) + strlen(s) + 24, sizeof(char));
+ sprintf(cmd, "%s -p0x%x -d0x%x -- %s",
+ lessecho, openquote, closequote, s);
+ fd = shellcmd(cmd);
+ free(s);
+ free(cmd);
+ if (fd == NULL)
+ {
+ /*
+ * Cannot create the pipe.
+ * Just return the original (fexpanded) filename.
+ */
+ free(filename);
+ return (ofilename);
+ }
+ gfilename = readfd(fd);
+ pclose(fd);
+ if (*gfilename == '\0')
+ {
+ free(gfilename);
+ free(filename);
+ return (ofilename);
+ }
+}
+#else
+ /*
+ * No globbing functions at all. Just use the fexpanded filename.
+ */
+ gfilename = save(filename);
+#endif
+#endif
+#endif
+ free(filename);
+ free(ofilename);
+ return (gfilename);
+}
+
+/*
+ * See if we should open a "replacement file"
+ * instead of the file we're about to open.
+ */
+ public char *
+open_altfile(filename, pf, pfd)
+ char *filename;
+ int *pf;
+ void **pfd;
+{
+#if !HAVE_POPEN
+ return (NULL);
+#else
+ char *lessopen;
+ char *gfilename;
+ char *cmd;
+ FILE *fd;
+#if HAVE_FILENO
+ int returnfd = 0;
+#endif
+
+ if (secure)
+ return (NULL);
+ ch_ungetchar(-1);
+ if ((lessopen = lgetenv("LESSOPEN")) == NULL)
+ return (NULL);
+ if (strcmp(filename, "-") == 0)
+ return (NULL);
+ if (*lessopen == '|')
+ {
+ /*
+ * If LESSOPEN starts with a |, it indicates
+ * a "pipe preprocessor".
+ */
+#if HAVE_FILENO
+ lessopen++;
+ returnfd = 1;
+#else
+ error("LESSOPEN pipe is not supported", NULL_PARG);
+ return (NULL);
+#endif
+ }
+
+ gfilename = esc_metachars(filename);
+ if (gfilename == NULL)
+ {
+ /*
+ * Cannot escape metacharacters.
+ */
+ return (NULL);
+ }
+ cmd = (char *) ecalloc(strlen(lessopen) + strlen(gfilename) + 2,
+ sizeof(char));
+ sprintf(cmd, lessopen, gfilename);
+ fd = shellcmd(cmd);
+ free(gfilename);
+ free(cmd);
+ if (fd == NULL)
+ {
+ /*
+ * Cannot create the pipe.
+ */
+ return (NULL);
+ }
+#if HAVE_FILENO
+ if (returnfd)
+ {
+ int f;
+ char c;
+
+ /*
+ * Read one char to see if the pipe will produce any data.
+ * If it does, push the char back on the pipe.
+ */
+ f = fileno(fd);
+ SET_BINARY(f);
+ if (read(f, &c, 1) != 1)
+ {
+ /*
+ * Pipe is empty. This means there is no alt file.
+ */
+ pclose(fd);
+ return (NULL);
+ }
+ ch_ungetchar(c);
+ *pfd = (void *) fd;
+ *pf = f;
+ return (save("-"));
+ }
+#endif
+ gfilename = readfd(fd);
+ pclose(fd);
+ if (*gfilename == '\0')
+ /*
+ * Pipe is empty. This means there is no alt file.
+ */
+ return (NULL);
+ return (gfilename);
+#endif /* HAVE_POPEN */
+}
+
+/*
+ * Close a replacement file.
+ */
+ public void
+close_altfile(altfilename, filename, pipefd)
+ char *altfilename;
+ char *filename;
+ void *pipefd;
+{
+#if HAVE_POPEN
+ char *lessclose;
+ char *gfilename;
+ char *galtfilename;
+ FILE *fd;
+ char *cmd;
+
+ if (secure)
+ return;
+ if (pipefd != NULL)
+ pclose((FILE*) pipefd);
+ if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
+ return;
+ gfilename = esc_metachars(filename);
+ if (gfilename == NULL)
+ {
+ return;
+ }
+ galtfilename = esc_metachars(altfilename);
+ if (galtfilename == NULL)
+ {
+ free(gfilename);
+ return;
+ }
+ cmd = (char *) ecalloc(strlen(lessclose) + strlen(gfilename) +
+ strlen(galtfilename) + 2, sizeof(char));
+ sprintf(cmd, lessclose, gfilename, galtfilename);
+ fd = shellcmd(cmd);
+ free(galtfilename);
+ free(gfilename);
+ free(cmd);
+ if (fd != NULL)
+ pclose(fd);
+#endif
+}
+
+/*
+ * Is the specified file a directory?
+ */
+ public int
+is_dir(filename)
+ char *filename;
+{
+ int isdir = 0;
+
+ filename = unquote_file(filename);
+#if HAVE_STAT
+{
+ int r;
+ struct stat statbuf;
+
+ r = stat(filename, &statbuf);
+ isdir = (r >= 0 && S_ISDIR(statbuf.st_mode));
+}
+#else
+#ifdef _OSK
+{
+ register int f;
+
+ f = open(filename, S_IREAD | S_IFDIR);
+ if (f >= 0)
+ close(f);
+ isdir = (f >= 0);
+}
+#endif
+#endif
+ free(filename);
+ return (isdir);
+}
+
+/*
+ * Returns NULL if the file can be opened and
+ * is an ordinary file, otherwise an error message
+ * (if it cannot be opened or is a directory, etc.)
+ */
+ public char *
+bad_file(filename)
+ char *filename;
+{
+ register char *m = NULL;
+
+ filename = unquote_file(filename);
+ if (is_dir(filename))
+ {
+ static char is_dir[] = " is a directory";
+
+ m = (char *) ecalloc(strlen(filename) + sizeof(is_dir),
+ sizeof(char));
+ strcpy(m, filename);
+ strcat(m, is_dir);
+ } else
+ {
+#if HAVE_STAT
+ int r;
+ struct stat statbuf;
+
+ r = stat(filename, &statbuf);
+ if (r < 0)
+ {
+ m = errno_message(filename);
+ } else if (force_open)
+ {
+ m = NULL;
+ } else if (!S_ISREG(statbuf.st_mode))
+ {
+ static char not_reg[] = " is not a regular file (use -f to see it)";
+ m = (char *) ecalloc(strlen(filename) + sizeof(not_reg),
+ sizeof(char));
+ strcpy(m, filename);
+ strcat(m, not_reg);
+ }
+#endif
+ }
+ free(filename);
+ return (m);
+}
+
+/*
+ * Return the size of a file, as cheaply as possible.
+ * In Unix, we can stat the file.
+ */
+ public POSITION
+filesize(f)
+ int f;
+{
+#if HAVE_STAT
+ struct stat statbuf;
+
+ if (fstat(f, &statbuf) >= 0)
+ return ((POSITION) statbuf.st_size);
+#else
+#ifdef _OSK
+ long size;
+
+ if ((size = (long) _gs_size(f)) >= 0)
+ return ((POSITION) size);
+#endif
+#endif
+ return (seek_filesize(f));
+}
+
diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c
new file mode 100644
index 000000000000..722bce55a0cc
--- /dev/null
+++ b/contrib/less/forwback.c
@@ -0,0 +1,412 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Primitives for displaying the file on the screen,
+ * scrolling either forward or backward.
+ */
+
+#include "less.h"
+#include "position.h"
+
+public int hit_eof; /* Keeps track of how many times we hit end of file */
+public int screen_trashed;
+public int squished;
+public int no_back_scroll = 0;
+
+extern int sigs;
+extern int top_scroll;
+extern int quiet;
+extern int sc_width, sc_height;
+extern int quit_at_eof;
+extern int plusoption;
+extern int forw_scroll;
+extern int back_scroll;
+extern int ignore_eoi;
+extern int clear_bg;
+extern int final_attr;
+#if TAGS
+extern char *tagoption;
+#endif
+
+/*
+ * Sound the bell to indicate user is trying to move past end of file.
+ */
+ static void
+eof_bell()
+{
+ if (quiet == NOT_QUIET)
+ bell();
+ else
+ vbell();
+}
+
+/*
+ * Check to see if the end of file is currently "displayed".
+ */
+ static void
+eof_check()
+{
+ POSITION pos;
+
+ if (ignore_eoi)
+ return;
+ if (ABORT_SIGS())
+ return;
+ /*
+ * If the bottom line is empty, we are at EOF.
+ * If the bottom line ends at the file length,
+ * we must be just at EOF.
+ */
+ pos = position(BOTTOM_PLUS_ONE);
+ if (pos == NULL_POSITION || pos == ch_length())
+ hit_eof++;
+}
+
+/*
+ * If the screen is "squished", repaint it.
+ * "Squished" means the first displayed line is not at the top
+ * of the screen; this can happen when we display a short file
+ * for the first time.
+ */
+ static void
+squish_check()
+{
+ if (!squished)
+ return;
+ squished = 0;
+ repaint();
+}
+
+/*
+ * Display n lines, scrolling forward,
+ * starting at position pos in the input file.
+ * "force" means display the n lines even if we hit end of file.
+ * "only_last" means display only the last screenful if n > screen size.
+ * "nblank" is the number of blank lines to draw before the first
+ * real line. If nblank > 0, the pos must be NULL_POSITION.
+ * The first real line after the blanks will start at ch_zero().
+ */
+ public void
+forw(n, pos, force, only_last, nblank)
+ register int n;
+ POSITION pos;
+ int force;
+ int only_last;
+ int nblank;
+{
+ int eof = 0;
+ int nlines = 0;
+ int do_repaint;
+ static int first_time = 1;
+
+ squish_check();
+
+ /*
+ * do_repaint tells us not to display anything till the end,
+ * then just repaint the entire screen.
+ * We repaint if we are supposed to display only the last
+ * screenful and the request is for more than a screenful.
+ * Also if the request exceeds the forward scroll limit
+ * (but not if the request is for exactly a screenful, since
+ * repainting itself involves scrolling forward a screenful).
+ */
+ do_repaint = (only_last && n > sc_height-1) ||
+ (forw_scroll >= 0 && n > forw_scroll && n != sc_height-1);
+
+ if (!do_repaint)
+ {
+ /*
+ * Forget any current line shift we might have
+ * (from the last line of the previous screenful).
+ */
+ extern int cshift;
+ cshift = 0;
+
+ if (top_scroll && n >= sc_height - 1 && pos != ch_length())
+ {
+ /*
+ * Start a new screen.
+ * {{ This is not really desirable if we happen
+ * to hit eof in the middle of this screen,
+ * but we don't yet know if that will happen. }}
+ */
+ pos_clear();
+ add_forw_pos(pos);
+ force = 1;
+ if (top_scroll == OPT_ONPLUS || first_time)
+ clear();
+ home();
+ } else
+ {
+ clear_bot();
+ }
+
+ if (pos != position(BOTTOM_PLUS_ONE) || empty_screen())
+ {
+ /*
+ * This is not contiguous with what is
+ * currently displayed. Clear the screen image
+ * (position table) and start a new screen.
+ */
+ pos_clear();
+ add_forw_pos(pos);
+ force = 1;
+ if (top_scroll)
+ {
+ if (top_scroll == OPT_ONPLUS)
+ clear();
+ home();
+ } else if (!first_time)
+ {
+ putstr("...skipping...\n");
+ }
+ }
+ }
+
+ while (--n >= 0)
+ {
+ /*
+ * Read the next line of input.
+ */
+ if (nblank > 0)
+ {
+ /*
+ * Still drawing blanks; don't get a line
+ * from the file yet.
+ * If this is the last blank line, get ready to
+ * read a line starting at ch_zero() next time.
+ */
+ if (--nblank == 0)
+ pos = ch_zero();
+ } else
+ {
+ /*
+ * Get the next line from the file.
+ */
+ pos = forw_line(pos);
+ if (pos == NULL_POSITION)
+ {
+ /*
+ * End of file: stop here unless the top line
+ * is still empty, or "force" is true.
+ * Even if force is true, stop when the last
+ * line in the file reaches the top of screen.
+ */
+ eof = 1;
+ if (!force && position(TOP) != NULL_POSITION)
+ break;
+ if (!empty_lines(0, 0) &&
+ !empty_lines(1, 1) &&
+ empty_lines(2, sc_height-1))
+ break;
+ }
+ }
+ /*
+ * Add the position of the next line to the position table.
+ * Display the current line on the screen.
+ */
+ add_forw_pos(pos);
+ nlines++;
+ if (do_repaint)
+ continue;
+ /*
+ * If this is the first screen displayed and
+ * we hit an early EOF (i.e. before the requested
+ * number of lines), we "squish" the display down
+ * at the bottom of the screen.
+ * But don't do this if a + option or a -t option
+ * was given. These options can cause us to
+ * start the display after the beginning of the file,
+ * and it is not appropriate to squish in that case.
+ */
+ if (first_time && pos == NULL_POSITION && !top_scroll &&
+#if TAGS
+ tagoption == NULL &&
+#endif
+ !plusoption)
+ {
+ squished = 1;
+ continue;
+ }
+ if (top_scroll == OPT_ON)
+ clear_eol();
+ put_line();
+ if (clear_bg && final_attr != AT_NORMAL)
+ {
+ /*
+ * Writing the last character on the last line
+ * of the display may have scrolled the screen.
+ * If we were in standout mode, clear_bg terminals
+ * will fill the new line with the standout color.
+ * Now we're in normal mode again, so clear the line.
+ */
+ clear_eol();
+ }
+ }
+
+ if (ignore_eoi)
+ hit_eof = 0;
+ else if (eof && !ABORT_SIGS())
+ hit_eof++;
+ else
+ eof_check();
+ if (nlines == 0)
+ eof_bell();
+ else if (do_repaint)
+ repaint();
+ first_time = 0;
+ (void) currline(BOTTOM);
+}
+
+/*
+ * Display n lines, scrolling backward.
+ */
+ public void
+back(n, pos, force, only_last)
+ register int n;
+ POSITION pos;
+ int force;
+ int only_last;
+{
+ int nlines = 0;
+ int do_repaint;
+
+ squish_check();
+ do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1));
+ hit_eof = 0;
+ while (--n >= 0)
+ {
+ /*
+ * Get the previous line of input.
+ */
+ pos = back_line(pos);
+ if (pos == NULL_POSITION)
+ {
+ /*
+ * Beginning of file: stop here unless "force" is true.
+ */
+ if (!force)
+ break;
+ }
+ /*
+ * Add the position of the previous line to the position table.
+ * Display the line on the screen.
+ */
+ add_back_pos(pos);
+ nlines++;
+ if (!do_repaint)
+ {
+ home();
+ add_line();
+ put_line();
+ }
+ }
+
+ eof_check();
+ if (nlines == 0)
+ eof_bell();
+ else if (do_repaint)
+ repaint();
+ (void) currline(BOTTOM);
+}
+
+/*
+ * Display n more lines, forward.
+ * Start just after the line currently displayed at the bottom of the screen.
+ */
+ public void
+forward(n, force, only_last)
+ int n;
+ int force;
+ int only_last;
+{
+ POSITION pos;
+
+ if (quit_at_eof && hit_eof && !(ch_getflags() & CH_HELPFILE))
+ {
+ /*
+ * If the -e flag is set and we're trying to go
+ * forward from end-of-file, go on to the next file.
+ */
+ if (edit_next(1))
+ quit(QUIT_OK);
+ return;
+ }
+
+ pos = position(BOTTOM_PLUS_ONE);
+ if (pos == NULL_POSITION && (!force || empty_lines(2, sc_height-1)))
+ {
+ if (ignore_eoi)
+ {
+ /*
+ * ignore_eoi is to support A_F_FOREVER.
+ * Back up until there is a line at the bottom
+ * of the screen.
+ */
+ if (empty_screen())
+ pos = ch_zero();
+ else
+ {
+ do
+ {
+ back(1, position(TOP), 1, 0);
+ pos = position(BOTTOM_PLUS_ONE);
+ } while (pos == NULL_POSITION);
+ }
+ } else
+ {
+ eof_bell();
+ hit_eof++;
+ return;
+ }
+ }
+ forw(n, pos, force, only_last, 0);
+}
+
+/*
+ * Display n more lines, backward.
+ * Start just before the line currently displayed at the top of the screen.
+ */
+ public void
+backward(n, force, only_last)
+ int n;
+ int force;
+ int only_last;
+{
+ POSITION pos;
+
+ pos = position(TOP);
+ if (pos == NULL_POSITION && (!force || position(BOTTOM) == 0))
+ {
+ eof_bell();
+ return;
+ }
+ back(n, pos, force, only_last);
+}
+
+/*
+ * Get the backwards scroll limit.
+ * Must call this function instead of just using the value of
+ * back_scroll, because the default case depends on sc_height and
+ * top_scroll, as well as back_scroll.
+ */
+ public int
+get_back_scroll()
+{
+ if (no_back_scroll)
+ return (0);
+ if (back_scroll >= 0)
+ return (back_scroll);
+ if (top_scroll)
+ return (sc_height - 2);
+ return (10000); /* infinity */
+}
diff --git a/contrib/less/funcs.h b/contrib/less/funcs.h
new file mode 100644
index 000000000000..22cb7df6dd7b
--- /dev/null
+++ b/contrib/less/funcs.h
@@ -0,0 +1,240 @@
+ public char * save ();
+ public VOID_POINTER ecalloc ();
+ public char * skipsp ();
+ public int sprefix ();
+ public void quit ();
+ public void raw_mode ();
+ public void scrsize ();
+ public char * special_key_str ();
+ public void get_term ();
+ public void init ();
+ public void deinit ();
+ public void home ();
+ public void add_line ();
+ public void remove_top ();
+ public void lower_left ();
+ public void check_winch ();
+ public void goto_line ();
+ public void vbell ();
+ public void bell ();
+ public void clear ();
+ public void clear_eol ();
+ public void clear_bot ();
+ public void so_enter ();
+ public void so_exit ();
+ public void ul_enter ();
+ public void ul_exit ();
+ public void bo_enter ();
+ public void bo_exit ();
+ public void bl_enter ();
+ public void bl_exit ();
+ public void backspace ();
+ public void putbs ();
+ public char WIN32getch ();
+ public void match_brac ();
+ public void ch_ungetchar ();
+ public void end_logfile ();
+ public void sync_logfile ();
+ public int ch_seek ();
+ public int ch_end_seek ();
+ public int ch_beg_seek ();
+ public POSITION ch_length ();
+ public POSITION ch_tell ();
+ public int ch_forw_get ();
+ public int ch_back_get ();
+ public int ch_nbuf ();
+ public void ch_flush ();
+ public int seekable ();
+ public void ch_init ();
+ public void ch_close ();
+ public int ch_getflags ();
+ public void ch_dump ();
+ public void init_charset ();
+ public int binary_char ();
+ public int control_char ();
+ public char * prchar ();
+ public void cmd_reset ();
+ public void clear_cmd ();
+ public void cmd_putstr ();
+ public int len_cmdbuf ();
+ public void set_mlist ();
+ public void cmd_addhist ();
+ public void cmd_accept ();
+ public int cmd_char ();
+ public int cmd_int ();
+ public char * get_cmdbuf ();
+ public int in_mca ();
+ public void dispversion ();
+ public int getcc ();
+ public void ungetcc ();
+ public void ungetsc ();
+ public void commands ();
+ public void init_cmds ();
+ public void add_fcmd_table ();
+ public void add_ecmd_table ();
+ public int cmd_search ();
+ public int fcmd_decode ();
+ public int ecmd_decode ();
+ public char * lgetenv ();
+ public int lesskey ();
+ public void add_hometable ();
+ public int editchar ();
+ public void init_textlist ();
+ public char * forw_textlist ();
+ public char * back_textlist ();
+ public int edit ();
+ public int edit_ifile ();
+ public int edit_list ();
+ public int edit_first ();
+ public int edit_last ();
+ public int edit_next ();
+ public int edit_prev ();
+ public int edit_index ();
+ public IFILE save_curr_ifile ();
+ public void unsave_ifile ();
+ public void reedit_ifile ();
+ public int edit_stdin ();
+ public void cat_file ();
+ public void use_logfile ();
+ public char * unquote_file ();
+ public char * homefile ();
+ public char * fexpand ();
+ public char * fcomplete ();
+ public int bin_file ();
+ public char * esc_metachars ();
+ public char * esc_metachars ();
+ public char * lglob ();
+ public char * open_altfile ();
+ public void close_altfile ();
+ public int is_dir ();
+ public char * bad_file ();
+ public POSITION filesize ();
+ public void forw ();
+ public void back ();
+ public void forward ();
+ public void backward ();
+ public int get_back_scroll ();
+ public void del_ifile ();
+ public IFILE next_ifile ();
+ public IFILE prev_ifile ();
+ public IFILE getoff_ifile ();
+ public int nifile ();
+ public IFILE get_ifile ();
+ public char * get_filename ();
+ public int get_index ();
+ public void store_pos ();
+ public void get_pos ();
+ public void set_open ();
+ public int opened ();
+ public void hold_ifile ();
+ public int held_ifile ();
+ public void * get_filestate ();
+ public void set_filestate ();
+ public void if_dump ();
+ public POSITION forw_line ();
+ public POSITION back_line ();
+ public void set_attnpos ();
+ public void jump_forw ();
+ public void jump_back ();
+ public void repaint ();
+ public void jump_percent ();
+ public void jump_line_loc ();
+ public void jump_loc ();
+ public void init_line ();
+ public void prewind ();
+ public void plinenum ();
+ public int pappend ();
+ public void pdone ();
+ public int gline ();
+ public void null_line ();
+ public POSITION forw_raw_line ();
+ public POSITION back_raw_line ();
+ public void clr_linenum ();
+ public void add_lnum ();
+ public int find_linenum ();
+ public POSITION find_pos ();
+ public int currline ();
+ public void lsystem ();
+ public int pipe_mark ();
+ public int pipe_data ();
+ public void init_mark ();
+ public int badmark ();
+ public void setmark ();
+ public void lastmark ();
+ public void gomark ();
+ public POSITION markpos ();
+ public void unmark ();
+ public void opt_o ();
+ public void opt__O ();
+ public void opt_l ();
+ public void opt_k ();
+ public void opt_t ();
+ public void opt__T ();
+ public void opt_p ();
+ public void opt__P ();
+ public void opt_b ();
+ public void opt_i ();
+ public void opt__V ();
+ public void opt_D ();
+ public void opt_quote ();
+ public void opt_query ();
+ public int get_swindow ();
+ public void scan_option ();
+ public void toggle_option ();
+ public int single_char_option ();
+ public char * opt_prompt ();
+ public int isoptpending ();
+ public void nopendopt ();
+ public int getnum ();
+ public void init_option ();
+ public struct option * findopt ();
+ public struct option * findopt_name ();
+ public int iread ();
+ public void intread ();
+ public long get_time ();
+ public char * errno_message ();
+ public int percentage ();
+ public POSITION percent_pos ();
+ public int os9_signal ();
+ public int isatty ();
+ public void put_line ();
+ public void flush ();
+ public int putchr ();
+ public void putstr ();
+ public void get_return ();
+ public void error ();
+ public void ierror ();
+ public int query ();
+ public POSITION position ();
+ public void add_forw_pos ();
+ public void add_back_pos ();
+ public void pos_clear ();
+ public void pos_init ();
+ public int onscreen ();
+ public int empty_screen ();
+ public int empty_lines ();
+ public void get_scrpos ();
+ public int adjsline ();
+ public void init_prompt ();
+ public char * pr_expand ();
+ public char * eq_message ();
+ public char * pr_string ();
+ public void repaint_hilite ();
+ public void clear_attn ();
+ public void undo_search ();
+ public void clr_hilite ();
+ public int is_hilited ();
+ public void chg_caseless ();
+ public void chg_hilite ();
+ public int search ();
+ public void prep_hilite ();
+ public RETSIGTYPE winch ();
+ public RETSIGTYPE winch ();
+ public void init_signals ();
+ public void psignals ();
+ public void findtag ();
+ public int edit_tagfile ();
+ public POSITION tagsearch ();
+ public void open_getchr ();
+ public void close_getchr ();
+ public int getchr ();
diff --git a/contrib/less/help.c b/contrib/less/help.c
new file mode 100644
index 000000000000..f964ce224c45
--- /dev/null
+++ b/contrib/less/help.c
@@ -0,0 +1,214 @@
+/* This file was generated by mkhelp from less.hlp */
+#include "less.h"
+constant char helpdata[] = {
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','\b','S','U','\b','U','M','\b','M','M','\b','M','A','\b','A','R','\b','R','Y','\b','Y',' ','O','\b','O','F','\b','F',' ','L','\b','L','E','\b','E','S','\b','S','S','\b','S',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n',
+'\n',
+' ',' ',' ',' ',' ',' ','C','o','m','m','a','n','d','s',' ','m','a','r','k','e','d',' ','w','i','t','h',' ','*',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','n','u','m','b','e','r',',',' ','_','\b','N','.','\n',
+' ',' ',' ',' ',' ',' ','N','o','t','e','s',' ','i','n',' ','p','a','r','e','n','t','h','e','s','e','s',' ','i','n','d','i','c','a','t','e',' ','t','h','e',' ','b','e','h','a','v','i','o','r',' ','i','f',' ','_','\b','N',' ','i','s',' ','g','i','v','e','n','.','\n',
+'\n',
+' ',' ','h',' ',' ','H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','i','s',' ','h','e','l','p','.','\n',
+' ',' ','q',' ',' ',':','q',' ',' ','Q',' ',' ',':','Q',' ',' ','Z','Z',' ',' ',' ',' ',' ','E','x','i','t','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','\b','M','O','\b','O','V','\b','V','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','e',' ',' ','^','E',' ',' ','j',' ',' ','^','N',' ',' ','C','R',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','y',' ',' ','^','Y',' ',' ','k',' ',' ','^','K',' ',' ','^','P',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','f',' ',' ','^','F',' ',' ','^','V',' ',' ','S','P','A','C','E',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','b',' ',' ','^','B',' ',' ','E','S','C','-','v',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','z',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','E','S','C','-','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',',',' ','b','u','t',' ','d','o','n','\'','t',' ','s','t','o','p',' ','a','t',' ','e','n','d','-','o','f','-','f','i','l','e','.','\n',
+' ',' ','d',' ',' ','^','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','E','S','C','-','(',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','8',' ','c','h','a','r','a','c','t','e','r',' ','p','o','s','i','t','i','o','n','s',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
+' ',' ','E','S','C','-',')',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','8',' ','c','h','a','r','a','c','t','e','r',' ','p','o','s','i','t','i','o','n','s',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
+' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n',
+' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','a','u','l','t',' ','"','w','i','n','d','o','w','"',' ','i','s',' ','t','h','e',' ','s','c','r','e','e','n',' ','h','e','i','g','h','t','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','a','u','l','t',' ','"','h','a','l','f','-','w','i','n','d','o','w','"',' ','i','s',' ','h','a','l','f',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n',' ','h','e','i','g','h','t','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','\b','S','E','\b','E','A','\b','A','R','\b','R','C','\b','C','H','\b','H','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','/','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','S','e','a','r','c','h',' ','f','o','r','w','a','r','d',' ','f','o','r',' ','(','_','\b','N','-','t','h',')',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','.','\n',
+' ',' ','?','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','S','e','a','r','c','h',' ','b','a','c','k','w','a','r','d',' ','f','o','r',' ','(','_','\b','N','-','t','h',')',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','.','\n',
+' ',' ','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',' ','(','f','o','r',' ','_','\b','N','-','t','h',' ','o','c','c','u','r','r','e','n','c','e',')','.','\n',
+' ',' ','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',' ','i','n',' ','r','e','v','e','r','s','e',' ','d','i','r','e','c','t','i','o','n','.','\n',
+' ',' ','E','S','C','-','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
+' ',' ','E','S','C','-','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','r','e','v','e','r','s','e',' ','d','i','r','.',' ','&',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
+' ',' ','E','S','C','-','u',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','n','d','o',' ','(','t','o','g','g','l','e',')',' ','s','e','a','r','c','h',' ','h','i','g','h','l','i','g','h','t','i','n','g','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','p','a','t','t','e','r','n','s',' ','m','a','y',' ','b','e',' ','m','o','d','i','f','i','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','N',' ','o','r',' ','!',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','N','O','N','-','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','E',' ','o','r',' ','*',' ',' ','S','e','a','r','c','h',' ','m','u','l','t','i','p','l','e',' ','f','i','l','e','s',' ','(','p','a','s','s',' ','t','h','r','u',' ','E','N','D',' ','O','F',' ','F','I','L','E',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','F',' ','o','r',' ','@',' ',' ','S','t','a','r','t',' ','s','e','a','r','c','h',' ','a','t',' ','F','I','R','S','T',' ','f','i','l','e',' ','(','f','o','r',' ','/',')',' ','o','r',' ','l','a','s','t',' ','f','i','l','e',' ','(','f','o','r',' ','?',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','K',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','m','a','t','c','h','e','s',',',' ','b','u','t',' ','d','o','n','\'','t',' ','m','o','v','e',' ','(','K','E','E','P',' ','p','o','s','i','t','i','o','n',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','R',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','R','E','G','U','L','A','R',' ','E','X','P','R','E','S','S','I','O','N','S','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','J','\b','J','U','\b','U','M','\b','M','P','\b','P','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','g',' ',' ','<',' ',' ','E','S','C','-','<',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','f','i','r','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n',
+' ',' ','G',' ',' ','>',' ',' ','E','S','C','-','>',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','l','a','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n',
+' ',' ','p',' ',' ','%',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','b','e','g','i','n','n','i','n','g',' ','o','f',' ','f','i','l','e',' ','(','o','r',' ','_','\b','N',' ','p','e','r','c','e','n','t',' ','i','n','t','o',' ','f','i','l','e',')','.','\n',
+' ',' ','{',' ',' ','(',' ',' ','[',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','}',' ',')',' ',']','.','\n',
+' ',' ','}',' ',' ',')',' ',' ',']',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','{',' ','(',' ','[','.','\n',
+' ',' ','E','S','C','-','^','F',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>',' ',' ','*',' ',' ','F','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>','.','\n',
+' ',' ','E','S','C','-','^','B',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>',' ',' ','*',' ',' ','F','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','"','f','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t','"',' ','c','o','m','m','a','n','d',' ','g','o','e','s',' ','f','o','r','w','a','r','d',' ','t','o',' ','t','h','e',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','m','a','t','c','h','i','n','g',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','i','n',' ','t','h','e',' ','t','o','p',' ','l','i','n','e','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','"','f','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t','"',' ','c','o','m','m','a','n','d',' ','g','o','e','s',' ','b','a','c','k','w','a','r','d',' ','t','o',' ','t','h','e',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','m','a','t','c','h','i','n','g',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','i','n',' ','t','h','e',' ','b','o','t','t','o','m',' ','l','i','n','e','.','\n',
+'\n',
+' ',' ','m','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','a','r','k',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','p','o','s','i','t','i','o','n',' ','w','i','t','h',' ','<','l','e','t','t','e','r','>','.','\n',
+' ',' ','\'','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','a',' ','p','r','e','v','i','o','u','s','l','y',' ','m','a','r','k','e','d',' ','p','o','s','i','t','i','o','n','.','\n',
+' ',' ','\'','\'',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','o','s','i','t','i','o','n','.','\n',
+' ',' ','^','X','^','X',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','m','e',' ','a','s',' ','\'','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','A',' ','m','a','r','k',' ','i','s',' ','a','n','y',' ','u','p','p','e','r','-','c','a','s','e',' ','o','r',' ','l','o','w','e','r','-','c','a','s','e',' ','l','e','t','t','e','r','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','C','e','r','t','a','i','n',' ','m','a','r','k','s',' ','a','r','e',' ','p','r','e','d','e','f','i','n','e','d',':','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','^',' ',' ','m','e','a','n','s',' ',' ','b','e','g','i','n','n','i','n','g',' ','o','f',' ','t','h','e',' ','f','i','l','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','$',' ',' ','m','e','a','n','s',' ',' ','e','n','d',' ','o','f',' ','t','h','e',' ','f','i','l','e','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','\b','C','H','\b','H','A','\b','A','N','\b','N','G','\b','G','I','\b','I','N','\b','N','G','\b','G',' ','F','\b','F','I','\b','I','L','\b','L','E','\b','E','S','\b','S','\n',
+'\n',
+' ',' ',':','e',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','a','m','i','n','e',' ','a',' ','n','e','w',' ','f','i','l','e','.','\n',
+' ',' ','^','X','^','V',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','m','e',' ','a','s',' ',':','e','.','\n',
+' ',' ',':','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','n','e','x','t',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','p',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','p','r','e','v','i','o','u','s',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','x',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','f','i','r','s','t',' ','(','o','r',' ','_','\b','N','-','t','h',')',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','l','i','s','t','.','\n',
+' ',' ','=',' ',' ','^','G',' ',' ',':','f',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','i','n','t',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','n','a','m','e','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','\b','M','I','\b','I','S','\b','S','C','\b','C','E','\b','E','L','\b','L','L','\b','L','A','\b','A','N','\b','N','E','\b','E','O','\b','O','U','\b','U','S','\b','S',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n',
+'\n',
+' ',' ','-','_','\b','<','_','\b','f','_','\b','l','_','\b','a','_','\b','g','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','o','g','g','l','e',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n',' ','[','s','e','e',' ','O','P','T','I','O','N','S',' ','b','e','l','o','w',']','.','\n',
+' ',' ','-','-','_','\b','<','_','\b','n','_','\b','a','_','\b','m','_','\b','e','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','o','g','g','l','e',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n',',',' ','b','y',' ','n','a','m','e','.','\n',
+' ',' ','_','_','\b','<','_','\b','f','_','\b','l','_','\b','a','_','\b','g','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','s','e','t','t','i','n','g',' ','o','f',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n','.','\n',
+' ',' ','_','_','_','\b','<','_','\b','n','_','\b','a','_','\b','m','_','\b','e','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','s','e','t','t','i','n','g',' ','o','f',' ','a','n',' ','o','p','t','i','o','n',',',' ','b','y',' ','n','a','m','e','.','\n',
+' ',' ','+','_','\b','c','_','\b','m','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','l','e','s','s',' ','c','m','d',' ','e','a','c','h',' ','t','i','m','e',' ','a',' ','n','e','w',' ','f','i','l','e',' ','i','s',' ','e','x','a','m','i','n','e','d','.','\n',
+'\n',
+' ',' ','!','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d',' ','w','i','t','h',' ','$','S','H','E','L','L','.','\n',
+' ',' ','|','X','\b','X','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','i','p','e',' ','f','i','l','e',' ','b','e','t','w','e','e','n',' ','c','u','r','r','e','n','t',' ','p','o','s',' ','&',' ','m','a','r','k',' ','X','\b','X',' ','t','o',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d','.','\n',
+' ',' ','v',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','d','i','t',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','w','i','t','h',' ','$','V','I','S','U','A','L',' ','o','r',' ','$','E','D','I','T','O','R','.','\n',
+' ',' ','V',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','i','n','t',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','O','\b','O','P','\b','P','T','\b','T','I','\b','I','O','\b','O','N','\b','N','S','\b','S','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ','M','o','s','t',' ','o','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','c','h','a','n','g','e','d',' ','e','i','t','h','e','r',' ','o','n',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e',',','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','o','r',' ','f','r','o','m',' ','w','i','t','h','i','n',' ','l','e','s','s',' ','b','y',' ','u','s','i','n','g',' ','t','h','e',' ','-',' ','o','r',' ','-','-',' ','c','o','m','m','a','n','d','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','O','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','g','i','v','e','n',' ','i','n',' ','o','n','e',' ','o','f',' ','t','w','o',' ','f','o','r','m','s',':',' ','e','i','t','h','e','r',' ','a',' ','s','i','n','g','l','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','c','h','a','r','a','c','t','e','r',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','-',',',' ','o','r',' ','a',' ','n','a','m','e',' ','p','r','e','c','e','e','d','e','d',' ','b','y',' ','-','-','.','\n',
+'\n',
+' ',' ','-','?',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','e','l','p','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n',
+' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n',
+' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','a','u','t','o','m','a','t','i','c','a','l','l','y',' ','a','l','l','o','c','a','t','e',' ','b','u','f','f','e','r','s',' ','f','o','r',' ','p','i','p','e','s','.','\n',
+' ',' ','-','c',' ',' ','-','C',' ',' ','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n',' ',' ','-','-','C','L','E','A','R','-','S','C','R','E','E','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','s','c','r','o','l','l','i','n','g','/','c','l','e','a','r','i','n','g','.','\n',
+' ',' ','-','d',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','d','u','m','b','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','u','m','b',' ','t','e','r','m','i','n','a','l','.','\n',
+' ',' ','-','D',' ','[','_','\b','x','_','\b','n','_','\b','.','_','\b','n',']',' ',' ','.',' ',' ','-','-','c','o','l','o','r','=','_','\b','x','_','\b','n','_','\b','.','_','\b','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','c','r','e','e','n',' ','c','o','l','o','r','s','.',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')','\n',
+' ',' ','-','e',' ',' ','-','E',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','t','-','a','t','-','e','o','f',' ',' ','-','-','Q','U','I','T','-','A','T','-','E','O','F','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','a','t',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n',
+' ',' ','-','f',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','r','c','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','c','e',' ','o','p','e','n',' ','n','o','n','-','r','e','g','u','l','a','r',' ','f','i','l','e','s','.','\n',
+' ',' ','-','F',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','q','u','i','t','-','i','f','-','o','n','e','-','s','c','r','e','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','i','f',' ','e','n','t','i','r','e',' ','f','i','l','e',' ','f','i','t','s',' ','o','n',' ','f','i','r','s','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','-','g',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','s','e','a','r','c','h','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','o','n','l','y',' ','l','a','s','t',' ','m','a','t','c','h',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','G',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','S','E','A','R','C','H','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','h','i','g','h','l','i','g','h','t',' ','a','n','y',' ','m','a','t','c','h','e','s',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','h',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','b','a','c','k','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n',
+' ',' ','-','i',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','i','g','n','o','r','e','-','c','a','s','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','s','e','a','r','c','h','e','s',' ','t','h','a','t',' ','d','o',' ','n','o','t',' ','c','o','n','t','a','i','n',' ','u','p','p','e','r','c','a','s','e','.','\n',
+' ',' ','-','I',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','I','G','N','O','R','E','-','C','A','S','E','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','a','l','l',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','j',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','j','u','m','p','-','t','a','r','g','e','t','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','c','r','e','e','n',' ','p','o','s','i','t','i','o','n',' ','o','f',' ','t','a','r','g','e','t',' ','l','i','n','e','s','.','\n',
+' ',' ','-','k',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','e','s','s','k','e','y','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a',' ','l','e','s','s','k','e','y',' ','f','i','l','e','.','\n',
+' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','p','r','o','m','p','t',' ','s','t','y','l','e','.','\n',
+' ',' ','-','n',' ',' ','-','N',' ',' ','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n',
+' ',' ','-','o',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','o','g','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','s','t','a','n','d','a','r','d',' ','i','n','p','u','t',' ','o','n','l','y',')','.','\n',
+' ',' ','-','O',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','L','O','G','-','F','I','L','E','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','u','n','c','o','n','d','i','t','i','o','n','a','l','l','y',' ','o','v','e','r','w','r','i','t','e',')','.','\n',
+' ',' ','-','p',' ','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']',' ',' ','-','-','p','a','t','t','e','r','n','=','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','t','a','r','t',' ','a','t',' ','p','a','t','t','e','r','n',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n',
+' ',' ','-','P',' ','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']',' ',' ',' ','-','-','p','r','o','m','p','t','=','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','i','n','e',' ','n','e','w',' ','p','r','o','m','p','t','.','\n',
+' ',' ','-','q',' ',' ','-','Q',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','e','t',' ',' ','-','-','Q','U','I','E','T',' ',' ','-','-','s','i','l','e','n','t',' ','-','-','S','I','L','E','N','T','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','e','t',' ','t','h','e',' ','t','e','r','m','i','n','a','l',' ','b','e','l','l','.','\n',
+' ',' ','-','r',' ',' ','-','R',' ',' ','.','.','.','.',' ',' ','-','-','r','a','w','-','c','o','n','t','r','o','l','-','c','h','a','r','s',' ',' ','-','-','R','A','W','-','C','O','N','T','R','O','L','-','C','H','A','R','S','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','O','u','t','p','u','t',' ','"','r','a','w','"',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ','-','s',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','q','u','e','e','z','e','-','b','l','a','n','k','-','l','i','n','e','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','q','u','e','e','z','e',' ','m','u','l','t','i','p','l','e',' ','b','l','a','n','k',' ','l','i','n','e','s','.','\n',
+' ',' ','-','S',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','h','o','p','-','l','o','n','g','-','l','i','n','e','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','l','o','n','g',' ','l','i','n','e','s','.','\n',
+' ',' ','-','t',' ','[','_','\b','t','_','\b','a','_','\b','g',']',' ',' ','.','.',' ',' ','-','-','t','a','g','=','[','_','\b','t','_','\b','a','_','\b','g',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','i','n','d',' ','a',' ','t','a','g','.','\n',
+' ',' ','-','T',' ','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ','-','-','t','a','g','-','f','i','l','e','=','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a','n',' ','a','l','t','e','r','n','a','t','e',' ','t','a','g','s',' ','f','i','l','e','.','\n',
+' ',' ','-','u',' ',' ','-','U',' ',' ','.','.','.','.',' ',' ','-','-','u','n','d','e','r','l','i','n','e','-','s','p','e','c','i','a','l',' ',' ','-','-','U','N','D','E','R','L','I','N','E','-','S','P','E','C','I','A','L','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','a','n','g','e',' ','h','a','n','d','l','i','n','g',' ','o','f',' ','b','a','c','k','s','p','a','c','e','s','.','\n',
+' ',' ','-','V',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','v','e','r','s','i','o','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
+' ',' ','-','w',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','u','n','r','e','a','d','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','f','o','r','w','a','r','d','-','s','c','r','e','e','n','.','\n',
+' ',' ','-','W',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','U','N','R','E','A','D','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','a','n','y',' ','f','o','r','w','a','r','d',' ','m','o','v','e','m','e','n','t','.','\n',
+' ',' ','-','x',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','t','a','b','s','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','a','b',' ','s','t','o','p','s','.','\n',
+' ',' ','-','X',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','i','n','i','t','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
+' ',' ','-','y',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','f','o','r','w','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n',
+' ',' ','-','z',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','w','i','n','d','o','w','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','i','z','e',' ','o','f',' ','w','i','n','d','o','w','.','\n',
+' ',' ','-','"',' ','[','_','\b','c','[','_','\b','c',']',']',' ',' ','.',' ',' ','-','-','q','u','o','t','e','s','=','[','_','\b','c','[','_','\b','c',']',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','h','e','l','l',' ','q','u','o','t','e',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ','-','~',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','t','i','l','d','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','d','i','s','p','l','a','y',' ','t','i','l','d','e','s',' ','a','f','t','e','r',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','\b','L','I','\b','I','N','\b','N','E','\b','E',' ','E','\b','E','D','\b','D','I','\b','I','T','\b','T','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ','T','h','e','s','e',' ','k','e','y','s',' ','c','a','n',' ','b','e',' ','u','s','e','d',' ','t','o',' ','e','d','i','t',' ','t','e','x','t',' ','b','e','i','n','g',' ','e','n','t','e','r','e','d',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','o','n',' ','t','h','e',' ','"','c','o','m','m','a','n','d',' ','l','i','n','e','"',' ','a','t',' ','t','h','e',' ','b','o','t','t','o','m',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n','.','\n',
+'\n',
+' ','R','i','g','h','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','l',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
+' ','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','h',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
+' ','C','N','T','L','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n',
+' ','C','N','T','L','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n',
+' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n',
+' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n',
+' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
+' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n',
+' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n',
+' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n',
+' ','C','N','T','L','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n',
+'\n',
+ 0 };
+constant int size_helpdata = sizeof(helpdata) - 1;
diff --git a/contrib/less/ifile.c b/contrib/less/ifile.c
new file mode 100644
index 000000000000..1758a0cc4784
--- /dev/null
+++ b/contrib/less/ifile.c
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * An IFILE represents an input file.
+ *
+ * It is actually a pointer to an ifile structure,
+ * but is opaque outside this module.
+ * Ifile structures are kept in a linked list in the order they
+ * appear on the command line.
+ * Any new file which does not already appear in the list is
+ * inserted after the current file.
+ */
+
+#include "less.h"
+
+extern IFILE curr_ifile;
+
+struct ifile {
+ struct ifile *h_next; /* Links for command line list */
+ struct ifile *h_prev;
+ char *h_filename; /* Name of the file */
+ void *h_filestate; /* File state (used in ch.c) */
+ int h_index; /* Index within command line list */
+ int h_hold; /* Hold count */
+ char h_opened; /* Has this ifile been opened? */
+ struct scrpos h_scrpos; /* Saved position within the file */
+};
+
+/*
+ * Convert an IFILE (external representation)
+ * to a struct file (internal representation), and vice versa.
+ */
+#define int_ifile(h) ((struct ifile *)(h))
+#define ext_ifile(h) ((IFILE)(h))
+
+/*
+ * Anchor for linked list.
+ */
+static struct ifile anchor = { &anchor, &anchor, NULL, NULL, 0, 0, '\0',
+ { NULL_POSITION, 0 } };
+static int ifiles = 0;
+
+ static void
+incr_index(p, incr)
+ register struct ifile *p;
+ int incr;
+{
+ for (; p != &anchor; p = p->h_next)
+ p->h_index += incr;
+}
+
+/*
+ * Link an ifile into the ifile list.
+ */
+ static void
+link_ifile(p, prev)
+ struct ifile *p;
+ struct ifile *prev;
+{
+ /*
+ * Link into list.
+ */
+ if (prev == NULL)
+ prev = &anchor;
+ p->h_next = prev->h_next;
+ p->h_prev = prev;
+ prev->h_next->h_prev = p;
+ prev->h_next = p;
+ /*
+ * Calculate index for the new one,
+ * and adjust the indexes for subsequent ifiles in the list.
+ */
+ p->h_index = prev->h_index + 1;
+ incr_index(p->h_next, 1);
+ ifiles++;
+}
+
+/*
+ * Unlink an ifile from the ifile list.
+ */
+ static void
+unlink_ifile(p)
+ struct ifile *p;
+{
+ p->h_next->h_prev = p->h_prev;
+ p->h_prev->h_next = p->h_next;
+ incr_index(p->h_next, -1);
+ ifiles--;
+}
+
+/*
+ * Allocate a new ifile structure and stick a filename in it.
+ * It should go after "prev" in the list
+ * (or at the beginning of the list if "prev" is NULL).
+ * Return a pointer to the new ifile structure.
+ */
+ static struct ifile *
+new_ifile(filename, prev)
+ char *filename;
+ struct ifile *prev;
+{
+ register struct ifile *p;
+
+ /*
+ * Allocate and initialize structure.
+ */
+ p = (struct ifile *) ecalloc(1, sizeof(struct ifile));
+ p->h_filename = save(filename);
+ p->h_scrpos.pos = NULL_POSITION;
+ p->h_opened = 0;
+ p->h_hold = 0;
+ p->h_filestate = NULL;
+ link_ifile(p, prev);
+ return (p);
+}
+
+/*
+ * Delete an existing ifile structure.
+ */
+ public void
+del_ifile(h)
+ IFILE h;
+{
+ register struct ifile *p;
+
+ if (h == NULL_IFILE)
+ return;
+ /*
+ * If the ifile we're deleting is the currently open ifile,
+ * move off it.
+ */
+ unmark(h);
+ if (h == curr_ifile)
+ curr_ifile = getoff_ifile(curr_ifile);
+ p = int_ifile(h);
+ unlink_ifile(p);
+ free(p->h_filename);
+ free(p);
+}
+
+/*
+ * Get the ifile after a given one in the list.
+ */
+ public IFILE
+next_ifile(h)
+ IFILE h;
+{
+ register struct ifile *p;
+
+ p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
+ if (p->h_next == &anchor)
+ return (NULL_IFILE);
+ return (ext_ifile(p->h_next));
+}
+
+/*
+ * Get the ifile before a given one in the list.
+ */
+ public IFILE
+prev_ifile(h)
+ IFILE h;
+{
+ register struct ifile *p;
+
+ p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
+ if (p->h_prev == &anchor)
+ return (NULL_IFILE);
+ return (ext_ifile(p->h_prev));
+}
+
+/*
+ * Return a different ifile from the given one.
+ */
+ public IFILE
+getoff_ifile(ifile)
+ IFILE ifile;
+{
+ IFILE newifile;
+
+ if ((newifile = prev_ifile(ifile)) != NULL_IFILE)
+ return (newifile);
+ if ((newifile = next_ifile(ifile)) != NULL_IFILE)
+ return (newifile);
+ return (NULL_IFILE);
+}
+
+/*
+ * Return the number of ifiles.
+ */
+ public int
+nifile()
+{
+ return (ifiles);
+}
+
+/*
+ * Find an ifile structure, given a filename.
+ */
+ static struct ifile *
+find_ifile(filename)
+ char *filename;
+{
+ register struct ifile *p;
+
+ for (p = anchor.h_next; p != &anchor; p = p->h_next)
+ if (strcmp(filename, p->h_filename) == 0)
+ return (p);
+ return (NULL);
+}
+
+/*
+ * Get the ifile associated with a filename.
+ * If the filename has not been seen before,
+ * insert the new ifile after "prev" in the list.
+ */
+ public IFILE
+get_ifile(filename, prev)
+ char *filename;
+ IFILE prev;
+{
+ register struct ifile *p;
+
+ if ((p = find_ifile(filename)) == NULL)
+ p = new_ifile(filename, int_ifile(prev));
+ return (ext_ifile(p));
+}
+
+/*
+ * Get the filename associated with a ifile.
+ */
+ public char *
+get_filename(ifile)
+ IFILE ifile;
+{
+ if (ifile == NULL)
+ return (NULL);
+ return (int_ifile(ifile)->h_filename);
+}
+
+/*
+ * Get the index of the file associated with a ifile.
+ */
+ public int
+get_index(ifile)
+ IFILE ifile;
+{
+ return (int_ifile(ifile)->h_index);
+}
+
+/*
+ * Save the file position to be associated with a given file.
+ */
+ public void
+store_pos(ifile, scrpos)
+ IFILE ifile;
+ struct scrpos *scrpos;
+{
+ int_ifile(ifile)->h_scrpos = *scrpos;
+}
+
+/*
+ * Recall the file position associated with a file.
+ * If no position has been associated with the file, return NULL_POSITION.
+ */
+ public void
+get_pos(ifile, scrpos)
+ IFILE ifile;
+ struct scrpos *scrpos;
+{
+ *scrpos = int_ifile(ifile)->h_scrpos;
+}
+
+/*
+ * Mark the ifile as "opened".
+ */
+ public void
+set_open(ifile)
+ IFILE ifile;
+{
+ int_ifile(ifile)->h_opened = 1;
+}
+
+/*
+ * Return whether the ifile has been opened previously.
+ */
+ public int
+opened(ifile)
+ IFILE ifile;
+{
+ return (int_ifile(ifile)->h_opened);
+}
+
+ public void
+hold_ifile(ifile, incr)
+ IFILE ifile;
+ int incr;
+{
+ int_ifile(ifile)->h_hold += incr;
+}
+
+ public int
+held_ifile(ifile)
+ IFILE ifile;
+{
+ return (int_ifile(ifile)->h_hold);
+}
+
+ public void *
+get_filestate(ifile)
+ IFILE ifile;
+{
+ return (int_ifile(ifile)->h_filestate);
+}
+
+ public void
+set_filestate(ifile, filestate)
+ IFILE ifile;
+ void *filestate;
+{
+ int_ifile(ifile)->h_filestate = filestate;
+}
+
+#if 0
+ public void
+if_dump()
+{
+ register struct ifile *p;
+
+ for (p = anchor.h_next; p != &anchor; p = p->h_next)
+ {
+ printf("%x: %d. <%s> pos %d,%x\n",
+ p, p->h_index, p->h_filename,
+ p->h_scrpos.ln, p->h_scrpos.pos);
+ ch_dump(p->h_filestate);
+ }
+}
+#endif
diff --git a/contrib/less/input.c b/contrib/less/input.c
new file mode 100644
index 000000000000..cf7d902296e4
--- /dev/null
+++ b/contrib/less/input.c
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * High level routines dealing with getting lines of input
+ * from the file being viewed.
+ *
+ * When we speak of "lines" here, we mean PRINTABLE lines;
+ * lines processed with respect to the screen width.
+ * We use the term "raw line" to refer to lines simply
+ * delimited by newlines; not processed with respect to screen width.
+ */
+
+#include "less.h"
+
+extern int squeeze;
+extern int chopline;
+extern int quit_if_one_screen;
+extern int sigs;
+extern int ignore_eoi;
+extern POSITION start_attnpos;
+extern POSITION end_attnpos;
+#if HILITE_SEARCH
+extern int hilite_search;
+extern int size_linebuf;
+#endif
+
+/*
+ * Get the next line.
+ * A "current" position is passed and a "new" position is returned.
+ * The current position is the position of the first character of
+ * a line. The new position is the position of the first character
+ * of the NEXT line. The line obtained is the line starting at curr_pos.
+ */
+ public POSITION
+forw_line(curr_pos)
+ POSITION curr_pos;
+{
+ POSITION new_pos;
+ register int c;
+ int blankline;
+ int endline;
+
+ if (curr_pos == NULL_POSITION)
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+#if HILITE_SEARCH
+ if (hilite_search == OPT_ONPLUS)
+ /*
+ * If we are ignoring EOI (command F), only prepare
+ * one line ahead, to avoid getting stuck waiting for
+ * slow data without displaying the data we already have.
+ * If we're not ignoring EOI, we *could* do the same, but
+ * for efficiency we prepare several lines ahead at once.
+ */
+ prep_hilite(curr_pos, curr_pos + 3*size_linebuf,
+ ignore_eoi ? 1 : -1);
+#endif
+ if (ch_seek(curr_pos))
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+
+ prewind();
+ plinenum(curr_pos);
+ (void) ch_seek(curr_pos);
+
+ c = ch_forw_get();
+ if (c == EOI)
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ blankline = (c == '\n' || c == '\r');
+
+ for (;;)
+ {
+ if (ABORT_SIGS())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ if (c == '\n' || c == EOI)
+ {
+ /*
+ * End of the line.
+ */
+ new_pos = ch_tell();
+ endline = TRUE;
+ break;
+ }
+
+ /*
+ * Append the char to the line and get the next char.
+ */
+ if (pappend(c, ch_tell()-1))
+ {
+ /*
+ * The char won't fit in the line; the line
+ * is too long to print in the screen width.
+ * End the line here.
+ */
+ if (chopline)
+ {
+ do
+ {
+ c = ch_forw_get();
+ } while (c != '\n' && c != EOI);
+ new_pos = ch_tell();
+ endline = TRUE;
+ quit_if_one_screen = FALSE;
+ } else
+ {
+ new_pos = ch_tell() - 1;
+ endline = FALSE;
+ }
+ break;
+ }
+ c = ch_forw_get();
+ }
+ pdone(endline);
+
+ if (squeeze && blankline)
+ {
+ /*
+ * This line is blank.
+ * Skip down to the last contiguous blank line
+ * and pretend it is the one which we are returning.
+ */
+ while ((c = ch_forw_get()) == '\n' || c == '\r')
+ if (ABORT_SIGS())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ if (c != EOI)
+ (void) ch_back_get();
+ new_pos = ch_tell();
+ }
+
+ return (new_pos);
+}
+
+/*
+ * Get the previous line.
+ * A "current" position is passed and a "new" position is returned.
+ * The current position is the position of the first character of
+ * a line. The new position is the position of the first character
+ * of the PREVIOUS line. The line obtained is the one starting at new_pos.
+ */
+ public POSITION
+back_line(curr_pos)
+ POSITION curr_pos;
+{
+ POSITION new_pos, begin_new_pos;
+ int c;
+ int endline;
+
+ if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+#if HILITE_SEARCH
+ if (hilite_search == OPT_ONPLUS)
+ prep_hilite((curr_pos < 3*size_linebuf) ?
+ 0 : curr_pos - 3*size_linebuf, curr_pos, -1);
+#endif
+ if (ch_seek(curr_pos-1))
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+
+ if (squeeze)
+ {
+ /*
+ * Find out if the "current" line was blank.
+ */
+ (void) ch_forw_get(); /* Skip the newline */
+ c = ch_forw_get(); /* First char of "current" line */
+ (void) ch_back_get(); /* Restore our position */
+ (void) ch_back_get();
+
+ if (c == '\n' || c == '\r')
+ {
+ /*
+ * The "current" line was blank.
+ * Skip over any preceding blank lines,
+ * since we skipped them in forw_line().
+ */
+ while ((c = ch_back_get()) == '\n' || c == '\r')
+ if (ABORT_SIGS())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ if (c == EOI)
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ (void) ch_forw_get();
+ }
+ }
+
+ /*
+ * Scan backwards until we hit the beginning of the line.
+ */
+ for (;;)
+ {
+ if (ABORT_SIGS())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ c = ch_back_get();
+ if (c == '\n')
+ {
+ /*
+ * This is the newline ending the previous line.
+ * We have hit the beginning of the line.
+ */
+ new_pos = ch_tell() + 1;
+ break;
+ }
+ if (c == EOI)
+ {
+ /*
+ * We have hit the beginning of the file.
+ * This must be the first line in the file.
+ * This must, of course, be the beginning of the line.
+ */
+ new_pos = ch_tell();
+ break;
+ }
+ }
+
+ /*
+ * Now scan forwards from the beginning of this line.
+ * We keep discarding "printable lines" (based on screen width)
+ * until we reach the curr_pos.
+ *
+ * {{ This algorithm is pretty inefficient if the lines
+ * are much longer than the screen width,
+ * but I don't know of any better way. }}
+ */
+ if (ch_seek(new_pos))
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ endline = FALSE;
+ loop:
+ begin_new_pos = new_pos;
+ prewind();
+ plinenum(new_pos);
+ (void) ch_seek(new_pos);
+
+ do
+ {
+ c = ch_forw_get();
+ if (c == EOI || ABORT_SIGS())
+ {
+ null_line();
+ return (NULL_POSITION);
+ }
+ new_pos++;
+ if (c == '\n')
+ {
+ endline = TRUE;
+ break;
+ }
+ if (pappend(c, ch_tell()-1))
+ {
+ /*
+ * Got a full printable line, but we haven't
+ * reached our curr_pos yet. Discard the line
+ * and start a new one.
+ */
+ if (chopline)
+ {
+ endline = TRUE;
+ quit_if_one_screen = FALSE;
+ break;
+ }
+ pdone(0);
+ (void) ch_back_get();
+ new_pos--;
+ goto loop;
+ }
+ } while (new_pos < curr_pos);
+
+ pdone(endline);
+
+ return (begin_new_pos);
+}
+
+/*
+ * Set attnpos.
+ */
+ public void
+set_attnpos(pos)
+ POSITION pos;
+{
+ int c;
+
+ if (pos != NULL_POSITION)
+ {
+ if (ch_seek(pos))
+ return;
+ for (;;)
+ {
+ c = ch_forw_get();
+ if (c == EOI)
+ return;
+ if (c != '\n' && c != '\r')
+ break;
+ pos++;
+ }
+ }
+ start_attnpos = pos;
+ for (;;)
+ {
+ c = ch_forw_get();
+ pos++;
+ if (c == EOI || c == '\n' || c == '\r')
+ break;
+ }
+ end_attnpos = pos;
+}
diff --git a/contrib/less/install.sh b/contrib/less/install.sh
new file mode 100755
index 000000000000..0ff4b6a08e80
--- /dev/null
+++ b/contrib/less/install.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+#
+# install - install a program, script, or datafile
+# This comes from X11R5; it is not part of GNU.
+#
+# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+
+instcmd="$mvprog"
+chmodcmd=""
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+fi
+
+if [ x"$dst" = x ]
+then
+ echo "install: no destination specified"
+ exit 1
+fi
+
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+if [ -d $dst ]
+then
+ dst="$dst"/`basename $src`
+fi
+
+# Make a temp file name in the proper directory.
+
+dstdir=`dirname $dst`
+dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+$doit $instcmd $src $dsttmp
+
+# and set any options; do chmod last to preserve setuid bits
+
+if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
+if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
+if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
+if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
+
+# Now rename the file to the real destination.
+
+$doit $rmcmd $dst
+$doit $mvcmd $dsttmp $dst
+
+
+exit 0
diff --git a/contrib/less/jump.c b/contrib/less/jump.c
new file mode 100644
index 000000000000..a8f9c6aec1f6
--- /dev/null
+++ b/contrib/less/jump.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines which jump to a new location in the file.
+ */
+
+#include "less.h"
+#include "position.h"
+
+extern int hit_eof;
+extern int jump_sline;
+extern int squished;
+extern int screen_trashed;
+extern int sc_width, sc_height;
+extern int show_attn;
+
+/*
+ * Jump to the end of the file.
+ */
+ public void
+jump_forw()
+{
+ POSITION pos;
+
+ if (ch_end_seek())
+ {
+ error("Cannot seek to end of file", NULL_PARG);
+ return;
+ }
+ /*
+ * Position the last line in the file at the last screen line.
+ * Go back one line from the end of the file
+ * to get to the beginning of the last line.
+ */
+ pos = back_line(ch_tell());
+ if (pos == NULL_POSITION)
+ jump_loc((POSITION)0, sc_height-1);
+ else
+ jump_loc(pos, sc_height-1);
+}
+
+/*
+ * Jump to line n in the file.
+ */
+ public void
+jump_back(n)
+ int n;
+{
+ POSITION pos;
+ PARG parg;
+
+ /*
+ * Find the position of the specified line.
+ * If we can seek there, just jump to it.
+ * If we can't seek, but we're trying to go to line number 1,
+ * use ch_beg_seek() to get as close as we can.
+ */
+ pos = find_pos(n);
+ if (pos != NULL_POSITION && ch_seek(pos) == 0)
+ {
+ if (show_attn)
+ set_attnpos(pos);
+ jump_loc(pos, jump_sline);
+ } else if (n <= 1 && ch_beg_seek() == 0)
+ {
+ jump_loc(ch_tell(), jump_sline);
+ error("Cannot seek to beginning of file", NULL_PARG);
+ } else
+ {
+ parg.p_int = n;
+ error("Cannot seek to line number %d", &parg);
+ }
+}
+
+/*
+ * Repaint the screen.
+ */
+ public void
+repaint()
+{
+ struct scrpos scrpos;
+ /*
+ * Start at the line currently at the top of the screen
+ * and redisplay the screen.
+ */
+ get_scrpos(&scrpos);
+ pos_clear();
+ jump_loc(scrpos.pos, scrpos.ln);
+}
+
+/*
+ * Jump to a specified percentage into the file.
+ */
+ public void
+jump_percent(percent)
+ int percent;
+{
+ POSITION pos, len;
+
+ /*
+ * Determine the position in the file
+ * (the specified percentage of the file's length).
+ */
+ if ((len = ch_length()) == NULL_POSITION)
+ {
+ ierror("Determining length of file", NULL_PARG);
+ ch_end_seek();
+ }
+ if ((len = ch_length()) == NULL_POSITION)
+ {
+ error("Don't know length of file", NULL_PARG);
+ return;
+ }
+ pos = percent_pos(len, percent);
+ if (pos >= len)
+ pos = len-1;
+
+ jump_line_loc(pos, jump_sline);
+}
+
+/*
+ * Jump to a specified position in the file.
+ * Like jump_loc, but the position need not be
+ * the first character in a line.
+ */
+ public void
+jump_line_loc(pos, sline)
+ POSITION pos;
+ int sline;
+{
+ int c;
+
+ if (ch_seek(pos) == 0)
+ {
+ /*
+ * Back up to the beginning of the line.
+ */
+ while ((c = ch_back_get()) != '\n' && c != EOI)
+ ;
+ if (c == '\n')
+ (void) ch_forw_get();
+ pos = ch_tell();
+ }
+ if (show_attn)
+ set_attnpos(pos);
+ jump_loc(pos, sline);
+}
+
+/*
+ * Jump to a specified position in the file.
+ * The position must be the first character in a line.
+ * Place the target line on a specified line on the screen.
+ */
+ public void
+jump_loc(pos, sline)
+ POSITION pos;
+ int sline;
+{
+ register int nline;
+ POSITION tpos;
+ POSITION bpos;
+
+ /*
+ * Normalize sline.
+ */
+ sline = adjsline(sline);
+
+ if ((nline = onscreen(pos)) >= 0)
+ {
+ /*
+ * The line is currently displayed.
+ * Just scroll there.
+ */
+ nline -= sline;
+ if (nline > 0)
+ forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0);
+ else
+ back(-nline, position(TOP), 1, 0);
+ if (show_attn)
+ repaint_hilite(1);
+ return;
+ }
+
+ /*
+ * Line is not on screen.
+ * Seek to the desired location.
+ */
+ if (ch_seek(pos))
+ {
+ error("Cannot seek to that file position", NULL_PARG);
+ return;
+ }
+
+ /*
+ * See if the desired line is before or after
+ * the currently displayed screen.
+ */
+ tpos = position(TOP);
+ bpos = position(BOTTOM_PLUS_ONE);
+ if (tpos == NULL_POSITION || pos >= tpos)
+ {
+ /*
+ * The desired line is after the current screen.
+ * Move back in the file far enough so that we can
+ * call forw() and put the desired line at the
+ * sline-th line on the screen.
+ */
+ for (nline = 0; nline < sline; nline++)
+ {
+ if (bpos != NULL_POSITION && pos <= bpos)
+ {
+ /*
+ * Surprise! The desired line is
+ * close enough to the current screen
+ * that we can just scroll there after all.
+ */
+ forw(sc_height-sline+nline-1, bpos, 1, 0, 0);
+ if (show_attn)
+ repaint_hilite(1);
+ return;
+ }
+ pos = back_line(pos);
+ if (pos == NULL_POSITION)
+ {
+ /*
+ * Oops. Ran into the beginning of the file.
+ * Exit the loop here and rely on forw()
+ * below to draw the required number of
+ * blank lines at the top of the screen.
+ */
+ break;
+ }
+ }
+ lastmark();
+ hit_eof = 0;
+ squished = 0;
+ screen_trashed = 0;
+ forw(sc_height-1, pos, 1, 0, sline-nline);
+ } else
+ {
+ /*
+ * The desired line is before the current screen.
+ * Move forward in the file far enough so that we
+ * can call back() and put the desired line at the
+ * sline-th line on the screen.
+ */
+ for (nline = sline; nline < sc_height - 1; nline++)
+ {
+ pos = forw_line(pos);
+ if (pos == NULL_POSITION)
+ {
+ /*
+ * Ran into end of file.
+ * This shouldn't normally happen,
+ * but may if there is some kind of read error.
+ */
+ break;
+ }
+ if (pos >= tpos)
+ {
+ /*
+ * Surprise! The desired line is
+ * close enough to the current screen
+ * that we can just scroll there after all.
+ */
+ back(nline+1, tpos, 1, 0);
+ if (show_attn)
+ repaint_hilite(1);
+ return;
+ }
+ }
+ lastmark();
+ clear();
+ screen_trashed = 0;
+ add_back_pos(pos);
+ back(sc_height-1, pos, 1, 0);
+ }
+}
diff --git a/contrib/less/less.h b/contrib/less/less.h
new file mode 100644
index 000000000000..021b2df5e0e7
--- /dev/null
+++ b/contrib/less/less.h
@@ -0,0 +1,382 @@
+/*
+ * Copyright (C) 1984-2000 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Standard include file for "less".
+ */
+
+/*
+ * Defines for MSDOS_COMPILER.
+ */
+#define MSOFTC 1 /* Microsoft C */
+#define BORLANDC 2 /* Borland C */
+#define WIN32C 3 /* Windows (Borland C or Microsoft C) */
+#define DJGPPC 4 /* DJGPP C */
+
+/*
+ * Include the file of compile-time options.
+ * The <> make cc search for it in -I., not srcdir.
+ */
+#include <defines.h>
+
+#ifdef _SEQUENT_
+/*
+ * Kludge for Sequent Dynix systems that have sigsetmask, but
+ * it's not compatible with the way less calls it.
+ * {{ Do other systems need this? }}
+ */
+#undef HAVE_SIGSETMASK
+#endif
+
+/*
+ * Language details.
+ */
+#if HAVE_VOID
+#define VOID_POINTER void *
+#else
+#define VOID_POINTER char *
+#define void int
+#endif
+#if HAVE_CONST
+#define constant const
+#else
+#define constant
+#endif
+
+#define public /* PUBLIC FUNCTION */
+
+/* Library function declarations */
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef _OSK
+#include <modes.h>
+#include <strings.h>
+#endif
+#if MSDOS_COMPILER==WIN32C
+#include <io.h>
+#endif
+#if MSDOS_COMPILER==DJGPPC
+#include <io.h>
+#include <sys/exceptn.h>
+#include <conio.h>
+#include <pc.h>
+#endif
+
+#if !HAVE_STDLIB_H
+char *getenv();
+off_t lseek();
+VOID_POINTER calloc();
+void free();
+#endif
+
+/*
+ * Simple lowercase test which can be used during option processing
+ * (before options are parsed which might tell us what charset to use).
+ */
+#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
+#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
+#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A')
+#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a')
+
+#if !HAVE_UPPER_LOWER
+#define isupper(c) SIMPLE_IS_UPPER(c)
+#define islower(c) SIMPLE_IS_LOWER(c)
+#define toupper(c) SIMPLE_TO_UPPER(c)
+#define tolower(c) SIMPLE_TO_LOWER(c)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define OPT_OFF 0
+#define OPT_ON 1
+#define OPT_ONPLUS 2
+
+#if !HAVE_MEMCPY
+#ifndef memcpy
+#define memcpy(to,from,len) bcopy((from),(to),(len))
+#endif
+#endif
+
+#define BAD_LSEEK ((off_t)-1)
+
+/*
+ * Special types and constants.
+ */
+typedef long POSITION;
+#define PR_POSITION "%ld"
+#define MAX_PRINT_POSITION 20
+#define MAX_PRINT_INT 10
+
+#define NULL_POSITION ((POSITION)(-1))
+
+/*
+ * Flags for open()
+ */
+#if MSDOS_COMPILER || OS2
+#define OPEN_READ (O_RDONLY|O_BINARY)
+#else
+#ifdef _OSK
+#define OPEN_READ (S_IREAD)
+#else
+#ifdef O_RDONLY
+#define OPEN_READ (O_RDONLY)
+#else
+#define OPEN_READ (0)
+#endif
+#endif
+#endif
+
+#if defined(O_WRONLY) && defined(O_APPEND)
+#define OPEN_APPEND (O_APPEND|O_WRONLY)
+#else
+#ifdef _OSK
+#define OPEN_APPEND (S_IWRITE)
+#else
+#define OPEN_APPEND (1)
+#endif
+#endif
+
+/*
+ * Set a file descriptor to binary mode.
+ */
+#if MSDOS_COMPILER==MSOFTC
+#define SET_BINARY(f) _setmode(f, _O_BINARY);
+#else
+#if MSDOS_COMPILER
+#define SET_BINARY(f) setmode(f, O_BINARY)
+#else
+#define SET_BINARY(f)
+#endif
+#endif
+
+/*
+ * Does the shell treat "?" as a metacharacter?
+ */
+#if MSDOS_COMPILER || OS2 || _OSK
+#define SHELL_META_QUEST 0
+#else
+#define SHELL_META_QUEST 1
+#endif
+
+#define SPACES_IN_FILENAMES 1
+
+/*
+ * An IFILE represents an input file.
+ */
+#define IFILE VOID_POINTER
+#define NULL_IFILE ((IFILE)NULL)
+
+/*
+ * The structure used to represent a "screen position".
+ * This consists of a file position, and a screen line number.
+ * The meaning is that the line starting at the given file
+ * position is displayed on the ln-th line of the screen.
+ * (Screen lines before ln are empty.)
+ */
+struct scrpos
+{
+ POSITION pos;
+ int ln;
+};
+
+typedef union parg
+{
+ char *p_string;
+ int p_int;
+} PARG;
+
+#define NULL_PARG ((PARG *)NULL)
+
+struct textlist
+{
+ char *string;
+ char *endstring;
+};
+
+#define EOI (-1)
+
+#define READ_INTR (-2)
+
+/* How quiet should we be? */
+#define NOT_QUIET 0 /* Ring bell at eof and for errors */
+#define LITTLE_QUIET 1 /* Ring bell only for errors */
+#define VERY_QUIET 2 /* Never ring bell */
+
+/* How should we prompt? */
+#define PR_SHORT 0 /* Prompt with colon */
+#define PR_MEDIUM 1 /* Prompt with message */
+#define PR_LONG 2 /* Prompt with longer message */
+
+/* How should we handle backspaces? */
+#define BS_SPECIAL 0 /* Do special things for underlining and bold */
+#define BS_NORMAL 1 /* \b treated as normal char; actually output */
+#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
+
+/* How should we search? */
+#define SRCH_FORW 000001 /* Search forward from current position */
+#define SRCH_BACK 000002 /* Search backward from current position */
+#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */
+#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */
+#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */
+#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */
+#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */
+#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */
+
+#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
+ (((t) & ~SRCH_FORW) | SRCH_BACK) : \
+ (((t) & ~SRCH_BACK) | SRCH_FORW))
+
+/* */
+#define NO_MCA 0
+#define MCA_DONE 1
+#define MCA_MORE 2
+
+#define CC_OK 0 /* Char was accepted & processed */
+#define CC_QUIT 1 /* Char was a request to abort current cmd */
+#define CC_ERROR 2 /* Char could not be accepted due to error */
+#define CC_PASS 3 /* Char was rejected (internal) */
+
+#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
+
+/* Special chars used to tell put_line() to do something special */
+#define AT_NORMAL (0)
+#define AT_UNDERLINE (1)
+#define AT_BOLD (2)
+#define AT_BLINK (3)
+#define AT_INVIS (4)
+#define AT_STANDOUT (5)
+
+#if IS_EBCDIC_HOST
+/*
+ * Long definition for EBCDIC.
+ * Since the argument is usually a constant, this macro normally compiles
+ * into a constant.
+ */
+#define CONTROL(c) ( \
+ (c)=='[' ? '\047' : \
+ (c)=='a' ? '\001' : \
+ (c)=='b' ? '\002' : \
+ (c)=='c' ? '\003' : \
+ (c)=='d' ? '\067' : \
+ (c)=='e' ? '\055' : \
+ (c)=='f' ? '\056' : \
+ (c)=='g' ? '\057' : \
+ (c)=='h' ? '\026' : \
+ (c)=='i' ? '\005' : \
+ (c)=='j' ? '\025' : \
+ (c)=='k' ? '\013' : \
+ (c)=='l' ? '\014' : \
+ (c)=='m' ? '\015' : \
+ (c)=='n' ? '\016' : \
+ (c)=='o' ? '\017' : \
+ (c)=='p' ? '\020' : \
+ (c)=='q' ? '\021' : \
+ (c)=='r' ? '\022' : \
+ (c)=='s' ? '\023' : \
+ (c)=='t' ? '\074' : \
+ (c)=='u' ? '\075' : \
+ (c)=='v' ? '\062' : \
+ (c)=='w' ? '\046' : \
+ (c)=='x' ? '\030' : \
+ (c)=='y' ? '\031' : \
+ (c)=='z' ? '\077' : \
+ (c)=='A' ? '\001' : \
+ (c)=='B' ? '\002' : \
+ (c)=='C' ? '\003' : \
+ (c)=='D' ? '\067' : \
+ (c)=='E' ? '\055' : \
+ (c)=='F' ? '\056' : \
+ (c)=='G' ? '\057' : \
+ (c)=='H' ? '\026' : \
+ (c)=='I' ? '\005' : \
+ (c)=='J' ? '\025' : \
+ (c)=='K' ? '\013' : \
+ (c)=='L' ? '\014' : \
+ (c)=='M' ? '\015' : \
+ (c)=='N' ? '\016' : \
+ (c)=='O' ? '\017' : \
+ (c)=='P' ? '\020' : \
+ (c)=='Q' ? '\021' : \
+ (c)=='R' ? '\022' : \
+ (c)=='S' ? '\023' : \
+ (c)=='T' ? '\074' : \
+ (c)=='U' ? '\075' : \
+ (c)=='V' ? '\062' : \
+ (c)=='W' ? '\046' : \
+ (c)=='X' ? '\030' : \
+ (c)=='Y' ? '\031' : \
+ (c)=='Z' ? '\077' : \
+ (c)=='|' ? '\031' : \
+ (c)=='\\' ? '\034' : \
+ (c)=='^' ? '\036' : \
+ (c)&077)
+#else
+#define CONTROL(c) ((c)&037)
+#endif /* IS_EBCDIC_HOST */
+
+#define ESC CONTROL('[')
+
+#if _OSK_MWC32
+#define LSIGNAL(sig,func) os9_signal(sig,func)
+#else
+#define LSIGNAL(sig,func) signal(sig,func)
+#endif
+
+#define S_INTERRUPT 01
+#define S_STOP 02
+#define S_WINCH 04
+#define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
+
+#define QUIT_OK 0
+#define QUIT_ERROR 1
+#define QUIT_SAVED_STATUS (-1)
+
+/* filestate flags */
+#define CH_CANSEEK 001
+#define CH_KEEPOPEN 002
+#define CH_POPENED 004
+#define CH_HELPFILE 010
+
+#define ch_zero() ((POSITION)0)
+
+#define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@"
+
+#include "funcs.h"
+
diff --git a/contrib/less/less.hlp b/contrib/less/less.hlp
new file mode 100644
index 000000000000..89361a789c64
--- /dev/null
+++ b/contrib/less/less.hlp
@@ -0,0 +1,209 @@
+
+ SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS
+
+ Commands marked with * may be preceded by a number, _N.
+ Notes in parentheses indicate the behavior if _N is given.
+
+ h H Display this help.
+ q :q Q :Q ZZ Exit.
+ ---------------------------------------------------------------------------
+
+ MMOOVVIINNGG
+
+ e ^E j ^N CR * Forward one line (or _N lines).
+ y ^Y k ^K ^P * Backward one line (or _N lines).
+ f ^F ^V SPACE * Forward one window (or _N lines).
+ b ^B ESC-v * Backward one window (or _N lines).
+ z * Forward one window (and set window to _N).
+ w * Backward one window (and set window to _N).
+ ESC-SPACE * Forward one window, but don't stop at end-of-file.
+ d ^D * Forward one half-window (and set half-window to _N).
+ u ^U * Backward one half-window (and set half-window to _N).
+ ESC-( RightArrow * Left 8 character positions (or _N positions).
+ ESC-) LeftArrow * Right 8 character positions (or _N positions).
+ F Forward forever; like "tail -f".
+ r ^R ^L Repaint screen.
+ R Repaint screen, discarding buffered input.
+ ---------------------------------------------------
+ Default "window" is the screen height.
+ Default "half-window" is half of the screen height.
+ ---------------------------------------------------------------------------
+
+ SSEEAARRCCHHIINNGG
+
+ /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line.
+ ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line.
+ n * Repeat previous search (for _N-th occurrence).
+ N * Repeat previous search in reverse direction.
+ ESC-n * Repeat previous search, spanning files.
+ ESC-N * Repeat previous search, reverse dir. & spanning files.
+ ESC-u Undo (toggle) search highlighting.
+ ---------------------------------------------------
+ Search patterns may be modified by one or more of:
+ ^N or ! Search for NON-matching lines.
+ ^E or * Search multiple files (pass thru END OF FILE).
+ ^F or @ Start search at FIRST file (for /) or last file (for ?).
+ ^K Highlight matches, but don't move (KEEP position).
+ ^R Don't use REGULAR EXPRESSIONS.
+ ---------------------------------------------------------------------------
+
+ JJUUMMPPIINNGG
+
+ g < ESC-< * Go to first line in file (or line _N).
+ G > ESC-> * Go to last line in file (or line _N).
+ p % * Go to beginning of file (or _N percent into file).
+ { ( [ * Find close bracket } ) ].
+ } ) ] * Find open bracket { ( [.
+ ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
+ ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>
+ ---------------------------------------------------
+ Each "find close bracket" command goes forward to the close bracket
+ matching the (_N-th) open bracket in the top line.
+ Each "find open bracket" command goes backward to the open bracket
+ matching the (_N-th) close bracket in the bottom line.
+
+ m_<_l_e_t_t_e_r_> Mark the current position with <letter>.
+ '_<_l_e_t_t_e_r_> Go to a previously marked position.
+ '' Go to the previous position.
+ ^X^X Same as '.
+ ---------------------------------------------------
+ A mark is any upper-case or lower-case letter.
+ Certain marks are predefined:
+ ^ means beginning of the file
+ $ means end of the file
+ ---------------------------------------------------------------------------
+
+ CCHHAANNGGIINNGG FFIILLEESS
+
+ :e [_f_i_l_e] Examine a new file.
+ ^X^V Same as :e.
+ :n * Examine the (_N-th) next file from the command line.
+ :p * Examine the (_N-th) previous file from the command line.
+ :x * Examine the first (or _N-th) file from the command line.
+ :d Delete the current file from the command line list.
+ = ^G :f Print current file name.
+ ---------------------------------------------------------------------------
+
+ MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS
+
+ -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below].
+ --_<_n_a_m_e_> Toggle a command line option, by name.
+ __<_f_l_a_g_> Display the setting of a command line option.
+ ___<_n_a_m_e_> Display the setting of an option, by name.
+ +_c_m_d Execute the less cmd each time a new file is examined.
+
+ !_c_o_m_m_a_n_d Execute the shell command with $SHELL.
+ |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
+ v Edit the current file with $VISUAL or $EDITOR.
+ V Print version number of "less".
+ ---------------------------------------------------------------------------
+
+ OOPPTTIIOONNSS
+
+ Most options may be changed either on the command line,
+ or from within less by using the - or -- command.
+ Options may be given in one of two forms: either a single
+ character preceded by a -, or a name preceeded by --.
+
+ -? ........ --help
+ Display help (from command line).
+ -a ........ --search-skip-screen
+ Forward search skips current screen.
+ -b [_N] .... --buffers=[_N]
+ Number of buffers.
+ -B ........ --auto-buffers
+ Don't automatically allocate buffers for pipes.
+ -c -C .... --clear-screen --CLEAR-SCREEN
+ Repaint by scrolling/clearing.
+ -d ........ --dumb
+ Dumb terminal.
+ -D [_x_n_._n] . --color=_x_n_._n
+ Set screen colors. (MS-DOS only)
+ -e -E .... --quit-at-eof --QUIT-AT-EOF
+ Quit at end of file.
+ -f ........ --force
+ Force open non-regular files.
+ -F ........ --quit-if-one-screen
+ Quit if entire file fits on first screen.
+ -g ........ --hilite-search
+ Highlight only last match for searches.
+ -G ........ --HILITE-SEARCH
+ Don't highlight any matches for searches.
+ -h [_N] .... --max-back-scroll=[_N]
+ Backward scroll limit.
+ -i ........ --ignore-case
+ Ignore case in searches that do not contain uppercase.
+ -I ........ --IGNORE-CASE
+ Ignore case in all searches.
+ -j [_N] .... --jump-target=[_N]
+ Screen position of target lines.
+ -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e]
+ Use a lesskey file.
+ -m -M .... --long-prompt --LONG-PROMPT
+ Set prompt style.
+ -n -N .... --line-numbers --LINE-NUMBERS
+ Use line numbers.
+ -o [_f_i_l_e] . --log-file=[_f_i_l_e]
+ Copy to log file (standard input only).
+ -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e]
+ Copy to log file (unconditionally overwrite).
+ -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n]
+ Start at pattern (from command line).
+ -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t]
+ Define new prompt.
+ -q -Q .... --quiet --QUIET --silent --SILENT
+ Quiet the terminal bell.
+ -r -R .... --raw-control-chars --RAW-CONTROL-CHARS
+ Output "raw" control characters.
+ -s ........ --squeeze-blank-lines
+ Squeeze multiple blank lines.
+ -S ........ --chop-long-lines
+ Chop long lines.
+ -t [_t_a_g] .. --tag=[_t_a_g]
+ Find a tag.
+ -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
+ Use an alternate tags file.
+ -u -U .... --underline-special --UNDERLINE-SPECIAL
+ Change handling of backspaces.
+ -V ........ --version
+ Display the version number of "less".
+ -w ........ --hilite-unread
+ Highlight first new line after forward-screen.
+ -W ........ --HILITE-UNREAD
+ Highlight first new line after any forward movement.
+ -x [_N] .... --tabs=[_N]
+ Set tab stops.
+ -X ........ --no-init
+ Don't use termcap init/deinit strings.
+ -y [_N] .... --max-forw-scroll=[_N]
+ Forward scroll limit.
+ -z [_N] .... --window=[_N]
+ Set size of window.
+ -" [_c[_c]] . --quotes=[_c[_c]]
+ Set shell quote characters.
+ -~ ........ --tilde
+ Don't display tildes after end of file.
+ ---------------------------------------------------------------------------
+
+ LLIINNEE EEDDIITTIINNGG
+
+ These keys can be used to edit text being entered
+ on the "command line" at the bottom of the screen.
+
+ RightArrow ESC-l Move cursor right one character.
+ LeftArrow ESC-h Move cursor left one character.
+ CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word.
+ CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word.
+ HOME ESC-0 Move cursor to start of line.
+ END ESC-$ Move cursor to end of line.
+ BACKSPACE Delete char to left of cursor.
+ DELETE ESC-x Delete char under cursor.
+ CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor.
+ CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor.
+ CNTL-U ESC (MS-DOS only) Delete entire line.
+ UpArrow ESC-k Retrieve previous command line.
+ DownArrow ESC-j Retrieve next command line.
+ TAB Complete filename & cycle.
+ SHIFT-TAB ESC-TAB Complete filename & reverse cycle.
+ CNTL-L Complete filename, list all.
+
diff --git a/contrib/less/less.man b/contrib/less/less.man
new file mode 100644
index 000000000000..e0d317aeb221
--- /dev/null
+++ b/contrib/less/less.man
@@ -0,0 +1,1914 @@
+
+
+
+LESS(1) LESS(1)
+
+
+NNAAMMEE
+ less - opposite of more
+
+SSYYNNOOPPSSIISS
+ lleessss --??
+ lleessss ----hheellpp
+ lleessss --VV
+ lleessss ----vveerrssiioonn
+ lleessss [[--[[++]]aaBBccCCddeeEEffggGGiiIImmMMnnNNqqQQrrssSSuuUUVVwwXX]]
+ [[--bb _b_u_f_s]] [[--hh _l_i_n_e_s]] [[--jj _l_i_n_e]] [[--kk _k_e_y_f_i_l_e]]
+ [[--{{ooOO}} _l_o_g_f_i_l_e]] [[--pp _p_a_t_t_e_r_n]] [[--PP _p_r_o_m_p_t]] [[--tt _t_a_g]]
+ [[--TT _t_a_g_s_f_i_l_e]] [[--xx _t_a_b]] [[--yy _l_i_n_e_s]] [[--[[zz]] _l_i_n_e_s]]
+ [[++[[++]]_c_m_d]] [[----]] [[_f_i_l_e_n_a_m_e]]......
+ (See the OPTIONS section for alternate option syntax with
+ long option names.)
+
+
+DDEESSCCRRIIPPTTIIOONN
+ _L_e_s_s is a program similar to _m_o_r_e (1), but which allows
+ backward movement in the file as well as forward movement.
+ Also, _l_e_s_s does not have to read the entire input file
+ before starting, so with large input files it starts up
+ faster than text editors like _v_i (1). _L_e_s_s uses termcap
+ (or terminfo on some systems), so it can run on a variety
+ of terminals. There is even limited support for hardcopy
+ terminals. (On a hardcopy terminal, lines which should be
+ printed at the top of the screen are prefixed with a
+ caret.)
+
+ Commands are based on both _m_o_r_e and _v_i_. Commands may be
+ preceded by a decimal number, called N in the descriptions
+ below. The number is used by some commands, as indicated.
+
+
+CCOOMMMMAANNDDSS
+ In the following descriptions, ^X means control-X. ESC
+ stands for the ESCAPE key; for example ESC-v means the two
+ character sequence "ESCAPE", then "v".
+
+ h or H Help: display a summary of these commands. If you
+ forget all the other commands, remember this one.
+
+ SPACE or ^V or f or ^F
+ Scroll forward N lines, default one window (see
+ option -z below). If N is more than the screen
+ size, only the final screenful is displayed. Warn-
+ ing: some systems use ^V as a special literaliza-
+ tion character.
+
+ z Like SPACE, but if N is specified, it becomes the
+ new window size.
+
+ ESC-SPACE
+ Like SPACE, but scrolls a full screenful, even if
+
+
+
+ Version 354: 23 Mar 2000 1
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ it reaches end-of-file in the process.
+
+ RETURN or ^N or e or ^E or j or ^J
+ Scroll forward N lines, default 1. The entire N
+ lines are displayed, even if N is more than the
+ screen size.
+
+ d or ^D
+ Scroll forward N lines, default one half of the
+ screen size. If N is specified, it becomes the new
+ default for subsequent d and u commands.
+
+ b or ^B or ESC-v
+ Scroll backward N lines, default one window (see
+ option -z below). If N is more than the screen
+ size, only the final screenful is displayed.
+
+ w Like ESC-v, but if N is specified, it becomes the
+ new window size.
+
+ y or ^Y or ^P or k or ^K
+ Scroll backward N lines, default 1. The entire N
+ lines are displayed, even if N is more than the
+ screen size. Warning: some systems use ^Y as a
+ special job control character.
+
+ u or ^U
+ Scroll backward N lines, default one half of the
+ screen size. If N is specified, it becomes the new
+ default for subsequent d and u commands.
+
+ ESC-) or RIGHTARROW
+ Scroll horizontally right N characters, default 8.
+ This behaves best if you also set the -S option
+ (chop lines). Note that if you wish to enter a
+ number N, you must use ESC-), not RIGHTARROW,
+ because the arrow is taken to be a line editing
+ command (see the LINE EDITING section).
+
+ ESC-( or LEFTARROW
+ Scroll horizontally left N characters, default 8.
+
+ r or ^R or ^L
+ Repaint the screen.
+
+ R Repaint the screen, discarding any buffered input.
+ Useful if the file is changing while it is being
+ viewed.
+
+ F Scroll forward, and keep trying to read when the
+ end of file is reached. Normally this command
+ would be used when already at the end of the file.
+ It is a way to monitor the tail of a file which is
+ growing while it is being viewed. (The behavior is
+
+
+
+ Version 354: 23 Mar 2000 2
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ similar to the "tail -f" command.)
+
+ g or < or ESC-<
+ Go to line N in the file, default 1 (beginning of
+ file). (Warning: this may be slow if N is large.)
+
+ G or > or ESC->
+ Go to line N in the file, default the end of the
+ file. (Warning: this may be slow if N is large, or
+ if N is not specified and standard input, rather
+ than a file, is being read.)
+
+ p or % Go to a position N percent into the file. N should
+ be between 0 and 100.
+
+ { If a left curly bracket appears in the top line
+ displayed on the screen, the { command will go to
+ the matching right curly bracket. The matching
+ right curly bracket is positioned on the bottom
+ line of the screen. If there is more than one left
+ curly bracket on the top line, a number N may be
+ used to specify the N-th bracket on the line.
+
+ } If a right curly bracket appears in the bottom line
+ displayed on the screen, the } command will go to
+ the matching left curly bracket. The matching left
+ curly bracket is positioned on the top line of the
+ screen. If there is more than one right curly
+ bracket on the top line, a number N may be used to
+ specify the N-th bracket on the line.
+
+ ( Like {, but applies to parentheses rather than
+ curly brackets.
+
+ ) Like }, but applies to parentheses rather than
+ curly brackets.
+
+ [ Like {, but applies to square brackets rather than
+ curly brackets.
+
+ ] Like }, but applies to square brackets rather than
+ curly brackets.
+
+ ESC-^F Followed by two characters, acts like {, but uses
+ the two characters as open and close brackets,
+ respectively. For example, "ESC ^F < >" could be
+ used to go forward to the > which matches the < in
+ the top displayed line.
+
+ ESC-^B Followed by two characters, acts like }, but uses
+ the two characters as open and close brackets,
+ respectively. For example, "ESC ^B < >" could be
+ used to go backward to the < which matches the > in
+ the bottom displayed line.
+
+
+
+ Version 354: 23 Mar 2000 3
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ m Followed by any lowercase letter, marks the current
+ position with that letter.
+
+ ' (Single quote.) Followed by any lowercase letter,
+ returns to the position which was previously marked
+ with that letter. Followed by another single
+ quote, returns to the position at which the last
+ "large" movement command was executed. Followed by
+ a ^ or $, jumps to the beginning or end of the file
+ respectively. Marks are preserved when a new file
+ is examined, so the ' command can be used to switch
+ between input files.
+
+ ^X^X Same as single quote.
+
+ /pattern
+ Search forward in the file for the N-th line con-
+ taining the pattern. N defaults to 1. The pattern
+ is a regular expression, as recognized by _e_d_. The
+ search starts at the second line displayed (but see
+ the -a and -j options, which change this).
+
+ Certain characters are special if entered at the
+ beginning of the pattern; they modify the type of
+ search rather than become part of the pattern:
+
+ ^N or !
+ Search for lines which do NOT match the pat-
+ tern.
+
+ ^E or *
+ Search multiple files. That is, if the
+ search reaches the END of the current file
+ without finding a match, the search contin-
+ ues in the next file in the command line
+ list.
+
+ ^F or @
+ Begin the search at the first line of the
+ FIRST file in the command line list, regard-
+ less of what is currently displayed on the
+ screen or the settings of the -a or -j
+ options.
+
+ ^K Highlight any text which matches the pattern
+ on the current screen, but don't move to the
+ first match (KEEP current position).
+
+ ^R Don't interpret regular expression metachar-
+ acters; that is, do a simple textual compar-
+ ison.
+
+ ?pattern
+ Search backward in the file for the N-th line
+
+
+
+ Version 354: 23 Mar 2000 4
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ containing the pattern. The search starts at the
+ line immediately before the top line displayed.
+
+ Certain characters are special as in the / command:
+
+ ^N or !
+ Search for lines which do NOT match the pat-
+ tern.
+
+ ^E or *
+ Search multiple files. That is, if the
+ search reaches the beginning of the current
+ file without finding a match, the search
+ continues in the previous file in the com-
+ mand line list.
+
+ ^F or @
+ Begin the search at the last line of the
+ last file in the command line list, regard-
+ less of what is currently displayed on the
+ screen or the settings of the -a or -j
+ options.
+
+ ^K As in forward searches.
+
+ ^R As in forward searches.
+
+ ESC-/pattern
+ Same as "/*".
+
+ ESC-?pattern
+ Same as "?*".
+
+ n Repeat previous search, for N-th line containing
+ the last pattern. If the previous search was modi-
+ fied by ^N, the search is made for the N-th line
+ NOT containing the pattern. If the previous search
+ was modified by ^E, the search continues in the
+ next (or previous) file if not satisfied in the
+ current file. If the previous search was modified
+ by ^R, the search is done without using regular
+ expressions. There is no effect if the previous
+ search was modified by ^F or ^K.
+
+ N Repeat previous search, but in the reverse direc-
+ tion.
+
+ ESC-n Repeat previous search, but crossing file bound-
+ aries. The effect is as if the previous search
+ were modified by *.
+
+ ESC-N Repeat previous search, but in the reverse direc-
+ tion and crossing file boundaries.
+
+
+
+
+ Version 354: 23 Mar 2000 5
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ ESC-u Undo search highlighting. Turn off highlighting of
+ strings matching the current search pattern. If
+ highlighting is already off because of a previous
+ ESC-u command, turn highlighting back on. Any
+ search command will also turn highlighting back on.
+ (Highlighting can also be disabled by toggling the
+ -G option; in that case search commands do not turn
+ highlighting back on.)
+
+ :e [filename]
+ Examine a new file. If the filename is missing,
+ the "current" file (see the :n and :p commands
+ below) from the list of files in the command line
+ is re-examined. A percent sign (%) in the filename
+ is replaced by the name of the current file. A
+ pound sign (#) is replaced by the name of the pre-
+ viously examined file. However, two consecutive
+ percent signs are simply replaced with a single
+ percent sign. This allows you to enter a filename
+ that contains a percent sign in the name. Simi-
+ larly, two consecutive pound signs are replaced
+ with a single pound sign. The filename is inserted
+ into the command line list of files so that it can
+ be seen by subsequent :n and :p commands. If the
+ filename consists of several files, they are all
+ inserted into the list of files and the first one
+ is examined. If the filename contains one or more
+ spaces, the entire filename should be enclosed in
+ double quotes (also see the -" option).
+
+ ^X^V or E
+ Same as :e. Warning: some systems use ^V as a spe-
+ cial literalization character. On such systems,
+ you may not be able to use ^V.
+
+ :n Examine the next file (from the list of files given
+ in the command line). If a number N is specified,
+ the N-th next file is examined.
+
+ :p Examine the previous file in the command line list.
+ If a number N is specified, the N-th previous file
+ is examined.
+
+ :x Examine the first file in the command line list.
+ If a number N is specified, the N-th file in the
+ list is examined.
+
+ :d Remove the current file from the list of files.
+
+ = or ^G or :f
+ Prints some information about the file being
+ viewed, including its name and the line number and
+ byte offset of the bottom line being displayed. If
+ possible, it also prints the length of the file,
+
+
+
+ Version 354: 23 Mar 2000 6
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ the number of lines in the file and the percent of
+ the file above the last displayed line.
+
+ - Followed by one of the command line option letters
+ (see OPTIONS below), this will change the setting
+ of that option and print a message describing the
+ new setting. If a ^P (CONTROL-P) is entered imme-
+ diately after the dash, the setting of the option
+ is changed but no message is printed. If the
+ option letter has a numeric value (such as -b or
+ -h), or a string value (such as -P or -t), a new
+ value may be entered after the option letter. If
+ no new value is entered, a message describing the
+ current setting is printed and nothing is changed.
+
+ -- Like the - command, but takes a long option name
+ (see OPTIONS below) rather than a single option
+ letter. You must press RETURN after typing the
+ option name. A ^P immediately after the second
+ dash suppresses printing of a message describing
+ the new setting, as in the - command.
+
+ -+ Followed by one of the command line option letters
+ this will reset the option to its default setting
+ and print a message describing the new setting.
+ (The "-+_X" command does the same thing as "-+_X" on
+ the command line.) This does not work for string-
+ valued options.
+
+ --+ Like the -+ command, but takes a long option name
+ rather than a single option letter.
+
+ -! Followed by one of the command line option letters,
+ this will reset the option to the "opposite" of its
+ default setting and print a message describing the
+ new setting. This does not work for numeric or
+ string-valued options.
+
+ --! Like the -! command, but takes a long option name
+ rather than a single option letter.
+
+ _ (Underscore.) Followed by one of the command line
+ option letters, this will print a message describ-
+ ing the current setting of that option. The set-
+ ting of the option is not changed.
+
+ __ (Double underscore.) Like the _ (underscore) com-
+ mand, but takes a long option name rather than a
+ single option letter. You must press RETURN after
+ typing the option name.
+
+ +cmd Causes the specified cmd to be executed each time a
+ new file is examined. For example, +G causes _l_e_s_s
+ to initially display each file starting at the end
+
+
+
+ Version 354: 23 Mar 2000 7
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ rather than the beginning.
+
+ V Prints the version number of _l_e_s_s being run.
+
+ q or Q or :q or :Q or ZZ
+ Exits _l_e_s_s_.
+
+ The following four commands may or may not be valid,
+ depending on your particular installation.
+
+
+ v Invokes an editor to edit the current file being
+ viewed. The editor is taken from the environment
+ variable VISUAL if defined, or EDITOR if VISUAL is
+ not defined, or defaults to "vi" if neither VISUAL
+ nor EDITOR is defined. See also the discussion of
+ LESSEDIT under the section on PROMPTS below.
+
+ ! shell-command
+ Invokes a shell to run the shell-command given. A
+ percent sign (%) in the command is replaced by the
+ name of the current file. A pound sign (#) is
+ replaced by the name of the previously examined
+ file. "!!" repeats the last shell command. "!"
+ with no shell command simply invokes a shell. On
+ Unix systems, the shell is taken from the environ-
+ ment variable SHELL, or defaults to "sh". On MS-
+ DOS and OS/2 systems, the shell is the normal com-
+ mand processor.
+
+ | <m> shell-command
+ <m> represents any mark letter. Pipes a section of
+ the input file to the given shell command. The
+ section of the file to be piped is between the
+ first line on the current screen and the position
+ marked by the letter. <m> may also be ^ or $ to
+ indicate beginning or end of file respectively. If
+ <m> is . or newline, the current screen is piped.
+
+ s filename
+ Save the input to a file. This only works if the
+ input is a pipe, not an ordinary file.
+
+
+OOPPTTIIOONNSS
+ Command line options are described below. Most options
+ may be changed while _l_e_s_s is running, via the "-" command.
+
+ Most options may be given in one of two forms: either a
+ dash followed by a single letter, or two dashes followed
+ by a long option name. A long option name may be abbrevi-
+ ated as long as the abbreviation is unambiguous. For
+ example, --quit-at-eof may be abbreviated --quit, but not
+ --qui, since both --quit-at-eof and --quiet begin with
+
+
+
+ Version 354: 23 Mar 2000 8
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ --qui. Some long option names are in uppercase, such as
+ --QUIT-AT-EOF, as distinct from --quit-at-eof. Such
+ option names need only have their first letter capital-
+ ized; the remainder of the name may be in either case.
+ For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
+
+ Options are also taken from the environment variable
+ "LESS". For example, to avoid typing "less -options ..."
+ each time _l_e_s_s is invoked, you might tell _c_s_h_:
+
+ setenv LESS "-options"
+
+ or if you use _s_h_:
+
+ LESS="-options"; export LESS
+
+ On MS-DOS, you don't need the quotes, but you should
+ replace any percent signs in the options string by double
+ percent signs.
+
+ The environment variable is parsed before the command
+ line, so command line options override the LESS environ-
+ ment variable. If an option appears in the LESS variable,
+ it can be reset to its default value on the command line
+ by beginning the command line option with "-+".
+
+ For options like -P or -D which take a following string, a
+ dollar sign ($) must be used to signal the end of the
+ string. For example, to set two -D options on MS-DOS, you
+ must have a dollar sign between them, like this:
+
+ LESS="-Dn9.1$-Ds4.1"
+
+
+ -? or --help
+ This option displays a summary of the commands
+ accepted by _l_e_s_s (the same as the h command).
+ (Depending on how your shell interprets the ques-
+ tion mark, it may be necessary to quote the ques-
+ tion mark, thus: "-\?".)
+
+ -a or --search-skip-screen
+ Causes searches to start after the last line dis-
+ played on the screen, thus skipping all lines dis-
+ played on the screen. By default, searches start
+ at the second line on the screen (or after the last
+ found line; see the -j option).
+
+ -b_n or --buffers=_n
+ Specifies the number of buffers _l_e_s_s will use for
+ each file. Buffers are 1K, and by default 10
+ buffers are used for each file (except if the file
+ is a pipe; see the -B option). The number _n speci-
+ fies a different number of buffers to use.
+
+
+
+ Version 354: 23 Mar 2000 9
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ -B or --auto-buffers
+ By default, when data is read from a pipe, buffers
+ are allocated automatically as needed. If a large
+ amount of data is read from the pipe, this can
+ cause a large amount of memory to be allocated.
+ The -B option disables this automatic allocation of
+ buffers for pipes, so that only the number of
+ buffers specified by the -b option are used. Warn-
+ ing: use of -B can result in erroneous display,
+ since only the most recently viewed part of the
+ file is kept in memory; any earlier data is lost.
+
+ -c or --clear-screen
+ Causes full screen repaints to be painted from the
+ top line down. By default, full screen repaints
+ are done by scrolling from the bottom of the
+ screen.
+
+ -C or --CLEAR-SCREEN
+ The -C option is like -c, but the screen is cleared
+ before it is repainted.
+
+ -d or --dumb
+ The -d option suppresses the error message normally
+ displayed if the terminal is dumb; that is, lacks
+ some important capability, such as the ability to
+ clear the screen or scroll backward. The -d option
+ does not otherwise change the behavior of _l_e_s_s on a
+ dumb terminal).
+
+ -Dxx_c_o_l_o_r or --color=xx_c_o_l_o_r
+ [MS-DOS only] Sets the color of the text displayed.
+ xx is a single character which selects the type of
+ text whose color is being set: n=normal, s=stand-
+ out, d=bold, u=underlined, k=blink. _c_o_l_o_r is a
+ pair of numbers separated by a period. The first
+ number selects the foreground color and the second
+ selects the background color of the text. A single
+ number _N is the same as _N_._0.
+
+ -e or --quit-at-eof
+ Causes _l_e_s_s to automatically exit the second time
+ it reaches end-of-file. By default, the only way
+ to exit _l_e_s_s is via the "q" command.
+
+ -E or --QUIT-AT-EOF
+ Causes _l_e_s_s to automatically exit the first time it
+ reaches end-of-file.
+
+ -f or --force
+ Forces non-regular files to be opened. (A non-reg-
+ ular file is a directory or a device special file.)
+ Also suppresses the warning message when a binary
+ file is opened. By default, _l_e_s_s will refuse to
+
+
+
+ Version 354: 23 Mar 2000 10
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ open non-regular files.
+
+ -F or --quit-if-one-screen
+ Causes _l_e_s_s to automatically exit if the entire
+ file can be displayed on the first screen.
+
+ -g or --hilite-search
+ Normally, _l_e_s_s will highlight ALL strings which
+ match the last search command. The -g option
+ changes this behavior to highlight only the partic-
+ ular string which was found by the last search com-
+ mand. This can cause _l_e_s_s to run somewhat faster
+ than the default.
+
+ -G or --HILITE-SEARCH
+ The -G option suppresses all highlighting of
+ strings found by search commands.
+
+ -h_n or ---max-back-scroll=_n
+ Specifies a maximum number of lines to scroll back-
+ ward. If it is necessary to scroll backward more
+ than _n lines, the screen is repainted in a forward
+ direction instead. (If the terminal does not have
+ the ability to scroll backward, -h0 is implied.)
+
+ -i or --ignore-case
+ Causes searches to ignore case; that is, uppercase
+ and lowercase are considered identical. This
+ option is ignored if any uppercase letters appear
+ in the search pattern; in other words, if a pattern
+ contains uppercase letters, then that search does
+ not ignore case.
+
+ -I or --IGNORE-CASE
+ Like -i, but searches ignore case even if the pat-
+ tern contains uppercase letters.
+
+ -j_n or --jump-target=_n
+ Specifies a line on the screen where the "target"
+ line is to be positioned. A target line is the
+ object of a text search, tag search, jump to a line
+ number, jump to a file percentage, or jump to a
+ marked position. The screen line is specified by a
+ number: the top line on the screen is 1, the next
+ is 2, and so on. The number may be negative to
+ specify a line relative to the bottom of the
+ screen: the bottom line on the screen is -1, the
+ second to the bottom is -2, and so on. If the -j
+ option is used, searches begin at the line immedi-
+ ately after the target line. For example, if "-j4"
+ is used, the target line is the fourth line on the
+ screen, so searches begin at the fifth line on the
+ screen.
+
+
+
+
+ Version 354: 23 Mar 2000 11
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ -k_f_i_l_e_n_a_m_e or --lesskey-file=_f_i_l_e_n_a_m_e
+ Causes _l_e_s_s to open and interpret the named file as
+ a _l_e_s_s_k_e_y (1) file. Multiple -k options may be
+ specified. If the LESSKEY or LESSKEY_SYSTEM envi-
+ ronment variable is set, or if a lesskey file is
+ found in a standard place (see KEY BINDINGS), it is
+ also used as a _l_e_s_s_k_e_y file.
+
+ -m or --long-prompt
+ Causes _l_e_s_s to prompt verbosely (like _m_o_r_e), with
+ the percent into the file. By default, _l_e_s_s
+ prompts with a colon.
+
+ -M or --LONG-PROMPT
+ Causes _l_e_s_s to prompt even more verbosely than
+ _m_o_r_e_.
+
+ -n or --line-numbers
+ Suppresses line numbers. The default (to use line
+ numbers) may cause _l_e_s_s to run more slowly in some
+ cases, especially with a very large input file.
+ Suppressing line numbers with the -n option will
+ avoid this problem. Using line numbers means: the
+ line number will be displayed in the verbose prompt
+ and in the = command, and the v command will pass
+ the current line number to the editor (see also the
+ discussion of LESSEDIT in PROMPTS below).
+
+ -N or --LINE-NUMBERS
+ Causes a line number to be displayed at the begin-
+ ning of each line in the display.
+
+ -o_f_i_l_e_n_a_m_e or --log-file=_f_i_l_e_n_a_m_e
+ Causes _l_e_s_s to copy its input to the named file as
+ it is being viewed. This applies only when the
+ input file is a pipe, not an ordinary file. If the
+ file already exists, _l_e_s_s will ask for confirmation
+ before overwriting it.
+
+ -O_f_i_l_e_n_a_m_e or --LOG-FILE=_f_i_l_e_n_a_m_e
+ The -O option is like -o, but it will overwrite an
+ existing file without asking for confirmation.
+
+ If no log file has been specified, the -o and -O
+ options can be used from within _l_e_s_s to specify a
+ log file. Without a file name, they will simply
+ report the name of the log file. The "s" command
+ is equivalent to specifying -o from within _l_e_s_s_.
+
+ -p_p_a_t_t_e_r_n or --pattern=_p_a_t_t_e_r_n
+ The -p option on the command line is equivalent to
+ specifying +/_p_a_t_t_e_r_n; that is, it tells _l_e_s_s to
+ start at the first occurrence of _p_a_t_t_e_r_n in the
+ file.
+
+
+
+ Version 354: 23 Mar 2000 12
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ -P_p_r_o_m_p_t or --prompt=_p_r_o_m_p_t
+ Provides a way to tailor the three prompt styles to
+ your own preference. This option would normally be
+ put in the LESS environment variable, rather than
+ being typed in with each _l_e_s_s command. Such an
+ option must either be the last option in the LESS
+ variable, or be terminated by a dollar sign. -Ps
+ followed by a string changes the default (short)
+ prompt to that string. -Pm changes the medium (-m)
+ prompt. -PM changes the long (-M) prompt. -Ph
+ changes the prompt for the help screen. -P=
+ changes the message printed by the = command. All
+ prompt strings consist of a sequence of letters and
+ special escape sequences. See the section on
+ PROMPTS for more details.
+
+ -q or --quiet or --silent
+ Causes moderately "quiet" operation: the terminal
+ bell is not rung if an attempt is made to scroll
+ past the end of the file or before the beginning of
+ the file. If the terminal has a "visual bell", it
+ is used instead. The bell will be rung on certain
+ other errors, such as typing an invalid character.
+ The default is to ring the terminal bell in all
+ such cases.
+
+ -Q or --QUIET or --SILENT
+ Causes totally "quiet" operation: the terminal bell
+ is never rung.
+
+ -r or --raw-control-chars
+ Causes "raw" control characters to be displayed.
+ The default is to display control characters using
+ the caret notation; for example, a control-A (octal
+ 001) is displayed as "^A". Warning: when the -r
+ option is used, _l_e_s_s cannot keep track of the
+ actual appearance of the screen (since this depends
+ on how the screen responds to each type of control
+ character). Thus, various display problems may
+ result, such as long lines being split in the wrong
+ place.
+
+ -R or --RAW-CONTROL-CHARS
+ Like -r, but tries to keep track of the screen
+ appearance where possible. This works only if the
+ input consists of normal text and possibly some
+ ANSI "color" escape sequences, which are sequences
+ of the form:
+
+ ESC [ ... m
+
+ where the "..." is zero or more characters other
+ than "m". For the purpose of keeping track of
+ screen appearance, all control characters and all
+
+
+
+ Version 354: 23 Mar 2000 13
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ ANSI color escape sequences are assumed to not move
+ the cursor. You can make _l_e_s_s think that charac-
+ ters other than "m" can end ANSI color escape
+ sequences by setting the environment variable
+ LESSANSIENDCHARS to the list of characters which
+ can end a color escape sequence.
+
+ -s or --squeeze-blank-lines
+ Causes consecutive blank lines to be squeezed into
+ a single blank line. This is useful when viewing
+ _n_r_o_f_f output.
+
+ -S or --chop-long-lines
+ Causes lines longer than the screen width to be
+ chopped rather than folded. That is, the remainder
+ of a long line is simply discarded. The default is
+ to fold long lines; that is, display the remainder
+ on the next line.
+
+ -t_t_a_g or --tag=_t_a_g
+ The -t option, followed immediately by a TAG, will
+ edit the file containing that tag. For this to
+ work, there must be a file called "tags" in the
+ current directory, which was previously built by
+ the _c_t_a_g_s (1) command. This option may also be
+ specified from within _l_e_s_s (using the - command) as
+ a way of examining a new file. The command ":t" is
+ equivalent to specifying -t from within _l_e_s_s_.
+
+ -T_t_a_g_s_f_i_l_e or --tag-file=_t_a_g_s_f_i_l_e
+ Specifies a tags file to be used instead of "tags".
+
+ -u or --underline-special
+ Causes backspaces and carriage returns to be
+ treated as printable characters; that is, they are
+ sent to the terminal when they appear in the input.
+
+ -U or --UNDERLINE-SPECIAL
+ Causes backspaces, tabs and carriage returns to be
+ treated as control characters; that is, they are
+ handled as specified by the -r option.
+
+ By default, if neither -u nor -U is given,
+ backspaces which appear adjacent to an underscore
+ character are treated specially: the underlined
+ text is displayed using the terminal's hardware
+ underlining capability. Also, backspaces which
+ appear between two identical characters are treated
+ specially: the overstruck text is printed using the
+ terminal's hardware boldface capability. Other
+ backspaces are deleted, along with the preceding
+ character. Carriage returns immediately followed
+ by a newline are deleted. other carriage returns
+ are handled as specified by the -r option. Text
+
+
+
+ Version 354: 23 Mar 2000 14
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ which is overstruck or underlined can be searched
+ for if neither -u nor -U is in effect.
+
+ -V or --version
+ Displays the version number of _l_e_s_s_.
+
+ -w or --hilite-unread
+ Temporarily highlights the first "new" line after a
+ forward movement of a full page. The first "new"
+ line is the line immediately following the line
+ previously at the bottom of the screen. Also high-
+ lights the target line after a g or p command. The
+ highlight is removed at the next command which
+ causes movement.
+
+ -W or --HILITE-UNREAD
+ Like -w, but temporarily highlights the first new
+ line after any forward movement command larger than
+ one line.
+
+ -x_n or --tabs=_n
+ Sets tab stops every _n positions. The default for
+ _n is 8.
+
+ -X or --no-init
+ Disables sending the termcap initialization and
+ deinitialization strings to the terminal. This is
+ sometimes desirable if the deinitialization string
+ does something unnecessary, like clearing the
+ screen.
+
+ -y_n or --max-forw-scroll=_n
+ Specifies a maximum number of lines to scroll for-
+ ward. If it is necessary to scroll forward more
+ than _n lines, the screen is repainted instead. The
+ -c or -C option may be used to repaint from the top
+ of the screen if desired. By default, any forward
+ movement causes scrolling.
+
+ -[z]_n or --window=_n
+ Changes the default scrolling window size to _n
+ lines. The default is one screenful. The z and w
+ commands can also be used to change the window
+ size. The "z" may be omitted for compatibility
+ with _m_o_r_e_. If the number _n is negative, it indi-
+ cates _n lines less than the current screen size.
+ For example, if the screen is 24 lines, _-_z_-_4 sets
+ the scrolling window to 20 lines. If the screen is
+ resized to 40 lines, the scrolling window automati-
+ cally changes to 36 lines.
+
+ -"_c_c or --quotes=_c_c
+ Changes the filename quoting character. This may
+ be necessary if you are trying to name a file which
+
+
+
+ Version 354: 23 Mar 2000 15
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ contains both spaces and quote characters. Fol-
+ lowed by a single character, this changes the quote
+ character to that character. Filenames containing
+ a space should then be surrounded by that character
+ rather than by double quotes. Followed by two
+ characters, changes the open quote to the first
+ character, and the close quote to the second char-
+ acter. Filenames containing a space should then be
+ preceded by the open quote character and followed
+ by the close quote character. Note that even after
+ the quote characters are changed, this option
+ remains -" (a dash followed by a double quote).
+
+ -~ or --tilde
+ Normally lines after end of file are displayed as a
+ single tilde (~). This option causes lines after
+ end of file to be displayed as blank lines.
+
+ -- A command line argument of "--" marks the end of
+ option arguments. Any arguments following this are
+ interpreted as filenames. This can be useful when
+ viewing a file whose name begins with a "-" or "+".
+
+ + If a command line option begins with ++, the remain-
+ der of that option is taken to be an initial com-
+ mand to _l_e_s_s_. For example, +G tells _l_e_s_s to start
+ at the end of the file rather than the beginning,
+ and +/xyz tells it to start at the first occurrence
+ of "xyz" in the file. As a special case, +<number>
+ acts like +<number>g; that is, it starts the dis-
+ play at the specified line number (however, see the
+ caveat under the "g" command above). If the option
+ starts with ++, the initial command applies to
+ every file being viewed, not just the first one.
+ The + command described previously may also be used
+ to set (or change) an initial command for every
+ file.
+
+
+LLIINNEE EEDDIITTIINNGG
+ When entering command line at the bottom of the screen
+ (for example, a filename for the :e command, or the pat-
+ tern for a search command), certain keys can be used to
+ manipulate the command line. Most commands have an alter-
+ nate form in [ brackets ] which can be used if a key does
+ not exist on a particular keyboard. (The bracketed forms
+ do not work in the MS-DOS version.) Any of these special
+ keys may be entered literally by preceding it with the
+ "literal" character, either ^V or ^A. A backslash itself
+ may also be entered literally by entering two backslashes.
+
+ LEFTARROW [ ESC-h ]
+ Move the cursor one space to the left.
+
+
+
+
+ Version 354: 23 Mar 2000 16
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ RIGHTARROW [ ESC-l ]
+ Move the cursor one space to the right.
+
+ ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
+ (That is, CONTROL and LEFTARROW simultaneously.)
+ Move the cursor one word to the left.
+
+ ^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
+ (That is, CONTROL and RIGHTARROW simultaneously.)
+ Move the cursor one word to the right.
+
+ HOME [ ESC-0 ]
+ Move the cursor to the beginning of the line.
+
+ END [ ESC-$ ]
+ Move the cursor to the end of the line.
+
+ BACKSPACE
+ Delete the character to the left of the cursor, or
+ cancel the command if the command line is empty.
+
+ DELETE or [ ESC-x ]
+ Delete the character under the cursor.
+
+ ^BACKSPACE [ ESC-BACKSPACE ]
+ (That is, CONTROL and BACKSPACE simultaneously.)
+ Delete the word to the left of the cursor.
+
+ ^DELETE [ ESC-X or ESC-DELETE ]
+ (That is, CONTROL and DELETE simultaneously.)
+ Delete the word under the cursor.
+
+ UPARROW [ ESC-k ]
+ Retrieve the previous command line.
+
+ DOWNARROW [ ESC-j ]
+ Retrieve the next command line.
+
+ TAB Complete the partial filename to the left of the
+ cursor. If it matches more than one filename, the
+ first match is entered into the command line.
+ Repeated TABs will cycle thru the other matching
+ filenames. If the completed filename is a direc-
+ tory, a "/" is appended to the filename. (On MS-
+ DOS systems, a "\" is appended.) The environment
+ variable LESSSEPARATOR can be used to specify a
+ different character to append to a directory name.
+
+ BACKTAB [ ESC-TAB ]
+ Like, TAB, but cycles in the reverse direction thru
+ the matching filenames.
+
+ ^L Complete the partial filename to the left of the
+ cursor. If it matches more than one filename, all
+
+
+
+ Version 354: 23 Mar 2000 17
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ matches are entered into the command line (if they
+ fit).
+
+ ^U (Unix) or ESC (MS-DOS)
+ Delete the entire command line, or cancel the com-
+ mand if the command line is empty. If you have
+ changed your line-kill character in Unix to some-
+ thing other than ^U, that character is used instead
+ of ^U.
+
+
+KKEEYY BBIINNDDIINNGGSS
+ You may define your own _l_e_s_s commands by using the program
+ _l_e_s_s_k_e_y (1) to create a lesskey file. This file specifies
+ a set of command keys and an action associated with each
+ key. You may also use _l_e_s_s_k_e_y to change the line-editing
+ keys (see LINE EDITING), and to set environment variables.
+ If the environment variable LESSKEY is set, _l_e_s_s uses that
+ as the name of the lesskey file. Otherwise, _l_e_s_s looks in
+ a standard place for the lesskey file: On Unix systems,
+ _l_e_s_s looks for a lesskey file called "$HOME/.less". On
+ MS-DOS and Windows systems, _l_e_s_s looks for a lesskey file
+ called "$HOME/_less", and if it is not found there, then
+ looks for a lesskey file called "_less" in any directory
+ specified in the PATH environment variable. On OS/2 sys-
+ tems, _l_e_s_s looks for a lesskey file called
+ "$HOME/less.ini", and if it is not found, then looks for a
+ lesskey file called "less.ini" in any directory specified
+ in the INIT environment variable, and if it not found
+ there, then looks for a lesskey file called "less.ini" in
+ any directory specified in the PATH environment variable.
+ See the _l_e_s_s_k_e_y manual page for more details.
+
+ A system-wide lesskey file may also be set up to provide
+ key bindings. If a key is defined in both a local lesskey
+ file and in the system-wide file, key bindings in the
+ local file take precedence over those in the system-wide
+ file. If the environment variable LESSKEY_SYSTEM is set,
+ _l_e_s_s uses that as the name of the system-wide lesskey
+ file. Otherwise, _l_e_s_s looks in a standard place for the
+ system-wide lesskey file: On Unix systems, the system-wide
+ lesskey file is /usr/local/bin/.sysless. (However, if
+ _l_e_s_s was built with a different binary directory than
+ /usr/local/bin, that directory is where the .sysless file
+ is found.) On MS-DOS and Windows systems, the system-wide
+ lesskey file is c:\_sysless. On OS/2 systems, the system-
+ wide lesskey file is c:\sysless.ini.
+
+
+IINNPPUUTT PPRREEPPRROOCCEESSSSOORR
+ You may define an "input preprocessor" for _l_e_s_s_. Before
+ _l_e_s_s opens a file, it first gives your input preprocessor
+ a chance to modify the way the contents of the file are
+ displayed. An input preprocessor is simply an executable
+
+
+
+ Version 354: 23 Mar 2000 18
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ program (or shell script), which writes the contents of
+ the file to a different file, called the replacement file.
+ The contents of the replacement file are then displayed in
+ place of the contents of the original file. However, it
+ will appear to the user as if the original file is opened;
+ that is, _l_e_s_s will display the original filename as the
+ name of the current file.
+
+ An input preprocessor receives one command line argument,
+ the original filename, as entered by the user. It should
+ create the replacement file, and when finished, print the
+ name of the replacement file to its standard output. If
+ the input preprocessor does not output a replacement file-
+ name, _l_e_s_s uses the original file, as normal. The input
+ preprocessor is not called when viewing standard input.
+ To set up an input preprocessor, set the LESSOPEN environ-
+ ment variable to a command line which will invoke your
+ input preprocessor. This command line should include one
+ occurrence of the string "%s", which will be replaced by
+ the filename when the input preprocessor command is
+ invoked.
+
+ When _l_e_s_s closes a file opened in such a way, it will call
+ another program, called the input postprocessor, which may
+ perform any desired clean-up action (such as deleting the
+ replacement file created by LESSOPEN). This program
+ receives two command line arguments, the original filename
+ as entered by the user, and the name of the replacement
+ file. To set up an input postprocessor, set the LESSCLOSE
+ environment variable to a command line which will invoke
+ your input postprocessor. It may include two occurrences
+ of the string "%s"; the first is replaced with the origi-
+ nal name of the file and the second with the name of the
+ replacement file, which was output by LESSOPEN.
+
+ For example, on many Unix systems, these two scripts will
+ allow you to keep files in compressed format, but still
+ let _l_e_s_s view them directly:
+
+ lessopen.sh:
+ #! /bin/sh
+ case "$1" in
+ *.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
+ if [ -s /tmp/less.$$ ]; then
+ echo /tmp/less.$$
+ else
+ rm -f /tmp/less.$$
+ fi
+ ;;
+ esac
+
+ lessclose.sh:
+ #! /bin/sh
+ rm $2
+
+
+
+ Version 354: 23 Mar 2000 19
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ To use these scripts, put them both where they can be exe-
+ cuted and set LESSOPEN="lessopen.sh %s", and
+ LESSCLOSE="lessclose.sh %s %s". More complex LESSOPEN and
+ LESSCLOSE scripts may be written to accept other types of
+ compressed files, and so on.
+
+ It is also possible to set up an input preprocessor to
+ pipe the file data directly to _l_e_s_s_, rather than putting
+ the data into a replacement file. This avoids the need to
+ decompress the entire file before starting to view it. An
+ input preprocessor that works this way is called an input
+ pipe. An input pipe, instead of writing the name of a
+ replacement file on its standard output, writes the entire
+ contents of the replacement file on its standard output.
+ If the input pipe does not write any characters on its
+ standard output, then there is no replacement file and
+ _l_e_s_s uses the original file, as normal. To use an input
+ pipe, make the first character in the LESSOPEN environment
+ variable a vertical bar (|) to signify that the input pre-
+ processor is an input pipe.
+
+ For example, on many Unix systems, this script will work
+ like the previous example scripts:
+
+ lesspipe.sh:
+ #! /bin/sh
+ case "$1" in
+ *.Z) uncompress -c $1 2>/dev/null
+ ;;
+ esac
+
+ To use this script, put it where it can be executed and
+ set LESSOPEN="|lesspipe.sh %s". When an input pipe is
+ used, a LESSCLOSE postprocessor can be used, but it is
+ usually not necessary since there is no replacement file
+ to clean up. In this case, the replacement file name
+ passed to the LESSCLOSE postprocessor is "-".
+
+
+NNAATTIIOONNAALL CCHHAARRAACCTTEERR SSEETTSS
+ There are three types of characters in the input file:
+
+ normal characters
+ can be displayed directly to the screen.
+
+ control characters
+ should not be displayed directly, but are expected
+ to be found in ordinary text files (such as
+ backspace and tab).
+
+ binary characters
+ should not be displayed directly and are not
+ expected to be found in text files.
+
+
+
+
+ Version 354: 23 Mar 2000 20
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ A "character set" is simply a description of which charac-
+ ters are to be considered normal, control, and binary.
+ The LESSCHARSET environment variable may be used to select
+ a character set. Possible values for LESSCHARSET are:
+
+ ascii BS, TAB, NL, CR, and formfeed are control charac-
+ ters, all chars with values between 32 and 126 are
+ normal, and all others are binary.
+
+ iso8859
+ Selects an ISO 8859 character set. This is the
+ same as ASCII, except characters between 160 and
+ 255 are treated as normal characters.
+
+ latin1 Same as iso8859.
+
+ dos Selects a character set appropriate for MS-DOS.
+
+ ebcdic Selects an EBCDIC character set.
+
+ koi8-r Selects a Russian character set.
+
+ next Selects a character set appropriate for NeXT com-
+ puters.
+
+ utf-8 Selects the UTF-8 encoding of the ISO 10646 charac-
+ ter set.
+
+ If the LESSCHARSET environment variable is not set, the
+ default character set is latin1. However, if the string
+ "UTF-8" is found in the LC_ALL, LC_CTYPE or LANG environ-
+ ment variables, then the default character set is utf-8
+ instead.
+
+ In special cases, it may be desired to tailor _l_e_s_s to use
+ a character set other than the ones definable by LESS-
+ CHARSET. In this case, the environment variable LESS-
+ CHARDEF can be used to define a character set. It should
+ be set to a string where each character in the string rep-
+ resents one character in the character set. The character
+ "." is used for a normal character, "c" for control, and
+ "b" for binary. A decimal number may be used for repeti-
+ tion. For example, "bccc4b." would mean character 0 is
+ binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are binary,
+ and 8 is normal. All characters after the last are taken
+ to be the same as the last, so characters 9 through 255
+ would be normal. (This is an example, and does not neces-
+ sarily represent any real character set.)
+
+ This table shows the value of LESSCHARDEF which is equiva-
+ lent to each of the possible values for LESSCHARSET:
+
+ ascii 8bcccbcc18b95.b
+ dos 8bcccbcc12bc5b95.b.
+
+
+
+ Version 354: 23 Mar 2000 21
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
+ 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
+ iso8859 8bcccbcc18b95.33b.
+ koi8-r 8bcccbcc18b95.b128.
+ latin1 8bcccbcc18b95.33b.
+ next 8bcccbcc18b95.bb125.bb
+
+ If neither LESSCHARSET nor LESSCHARDEF is set, but your
+ system supports the _s_e_t_l_o_c_a_l_e interface, _l_e_s_s will use
+ setlocale to determine the character set. setlocale is
+ controlled by setting the LANG or LC_CTYPE environment
+ variables.
+
+ Control and binary characters are displayed in standout
+ (reverse video). Each such character is displayed in
+ caret notation if possible (e.g. ^A for control-A). Caret
+ notation is used only if inverting the 0100 bit results in
+ a normal printable character. Otherwise, the character is
+ displayed as a hex number in angle brackets. This format
+ can be changed by setting the LESSBINFMT environment vari-
+ able. LESSBINFMT may begin with a "*" and one character
+ to select the display attribute: "*k" is blinking, "*d" is
+ bold, "*u" is underlined, "*s" is standout, and "*n" is
+ normal. If LESSBINFMT does not begin with a "*", normal
+ attribute is assumed. The remainder of LESSBINFMT is a
+ string which may include one printf-style escape sequence
+ (a % followed by x, X, o, d, etc.). For example, if LESS-
+ BINFMT is "*u[%x]", binary characters are displayed in
+ underlined hexadecimal surrounded by brackets. The
+ default if no LESSBINFMT is specified is "*s<%X>".
+
+
+PPRROOMMPPTTSS
+ The -P option allows you to tailor the prompt to your
+ preference. The string given to the -P option replaces
+ the specified prompt string. Certain characters in the
+ string are interpreted specially. The prompt mechanism is
+ rather complicated to provide flexibility, but the ordi-
+ nary user need not understand the details of constructing
+ personalized prompt strings.
+
+ A percent sign followed by a single character is expanded
+ according to what the following character is:
+
+ %b_X Replaced by the byte offset into the current input
+ file. The b is followed by a single character
+ (shown as _X above) which specifies the line whose
+ byte offset is to be used. If the character is a
+ "t", the byte offset of the top line in the display
+ is used, an "m" means use the middle line, a "b"
+ means use the bottom line, a "B" means use the line
+ just after the bottom line, and a "j" means use the
+ "target" line, as specified by the -j option.
+
+
+
+
+ Version 354: 23 Mar 2000 22
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ %B Replaced by the size of the current input file.
+
+ %c Replaced by the column number of the text appearing
+ in the first column of the screen.
+
+ %d_X Replaced by the page number of a line in the input
+ file. The line to be used is determined by the _X,
+ as with the %b option.
+
+ %D Replaced by the number of pages in the input file,
+ or equivalently, the page number of the last line
+ in the input file.
+
+ %E Replaced by the name of the editor (from the VISUAL
+ environment variable, or the EDITOR environment
+ variable if VISUAL is not defined). See the dis-
+ cussion of the LESSEDIT feature below.
+
+ %f Replaced by the name of the current input file.
+
+ %i Replaced by the index of the current file in the
+ list of input files.
+
+ %l_X Replaced by the line number of a line in the input
+ file. The line to be used is determined by the _X,
+ as with the %b option.
+
+ %L Replaced by the line number of the last line in the
+ input file.
+
+ %m Replaced by the total number of input files.
+
+ %p_X Replaced by the percent into the current input
+ file, based on byte offsets. The line used is
+ determined by the _X as with the %b option.
+
+ %P_X Replaced by the percent into the current input
+ file, based on line numbers. The line used is
+ determined by the _X as with the %b option.
+
+ %s Same as %B.
+
+ %t Causes any trailing spaces to be removed. Usually
+ used at the end of the string, but may appear any-
+ where.
+
+ %x Replaced by the name of the next input file in the
+ list.
+
+ If any item is unknown (for example, the file size if
+ input is a pipe), a question mark is printed instead.
+
+ The format of the prompt string can be changed depending
+ on certain conditions. A question mark followed by a
+
+
+
+ Version 354: 23 Mar 2000 23
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ single character acts like an "IF": depending on the fol-
+ lowing character, a condition is evaluated. If the condi-
+ tion is true, any characters following the question mark
+ and condition character, up to a period, are included in
+ the prompt. If the condition is false, such characters
+ are not included. A colon appearing between the question
+ mark and the period can be used to establish an "ELSE":
+ any characters between the colon and the period are
+ included in the string if and only if the IF condition is
+ false. Condition characters (which follow a question
+ mark) may be:
+
+ ?a True if any characters have been included in the
+ prompt so far.
+
+ ?b_X True if the byte offset of the specified line is
+ known.
+
+ ?B True if the size of current input file is known.
+
+ ?c True if the text is horizontally shifted (%c is not
+ zero).
+
+ ?d_X True if the page number of the specified line is
+ known.
+
+ ?e True if at end-of-file.
+
+ ?f True if there is an input filename (that is, if
+ input is not a pipe).
+
+ ?l_X True if the line number of the specified line is
+ known.
+
+ ?L True if the line number of the last line in the
+ file is known.
+
+ ?m True if there is more than one input file.
+
+ ?n True if this is the first prompt in a new input
+ file.
+
+ ?p_X True if the percent into the current input file,
+ based on byte offsets, of the specified line is
+ known.
+
+ ?P_X True if the percent into the current input file,
+ based on line numbers, of the specified line is
+ known.
+
+ ?s Same as "?B".
+
+ ?x True if there is a next input file (that is, if the
+ current input file is not the last one).
+
+
+
+ Version 354: 23 Mar 2000 24
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ Any characters other than the special ones (question mark,
+ colon, period, percent, and backslash) become literally
+ part of the prompt. Any of the special characters may be
+ included in the prompt literally by preceding it with a
+ backslash.
+
+ Some examples:
+
+ ?f%f:Standard input.
+
+ This prompt prints the filename, if known; otherwise the
+ string "Standard input".
+
+ ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
+
+ This prompt would print the filename, if known. The file-
+ name is followed by the line number, if known, otherwise
+ the percent if known, otherwise the byte offset if known.
+ Otherwise, a dash is printed. Notice how each question
+ mark has a matching period, and how the % after the %pt is
+ included literally by escaping it with a backslash.
+
+ ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t
+
+ This prints the filename if this is the first prompt in a
+ file, followed by the "file N of N" message if there is
+ more than one input file. Then, if we are at end-of-file,
+ the string "(END)" is printed followed by the name of the
+ next file, if there is one. Finally, any trailing spaces
+ are truncated. This is the default prompt. For refer-
+ ence, here are the defaults for the other two prompts (-m
+ and -M respectively). Each is broken into two lines here
+ for readability only.
+
+ ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.:
+ ?pB%pB\%:byte %bB?s/%s...%t
+
+ ?f%f .?n?m(file %i of %m) ..?ltlines %lt-%lb?L/%L. :
+ byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t
+
+ And here is the default message produced by the = command:
+
+ ?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. .
+ byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
+
+ The prompt expansion features are also used for another
+ purpose: if an environment variable LESSEDIT is defined,
+ it is used as the command to be executed when the v com-
+ mand is invoked. The LESSEDIT string is expanded in the
+ same way as the prompt strings. The default value for
+ LESSEDIT is:
+
+ %E ?lm+%lm. %f
+
+
+
+
+ Version 354: 23 Mar 2000 25
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ Note that this expands to the editor name, followed by a +
+ and the line number, followed by the file name. If your
+ editor does not accept the "+linenumber" syntax, or has
+ other differences in invocation syntax, the LESSEDIT vari-
+ able can be changed to modify this default.
+
+
+SSEECCUURRIITTYY
+ When the environment variable LESSSECURE is set to 1, _l_e_s_s
+ runs in a "secure" mode. This means these features are
+ disabled:
+
+ ! the shell command
+
+ | the pipe command
+
+ :e the examine command.
+
+ v the editing command
+
+ s -o log files
+
+ -k use of lesskey files
+
+ -t use of tags files
+
+ metacharacters in filenames, such as *
+
+ filename completion (TAB, ^L)
+
+ Less can also be compiled to be permanently in "secure"
+ mode.
+
+
+EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
+ Environment variables may be specified either in the sys-
+ tem environment as usual, or in a _l_e_s_s_k_e_y (1) file. If
+ environment variables are defined in more than one place,
+ variables defined in a local lesskey file take precedence
+ over variables defined in the system environment, which
+ take precedence over variables defined in the system-wide
+ lesskey file.
+
+ COLUMNS
+ Sets the number of columns on the screen. Takes
+ precedence over the number of columns specified by
+ the TERM variable. (But if you have a windowing
+ system which supports TIOCGWINSZ or WIOCGETD, the
+ window system's idea of the screen size takes
+ precedence over the LINES and COLUMNS environment
+ variables.)
+
+ EDITOR The name of the editor (used for the v command).
+
+
+
+
+ Version 354: 23 Mar 2000 26
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ HOME Name of the user's home directory (used to find a
+ lesskey file on Unix systems).
+
+ HOMEDRIVE, HOMEPATH
+ Concatenation of the HOMEDRIVE and HOMEPATH envi-
+ ronment variables is the name of the user's home
+ directory if the HOME variable is not set (only in
+ the Windows version).
+
+ INIT Name of the user's init directory (used to find a
+ lesskey file on OS/2 systems).
+
+ LANG Language for determining the character set.
+
+ LC_CTYPE
+ Language for determining the character set.
+
+ LESS Options which are passed to _l_e_s_s automatically.
+
+ LESSANSIENDCHARS
+ Characters which are assumed to end an ANSI color
+ escape sequence (default "m").
+
+ LESSBINFMT
+ Format for displaying non-printable, non-control
+ characters.
+
+ LESSCHARDEF
+ Defines a character set.
+
+ LESSCHARSET
+ Selects a predefined character set.
+
+ LESSCLOSE
+ Command line to invoke the (optional) input-post-
+ processor.
+
+ LESSECHO
+ Name of the lessecho program (default "lessecho").
+ The lessecho program is needed to expand metachar-
+ acters, such as * and ?, in filenames on Unix sys-
+ tems.
+
+ LESSEDIT
+ Editor prototype string (used for the v command).
+ See discussion under PROMPTS.
+
+ LESSKEY
+ Name of the default lesskey(1) file.
+
+ LESSKEY_SYSTEM
+ Name of the default system-wide lesskey(1) file.
+
+
+
+
+
+ Version 354: 23 Mar 2000 27
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ LESSMETACHARS
+ List of characters which are considered "metachar-
+ acters" by the shell.
+
+ LESSMETAESCAPE
+ Prefix which less will add before each metacharac-
+ ter in a command sent to the shell. If LESS-
+ METAESCAPE is an empty string, commands containing
+ metacharacters will not be passed to the shell.
+
+ LESSOPEN
+ Command line to invoke the (optional) input-prepro-
+ cessor.
+
+ LESSSECURE
+ Runs less in "secure" mode. See discussion under
+ SECURITY.
+
+ LESSSEPARATOR
+ String to be appended to a directory name in file-
+ name completion.
+
+ LINES Sets the number of lines on the screen. Takes
+ precedence over the number of lines specified by
+ the TERM variable. (But if you have a windowing
+ system which supports TIOCGWINSZ or WIOCGETD, the
+ window system's idea of the screen size takes
+ precedence over the LINES and COLUMNS environment
+ variables.)
+
+ PATH User's search path (used to find a lesskey file on
+ MS-DOS and OS/2 systems).
+
+ SHELL The shell used to execute the ! command, as well as
+ to expand filenames.
+
+ TERM The type of terminal on which _l_e_s_s is being run.
+
+ VISUAL The name of the editor (used for the v command).
+
+
+SSEEEE AALLSSOO
+ lesskey(1)
+
+
+WWAARRNNIINNGGSS
+ The = command and prompts (unless changed by -P) report
+ the line numbers of the lines at the top and bottom of the
+ screen, but the byte and percent of the line after the one
+ at the bottom of the screen.
+
+ If the :e command is used to name more than one file, and
+ one of the named files has been viewed previously, the new
+ files may be entered into the list in an unexpected order.
+
+
+
+ Version 354: 23 Mar 2000 28
+
+
+
+
+
+LESS(1) LESS(1)
+
+
+ On certain older terminals (the so-called "magic cookie"
+ terminals), search highlighting will cause an erroneous
+ display. On such terminals, search highlighting is dis-
+ abled by default to avoid possible problems.
+
+ In certain cases, when search highlighting is enabled and
+ a search pattern begins with a ^, more text than the
+ matching string may be highlighted. (This problem does
+ not occur when less is compiled to use the POSIX regular
+ expression package.)
+
+ On some systems, _s_e_t_l_o_c_a_l_e claims that ASCII characters 0
+ thru 31 are control characters rather than binary charac-
+ ters. This causes _l_e_s_s to treat some binary files as
+ ordinary, non-binary files. To workaround this problem,
+ set the environment variable LESSCHARSET to "ascii" (or
+ whatever character set is appropriate).
+
+ See http://www.flash.net/~marknu/less for the latest list
+ of known bugs in this version of less.
+
+
+CCOOPPYYRRIIGGHHTT
+ Copyright (C) 2000 Mark Nudelman
+
+ less is part of the GNU project and is free software. You
+ can redistribute it and/or modify it under the terms of
+ either (1) the GNU General Public License as published by
+ the Free Software Foundation; or (2) the Less License.
+ See the file README in the less distribution for more
+ details regarding redistribution. You should have
+ received a copy of the GNU General Public License along
+ with the source for less; see the file COPYING. If not,
+ write to the Free Software Foundation, 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307, USA. You should also
+ have received a copy of the Less License; see the file
+ LICENSE.
+
+ less is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied war-
+ ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR-
+ POSE. See the GNU General Public License for more
+ details.
+
+
+AAUUTTHHOORR
+ Mark Nudelman <marknu@flash.net>
+ Send bug reports or comments to the above address or to
+ bug-less@gnu.org.
+
+
+
+
+
+
+
+
+ Version 354: 23 Mar 2000 29
+
+
diff --git a/contrib/less/less.nro b/contrib/less/less.nro
new file mode 100644
index 000000000000..4240c54f5de5
--- /dev/null
+++ b/contrib/less/less.nro
@@ -0,0 +1,1502 @@
+.TH LESS 1 "Version 354: 23 Mar 2000"
+.SH NAME
+less \- opposite of more
+.SH SYNOPSIS
+.B "less -?"
+.br
+.B "less --help"
+.br
+.B "less -V"
+.br
+.B "less --version"
+.br
+.B "less [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]"
+.br
+.B " [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
+.br
+.B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
+.br
+.B " [-T \fItagsfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]"
+.br
+.B " [+[+]\fIcmd\fP] [--] [\fIfilename\fP]..."
+.br
+(See the OPTIONS section for alternate option syntax with long option names.)
+
+.SH DESCRIPTION
+.I Less
+is a program similar to
+.I more
+(1), but which allows backward movement
+in the file as well as forward movement.
+Also,
+.I less
+does not have to read the entire input file before starting,
+so with large input files it starts up faster than text editors like
+.I vi
+(1).
+.I Less
+uses termcap (or terminfo on some systems),
+so it can run on a variety of terminals.
+There is even limited support for hardcopy terminals.
+(On a hardcopy terminal, lines which should be printed at the top
+of the screen are prefixed with a caret.)
+.PP
+Commands are based on both
+.I more
+and
+.I vi.
+Commands may be preceded by a decimal number,
+called N in the descriptions below.
+The number is used by some commands, as indicated.
+
+.SH COMMANDS
+In the following descriptions, ^X means control-X.
+ESC stands for the ESCAPE key; for example ESC-v means the
+two character sequence "ESCAPE", then "v".
+.IP "h or H"
+Help: display a summary of these commands.
+If you forget all the other commands, remember this one.
+.IP "SPACE or ^V or f or ^F"
+Scroll forward N lines, default one window (see option -z below).
+If N is more than the screen size, only the final screenful is displayed.
+Warning: some systems use ^V as a special literalization character.
+.IP "z"
+Like SPACE, but if N is specified, it becomes the new window size.
+.IP "ESC-SPACE"
+Like SPACE, but scrolls a full screenful, even if it reaches
+end-of-file in the process.
+.IP "RETURN or ^N or e or ^E or j or ^J"
+Scroll forward N lines, default 1.
+The entire N lines are displayed, even if N is more than the screen size.
+.IP "d or ^D"
+Scroll forward N lines, default one half of the screen size.
+If N is specified, it becomes the new default for
+subsequent d and u commands.
+.IP "b or ^B or ESC-v"
+Scroll backward N lines, default one window (see option -z below).
+If N is more than the screen size, only the final screenful is displayed.
+.IP "w"
+Like ESC-v, but if N is specified, it becomes the new window size.
+.IP "y or ^Y or ^P or k or ^K"
+Scroll backward N lines, default 1.
+The entire N lines are displayed, even if N is more than the screen size.
+Warning: some systems use ^Y as a special job control character.
+.IP "u or ^U"
+Scroll backward N lines, default one half of the screen size.
+If N is specified, it becomes the new default for
+subsequent d and u commands.
+.IP "ESC-) or RIGHTARROW"
+Scroll horizontally right N characters, default 8.
+This behaves best if you also set the -S option (chop lines).
+Note that if you wish to enter a number N, you must use ESC-), not RIGHTARROW,
+because the arrow is taken to be a line editing command
+(see the LINE EDITING section).
+.IP "ESC-( or LEFTARROW"
+Scroll horizontally left N characters, default 8.
+.IP "r or ^R or ^L"
+Repaint the screen.
+.IP R
+Repaint the screen, discarding any buffered input.
+Useful if the file is changing while it is being viewed.
+.IP "F"
+Scroll forward, and keep trying to read when the
+end of file is reached.
+Normally this command would be used when already at the end of the file.
+It is a way to monitor the tail of a file which is growing
+while it is being viewed.
+(The behavior is similar to the "tail -f" command.)
+.IP "g or < or ESC-<"
+Go to line N in the file, default 1 (beginning of file).
+(Warning: this may be slow if N is large.)
+.IP "G or > or ESC->"
+Go to line N in the file, default the end of the file.
+(Warning: this may be slow if N is large,
+or if N is not specified and
+standard input, rather than a file, is being read.)
+.IP "p or %"
+Go to a position N percent into the file.
+N should be between 0 and 100.
+.IP "{"
+If a left curly bracket appears in the top line displayed
+on the screen,
+the { command will go to the matching right curly bracket.
+The matching right curly bracket is positioned on the bottom
+line of the screen.
+If there is more than one left curly bracket on the top line,
+a number N may be used to specify the N-th bracket on the line.
+.IP "}"
+If a right curly bracket appears in the bottom line displayed
+on the screen,
+the } command will go to the matching left curly bracket.
+The matching left curly bracket is positioned on the top
+line of the screen.
+If there is more than one right curly bracket on the top line,
+a number N may be used to specify the N-th bracket on the line.
+.IP "("
+Like {, but applies to parentheses rather than curly brackets.
+.IP ")"
+Like }, but applies to parentheses rather than curly brackets.
+.IP "["
+Like {, but applies to square brackets rather than curly brackets.
+.IP "]"
+Like }, but applies to square brackets rather than curly brackets.
+.IP "ESC-^F"
+Followed by two characters,
+acts like {, but uses the two characters as open and close brackets,
+respectively.
+For example, "ESC ^F < >" could be used to
+go forward to the > which matches the < in the top displayed line.
+.IP "ESC-^B"
+Followed by two characters,
+acts like }, but uses the two characters as open and close brackets,
+respectively.
+For example, "ESC ^B < >" could be used to
+go backward to the < which matches the > in the bottom displayed line.
+.IP m
+Followed by any lowercase letter,
+marks the current position with that letter.
+.IP "'"
+(Single quote.)
+Followed by any lowercase letter, returns to the position which
+was previously marked with that letter.
+Followed by another single quote, returns to the position at
+which the last "large" movement command was executed.
+Followed by a ^ or $, jumps to the beginning or end of the
+file respectively.
+Marks are preserved when a new file is examined,
+so the ' command can be used to switch between input files.
+.IP "^X^X"
+Same as single quote.
+.IP /pattern
+Search forward in the file for the N-th line containing the pattern.
+N defaults to 1.
+The pattern is a regular expression, as recognized by
+.I ed.
+The search starts at the second line displayed
+(but see the -a and -j options, which change this).
+.sp
+Certain characters are special
+if entered at the beginning of the pattern;
+they modify the type of search rather than become part of the pattern:
+.RS
+.IP "^N or !"
+Search for lines which do NOT match the pattern.
+.IP "^E or *"
+Search multiple files.
+That is, if the search reaches the END of the current file
+without finding a match,
+the search continues in the next file in the command line list.
+.IP "^F or @"
+Begin the search at the first line of the FIRST file
+in the command line list,
+regardless of what is currently displayed on the screen
+or the settings of the -a or -j options.
+.IP "^K"
+Highlight any text which matches the pattern on the current screen,
+but don't move to the first match (KEEP current position).
+.IP "^R"
+Don't interpret regular expression metacharacters;
+that is, do a simple textual comparison.
+.RE
+.IP ?pattern
+Search backward in the file for the N-th line containing the pattern.
+The search starts at the line immediately before the top line displayed.
+.sp
+Certain characters are special as in the / command:
+.RS
+.IP "^N or !"
+Search for lines which do NOT match the pattern.
+.IP "^E or *"
+Search multiple files.
+That is, if the search reaches the beginning of the current file
+without finding a match,
+the search continues in the previous file in the command line list.
+.IP "^F or @"
+Begin the search at the last line of the last file
+in the command line list,
+regardless of what is currently displayed on the screen
+or the settings of the -a or -j options.
+.IP "^K"
+As in forward searches.
+.IP "^R"
+As in forward searches.
+.RE
+.IP "ESC-/pattern"
+Same as "/*".
+.IP "ESC-?pattern"
+Same as "?*".
+.IP n
+Repeat previous search, for N-th line containing the last pattern.
+If the previous search was modified by ^N, the search is made for the
+N-th line NOT containing the pattern.
+If the previous search was modified by ^E, the search continues
+in the next (or previous) file if not satisfied in the current file.
+If the previous search was modified by ^R, the search is done
+without using regular expressions.
+There is no effect if the previous search was modified by ^F or ^K.
+.IP N
+Repeat previous search, but in the reverse direction.
+.IP "ESC-n"
+Repeat previous search, but crossing file boundaries.
+The effect is as if the previous search were modified by *.
+.IP "ESC-N"
+Repeat previous search, but in the reverse direction
+and crossing file boundaries.
+.IP "ESC-u"
+Undo search highlighting.
+Turn off highlighting of strings matching the current search pattern.
+If highlighting is already off because of a previous ESC-u command,
+turn highlighting back on.
+Any search command will also turn highlighting back on.
+(Highlighting can also be disabled by toggling the -G option;
+in that case search commands do not turn highlighting back on.)
+.IP ":e [filename]"
+Examine a new file.
+If the filename is missing, the "current" file (see the :n and :p commands
+below) from the list of files in the command line is re-examined.
+A percent sign (%) in the filename is replaced by the name of the
+current file.
+A pound sign (#) is replaced by the name of the previously examined file.
+However, two consecutive percent signs are simply
+replaced with a single percent sign.
+This allows you to enter a filename that contains a percent sign
+in the name.
+Similarly, two consecutive pound signs are replaced with a single pound sign.
+The filename is inserted into the command line list of files
+so that it can be seen by subsequent :n and :p commands.
+If the filename consists of several files, they are all inserted into
+the list of files and the first one is examined.
+If the filename contains one or more spaces,
+the entire filename should be enclosed in double quotes
+(also see the -" option).
+.IP "^X^V or E"
+Same as :e.
+Warning: some systems use ^V as a special literalization character.
+On such systems, you may not be able to use ^V.
+.IP ":n"
+Examine the next file (from the list of files given in the command line).
+If a number N is specified, the N-th next file is examined.
+.IP ":p"
+Examine the previous file in the command line list.
+If a number N is specified, the N-th previous file is examined.
+.IP ":x"
+Examine the first file in the command line list.
+If a number N is specified, the N-th file in the list is examined.
+.IP ":d"
+Remove the current file from the list of files.
+.IP "= or ^G or :f"
+Prints some information about the file being viewed,
+including its name
+and the line number and byte offset of the bottom line being displayed.
+If possible, it also prints the length of the file,
+the number of lines in the file
+and the percent of the file above the last displayed line.
+.IP \-
+Followed by one of the command line option letters (see OPTIONS below),
+this will change the setting of that option
+and print a message describing the new setting.
+If a ^P (CONTROL-P) is entered immediately after the dash,
+the setting of the option is changed but no message is printed.
+If the option letter has a numeric value (such as -b or -h),
+or a string value (such as -P or -t),
+a new value may be entered after the option letter.
+If no new value is entered, a message describing
+the current setting is printed and nothing is changed.
+.IP \-\-
+Like the \- command, but takes a long option name (see OPTIONS below)
+rather than a single option letter.
+You must press RETURN after typing the option name.
+A ^P immediately after the second dash suppresses printing of a
+message describing the new setting, as in the \- command.
+.IP \-+
+Followed by one of the command line option letters
+this will reset the option to its default setting
+and print a message describing the new setting.
+(The "\-+\fIX\fP" command does the same thing
+as "\-+\fIX\fP" on the command line.)
+This does not work for string-valued options.
+.IP \-\-+
+Like the \-+ command, but takes a long option name
+rather than a single option letter.
+.IP \-!
+Followed by one of the command line option letters,
+this will reset the option to the "opposite" of its default setting
+and print a message describing the new setting.
+This does not work for numeric or string-valued options.
+.IP \-\-!
+Like the \-! command, but takes a long option name
+rather than a single option letter.
+.IP _
+(Underscore.)
+Followed by one of the command line option letters,
+this will print a message describing the current setting of that option.
+The setting of the option is not changed.
+.IP __
+(Double underscore.)
+Like the _ (underscore) command, but takes a long option name
+rather than a single option letter.
+You must press RETURN after typing the option name.
+.IP +cmd
+Causes the specified cmd to be executed each time a new file is examined.
+For example, +G causes
+.I less
+to initially display each file starting at the end
+rather than the beginning.
+.IP V
+Prints the version number of
+.I less
+being run.
+.IP "q or Q or :q or :Q or ZZ"
+Exits
+.I less.
+.PP
+The following
+four
+commands may or may not be valid, depending on your particular installation.
+.PP
+.IP v
+Invokes an editor to edit the current file being viewed.
+The editor is taken from the environment variable VISUAL if defined,
+or EDITOR if VISUAL is not defined,
+or defaults to "vi" if neither VISUAL nor EDITOR is defined.
+See also the discussion of LESSEDIT under the section on PROMPTS below.
+.IP "! shell-command"
+Invokes a shell to run the shell-command given.
+A percent sign (%) in the command is replaced by the name of the
+current file.
+A pound sign (#) is replaced by the name of the previously examined file.
+"!!" repeats the last shell command.
+"!" with no shell command simply invokes a shell.
+On Unix systems, the shell is taken from the environment variable SHELL,
+or defaults to "sh".
+On MS-DOS and OS/2 systems, the shell is the normal command processor.
+.IP "| <m> shell-command"
+<m> represents any mark letter.
+Pipes a section of the input file to the given shell command.
+The section of the file to be piped is between the first line on
+the current screen and the position marked by the letter.
+<m> may also be ^ or $ to indicate beginning or end of file respectively.
+If <m> is . or newline, the current screen is piped.
+.IP "s filename"
+Save the input to a file.
+This only works if the input is a pipe, not an ordinary file.
+.PP
+.SH OPTIONS
+Command line options are described below.
+Most options may be changed while
+.I less
+is running, via the "\-" command.
+.PP
+Most options may be given in one of two forms:
+either a dash followed by a single letter,
+or two dashes followed by a long option name.
+A long option name may be abbreviated as long as
+the abbreviation is unambiguous.
+For example, --quit-at-eof may be abbreviated --quit, but not
+--qui, since both --quit-at-eof and --quiet begin with --qui.
+Some long option names are in uppercase, such as --QUIT-AT-EOF, as
+distinct from --quit-at-eof.
+Such option names need only have their first letter capitalized;
+the remainder of the name may be in either case.
+For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
+.PP
+Options are also taken from the environment variable "LESS".
+For example,
+to avoid typing "less -options ..." each time
+.I less
+is invoked, you might tell
+.I csh:
+.sp
+setenv LESS "-options"
+.sp
+or if you use
+.I sh:
+.sp
+LESS="-options"; export LESS
+.sp
+On MS-DOS, you don't need the quotes, but you should replace any
+percent signs in the options string by double percent signs.
+.sp
+The environment variable is parsed before the command line,
+so command line options override the LESS environment variable.
+If an option appears in the LESS variable, it can be reset
+to its default value on the command line by beginning the command
+line option with "\-+".
+.sp
+For options like -P or -D which take a following string,
+a dollar sign ($) must be used to signal the end of the string.
+For example, to set two -D options on MS-DOS, you must have
+a dollar sign between them, like this:
+.sp
+LESS="-Dn9.1$-Ds4.1"
+.sp
+.IP "-? or --help"
+This option displays a summary of the commands accepted by
+.I less
+(the same as the h command).
+(Depending on how your shell interprets the question mark,
+it may be necessary to quote the question mark, thus: "-\\?".)
+.IP "-a or --search-skip-screen"
+Causes searches to start after the last line
+displayed on the screen,
+thus skipping all lines displayed on the screen.
+By default, searches start at the second line on the screen
+(or after the last found line; see the -j option).
+.IP "-b\fIn\fP or --buffers=\fIn\fP"
+Specifies the number of buffers
+.I less
+will use for each file.
+Buffers are 1K, and by default 10 buffers are used for each file
+(except if the file is a pipe; see the -B option).
+The number \fIn\fP specifies a different number of buffers to use.
+.IP "-B or --auto-buffers"
+By default, when data is read from a pipe,
+buffers are allocated automatically as needed.
+If a large amount of data is read from the pipe, this can cause
+a large amount of memory to be allocated.
+The -B option disables this automatic allocation of buffers for pipes,
+so that only the number of buffers specified by the -b option are used.
+Warning: use of -B can result in erroneous display, since only the
+most recently viewed part of the file is kept in memory;
+any earlier data is lost.
+.IP "-c or --clear-screen"
+Causes full screen repaints to be painted from the top line down.
+By default,
+full screen repaints are done by scrolling from the bottom of the screen.
+.IP "-C or --CLEAR-SCREEN"
+The -C option is like -c, but the screen is cleared before it is repainted.
+.IP "-d or --dumb"
+The -d option suppresses the error message
+normally displayed if the terminal is dumb;
+that is, lacks some important capability,
+such as the ability to clear the screen or scroll backward.
+The -d option does not otherwise change the behavior of
+.I less
+on a dumb terminal).
+.IP "-D\fBx\fP\fIcolor\fP or --color=\fBx\fP\fIcolor\fP"
+[MS-DOS only]
+Sets the color of the text displayed.
+\fBx\fP is a single character which selects the type of text whose color is
+being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
+\fIcolor\fP is a pair of numbers separated by a period.
+The first number selects the foreground color and the second selects
+the background color of the text.
+A single number \fIN\fP is the same as \fIN.0\fP.
+.IP "-e or --quit-at-eof"
+Causes
+.I less
+to automatically exit
+the second time it reaches end-of-file.
+By default, the only way to exit
+.I less
+is via the "q" command.
+.IP "-E or --QUIT-AT-EOF"
+Causes
+.I less
+to automatically exit the first time it reaches end-of-file.
+.IP "-f or --force"
+Forces non-regular files to be opened.
+(A non-regular file is a directory or a device special file.)
+Also suppresses the warning message when a binary file is opened.
+By default,
+.I less
+will refuse to open non-regular files.
+.IP "-F or --quit-if-one-screen"
+Causes
+.I less
+to automatically exit
+if the entire file can be displayed on the first screen.
+.IP "-g or --hilite-search"
+Normally,
+.I less
+will highlight ALL strings which match the last search command.
+The -g option changes this behavior to highlight only the particular string
+which was found by the last search command.
+This can cause
+.I less
+to run somewhat faster than the default.
+.IP "-G or --HILITE-SEARCH"
+The -G option suppresses all highlighting of strings found by search commands.
+.IP "-h\fIn\fP or ---max-back-scroll=\fIn\fP"
+Specifies a maximum number of lines to scroll backward.
+If it is necessary to scroll backward more than \fIn\fP lines,
+the screen is repainted in a forward direction instead.
+(If the terminal does not have the ability to scroll
+backward, -h0 is implied.)
+.IP "-i or --ignore-case"
+Causes searches to ignore case; that is,
+uppercase and lowercase are considered identical.
+This option is ignored if any uppercase letters
+appear in the search pattern;
+in other words,
+if a pattern contains uppercase letters, then that search does not ignore case.
+.IP "-I or --IGNORE-CASE"
+Like -i, but searches ignore case even if
+the pattern contains uppercase letters.
+.IP "-j\fIn\fP or --jump-target=\fIn\fP"
+Specifies a line on the screen where the "target" line
+is to be positioned.
+A target line is the object of a text search,
+tag search, jump to a line number,
+jump to a file percentage, or jump to a marked position.
+The screen line is specified by a number: the top line on the screen
+is 1, the next is 2, and so on.
+The number may be negative to specify a line relative to the bottom
+of the screen: the bottom line on the screen is -1, the second
+to the bottom is -2, and so on.
+If the -j option is used, searches begin at the line immediately
+after the target line.
+For example, if "-j4" is used, the target line is the
+fourth line on the screen, so searches begin at the fifth line
+on the screen.
+.IP "-k\fIfilename\fP or --lesskey-file=\fIfilename\fP"
+Causes
+.I less
+to open and interpret the named file as a
+.I lesskey
+(1) file.
+Multiple -k options may be specified.
+If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or
+if a lesskey file is found in a standard place (see KEY BINDINGS),
+it is also used as a
+.I lesskey
+file.
+.IP "-m or --long-prompt"
+Causes
+.I less
+to prompt verbosely (like \fImore\fP),
+with the percent into the file.
+By default,
+.I less
+prompts with a colon.
+.IP "-M or --LONG-PROMPT"
+Causes
+.I less
+to prompt even more verbosely than
+.I more.
+.IP "-n or --line-numbers"
+Suppresses line numbers.
+The default (to use line numbers) may cause
+.I less
+to run more slowly in some cases, especially with a very large input file.
+Suppressing line numbers with the -n option will avoid this problem.
+Using line numbers means: the line number will be displayed in the verbose
+prompt and in the = command,
+and the v command will pass the current line number to the editor
+(see also the discussion of LESSEDIT in PROMPTS below).
+.IP "-N or --LINE-NUMBERS"
+Causes a line number to be displayed at the beginning of
+each line in the display.
+.IP "-o\fIfilename\fP or --log-file=\fIfilename\fP"
+Causes
+.I less
+to copy its input to the named file as it is being viewed.
+This applies only when the input file is a pipe,
+not an ordinary file.
+If the file already exists,
+.I less
+will ask for confirmation before overwriting it.
+.IP "-O\fIfilename\fP or --LOG-FILE=\fIfilename\fP"
+The -O option is like -o, but it will overwrite an existing
+file without asking for confirmation.
+.sp
+If no log file has been specified,
+the -o and -O options can be used from within
+.I less
+to specify a log file.
+Without a file name, they will simply report the name of the log file.
+The "s" command is equivalent to specifying -o from within
+.I less.
+.IP "-p\fIpattern\fP or --pattern=\fIpattern\fP"
+The -p option on the command line is equivalent to
+specifying +/\fIpattern\fP;
+that is, it tells
+.I less
+to start at the first occurrence of \fIpattern\fP in the file.
+.IP "-P\fIprompt\fP or --prompt=\fIprompt\fP"
+Provides a way to tailor the three prompt
+styles to your own preference.
+This option would normally be put in the LESS environment
+variable, rather than being typed in with each
+.I less
+command.
+Such an option must either be the last option in the LESS variable,
+or be terminated by a dollar sign.
+-Ps followed by a string changes the default (short) prompt
+to that string.
+-Pm changes the medium (-m) prompt.
+-PM changes the long (-M) prompt.
+-Ph changes the prompt for the help screen.
+-P= changes the message printed by the = command.
+All prompt strings consist of a sequence of
+letters and special escape sequences.
+See the section on PROMPTS for more details.
+.IP "-q or --quiet or --silent"
+Causes moderately "quiet" operation:
+the terminal bell is not rung
+if an attempt is made to scroll past the end of the file
+or before the beginning of the file.
+If the terminal has a "visual bell", it is used instead.
+The bell will be rung on certain other errors,
+such as typing an invalid character.
+The default is to ring the terminal bell in all such cases.
+.IP "-Q or --QUIET or --SILENT"
+Causes totally "quiet" operation:
+the terminal bell is never rung.
+.IP "-r or --raw-control-chars"
+Causes "raw" control characters to be displayed.
+The default is to display control characters using the caret notation;
+for example, a control-A (octal 001) is displayed as "^A".
+Warning: when the -r option is used,
+.I less
+cannot keep track of the actual appearance of the screen
+(since this depends on how the screen responds to
+each type of control character).
+Thus, various display problems may result,
+such as long lines being split in the wrong place.
+.IP "-R or --RAW-CONTROL-CHARS"
+Like -r, but tries to keep track of the screen appearance where possible.
+This works only if the input consists of normal text and possibly some
+ANSI "color" escape sequences, which are sequences of the form:
+.sp
+ ESC [ ... m
+.sp
+where the "..." is zero or more characters other than "m".
+For the purpose of keeping track of screen appearance,
+all control characters and all ANSI color escape sequences are
+assumed to not move the cursor.
+You can make
+.I less
+think that characters other than "m" can end ANSI color escape sequences
+by setting the environment variable LESSANSIENDCHARS to the list of
+characters which can end a color escape sequence.
+.IP "-s or --squeeze-blank-lines"
+Causes consecutive blank lines to be squeezed into a single blank line.
+This is useful when viewing
+.I nroff
+output.
+.IP "-S or --chop-long-lines"
+Causes lines longer than the screen width to be
+chopped rather than folded.
+That is, the remainder of a long line is simply discarded.
+The default is to fold long lines; that is, display the remainder
+on the next line.
+.IP "-t\fItag\fP or --tag=\fItag\fP"
+The -t option, followed immediately by a TAG,
+will edit the file containing that tag.
+For this to work, there must be a file called "tags" in the
+current directory, which was previously built by the
+.I ctags
+(1) command.
+This option may also be specified from within
+.I less
+(using the \- command) as a way of examining a new file.
+The command ":t" is equivalent to specifying -t from within
+.I less.
+.IP "-T\fItagsfile\fP or --tag-file=\fItagsfile\fP"
+Specifies a tags file to be used instead of "tags".
+.IP "-u or --underline-special"
+Causes backspaces and carriage returns to be treated as printable characters;
+that is, they are sent to the terminal when they appear in the input.
+.IP "-U or --UNDERLINE-SPECIAL"
+Causes backspaces, tabs and carriage returns to be
+treated as control characters;
+that is, they are handled as specified by the -r option.
+.sp
+By default, if neither -u nor -U is given,
+backspaces which appear adjacent to an underscore character
+are treated specially:
+the underlined text is displayed
+using the terminal's hardware underlining capability.
+Also, backspaces which appear between two identical characters
+are treated specially:
+the overstruck text is printed
+using the terminal's hardware boldface capability.
+Other backspaces are deleted, along with the preceding character.
+Carriage returns immediately followed by a newline are deleted.
+other carriage returns are handled as specified by the -r option.
+Text which is overstruck or underlined can be searched for
+if neither -u nor -U is in effect.
+.IP "-V or --version"
+Displays the version number of
+.I less.
+.IP "-w or --hilite-unread"
+Temporarily highlights the first "new" line after a forward movement
+of a full page.
+The first "new" line is the line immediately following the line previously
+at the bottom of the screen.
+Also highlights the target line after a g or p command.
+The highlight is removed at the next command which causes movement.
+.IP "-W or --HILITE-UNREAD"
+Like -w, but temporarily highlights the first new line after any
+forward movement command larger than one line.
+.IP "-x\fIn\fP or --tabs=\fIn\fP"
+Sets tab stops every \fIn\fP positions.
+The default for \fIn\fP is 8.
+.IP "-X or --no-init"
+Disables sending the termcap initialization and deinitialization strings
+to the terminal.
+This is sometimes desirable if the deinitialization string does
+something unnecessary, like clearing the screen.
+.IP "-y\fIn\fP or --max-forw-scroll=\fIn\fP"
+Specifies a maximum number of lines to scroll forward.
+If it is necessary to scroll forward more than \fIn\fP lines,
+the screen is repainted instead.
+The -c or -C option may be used to repaint from the top of
+the screen if desired.
+By default, any forward movement causes scrolling.
+.IP "-[z]\fIn\fP or --window=\fIn\fP"
+Changes the default scrolling window size to \fIn\fP lines.
+The default is one screenful.
+The z and w commands can also be used to change the window size.
+The "z" may be omitted for compatibility with
+.I more.
+If the number
+.I n
+is negative, it indicates
+.I n
+lines less than the current screen size.
+For example, if the screen is 24 lines, \fI-z-4\fP sets the
+scrolling window to 20 lines. If the screen is resized to 40 lines,
+the scrolling window automatically changes to 36 lines.
+.IP -"\fIcc\fP\ or\ --quotes=\fIcc\fP
+Changes the filename quoting character.
+This may be necessary if you are trying to name a file
+which contains both spaces and quote characters.
+Followed by a single character, this changes the quote character to that
+character.
+Filenames containing a space should then be surrounded by that character
+rather than by double quotes.
+Followed by two characters, changes the open quote to the first character,
+and the close quote to the second character.
+Filenames containing a space should then be preceded by the open quote
+character and followed by the close quote character.
+Note that even after the quote characters are changed, this option
+remains -" (a dash followed by a double quote).
+.IP "-~ or --tilde"
+Normally lines after end of file are displayed as a single tilde (~).
+This option causes lines after end of file to be displayed as blank lines.
+.IP --
+A command line argument of "--" marks the end of option arguments.
+Any arguments following this are interpreted as filenames.
+This can be useful when viewing a file whose name begins with a "-" or "+".
+.IP +
+If a command line option begins with \fB+\fP,
+the remainder of that option is taken to be an initial command to
+.I less.
+For example, +G tells
+.I less
+to start at the end of the file rather than the beginning,
+and +/xyz tells it to start at the first occurrence of "xyz" in the file.
+As a special case, +<number> acts like +<number>g;
+that is, it starts the display at the specified line number
+(however, see the caveat under the "g" command above).
+If the option starts with ++, the initial command applies to
+every file being viewed, not just the first one.
+The + command described previously
+may also be used to set (or change) an initial command for every file.
+
+.SH "LINE EDITING"
+When entering command line at the bottom of the screen
+(for example, a filename for the :e command,
+or the pattern for a search command),
+certain keys can be used to manipulate the command line.
+Most commands have an alternate form in [ brackets ] which can be used if
+a key does not exist on a particular keyboard.
+(The bracketed forms do not work in the MS-DOS version.)
+Any of these special keys may be entered literally by preceding
+it with the "literal" character, either ^V or ^A.
+A backslash itself may also be entered literally by entering two backslashes.
+.IP "LEFTARROW [ ESC-h ]"
+Move the cursor one space to the left.
+.IP "RIGHTARROW [ ESC-l ]"
+Move the cursor one space to the right.
+.IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
+(That is, CONTROL and LEFTARROW simultaneously.)
+Move the cursor one word to the left.
+.IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
+(That is, CONTROL and RIGHTARROW simultaneously.)
+Move the cursor one word to the right.
+.IP "HOME [ ESC-0 ]"
+Move the cursor to the beginning of the line.
+.IP "END [ ESC-$ ]"
+Move the cursor to the end of the line.
+.IP "BACKSPACE"
+Delete the character to the left of the cursor,
+or cancel the command if the command line is empty.
+.IP "DELETE or [ ESC-x ]"
+Delete the character under the cursor.
+.IP "^BACKSPACE [ ESC-BACKSPACE ]"
+(That is, CONTROL and BACKSPACE simultaneously.)
+Delete the word to the left of the cursor.
+.IP "^DELETE [ ESC-X or ESC-DELETE ]"
+(That is, CONTROL and DELETE simultaneously.)
+Delete the word under the cursor.
+.IP "UPARROW [ ESC-k ]"
+Retrieve the previous command line.
+.IP "DOWNARROW [ ESC-j ]"
+Retrieve the next command line.
+.IP "TAB"
+Complete the partial filename to the left of the cursor.
+If it matches more than one filename, the first match
+is entered into the command line.
+Repeated TABs will cycle thru the other matching filenames.
+If the completed filename is a directory, a "/" is appended to the filename.
+(On MS-DOS systems, a "\\" is appended.)
+The environment variable LESSSEPARATOR can be used to specify a
+different character to append to a directory name.
+.IP "BACKTAB [ ESC-TAB ]"
+Like, TAB, but cycles in the reverse direction thru the matching filenames.
+.IP "^L"
+Complete the partial filename to the left of the cursor.
+If it matches more than one filename, all matches are entered into
+the command line (if they fit).
+.IP "^U (Unix) or ESC (MS-DOS)"
+Delete the entire command line,
+or cancel the command if the command line is empty.
+If you have changed your line-kill character in Unix to something
+other than ^U, that character is used instead of ^U.
+
+.SH "KEY BINDINGS"
+You may define your own
+.I less
+commands by using the program
+.I lesskey
+(1)
+to create a lesskey file.
+This file specifies a set of command keys and an action
+associated with each key.
+You may also use
+.I lesskey
+to change the line-editing keys (see LINE EDITING),
+and to set environment variables.
+If the environment variable LESSKEY is set,
+.I less
+uses that as the name of the lesskey file.
+Otherwise,
+.I less
+looks in a standard place for the lesskey file:
+On Unix systems,
+.I less
+looks for a lesskey file called "$HOME/.less".
+On MS-DOS and Windows systems,
+.I less
+looks for a lesskey file called "$HOME/_less", and if it is not found there,
+then looks for a lesskey file called "_less" in any directory specified
+in the PATH environment variable.
+On OS/2 systems,
+.I less
+looks for a lesskey file called "$HOME/less.ini", and if it is not found,
+then looks for a lesskey file called "less.ini" in any directory specified
+in the INIT environment variable, and if it not found there,
+then looks for a lesskey file called "less.ini" in any directory specified
+in the PATH environment variable.
+See the
+.I lesskey
+manual page for more details.
+.P
+A system-wide lesskey file may also be set up to provide key bindings.
+If a key is defined in both a local lesskey file and in the
+system-wide file, key bindings in the local file take precedence over
+those in the system-wide file.
+If the environment variable LESSKEY_SYSTEM is set,
+.I less
+uses that as the name of the system-wide lesskey file.
+Otherwise,
+.I less
+looks in a standard place for the system-wide lesskey file:
+On Unix syste