summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/less/INSTALL146
-rw-r--r--usr.bin/less/Makefile.aut116
-rw-r--r--usr.bin/less/Makefile.dsb51
-rw-r--r--usr.bin/less/Makefile.dsg92
-rw-r--r--usr.bin/less/Makefile.dsu59
-rw-r--r--usr.bin/less/Makefile.in122
-rw-r--r--usr.bin/less/Makefile.inc6
-rw-r--r--usr.bin/less/Makefile.o2e43
-rw-r--r--usr.bin/less/Makefile.o9c47
-rw-r--r--usr.bin/less/Makefile.o9u43
-rw-r--r--usr.bin/less/Makefile.wnb71
-rw-r--r--usr.bin/less/Makefile.wnm56
-rw-r--r--usr.bin/less/NEWS865
-rw-r--r--usr.bin/less/README237
-rw-r--r--usr.bin/less/brac.c46
-rw-r--r--usr.bin/less/ch.c460
-rw-r--r--usr.bin/less/charset.c703
-rw-r--r--usr.bin/less/charset.h28
-rw-r--r--usr.bin/less/cmd.h44
-rw-r--r--usr.bin/less/cmdbuf.c708
-rw-r--r--usr.bin/less/command.c636
-rw-r--r--usr.bin/less/configure6747
-rw-r--r--usr.bin/less/configure.ac563
-rw-r--r--usr.bin/less/cvt.c49
-rw-r--r--usr.bin/less/decode.c632
-rw-r--r--usr.bin/less/defines.ds400
-rw-r--r--usr.bin/less/defines.h415
-rw-r--r--usr.bin/less/defines.h.in432
-rw-r--r--usr.bin/less/defines.o2328
-rw-r--r--usr.bin/less/defines.o9340
-rw-r--r--usr.bin/less/defines.wn339
-rw-r--r--usr.bin/less/edit.c386
-rw-r--r--usr.bin/less/filename.c820
-rw-r--r--usr.bin/less/forwback.c207
-rw-r--r--usr.bin/less/funcs.h583
-rw-r--r--usr.bin/less/help.c235
-rw-r--r--usr.bin/less/ifile.c169
-rw-r--r--usr.bin/less/input.c224
-rw-r--r--usr.bin/less/install.sh119
-rw-r--r--usr.bin/less/jump.c134
-rw-r--r--usr.bin/less/less.h342
-rw-r--r--usr.bin/less/less/Makefile7
-rw-r--r--usr.bin/less/lessecho.c271
-rw-r--r--usr.bin/less/lessecho.man49
-rw-r--r--usr.bin/less/lessecho.nro47
-rw-r--r--usr.bin/less/lesskey.167
-rw-r--r--usr.bin/less/lesskey.c481
-rw-r--r--usr.bin/less/lesskey.h5
-rw-r--r--usr.bin/less/lesskey/Makefile11
-rw-r--r--usr.bin/less/lglob.h32
-rw-r--r--usr.bin/less/line.c663
-rw-r--r--usr.bin/less/linenum.c180
-rw-r--r--usr.bin/less/lsystem.c235
-rw-r--r--usr.bin/less/main.c359
-rw-r--r--usr.bin/less/mark.c88
-rw-r--r--usr.bin/less/mkfuncs.awk9
-rw-r--r--usr.bin/less/mkinstalldirs32
-rw-r--r--usr.bin/less/optfunc.c411
-rw-r--r--usr.bin/less/option.c374
-rw-r--r--usr.bin/less/option.h17
-rw-r--r--usr.bin/less/opttbl.c365
-rw-r--r--usr.bin/less/os.c266
-rw-r--r--usr.bin/less/output.c434
-rw-r--r--usr.bin/less/pattern.c317
-rw-r--r--usr.bin/less/pattern.h47
-rw-r--r--usr.bin/less/pckeys.h34
-rw-r--r--usr.bin/less/position.c95
-rw-r--r--usr.bin/less/position.h5
-rw-r--r--usr.bin/less/prompt.c347
-rw-r--r--usr.bin/less/regexp.c1254
-rw-r--r--usr.bin/less/regexp.h34
-rw-r--r--usr.bin/less/screen.c2195
-rw-r--r--usr.bin/less/scrsize.c104
-rw-r--r--usr.bin/less/search.c675
-rw-r--r--usr.bin/less/signal.c152
-rw-r--r--usr.bin/less/tags.c313
-rw-r--r--usr.bin/less/ttyin.c130
-rw-r--r--usr.bin/less/version.c765
78 files changed, 4628 insertions, 24285 deletions
diff --git a/usr.bin/less/INSTALL b/usr.bin/less/INSTALL
deleted file mode 100644
index 8a7d026f700..00000000000
--- a/usr.bin/less/INSTALL
+++ /dev/null
@@ -1,146 +0,0 @@
- This is a generic INSTALL file for utilities distributions.
-If this package does not come with, e.g., installable documentation or
-data files, please ignore the references to them below.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation, and
-creates the Makefile(s) (one in each subdirectory of the source
-directory). In some packages it creates a C header file containing
-system-dependent definitions. It also creates a file `config.status'
-that you can run in the future to recreate the current configuration.
-
-To compile this package:
-
-1. Configure the package for your system.
-
- Normally, you just `cd' to the directory containing the package's
-source code and type `./configure'. 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 it is running, it
-prints some messages that tell what it is doing. If you don't want to
-see any messages, run `configure' with its standard output redirected
-to `/dev/null'; for example, `./configure >/dev/null'.
-
- To compile the package in a different directory from the one
-containing the source code, 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
-for some reason `configure' is not in the source code directory that
-you are configuring, then it will report that it can't find the source
-code. In that case, run `configure' with the option `--srcdir=DIR',
-where DIR is the directory that contains the source code.
-
- 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'. Alternately, you can do so by consistently
-giving a value for the `prefix' variable when you run `make', e.g.,
- make prefix=/usr/gnu
- make prefix=/usr/gnu install
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH' or set the `make'
-variable `exec_prefix' to PATH, the package will use PATH as the prefix
-for installing programs and libraries. Data files and documentation
-will still use the regular prefix. Normally, all files are installed
-using the same prefix.
-
- Some packages pay attention to `--with-PACKAGE' options to
-`configure', where PACKAGE is something like `gnu-as' or `x' (for the
-X Window System). They may also pay attention to `--enable-FEATURE'
-options, where FEATURE indicates an optional part of the package. The
-README should mention any `--with-' and `--enable-' options that the
-package recognizes.
-
- `configure' also recognizes the following options:
-
-`--help'
- Print a summary of the options to `configure', and exit.
-
-`--quiet'
-`--silent'
- Do not print messages saying which checks are being made.
-
-`--verbose'
- Print the results of the checks.
-
-`--version'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--x-includes=DIR'
- X include files are in DIR.
-
-`--x-libraries=DIR'
- X library files are in DIR.
-
- `configure' also accepts and ignores some other options.
-
- On systems that require unusual options for compilation or linking
-that the package's `configure' script does not know about, you can give
-`configure' initial values for variables by setting them in the
-environment. In Bourne-compatible shells, you can do that on the
-command line like this:
-
- CC='gcc -traditional' LIBS=-lposix ./configure
-
-On systems that have the `env' program, you can do it like this:
-
- env CC='gcc -traditional' LIBS=-lposix ./configure
-
- Here are the `make' variables that you might want to override with
-environment variables when running `configure'.
-
- For these variables, any value given in the environment overrides the
-value that `configure' would choose:
-
- - Variable: CC
- C compiler program. The default is `cc'.
-
- - Variable: INSTALL
- Program to use to install files. The default is `install' if you
- have it, `cp' otherwise.
-
- For these variables, any value given in the environment is added to
-the value that `configure' chooses:
-
- - Variable: DEFS
- Configuration options, in the form `-Dfoo -Dbar...'. Do not use
- this variable in packages that create a configuration header file.
-
- - Variable: LIBS
- Libraries to link with, in the form `-lfoo -lbar...'.
-
- If you need to do unusual things to compile the package, we encourage
-you to figure out how `configure' could check whether to do them, and
-mail diffs or instructions to the address given in the README so we
-can include them in the next release.
-
-2. Type `make' to compile the package. If you want, you can override
-the `make' variables CFLAGS and LDFLAGS like this:
-
- make CFLAGS=-O2 LDFLAGS=-s
-
-3. If the package comes with self-tests and you want to run them,
-type `make check'. If you're not sure whether there are any, try it;
-if `make' responds with something like
- make: *** No way to make target `check'. Stop.
-then the package does not come with self-tests.
-
-4. Type `make install' to install programs, data files, and
-documentation.
-
-5. You can remove the program binaries and object files from the
-source directory by typing `make clean'. To also remove the
-Makefile(s), the header file containing system-dependent definitions
-(if the package uses one), and `config.status' (all the files that
-`configure' created), type `make distclean'.
-
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need it if you want to regenerate
-`configure' using a newer version of `autoconf'.
diff --git a/usr.bin/less/Makefile.aut b/usr.bin/less/Makefile.aut
deleted file mode 100644
index f105d6902f0..00000000000
--- a/usr.bin/less/Makefile.aut
+++ /dev/null
@@ -1,116 +0,0 @@
-# Makefile for authoring less.
-
-EMAIL = markn@greenwoodsoftware.com
-HOMEPAGE = http://www.greenwoodsoftware.com/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.dsu \
- 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.ac lesskey.c lessecho.c scrsize.c \
- cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
- install.sh defines.h.in 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.ac \
- ${srcdir}/Makefile.in
- 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/usr.bin/less/Makefile.dsb b/usr.bin/less/Makefile.dsb
deleted file mode 100644
index e45b6025cf4..00000000000
--- a/usr.bin/less/Makefile.dsb
+++ /dev/null
@@ -1,51 +0,0 @@
-# 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 cvt.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 pattern.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/usr.bin/less/Makefile.dsg b/usr.bin/less/Makefile.dsg
deleted file mode 100644
index b921b5dec9b..00000000000
--- a/usr.bin/less/Makefile.dsg
+++ /dev/null
@@ -1,92 +0,0 @@
-# Makefile for less under DJGPP v2.0 or later.
-
-#### Start of system configuration section. ####
-
-srcdir = .
-VPATH = .
-
-CC = gcc
-INSTALL = ginstall -c
-INSTALL_PROGRAM = ginstall
-INSTALL_DATA = ginstall -m 644
-AWK = gawk
-
-CFLAGS = -O2 -g
-CFLAGS_COMPILE_ONLY = -c
-#LDFLAGS = -s
-LDFLAGS = -g
-O=o
-
-LIBS =
-prefix = /dev/env/DJDIR
-exec_prefix = ${prefix}
-
-bindir = ${exec_prefix}/bin
-sysconfdir = ${prefix}/etc
-mandir = ${prefix}/man
-manext = 1
-
-#### 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} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<
-
-OBJ = \
- main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
- command.${O} cvt.${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} pattern.${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}: ${srcdir}/less.h defines.h ${srcdir}/funcs.h
-
-install: all ${srcdir}/less.man ${srcdir}/lesskey.man
- ${INSTALL_PROGRAM} less.exe ${bindir}/less.exe
- ${INSTALL_PROGRAM} lesskey.exe ${bindir}/lesskey.exe
- ${INSTALL_PROGRAM} lessecho.exe ${bindir}/lessecho.exe
- ${INSTALL_DATA} ${srcdir}/less.man ${mandir}/man${manext}/less.${manext}
- ${INSTALL_DATA} ${srcdir}/lesskey.man ${mandir}/man${manext}/lesskey.${manext}
-
-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/usr.bin/less/Makefile.dsu b/usr.bin/less/Makefile.dsu
deleted file mode 100644
index 40a253848f6..00000000000
--- a/usr.bin/less/Makefile.dsu
+++ /dev/null
@@ -1,59 +0,0 @@
-# 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 cvt.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 pattern.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/usr.bin/less/Makefile.in b/usr.bin/less/Makefile.in
deleted file mode 100644
index 8c8aed81edc..00000000000
--- a/usr.bin/less/Makefile.in
+++ /dev/null
@@ -1,122 +0,0 @@
-# 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@
-CPPFLAGS = @CPPFLAGS@
-EXEEXT = @EXEEXT@
-O=o
-
-LIBS = @LIBS@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-# Where the installed binary goes.
-bindir = @bindir@
-binprefix =
-
-sysconfdir = @sysconfdir@
-datarootdir = @datarootdir@
-
-mandir = @mandir@
-manext = 1
-manprefix =
-DESTDIR =
-
-#### 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} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<
-
-OBJ = \
- main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
- command.${O} cvt.${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} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
- tags.${O} ttyin.${O} version.${O} @REGEX_O@
-
-all: less$(EXEEXT) lesskey$(EXEEXT) lessecho$(EXEEXT)
-
-less$(EXEEXT): ${OBJ}
- ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
-
-lesskey$(EXEEXT): lesskey.${O} version.${O}
- ${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
-
-lessecho$(EXEEXT): 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 ${srcdir}/lessecho.nro installdirs
- ${INSTALL_PROGRAM} less$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}less$(EXEEXT)
- ${INSTALL_PROGRAM} lesskey$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}lesskey$(EXEEXT)
- ${INSTALL_PROGRAM} lessecho$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}lessecho$(EXEEXT)
- ${INSTALL_DATA} ${srcdir}/less.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}less.${manext}
- ${INSTALL_DATA} ${srcdir}/lesskey.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}lesskey.${manext}
- ${INSTALL_DATA} ${srcdir}/lessecho.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}lessecho.${manext}
-
-install-strip:
- ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install
-
-installdirs: mkinstalldirs
- ${srcdir}/mkinstalldirs ${DESTDIR}${bindir} ${DESTDIR}${mandir}/man${manext}
-
-uninstall:
- rm -f ${DESTDIR}${bindir}/${binprefix}less$(EXEEXT)
- rm -f ${DESTDIR}${bindir}/${binprefix}lesskey$(EXEEXT)
- rm -f ${DESTDIR}${bindir}/${binprefix}lessecho$(EXEEXT)
- rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}less.${manext}
- rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}lesskey.${manext}
- rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}lessecho.${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.ac
- cd ${srcdir}; autoheader; autoconf
-
-clean:
- rm -f *.${O} core less$(EXEEXT) lesskey$(EXEEXT) lessecho$(EXEEXT)
-
-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/usr.bin/less/Makefile.inc b/usr.bin/less/Makefile.inc
deleted file mode 100644
index 9a8aee08317..00000000000
--- a/usr.bin/less/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@
-# $OpenBSD: Makefile.inc,v 1.1 2011/09/16 18:20:14 shadchin Exp $
-
-BINDIR= /usr/bin
-CPPFLAGS+= -I${.CURDIR}/..
-
-.PATH: ${.CURDIR}/..
diff --git a/usr.bin/less/Makefile.o2e b/usr.bin/less/Makefile.o2e
deleted file mode 100644
index 3bb6dfc4eb5..00000000000
--- a/usr.bin/less/Makefile.o2e
+++ /dev/null
@@ -1,43 +0,0 @@
-# Makefile for less.
-# OS/2 version, for emx+gcc compiler
-
-#### Start of system configuration section. ####
-
-CC = gcc -Zomf
-CFLAGS = -I. -O2 -Wall
-LDFLAGS = -s -Zcrtdll
-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} cvt.${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} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
- tags.${O} ttyin.${O} version.${O} regexp.${O}
-
-all: less.exe lesskey.exe scrsize.exe
-
-less.exe: ${OBJ}
- ${CC} ${OBJ} -o $@ ${LDFLAGS} ${LIBS}
-
-lesskey.exe: lesskey.${O} version.${O}
- ${CC} lesskey.${O} version.${O} -o $@ ${LDFLAGS}
-
-scrsize.exe: scrsize.c
- ${CC} ${CFLAGS} -D__ST_MT_ERRNO__ -s -Zmtd -lX11 $<
-
-${OBJ}: defines.h less.h
-
-defines.h: defines.o2
- copy defines.o2 defines.h
diff --git a/usr.bin/less/Makefile.o9c b/usr.bin/less/Makefile.o9c
deleted file mode 100644
index e107f55946b..00000000000
--- a/usr.bin/less/Makefile.o9c
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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} cvt.${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} pattern.${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/usr.bin/less/Makefile.o9u b/usr.bin/less/Makefile.o9u
deleted file mode 100644
index 8ca84c89725..00000000000
--- a/usr.bin/less/Makefile.o9u
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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} cvt.${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} pattern.${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/usr.bin/less/Makefile.wnb b/usr.bin/less/Makefile.wnb
deleted file mode 100644
index 75a65cdd2c5..00000000000
--- a/usr.bin/less/Makefile.wnb
+++ /dev/null
@@ -1,71 +0,0 @@
-# Makefile for less.
-# Windows version
-# Bolarnd C++ 5.5.1 free command line tools
-
-#### Start of system configuration section. ####
-#
-# Borland's make knows its own location in the
-# filesystem.
-#
-
-CC = bcc32
-LIBDIR = $(MAKEDIR)\..\lib
-
-CFLAGS = -O2 -w-pro -TWC -P-c -v- -d -f- -ff- -vi
-LDFLAGS = -Tpe -v- -ap -c -x -V4.0 -GF:AGGRESSIVE
-LD = ilink32
-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 cvt.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 pattern.obj position.obj prompt.obj search.obj signal.obj \
- tags.obj ttyin.obj version.obj regexp.obj
-
-all: less lesskey lessecho
-
-#
-# This is really horrible, but the command line is too long for
-# MS-DOS if we try to link ${OBJ}.
-#
-less: ${OBJ}
- ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
-
-lesskey: lesskey.obj version.obj
- ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
-
-lessecho: lessecho.obj version.obj
- ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.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 *.il?
- -del *.tds
- -del defines.h
-
-spotless: clean
- -del less.exe
- -del lesskey.exe
- -del lessecho.exe
-
-realclean: spotless
-
-distclean: spotless
-
diff --git a/usr.bin/less/Makefile.wnm b/usr.bin/less/Makefile.wnm
deleted file mode 100644
index 7b33833837d..00000000000
--- a/usr.bin/less/Makefile.wnm
+++ /dev/null
@@ -1,56 +0,0 @@
-# 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 = /nologo /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 = /nologo /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 cvt.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 pattern.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/usr.bin/less/NEWS b/usr.bin/less/NEWS
deleted file mode 100644
index e03f35af352..00000000000
--- a/usr.bin/less/NEWS
+++ /dev/null
@@ -1,865 +0,0 @@
-
- NEWS about less
-
-======================================================================
-
- For the latest news about less, see the "less" Web page:
- http://www.greenwoodsoftware.com/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.
-
-======================================================================
-
- Major changes between "less" versions 451 and 458
-
-* Allow backslash escaping of metacharacters in LESS environment variable
- after the --use-backslash option.
-
-* Don't quit if syntax errors are found in command line options.
-
-* Increase sizes of some internal buffers.
-
-* Fix configure bug with --with-regex=none.
-
-* Fix crash with "stty rows 0".
-
-* Fix Win32 attribute display bug.
-
-* Fix display bug when using up/down arrow on the command line.
-
-======================================================================
-
- Major changes between "less" versions 444 and 451
-
-* Add ESC-F command to keep reading data until a pattern is found.
-
-* Use exit code of LESSOPEN script if LESSOPEN starts with "||".
-
-* When up/down arrow is used on the command line immediately after
- typing text, the next command starting with that text is found.
-
-* Add support for GNU regex.
-
-* Add configure option --with-regex=none and fix compile errors
- when compiling with no regex library.
-
-* Fix bugs handling SGR sequences in Win32.
-
-* Fix possible crashes caused by malformed LESSOPEN or
- LESSCLOSE variables.
-
-* Fix bug highlighting text which is discontiguous in the file
- due to backspace processing.
-
-* Fix bug in displaying status column when scrolling backwards
- with -J and -S in effect.
-
-======================================================================
-
- Major changes between "less" versions 443 and 444
-
-* Fix bug in unget handling that can cause strange effects on the
- command line.
-
-* Remove vestiges of obsolete -l option that can cause a crash.
-
-======================================================================
-
- Major changes between "less" versions 436 and 443
-
-* Change search behavior such that when a search is given an explicit
- pattern, the entire displayed screen is included in the search and
- not just the portion after the target line.
-
-* Add -A option to change search behavior to the old way: only
- the portion of the screen after the target line is searched.
-
-* Add %F formatting to prompt strings, replaced by the last component
- of the input file.
-
-* Control-G while editing a command exits the command.
-
-* Less now exits with status 2 if control-C is pressed and -K is in effect.
-
-* Fix "ungetc overflow" when passing long commands via the -p option.
-
-* Fix bug in using line filtering via the & command
- in combination with -i and -I.
-
-* Fix bug in handling negative arguments to the -j option.
-
-* Fix bug in handling %t in prompt strings.
-
-* Improve handling of long option names.
-
-* Improve percentage calculation for very large files.
-
-======================================================================
-
- Major changes between "less" versions 429 and 436
-
-* Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
-
-* Allow a fraction as the argument to the -# (--shift) option.
-
-* Fix highlight bug when underlined/overstruck text matches at end of line.
-
-* Fix non-regex searches with ctrl-R.
-
-======================================================================
-
- Major changes between "less" versions 424 and 429
-
-* LESSOPEN pipe will now be used on standard input, if the LESSOPEN
- environment variable begins with "|-".
-
-* The -D option with one number now means use the normal background color.
-
-* Don't change permissions on history file if it is not a regular file.
-
-* Fix non-ANSI-compliant code that caused problems with some compilers.
-
-* Fix binary file detection in UTF-8 mode.
-
-* Fix display problems with long lines on "ignaw" terminals.
-
-* Fix problem interrupting the line number calculation for initial prompt.
-
-* Fix SGR emulation when dealing with multiple attributes (eg. bold+underline).
-
-* Fix highlight bug when searching for underlined/overstruck text.
-
-======================================================================
-
- Major changes between "less" versions 418 and 424
-
-* New "&" command allows filtering of lines based on a pattern.
-
-* Status column now displays a search match, even if the matched
- string is scrolled off screen because -S is in effect.
-
-* Improve behavior of -F option.
-
-* Allow CSI character (0x9B) to work in UTF-8 mode.
-
-* Output carriage return at startup in case terminal doesn't default
- to column 1.
-
-* Fix bug in '' (quote, quote) command after G command.
-
-======================================================================
-
- Major changes between "less" versions 416 and 418
-
-* Color escape sequences are now supported in WIN32 build.
-
-* Makefile now uses EXEEXT feature of autoconf.
-
-* Fix search bug when using -R and text contains ANSI color escape sequences.
-
-* Fix crash when using -r with UTF-8 text containing 0x9B bytes.
-
-* Fix display bug when using ' command to move less than one page forward.
-
-* Update GPL to version 3.
-
-======================================================================
-
- Major changes between "less" versions 409 and 416
-
-* New --follow-name option makes F command follow the name of a file
- rather than the file descriptor if an open file is renamed.
-
-* Make searching with -i/-I work correctly with non-ASCII text.
-
-* Fix DJGPP build.
-
-======================================================================
-
- Major changes between "less" versions 406 and 409
-
-* Support CSI escape sequences, like SGR escape sequences.
-
-* Fix bug which caused screen to fail to repaint when window is resized.
-
-* Fix bug in using -i and -I flags with non-ASCII text.
-
-* Fix configure bug on systems which don't support langinfo.h.
-
-* Fix crash when searching text containing certain invalid UTF-8 sequences.
-
-======================================================================
-
- Major changes between "less" versions 394 and 406
-
-* Allow decimal point in number for % (percent) command.
-
-* Allow decimal point in number for -j option (fraction of screen height).
-
-* Make n command fetch previous pattern from history file on first search.
-
-* Don't rewrite history file if it has not changed.
-
-* Don't move to bottom of screen on first page.
-
-* Don't output extraneous newlines, so copy & pasting lines from the
- output works better.
-
-* The -c option has been made identical with the -C option.
-
-* Allow "/dev/null" as synomym for "-" in LESSHISTFILE to indicate
- that no history file should be used.
-
-* Search can now find text which follows a null byte, if the PCRE
- library is used, or if no-regex searching (ctrl-R) is used.
-
-* Better compatibility with POSIX more specification.
-
-* Make -f work for directories.
-
-* Make "t" cmd traverse tags in the correct order.
-
-* Allow a few binary characters in the input file before warning
- that the file is binary.
-
-* Don't warn that file is binary if it merely contains ANSI color sequences
- and -R is in effect.
-
-* Update Unicode character tables.
-
-* Support DESTDIR in Makefile.
-
-* Fix bug when filename contains certain shell metacharacters such as "$".
-
-* Fix bug when resizing the window while waiting for input from a pipe.
-
-* Fix configure bugs.
-
-======================================================================
-
- Major changes between "less" versions 382 and 394
-
-* Add history file to save search and shell command history between
- invocations of less.
-
-* Improve behavior of history list for search and shell commands.
-
-* Add -K (or --quit-on-intr) option to make less exit immediately on ctrl-C.
-
-* Improve handling of UTF-8 files and commands, including better
- line wrapping and handling double-width chars.
-
-* Added LESSUTFBINFMT environment variable to control display of
- non-printable characters in a UTF-8 file.
-
-* Add --with-secure option to configure, to make it easier to
- build a secure version of less.
-
-* Show search matches in the status column even if search highlights
- are disabled via the -G option or the ESC-u command.
-
-* Improve performance when the file contains very long lines.
-
-* Add "windows" charset.
-
-* Add man page for lessecho.
-
-* Add support for erase2 character, treated same as erase.
-
-* Use ASCII lowercase/uppercase logic when operating on the command line.
-
-* Update makefile for Borland C++ 5.5.1.
-
-* Fix bug in calculating number of pages for %D prompt.
-
-* Fix bug in handling tag file error.
-
-* Fix obscure bug if input file is deleted while viewing help.
-
-* Fix bug handling filenames which include square brackets.
-
-* Fix possible buffer overflow in "global" tag search.
-
-* Fix possible buffer overflow in usage of LESSOPEN and LESSCLOSE.
-
-* Fix buffer overflow in reverse search.
-
-======================================================================
-
- Major changes between "less" versions 381 and 382
-
-* Removed some old copyrighted code.
- This probably breaks OS/9 support.
-
-======================================================================
-
- Major changes between "less" versions 378 and 381
-
-* New -L option to disable LESSOPEN processing.
-
-* Further support for large (64 bit) file addressing.
- Large file support is now set up by the configure script.
-
-* Use autoconf 2.54.
- Replace configure.in, acconfig.h, defines.h.top with configure.ac.
-
-* Overstriking underscore with underscore is now bold or underlined
- depending on context.
-
-* Use only 7 spaces for line numbers in -N mode, if possible.
-
-* Fix some bugs in handling overstriking in UTF-8 files.
-
-* Fix some nroff issues in the man page.
-
-======================================================================
-
- Major changes between "less" versions 376 and 378
-
-* Bug fixes:
- Default buffer space is now 64K as documented.
- Search highlighting works properly when used with -R.
- Windows version works properly when input file contains carriage returns.
- Clean up some compiler warnings.
-
-======================================================================
-
- Major changes between "less" versions 358 and 376
-
-* -x option can now specify multiple variable-width tab stops.
-
-* -X option no longer disables keypad initialization.
- New option --no-keypad disables keypad initialization.
-
-* New commands t and T step through multiple tag matches.
- Added support for "global(1)" tags
- (see http://www.gnu.org/software/global/global.html).
-
-* New prompt style set by option -Pw defines the message printed
- while waiting for data in the F command.
-
-* System-wide lesskey file now defaults to sysless in etc directory
- instead of .sysless in bin directory.
- Use "configure --sysconfdir=..." to change it.
- (For backwards compatibility, .sysless in bin is still recognized.)
-
-* Pressing RightArrow or LeftArrow while entering a number now shifts
- the display N columns rather than editing the number itself.
-
-* Status column (enabled with -J) now shows search results.
-
-* Windows version sets window title.
-
-* Default LESSCHARSET for MS-DOS versions is now "dos".
-
-* Searching works better with ANSI (SGR) escape sequences.
- ANSI color escape sequences are now supported in the MS-DOS (DJGPP) version.
-
-* Improved performance in reading very large pipes.
-
-* Eliminated some dependencies on file offets being 32 bits.
-
-* Fixed problems when viewing files with very long lines.
-
-* Fixed overstriking in UTF-8 mode, and overstriking tabs.
-
-* Improved horizontal shifting of text using -R option with ANSI color.
-
-* Improved handling of filenames containing shell metacharacters.
-
-* Some fixes for EBCDIC systems.
-
-* Some fixes for OS/2 systems.
-
-======================================================================
-
- Major changes between "less" versions 354 and 358
-
-* Add -J (--status-column) option to display a status column.
-
-* Add -# (--shift) option to set default horizontal shift distance.
- Default horizontal shift distance is now one-half screen width.
-
-* Horizontal shifting does not shift line numbers if -N is in effect.
-
-* Horizontal shifting acts as though -S were set, to avoid confusion.
-
-======================================================================
-
-
- 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/usr.bin/less/README b/usr.bin/less/README
deleted file mode 100644
index a7bdba4596e..00000000000
--- a/usr.bin/less/README
+++ /dev/null
@@ -1,237 +0,0 @@
-
- Less, version 458
-
- This is the distribution of less, version 458, released 04 Apr 2013.
- 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 3, 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.
- See http://www.greenwoodsoftware.com/less for the latest info.
-
-=========================================================================
-
-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).
- none No regular expressions, only simple string matching.
- --with-secure
- Builds a "secure" version of less, with some features disabled
- to prevent users from viewing other files, accessing shell
- commands, etc.
-
-
-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 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 bug-less@gnu.org.
-
-Note to hackers: comments noting possible improvements are enclosed
-in double curly brackets {{ like this }}.
-
-(Note that the above note was originally written at a time when
-"hackers" most commonly meant "enthusiastic and dedicated computer
-programmers", not "persons who attempt to circumvent computer security".)
-
-
-
-=======================================================================
-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.DSU 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,
- lesskey.exe and scrsize.exe in a directory which is included in
- your PATH. scrsize.exe is required only if you use a terminal
- emulator such as xterm or rxvt.
-
-
-
-=======================================================================
-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.
-
-=======================================================================
-ACKNOWLEDGMENTS:
- Some versions of the less distribution are packaged using
- Info-ZIP's compression utility.
- Info-ZIP's software is free and can be obtained as source
- code or executables from various anonymous-ftp sites,
- including ftp.uu.net:/pub/archiving/zip.
diff --git a/usr.bin/less/brac.c b/usr.bin/less/brac.c
index 70a7771ee30..051005dfdb2 100644
--- a/usr.bin/less/brac.c
+++ b/usr.bin/less/brac.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to perform bracket matching functions.
@@ -16,26 +19,20 @@
#include "position.h"
/*
- * Try to match the n-th open bracket
+ * Try to match the n-th open bracket
* which appears in the top displayed line (forwdir),
- * or the n-th close bracket
+ * or the n-th close bracket
* which appears in the bottom displayed line (!forwdir).
- * The characters which serve as "open bracket" and
+ * 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;
+void
+match_brac(int obrac, int cbrac, int forwdir, int n)
{
- register int c;
- register int nest;
- POSITION pos;
- int (*chget)();
-
- extern int ch_forw_get(), ch_back_get();
+ int c;
+ int nest;
+ off_t pos;
+ int (*chget)(void);
/*
* Seek to the line containing the open bracket.
@@ -43,8 +40,7 @@ match_brac(obrac, cbrac, forwdir, n)
* depending on the type of bracket.
*/
pos = position((forwdir) ? TOP : BOTTOM);
- if (pos == NULL_POSITION || ch_seek(pos))
- {
+ if (pos == -1 || ch_seek(pos)) {
if (forwdir)
error("Nothing in top line", NULL_PARG);
else
@@ -55,10 +51,8 @@ match_brac(obrac, cbrac, forwdir, n)
/*
* Look thru the line to find the open bracket to match.
*/
- do
- {
- if ((c = ch_forw_get()) == '\n' || c == EOI)
- {
+ do {
+ if ((c = ch_forw_get()) == '\n' || c == EOI) {
if (forwdir)
error("No bracket in top line", NULL_PARG);
else
@@ -81,12 +75,10 @@ match_brac(obrac, cbrac, forwdir, n)
*/
chget = (forwdir) ? ch_forw_get : ch_back_get;
nest = 0;
- while ((c = (*chget)()) != EOI)
- {
- if (c == obrac)
+ while ((c = (*chget)()) != EOI) {
+ if (c == obrac) {
nest++;
- else if (c == cbrac && --nest < 0)
- {
+ } else if (c == cbrac && --nest < 0) {
/*
* Found the matching bracket.
* If searching backward, put it on the top line.
diff --git a/usr.bin/less/ch.c b/usr.bin/less/ch.c
index 261668bec30..3303ede4083 100644
--- a/usr.bin/less/ch.c
+++ b/usr.bin/less/ch.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Low level character input from the input file.
@@ -15,20 +18,15 @@
*/
#include "less.h"
-#if MSDOS_COMPILER==WIN32C
-#include <errno.h>
-#include <windows.h>
-#endif
-#if HAVE_STAT_INO
#include <sys/stat.h>
extern dev_t curr_dev;
extern ino_t curr_ino;
-#endif
+extern int less_is_more;
-typedef POSITION BLOCKNUM;
+typedef off_t BLOCKNUM;
-public int ignore_eoi;
+int ignore_eoi;
/*
* Pool of buffers holding the most recently used blocks of the input file.
@@ -48,7 +46,7 @@ struct buf {
unsigned int datasize;
unsigned char data[LBUFSIZE];
};
-#define bufnode_buf(bn) ((struct buf *) bn)
+#define bufnode_buf(bn) ((struct buf *)bn)
/*
* The file state is maintained in a filestate structure.
@@ -60,11 +58,11 @@ struct filestate {
struct bufnode hashtbl[BUFHASH_SIZE];
int file;
int flags;
- POSITION fpos;
+ off_t fpos;
int nbufs;
BLOCKNUM block;
unsigned int offset;
- POSITION fsize;
+ off_t fsize;
};
#define ch_bufhead thisfile->buflist.next
@@ -79,7 +77,7 @@ struct filestate {
#define END_OF_CHAIN (&thisfile->buflist)
#define END_OF_HCHAIN(h) (&thisfile->hashtbl[h])
-#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1))
+#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1))
/*
* Macros to manipulate the list of buffers in thisfile->buflist.
@@ -87,17 +85,17 @@ struct filestate {
#define FOR_BUFS(bn) \
for (bn = ch_bufhead; bn != END_OF_CHAIN; bn = bn->next)
-#define BUF_RM(bn) \
+#define BUF_RM(bn) \
(bn)->next->prev = (bn)->prev; \
(bn)->prev->next = (bn)->next;
-#define BUF_INS_HEAD(bn) \
+#define BUF_INS_HEAD(bn) \
(bn)->next = ch_bufhead; \
(bn)->prev = END_OF_CHAIN; \
ch_bufhead->prev = (bn); \
ch_bufhead = (bn);
-#define BUF_INS_TAIL(bn) \
+#define BUF_INS_TAIL(bn) \
(bn)->next = END_OF_CHAIN; \
(bn)->prev = ch_buftail; \
ch_buftail->next = (bn); \
@@ -106,15 +104,15 @@ struct filestate {
/*
* Macros to manipulate the list of buffers in thisfile->hashtbl[n].
*/
-#define FOR_BUFS_IN_CHAIN(h,bn) \
+#define FOR_BUFS_IN_CHAIN(h, bn) \
for (bn = thisfile->hashtbl[h].hnext; \
- bn != END_OF_HCHAIN(h); bn = bn->hnext)
+ bn != END_OF_HCHAIN(h); bn = bn->hnext)
#define BUF_HASH_RM(bn) \
(bn)->hnext->hprev = (bn)->hprev; \
(bn)->hprev->hnext = (bn)->hnext;
-#define BUF_HASH_INS(bn,h) \
+#define BUF_HASH_INS(bn, h) \
(bn)->hnext = thisfile->hashtbl[h].hnext; \
(bn)->hprev = END_OF_HCHAIN(h); \
thisfile->hashtbl[h].hnext->hprev = (bn); \
@@ -130,40 +128,37 @@ extern int secure;
extern int screen_trashed;
extern int follow_mode;
extern IFILE curr_ifile;
-#if LOGFILE
extern int logfile;
extern char *namelogfile;
-#endif
-static int ch_addbuf();
+static int ch_addbuf(void);
/*
* Get the character pointed to by the read pointer.
*/
- int
-ch_get()
+int
+ch_get(void)
{
- register struct buf *bp;
- register struct bufnode *bn;
- register int n;
- register int slept;
- register int h;
- POSITION pos;
- POSITION len;
+ struct buf *bp;
+ struct bufnode *bn;
+ int n;
+ int slept;
+ int h;
+ off_t pos;
+ off_t len;
if (thisfile == NULL)
return (EOI);
/*
- * Quick check for the common case where
+ * Quick check for the common case where
* the desired char is in the head buffer.
*/
- if (ch_bufhead != END_OF_CHAIN)
- {
+ if (ch_bufhead != END_OF_CHAIN) {
bp = bufnode_buf(ch_bufhead);
if (ch_block == bp->block && ch_offset < bp->datasize)
- return bp->data[ch_offset];
+ return (bp->data[ch_offset]);
}
slept = FALSE;
@@ -172,11 +167,9 @@ ch_get()
* Look for a buffer holding the desired block.
*/
h = BUFHASH(ch_block);
- FOR_BUFS_IN_CHAIN(h, bn)
- {
+ FOR_BUFS_IN_CHAIN(h, bn) {
bp = bufnode_buf(bn);
- if (bp->block == ch_block)
- {
+ if (bp->block == ch_block) {
if (ch_offset >= bp->datasize)
/*
* Need more data in this buffer.
@@ -185,26 +178,26 @@ ch_get()
goto found;
}
}
- if (bn == END_OF_HCHAIN(h))
- {
+ if (bn == END_OF_HCHAIN(h)) {
/*
- * Block is not in a buffer.
- * Take the least recently used buffer
+ * 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,
+ * If the LRU buffer has data in it,
* then maybe allocate a new buffer.
*/
- if (ch_buftail == END_OF_CHAIN ||
- bufnode_buf(ch_buftail)->block != -1)
- {
+ if (ch_buftail == END_OF_CHAIN ||
+ bufnode_buf(ch_buftail)->block != -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.
+ * 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)) ||
- (maxbufs < 0 || ch_nbufs < maxbufs))
+ (maxbufs < 0 || ch_nbufs < maxbufs))
if (ch_addbuf())
/*
* Allocation failed: turn off autobuf.
@@ -219,16 +212,15 @@ ch_get()
BUF_HASH_INS(bn, h); /* Insert into new hash chain. */
}
- read_more:
+read_more:
pos = (ch_block * LBUFSIZE) + bp->datasize;
- if ((len = ch_length()) != NULL_POSITION && pos >= len)
+ if ((len = ch_length()) != -1 && pos >= len)
/*
* At end of file.
*/
return (EOI);
- if (pos != ch_fpos)
- {
+ 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).
@@ -236,52 +228,41 @@ ch_get()
*/
if (!(ch_flags & CH_CANSEEK))
return ('?');
- if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
- {
- error("seek error", NULL_PARG);
+ if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK) {
+ error("seek error", NULL_PARG);
clear_eol();
return (EOI);
- }
- ch_fpos = pos;
- }
+ }
+ 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;
+ if (ch_ungotchar != -1) {
+ bp->data[bp->datasize] = (unsigned char)ch_ungotchar;
n = 1;
ch_ungotchar = -1;
- } else
- {
- n = iread(ch_file, &bp->data[bp->datasize],
- (unsigned int)(LBUFSIZE - bp->datasize));
+ } 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();
- }
+ if (n < 0) {
+ 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
+ (void) write(logfile, (char *)&bp->data[bp->datasize], n);
ch_fpos += n;
bp->datasize += n;
@@ -290,56 +271,46 @@ ch_get()
* If we have read to end of file, set ch_fsize to indicate
* the position of the end of file.
*/
- if (n == 0)
- {
+ if (n == 0) {
ch_fsize = pos;
- if (ignore_eoi)
- {
+ if (ignore_eoi) {
/*
* We are ignoring EOF.
* Wait a while, then try again.
*/
- if (!slept)
- {
+ if (!slept) {
PARG parg;
parg.p_string = wait_message();
ierror("%s", &parg);
}
-#if !MSDOS_COMPILER
- sleep(1);
-#else
-#if MSDOS_COMPILER==WIN32C
- Sleep(1000);
-#endif
-#endif
+ sleep(1);
slept = TRUE;
-#if HAVE_STAT_INO
- if (follow_mode == FOLLOW_NAME)
- {
- /* See whether the file's i-number has changed.
+ if (follow_mode == FOLLOW_NAME) {
+ /*
+ * See whether the file's i-number has changed.
* If so, force the file to be closed and
- * reopened. */
+ * reopened.
+ */
struct stat st;
int r = stat(get_filename(curr_ifile), &st);
if (r == 0 && (st.st_ino != curr_ino ||
- st.st_dev != curr_dev))
- {
- /* screen_trashed=2 causes
- * make_display to reopen the file. */
+ st.st_dev != curr_dev)) {
+ /*
+ * screen_trashed=2 causes
+ * make_display to reopen the file.
+ */
screen_trashed = 2;
return (EOI);
}
}
-#endif
}
if (sigs)
return (EOI);
}
- found:
- if (ch_bufhead != bn)
- {
+found:
+ if (ch_bufhead != bn) {
/*
* Move the buffer to the head of the buffer chain.
* This orders the buffer chain, most- to least-recently used.
@@ -365,32 +336,29 @@ ch_get()
}
/*
- * ch_ungetchar is a rather kludgy and limited way to push
+ * 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;
+void
+ch_ungetchar(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()
+void
+end_logfile(void)
{
static int tried = FALSE;
if (logfile < 0)
return;
- if (!tried && ch_fsize == NULL_POSITION)
- {
+ if (!tried && ch_fsize == -1) {
tried = TRUE;
ierror("Finishing logfile", NULL_PARG);
while (ch_forw_get() != EOI)
@@ -407,54 +375,46 @@ end_logfile()
* Invoked from the - command; see toggle_option().
* Write all the existing buffered data to the log file.
*/
- public void
-sync_logfile()
+void
+sync_logfile(void)
{
- register struct buf *bp;
- register struct bufnode *bn;
+ struct buf *bp;
+ struct bufnode *bn;
int warned = FALSE;
BLOCKNUM block;
BLOCKNUM nblocks;
nblocks = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE;
- for (block = 0; block < nblocks; block++)
- {
+ for (block = 0; block < nblocks; block++) {
int wrote = FALSE;
- FOR_BUFS(bn)
- {
+ FOR_BUFS(bn) {
bp = bufnode_buf(bn);
- if (bp->block == block)
- {
- write(logfile, (char *) bp->data, bp->datasize);
+ if (bp->block == block) {
+ (void) write(logfile, (char *)bp->data,
+ bp->datasize);
wrote = TRUE;
break;
}
}
- if (!wrote && !warned)
- {
- error("Warning: log file is incomplete",
- NULL_PARG);
+ if (!wrote && !warned) {
+ error("Warning: log file is incomplete", NULL_PARG);
warned = TRUE;
}
}
}
-#endif
-
/*
* Determine if a specific block is currently in one of the buffers.
*/
- static int
-buffered(block)
- BLOCKNUM block;
+static int
+buffered(BLOCKNUM block)
{
register struct buf *bp;
register struct bufnode *bn;
register int h;
h = BUFHASH(block);
- FOR_BUFS_IN_CHAIN(h, bn)
- {
+ FOR_BUFS_IN_CHAIN(h, bn) {
bp = bufnode_buf(bn);
if (bp->block == block)
return (TRUE);
@@ -466,27 +426,25 @@ buffered(block)
* 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;
+int
+ch_seek(off_t pos)
{
BLOCKNUM new_block;
- POSITION len;
+ off_t len;
if (thisfile == NULL)
return (0);
len = ch_length();
- if (pos < ch_zero() || (len != NULL_POSITION && pos > len))
+ if (pos < ch_zero() || (len != -1 && pos > len))
return (1);
new_block = pos / LBUFSIZE;
- if (!(ch_flags & CH_CANSEEK) && pos != ch_fpos && !buffered(new_block))
- {
+ if (!(ch_flags & CH_CANSEEK) && pos != ch_fpos &&
+ !buffered(new_block)) {
if (ch_fpos > pos)
return (1);
- while (ch_fpos < pos)
- {
+ while (ch_fpos < pos) {
if (ch_forw_get() == EOI)
return (1);
if (ABORT_SIGS())
@@ -505,10 +463,10 @@ ch_seek(pos)
/*
* Seek to the end of the file.
*/
- public int
-ch_end_seek()
+int
+ch_end_seek(void)
{
- POSITION len;
+ off_t len;
if (thisfile == NULL)
return (0);
@@ -517,7 +475,7 @@ ch_end_seek()
ch_fsize = filesize(ch_file);
len = ch_length();
- if (len != NULL_POSITION)
+ if (len != -1)
return (ch_seek(len));
/*
@@ -534,11 +492,11 @@ ch_end_seek()
* 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()
+int
+ch_beg_seek(void)
{
- register struct bufnode *bn;
- register struct bufnode *firstbn;
+ struct bufnode *bn;
+ struct bufnode *firstbn;
/*
* Try a plain ch_seek first.
@@ -553,8 +511,7 @@ ch_beg_seek()
firstbn = ch_bufhead;
if (firstbn == END_OF_CHAIN)
return (1);
- FOR_BUFS(bn)
- {
+ FOR_BUFS(bn) {
if (bufnode_buf(bn)->block < bufnode_buf(firstbn)->block)
firstbn = bn;
}
@@ -566,13 +523,13 @@ ch_beg_seek()
/*
* Return the length of the file, if known.
*/
- public POSITION
-ch_length()
+off_t
+ch_length(void)
{
if (thisfile == NULL)
- return (NULL_POSITION);
+ return (-1);
if (ignore_eoi)
- return (NULL_POSITION);
+ return (-1);
if (ch_flags & CH_NODATA)
return (0);
return (ch_fsize);
@@ -581,31 +538,30 @@ ch_length()
/*
* Return the current position in the file.
*/
- public POSITION
-ch_tell()
+off_t
+ch_tell(void)
{
if (thisfile == NULL)
- return (NULL_POSITION);
- return (ch_block * LBUFSIZE) + ch_offset;
+ return (-1);
+ return ((ch_block * LBUFSIZE) + ch_offset);
}
/*
* Get the current char and post-increment the read pointer.
*/
- public int
-ch_forw_get()
+int
+ch_forw_get(void)
{
- register int c;
+ int c;
if (thisfile == NULL)
return (EOI);
c = ch_get();
if (c == EOI)
return (EOI);
- if (ch_offset < LBUFSIZE-1)
+ if (ch_offset < LBUFSIZE-1) {
ch_offset++;
- else
- {
+ } else {
ch_block ++;
ch_offset = 0;
}
@@ -615,15 +571,14 @@ ch_forw_get()
/*
* Pre-decrement the read pointer and get the new current char.
*/
- public int
-ch_back_get()
+int
+ch_back_get(void)
{
if (thisfile == NULL)
return (EOI);
- if (ch_offset > 0)
+ if (ch_offset > 0) {
ch_offset --;
- else
- {
+ } else {
if (ch_block <= 0)
return (EOI);
if (!(ch_flags & CH_CANSEEK) && !buffered(ch_block-1))
@@ -638,14 +593,12 @@ ch_back_get()
* Set max amount of buffer space.
* bufspace is in units of 1024 bytes. -1 mean no limit.
*/
- public void
-ch_setbufspace(bufspace)
- int bufspace;
+void
+ch_setbufspace(int bufspace)
{
- if (bufspace < 0)
+ if (bufspace < 0) {
maxbufs = -1;
- else
- {
+ } else {
maxbufs = ((bufspace * 1024) + LBUFSIZE-1) / LBUFSIZE;
if (maxbufs < 1)
maxbufs = 1;
@@ -655,29 +608,27 @@ ch_setbufspace(bufspace)
/*
* Flush (discard) any saved file state, including buffer contents.
*/
- public void
-ch_flush()
+void
+ch_flush(void)
{
- register struct bufnode *bn;
+ struct bufnode *bn;
if (thisfile == NULL)
return;
- if (!(ch_flags & CH_CANSEEK))
- {
+ 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;
+ ch_fsize = -1;
return;
}
/*
* Initialize all the buffers.
*/
- FOR_BUFS(bn)
- {
+ FOR_BUFS(bn) {
bufnode_buf(bn)->block = -1;
}
@@ -696,19 +647,17 @@ ch_flush()
#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
+ * /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;
+ if (ch_fsize == 0) {
+ ch_fsize = -1;
ch_flags &= ~CH_CANSEEK;
}
#endif
- if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
- {
+ if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK) {
/*
* Warning only; even if the seek fails for some reason,
* there's a good chance we're at the beginning anyway.
@@ -722,17 +671,17 @@ ch_flush()
* Allocate a new buffer.
* The buffer is added to the tail of the buffer chain.
*/
- static int
-ch_addbuf()
+static int
+ch_addbuf(void)
{
- register struct buf *bp;
- register struct bufnode *bn;
+ struct buf *bp;
+ struct bufnode *bn;
/*
- * Allocate and initialize a new buffer and link it
+ * Allocate and initialize a new buffer and link it
* onto the tail of the buffer list.
*/
- bp = (struct buf *) calloc(1, sizeof(struct buf));
+ bp = calloc(1, sizeof (struct buf));
if (bp == NULL)
return (1);
ch_nbufs++;
@@ -747,13 +696,12 @@ ch_addbuf()
/*
*
*/
- static void
-init_hashtbl()
+static void
+init_hashtbl(void)
{
- register int h;
+ int h;
- for (h = 0; h < BUFHASH_SIZE; h++)
- {
+ for (h = 0; h < BUFHASH_SIZE; h++) {
thisfile->hashtbl[h].hnext = END_OF_HCHAIN(h);
thisfile->hashtbl[h].hprev = END_OF_HCHAIN(h);
}
@@ -762,13 +710,12 @@ init_hashtbl()
/*
* Delete all buffers for this file.
*/
- static void
-ch_delbufs()
+static void
+ch_delbufs(void)
{
- register struct bufnode *bn;
+ struct bufnode *bn;
- while (ch_bufhead != END_OF_CHAIN)
- {
+ while (ch_bufhead != END_OF_CHAIN) {
bn = ch_bufhead;
BUF_RM(bn);
free(bufnode_buf(bn));
@@ -780,21 +727,9 @@ ch_delbufs()
/*
* Is it possible to seek on a file descriptor?
*/
- public int
-seekable(f)
- int f;
+int
+seekable(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, SEEK_SET) != BAD_LSEEK);
}
@@ -802,8 +737,8 @@ seekable(f)
* Force EOF to be at the current read position.
* This is used after an ignore_eof read, during which the EOF may change.
*/
- public void
-ch_set_eof()
+void
+ch_set_eof(void)
{
ch_fsize = ch_fpos;
}
@@ -812,22 +747,18 @@ ch_set_eof()
/*
* Initialize file state for a new file.
*/
- public void
-ch_init(f, flags)
- int f;
- int flags;
+void
+ch_init(int f, int flags)
{
/*
* See if we already have a filestate for this file.
*/
- thisfile = (struct filestate *) get_filestate(curr_ifile);
- if (thisfile == NULL)
- {
+ thisfile = get_filestate(curr_ifile);
+ if (thisfile == NULL) {
/*
* Allocate and initialize a new filestate.
*/
- thisfile = (struct filestate *)
- calloc(1, sizeof(struct filestate));
+ thisfile = calloc(1, sizeof (struct filestate));
thisfile->buflist.next = thisfile->buflist.prev = END_OF_CHAIN;
thisfile->nbufs = 0;
thisfile->flags = 0;
@@ -835,7 +766,7 @@ ch_init(f, flags)
thisfile->block = 0;
thisfile->offset = 0;
thisfile->file = -1;
- thisfile->fsize = NULL_POSITION;
+ thisfile->fsize = -1;
ch_flags = flags;
init_hashtbl();
/*
@@ -853,24 +784,23 @@ ch_init(f, flags)
/*
* Close a filestate.
*/
- public void
-ch_close()
+void
+ch_close(void)
{
int keepstate = FALSE;
if (thisfile == NULL)
return;
- if (ch_flags & (CH_CANSEEK|CH_POPENED|CH_HELPFILE))
- {
+ 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
+ } else {
keepstate = TRUE;
- if (!(ch_flags & CH_KEEPOPEN))
- {
+ }
+ if (!(ch_flags & CH_KEEPOPEN)) {
/*
* We don't need to keep the file descriptor open
* (because we can re-open it.)
@@ -880,58 +810,26 @@ ch_close()
if (!(ch_flags & CH_POPENED))
close(ch_file);
ch_file = -1;
- } else
+ } else {
keepstate = TRUE;
- if (!keepstate)
- {
+ }
+ if (!keepstate) {
/*
* We don't even need to keep the filestate structure.
*/
free(thisfile);
thisfile = NULL;
- set_filestate(curr_ifile, (void *) NULL);
+ set_filestate(curr_ifile, NULL);
}
}
/*
* Return ch_flags for the current file.
*/
- public int
-ch_getflags()
+int
+ch_getflags(void)
{
if (thisfile == NULL)
return (0);
return (ch_flags);
}
-
-#if 0
- public void
-ch_dump(struct filestate *fs)
-{
- struct buf *bp;
- struct bufnode *bn;
- 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 (bn = fs->next; bn != &fs->buflist; bn = bn->next)
- {
- bp = bufnode_buf(bn);
- 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/usr.bin/less/charset.c b/usr.bin/less/charset.c
index 79104aaebe3..db4f3cf97bb 100644
--- a/usr.bin/less/charset.c
+++ b/usr.bin/less/charset.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Functions to define the character set
@@ -14,17 +17,14 @@
*/
#include "less.h"
-#if HAVE_LOCALE
#include <locale.h>
#include <ctype.h>
#include <langinfo.h>
-#endif
#include "charset.h"
-public int utf_mode = 0;
+int utf_mode = 0;
-#if !SMALL
/*
* Predefined character sets,
* selected by the LESSCHARSET environment variable.
@@ -34,27 +34,29 @@ struct charset {
int *p_flag;
char *desc;
} charsets[] = {
- { "ascii", NULL, "8bcccbcc18b95.b" },
- { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" },
- { "iso8859", NULL, "8bcccbcc18b95.33b." },
- { "latin3", NULL, "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
- { "arabic", NULL, "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
- { "greek", NULL, "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
- { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" },
- { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
- { "koi8-r", NULL, "8bcccbcc18b95.b." },
- { "KOI8-T", NULL, "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
- { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." },
- { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." },
- { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." },
- { "next", NULL, "8bcccbcc18b95.bb125.bb" },
- { "dos", NULL, "8bcccbcc12bc5b95.b." },
- { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." },
- { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
- { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
- { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
- { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
+ /* BEGIN CSTYLED */
+ { "ascii", NULL, "8bcccbcc18b95.b" },
+ { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" },
+ { "iso8859", NULL, "8bcccbcc18b95.33b." },
+ { "latin3", NULL, "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
+ { "arabic", NULL, "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
+ { "greek", NULL, "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
+ { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" },
+ { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
+ { "koi8-r", NULL, "8bcccbcc18b95.b." },
+ { "KOI8-T", NULL, "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
+ { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." },
+ { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." },
+ { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." },
+ { "next", NULL, "8bcccbcc18b95.bb125.bb" },
+ { "dos", NULL, "8bcccbcc12bc5b95.b." },
+ { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." },
+ { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
+ { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
+ { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
+ { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
{ NULL, NULL, NULL }
+ /* END CSTYLED */
};
/*
@@ -67,6 +69,8 @@ struct cs_alias {
{ "UTF-8", "utf-8" },
{ "ANSI_X3.4-1968", "ascii" },
{ "US-ASCII", "ascii" },
+ { "646", "ascii" },
+ { "C", "ascii" },
{ "latin1", "iso8859" },
{ "ISO-8859-1", "iso8859" },
{ "latin9", "iso8859" },
@@ -111,9 +115,9 @@ struct cs_alias {
#define IS_CONTROL_CHAR 02
static char chardef[256];
-static char *binfmt = NULL;
-static char *utfbinfmt = NULL;
-public int binattr = AT_STANDOUT;
+static const char *binfmt = NULL;
+static const char *utfbinfmt = NULL;
+int binattr = AT_STANDOUT;
/*
@@ -122,7 +126,7 @@ public int binattr = AT_STANDOUT;
* 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
+ * A decimal number followed by a letter is taken to be a
* repetition of the letter.
*
* Each letter is one of:
@@ -130,21 +134,18 @@ public int binattr = AT_STANDOUT;
* b binary character
* c control character
*/
- static void
-ichardef(s)
- char *s;
+static void
+ichardef(char *s)
{
- register char *cp;
- register int n;
- register char v;
+ char *cp;
+ int n;
+ char v;
n = 0;
v = 0;
cp = chardef;
- while (*s != '\0')
- {
- switch (*s++)
- {
+ while (*s != '\0') {
+ switch (*s++) {
case '.':
v = 0;
break;
@@ -166,10 +167,8 @@ ichardef(s)
/*NOTREACHED*/
}
- do
- {
- if (cp >= chardef + sizeof(chardef))
- {
+ do {
+ if (cp >= chardef + sizeof (chardef)) {
error("chardef longer than 256", NULL_PARG);
quit(QUIT_ERROR);
/*NOTREACHED*/
@@ -179,7 +178,7 @@ ichardef(s)
n = 0;
}
- while (cp < chardef + sizeof(chardef))
+ while (cp < chardef + sizeof (chardef))
*cp++ = v;
}
@@ -187,31 +186,25 @@ ichardef(s)
* Define a charset, given a charset name.
* The valid charset names are listed in the "charsets" array.
*/
- static int
-icharset(name, no_error)
- register char *name;
- int no_error;
+static int
+icharset(char *name, int no_error)
{
- register struct charset *p;
- register struct cs_alias *a;
+ struct charset *p;
+ struct cs_alias *a;
if (name == NULL || *name == '\0')
return (0);
/* First see if the name is an alias. */
- for (a = cs_aliases; a->name != NULL; a++)
- {
- if (strcmp(name, a->name) == 0)
- {
+ for (a = cs_aliases; a->name != NULL; a++) {
+ if (strcmp(name, a->name) == 0) {
name = a->oname;
break;
}
}
- for (p = charsets; p->name != NULL; p++)
- {
- if (strcmp(name, p->name) == 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;
@@ -226,17 +219,15 @@ icharset(name, no_error)
return (0);
}
-#if HAVE_LOCALE
/*
* Define a charset, given a locale name.
*/
- static void
-ilocale()
+static void
+ilocale(void)
{
- register int c;
+ int c;
- for (c = 0; c < (int) sizeof(chardef); c++)
- {
+ for (c = 0; c < sizeof (chardef); c++) {
if (isprint(c))
chardef[c] = 0;
else if (iscntrl(c))
@@ -245,51 +236,100 @@ ilocale()
chardef[c] = IS_BINARY_CHAR|IS_CONTROL_CHAR;
}
}
-#endif
-/*
- * Define the printing format for control (or binary utf) chars.
- */
- static void
-setbinfmt(s, fmtvarptr, default_fmt)
- char *s;
- char **fmtvarptr;
- char *default_fmt;
+static int
+checkfmt(const char *s)
{
- if (s && utf_mode)
- {
- /* It would be too hard to account for width otherwise. */
- char *t = s;
- while (*t)
- {
- if (*t < ' ' || *t > '~')
- {
- s = default_fmt;
- goto attr;
+ char c;
+ int seen = 0;
+
+ /* %[<flags>][<width>][.<prec>][<type>]<fmt> */
+
+ if (*s == '*') { /* skip leading attribute if there */
+ s++;
+ if (strchr("dksu", *s) == NULL) {
+ return (-1);
+ }
+ s++;
+ }
+
+ while ((c = *s++) != 0) {
+ if (!isascii(c) || !isprint(c)) {
+ return (-1);
+ }
+ if (c != '%') {
+ continue;
+ }
+ if (*s == '%') { /* % escaped with second % */
+ s++;
+ continue;
+ }
+ if (seen) {
+ return (-1); /* 2nd % format item! */
+ }
+ while (strchr(" '+-0#", *s) != NULL) { /* skip flags */
+ s++;
+ }
+ while (isdigit(*s)) { /* skip width */
+ s++;
+ }
+ if (*s == '.') { /* skip precision */
+ s++;
+ while (isdigit(*s)) {
+ s++;
}
- t++;
}
+ /* type width specifications, only "l", "h", and "hh" valid */
+ if (*s == 'l') {
+ s++;
+ } else if (*s == 'h') {
+ s++;
+ if (*s == 'h')
+ s++;
+ }
+
+ if (strchr("cCdiouxX", *s) == NULL) {
+ /* bad or evil format character (%s, %n, etc.) */
+ return (-1);
+ }
+
+ seen = 1;
}
- /* %n is evil */
- if (s == NULL || *s == '\0' ||
- (*s == '*' && (s[1] == '\0' || s[2] == '\0' || strchr(s + 2, 'n'))) ||
- (*s != '*' && strchr(s, 'n')))
+ return (0);
+}
+
+/*
+ * Define the printing format for control (or binary utf) chars.
+ */
+static void
+setbinfmt(char *e, const char **fmtvarptr, const char *default_fmt)
+{
+ const char *s;
+
+ if (((s = lgetenv(e)) == NULL) || (*s == 0)) {
s = default_fmt;
+ goto attr;
+ }
+
+ if (s != NULL && *s != 0) {
+ if (checkfmt(s) < 0) {
+ s = default_fmt;
+ goto attr;
+ }
+ }
/*
* Select the attributes if it starts with "*".
*/
- attr:
- if (*s == '*')
- {
- switch (s[1])
- {
- case 'd': binattr = AT_BOLD; break;
- case 'k': binattr = AT_BLINK; break;
- case 's': binattr = AT_STANDOUT; break;
+attr:
+ 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;
+ default: binattr = AT_NORMAL; break;
}
s += 2;
}
@@ -299,8 +339,8 @@ setbinfmt(s, fmtvarptr, default_fmt)
/*
*
*/
- static void
-set_charset()
+static void
+set_charset(void)
{
char *s;
@@ -315,85 +355,44 @@ set_charset()
* LESSCHARSET is not defined: try LESSCHARDEF.
*/
s = lgetenv("LESSCHARDEF");
- if (s != NULL && *s != '\0')
- {
+ if (s != NULL && *s != '\0') {
ichardef(s);
return;
}
-#if HAVE_LOCALE
-#ifdef CODESET
/*
* Try using the codeset name as the charset name.
*/
s = nl_langinfo(CODESET);
if (icharset(s, 1))
return;
-#endif
-#endif
-#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
- || strstr(s, "UTF8") != NULL || strstr(s, "utf8") != NULL)
- if (icharset("utf-8", 1))
- return;
- }
-#endif
-
-#if HAVE_LOCALE
/*
* Get character definitions from locale functions,
* rather than from predefined charset entry.
*/
ilocale();
-#if MSDOS_COMPILER
- /*
- * Default to "dos".
- */
- (void) icharset("dos", 1);
-#else
- /*
- * Default to "latin1".
- */
- (void) icharset("latin1", 1);
-#endif
-#endif
}
/*
* Initialize charset data structures.
*/
- public void
-init_charset()
+void
+init_charset(void)
{
- char *s;
-
-#if HAVE_LOCALE
setlocale(LC_ALL, "");
-#endif
set_charset();
- s = lgetenv("LESSBINFMT");
- setbinfmt(s, &binfmt, "*s<%02X>");
-
- s = lgetenv("LESSUTFBINFMT");
- setbinfmt(s, &utfbinfmt, "<U+%04lX>");
+ setbinfmt("LESSBINFMT", &binfmt, "*s<%02X>");
+ setbinfmt("LESSUTFBINFMT", &utfbinfmt, "<U+%04lX>");
}
/*
* Is a given character a "binary" character?
*/
- public int
-binary_char(c)
- LWCHAR c;
+int
+binary_char(LWCHAR c)
{
if (utf_mode)
return (is_ubin_char(c));
@@ -404,9 +403,8 @@ binary_char(c)
/*
* Is a given character a "control" character?
*/
- public int
-control_char(c)
- LWCHAR c;
+int
+control_char(LWCHAR c)
{
c &= 0377;
return (chardef[c] & IS_CONTROL_CHAR);
@@ -416,83 +414,62 @@ control_char(c)
* Return the printable form of a character.
* For example, in the "ascii" charset '\3' is printed as "^C".
*/
- public char *
-prchar(c)
- LWCHAR c;
+char *
+prchar(LWCHAR c)
{
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
static char buf[32];
c &= 0377;
if ((c < 128 || !utf_mode) && !control_char(c))
- SNPRINTF1(buf, sizeof(buf), "%c", (int) c);
+ (void) snprintf(buf, sizeof (buf), "%c", (int)c);
else if (c == ESC)
- strlcpy(buf, "ESC", sizeof(buf));
-#if IS_EBCDIC_HOST
- else if (!binary_char(c) && c < 64)
- SNPRINTF1(buf, sizeof(buf), "^%c",
- /*
- * This array roughly inverts CONTROL() #defined in less.h,
- * and should be kept in sync with CONTROL() and IBM-1047.
- */
- "@ABC.I.?...KLMNO"
- "PQRS.JH.XY.."
- "\\]^_"
- "......W[.....EFG"
- "..V....D....TU.Z"[c]);
-#else
- else if (c < 128 && !control_char(c ^ 0100))
- SNPRINTF1(buf, sizeof(buf), "^%c", (int) (c ^ 0100));
-#endif
+ (void) strlcpy(buf, "ESC", sizeof (buf));
+ else if (c < 128 && !control_char(c ^ 0100))
+ (void) snprintf(buf, sizeof (buf), "^%c", (int)(c ^ 0100));
else
- SNPRINTF1(buf, sizeof(buf), binfmt, c);
+ (void) snprintf(buf, sizeof (buf), binfmt, c);
return (buf);
}
/*
* Return the printable form of a UTF-8 character.
*/
- public char *
-prutfchar(ch)
- LWCHAR ch;
+char *
+prutfchar(LWCHAR ch)
{
static char buf[32];
- if (ch == ESC)
- strlcpy(buf, "ESC", sizeof(buf));
- else if (ch < 128 && control_char(ch))
- {
+ if (ch == ESC) {
+ (void) strlcpy(buf, "ESC", sizeof (buf));
+ } else if (ch < 128 && control_char(ch)) {
if (!control_char(ch ^ 0100))
- SNPRINTF1(buf, sizeof(buf), "^%c", ((char) ch) ^ 0100);
+ (void) snprintf(buf, sizeof (buf), "^%c",
+ ((char)ch) ^ 0100);
else
- SNPRINTF1(buf, sizeof(buf), binfmt, (char) ch);
- } else if (is_ubin_char(ch))
- SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch);
- else
- {
+ (void) snprintf(buf, sizeof (buf), binfmt, (char)ch);
+ } else if (is_ubin_char(ch)) {
+ (void) snprintf(buf, sizeof (buf), utfbinfmt, ch);
+ } else {
int len;
- if (ch >= 0x80000000)
- {
+ if (ch >= 0x80000000) {
len = 3;
ch = 0xFFFD;
- } else
- {
- len = (ch < 0x80) ? 1
- : (ch < 0x800) ? 2
- : (ch < 0x10000) ? 3
- : (ch < 0x200000) ? 4
- : (ch < 0x4000000) ? 5
- : 6;
+ } else {
+ len = (ch < 0x80) ? 1
+ : (ch < 0x800) ? 2
+ : (ch < 0x10000) ? 3
+ : (ch < 0x200000) ? 4
+ : (ch < 0x4000000) ? 5
+ : 6;
}
buf[len] = '\0';
- if (len == 1)
- *buf = (char) ch;
- else
- {
+ if (len == 1) {
+ *buf = (char)ch;
+ } else {
*buf = ((1 << len) - 1) << (8 - len);
- while (--len > 0)
- {
- buf[len] = (char) (0x80 | (ch & 0x3F));
+ while (--len > 0) {
+ buf[len] = (char)(0x80 | (ch & 0x3F));
ch >>= 6;
}
*buf |= ch;
@@ -504,32 +481,30 @@ prutfchar(ch)
/*
* Get the length of a UTF-8 character in bytes.
*/
- public int
-utf_len(ch)
- char ch;
+int
+utf_len(char ch)
{
if ((ch & 0x80) == 0)
- return 1;
+ return (1);
if ((ch & 0xE0) == 0xC0)
- return 2;
+ return (2);
if ((ch & 0xF0) == 0xE0)
- return 3;
+ return (3);
if ((ch & 0xF8) == 0xF0)
- return 4;
+ return (4);
if ((ch & 0xFC) == 0xF8)
- return 5;
+ return (5);
if ((ch & 0xFE) == 0xFC)
- return 6;
+ return (6);
/* Invalid UTF-8 encoding. */
- return 1;
+ return (1);
}
/*
* Is a UTF-8 character well-formed?
*/
- public int
-is_utf8_well_formed(s)
- unsigned char *s;
+int
+is_utf8_well_formed(const char *s)
{
int i;
int len;
@@ -537,15 +512,13 @@ is_utf8_well_formed(s)
if (IS_UTF8_INVALID(s[0]))
return (0);
- len = utf_len((char) s[0]);
+ len = utf_len((char)s[0]);
if (len == 1)
return (1);
- if (len == 2)
- {
- if (s[0] < 0xC2)
- return (0);
- } else
- {
+ if (len == 2) {
+ if ((unsigned char)(s[0]) < 0xC2)
+ return (0);
+ } else {
unsigned char mask;
mask = (~((1 << (8-len)) - 1)) & 0xFF;
if (s[0] == mask && (s[1] & mask) == 0x80)
@@ -561,139 +534,121 @@ is_utf8_well_formed(s)
/*
* Get the value of a UTF-8 character.
*/
- public LWCHAR
-get_wchar(p)
- char *p;
+LWCHAR
+get_wchar(const char *p)
{
- switch (utf_len(p[0]))
- {
+ switch (utf_len(p[0])) {
case 1:
default:
/* 0xxxxxxx */
return (LWCHAR)
- (p[0] & 0xFF);
+ (p[0] & 0xFF);
case 2:
/* 110xxxxx 10xxxxxx */
return (LWCHAR) (
- ((p[0] & 0x1F) << 6) |
- (p[1] & 0x3F));
+ ((p[0] & 0x1F) << 6) |
+ (p[1] & 0x3F));
case 3:
/* 1110xxxx 10xxxxxx 10xxxxxx */
return (LWCHAR) (
- ((p[0] & 0x0F) << 12) |
- ((p[1] & 0x3F) << 6) |
- (p[2] & 0x3F));
+ ((p[0] & 0x0F) << 12) |
+ ((p[1] & 0x3F) << 6) |
+ (p[2] & 0x3F));
case 4:
/* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
return (LWCHAR) (
- ((p[0] & 0x07) << 18) |
- ((p[1] & 0x3F) << 12) |
- ((p[2] & 0x3F) << 6) |
- (p[3] & 0x3F));
+ ((p[0] & 0x07) << 18) |
+ ((p[1] & 0x3F) << 12) |
+ ((p[2] & 0x3F) << 6) |
+ (p[3] & 0x3F));
case 5:
/* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
return (LWCHAR) (
- ((p[0] & 0x03) << 24) |
- ((p[1] & 0x3F) << 18) |
- ((p[2] & 0x3F) << 12) |
- ((p[3] & 0x3F) << 6) |
- (p[4] & 0x3F));
+ ((p[0] & 0x03) << 24) |
+ ((p[1] & 0x3F) << 18) |
+ ((p[2] & 0x3F) << 12) |
+ ((p[3] & 0x3F) << 6) |
+ (p[4] & 0x3F));
case 6:
/* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
return (LWCHAR) (
- ((p[0] & 0x01) << 30) |
- ((p[1] & 0x3F) << 24) |
- ((p[2] & 0x3F) << 18) |
- ((p[3] & 0x3F) << 12) |
- ((p[4] & 0x3F) << 6) |
- (p[5] & 0x3F));
+ ((p[0] & 0x01) << 30) |
+ ((p[1] & 0x3F) << 24) |
+ ((p[2] & 0x3F) << 18) |
+ ((p[3] & 0x3F) << 12) |
+ ((p[4] & 0x3F) << 6) |
+ (p[5] & 0x3F));
}
}
/*
* Store a character into a UTF-8 string.
*/
- public void
-put_wchar(pp, ch)
- char **pp;
- LWCHAR ch;
+void
+put_wchar(char **pp, LWCHAR ch)
{
- if (!utf_mode || ch < 0x80)
- {
+ if (!utf_mode || ch < 0x80) {
/* 0xxxxxxx */
- *(*pp)++ = (char) ch;
- } else if (ch < 0x800)
- {
+ *(*pp)++ = (char)ch;
+ } else if (ch < 0x800) {
/* 110xxxxx 10xxxxxx */
- *(*pp)++ = (char) (0xC0 | ((ch >> 6) & 0x1F));
- *(*pp)++ = (char) (0x80 | (ch & 0x3F));
- } else if (ch < 0x10000)
- {
+ *(*pp)++ = (char)(0xC0 | ((ch >> 6) & 0x1F));
+ *(*pp)++ = (char)(0x80 | (ch & 0x3F));
+ } else if (ch < 0x10000) {
/* 1110xxxx 10xxxxxx 10xxxxxx */
- *(*pp)++ = (char) (0xE0 | ((ch >> 12) & 0x0F));
- *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
- *(*pp)++ = (char) (0x80 | (ch & 0x3F));
- } else if (ch < 0x200000)
- {
+ *(*pp)++ = (char)(0xE0 | ((ch >> 12) & 0x0F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 6) & 0x3F));
+ *(*pp)++ = (char)(0x80 | (ch & 0x3F));
+ } else if (ch < 0x200000) {
/* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
- *(*pp)++ = (char) (0xF0 | ((ch >> 18) & 0x07));
- *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
- *(*pp)++ = (char) (0x80 | (ch & 0x3F));
- } else if (ch < 0x4000000)
- {
+ *(*pp)++ = (char)(0xF0 | ((ch >> 18) & 0x07));
+ *(*pp)++ = (char)(0x80 | ((ch >> 12) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 6) & 0x3F));
+ *(*pp)++ = (char)(0x80 | (ch & 0x3F));
+ } else if (ch < 0x4000000) {
/* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- *(*pp)++ = (char) (0xF0 | ((ch >> 24) & 0x03));
- *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
- *(*pp)++ = (char) (0x80 | (ch & 0x3F));
- } else
- {
+ *(*pp)++ = (char)(0xF0 | ((ch >> 24) & 0x03));
+ *(*pp)++ = (char)(0x80 | ((ch >> 18) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 12) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 6) & 0x3F));
+ *(*pp)++ = (char)(0x80 | (ch & 0x3F));
+ } else {
/* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
- *(*pp)++ = (char) (0xF0 | ((ch >> 30) & 0x01));
- *(*pp)++ = (char) (0x80 | ((ch >> 24) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
- *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
- *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+ *(*pp)++ = (char)(0xF0 | ((ch >> 30) & 0x01));
+ *(*pp)++ = (char)(0x80 | ((ch >> 24) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 18) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 12) & 0x3F));
+ *(*pp)++ = (char)(0x80 | ((ch >> 6) & 0x3F));
+ *(*pp)++ = (char)(0x80 | (ch & 0x3F));
}
}
/*
* Step forward or backward one character in a string.
*/
- public LWCHAR
-step_char(pp, dir, limit)
- char **pp;
- signed int dir;
- char *limit;
+LWCHAR
+step_char(char **pp, int dir, char *limit)
{
LWCHAR ch;
int len;
char *p = *pp;
- if (!utf_mode)
- {
+ if (!utf_mode) {
/* It's easy if chars are one byte. */
if (dir > 0)
ch = (LWCHAR) ((p < limit) ? *p++ : 0);
else
ch = (LWCHAR) ((p > limit) ? *--p : 0);
- } else if (dir > 0)
- {
+ } else if (dir > 0) {
len = utf_len(*p);
- if (p + len > limit)
- {
+ if (p + len > limit) {
ch = 0;
p = limit;
- } else
- {
+ } else {
ch = get_wchar(p);
p += len;
}
- } else
- {
+ } else {
while (p > limit && IS_UTF8_TRAIL(p[-1]))
p--;
if (p > limit)
@@ -702,7 +657,7 @@ step_char(pp, dir, limit)
ch = 0;
}
*pp = p;
- return ch;
+ return (ch);
}
/*
@@ -796,7 +751,7 @@ static struct wchar_range comp_table[] = {
* Special pairs, not ranges.
*/
static struct wchar_range comb_table[] = {
- {0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
+ {0x0644, 0x0622}, {0x0644, 0x0623}, {0x0644, 0x0625}, {0x0644, 0x0627},
};
/*
@@ -813,10 +768,10 @@ static struct wchar_range comb_table[] = {
* dated 2005-11-30T00:58:48Z
*/
static struct wchar_range ubin_table[] = {
- { 0x0000, 0x0007} /* Cc */,
- { 0x000B, 0x000C} /* Cc */,
- { 0x000E, 0x001A} /* Cc */,
- { 0x001C, 0x001F} /* Cc */,
+ { 0x0000, 0x0007} /* Cc */,
+ { 0x000B, 0x000C} /* Cc */,
+ { 0x000E, 0x001A} /* Cc */,
+ { 0x001C, 0x001F} /* Cc */,
{ 0x007F, 0x009F} /* Cc */,
#if 0
{ 0x00AD, 0x00AD} /* Cf */,
@@ -1066,9 +1021,9 @@ static struct wchar_range ubin_table[] = {
{ 0xE0080, 0xE00FF} /* Cn */, { 0xE01F0, 0xEFFFF} /* Cn */,
{ 0xF0000, 0xFFFFD} /* Co */,
{ 0xFFFFE, 0xFFFFF} /* Cn */,
- {0x100000,0x10FFFD} /* Co */,
- {0x10FFFE,0x10FFFF} /* Cn */,
- {0x110000,0x7FFFFFFF} /* ISO 10646?? */
+ { 0x100000, 0x10FFFD} /* Co */,
+ { 0x10FFFE, 0x10FFFF} /* Cn */,
+ { 0x110000, 0x7FFFFFFF} /* ISO 10646?? */
};
/*
@@ -1092,62 +1047,58 @@ static struct wchar_range wide_table[] = {
{ 0x20000, 0x2FFFD} /* W */, { 0x30000, 0x3FFFD} /* W */,
};
- static int
-is_in_table(ch, table, tsize)
- LWCHAR ch;
- struct wchar_range table[];
- int tsize;
+static int
+is_in_table(LWCHAR ch, struct wchar_range table[], int tsize)
{
int hi;
int lo;
/* Binary search in the table. */
if (ch < table[0].first)
- return 0;
+ return (0);
lo = 0;
hi = tsize - 1;
- while (lo <= hi)
- {
+ while (lo <= hi) {
int mid = (lo + hi) / 2;
if (ch > table[mid].last)
lo = mid + 1;
else if (ch < table[mid].first)
hi = mid - 1;
else
- return 1;
+ return (1);
}
- return 0;
+ return (0);
}
/*
* Is a character a UTF-8 composing character?
* If a composing character follows any char, the two combine into one glyph.
*/
- public int
-is_composing_char(ch)
- LWCHAR ch;
+int
+is_composing_char(LWCHAR ch)
{
- return is_in_table(ch, comp_table, (sizeof(comp_table) / sizeof(*comp_table)));
+ return (is_in_table(ch, comp_table,
+ (sizeof (comp_table) / sizeof (*comp_table))));
}
/*
* Should this UTF-8 character be treated as binary?
*/
- public int
-is_ubin_char(ch)
- LWCHAR ch;
+int
+is_ubin_char(LWCHAR ch)
{
- return is_in_table(ch, ubin_table, (sizeof(ubin_table) / sizeof(*ubin_table)));
+ return (is_in_table(ch, ubin_table,
+ (sizeof (ubin_table) / sizeof (*ubin_table))));
}
/*
* Is this a double width UTF-8 character?
*/
- public int
-is_wide_char(ch)
- LWCHAR ch;
+int
+is_wide_char(LWCHAR ch)
{
- return is_in_table(ch, wide_table, (sizeof(wide_table) / sizeof(*wide_table)));
+ return (is_in_table(ch, wide_table,
+ (sizeof (wide_table) / sizeof (*wide_table))));
}
/*
@@ -1155,95 +1106,15 @@ is_wide_char(ch)
* A combining char acts like an ordinary char, but if it follows
* a specific char (not any char), the two combine into one glyph.
*/
- public int
-is_combining_char(ch1, ch2)
- LWCHAR ch1;
- LWCHAR ch2;
+int
+is_combining_char(LWCHAR ch1, LWCHAR ch2)
{
/* The table is small; use linear search. */
int i;
- for (i = 0; i < sizeof(comb_table)/sizeof(*comb_table); i++)
- {
+ for (i = 0; i < sizeof (comb_table) / sizeof (*comb_table); i++) {
if (ch1 == comb_table[i].first &&
ch2 == comb_table[i].last)
- return 1;
+ return (1);
}
- return 0;
-}
-
-#else /* !SMALL */
-
-public int binattr = AT_STANDOUT;
-
- public void
-init_charset()
-{
- return;
-}
-
-/*
- * Is a given character a "binary" character?
- */
- public int
-binary_char(c)
- LWCHAR c;
-{
- return (!isprint(c) && !isspace(c));
-}
-
-/*
- * Is a given character a "control" character?
- */
- public int
-control_char(c)
- LWCHAR c;
-{
- return (iscntrl(c));
-}
-
-/*
- * Return the printable form of a character.
- * For example, in the "ascii" charset '\3' is printed as "^C".
- */
- public char *
-prchar(c)
- LWCHAR c;
-{
- static char buf[8];
-
- c &= 0377;
- if (!iscntrl(c))
- snprintf(buf, sizeof(buf), "%c", c);
- else if (c == ESC)
- strlcpy(buf, "ESC", sizeof(buf));
- else if (c < 128 && !iscntrl(c ^ 0100))
- snprintf(buf, sizeof(buf), "^%c", c ^ 0100);
- else
- snprintf(buf, sizeof(buf), "*s<%X>", c);
- return (buf);
-}
-
-/*
- * Step forward or backward one character in a string.
- */
- public LWCHAR
-step_char(pp, dir, limit)
- char **pp;
- signed int dir;
- char *limit;
-{
- LWCHAR ch;
- int len;
- char *p = *pp;
-
- /* It's easy if chars are one byte. */
- if (dir > 0)
- ch = (LWCHAR) ((p < limit) ? *p++ : 0);
- else
- ch = (LWCHAR) ((p > limit) ? *--p : 0);
-
- *pp = p;
- return ch;
+ return (0);
}
-
-#endif /* !SMALL */
diff --git a/usr.bin/less/charset.h b/usr.bin/less/charset.h
index 8ccf748df09..83bdba63468 100644
--- a/usr.bin/less/charset.h
+++ b/usr.bin/less/charset.h
@@ -1,19 +1,21 @@
/*
- * Copyright (C) 2005-2011 Mark Nudelman
+ * Copyright (C) 1984-2012 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.
+ * For more information, see the README file.
*/
-
-#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
-#define IS_UTF8_TRAIL(c) (((c) & 0xC0) == 0x80)
-#define IS_UTF8_LEAD2(c) (((c) & 0xE0) == 0xC0)
-#define IS_UTF8_LEAD3(c) (((c) & 0xF0) == 0xE0)
-#define IS_UTF8_LEAD4(c) (((c) & 0xF8) == 0xF0)
-#define IS_UTF8_LEAD5(c) (((c) & 0xFC) == 0xF8)
-#define IS_UTF8_LEAD6(c) (((c) & 0xFE) == 0xFC)
-#define IS_UTF8_INVALID(c) (((c) & 0xFE) == 0xFE)
-#define IS_UTF8_LEAD(c) (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
+#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
+#define IS_UTF8_TRAIL(c) (((c) & 0xC0) == 0x80)
+#define IS_UTF8_LEAD2(c) (((c) & 0xE0) == 0xC0)
+#define IS_UTF8_LEAD3(c) (((c) & 0xF0) == 0xE0)
+#define IS_UTF8_LEAD4(c) (((c) & 0xF8) == 0xF0)
+#define IS_UTF8_LEAD5(c) (((c) & 0xFC) == 0xF8)
+#define IS_UTF8_LEAD6(c) (((c) & 0xFE) == 0xFC)
+#define IS_UTF8_INVALID(c) (((c) & 0xFE) == 0xFE)
+#define IS_UTF8_LEAD(c) (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
diff --git a/usr.bin/less/cmd.h b/usr.bin/less/cmd.h
index 9a721602db4..947a04e6029 100644
--- a/usr.bin/less/cmd.h
+++ b/usr.bin/less/cmd.h
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
#define MAX_USERCMD 1000
#define MAX_CMDLEN 16
@@ -66,6 +69,7 @@
#define A_PREV_TAG 54
#define A_FILTER 55
#define A_F_UNTIL_HILITE 56
+#define A_F_SKIP 57
#define A_INVALID 100
#define A_NOACTION 101
@@ -73,7 +77,7 @@
#define A_END_LIST 103
#define A_SPECIAL_KEY 104
-#define A_SKIP 127
+#define A_SKIP 127
#define A_EXTRA 0200
@@ -113,21 +117,21 @@
#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
+#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/usr.bin/less/cmdbuf.c b/usr.bin/less/cmdbuf.c
index 59d18968195..679340079d7 100644
--- a/usr.bin/less/cmdbuf.c
+++ b/usr.bin/less/cmdbuf.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Functions which manipulate the command buffer.
@@ -16,9 +19,7 @@
#include "less.h"
#include "cmd.h"
#include "charset.h"
-#if HAVE_STAT
#include <sys/stat.h>
-#endif
extern int sc_width;
extern int utf_mode;
@@ -31,8 +32,7 @@ static int cmd_offset; /* Index into cmdbuf of first displayed char */
static int literal; /* Next input char should not be interpreted */
static int updown_match = -1; /* Prefix length in up/down movement */
-#if TAB_COMPLETE_FILENAME
-static int cmd_complete();
+static int cmd_complete(int);
/*
* These variables are statics used by cmd_complete.
*/
@@ -42,22 +42,17 @@ 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
+static int cmd_left(void);
+static int cmd_right(void);
-#if CMD_HISTORY
+char openquote = '"';
+char closequote = '"';
/* History file */
-#define HISTFILE_FIRST_LINE ".less-history-file:"
-#define HISTFILE_SEARCH_SECTION ".search"
-#define HISTFILE_SHELL_SECTION ".shell"
+#define HISTFILE_FIRST_LINE ".less-history-file:"
+#define HISTFILE_SEARCH_SECTION ".search"
+#define HISTFILE_SHELL_SECTION ".shell"
/*
* A mlist structure represents a command history.
@@ -74,30 +69,17 @@ struct mlist
/*
* These are the various command histories that exist.
*/
-struct mlist mlist_search =
+struct mlist mlist_search =
{ &mlist_search, &mlist_search, &mlist_search, NULL, 0 };
-public void * constant ml_search = (void *) &mlist_search;
+void * const ml_search = (void *) &mlist_search;
-struct mlist mlist_examine =
+struct mlist mlist_examine =
{ &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 };
-public void * constant ml_examine = (void *) &mlist_examine;
+void * const ml_examine = (void *) &mlist_examine;
-#if SHELL_ESCAPE || PIPEC
-struct mlist mlist_shell =
+struct mlist mlist_shell =
{ &mlist_shell, &mlist_shell, &mlist_shell, NULL, 0 };
-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 */
+void * const ml_shell = (void *) &mlist_shell;
/*
* History for the current command.
@@ -113,8 +95,8 @@ static int cmd_mbc_buf_index;
/*
* Reset command buffer (to empty).
*/
- public void
-cmd_reset()
+void
+cmd_reset(void)
{
cp = cmdbuf;
*cp = '\0';
@@ -128,8 +110,8 @@ cmd_reset()
/*
* Clear command line.
*/
- public void
-clear_cmd()
+void
+clear_cmd(void)
{
cmd_col = prompt_col = 0;
cmd_mbc_buf_len = 0;
@@ -139,33 +121,26 @@ clear_cmd()
/*
* Display a string, usually as a prompt for input into the command buffer.
*/
- public void
-cmd_putstr(s)
- char *s;
+void
+cmd_putstr(char *s)
{
LWCHAR prev_ch = 0;
LWCHAR ch;
char *endline = s + strlen(s);
- while (*s != '\0')
- {
+ while (*s != '\0') {
char *ns = s;
ch = step_char(&ns, +1, endline);
while (s < ns)
putchr(*s++);
- if (!utf_mode)
- {
+ if (!utf_mode) {
cmd_col++;
prompt_col++;
- }
-#if !SMALL
- else if (!is_composing_char(ch) &&
- !is_combining_char(prev_ch, ch))
- {
+ } else if (!is_composing_char(ch) &&
+ !is_combining_char(prev_ch, ch)) {
int width = is_wide_char(ch) ? 2 : 1;
cmd_col += width;
prompt_col += width;
}
-#endif /* !SMALL */
prev_ch = ch;
}
}
@@ -173,15 +148,14 @@ cmd_putstr(s)
/*
* How many characters are in the command buffer?
*/
- public int
-len_cmdbuf()
+int
+len_cmdbuf(void)
{
char *s = cmdbuf;
char *endline = s + strlen(s);
int len = 0;
- while (*s != '\0')
- {
+ while (*s != '\0') {
step_char(&s, +1, endline);
len++;
}
@@ -191,69 +165,51 @@ len_cmdbuf()
/*
* Common part of cmd_step_right() and cmd_step_left().
*/
- static char *
-cmd_step_common(p, ch, len, pwidth, bswidth)
- char *p;
- LWCHAR ch;
- int len;
- int *pwidth;
- int *bswidth;
+static char *
+cmd_step_common(char *p, LWCHAR ch, int len, int *pwidth, int *bswidth)
{
char *pr;
- if (len == 1)
- {
- pr = prchar((int) ch);
- if (pwidth != NULL || bswidth != NULL)
- {
+ if (len == 1) {
+ pr = prchar((int)ch);
+ if (pwidth != NULL || bswidth != NULL) {
int len = strlen(pr);
if (pwidth != NULL)
*pwidth = len;
if (bswidth != NULL)
*bswidth = len;
}
- }
-#if !SMALL
- else
- {
+ } else {
pr = prutfchar(ch);
- if (pwidth != NULL || bswidth != NULL)
- {
- if (is_composing_char(ch))
- {
+ if (pwidth != NULL || bswidth != NULL) {
+ if (is_composing_char(ch)) {
if (pwidth != NULL)
*pwidth = 0;
if (bswidth != NULL)
*bswidth = 0;
- } else if (is_ubin_char(ch))
- {
+ } else if (is_ubin_char(ch)) {
int len = strlen(pr);
if (pwidth != NULL)
*pwidth = len;
if (bswidth != NULL)
*bswidth = len;
- } else
- {
+ } else {
LWCHAR prev_ch = step_char(&p, -1, cmdbuf);
- if (is_combining_char(prev_ch, ch))
- {
+ if (is_combining_char(prev_ch, ch)) {
if (pwidth != NULL)
*pwidth = 0;
if (bswidth != NULL)
*bswidth = 0;
- } else
- {
+ } else {
if (pwidth != NULL)
*pwidth = is_wide_char(ch)
- ? 2
- : 1;
+ ? 2 : 1;
if (bswidth != NULL)
*bswidth = 1;
}
}
}
}
-#endif /* !SMALL */
return (pr);
}
@@ -261,47 +217,39 @@ cmd_step_common(p, ch, len, pwidth, bswidth)
/*
* Step a pointer one character right in the command buffer.
*/
- static char *
-cmd_step_right(pp, pwidth, bswidth)
- char **pp;
- int *pwidth;
- int *bswidth;
+static char *
+cmd_step_right(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, +1, p + strlen(p));
- return cmd_step_common(p, ch, *pp - p, pwidth, bswidth);
+ return (cmd_step_common(p, ch, *pp - p, pwidth, bswidth));
}
/*
* Step a pointer one character left in the command buffer.
*/
- static char *
-cmd_step_left(pp, pwidth, bswidth)
- char **pp;
- int *pwidth;
- int *bswidth;
+static char *
+cmd_step_left(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, -1, cmdbuf);
- return cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth);
+ return (cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth));
}
/*
* 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;
+static void
+cmd_repaint(char *old_cp)
{
/*
* Repaint the line from the current position.
*/
clear_eol();
- while (*cp != '\0')
- {
+ while (*cp != '\0') {
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
@@ -311,8 +259,7 @@ cmd_repaint(old_cp)
putstr(pr);
cmd_col += width;
}
- while (*cp != '\0')
- {
+ while (*cp != '\0') {
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
@@ -333,11 +280,10 @@ cmd_repaint(old_cp)
* Put the cursor at "home" (just after the prompt),
* and set cp to the corresponding char in cmdbuf.
*/
- static void
-cmd_home()
+static void
+cmd_home(void)
{
- while (cmd_col > prompt_col)
- {
+ while (cmd_col > prompt_col) {
int width, bswidth;
cmd_step_left(&cp, &width, &bswidth);
@@ -352,8 +298,8 @@ cmd_home()
/*
* Shift the cmdbuf display left a half-screen.
*/
- static void
-cmd_lshift()
+static void
+cmd_lshift(void)
{
char *s;
char *save_cp;
@@ -365,14 +311,12 @@ cmd_lshift()
*/
s = cmdbuf + cmd_offset;
cols = 0;
- while (cols < (sc_width - prompt_col) / 2 && *s != '\0')
- {
+ while (cols < (sc_width - prompt_col) / 2 && *s != '\0') {
int width;
cmd_step_right(&s, &width, NULL);
cols += width;
}
- while (*s != '\0')
- {
+ while (*s != '\0') {
int width;
char *ns = s;
cmd_step_right(&ns, &width, NULL);
@@ -390,8 +334,8 @@ cmd_lshift()
/*
* Shift the cmdbuf display right a half-screen.
*/
- static void
-cmd_rshift()
+static void
+cmd_rshift(void)
{
char *s;
char *save_cp;
@@ -404,8 +348,7 @@ cmd_rshift()
*/
s = cmdbuf + cmd_offset;
cols = 0;
- while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf)
- {
+ while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf) {
int width;
cmd_step_left(&s, &width, NULL);
cols += width;
@@ -420,15 +363,14 @@ cmd_rshift()
/*
* Move cursor right one character.
*/
- static int
-cmd_right()
+static int
+cmd_right(void)
{
char *pr;
char *ncp;
int width;
-
- if (*cp == '\0')
- {
+
+ if (*cp == '\0') {
/* Already at the end of the line. */
return (CC_OK);
}
@@ -441,8 +383,7 @@ cmd_right()
cp = ncp;
cmd_col += width;
putstr(pr);
- while (*cp != '\0')
- {
+ while (*cp != '\0') {
pr = cmd_step_right(&ncp, &width, NULL);
if (width > 0)
break;
@@ -455,20 +396,18 @@ cmd_right()
/*
* Move cursor left one character.
*/
- static int
-cmd_left()
+static int
+cmd_left(void)
{
char *ncp;
int width, bswidth;
-
- if (cp <= cmdbuf)
- {
+
+ if (cp <= cmdbuf) {
/* Already at the beginning of the line */
return (CC_OK);
}
ncp = cp;
- while (ncp > cmdbuf)
- {
+ while (ncp > cmdbuf) {
cmd_step_left(&ncp, &width, &bswidth);
if (width > 0)
break;
@@ -485,20 +424,17 @@ cmd_left()
/*
* Insert a char into the command buffer, at the current position.
*/
- static int
-cmd_ichar(cs, clen)
- char *cs;
- int clen;
+static int
+cmd_ichar(char *cs, int clen)
{
char *s;
-
- if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1)
- {
+
+ if (strlen(cmdbuf) + clen >= sizeof (cmdbuf)-1) {
/* No room in the command buffer for another char. */
- bell();
+ ring_bell();
return (CC_ERROR);
}
-
+
/*
* Make room for the new character (shift the tail of the buffer right).
*/
@@ -522,14 +458,13 @@ cmd_ichar(cs, clen)
* Backspace in the command buffer.
* Delete the char to the left of the cursor.
*/
- static int
-cmd_erase()
+static int
+cmd_erase(void)
{
- register char *s;
+ char *s;
int clen;
- if (cp == cmdbuf)
- {
+ if (cp == cmdbuf) {
/*
* Backspace past beginning of the buffer:
* this usually means abort the command.
@@ -546,8 +481,7 @@ cmd_erase()
/*
* Remove the char from the buffer (shift the buffer left).
*/
- for (s = cp; ; s++)
- {
+ for (s = cp; ; s++) {
s[0] = s[clen];
if (s[0] == '\0')
break;
@@ -558,7 +492,7 @@ cmd_erase()
*/
updown_match = -1;
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.
@@ -571,11 +505,10 @@ cmd_erase()
/*
* Delete the char under the cursor.
*/
- static int
-cmd_delete()
+static int
+cmd_delete(void)
{
- if (*cp == '\0')
- {
+ if (*cp == '\0') {
/* At end of string; there is no char under the cursor. */
return (CC_OK);
}
@@ -590,19 +523,17 @@ cmd_delete()
/*
* Delete the "word" to the left of the cursor.
*/
- static int
-cmd_werase()
+static int
+cmd_werase(void)
{
- if (cp > cmdbuf && cp[-1] == ' ')
- {
+ 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
- {
+ } else {
/*
* If the char left of cursor is not a space,
* erase all the nonspaces left of cursor (the whole "word").
@@ -616,19 +547,17 @@ cmd_werase()
/*
* Delete the "word" under the cursor.
*/
- static int
-cmd_wdelete()
+static int
+cmd_wdelete(void)
{
- if (*cp == ' ')
- {
+ 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
- {
+ } else {
/*
* If the char under the cursor is not a space,
* delete it and all nonspaces right of cursor (the whole word).
@@ -642,11 +571,10 @@ cmd_wdelete()
/*
* Delete all chars in the command buffer.
*/
- static int
-cmd_kill()
+static int
+cmd_kill(void)
{
- if (cmdbuf[0] == '\0')
- {
+ if (cmdbuf[0] == '\0') {
/* Buffer is already empty; abort the current command. */
return (CC_QUIT);
}
@@ -668,63 +596,52 @@ cmd_kill()
/*
* Select an mlist structure to be the current command history.
*/
- public void
-set_mlist(mlist, cmdflags)
- void *mlist;
- int cmdflags;
+void
+set_mlist(void *mlist, int cmdflags)
{
-#if CMD_HISTORY
- curr_mlist = (struct mlist *) mlist;
+ curr_mlist = (struct mlist *)mlist;
curr_cmdflags = cmdflags;
/* Make sure the next up-arrow moves to the last string in the mlist. */
if (curr_mlist != NULL)
curr_mlist->curr_mp = curr_mlist;
-#endif
}
-#if CMD_HISTORY
/*
* Move up or down in the currently selected command history list.
* Only consider entries whose first updown_match chars are equal to
* cmdbuf's corresponding chars.
*/
- static int
-cmd_updown(action)
- int action;
+static int
+cmd_updown(int action)
{
char *s;
struct mlist *ml;
-
- if (curr_mlist == NULL)
- {
+
+ if (curr_mlist == NULL) {
/*
* The current command has no history list.
*/
- bell();
+ ring_bell();
return (CC_OK);
}
- if (updown_match < 0)
- {
+ if (updown_match < 0) {
updown_match = cp - cmdbuf;
}
/*
* Find the next history entry which matches.
*/
- for (ml = curr_mlist->curr_mp;;)
- {
+ for (ml = curr_mlist->curr_mp; ; ) {
ml = (action == EC_UP) ? ml->prev : ml->next;
- if (ml == curr_mlist)
- {
+ if (ml == curr_mlist) {
/*
* We reached the end (or beginning) of the list.
*/
break;
}
- if (strncmp(cmdbuf, ml->string, updown_match) == 0)
- {
+ if (strncmp(cmdbuf, ml->string, updown_match) == 0) {
/*
* This entry matches; stop here.
* Copy the entry into cmdbuf and echo it on the screen.
@@ -735,8 +652,8 @@ cmd_updown(action)
s = "";
cmd_home();
clear_eol();
- strlcpy(cmdbuf, s, sizeof(cmdbuf));
- for (cp = cmdbuf; *cp != '\0'; )
+ strlcpy(cmdbuf, s, sizeof (cmdbuf));
+ for (cp = cmdbuf; *cp != '\0'; )
cmd_right();
return (CC_OK);
}
@@ -744,22 +661,18 @@ cmd_updown(action)
/*
* We didn't find a history entry that matches.
*/
- bell();
+ ring_bell();
return (CC_OK);
}
-#endif
/*
* Add a string to a history list.
*/
- public void
-cmd_addhist(mlist, cmd)
- struct mlist *mlist;
- char *cmd;
+void
+cmd_addhist(struct mlist *mlist, const char *cmd)
{
-#if CMD_HISTORY
struct mlist *ml;
-
+
/*
* Don't save a trivial command.
*/
@@ -771,13 +684,12 @@ cmd_addhist(mlist, cmd)
* last command in the history.
*/
ml = mlist->prev;
- if (ml == mlist || strcmp(ml->string, cmd) != 0)
- {
+ if (ml == mlist || strcmp(ml->string, cmd) != 0) {
/*
* 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 = ecalloc(1, sizeof (struct mlist));
ml->string = save(cmd);
ml->next = mlist;
ml->prev = mlist->prev;
@@ -789,17 +701,15 @@ cmd_addhist(mlist, cmd)
* 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()
+void
+cmd_accept(void)
{
-#if CMD_HISTORY
/*
* Nothing to do if there is no currently selected history list.
*/
@@ -807,7 +717,6 @@ cmd_accept()
return;
cmd_addhist(curr_mlist, cmdbuf);
curr_mlist->modified = 1;
-#endif
}
/*
@@ -818,42 +727,32 @@ cmd_accept()
* CC_OK Line edit function done.
* CC_QUIT The char requests the current command to be aborted.
*/
- static int
-cmd_edit(c)
- int c;
+static int
+cmd_edit(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)
- {
+ switch (action) {
case EC_RIGHT:
not_in_completion();
return (cmd_right());
@@ -910,18 +809,14 @@ cmd_edit(c)
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:
@@ -930,26 +825,22 @@ cmd_edit(c)
}
}
-#if TAB_COMPLETE_FILENAME
/*
* Insert a string into the command buffer, at the current position.
*/
- static int
-cmd_istr(str)
- char *str;
+static int
+cmd_istr(char *str)
{
char *s;
int action;
char *endline = str + strlen(str);
-
- for (s = str; *s != '\0'; )
- {
+
+ for (s = str; *s != '\0'; ) {
char *os = s;
step_char(&s, +1, endline);
action = cmd_ichar(os, s - os);
- if (action != CC_OK)
- {
- bell();
+ if (action != CC_OK) {
+ ring_bell();
return (action);
}
}
@@ -962,52 +853,33 @@ cmd_istr(str)
* Return pointer to the beginning of the word and put the
* cursor at the end of the word.
*/
- static char *
-delimit_word()
+static char *
+delimit_word(void)
{
char *word;
-#if SPACES_IN_FILENAMES
char *p;
int delim_quoted = 0;
int meta_quoted = 0;
char *esc = get_meta_escape();
int esclen = strlen(esc);
-#endif
-
+
/*
* Move cursor to end of word.
*/
- if (*cp != ' ' && *cp != '\0')
- {
+ 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.
- */
- ;
-#if 0
- } else
- {
- /*
- * Cursor is on a space and char to the left is a space.
- * Huh? There's no word here.
- */
- return (NULL);
-#endif
}
+
/*
* Find the beginning of the word which the cursor is in.
*/
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
@@ -1018,48 +890,41 @@ delimit_word()
break;
if (word >= cp)
return (cp);
- for (p = cmdbuf; p < cp; p++)
- {
- if (meta_quoted)
- {
+ for (p = cmdbuf; p < cp; p++) {
+ if (meta_quoted) {
meta_quoted = 0;
} else if (esclen > 0 && p + esclen < cp &&
- strncmp(p, esc, esclen) == 0)
- {
+ strncmp(p, esc, esclen) == 0) {
meta_quoted = 1;
p += esclen - 1;
- } else if (delim_quoted)
- {
+ } else if (delim_quoted) {
if (*p == closequote)
delim_quoted = 0;
- } else /* (!delim_quoted) */
- {
+ } else { /* (!delim_quoted) */
if (*p == openquote)
delim_quoted = 1;
else if (*p == ' ')
word = p+1;
}
}
-#endif
return (word);
}
/*
* Set things up to enter completion mode.
- * Expand the word under the cursor into a list of filenames
+ * 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()
+static void
+init_compl(void)
{
char *word;
char c;
-
+
/*
* Get rid of any previous tk_text.
*/
- if (tk_text != NULL)
- {
+ if (tk_text != NULL) {
free(tk_text);
tk_text = NULL;
}
@@ -1079,8 +944,8 @@ init_compl()
*/
if (tk_original != NULL)
free(tk_original);
- tk_original = (char *) ecalloc(cp-word+1, sizeof(char));
- strncpy(tk_original, word, cp-word);
+ tk_original = ecalloc(cp-word+1, sizeof (char));
+ (void) strncpy(tk_original, word, cp-word);
/*
* Get the expanded filename.
* This may result in a single filename, or
@@ -1088,20 +953,13 @@ init_compl()
*/
c = *cp;
*cp = '\0';
- if (*word != openquote)
- {
+ if (*word != openquote) {
tk_text = fcomplete(word);
- } else
- {
-#if MSDOS_COMPILER
- char *qword = NULL;
-#else
+ } else {
char *qword = shell_quote(word+1);
-#endif
- if (qword == NULL)
+ if (qword == NULL) {
tk_text = fcomplete(word+1);
- else
- {
+ } else {
tk_text = fcomplete(qword);
free(qword);
}
@@ -1112,13 +970,10 @@ init_compl()
/*
* Return the next word in the current completion list.
*/
- static char *
-next_compl(action, prev)
- int action;
- char *prev;
+static char *
+next_compl(int action, char *prev)
{
- switch (action)
- {
+ switch (action) {
case EC_F_COMPLETE:
return (forw_textlist(&tk_tlist, prev));
case EC_B_COMPLETE:
@@ -1134,57 +989,50 @@ next_compl(action, prev)
* 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;
+static int
+cmd_complete(int action)
{
char *s;
- if (!in_completion || action == EC_EXPAND)
- {
+ if (!in_completion || action == EC_EXPAND) {
/*
- * Expand the word under the cursor and
- * use the first word in the expansion
+ * 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();
+ if (tk_text == NULL) {
+ ring_bell();
return (CC_OK);
}
- if (action == EC_EXPAND)
- {
+ if (action == EC_EXPAND) {
/*
* Use the whole list.
*/
tk_trial = tk_text;
- } else
- {
+ } else {
/*
* Use the first filename in the list.
*/
in_completion = 1;
init_textlist(&tk_tlist, tk_text);
- tk_trial = next_compl(action, (char*)NULL);
+ tk_trial = next_compl(action, NULL);
}
- } else
- {
+ } 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.
- */
+
+ /*
+ * Remove the original word, or the previous trial completion.
+ */
while (cp > tk_ipoint)
(void) cmd_erase();
-
- if (tk_trial == NULL)
- {
+
+ if (tk_trial == NULL) {
/*
* There are no more trial completions.
* Insert the original (uncompleted) filename.
@@ -1192,8 +1040,7 @@ cmd_complete(action)
in_completion = 0;
if (cmd_istr(tk_original) != CC_OK)
goto fail;
- } else
- {
+ } else {
/*
* Insert trial completion.
*/
@@ -1202,28 +1049,25 @@ cmd_complete(action)
/*
* If it is a directory, append a slash.
*/
- if (is_dir(tk_trial))
- {
+ if (is_dir(tk_trial)) {
if (cp > cmdbuf && cp[-1] == closequote)
(void) cmd_erase();
s = lgetenv("LESSSEPARATOR");
if (s == NULL)
- s = PATHNAME_SEP;
+ s = "/";
if (cmd_istr(s) != CC_OK)
goto fail;
}
}
-
+
return (CC_OK);
-
+
fail:
in_completion = 0;
- bell();
+ ring_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.
@@ -1232,56 +1076,48 @@ fail:
* 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
+cmd_char(int c)
{
int action;
int len;
- if (!utf_mode)
- {
- cmd_mbc_buf[0] = c;
+ if (!utf_mode) {
+ cmd_mbc_buf[0] = c & 0xff;
len = 1;
- }
-#if !SMALL
- else
- {
+ } else {
/* Perform strict validation in all possible cases. */
- if (cmd_mbc_buf_len == 0)
- {
- retry:
+ if (cmd_mbc_buf_len == 0) {
+retry:
cmd_mbc_buf_index = 1;
- *cmd_mbc_buf = c;
+ *cmd_mbc_buf = c & 0xff;
if (IS_ASCII_OCTET(c))
cmd_mbc_buf_len = 1;
- else if (IS_UTF8_LEAD(c))
- {
+ else if (IS_UTF8_LEAD(c)) {
cmd_mbc_buf_len = utf_len(c);
return (CC_OK);
- } else
- {
+ } else {
/* UTF8_INVALID or stray UTF8_TRAIL */
- bell();
+ ring_bell();
return (CC_ERROR);
}
- } else if (IS_UTF8_TRAIL(c))
- {
- cmd_mbc_buf[cmd_mbc_buf_index++] = c;
+ } else if (IS_UTF8_TRAIL(c)) {
+ cmd_mbc_buf[cmd_mbc_buf_index++] = c & 0xff;
if (cmd_mbc_buf_index < cmd_mbc_buf_len)
return (CC_OK);
- if (!is_utf8_well_formed(cmd_mbc_buf))
- {
- /* complete, but not well formed (non-shortest form), sequence */
+ if (!is_utf8_well_formed(cmd_mbc_buf)) {
+ /*
+ * complete, but not well formed
+ * (non-shortest form), sequence
+ */
cmd_mbc_buf_len = 0;
- bell();
+ ring_bell();
return (CC_ERROR);
}
- } else
- {
+ } else {
/* Flush incomplete (truncated) sequence. */
cmd_mbc_buf_len = 0;
- bell();
+ ring_bell();
/* Handle new char. */
goto retry;
}
@@ -1289,25 +1125,21 @@ cmd_char(c)
len = cmd_mbc_buf_len;
cmd_mbc_buf_len = 0;
}
-#endif /* !SMALL */
- if (literal)
- {
+ if (literal) {
/*
* Insert the char, even if it is a line-editing char.
*/
literal = 0;
return (cmd_ichar(cmd_mbc_buf, len));
}
-
+
/*
* See if it is a line-editing character.
*/
- if (in_mca() && len == 1)
- {
+ if (in_mca() && len == 1) {
action = cmd_edit(c);
- switch (action)
- {
+ switch (action) {
case CC_OK:
case CC_QUIT:
return (action);
@@ -1315,7 +1147,7 @@ cmd_char(c)
break;
}
}
-
+
/*
* Insert the char into the command buffer.
*/
@@ -1325,9 +1157,8 @@ cmd_char(c)
/*
* Return the number currently in the command buffer.
*/
- public LINENUM
-cmd_int(frac)
- long *frac;
+LINENUM
+cmd_int(long *frac)
{
char *p;
LINENUM n = 0;
@@ -1336,8 +1167,7 @@ cmd_int(frac)
for (p = cmdbuf; *p >= '0' && *p <= '9'; p++)
n = (n * 10) + (*p - '0');
*frac = 0;
- if (*p++ == '.')
- {
+ if (*p++ == '.') {
*frac = getfraction(&p, NULL, &err);
/* {{ do something if err is set? }} */
}
@@ -1347,72 +1177,57 @@ cmd_int(frac)
/*
* Return a pointer to the command buffer.
*/
- public char *
-get_cmdbuf()
+char *
+get_cmdbuf(void)
{
return (cmdbuf);
}
-#if CMD_HISTORY
/*
* Return the last (most recent) string in the current command history.
*/
- public char *
-cmd_lastpattern()
+char *
+cmd_lastpattern(void)
{
if (curr_mlist == NULL)
return (NULL);
return (curr_mlist->curr_mp->prev->string);
}
-#endif
-#if CMD_HISTORY
/*
* Get the name of the history file.
*/
- static char *
-histfile_name()
+static char *
+histfile_name(void)
{
char *home;
char *name;
- int len;
-
+
/* See if filename is explicitly specified by $LESSHISTFILE. */
name = lgetenv("LESSHISTFILE");
- if (name != NULL && *name != '\0')
- {
+ if (name != NULL && *name != '\0') {
if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
- /* $LESSHISTFILE == "-" means don't use a history file. */
+ /* $LESSHISTFILE == "-" means don't use history file */
return (NULL);
return (save(name));
}
/* Otherwise, file is in $HOME if enabled. */
- if (strcmp (LESSHISTFILE, "-") == 0)
+ if (strcmp(LESSHISTFILE, "-") == 0)
return (NULL);
home = lgetenv("HOME");
- if (home == NULL || *home == '\0')
- {
-#if OS2
- home = lgetenv("INIT");
- if (home == NULL || *home == '\0')
-#endif
- return (NULL);
+ if (home == NULL || *home == '\0') {
+ return (NULL);
}
- len = strlen(home) + strlen(LESSHISTFILE) + 2;
- name = (char *) ecalloc(len, sizeof(char));
- SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
- return (name);
+ return (easprintf("%s/%s", home, LESSHISTFILE));
}
-#endif /* CMD_HISTORY */
/*
* Initialize history from a .lesshist file.
*/
- public void
-init_cmdhist()
+void
+init_cmdhist(void)
{
-#if CMD_HISTORY
struct mlist *ml = NULL;
char line[CMDBUF_SIZE];
char *filename;
@@ -1426,49 +1241,36 @@ init_cmdhist()
free(filename);
if (f == NULL)
return;
- if (fgets(line, sizeof(line), f) == NULL ||
- strncmp(line, HISTFILE_FIRST_LINE, strlen(HISTFILE_FIRST_LINE)) != 0)
- {
- fclose(f);
+ if (fgets(line, sizeof (line), f) == NULL ||
+ strncmp(line, HISTFILE_FIRST_LINE,
+ strlen(HISTFILE_FIRST_LINE)) != 0) {
+ (void) fclose(f);
return;
}
- while (fgets(line, sizeof(line), f) != NULL)
- {
- for (p = line; *p != '\0'; p++)
- {
- if (*p == '\n' || *p == '\r')
- {
+ while (fgets(line, sizeof (line), f) != NULL) {
+ for (p = line; *p != '\0'; p++) {
+ if (*p == '\n' || *p == '\r') {
*p = '\0';
break;
}
}
if (strcmp(line, HISTFILE_SEARCH_SECTION) == 0)
ml = &mlist_search;
- else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0)
- {
-#if SHELL_ESCAPE || PIPEC
+ else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0) {
ml = &mlist_shell;
-#else
- ml = NULL;
-#endif
- } else if (*line == '"')
- {
+ } else if (*line == '"') {
if (ml != NULL)
cmd_addhist(ml, line+1);
}
}
- fclose(f);
-#endif /* CMD_HISTORY */
+ (void) fclose(f);
}
/*
*
*/
-#if CMD_HISTORY
- static void
-save_mlist(ml, f)
- struct mlist *ml;
- FILE *f;
+static void
+save_mlist(struct mlist *ml, FILE *f)
{
int histsize = 0;
int n;
@@ -1481,34 +1283,32 @@ save_mlist(ml, f)
histsize = 100;
ml = ml->prev;
- for (n = 0; n < histsize; n++)
- {
+ for (n = 0; n < histsize; n++) {
if (ml->string == NULL)
break;
ml = ml->prev;
}
for (ml = ml->next; ml->string != NULL; ml = ml->next)
- fprintf(f, "\"%s\n", ml->string);
+ (void) fprintf(f, "\"%s\n", ml->string);
}
-#endif /* CMD_HISTORY */
/*
*
*/
- public void
-save_cmdhist()
+void
+save_cmdhist(void)
{
-#if CMD_HISTORY
char *filename;
FILE *f;
int modified = 0;
+ int do_chmod = 1;
+ struct stat statbuf;
+ int r;
if (mlist_search.modified)
modified = 1;
-#if SHELL_ESCAPE || PIPEC
if (mlist_shell.modified)
modified = 1;
-#endif
if (!modified)
return;
filename = histfile_name();
@@ -1518,32 +1318,22 @@ save_cmdhist()
free(filename);
if (f == NULL)
return;
-#if HAVE_FCHMOD
-{
+
/* Make history file readable only by owner. */
- int do_chmod = 1;
-#if HAVE_STAT
- struct stat statbuf;
- int r = fstat(fileno(f), &statbuf);
+ r = fstat(fileno(f), &statbuf);
if (r < 0 || !S_ISREG(statbuf.st_mode))
/* Don't chmod if not a regular file. */
do_chmod = 0;
-#endif
if (do_chmod)
- fchmod(fileno(f), 0600);
-}
-#endif
+ (void) fchmod(fileno(f), 0600);
- fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
+ (void) fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
- fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
+ (void) fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
save_mlist(&mlist_search, f);
-#if SHELL_ESCAPE || PIPEC
- fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
+ (void) fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
save_mlist(&mlist_shell, f);
-#endif
- fclose(f);
-#endif /* CMD_HISTORY */
+ (void) fclose(f);
}
diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c
index 9b4a1623997..d81f9c292b8 100644
--- a/usr.bin/less/command.c
+++ b/usr.bin/less/command.c
@@ -6,16 +6,16 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* User-level command processor.
*/
#include "less.h"
-#if MSDOS_COMPILER==WIN32C
-#include <windows.h>
-#endif
#include "position.h"
#include "option.h"
#include "cmd.h"
@@ -23,6 +23,7 @@
extern int erase_char, erase2_char, kill_char;
extern volatile sig_atomic_t sigs;
extern int quit_if_one_screen;
+extern int less_is_more;
extern int squished;
extern int sc_width;
extern int sc_height;
@@ -35,30 +36,23 @@ extern int ignore_eoi;
extern int secure;
extern int hshift;
extern int show_attn;
-extern POSITION highest_hilite;
+extern off_t highest_hilite;
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 void *ml_search;
+extern void *ml_examine;
+extern void *ml_shell;
extern char *editor;
extern char *editproto;
-#endif
extern int screen_trashed; /* The screen has been overwritten */
extern int shift_count;
extern int oldbot;
extern int forw_prompt;
-extern int less_is_more;
-#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 LINENUM number; /* The number typed by the user */
@@ -67,17 +61,15 @@ static struct loption *curropt;
static int opt_lower;
static int optflag;
static int optgetname;
-static POSITION bottompos;
+static off_t bottompos;
static int save_hshift;
-#if PIPEC
-static char pipec;
-#endif
+static int pipec;
struct ungot {
struct ungot *ug_next;
- char ug_char;
+ int ug_char;
};
-static struct ungot* ungot = NULL;
+static struct ungot *ungot = NULL;
static int unget_end = 0;
static void multi_search();
@@ -87,12 +79,10 @@ static void multi_search();
* This looks nicer if the command takes a long time before
* updating the screen.
*/
- static void
-cmd_exec()
+static void
+cmd_exec(void)
{
-#if HILITE_SEARCH
clear_attn();
-#endif
clear_bot();
flush();
}
@@ -100,22 +90,18 @@ cmd_exec()
/*
* Set up the display to start a new multi-character command.
*/
- static void
-start_mca(action, prompt, mlist, cmdflags)
- int action;
- constant char *prompt;
- constant void *mlist;
- int cmdflags;
+static void
+start_mca(int action, const char *prompt, void *mlist, int cmdflags)
{
mca = action;
clear_bot();
clear_cmd();
- cmd_putstr(prompt);
+ cmd_putstr((char *)prompt);
set_mlist(mlist, cmdflags);
}
- public int
-in_mca()
+int
+in_mca(void)
{
return (mca != 0 && mca != A_PREFIX);
}
@@ -123,15 +109,12 @@ in_mca()
/*
* Set up the display to start a new search command.
*/
- static void
-mca_search()
+static void
+mca_search(void)
{
-#if HILITE_SEARCH
if (search_type & SRCH_FILTER)
mca = A_FILTER;
- else
-#endif
- if (search_type & SRCH_FORW)
+ else if (search_type & SRCH_FORW)
mca = A_F_SEARCH;
else
mca = A_B_SEARCH;
@@ -150,12 +133,9 @@ mca_search()
if (search_type & SRCH_NO_REGEX)
cmd_putstr("Regex-off ");
-#if HILITE_SEARCH
if (search_type & SRCH_FILTER)
cmd_putstr("&/");
- else
-#endif
- if (search_type & SRCH_FORW)
+ else if (search_type & SRCH_FORW)
cmd_putstr("/");
else
cmd_putstr("?");
@@ -165,13 +145,13 @@ mca_search()
/*
* Set up the display to start a new toggle-option command.
*/
- static void
-mca_opt_toggle()
+static void
+mca_opt_toggle(void)
{
int no_prompt;
int flag;
char *dash;
-
+
no_prompt = (optflag & OPT_NO_PROMPT);
flag = (optflag & ~OPT_NO_PROMPT);
dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
@@ -180,14 +160,11 @@ mca_opt_toggle()
clear_bot();
clear_cmd();
cmd_putstr(dash);
-#if GNU_OPTIONS
if (optgetname)
cmd_putstr(dash);
-#endif
if (no_prompt)
cmd_putstr("(P)");
- switch (flag)
- {
+ switch (flag) {
case OPT_UNSET:
cmd_putstr("+");
break;
@@ -201,26 +178,23 @@ mca_opt_toggle()
/*
* Execute a multicharacter command.
*/
- static void
-exec_mca()
+static void
+exec_mca(void)
{
- register char *cbuf;
+ char *cbuf;
cmd_exec();
cbuf = get_cmdbuf();
- switch (mca)
- {
+ switch (mca) {
case A_F_SEARCH:
case A_B_SEARCH:
- multi_search(cbuf, (int) number);
+ multi_search(cbuf, (int)number);
break;
-#if HILITE_SEARCH
case A_FILTER:
search_type ^= SRCH_NO_MATCH;
set_filter_pattern(cbuf, search_type);
break;
-#endif
case A_FIRSTCMD:
/*
* Skip leading spaces or + signs in the string.
@@ -239,31 +213,45 @@ exec_mca()
curropt = NULL;
break;
case A_F_BRACKET:
- match_brac(cbuf[0], cbuf[1], 1, (int) number);
+ match_brac(cbuf[0], cbuf[1], 1, (int)number);
break;
case A_B_BRACKET:
- match_brac(cbuf[1], cbuf[0], 0, (int) number);
+ match_brac(cbuf[1], cbuf[0], 0, (int)number);
break;
-#if EXAMINE
case A_EXAMINE:
if (secure)
break;
+
+ /* POSIX behavior, but possibly generally useful */
+ if (strlen(cbuf) == 0) {
+ reopen_curr_ifile();
+ jump_back(1);
+ break;
+ }
+ /* POSIX behavior - probably not generally useful */
+ if (less_is_more && (strcmp(cbuf, "#") == 0)) {
+ if (ntags()) {
+ error("No previous file", NULL_PARG);
+ break;
+ }
+ if (edit_prev(1)) {
+ error("No previous file", NULL_PARG);
+ } else {
+ jump_back(1);
+ }
+ break;
+ }
edit_list(cbuf);
-#if TAGS
/* If tag structure is loaded then clean it up. */
cleantags();
-#endif
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 (*cbuf != '!') {
if (shellcmd != NULL)
free(shellcmd);
shellcmd = fexpand(cbuf);
@@ -276,24 +264,20 @@ exec_mca()
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
}
}
/*
* Is a character an erase or kill char?
*/
- static int
-is_erase_char(c)
- int c;
+static int
+is_erase_char(int c)
{
return (c == erase_char || c == erase2_char || c == kill_char);
}
@@ -301,72 +285,58 @@ is_erase_char(c)
/*
* Handle the first char of an option (after the initial dash).
*/
- static int
-mca_opt_first_char(c)
- int c;
+static int
+mca_opt_first_char(int c)
{
int flag = (optflag & ~OPT_NO_PROMPT);
-#if GNU_OPTIONS
- if (flag == OPT_NO_TOGGLE)
- {
- switch (c)
- {
+ if (flag == OPT_NO_TOGGLE) {
+ switch (c) {
case '_':
/* "__" = long option name. */
optgetname = TRUE;
mca_opt_toggle();
return (MCA_MORE);
}
- } else
-#endif
- {
- switch (c)
- {
+ } else {
+ switch (c) {
case '+':
/* "-+" = UNSET. */
- optflag = (flag == OPT_UNSET) ?
- OPT_TOGGLE : OPT_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;
+ 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);
-#if GNU_OPTIONS
case '-':
/* "--" = long option name. */
optgetname = TRUE;
mca_opt_toggle();
return (MCA_MORE);
-#endif
}
}
/* Char was not handled here. */
return (NO_MCA);
}
-#if GNU_OPTIONS
/*
* Add a char to a long option name.
* See if we've got a match for an option name yet.
- * If so, display the complete name and stop
+ * If so, display the complete name and stop
* accepting chars until user hits RETURN.
*/
- static int
-mca_opt_nonfirst_char(c)
- int c;
+static int
+mca_opt_nonfirst_char(int c)
{
char *p;
char *oname;
- if (curropt != NULL)
- {
+ if (curropt != NULL) {
/*
* Already have a match for the name.
* Don't accept anything but erase/kill.
@@ -382,10 +352,9 @@ mca_opt_nonfirst_char(c)
if (cmd_char(c) == CC_QUIT)
return (MCA_DONE);
p = get_cmdbuf();
- opt_lower = ASCII_IS_LOWER(p[0]);
+ opt_lower = islower(p[0]);
curropt = findopt_name(&p, &oname, NULL);
- if (curropt != NULL)
- {
+ if (curropt != NULL) {
/*
* Got a match.
* Remember the option and
@@ -393,25 +362,22 @@ mca_opt_nonfirst_char(c)
*/
cmd_reset();
mca_opt_toggle();
- for (p = oname; *p != '\0'; p++)
- {
+ for (p = oname; *p != '\0'; p++) {
c = *p;
- if (!opt_lower && ASCII_IS_LOWER(c))
- c = ASCII_TO_UPPER(c);
+ if (!opt_lower && islower(c))
+ c = toupper(c);
if (cmd_char(c) != CC_OK)
return (MCA_DONE);
}
}
return (MCA_MORE);
}
-#endif
/*
* Handle a char of an option toggle command.
*/
- static int
-mca_opt_char(c)
- int c;
+static int
+mca_opt_char(int c)
{
PARG parg;
@@ -420,71 +386,62 @@ mca_opt_char(c)
* or one char of a long option name,
* or one char of the option parameter.
*/
- if (curropt == NULL && len_cmdbuf() == 0)
- {
+ if (curropt == NULL && len_cmdbuf() == 0) {
int ret = mca_opt_first_char(c);
if (ret != NO_MCA)
return (ret);
}
-#if GNU_OPTIONS
- if (optgetname)
- {
+ if (optgetname) {
/* We're getting a long option name. */
if (c != '\n' && c != '\r')
return (mca_opt_nonfirst_char(c));
- if (curropt == NULL)
- {
+ if (curropt == NULL) {
parg.p_string = get_cmdbuf();
error("There is no --%s option", &parg);
return (MCA_DONE);
}
optgetname = FALSE;
cmd_reset();
- } else
-#endif
- {
+ } else {
if (is_erase_char(c))
return (NO_MCA);
if (curropt != NULL)
/* We're getting the option parameter. */
return (NO_MCA);
curropt = findopt(c);
- if (curropt == NULL)
- {
+ if (curropt == NULL) {
parg.p_string = propt(c);
error("There is no %s option", &parg);
return (MCA_DONE);
}
}
/*
- * If the option which was entered does not take a
+ * If the option which was entered does not take a
* parameter, toggle the option immediately,
* so user doesn't have to hit RETURN.
*/
if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE ||
- !opt_has_param(curropt))
- {
- toggle_option(curropt, ASCII_IS_LOWER(c), "", optflag);
+ !opt_has_param(curropt)) {
+ toggle_option(curropt, islower(c), "", optflag);
return (MCA_DONE);
}
/*
* Display a prompt appropriate for the option parameter.
*/
- start_mca(A_OPT_TOGGLE, opt_prompt(curropt), (void*)NULL, 0);
+ start_mca(A_OPT_TOGGLE, opt_prompt(curropt), NULL, 0);
return (MCA_MORE);
}
/*
* Handle a char of a search command.
*/
- static int
-mca_search_char(c)
- int c;
+static int
+mca_search_char(int c)
{
int flag = 0;
/*
- * Certain characters as the first char of
+ * Certain characters as the first char of
* the pattern have special meaning:
* ! Toggle the NO_MATCH flag
* * Toggle the PAST_EOF flag
@@ -493,8 +450,7 @@ mca_search_char(c)
if (len_cmdbuf() > 0)
return (NO_MCA);
- switch (c)
- {
+ switch (c) {
case CONTROL('E'): /* ignore END of file */
case '*':
if (mca != A_FILTER)
@@ -518,8 +474,7 @@ mca_search_char(c)
break;
}
- if (flag != 0)
- {
+ if (flag != 0) {
search_type ^= flag;
mca_search();
return (MCA_MORE);
@@ -530,14 +485,12 @@ mca_search_char(c)
/*
* Handle a character of a multi-character command.
*/
- static int
-mca_char(c)
- int c;
+static int
+mca_char(int c)
{
int ret;
- switch (mca)
- {
+ switch (mca) {
case 0:
/*
* We're not in a multicharacter command.
@@ -558,12 +511,12 @@ mca_char(c)
* Entering digits of a number.
* Terminated by a non-digit.
*/
- if (!((c >= '0' && c <= '9') || c == '.') &&
- editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID)
- {
+ if (!((c >= '0' && c <= '9') || c == '.') && editchar(c,
+ EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) ==
+ A_INVALID) {
/*
* Not part of the number.
- * End the number and treat this char
+ * End the number and treat this char
* as a normal command character.
*/
number = cmd_int(&fraction);
@@ -595,8 +548,7 @@ mca_char(c)
/*
* The multichar command is terminated by a newline.
*/
- if (c == '\n' || c == '\r')
- {
+ if (c == '\n' || c == '\r') {
/*
* Execute the command.
*/
@@ -613,8 +565,7 @@ mca_char(c)
*/
return (MCA_DONE);
- if ((mca == A_F_BRACKET || mca == A_B_BRACKET) && len_cmdbuf() >= 2)
- {
+ 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
@@ -633,49 +584,46 @@ mca_char(c)
/*
* Discard any buffered file data.
*/
- static void
-clear_buffers()
+static void
+clear_buffers(void)
{
if (!(ch_getflags() & CH_CANSEEK))
return;
ch_flush();
clr_linenum();
-#if HILITE_SEARCH
clr_hilite();
-#endif
}
/*
* Make sure the screen is displayed.
*/
- static void
-make_display()
+static void
+make_display(void)
{
/*
* If nothing is displayed yet, display starting from initial_scrpos.
*/
- if (empty_screen())
- {
- if (initial_scrpos.pos == NULL_POSITION)
+ if (empty_screen()) {
+ if (initial_scrpos.pos == -1)
/*
* {{ Maybe this should be:
* jump_loc(ch_zero(), jump_sline);
- * but this behavior seems rather unexpected
+ * 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)
- {
+ } else if (screen_trashed) {
int save_top_scroll = top_scroll;
int save_ignore_eoi = ignore_eoi;
top_scroll = 1;
ignore_eoi = 0;
- if (screen_trashed == 2)
- {
- /* Special case used by ignore_eoi: re-open the input file
- * and jump to the end of the file. */
+ if (screen_trashed == 2) {
+ /*
+ * Special case used by ignore_eoi: re-open the input
+ * file and jump to the end of the file.
+ */
reopen_curr_ifile();
jump_forw();
}
@@ -688,15 +636,14 @@ make_display()
/*
* Display the appropriate prompt.
*/
- static void
-prompt()
+static void
+prompt(void)
{
- register constant char *p;
+ const char *p;
- if (ungot != NULL)
- {
+ if (ungot != NULL) {
/*
- * No prompt necessary if commands are from
+ * No prompt necessary if commands are from
* ungotten chars rather than from the user.
*/
return;
@@ -712,7 +659,7 @@ prompt()
* If we've hit EOF on the last file and the -E flag is set, quit.
*/
if (get_quit_at_eof() == OPT_ONPLUS &&
- eof_displayed() && !(ch_getflags() & CH_HELPFILE) &&
+ eof_displayed() && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
@@ -720,24 +667,17 @@ prompt()
* If the entire file is displayed and the -F flag is set, quit.
*/
if (quit_if_one_screen &&
- entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) &&
+ entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
-#if MSDOS_COMPILER==WIN32C
- /*
- * In Win32, display the file name in the window title.
- */
- if (!(ch_getflags() & CH_HELPFILE))
- SetConsoleTitle(pr_expand("Less?f - %f.", 0));
-#endif
/*
* Select the proper prompt and display it.
*/
/*
- * If the previous action was a forward movement,
+ * If the previous action was a forward movement,
* don't clear the bottom line of the display;
- * just print the prompt since the forward movement guarantees
+ * just print the prompt since the forward movement guarantees
* that we're in the right position to display the prompt.
* Clearing the line could cause a problem: for example, if the last
* line displayed ended at the right screen edge without a newline,
@@ -748,13 +688,12 @@ prompt()
clear_bot();
clear_cmd();
forw_prompt = 0;
- p = pr_string();
+ p = prompt_string();
if (is_filtering())
putstr("& ");
- if (p == NULL || *p == '\0')
+ if (p == NULL || *p == '\0') {
putchr(':');
- else
- {
+ } else {
at_enter(AT_STANDOUT);
putstr(p);
at_exit();
@@ -765,8 +704,8 @@ prompt()
/*
* Display the less version message.
*/
- public void
-dispversion()
+void
+dispversion(void)
{
PARG parg;
@@ -780,11 +719,10 @@ dispversion()
* but may come from ungotten characters
* (characters previously given to ungetcc or ungetsc).
*/
- public int
-getcc()
+int
+getcc(void)
{
- if (unget_end)
- {
+ if (unget_end) {
/*
* We have just run out of ungotten chars.
*/
@@ -794,8 +732,7 @@ getcc()
/*
* Command is incomplete, so try to complete it.
*/
- switch (mca)
- {
+ switch (mca) {
case A_DIGIT:
/*
* We have a number but no command. Treat as #g.
@@ -807,7 +744,7 @@ getcc()
/*
* We have "/string" but no newline. Add the \n.
*/
- return ('\n');
+ return ('\n');
default:
/*
@@ -817,8 +754,7 @@ getcc()
}
}
- if (ungot == NULL)
- {
+ if (ungot == NULL) {
/*
* Normal case: no ungotten chars, so get one from the user.
*/
@@ -830,7 +766,7 @@ getcc()
*/
{
struct ungot *ug = ungot;
- char c = ug->ug_char;
+ int c = ug->ug_char;
ungot = ug->ug_next;
free(ug);
unget_end = (ungot == NULL);
@@ -842,11 +778,10 @@ getcc()
* "Unget" a command character.
* The next getcc() will return this character.
*/
- public void
-ungetcc(c)
- int c;
+void
+ungetcc(int c)
{
- struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
+ struct ungot *ug = ecalloc(1, sizeof (struct ungot));
ug->ug_char = c;
ug->ug_next = ungot;
@@ -858,9 +793,8 @@ ungetcc(c)
* Unget a whole string of command characters.
* The next sequence of getcc()'s will return this string.
*/
- public void
-ungetsc(s)
- char *s;
+void
+ungetsc(char *s)
{
register char *p;
@@ -873,30 +807,26 @@ ungetsc(s)
* 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;
+static void
+multi_search(char *pattern, int n)
{
- register int nomore;
+ int nomore;
IFILE save_ifile;
int changed_file;
changed_file = 0;
save_ifile = save_curr_ifile();
- if (search_type & SRCH_FIRST_FILE)
- {
+ if (search_type & SRCH_FIRST_FILE) {
/*
- * Start at the first (or last) 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)
- {
+ if (nomore) {
unsave_ifile(save_ifile);
return;
}
@@ -904,8 +834,7 @@ multi_search(pattern, n)
search_type &= ~SRCH_FIRST_FILE;
}
- for (;;)
- {
+ for (;;) {
n = search(search_type, pattern, n);
/*
* The SRCH_NO_MOVE flag doesn't "stick": it gets cleared
@@ -913,8 +842,7 @@ multi_search(pattern, n)
* using a /@@ search.
*/
search_type &= ~SRCH_NO_MOVE;
- if (n == 0)
- {
+ if (n == 0) {
/*
* Found it.
*/
@@ -954,14 +882,12 @@ multi_search(pattern, n)
if (n > 0)
error("Pattern not found", NULL_PARG);
- if (changed_file)
- {
+ if (changed_file) {
/*
* Restore the file we were originally viewing.
*/
reedit_ifile(save_ifile);
- } else
- {
+ } else {
unsave_ifile(save_ifile);
}
}
@@ -969,11 +895,10 @@ multi_search(pattern, n)
/*
* Forward forever, or until a highlighted line appears.
*/
- static int
-forw_loop(until_hilite)
- int until_hilite;
+static int
+forw_loop(int until_hilite)
{
- POSITION curr_len;
+ off_t curr_len;
if (ch_getflags() & CH_HELPFILE)
return (A_NOACTION);
@@ -981,13 +906,11 @@ forw_loop(until_hilite)
cmd_exec();
jump_forw();
curr_len = ch_length();
- highest_hilite = until_hilite ? curr_len : NULL_POSITION;
+ highest_hilite = until_hilite ? curr_len : -1;
ignore_eoi = 1;
- while (!sigs)
- {
- if (until_hilite && highest_hilite > curr_len)
- {
- bell();
+ while (!sigs) {
+ if (until_hilite && highest_hilite > curr_len) {
+ ring_bell();
break;
}
make_display();
@@ -997,8 +920,8 @@ forw_loop(until_hilite)
ch_set_eof();
/*
- * This gets us back in "F mode" after processing
- * a non-abort signal (e.g. window-change).
+ * This gets us back in "F mode" after processing
+ * a non-abort signal (e.g. window-change).
*/
if (sigs && !ABORT_SIGS())
return (until_hilite ? A_F_UNTIL_HILITE : A_F_FOREVER);
@@ -1010,12 +933,12 @@ forw_loop(until_hilite)
* Main command processor.
* Accept and execute commands until a quit command.
*/
- public void
-commands()
+void
+commands(void)
{
- register int c;
- register int action;
- register char *cbuf;
+ int c = 0;
+ int action;
+ char *cbuf;
int newaction;
int save_search_type;
char *extra;
@@ -1029,8 +952,7 @@ commands()
wscroll = (sc_height + 1) / 2;
newaction = A_NOACTION;
- for (;;)
- {
+ for (;;) {
mca = 0;
cmd_accept();
number = 0;
@@ -1039,20 +961,13 @@ commands()
/*
* See if any signals need processing.
*/
- if (sigs)
- {
+ 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();
@@ -1062,24 +977,21 @@ commands()
if (newaction == A_NOACTION)
c = getcc();
- again:
+again:
if (sigs)
continue;
- if (newaction != A_NOACTION)
- {
+ if (newaction != A_NOACTION) {
action = newaction;
newaction = A_NOACTION;
- } else
- {
+ } 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))
- {
+ switch (mca_char(c)) {
case MCA_MORE:
/*
* Need another character.
@@ -1103,20 +1015,18 @@ commands()
/*
* Decode the command character and decide what to do.
*/
- if (mca)
- {
+ 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
+ * 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
- {
+ } else {
/*
* Don't use cmd_char if we're starting fresh
* at the beginning of a command, because we
@@ -1125,7 +1035,7 @@ commands()
* want erase_char/kill_char to be treated
* as line editing characters.
*/
- tbuf[0] = c;
+ tbuf[0] = (char)c;
tbuf[1] = '\0';
cbuf = tbuf;
}
@@ -1146,8 +1056,7 @@ commands()
if (action != A_PREFIX)
cmd_reset();
- switch (action)
- {
+ switch (action) {
case A_DIGIT:
/*
* First digit of a number.
@@ -1160,7 +1069,7 @@ commands()
* Forward one window (and set the window size).
*/
if (number > 0)
- swindow = (int) number;
+ swindow = (int)number;
/* FALLTHRU */
case A_F_SCREEN:
/*
@@ -1171,7 +1080,7 @@ commands()
cmd_exec();
if (show_attn)
set_attnpos(bottompos);
- forward((int) number, 0, 1);
+ forward((int)number, 0, 1);
break;
case A_B_WINDOW:
@@ -1179,7 +1088,7 @@ commands()
* Backward one window (and set the window size).
*/
if (number > 0)
- swindow = (int) number;
+ swindow = (int)number;
/* FALLTHRU */
case A_B_SCREEN:
/*
@@ -1188,7 +1097,7 @@ commands()
if (number <= 0)
number = get_swindow();
cmd_exec();
- backward((int) number, 0, 1);
+ backward((int)number, 0, 1);
break;
case A_F_LINE:
@@ -1200,7 +1109,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS && number > 1)
set_attnpos(bottompos);
- forward((int) number, 0, 0);
+ forward((int)number, 0, 0);
break;
case A_B_LINE:
@@ -1210,7 +1119,22 @@ commands()
if (number <= 0)
number = 1;
cmd_exec();
- backward((int) number, 0, 0);
+ backward((int)number, 0, 0);
+ break;
+
+ case A_F_SKIP:
+ /*
+ * Skip ahead one screen, and then number lines.
+ */
+ if (number <= 0) {
+ number = get_swindow();
+ } else {
+ number += get_swindow();
+ }
+ cmd_exec();
+ if (show_attn == OPT_ONPLUS)
+ set_attnpos(bottompos);
+ forward((int)number, 0, 1);
break;
case A_FF_LINE:
@@ -1222,7 +1146,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS && number > 1)
set_attnpos(bottompos);
- forward((int) number, 1, 0);
+ forward((int)number, 1, 0);
break;
case A_BF_LINE:
@@ -1232,9 +1156,9 @@ commands()
if (number <= 0)
number = 1;
cmd_exec();
- backward((int) number, 1, 0);
+ backward((int)number, 1, 0);
break;
-
+
case A_FF_SCREEN:
/*
* Force forward one screen.
@@ -1244,7 +1168,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS)
set_attnpos(bottompos);
- forward((int) number, 1, 0);
+ forward((int)number, 1, 0);
break;
case A_F_FOREVER:
@@ -1260,11 +1184,11 @@ commands()
case A_F_SCROLL:
/*
- * Forward N lines
+ * Forward N lines
* (default same as last 'd' or 'u' command).
*/
if (number > 0)
- wscroll = (int) number;
+ wscroll = (int)number;
cmd_exec();
if (show_attn == OPT_ONPLUS)
set_attnpos(bottompos);
@@ -1273,11 +1197,11 @@ commands()
case A_B_SCROLL:
/*
- * Forward N lines
+ * Forward N lines
* (default same as last 'd' or 'u' command).
*/
if (number > 0)
- wscroll = (int) number;
+ wscroll = (int)number;
cmd_exec();
backward(wscroll, 0, 0);
break;
@@ -1311,18 +1235,16 @@ commands()
/*
* Go to a specified percentage into the file.
*/
- if (number < 0)
- {
+ if (number < 0) {
number = 0;
fraction = 0;
}
- if (number > 100)
- {
+ if (number > 100) {
number = 100;
fraction = 0;
}
cmd_exec();
- jump_percent((int) number, fraction);
+ jump_percent((int)number, fraction);
break;
case A_GOEND:
@@ -1343,7 +1265,7 @@ commands()
cmd_exec();
if (number < 0)
number = 0;
- jump_line_loc((POSITION) number, jump_sline);
+ jump_line_loc((off_t) number, jump_sline);
break;
case A_STAT:
@@ -1369,10 +1291,8 @@ commands()
/*
* Exit.
*/
-#if !SMALL
- if (curr_ifile != NULL_IFILE &&
- ch_getflags() & CH_HELPFILE)
- {
+ if (curr_ifile != NULL_IFILE &&
+ ch_getflags() & CH_HELPFILE) {
/*
* Quit while viewing the help file
* just means return to viewing the
@@ -1382,7 +1302,6 @@ commands()
if (edit_prev(1) == 0)
break;
}
-#endif /* !SMALL */
if (extra != NULL)
quit(*extra);
quit(QUIT_OK);
@@ -1395,7 +1314,7 @@ commands()
if (number <= 0) number = 1; \
mca_search(); \
cmd_exec(); \
- multi_search((char *)NULL, (int) number);
+ multi_search(NULL, (int)number);
case A_F_SEARCH:
@@ -1423,15 +1342,10 @@ commands()
goto again;
case A_FILTER:
-#if HILITE_SEARCH
search_type = SRCH_FORW | SRCH_FILTER;
mca_search();
c = getcc();
goto again;
-#else
- error("Command not available", NULL_PARG);
- break;
-#endif
case A_AGAIN_SEARCH:
/*
@@ -1439,7 +1353,7 @@ commands()
*/
DO_SEARCH();
break;
-
+
case A_T_AGAIN_SEARCH:
/*
* Repeat previous search, multiple files.
@@ -1459,8 +1373,8 @@ commands()
break;
case A_T_REVERSE_SEARCH:
- /*
- * Repeat previous search,
+ /*
+ * Repeat previous search,
* multiple files in reverse direction.
*/
save_search_type = search_type;
@@ -1478,7 +1392,6 @@ commands()
/*
* Help.
*/
-#if !SMALL
if (ch_getflags() & CH_HELPFILE)
break;
if (ungot != NULL || unget_end) {
@@ -1492,48 +1405,37 @@ commands()
save_hshift = hshift;
hshift = 0;
(void) edit(helpfile());
-#endif /* !SMALL */
break;
case A_EXAMINE:
-#if EXAMINE
/*
* Edit a new file. Get the filename.
*/
- if (secure)
- {
+ 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)
- {
+ if (secure) {
error("Command not available", NULL_PARG);
break;
}
if (ch_getflags() & CH_HELPFILE)
break;
- if (strcmp(get_filename(curr_ifile), "-") == 0)
- {
+ if (strcmp(get_filename(curr_ifile), "-") == 0) {
error("Cannot edit standard input", NULL_PARG);
break;
}
- if (curr_altfilename != NULL)
- {
- error("WARNING: This file was viewed via LESSOPEN",
- NULL_PARG);
+ if (curr_altfilename != NULL) {
+ error("WARNING: This file was viewed via "
+ "LESSOPEN", NULL_PARG);
}
start_mca(A_SHELL, "!", ml_shell, 0);
/*
@@ -1544,29 +1446,21 @@ commands()
*/
make_display();
cmd_exec();
- lsystem(pr_expand(editproto, 0), (char*)NULL);
+ lsystem(pr_expand(editproto, 0), NULL);
break;
-#else
- error("Command not available", NULL_PARG);
- break;
-#endif
case A_NEXT_FILE:
/*
* Examine next file.
*/
-#if TAGS
- if (ntags())
- {
+ if (ntags()) {
error("No next file", NULL_PARG);
break;
}
-#endif
if (number <= 0)
number = 1;
- if (edit_next((int) number))
- {
- if (get_quit_at_eof() && eof_displayed() &&
+ if (edit_next((int)number)) {
+ if (get_quit_at_eof() && eof_displayed() &&
!(ch_getflags() & CH_HELPFILE))
quit(QUIT_OK);
parg.p_string = (number > 1) ? "(N-th) " : "";
@@ -1578,62 +1472,46 @@ commands()
/*
* Examine previous file.
*/
-#if TAGS
- if (ntags())
- {
+ if (ntags()) {
error("No previous file", NULL_PARG);
break;
}
-#endif
if (number <= 0)
number = 1;
- if (edit_prev((int) number))
- {
+ if (edit_prev((int)number)) {
parg.p_string = (number > 1) ? "(N-th) " : "";
error("No %sprevious file", &parg);
}
break;
case A_NEXT_TAG:
-#if TAGS
if (number <= 0)
number = 1;
- tagfile = nexttag((int) number);
- if (tagfile == NULL)
- {
+ tagfile = nexttag((int)number);
+ if (tagfile == NULL) {
error("No next tag", NULL_PARG);
break;
}
- if (edit(tagfile) == 0)
- {
- POSITION pos = tagsearch();
- if (pos != NULL_POSITION)
+ if (edit(tagfile) == 0) {
+ off_t pos = tagsearch();
+ if (pos != -1)
jump_loc(pos, jump_sline);
}
-#else
- error("Command not available", NULL_PARG);
-#endif
break;
case A_PREV_TAG:
-#if TAGS
if (number <= 0)
number = 1;
- tagfile = prevtag((int) number);
- if (tagfile == NULL)
- {
+ tagfile = prevtag((int)number);
+ if (tagfile == NULL) {
error("No previous tag", NULL_PARG);
break;
}
- if (edit(tagfile) == 0)
- {
- POSITION pos = tagsearch();
- if (pos != NULL_POSITION)
+ if (edit(tagfile) == 0) {
+ off_t pos = tagsearch();
+ if (pos != -1)
jump_loc(pos, jump_sline);
}
-#else
- error("Command not available", NULL_PARG);
-#endif
break;
case A_INDEX_FILE:
@@ -1642,7 +1520,7 @@ commands()
*/
if (number <= 0)
number = 1;
- if (edit_index((int) number))
+ if (edit_index((int)number))
error("No such file", NULL_PARG);
break;
@@ -1651,13 +1529,11 @@ commands()
break;
old_ifile = curr_ifile;
new_ifile = getoff_ifile(curr_ifile);
- if (new_ifile == NULL_IFILE)
- {
- bell();
+ if (new_ifile == NULL_IFILE) {
+ ring_bell();
break;
}
- if (edit_ifile(new_ifile) != 0)
- {
+ if (edit_ifile(new_ifile) != 0) {
reedit_ifile(old_ifile);
break;
}
@@ -1685,7 +1561,7 @@ commands()
/*
* Set an initial command for new files.
*/
- start_mca(A_FIRSTCMD, "+", (void*)NULL, 0);
+ start_mca(A_FIRSTCMD, "+", NULL, 0);
c = getcc();
goto again;
@@ -1693,19 +1569,13 @@ commands()
/*
* Shell escape.
*/
-#if SHELL_ESCAPE
- if (secure)
- {
+ 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:
/*
@@ -1735,15 +1605,14 @@ commands()
break;
case A_PIPE:
-#if PIPEC
- if (secure)
- {
+ if (secure) {
error("Command not available", NULL_PARG);
break;
}
start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
c = getcc();
- if (c == erase_char || c == erase2_char || c == kill_char)
+ if (c == erase_char || c == erase2_char ||
+ c == kill_char)
break;
if (c == '\n' || c == '\r')
c = '.';
@@ -1753,10 +1622,6 @@ commands()
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:
@@ -1769,7 +1634,7 @@ commands()
shift_count = number;
else
number = (shift_count > 0) ?
- shift_count : sc_width / 2;
+ shift_count : sc_width / 2;
if (number > hshift)
number = hshift;
hshift -= number;
@@ -1781,7 +1646,7 @@ commands()
shift_count = number;
else
number = (shift_count > 0) ?
- shift_count : sc_width / 2;
+ shift_count : sc_width / 2;
hshift += number;
screen_trashed = 1;
break;
@@ -1792,11 +1657,10 @@ commands()
* Display the current char, so the user knows
* what's going on, and get another character.
*/
- if (mca != A_PREFIX)
- {
+ if (mca != A_PREFIX) {
cmd_reset();
start_mca(A_PREFIX, " ", (void*)NULL,
- CF_QUIT_ON_ERASE);
+ CF_QUIT_ON_ERASE);
(void) cmd_char(c);
}
c = getcc();
@@ -1806,7 +1670,7 @@ commands()
break;
default:
- bell();
+ ring_bell();
break;
}
}
diff --git a/usr.bin/less/configure b/usr.bin/less/configure
deleted file mode 100644
index e401d588b8d..00000000000
--- a/usr.bin/less/configure
+++ /dev/null
@@ -1,6747 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for less 1.
-#
-#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
- && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='print -r --'
- as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
-else
- if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
- as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
- as_echo_n='/usr/ucb/echo -n'
- else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
- case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
- esac;
- expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
- '
- export as_echo_n_body
- as_echo_n='sh -c $as_echo_n_body as_echo'
- fi
- export as_echo_body
- as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- PATH_SEPARATOR=:
- (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
- (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
- PATH_SEPARATOR=';'
- }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there. '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
- && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test "x$CONFIG_SHELL" = x; then
- as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '\${1+\"\$@\"}'='\"\$@\"'
- setopt NO_GLOB_SUBST
-else
- case \`(set -o) 2>/dev/null\` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-"
- as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
- exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1"
- as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
- as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
- eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
- test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
- if (eval "$as_required") 2>/dev/null; then :
- as_have_required=yes
-else
- as_have_required=no
-fi
- if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- as_found=:
- case $as_dir in #(
- /*)
- for as_base in sh bash ksh sh5; do
- # Try only shells that exist, to save several forks.
- as_shell=$as_dir/$as_base
- if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
- { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
- CONFIG_SHELL=$as_shell as_have_required=yes
- if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
- break 2
-fi
-fi
- done;;
- esac
- as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
- { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
- CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
- if test "x$CONFIG_SHELL" != x; then :
- # We cannot yet assume a decent shell, so we have to provide a
- # neutralization value for shells without unset; and this also
- # works around shells that cannot unset nonexistent variables.
- # Preserve -v and -x to the replacement shell.
- BASH_ENV=/dev/null
- ENV=/dev/null
- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
- export CONFIG_SHELL
- case $- in # ((((
- *v*x* | *x*v* ) as_opts=-vx ;;
- *v* ) as_opts=-v ;;
- *x* ) as_opts=-x ;;
- * ) as_opts= ;;
- esac
- exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
-fi
-
- if test x$as_have_required = xno; then :
- $as_echo "$0: This script requires a shell more modern than all"
- $as_echo "$0: the shells that I found on your system."
- if test x${ZSH_VERSION+set} = xset ; then
- $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
- $as_echo "$0: be upgraded to zsh 4.3.4 or later."
- else
- $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
-$0: including any error possibly output before this
-$0: message. Then install a modern shell, or manually run
-$0: the script under such a shell if you do have one."
- fi
- exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
- { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
- return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
- set +e
- as_fn_set_status $1
- exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
- case $as_dir in #(
- -*) as_dir=./$as_dir;;
- esac
- test -d "$as_dir" || eval $as_mkdir_p || {
- as_dirs=
- while :; do
- case $as_dir in #(
- *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
- *) as_qdir=$as_dir;;
- esac
- as_dirs="'$as_qdir' $as_dirs"
- as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- test -d "$as_dir" && break
- done
- test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
- eval 'as_fn_append ()
- {
- eval $1+=\$2
- }'
-else
- as_fn_append ()
- {
- eval $1=\$$1\$2
- }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
- eval 'as_fn_arith ()
- {
- as_val=$(( $* ))
- }'
-else
- as_fn_arith ()
- {
- as_val=`expr "$@" || test $? -eq 1`
- }
-fi # as_fn_arith
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
- as_status=$1; test $as_status -eq 0 && as_status=1
- if test "$4"; then
- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
- fi
- $as_echo "$as_me: error: $2" >&2
- as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
- as_lineno_1=$LINENO as_lineno_1a=$LINENO
- as_lineno_2=$LINENO as_lineno_2a=$LINENO
- eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
- test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
- # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
- sed -n '
- p
- /[$]LINENO/=
- ' <$as_myself |
- sed '
- s/[$]LINENO.*/&-/
- t lineno
- b
- :lineno
- N
- :loop
- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
- t loop
- s/-\n.*//
- ' >$as_me.lineno &&
- chmod +x "$as_me.lineno" ||
- { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensitive to this).
- . "./$as_me.lineno"
- # Exit status is that of the last command.
- exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
- case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- xy) ECHO_C='\c';;
- *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
- ECHO_T=' ';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
- if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
- as_ln_s='cp -p'
- fi
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p='mkdir -p "$as_dir"'
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME='less'
-PACKAGE_TARNAME='less'
-PACKAGE_VERSION='1'
-PACKAGE_STRING='less 1'
-PACKAGE_BUGREPORT=''
-PACKAGE_URL=''
-
-ac_unique_file="forwback.c"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='LTLIBOBJS
-LIBOBJS
-REGEX_O
-INSTALL_DATA
-INSTALL_SCRIPT
-INSTALL_PROGRAM
-EGREP
-GREP
-CPP
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-enable_largefile
-with_secure
-with_no_float
-with_regex
-with_editor
-'
- ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS
-CPP'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-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=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
- *=) ac_optarg= ;;
- *) ac_optarg=yes ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_dashdash$ac_option in
- --)
- ac_dashdash=yes ;;
-
- -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_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$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 ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=*)
- datadir=$ac_optarg ;;
-
- -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
- | --dataroo | --dataro | --datar)
- ac_prev=datarootdir ;;
- -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
- | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
- datarootdir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"enable_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval enable_$ac_useropt=no ;;
-
- -docdir | --docdir | --docdi | --doc | --do)
- ac_prev=docdir ;;
- -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
- docdir=$ac_optarg ;;
-
- -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
- ac_prev=dvidir ;;
- -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
- dvidir=$ac_optarg ;;
-
- -enable-* | --enable-*)
- ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"enable_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval enable_$ac_useropt=\$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 | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
- ac_prev=htmldir ;;
- -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
- | --ht=*)
- htmldir=$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 ;;
-
- -localedir | --localedir | --localedi | --localed | --locale)
- ac_prev=localedir ;;
- -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
- localedir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst | --locals)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
- 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 | -n)
- 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 ;;
-
- -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
- ac_prev=pdfdir ;;
- -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
- pdfdir=$ac_optarg ;;
-
- -psdir | --psdir | --psdi | --psd | --ps)
- ac_prev=psdir ;;
- -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
- psdir=$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_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"with_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval with_$ac_useropt=\$ac_optarg ;;
-
- -without-* | --without-*)
- ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"with_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval with_$ac_useropt=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 ;;
-
- -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- case $ac_envvar in #(
- '' | [0-9]* | *[!_$as_cr_alnum]* )
- as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
- esac
- eval $ac_envvar=\$ac_optarg
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- as_fn_error $? "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
- case $enable_option_checking in
- no) ;;
- fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
- *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
- esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
- datadir sysconfdir sharedstatedir localstatedir includedir \
- oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
-do
- eval ac_val=\$$ac_var
- # Remove trailing slashes.
- case $ac_val in
- */ )
- ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
- eval $ac_var=\$ac_val;;
- esac
- # Be sure to have absolute directory names.
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) continue;;
- NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
- esac
- as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used" >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
- as_fn_error $? "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
- as_fn_error $? "pwd does not report name of working directory"
-
-
-# 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 the parent directory.
- ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_myself" : 'X\(//\)[^/]' \| \
- X"$as_myself" : 'X\(//\)$' \| \
- X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- 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
- test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
- as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
- pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
- srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
- eval ac_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_env_${ac_var}_value=\$${ac_var}
- eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # 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 <<_ACEOF
-\`configure' configures less 1 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking ...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
- --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
- --infodir=DIR info documentation [DATAROOTDIR/info]
- --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
- --mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/less]
- --htmldir=DIR html documentation [DOCDIR]
- --dvidir=DIR dvi documentation [DOCDIR]
- --pdfdir=DIR pdf documentation [DOCDIR]
- --psdir=DIR ps documentation [DOCDIR]
-_ACEOF
-
- cat <<\_ACEOF
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of less 1:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-option-checking ignore unrecognized --enable/--with options
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --disable-largefile omit support for large files
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-secure Compile in secure mode
- --with-no-float Do not use floating point
- --with-regex={auto,gnu,pcre,posix,regcmp,re_comp,regcomp,regcomp-local,none} Select a regular expression library auto
- --with-editor=PROGRAM use PROGRAM as the default editor vi
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- LIBS libraries to pass to the linker, e.g. -l<library>
- CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
- you have headers in a nonstandard directory <include dir>
- CPP C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to the package provider.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d "$ac_dir" ||
- { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
- continue
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
- cd "$ac_dir" || { ac_status=$?; continue; }
- # Check for guested configure.
- if test -f "$ac_srcdir/configure.gnu"; then
- echo &&
- $SHELL "$ac_srcdir/configure.gnu" --help=recursive
- elif test -f "$ac_srcdir/configure"; then
- echo &&
- $SHELL "$ac_srcdir/configure" --help=recursive
- else
- $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi || ac_status=$?
- cd "$ac_pwd" || { ac_status=$?; break; }
- done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
- cat <<\_ACEOF
-less configure 1
-generated by GNU Autoconf 2.68
-
-Copyright (C) 2010 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- rm -f conftest.$ac_objext
- if { { ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compile") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- rm -f conftest.$ac_objext conftest$ac_exeext
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext && {
- test "$cross_compiling" = yes ||
- $as_test_x conftest$ac_exeext
- }; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
- # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
- # interfere with the next link command; also delete a directory that is
- # left behind by Apple's compiler. We do this before executing the actions.
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } > conftest.i && {
- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
- test ! -s conftest.err
- }; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then :
- ac_retval=0
-else
- $as_echo "$as_me: program exited with status $ac_status" >&5
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=$ac_status
-fi
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if eval \${$3+:} false; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
- # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_header_compiler=yes
-else
- ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- ac_header_preproc=yes
-else
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
- yes:no: )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
- no:yes:* )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
-esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-
-# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
-# -------------------------------------------
-# Tests whether TYPE exists after having included INCLUDES, setting cache
-# variable VAR accordingly.
-ac_fn_c_check_type ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- eval "$3=no"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-int
-main ()
-{
-if (sizeof ($2))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-int
-main ()
-{
-if (sizeof (($2)))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
- eval "$3=yes"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_type
-
-# ac_fn_c_check_func LINENO FUNC VAR
-# ----------------------------------
-# Tests whether FUNC exists, setting the cache variable VAR accordingly
-ac_fn_c_check_func ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $2 innocuous_$2
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $2 (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $2
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $2 ();
-/* 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_$2 || defined __stub___$2
-choke me
-#endif
-
-int
-main ()
-{
-return $2 ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_func
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by less $as_me 1, which was
-generated by GNU Autoconf 2.68. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- $as_echo "PATH: $as_dir"
- done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *\'*)
- ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
- 2)
- as_fn_append ac_configure_args1 " '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- as_fn_append ac_configure_args " '$ac_arg'"
- ;;
- esac
- done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- $as_echo "## ---------------- ##
-## Cache variables. ##
-## ---------------- ##"
- echo
- # The following way of writing the cache mishandles newlines in values,
-(
- for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
- *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
- (set) 2>&1 |
- case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- sed -n \
- "s/'\''/'\''\\\\'\'''\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
- ;; #(
- *)
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-)
- echo
-
- $as_echo "## ----------------- ##
-## Output variables. ##
-## ----------------- ##"
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- $as_echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- $as_echo "## ------------------- ##
-## File substitutions. ##
-## ------------------- ##"
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- $as_echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- $as_echo "## ----------- ##
-## confdefs.h. ##
-## ----------- ##"
- echo
- cat confdefs.h
- echo
- fi
- test "$ac_signal" != 0 &&
- $as_echo "$as_me: caught signal $ac_signal"
- $as_echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core core.conftest.* &&
- rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
- # We do not want a PATH search for config.site.
- case $CONFIG_SITE in #((
- -*) ac_site_file1=./$CONFIG_SITE;;
- */*) ac_site_file1=$CONFIG_SITE;;
- *) ac_site_file1=./$CONFIG_SITE;;
- esac
-elif test "x$prefix" != xNONE; then
- ac_site_file1=$prefix/share/config.site
- ac_site_file2=$prefix/etc/config.site
-else
- ac_site_file1=$ac_default_prefix/share/config.site
- ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
- test "x$ac_site_file" = xNONE && continue
- if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file" \
- || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5 ; }
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special files
- # actually), so we avoid doing that. DJGPP emulates it as a regular file.
- if test /dev/null != "$cache_file" && test -f "$cache_file"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . "$cache_file";;
- *) . "./$cache_file";;
- esac
- fi
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val=\$ac_cv_env_${ac_var}_value
- eval ac_new_val=\$ac_env_${ac_var}_value
- case $ac_old_set,$ac_new_set in
- set,)
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- # differences in whitespace do not lead to failure.
- ac_old_val_w=`echo x $ac_old_val`
- ac_new_val_w=`echo x $ac_new_val`
- if test "$ac_old_val_w" != "$ac_new_val_w"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- ac_cache_corrupted=:
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
- eval $ac_var=\$ac_old_val
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
-$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
-$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) as_fn_append ac_configure_args " '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-ac_config_headers="$ac_config_headers defines.h"
-
-
-# Checks for programs.
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_ac_ct_CC="gcc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- fi
-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
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_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 $# != 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
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl.exe
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl.exe
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$ac_ct_CC" && break
-done
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5 ; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
- { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compiler $ac_option >&5") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- sed '10a\
-... rest of stderr output deleted ...
- 10q' conftest.err >conftest.er1
- cat conftest.er1 >&5
- fi
- rm -f conftest.er1 conftest.err
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
- * ) ac_rmfiles="$ac_rmfiles $ac_file";;
- esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link_default") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile. We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
- then :; else
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- fi
- # We set ac_cv_exeext here because the later test for it is not
- # safe: cross compilers may not add the suffix if given an `-o'
- # argument, so we may need to know it at that point already.
- # Even if this section looks crufty: it has the advantage of
- # actually working.
- break;;
- * )
- break;;
- esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
- ac_file=''
-fi
-if test -z "$ac_file"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5 ; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- break;;
- * ) break;;
- esac
-done
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5 ; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
- { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }
- if { ac_try='./conftest$ac_cv_exeext'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5 ; }
- fi
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compile") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- for ac_file in conftest.o conftest.obj conftest.*; do
- test -f "$ac_file" || continue;
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5 ; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_compiler_gnu=yes
-else
- ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
- GCC=yes
-else
- GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_save_c_werror_flag=$ac_c_werror_flag
- ac_c_werror_flag=yes
- ac_cv_prog_cc_g=no
- CFLAGS="-g"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
-else
- CFLAGS=""
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
- ac_c_werror_flag=$ac_save_c_werror_flag
- CFLAGS="-g"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
- inside strings and character constants. */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
- test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
- x)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
- xno)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
- *)
- CC="$CC $ac_cv_prog_cc_c89"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5
-$as_echo_n "checking for library containing strerror... " >&6; }
-if ${ac_cv_search_strerror+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char strerror ();
-int
-main ()
-{
-return strerror ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' cposix; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_strerror=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_strerror+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_strerror+:} false; then :
-
-else
- ac_cv_search_strerror=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5
-$as_echo "$ac_cv_search_strerror" >&6; }
-ac_res=$ac_cv_search_strerror
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if ${ac_cv_prog_CPP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
-continue
-else
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
-continue
-else
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5 ; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -z "$GREP"; then
- ac_path_GREP_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in grep ggrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
- # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
- ac_count=0
- $as_echo_n 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- $as_echo 'GREP' >> "conftest.nl"
- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_GREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_GREP="$ac_path_GREP"
- ac_path_GREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_GREP_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_GREP"; then
- as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
- fi
-else
- ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
- then ac_cv_path_EGREP="$GREP -E"
- else
- if test -z "$EGREP"; then
- ac_path_EGREP_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in egrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
- # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
- ac_count=0
- $as_echo_n 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- $as_echo 'EGREP' >> "conftest.nl"
- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_EGREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_EGREP="$ac_path_EGREP"
- ac_path_EGREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_EGREP_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_EGREP"; then
- as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
- fi
-else
- ac_cv_path_EGREP=$EGREP
-fi
-
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-if test $ac_cv_c_compiler_gnu = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
-$as_echo_n "checking whether $CC needs -traditional... " >&6; }
-if ${ac_cv_prog_gcc_traditional+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_pattern="Autoconf.*'x'"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sgtty.h>
-Autoconf TIOCGETP
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "$ac_pattern" >/dev/null 2>&1; then :
- ac_cv_prog_gcc_traditional=yes
-else
- ac_cv_prog_gcc_traditional=no
-fi
-rm -f conftest*
-
-
- if test $ac_cv_prog_gcc_traditional = no; then
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <termio.h>
-Autoconf TCGETA
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "$ac_pattern" >/dev/null 2>&1; then :
- ac_cv_prog_gcc_traditional=yes
-fi
-rm -f conftest*
-
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
-$as_echo "$ac_cv_prog_gcc_traditional" >&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
- elif test -f "$ac_dir/shtool"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-
-
-# 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
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if ${ac_cv_path_install+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
- ./ | .// | /[cC]/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- fi
- done
- done
- ;;
-esac
-
- done
-IFS=$as_save_IFS
-
-rm -rf conftest.one conftest.two conftest.dir
-
-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. Don't cache a
- # value for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
- INSTALL=$ac_install_sh
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&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_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-# Checks for compilation model.
-# Check whether --enable-largefile was given.
-if test "${enable_largefile+set}" = set; then :
- enableval=$enable_largefile;
-fi
-
-if test "$enable_largefile" != no; then
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
-$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if ${ac_cv_sys_largefile_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_sys_largefile_CC=no
- if test "$GCC" != yes; then
- ac_save_CC=$CC
- while :; do
- # IRIX 6.2 and later do not support large files by default,
- # so use the C compiler's -n32 option if that helps.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
- if ac_fn_c_try_compile "$LINENO"; then :
- break
-fi
-rm -f core conftest.err conftest.$ac_objext
- CC="$CC -n32"
- if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sys_largefile_CC=' -n32'; break
-fi
-rm -f core conftest.err conftest.$ac_objext
- break
- done
- CC=$ac_save_CC
- rm -f conftest.$ac_ext
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5
-$as_echo "$ac_cv_sys_largefile_CC" >&6; }
- if test "$ac_cv_sys_largefile_CC" != no; then
- CC=$CC$ac_cv_sys_largefile_CC
- fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
-$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if ${ac_cv_sys_file_offset_bits+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- while :; do
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sys_file_offset_bits=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sys_file_offset_bits=64; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_cv_sys_file_offset_bits=unknown
- break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5
-$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
-case $ac_cv_sys_file_offset_bits in #(
- no | unknown) ;;
- *)
-cat >>confdefs.h <<_ACEOF
-#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
-_ACEOF
-;;
-esac
-rm -rf conftest*
- if test $ac_cv_sys_file_offset_bits = unknown; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
-$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if ${ac_cv_sys_large_files+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- while :; do
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sys_large_files=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#define _LARGE_FILES 1
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sys_large_files=1; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_cv_sys_large_files=unknown
- break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5
-$as_echo "$ac_cv_sys_large_files" >&6; }
-case $ac_cv_sys_large_files in #(
- no | unknown) ;;
- *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGE_FILES $ac_cv_sys_large_files
-_ACEOF
-;;
-esac
-rm -rf conftest*
- fi
-fi
-
-
-# Checks for general libraries.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgoto in -ltinfo" >&5
-$as_echo_n "checking for tgoto in -ltinfo... " >&6; }
-if ${ac_cv_lib_tinfo_tgoto+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltinfo $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char tgoto ();
-int
-main ()
-{
-return tgoto ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_tinfo_tgoto=yes
-else
- ac_cv_lib_tinfo_tgoto=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgoto" >&5
-$as_echo "$ac_cv_lib_tinfo_tgoto" >&6; }
-if test "x$ac_cv_lib_tinfo_tgoto" = xyes; then :
- have_tinfo=yes
-else
- have_tinfo=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lxcurses" >&5
-$as_echo_n "checking for initscr in -lxcurses... " >&6; }
-if ${ac_cv_lib_xcurses_initscr+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lxcurses $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char initscr ();
-int
-main ()
-{
-return initscr ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_xcurses_initscr=yes
-else
- ac_cv_lib_xcurses_initscr=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xcurses_initscr" >&5
-$as_echo "$ac_cv_lib_xcurses_initscr" >&6; }
-if test "x$ac_cv_lib_xcurses_initscr" = xyes; then :
- have_xcurses=yes
-else
- have_xcurses=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncursesw" >&5
-$as_echo_n "checking for initscr in -lncursesw... " >&6; }
-if ${ac_cv_lib_ncursesw_initscr+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lncursesw $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char initscr ();
-int
-main ()
-{
-return initscr ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_ncursesw_initscr=yes
-else
- ac_cv_lib_ncursesw_initscr=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_initscr" >&5
-$as_echo "$ac_cv_lib_ncursesw_initscr" >&6; }
-if test "x$ac_cv_lib_ncursesw_initscr" = xyes; then :
- have_ncursesw=yes
-else
- have_ncursesw=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5
-$as_echo_n "checking for initscr in -lncurses... " >&6; }
-if ${ac_cv_lib_ncurses_initscr+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lncurses $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char initscr ();
-int
-main ()
-{
-return initscr ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_ncurses_initscr=yes
-else
- ac_cv_lib_ncurses_initscr=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5
-$as_echo "$ac_cv_lib_ncurses_initscr" >&6; }
-if test "x$ac_cv_lib_ncurses_initscr" = xyes; then :
- have_ncurses=yes
-else
- have_ncurses=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lcurses" >&5
-$as_echo_n "checking for initscr in -lcurses... " >&6; }
-if ${ac_cv_lib_curses_initscr+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcurses $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char initscr ();
-int
-main ()
-{
-return initscr ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_curses_initscr=yes
-else
- ac_cv_lib_curses_initscr=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_initscr" >&5
-$as_echo "$ac_cv_lib_curses_initscr" >&6; }
-if test "x$ac_cv_lib_curses_initscr" = xyes; then :
- have_curses=yes
-else
- have_curses=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5
-$as_echo_n "checking for tgetent in -ltermcap... " >&6; }
-if ${ac_cv_lib_termcap_tgetent+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltermcap $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char tgetent ();
-int
-main ()
-{
-return tgetent ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_termcap_tgetent=yes
-else
- ac_cv_lib_termcap_tgetent=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5
-$as_echo "$ac_cv_lib_termcap_tgetent" >&6; }
-if test "x$ac_cv_lib_termcap_tgetent" = xyes; then :
- have_termcap=yes
-else
- have_termcap=no
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermlib" >&5
-$as_echo_n "checking for tgetent in -ltermlib... " >&6; }
-if ${ac_cv_lib_termlib_tgetent+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltermlib $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char tgetent ();
-int
-main ()
-{
-return tgetent ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_termlib_tgetent=yes
-else
- ac_cv_lib_termlib_tgetent=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termlib_tgetent" >&5
-$as_echo "$ac_cv_lib_termlib_tgetent" >&6; }
-if test "x$ac_cv_lib_termlib_tgetent" = xyes; then :
- have_termlib=yes
-else
- have_termlib=no
-fi
-
-# Regular expressions (regcmp) are in -lgen on Solaris 2, (but in libc
-# at least on Solaris 10 (2.10)) and in -lintl on SCO Unix.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing regcmp" >&5
-$as_echo_n "checking for library containing regcmp... " >&6; }
-if ${ac_cv_search_regcmp+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char regcmp ();
-int
-main ()
-{
-return regcmp ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' gen intl PW; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_regcmp=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_regcmp+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_regcmp+:} false; then :
-
-else
- ac_cv_search_regcmp=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_regcmp" >&5
-$as_echo "$ac_cv_search_regcmp" >&6; }
-ac_res=$ac_cv_search_regcmp
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-
-# Checks for terminal libraries
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working terminal libraries" >&5
-$as_echo_n "checking for working terminal libraries... " >&6; }
-TERMLIBS=
-
-# 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
-if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
- curses_broken=1
-fi
-fi
-
-if test $curses_broken = 0; then
-
-# -- Try tinfo.
-if test "x$TERMLIBS" = x; then
- if test $have_tinfo = yes; then
- TERMLIBS="-ltinfo"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- Try xcurses.
-if test "x$TERMLIBS" = x; then
- if test $have_xcurses = yes; then
- TERMLIBS="-lxcurses"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- Try ncursesw.
-if test "x$TERMLIBS" = x; then
- if test $have_ncursesw = yes; then
- TERMLIBS="-lncursesw"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- Try ncurses.
-if test "x$TERMLIBS" = x; then
- if test $have_ncurses = yes; then
- TERMLIBS="-lncurses"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- Try curses.
-if test "x$TERMLIBS" = x; then
- if test $have_curses = yes; then
- TERMLIBS="-lcurses"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- 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"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
- fi
-fi
-fi
-
-# -- Try termcap.
-if test "x$TERMLIBS" = x; then
- if test $have_termcap = yes; then
- TERMLIBS="-ltermcap"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-# -- Try termlib.
-if test "x$TERMLIBS" = x; then
- if test $have_termlib = yes; then
- TERMLIBS="-lcurses -ltermlib"
- SAVE_LIBS=$LIBS
- LIBS="$LIBS $TERMLIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- termok=yes
-else
- termok=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$SAVE_LIBS
- if test $termok = no; then TERMLIBS=""; fi
- fi
-fi
-
-if test "x$TERMLIBS" = x; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: Cannot find terminal libraries - configure failed" >&5
-$as_echo "Cannot find terminal libraries - configure failed" >&6; }
- exit 1
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TERMLIBS" >&5
-$as_echo "using $TERMLIBS" >&6; }
-LIBS="$LIBS $TERMLIBS"
-
-# Checks for header files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#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))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-for ac_header 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 wctype.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-# Checks for typedefs, structures, and compiler characteristics.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5
-$as_echo_n "checking whether stat file-mode macros are broken... " >&6; }
-if ${ac_cv_header_stat_broken+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if defined S_ISBLK && defined S_IFDIR
-extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
-#endif
-
-#if defined S_ISBLK && defined S_IFCHR
-extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
-#endif
-
-#if defined S_ISLNK && defined S_IFREG
-extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
-#endif
-
-#if defined S_ISSOCK && defined S_IFREG
-extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
-#endif
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stat_broken=no
-else
- ac_cv_header_stat_broken=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5
-$as_echo "$ac_cv_header_stat_broken" >&6; }
-if test $ac_cv_header_stat_broken = yes; then
-
-$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
-$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
-if ${ac_cv_c_const+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-/* FIXME: Include the comments suggested by Paul. */
-#ifndef __cplusplus
- /* Ultrix mips cc rejects this. */
- typedef int charset[2];
- const charset cs;
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *pcpcc;
- char **ppc;
- /* NEC SVR4.0.2 mips cc rejects this. */
- struct point {int x, y;};
- static struct point const zero = {0,0};
- /* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in
- an arm of an if-expression whose if-part is not a constant
- expression */
- const char *g = "string";
- pcpcc = &g + (g ? g-g : 0);
- /* HPUX 7.0 cc rejects these. */
- ++pcpcc;
- ppc = (char**) pcpcc;
- pcpcc = (char const *const *) ppc;
- { /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
- if (s) return 0;
- }
- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
- }
- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
- }
- { /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
- if (!foo) return 0;
- }
- return !cs[0] && !zero.x;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_c_const=yes
-else
- ac_cv_c_const=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
-$as_echo "$ac_cv_c_const" >&6; }
-if test $ac_cv_c_const = no; then
-
-$as_echo "#define const /**/" >>confdefs.h
-
-fi
-
-ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
-if test "x$ac_cv_type_off_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define off_t long int
-_ACEOF
-
-fi
-
-ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
-if test "x$ac_cv_type_size_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define size_t unsigned int
-_ACEOF
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
-$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
-if ${ac_cv_header_time+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_time=yes
-else
- ac_cv_header_time=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
-$as_echo "$ac_cv_header_time" >&6; }
-if test $ac_cv_header_time = yes; then
-
-$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-
-
-# Autoheader templates for symbols defined later by AC_DEFINE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Checks for identifiers.
-ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
-if test "x$ac_cv_type_off_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define off_t long int
-_ACEOF
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for void" >&5
-$as_echo_n "checking for void... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-void *foo = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_VOID 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for const" >&5
-$as_echo_n "checking for const... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-const int foo = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_CONST 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for time_t" >&5
-$as_echo_n "checking for time_t... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <time.h>
-int
-main ()
-{
-time_t t = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_TIME_T 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_ino in struct stat" >&5
-$as_echo_n "checking for st_ino in struct stat... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/stat.h>
-int
-main ()
-{
-struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_STAT_INO 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-# Checks for library functions.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
-$as_echo_n "checking return type of signal handlers... " >&6; }
-if ${ac_cv_type_signal+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-
-int
-main ()
-{
-return *(signal (0, 0)) (0) == 1;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_type_signal=int
-else
- ac_cv_type_signal=void
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
-$as_echo "$ac_cv_type_signal" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define RETSIGTYPE $ac_cv_type_signal
-_ACEOF
-
-
-for ac_func in fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcpy" >&5
-$as_echo_n "checking for memcpy... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-int
-main ()
-{
-memcpy(0,0,0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_MEMCPY 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strchr" >&5
-$as_echo_n "checking for strchr... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-int
-main ()
-{
-strchr("x",'x');
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRCHR 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strstr" >&5
-$as_echo_n "checking for strstr... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-int
-main ()
-{
-strstr("x","x");
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRSTR 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-# Some systems have termios.h but not the corresponding functions.
-ac_fn_c_check_func "$LINENO" "tcgetattr" "ac_cv_func_tcgetattr"
-if test "x$ac_cv_func_tcgetattr" = xyes; then :
- $as_echo "#define HAVE_TERMIOS_FUNCS 1" >>confdefs.h
-
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fileno" >&5
-$as_echo_n "checking for fileno... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-int
-main ()
-{
-static int x; x = fileno(stdin);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_FILENO 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strerror" >&5
-$as_echo_n "checking for strerror... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end 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;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRERROR 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys_errlist" >&5
-$as_echo_n "checking for sys_errlist... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-extern char *sys_errlist[]; static char **x; x = sys_errlist;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-ac_fn_c_check_type "$LINENO" "sigset_t" "ac_cv_type_sigset_t" "#include <signal.h>
-"
-if test "x$ac_cv_type_sigset_t" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_SIGSET_T 1
-_ACEOF
-
-
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigemptyset" >&5
-$as_echo_n "checking for sigemptyset... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <signal.h>
-
-int
-main ()
-{
-sigset_t s; sigemptyset(&s);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_SIGEMPTYSET 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-have_errno=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for errno" >&5
-$as_echo_n "checking for errno... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
-int
-main ()
-{
-static int x; x = errno;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - in errno.h" >&5
-$as_echo "yes - in errno.h" >&6; }; $as_echo "#define HAVE_ERRNO 1" >>confdefs.h
- have_errno=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test $have_errno = no; then
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
-int
-main ()
-{
-extern int errno; static int x; x = errno;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - must define" >&5
-$as_echo "yes - must define" >&6; }; $as_echo "#define HAVE_ERRNO 1" >>confdefs.h
- $as_echo "#define MUST_DEFINE_ERRNO 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale" >&5
-$as_echo_n "checking for locale... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <locale.h>
-#include <ctype.h>
-#include <langinfo.h>
-int
-main ()
-{
-setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_LOCALE 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ctype functions" >&5
-$as_echo_n "checking for ctype functions... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end 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;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_UPPER_LOWER 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype functions" >&5
-$as_echo_n "checking for wctype functions... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <wctype.h>
-int
-main ()
-{
-iswlower(0); iswupper(0); towlower(0); towupper(0);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_WCTYPE 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-# Checks for external variable ospeed in the termcap library.
-have_ospeed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking termcap for ospeed" >&5
-$as_echo_n "checking termcap for ospeed... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end 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;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - in termcap.h" >&5
-$as_echo "yes - in termcap.h" >&6; }; $as_echo "#define HAVE_OSPEED 1" >>confdefs.h
- have_ospeed=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test $have_ospeed = no; then
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-extern short ospeed; ospeed = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - must define" >&5
-$as_echo "yes - must define" >&6; }; $as_echo "#define HAVE_OSPEED 1" >>confdefs.h
- $as_echo "#define MUST_DEFINE_OSPEED 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-
-# Compile in secure mode?
-
-# Check whether --with-secure was given.
-if test "${with_secure+set}" = set; then :
- withval=$with_secure; $as_echo "#define SECURE_COMPILE 1" >>confdefs.h
-
-else
- $as_echo "#define SECURE_COMPILE 0" >>confdefs.h
-
-fi
-
-
-# Should we use floating point?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for floating point" >&5
-$as_echo_n "checking for floating point... " >&6; }
-
-# Check whether --with-no-float was given.
-if test "${with_no_float+set}" = set; then :
- withval=$with_no_float; WANT_NO_FLOAT=1
-else
- WANT_NO_FLOAT=0
-fi
-
-if test $WANT_NO_FLOAT = 0; then
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-double f1 = 12.5; double f2 = f1*f1/2.5;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled by user" >&5
-$as_echo "disabled by user" >&6; }
-fi
-
-# Checks for regular expression functions.
-have_regex=no
-have_posix_regex=unknown
-supported_regex=""
-
-# Select a regular expression library.
-WANT_REGEX=auto
-
-# Check whether --with-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
-# Some versions of Solaris have a regcomp() function, but it doesn't work!
-# So we run a test program. If we're cross-compiling, do it the old way.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for POSIX regcomp" >&5
-$as_echo_n "checking for POSIX regcomp... " >&6; }
-if test "$cross_compiling" = yes; then :
- have_posix_regex=unknown
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end 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); }
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- have_posix_regex=yes
-else
- have_posix_regex=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-if test $have_posix_regex = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- $as_echo "#define HAVE_POSIX_REGCOMP 1" >>confdefs.h
- supported_regex="$supported_regex posix"
- have_regex=yes
-elif test $have_posix_regex = unknown; then
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <sys/types.h>
-#include <regex.h>
-int
-main ()
-{
-regex_t *r; regfree(r);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- $as_echo "#define HAVE_POSIX_REGCOMP 1" >>confdefs.h
- have_regex=yes; supported_regex="$supported_regex posix"
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-fi
-fi
-
-if test $have_regex = no; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
-$as_echo_n "checking for pcre_compile in -lpcre... " >&6; }
-if ${ac_cv_lib_pcre_pcre_compile+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpcre $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pcre_compile ();
-int
-main ()
-{
-return pcre_compile ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_pcre_pcre_compile=yes
-else
- ac_cv_lib_pcre_pcre_compile=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5
-$as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; }
-if test "x$ac_cv_lib_pcre_pcre_compile" = xyes; then :
- $as_echo "#define HAVE_PCRE 1" >>confdefs.h
- LIBS="$LIBS -lpcre" have_regex=yes; supported_regex="$supported_regex pcre"
-fi
-
-fi
-fi
-
-if test $have_regex = no; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = gnu; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for re_compile_pattern in -lc" >&5
-$as_echo_n "checking for re_compile_pattern in -lc... " >&6; }
-if ${ac_cv_lib_c_re_compile_pattern+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char re_compile_pattern ();
-int
-main ()
-{
-return re_compile_pattern ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_c_re_compile_pattern=yes
-else
- ac_cv_lib_c_re_compile_pattern=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_re_compile_pattern" >&5
-$as_echo "$ac_cv_lib_c_re_compile_pattern" >&6; }
-if test "x$ac_cv_lib_c_re_compile_pattern" = xyes; then :
- $as_echo "#define HAVE_GNU_REGEX 1" >>confdefs.h
- have_regex=yes; supported_regex="$supported_regex gnu"
-fi
-
-fi
-fi
-
-if test $have_regex = no; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
-ac_fn_c_check_func "$LINENO" "regcmp" "ac_cv_func_regcmp"
-if test "x$ac_cv_func_regcmp" = xyes; then :
- $as_echo "#define HAVE_REGCMP 1" >>confdefs.h
- have_regex=yes; supported_regex="$supported_regex regcmp"
-fi
-
-fi
-fi
-
-if test $have_regex = no; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for V8 regcomp" >&5
-$as_echo_n "checking for V8 regcomp... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include "regexp.h"
-int
-main ()
-{
-regcomp("");
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_V8_REGCOMP 1" >>confdefs.h
- have_regex=yes; supported_regex="$supported_regex regcomp"
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-fi
-
-if test $have_regex = no && test -f ${srcdir}/regexp.c; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using V8 regcomp -- local source" >&5
-$as_echo "using V8 regcomp -- local source" >&6; }; $as_echo "#define HAVE_V8_REGCOMP 1" >>confdefs.h
-
-supported_regex="$supported_regex regcomp-local"
-$as_echo "#define HAVE_REGEXEC2 1" >>confdefs.h
- 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
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for re_comp" >&5
-$as_echo_n "checking for re_comp... " >&6; }
-ac_fn_c_check_func "$LINENO" "re_comp" "ac_cv_func_re_comp"
-if test "x$ac_cv_func_re_comp" = xyes; then :
- $as_echo "#define HAVE_RE_COMP 1" >>confdefs.h
- have_regex=yes; supported_regex="$supported_regex re_comp"
-fi
-
-fi
-fi
-
-if test $have_regex = no; then
-if test $WANT_REGEX = auto -o $WANT_REGEX = none; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using no regex" >&5
-$as_echo "using no regex" >&6; }
-else
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find regular expression library" >&5
-$as_echo "$as_me: WARNING: cannot find regular expression library" >&2;}
-fi
-$as_echo "#define NO_REGEX 1" >>confdefs.h
- supported_regex="$supported_regex none"
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: regular expression library: $supported_regex" >&5
-$as_echo "regular expression library: $supported_regex" >&6; }
-
-
-# Check whether --with-editor was given.
-if test "${with_editor+set}" = set; then :
- withval=$with_editor; cat >>confdefs.h <<_ACEOF
-#define EDIT_PGM "$withval"
-_ACEOF
-
-else
- $as_echo "#define EDIT_PGM \"vi\"" >>confdefs.h
-
-fi
-
-
-
-
-ac_config_files="$ac_config_files Makefile"
-
-cat >confcache <<\_ACEOF
-# 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, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# 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.
-(
- for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
- *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
-
- (set) 2>&1 |
- case $as_nl`(ac_space=' '; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- # `set' does not quote correctly, so add quotes: double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \.
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;; #(
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-) |
- sed '
- /^ac_cv_env_/b end
- t clear
- :clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
- if test -w "$cache_file"; then
- if test "x$cache_file" != "x/dev/null"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
- if test ! -f "$cache_file" || test -h "$cache_file"; then
- cat confcache >"$cache_file"
- else
- case $cache_file in #(
- */* | ?:*)
- mv -f confcache "$cache_file"$$ &&
- mv -f "$cache_file"$$ "$cache_file" ;; #(
- *)
- mv -f confcache "$cache_file" ;;
- esac
- fi
- fi
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-U=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
- ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
- # will be set to the directory where LIBOBJS objects are built.
- as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
- as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
- && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='print -r --'
- as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
-else
- if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
- as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
- as_echo_n='/usr/ucb/echo -n'
- else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
- case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
- esac;
- expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
- '
- export as_echo_n_body
- as_echo_n='sh -c $as_echo_n_body as_echo'
- fi
- export as_echo_body
- as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- PATH_SEPARATOR=:
- (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
- (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
- PATH_SEPARATOR=';'
- }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there. '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
- && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
- as_status=$1; test $as_status -eq 0 && as_status=1
- if test "$4"; then
- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
- fi
- $as_echo "$as_me: error: $2" >&2
- as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
- return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
- set +e
- as_fn_set_status $1
- exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
- { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
- eval 'as_fn_append ()
- {
- eval $1+=\$2
- }'
-else
- as_fn_append ()
- {
- eval $1=\$$1\$2
- }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
- eval 'as_fn_arith ()
- {
- as_val=$(( $* ))
- }'
-else
- as_fn_arith ()
- {
- as_val=`expr "$@" || test $? -eq 1`
- }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
- case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- xy) ECHO_C='\c';;
- *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
- ECHO_T=' ';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
- if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
- as_ln_s='cp -p'
- fi
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
- case $as_dir in #(
- -*) as_dir=./$as_dir;;
- esac
- test -d "$as_dir" || eval $as_mkdir_p || {
- as_dirs=
- while :; do
- case $as_dir in #(
- *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
- *) as_qdir=$as_dir;;
- esac
- as_dirs="'$as_qdir' $as_dirs"
- as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- test -d "$as_dir" && break
- done
- test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p='mkdir -p "$as_dir"'
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by less $as_me 1, which was
-generated by GNU Autoconf 2.68. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration. Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
- -h, --help print this help, then exit
- -V, --version print version number and configuration settings, then exit
- --config print configuration, then exit
- -q, --quiet, --silent
- do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to the package provider."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-less config.status 1
-configured by $0, generated by GNU Autoconf 2.68,
- with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2010 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=?*)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- --*=)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=
- ac_shift=:
- ;;
- *)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- esac
-
- case $ac_option in
- # Handling of the options.
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
- $as_echo "$ac_cs_version"; exit ;;
- --config | --confi | --conf | --con | --co | --c )
- $as_echo "$ac_cs_config"; exit ;;
- --debug | --debu | --deb | --de | --d | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
- '') as_fn_error $? "missing file argument" ;;
- esac
- as_fn_append CONFIG_FILES " '$ac_optarg'"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- as_fn_append CONFIG_HEADERS " '$ac_optarg'"
- ac_need_defaults=false;;
- --he | --h)
- # Conflict between --help and --header
- as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
- --help | --hel | -h )
- $as_echo "$ac_cs_usage"; exit ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
- *) as_fn_append ac_config_targets " $1"
- ac_need_defaults=false ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
- shift
- \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
- CONFIG_SHELL='$SHELL'
- export CONFIG_SHELL
- exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
- $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
- case $ac_config_target in
- "defines.h") CONFIG_HEADERS="$CONFIG_HEADERS defines.h" ;;
- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-
- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
- esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
- tmp= ac_tmp=
- trap 'exit_status=$?
- : "${ac_tmp:=$tmp}"
- { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
- trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
- test -d "$tmp"
-} ||
-{
- tmp=./conf$$-$RANDOM
- (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
- eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
- ac_cs_awk_cr='\\r'
-else
- ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
- echo "cat >conf$$subs.awk <<_ACEOF" &&
- echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
- echo "_ACEOF"
-} >conf$$subs.sh ||
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
- . ./conf$$subs.sh ||
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
- ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
- if test $ac_delim_n = $ac_delim_num; then
- break
- elif $ac_last_try; then
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
- N
- s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
- for (key in S) S_is_set[key] = 1
- FS = ""
-
-}
-{
- line = $ 0
- nfields = split(line, field, "@")
- substed = 0
- len = length(field[1])
- for (i = 2; i < nfields; i++) {
- key = field[i]
- keylen = length(key)
- if (S_is_set[key]) {
- value = S[key]
- line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
- len += length(value) + length(field[++i])
- substed = 1
- } else
- len += 1 + keylen
- }
-
- print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
- sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
- cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
- || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
-h
-s///
-s/^/:/
-s/[ ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[ ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[ ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
- ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
- if test -z "$ac_tt"; then
- break
- elif $ac_last_try; then
- as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any. Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[ ]*#[ ]*define[ ][ ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- for (key in D) D_is_set[key] = 1
- FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
- line = \$ 0
- split(line, arg, " ")
- if (arg[1] == "#") {
- defundef = arg[2]
- mac1 = arg[3]
- } else {
- defundef = substr(arg[1], 2)
- mac1 = arg[2]
- }
- split(mac1, mac2, "(") #)
- macro = mac2[1]
- prefix = substr(line, 1, index(line, defundef) - 1)
- if (D_is_set[macro]) {
- # Preserve the white space surrounding the "#".
- print prefix "define", macro P[macro] D[macro]
- next
- } else {
- # Replace #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.
- if (defundef == "undef") {
- print "/*", prefix defundef, macro, "*/"
- next
- }
- }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
- as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
-shift
-for ac_tag
-do
- case $ac_tag in
- :[FHLC]) ac_mode=$ac_tag; continue;;
- esac
- case $ac_mode$ac_tag in
- :[FHL]*:*);;
- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
- :[FH]-) ac_tag=-:-;;
- :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
- esac
- ac_save_IFS=$IFS
- IFS=:
- set x $ac_tag
- IFS=$ac_save_IFS
- shift
- ac_file=$1
- shift
-
- case $ac_mode in
- :L) ac_source=$1;;
- :[FH])
- ac_file_inputs=
- for ac_f
- do
- case $ac_f in
- -) ac_f="$ac_tmp/stdin";;
- *) # Look for the file first in the build tree, then in the source tree
- # (if the path is not absolute). The absolute path cannot be DOS-style,
- # because $ac_f cannot contain `:'.
- test -f "$ac_f" ||
- case $ac_f in
- [\\/$]*) false;;
- *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
- esac ||
- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
- esac
- case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
- as_fn_append ac_file_inputs " '$ac_f'"
- done
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- configure_input='Generated from '`
- $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
- `' by configure.'
- if test x"$ac_file" != x-; then
- configure_input="$ac_file. $configure_input"
- { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
- fi
- # Neutralize special characters interpreted by sed in replacement strings.
- case $configure_input in #(
- *\&* | *\|* | *\\* )
- ac_sed_conf_input=`$as_echo "$configure_input" |
- sed 's/[\\\\&|]/\\\\&/g'`;; #(
- *) ac_sed_conf_input=$configure_input;;
- esac
-
- case $ac_tag in
- *:-:* | *:-) cat >"$ac_tmp/stdin" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
- esac
- ;;
- esac
-
- ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- as_dir="$ac_dir"; as_fn_mkdir_p
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
- case $ac_mode in
- :F)
- #
- # CONFIG_FILE
- #
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
- esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
- p
- q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- ac_datarootdir_hack='
- s&@datadir@&$datadir&g
- s&@docdir@&$docdir&g
- s&@infodir@&$infodir&g
- s&@localedir@&$localedir&g
- s&@mandir@&$mandir&g
- s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
- >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
- { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
- "$ac_tmp/out"`; test -z "$ac_out"; } &&
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined" >&2;}
-
- rm -f "$ac_tmp/stdin"
- case $ac_file in
- -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
- *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
- esac \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
- :H)
- #
- # CONFIG_HEADER
- #
- if test x"$ac_file" != x-; then
- {
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
- } >"$ac_tmp/config.h" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
- else
- rm -f "$ac_file"
- mv "$ac_tmp/config.h" "$ac_file" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- fi
- else
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
- || as_fn_error $? "could not create -" "$LINENO" 5
- fi
- ;;
-
-
- esac
-
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
- as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
diff --git a/usr.bin/less/configure.ac b/usr.bin/less/configure.ac
deleted file mode 100644
index d9e6ccab6ec..00000000000
--- a/usr.bin/less/configure.ac
+++ /dev/null
@@ -1,563 +0,0 @@
-# Process this file with autoconf to produce a configure script.
-
-# Copyright (C) 1984-2002 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.
-
-# Autoconf initialization.
-AC_INIT(less, 1)
-AC_CONFIG_SRCDIR([forwback.c])
-AC_CONFIG_HEADER([defines.h])
-
-# Checks for programs.
-AC_PROG_CC
-AC_ISC_POSIX
-AC_PROG_GCC_TRADITIONAL
-AC_PROG_INSTALL
-
-# Checks for compilation model.
-AC_SYS_LARGEFILE
-
-# Checks for general 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])
-# Regular expressions (regcmp) are in -lgen on Solaris 2,
-# and in -lintl on SCO Unix.
-AC_CHECK_LIB(gen, regcmp)
-AC_CHECK_LIB(intl, regcmp)
-AC_CHECK_LIB(PW, regcmp)
-
-# Checks for terminal libraries
-AC_MSG_CHECKING([for working terminal libraries])
-TERMLIBS=
-
-# 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
-if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
- curses_broken=1
-fi
-fi
-
-if test $curses_broken = 0; then
-# -- 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
-
-# -- 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
-
-# -- 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
-
-# -- 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
-
-# -- 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
-
-# -- 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"
-
-# Checks for header files.
-AC_HEADER_STDC
-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])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_HEADER_STAT
-AC_C_CONST
-AC_TYPE_OFF_T
-AC_TYPE_SIZE_T
-AC_HEADER_TIME
-
-# Autoheader templates for symbols defined later by AC_DEFINE.
-AH_TEMPLATE([HAVE_POSIX_REGCOMP],
- [POSIX regcomp() and regex.h])
-AH_TEMPLATE([HAVE_PCRE],
- [PCRE (Perl-compatible regular expression) library])
-AH_TEMPLATE([HAVE_RE_COMP],
- [BSD re_comp()])
-AH_TEMPLATE([HAVE_REGCMP],
- [System V regcmp()])
-AH_TEMPLATE([HAVE_V8_REGCOMP],
- [Henry Spencer V8 regcomp() and regexp.h])
-AH_TEMPLATE([NO_REGEX],
- [pattern matching is supported, but without metacharacters.])
-AH_TEMPLATE([HAVE_REGEXEC2],
- [])
-AH_TEMPLATE([HAVE_VOID],
- [Define HAVE_VOID if your compiler supports the "void" type.])
-AH_TEMPLATE([HAVE_CONST],
- [Define HAVE_CONST if your compiler supports the "const" modifier.])
-AH_TEMPLATE([HAVE_TIME_T],
- [Define HAVE_TIME_T if your system supports the "time_t" type.])
-AH_TEMPLATE([HAVE_STRERROR],
- [Define HAVE_STRERROR if you have the strerror() function.])
-AH_TEMPLATE([HAVE_FILENO],
- [Define HAVE_FILENO if you have the fileno() macro.])
-AH_TEMPLATE([HAVE_ERRNO],
- [Define HAVE_ERRNO if you have the errno variable.])
-AH_TEMPLATE([MUST_DEFINE_ERRNO],
- [Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
-AH_TEMPLATE([HAVE_SYS_ERRLIST],
- [Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
-AH_TEMPLATE([HAVE_OSPEED],
- [Define HAVE_OSPEED if your termcap library has the ospeed variable.])
-AH_TEMPLATE([MUST_DEFINE_OSPEED],
- [Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
-AH_TEMPLATE([HAVE_LOCALE],
- [Define HAVE_LOCALE if you have locale.h and setlocale.])
-AH_TEMPLATE([HAVE_TERMIOS_FUNCS],
- [Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
-AH_TEMPLATE([HAVE_UPPER_LOWER],
- [Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
-AH_TEMPLATE([HAVE_SIGSET_T],
- [Define HAVE_SIGSET_T you have the sigset_t type.])
-AH_TEMPLATE([HAVE_SIGEMPTYSET],
- [Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
-AH_TEMPLATE([EDIT_PGM],
- [Define EDIT_PGM to your editor.])
-
-# 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)])
-
-# Checks for library functions.
-AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system])
-
-# 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)])
-
-AC_MSG_CHECKING(for sigset_t)
-AC_TRY_LINK([
-#include <signal.h>
-], [sigset_t s; s = 0;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
-
-AC_MSG_CHECKING(for sigemptyset)
-AC_TRY_LINK([
-#include <signal.h>
-], [sigset_t s; sigemptyset(&s);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [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)])
-
-# 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
-
-# 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
-# Some versions of Solaris have a regcomp() function, but it doesn't work!
-# 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_DEFINE(EDIT_PGM, "vi"))
-
-AH_TOP([
-/* 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 */
-#define TABSTOP_MAX 32 /* Max number of custom tab stops */
-
-/* Settings automatically determined by configure. */
-])
-
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
diff --git a/usr.bin/less/cvt.c b/usr.bin/less/cvt.c
index d7809917d97..ce22032fe0b 100644
--- a/usr.bin/less/cvt.c
+++ b/usr.bin/less/cvt.c
@@ -6,6 +6,10 @@
*
* For more information, see the README file.
*/
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to convert text in various ways. Used by search.
@@ -19,14 +23,12 @@ extern int utf_mode;
/*
* Get the length of a buffer needed to convert a string.
*/
- public int
-cvt_length(len, ops)
- int len;
- int ops;
+int
+cvt_length(int len)
{
if (utf_mode)
/*
- * Just copying a string in UTF-8 mode can cause it to grow
+ * Just copying a string in UTF-8 mode can cause it to grow
* in length.
* Four output bytes for one input byte is the worst case.
*/
@@ -37,12 +39,11 @@ cvt_length(len, ops)
/*
* Allocate a chpos array for use by cvt_text.
*/
- public int *
-cvt_alloc_chpos(len)
- int len;
+int *
+cvt_alloc_chpos(int len)
{
int i;
- int *chpos = (int *) ecalloc(sizeof(int), len);
+ int *chpos = ecalloc(sizeof (int), len);
/* Initialize all entries to an invalid position. */
for (i = 0; i < len; i++)
chpos[i] = -1;
@@ -54,18 +55,13 @@ cvt_alloc_chpos(len)
* Returns converted text in odst. The original offset of each
* odst character (when it was in osrc) is returned in the chpos array.
*/
- public void
-cvt_text(odst, osrc, chpos, lenp, ops)
- char *odst;
- char *osrc;
- int *chpos;
- int *lenp;
- int ops;
+void
+cvt_text(char *odst, char *osrc, int *chpos, int *lenp, int ops)
{
char *dst;
char *edst = odst;
char *src;
- register char *src_end;
+ char *src_end;
LWCHAR ch;
if (lenp != NULL)
@@ -73,35 +69,27 @@ cvt_text(odst, osrc, chpos, lenp, ops)
else
src_end = osrc + strlen(osrc);
- for (src = osrc, dst = odst; src < src_end; )
- {
+ for (src = osrc, dst = odst; src < src_end; ) {
int src_pos = src - osrc;
int dst_pos = dst - odst;
ch = step_char(&src, +1, src_end);
- if ((ops & CVT_BS) && ch == '\b' && dst > odst)
- {
+ if ((ops & CVT_BS) && ch == '\b' && dst > odst) {
/* Delete backspace and preceding char. */
do {
dst--;
} while (dst > odst &&
- !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst));
- } else if ((ops & CVT_ANSI) && IS_CSI_START(ch))
- {
+ !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst));
+ } else if ((ops & CVT_ANSI) && IS_CSI_START(ch)) {
/* Skip to end of ANSI escape sequence. */
src++; /* skip the CSI start char */
while (src < src_end)
if (!is_ansi_middle(*src++))
break;
- } else
- {
+ } else {
/* Just copy the char to the destination buffer. */
if ((ops & CVT_TO_LC) && IS_UPPER(ch))
ch = TO_LOWER(ch);
-#if !SMALL
put_wchar(&dst, ch);
-#else
- *dst++ = (char)ch;
-#endif /* !SMALL */
/* Record the original position of the char. */
if (chpos != NULL)
chpos[dst_pos] = src_pos;
@@ -114,5 +102,4 @@ cvt_text(odst, osrc, chpos, lenp, ops)
*edst = '\0';
if (lenp != NULL)
*lenp = edst - odst;
- /* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */
}
diff --git a/usr.bin/less/decode.c b/usr.bin/less/decode.c
index 6d0312d8890..7f61d8c8b00 100644
--- a/usr.bin/less/decode.c
+++ b/usr.bin/less/decode.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to decode user commands.
@@ -34,9 +37,9 @@
#include "lesskey.h"
extern int erase_char, erase2_char, kill_char;
-extern int secure;
+extern int secure, less_is_more;
-#define SK(k) \
+#define SK(k) \
SK_SPECIAL_KEY, (k), 6, 1, 1, 1
/*
* Command table is ordered roughly according to expected
@@ -45,164 +48,171 @@ extern int secure;
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,
- ESC,'F',0, A_F_UNTIL_HILITE,
- '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_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,
- '&',0, A_FILTER,
- '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,
- 't',0, A_NEXT_TAG,
- 'T',0, A_PREV_TAG,
- ':','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
+ '\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,
+ ESC, 'F', 0, A_F_UNTIL_HILITE,
+ '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_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,
+ '&', 0, A_FILTER,
+ '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,
+ 't', 0, A_NEXT_TAG,
+ 'T', 0, A_PREV_TAG,
+ ':', 'x', 0, A_INDEX_FILE,
+ ':', 'd', 0, A_REMOVE_FILE,
+ ':', 't', 0, A_OPT_TOGGLE|A_EXTRA, 't', 0,
+ '|', 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 lesstable[] = {
+ '-', 0, A_OPT_TOGGLE,
+ 's', 0, A_OPT_TOGGLE|A_EXTRA, 'o', 0,
+ '_', 0, A_DISP_OPTION
+};
+
+static unsigned char moretable[] = {
+ 's', 0, A_F_SKIP
};
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 */
- CONTROL('G'),0, EC_ABORT, /* CTRL-G */
+ '\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 */
+ CONTROL('G'), 0, EC_ABORT, /* CTRL-G */
};
/*
@@ -227,27 +237,22 @@ 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;
+static void
+expand_special_keys(char *table, int len)
{
- register char *fm;
- register char *to;
- register int a;
+ char *fm;
+ char *to;
+ int a;
char *repl;
int klen;
- for (fm = table; fm < table + len; )
- {
+ 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)
- {
+ for (to = fm; *fm != '\0'; ) {
+ if (*fm != SK_SPECIAL_KEY) {
*to++ = *fm++;
continue;
}
@@ -263,22 +268,21 @@ expand_special_keys(table, len)
repl = special_key_str(fm[1]);
klen = fm[2] & 0377;
fm += klen;
- if (repl == NULL || (int) strlen(repl) > 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
+ * 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)
- {
+ if (a & A_EXTRA) {
while (*fm++ != '\0')
continue;
}
@@ -288,22 +292,21 @@ expand_special_keys(table, len)
/*
* Initialize the command lists.
*/
- public void
-init_cmds()
+void
+init_cmds(void)
{
/*
* Add the default command tables.
*/
- add_fcmd_table((char*)cmdtable, sizeof(cmdtable));
- add_ecmd_table((char*)edittable, sizeof(edittable));
-#if USERFILE
- /*
- * For backwards compatibility,
- * try to add tables in the OLD system lesskey file.
- */
-#ifdef BINDIR
- add_hometable(NULL, BINDIR "/.sysless", 1);
-#endif
+ add_fcmd_table((char *)cmdtable, sizeof (cmdtable));
+ add_ecmd_table((char *)edittable, sizeof (edittable));
+ if (less_is_more) {
+ add_fcmd_table((char *)moretable, sizeof (moretable));
+ return;
+ } else {
+ add_fcmd_table((char *)lesstable, sizeof (lesstable));
+ }
+
/*
* Try to add the tables in the system lesskey file.
*/
@@ -312,29 +315,23 @@ init_cmds()
* 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;
+static int
+add_cmd_table(struct tablelist **tlist, char *buf, int len)
{
- register struct tablelist *t;
+ struct tablelist *t;
if (len == 0)
return (0);
/*
- * Allocate a tablelist structure, initialize it,
+ * Allocate a tablelist structure, initialize it,
* and link it into the list of tables.
*/
- if ((t = (struct tablelist *)
- calloc(1, sizeof(struct tablelist))) == NULL)
- {
+ if ((t = calloc(1, sizeof (struct tablelist))) == NULL) {
return (-1);
}
expand_special_keys(buf, len);
@@ -348,10 +345,8 @@ add_cmd_table(tlist, buf, len)
/*
* Add a command table.
*/
- public void
-add_fcmd_table(buf, len)
- char *buf;
- int len;
+void
+add_fcmd_table(char *buf, int len)
{
if (add_cmd_table(&list_fcmd_tables, buf, len) < 0)
error("Warning: some commands disabled", NULL_PARG);
@@ -360,10 +355,8 @@ add_fcmd_table(buf, len)
/*
* Add an editing command table.
*/
- public void
-add_ecmd_table(buf, len)
- char *buf;
- int len;
+void
+add_ecmd_table(char *buf, int len)
{
if (add_cmd_table(&list_ecmd_tables, buf, len) < 0)
error("Warning: some edit commands disabled", NULL_PARG);
@@ -372,35 +365,27 @@ add_ecmd_table(buf, len)
/*
* Add an environment variable table.
*/
- static void
-add_var_table(tlist, buf, len)
- struct tablelist **tlist;
- char *buf;
- int len;
+static void
+add_var_table(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);
+ error("Warning: environment variables from "
+ "lesskey file unavailable", NULL_PARG);
}
/*
* Search a single command table for the command string in cmd.
*/
- static int
-cmd_search(cmd, table, endtable, sp)
- char *cmd;
- char *table;
- char *endtable;
- char **sp;
+static int
+cmd_search(const char *cmd, char *table, char *endtable, char **sp)
{
- register char *p;
- register char *q;
- register int a;
+ char *p;
+ const char *q;
+ int a;
*sp = NULL;
- for (p = table, q = cmd; p < endtable; p++, q++)
- {
- if (*p == *q)
- {
+ 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.
@@ -408,13 +393,11 @@ cmd_search(cmd, table, endtable, sp)
* after the null at the end of the string
* in the command table.
*/
- if (*p == '\0')
- {
+ if (*p == '\0') {
a = *++p & 0377;
while (a == A_SKIP)
a = *++p & 0377;
- if (a == A_END_LIST)
- {
+ if (a == A_END_LIST) {
/*
* We get here only if the original
* cmd string passed in was empty ("").
@@ -426,33 +409,29 @@ cmd_search(cmd, table, endtable, sp)
/*
* Check for an "extra" string.
*/
- if (a & A_EXTRA)
- {
+ if (a & A_EXTRA) {
*sp = ++p;
a &= ~A_EXTRA;
}
return (a);
}
- } else if (*q == '\0')
- {
+ } 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
- {
+ } 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)
- {
+ if (*p == '\0' && p[1] == A_END_LIST) {
/*
- * A_END_LIST is a special marker that tells
+ * A_END_LIST is a special marker that tells
* us to abort the cmd search.
*/
return (A_UINVALID);
@@ -477,21 +456,17 @@ cmd_search(cmd, table, endtable, sp)
* 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;
+static int
+cmd_decode(struct tablelist *tlist, const char *cmd, char **sp)
{
- register struct tablelist *t;
- register int action = A_INVALID;
+ struct tablelist *t;
+ 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)
- {
+ 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;
@@ -504,10 +479,8 @@ cmd_decode(tlist, cmd, sp)
/*
* Decode a command from the cmdtables list.
*/
- public int
-fcmd_decode(cmd, sp)
- char *cmd;
- char **sp;
+int
+fcmd_decode(const char *cmd, char **sp)
{
return (cmd_decode(list_fcmd_tables, cmd, sp));
}
@@ -515,10 +488,8 @@ fcmd_decode(cmd, sp)
/*
* Decode a command from the edittables list.
*/
- public int
-ecmd_decode(cmd, sp)
- char *cmd;
- char **sp;
+int
+ecmd_decode(const char *cmd, char **sp)
{
return (cmd_decode(list_ecmd_tables, cmd, sp));
}
@@ -527,13 +498,22 @@ ecmd_decode(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;
+char *
+lgetenv(char *var)
{
int a;
char *s;
+ /*
+ * Ignore lookups of any LESS* setting when we are more, and ignore
+ * the less key files
+ */
+ if (less_is_more) {
+ if (strncmp(var, "LESS", 4) == 0) {
+ return (NULL);
+ }
+ return (getenv(var));
+ }
a = cmd_decode(list_var_tables, var, &s);
if (a == EV_OK)
return (s);
@@ -546,15 +526,13 @@ lgetenv(var)
return (NULL);
}
-#if USERFILE
/*
* Get an "integer" from a lesskey file.
- * Integers are stored in a funny format:
+ * Integers are stored in a funny format:
* two bytes, low order first, in radix KRADIX.
*/
- static int
-gint(sp)
- char **sp;
+static int
+gint(char **sp)
{
int n;
@@ -566,16 +544,14 @@ gint(sp)
/*
* Process an old (pre-v241) lesskey file.
*/
- static int
-old_lesskey(buf, len)
- char *buf;
- int len;
+static int
+old_lesskey(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
+ * 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')
@@ -584,18 +560,15 @@ old_lesskey(buf, len)
return (0);
}
-/*
+/*
* Process a new (post-v241) lesskey file.
*/
- static int
-new_lesskey(buf, len, sysvar)
- char *buf;
- int len;
- int sysvar;
+static int
+new_lesskey(char *buf, int len, int sysvar)
{
char *p;
- register int c;
- register int n;
+ int c;
+ int n;
/*
* New-style lesskey file.
@@ -606,11 +579,9 @@ new_lesskey(buf, len, sysvar)
buf[len-1] != C2_END_LESSKEY_MAGIC)
return (-1);
p = buf + 4;
- for (;;)
- {
+ for (;;) {
c = *p++;
- switch (c)
- {
+ switch (c) {
case CMD_SECTION:
n = gint(&p);
add_fcmd_table(p, n);
@@ -623,8 +594,8 @@ new_lesskey(buf, len, sysvar)
break;
case VAR_SECTION:
n = gint(&p);
- add_var_table((sysvar) ?
- &list_sysvar_tables : &list_var_tables, p, n);
+ add_var_table((sysvar) ?
+ &list_sysvar_tables : &list_var_tables, p, n);
p += n;
break;
case END_SECTION:
@@ -641,15 +612,13 @@ new_lesskey(buf, len, sysvar)
/*
* Set up a user command table, based on a "lesskey" file.
*/
- public int
-lesskey(filename, sysvar)
- char *filename;
- int sysvar;
+int
+lesskey(char *filename, int sysvar)
{
- register char *buf;
- register POSITION len;
- register long n;
- register int f;
+ char *buf;
+ off_t len;
+ long n;
+ int f;
if (secure)
return (1);
@@ -671,29 +640,25 @@ lesskey(filename, sysvar)
* rely on the lesskey program to generate a good .less file. }}
*/
len = filesize(f);
- if (len == NULL_POSITION || len < 3)
- {
+ if (len == -1 || len < 3) {
/*
* Bad file (valid file must have at least 3 chars).
*/
- close(f);
+ (void) close(f);
return (-1);
}
- if ((buf = (char *) calloc((int)len, sizeof(char))) == NULL)
- {
- close(f);
+ if ((buf = calloc((int)len, sizeof (char))) == NULL) {
+ (void) close(f);
return (-1);
}
- if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
- {
+ if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK) {
free(buf);
- close(f);
+ (void) close(f);
return (-1);
}
n = read(f, buf, (unsigned int) len);
close(f);
- if (n != len)
- {
+ if (n != len) {
free(buf);
return (-1);
}
@@ -711,11 +676,8 @@ lesskey(filename, sysvar)
/*
* Add the standard lesskey file "$HOME/.less"
*/
- public void
-add_hometable(envname, def_filename, sysvar)
- char *envname;
- char *def_filename;
- int sysvar;
+void
+add_hometable(char *envname, char *def_filename, int sysvar)
{
char *filename;
PARG parg;
@@ -728,28 +690,24 @@ add_hometable(envname, def_filename, sysvar)
filename = homefile(def_filename);
if (filename == NULL)
return;
- if (lesskey(filename, sysvar) < 0)
- {
+ 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
+editchar(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.
@@ -761,56 +719,47 @@ editchar(c, flags)
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)
+ if (nch > 0)
c = getcc();
- usercmd[nch] = c;
+ usercmd[nch] = (char)c;
usercmd[nch+1] = '\0';
nch++;
action = ecmd_decode(usercmd, &s);
} while (action == A_PREFIX);
-
- if (flags & EC_NORIGHTLEFT)
- {
- switch (action)
- {
+
+ if (flags & EC_NORIGHTLEFT) {
+ switch (action) {
case EC_RIGHT:
case EC_LEFT:
action = A_INVALID;
break;
}
}
-#if CMD_HISTORY
- if (flags & EC_NOHISTORY)
- {
+ if (flags & EC_NOHISTORY) {
/*
* The caller says there is no history list.
* Reject any history-manipulation action.
*/
- switch (action)
- {
+ switch (action) {
case EC_UP:
case EC_DOWN:
action = A_INVALID;
break;
}
}
-#endif
-#if TAB_COMPLETE_FILENAME
- if (flags & EC_NOCOMPLETE)
- {
+ if (flags & EC_NOCOMPLETE) {
/*
* The caller says we don't want any filename completion cmds.
* Reject them.
*/
- switch (action)
- {
+ switch (action) {
case EC_F_COMPLETE:
case EC_B_COMPLETE:
case EC_EXPAND:
@@ -818,24 +767,19 @@ editchar(c, flags)
break;
}
}
-#endif
- if ((flags & EC_PEEK) || action == A_INVALID)
- {
+ 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
+ * This does NOT include the original character that was
* passed in as a parameter.
*/
- while (nch > 1)
- {
+ while (nch > 1) {
ungetcc(usercmd[--nch]);
}
- } else
- {
+ } else {
if (s != NULL)
ungetsc(s);
}
- return action;
+ return (action);
}
-
diff --git a/usr.bin/less/defines.ds b/usr.bin/less/defines.ds
deleted file mode 100644
index 4dbbd6518a1..00000000000
--- a/usr.bin/less/defines.ds
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright (C) 1984-2011 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).
- * LESSHISTFILE is the filename of the history file
- * (in the HOME directory).
- */
-#define LESSKEYFILE "_less"
-#define LESSKEYFILE_SYS "c:\\_sysless"
-#define DEF_LESSKEYINFILE "_lesskey"
-#define LESSHISTFILE "_lesshst"
-
-
-/* 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
-
-/*
- * 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 */
-#define TABSTOP_MAX 32 /* Max number of custom tab stops */
-
-/* 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 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. */
-#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 sigprocmask function. */
-#define HAVE_SIGPROCMASK 0
-
-/* Define if you have the sigset_t type and sigemptyset macro */
-#define HAVE_SIGSET_T 0
-#define HAVE_SIGEMPTYSET 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 snprintf function. */
-#define HAVE_SNPRINTF 0
-
-/* Define if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_H 0
-
-/* 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/usr.bin/less/defines.h b/usr.bin/less/defines.h
index 963fa44f6f9..a1e534b2d09 100644
--- a/usr.bin/less/defines.h
+++ b/usr.bin/less/defines.h
@@ -1,117 +1,14 @@
-/* defines.h. Generated by configure. */
-/* defines.h.in. Generated from configure.ac 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.
- * SECURE_COMPILE is set by the --with-secure configure option.
- */
-#define SECURE SECURE_COMPILE
-
-/*
- * SMALL is 1 if you wish to disable a bunch of features in order to
- * build a smaller less binary.
- */
-#define SMALL 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 && !SMALL)
-
-/*
- * EXAMINE is 1 if you wish to allow examining files by name from within less.
- */
-#define EXAMINE (!SECURE && !SMALL)
-
-/*
- * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
- * to complete filenames at prompts.
- */
-#define TAB_COMPLETE_FILENAME (!SECURE && !SMALL)
-
-/*
- * CMD_HISTORY is 1 if you wish to allow keys to cycle through
- * previous commands at prompts.
- */
-#define CMD_HISTORY (!SMALL)
-
-/*
- * 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 && !SMALL)
-
-/*
- * TAGS is 1 if you wish to support tag files.
- */
-#define TAGS (!SECURE && !SMALL)
-
-/*
- * USERFILE is 1 if you wish to allow a .less file to specify
- * user-defined key bindings.
- */
-#define USERFILE (!SECURE && !SMALL)
-
-/*
- * 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 && !SMALL)
-
-/*
- * PIPEC is 1 if you wish to have the "|" command
- * which allows the user to pipe data into a shell command.
- */
-#define PIPEC (!SECURE && !SMALL)
-
-/*
- * LOGFILE is 1 if you wish to allow the -l option (to create log files).
- */
-#define LOGFILE (!SECURE && !SMALL)
-
-/*
- * GNU_OPTIONS is 1 if you wish to support the GNU-style command
- * line options --help and --version.
- */
-#define GNU_OPTIONS (!SMALL)
-
-/*
- * 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.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ *
+ * This file is made available under the terms of the Less License.
*/
-#define ONLY_RETURN 0
/*
- * LESSKEYFILE is the filename of the default lesskey output file
+ * 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
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
@@ -119,52 +16,8 @@
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
-#define LESSHISTFILE "-"
-
-
-/* Settings always true on Unix. */
-
-/*
- * Define MSDOS_COMPILER if compiling under Microsoft C.
- */
-#define MSDOS_COMPILER 0
-
-/*
- * Pathname separator character.
- */
-#define PATHNAME_SEP "/"
-
-/*
- * The value returned from tgetent on success.
- * Some HP-UX systems return 0 on success.
- */
-#define TGETENT_OK 1
-
-/*
- * 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
+#define LESSHISTFILE "-"
+#define TGETENT_OK 1 /* "OK" from curses.h */
/*
* Default shell metacharacters and meta-escape character.
@@ -172,34 +25,6 @@
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METAESCAPE "\\"
-/*
- * HAVE_DUP is 1 if your system has the dup() call.
- */
-#define HAVE_DUP 1
-
-/* Define to 1 if you have the memcpy() function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the strchr() function. */
-#define HAVE_STRCHR 1
-
-/* Define to 1 if you have the strstr() function. */
-#define HAVE_STRSTR 1
-
-/*
- * Sizes of various buffers.
- */
-#if SMALL /* old sizes for small memory machines */
-#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 TABSTOP_MAX 32 /* Max number of custom tab stops */
-#else /* more reasonable sizes for modern machines */
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
#define UNGOT_SIZE 200 /* Max chars to unget() */
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
@@ -209,228 +34,4 @@
#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
#define TAGLINE_SIZE 1024 /* Max size of line in tags file */
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
-#endif
-
-/* Settings automatically determined by configure. */
-
-
-/* Define EDIT_PGM to your editor. */
-#define EDIT_PGM "vi"
-
-/* Define HAVE_CONST if your compiler supports the "const" modifier. */
-#define HAVE_CONST 1
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define HAVE_ERRNO if you have the errno variable. */
-#define HAVE_ERRNO 1
-
-/* Define to 1 if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define to 1 if you have the `fchmod' function. */
-#define HAVE_FCHMOD 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define HAVE_FILENO if you have the fileno() macro. */
-#define HAVE_FILENO 1
-
-/* Define HAVE_FLOAT if your compiler supports the "double" type. */
-#define HAVE_FLOAT 1
-
-/* Define to 1 if you have the `fsync' function. */
-#define HAVE_FSYNC 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define HAVE_LOCALE if you have locale.h and setlocale. */
-#define HAVE_LOCALE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
-#define HAVE_OSPEED 1
-
-/* PCRE (Perl-compatible regular expression) library */
-/* #undef HAVE_PCRE */
-
-/* Define to 1 if you have the `popen' function. */
-#define HAVE_POPEN 1
-
-/* POSIX regcomp() and regex.h */
-#define HAVE_POSIX_REGCOMP 1
-
-/* System V regcmp() */
-/* #undef HAVE_REGCMP */
-
-/* */
-/* #undef HAVE_REGEXEC2 */
-
-/* BSD re_comp() */
-/* #undef HAVE_RE_COMP */
-
-/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
-#define HAVE_SIGEMPTYSET 1
-
-/* Define to 1 if you have the `sigprocmask' function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define to 1 if you have the `sigsetmask' function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define to 1 if the system has the type `sigset_t'. */
-#define HAVE_SIGSET_T 1
-
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
-/* Define to 1 if you have the `stat' function. */
-#define HAVE_STAT 1
-
-/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
-#define HAVE_STAT_INO 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define HAVE_STRERROR if you have the strerror() function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `system' function. */
-#define HAVE_SYSTEM 1
-
-/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
-#define HAVE_SYS_ERRLIST 1
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/stream.h> header file. */
-/* #undef HAVE_SYS_STREAM_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <termcap.h> header file. */
-#define HAVE_TERMCAP_H 1
-
-/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
-#define HAVE_TERMIOS_FUNCS 1
-
-/* Define to 1 if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define to 1 if you have the <termio.h> header file. */
-/* #undef HAVE_TERMIO_H */
-
-/* Define to 1 if you have the <time.h> header file. */
-#define HAVE_TIME_H 1
-
-/* Define HAVE_TIME_T if your system supports the "time_t" type. */
-#define HAVE_TIME_T 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
-#define HAVE_UPPER_LOWER 1
-
-/* Henry Spencer V8 regcomp() and regexp.h */
-/* #undef HAVE_V8_REGCOMP */
-
-/* Define to 1 if you have the <values.h> header file. */
-/* #undef HAVE_VALUES_H */
-
-/* Define HAVE_VOID if your compiler supports the "void" type. */
-#define HAVE_VOID 1
-
-/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
-#define HAVE_WCTYPE 1
-
-/* Define to 1 if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_H 1
-
-/* Define to 1 if you have the `_setjmp' function. */
-#define HAVE__SETJMP 1
-
-/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
- */
-/* #undef MUST_DEFINE_ERRNO */
-
-/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
- termcap.h. */
-/* #undef MUST_DEFINE_OSPEED */
-
-/* pattern matching is supported, but without metacharacters. */
-/* #undef NO_REGEX */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "less"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "less 1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "less"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1"
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* Define SECURE_COMPILE=1 to build a secure version of less. */
-#define SECURE_COMPILE 0
-
-/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to `long int' if <sys/types.h> does not define. */
-/* #undef off_t */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
+#define EDIT_PGM "vi" /* Editor program */
diff --git a/usr.bin/less/defines.h.in b/usr.bin/less/defines.h.in
deleted file mode 100644
index bfd0ab78d71..00000000000
--- a/usr.bin/less/defines.h.in
+++ /dev/null
@@ -1,432 +0,0 @@
-/* defines.h.in. Generated from configure.ac 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.
- * SECURE_COMPILE is set by the --with-secure configure option.
- */
-#define SECURE SECURE_COMPILE
-
-/*
- * 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).
- * LESSHISTFILE is the filename of the history file
- * (in the HOME directory).
- */
-#define LESSKEYFILE ".less"
-#define LESSKEYFILE_SYS SYSDIR "/sysless"
-#define DEF_LESSKEYINFILE ".lesskey"
-#define LESSHISTFILE ".lesshst"
-
-
-/* Settings always true on Unix. */
-
-/*
- * Define MSDOS_COMPILER if compiling under Microsoft C.
- */
-#define MSDOS_COMPILER 0
-
-/*
- * Pathname separator character.
- */
-#define PATHNAME_SEP "/"
-
-/*
- * The value returned from tgetent on success.
- * Some HP-UX systems return 0 on success.
- */
-#define TGETENT_OK 1
-
-/*
- * 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
-
-/* Define to 1 if you have the memcpy() function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the strchr() function. */
-#define HAVE_STRCHR 1
-
-/* Define to 1 if you have the strstr() function. */
-#define HAVE_STRSTR 1
-
-/*
- * Sizes of various buffers.
- */
-#if 0 /* old sizes for small memory machines */
-#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 TABSTOP_MAX 32 /* Max number of custom tab stops */
-#else /* more reasonable sizes for modern machines */
-#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
-#define UNGOT_SIZE 200 /* Max chars to unget() */
-#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
-#define OUTBUF_SIZE 1024 /* Output buffer */
-#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
-#define TABSTOP_MAX 128 /* Max number of custom tab stops */
-#endif
-
-/* Settings automatically determined by configure. */
-
-
-/* Define EDIT_PGM to your editor. */
-#undef EDIT_PGM
-
-/* Define HAVE_CONST if your compiler supports the "const" modifier. */
-#undef HAVE_CONST
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#undef HAVE_CTYPE_H
-
-/* Define HAVE_ERRNO if you have the errno variable. */
-#undef HAVE_ERRNO
-
-/* Define to 1 if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
-/* Define to 1 if you have the `fchmod' function. */
-#undef HAVE_FCHMOD
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define HAVE_FILENO if you have the fileno() macro. */
-#undef HAVE_FILENO
-
-/* Define HAVE_FLOAT if your compiler supports the "double" type. */
-#undef HAVE_FLOAT
-
-/* Define to 1 if you have the `fsync' function. */
-#undef HAVE_FSYNC
-
-/* GNU regex library */
-#undef HAVE_GNU_REGEX
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
-/* Define HAVE_LOCALE if you have locale.h and setlocale. */
-#undef HAVE_LOCALE
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
-#undef HAVE_OSPEED
-
-/* PCRE (Perl-compatible regular expression) library */
-#undef HAVE_PCRE
-
-/* Define to 1 if you have the `popen' function. */
-#undef HAVE_POPEN
-
-/* POSIX regcomp() and regex.h */
-#undef HAVE_POSIX_REGCOMP
-
-/* System V regcmp() */
-#undef HAVE_REGCMP
-
-/* */
-#undef HAVE_REGEXEC2
-
-/* BSD re_comp() */
-#undef HAVE_RE_COMP
-
-/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
-#undef HAVE_SIGEMPTYSET
-
-/* Define to 1 if you have the `sigprocmask' function. */
-#undef HAVE_SIGPROCMASK
-
-/* Define to 1 if you have the `sigsetmask' function. */
-#undef HAVE_SIGSETMASK
-
-/* Define to 1 if the system has the type `sigset_t'. */
-#undef HAVE_SIGSET_T
-
-/* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
-
-/* Define to 1 if you have the `stat' function. */
-#undef HAVE_STAT
-
-/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
-#undef HAVE_STAT_INO
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#undef HAVE_STDIO_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define HAVE_STRERROR if you have the strerror() function. */
-#undef HAVE_STRERROR
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `system' function. */
-#undef HAVE_SYSTEM
-
-/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
-#undef HAVE_SYS_ERRLIST
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/stream.h> header file. */
-#undef HAVE_SYS_STREAM_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <termcap.h> header file. */
-#undef HAVE_TERMCAP_H
-
-/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
-#undef HAVE_TERMIOS_FUNCS
-
-/* Define to 1 if you have the <termios.h> header file. */
-#undef HAVE_TERMIOS_H
-
-/* Define to 1 if you have the <termio.h> header file. */
-#undef HAVE_TERMIO_H
-
-/* Define to 1 if you have the <time.h> header file. */
-#undef HAVE_TIME_H
-
-/* Define HAVE_TIME_T if your system supports the "time_t" type. */
-#undef HAVE_TIME_T
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
-#undef HAVE_UPPER_LOWER
-
-/* Henry Spencer V8 regcomp() and regexp.h */
-#undef HAVE_V8_REGCOMP
-
-/* Define to 1 if you have the <values.h> header file. */
-#undef HAVE_VALUES_H
-
-/* Define HAVE_VOID if your compiler supports the "void" type. */
-#undef HAVE_VOID
-
-/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
-#undef HAVE_WCTYPE
-
-/* Define to 1 if you have the <wctype.h> header file. */
-#undef HAVE_WCTYPE_H
-
-/* Define to 1 if you have the `_setjmp' function. */
-#undef HAVE__SETJMP
-
-/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
- */
-#undef MUST_DEFINE_ERRNO
-
-/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
- termcap.h. */
-#undef MUST_DEFINE_OSPEED
-
-/* pattern matching is supported, but without metacharacters. */
-#undef NO_REGEX
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
-/* Define SECURE_COMPILE=1 to build a secure version of less. */
-#undef SECURE_COMPILE
-
-/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-#undef STAT_MACROS_BROKEN
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
-/* Define for large files, on AIX-style hosts. */
-#undef _LARGE_FILES
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to `long int' if <sys/types.h> does not define. */
-#undef off_t
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
diff --git a/usr.bin/less/defines.o2 b/usr.bin/less/defines.o2
deleted file mode 100644
index 0fd8cc73503..00000000000
--- a/usr.bin/less/defines.o2
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 1984-2011 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 "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.
- */
-#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).
- * LESSHISTFILE is the filename of the history file
- * (in the HOME directory).
- */
-#define LESSKEYFILE "less.ini"
-#define LESSKEYFILE_SYS "C:\\sysless.ini"
-#define DEF_LESSKEYINFILE "lesskey.ini"
-#define LESSHISTFILE "lesshst.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
-
-/*
- * 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 */
-#define TABSTOP_MAX 32 /* Max number of custom tab stops */
-
-/* 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
-/* #undef MUST_DEFINE_ERRNO */
-
-/* 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 1
-/* 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 1
-
-/* 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 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 0
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigset_t type and sigemptyset macro */
-#define HAVE_SIGSET_T 1
-#define HAVE_SIGEMPTYSET 1
-
-/* 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 strstr function. */
-#define HAVE_STRSTR 1
-
-/* Define if you have the system function. */
-#define HAVE_SYSTEM 1
-
-/* Define if you have the snprintf function. */
-#define HAVE_SNPRINTF 0
-
-/* Define if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_H 0
-
-/* 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 1
-
-/* 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 1
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* 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/usr.bin/less/defines.o9 b/usr.bin/less/defines.o9
deleted file mode 100644
index 3bb1d2cb8ca..00000000000
--- a/usr.bin/less/defines.o9
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright (C) 1984-2011 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).
- * LESSHISTFILE is the filename of the history file
- * (in the HOME directory).
- */
-#define LESSKEYFILE ".less"
-#define LESSKEYFILE_SYS "/.sysless"
-#define DEF_LESSKEYINFILE ".lesskey"
-#define LESSHISTFILE ".lesshst"
-
-
-/* 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 TABSTOP_MAX 32 /* Max number of custom tab stops */
-
-/* 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 sigprocmask function. */
-#define HAVE_SIGPROCMASK 0
-
-/* Define if you have the sigset_t type and sigemptyset macro */
-#define HAVE_SIGSET_T 0
-#define HAVE_SIGEMPTYSET 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 snprintf function. */
-#define HAVE_SNPRINTF 0
-
-/* Define if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_H 0
-
-/* 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/usr.bin/less/defines.wn b/usr.bin/less/defines.wn
deleted file mode 100644
index 416a548e745..00000000000
--- a/usr.bin/less/defines.wn
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 1984-2011 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).
- * LESSHISTFILE is the filename of the history file
- * (in the HOME directory).
- */
-#define LESSKEYFILE "_less"
-#define LESSKEYFILE_SYS "c:\\_sysless"
-#define DEF_LESSKEYINFILE "_lesskey"
-#define LESSHISTFILE "_lesshst"
-
-
-/* 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
-
-/*
- * 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 */
-#define TABSTOP_MAX 32 /* Max number of custom tab stops */
-
-/* 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 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 sigprocmask function. */
-#define HAVE_SIGPROCMASK 0
-
-/* Define if you have the sigset_t type and sigemptyset macro */
-#define HAVE_SIGSET_T 0
-#define HAVE_SIGEMPTYSET 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 snprintf function. */
-#define HAVE_SNPRINTF 1
-
-/* Define if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define if you have the <wctype.h> header file. */
-#define HAVE_WCTYPE_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 HAVE_FLOAT if your compiler supports the "double" type. */
-#define HAVE_FLOAT 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 <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
-#define snprintf _snprintf
-
-#pragma warning(disable:4996)
diff --git a/usr.bin/less/edit.c b/usr.bin/less/edit.c
index 28720fdef75..1224dac52ce 100644
--- a/usr.bin/less/edit.c
+++ b/usr.bin/less/edit.c
@@ -6,18 +6,18 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
#include "less.h"
-#if HAVE_STAT
#include <sys/stat.h>
-#endif
-public int fd0 = 0;
+static 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;
@@ -26,27 +26,21 @@ extern volatile sig_atomic_t sigs;
extern IFILE curr_ifile;
extern IFILE old_ifile;
extern struct scrpos initial_scrpos;
-extern void constant *ml_examine;
-#if SPACES_IN_FILENAMES
+extern void *ml_examine;
extern char openquote;
extern char closequote;
-#endif
-
-#if LOGFILE
+extern int less_is_more;
extern int logfile;
extern int force_logfile;
extern char *namelogfile;
-#endif
-#if HAVE_STAT_INO
-public dev_t curr_dev;
-public ino_t curr_ino;
-#endif
+dev_t curr_dev;
+ino_t curr_ino;
char *curr_altfilename = NULL;
static void *curr_altpipe;
-#if EXAMINE || TAB_COMPLETE_FILENAME
+
/*
* Textlist functions deal with a list of words separated by spaces.
* init_textlist sets up a textlist structure.
@@ -54,57 +48,41 @@ static void *curr_altpipe;
* 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;
+void
+init_textlist(struct textlist *tlist, char *str)
{
char *s;
-#if SPACES_IN_FILENAMES
int meta_quoted = 0;
int delim_quoted = 0;
char *esc = get_meta_escape();
int esclen = strlen(esc);
-#endif
-
+
tlist->string = skipsp(str);
tlist->endstring = tlist->string + strlen(tlist->string);
- for (s = str; s < tlist->endstring; s++)
- {
-#if SPACES_IN_FILENAMES
- if (meta_quoted)
- {
+ for (s = str; s < tlist->endstring; s++) {
+ if (meta_quoted) {
meta_quoted = 0;
} else if (esclen > 0 && s + esclen < tlist->endstring &&
- strncmp(s, esc, esclen) == 0)
- {
+ strncmp(s, esc, esclen) == 0) {
meta_quoted = 1;
s += esclen - 1;
- } else if (delim_quoted)
- {
+ } else if (delim_quoted) {
if (*s == closequote)
delim_quoted = 0;
- } else /* (!delim_quoted) */
- {
+ } else /* (!delim_quoted) */ {
if (*s == openquote)
delim_quoted = 1;
else if (*s == ' ')
*s = '\0';
}
-#else
- if (*s == ' ')
- *s = '\0';
-#endif
}
}
- public char *
-forw_textlist(tlist, prev)
- struct textlist *tlist;
- char *prev;
+char *
+forw_textlist(struct textlist *tlist, char *prev)
{
char *s;
-
+
/*
* prev == NULL means return the first word in the list.
* Otherwise, return the word after "prev".
@@ -122,13 +100,11 @@ forw_textlist(tlist, prev)
return (s);
}
- public char *
-back_textlist(tlist, prev)
- struct textlist *tlist;
- char *prev;
+char *
+back_textlist(struct textlist *tlist, char *prev)
{
char *s;
-
+
/*
* prev == NULL means return the last word in the list.
* Otherwise, return the word before "prev".
@@ -147,16 +123,15 @@ back_textlist(tlist, prev)
s--;
return (s);
}
-#endif /* EXAMINE || TAB_COMPLETE_FILENAME */
/*
* Close the current input file.
*/
- static void
-close_file()
+static void
+close_file(void)
{
struct scrpos scrpos;
-
+
if (curr_ifile == NULL_IFILE)
return;
@@ -165,8 +140,7 @@ close_file()
* the same position if we edit this file again.
*/
get_scrpos(&scrpos);
- if (scrpos.pos != NULL_POSITION)
- {
+ if (scrpos.pos != -1) {
store_pos(curr_ifile, &scrpos);
lastmark();
}
@@ -178,17 +152,14 @@ close_file()
* If we opened a file using an alternate name,
* do special stuff to close it.
*/
- if (curr_altfilename != NULL)
- {
+ if (curr_altfilename != NULL) {
close_altfile(curr_altfilename, get_filename(curr_ifile),
- curr_altpipe);
+ curr_altpipe);
free(curr_altfilename);
curr_altfilename = NULL;
}
curr_ifile = NULL_IFILE;
-#if HAVE_STAT_INO
curr_ino = curr_dev = 0;
-#endif
}
/*
@@ -196,22 +167,20 @@ close_file()
* Filename == "-" means standard input.
* Filename == NULL means just close the current file.
*/
- public int
-edit(filename)
- char *filename;
+int
+edit(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
+edit_ifile(IFILE ifile)
{
int f;
int answer;
@@ -224,9 +193,8 @@ edit_ifile(ifile)
void *alt_pipe;
IFILE was_curr_ifile;
PARG parg;
-
- if (ifile == curr_ifile)
- {
+
+ if (ifile == curr_ifile) {
/*
* Already have the correct file open.
*/
@@ -240,28 +208,22 @@ edit_ifile(ifile)
* {{ 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)
- {
+ if (curr_ifile != NULL_IFILE) {
chflags = ch_getflags();
close_file();
-#if !SMALL
- if ((chflags & CH_HELPFILE) && held_ifile(was_curr_ifile) <= 1)
- {
+ 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;
}
-#endif /* !SMALL */
}
- if (ifile == NULL_IFILE)
- {
+ if (ifile == NULL_IFILE) {
/*
* No new file to open.
* (Don't set old_ifile, because if you call edit_ifile(NULL),
@@ -282,54 +244,35 @@ edit_ifile(ifile)
qopen_filename = shell_unquote(open_filename);
chflags = 0;
-#if !SMALL
if (strcmp(open_filename, helpfile()) == 0)
chflags |= CH_HELPFILE;
-#endif /* !SMALL */
- if (alt_pipe != NULL)
- {
+ 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
+ * 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)
- {
- /*
+ } 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_EMPTYFILE) == 0)
- {
+ } else if (strcmp(open_filename, FAKE_EMPTYFILE) == 0) {
f = -1;
chflags |= CH_NODATA;
- } else if ((parg.p_string = bad_file(open_filename)) != NULL)
- {
+ } 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)
- {
+err1:
+ if (alt_filename != NULL) {
close_altfile(alt_filename, filename, alt_pipe);
free(alt_filename);
}
@@ -339,40 +282,35 @@ edit_ifile(ifile)
/*
* Re-open the current file.
*/
- if (was_curr_ifile == ifile)
- {
+ if (was_curr_ifile == ifile) {
/*
- * Whoops. The "current" ifile is the one we just deleted.
- * Just give up.
+ * Whoops. The "current" ifile is the one we just
+ * deleted. Just give up.
*/
quit(QUIT_ERROR);
}
reedit_ifile(was_curr_ifile);
return (1);
- } else if ((f = open(qopen_filename, OPEN_READ)) < 0)
- {
+ } else if ((f = open(qopen_filename, O_RDONLY)) < 0) {
/*
* Got an error trying to open it.
*/
parg.p_string = errno_message(filename);
error("%s", &parg);
free(parg.p_string);
- goto err1;
- } else
- {
+ goto err1;
+ } else {
chflags |= CH_CANSEEK;
- if (!force_open && !opened(ifile) && bin_file(f))
- {
+ if (!force_open && !opened(ifile) && bin_file(f)) {
/*
- * Looks like a binary file.
+ * 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);
+ answer = query("\"%s\" may be a binary file. "
+ "See it anyway? ", &parg);
+ if (answer != 'y' && answer != 'Y') {
+ (void) close(f);
goto err1;
}
}
@@ -382,8 +320,7 @@ edit_ifile(ifile)
* Get the new ifile.
* Get the saved position for the file.
*/
- if (was_curr_ifile != NULL_IFILE)
- {
+ if (was_curr_ifile != NULL_IFILE) {
old_ifile = was_curr_ifile;
unsave_ifile(was_curr_ifile);
}
@@ -395,35 +332,27 @@ edit_ifile(ifile)
new_file = TRUE;
ch_init(f, chflags);
- if (!(chflags & CH_HELPFILE))
- {
-#if LOGFILE
+ if (!(chflags & CH_HELPFILE)) {
+ struct stat statbuf;
+ int r;
+
if (namelogfile != NULL && is_tty)
use_logfile(namelogfile);
-#endif
-#if HAVE_STAT_INO
- /* Remember the i-number and device of the opened file. */
- {
- struct stat statbuf;
- int r = stat(qopen_filename, &statbuf);
- if (r == 0)
- {
- curr_ino = statbuf.st_ino;
- curr_dev = statbuf.st_dev;
- }
+ /* Remember the i-number and device of opened file. */
+ r = stat(qopen_filename, &statbuf);
+ if (r == 0) {
+ curr_ino = statbuf.st_ino;
+ curr_dev = statbuf.st_dev;
}
-#endif
if (every_first_cmd != NULL)
ungetsc(every_first_cmd);
}
-
free(qopen_filename);
no_display = !any_display;
flush();
any_display = TRUE;
- if (is_tty)
- {
+ if (is_tty) {
/*
* Output is to a real tty.
*/
@@ -433,12 +362,9 @@ edit_ifile(ifile)
*/
pos_clear();
clr_linenum();
-#if HILITE_SEARCH
clr_hilite();
-#endif
cmd_addhist(ml_examine, filename);
- if (no_display && errmsgs > 0)
- {
+ if (no_display && errmsgs > 0) {
/*
* We displayed some messages on error output
* (file descriptor 2; see error() function).
@@ -453,15 +379,13 @@ edit_ifile(ifile)
return (0);
}
-#if EXAMINE
/*
* 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;
+int
+edit_list(char *filelist)
{
IFILE save_ifile;
char *good_filename;
@@ -473,22 +397,21 @@ edit_list(filelist)
save_ifile = save_curr_ifile();
good_filename = NULL;
-
+
/*
* Run thru each filename in the list.
- * Try to glob the filename.
+ * 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)
- {
+ 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)
- {
+ while ((gfilename = forw_textlist(&tl_gfiles, gfilename)) !=
+ NULL) {
if (edit(gfilename) == 0 && good_filename == NULL)
good_filename = get_filename(curr_ifile);
}
@@ -497,13 +420,11 @@ edit_list(filelist)
/*
* Edit the first valid filename in the list.
*/
- if (good_filename == NULL)
- {
+ if (good_filename == NULL) {
unsave_ifile(save_ifile);
return (1);
}
- if (get_ifile(good_filename, curr_ifile) == curr_ifile)
- {
+ if (get_ifile(good_filename, curr_ifile) == curr_ifile) {
/*
* Trying to edit the current file; don't reopen it.
*/
@@ -513,13 +434,12 @@ edit_list(filelist)
reedit_ifile(save_ifile);
return (edit(good_filename));
}
-#endif /* EXAMINE */
/*
* Edit the first file in the command line (ifile) list.
*/
- public int
-edit_first()
+int
+edit_first(void)
{
curr_ifile = NULL_IFILE;
return (edit_next(1));
@@ -528,8 +448,8 @@ edit_first()
/*
* Edit the last file in the command line (ifile) list.
*/
- public int
-edit_last()
+int
+edit_last(void)
{
curr_ifile = NULL_IFILE;
return (edit_prev(1));
@@ -539,34 +459,27 @@ edit_last()
/*
* Edit the n-th next or previous file in the command line (ifile) list.
*/
- static int
-edit_istep(h, n, dir)
- IFILE h;
- int n;
- int dir;
+static int
+edit_istep(IFILE h, int n, int dir)
{
IFILE next;
/*
* Skip n filenames, then try to edit each filename.
*/
- for (;;)
- {
+ for (;;) {
next = (dir > 0) ? next_ifile(h) : prev_ifile(h);
- if (--n < 0)
- {
+ if (--n < 0) {
if (edit_ifile(h) == 0)
break;
}
- if (next == NULL_IFILE)
- {
+ if (next == NULL_IFILE) {
/*
* Reached end of the ifile list.
*/
return (1);
}
- if (ABORT_SIGS())
- {
+ if (ABORT_SIGS()) {
/*
* Interrupt breaks out, if we're in a long
* list of files that can't be opened.
@@ -574,57 +487,48 @@ edit_istep(h, n, dir)
return (1);
}
h = next;
- }
+ }
/*
* Found a file that we can edit.
*/
return (0);
}
- static int
-edit_inext(h, n)
- IFILE h;
- int n;
+static int
+edit_inext(IFILE h, int n)
{
return (edit_istep(h, n, +1));
}
- public int
-edit_next(n)
- int n;
+int
+edit_next(int n)
{
- return edit_istep(curr_ifile, n, +1);
+ return (edit_istep(curr_ifile, n, +1));
}
- static int
-edit_iprev(h, n)
- IFILE h;
- int n;
+static int
+edit_iprev(IFILE h, int n)
{
return (edit_istep(h, n, -1));
}
- public int
-edit_prev(n)
- int n;
+int
+edit_prev(int n)
{
- return edit_istep(curr_ifile, n, -1);
+ return (edit_istep(curr_ifile, n, -1));
}
/*
* Edit a specific file in the command line (ifile) list.
*/
- public int
-edit_index(n)
- int n;
+int
+edit_index(int n)
{
IFILE h;
h = NULL_IFILE;
- do
- {
- if ((h = next_ifile(h)) == NULL_IFILE)
- {
+ do {
+ if ((h = next_ifile(h)) == NULL_IFILE) {
/*
* Reached end of the list without finding it.
*/
@@ -635,17 +539,16 @@ edit_index(n)
return (edit_ifile(h));
}
- public IFILE
-save_curr_ifile()
+IFILE
+save_curr_ifile(void)
{
if (curr_ifile != NULL_IFILE)
hold_ifile(curr_ifile, 1);
return (curr_ifile);
}
- public void
-unsave_ifile(save_ifile)
- IFILE save_ifile;
+void
+unsave_ifile(IFILE save_ifile)
{
if (save_ifile != NULL_IFILE)
hold_ifile(save_ifile, -1);
@@ -654,9 +557,8 @@ unsave_ifile(save_ifile)
/*
* Reedit the ifile which was previously open.
*/
- public void
-reedit_ifile(save_ifile)
- IFILE save_ifile;
+void
+reedit_ifile(IFILE save_ifile)
{
IFILE next;
IFILE prev;
@@ -688,8 +590,8 @@ reedit_ifile(save_ifile)
quit(QUIT_ERROR);
}
- public void
-reopen_curr_ifile()
+void
+reopen_curr_ifile(void)
{
IFILE save_ifile = save_curr_ifile();
close_file();
@@ -699,12 +601,17 @@ reopen_curr_ifile()
/*
* Edit standard input.
*/
- public int
-edit_stdin()
+int
+edit_stdin(void)
{
- if (isatty(fd0))
- {
- error("Missing filename (\"less --help\" for help)", NULL_PARG);
+ if (isatty(fd0)) {
+ if (less_is_more) {
+ error("Missing filename (\"more -h\" for help)",
+ NULL_PARG);
+ } else {
+ error("Missing filename (\"less --help\" for help)",
+ NULL_PARG);
+ }
quit(QUIT_OK);
}
return (edit("-"));
@@ -714,29 +621,26 @@ edit_stdin()
* Copy a file directly to standard output.
* Used if standard output is not a tty.
*/
- public void
-cat_file()
+void
+cat_file(void)
{
- register int c;
+ 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.
+ * is standard input, create the log file.
* We take care not to blindly overwrite an existing file.
*/
- public void
-use_logfile(filename)
- char *filename;
+void
+use_logfile(char *filename)
{
- register int exists;
- register int answer;
+ int exists;
+ int answer;
PARG parg;
if (ch_getflags() & CH_CANSEEK)
@@ -757,24 +661,22 @@ use_logfile(filename)
* Decide whether to overwrite the log file or append to it.
* If it doesn't exist we "overwrite" it.
*/
- if (!exists || force_logfile)
- {
+ if (!exists || force_logfile) {
/*
* Overwrite (or create) the log file.
*/
answer = 'O';
- } else
- {
+ } else {
/*
* Ask user what to do.
*/
parg.p_string = filename;
- answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
+ answer = query("Warning: \"%s\" exists; "
+ "Overwrite, Append or Don't log? ", &parg);
}
loop:
- switch (answer)
- {
+ switch (answer) {
case 'O': case 'o':
/*
* Overwrite: create the file.
@@ -786,8 +688,7 @@ loop:
* Append: open the file and seek to the end.
*/
logfile = open(filename, OPEN_APPEND);
- if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK)
- {
+ if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK) {
close(logfile);
logfile = -1;
}
@@ -805,12 +706,12 @@ loop:
/*
* Eh?
*/
- answer = query("Overwrite, Append, or Don't log? (Type \"O\", \"A\", \"D\" or \"q\") ", NULL_PARG);
+ answer = query("Overwrite, Append, or Don't log? "
+ "(Type \"O\", \"A\", \"D\" or \"q\") ", NULL_PARG);
goto loop;
}
- if (logfile < 0)
- {
+ if (logfile < 0) {
/*
* Error in opening logfile.
*/
@@ -820,7 +721,4 @@ loop:
return;
}
free(filename);
- SET_BINARY(logfile);
}
-
-#endif
diff --git a/usr.bin/less/filename.c b/usr.bin/less/filename.c
index 75297f9fe8a..c84a85ef67d 100644
--- a/usr.bin/less/filename.c
+++ b/usr.bin/less/filename.c
@@ -6,46 +6,24 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to mess around with filenames (and files).
* Much of this is very OS dependent.
+ *
+ * Modified for illumos/POSIX -- it uses native glob(3C) rather than
+ * popen to a shell to perform the expansion.
*/
#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>
-#define _MAX_PATH PATH_MAX
-#endif
-#endif
-#ifdef _OSK
-#include <rbf.h>
-#ifndef _OSK_MWC32
-#include <modes.h>
-#endif
-#endif
-#if OS2
-#include <signal.h>
-#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
-
+#include <glob.h>
+#include <stdarg.h>
extern int force_open;
extern int secure;
@@ -54,41 +32,33 @@ extern int ctldisp;
extern int utf_mode;
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 *
-shell_unquote(str)
- char *str;
+char *
+shell_unquote(char *str)
{
char *name;
char *p;
- name = p = (char *) ecalloc(strlen(str)+1, sizeof(char));
- if (*str == openquote)
- {
+ name = p = ecalloc(strlen(str)+1, sizeof (char));
+ if (*str == openquote) {
str++;
- while (*str != '\0')
- {
- if (*str == closequote)
- {
+ while (*str != '\0') {
+ if (*str == closequote) {
if (str[1] != closequote)
break;
str++;
}
*p++ = *str++;
}
- } else
- {
+ } else {
char *esc = get_meta_escape();
int esclen = strlen(esc);
- while (*str != '\0')
- {
+ while (*str != '\0') {
if (esclen > 0 && strncmp(str, esc, esclen) == 0)
str += esclen;
*p++ = *str++;
@@ -101,8 +71,8 @@ shell_unquote(str)
/*
* Get the shell's escape character.
*/
- public char *
-get_meta_escape()
+char *
+get_meta_escape(void)
{
char *s;
@@ -115,13 +85,12 @@ get_meta_escape()
/*
* Get the characters which the shell considers to be "metacharacters".
*/
- static char *
-metachars()
+static char *
+metachars(void)
{
static char *mchars = NULL;
- if (mchars == NULL)
- {
+ if (mchars == NULL) {
mchars = lgetenv("LESSMETACHARS");
if (mchars == NULL)
mchars = DEF_METACHARS;
@@ -132,9 +101,8 @@ metachars()
/*
* Is this a shell metacharacter?
*/
- static int
-metachar(c)
- char c;
+static int
+metachar(char c)
{
return (strchr(metachars(), c) != NULL);
}
@@ -142,11 +110,11 @@ metachar(c)
/*
* Insert a backslash before each metacharacter in a string.
*/
- public char *
-shell_quote(s)
- char *s;
+char *
+shell_quote(const char *s)
{
- char *p;
+ const char *p;
+ char *r;
char *newstr;
int len;
char *esc = get_meta_escape();
@@ -158,22 +126,18 @@ shell_quote(s)
* Determine how big a string we need to allocate.
*/
len = 1; /* Trailing null byte */
- for (p = s; *p != '\0'; p++)
- {
+ for (p = s; *p != '\0'; p++) {
len++;
if (*p == openquote || *p == closequote)
have_quotes = 1;
- if (metachar(*p))
- {
- if (esclen == 0)
- {
+ if (metachar(*p)) {
+ if (esclen == 0) {
/*
- * We've got a metachar, but this shell
+ * We've got a metachar, but this shell
* doesn't support escape chars. Use quotes.
*/
use_quotes = 1;
- } else
- {
+ } else {
/*
* Allow space for the escape char.
*/
@@ -181,37 +145,27 @@ shell_quote(s)
}
}
}
- if (use_quotes)
- {
- if (have_quotes)
- /*
- * We can't quote a string that contains quotes.
- */
- return (NULL);
- len = strlen(s) + 3;
- }
/*
* Allocate and construct the new string.
*/
- newstr = p = (char *) ecalloc(len, sizeof(char));
- if (use_quotes)
- {
- SNPRINTF3(newstr, len, "%c%s%c", openquote, s, closequote);
- } else
- {
- while (*s != '\0')
- {
- if (metachar(*s))
- {
+ if (use_quotes) {
+ /* We can't quote a string that contains quotes. */
+ if (have_quotes)
+ return (NULL);
+ newstr = easprintf("%c%s%c", openquote, s, closequote);
+ } else {
+ newstr = r = ecalloc(len, sizeof (char));
+ while (*s != '\0') {
+ if (metachar(*s)) {
/*
* Add the escape char.
*/
- strlcpy(p, esc, newstr + len - p);
- p += esclen;
+ (void) strlcpy(r, esc, newstr + len - p);
+ r += esclen;
}
- *p++ = *s++;
+ *r++ = *s++;
}
- *p = '\0';
+ *r = '\0';
}
return (newstr);
}
@@ -220,14 +174,11 @@ shell_quote(s)
* 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;
+static char *
+dirfile(const char *dirname, const char *filename)
{
char *pathname;
char *qpathname;
- size_t len;
int f;
if (dirname == NULL || *dirname == '\0')
@@ -235,75 +186,30 @@ dirfile(dirname, filename)
/*
* Construct the full pathname.
*/
- len= strlen(dirname) + strlen(filename) + 2;
- pathname = (char *) calloc(len, sizeof(char));
- if (pathname == NULL)
- return (NULL);
- SNPRINTF3(pathname, len, "%s%s%s", dirname, PATHNAME_SEP, filename);
+ pathname = easprintf("%s/%s", dirname, filename);
/*
* Make sure the file exists.
*/
qpathname = shell_unquote(pathname);
- f = open(qpathname, OPEN_READ);
- if (f < 0)
- {
+ f = open(qpathname, O_RDONLY);
+ if (f < 0) {
free(pathname);
pathname = NULL;
- } else
- {
- close(f);
+ } else {
+ (void) close(f);
}
free(qpathname);
return (pathname);
}
-#if USERFILE
/*
* Return the full pathname of the given file in the "home directory".
*/
- public char *
-homefile(filename)
- char *filename;
+char *
+homefile(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
- strlcpy(pathname, res, _MAX_PATH);
- }
-#else
- _searchenv(filename, "PATH", pathname);
-#endif
- if (*pathname != '\0')
- return (pathname);
- free(pathname);
-#endif
- return (NULL);
+ return (dirfile(lgetenv("HOME"), filename));
}
-#endif /* USERFILE */
/*
* Expand a string, substituting any "%" with the current filename,
@@ -312,39 +218,33 @@ homefile(filename)
* Likewise for a string of N "#"s.
* {{ This is a lot of work just to support % and #. }}
*/
- public char *
-fexpand(s)
- char *s;
+char *
+fexpand(char *s)
{
- register char *fr, *to;
- register int n;
- register char *e;
+ char *fr, *to;
+ int n;
+ char *e;
IFILE ifile;
#define fchar_ifile(c) \
- ((c) == '%' ? curr_ifile : \
- (c) == '#' ? old_ifile : NULL_IFILE)
+ ((c) == '%' ? curr_ifile : (c) == '#' ? old_ifile : NULL_IFILE)
/*
- * Make one pass to see how big a buffer we
+ * 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)
- {
+ for (fr = s; *fr != '\0'; fr++) {
+ switch (*fr) {
case '%':
case '#':
- if (fr > s && fr[-1] == *fr)
- {
+ 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)
- {
+ } else if (fr[1] != *fr) {
/*
* Single char (not repeated). Treat specially.
*/
@@ -365,29 +265,24 @@ fexpand(s)
}
}
- e = (char *) ecalloc(n+1, sizeof(char));
+ e = ecalloc(n+1, sizeof (char));
/*
* Now copy the string, expanding any "%" or "#".
*/
to = e;
- for (fr = s; *fr != '\0'; fr++)
- {
- switch (*fr)
- {
+ for (fr = s; *fr != '\0'; fr++) {
+ switch (*fr) {
case '%':
case '#':
- if (fr > s && fr[-1] == *fr)
- {
+ if (fr > s && fr[-1] == *fr) {
*to++ = *fr;
- } else if (fr[1] != *fr)
- {
+ } else if (fr[1] != *fr) {
ifile = fchar_ifile(*fr);
- if (ifile == NULL_IFILE)
+ if (ifile == NULL_IFILE) {
*to++ = *fr;
- else
- {
- strlcpy(to, get_filename(ifile),
+ } else {
+ (void) strlcpy(to, get_filename(ifile),
e + n + 1 - to);
to += strlen(to);
}
@@ -402,57 +297,26 @@ fexpand(s)
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 *
+fcomplete(char *s)
{
char *fpat;
char *qs;
- size_t len;
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;
- len = strlen(s) + 4;
- fpat = (char *) ecalloc(len, sizeof(char));
- if (strchr(slash, '.') == NULL)
- SNPRINTF1(fpat, len, "%s*.*", s);
- else
- SNPRINTF1(fpat, len, "%s*", s);
- }
-#else
- {
- len = strlen(s) + 2;
- fpat = (char *) ecalloc(len, sizeof(char));
- SNPRINTF1(fpat, len, "%s*", s);
- }
-#endif
+ fpat = easprintf("%s*", s);
+
qs = lglob(fpat);
s = shell_unquote(qs);
- if (strcmp(s,fpat) == 0)
- {
+ if (strcmp(s, fpat) == 0) {
/*
* The filename didn't expand.
*/
@@ -463,33 +327,29 @@ fcomplete(s)
free(fpat);
return (qs);
}
-#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
+bin_file(int f)
{
int n;
int bin_count = 0;
char data[256];
- char* p;
- char* pend;
+ char *p;
+ char *pend;
if (!seekable(f))
return (0);
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
return (0);
- n = read(f, data, sizeof(data));
+ n = read(f, data, sizeof (data));
pend = &data[n];
- for (p = data; p < pend; )
- {
+ for (p = data; p < pend; ) {
LWCHAR c = step_char(&p, +1, pend);
- if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
- {
+ if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) {
do {
c = step_char(&p, +1, pend);
} while (p < pend && is_ansi_middle(c));
@@ -506,372 +366,241 @@ bin_file(f)
/*
* Try to determine the size of a file by seeking to the end.
*/
- static POSITION
-seek_filesize(f)
- int f;
+static off_t
+seek_filesize(int f)
{
off_t spos;
spos = lseek(f, (off_t)0, SEEK_END);
if (spos == BAD_LSEEK)
- return (NULL_POSITION);
- return ((POSITION) spos);
+ return (-1);
+ return (spos);
}
/*
* Read a string from a file.
* Return a pointer to the string in memory.
*/
- static char *
-readfd(fd)
- FILE *fd;
+static char *
+readfd(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++)
- {
+ buf = ecalloc(len, sizeof (char));
+ for (p = buf; ; p++) {
if ((ch = getc(fd)) == '\n' || ch == EOF)
break;
- if (p - buf >= len-1)
- {
+ 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));
+ p = ecalloc(len, sizeof (char));
strlcpy(p, buf, len);
free(buf);
buf = p;
p = buf + strlen(buf);
}
- *p = ch;
+ *p = (char)ch;
}
*p = '\0';
return (buf);
}
-
-
-#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;
+static FILE *
+shellcmd(char *cmd)
{
FILE *fd;
-#if HAVE_SHELL
char *shell;
shell = lgetenv("SHELL");
- if (shell != NULL && *shell != '\0')
- {
+ if (shell != NULL && *shell != '\0') {
char *scmd;
char *esccmd;
/*
- * Read the output of <$SHELL -c cmd>.
+ * Read the output of <$SHELL -c cmd>.
* Escape any metacharacters in the command.
*/
esccmd = shell_quote(cmd);
- if (esccmd == NULL)
- {
+ if (esccmd == NULL) {
fd = popen(cmd, "r");
- } else
- {
- size_t len = strlen(shell) + strlen(esccmd) + 5;
- scmd = (char *) ecalloc(len, sizeof(char));
- SNPRINTF3(scmd, len, "%s %s %s", shell, shell_coption(), esccmd);
+ } else {
+ scmd = easprintf("%s -c %s", shell, esccmd);
free(esccmd);
fd = popen(scmd, "r");
free(scmd);
}
- } else
-#endif
- {
+ } else {
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 */
-
-
-#if !SMALL
/*
* Expand a filename, doing any system-specific metacharacter substitutions.
*/
- public char *
-lglob(filename)
- char *filename;
+char *
+lglob(char *filename)
{
char *gfilename;
char *ofilename;
+ glob_t list;
+ int i;
+ int length;
+ char *p;
+ char *qfilename;
ofilename = fexpand(filename);
if (secure)
return (ofilename);
filename = shell_unquote(ofilename);
-#ifdef DECL_GLOB_LIST
-{
/*
* The globbing function returns a list of names.
*/
- int length;
- char *p;
- char *qfilename;
- DECL_GLOB_LIST(list)
- GLOB_LIST(filename, list);
- if (GLOB_LIST_FAILED(list))
- {
+#ifndef GLOB_TILDE
+#define GLOB_TILDE 0
+#endif
+#ifndef GLOB_LIMIT
+#define GLOB_LIMIT 0
+#endif
+ if (glob(filename, GLOB_TILDE | GLOB_LIMIT, NULL, &list) != 0) {
free(filename);
return (ofilename);
}
length = 1; /* Room for trailing null byte */
- for (SCAN_GLOB_LIST(list, p))
- {
- INIT_GLOB_LIST(list, p);
+ for (i = 0; i < list.gl_pathc; i++) {
+ p = list.gl_pathv[i];
qfilename = shell_quote(p);
- if (qfilename != NULL)
- {
- length += strlen(qfilename) + 1;
+ if (qfilename != NULL) {
+ length += strlen(qfilename) + 1;
free(qfilename);
}
}
- gfilename = (char *) ecalloc(length, sizeof(char));
- for (SCAN_GLOB_LIST(list, p))
- {
- INIT_GLOB_LIST(list, p);
+ gfilename = ecalloc(length, sizeof (char));
+ for (i = 0; i < list.gl_pathc; i++) {
+ p = list.gl_pathv[i];
qfilename = shell_quote(p);
- if (qfilename != NULL)
- {
- snprintf(gfilename + strlen(gfilename),
- length - strlen(gfilename), "%s ", qfilename);
- free(qfilename);
- }
- }
- /*
- * Overwrite the final trailing space with a null terminator.
- */
- if (gfilename[0] != '\0' && gfilename[strlen(gfilename) - 1] == ' ')
- gfilename[strlen(gfilename) - 1] = '\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;
- char *pathname;
- char *qpathname;
- 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;
- pathname = (char *) ecalloc(n, sizeof(char));
- SNPRINTF3(pathname, n, "%s%s%s", drive, dir, fnd.GLOB_NAME);
- qpathname = shell_quote(pathname);
- free(pathname);
- if (qpathname != NULL)
- {
- n = strlen(qpathname);
- 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));
- strlcpy(p, gfilename, len);
- free(gfilename);
- gfilename = p;
- p = gfilename + strlen(gfilename);
+ if (qfilename != NULL) {
+ if (i != 0) {
+ (void) strlcat(gfilename, " ", length);
}
- strlcpy(p, qpathname, gfilename + len - p);
- free(qpathname);
- p += n;
- *p++ = ' ';
+ (void) strlcat(gfilename, qfilename, length);
+ free(qfilename);
}
- } 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;
- char *esc;
- size_t len;
-
- esc = get_meta_escape();
- if (strlen(esc) == 0)
- esc = "-";
- esc = shell_quote(esc);
- if (esc == NULL)
- {
- free(filename);
- return (ofilename);
- }
- lessecho = lgetenv("LESSECHO");
- if (lessecho == NULL || *lessecho == '\0')
- lessecho = "lessecho";
- /*
- * Invoke lessecho, and read its output (a globbed list of filenames).
- */
- len = strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24;
- cmd = (char *) ecalloc(len, sizeof(char));
- SNPRINTF4(cmd, len, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc);
- free(esc);
- for (s = metachars(); *s != '\0'; s++)
- snprintf(cmd + strlen(cmd), len - strlen(cmd), "-n0x%x ", *s);
- snprintf(cmd + strlen(cmd), len - strlen(cmd), "-- %s", ofilename);
- fd = shellcmd(cmd);
- 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
+ globfree(&list);
free(filename);
free(ofilename);
return (gfilename);
}
-#endif /* !SMALL */
/*
- * Return number of %s escapes in a string.
- * Return a large number if there are any other % escapes besides %s.
+ * Expand LESSOPEN or LESSCLOSE. Returns a newly allocated string
+ * on success, NULL otherwise.
*/
- static int
-num_pct_s(lessopen)
- char *lessopen;
+static char *
+expand_pct_s(const char *fmt, ...)
{
- int num;
+ int n;
+ int len;
+ char *r, *d;
+ const char *f[3]; /* max expansions + 1 for NULL */
+ va_list ap;
+
+ va_start(ap, fmt);
+ for (n = 0; n < ((sizeof (f)/sizeof (f[0])) - 1); n++) {
+ f[n] = (const char *)va_arg(ap, const char *);
+ if (f[n] == NULL) {
+ break;
+ }
+ }
+ va_end(ap);
+ f[n] = NULL; /* terminate list */
+
+ len = strlen(fmt) + 1;
+ for (n = 0; f[n] != NULL; n++) {
+ len += strlen(f[n]); /* technically could -2 for "%s" */
+ }
+ r = ecalloc(len, sizeof (char));
- for (num = 0;; num++)
- {
- lessopen = strchr(lessopen, '%');
- if (lessopen == NULL)
+ for (n = 0, d = r; *fmt != 0; ) {
+ if (*fmt != '%') {
+ *d++ = *fmt++;
+ continue;
+ }
+ fmt++;
+ /* Permit embedded "%%" */
+ switch (*fmt) {
+ case '%':
+ *d++ = '%';
+ fmt++;
+ break;
+ case 's':
+ if (f[n] == NULL) {
+ va_end(ap);
+ free(r);
+ return (NULL);
+ }
+ (void) strlcpy(d, f[n++], r + len - d);
+ fmt++;
+ d += strlen(d);
break;
- if (*++lessopen != 's')
- return (999);
+ default:
+ va_end(ap);
+ free(r);
+ return (NULL);
+ }
}
- return (num);
+ *d = '\0';
+ return (r);
}
/*
- * See if we should open a "replacement file"
+ * 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;
+char *
+open_altfile(char *filename, int *pf, void **pfd)
{
-#if !HAVE_POPEN
- return (NULL);
-#else
char *lessopen;
char *cmd;
- size_t len;
FILE *fd;
-#if HAVE_FILENO
int returnfd = 0;
-#endif
-
+
if (!use_lessopen || secure)
return (NULL);
ch_ungetchar(-1);
if ((lessopen = lgetenv("LESSOPEN")) == NULL)
return (NULL);
- while (*lessopen == '|')
- {
+ while (*lessopen == '|') {
/*
- * If LESSOPEN starts with a |, it indicates
+ * If LESSOPEN starts with a |, it indicates
* a "pipe preprocessor".
*/
-#if !HAVE_FILENO
- error("LESSOPEN pipe is not supported", NULL_PARG);
- return (NULL);
-#else
lessopen++;
returnfd++;
-#endif
}
if (*lessopen == '-') {
/*
@@ -882,27 +611,20 @@ open_altfile(filename, pf, pfd)
if (strcmp(filename, "-") == 0)
return (NULL);
}
- if (num_pct_s(lessopen) > 1)
- {
+
+ if ((cmd = expand_pct_s(lessopen, filename, NULL)) == NULL) {
error("Invalid LESSOPEN variable", NULL_PARG);
return (NULL);
}
-
- len = strlen(lessopen) + strlen(filename) + 2;
- cmd = (char *) ecalloc(len, sizeof(char));
- SNPRINTF1(cmd, len, lessopen, filename);
fd = shellcmd(cmd);
free(cmd);
- if (fd == NULL)
- {
+ if (fd == NULL) {
/*
* Cannot create the pipe.
*/
return (NULL);
}
-#if HAVE_FILENO
- if (returnfd)
- {
+ if (returnfd) {
int f;
char c;
@@ -911,13 +633,11 @@ open_altfile(filename, pf, pfd)
* If it does, push the char back on the pipe.
*/
f = fileno(fd);
- SET_BINARY(f);
- if (read(f, &c, 1) != 1)
- {
+ if (read(f, &c, 1) != 1) {
/*
* Pipe is empty.
* If more than 1 pipe char was specified,
- * the exit status tells whether the file itself
+ * the exit status tells whether the file itself
* is empty, or if there is no alt file.
* If only one pipe char, just assume no alt file.
*/
@@ -934,7 +654,6 @@ open_altfile(filename, pf, pfd)
*pf = f;
return (save("-"));
}
-#endif
cmd = readfd(fd);
pclose(fd);
if (*cmd == '\0')
@@ -943,84 +662,50 @@ open_altfile(filename, pf, pfd)
*/
return (NULL);
return (cmd);
-#endif /* HAVE_POPEN */
}
/*
* Close a replacement file.
*/
- public void
-close_altfile(altfilename, filename, pipefd)
- char *altfilename;
- char *filename;
- void *pipefd;
+void
+close_altfile(char *altfilename, char *filename, void *pipefd)
{
-#if HAVE_POPEN
char *lessclose;
FILE *fd;
char *cmd;
- size_t len;
-
+
if (secure)
return;
- if (pipefd != NULL)
- {
-#if OS2
- /*
- * The pclose function of OS/2 emx sometimes fails.
- * Send SIGINT to the piped process before closing it.
- */
- kill(((FILE*)pipefd)->_pid, SIGINT);
-#endif
- pclose((FILE*) pipefd);
+ if (pipefd != NULL) {
+ pclose((FILE *)pipefd);
}
if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
- return;
- if (num_pct_s(lessclose) > 2)
- {
- error("Invalid LESSCLOSE variable");
+ return;
+ cmd = expand_pct_s(lessclose, filename, altfilename, NULL);
+ if (cmd == NULL) {
+ error("Invalid LESSCLOSE variable", NULL_PARG);
return;
}
- len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2;
- cmd = (char *) ecalloc(len, sizeof(char));
- SNPRINTF2(cmd, len, lessclose, filename, altfilename);
fd = shellcmd(cmd);
free(cmd);
if (fd != NULL)
- pclose(fd);
-#endif
+ (void) pclose(fd);
}
-
+
/*
* Is the specified file a directory?
*/
- public int
-is_dir(filename)
- char *filename;
+int
+is_dir(char *filename)
{
int isdir = 0;
-
- filename = shell_unquote(filename);
-#if HAVE_STAT
-{
int r;
struct stat statbuf;
+ filename = shell_unquote(filename);
+
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);
}
@@ -1030,44 +715,27 @@ is_dir(filename)
* 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;
+char *
+bad_file(char *filename)
{
- register char *m = NULL;
- size_t len;
+ char *m = NULL;
filename = shell_unquote(filename);
- if (!force_open && is_dir(filename))
- {
- static char is_a_dir[] = " is a directory";
-
- len = strlen(filename) + sizeof(is_a_dir);
- m = (char *) ecalloc(len, sizeof(char));
- strlcpy(m, filename, len);
- strlcat(m, is_a_dir, len);
- } else
- {
-#if HAVE_STAT
+ if (!force_open && is_dir(filename)) {
+ m = easprintf("%s is a directory", filename);
+ } else {
int r;
struct stat statbuf;
r = stat(filename, &statbuf);
- if (r < 0)
- {
+ if (r < 0) {
m = errno_message(filename);
- } else if (force_open)
- {
+ } 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)";
- len = strlen(filename) + sizeof(not_reg);
- m = (char *) ecalloc(len, sizeof(char));
- strlcpy(m, filename, len);
- strlcat(m, not_reg, len);
+ } else if (!S_ISREG(statbuf.st_mode)) {
+ m = easprintf("%s is not a regular file (use -f to "
+ "see it)", filename);
}
-#endif
}
free(filename);
return (m);
@@ -1077,50 +745,28 @@ bad_file(filename)
* Return the size of a file, as cheaply as possible.
* In Unix, we can stat the file.
*/
- public POSITION
-filesize(f)
- int f;
+off_t
+filesize(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 (statbuf.st_size);
return (seek_filesize(f));
}
/*
- *
- */
- public char *
-shell_coption()
-{
- return ("-c");
-}
-
-/*
* Return last component of a pathname.
*/
- public char *
-last_component(name)
- char *name;
+char *
+last_component(char *name)
{
char *slash;
- for (slash = name + strlen(name); slash > name; )
- {
+ for (slash = name + strlen(name); slash > name; ) {
--slash;
- if (*slash == *PATHNAME_SEP || *slash == '/')
+ if (*slash == '/')
return (slash + 1);
}
return (name);
}
-
diff --git a/usr.bin/less/forwback.c b/usr.bin/less/forwback.c
index 9e2d1a10433..6c7d6c23eb7 100644
--- a/usr.bin/less/forwback.c
+++ b/usr.bin/less/forwback.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Primitives for displaying the file on the screen,
@@ -16,10 +19,10 @@
#include "less.h"
#include "position.h"
-public int screen_trashed;
-public int squished;
-public int no_back_scroll = 0;
-public int forw_prompt;
+int screen_trashed;
+int squished;
+int no_back_scroll = 0;
+int forw_prompt;
extern volatile sig_atomic_t sigs;
extern int top_scroll;
@@ -32,18 +35,16 @@ extern int ignore_eoi;
extern int clear_bg;
extern int final_attr;
extern int oldbot;
-#if TAGS
extern char *tagoption;
-#endif
/*
* Sound the bell to indicate user is trying to move past end of file.
*/
- static void
-eof_bell()
+static void
+eof_bell(void)
{
if (quiet == NOT_QUIET)
- bell();
+ ring_bell();
else
vbell();
}
@@ -51,15 +52,15 @@ eof_bell()
/*
* Check to see if the end of file is currently displayed.
*/
- public int
-eof_displayed()
+int
+eof_displayed(void)
{
- POSITION pos;
+ off_t pos;
if (ignore_eoi)
return (0);
- if (ch_length() == NULL_POSITION)
+ if (ch_length() == -1)
/*
* If the file length is not known,
* we can't possibly be displaying EOF.
@@ -72,16 +73,16 @@ eof_displayed()
* we must be just at EOF.
*/
pos = position(BOTTOM_PLUS_ONE);
- return (pos == NULL_POSITION || pos == ch_length());
+ return (pos == -1 || pos == ch_length());
}
/*
* Check to see if the entire file is currently displayed.
*/
- public int
-entire_file_displayed()
+int
+entire_file_displayed(void)
{
- POSITION pos;
+ off_t pos;
/* Make sure last line of file is displayed. */
if (!eof_displayed())
@@ -89,7 +90,7 @@ entire_file_displayed()
/* Make sure first line of file is displayed. */
pos = position(0);
- return (pos == NULL_POSITION || pos == 0);
+ return (pos == -1 || pos == 0);
}
/*
@@ -98,8 +99,8 @@ entire_file_displayed()
* of the screen; this can happen when we display a short file
* for the first time.
*/
- public void
-squish_check()
+void
+squish_check(void)
{
if (!squished)
return;
@@ -108,23 +109,17 @@ squish_check()
}
/*
- * Display n lines, scrolling forward,
+ * 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.
+ * real line. If nblank > 0, the pos must be -1.
* 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;
+void
+forw(int n, off_t pos, int force, int only_last, int nblank)
{
- int eof = 0;
int nlines = 0;
int do_repaint;
static int first_time = 1;
@@ -132,21 +127,19 @@ forw(n, pos, force, only_last, nblank)
squish_check();
/*
- * do_repaint tells us not to display anything till the end,
+ * 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
+ * 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);
+ do_repaint = (only_last && n > sc_height-1) ||
+ (forw_scroll >= 0 && n > forw_scroll && n != sc_height-1);
- if (!do_repaint)
- {
- if (top_scroll && n >= sc_height - 1 && pos != ch_length())
- {
+ if (!do_repaint) {
+ if (top_scroll && n >= sc_height - 1 && pos != ch_length()) {
/*
* Start a new screen.
* {{ This is not really desirable if we happen
@@ -156,66 +149,58 @@ forw(n, pos, force, only_last, nblank)
pos_clear();
add_forw_pos(pos);
force = 1;
- clear();
+ do_clear();
home();
}
- if (pos != position(BOTTOM_PLUS_ONE) || empty_screen())
- {
+ if (pos != position(BOTTOM_PLUS_ONE) || empty_screen()) {
/*
* This is not contiguous with what is
- * currently displayed. Clear the screen image
+ * currently displayed. Clear the screen image
* (position table) and start a new screen.
*/
pos_clear();
add_forw_pos(pos);
force = 1;
- if (top_scroll)
- {
- clear();
+ if (top_scroll) {
+ do_clear();
home();
- } else if (!first_time)
- {
+ } else if (!first_time) {
putstr("...skipping...\n");
}
}
}
- while (--n >= 0)
- {
+ while (--n >= 0) {
/*
* Read the next line of input.
*/
- if (nblank > 0)
- {
+ if (nblank > 0) {
/*
- * Still drawing blanks; don't get a line
+ * 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
- {
- /*
+ } else {
+ /*
* Get the next line from the file.
*/
pos = forw_line(pos);
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
- * End of file: stop here unless the top line
+ * 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)
+ if (!force && position(TOP) != -1)
break;
- if (!empty_lines(0, 0) &&
+ if (!empty_lines(0, 0) &&
!empty_lines(1, 1) &&
- empty_lines(2, sc_height-1))
+ empty_lines(2, sc_height-1))
break;
}
}
@@ -237,37 +222,12 @@ forw(n, pos, force, only_last, nblank)
* 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)
- {
+ if (first_time && pos == -1 && !top_scroll &&
+ tagoption == NULL && !plusoption) {
squished = 1;
continue;
}
put_line();
-#if 0
- /* {{
- * Can't call clear_eol here. The cursor might be at end of line
- * on an ignaw terminal, so clear_eol would clear the last char
- * of the current line instead of all of the next line.
- * If we really need to do this on clear_bg terminals, we need
- * to find a better way.
- * }}
- */
- if (clear_bg && apply_at_specials(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();
- }
-#endif
forw_prompt = 1;
}
@@ -282,26 +242,20 @@ forw(n, pos, force, only_last, nblank)
/*
* Display n lines, scrolling backward.
*/
- public void
-back(n, pos, force, only_last)
- register int n;
- POSITION pos;
- int force;
- int only_last;
+void
+back(int n, off_t 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));
- while (--n >= 0)
- {
+ while (--n >= 0) {
/*
* Get the previous line of input.
*/
pos = back_line(pos);
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* Beginning of file: stop here unless "force" is true.
*/
@@ -314,8 +268,7 @@ back(n, pos, force, only_last)
*/
add_back_pos(pos);
nlines++;
- if (!do_repaint)
- {
+ if (!do_repaint) {
home();
add_line();
put_line();
@@ -335,16 +288,13 @@ back(n, pos, force, only_last)
* 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;
+void
+forward(int n, int force, int only_last)
{
- POSITION pos;
+ off_t pos;
- if (get_quit_at_eof() && eof_displayed() && !(ch_getflags() & CH_HELPFILE))
- {
+ if (get_quit_at_eof() && eof_displayed() &&
+ !(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.
@@ -355,27 +305,22 @@ forward(n, force, only_last)
}
pos = position(BOTTOM_PLUS_ONE);
- if (pos == NULL_POSITION && (!force || empty_lines(2, sc_height-1)))
- {
- if (ignore_eoi)
- {
+ if (pos == -1 && (!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())
+ if (empty_screen()) {
pos = ch_zero();
- else
- {
- do
- {
+ } else {
+ do {
back(1, position(TOP), 1, 0);
pos = position(BOTTOM_PLUS_ONE);
- } while (pos == NULL_POSITION);
+ } while (pos == -1);
}
- } else
- {
+ } else {
eof_bell();
return;
}
@@ -387,19 +332,15 @@ forward(n, force, only_last)
* 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;
+void
+backward(int n, int force, int only_last)
{
- POSITION pos;
+ off_t pos;
pos = position(TOP);
- if (pos == NULL_POSITION && (!force || position(BOTTOM) == 0))
- {
+ if (pos == -1 && (!force || position(BOTTOM) == 0)) {
eof_bell();
- return;
+ return;
}
back(n, pos, force, only_last);
}
@@ -410,8 +351,8 @@ backward(n, force, only_last)
* back_scroll, because the default case depends on sc_height and
* top_scroll, as well as back_scroll.
*/
- public int
-get_back_scroll()
+int
+get_back_scroll(void)
{
if (no_back_scroll)
return (0);
diff --git a/usr.bin/less/funcs.h b/usr.bin/less/funcs.h
index 0e138ea4604..701eefd0780 100644
--- a/usr.bin/less/funcs.h
+++ b/usr.bin/less/funcs.h
@@ -1,293 +1,290 @@
- 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 win32_scroll_up ();
- public void lower_left ();
- public void line_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 at_enter ();
- public void at_exit ();
- public void at_switch ();
- public int is_at_equiv ();
- public int apply_at_specials ();
- public void backspace ();
- public void putbs ();
- public char WIN32getch ();
- public void WIN32setcolors ();
- public void WIN32textout ();
- 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 void ch_setbufspace ();
- public void ch_flush ();
- public int seekable ();
- public void ch_set_eof ();
- 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 char * prutfchar ();
- public int utf_len ();
- public int is_utf8_well_formed ();
- public LWCHAR get_wchar ();
- public void put_wchar ();
- public LWCHAR step_char ();
- public int is_composing_char ();
- public int is_ubin_char ();
- public int is_wide_char ();
- public int is_combining_char ();
- 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 LINENUM cmd_int ();
- public char * get_cmdbuf ();
- public char * cmd_lastpattern ();
- public void init_cmdhist ();
- public void save_cmdhist ();
- public int in_mca ();
- public void dispversion ();
- public int getcc ();
- public void ungetcc ();
- public void ungetsc ();
- public void commands ();
- public int cvt_length ();
- public int * cvt_alloc_chpos ();
- public void cvt_text ();
- public void init_cmds ();
- public void add_fcmd_table ();
- public void add_ecmd_table ();
- 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 void reopen_curr_ifile ();
- public int edit_stdin ();
- public void cat_file ();
- public void use_logfile ();
- public char * shell_unquote ();
- public char * get_meta_escape ();
- public char * shell_quote ();
- public char * homefile ();
- public char * fexpand ();
- public char * fcomplete ();
- public int bin_file ();
- public char * lglob ();
- public char * open_altfile ();
- public void close_altfile ();
- public int is_dir ();
- public char * bad_file ();
- public POSITION filesize ();
- public char * shell_coption ();
- public char * last_component ();
- public int eof_displayed ();
- public int entire_file_displayed ();
- public void squish_check ();
- 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 int is_ascii_char ();
- public void prewind ();
- public void plinenum ();
- public void pshift_all ();
- public int is_ansi_end ();
- public int is_ansi_middle ();
- public int pappend ();
- public int pflushmbc ();
- public void pdone ();
- public void set_status_col ();
- 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 LINENUM find_linenum ();
- public POSITION find_pos ();
- public LINENUM 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_j ();
- public void calc_jump_sline ();
- public void opt_shift ();
- public void calc_shift_count ();
- 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_x ();
- public void opt_quote ();
- public void opt_query ();
- public int get_swindow ();
- public char * propt ();
- public void scan_option ();
- public void toggle_option ();
- public int opt_has_param ();
- public char * opt_prompt ();
- public int isoptpending ();
- public void nopendopt ();
- public int getnum ();
- public long getfraction ();
- public int get_quit_at_eof ();
- public void init_option ();
- public struct loption * findopt ();
- public struct loption * findopt_name ();
- public int iread ();
- public long get_time ();
- public char * errno_message ();
- public int percentage ();
- public POSITION percent_pos ();
- public int os9_signal ();
- 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 int compile_pattern ();
- public void uncompile_pattern ();
- public int is_null_pattern ();
- public int match_pattern ();
- 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 char * wait_message ();
- public void init_search ();
- public void repaint_hilite ();
- public void clear_attn ();
- public void undo_search ();
- public void clr_hlist ();
- public void clr_hilite ();
- public void clr_filter ();
- public int is_filtered ();
- public int is_hilited ();
- public void chg_caseless ();
- public void chg_hilite ();
- public int search ();
- public void prep_hilite ();
- public void set_filter_pattern ();
- public int is_filtering ();
- public RETSIGTYPE winch ();
- public RETSIGTYPE winch ();
- public void init_signals ();
- public void psignals ();
- public void cleantags ();
- public int gettagtype ();
- public void findtag ();
- public POSITION tagsearch ();
- public char * nexttag ();
- public char * prevtag ();
- public int ntags ();
- public int curr_tag ();
- public int edit_tagfile ();
- public void open_getchr ();
- public void close_getchr ();
- public int getchr ();
- public void (*lsignal()) ();
- public char * helpfile ();
+/*
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ *
+ * This file is made available under the terms of the Less License.
+ */
+
+#include <regex.h>
+
+struct mlist;
+struct loption;
+
+extern char *save(const char *);
+extern void *ecalloc(int, unsigned int);
+/*PRINTFLIKE1*/
+extern char *easprintf(const char *, ...);
+extern char *estrdup(const char *);
+extern char *skipsp(char *);
+extern int sprefix(char *, char *, int);
+extern void quit(int);
+extern void raw_mode(int);
+extern char *special_key_str(int);
+extern void get_term(void);
+extern void init(void);
+extern void deinit(void);
+extern void home(void);
+extern void add_line(void);
+extern void lower_left(void);
+extern void line_left(void);
+extern void goto_line(int);
+extern void vbell(void);
+extern void ring_bell(void);
+extern void do_clear(void);
+extern void clear_eol(void);
+extern void clear_bot(void);
+extern void at_enter(int);
+extern void at_exit(void);
+extern void at_switch(int);
+extern int is_at_equiv(int, int);
+extern int apply_at_specials(int);
+extern void putbs(void);
+extern void match_brac(int, int, int, int);
+extern void ch_ungetchar(int);
+extern void end_logfile(void);
+extern void sync_logfile(void);
+extern int ch_seek(off_t);
+extern int ch_end_seek(void);
+extern int ch_beg_seek(void);
+extern off_t ch_length(void);
+extern off_t ch_tell(void);
+extern int ch_forw_get(void);
+extern int ch_back_get(void);
+extern void ch_setbufspace(int);
+extern void ch_flush(void);
+extern int seekable(int);
+extern void ch_set_eof(void);
+extern void ch_init(int, int);
+extern void ch_close(void);
+extern int ch_getflags(void);
+extern void init_charset(void);
+extern int binary_char(LWCHAR);
+extern int control_char(LWCHAR);
+extern char *prchar(LWCHAR);
+extern char *prutfchar(LWCHAR);
+extern int utf_len(char);
+extern int is_utf8_well_formed(const char *);
+extern LWCHAR get_wchar(const char *);
+extern void put_wchar(char **, LWCHAR);
+extern LWCHAR step_char(char **, int, char *);
+extern int is_composing_char(LWCHAR);
+extern int is_ubin_char(LWCHAR);
+extern int is_wide_char(LWCHAR);
+extern int is_combining_char(LWCHAR, LWCHAR);
+extern void cmd_reset(void);
+extern void clear_cmd(void);
+extern void cmd_putstr(char *);
+extern int len_cmdbuf(void);
+extern void set_mlist(void *, int);
+extern void cmd_addhist(struct mlist *, const char *);
+extern void cmd_accept(void);
+extern int cmd_char(int);
+extern LINENUM cmd_int(long *);
+extern char *get_cmdbuf(void);
+extern char *cmd_lastpattern(void);
+extern void init_cmdhist(void);
+extern void save_cmdhist(void);
+extern int in_mca(void);
+extern void dispversion(void);
+extern int getcc(void);
+extern void ungetcc(int);
+extern void ungetsc(char *);
+extern void commands(void);
+extern int cvt_length(int);
+extern int *cvt_alloc_chpos(int);
+extern void cvt_text(char *, char *, int *, int *, int);
+extern void init_cmds(void);
+extern void add_fcmd_table(char *, int);
+extern void add_ecmd_table(char *, int);
+extern int fcmd_decode(const char *, char **);
+extern int ecmd_decode(const char *, char **);
+extern char *lgetenv(char *);
+extern int lesskey(char *, int);
+extern void add_hometable(char *, char *, int);
+extern int editchar(int, int);
+extern void init_textlist(struct textlist *, char *);
+extern char *forw_textlist(struct textlist *, char *);
+extern char *back_textlist(struct textlist *, char *);
+extern int edit(char *);
+extern int edit_ifile(IFILE);
+extern int edit_list(char *);
+extern int edit_first(void);
+extern int edit_last(void);
+extern int edit_next(int);
+extern int edit_prev(int);
+extern int edit_index(int);
+extern IFILE save_curr_ifile(void);
+extern void unsave_ifile(IFILE);
+extern void reedit_ifile(IFILE);
+extern void reopen_curr_ifile(void);
+extern int edit_stdin(void);
+extern void cat_file(void);
+extern void use_logfile(char *);
+extern char *shell_unquote(char *);
+extern char *get_meta_escape(void);
+extern char *shell_quote(const char *);
+extern char *homefile(char *);
+extern char *fexpand(char *);
+extern char *fcomplete(char *);
+extern int bin_file(int f);
+extern char *lglob(char *);
+extern char *open_altfile(char *, int *, void **);
+extern void close_altfile(char *, char *, void *);
+extern int is_dir(char *);
+extern char *bad_file(char *);
+extern off_t filesize(int);
+extern char *last_component(char *);
+extern int eof_displayed(void);
+extern int entire_file_displayed(void);
+extern void squish_check(void);
+extern void forw(int, off_t, int, int, int);
+extern void back(int, off_t, int, int);
+extern void forward(int, int, int);
+extern void backward(int, int, int);
+extern int get_back_scroll(void);
+extern void del_ifile(IFILE);
+extern IFILE next_ifile(IFILE);
+extern IFILE prev_ifile(IFILE);
+extern IFILE getoff_ifile(IFILE);
+extern int nifile(void);
+extern IFILE get_ifile(char *, IFILE);
+extern char *get_filename(IFILE);
+extern int get_index(IFILE);
+extern void store_pos(IFILE, struct scrpos *);
+extern void get_pos(IFILE, struct scrpos *);
+extern int opened(IFILE);
+extern void hold_ifile(IFILE, int);
+extern int held_ifile(IFILE);
+extern void set_open(IFILE);
+extern void *get_filestate(IFILE);
+extern void set_filestate(IFILE, void *);
+extern off_t forw_line(off_t);
+extern off_t back_line(off_t);
+extern void set_attnpos(off_t);
+extern void jump_forw(void);
+extern void jump_back(LINENUM);
+extern void repaint(void);
+extern void jump_percent(int, long);
+extern void jump_line_loc(off_t, int);
+extern void jump_loc(off_t, int);
+extern void init_line(void);
+extern int is_ascii_char(LWCHAR);
+extern void prewind(void);
+extern void plinenum(LINENUM);
+extern void pshift_all(void);
+extern int is_ansi_end(LWCHAR);
+extern int is_ansi_middle(LWCHAR);
+extern int pappend(char, off_t);
+extern int pflushmbc(void);
+extern void pdone(int, int);
+extern void set_status_col(char);
+extern int gline(int, int *);
+extern void null_line(void);
+extern off_t forw_raw_line(off_t, char **, int *);
+extern off_t back_raw_line(off_t, char **, int *);
+extern void clr_linenum(void);
+extern void add_lnum(LINENUM, off_t);
+extern LINENUM find_linenum(off_t);
+extern off_t find_pos(LINENUM);
+extern LINENUM currline(int);
+extern void lsystem(const char *, const char *);
+extern int pipe_mark(int, char *);
+extern void init_mark(void);
+extern int badmark(int);
+extern void setmark(int);
+extern void lastmark(void);
+extern void gomark(int);
+extern off_t markpos(int);
+extern void unmark(IFILE);
+extern void opt_o(int, char *);
+extern void opt__O(int, char *);
+extern void opt_j(int, char *);
+extern void calc_jump_sline(void);
+extern void opt_shift(int, char *);
+extern void calc_shift_count(void);
+extern void opt_k(int, char *);
+extern void opt_t(int, char *);
+extern void opt__T(int, char *);
+extern void opt_p(int, char *);
+extern void opt__P(int, char *);
+extern void opt_b(int, char *);
+extern void opt_i(int, char *);
+extern void opt__V(int, char *);
+extern void opt_x(int, char *);
+extern void opt_quote(int, char *);
+extern void opt_query(int, char *);
+extern int get_swindow(void);
+extern char *propt(int);
+extern void scan_option(char *);
+extern void toggle_option(struct loption *, int, char *, int);
+extern int opt_has_param(struct loption *);
+extern char *opt_prompt(struct loption *);
+extern int isoptpending(void);
+extern void nopendopt(void);
+extern int getnum(char **, char *, int *);
+extern long getfraction(char **, char *, int *);
+extern int get_quit_at_eof(void);
+extern void init_option(void);
+extern struct loption *findopt(int);
+extern struct loption *findopt_name(char **, char **, int *);
+extern int iread(int, unsigned char *, unsigned int);
+extern long get_time(void);
+extern char *errno_message(char *);
+extern int percentage(off_t, off_t);
+extern off_t percent_pos(off_t, int, long);
+extern void put_line(void);
+extern void flush(void);
+extern int putchr(int);
+extern void putstr(const char *);
+extern void get_return(void);
+extern void error(const char *, PARG *);
+extern void ierror(const char *, PARG *);
+extern int query(const char *, PARG *);
+extern int compile_pattern(char *, int, regex_t **);
+extern void uncompile_pattern(regex_t **);
+extern int is_null_pattern(void *);
+extern int match_pattern(void *, char *, char *, int, char **, char **,
+ int, int);
+extern off_t position(int);
+extern void add_forw_pos(off_t);
+extern void add_back_pos(off_t);
+extern void pos_clear(void);
+extern void pos_init(void);
+extern int onscreen(off_t);
+extern int empty_screen(void);
+extern int empty_lines(int, int);
+extern void get_scrpos(struct scrpos *);
+extern int adjsline(int);
+extern void init_prompt(void);
+extern char *pr_expand(const char *, int);
+extern char *eq_message(void);
+extern char *prompt_string(void);
+extern char *wait_message(void);
+extern void init_search(void);
+extern void repaint_hilite(int);
+extern void clear_attn(void);
+extern void undo_search(void);
+extern void clr_hilite(void);
+extern int is_filtered(off_t);
+extern int is_hilited(off_t, off_t, int, int *);
+extern void chg_caseless(void);
+extern void chg_hilite(void);
+extern int search(int, char *, int);
+extern void prep_hilite(off_t, off_t, int);
+extern void set_filter_pattern(char *, int);
+extern int is_filtering(void);
+extern void sigwinch(int);
+extern void init_signals(int);
+extern void psignals(void);
+extern void cleantags(void);
+extern void findtag(char *);
+extern off_t tagsearch(void);
+extern char *nexttag(int);
+extern char *prevtag(int);
+extern int ntags(void);
+extern int curr_tag(void);
+extern int edit_tagfile(void);
+extern void open_getchr(void);
+extern void close_getchr(void);
+extern int getchr(void);
+extern void *lsignal(int, void (*)(int));
+extern char *helpfile(void);
diff --git a/usr.bin/less/help.c b/usr.bin/less/help.c
deleted file mode 100644
index 46b8ff1ec38..00000000000
--- a/usr.bin/less/help.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* 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',
-' ',' ',' ',' ',' ',' ','A',' ','k','e','y',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','c','a','r','e','t',' ','i','n','d','i','c','a','t','e','s',' ','t','h','e',' ','C','t','r','l',' ','k','e','y',';',' ','t','h','u','s',' ','^','K',' ','i','s',' ','c','t','r','l','-','K','.','\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',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','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',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','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',
-' ',' ','&','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','s','p','l','a','y',' ','o','n','l','y',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','\n',
-' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
-' ',' ',' ',' ',' ',' ',' ',' ','A',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','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',
-' ',' ','t',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','n','e','x','t',' ','t','a','g','.','\n',
-' ',' ','T',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','p','r','e','v','i','o','u','s',' ','t','a','g','.','\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','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',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','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',
-' ',' ','-','A',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','S','E','A','R','C','H','-','S','K','I','P','-','S','C','R','E','E','N','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','s','t','a','r','t','s',' ','j','u','s','t',' ','a','f','t','e','r',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\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','l','e','a','r','-','s','c','r','e','e','n','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','c','l','e','a','r','i','n','g',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','s','c','r','o','l','l','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',
-' ',' ','-','J',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','t','a','t','u','s','-','c','o','l','u','m','n','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','a','t',' ','l','e','f','t',' ','e','d','g','e',' ','o','f',' ','s','c','r','e','e','n','.','\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',
-' ',' ','-','K',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','q','u','i','t','-','o','n','-','i','n','t','r','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','i','t',' ','l','e','s','s',' ','i','n',' ','r','e','s','p','o','n','s','e',' ','t','o',' ','c','t','r','l','-','C','.','\n',
-' ',' ','-','L',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','l','e','s','s','o','p','e','n','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','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',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','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',' ','(','t','r','u','n','c','a','t','e',')',' ','l','o','n','g',' ','l','i','n','e','s',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','w','r','a','p','p','i','n','g','.','\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',
-' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','o','r','i','z','o','n','t','a','l',' ','s','c','r','o','l','l',' ','a','m','o','u','n','t',' ','(','0',' ','=',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',')','\n',
-' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
-' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n',
-'\n',
-'\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','t','r','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','t','r','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','t','r','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','t','r','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','t','r','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','t','r','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',
-'\n',
- 0 };
-constant int size_helpdata = sizeof(helpdata) - 1;
diff --git a/usr.bin/less/ifile.c b/usr.bin/less/ifile.c
index 918e0522db3..04764adb3a6 100644
--- a/usr.bin/less/ifile.c
+++ b/usr.bin/less/ifile.c
@@ -6,14 +6,17 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* 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
+ * 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.
@@ -38,32 +41,28 @@ struct ifile {
* 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))
+#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 } };
+ { -1, 0 } };
static int ifiles = 0;
- static void
-incr_index(p, incr)
- register struct ifile *p;
- int incr;
+static void
+incr_index(struct ifile *p, int incr)
{
- for (; p != &anchor; p = p->h_next)
+ 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;
+static void
+link_ifile(struct ifile *p, struct ifile *prev)
{
/*
* Link into list.
@@ -82,13 +81,12 @@ link_ifile(p, prev)
incr_index(p->h_next, 1);
ifiles++;
}
-
+
/*
* Unlink an ifile from the ifile list.
*/
- static void
-unlink_ifile(p)
- struct ifile *p;
+static void
+unlink_ifile(struct ifile *p)
{
p->h_next->h_prev = p->h_prev;
p->h_prev->h_next = p->h_next;
@@ -102,19 +100,17 @@ unlink_ifile(p)
* (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;
+static struct ifile *
+new_ifile(char *filename, struct ifile *prev)
{
- register struct ifile *p;
+ struct ifile *p;
/*
* Allocate and initialize structure.
*/
- p = (struct ifile *) ecalloc(1, sizeof(struct ifile));
+ p = ecalloc(1, sizeof (struct ifile));
p->h_filename = save(filename);
- p->h_scrpos.pos = NULL_POSITION;
+ p->h_scrpos.pos = -1;
p->h_opened = 0;
p->h_hold = 0;
p->h_filestate = NULL;
@@ -125,11 +121,10 @@ new_ifile(filename, prev)
/*
* Delete an existing ifile structure.
*/
- public void
-del_ifile(h)
- IFILE h;
+void
+del_ifile(IFILE h)
{
- register struct ifile *p;
+ struct ifile *p;
if (h == NULL_IFILE)
return;
@@ -149,11 +144,10 @@ del_ifile(h)
/*
* Get the ifile after a given one in the list.
*/
- public IFILE
-next_ifile(h)
- IFILE h;
+IFILE
+next_ifile(IFILE h)
{
- register struct ifile *p;
+ struct ifile *p;
p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
if (p->h_next == &anchor)
@@ -164,11 +158,10 @@ next_ifile(h)
/*
* Get the ifile before a given one in the list.
*/
- public IFILE
-prev_ifile(h)
- IFILE h;
+IFILE
+prev_ifile(IFILE h)
{
- register struct ifile *p;
+ struct ifile *p;
p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
if (p->h_prev == &anchor)
@@ -179,12 +172,11 @@ prev_ifile(h)
/*
* Return a different ifile from the given one.
*/
- public IFILE
-getoff_ifile(ifile)
- IFILE ifile;
+IFILE
+getoff_ifile(IFILE ifile)
{
IFILE newifile;
-
+
if ((newifile = prev_ifile(ifile)) != NULL_IFILE)
return (newifile);
if ((newifile = next_ifile(ifile)) != NULL_IFILE)
@@ -195,8 +187,8 @@ getoff_ifile(ifile)
/*
* Return the number of ifiles.
*/
- public int
-nifile()
+int
+nifile(void)
{
return (ifiles);
}
@@ -204,11 +196,10 @@ nifile()
/*
* Find an ifile structure, given a filename.
*/
- static struct ifile *
-find_ifile(filename)
- char *filename;
+static struct ifile *
+find_ifile(const char *filename)
{
- register struct ifile *p;
+ struct ifile *p;
for (p = anchor.h_next; p != &anchor; p = p->h_next)
if (strcmp(filename, p->h_filename) == 0)
@@ -221,12 +212,10 @@ find_ifile(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;
+IFILE
+get_ifile(char *filename, IFILE prev)
{
- register struct ifile *p;
+ struct ifile *p;
if ((p = find_ifile(filename)) == NULL)
p = new_ifile(filename, int_ifile(prev));
@@ -236,9 +225,8 @@ get_ifile(filename, prev)
/*
* Get the filename associated with a ifile.
*/
- public char *
-get_filename(ifile)
- IFILE ifile;
+char *
+get_filename(IFILE ifile)
{
if (ifile == NULL)
return (NULL);
@@ -248,32 +236,27 @@ get_filename(ifile)
/*
* Get the index of the file associated with a ifile.
*/
- public int
-get_index(ifile)
- IFILE ifile;
+int
+get_index(IFILE ifile)
{
- return (int_ifile(ifile)->h_index);
+ 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;
+void
+store_pos(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.
+ * If no position has been associated with the file, return -1.
*/
- public void
-get_pos(ifile, scrpos)
- IFILE ifile;
- struct scrpos *scrpos;
+void
+get_pos(IFILE ifile, struct scrpos *scrpos)
{
*scrpos = int_ifile(ifile)->h_scrpos;
}
@@ -281,9 +264,8 @@ get_pos(ifile, scrpos)
/*
* Mark the ifile as "opened".
*/
- public void
-set_open(ifile)
- IFILE ifile;
+void
+set_open(IFILE ifile)
{
int_ifile(ifile)->h_opened = 1;
}
@@ -291,57 +273,32 @@ set_open(ifile)
/*
* Return whether the ifile has been opened previously.
*/
- public int
-opened(ifile)
- IFILE ifile;
+int
+opened(IFILE ifile)
{
return (int_ifile(ifile)->h_opened);
}
- public void
-hold_ifile(ifile, incr)
- IFILE ifile;
- int incr;
+void
+hold_ifile(IFILE ifile, int incr)
{
int_ifile(ifile)->h_hold += incr;
}
-#if !SMALL
- public int
-held_ifile(ifile)
- IFILE ifile;
+int
+held_ifile(IFILE ifile)
{
return (int_ifile(ifile)->h_hold);
}
-#endif /* !SMALL */
- public void *
-get_filestate(ifile)
- IFILE ifile;
+void *
+get_filestate(IFILE ifile)
{
return (int_ifile(ifile)->h_filestate);
}
- public void
-set_filestate(ifile, filestate)
- IFILE ifile;
- void *filestate;
+void
+set_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/usr.bin/less/input.c b/usr.bin/less/input.c
index 039518d64e2..61e84786d32 100644
--- a/usr.bin/less/input.c
+++ b/usr.bin/less/input.c
@@ -6,10 +6,13 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
- * High level routines dealing with getting lines of input
+ * High level routines dealing with getting lines of input
* from the file being viewed.
*
* When we speak of "lines" here, we mean PRINTABLE lines;
@@ -27,12 +30,10 @@ extern int quit_if_one_screen;
extern volatile sig_atomic_t sigs;
extern int ignore_eoi;
extern int status_col;
-extern POSITION start_attnpos;
-extern POSITION end_attnpos;
-#if HILITE_SEARCH
+extern off_t start_attnpos;
+extern off_t end_attnpos;
extern int hilite_search;
extern int size_linebuf;
-#endif
/*
* Get the next line.
@@ -41,24 +42,21 @@ extern int size_linebuf;
* 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;
+off_t
+forw_line(off_t curr_pos)
{
- POSITION base_pos;
- POSITION new_pos;
+ off_t base_pos;
+ off_t new_pos;
register int c;
int blankline;
int endline;
int backchars;
get_forw_line:
- if (curr_pos == NULL_POSITION)
- {
+ if (curr_pos == -1) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
-#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
/*
* If we are ignoring EOI (command F), only prepare
@@ -67,31 +65,26 @@ get_forw_line:
* 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))
- {
+ prep_hilite(curr_pos, curr_pos + 3*size_linebuf,
+ ignore_eoi ? 1 : -1);
+ if (ch_seek(curr_pos)) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
/*
* Step back to the beginning of the line.
*/
base_pos = curr_pos;
- for (;;)
- {
- if (ABORT_SIGS())
- {
+ for (;;) {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
c = ch_back_get();
if (c == EOI)
break;
- if (c == '\n')
- {
+ if (c == '\n') {
(void) ch_forw_get();
break;
}
@@ -101,22 +94,19 @@ get_forw_line:
/*
* Read forward again to the position we should start at.
*/
- prewind();
+ prewind();
plinenum(base_pos);
(void) ch_seek(base_pos);
new_pos = base_pos;
- while (new_pos < curr_pos)
- {
- if (ABORT_SIGS())
- {
+ while (new_pos < curr_pos) {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
c = ch_forw_get();
backchars = pappend(c, new_pos);
new_pos++;
- if (backchars > 0)
- {
+ if (backchars > 0) {
pshift_all();
new_pos -= backchars;
while (--backchars >= 0)
@@ -130,32 +120,27 @@ get_forw_line:
* Read the first character to display.
*/
c = ch_forw_get();
- if (c == EOI)
- {
+ if (c == EOI) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
blankline = (c == '\n' || c == '\r');
/*
* Read each character in the line and append to the line buffer.
*/
- for (;;)
- {
- if (ABORT_SIGS())
- {
+ for (;;) {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
- if (c == '\n' || c == EOI)
- {
+ if (c == '\n' || c == EOI) {
/*
* End of the line.
*/
backchars = pflushmbc();
new_pos = ch_tell();
- if (backchars > 0 && !chopline && hshift == 0)
- {
+ if (backchars > 0 && !chopline && hshift == 0) {
new_pos -= backchars + 1;
endline = FALSE;
} else
@@ -169,29 +154,24 @@ get_forw_line:
* Append the char to the line and get the next char.
*/
backchars = pappend(c, ch_tell()-1);
- if (backchars > 0)
- {
+ if (backchars > 0) {
/*
* 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 || hshift > 0)
- {
- do
- {
- if (ABORT_SIGS())
- {
+ if (chopline || hshift > 0) {
+ do {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
c = ch_forw_get();
} while (c != '\n' && c != EOI);
new_pos = ch_tell();
endline = TRUE;
quit_if_one_screen = FALSE;
- } else
- {
+ } else {
new_pos = ch_tell() - backchars;
endline = FALSE;
}
@@ -202,9 +182,7 @@ get_forw_line:
pdone(endline, 1);
-#if HILITE_SEARCH
- if (is_filtered(base_pos))
- {
+ if (is_filtered(base_pos)) {
/*
* We don't want to display this line.
* Get the next line.
@@ -215,20 +193,17 @@ get_forw_line:
if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
set_status_col('*');
-#endif
- if (squeeze && blankline)
- {
+ 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())
- {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
if (c != EOI)
(void) ch_back_get();
@@ -245,59 +220,50 @@ get_forw_line:
* 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;
+off_t
+back_line(off_t curr_pos)
{
- POSITION new_pos, begin_new_pos, base_pos;
+ off_t new_pos, begin_new_pos, base_pos;
int c;
int endline;
int backchars;
get_back_line:
- if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
- {
+ if (curr_pos == -1 || curr_pos <= ch_zero()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
-#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
- prep_hilite((curr_pos < 3*size_linebuf) ?
- 0 : curr_pos - 3*size_linebuf, curr_pos, -1);
-#endif
- if (ch_seek(curr_pos-1))
- {
+ prep_hilite((curr_pos < 3*size_linebuf) ?
+ 0 : curr_pos - 3*size_linebuf, curr_pos, -1);
+ if (ch_seek(curr_pos-1)) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
- if (squeeze)
- {
+ 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_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')
- {
+ 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())
- {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
- if (c == EOI)
- {
+ if (c == EOI) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
(void) ch_forw_get();
}
@@ -306,16 +272,13 @@ get_back_line:
/*
* Scan backwards until we hit the beginning of the line.
*/
- for (;;)
- {
- if (ABORT_SIGS())
- {
+ for (;;) {
+ if (ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
c = ch_back_get();
- if (c == '\n')
- {
+ if (c == '\n') {
/*
* This is the newline ending the previous line.
* We have hit the beginning of the line.
@@ -323,8 +286,7 @@ get_back_line:
base_pos = ch_tell() + 1;
break;
}
- if (c == EOI)
- {
+ if (c == EOI) {
/*
* We have hit the beginning of the file.
* This must be the first line in the file.
@@ -341,36 +303,31 @@ get_back_line:
* until we reach the curr_pos.
*
* {{ This algorithm is pretty inefficient if the lines
- * are much longer than the screen width,
+ * are much longer than the screen width,
* but I don't know of any better way. }}
*/
new_pos = base_pos;
- if (ch_seek(new_pos))
- {
+ if (ch_seek(new_pos)) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
endline = FALSE;
prewind();
plinenum(new_pos);
- loop:
+loop:
begin_new_pos = new_pos;
(void) ch_seek(new_pos);
- do
- {
+ do {
c = ch_forw_get();
- if (c == EOI || ABORT_SIGS())
- {
+ if (c == EOI || ABORT_SIGS()) {
null_line();
- return (NULL_POSITION);
+ return (-1);
}
new_pos++;
- if (c == '\n')
- {
+ if (c == '\n') {
backchars = pflushmbc();
- if (backchars > 0 && !chopline && hshift == 0)
- {
+ if (backchars > 0 && !chopline && hshift == 0) {
backchars++;
goto shift;
}
@@ -378,23 +335,20 @@ get_back_line:
break;
}
backchars = pappend(c, ch_tell()-1);
- if (backchars > 0)
- {
+ if (backchars > 0) {
/*
* Got a full printable line, but we haven't
* reached our curr_pos yet. Discard the line
* and start a new one.
*/
- if (chopline || hshift > 0)
- {
+ if (chopline || hshift > 0) {
endline = TRUE;
quit_if_one_screen = FALSE;
break;
}
shift:
pshift_all();
- while (backchars-- > 0)
- {
+ while (backchars-- > 0) {
(void) ch_back_get();
new_pos--;
}
@@ -404,9 +358,7 @@ get_back_line:
pdone(endline, 0);
-#if HILITE_SEARCH
- if (is_filtered(base_pos))
- {
+ if (is_filtered(base_pos)) {
/*
* We don't want to display this line.
* Get the previous line.
@@ -415,9 +367,9 @@ get_back_line:
goto get_back_line;
}
- if (status_col && curr_pos > 0 && is_hilited(base_pos, curr_pos-1, 1, NULL))
+ if (status_col && curr_pos > 0 &&
+ is_hilited(base_pos, curr_pos-1, 1, NULL))
set_status_col('*');
-#endif
return (begin_new_pos);
}
@@ -425,18 +377,15 @@ get_back_line:
/*
* Set attnpos.
*/
- public void
-set_attnpos(pos)
- POSITION pos;
+void
+set_attnpos(off_t pos)
{
int c;
- if (pos != NULL_POSITION)
- {
+ if (pos != -1) {
if (ch_seek(pos))
return;
- for (;;)
- {
+ for (;;) {
c = ch_forw_get();
if (c == EOI)
return;
@@ -446,8 +395,7 @@ set_attnpos(pos)
}
}
start_attnpos = pos;
- for (;;)
- {
+ for (;;) {
c = ch_forw_get();
pos++;
if (c == EOI || c == '\n' || c == '\r')
diff --git a/usr.bin/less/install.sh b/usr.bin/less/install.sh
deleted file mode 100644
index 41ea84f9e54..00000000000
--- a/usr.bin/less/install.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/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/usr.bin/less/jump.c b/usr.bin/less/jump.c
index 075aa64d597..834916b1d06 100644
--- a/usr.bin/less/jump.c
+++ b/usr.bin/less/jump.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines which jump to a new location in the file.
@@ -25,18 +28,17 @@ extern int top_scroll;
/*
* Jump to the end of the file.
*/
- public void
-jump_forw()
+void
+jump_forw(void)
{
- POSITION pos;
- POSITION end_pos;
+ off_t pos;
+ off_t end_pos;
- if (ch_end_seek())
- {
+ if (ch_end_seek()) {
error("Cannot seek to end of file", NULL_PARG);
return;
}
- /*
+ /*
* Note; lastmark will be called later by jump_loc, but it fails
* because the position table has been cleared by pos_clear below.
* So call it here before calling pos_clear.
@@ -50,10 +52,9 @@ jump_forw()
pos_clear();
end_pos = ch_tell();
pos = back_line(end_pos);
- if (pos == NULL_POSITION)
- jump_loc((POSITION)0, sc_height-1);
- else
- {
+ if (pos == -1) {
+ jump_loc(0, sc_height-1);
+ } else {
jump_loc(pos, sc_height-1);
if (position(sc_height-1) != end_pos)
repaint();
@@ -63,11 +64,10 @@ jump_forw()
/*
* Jump to line n in the file.
*/
- public void
-jump_back(linenum)
- LINENUM linenum;
+void
+jump_back(LINENUM linenum)
{
- POSITION pos;
+ off_t pos;
PARG parg;
/*
@@ -77,17 +77,14 @@ jump_back(linenum)
* use ch_beg_seek() to get as close as we can.
*/
pos = find_pos(linenum);
- if (pos != NULL_POSITION && ch_seek(pos) == 0)
- {
+ if (pos != -1 && ch_seek(pos) == 0) {
if (show_attn)
set_attnpos(pos);
jump_loc(pos, jump_sline);
- } else if (linenum <= 1 && ch_beg_seek() == 0)
- {
+ } else if (linenum <= 1 && ch_beg_seek() == 0) {
jump_loc(ch_tell(), jump_sline);
error("Cannot seek to beginning of file", NULL_PARG);
- } else
- {
+ } else {
parg.p_linenum = linenum;
error("Cannot seek to line number %n", &parg);
}
@@ -96,8 +93,8 @@ jump_back(linenum)
/*
* Repaint the screen.
*/
- public void
-repaint()
+void
+repaint(void)
{
struct scrpos scrpos;
/*
@@ -112,24 +109,20 @@ repaint()
/*
* Jump to a specified percentage into the file.
*/
- public void
-jump_percent(percent, fraction)
- int percent;
- long fraction;
+void
+jump_percent(int percent, long fraction)
{
- POSITION pos, len;
+ off_t pos, len;
/*
* Determine the position in the file
* (the specified percentage of the file's length).
*/
- if ((len = ch_length()) == NULL_POSITION)
- {
+ if ((len = ch_length()) == -1) {
ierror("Determining length of file", NULL_PARG);
ch_end_seek();
}
- if ((len = ch_length()) == NULL_POSITION)
- {
+ if ((len = ch_length()) == -1) {
error("Don't know length of file", NULL_PARG);
return;
}
@@ -142,18 +135,15 @@ jump_percent(percent, fraction)
/*
* Jump to a specified position in the file.
- * Like jump_loc, but the position need not be
+ * 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;
+void
+jump_line_loc(off_t pos, int sline)
{
int c;
- if (ch_seek(pos) == 0)
- {
+ if (ch_seek(pos) == 0) {
/*
* Back up to the beginning of the line.
*/
@@ -173,24 +163,21 @@ jump_line_loc(pos, sline)
* 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;
+void
+jump_loc(off_t pos, int sline)
{
- register int nline;
- POSITION tpos;
- POSITION bpos;
+ int nline;
+ off_t tpos;
+ off_t bpos;
/*
* Normalize sline.
*/
sline = adjsline(sline);
- if ((nline = onscreen(pos)) >= 0)
- {
+ if ((nline = onscreen(pos)) >= 0) {
/*
- * The line is currently displayed.
+ * The line is currently displayed.
* Just scroll there.
*/
nline -= sline;
@@ -198,10 +185,8 @@ jump_loc(pos, sline)
forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0);
else
back(-nline, position(TOP), 1, 0);
-#if HILITE_SEARCH
if (show_attn)
repaint_hilite(1);
-#endif
return;
}
@@ -209,45 +194,38 @@ jump_loc(pos, sline)
* Line is not on screen.
* Seek to the desired location.
*/
- if (ch_seek(pos))
- {
+ if (ch_seek(pos)) {
error("Cannot seek to that file position", NULL_PARG);
return;
}
/*
- * See if the desired line is before or after
+ * 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)
- {
+ if (tpos == -1 || 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
+ * 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)
- {
+ for (nline = 0; nline < sline; nline++) {
+ if (bpos != -1 && 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 HILITE_SEARCH
if (show_attn)
repaint_hilite(1);
-#endif
return;
}
pos = back_line(pos);
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* Oops. Ran into the beginning of the file.
* Exit the loop here and rely on forw()
@@ -261,44 +239,38 @@ jump_loc(pos, sline)
squished = 0;
screen_trashed = 0;
forw(sc_height-1, pos, 1, 0, sline-nline);
- } else
- {
+ } 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
+ * can call back() and put the desired line at the
* sline-th line on the screen.
*/
- for (nline = sline; nline < sc_height - 1; nline++)
- {
+ for (nline = sline; nline < sc_height - 1; nline++) {
pos = forw_line(pos);
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* Ran into end of file.
- * This shouldn't normally happen,
+ * This shouldn't normally happen,
* but may if there is some kind of read error.
*/
break;
}
- if (pos >= tpos)
- {
- /*
+ 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 HILITE_SEARCH
+ back(nline + 1, tpos, 1, 0);
if (show_attn)
repaint_hilite(1);
-#endif
return;
}
}
lastmark();
if (!top_scroll)
- clear();
+ do_clear();
else
home();
screen_trashed = 0;
diff --git a/usr.bin/less/less.h b/usr.bin/less/less.h
index c7471e1f748..bbce60a2817 100644
--- a/usr.bin/less/less.h
+++ b/usr.bin/less/less.h
@@ -6,20 +6,14 @@
*
* For more information, see the README file.
*/
-
-#define NEWBOT 1
-
/*
- * Standard include file for "less".
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
*/
/*
- * Defines for MSDOS_COMPILER.
+ * Standard include file for "less".
*/
-#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.
@@ -27,99 +21,24 @@
*/
#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_WCTYPE_H
#include <wctype.h>
-#endif
-#if HAVE_LIMITS_H
#include <limits.h>
-#endif
-#if HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
#include <string.h>
-#endif
+#include <libgen.h>
#include <signal.h>
-/* OS-specific includes */
-#ifdef _OSK
-#include <modes.h>
-#include <strings.h>
-#endif
-
-#ifdef __TANDEM
-#include <floss.h>
-#endif
-
-#if MSDOS_COMPILER==WIN32C || OS2
-#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 ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
-#define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
-#define ASCII_TO_UPPER(c) ((c) - 'a' + 'A')
-#define ASCII_TO_LOWER(c) ((c) - 'A' + 'a')
#undef IS_UPPER
#undef IS_LOWER
@@ -128,42 +47,15 @@ void free();
#undef IS_SPACE
#undef IS_DIGIT
-#if HAVE_WCTYPE
#define IS_UPPER(c) iswupper(c)
#define IS_LOWER(c) iswlower(c)
#define TO_UPPER(c) towupper(c)
#define TO_LOWER(c) towlower(c)
-#else
-#if HAVE_UPPER_LOWER
-#define IS_UPPER(c) isupper((unsigned char) (c))
-#define IS_LOWER(c) islower((unsigned char) (c))
-#define TO_UPPER(c) toupper((unsigned char) (c))
-#define TO_LOWER(c) tolower((unsigned char) (c))
-#else
-#define IS_UPPER(c) ASCII_IS_UPPER(c)
-#define IS_LOWER(c) ASCII_IS_LOWER(c)
-#define TO_UPPER(c) ASCII_TO_UPPER(c)
-#define TO_LOWER(c) ASCII_TO_LOWER(c)
-#endif
-#endif
-
-#ifdef isspace
-#define IS_SPACE(c) isspace((unsigned char)(c))
-#else
-#define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
-#endif
-#ifdef isdigit
-#define IS_DIGIT(c) isdigit((unsigned char)(c))
-#else
-#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
-#endif
-
-#define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
+#define IS_SPACE(c) isspace((unsigned char)(c))
+#define IS_DIGIT(c) isdigit((unsigned char)(c))
-#ifndef NULL
-#define NULL 0
-#endif
+#define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
#ifndef TRUE
#define TRUE 1
@@ -176,36 +68,10 @@ void free();
#define OPT_ON 1
#define OPT_ONPLUS 2
-#if !HAVE_MEMCPY
-#ifndef memcpy
-#define memcpy(to,from,len) bcopy((from),(to),(len))
-#endif
-#endif
-
-#if HAVE_SNPRINTF
-#define SNPRINTF1(str, size, fmt, v1) snprintf((str), (size), (fmt), (v1))
-#define SNPRINTF2(str, size, fmt, v1, v2) snprintf((str), (size), (fmt), (v1), (v2))
-#define SNPRINTF3(str, size, fmt, v1, v2, v3) snprintf((str), (size), (fmt), (v1), (v2), (v3))
-#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4))
-#else
-/* Use unsafe sprintf if we don't have snprintf. */
-#define SNPRINTF1(str, size, fmt, v1) sprintf((str), (fmt), (v1))
-#define SNPRINTF2(str, size, fmt, v1, v2) sprintf((str), (fmt), (v1), (v2))
-#define SNPRINTF3(str, size, fmt, v1, v2, v3) sprintf((str), (fmt), (v1), (v2), (v3))
-#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4))
-#endif
-
#define BAD_LSEEK ((off_t)-1)
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
#ifndef CHAR_BIT
-#define CHAR_BIT 8
+#define CHAR_BIT 8
#endif
/*
@@ -213,75 +79,31 @@ void free();
* 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
* add 1 for integer division truncation; add 1 more for a minus sign.
*/
-#define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1)
+#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1)
/*
* Special types and constants.
*/
typedef unsigned long LWCHAR;
-typedef off_t POSITION;
typedef off_t LINENUM;
-#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
-#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */
-
-#define NULL_POSITION ((POSITION)(-1))
+#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
+#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */
/*
* 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 || OS2
-#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)
+#define IFILE void *
+#define NULL_IFILE (NULL)
/*
* The structure used to represent a "screen position".
@@ -290,9 +112,8 @@ typedef off_t LINENUM;
* position is displayed on the ln-th line of the screen.
* (Screen lines before ln are empty.)
*/
-struct scrpos
-{
- POSITION pos;
+struct scrpos {
+ off_t pos;
int ln;
};
@@ -316,8 +137,8 @@ struct textlist
#define READ_INTR (-2)
/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
-#define NUM_FRAC_DENOM 1000000
-#define NUM_LOG_FRAC_DENOM 6
+#define NUM_FRAC_DENOM 1000000
+#define NUM_LOG_FRAC_DENOM 6
/* How quiet should we be? */
#define NOT_QUIET 0 /* Ring bell at eof and for errors */
@@ -335,16 +156,16 @@ struct textlist
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
/* How should we search? */
-#define SRCH_FORW (1 << 0) /* Search forward from current position */
-#define SRCH_BACK (1 << 1) /* Search backward from current position */
-#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */
-#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */
-#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */
-#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */
-#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
-#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */
-#define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */
-#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
+#define SRCH_FORW (1 << 0) /* Search forward from current position */
+#define SRCH_BACK (1 << 1) /* Search backward from current position */
+#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */
+#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */
+#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */
+#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */
+#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
+#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */
+#define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */
+#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
@@ -360,7 +181,7 @@ struct textlist
#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 */
+#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
/* Special char bit-flags used to tell put_line() to do something special */
#define AT_NORMAL (0)
@@ -372,104 +193,16 @@ struct textlist
#define AT_BINARY (1 << 5) /* LESS*BINFMT representation */
#define AT_HILITE (1 << 6) /* Internal highlights (e.g., for search) */
-#if '0' == 240
-#define IS_EBCDIC_HOST 1
-#endif
-
-#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('[')
#define CSI ((unsigned char)'\233')
-#if _OSK_MWC32
-#define LSIGNAL(sig,func) os9_signal(sig,func)
-#else
-#define LSIGNAL(sig,func) lsignal(sig,func)
-#endif
-
-#if HAVE_SIGPROCMASK
-#if HAVE_SIGSET_T
-#else
-#undef HAVE_SIGPROCMASK
-#endif
-#endif
-#if HAVE_SIGPROCMASK
-#if HAVE_SIGEMPTYSET
-#else
-#undef sigemptyset
-#define sigemptyset(mp) *(mp) = 0
-#endif
-#endif
+#define LSIGNAL(sig, func) lsignal(sig, func)
#define S_INTERRUPT 01
#define S_STOP 02
-#define S_WINCH 04
+#define S_WINCH 04
#define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
#define QUIT_OK 0
@@ -477,8 +210,8 @@ struct textlist
#define QUIT_INTERRUPT 2
#define QUIT_SAVED_STATUS (-1)
-#define FOLLOW_DESC 0
-#define FOLLOW_NAME 1
+#define FOLLOW_DESC 0
+#define FOLLOW_NAME 1
/* filestate flags */
#define CH_CANSEEK 001
@@ -488,10 +221,9 @@ struct textlist
#define CH_NODATA 020 /* Special case for zero length files */
-#define ch_zero() ((POSITION)0)
+#define ch_zero() (0)
-#define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@"
-#define FAKE_EMPTYFILE "@/\\less/\\empty/\\file/\\@"
+#define FAKE_EMPTYFILE "@/\\less/\\empty/\\file/\\@"
/* Flags for cvt_text */
#define CVT_TO_LC 01 /* Convert upper-case to lower-case */
@@ -502,6 +234,6 @@ struct textlist
#include "funcs.h"
/* Functions not included in funcs.h */
-void postoa();
-void linenumtoa();
-void inttoa();
+void postoa(off_t, char *, size_t);
+void linenumtoa(LINENUM, char *, size_t);
+void inttoa(int, char *, size_t);
diff --git a/usr.bin/less/less/Makefile b/usr.bin/less/less/Makefile
index 4788428a415..a3f778e7576 100644
--- a/usr.bin/less/less/Makefile
+++ b/usr.bin/less/less/Makefile
@@ -1,4 +1,6 @@
-# $OpenBSD: Makefile,v 1.4 2014/05/10 16:45:23 schwarze Exp $
+# $OpenBSD: Makefile,v 1.5 2015/11/05 22:08:44 nicm Exp $
+
+.PATH: ${.CURDIR}/..
PROG= less
SRCS= main.c screen.c brac.c ch.c charset.c cmdbuf.c command.c cvt.c \
@@ -13,10 +15,11 @@ DPADD= ${LIBCURSES}
LINKS= ${BINDIR}/less ${BINDIR}/more
MAN= less.1 more.1
+BINDIR= /usr/bin
HELPDIR=${SHAREDIR}/misc
-CFLAGS+=-DBINDIR=\"${BINDIR}\" -DSYSDIR=\"/etc\" -DHELPDIR=\"${HELPDIR}\"
+CFLAGS+=-I${.CURDIR}/.. -DSYSDIR=\"/etc\" -DHELPDIR=\"${HELPDIR}\"
CDIAGFLAGS+=-Wall -W
diff --git a/usr.bin/less/lessecho.c b/usr.bin/less/lessecho.c
deleted file mode 100644
index ff650bbb475..00000000000
--- a/usr.bin/less/lessecho.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 1984-2012 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, see the README file.
- */
-
-
-/*
- * lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...
- * Simply echos its filename arguments on standard output.
- * But any argument containing spaces is enclosed in quotes.
- *
- * -ox Specifies "x" to be the open quote character.
- * -cx Specifies "x" to be the close quote character.
- * -pn Specifies "n" to be the open quote character, as an integer.
- * -dn Specifies "n" to be the close quote character, as an integer.
- * -mx Specifies "x" to be a metachar.
- * -nn Specifies "n" to be a metachar, as an integer.
- * -ex Specifies "x" to be the escape char for metachars.
- * -fn Specifies "x" to be the escape char for metachars, as an integer.
- * -a Specifies that all arguments are to be quoted.
- * The default is that only arguments containing spaces are quoted.
- */
-
-#include "less.h"
-
-static char *version = "$Revision: 1.4 $";
-
-static int quote_all = 0;
-static char openquote = '"';
-static char closequote = '"';
-static char *meta_escape = "\\";
-static char meta_escape_buf[2];
-static char metachars[64] = "";
-static int num_metachars = 0;
-
- static void
-pr_usage()
-{
- fprintf(stderr,
- "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
-}
-
- static void
-pr_version()
-{
- char *p;
- char buf[10];
- char *pbuf = buf;
-
- for (p = version; *p != ' '; p++)
- if (*p == '\0')
- return;
- for (p++; *p != '$' && *p != ' ' && *p != '\0'; p++)
- *pbuf++ = *p;
- *pbuf = '\0';
- printf("%s\n", buf);
-}
-
- static void
-pr_error(s)
- char *s;
-{
- fprintf(stderr, "%s\n", s);
- exit(1);
-}
-
- static long
-lstrtol(s, radix, pend)
- char *s;
- int radix;
- char **pend;
-{
- int v;
- int neg = 0;
- long n = 0;
-
- /* Skip leading white space. */
- while (*s == ' ' || *s == '\t')
- s++;
-
- /* Check for a leading + or -. */
- if (*s == '-')
- {
- neg = 1;
- s++;
- } else if (*s == '+')
- {
- s++;
- }
-
- /* Determine radix if caller does not specify. */
- if (radix == 0)
- {
- radix = 10;
- if (*s == '0')
- {
- switch (*++s)
- {
- case 'x':
- radix = 16;
- s++;
- break;
- default:
- radix = 8;
- break;
- }
- }
- }
-
- /* Parse the digits of the number. */
- for (;;)
- {
- if (*s >= '0' && *s <= '9')
- v = *s - '0';
- else if (*s >= 'a' && *s <= 'f')
- v = *s - 'a' + 10;
- else if (*s >= 'A' && *s <= 'F')
- v = *s - 'A' + 10;
- else
- break;
- if (v >= radix)
- break;
- n = n * radix + v;
- s++;
- }
-
- if (pend != NULL)
- {
- /* Skip trailing white space. */
- while (*s == ' ' || *s == '\t')
- s++;
- *pend = s;
- }
- if (neg)
- return (-n);
- return (n);
-}
-
-
-#if !HAVE_STRCHR
- char *
-strchr(s, c)
- char *s;
- int c;
-{
- for ( ; *s != '\0'; s++)
- if (*s == c)
- return (s);
- if (c == '\0')
- return (s);
- return (NULL);
-}
-#endif
-
- int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- char *arg;
- char *s;
- int no_more_options;
-
- no_more_options = 0;
- while (--argc > 0)
- {
- arg = *++argv;
- if (*arg != '-' || no_more_options)
- break;
- switch (*++arg)
- {
- case 'a':
- quote_all = 1;
- break;
- case 'c':
- closequote = *++arg;
- break;
- case 'd':
- closequote = lstrtol(++arg, 0, &s);
- if (s == arg)
- pr_error("Missing number after -d");
- break;
- case 'e':
- if (strcmp(++arg, "-") == 0)
- meta_escape = "";
- else
- meta_escape = arg;
- break;
- case 'f':
- meta_escape_buf[0] = lstrtol(++arg, 0, &s);
- meta_escape = meta_escape_buf;
- if (s == arg)
- pr_error("Missing number after -f");
- break;
- case 'o':
- openquote = *++arg;
- break;
- case 'p':
- openquote = lstrtol(++arg, 0, &s);
- if (s == arg)
- pr_error("Missing number after -p");
- break;
- case 'm':
- metachars[num_metachars++] = *++arg;
- metachars[num_metachars] = '\0';
- break;
- case 'n':
- metachars[num_metachars++] = lstrtol(++arg, 0, &s);
- if (s == arg)
- pr_error("Missing number after -n");
- metachars[num_metachars] = '\0';
- break;
- case '?':
- pr_usage();
- return (0);
- case '-':
- if (*++arg == '\0')
- {
- no_more_options = 1;
- break;
- }
- if (strcmp(arg, "version") == 0)
- {
- pr_version();
- return (0);
- }
- if (strcmp(arg, "help") == 0)
- {
- pr_usage();
- return (0);
- }
- pr_error("Invalid option after --");
- default:
- pr_error("Invalid option letter");
- }
- }
-
- while (argc-- > 0)
- {
- int has_meta = 0;
- arg = *argv++;
- for (s = arg; *s != '\0'; s++)
- {
- if (strchr(metachars, *s) != NULL)
- {
- has_meta = 1;
- break;
- }
- }
- if (quote_all || (has_meta && strlen(meta_escape) == 0))
- printf("%c%s%c", openquote, arg, closequote);
- else
- {
- for (s = arg; *s != '\0'; s++)
- {
- if (strchr(metachars, *s) != NULL)
- printf("%s", meta_escape);
- printf("%c", *s);
- }
- }
- if (argc > 0)
- printf(" ");
- else
- printf("\n");
- }
- return (0);
-}
diff --git a/usr.bin/less/lessecho.man b/usr.bin/less/lessecho.man
deleted file mode 100644
index 682b0bd835e..00000000000
--- a/usr.bin/less/lessecho.man
+++ /dev/null
@@ -1,49 +0,0 @@
-LESSECHO(1) LESSECHO(1)
-
-
-
-NAME
- lessecho - expand metacharacters
-
-SYNOPSIS
- lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ...
-
-DESCRIPTION
- lessecho is a program that simply echos its arguments on standard out-
- put. But any argument containing spaces is enclosed in quotes.
-
-OPTIONS
- A summary of options is included below.
-
- -ox Specifies "x" to be the open quote character.
-
- -cx Specifies "x" to be the close quote character.
-
- -pn Specifies "n" to be the open quote character, as an integer.
-
- -dn Specifies "n" to be the close quote character, as an integer.
-
- -mx Specifies "x" to be a metachar.
-
- -nn Specifies "n" to be a metachar, as an integer.
-
- -ex Specifies "x" to be the escape char for metachars.
-
- -fn Specifies "n" to be the escape char for metachars, as an inte-
- ger.
-
- -a Specifies that all arguments are to be quoted. The default is
- that only arguments containing spaces are quoted.
-
-SEE ALSO
- less(1)
-
-AUTHOR
- This manual page was written by Thomas Schoepf <schoepf@debian.org>,
- for the Debian GNU/Linux system (but may be used by others).
-
- Send bug reports or comments to bug-less@gnu.org.
-
-
-
- Version 444: 09 Jun 2011 LESSECHO(1)
diff --git a/usr.bin/less/lessecho.nro b/usr.bin/less/lessecho.nro
deleted file mode 100644
index 46540e8bcca..00000000000
--- a/usr.bin/less/lessecho.nro
+++ /dev/null
@@ -1,47 +0,0 @@
-.TH LESSECHO 1 "Version 444: 09 Jun 2011"
-.SH NAME
-lessecho \- expand metacharacters
-.SH SYNOPSIS
-.B lessecho
-.I "[-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ..."
-.SH "DESCRIPTION"
-.I lessecho
-is a program that simply echos its arguments on standard output.
-But any argument containing spaces is enclosed in quotes.
-.SH OPTIONS
-A summary of options is included below.
-.TP
-.B \-ox
-Specifies "x" to be the open quote character.
-.TP
-.B \-cx
-Specifies "x" to be the close quote character.
-.TP
-.B \-pn
-Specifies "n" to be the open quote character, as an integer.
-.TP
-.B \-dn
-Specifies "n" to be the close quote character, as an integer.
-.TP
-.B \-mx
-Specifies "x" to be a metachar.
-.TP
-.B \-nn
-Specifies "n" to be a metachar, as an integer.
-.TP
-.B \-ex
-Specifies "x" to be the escape char for metachars.
-.TP
-.B \-fn
-Specifies "n" to be the escape char for metachars, as an integer.
-.TP
-.B \-a
-Specifies that all arguments are to be quoted.
-The default is that only arguments containing spaces are quoted.
-.SH "SEE ALSO"
-less(1)
-.SH AUTHOR
-This manual page was written by Thomas Schoepf <schoepf@debian.org>,
-for the Debian GNU/Linux system (but may be used by others).
-.PP
-Send bug reports or comments to bug-less@gnu.org.
diff --git a/usr.bin/less/lesskey.1 b/usr.bin/less/lesskey.1
index 105523de987..f52ed5a6f98 100644
--- a/usr.bin/less/lesskey.1
+++ b/usr.bin/less/lesskey.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: lesskey.1,v 1.12 2014/11/23 08:01:06 bentley Exp $
+.\" $OpenBSD: lesskey.1,v 1.13 2015/11/05 22:08:44 nicm Exp $
.\"
.\" Copyright (C) 2000-2012 Mark Nudelman
.\"
@@ -22,7 +22,7 @@
.\" 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.
-.Dd $Mdocdate: November 23 2014 $
+.Dd $Mdocdate: November 5 2015 $
.Dt LESSKEY 1
.Os
.Sh NAME
@@ -30,7 +30,8 @@
.Nd specify key bindings for less
.Sh SYNOPSIS
.Nm lesskey
-.Op Fl o Ar output | Fl -output Ns = Ns Ar output
+.Oo Fl o Ar output
+.Pf " | " Fl -output Ns = Ns Ar output Oc
.Op Ar input
.Nm lesskey
.Fl V | -version
@@ -108,9 +109,7 @@ Defines new line-editing keys.
Defines environment variables.
.El
.Pp
-Blank lines and lines which start with a pound sign
-.Pq Sq #
-are ignored,
+Blank lines and lines which start with a pound sign (#) are ignored,
except for the special section header lines.
.Sh COMMAND SECTION
The command section begins with the line
@@ -182,22 +181,24 @@ to be taken literally.
Characters which must be preceded by backslash include
caret, space, tab and the backslash itself.
.Pp
-An action may be followed by an additional string.
+An action may be followed by an
+.Qq extra
+string.
When such a command is entered while running less,
the action is performed, and then the extra
-string is parsed, just as if it were typed into less.
+string is parsed, just as if it were typed in to less.
This feature can be used in certain cases to extend
the functionality of a command.
For example, see the
-.Cm {
+.Sq {
and
-.Cm :t
+.Sq :t
commands in the example below.
The extra string has a special meaning for the
-.Cm quit
+.Qq quit
action:
when less quits,
-the first character of the extra string is used as its exit status.
+first character of the extra string is used as its exit status.
.Pp
The following input file describes the set of
default command keys used by less:
@@ -320,37 +321,31 @@ Commands specified by
take precedence over the default commands.
A default command key may be disabled by including it in the
input file with the action
-.Cm invalid .
+.Qq invalid .
Alternatively, a key may be defined
to do nothing by using the action
-.Cm noaction .
-.Cm noaction
+.Qq noaction .
+.Qq noaction
is similar to
-.Cm invalid ,
+.Qq invalid ,
but less will give an error beep for an
-.Cm invalid
+.Qq invalid
command, but not for a
-.Cm noaction
+.Qq noaction
command.
-In addition, all default commands may be disabled by
+In addition, ALL default commands may be disabled by
adding this control line to the input file:
.Pp
.Dl #stop
.Pp
This will cause all default commands to be ignored.
-The
-.Cm #stop
-line should be the last line in that section of the file.
+The #stop line should be the last line in that section of the file.
.Pp
-Be aware that
-.Cm #stop
-can be dangerous.
+Be aware that #stop can be dangerous.
Since all default commands are disabled, you must provide sufficient
-commands before the
-.Cm #stop
-line to enable all necessary actions.
+commands before the #stop line to enable all necessary actions.
For example, failure to provide a
-.Cm quit
+.Qq quit
command can lead to frustration.
.Sh LINE EDITING SECTION
The line-editing section begins with the line:
@@ -415,11 +410,9 @@ Although the lesskey file can be used to override variables set in the
environment, the main purpose of assigning variables in the lesskey file
is simply to have all less configuration information stored in one file.
.Pp
-The following input file sets the
-.Fl i
-option whenever less is run,
+The following input file sets the -i option whenever less is run,
and specifies the character set to be
-.Cm latin1 :
+.Qq latin1 :
.Bd -literal -offset indent
#env
LESS = -i
@@ -438,15 +431,15 @@ file.
.El
.Sh FILES
.Bl -tag -width "$HOME/.lesskey" -compact
-.It Pa $HOME/.less
+.It $HOME/.less
Default
.Nm
file.
-.It Pa $HOME/.lesskey
+.It $HOME/.lesskey
Default
.Nm
input file.
-.It Pa /etc/sysless
+.It /etc/sysless
Default system-wide
.Nm
file.
@@ -457,7 +450,7 @@ file.
.An Mark Nudelman
.Pp
Send bug reports or comments to
-.Aq Mt bug-less@gnu.org .
+.Aq Mt bug\-less@gnu.org .
.\" .Sh CAVEATS
.\" On MS-DOS and OS/2 systems, certain keys send a sequence of characters
.\" which start with a NUL character (0).
diff --git a/usr.bin/less/lesskey.c b/usr.bin/less/lesskey.c
index e881823fd2a..937f5c14709 100644
--- a/usr.bin/less/lesskey.c
+++ b/usr.bin/less/lesskey.c
@@ -6,12 +6,15 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* lesskey [-o output] [input]
*
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Make a .less file.
* If no input file is specified, standard input is used.
@@ -21,9 +24,9 @@
* key bindings. Basically any sequence of 1 to MAX_CMDLEN
* keystrokes may be bound to an existing less function.
*
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
- * The input file is an ascii file consisting of a
+ * The input file is an ascii file consisting of a
* sequence of lines of the form:
* string <whitespace> action [chars] <newline>
*
@@ -37,14 +40,14 @@
* to specify a character by its octal value.
* 4. A backslash followed by b, e, n, r or t
* to specify \b, ESC, \n, \r or \t, respectively.
- * 5. Any character (other than those mentioned above) preceded
+ * 5. Any character (other than those mentioned above) preceded
* by a \ to specify the character itself (characters which
* must be preceded by \ include ^, \, and whitespace.
* "action" is the name of a "less" action, from the table below.
* "chars" is an optional sequence of characters which is treated
* as keyboard input after the command is executed.
*
- * Blank lines and lines which start with # are ignored,
+ * Blank lines and lines which start with # are ignored,
* except for the special control lines:
* #command Signals the beginning of the command
* keys section.
@@ -55,7 +58,7 @@
* #stop Stops command parsing in less;
* causes all default keys to be disabled.
*
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* The output file is a non-ascii file, consisting of a header,
* one or more sections, and a trailer.
@@ -63,7 +66,7 @@
* and the section data. Normally there are three sections:
* CMD_SECTION Definition of command keys.
* EDIT_SECTION Definition of editing keys.
- * END_SECTION A special section header, with no
+ * END_SECTION A special section header, with no
* length word or section data.
*
* Section data consists of zero or more byte sequences of the form:
@@ -77,7 +80,7 @@
* If action is ORed with A_EXTRA, the action byte is followed
* by the null-terminated "chars" string.
*
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "less.h"
@@ -90,71 +93,73 @@ struct cmdname
int cn_action;
};
-struct cmdname cmdnames[] =
+static void lkerr(char *s);
+
+struct cmdname cmdnames[] =
{
- { "back-bracket", A_B_BRACKET },
- { "back-line", A_B_LINE },
- { "back-line-force", A_BF_LINE },
- { "back-screen", A_B_SCREEN },
- { "back-scroll", A_B_SCROLL },
- { "back-search", A_B_SEARCH },
- { "back-window", A_B_WINDOW },
- { "debug", A_DEBUG },
- { "digit", A_DIGIT },
- { "display-flag", A_DISP_OPTION },
- { "display-option", A_DISP_OPTION },
- { "end", A_GOEND },
- { "examine", A_EXAMINE },
- { "filter", A_FILTER },
- { "first-cmd", A_FIRSTCMD },
- { "firstcmd", A_FIRSTCMD },
- { "flush-repaint", A_FREPAINT },
- { "forw-bracket", A_F_BRACKET },
- { "forw-forever", A_F_FOREVER },
- { "forw-until-hilite", A_F_UNTIL_HILITE },
- { "forw-line", A_F_LINE },
- { "forw-line-force", A_FF_LINE },
- { "forw-screen", A_F_SCREEN },
- { "forw-screen-force", A_FF_SCREEN },
- { "forw-scroll", A_F_SCROLL },
- { "forw-search", A_F_SEARCH },
- { "forw-window", A_F_WINDOW },
- { "goto-end", A_GOEND },
- { "goto-line", A_GOLINE },
- { "goto-mark", A_GOMARK },
- { "help", A_HELP },
- { "index-file", A_INDEX_FILE },
- { "invalid", A_UINVALID },
- { "left-scroll", A_LSHIFT },
- { "next-file", A_NEXT_FILE },
- { "next-tag", A_NEXT_TAG },
- { "noaction", A_NOACTION },
- { "percent", A_PERCENT },
- { "pipe", A_PIPE },
- { "prev-file", A_PREV_FILE },
- { "prev-tag", A_PREV_TAG },
- { "quit", A_QUIT },
- { "remove-file", A_REMOVE_FILE },
- { "repaint", A_REPAINT },
- { "repaint-flush", A_FREPAINT },
- { "repeat-search", A_AGAIN_SEARCH },
- { "repeat-search-all", A_T_AGAIN_SEARCH },
- { "reverse-search", A_REVERSE_SEARCH },
- { "reverse-search-all", A_T_REVERSE_SEARCH },
- { "right-scroll", A_RSHIFT },
- { "set-mark", A_SETMARK },
- { "shell", A_SHELL },
- { "status", A_STAT },
- { "toggle-flag", A_OPT_TOGGLE },
- { "toggle-option", A_OPT_TOGGLE },
- { "undo-hilite", A_UNDO_SEARCH },
- { "version", A_VERSION },
- { "visual", A_VISUAL },
- { NULL, 0 }
+ { "back-bracket", A_B_BRACKET },
+ { "back-line", A_B_LINE },
+ { "back-line-force", A_BF_LINE },
+ { "back-screen", A_B_SCREEN },
+ { "back-scroll", A_B_SCROLL },
+ { "back-search", A_B_SEARCH },
+ { "back-window", A_B_WINDOW },
+ { "debug", A_DEBUG },
+ { "digit", A_DIGIT },
+ { "display-flag", A_DISP_OPTION },
+ { "display-option", A_DISP_OPTION },
+ { "end", A_GOEND },
+ { "examine", A_EXAMINE },
+ { "filter", A_FILTER },
+ { "first-cmd", A_FIRSTCMD },
+ { "firstcmd", A_FIRSTCMD },
+ { "flush-repaint", A_FREPAINT },
+ { "forw-bracket", A_F_BRACKET },
+ { "forw-forever", A_F_FOREVER },
+ { "forw-until-hilite", A_F_UNTIL_HILITE },
+ { "forw-line", A_F_LINE },
+ { "forw-line-force", A_FF_LINE },
+ { "forw-screen", A_F_SCREEN },
+ { "forw-screen-force", A_FF_SCREEN },
+ { "forw-scroll", A_F_SCROLL },
+ { "forw-search", A_F_SEARCH },
+ { "forw-skip", A_F_SKIP },
+ { "forw-window", A_F_WINDOW },
+ { "goto-end", A_GOEND },
+ { "goto-line", A_GOLINE },
+ { "goto-mark", A_GOMARK },
+ { "help", A_HELP },
+ { "index-file", A_INDEX_FILE },
+ { "invalid", A_UINVALID },
+ { "left-scroll", A_LSHIFT },
+ { "next-file", A_NEXT_FILE },
+ { "next-tag", A_NEXT_TAG },
+ { "noaction", A_NOACTION },
+ { "percent", A_PERCENT },
+ { "pipe", A_PIPE },
+ { "prev-file", A_PREV_FILE },
+ { "prev-tag", A_PREV_TAG },
+ { "quit", A_QUIT },
+ { "remove-file", A_REMOVE_FILE },
+ { "repaint", A_REPAINT },
+ { "repaint-flush", A_FREPAINT },
+ { "repeat-search", A_AGAIN_SEARCH },
+ { "repeat-search-all", A_T_AGAIN_SEARCH },
+ { "reverse-search", A_REVERSE_SEARCH },
+ { "reverse-search-all", A_T_REVERSE_SEARCH },
+ { "right-scroll", A_RSHIFT },
+ { "set-mark", A_SETMARK },
+ { "shell", A_SHELL },
+ { "status", A_STAT },
+ { "toggle-flag", A_OPT_TOGGLE },
+ { "toggle-option", A_OPT_TOGGLE },
+ { "undo-hilite", A_UNDO_SEARCH },
+ { "version", A_VERSION },
+ { "visual", A_VISUAL },
+ { NULL, 0 }
};
-struct cmdname editnames[] =
-{
+struct cmdname editnames[] = {
{ "back-complete", EC_B_COMPLETE },
{ "backspace", EC_BACKSPACE },
{ "delete", EC_DELETE },
@@ -191,14 +196,14 @@ struct table vartable;
struct table *currtable = &cmdtable;
char fileheader[] = {
- C0_LESSKEY_MAGIC,
- C1_LESSKEY_MAGIC,
- C2_LESSKEY_MAGIC,
+ C0_LESSKEY_MAGIC,
+ C1_LESSKEY_MAGIC,
+ C2_LESSKEY_MAGIC,
C3_LESSKEY_MAGIC
};
char filetrailer[] = {
- C0_END_LESSKEY_MAGIC,
- C1_END_LESSKEY_MAGIC,
+ C0_END_LESSKEY_MAGIC,
+ C1_END_LESSKEY_MAGIC,
C2_END_LESSKEY_MAGIC
};
char cmdsection[1] = { CMD_SECTION };
@@ -207,55 +212,50 @@ char varsection[1] = { VAR_SECTION };
char endsection[1] = { END_SECTION };
char *infile = NULL;
-char *outfile = NULL ;
+char *outfile = NULL;
int linenum;
int errors;
extern char version[];
- void
-usage()
+void
+usage(void)
{
- fprintf(stderr, "usage: lesskey [-o output] [input]\n");
+ (void) fprintf(stderr, "usage: lesskey [-o output] [input]\n");
exit(1);
}
- char *
-mkpathname(dirname, filename)
- char *dirname;
- char *filename;
+char *
+mkpathname(char *dirname, char *filename)
{
char *pathname;
size_t len;
len = strlen(dirname) + strlen(filename) + 2;
- pathname = calloc(len, sizeof(char));
- strlcpy(pathname, dirname, len);
- strlcat(pathname, PATHNAME_SEP, len);
- strlcat(pathname, filename, len);
+ pathname = calloc(1, len);
+ if (pathname == NULL) {
+ fprintf(stderr, "mkpathname: out of memory\n");
+ exit(1);
+ }
+ (void) snprintf(pathname, len, "%s/%s", dirname, filename);
return (pathname);
}
/*
* Figure out the name of a default file (in the user's HOME directory).
*/
- char *
-homefile(filename)
- char *filename;
+char *
+homefile(char *filename)
{
char *p;
char *pathname;
- if ((p = getenv("HOME")) != NULL && *p != '\0')
+ if ((p = getenv("HOME")) != NULL && *p != '\0') {
pathname = mkpathname(p, filename);
-#if OS2
- else if ((p = getenv("INIT")) != NULL && *p != '\0')
- pathname = mkpathname(p, filename);
-#endif
- else
- {
- fprintf(stderr, "cannot find $HOME - using current directory\n");
+ } else {
+ (void) fprintf(stderr, "cannot find $HOME - "
+ "using current directory\n");
pathname = mkpathname(".", filename);
}
return (pathname);
@@ -264,16 +264,13 @@ homefile(filename)
/*
* Parse command line arguments.
*/
- void
-parse_args(argc, argv)
- int argc;
- char **argv;
+void
+parse_args(int argc, char **argv)
{
char *arg;
outfile = NULL;
- while (--argc > 0)
- {
+ while (--argc > 0) {
arg = *++argv;
if (arg[0] != '-')
/* Arg does not start with "-"; it's not an option. */
@@ -281,18 +278,15 @@ parse_args(argc, argv)
if (arg[1] == '\0')
/* "-" means standard input. */
break;
- if (arg[1] == '-' && arg[2] == '\0')
- {
+ if (arg[1] == '-' && arg[2] == '\0') {
/* "--" means end of options. */
argc--;
argv++;
break;
}
- switch (arg[1])
- {
+ switch (arg[1]) {
case '-':
- if (strncmp(arg, "--output", 8) == 0)
- {
+ if (strncmp(arg, "--output", 8) == 0) {
if (arg[8] == '\0')
outfile = &arg[8];
else if (arg[8] == '=')
@@ -301,8 +295,7 @@ parse_args(argc, argv)
usage();
goto opt_o;
}
- if (strcmp(arg, "--version") == 0)
- {
+ if (strcmp(arg, "--version") == 0) {
goto opt_V;
}
usage();
@@ -310,8 +303,7 @@ parse_args(argc, argv)
case 'o':
outfile = &argv[0][2];
opt_o:
- if (*outfile == '\0')
- {
+ if (*outfile == '\0') {
if (--argc <= 0)
usage();
outfile = *(++argv);
@@ -319,7 +311,7 @@ parse_args(argc, argv)
break;
case 'V':
opt_V:
- printf("lesskey version %s\n", version);
+ (void) printf("lesskey version %s\n", version);
exit(0);
default:
usage();
@@ -339,8 +331,8 @@ parse_args(argc, argv)
/*
* Initialize data structures.
*/
- void
-init_tables()
+void
+init_tables(void)
{
cmdtable.names = cmdnames;
cmdtable.pbuffer = cmdtable.buffer;
@@ -355,25 +347,21 @@ init_tables()
/*
* Parse one character of a string.
*/
- char *
-tstr(pp, xlate)
- char **pp;
- int xlate;
+char *
+tstr(char **pp, int xlate)
{
- register char *p;
- register char ch;
- register int i;
+ char *p;
+ char ch;
+ int i;
static char buf[10];
static char tstr_control_k[] =
{ SK_SPECIAL_KEY, SK_CONTROL_K, 6, 1, 1, 1, '\0' };
p = *pp;
- switch (*p)
- {
+ switch (*p) {
case '\\':
++p;
- switch (*p)
- {
+ switch (*p) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
/*
@@ -383,10 +371,11 @@ tstr(pp, xlate)
i = 0;
do
ch = 8*ch + (*p - '0');
- while (*++p >= '0' && *p <= '7' && ++i < 3);
+ while (*++p >= '0' && *p <= '7' && ++i < 3)
+ ;
*pp = p;
if (xlate && ch == CONTROL('K'))
- return tstr_control_k;
+ return (tstr_control_k);
buf[0] = ch;
buf[1] = '\0';
return (buf);
@@ -408,10 +397,8 @@ tstr(pp, xlate)
*pp = p+1;
return ("\t");
case 'k':
- if (xlate)
- {
- switch (*++p)
- {
+ if (xlate) {
+ switch (*++p) {
case 'u': ch = SK_UP_ARROW; break;
case 'd': ch = SK_DOWN_ARROW; break;
case 'r': ch = SK_RIGHT_ARROW; break;
@@ -422,7 +409,7 @@ tstr(pp, xlate)
case 'e': ch = SK_END; break;
case 'x': ch = SK_DELETE; break;
default:
- error("illegal char after \\k");
+ lkerr("illegal char after \\k");
*pp = p+1;
return ("");
}
@@ -439,14 +426,14 @@ tstr(pp, xlate)
/* FALLTHRU */
default:
/*
- * Backslash followed by any other char
+ * Backslash followed by any other char
* just means that char.
*/
*pp = p+1;
buf[0] = *p;
buf[1] = '\0';
if (xlate && buf[0] == CONTROL('K'))
- return tstr_control_k;
+ return (tstr_control_k);
return (buf);
}
case '^':
@@ -457,25 +444,24 @@ tstr(pp, xlate)
buf[0] = CONTROL(p[1]);
buf[1] = '\0';
if (buf[0] == CONTROL('K'))
- return tstr_control_k;
+ return (tstr_control_k);
return (buf);
}
*pp = p+1;
buf[0] = *p;
buf[1] = '\0';
if (xlate && buf[0] == CONTROL('K'))
- return tstr_control_k;
+ return (tstr_control_k);
return (buf);
}
/*
* Skip leading spaces in a string.
*/
- public char *
-skipsp(s)
- register char *s;
+char *
+skipsp(char *s)
{
- while (*s == ' ' || *s == '\t')
+ while (*s == ' ' || *s == '\t')
s++;
return (s);
}
@@ -483,9 +469,8 @@ skipsp(s)
/*
* Skip non-space characters in a string.
*/
- public char *
-skipnsp(s)
- register char *s;
+char *
+skipnsp(char *s)
{
while (*s != '\0' && *s != ' ' && *s != '\t')
s++;
@@ -496,11 +481,10 @@ skipnsp(s)
* Clean up an input line:
* strip off the trailing newline & any trailing # comment.
*/
- char *
-clean_line(s)
- char *s;
+char *
+clean_line(char *s)
{
- register int i;
+ int i;
s = skipsp(s);
for (i = 0; s[i] != '\n' && s[i] != '\r' && s[i] != '\0'; i++)
@@ -513,55 +497,47 @@ clean_line(s)
/*
* Add a byte to the output command table.
*/
- void
-add_cmd_char(c)
- int c;
+void
+add_cmd_char(int c)
{
- if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD)
- {
- error("too many commands");
+ if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD) {
+ lkerr("too many commands");
exit(1);
}
- *(currtable->pbuffer)++ = c;
+ *(currtable->pbuffer)++ = (char)c;
}
/*
* Add a string to the output command table.
*/
- void
-add_cmd_str(s)
- char *s;
+void
+add_cmd_str(char *s)
{
- for ( ; *s != '\0'; s++)
+ for (; *s != '\0'; s++)
add_cmd_char(*s);
}
/*
* See if we have a special "control" line.
*/
- int
-control_line(s)
- char *s;
+int
+control_line(char *s)
{
-#define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0)
+#define PREFIX(str, pat) (strncmp(str, pat, strlen(pat)) == 0)
- if (PREFIX(s, "#line-edit"))
- {
+ if (PREFIX(s, "#line-edit")) {
currtable = &edittable;
return (1);
}
- if (PREFIX(s, "#command"))
- {
+ if (PREFIX(s, "#command")) {
currtable = &cmdtable;
return (1);
}
- if (PREFIX(s, "#env"))
- {
+ if (PREFIX(s, "#env")) {
currtable = &vartable;
return (1);
}
- if (PREFIX(s, "#stop"))
- {
+ if (PREFIX(s, "#stop")) {
add_cmd_char('\0');
add_cmd_char(A_END_LIST);
return (1);
@@ -572,15 +548,11 @@ control_line(s)
/*
* Output some bytes.
*/
- void
-fputbytes(fd, buf, len)
- FILE *fd;
- char *buf;
- int len;
+void
+fputbytes(FILE *fd, char *buf, int len)
{
- while (len-- > 0)
- {
- fwrite(buf, sizeof(char), 1, fd);
+ while (len-- > 0) {
+ (void) fwrite(buf, sizeof (char), 1, fd);
buf++;
}
}
@@ -588,53 +560,47 @@ fputbytes(fd, buf, len)
/*
* Output an integer, in special KRADIX form.
*/
- void
-fputint(fd, val)
- FILE *fd;
- unsigned int val;
+void
+fputint(FILE *fd, unsigned int val)
{
char c;
- if (val >= KRADIX*KRADIX)
- {
- fprintf(stderr, "error: integer too big (%d > %d)\n",
- val, KRADIX*KRADIX);
+ if (val >= KRADIX*KRADIX) {
+ (void) fprintf(stderr, "error: integer too big (%d > %d)\n",
+ val, KRADIX*KRADIX);
exit(1);
}
c = val % KRADIX;
- fwrite(&c, sizeof(char), 1, fd);
+ (void) fwrite(&c, sizeof (char), 1, fd);
c = val / KRADIX;
- fwrite(&c, sizeof(char), 1, fd);
+ (void) fwrite(&c, sizeof (char), 1, fd);
}
/*
* Find an action, given the name of the action.
*/
- int
-findaction(actname)
- char *actname;
+int
+findaction(char *actname)
{
int i;
for (i = 0; currtable->names[i].cn_name != NULL; i++)
if (strcmp(currtable->names[i].cn_name, actname) == 0)
return (currtable->names[i].cn_action);
- error("unknown action");
+ lkerr("unknown action");
return (A_INVALID);
}
- void
-error(s)
- char *s;
+void
+lkerr(char *s)
{
- fprintf(stderr, "line %d: %s\n", linenum, s);
+ (void) fprintf(stderr, "line %d: %s\n", linenum, s);
errors++;
}
- void
-parse_cmdline(p)
- char *p;
+void
+parse_cmdline(char *p)
{
int cmdlen;
char *actname;
@@ -646,12 +612,11 @@ parse_cmdline(p)
* Parse the command string and store it in the current table.
*/
cmdlen = 0;
- do
- {
+ do {
s = tstr(&p, 1);
cmdlen += strlen(s);
if (cmdlen > MAX_CMDLEN)
- error("command too long");
+ lkerr("command too long");
else
add_cmd_str(s);
} while (*p != ' ' && *p != '\t' && *p != '\0');
@@ -666,9 +631,8 @@ parse_cmdline(p)
* Terminate the action name with a null byte.
*/
p = skipsp(p);
- if (*p == '\0')
- {
- error("missing action");
+ if (*p == '\0') {
+ lkerr("missing action");
return;
}
actname = p;
@@ -686,11 +650,9 @@ parse_cmdline(p)
*/
*p = c;
p = skipsp(p);
- if (*p == '\0')
- {
+ if (*p == '\0') {
add_cmd_char(action);
- } else
- {
+ } else {
/*
* OR the special value A_EXTRA into the action byte.
* Put the extra string after the action byte.
@@ -702,14 +664,12 @@ parse_cmdline(p)
}
}
- void
-parse_varline(p)
- char *p;
+void
+parse_varline(char *p)
{
char *s;
- do
- {
+ do {
s = tstr(&p, 0);
add_cmd_str(s);
} while (*p != ' ' && *p != '\t' && *p != '=' && *p != '\0');
@@ -719,17 +679,15 @@ parse_varline(p)
add_cmd_char('\0');
p = skipsp(p);
- if (*p++ != '=')
- {
- error("missing =");
+ if (*p++ != '=') {
+ lkerr("missing =");
return;
}
add_cmd_char(EV_OK|A_EXTRA);
p = skipsp(p);
- while (*p != '\0')
- {
+ while (*p != '\0') {
s = tstr(&p, 0);
add_cmd_str(s);
}
@@ -739,9 +697,8 @@ parse_varline(p)
/*
* Parse a line from the lesskey file.
*/
- void
-parse_line(line)
- char *line;
+void
+parse_line(char *line)
{
char *p;
@@ -765,36 +722,13 @@ parse_line(line)
parse_cmdline(p);
}
- int
-main(argc, argv)
- int argc;
- char *argv[];
+int
+main(int argc, char **argv)
{
FILE *desc;
FILE *out;
char line[1024];
-#ifdef WIN32
- if (getenv("HOME") == NULL)
- {
- /*
- * If there is no HOME environment variable,
- * try the concatenation of HOMEDRIVE + HOMEPATH.
- */
- char *drive = getenv("HOMEDRIVE");
- char *path = getenv("HOMEPATH");
- if (drive != NULL && path != NULL)
- {
- size_t len = strlen(drive) + strlen(path) + 6;
- char *env = (char *) calloc(len, sizeof(char));
- strlcpy(env, "HOME=", len);
- strlcat(env, drive, len);
- strlcat(env, path, len);
- putenv(env);
- }
- }
-#endif /* WIN32 */
-
/*
* Process command line arguments.
*/
@@ -806,13 +740,8 @@ main(argc, argv)
*/
if (strcmp(infile, "-") == 0)
desc = stdin;
- else if ((desc = fopen(infile, "r")) == NULL)
- {
-#if HAVE_PERROR
+ else if ((desc = fopen(infile, "r")) == NULL) {
perror(infile);
-#else
- fprintf(stderr, "Cannot open %s\n", infile);
-#endif
usage();
}
@@ -821,8 +750,7 @@ main(argc, argv)
*/
errors = 0;
linenum = 0;
- while (fgets(line, sizeof(line), desc) != NULL)
- {
+ while (fgets(line, sizeof (line), desc) != NULL) {
++linenum;
parse_line(line);
}
@@ -831,9 +759,9 @@ main(argc, argv)
* Write the output file.
* If no output file was specified, use "$HOME/.less"
*/
- if (errors > 0)
- {
- fprintf(stderr, "%d errors; no output produced\n", errors);
+ if (errors > 0) {
+ (void) fprintf(stderr, "%d errors; no output produced\n",
+ errors);
exit(1);
}
@@ -841,35 +769,34 @@ main(argc, argv)
outfile = getenv("LESSKEY");
if (outfile == NULL)
outfile = homefile(LESSKEYFILE);
- if ((out = fopen(outfile, "wb")) == NULL)
- {
-#if HAVE_PERROR
+ if ((out = fopen(outfile, "wb")) == NULL) {
perror(outfile);
-#else
- fprintf(stderr, "Cannot open %s\n", outfile);
-#endif
exit(1);
}
/* File header */
- fputbytes(out, fileheader, sizeof(fileheader));
+ fputbytes(out, fileheader, sizeof (fileheader));
/* Command key section */
- fputbytes(out, cmdsection, sizeof(cmdsection));
+ fputbytes(out, cmdsection, sizeof (cmdsection));
fputint(out, cmdtable.pbuffer - cmdtable.buffer);
- fputbytes(out, (char *)cmdtable.buffer, cmdtable.pbuffer-cmdtable.buffer);
+ fputbytes(out, (char *)cmdtable.buffer,
+ cmdtable.pbuffer-cmdtable.buffer);
+
/* Edit key section */
- fputbytes(out, editsection, sizeof(editsection));
+ fputbytes(out, editsection, sizeof (editsection));
fputint(out, edittable.pbuffer - edittable.buffer);
- fputbytes(out, (char *)edittable.buffer, edittable.pbuffer-edittable.buffer);
+ fputbytes(out, (char *)edittable.buffer,
+ edittable.pbuffer-edittable.buffer);
/* Environment variable section */
- fputbytes(out, varsection, sizeof(varsection));
+ fputbytes(out, varsection, sizeof (varsection));
fputint(out, vartable.pbuffer - vartable.buffer);
- fputbytes(out, (char *)vartable.buffer, vartable.pbuffer-vartable.buffer);
+ fputbytes(out, (char *)vartable.buffer,
+ vartable.pbuffer-vartable.buffer);
/* File trailer */
- fputbytes(out, endsection, sizeof(endsection));
- fputbytes(out, filetrailer, sizeof(filetrailer));
+ fputbytes(out, endsection, sizeof (endsection));
+ fputbytes(out, filetrailer, sizeof (filetrailer));
return (0);
}
diff --git a/usr.bin/less/lesskey.h b/usr.bin/less/lesskey.h
index 91098a59aa2..49129adb848 100644
--- a/usr.bin/less/lesskey.h
+++ b/usr.bin/less/lesskey.h
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Format of a lesskey file:
diff --git a/usr.bin/less/lesskey/Makefile b/usr.bin/less/lesskey/Makefile
index 36cf1222536..b87ec363a74 100644
--- a/usr.bin/less/lesskey/Makefile
+++ b/usr.bin/less/lesskey/Makefile
@@ -1,10 +1,15 @@
-# $OpenBSD: Makefile,v 1.1 2011/09/16 18:12:09 shadchin Exp $
+# $OpenBSD: Makefile,v 1.2 2015/11/05 22:08:44 nicm Exp $
+
+.PATH: ${.CURDIR}/..
PROG= lesskey
SRCS= lesskey.c version.c
-CDIAGFLAGS+=-Wall -W
-
MAN= lesskey.1
+BINDIR= /usr/bin
+
+CFLAGS+=-I${.CURDIR}/..
+
+CDIAGFLAGS+=-Wall -W
.include <bsd.prog.mk>
diff --git a/usr.bin/less/lglob.h b/usr.bin/less/lglob.h
deleted file mode 100644
index b5c32005386..00000000000
--- a/usr.bin/less/lglob.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 1984-2012 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, see the README file.
- */
-
-
-/*
- * Macros to define the method of doing filename "globbing".
- * There are three possible mechanisms:
- * 1. GLOB_LIST
- * This defines a function that returns a list of matching filenames.
- * 2. GLOB_NAME
- * This defines a function that steps thru the list of matching
- * filenames, returning one name each time it is called.
- * 3. GLOB_STRING
- * This defines a function that returns the complete list of
- * matching filenames as a single space-separated string.
- */
-
-#include <glob.h>
-
-#define GLOB_FLAGS (GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE)
-#define DECL_GLOB_LIST(list) glob_t list; int i;
-#define GLOB_LIST(filename,list) glob(filename,GLOB_FLAGS,0,&list)
-#define GLOB_LIST_FAILED(list) 0
-#define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++
-#define INIT_GLOB_LIST(list,p) p = list.gl_pathv[i]
-#define GLOB_LIST_DONE(list) globfree(&list)
diff --git a/usr.bin/less/line.c b/usr.bin/less/line.c
index 0517e23d85b..9638b2714ac 100644
--- a/usr.bin/less/line.c
+++ b/usr.bin/less/line.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to manipulate the "line buffer".
@@ -17,34 +20,31 @@
#include "less.h"
#include "charset.h"
-#include <err.h>
-
static char *linebuf = NULL; /* Buffer which holds the current output line */
static char *attr = NULL; /* Extension of linebuf to hold attributes */
-public int size_linebuf = 0; /* Size of line buffer (and attr buffer) */
+int size_linebuf = 0; /* Size of line buffer (and attr buffer) */
static int cshift; /* Current left-shift of output line buffer */
-public int hshift; /* Desired left-shift of output line buffer */
-public int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */
-public int ntabstops = 1; /* Number of tabstops */
-public int tabdefault = 8; /* Default repeated tabstops */
-public POSITION highest_hilite; /* Pos of last hilite in file found so far */
+int hshift; /* Desired left-shift of output line buffer */
+int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */
+int ntabstops = 1; /* Number of tabstops */
+int tabdefault = 8; /* Default repeated tabstops */
+off_t highest_hilite; /* Pos of last hilite in file found so far */
static int curr; /* Index into linebuf */
-static int column; /* Printable length, accounting for
- backspaces, etc. */
+static int column; /* Printable length, accounting for backspaces, etc. */
static int overstrike; /* Next char should overstrike previous char */
static int last_overstrike = AT_NORMAL;
static int is_null_line; /* There is no current line */
static int lmargin; /* Left margin */
static char pendc;
-static POSITION pendpos;
+static off_t pendpos;
static char *end_ansi_chars;
static char *mid_ansi_chars;
-static int attr_swidth();
-static int attr_ewidth();
-static int do_append();
+static int attr_swidth(int);
+static int attr_ewidth(int);
+static int do_append(LWCHAR, char *, off_t);
extern volatile sig_atomic_t sigs;
extern int bs_mode;
@@ -60,19 +60,19 @@ extern int bl_s_width, bl_e_width;
extern int so_s_width, so_e_width;
extern int sc_width, sc_height;
extern int utf_mode;
-extern POSITION start_attnpos;
-extern POSITION end_attnpos;
+extern off_t start_attnpos;
+extern off_t end_attnpos;
static char mbc_buf[MAX_UTF_CHAR_LEN];
static int mbc_buf_len = 0;
static int mbc_buf_index = 0;
-static POSITION mbc_pos;
+static off_t mbc_pos;
/*
* Initialize from environment variables.
*/
- public void
-init_line()
+void
+init_line(void)
{
end_ansi_chars = lgetenv("LESSANSIENDCHARS");
if (end_ansi_chars == NULL || *end_ansi_chars == '\0')
@@ -82,52 +82,41 @@ init_line()
if (mid_ansi_chars == NULL || *mid_ansi_chars == '\0')
mid_ansi_chars = "0123456789;[?!\"'#%()*+ ";
- linebuf = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
- attr = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
+ linebuf = ecalloc(LINEBUF_SIZE, sizeof (char));
+ attr = ecalloc(LINEBUF_SIZE, sizeof (char));
size_linebuf = LINEBUF_SIZE;
}
/*
* Expand the line buffer.
*/
- static int
-expand_linebuf()
+static int
+expand_linebuf(void)
{
/* Double the size of the line buffer. */
int new_size = size_linebuf * 2;
/* Just realloc to expand the buffer, if we can. */
- char *new_buf;
- char *new_attr;
-
- new_buf = realloc(linebuf, new_size);
- if (new_buf == NULL)
- return 1;
- new_attr = realloc(attr, new_size);
- if (new_attr == NULL) {
- /* realloc linebuf back to original size */
- linebuf = realloc(new_buf, size_linebuf);
- if (linebuf == NULL)
- err(1, NULL);
- return 1;
+ char *new_buf = realloc(linebuf, new_size);
+ char *new_attr = realloc(attr, new_size);
+ if (new_buf == NULL || new_attr == NULL) {
+ if (new_attr != NULL)
+ free(new_attr);
+ if (new_buf != NULL)
+ free(new_buf);
+ return (1);
}
- /*
- * We realloc'd the buffers; they already have the old contents.
- */
- memset(new_buf + size_linebuf, 0, new_size - size_linebuf);
- memset(new_attr + size_linebuf, 0, new_size - size_linebuf);
linebuf = new_buf;
attr = new_attr;
size_linebuf = new_size;
- return 0;
+ return (0);
}
/*
* Is a character ASCII?
*/
- public int
-is_ascii_char(ch)
- LWCHAR ch;
+int
+is_ascii_char(LWCHAR ch)
{
return (ch <= 0x7F);
}
@@ -135,8 +124,8 @@ is_ascii_char(ch)
/*
* Rewind the line buffer.
*/
- public void
-prewind()
+void
+prewind(void)
{
curr = 0;
column = 0;
@@ -154,19 +143,17 @@ prewind()
/*
* Insert the line number (of the given position) into the line buffer.
*/
- public void
-plinenum(pos)
- POSITION pos;
+void
+plinenum(off_t pos)
{
- register LINENUM linenum = 0;
- register int i;
+ LINENUM linenum = 0;
+ int i;
- if (linenums == OPT_ONPLUS)
- {
+ if (linenums == OPT_ONPLUS) {
/*
* Get the line number and put it in the current line.
* {{ Note: since find_linenum calls forw_raw_line,
- * it may seek in the input file, requiring the caller
+ * it may seek in the input file, requiring the caller
* of plinenum to re-seek if necessary. }}
* {{ Since forw_raw_line modifies linebuf, we must
* do this first, before storing anything in linebuf. }}
@@ -177,10 +164,9 @@ plinenum(pos)
/*
* Display a status column if the -J option is set.
*/
- if (status_col)
- {
+ if (status_col) {
linebuf[curr] = ' ';
- if (start_attnpos != NULL_POSITION &&
+ if (start_attnpos != -1 &&
pos >= start_attnpos && pos < end_attnpos)
attr[curr] = AT_NORMAL|AT_HILITE;
else
@@ -192,12 +178,11 @@ plinenum(pos)
* Display the line number at the start of each line
* if the -N option is set.
*/
- if (linenums == OPT_ONPLUS)
- {
+ if (linenums == OPT_ONPLUS) {
char buf[INT_STRLEN_BOUND(pos) + 2];
int n;
- linenumtoa(linenum, buf, sizeof(buf));
+ linenumtoa(linenum, buf, sizeof (buf));
n = strlen(buf);
if (n < MIN_LINENUM_WIDTH)
n = MIN_LINENUM_WIDTH;
@@ -213,8 +198,7 @@ plinenum(pos)
/*
* Append enough spaces to bring us to the lmargin.
*/
- while (column < lmargin)
- {
+ while (column < lmargin) {
linebuf[curr] = ' ';
attr[curr++] = AT_NORMAL;
column++;
@@ -225,9 +209,8 @@ plinenum(pos)
* Shift the input line left.
* This means discarding N printable chars at the start of the buffer.
*/
- static void
-pshift(shift)
- int shift;
+static void
+pshift(int shift)
{
LWCHAR prev_ch = 0;
unsigned char c;
@@ -249,29 +232,24 @@ pshift(shift)
* We keep on going when shifted == shift
* to get all combining chars.
*/
- while (shifted <= shift && from < curr)
- {
+ while (shifted <= shift && from < curr) {
c = linebuf[from];
- if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
- {
+ if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) {
/* Keep cumulative effect. */
linebuf[to] = c;
attr[to++] = attr[from++];
- while (from < curr && linebuf[from])
- {
+ while (from < curr && linebuf[from]) {
linebuf[to] = linebuf[from];
attr[to++] = attr[from];
if (!is_ansi_middle(linebuf[from++]))
break;
- }
+ }
continue;
}
width = 0;
-#if !SMALL
- if (!IS_ASCII_OCTET(c) && utf_mode)
- {
+ if (!IS_ASCII_OCTET(c) && utf_mode) {
/* Assumes well-formedness validation already done. */
LWCHAR ch;
@@ -279,20 +257,16 @@ pshift(shift)
if (from + len > curr)
break;
ch = get_wchar(linebuf + from);
- if (!is_composing_char(ch) && !is_combining_char(prev_ch, ch))
+ if (!is_composing_char(ch) &&
+ !is_combining_char(prev_ch, ch))
width = is_wide_char(ch) ? 2 : 1;
prev_ch = ch;
- } else
-#endif /* !SMALL */
- {
+ } else {
len = 1;
if (c == '\b')
/* XXX - Incorrect if several '\b' in a row. */
-#if !SMALL
- width = (utf_mode && is_wide_char(prev_ch)) ? -2 : -1;
-#else
- width = -1;
-#endif /* !SMALL */
+ width = (utf_mode && is_wide_char(prev_ch)) ?
+ -2 : -1;
else if (!control_char(c))
width = 1;
prev_ch = 0;
@@ -315,14 +289,12 @@ pshift(shift)
/* Adjust width for magic cookies. */
prev_attr = (to > 0) ? attr[to-1] : AT_NORMAL;
next_attr = (from + len < curr) ? attr[from + len] : prev_attr;
- if (!is_at_equiv(attr[from], prev_attr) &&
- !is_at_equiv(attr[from], next_attr))
- {
+ if (!is_at_equiv(attr[from], prev_attr) &&
+ !is_at_equiv(attr[from], next_attr)) {
width += attr_swidth(attr[from]);
if (from + len < curr)
width += attr_ewidth(attr[from]);
- if (is_at_equiv(prev_attr, next_attr))
- {
+ if (is_at_equiv(prev_attr, next_attr)) {
width += attr_ewidth(prev_attr);
if (from + len < curr)
width += attr_swidth(next_attr);
@@ -336,8 +308,7 @@ pshift(shift)
if (shifted < 0)
shifted = 0;
}
- while (from < curr)
- {
+ while (from < curr) {
linebuf[to] = linebuf[from];
attr[to++] = attr[from++];
}
@@ -349,8 +320,8 @@ pshift(shift)
/*
*
*/
- public void
-pshift_all()
+void
+pshift_all(void)
{
pshift(column);
}
@@ -359,9 +330,8 @@ pshift_all()
* Return the printing width of the start (enter) sequence
* for a given character attribute.
*/
- static int
-attr_swidth(a)
- int a;
+static int
+attr_swidth(int a)
{
int w = 0;
@@ -376,16 +346,15 @@ attr_swidth(a)
if (a & AT_STANDOUT)
w += so_s_width;
- return w;
+ return (w);
}
/*
* Return the printing width of the end (exit) sequence
* for a given character attribute.
*/
- static int
-attr_ewidth(a)
- int a;
+static int
+attr_ewidth(int a)
{
int w = 0;
@@ -400,7 +369,7 @@ attr_ewidth(a)
if (a & AT_STANDOUT)
w += so_e_width;
- return w;
+ return (w);
}
/*
@@ -409,11 +378,8 @@ attr_ewidth(a)
* Adding a character with a given attribute may cause an enter or exit
* attribute sequence to be inserted, so this must be taken into account.
*/
- static int
-pwidth(ch, a, prev_ch)
- LWCHAR ch;
- int a;
- LWCHAR prev_ch;
+static int
+pwidth(LWCHAR ch, int a, LWCHAR prev_ch)
{
int w;
@@ -422,16 +388,10 @@ pwidth(ch, a, prev_ch)
* Backspace moves backwards one or two positions.
* XXX - Incorrect if several '\b' in a row.
*/
-#if !SMALL
- return (utf_mode && is_wide_char(prev_ch)) ? -2 : -1;
-#else
- return -1;
-#endif /* !SMALL */
-
- if (!utf_mode || is_ascii_char(ch))
- {
- if (control_char((char)ch))
- {
+ return ((utf_mode && is_wide_char(prev_ch)) ? -2 : -1);
+
+ if (!utf_mode || is_ascii_char(ch)) {
+ if (control_char((char)ch)) {
/*
* Control characters do unpredictable things,
* so we don't even try to guess; say it doesn't move.
@@ -439,12 +399,8 @@ pwidth(ch, a, prev_ch)
*/
return (0);
}
- }
-#if !SMALL
- else
- {
- if (is_composing_char(ch) || is_combining_char(prev_ch, ch))
- {
+ } else {
+ if (is_composing_char(ch) || is_combining_char(prev_ch, ch)) {
/*
* Composing and combining chars take up no space.
*
@@ -459,17 +415,14 @@ pwidth(ch, a, prev_ch)
return (0);
}
}
-#endif /* !SMALL */
/*
* Other characters take one or two columns,
* plus the width of any attribute enter/exit sequence.
*/
w = 1;
-#if !SMALL
if (is_wide_char(ch))
w++;
-#endif /* !SMALL */
if (curr > 0 && !is_at_equiv(attr[curr-1], a))
w += attr_ewidth(attr[curr-1]);
if ((apply_at_specials(a) != AT_NORMAL) &&
@@ -482,8 +435,8 @@ pwidth(ch, a, prev_ch)
* Delete to the previous base character in the line buffer.
* Return 1 if one is found.
*/
- static int
-backc()
+static int
+backc(void)
{
LWCHAR prev_ch;
char *p = linebuf + curr;
@@ -491,27 +444,25 @@ backc()
int width;
/* This assumes that there is no '\b' in linebuf. */
- while ( curr > lmargin
- && column > lmargin
- && (!(attr[curr - 1] & (AT_ANSI|AT_BINARY))))
- {
+ while (curr > lmargin && column > lmargin &&
+ (!(attr[curr - 1] & (AT_ANSI|AT_BINARY)))) {
curr = p - linebuf;
prev_ch = step_char(&p, -1, linebuf + lmargin);
width = pwidth(ch, attr[curr], prev_ch);
column -= width;
if (width > 0)
- return 1;
+ return (1);
ch = prev_ch;
}
- return 0;
+ return (0);
}
/*
* Are we currently within a recognized ANSI escape sequence?
*/
- static int
-in_ansi_esc_seq()
+static int
+in_ansi_esc_seq(void)
{
char *p;
@@ -519,8 +470,7 @@ in_ansi_esc_seq()
* Search backwards for either an ESC (which means we ARE in a seq);
* or an end char (which means we're NOT in a seq).
*/
- for (p = &linebuf[curr]; p > linebuf; )
- {
+ for (p = &linebuf[curr]; p > linebuf; ) {
LWCHAR ch = step_char(&p, -1, linebuf);
if (IS_CSI_START(ch))
return (1);
@@ -533,74 +483,59 @@ in_ansi_esc_seq()
/*
* Is a character the end of an ANSI escape sequence?
*/
- public int
-is_ansi_end(ch)
- LWCHAR ch;
+int
+is_ansi_end(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
- return (strchr(end_ansi_chars, (char) ch) != NULL);
+ return (strchr(end_ansi_chars, (char)ch) != NULL);
}
/*
*
*/
- public int
-is_ansi_middle(ch)
- LWCHAR ch;
+int
+is_ansi_middle(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
if (is_ansi_end(ch))
return (0);
- return (strchr(mid_ansi_chars, (char) ch) != NULL);
+ return (strchr(mid_ansi_chars, (char)ch) != NULL);
}
/*
* Append a character and attribute to the line buffer.
*/
-#define STORE_CHAR(ch,a,rep,pos) \
- do { \
- if (store_char((ch),(a),(rep),(pos))) return (1); \
- } while (0)
-
- static int
-store_char(ch, a, rep, pos)
- LWCHAR ch;
- int a;
- char *rep;
- POSITION pos;
+#define STORE_CHAR(ch, a, rep, pos) \
+ if (store_char((ch), (a), (rep), (pos))) \
+ return (1)
+
+static int
+store_char(LWCHAR ch, char a, char *rep, off_t pos)
{
int w;
int replen;
char cs;
+ int matches;
w = (a & (AT_UNDERLINE|AT_BOLD)); /* Pre-use w. */
if (w != AT_NORMAL)
last_overstrike = w;
-#if HILITE_SEARCH
- {
- int matches;
- if (is_hilited(pos, pos+1, 0, &matches))
- {
- /*
- * This character should be highlighted.
- * Override the attribute passed in.
- */
- if (a != AT_ANSI)
- {
- if (highest_hilite != NULL_POSITION &&
- pos > highest_hilite)
- highest_hilite = pos;
- a |= AT_HILITE;
- }
+ if (is_hilited(pos, pos+1, 0, &matches)) {
+ /*
+ * This character should be highlighted.
+ * Override the attribute passed in.
+ */
+ if (a != AT_ANSI) {
+ if (highest_hilite != -1 && pos > highest_hilite)
+ highest_hilite = pos;
+ a |= AT_HILITE;
}
}
-#endif
- if (ctldisp == OPT_ONPLUS && in_ansi_esc_seq())
- {
+ if (ctldisp == OPT_ONPLUS && in_ansi_esc_seq()) {
if (!is_ansi_end(ch) && !is_ansi_middle(ch)) {
/* Remove whole unrecognized sequence. */
char *p = &linebuf[curr];
@@ -609,18 +544,14 @@ store_char(ch, a, rep, pos)
bch = step_char(&p, -1, linebuf);
} while (p > linebuf && !IS_CSI_START(bch));
curr = p - linebuf;
- return 0;
+ return (0);
}
a = AT_ANSI; /* Will force re-AT_'ing around it. */
w = 0;
- }
- else if (ctldisp == OPT_ONPLUS && IS_CSI_START(ch))
- {
+ } else if (ctldisp == OPT_ONPLUS && IS_CSI_START(ch)) {
a = AT_ANSI; /* Will force re-AT_'ing around it. */
w = 0;
- }
- else
- {
+ } else {
char *p = &linebuf[curr];
LWCHAR prev_ch = step_char(&p, -1, linebuf);
w = pwidth(ch, a, prev_ch);
@@ -632,21 +563,14 @@ store_char(ch, a, rep, pos)
*/
return (1);
- if (rep == NULL)
- {
- cs = (char) ch;
+ if (rep == NULL) {
+ cs = (char)ch;
rep = &cs;
replen = 1;
- } else
- {
-#if !SMALL
+ } else {
replen = utf_len(rep[0]);
-#else
- replen = 1;
-#endif /* !SMALL */
}
- if (curr + replen >= size_linebuf-6)
- {
+ if (curr + replen >= size_linebuf-6) {
/*
* Won't fit in line buffer.
* Try to expand it.
@@ -655,8 +579,7 @@ store_char(ch, a, rep, pos)
return (1);
}
- while (replen-- > 0)
- {
+ while (replen-- > 0) {
linebuf[curr] = *rep++;
attr[curr] = a;
curr++;
@@ -669,44 +592,42 @@ store_char(ch, a, rep, pos)
* Append a tab to the line buffer.
* Store spaces to represent the tab.
*/
-#define STORE_TAB(a,pos) \
- do { if (store_tab((a),(pos))) return (1); } while (0)
+#define STORE_TAB(a, pos) \
+ if (store_tab((a), (pos))) \
+ return (1)
- static int
-store_tab(attr, pos)
- int attr;
- POSITION pos;
+static int
+store_tab(int attr, off_t pos)
{
int to_tab = column + cshift - lmargin;
int i;
if (ntabstops < 2 || to_tab >= tabstops[ntabstops-1])
to_tab = tabdefault -
- ((to_tab - tabstops[ntabstops-1]) % tabdefault);
- else
- {
+ ((to_tab - tabstops[ntabstops-1]) % tabdefault);
+ else {
for (i = ntabstops - 2; i >= 0; i--)
if (to_tab >= tabstops[i])
break;
to_tab = tabstops[i+1] - to_tab;
}
- if (column + to_tab - 1 + pwidth(' ', attr, 0) + attr_ewidth(attr) > sc_width)
- return 1;
+ if (column + to_tab - 1 + pwidth(' ', attr, 0) +
+ attr_ewidth(attr) > sc_width)
+ return (1);
do {
STORE_CHAR(' ', attr, " ", pos);
} while (--to_tab > 0);
- return 0;
+ return (0);
}
-#define STORE_PRCHAR(c, pos) \
- do { if (store_prchar((c), (pos))) return 1; } while (0)
+#define STORE_PRCHAR(c, pos) \
+ if (store_prchar((c), (pos))) \
+ return (1)
- static int
-store_prchar(c, pos)
- char c;
- POSITION pos;
+static int
+store_prchar(char c, off_t pos)
{
char *s;
@@ -719,45 +640,39 @@ store_prchar(c, pos)
* Make sure we can get the entire representation
* of the character on this line.
*/
- if (column + (int) strlen(s) - 1 +
- pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
- return 1;
+ if (column + (int)strlen(s) - 1 +
+ pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
+ return (1);
- for ( ; *s != 0; s++)
+ for (; *s != 0; s++) {
STORE_CHAR(*s, AT_BINARY, NULL, pos);
-
- return 0;
+ }
+ return (0);
}
-#if !SMALL
- static int
-flush_mbc_buf(pos)
- POSITION pos;
+static int
+flush_mbc_buf(off_t pos)
{
int i;
for (i = 0; i < mbc_buf_index; i++)
if (store_prchar(mbc_buf[i], pos))
- return mbc_buf_index - i;
+ return (mbc_buf_index - i);
- return 0;
+ return (0);
}
-#endif /* !SMALL */
/*
* Append a character to the line buffer.
* Expand tabs into spaces, handle underlining, boldfacing, etc.
* Returns 0 if ok, 1 if couldn't fit in buffer.
*/
- public int
-pappend(c, pos)
- char c;
- POSITION pos;
+int
+pappend(char c, off_t pos)
{
int r;
- if (pendc)
- {
+ if (pendc) {
if (do_append(pendc, NULL, pendpos))
/*
* Oops. We've probably lost the char which
@@ -767,11 +682,8 @@ pappend(c, pos)
pendc = '\0';
}
- if (c == '\r' && bs_mode == BS_SPECIAL)
- {
-#if !SMALL
- if (mbc_buf_len > 0) /* utf_mode must be on. */
- {
+ if (c == '\r' && bs_mode == BS_SPECIAL) {
+ if (mbc_buf_len > 0) /* utf_mode must be on. */ {
/* Flush incomplete (truncated) sequence. */
r = flush_mbc_buf(mbc_pos);
mbc_buf_index = r + 1;
@@ -779,10 +691,9 @@ pappend(c, pos)
if (r)
return (mbc_buf_index);
}
-#endif /* !SMALL */
/*
- * Don't put the CR into the buffer until we see
+ * Don't put the CR into the buffer until we see
* the next char. If the next char is a newline,
* discard the CR.
*/
@@ -791,42 +702,36 @@ pappend(c, pos)
return (0);
}
- if (!utf_mode)
- {
+ if (!utf_mode) {
r = do_append((LWCHAR) c, NULL, pos);
- }
-#if !SMALL
- else
- {
+ } else {
/* Perform strict validation in all possible cases. */
- if (mbc_buf_len == 0)
- {
- retry:
+ if (mbc_buf_len == 0) {
+retry:
mbc_buf_index = 1;
*mbc_buf = c;
- if (IS_ASCII_OCTET(c))
+ if (IS_ASCII_OCTET(c)) {
r = do_append((LWCHAR) c, NULL, pos);
- else if (IS_UTF8_LEAD(c))
- {
+ } else if (IS_UTF8_LEAD(c)) {
mbc_buf_len = utf_len(c);
mbc_pos = pos;
return (0);
- } else
+ } else {
/* UTF8_INVALID or stray UTF8_TRAIL */
r = flush_mbc_buf(pos);
- } else if (IS_UTF8_TRAIL(c))
- {
+ }
+ } else if (IS_UTF8_TRAIL(c)) {
mbc_buf[mbc_buf_index++] = c;
if (mbc_buf_index < mbc_buf_len)
return (0);
if (is_utf8_well_formed(mbc_buf))
- r = do_append(get_wchar(mbc_buf), mbc_buf, mbc_pos);
+ r = do_append(get_wchar(mbc_buf), mbc_buf,
+ mbc_pos);
else
/* Complete, but not shortest form, sequence. */
mbc_buf_index = r = flush_mbc_buf(mbc_pos);
mbc_buf_len = 0;
- } else
- {
+ } else {
/* Flush incomplete (truncated) sequence. */
r = flush_mbc_buf(mbc_pos);
mbc_buf_index = r + 1;
@@ -834,9 +739,8 @@ pappend(c, pos)
/* Handle new char. */
if (!r)
goto retry;
- }
+ }
}
-#endif /* !SMALL */
/*
* If we need to shift the line, do it.
@@ -844,32 +748,26 @@ pappend(c, pos)
* so shifting it doesn't affect the chars we're currently
* pappending. (Bold & underline can get messed up otherwise.)
*/
- if (cshift < hshift && column > sc_width / 2)
- {
+ if (cshift < hshift && column > sc_width / 2) {
linebuf[curr] = '\0';
pshift(hshift - cshift);
}
- if (r)
- {
+ if (r) {
/* How many chars should caller back up? */
r = (!utf_mode) ? 1 : mbc_buf_index;
}
return (r);
}
- static int
-do_append(ch, rep, pos)
- LWCHAR ch;
- char *rep;
- POSITION pos;
+static int
+do_append(LWCHAR ch, char *rep, off_t pos)
{
- register int a;
+ int a;
LWCHAR prev_ch;
a = AT_NORMAL;
- if (ch == '\b')
- {
+ if (ch == '\b') {
if (bs_mode == BS_CONTROL)
goto do_control_char;
@@ -878,37 +776,32 @@ do_append(ch, rep, pos)
* backspace over part of the printed
* representation of a binary character.
*/
- if ( curr <= lmargin
- || column <= lmargin
- || (attr[curr - 1] & (AT_ANSI|AT_BINARY)))
+ if (curr <= lmargin ||
+ column <= lmargin ||
+ (attr[curr - 1] & (AT_ANSI|AT_BINARY))) {
STORE_PRCHAR('\b', pos);
- else if (bs_mode == BS_NORMAL)
+ } else if (bs_mode == BS_NORMAL) {
STORE_CHAR(ch, AT_NORMAL, NULL, pos);
- else if (bs_mode == BS_SPECIAL)
+ } else if (bs_mode == BS_SPECIAL) {
overstrike = backc();
+ }
- return 0;
+ return (0);
}
- if (overstrike > 0)
- {
+ if (overstrike > 0) {
/*
* Overstrike the character at the current position
- * in the line buffer. This will cause either
- * underline (if a "_" is overstruck),
+ * in the line buffer. This will cause either
+ * underline (if a "_" is overstruck),
* bold (if an identical character is overstruck),
* or just deletion of the character in the buffer.
*/
overstrike = utf_mode ? -1 : 0;
/* To be correct, this must be a base character. */
-#if !SMALL
prev_ch = get_wchar(linebuf + curr);
-#else
- prev_ch = (LWCHAR)((char)(linebuf + curr)[0] & 0xFF);
-#endif /* !SMALL */
a = attr[curr];
- if (ch == prev_ch)
- {
+ if (ch == prev_ch) {
/*
* Overstriking a char with itself means make it bold.
* But overstriking an underscore with itself is
@@ -916,45 +809,38 @@ do_append(ch, rep, pos)
* it could mean make it underlined.
* Use the previous overstrike to resolve it.
*/
- if (ch == '_')
- {
+ if (ch == '_') {
if ((a & (AT_BOLD|AT_UNDERLINE)) != AT_NORMAL)
a |= (AT_BOLD|AT_UNDERLINE);
else if (last_overstrike != AT_NORMAL)
a |= last_overstrike;
else
a |= AT_BOLD;
- } else
+ } else {
a |= AT_BOLD;
- } else if (ch == '_')
- {
+ }
+ } else if (ch == '_') {
a |= AT_UNDERLINE;
ch = prev_ch;
rep = linebuf + curr;
- } else if (prev_ch == '_')
- {
+ } else if (prev_ch == '_') {
a |= AT_UNDERLINE;
}
/* Else we replace prev_ch, but we keep its attributes. */
- } else if (overstrike < 0)
- {
-#if !SMALL
- if ( is_composing_char(ch)
- || is_combining_char(get_wchar(linebuf + curr), ch))
+ } else if (overstrike < 0) {
+ if (is_composing_char(ch) ||
+ is_combining_char(get_wchar(linebuf + curr), ch))
/* Continuation of the same overstrike. */
a = last_overstrike;
else
-#endif /* !SMALL */
overstrike = 0;
}
- if (ch == '\t')
- {
+ if (ch == '\t') {
/*
* Expand a tab into spaces.
*/
- switch (bs_mode)
- {
+ switch (bs_mode) {
case BS_CONTROL:
goto do_control_char;
case BS_NORMAL:
@@ -962,68 +848,55 @@ do_append(ch, rep, pos)
STORE_TAB(a, pos);
break;
}
- } else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch))
- {
- do_control_char:
- if (ctldisp == OPT_ON || (ctldisp == OPT_ONPLUS && IS_CSI_START(ch)))
- {
+ } else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch)) {
+do_control_char:
+ if (ctldisp == OPT_ON ||
+ (ctldisp == OPT_ONPLUS && IS_CSI_START(ch))) {
/*
* Output as a normal character.
*/
STORE_CHAR(ch, AT_NORMAL, rep, pos);
- } else
- {
- STORE_PRCHAR((char) ch, pos);
+ } else {
+ STORE_PRCHAR((char)ch, pos);
}
- }
-#if !SMALL
- else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch))
- {
+ } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch)) {
char *s;
s = prutfchar(ch);
- if (column + (int) strlen(s) - 1 +
+ if (column + (int)strlen(s) - 1 +
pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
return (1);
- for ( ; *s != 0; s++)
+ for (; *s != 0; s++)
STORE_CHAR(*s, AT_BINARY, NULL, pos);
- }
-#endif /* !SMALL */
- else
- {
+ } else {
STORE_CHAR(ch, a, rep, pos);
}
- return (0);
+ return (0);
}
/*
*
*/
- public int
-pflushmbc()
+int
+pflushmbc(void)
{
int r = 0;
-#if !SMALL
- if (mbc_buf_len > 0)
- {
+ if (mbc_buf_len > 0) {
/* Flush incomplete (truncated) sequence. */
r = flush_mbc_buf(mbc_pos);
mbc_buf_len = 0;
}
-#endif /* !SMALL */
- return r;
+ return (r);
}
/*
* Terminate the line in the line buffer.
*/
- public void
-pdone(endline, forw)
- int endline;
- int forw;
+void
+pdone(int endline, int forw)
{
(void) pflushmbc();
@@ -1041,12 +914,10 @@ pdone(endline, forw)
if (cshift < hshift)
pshift(hshift - cshift);
- if (ctldisp == OPT_ONPLUS && is_ansi_end('m'))
- {
+ if (ctldisp == OPT_ONPLUS && is_ansi_end('m')) {
/* Switch to normal attribute at end of line. */
char *p = "\033[m";
- for ( ; *p != '\0'; p++)
- {
+ for (; *p != '\0'; p++) {
linebuf[curr] = *p;
attr[curr++] = AT_ANSI;
}
@@ -1059,20 +930,18 @@ pdone(endline, forw)
* or if the terminal doesn't auto wrap,
* or if this is really the end of the line AND the terminal ignores
* a newline at the right edge.
- * (In the last case we don't want to output a newline if the terminal
+ * (In the last case we don't want to output a newline if the terminal
* doesn't ignore it since that would produce an extra blank line.
* But we do want to output a newline if the terminal ignores it in case
* the next line is blank. In that case the single newline output for
* that blank line would be ignored!)
*/
- if (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON)
- {
+ if (column < sc_width || !auto_wrap || (endline && ignaw) ||
+ ctldisp == OPT_ON) {
linebuf[curr] = '\n';
attr[curr] = AT_NORMAL;
curr++;
- }
- else if (ignaw && column >= sc_width && forw)
- {
+ } else if (ignaw && column >= sc_width && forw) {
/*
* Terminals with "ignaw" don't wrap until they *really* need
* to, i.e. when the character *after* the last one to fit on a
@@ -1080,16 +949,16 @@ pdone(endline, forw)
* get in the state where a full screen width of characters
* have been output but the cursor is sitting on the right edge
* instead of at the start of the next line.
- * So we nudge them into wrapping by outputting a space
- * character plus a backspace. But do this only if moving
+ * So we nudge them into wrapping by outputting a space
+ * character plus a backspace. But do this only if moving
* forward; if we're moving backward and drawing this line at
* the top of the screen, the space would overwrite the first
- * char on the next line. We don't need to do this "nudge"
+ * char on the next line. We don't need to do this "nudge"
* at the top of the screen anyway.
*/
linebuf[curr] = ' ';
attr[curr++] = AT_NORMAL;
- linebuf[curr] = '\b';
+ linebuf[curr] = '\b';
attr[curr++] = AT_NORMAL;
}
linebuf[curr] = '\0';
@@ -1099,9 +968,8 @@ pdone(endline, forw)
/*
*
*/
- public void
-set_status_col(c)
- char c;
+void
+set_status_col(char c)
{
linebuf[0] = c;
attr[0] = AT_NORMAL|AT_HILITE;
@@ -1112,29 +980,24 @@ set_status_col(c)
* Return the character as the function return value,
* and the character attribute in *ap.
*/
- public int
-gline(i, ap)
- register int i;
- register int *ap;
+int
+gline(int i, int *ap)
{
- if (is_null_line)
- {
+ if (is_null_line) {
/*
* If there is no current line, we pretend the line is
* either "~" or "", depending on the "twiddle" flag.
*/
- if (twiddle)
- {
- if (i == 0)
- {
+ if (twiddle) {
+ if (i == 0) {
*ap = AT_BOLD;
- return '~';
+ return ('~');
}
--i;
}
/* Make sure we're back to AT_NORMAL before the '\n'. */
*ap = AT_NORMAL;
- return i ? '\0' : '\n';
+ return (i ? '\0' : '\n');
}
*ap = attr[i];
@@ -1144,8 +1007,8 @@ gline(i, ap)
/*
* Indicate that there is no current line.
*/
- public void
-null_line()
+void
+null_line(void)
{
is_null_line = 1;
cshift = 0;
@@ -1156,32 +1019,25 @@ null_line()
* lines which are not split for screen width.
* {{ This is supposed to be more efficient than forw_line(). }}
*/
- public POSITION
-forw_raw_line(curr_pos, linep, line_lenp)
- POSITION curr_pos;
- char **linep;
- int *line_lenp;
+off_t
+forw_raw_line(off_t curr_pos, char **linep, int *line_lenp)
{
- register int n;
- register int c;
- POSITION new_pos;
+ int n;
+ int c;
+ off_t new_pos;
- if (curr_pos == NULL_POSITION || ch_seek(curr_pos) ||
- (c = ch_forw_get()) == EOI)
- return (NULL_POSITION);
+ if (curr_pos == -1 || ch_seek(curr_pos) ||
+ (c = ch_forw_get()) == EOI)
+ return (-1);
n = 0;
- for (;;)
- {
- if (c == '\n' || c == EOI || ABORT_SIGS())
- {
+ for (;;) {
+ if (c == '\n' || c == EOI || ABORT_SIGS()) {
new_pos = ch_tell();
break;
}
- if (n >= size_linebuf-1)
- {
- if (expand_linebuf())
- {
+ if (n >= size_linebuf-1) {
+ if (expand_linebuf()) {
/*
* Overflowed the input buffer.
* Pretend the line ended here.
@@ -1190,7 +1046,7 @@ forw_raw_line(curr_pos, linep, line_lenp)
break;
}
}
- linebuf[n++] = c;
+ linebuf[n++] = (char)c;
c = ch_forw_get();
}
linebuf[n] = '\0';
@@ -1205,27 +1061,21 @@ forw_raw_line(curr_pos, linep, line_lenp)
* Analogous to back_line(), but deals with "raw lines".
* {{ This is supposed to be more efficient than back_line(). }}
*/
- public POSITION
-back_raw_line(curr_pos, linep, line_lenp)
- POSITION curr_pos;
- char **linep;
- int *line_lenp;
+off_t
+back_raw_line(off_t curr_pos, char **linep, int *line_lenp)
{
- register int n;
- register int c;
- POSITION new_pos;
+ int n;
+ int c;
+ off_t new_pos;
- if (curr_pos == NULL_POSITION || curr_pos <= ch_zero() ||
- ch_seek(curr_pos-1))
- return (NULL_POSITION);
+ if (curr_pos == -1 || curr_pos <= ch_zero() || ch_seek(curr_pos - 1))
+ return (-1);
n = size_linebuf;
linebuf[--n] = '\0';
- for (;;)
- {
+ for (;;) {
c = ch_back_get();
- if (c == '\n' || ABORT_SIGS())
- {
+ if (c == '\n' || ABORT_SIGS()) {
/*
* This is the newline ending the previous line.
* We have hit the beginning of the line.
@@ -1233,8 +1083,7 @@ back_raw_line(curr_pos, linep, line_lenp)
new_pos = ch_tell() + 1;
break;
}
- if (c == EOI)
- {
+ if (c == EOI) {
/*
* We have hit the beginning of the file.
* This must be the first line in the file.
@@ -1243,11 +1092,9 @@ back_raw_line(curr_pos, linep, line_lenp)
new_pos = ch_zero();
break;
}
- if (n <= 0)
- {
+ if (n <= 0) {
int old_size_linebuf = size_linebuf;
- if (expand_linebuf())
- {
+ if (expand_linebuf()) {
/*
* Overflowed the input buffer.
* Pretend the line ended here.
diff --git a/usr.bin/less/linenum.c b/usr.bin/less/linenum.c
index db2e9229273..8be49ed6f33 100644
--- a/usr.bin/less/linenum.c
+++ b/usr.bin/less/linenum.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Code to handle displaying line numbers.
@@ -42,8 +45,8 @@ struct linenum_info
{
struct linenum_info *next; /* Link to next in the list */
struct linenum_info *prev; /* Line to previous in the list */
- POSITION pos; /* File position */
- POSITION gap; /* Gap between prev and next */
+ off_t pos; /* File position */
+ off_t gap; /* Gap between prev and next */
LINENUM line; /* Line number */
};
/*
@@ -62,7 +65,7 @@ struct linenum_info
static struct linenum_info anchor; /* Anchor of the list */
static struct linenum_info *freelist; /* Anchor of the unused entries */
static struct linenum_info pool[NPOOL]; /* The pool itself */
-static struct linenum_info *spare; /* We always keep one spare entry */
+static struct linenum_info *spare; /* We always keep one spare entry */
extern int linenums;
extern volatile sig_atomic_t sigs;
@@ -72,10 +75,10 @@ extern int screen_trashed;
/*
* Initialize the line number structures.
*/
- public void
-clr_linenum()
+void
+clr_linenum(void)
{
- register struct linenum_info *p;
+ struct linenum_info *p;
/*
* Put all the entries on the free list.
@@ -93,16 +96,15 @@ clr_linenum()
*/
anchor.next = anchor.prev = &anchor;
anchor.gap = 0;
- anchor.pos = (POSITION)0;
+ anchor.pos = 0;
anchor.line = 1;
}
/*
* Calculate the gap for an entry.
*/
- static void
-calcgap(p)
- register struct linenum_info *p;
+static void
+calcgap(struct linenum_info *p)
{
/*
* Don't bother to compute a gap for the anchor.
@@ -120,16 +122,14 @@ calcgap(p)
* The specified position (pos) should be the file position of the
* FIRST character in the specified line.
*/
- public void
-add_lnum(linenum, pos)
- LINENUM linenum;
- POSITION pos;
+void
+add_lnum(LINENUM linenum, off_t pos)
{
- register struct linenum_info *p;
- register struct linenum_info *new;
- register struct linenum_info *nextp;
- register struct linenum_info *prevp;
- register POSITION mingap;
+ struct linenum_info *p;
+ struct linenum_info *new;
+ struct linenum_info *nextp;
+ struct linenum_info *prevp;
+ off_t mingap;
/*
* Find the proper place in the list for the new one.
@@ -142,16 +142,14 @@ add_lnum(linenum, pos)
nextp = p;
prevp = p->prev;
- if (freelist != NULL)
- {
+ if (freelist != NULL) {
/*
* We still have free (unused) entries.
* Use one of them.
*/
new = freelist;
freelist = freelist->next;
- } else
- {
+ } else {
/*
* No free entries.
* Use the "spare" entry.
@@ -179,8 +177,7 @@ add_lnum(linenum, pos)
calcgap(nextp);
calcgap(prevp);
- if (spare == NULL)
- {
+ if (spare == NULL) {
/*
* We have used the spare entry.
* Scan the list to find the one with the smallest
@@ -191,10 +188,8 @@ add_lnum(linenum, pos)
* not computed by calcgap.
*/
mingap = anchor.next->gap;
- for (p = anchor.next; p->next != &anchor; p = p->next)
- {
- if (p->gap <= mingap)
- {
+ for (p = anchor.next; p->next != &anchor; p = p->next) {
+ if (p->gap <= mingap) {
spare = p;
mingap = p->gap;
}
@@ -208,45 +203,33 @@ add_lnum(linenum, pos)
* If we get stuck in a long loop trying to figure out the
* line number, print a message to tell the user what we're doing.
*/
- static void
-longloopmessage()
+static void
+longloopmessage(void)
{
ierror("Calculating line numbers", NULL_PARG);
}
static int loopcount;
-#if HAVE_TIME
static long startime;
-#endif
- static void
-longish()
+static void
+longish(void)
{
-#if HAVE_TIME
- if (loopcount >= 0 && ++loopcount > 100)
- {
+ if (loopcount >= 0 && ++loopcount > 100) {
loopcount = 0;
- if (get_time() >= startime + LONGTIME)
- {
+ if (get_time() >= startime + LONGTIME) {
longloopmessage();
loopcount = -1;
}
}
-#else
- if (loopcount >= 0 && ++loopcount > LONGLOOP)
- {
- longloopmessage();
- loopcount = -1;
- }
-#endif
}
/*
* Turn off line numbers because the user has interrupted
* a lengthy line number calculation.
*/
- static void
-abort_long()
+static void
+abort_long(void)
{
if (linenums == OPT_ONPLUS)
/*
@@ -261,20 +244,19 @@ abort_long()
* Find the line number associated with a given position.
* Return 0 if we can't figure it out.
*/
- public LINENUM
-find_linenum(pos)
- POSITION pos;
+LINENUM
+find_linenum(off_t pos)
{
- register struct linenum_info *p;
- register LINENUM linenum;
- POSITION cpos;
+ struct linenum_info *p;
+ LINENUM linenum;
+ off_t cpos;
if (!linenums)
/*
* We're not using line numbers.
*/
return (0);
- if (pos == NULL_POSITION)
+ if (pos == -1)
/*
* Caller doesn't know what he's talking about.
*/
@@ -300,16 +282,13 @@ find_linenum(pos)
* reading the file forward or backward till we
* get to the place we want.
*
- * First decide whether we should go forward from the
+ * First decide whether we should go forward from the
* previous one or backwards from the next one.
- * The decision is based on which way involves
+ * The decision is based on which way involves
* traversing fewer bytes in the file.
*/
-#if HAVE_TIME
startime = get_time();
-#endif
- if (p == &anchor || pos - p->prev->pos < p->pos - pos)
- {
+ if (p == &anchor || pos - p->prev->pos < p->pos - pos) {
/*
* Go forward.
*/
@@ -317,17 +296,16 @@ find_linenum(pos)
if (ch_seek(p->pos))
return (0);
loopcount = 0;
- for (linenum = p->line, cpos = p->pos; cpos < pos; linenum++)
- {
+ for (linenum = p->line, cpos = p->pos; cpos < pos; linenum++) {
/*
* Allow a signal to abort this loop.
*/
- cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
+ cpos = forw_raw_line(cpos, NULL, NULL);
if (ABORT_SIGS()) {
abort_long();
return (0);
}
- if (cpos == NULL_POSITION)
+ if (cpos == -1)
return (0);
longish();
}
@@ -341,25 +319,23 @@ find_linenum(pos)
*/
if (cpos > pos)
linenum--;
- } else
- {
+ } else {
/*
* Go backward.
*/
if (ch_seek(p->pos))
return (0);
loopcount = 0;
- for (linenum = p->line, cpos = p->pos; cpos > pos; linenum--)
- {
+ for (linenum = p->line, cpos = p->pos; cpos > pos; linenum--) {
/*
* Allow a signal to abort this loop.
*/
- cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
+ cpos = back_raw_line(cpos, NULL, NULL);
if (ABORT_SIGS()) {
abort_long();
return (0);
}
- if (cpos == NULL_POSITION)
+ if (cpos == -1)
return (0);
longish();
}
@@ -374,14 +350,13 @@ find_linenum(pos)
/*
* Find the position of a given line number.
- * Return NULL_POSITION if we can't figure it out.
+ * Return -1 if we can't figure it out.
*/
- public POSITION
-find_pos(linenum)
- LINENUM linenum;
+off_t
+find_pos(LINENUM linenum)
{
- register struct linenum_info *p;
- POSITION cpos;
+ struct linenum_info *p;
+ off_t cpos;
LINENUM clinenum;
if (linenum <= 1)
@@ -399,42 +374,42 @@ find_pos(linenum)
/* Found it exactly. */
return (p->pos);
- if (p == &anchor || linenum - p->prev->line < p->line - linenum)
- {
+ if (p == &anchor || linenum - p->prev->line < p->line - linenum) {
/*
* Go forward.
*/
p = p->prev;
if (ch_seek(p->pos))
- return (NULL_POSITION);
- for (clinenum = p->line, cpos = p->pos; clinenum < linenum; clinenum++)
- {
+ return (-1);
+ for (clinenum = p->line, cpos = p->pos;
+ clinenum < linenum;
+ clinenum++) {
/*
* Allow a signal to abort this loop.
*/
- cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
+ cpos = forw_raw_line(cpos, NULL, NULL);
if (ABORT_SIGS())
- return (NULL_POSITION);
- if (cpos == NULL_POSITION)
- return (NULL_POSITION);
+ return (-1);
+ if (cpos == -1)
+ return (-1);
}
- } else
- {
+ } else {
/*
* Go backward.
*/
if (ch_seek(p->pos))
- return (NULL_POSITION);
- for (clinenum = p->line, cpos = p->pos; clinenum > linenum; clinenum--)
- {
+ return (-1);
+ for (clinenum = p->line, cpos = p->pos;
+ clinenum > linenum;
+ clinenum--) {
/*
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS())
- return (NULL_POSITION);
- if (cpos == NULL_POSITION)
- return (NULL_POSITION);
+ return (-1);
+ if (cpos == -1)
+ return (-1);
}
}
/*
@@ -449,19 +424,18 @@ find_pos(linenum)
* The argument "where" tells which line is to be considered
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc).
*/
- public LINENUM
-currline(where)
- int where;
+LINENUM
+currline(int where)
{
- POSITION pos;
- POSITION len;
+ off_t pos;
+ off_t len;
LINENUM linenum;
pos = position(where);
len = ch_length();
- while (pos == NULL_POSITION && where >= 0 && where < sc_height)
+ while (pos == -1 && where >= 0 && where < sc_height)
pos = position(++where);
- if (pos == NULL_POSITION)
+ if (pos == -1)
pos = len;
linenum = find_linenum(pos);
if (pos == len)
diff --git a/usr.bin/less/lsystem.c b/usr.bin/less/lsystem.c
index 7662d2c26a5..4cc9d54f117 100644
--- a/usr.bin/less/lsystem.c
+++ b/usr.bin/less/lsystem.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to execute other programs.
@@ -17,40 +20,22 @@
#include <signal.h>
#include "position.h"
-#if MSDOS_COMPILER
-#include <dos.h>
-#ifdef _MSC_VER
-#include <direct.h>
-#define setdisk(n) _chdrive((n)+1)
-#else
-#include <dir.h>
-#endif
-#endif
-
extern int screen_trashed;
extern IFILE curr_ifile;
-
-#if HAVE_SYSTEM
+static int pipe_data(char *cmd, off_t spos, off_t epos);
/*
* Pass the specified command to a shell to be executed.
* Like plain "system()", but handles resetting terminal modes, etc.
*/
- public void
-lsystem(cmd, donemsg)
- char *cmd;
- char *donemsg;
+void
+lsystem(const char *cmd, const char *donemsg)
{
- register int inp;
-#if HAVE_SHELL
- register char *shell;
- register char *p;
-#endif
+ int inp;
+ char *shell;
+ char *p;
IFILE save_ifile;
-#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
- char cwd[FILENAME_MAX+1];
-#endif
/*
* Print the command which is to be executed,
@@ -58,30 +43,13 @@ lsystem(cmd, donemsg)
*/
if (cmd[0] == '-')
cmd++;
- else
- {
+ else {
clear_bot();
putstr("!");
putstr(cmd);
putstr("\n");
}
-#if MSDOS_COMPILER
-#if MSDOS_COMPILER==WIN32C
- if (*cmd == '\0')
- cmd = getenv("COMSPEC");
-#else
- /*
- * Working directory is global on MSDOS.
- * The child might change the working directory, so we
- * must save and restore CWD across calls to "system",
- * or else we won't find our file when we return and
- * try to "reedit_ifile" it.
- */
- getcwd(cwd, FILENAME_MAX);
-#endif
-#endif
-
/*
* Close the current input file.
*/
@@ -94,31 +62,21 @@ lsystem(cmd, donemsg)
deinit();
flush(); /* Make sure the deinit chars get out */
raw_mode(0);
-#if MSDOS_COMPILER==WIN32C
- close_getchr();
-#endif
/*
* Restore signals to their defaults.
*/
init_signals(0);
-#if HAVE_DUP
/*
* Force standard input to be the user's terminal
- * (the normal standard input), even if less's standard input
+ * (the normal standard input), even if less's standard input
* is coming from a pipe.
*/
inp = dup(0);
- close(0);
-#if OS2
- /* The __open() system call translates "/dev/tty" to "con". */
- if (__open("/dev/tty", OPEN_READ) < 0)
-#else
+ (void) close(0);
if (open("/dev/tty", OPEN_READ) < 0)
-#endif
- dup(inp);
-#endif
+ (void) dup(inp);
/*
* Pass the command to the system to be executed.
@@ -126,117 +84,60 @@ lsystem(cmd, donemsg)
* <$SHELL -c "command"> instead of just <command>.
* If the command is empty, just invoke a shell.
*/
-#if HAVE_SHELL
p = NULL;
- if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0')
- {
- if (*cmd == '\0')
+ if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0') {
+ if (*cmd == '\0') {
p = save(shell);
- else
- {
+ } else {
char *esccmd = shell_quote(cmd);
- if (esccmd != NULL)
- {
- size_t len = strlen(shell) + strlen(esccmd) + 5;
- p = (char *) ecalloc(len, sizeof(char));
- SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd);
+ if (esccmd != NULL) {
+ p = easprintf("%s -c %s", shell, esccmd);
free(esccmd);
}
}
}
- if (p == NULL)
- {
+ if (p == NULL) {
if (*cmd == '\0')
p = save("sh");
else
p = save(cmd);
}
- system(p);
+ (void) system(p);
free(p);
-#else
-#if MSDOS_COMPILER==DJGPPC
- /*
- * Make stdin of the child be in cooked mode.
- */
- setmode(0, O_TEXT);
- /*
- * We don't need to catch signals of the child (it
- * also makes trouble with some DPMI servers).
- */
- __djgpp_exception_toggle();
- system(cmd);
- __djgpp_exception_toggle();
-#else
- system(cmd);
-#endif
-#endif
-#if HAVE_DUP
/*
* Restore standard input, reset signals, raw mode, etc.
*/
- close(0);
- dup(inp);
- close(inp);
-#endif
+ (void) close(0);
+ (void) dup(inp);
+ (void) close(inp);
-#if MSDOS_COMPILER==WIN32C
- open_getchr();
-#endif
init_signals(1);
raw_mode(1);
- if (donemsg != NULL)
- {
+ if (donemsg != NULL) {
putstr(donemsg);
putstr(" (press RETURN)");
get_return();
- putchr('\n');
+ (void) putchr('\n');
flush();
}
init();
screen_trashed = 1;
-#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
- /*
- * Restore the previous directory (possibly
- * changed by the child program we just ran).
- */
- chdir(cwd);
-#if MSDOS_COMPILER != DJGPPC
- /*
- * Some versions of chdir() don't change to the drive
- * which is part of CWD. (DJGPP does this in chdir.)
- */
- if (cwd[1] == ':')
- {
- if (cwd[0] >= 'a' && cwd[0] <= 'z')
- setdisk(cwd[0] - 'a');
- else if (cwd[0] >= 'A' && cwd[0] <= 'Z')
- setdisk(cwd[0] - 'A');
- }
-#endif
-#endif
-
/*
* Reopen the current input file.
*/
reedit_ifile(save_ifile);
-#if defined(SIGWINCH) || defined(SIGWIND)
/*
* Since we were ignoring window change signals while we executed
* the system command, we must assume the window changed.
* Warning: this leaves a signal pending (in "sigs"),
* so psignals() should be called soon after lsystem().
*/
- winch(0);
-#endif
+ sigwinch(0);
}
-#endif
-
-#if PIPEC
-
/*
* Pipe a section of the input file into the given shell command.
* The section to be piped is the section "between" the current
@@ -249,12 +150,10 @@ lsystem(cmd, donemsg)
* If the mark is on the current screen, or if the mark is ".",
* the whole current screen is piped.
*/
- public int
-pipe_mark(c, cmd)
- int c;
- char *cmd;
+int
+pipe_mark(int c, char *cmd)
{
- POSITION mpos, tpos, bpos;
+ off_t mpos, tpos, bpos;
/*
* mpos = the marked position.
@@ -262,36 +161,32 @@ pipe_mark(c, cmd)
* bpos = bottom of screen.
*/
mpos = markpos(c);
- if (mpos == NULL_POSITION)
+ if (mpos == -1)
return (-1);
tpos = position(TOP);
- if (tpos == NULL_POSITION)
+ if (tpos == -1)
tpos = ch_zero();
bpos = position(BOTTOM);
- if (c == '.')
- return (pipe_data(cmd, tpos, bpos));
- else if (mpos <= tpos)
- return (pipe_data(cmd, mpos, bpos));
- else if (bpos == NULL_POSITION)
- return (pipe_data(cmd, tpos, bpos));
- else
- return (pipe_data(cmd, tpos, mpos));
+ if (c == '.')
+ return (pipe_data(cmd, tpos, bpos));
+ else if (mpos <= tpos)
+ return (pipe_data(cmd, mpos, bpos));
+ else if (bpos == -1)
+ return (pipe_data(cmd, tpos, bpos));
+ else
+ return (pipe_data(cmd, tpos, mpos));
}
/*
* Create a pipe to the given shell command.
* Feed it the file contents between the positions spos and epos.
*/
- public int
-pipe_data(cmd, spos, epos)
- char *cmd;
- POSITION spos;
- POSITION epos;
+static int
+pipe_data(char *cmd, off_t spos, off_t epos)
{
- register FILE *f;
- register int c;
- extern FILE *popen();
+ FILE *f;
+ int c;
/*
* This is structured much like lsystem().
@@ -299,14 +194,12 @@ pipe_data(cmd, spos, epos)
* to perform the necessary deinitialization before running
* the command, and reinitialization after it.
*/
- if (ch_seek(spos) != 0)
- {
+ if (ch_seek(spos) != 0) {
error("Cannot seek to start position", NULL_PARG);
return (-1);
}
- if ((f = popen(cmd, "w")) == NULL)
- {
+ if ((f = popen(cmd, "w")) == NULL) {
error("Cannot create pipe", NULL_PARG);
return (-1);
}
@@ -319,16 +212,10 @@ pipe_data(cmd, spos, epos)
flush();
raw_mode(0);
init_signals(0);
-#if MSDOS_COMPILER==WIN32C
- close_getchr();
-#endif
-#ifdef SIGPIPE
LSIGNAL(SIGPIPE, SIG_IGN);
-#endif
c = EOI;
- while (epos == NULL_POSITION || spos++ <= epos)
- {
+ while (epos == -1 || spos++ <= epos) {
/*
* Read a character from the file and give it to the pipe.
*/
@@ -342,32 +229,22 @@ pipe_data(cmd, spos, epos)
/*
* Finish up the last line.
*/
- while (c != '\n' && c != EOI )
- {
- c = ch_forw_get();
- if (c == EOI)
- break;
- if (putc(c, f) == EOF)
- break;
- }
+ while (c != '\n' && c != EOI) {
+ c = ch_forw_get();
+ if (c == EOI)
+ break;
+ if (putc(c, f) == EOF)
+ break;
+ }
- pclose(f);
+ (void) pclose(f);
-#ifdef SIGPIPE
LSIGNAL(SIGPIPE, SIG_DFL);
-#endif
-#if MSDOS_COMPILER==WIN32C
- open_getchr();
-#endif
init_signals(1);
raw_mode(1);
init();
screen_trashed = 1;
-#if defined(SIGWINCH) || defined(SIGWIND)
/* {{ Probably don't need this here. }} */
- winch(0);
-#endif
+ sigwinch(0);
return (0);
}
-
-#endif
diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c
index 0b7940f5e4d..cb678c85266 100644
--- a/usr.bin/less/main.c
+++ b/usr.bin/less/main.c
@@ -6,105 +6,91 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Entry point, initialization, miscellaneous routines.
*/
+#include <libgen.h>
+#include <stdarg.h>
+#include <sys/types.h>
#include "less.h"
-#if MSDOS_COMPILER==WIN32C
-#include <windows.h>
-#endif
-
-public char * every_first_cmd = NULL;
-public int new_file;
-public int is_tty;
-public IFILE curr_ifile = NULL_IFILE;
-public IFILE old_ifile = NULL_IFILE;
-public struct scrpos initial_scrpos;
-public int any_display = FALSE;
-public POSITION start_attnpos = NULL_POSITION;
-public POSITION end_attnpos = NULL_POSITION;
-public int wscroll;
-public char * progname;
-public int quitting;
-public int secure;
-public int dohelp;
-
-#if LOGFILE
-public int logfile = -1;
-public int force_logfile = FALSE;
-public char * namelogfile = NULL;
-#endif
-
-#if EDITOR
-public char * editor;
-public char * editproto;
-#endif
-
-#if TAGS
-extern char * tags;
-extern char * tagoption;
-extern int jump_sline;
-#endif
-
-#ifdef WIN32
-static char consoleTitle[256];
-#endif
+char *every_first_cmd = NULL;
+int new_file;
+int is_tty;
+IFILE curr_ifile = NULL_IFILE;
+IFILE old_ifile = NULL_IFILE;
+struct scrpos initial_scrpos;
+int any_display = FALSE;
+off_t start_attnpos = -1;
+off_t end_attnpos = -1;
+int wscroll;
+
+static char *progname;
+
+int quitting;
+int secure;
+int dohelp;
+
+int logfile = -1;
+int force_logfile = FALSE;
+char *namelogfile = NULL;
+char *editor;
+char *editproto;
+
+extern char *tags;
+extern char *tagoption;
+extern int jump_sline;
extern int less_is_more;
extern int missing_cap;
extern int know_dumb;
+extern int quit_if_one_screen;
+extern int quit_at_eof;
extern int pr_type;
+extern int hilite_search;
+extern int use_lessopen;
+extern int no_init;
+extern int top_scroll;
+extern int errmsgs;
/*
* Entry point.
*/
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
IFILE ifile;
char *s;
-#ifdef __EMX__
- _response(&argc, &argv);
- _wildcard(&argc, &argv);
-#endif
-
- progname = *argv++;
+ progname = basename(argv[0]);
+ argv++;
argc--;
+ /*
+ * If the name of the executable program is "more",
+ * act like LESS_IS_MORE is set. We have to set this as early
+ * as possible for POSIX.
+ */
+ if ((strcmp(progname, "more") == 0) ||
+ (strcmp(progname, "page") == 0)) {
+ less_is_more = 1;
+ } else {
+ s = lgetenv("LESS_IS_MORE");
+ if (s != NULL && *s != '\0')
+ less_is_more = 1;
+ }
+
secure = 0;
s = lgetenv("LESSSECURE");
if (s != NULL && *s != '\0')
secure = 1;
-#ifdef WIN32
- if (getenv("HOME") == NULL)
- {
- /*
- * If there is no HOME environment variable,
- * try the concatenation of HOMEDRIVE + HOMEPATH.
- */
- char *drive = getenv("HOMEDRIVE");
- char *path = getenv("HOMEPATH");
- if (drive != NULL && path != NULL)
- {
- size_t len = strlen(drive) + strlen(path) + 6;
- char *env = (char *) ecalloc(len, sizeof(char));
- strlcpy(env, "HOME=", len);
- strlcat(env, drive, len);
- strlcat(env, path, len);
- putenv(env);
- }
- }
- GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char));
-#endif /* WIN32 */
-
/*
* Process command line arguments and LESS environment arguments.
* Command line arguments override environment arguments.
@@ -118,34 +104,38 @@ main(argc, argv)
init_option();
init_search();
- /*
- * If the name of the executable program is "more",
- * act like LESS_IS_MORE is set.
- */
- for (s = progname + strlen(progname); s > progname; s--)
- {
- if (s[-1] == PATHNAME_SEP[0])
- break;
- }
- if (strcmp(s, "more") == 0)
- less_is_more = 1;
init_prompt();
- if (less_is_more) {
- scan_option("-G");
- scan_option("-L");
- scan_option("-X");
- scan_option("-c");
- }
-
s = lgetenv(less_is_more ? "MORE" : "LESS");
if (s != NULL)
scan_option(save(s));
+ if (less_is_more) {
+ /* this is specified by XPG */
+ quit_at_eof = OPT_ON;
+
+ /* more users don't like the warning */
+ know_dumb = OPT_ON;
+
+ /* default prompt is medium */
+ pr_type = OPT_ON;
+
+ /* do not hilight search terms */
+ hilite_search = OPT_OFF;
+
+ /* do not use LESSOPEN */
+ use_lessopen = OPT_OFF;
+
+ /* do not set init strings to terminal */
+ no_init = OPT_ON;
+
+ /* repaint from top of screen */
+ top_scroll = OPT_OFF;
+ }
+
#define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0')
- while (argc > 0 && (isoptstring(*argv) || isoptpending()))
- {
+ while (argc > 0 && (isoptstring(*argv) || isoptpending())) {
s = *argv++;
argc--;
if (strcmp(s, "--") == 0)
@@ -154,8 +144,7 @@ main(argc, argv)
}
#undef isoptstring
- if (isoptpending())
- {
+ if (isoptpending()) {
/*
* Last command line option was a flag requiring a
* following string, but there was no following string.
@@ -164,10 +153,20 @@ main(argc, argv)
quit(QUIT_OK);
}
-#if EDITOR
+ if (errmsgs) {
+ quit(QUIT_ERROR);
+ }
+ if (less_is_more && quit_at_eof == OPT_ONPLUS) {
+ extern int no_init;
+ no_init = OPT_ON;
+ }
+ if (less_is_more && pr_type == OPT_ONPLUS) {
+ extern int quiet;
+ quiet = VERY_QUIET;
+ }
+
editor = lgetenv("VISUAL");
- if (editor == NULL || *editor == '\0')
- {
+ if (editor == NULL || *editor == '\0') {
editor = lgetenv("EDITOR");
if (editor == NULL || *editor == '\0')
editor = EDIT_PGM;
@@ -175,40 +174,16 @@ main(argc, argv)
editproto = lgetenv("LESSEDIT");
if (editproto == NULL || *editproto == '\0')
editproto = "%E ?lm+%lm. %f";
-#endif
/*
* Call get_ifile with all the command line filenames
* to "register" them with the ifile system.
*/
ifile = NULL_IFILE;
-#if !SMALL
if (dohelp)
ifile = get_ifile(helpfile(), ifile);
-#endif /* !SMALL */
- while (argc-- > 0)
- {
+ while (argc-- > 0) {
char *filename;
-#if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC)
- /*
- * Because the "shell" doesn't expand filename patterns,
- * treat each argument as a filename pattern rather than
- * a single filename.
- * Expand the pattern and iterate over the expanded list.
- */
- struct textlist tlist;
- char *gfilename;
-
- gfilename = lglob(*argv++);
- init_textlist(&tlist, gfilename);
- filename = NULL;
- while ((filename = forw_textlist(&tlist, filename)) != NULL)
- {
- (void) get_ifile(filename, ifile);
- ifile = prev_ifile(NULL_IFILE);
- }
- free(gfilename);
-#else
filename = shell_quote(*argv);
if (filename == NULL)
filename = *argv;
@@ -216,24 +191,19 @@ main(argc, argv)
(void) get_ifile(filename, ifile);
ifile = prev_ifile(NULL_IFILE);
free(filename);
-#endif
}
/*
* Set up terminal, etc.
*/
- if (!is_tty)
- {
+ if (!is_tty) {
/*
* Output is not a tty.
* Just copy the input file(s) to output.
*/
- SET_BINARY(1);
- if (nifile() == 0)
- {
+ if (nifile() == 0) {
if (edit_stdin() == 0)
cat_file();
- } else if (edit_first() == 0)
- {
+ } else if (edit_first() == 0) {
do {
cat_file();
} while (edit_next(1) == 0);
@@ -241,7 +211,7 @@ main(argc, argv)
quit(QUIT_OK);
}
- if (missing_cap && !know_dumb && !less_is_more)
+ if (missing_cap && !know_dumb)
error("WARNING: terminal is not fully functional", NULL_PARG);
init_mark();
open_getchr();
@@ -251,17 +221,14 @@ main(argc, argv)
/*
* Select the first file to examine.
*/
-#if TAGS
- if (tagoption != NULL || strcmp(tags, "-") == 0)
- {
+ if (tagoption != NULL || strcmp(tags, "-") == 0) {
/*
* A -t option was given.
* Verify that no filenames were also given.
* Edit the file selected by the "tags" search,
* and search for the proper line in the file.
*/
- if (nifile() > 0)
- {
+ if (nifile() > 0) {
error("No filenames allowed with -t option", NULL_PARG);
quit(QUIT_ERROR);
}
@@ -273,17 +240,13 @@ main(argc, argv)
* Set up initial_scrpos so we display that line.
*/
initial_scrpos.pos = tagsearch();
- if (initial_scrpos.pos == NULL_POSITION)
+ if (initial_scrpos.pos == -1)
quit(QUIT_ERROR);
initial_scrpos.ln = jump_sline;
- } else
-#endif
- if (nifile() == 0)
- {
+ } else if (nifile() == 0) {
if (edit_stdin()) /* Edit standard input */
quit(QUIT_ERROR);
- } else
- {
+ } else {
if (edit_first()) /* Edit first valid file in cmd line */
quit(QUIT_ERROR);
}
@@ -299,15 +262,13 @@ main(argc, argv)
* Copy a string to a "safe" place
* (that is, to a buffer allocated by calloc).
*/
- public char *
-save(s)
- char *s;
+char *
+save(const char *s)
{
- register char *p;
- size_t len = strlen(s) + 1;
+ char *p;
- p = (char *) ecalloc(len, sizeof(char));
- strlcpy(p, s, len);
+ if ((p = estrdup(s)) == NULL)
+ quit(QUIT_ERROR);
return (p);
}
@@ -315,14 +276,12 @@ save(s)
* Allocate memory.
* Like calloc(), but never returns an error (NULL).
*/
- public VOID_POINTER
-ecalloc(count, size)
- int count;
- unsigned int size;
+void *
+ecalloc(int count, unsigned int size)
{
- register VOID_POINTER p;
+ void *p;
- p = (VOID_POINTER) calloc(count, size);
+ p = calloc(count, size);
if (p != NULL)
return (p);
error("Cannot allocate memory", NULL_PARG);
@@ -331,61 +290,81 @@ ecalloc(count, size)
return (NULL);
}
+char *
+easprintf(const char *fmt, ...)
+{
+ char *p = NULL;
+ int rv;
+ va_list ap;
+
+ va_start(ap, fmt);
+ rv = vasprintf(&p, fmt, ap);
+ va_end(ap);
+
+ if (p == NULL || rv < 0) {
+ error("Cannot allocate memory", NULL_PARG);
+ quit(QUIT_ERROR);
+ /*NOTREACHED*/
+ }
+ return (p);
+}
+
+char *
+estrdup(const char *str)
+{
+ char *n = strdup(str);
+ if (n == NULL && str != NULL) {
+ error("Cannot allocate memory", NULL_PARG);
+ }
+ return (n);
+}
+
/*
* Skip leading spaces in a string.
*/
- public char *
-skipsp(s)
- register char *s;
+char *
+skipsp(char *s)
{
- while (*s == ' ' || *s == '\t')
+ while (*s == ' ' || *s == '\t')
s++;
return (s);
}
-#if GNU_OPTIONS
/*
* See how many characters of two strings are identical.
* If uppercase is true, the first string must begin with an uppercase
* character; the remainder of the first string may be either case.
*/
- public int
-sprefix(ps, s, uppercase)
- char *ps;
- char *s;
- int uppercase;
+int
+sprefix(char *ps, char *s, int uppercase)
{
- register int c;
- register int sc;
- register int len = 0;
+ int c;
+ int sc;
+ int len = 0;
- for ( ; *s != '\0'; s++, ps++)
- {
+ for (; *s != '\0'; s++, ps++) {
c = *ps;
- if (uppercase)
- {
- if (len == 0 && ASCII_IS_LOWER(c))
+ if (uppercase) {
+ if (len == 0 && isupper(c))
return (-1);
- if (ASCII_IS_UPPER(c))
- c = ASCII_TO_LOWER(c);
+ if (isupper(c))
+ c = tolower(c);
}
sc = *s;
- if (len > 0 && ASCII_IS_UPPER(sc))
- sc = ASCII_TO_LOWER(sc);
+ if (len > 0 && isupper(sc))
+ sc = tolower(sc);
if (c != sc)
break;
len++;
}
return (len);
}
-#endif /* GNU_OPTIONS */
/*
* Exit the program.
*/
- public void
-quit(status)
- int status;
+void
+quit(int status)
{
static int save_status;
@@ -398,33 +377,19 @@ quit(status)
else
save_status = status;
quitting = 1;
- edit((char*)NULL);
+ edit(NULL);
save_cmdhist();
if (any_display && is_tty)
clear_bot();
deinit();
flush();
raw_mode(0);
-#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
- /*
- * If we don't close 2, we get some garbage from
- * 2's buffer when it flushes automatically.
- * I cannot track this one down RB
- * The same bug shows up if we use ^C^C to abort.
- */
- close(2);
-#endif
-#ifdef WIN32
- SetConsoleTitle(consoleTitle);
-#endif
close_getchr();
exit(status);
}
-#if !SMALL
- public char *
+char *
helpfile(void)
{
return (less_is_more ? HELPDIR "/more.help" : HELPDIR "/less.help");
}
-#endif /* !SMALL */
diff --git a/usr.bin/less/mark.c b/usr.bin/less/mark.c
index ab87a619f75..09413859dda 100644
--- a/usr.bin/less/mark.c
+++ b/usr.bin/less/mark.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
#include "less.h"
@@ -34,21 +37,20 @@ static struct mark marks[NMARKS];
/*
* Initialize the mark table to show no marks are set.
*/
- public void
-init_mark()
+void
+init_mark(void)
{
int i;
for (i = 0; i < NMARKS; i++)
- marks[i].m_scrpos.pos = NULL_POSITION;
+ marks[i].m_scrpos.pos = -1;
}
/*
* See if a mark letter is valid (between a and z).
*/
- static struct mark *
-getumark(c)
- int c;
+static struct mark *
+getumark(int c)
{
if (c >= 'a' && c <= 'z')
return (&marks[c-'a']);
@@ -65,15 +67,13 @@ getumark(c)
* The mark struct may come either from the mark table
* or may be constructed on the fly for certain characters like ^, $.
*/
- static struct mark *
-getmark(c)
- int c;
+static struct mark *
+getmark(int c)
{
register struct mark *m;
static struct mark sm;
- switch (c)
- {
+ switch (c) {
case '^':
/*
* Beginning of the current file.
@@ -87,8 +87,7 @@ getmark(c)
/*
* End of the current file.
*/
- if (ch_end_seek())
- {
+ if (ch_end_seek()) {
error("Cannot seek to end of file", NULL_PARG);
return (NULL);
}
@@ -118,8 +117,7 @@ getmark(c)
m = getumark(c);
if (m == NULL)
break;
- if (m->m_scrpos.pos == NULL_POSITION)
- {
+ if (m->m_scrpos.pos == -1) {
error("Mark not set", NULL_PARG);
return (NULL);
}
@@ -128,24 +126,20 @@ getmark(c)
return (m);
}
-#if PIPEC
/*
* Is a mark letter is invalid?
*/
- public int
-badmark(c)
- int c;
+int
+badmark(int c)
{
return (getmark(c) == NULL);
}
-#endif /* PIPEC */
/*
* Set a user-defined mark.
*/
- public void
-setmark(c)
- int c;
+void
+setmark(int c)
{
register struct mark *m;
struct scrpos scrpos;
@@ -161,15 +155,15 @@ setmark(c)
/*
* Set lmark (the mark named by the apostrophe).
*/
- public void
-lastmark()
+void
+lastmark(void)
{
struct scrpos scrpos;
if (ch_getflags() & CH_HELPFILE)
return;
get_scrpos(&scrpos);
- if (scrpos.pos == NULL_POSITION)
+ if (scrpos.pos == -1)
return;
marks[LASTMARK].m_scrpos = scrpos;
marks[LASTMARK].m_ifile = curr_ifile;
@@ -178,11 +172,10 @@ lastmark()
/*
* Go to a mark.
*/
- public void
-gomark(c)
- int c;
+void
+gomark(int c)
{
- register struct mark *m;
+ struct mark *m;
struct scrpos scrpos;
m = getmark(c);
@@ -190,12 +183,11 @@ gomark(c)
return;
/*
- * If we're trying to go to the lastmark and
+ * If we're trying to go to the lastmark and
* it has not been set to anything yet,
* set it to the beginning of the current file.
*/
- if (m == &marks[LASTMARK] && m->m_scrpos.pos == NULL_POSITION)
- {
+ if (m == &marks[LASTMARK] && m->m_scrpos.pos == -1) {
m->m_ifile = curr_ifile;
m->m_scrpos.pos = ch_zero();
m->m_scrpos.ln = jump_sline;
@@ -207,8 +199,7 @@ gomark(c)
* (We save the screen position even if we're not using lmark.)
*/
scrpos = m->m_scrpos;
- if (m->m_ifile != curr_ifile)
- {
+ if (m->m_ifile != curr_ifile) {
/*
* Not in the current file; edit the correct file.
*/
@@ -219,43 +210,38 @@ gomark(c)
jump_loc(scrpos.pos, scrpos.ln);
}
-#if PIPEC
/*
* Return the position associated with a given mark letter.
*
- * We don't return which screen line the position
+ * We don't return which screen line the position
* is associated with, but this doesn't matter much,
* because it's always the first non-blank line on the screen.
*/
- public POSITION
-markpos(c)
- int c;
+off_t
+markpos(int c)
{
- register struct mark *m;
+ struct mark *m;
m = getmark(c);
if (m == NULL)
- return (NULL_POSITION);
+ return (-1);
- if (m->m_ifile != curr_ifile)
- {
+ if (m->m_ifile != curr_ifile) {
error("Mark not in current file", NULL_PARG);
- return (NULL_POSITION);
+ return (-1);
}
return (m->m_scrpos.pos);
}
-#endif /* PIPEC */
/*
* Clear the marks associated with a specified ifile.
*/
- public void
-unmark(ifile)
- IFILE ifile;
+void
+unmark(IFILE ifile)
{
int i;
for (i = 0; i < NMARKS; i++)
if (marks[i].m_ifile == ifile)
- marks[i].m_scrpos.pos = NULL_POSITION;
+ marks[i].m_scrpos.pos = -1;
}
diff --git a/usr.bin/less/mkfuncs.awk b/usr.bin/less/mkfuncs.awk
deleted file mode 100644
index dea28acebf5..00000000000
--- a/usr.bin/less/mkfuncs.awk
+++ /dev/null
@@ -1,9 +0,0 @@
-BEGIN { FS="("; state = 0 }
-
-/^ public/ { ftype = $0; state = 1 }
-
-{ if (state == 1)
- state = 2
- else if (state == 2)
- { print ftype,$1,"();"; state = 0 }
-}
diff --git a/usr.bin/less/mkinstalldirs b/usr.bin/less/mkinstalldirs
deleted file mode 100644
index 91f6d04e17c..00000000000
--- a/usr.bin/less/mkinstalldirs
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Last modified: 1994-03-25
-# Public domain
-
-errstatus=0
-
-for file in ${1+"$@"} ; do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
-
- pathcomp=
- for d in ${1+"$@"} ; do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
- mkdir "$pathcomp" || errstatus=$?
- fi
-
- pathcomp="$pathcomp/"
- done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
diff --git a/usr.bin/less/optfunc.c b/usr.bin/less/optfunc.c
index d782a055a05..43b090655d0 100644
--- a/usr.bin/less/optfunc.c
+++ b/usr.bin/less/optfunc.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Handling functions for command line options.
@@ -27,7 +30,6 @@
#include "less.h"
#include "option.h"
-extern int nbufs;
extern int bufspace;
extern int pr_type;
extern int plusoption;
@@ -47,57 +49,38 @@ extern IFILE curr_ifile;
extern char version[];
extern int jump_sline;
extern int jump_sline_fraction;
-extern int shift_count;
-extern int shift_count_fraction;
extern int less_is_more;
-#if LOGFILE
extern char *namelogfile;
extern int force_logfile;
extern int logfile;
-#endif
-#if TAGS
-public char *tagoption = NULL;
+char *tagoption = NULL;
extern char *tags;
-#endif
-#if MSDOS_COMPILER
-extern int nm_fg_color, nm_bg_color;
-extern int bo_fg_color, bo_bg_color;
-extern int ul_fg_color, ul_bg_color;
-extern int so_fg_color, so_bg_color;
-extern int bl_fg_color, bl_bg_color;
-#endif
-extern char *every_first_cmd;
-
-
-#if LOGFILE
+
+int shift_count; /* Number of positions to shift horizontally */
+static int shift_count_fraction = -1;
+
/*
* Handler for -o option.
*/
- public void
-opt_o(type, s)
- int type;
- char *s;
+void
+opt_o(int type, char *s)
{
PARG parg;
- if (secure)
- {
+ if (secure) {
error("log file support is not available", NULL_PARG);
return;
}
- switch (type)
- {
+ switch (type) {
case INIT:
namelogfile = s;
break;
case TOGGLE:
- if (ch_getflags() & CH_CANSEEK)
- {
+ if (ch_getflags() & CH_CANSEEK) {
error("Input is not a pipe", NULL_PARG);
return;
}
- if (logfile >= 0)
- {
+ if (logfile >= 0) {
error("Log file is already in use", NULL_PARG);
return;
}
@@ -107,10 +90,9 @@ opt_o(type, s)
sync_logfile();
break;
case QUERY:
- if (logfile < 0)
+ if (logfile < 0) {
error("No log file", NULL_PARG);
- else
- {
+ } else {
parg.p_string = namelogfile;
error("Log file \"%s\"", &parg);
}
@@ -121,62 +103,51 @@ opt_o(type, s)
/*
* Handler for -O option.
*/
- public void
-opt__O(type, s)
- int type;
- char *s;
+void
+opt__O(int type, char *s)
{
force_logfile = TRUE;
opt_o(type, s);
}
-#endif
/*
* Handlers for -j option.
*/
- public void
-opt_j(type, s)
- int type;
- char *s;
+void
+opt_j(int type, char *s)
{
PARG parg;
char buf[16];
int len;
int err;
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
- if (*s == '.')
- {
+ if (*s == '.') {
s++;
jump_sline_fraction = getfraction(&s, "j", &err);
if (err)
error("Invalid line fraction", NULL_PARG);
else
calc_jump_sline();
- } else
- {
+ } else {
int sline = getnum(&s, "j", &err);
- if (err)
+ if (err) {
error("Invalid line number", NULL_PARG);
- else
- {
+ } else {
jump_sline = sline;
jump_sline_fraction = -1;
}
}
break;
case QUERY:
- if (jump_sline_fraction < 0)
- {
+ if (jump_sline_fraction < 0) {
parg.p_int = jump_sline;
error("Position target at screen line %d", &parg);
- } else
- {
-
- snprintf(buf, sizeof(buf), ".%06d", jump_sline_fraction);
+ } else {
+ (void) snprintf(buf, sizeof (buf), ".%06d",
+ jump_sline_fraction);
len = strlen(buf);
while (len > 2 && buf[len-1] == '0')
len--;
@@ -188,8 +159,8 @@ opt_j(type, s)
}
}
- public void
-calc_jump_sline()
+void
+calc_jump_sline(void)
{
if (jump_sline_fraction < 0)
return;
@@ -199,49 +170,42 @@ calc_jump_sline()
/*
* Handlers for -# option.
*/
- public void
-opt_shift(type, s)
- int type;
- char *s;
+void
+opt_shift(int type, char *s)
{
PARG parg;
char buf[16];
int len;
int err;
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
- if (*s == '.')
- {
+ if (*s == '.') {
s++;
shift_count_fraction = getfraction(&s, "#", &err);
if (err)
error("Invalid column fraction", NULL_PARG);
else
calc_shift_count();
- } else
- {
+ } else {
int hs = getnum(&s, "#", &err);
- if (err)
+ if (err) {
error("Invalid column number", NULL_PARG);
- else
- {
+ } else {
shift_count = hs;
shift_count_fraction = -1;
}
}
break;
case QUERY:
- if (shift_count_fraction < 0)
- {
+ if (shift_count_fraction < 0) {
parg.p_int = shift_count;
error("Horizontal shift %d columns", &parg);
- } else
- {
+ } else {
- snprintf(buf, sizeof(buf), ".%06d", shift_count_fraction);
+ (void) snprintf(buf, sizeof (buf), ".%06d",
+ shift_count_fraction);
len = strlen(buf);
while (len > 2 && buf[len-1] == '0')
len--;
@@ -252,56 +216,46 @@ opt_shift(type, s)
break;
}
}
- public void
-calc_shift_count()
+
+void
+calc_shift_count(void)
{
if (shift_count_fraction < 0)
return;
shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM;
}
-#if USERFILE
- public void
-opt_k(type, s)
- int type;
- char *s;
+void
+opt_k(int type, char *s)
{
PARG parg;
- switch (type)
- {
+ switch (type) {
case INIT:
- if (lesskey(s, 0))
- {
+ if (lesskey(s, 0)) {
parg.p_string = s;
error("Cannot use lesskey file \"%s\"", &parg);
}
break;
}
}
-#endif
-#if TAGS
/*
* Handler for -t option.
*/
- public void
-opt_t(type, s)
- int type;
- char *s;
+void
+opt_t(int type, char *s)
{
IFILE save_ifile;
- POSITION pos;
+ off_t pos;
- switch (type)
- {
+ switch (type) {
case INIT:
tagoption = s;
/* Do the rest in main() */
break;
case TOGGLE:
- if (secure)
- {
+ if (secure) {
error("tags support is not available", NULL_PARG);
break;
}
@@ -311,8 +265,7 @@ opt_t(type, s)
* Try to open the file containing the tag
* and search for the tag in that file.
*/
- if (edit_tagfile() || (pos = tagsearch()) == NULL_POSITION)
- {
+ if (edit_tagfile() || (pos = tagsearch()) == -1) {
/* Failed: reopen the old file. */
reedit_ifile(save_ifile);
break;
@@ -326,15 +279,12 @@ opt_t(type, s)
/*
* Handler for -T option.
*/
- public void
-opt__T(type, s)
- int type;
- char *s;
+void
+opt__T(int type, char *s)
{
PARG parg;
- switch (type)
- {
+ switch (type) {
case INIT:
tags = s;
break;
@@ -348,35 +298,28 @@ opt__T(type, s)
break;
}
}
-#endif
/*
* Handler for -p option.
*/
- public void
-opt_p(type, s)
- int type;
- register char *s;
+void
+opt_p(int type, char *s)
{
- switch (type)
- {
+ switch (type) {
case INIT:
/*
* Unget a search command for the specified string.
* {{ This won't work if the "/" command is
* changed or invalidated by a .lesskey file. }}
*/
- if (less_is_more) {
- /*
- * In "more" mode, the -p argument is a command,
- * not a search string, run for each file.
- */
- every_first_cmd = save(s);
- } else {
- plusoption = TRUE;
- ungetsc(s);
+ plusoption = TRUE;
+ ungetsc(s);
+ /*
+ * In "more" mode, the -p argument is a command,
+ * not a search string, so we don't need a slash.
+ */
+ if (!less_is_more)
ungetsc("/");
- }
break;
}
}
@@ -384,23 +327,19 @@ opt_p(type, s)
/*
* Handler for -P option.
*/
- public void
-opt__P(type, s)
- int type;
- register char *s;
+void
+opt__P(int type, char *s)
{
- register char **proto;
+ char **proto;
PARG parg;
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
/*
* Figure out which prototype string should be changed.
*/
- switch (*s)
- {
+ switch (*s) {
case 's': proto = &prproto[PR_SHORT]; s++; break;
case 'm': proto = &prproto[PR_MEDIUM]; s++; break;
case 'M': proto = &prproto[PR_LONG]; s++; break;
@@ -422,14 +361,11 @@ opt__P(type, s)
/*
* Handler for the -b option.
*/
- /*ARGSUSED*/
- public void
-opt_b(type, s)
- int type;
- char *s;
+/*ARGSUSED*/
+void
+opt_b(int type, char *s)
{
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
/*
@@ -445,14 +381,11 @@ opt_b(type, s)
/*
* Handler for the -i option.
*/
- /*ARGSUSED*/
- public void
-opt_i(type, s)
- int type;
- char *s;
+/*ARGSUSED*/
+void
+opt_i(int type, char *s)
{
- switch (type)
- {
+ switch (type) {
case TOGGLE:
chg_caseless();
break;
@@ -465,14 +398,11 @@ opt_i(type, s)
/*
* Handler for the -V option.
*/
- /*ARGSUSED*/
- public void
-opt__V(type, s)
- int type;
- char *s;
+/*ARGSUSED*/
+void
+opt__V(int type, char *s)
{
- switch (type)
- {
+ switch (type) {
case TOGGLE:
case QUERY:
dispversion();
@@ -485,128 +415,27 @@ opt__V(type, s)
putstr("less ");
putstr(version);
putstr(" (");
-#if HAVE_GNU_REGEX
- putstr("GNU ");
-#endif
-#if HAVE_POSIX_REGCOMP
putstr("POSIX ");
-#endif
-#if HAVE_PCRE
- putstr("PCRE ");
-#endif
-#if HAVE_RE_COMP
- putstr("BSD ");
-#endif
-#if HAVE_REGCMP
- putstr("V8 ");
-#endif
-#if HAVE_V8_REGCOMP
- putstr("Spencer V8 ");
-#endif
-#if !HAVE_GNU_REGEX && !HAVE_POSIX_REGCOMP && !HAVE_PCRE && !HAVE_RE_COMP && !HAVE_REGCMP && !HAVE_V8_REGCOMP
- putstr("no ");
-#endif
putstr("regular expressions)\n");
putstr("Copyright (C) 1984-2012 Mark Nudelman\n\n");
- putstr("less comes with NO WARRANTY, to the extent permitted by law.\n");
+ putstr("less comes with NO WARRANTY, ");
+ putstr("to the extent permitted by law.\n");
putstr("For information about the terms of redistribution,\n");
putstr("see the file named README in the less distribution.\n");
putstr("Homepage: http://www.greenwoodsoftware.com/less\n");
+ putstr("\n");
+ putstr("Modified for use with illumos.\n");
+ putstr("Copyright 2014 Garrett D'Amore\n");
quit(QUIT_OK);
break;
}
}
-#if MSDOS_COMPILER
-/*
- * Parse an MSDOS color descriptor.
- */
- static void
-colordesc(s, fg_color, bg_color)
- char *s;
- int *fg_color;
- int *bg_color;
-{
- int fg, bg;
- int err;
-
- fg = getnum(&s, "D", &err);
- if (err)
- {
- error("Missing fg color in -D", NULL_PARG);
- return;
- }
- if (*s != '.')
- bg = nm_bg_color;
- else
- {
- s++;
- bg = getnum(&s, "D", &err);
- if (err)
- {
- error("Missing bg color in -D", NULL_PARG);
- return;
- }
- }
- if (*s != '\0')
- error("Extra characters at end of -D option", NULL_PARG);
- *fg_color = fg;
- *bg_color = bg;
-}
-
-/*
- * Handler for the -D option.
- */
- /*ARGSUSED*/
- public void
-opt_D(type, s)
- int type;
- char *s;
-{
- switch (type)
- {
- case INIT:
- case TOGGLE:
- switch (*s++)
- {
- case 'n':
- colordesc(s, &nm_fg_color, &nm_bg_color);
- break;
- case 'd':
- colordesc(s, &bo_fg_color, &bo_bg_color);
- break;
- case 'u':
- colordesc(s, &ul_fg_color, &ul_bg_color);
- break;
- case 'k':
- colordesc(s, &bl_fg_color, &bl_bg_color);
- break;
- case 's':
- colordesc(s, &so_fg_color, &so_bg_color);
- break;
- default:
- error("-D must be followed by n, d, u, k or s", NULL_PARG);
- break;
- }
- if (type == TOGGLE)
- {
- at_enter(AT_STANDOUT);
- at_exit();
- }
- break;
- case QUERY:
- break;
- }
-}
-#endif
-
/*
* Handler for the -x option.
*/
- public void
-opt_x(type, s)
- int type;
- register char *s;
+void
+opt_x(int type, char *s)
{
extern int tabstops[];
extern int ntabstops;
@@ -615,13 +444,11 @@ opt_x(type, s)
int i;
PARG p;
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
/* Start at 1 because tabstops[0] is always zero. */
- for (i = 1; i < TABSTOP_MAX; )
- {
+ for (i = 1; i < TABSTOP_MAX; ) {
int n = 0;
s = skipsp(s);
while (*s >= '0' && *s <= '9')
@@ -638,20 +465,18 @@ opt_x(type, s)
tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2];
break;
case QUERY:
- strlcpy(msg, "Tab stops ", sizeof(msg));
- if (ntabstops > 2)
- {
- for (i = 1; i < ntabstops; i++)
- {
+ (void) strlcpy(msg, "Tab stops ", sizeof(msg));
+ if (ntabstops > 2) {
+ for (i = 1; i < ntabstops; i++) {
if (i > 1)
strlcat(msg, ",", sizeof(msg));
- snprintf(msg+strlen(msg),
+ (void) snprintf(msg+strlen(msg),
sizeof(msg)-strlen(msg), "%d", tabstops[i]);
}
- snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg),
+ (void) snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg),
" and then ");
}
- snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg),
+ (void) snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg),
"every %d spaces", tabdefault);
p.p_string = msg;
error("%s", &p);
@@ -663,26 +488,22 @@ opt_x(type, s)
/*
* Handler for the -" option.
*/
- public void
-opt_quote(type, s)
- int type;
- register char *s;
+void
+opt_quote(int type, char *s)
{
char buf[3];
PARG parg;
- switch (type)
- {
+ switch (type) {
case INIT:
case TOGGLE:
- if (s[0] == '\0')
- {
+ if (s[0] == '\0') {
openquote = closequote = '\0';
break;
}
- if (s[1] != '\0' && s[2] != '\0')
- {
- error("-\" must be followed by 1 or 2 chars", NULL_PARG);
+ if (s[1] != '\0' && s[2] != '\0') {
+ error("-\" must be followed by 1 or 2 chars",
+ NULL_PARG);
return;
}
openquote = s[0];
@@ -705,14 +526,11 @@ opt_quote(type, s)
* "-?" means display a help message.
* If from the command line, exit immediately.
*/
- /*ARGSUSED*/
- public void
-opt_query(type, s)
- int type;
- char *s;
+/*ARGSUSED*/
+void
+opt_query(int type, char *s)
{
- switch (type)
- {
+ switch (type) {
case QUERY:
case TOGGLE:
error("Use \"h\" for help", NULL_PARG);
@@ -725,11 +543,10 @@ opt_query(type, s)
/*
* Get the "screen window" size.
*/
- public int
-get_swindow()
+int
+get_swindow(void)
{
if (swindow > 0)
return (swindow);
return (sc_height + swindow);
}
-
diff --git a/usr.bin/less/option.c b/usr.bin/less/option.c
index 33ab6f276bd..4afb2af8e4a 100644
--- a/usr.bin/less/option.c
+++ b/usr.bin/less/option.c
@@ -6,14 +6,17 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Process command line options.
*
* Each option is a single letter which controls a program variable.
* The options have defaults which may be changed via
- * the command line option, toggled via the "-" command,
+ * the command line option, toggled via the "-" command,
* or queried via the "_" command.
*/
@@ -21,7 +24,7 @@
#include "option.h"
static struct loption *pendopt;
-public int plusoption = FALSE;
+int plusoption = FALSE;
static char *optstring();
static int flip_triple();
@@ -35,15 +38,15 @@ extern int opt_use_backslash;
/*
* Return a printable description of an option.
*/
- static char *
-opt_desc(o)
- struct loption *o;
+static char *
+opt_desc(struct loption *o)
{
static char buf[OPTNAME_MAX + 10];
if (o->oletter == OLETTER_NONE)
- SNPRINTF1(buf, sizeof(buf), "--%s", o->onames->oname);
+ (void) snprintf(buf, sizeof (buf), "--%s", o->onames->oname);
else
- SNPRINTF2(buf, sizeof(buf), "-%c (--%s)", o->oletter, o->onames->oname);
+ (void) snprintf(buf, sizeof (buf), "-%c (--%s)",
+ o->oletter, o->onames->oname);
return (buf);
}
@@ -51,32 +54,31 @@ opt_desc(o)
* Return a string suitable for printing as the "name" of an option.
* For example, if the option letter is 'x', just return "-x".
*/
- public char *
-propt(c)
- int c;
+char *
+propt(int c)
{
static char buf[8];
- snprintf(buf, sizeof(buf), "-%s", prchar(c));
+ (void) snprintf(buf, sizeof (buf), "-%s", prchar(c));
return (buf);
}
-/*
- * Scan an argument (either from the command line or from the
+/*
+ * Scan an argument (either from the command line or from the
* LESS environment variable) and process it.
*/
- public void
-scan_option(s)
- char *s;
+void
+scan_option(char *s)
{
- register struct loption *o;
- register int optc;
+ struct loption *o;
+ int optc;
char *optname;
char *printopt;
char *str;
int set_default;
int lc;
int err;
+ int moreopt;
PARG parg;
if (s == NULL)
@@ -89,16 +91,14 @@ scan_option(s)
* without a following string. In that case, the current
* option is simply the argument for the previous option.
*/
- if (pendopt != NULL)
- {
- switch (pendopt->otype & OTYPE)
- {
+ if (pendopt != NULL) {
+ switch (pendopt->otype & OTYPE) {
case STRING:
(*pendopt->ofunc)(INIT, s);
break;
case NUMBER:
printopt = opt_desc(pendopt);
- *(pendopt->ovar) = getnum(&s, printopt, (int*)NULL);
+ *(pendopt->ovar) = getnum(&s, printopt, NULL);
break;
}
pendopt = NULL;
@@ -107,42 +107,43 @@ scan_option(s)
set_default = FALSE;
optname = NULL;
+ moreopt = 0;
+ o = NULL;
- while (*s != '\0')
- {
+ while (*s != '\0') {
/*
* Check some special cases first.
*/
- switch (optc = *s++)
- {
+ switch (optc = *s++) {
case ' ':
case '\t':
case END_OPTION_STRING:
continue;
case '-':
-#if GNU_OPTIONS
/*
* "--" indicates an option name instead of a letter.
*/
- if (*s == '-')
- {
- optname = ++s;
+ if (*s == '-') {
+ if (!less_is_more) {
+ optname = ++s;
+ }
break;
}
-#endif
/*
* "-+" means set these options back to their defaults.
- * (They may have been set otherwise by previous
+ * (They may have been set otherwise by previous
* options.)
*/
- set_default = (*s == '+');
- if (set_default)
- s++;
+ if (!less_is_more) {
+ set_default = (*s == '+');
+ if (set_default)
+ s++;
+ }
continue;
case '+':
/*
- * An option prefixed by a "+" is ungotten, so
- * that it is interpreted as less commands
+ * An option prefixed by a "+" is ungotten, so
+ * that it is interpreted as less commands
* processed at the start of the first input file.
* "++" means process the commands at the start of
* EVERY input file.
@@ -161,15 +162,48 @@ scan_option(s)
case '5': case '6': case '7': case '8': case '9':
/*
* Special "more" compatibility form "-<number>"
- * instead of -z<number> to set the scrolling
+ * instead of -z<number> to set the scrolling
* window size.
*/
s--;
optc = 'z';
+ moreopt = 1;
break;
case 'n':
- if (less_is_more)
+ if (less_is_more) {
+ moreopt = 1;
optc = 'z';
+ }
+ break;
+ case 'i':
+ if (less_is_more) {
+ moreopt = 1;
+ optc = 'I';
+ }
+ break;
+ case 'u':
+ if (less_is_more) {
+ moreopt = 1;
+ optc = 'U';
+ }
+ break;
+ case 'e':
+ if (less_is_more) {
+ moreopt = 1;
+ optc = 'E';
+ }
+ break;
+ case 'h':
+ if (less_is_more) {
+ moreopt = 1;
+ optc = '?';
+ }
+ break;
+ case 'd':
+ if (less_is_more) {
+ moreopt = 1;
+ optc = 'M';
+ }
break;
}
@@ -178,66 +212,57 @@ scan_option(s)
* Look up the option letter in the option table.
*/
err = 0;
- if (optname == NULL)
- {
+ if (optname == NULL) {
printopt = propt(optc);
- lc = ASCII_IS_LOWER(optc);
+ lc = islower(optc);
o = findopt(optc);
- }
-#if GNU_OPTIONS
- else
- {
+ if (less_is_more && (!moreopt) && (o != NULL) &&
+ ((o->otype & MORE_OK) == 0)) {
+ o = NULL;
+ }
+ } else {
printopt = optname;
- lc = ASCII_IS_LOWER(optname[0]);
+ lc = islower(optname[0]);
o = findopt_name(&optname, NULL, &err);
s = optname;
optname = NULL;
- if (*s == '\0' || *s == ' ')
- {
- /*
- * The option name matches exactly.
- */
- ;
- } else if (*s == '=')
- {
- /*
- * The option name is followed by "=value".
- */
+ switch (*s) {
+ case ' ': /* name matches exactly */
+ case '\0':
+ break;
+
+ case '=': /* name followed by "=value" */
if (o != NULL &&
(o->otype & OTYPE) != STRING &&
- (o->otype & OTYPE) != NUMBER)
- {
+ (o->otype & OTYPE) != NUMBER) {
parg.p_string = printopt;
- error("The %s option should not be followed by =",
- &parg);
+ error("The %s option should not be "
+ "followed by =", &parg);
return;
}
s++;
- } else
- {
- /*
- * The specified name is longer than the
- * real option name.
- */
+ break;
+ default: /* name longer than option, bad */
o = NULL;
}
}
-#endif
- if (o == NULL)
- {
+ if (o == NULL) {
parg.p_string = printopt;
- if (err == OPT_AMBIG)
- error("%s is an ambiguous abbreviation (\"less --help\" for help)",
- &parg);
- else
- error("There is no %s option (\"less --help\" for help)",
- &parg);
+ if (less_is_more) {
+ error("Illegal option %s (more -h for help)",
+ &parg);
+ } else if (err == OPT_AMBIG) {
+ error("%s is an ambiguous abbreviation "
+ "(\"less --help\" for help)", &parg);
+ } else {
+ error("There is no %s option "
+ "(\"less --help\" for help)", &parg);
+ }
return;
}
str = NULL;
- switch (o->otype & OTYPE)
- {
+ switch (o->otype & OTYPE) {
case BOOL:
if (set_default)
*(o->ovar) = o->odefault;
@@ -251,8 +276,7 @@ scan_option(s)
*(o->ovar) = flip_triple(o->odefault, lc);
break;
case STRING:
- if (*s == '\0')
- {
+ if (*s == '\0') {
/*
* Set pendopt and return.
* We will get the string next time
@@ -263,7 +287,7 @@ scan_option(s)
}
/*
* Don't do anything here.
- * All processing of STRING options is done by
+ * All processing of STRING options is done by
* the handling function.
*/
while (*s == ' ')
@@ -273,12 +297,11 @@ scan_option(s)
return;
break;
case NUMBER:
- if (*s == '\0')
- {
+ if (*s == '\0') {
pendopt = o;
return;
}
- *(o->ovar) = getnum(&s, printopt, (int*)NULL);
+ *(o->ovar) = getnum(&s, printopt, NULL);
break;
}
/*
@@ -300,14 +323,10 @@ scan_option(s)
* OPT_UNSET set to the default value
* OPT_SET set to the inverse of the default value
*/
- public void
-toggle_option(o, lower, s, how_toggle)
- struct loption *o;
- int lower;
- char *s;
- int how_toggle;
+void
+toggle_option(struct loption *o, int lower, char *s, int how_toggle)
{
- register int num;
+ int num;
int no_prompt;
int err;
PARG parg;
@@ -315,25 +334,22 @@ toggle_option(o, lower, s, how_toggle)
no_prompt = (how_toggle & OPT_NO_PROMPT);
how_toggle &= ~OPT_NO_PROMPT;
- if (o == NULL)
- {
+ if (o == NULL) {
error("No such option", NULL_PARG);
return;
}
- if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE))
- {
+ if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE)) {
parg.p_string = opt_desc(o);
error("Cannot change the %s option", &parg);
return;
}
- if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY))
- {
+ if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY)) {
parg.p_string = opt_desc(o);
error("Cannot query the %s option", &parg);
return;
- }
+ }
/*
* Check for something which appears to be a do_toggle
@@ -341,8 +357,7 @@ toggle_option(o, lower, s, how_toggle)
* This could be a string option with no string, or
* a number option with no number.
*/
- switch (o->otype & OTYPE)
- {
+ switch (o->otype & OTYPE) {
case STRING:
case NUMBER:
if (how_toggle == OPT_TOGGLE && *s == '\0')
@@ -350,24 +365,19 @@ toggle_option(o, lower, s, how_toggle)
break;
}
-#if HILITE_SEARCH
if (how_toggle != OPT_NO_TOGGLE && (o->otype & HL_REPAINT))
repaint_hilite(0);
-#endif
/*
* Now actually toggle (change) the variable.
*/
- if (how_toggle != OPT_NO_TOGGLE)
- {
- switch (o->otype & OTYPE)
- {
+ if (how_toggle != OPT_NO_TOGGLE) {
+ switch (o->otype & OTYPE) {
case BOOL:
/*
* Boolean.
*/
- switch (how_toggle)
- {
+ switch (how_toggle) {
case OPT_TOGGLE:
*(o->ovar) = ! *(o->ovar);
break;
@@ -382,13 +392,12 @@ toggle_option(o, lower, s, how_toggle)
case TRIPLE:
/*
* Triple:
- * If user gave the lower case letter, then switch
+ * If user gave the lower case letter, then switch
* to 1 unless already 1, in which case make it 0.
* If user gave the upper case letter, then switch
* to 2 unless already 2, in which case make it 0.
*/
- switch (how_toggle)
- {
+ switch (how_toggle) {
case OPT_TOGGLE:
*(o->ovar) = flip_triple(*(o->ovar), lower);
break;
@@ -405,12 +414,11 @@ toggle_option(o, lower, s, how_toggle)
* String: don't do anything here.
* The handling function will do everything.
*/
- switch (how_toggle)
- {
+ switch (how_toggle) {
case OPT_SET:
case OPT_UNSET:
- error("Cannot use \"-+\" or \"--\" for a string option",
- NULL_PARG);
+ error("Cannot use \"-+\" or \"--\" "
+ "for a string option", NULL_PARG);
return;
}
break;
@@ -418,8 +426,7 @@ toggle_option(o, lower, s, how_toggle)
/*
* Number: set the variable to the given number.
*/
- switch (how_toggle)
- {
+ switch (how_toggle) {
case OPT_TOGGLE:
num = getnum(&s, NULL, &err);
if (!err)
@@ -430,7 +437,7 @@ toggle_option(o, lower, s, how_toggle)
break;
case OPT_SET:
error("Can't use \"-!\" for a numeric option",
- NULL_PARG);
+ NULL_PARG);
return;
}
break;
@@ -438,24 +445,20 @@ toggle_option(o, lower, s, how_toggle)
}
/*
- * Call the handling function for any special action
+ * Call the handling function for any special action
* specific to this option.
*/
if (o->ofunc != NULL)
- (*o->ofunc)((how_toggle==OPT_NO_TOGGLE) ? QUERY : TOGGLE, s);
+ (*o->ofunc)((how_toggle == OPT_NO_TOGGLE) ? QUERY : TOGGLE, s);
-#if HILITE_SEARCH
if (how_toggle != OPT_NO_TOGGLE && (o->otype & HL_REPAINT))
chg_hilite();
-#endif
- if (!no_prompt)
- {
+ if (!no_prompt) {
/*
* Print a message describing the new setting.
*/
- switch (o->otype & OTYPE)
- {
+ switch (o->otype & OTYPE) {
case BOOL:
case TRIPLE:
/*
@@ -465,7 +468,7 @@ toggle_option(o, lower, s, how_toggle)
break;
case NUMBER:
/*
- * The message is in odesc[1] and has a %d for
+ * The message is in odesc[1] and has a %d for
* the value of the variable.
*/
parg.p_int = *(o->ovar);
@@ -486,10 +489,8 @@ toggle_option(o, lower, s, how_toggle)
/*
* "Toggle" a triple-valued option.
*/
- static int
-flip_triple(val, lc)
- int val;
- int lc;
+static int
+flip_triple(int val, int lc)
{
if (lc)
return ((val == OPT_ON) ? OPT_OFF : OPT_ON);
@@ -500,9 +501,8 @@ flip_triple(val, lc)
/*
* Determine if an option takes a parameter.
*/
- public int
-opt_has_param(o)
- struct loption *o;
+int
+opt_has_param(struct loption *o)
{
if (o == NULL)
return (0);
@@ -515,9 +515,8 @@ opt_has_param(o)
* Return the prompt to be used for a given option letter.
* Only string and number valued options have prompts.
*/
- public char *
-opt_prompt(o)
- struct loption *o;
+char *
+opt_prompt(struct loption *o)
{
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
return ("?");
@@ -526,13 +525,13 @@ opt_prompt(o)
/*
* Return whether or not there is a string option pending;
- * that is, if the previous option was a string-valued option letter
+ * that is, if the previous option was a string-valued option letter
* (like -P) without a following string.
* In that case, the current option is taken to be the string for
* the previous option.
*/
- public int
-isoptpending()
+int
+isoptpending(void)
{
return (pendopt != NULL);
}
@@ -540,9 +539,8 @@ isoptpending()
/*
* Print error message about missing string.
*/
- static void
-nostring(printopt)
- char *printopt;
+static void
+nostring(char *printopt)
{
PARG parg;
parg.p_string = printopt;
@@ -552,8 +550,8 @@ nostring(printopt)
/*
* Print error message if a STRING type option is not followed by a string.
*/
- public void
-nopendopt()
+void
+nopendopt(void)
{
nostring(opt_desc(pendopt));
}
@@ -563,35 +561,28 @@ nopendopt()
* In the latter case, replace the char with a null char.
* Return a pointer to the remainder of the string, if any.
*/
- static char *
-optstring(s, p_str, printopt, validchars)
- char *s;
- char **p_str;
- char *printopt;
- char *validchars;
+static char *
+optstring(char *s, char **p_str, char *printopt, char *validchars)
{
- register char *p;
- register char *out;
+ char *p;
+ char *out;
- if (*s == '\0')
- {
+ if (*s == '\0') {
nostring(printopt);
return (NULL);
}
/* Alloc could be more than needed, but not worth trimming. */
- *p_str = (char *) ecalloc(strlen(s)+1, sizeof(char));
+ *p_str = ecalloc(strlen(s)+1, sizeof (char));
out = *p_str;
- for (p = s; *p != '\0'; p++)
- {
- if (opt_use_backslash && *p == '\\' && p[1] != '\0')
- {
+ for (p = s; *p != '\0'; p++) {
+ if (opt_use_backslash && *p == '\\' && p[1] != '\0') {
/* Take next char literally. */
++p;
- } else
- {
- if (*p == END_OPTION_STRING ||
- (validchars != NULL && strchr(validchars, *p) == NULL))
+ } else {
+ if (*p == END_OPTION_STRING ||
+ (validchars != NULL &&
+ strchr(validchars, *p) == NULL))
/* End of option string. */
break;
}
@@ -603,20 +594,16 @@ optstring(s, p_str, printopt, validchars)
/*
*/
- static int
-num_error(printopt, errp)
- char *printopt;
- int *errp;
+static int
+num_error(char *printopt, int *errp)
{
PARG parg;
- if (errp != NULL)
- {
+ if (errp != NULL) {
*errp = TRUE;
return (-1);
}
- if (printopt != NULL)
- {
+ if (printopt != NULL) {
parg.p_string = printopt;
error("Number is required after %s", &parg);
}
@@ -628,20 +615,16 @@ num_error(printopt, errp)
* Like atoi(), but takes a pointer to a char *, and updates
* the char * to point after the translated number.
*/
- public int
-getnum(sp, printopt, errp)
- char **sp;
- char *printopt;
- int *errp;
+int
+getnum(char **sp, char *printopt, int *errp)
{
- register char *s;
- register int n;
- register int neg;
+ char *s;
+ int n;
+ int neg;
s = skipsp(*sp);
neg = FALSE;
- if (*s == '-')
- {
+ if (*s == '-') {
neg = TRUE;
s++;
}
@@ -665,13 +648,10 @@ getnum(sp, printopt, errp)
* The value of the fraction is returned as parts per NUM_FRAC_DENOM.
* That is, if "n" is returned, the fraction intended is n/NUM_FRAC_DENOM.
*/
- public long
-getfraction(sp, printopt, errp)
- char **sp;
- char *printopt;
- int *errp;
+long
+getfraction(char **sp, char *printopt, int *errp)
{
- register char *s;
+ char *s;
long frac = 0;
int fraclen = 0;
@@ -679,8 +659,7 @@ getfraction(sp, printopt, errp)
if (*s < '0' || *s > '9')
return (num_error(printopt, errp));
- for ( ; *s >= '0' && *s <= '9'; s++)
- {
+ for (; *s >= '0' && *s <= '9'; s++) {
frac = (frac * 10) + (*s - '0');
fraclen++;
}
@@ -700,11 +679,8 @@ getfraction(sp, printopt, errp)
/*
* Get the value of the -e flag.
*/
- public int
-get_quit_at_eof()
+int
+get_quit_at_eof(void)
{
- if (!less_is_more)
- return quit_at_eof;
- /* When less_is_more is set, the -e flag semantics are different. */
- return quit_at_eof ? OPT_ONPLUS : OPT_ON;
+ return (quit_at_eof);
}
diff --git a/usr.bin/less/option.h b/usr.bin/less/option.h
index c11ad3b4f01..7e29eda6faa 100644
--- a/usr.bin/less/option.h
+++ b/usr.bin/less/option.h
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
#define END_OPTION_STRING ('$')
@@ -23,10 +26,11 @@
#define HL_REPAINT 0200 /* Repaint hilites after toggling option */
#define NO_QUERY 0400 /* Option cannot be queried with "_" cmd */
#define INIT_HANDLER 01000 /* Call option handler function at startup */
+#define MORE_OK 02000 /* Allow when less_is_more */
#define OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR)
-#define OLETTER_NONE '\1' /* Invalid option letter */
+#define OLETTER_NONE '\1' /* Invalid option letter */
/*
* Argument to a handling function tells what type of activity:
@@ -40,18 +44,18 @@
#define OPT_TOGGLE 1
#define OPT_UNSET 2
#define OPT_SET 3
-#define OPT_NO_PROMPT 0100
+#define OPT_NO_PROMPT 0100
/* Error code from findopt_name */
-#define OPT_AMBIG 1
+#define OPT_AMBIG 1
struct optname
{
- char *oname; /* Long (GNU-style) option name */
+ char *oname; /* Long (GNU-style) option name */
struct optname *onext; /* List of synonymous option names */
};
-#define OPTNAME_MAX 32 /* Max length of long option name */
+#define OPTNAME_MAX 32 /* Max length of long option name */
struct loption
{
@@ -63,4 +67,3 @@ struct loption
void (*ofunc)(); /* Pointer to special handling function */
char *odesc[3]; /* Description of each value */
};
-
diff --git a/usr.bin/less/opttbl.c b/usr.bin/less/opttbl.c
index 9671d47196e..e5cd1c34ce9 100644
--- a/usr.bin/less/opttbl.c
+++ b/usr.bin/less/opttbl.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* The option table.
@@ -18,164 +21,88 @@
/*
* Variables controlled by command line options.
*/
-public int quiet; /* Should we suppress the audible bell? */
-public int how_search; /* Where should forward searches start? */
-public int top_scroll; /* Repaint screen from top?
- (alternative is scroll from bottom) */
-public int pr_type; /* Type of prompt (short, medium, long) */
-public int bs_mode; /* How to process backspaces */
-public int know_dumb; /* Don't complain about dumb terminals */
-public int quit_at_eof; /* Quit after hitting end of file twice */
-public int quit_if_one_screen; /* Quit if EOF on first screen */
-public int squeeze; /* Squeeze multiple blank lines into one */
-public int tabstop; /* Tab settings */
-public int back_scroll; /* Repaint screen on backwards movement */
-public int forw_scroll; /* Repaint screen on forward movement */
-public int caseless; /* Do "caseless" searches */
-public int linenums; /* Use line numbers */
-public int autobuf; /* Automatically allocate buffers as needed */
-public int bufspace; /* Max buffer space per file (K) */
-public int ctldisp; /* Send control chars to screen untranslated */
-public int force_open; /* Open the file even if not regular file */
-public int swindow; /* Size of scrolling window */
-public int jump_sline; /* Screen line of "jump target" */
-public long jump_sline_fraction = -1;
-public long shift_count_fraction = -1;
-public int chopline; /* Truncate displayed lines at screen width */
-public int no_init; /* Disable sending ti/te termcap strings */
-public int no_keypad; /* Disable sending ks/ke termcap strings */
-public int twiddle; /* Show tildes after EOF */
-public int show_attn; /* Hilite first unread line */
-public int shift_count; /* Number of positions to shift horizontally */
-public int status_col; /* Display a status column */
-public int use_lessopen; /* Use the LESSOPEN filter */
-public int quit_on_intr; /* Quit on interrupt */
-public int follow_mode; /* F cmd Follows file desc or file name? */
-public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */
-public int opt_use_backslash; /* Use backslash escaping in option parsing */
-#if HILITE_SEARCH
-public int hilite_search; /* Highlight matched search patterns? */
-#endif
+int quiet; /* Should we suppress the audible bell? */
+int how_search; /* Where should forward searches start? */
+int top_scroll; /* Repaint screen from top? (vs scroll from bottom) */
+int pr_type; /* Type of prompt (short, medium, long) */
+int bs_mode; /* How to process backspaces */
+int know_dumb; /* Don't complain about dumb terminals */
+int quit_at_eof; /* Quit after hitting end of file twice */
+int quit_if_one_screen; /* Quit if EOF on first screen */
+int squeeze; /* Squeeze multiple blank lines into one */
+int back_scroll; /* Repaint screen on backwards movement */
+int forw_scroll; /* Repaint screen on forward movement */
+int caseless; /* Do "caseless" searches */
+int linenums; /* Use line numbers */
+int autobuf; /* Automatically allocate buffers as needed */
+int bufspace; /* Max buffer space per file (K) */
+int ctldisp; /* Send control chars to screen untranslated */
+int force_open; /* Open the file even if not regular file */
+int swindow; /* Size of scrolling window */
+int jump_sline; /* Screen line of "jump target" */
+long jump_sline_fraction = -1;
+int chopline; /* Truncate displayed lines at screen width */
+int no_init; /* Disable sending ti/te termcap strings */
+int no_keypad; /* Disable sending ks/ke termcap strings */
+int twiddle; /* Show tildes after EOF */
+int show_attn; /* Hilite first unread line */
+int status_col; /* Display a status column */
+int use_lessopen; /* Use the LESSOPEN filter */
+int quit_on_intr; /* Quit on interrupt */
+int follow_mode; /* F cmd Follows file desc or file name? */
+int oldbot; /* Old bottom of screen behavior {{REMOVE}} */
+int opt_use_backslash; /* Use backslash escaping in option parsing */
+int hilite_search; /* Highlight matched search patterns? */
-public int less_is_more = 0; /* Make compatible with POSIX more */
+int less_is_more = 0; /* Make compatible with POSIX more */
/*
* Long option names.
*/
-#if GNU_OPTIONS
-static struct optname a_optname = { "search-skip-screen", NULL };
-static struct optname b_optname = { "buffers", NULL };
-static struct optname B__optname = { "auto-buffers", NULL };
-static struct optname c_optname = { "clear-screen", NULL };
-static struct optname d_optname = { "dumb", NULL };
-#if MSDOS_COMPILER
-static struct optname D__optname = { "color", NULL };
-#endif
-static struct optname e_optname = { "quit-at-eof", NULL };
-static struct optname f_optname = { "force", NULL };
-static struct optname F__optname = { "quit-if-one-screen", NULL };
-#if HILITE_SEARCH
-static struct optname g_optname = { "hilite-search", NULL };
-#endif
-static struct optname h_optname = { "max-back-scroll", NULL };
-static struct optname i_optname = { "ignore-case", NULL };
-static struct optname j_optname = { "jump-target", NULL };
-static struct optname J__optname = { "status-column", NULL };
-#if USERFILE
-static struct optname k_optname = { "lesskey-file", NULL };
-#endif
-static struct optname K__optname = { "quit-on-intr", NULL };
-static struct optname L__optname = { "no-lessopen", NULL };
-static struct optname m_optname = { "long-prompt", NULL };
-static struct optname n_optname = { "line-numbers", NULL };
-#if LOGFILE
-static struct optname o_optname = { "log-file", NULL };
-static struct optname O__optname = { "LOG-FILE", NULL };
-#endif
-static struct optname p_optname = { "pattern", NULL };
-static struct optname P__optname = { "prompt", NULL };
-static struct optname q2_optname = { "silent", NULL };
-static struct optname q_optname = { "quiet", &q2_optname };
-static struct optname r_optname = { "raw-control-chars", NULL };
-static struct optname s_optname = { "squeeze-blank-lines", NULL };
-static struct optname S__optname = { "chop-long-lines", NULL };
-#if TAGS
-static struct optname t_optname = { "tag", NULL };
-static struct optname T__optname = { "tag-file", NULL };
-#endif
-static struct optname u_optname = { "underline-special", NULL };
-static struct optname V__optname = { "version", NULL };
-static struct optname w_optname = { "hilite-unread", NULL };
-static struct optname x_optname = { "tabs", NULL };
-static struct optname X__optname = { "no-init", NULL };
-static struct optname y_optname = { "max-forw-scroll", NULL };
-static struct optname z_optname = { "window", NULL };
-static struct optname quote_optname = { "quotes", NULL };
-static struct optname tilde_optname = { "tilde", NULL };
-static struct optname query_optname = { "help", NULL };
-static struct optname pound_optname = { "shift", NULL };
-static struct optname keypad_optname = { "no-keypad", NULL };
-static struct optname oldbot_optname = { "old-bot", NULL };
-static struct optname follow_optname = { "follow-name", NULL };
-static struct optname use_backslash_optname = { "use-backslash", NULL };
-#else
-static struct optname fake_optname = { "fake", NULL };
-#define a_optname fake_optname
-#define b_optname fake_optname
-#define B__optname fake_optname
-#define c_optname fake_optname
-#define d_optname fake_optname
-#if MSDOS_COMPILER
-#define D__optname fake_optname
-#endif
-#define e_optname fake_optname
-#define f_optname fake_optname
-#define F__optname fake_optname
-#if HILITE_SEARCH
-#define g_optname fake_optname
-#endif
-#define h_optname fake_optname
-#define i_optname fake_optname
-#define j_optname fake_optname
-#define J__optname fake_optname
-#if USERFILE
-#define k_optname fake_optname
-#endif
-#define K__optname fake_optname
-#define L__optname fake_optname
-#define m_optname fake_optname
-#define n_optname fake_optname
-#if LOGFILE
-#define o_optname fake_optname
-#define O__optname fake_optname
-#endif
-#define p_optname fake_optname
-#define P__optname fake_optname
-#define q2_optname fake_optname
-#define q_optname fake_optname
-#define r_optname fake_optname
-#define s_optname fake_optname
-#define S__optname fake_optname
-#if TAGS
-#define t_optname fake_optname
-#define T__optname fake_optname
-#endif
-#define u_optname fake_optname
-#define V__optname fake_optname
-#define w_optname fake_optname
-#define x_optname fake_optname
-#define X__optname fake_optname
-#define y_optname fake_optname
-#define z_optname fake_optname
-#define quote_optname fake_optname
-#define tilde_optname fake_optname
-#define query_optname fake_optname
-#define pound_optname fake_optname
-#define keypad_optname fake_optname
-#define oldbot_optname fake_optname
-#define follow_optname fake_optname
-#define use_backslash_optname fake_optname
-#endif
+static struct optname a_optname = { "search-skip-screen", NULL };
+static struct optname b_optname = { "buffers", NULL };
+static struct optname B__optname = { "auto-buffers", NULL };
+static struct optname c_optname = { "clear-screen", NULL };
+static struct optname d_optname = { "dumb", NULL };
+static struct optname e_optname = { "quit-at-eof", NULL };
+static struct optname f_optname = { "force", NULL };
+static struct optname F__optname = { "quit-if-one-screen", NULL };
+static struct optname g_optname = { "hilite-search", NULL };
+static struct optname h_optname = { "max-back-scroll", NULL };
+static struct optname i_optname = { "ignore-case", NULL };
+static struct optname j_optname = { "jump-target", NULL };
+static struct optname J__optname = { "status-column", NULL };
+static struct optname k_optname = { "lesskey-file", NULL };
+static struct optname K__optname = { "quit-on-intr", NULL };
+static struct optname L__optname = { "no-lessopen", NULL };
+static struct optname m_optname = { "long-prompt", NULL };
+static struct optname n_optname = { "line-numbers", NULL };
+static struct optname o_optname = { "log-file", NULL };
+static struct optname O__optname = { "LOG-FILE", NULL };
+static struct optname p_optname = { "pattern", NULL };
+static struct optname P__optname = { "prompt", NULL };
+static struct optname q2_optname = { "silent", NULL };
+static struct optname q_optname = { "quiet", &q2_optname };
+static struct optname r_optname = { "raw-control-chars", NULL };
+static struct optname s_optname = { "squeeze-blank-lines", NULL };
+static struct optname S__optname = { "chop-long-lines", NULL };
+static struct optname t_optname = { "tag", NULL };
+static struct optname T__optname = { "tag-file", NULL };
+static struct optname u_optname = { "underline-special", NULL };
+static struct optname V__optname = { "version", NULL };
+static struct optname w_optname = { "hilite-unread", NULL };
+static struct optname x_optname = { "tabs", NULL };
+static struct optname X__optname = { "no-init", NULL };
+static struct optname y_optname = { "max-forw-scroll", NULL };
+static struct optname z_optname = { "window", NULL };
+static struct optname quote_optname = { "quotes", NULL };
+static struct optname tilde_optname = { "tilde", NULL };
+static struct optname query_optname = { "help", NULL };
+static struct optname pound_optname = { "shift", NULL };
+static struct optname keypad_optname = { "no-keypad", NULL };
+static struct optname oldbot_optname = { "old-bot", NULL };
+static struct optname follow_optname = { "follow-name", NULL };
+static struct optname use_backslash_optname = { "use-backslash", NULL };
/*
@@ -184,14 +111,13 @@ static struct optname fake_optname = { "fake", NULL };
* For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are
* the description of the option when set to 0, 1 or 2, respectively.
* For NUMBER options, odesc[0] is the prompt to use when entering
- * a new value, and odesc[1] is the description, which should contain
+ * a new value, and odesc[1] is the description, which should contain
* one %d which is replaced by the value of the number.
* For STRING options, odesc[0] is the prompt to use when entering
* a new value, and odesc[1], if not NULL, is the set of characters
* that are valid in the string.
*/
-static struct loption option[] =
-{
+static struct loption option[] = {
{ 'a', &a_optname,
TRIPLE, OPT_ONPLUS, &how_search, NULL,
{
@@ -202,7 +128,7 @@ static struct loption option[] =
},
{ 'b', &b_optname,
- NUMBER|INIT_HANDLER, 64, &bufspace, opt_b,
+ NUMBER|INIT_HANDLER, 64, &bufspace, opt_b,
{
"Max buffer space per file (K): ",
"Max buffer space per file: %dK",
@@ -218,7 +144,7 @@ static struct loption option[] =
}
},
{ 'c', &c_optname,
- TRIPLE, OPT_ON, &top_scroll, NULL,
+ TRIPLE|MORE_OK, OPT_ON, &top_scroll, NULL,
{
"Repaint by scrolling from bottom of screen",
"Repaint by painting from top of screen",
@@ -226,23 +152,13 @@ static struct loption option[] =
}
},
{ 'd', &d_optname,
- BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
+ BOOL|MORE_OK|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
{
"Assume intelligent terminal",
"Assume dumb terminal",
NULL
}
},
-#if MSDOS_COMPILER
- { 'D', &D__optname,
- STRING|REPAINT|NO_QUERY, 0, NULL, opt_D,
- {
- "color desc: ",
- "Ddknsu0123456789.",
- NULL
- }
- },
-#endif
{ 'e', &e_optname,
TRIPLE, OPT_OFF, &quit_at_eof, NULL,
{
@@ -267,7 +183,6 @@ static struct loption option[] =
NULL
}
},
-#if HILITE_SEARCH
{ 'g', &g_optname,
TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL,
{
@@ -276,7 +191,6 @@ static struct loption option[] =
"Highlight all matches for previous search pattern",
}
},
-#endif
{ 'h', &h_optname,
NUMBER, -1, &back_scroll, NULL,
{
@@ -309,12 +223,10 @@ static struct loption option[] =
NULL
}
},
-#if USERFILE
{ 'k', &k_optname,
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k,
{ NULL, NULL, NULL }
},
-#endif
{ 'K', &K__optname,
BOOL, OPT_OFF, &quit_on_intr, NULL,
{
@@ -347,7 +259,6 @@ static struct loption option[] =
"Constantly display line numbers"
}
},
-#if LOGFILE
{ 'o', &o_optname,
STRING, 0, NULL, opt_o,
{ "log file: ", NULL, NULL }
@@ -356,9 +267,8 @@ static struct loption option[] =
STRING, 0, NULL, opt__O,
{ "Log file: ", NULL, NULL }
},
-#endif
{ 'p', &p_optname,
- STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p,
+ STRING|NO_TOGGLE|NO_QUERY|MORE_OK, 0, NULL, opt_p,
{ NULL, NULL, NULL }
},
{ 'P', &P__optname,
@@ -378,11 +288,12 @@ static struct loption option[] =
{
"Display control characters as ^X",
"Display control characters directly",
- "Display control characters directly, processing ANSI sequences"
+ "Display control characters directly, "
+ "processing ANSI sequences"
}
},
{ 's', &s_optname,
- BOOL|REPAINT, OPT_OFF, &squeeze, NULL,
+ BOOL|REPAINT|MORE_OK, OPT_OFF, &squeeze, NULL,
{
"Display all blank lines",
"Squeeze multiple blank lines",
@@ -397,16 +308,14 @@ static struct loption option[] =
NULL
}
},
-#if TAGS
{ 't', &t_optname,
- STRING|NO_QUERY, 0, NULL, opt_t,
+ STRING|NO_QUERY|MORE_OK, 0, NULL, opt_t,
{ "tag: ", NULL, NULL }
},
{ 'T', &T__optname,
- STRING, 0, NULL, opt__T,
+ STRING|MORE_OK, 0, NULL, opt__T,
{ "tags file: ", NULL, NULL }
},
-#endif
{ 'u', &u_optname,
TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
{
@@ -424,7 +333,8 @@ static struct loption option[] =
{
"Don't highlight first unread line",
"Highlight first unread line after forward-screen",
- "Highlight first unread line after any forward movement",
+ "Highlight first unread line after any "
+ "forward movement",
}
},
{ 'x', &x_optname,
@@ -511,7 +421,8 @@ static struct loption option[] =
BOOL, OPT_OFF, &opt_use_backslash, NULL,
{
"Use backslash escaping in command line parameters",
- "Don't use backslash escaping in command line parameters",
+ "Don't use backslash escaping in command line "
+ "parameters",
NULL
}
},
@@ -522,42 +433,34 @@ static struct loption option[] =
/*
* Initialize each option to its default value.
*/
- public void
-init_option()
+void
+init_option(void)
{
- register struct loption *o;
- char *p;
+ struct loption *o;
- p = lgetenv("LESS_IS_MORE");
- if (p != NULL && *p != '\0')
- less_is_more = 1;
-
- for (o = option; o->oletter != '\0'; o++)
- {
+ for (o = option; o->oletter != '\0'; o++) {
/*
* Set each variable to its default.
*/
if (o->ovar != NULL)
*(o->ovar) = o->odefault;
if (o->otype & INIT_HANDLER)
- (*(o->ofunc))(INIT, (char *) NULL);
+ (*(o->ofunc))(INIT, NULL);
}
}
/*
* Find an option in the option table, given its option letter.
*/
- public struct loption *
-findopt(c)
- int c;
+struct loption *
+findopt(int c)
{
- register struct loption *o;
+ struct loption *o;
- for (o = option; o->oletter != '\0'; o++)
- {
+ for (o = option; o->oletter != '\0'; o++) {
if (o->oletter == c)
return (o);
- if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c)
+ if ((o->otype & TRIPLE) && (toupper(o->oletter) == c))
return (o);
}
return (NULL);
@@ -566,36 +469,31 @@ findopt(c)
/*
*
*/
- static int
-is_optchar(c)
- char c;
+static int
+is_optchar(char c)
{
- if (ASCII_IS_UPPER(c))
- return 1;
- if (ASCII_IS_LOWER(c))
- return 1;
+ if (isupper(c))
+ return (1);
+ if (islower(c))
+ return (1);
if (c == '-')
- return 1;
- return 0;
+ return (1);
+ return (0);
}
-#if GNU_OPTIONS
/*
* Find an option in the option table, given its option name.
* p_optname is the (possibly partial) name to look for, and
* is updated to point after the matched name.
* p_oname if non-NULL is set to point to the full option name.
*/
- public struct loption *
-findopt_name(p_optname, p_oname, p_err)
- char **p_optname;
- char **p_oname;
- int *p_err;
+struct loption *
+findopt_name(char **p_optname, char **p_oname, int *p_err)
{
char *optname = *p_optname;
- register struct loption *o;
- register struct optname *oname;
- register int len;
+ struct loption *o;
+ struct optname *oname;
+ int len;
int uppercase;
struct loption *maxo = NULL;
struct optname *maxoname = NULL;
@@ -606,37 +504,32 @@ findopt_name(p_optname, p_oname, p_err)
/*
* Check all options.
*/
- for (o = option; o->oletter != '\0'; o++)
- {
+ for (o = option; o->oletter != '\0'; o++) {
/*
* Check all names for this option.
*/
- for (oname = o->onames; oname != NULL; oname = oname->onext)
- {
- /*
+ for (oname = o->onames; oname != NULL; oname = oname->onext) {
+ /*
* Try normal match first (uppercase == 0),
* then, then if it's a TRIPLE option,
* try uppercase match (uppercase == 1).
*/
- for (uppercase = 0; uppercase <= 1; uppercase++)
- {
+ for (uppercase = 0; uppercase <= 1; uppercase++) {
len = sprefix(optname, oname->oname, uppercase);
- if (len <= 0 || is_optchar(optname[len]))
- {
+ if (len <= 0 || is_optchar(optname[len])) {
/*
* We didn't use all of the option name.
*/
continue;
}
- if (!exact && len == maxlen)
+ if (!exact && len == maxlen) {
/*
* Already had a partial match,
* and now there's another one that
* matches the same length.
*/
ambig = 1;
- else if (len > maxlen)
- {
+ } else if (len > maxlen) {
/*
* Found a better match than
* the one we had.
@@ -645,15 +538,14 @@ findopt_name(p_optname, p_oname, p_err)
maxoname = oname;
maxlen = len;
ambig = 0;
- exact = (len == (int)strlen(oname->oname));
+ exact = (len == strlen(oname->oname));
}
if (!(o->otype & TRIPLE))
break;
}
}
}
- if (ambig)
- {
+ if (ambig) {
/*
* Name matched more than one option.
*/
@@ -666,4 +558,3 @@ findopt_name(p_optname, p_oname, p_err)
*p_oname = maxoname == NULL ? NULL : maxoname->oname;
return (maxo);
}
-#endif
diff --git a/usr.bin/less/os.c b/usr.bin/less/os.c
index a4e42169b23..8b10e7f7907 100644
--- a/usr.bin/less/os.c
+++ b/usr.bin/less/os.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Operating system dependent routines.
@@ -22,110 +25,31 @@
#include "less.h"
#include <signal.h>
-#if HAVE_TIME_H
#include <time.h>
-#endif
-#if HAVE_ERRNO_H
#include <errno.h>
-#endif
-#if HAVE_VALUES_H
-#include <values.h>
-#endif
-
-#if HAVE_TIME_T
-#define time_type time_t
-#else
-#define time_type long
-#endif
extern volatile sig_atomic_t sigs;
/*
* Like read() system call, but is deliberately interruptible.
*/
- public int
-iread(fd, buf, len)
- int fd;
- char *buf;
- unsigned int len;
+int
+iread(int fd, unsigned char *buf, unsigned int len)
{
- register int n;
+ int n;
start:
-#if MSDOS_COMPILER==WIN32C
- if (ABORT_SIGS())
- return (READ_INTR);
-#else
-#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
- if (kbhit())
- {
- int c;
-
- c = getch();
- if (c == '\003')
- return (READ_INTR);
- ungetch(c);
- }
-#endif
-#endif
-
flush();
-#if MSDOS_COMPILER==DJGPPC
- if (isatty(fd))
- {
- /*
- * Don't try reading from a TTY until a character is
- * available, because that makes some background programs
- * believe DOS is busy in a way that prevents those
- * programs from working while "less" waits.
- */
- fd_set readfds;
-
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
- if (select(fd+1, &readfds, 0, 0, 0) == -1)
- return (-1);
- }
-#endif
n = read(fd, buf, len);
-#if 1
- /*
- * This is a kludge to workaround a problem on some systems
- * where terminating a remote tty connection causes read() to
- * start returning 0 forever, instead of -1.
- */
- {
- extern int ignore_eoi;
- if (!ignore_eoi)
- {
- static int consecutive_nulls = 0;
- if (n == 0)
- consecutive_nulls++;
- else
- consecutive_nulls = 0;
- if (consecutive_nulls > 20)
- quit(QUIT_ERROR);
- }
- }
-#endif
- if (n < 0)
- {
-#if HAVE_ERRNO
+ if (n < 0) {
/*
- * Certain values of errno indicate we should just retry the read.
+ * Certain values of errno indicate we should just retry the
+ * read.
*/
-#if MUST_DEFINE_ERRNO
- extern int errno;
-#endif
-#ifdef EINTR
if (errno == EINTR)
return (READ_INTR);
-#endif
-#ifdef EAGAIN
if (errno == EAGAIN)
goto start;
-#endif
-#endif
return (-1);
}
return (n);
@@ -134,174 +58,54 @@ start:
/*
* Return the current time.
*/
-#if HAVE_TIME
- public long
-get_time()
+long
+get_time(void)
{
- time_type t;
+ time_t t;
- time(&t);
+ (void) time(&t);
return (t);
}
-#endif
-
-
-#if !HAVE_STRERROR
-/*
- * Local version of strerror, if not available from the system.
- */
- static char *
-strerror(err)
- int err;
-{
-#if HAVE_SYS_ERRLIST
- static char buf[16];
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- if (err < sys_nerr)
- return sys_errlist[err];
- snprintf(buf, sizeof(buf), "Error %d", err);
- return buf;
-#else
- return ("cannot open");
-#endif
-}
-#endif
/*
* errno_message: Return an error message based on the value of "errno".
*/
- public char *
-errno_message(filename)
- char *filename;
+char *
+errno_message(char *filename)
{
- register char *p;
- register char *m;
- size_t len;
-#if HAVE_ERRNO
-#if MUST_DEFINE_ERRNO
- extern int errno;
-#endif
- p = strerror(errno);
-#else
- p = "cannot open";
-#endif
- len = strlen(filename) + strlen(p) + 3;
- m = (char *) ecalloc(len, sizeof(char));
- SNPRINTF2(m, len, "%s: %s", filename, p);
- return (m);
+ return (easprintf("%s: %s", filename, strerror(errno)));
}
-/* #define HAVE_FLOAT 0 */
-
- static POSITION
-muldiv(val, num, den)
- POSITION val, num, den;
+static off_t
+muldiv(off_t val, off_t num, off_t den)
{
-#if HAVE_FLOAT
- double v = (((double) val) * num) / den;
- return ((POSITION) (v + 0.5));
-#else
- POSITION v = ((POSITION) val) * num;
-
- if (v / num == val)
- /* No overflow */
- return (POSITION) (v / den);
- else
- /* Above calculation overflows;
- * use a method that is less precise but won't overflow. */
- return (POSITION) (val / (den / num));
-#endif
+ double v = (((double)val) * num) / den;
+ return ((off_t)(v + 0.5));
}
/*
- * Return the ratio of two POSITIONS, as a percentage.
- * {{ Assumes a POSITION is a long int. }}
+ * Return the ratio of two off_t, as a percentage.
+ * {{ Assumes a off_t is a long int. }}
*/
- public int
-percentage(num, den)
- POSITION num, den;
+int
+percentage(off_t num, off_t den)
{
- return (int) muldiv(num, (POSITION) 100, den);
+ return ((int)muldiv(num, (off_t)100, den));
}
/*
- * Return the specified percentage of a POSITION.
+ * Return the specified percentage of a off_t.
*/
- public POSITION
-percent_pos(pos, percent, fraction)
- POSITION pos;
- int percent;
- long fraction;
+off_t
+percent_pos(off_t pos, int percent, long fraction)
{
- /* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
- POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
+ /*
+ * Change percent (parts per 100) to perden
+ * (parts per NUM_FRAC_DENOM).
+ */
+ off_t perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
if (perden == 0)
return (0);
- return (POSITION) muldiv(pos, perden, (POSITION) NUM_FRAC_DENOM);
-}
-
-#if !HAVE_STRCHR
-/*
- * strchr is used by regexp.c.
- */
- char *
-strchr(s, c)
- char *s;
- int c;
-{
- for ( ; *s != '\0'; s++)
- if (*s == c)
- return (s);
- if (c == '\0')
- return (s);
- return (NULL);
-}
-#endif
-
-#if !HAVE_MEMCPY
- VOID_POINTER
-memcpy(dst, src, len)
- VOID_POINTER dst;
- VOID_POINTER src;
- int len;
-{
- char *dstp = (char *) dst;
- char *srcp = (char *) src;
- int i;
-
- for (i = 0; i < len; i++)
- dstp[i] = srcp[i];
- return (dst);
-}
-#endif
-
-#ifdef _OSK_MWC32
-
-/*
- * This implements an ANSI-style intercept setup for Microware C 3.2
- */
- public int
-os9_signal(type, handler)
- int type;
- RETSIGTYPE (*handler)();
-{
- intercept(handler);
-}
-
-#include <sgstat.h>
-
- int
-isatty(f)
- int f;
-{
- struct sgbuf sgbuf;
-
- if (_gs_opt(f, &sgbuf) < 0)
- return -1;
- return (sgbuf.sg_class == 0);
+ return (muldiv(pos, perden, (off_t)NUM_FRAC_DENOM));
}
-
-#endif
diff --git a/usr.bin/less/output.c b/usr.bin/less/output.c
index 5c93338b6b3..42b6a801578 100644
--- a/usr.bin/less/output.c
+++ b/usr.bin/less/output.c
@@ -6,21 +6,18 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* High level routines dealing with the output to the screen.
*/
#include "less.h"
-#if MSDOS_COMPILER==WIN32C
-#include "windows.h"
-#endif
-public int errmsgs; /* Count of messages displayed by error() */
-public int need_clr;
-public int final_attr;
-public int at_prompt;
+int errmsgs; /* Count of messages displayed by error() */
extern volatile sig_atomic_t sigs;
extern int sc_width;
@@ -30,27 +27,19 @@ extern int any_display;
extern int is_tty;
extern int oldbot;
-#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
-extern int ctldisp;
-extern int nm_fg_color, nm_bg_color;
-extern int bo_fg_color, bo_bg_color;
-extern int ul_fg_color, ul_bg_color;
-extern int so_fg_color, so_bg_color;
-extern int bl_fg_color, bl_bg_color;
-#endif
+static int need_clr;
/*
* Display the line which is in the line buffer.
*/
- public void
-put_line()
+void
+put_line(void)
{
- register int c;
- register int i;
+ int c;
+ int i;
int a;
- if (ABORT_SIGS())
- {
+ if (ABORT_SIGS()) {
/*
* Don't output if a signal is pending.
*/
@@ -58,16 +47,12 @@ put_line()
return;
}
- final_attr = AT_NORMAL;
-
- for (i = 0; (c = gline(i, &a)) != '\0'; i++)
- {
+ for (i = 0; (c = gline(i, &a)) != '\0'; i++) {
at_switch(a);
- final_attr = a;
if (c == '\b')
putbs();
else
- putchr(c);
+ (void) putchr(c);
}
at_exit();
@@ -92,232 +77,17 @@ static char *ob = obuf;
* sure these messages can be seen before they are
* overwritten or scrolled away.
*/
- public void
-flush()
+void
+flush(void)
{
- register int n;
- register int fd;
+ int n;
+ int fd;
ssize_t nwritten;
- n = ob - obuf;
+ n = (intptr_t)ob - (intptr_t)obuf;
if (n == 0)
return;
-#if MSDOS_COMPILER==MSOFTC
- if (is_tty && any_display)
- {
- *ob = '\0';
- _outtext(obuf);
- ob = obuf;
- return;
- }
-#else
-#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- if (is_tty && any_display)
- {
- *ob = '\0';
- if (ctldisp != OPT_ONPLUS)
- WIN32textout(obuf, ob - obuf);
- else
- {
- /*
- * Look for SGR escape sequences, and convert them
- * to color commands. Replace bold, underline,
- * and italic escapes into colors specified via
- * the -D command-line option.
- */
- char *anchor, *p, *p_next;
- unsigned char fg, bg;
- static unsigned char at;
-#if MSDOS_COMPILER==WIN32C
- /* Screen colors used by 3x and 4x SGR commands. */
- static unsigned char screen_color[] = {
- 0, /* BLACK */
- FOREGROUND_RED,
- FOREGROUND_GREEN,
- FOREGROUND_RED|FOREGROUND_GREEN,
- FOREGROUND_BLUE,
- FOREGROUND_BLUE|FOREGROUND_RED,
- FOREGROUND_BLUE|FOREGROUND_GREEN,
- FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
- };
-#else
- static enum COLORS screen_color[] = {
- BLACK, RED, GREEN, BROWN,
- BLUE, MAGENTA, CYAN, LIGHTGRAY
- };
-#endif
-
- for (anchor = p_next = obuf;
- (p_next = memchr(p_next, ESC, ob - p_next)) != NULL; )
- {
- p = p_next;
- if (p[1] == '[') /* "ESC-[" sequence */
- {
- if (p > anchor)
- {
- /*
- * If some chars seen since
- * the last escape sequence,
- * write them out to the screen.
- */
- WIN32textout(anchor, p-anchor);
- anchor = p;
- }
- p += 2; /* Skip the "ESC-[" */
- if (is_ansi_end(*p))
- {
- /*
- * Handle null escape sequence
- * "ESC[m", which restores
- * the normal color.
- */
- p++;
- anchor = p_next = p;
- at = 0;
- WIN32setcolors(nm_fg_color, nm_bg_color);
- continue;
- }
- p_next = p;
-
- /*
- * Select foreground/background colors
- * based on the escape sequence.
- */
- fg = nm_fg_color;
- bg = nm_bg_color;
- while (!is_ansi_end(*p))
- {
- char *q;
- long code = strtol(p, &q, 10);
-
- if (*q == '\0')
- {
- /*
- * Incomplete sequence.
- * Leave it unprocessed
- * in the buffer.
- */
- int slop = q - anchor;
- /* {{ strlcpy args overlap! }} */
- strlcpy(obuf, anchor,
- sizeof(obuf));
- ob = &obuf[slop];
- return;
- }
-
- if (q == p ||
- code > 49 || code < 0 ||
- (!is_ansi_end(*q) && *q != ';'))
- {
- p_next = q;
- break;
- }
- if (*q == ';')
- q++;
-
- switch (code)
- {
- default:
- /* case 0: all attrs off */
- fg = nm_fg_color;
- bg = nm_bg_color;
- at = 0;
- break;
- case 1: /* bold on */
- at |= 1;
- break;
- case 3: /* italic on */
- case 7: /* inverse on */
- at |= 2;
- break;
- case 4: /* underline on */
- at |= 4;
- break;
- case 5: /* slow blink on */
- case 6: /* fast blink on */
- at |= 8;
- break;
- case 8: /* concealed on */
- fg = (bg & 7) | 8;
- break;
- case 22: /* bold off */
- at &= ~1;
- break;
- case 23: /* italic off */
- case 27: /* inverse off */
- at &= ~2;
- break;
- case 24: /* underline off */
- at &= ~4;
- break;
- case 30: case 31: case 32:
- case 33: case 34: case 35:
- case 36: case 37:
- fg = (fg & 8) | (screen_color[code - 30]);
- break;
- case 39: /* default fg */
- fg = nm_fg_color;
- break;
- case 40: case 41: case 42:
- case 43: case 44: case 45:
- case 46: case 47:
- bg = (bg & 8) | (screen_color[code - 40]);
- break;
- case 49: /* default fg */
- bg = nm_bg_color;
- break;
- }
- p = q;
- }
- if (!is_ansi_end(*p) || p == p_next)
- break;
- if (at & 1)
- {
- /*
- * If \e[1m use defined bold
- * color, else set intensity.
- */
- if (p[-2] == '[')
- {
-#if MSDOS_COMPILER==WIN32C
- fg |= FOREGROUND_INTENSITY;
- bg |= BACKGROUND_INTENSITY;
-#else
- fg = bo_fg_color;
- bg = bo_bg_color;
-#endif
- } else
- fg |= 8;
- } else if (at & 2)
- {
- fg = so_fg_color;
- bg = so_bg_color;
- } else if (at & 4)
- {
- fg = ul_fg_color;
- bg = ul_bg_color;
- } else if (at & 8)
- {
- fg = bl_fg_color;
- bg = bl_bg_color;
- }
- fg &= 0xf;
- bg &= 0xf;
- WIN32setcolors(fg, bg);
- p_next = anchor = p + 1;
- } else
- p_next++;
- }
-
- /* Output what's left in the buffer. */
- WIN32textout(anchor, ob - anchor);
- }
- ob = obuf;
- return;
- }
-#endif
-#endif
fd = (any_display) ? STDOUT_FILENO : STDERR_FILENO;
nwritten = write(fd, obuf, n);
if (nwritten != n) {
@@ -331,104 +101,68 @@ flush()
/*
* Output a character.
*/
- public int
-putchr(c)
- int c;
+int
+putchr(int c)
{
-#if 0 /* fake UTF-8 output for testing */
- extern int utf_mode;
- if (utf_mode)
- {
- static char ubuf[MAX_UTF_CHAR_LEN];
- static int ubuf_len = 0;
- static int ubuf_index = 0;
- if (ubuf_len == 0)
- {
- ubuf_len = utf_len(c);
- ubuf_index = 0;
- }
- ubuf[ubuf_index++] = c;
- if (ubuf_index < ubuf_len)
- return c;
- c = get_wchar(ubuf) & 0xFF;
- ubuf_len = 0;
- }
-#endif
- if (need_clr)
- {
+ if (need_clr) {
need_clr = 0;
clear_bot();
}
-#if MSDOS_COMPILER
- if (c == '\n' && is_tty)
- {
- /* remove_top(1); */
- putchr('\r');
- }
-#else
-#ifdef _OSK
- if (c == '\n' && is_tty) /* In OS-9, '\n' == 0x0D */
- putchr(0x0A);
-#endif
-#endif
/*
* Some versions of flush() write to *ob, so we must flush
* when we are still one char from the end of obuf.
*/
- if (ob >= &obuf[sizeof(obuf)-1])
+ if (ob >= &obuf[sizeof (obuf)-1])
flush();
- *ob++ = c;
- at_prompt = 0;
+ *ob++ = (char)c;
return (c);
}
/*
* Output a string.
*/
- public void
-putstr(s)
- register char *s;
+void
+putstr(const char *s)
{
while (*s != '\0')
- putchr(*s++);
+ (void) putchr(*s++);
}
/*
* Convert an integral type to a string.
*/
-#define TYPE_TO_A_FUNC(funcname, type) \
-void funcname(num, buf, len) \
- type num; \
- char *buf; \
- size_t len; \
-{ \
- int neg = (num < 0); \
- char tbuf[INT_STRLEN_BOUND(num)+2]; \
- register char *s = tbuf + sizeof(tbuf); \
- if (neg) num = -num; \
- *--s = '\0'; \
- do { \
- *--s = (num % 10) + '0'; \
- } while ((num /= 10) != 0); \
- if (neg) *--s = '-'; \
- strlcpy(buf, s, len); \
+#define TYPE_TO_A_FUNC(funcname, type) \
+void \
+funcname(type num, char *buf, size_t len) \
+{ \
+ int neg = (num < 0); \
+ char tbuf[INT_STRLEN_BOUND(num)+2]; \
+ char *s = tbuf + sizeof (tbuf); \
+ if (neg) \
+ num = -num; \
+ *--s = '\0'; \
+ do { \
+ *--s = (num % 10) + '0'; \
+ } while ((num /= 10) != 0); \
+ if (neg) \
+ *--s = '-'; \
+ (void) strlcpy(buf, s, len); \
}
-TYPE_TO_A_FUNC(postoa, POSITION)
+TYPE_TO_A_FUNC(postoa, off_t)
TYPE_TO_A_FUNC(linenumtoa, LINENUM)
TYPE_TO_A_FUNC(inttoa, int)
/*
* Output an integer in a given radix.
*/
- static int
-iprint_int(num)
- int num;
+static int
+iprint_int(int num)
{
char buf[INT_STRLEN_BOUND(num)];
- inttoa(num, buf, sizeof(buf));
+ inttoa(num, buf, sizeof (buf));
putstr(buf);
return (strlen(buf));
}
@@ -436,13 +170,12 @@ iprint_int(num)
/*
* Output a line number in a given radix.
*/
- static int
-iprint_linenum(num)
- LINENUM num;
+static int
+iprint_linenum(LINENUM num)
{
char buf[INT_STRLEN_BOUND(num)];
- linenumtoa(num, buf, sizeof(buf));
+ linenumtoa(num, buf, sizeof (buf));
putstr(buf);
return (strlen(buf));
}
@@ -451,32 +184,25 @@ iprint_linenum(num)
* This function implements printf-like functionality
* using a more portable argument list mechanism than printf's.
*/
- static int
-less_printf(fmt, parg)
- register char *fmt;
- PARG *parg;
+static int
+less_printf(const char *fmt, PARG *parg)
{
register char *s;
register int col;
col = 0;
- while (*fmt != '\0')
- {
- if (*fmt != '%')
- {
- putchr(*fmt++);
+ while (*fmt != '\0') {
+ if (*fmt != '%') {
+ (void) putchr(*fmt++);
col++;
- } else
- {
+ } else {
++fmt;
- switch (*fmt++)
- {
+ switch (*fmt++) {
case 's':
s = parg->p_string;
parg++;
- while (*s != '\0')
- {
- putchr(*s++);
+ while (*s != '\0') {
+ (void) putchr(*s++);
col++;
}
break;
@@ -499,37 +225,29 @@ less_printf(fmt, parg)
* If some other non-trivial char is pressed, unget it, so it will
* become the next command.
*/
- public void
-get_return()
+void
+get_return(void)
{
int c;
-#if ONLY_RETURN
- while ((c = getchr()) != '\n' && c != '\r')
- bell();
-#else
c = getchr();
if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR)
ungetcc(c);
-#endif
}
/*
* Output a message in the lower left corner of the screen
* and wait for carriage return.
*/
- public void
-error(fmt, parg)
- char *fmt;
- PARG *parg;
+void
+error(const char *fmt, PARG *parg)
{
int col = 0;
static char return_to_continue[] = " (press RETURN)";
errmsgs++;
- if (any_display && is_tty)
- {
+ if (any_display && is_tty) {
if (!oldbot)
squish_check();
at_exit();
@@ -540,19 +258,18 @@ error(fmt, parg)
col += less_printf(fmt, parg);
- if (!(any_display && is_tty))
- {
- putchr('\n');
+ if (!(any_display && is_tty)) {
+ (void) putchr('\n');
return;
}
putstr(return_to_continue);
at_exit();
- col += sizeof(return_to_continue) + so_e_width;
+ col += sizeof (return_to_continue) + so_e_width;
get_return();
lower_left();
- clear_eol();
+ clear_eol();
if (col >= sc_width)
/*
@@ -573,10 +290,8 @@ static char intr_to_abort[] = "... (interrupt to abort)";
* Usually used to warn that we are beginning a potentially
* time-consuming operation.
*/
- public void
-ierror(fmt, parg)
- char *fmt;
- PARG *parg;
+void
+ierror(const char *fmt, PARG *parg)
{
at_exit();
clear_bot();
@@ -592,10 +307,8 @@ ierror(fmt, parg)
* Output a message in the lower left corner of the screen
* and return a single-character response.
*/
- public int
-query(fmt, parg)
- char *fmt;
- PARG *parg;
+int
+query(const char *fmt, PARG *parg)
{
register int c;
int col = 0;
@@ -606,9 +319,8 @@ query(fmt, parg)
(void) less_printf(fmt, parg);
c = getchr();
- if (!(any_display && is_tty))
- {
- putchr('\n');
+ if (!(any_display && is_tty)) {
+ (void) putchr('\n');
return (c);
}
diff --git a/usr.bin/less/pattern.c b/usr.bin/less/pattern.c
index bc346fd8bc2..aa88c43e02c 100644
--- a/usr.bin/less/pattern.c
+++ b/usr.bin/less/pattern.c
@@ -6,6 +6,10 @@
*
* For more information, see the README file.
*/
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to do pattern matching.
@@ -20,119 +24,39 @@ extern int less_is_more;
/*
* Compile a search pattern, for future use by match_pattern.
*/
- static int
-compile_pattern2(pattern, search_type, comp_pattern)
- char *pattern;
- int search_type;
- void **comp_pattern;
+static int
+compile_pattern2(char *pattern, int search_type, regex_t **comp_pattern)
{
+ regex_t *comp;
+
if (search_type & SRCH_NO_REGEX)
return (0);
- {
-#if HAVE_GNU_REGEX
- struct re_pattern_buffer *comp = (struct re_pattern_buffer *)
- ecalloc(1, sizeof(struct re_pattern_buffer));
- struct re_pattern_buffer **pcomp =
- (struct re_pattern_buffer **) comp_pattern;
- re_set_syntax(RE_SYNTAX_POSIX_EXTENDED);
- if (re_compile_pattern(pattern, strlen(pattern), comp))
- {
- free(comp);
- error("Invalid pattern", NULL_PARG);
- return (-1);
- }
- if (*pcomp != NULL)
- regfree(*pcomp);
- *pcomp = comp;
-#endif
-#if HAVE_POSIX_REGCOMP
- regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t));
- regex_t **pcomp = (regex_t **) comp_pattern;
- if (regcomp(comp, pattern, less_is_more ? 0 : REGCOMP_FLAG))
- {
+ comp = ecalloc(1, sizeof (regex_t));
+ if (regcomp(comp, pattern, less_is_more ? 0 : REGCOMP_FLAG)) {
free(comp);
error("Invalid pattern", NULL_PARG);
return (-1);
}
- if (*pcomp != NULL)
- regfree(*pcomp);
- *pcomp = comp;
-#endif
-#if HAVE_PCRE
- pcre *comp;
- pcre **pcomp = (pcre **) comp_pattern;
- constant char *errstring;
- int erroffset;
- PARG parg;
- comp = pcre_compile(pattern, 0,
- &errstring, &erroffset, NULL);
- if (comp == NULL)
- {
- parg.p_string = (char *) errstring;
- error("%s", &parg);
- return (-1);
- }
- *pcomp = comp;
-#endif
-#if HAVE_RE_COMP
- PARG parg;
- int *pcomp = (int *) comp_pattern;
- if ((parg.p_string = re_comp(pattern)) != NULL)
- {
- error("%s", &parg);
- return (-1);
- }
- *pcomp = 1;
-#endif
-#if HAVE_REGCMP
- char *comp;
- char **pcomp = (char **) comp_pattern;
- if ((comp = regcmp(pattern, 0)) == NULL)
- {
- error("Invalid pattern", NULL_PARG);
- return (-1);
- }
- if (pcomp != NULL)
- free(*pcomp);
- *pcomp = comp;
-#endif
-#if HAVE_V8_REGCOMP
- struct regexp *comp;
- struct regexp **pcomp = (struct regexp **) comp_pattern;
- if ((comp = regcomp(pattern)) == NULL)
- {
- /*
- * regcomp has already printed an error message
- * via regerror().
- */
- return (-1);
- }
- if (*pcomp != NULL)
- free(*pcomp);
- *pcomp = comp;
-#endif
- }
+ if (*comp_pattern != NULL)
+ regfree(*comp_pattern);
+ *comp_pattern = comp;
return (0);
}
/*
* Like compile_pattern2, but convert the pattern to lowercase if necessary.
*/
- public int
-compile_pattern(pattern, search_type, comp_pattern)
- char *pattern;
- int search_type;
- void **comp_pattern;
+int
+compile_pattern(char *pattern, int search_type, regex_t **comp_pattern)
{
char *cvt_pattern;
int result;
- if (caseless != OPT_ONPLUS && (caseless != OPT_ON || !less_is_more))
+ if (caseless != OPT_ONPLUS) {
cvt_pattern = pattern;
- else
- {
- cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC));
- cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC);
+ } else {
+ cvt_pattern = ecalloc(1, cvt_length(strlen(pattern)));
+ cvt_text(cvt_pattern, pattern, NULL, NULL, CVT_TO_LC);
}
result = compile_pattern2(cvt_pattern, search_type, comp_pattern);
if (cvt_pattern != pattern)
@@ -143,96 +67,40 @@ compile_pattern(pattern, search_type, comp_pattern)
/*
* Forget that we have a compiled pattern.
*/
- public void
-uncompile_pattern(pattern)
- void **pattern;
+void
+uncompile_pattern(regex_t **pattern)
{
-#if HAVE_GNU_REGEX
- struct re_pattern_buffer **pcomp = (struct re_pattern_buffer **) pattern;
- if (*pcomp != NULL)
- regfree(*pcomp);
- *pcomp = NULL;
-#endif
-#if HAVE_POSIX_REGCOMP
- regex_t **pcomp = (regex_t **) pattern;
- if (*pcomp != NULL)
- regfree(*pcomp);
- *pcomp = NULL;
-#endif
-#if HAVE_PCRE
- pcre **pcomp = (pcre **) pattern;
- if (*pcomp != NULL)
- pcre_free(*pcomp);
- *pcomp = NULL;
-#endif
-#if HAVE_RE_COMP
- int *pcomp = (int *) pattern;
- *pcomp = 0;
-#endif
-#if HAVE_REGCMP
- char **pcomp = (char **) pattern;
- if (*pcomp != NULL)
- free(*pcomp);
- *pcomp = NULL;
-#endif
-#if HAVE_V8_REGCOMP
- struct regexp **pcomp = (struct regexp **) pattern;
- if (*pcomp != NULL)
- free(*pcomp);
- *pcomp = NULL;
-#endif
+ if (*pattern != NULL)
+ regfree(*pattern);
+ *pattern = NULL;
}
/*
* Is a compiled pattern null?
*/
- public int
-is_null_pattern(pattern)
- void *pattern;
+int
+is_null_pattern(void *pattern)
{
-#if HAVE_GNU_REGEX
return (pattern == NULL);
-#endif
-#if HAVE_POSIX_REGCOMP
- return (pattern == NULL);
-#endif
-#if HAVE_PCRE
- return (pattern == NULL);
-#endif
-#if HAVE_RE_COMP
- return (pattern == 0);
-#endif
-#if HAVE_REGCMP
- return (pattern == NULL);
-#endif
-#if HAVE_V8_REGCOMP
- return (pattern == NULL);
-#endif
}
/*
* Simple pattern matching function.
* It supports no metacharacters like *, etc.
*/
- static int
-match(pattern, pattern_len, buf, buf_len, pfound, pend)
- char *pattern;
- int pattern_len;
- char *buf;
- int buf_len;
- char **pfound, **pend;
+static int
+match(char *pattern, int pattern_len, char *buf, int buf_len,
+ char **pfound, char **pend)
{
- register char *pp, *lp;
- register char *pattern_end = pattern + pattern_len;
- register char *buf_end = buf + buf_len;
+ char *pp, *lp;
+ char *pattern_end = pattern + pattern_len;
+ char *buf_end = buf + buf_len;
- for ( ; buf < buf_end; buf++)
- {
- for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++)
+ for (; buf < buf_end; buf++) {
+ for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++)
if (pp == pattern_end || lp == buf_end)
break;
- if (pp == pattern_end)
- {
+ if (pp == pattern_end) {
if (pfound != NULL)
*pfound = buf;
if (pend != NULL)
@@ -247,124 +115,31 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend)
* Perform a pattern match with the previously compiled pattern.
* Set sp and ep to the start and end of the matched string.
*/
- public int
-match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
- void *pattern;
- char *tpattern;
- char *line;
- int line_len;
- char **sp;
- char **ep;
- int notbol;
- int search_type;
+int
+match_pattern(void *pattern, char *tpattern, char *line, int line_len,
+ char **sp, char **ep, int notbol, int search_type)
{
int matched;
-#if HAVE_GNU_REGEX
- struct re_pattern_buffer *spattern = (struct re_pattern_buffer *) pattern;
-#endif
-#if HAVE_POSIX_REGCOMP
- regex_t *spattern = (regex_t *) pattern;
-#endif
-#if HAVE_PCRE
- pcre *spattern = (pcre *) pattern;
-#endif
-#if HAVE_RE_COMP
- int spattern = (int) pattern;
-#endif
-#if HAVE_REGCMP
- char *spattern = (char *) pattern;
-#endif
-#if HAVE_V8_REGCOMP
- struct regexp *spattern = (struct regexp *) pattern;
-#endif
+ regex_t *spattern = (regex_t *)pattern;
-#if NO_REGEX
- search_type |= SRCH_NO_REGEX;
-#endif
- if (search_type & SRCH_NO_REGEX)
- matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
- else
- {
-#if HAVE_GNU_REGEX
- {
- struct re_registers search_regs;
- regoff_t *starts = (regoff_t *) ecalloc(1, sizeof (regoff_t));
- regoff_t *ends = (regoff_t *) ecalloc(1, sizeof (regoff_t));
- spattern->not_bol = notbol;
- re_set_registers(spattern, &search_regs, 1, starts, ends);
- matched = re_search(spattern, line, line_len, 0, line_len, &search_regs) >= 0;
- if (matched)
- {
- *sp = line + search_regs.start[0];
- *ep = line + search_regs.end[0];
- }
- free(starts);
- free(ends);
- }
-#endif
-#if HAVE_POSIX_REGCOMP
- {
+ if (search_type & SRCH_NO_REGEX) {
+ matched = match(tpattern, strlen(tpattern), line, line_len,
+ sp, ep);
+ } else {
regmatch_t rm;
int flags = (notbol) ? REG_NOTBOL : 0;
-#ifdef REG_STARTEND
+#ifdef REG_STARTEND
flags |= REG_STARTEND;
rm.rm_so = 0;
rm.rm_eo = line_len;
#endif
matched = !regexec(spattern, line, 1, &rm, flags);
- if (matched)
- {
-#ifndef __WATCOMC__
+ if (matched) {
*sp = line + rm.rm_so;
*ep = line + rm.rm_eo;
-#else
- *sp = rm.rm_sp;
- *ep = rm.rm_ep;
-#endif
}
}
-#endif
-#if HAVE_PCRE
- {
- int flags = (notbol) ? PCRE_NOTBOL : 0;
- int ovector[3];
- matched = pcre_exec(spattern, NULL, line, line_len,
- 0, flags, ovector, 3) >= 0;
- if (matched)
- {
- *sp = line + ovector[0];
- *ep = line + ovector[1];
- }
- }
-#endif
-#if HAVE_RE_COMP
- matched = (re_exec(line) == 1);
- /*
- * re_exec doesn't seem to provide a way to get the matched string.
- */
- *sp = *ep = NULL;
-#endif
-#if HAVE_REGCMP
- *ep = regex(spattern, line);
- matched = (*ep != NULL);
- if (matched)
- *sp = __loc1;
-#endif
-#if HAVE_V8_REGCOMP
-#if HAVE_REGEXEC2
- matched = regexec2(spattern, line, notbol);
-#else
- matched = regexec(spattern, line);
-#endif
- if (matched)
- {
- *sp = spattern->startp[0];
- *ep = spattern->endp[0];
- }
-#endif
- }
matched = (!(search_type & SRCH_NO_MATCH) && matched) ||
- ((search_type & SRCH_NO_MATCH) && !matched);
+ ((search_type & SRCH_NO_MATCH) && !matched);
return (matched);
}
-
diff --git a/usr.bin/less/pattern.h b/usr.bin/less/pattern.h
index 3b44e2ddedb..80a4195f3cc 100644
--- a/usr.bin/less/pattern.h
+++ b/usr.bin/less/pattern.h
@@ -1,48 +1,17 @@
/*
- * Copyright (C) 1984-2011 Mark Nudelman
+ * Copyright (C) 1984-2012 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.
+ * For more information, see the README file.
+ */
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
*/
-#if HAVE_POSIX_REGCOMP
#include <regex.h>
-#ifdef REG_EXTENDED
#define REGCOMP_FLAG REG_EXTENDED
-#else
-#define REGCOMP_FLAG 0
-#endif
-#define DEFINE_PATTERN(name) regex_t *name
-#define CLEAR_PATTERN(name) name = NULL
-#endif
-
-#if HAVE_PCRE
-#include <pcre.h>
-#define DEFINE_PATTERN(name) pcre *name
-#define CLEAR_PATTERN(name) name = NULL
-#endif
-
-#if HAVE_RE_COMP
-char *re_comp();
-int re_exec();
-#define DEFINE_PATTERN(name) int name
-#define CLEAR_PATTERN(name) name = 0
-#endif
-
-#if HAVE_REGCMP
-char *regcmp();
-char *regex();
-extern char *__loc1;
-#define DEFINE_PATTERN(name) char *name
-#define CLEAR_PATTERN(name) name = NULL
-#endif
-
-#if HAVE_V8_REGCOMP
-#include "regexp.h"
-#define DEFINE_PATTERN(name) struct regexp *name
-#define CLEAR_PATTERN(name) name = NULL
-#endif
-
+#define DEFINE_PATTERN(name) regex_t *name
+#define CLEAR_PATTERN(name) name = NULL
diff --git a/usr.bin/less/pckeys.h b/usr.bin/less/pckeys.h
deleted file mode 100644
index 723df550f98..00000000000
--- a/usr.bin/less/pckeys.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 1984-2002 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.
- */
-
-
-/*
- * Definitions of keys on the PC.
- * Special (non-ASCII) keys on the PC send a two-byte sequence,
- * where the first byte is 0 and the second is as defined below.
- */
-#define PCK_SHIFT_TAB '\017'
-#define PCK_ALT_E '\022'
-#define PCK_CAPS_LOCK '\072'
-#define PCK_F1 '\073'
-#define PCK_NUM_LOCK '\105'
-#define PCK_HOME '\107'
-#define PCK_UP '\110'
-#define PCK_PAGEUP '\111'
-#define PCK_LEFT '\113'
-#define PCK_RIGHT '\115'
-#define PCK_END '\117'
-#define PCK_DOWN '\120'
-#define PCK_PAGEDOWN '\121'
-#define PCK_INSERT '\122'
-#define PCK_DELETE '\123'
-#define PCK_CTL_LEFT '\163'
-#define PCK_CTL_RIGHT '\164'
-#define PCK_CTL_DELETE '\223'
diff --git a/usr.bin/less/position.c b/usr.bin/less/position.c
index b655f077e3d..3aeb42bf3ed 100644
--- a/usr.bin/less/position.c
+++ b/usr.bin/less/position.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines dealing with the "position" table.
@@ -14,14 +17,14 @@
* first char on each currently displayed line.
*
* {{ The position table is scrolled by moving all the entries.
- * Would be better to have a circular table
- * and just change a couple of pointers. }}
+ * Would be better to have a circular table
+ * and just change a couple of pointers. }}
*/
#include "less.h"
#include "position.h"
-static POSITION *table = NULL; /* The position table */
+static off_t *table = NULL; /* The position table */
static int table_size;
extern int sc_width, sc_height;
@@ -35,12 +38,10 @@ extern int sc_width, sc_height;
* the bottom line on the screen
* the line after the bottom line on the screen
*/
- public POSITION
-position(where)
- int where;
+off_t
+position(int where)
{
- switch (where)
- {
+ switch (where) {
case BOTTOM:
where = sc_height - 2;
break;
@@ -56,11 +57,10 @@ position(where)
/*
* Add a new file position to the bottom of the position table.
*/
- public void
-add_forw_pos(pos)
- POSITION pos;
+void
+add_forw_pos(off_t pos)
{
- register int i;
+ int i;
/*
* Scroll the position table up.
@@ -73,11 +73,10 @@ add_forw_pos(pos)
/*
* Add a new file position to the top of the position table.
*/
- public void
-add_back_pos(pos)
- POSITION pos;
+void
+add_back_pos(off_t pos)
{
- register int i;
+ int i;
/*
* Scroll the position table down.
@@ -90,20 +89,20 @@ add_back_pos(pos)
/*
* Initialize the position table, done whenever we clear the screen.
*/
- public void
-pos_clear()
+void
+pos_clear(void)
{
- register int i;
+ int i;
for (i = 0; i < sc_height; i++)
- table[i] = NULL_POSITION;
+ table[i] = -1;
}
/*
* Allocate or reallocate the position table.
*/
- public void
-pos_init()
+void
+pos_init(void)
{
struct scrpos scrpos;
@@ -113,16 +112,16 @@ pos_init()
* If we already have a table, remember the first line in it
* before we free it, so we can copy that line to the new table.
*/
- if (table != NULL)
- {
+ if (table != NULL) {
get_scrpos(&scrpos);
- free((char*)table);
- } else
- scrpos.pos = NULL_POSITION;
- table = (POSITION *) ecalloc(sc_height, sizeof(POSITION));
+ free(table);
+ } else {
+ scrpos.pos = -1;
+ }
+ table = ecalloc(sc_height, sizeof (off_t));
table_size = sc_height;
pos_clear();
- if (scrpos.pos != NULL_POSITION)
+ if (scrpos.pos != -1)
table[scrpos.ln-1] = scrpos.pos;
}
@@ -131,9 +130,8 @@ pos_init()
* Check the position table to see if the position falls within its range.
* Return the position table entry if found, -1 if not.
*/
- public int
-onscreen(pos)
- POSITION pos;
+int
+onscreen(off_t pos)
{
register int i;
@@ -148,21 +146,19 @@ onscreen(pos)
/*
* See if the entire screen is empty.
*/
- public int
-empty_screen()
+int
+empty_screen(void)
{
return (empty_lines(0, sc_height-1));
}
- public int
-empty_lines(s, e)
- int s;
- int e;
+int
+empty_lines(int s, int e)
{
- register int i;
+ int i;
for (i = s; i <= e; i++)
- if (table[i] != NULL_POSITION && table[i] != 0)
+ if (table[i] != -1 && table[i] != 0)
return (0);
return (1);
}
@@ -175,19 +171,17 @@ empty_lines(s, e)
* such that the top few lines are empty, we may have to set
* the screen line to a number > 0.
*/
- public void
-get_scrpos(scrpos)
- struct scrpos *scrpos;
+void
+get_scrpos(struct scrpos *scrpos)
{
- register int i;
+ int i;
/*
* Find the first line on the screen which has something on it,
* and return the screen line number and the file position.
*/
for (i = 0; i < sc_height; i++)
- if (table[i] != NULL_POSITION)
- {
+ if (table[i] != -1) {
scrpos->ln = i+1;
scrpos->pos = table[i];
return;
@@ -195,7 +189,7 @@ get_scrpos(scrpos)
/*
* The screen is empty.
*/
- scrpos->pos = NULL_POSITION;
+ scrpos->pos = -1;
}
/*
@@ -207,9 +201,8 @@ get_scrpos(scrpos)
* or it may be in { -1 .. -(sc_height-1) } to refer to lines
* relative to the bottom of the screen.
*/
- public int
-adjsline(sline)
- int sline;
+int
+adjsline(int sline)
{
/*
* Negative screen line number means
diff --git a/usr.bin/less/position.h b/usr.bin/less/position.h
index 3b96637067e..3e42cc73c27 100644
--- a/usr.bin/less/position.h
+++ b/usr.bin/less/position.h
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Include file for interfacing to position.c modules.
diff --git a/usr.bin/less/prompt.c b/usr.bin/less/prompt.c
index fc02de3ef8e..0b5b25a13ed 100644
--- a/usr.bin/less/prompt.c
+++ b/usr.bin/less/prompt.c
@@ -6,14 +6,17 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Prompting and other messages.
* There are three flavors of prompts, SHORT, MEDIUM and LONG,
* selected by the -m/-M options.
* There is also the "equals message", printed by the = command.
- * A prompt is a message composed of various pieces, such as the
+ * A prompt is a message composed of various pieces, such as the
* name of the file being viewed, the percentage into the file, etc.
*/
@@ -30,32 +33,40 @@ extern int sc_height;
extern int jump_sline;
extern int less_is_more;
extern IFILE curr_ifile;
-#if EDITOR
extern char *editor;
extern char *editproto;
-#endif
/*
* Prototypes for the three flavors of prompts.
* These strings are expanded by pr_expand().
*/
-static constant char s_proto[] =
- "?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\\: %x..%t";
-static constant char m_proto[] =
- "?f%f .?m(%T %i of %m) .?e(END) ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t";
-static constant char M_proto[] =
- "?f%f .?n?m(%T %i of %m) ..?ltlines %lt-%lb?L/%L. :byte %bB?s/%s. .?e(END) ?x- Next\\: %x.:?pB%pB\\%..%t";
-static constant char e_proto[] =
- "?f%f .?m(%T %i of %m) .?ltlines %lt-%lb?L/%L. .byte %bB?s/%s. ?e(END) :?pB%pB\\%..%t";
-static constant char h_proto[] =
- "HELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done";
-static constant char w_proto[] =
- "Waiting for data";
-
-public char *prproto[3];
-public char constant *eqproto = e_proto;
-public char constant *hproto = h_proto;
-public char constant *wproto = w_proto;
+static const char s_proto[] =
+ "?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\\: %x..%t";
+static const char m_proto[] =
+ "?n?f%f .?m(%T %i of %m) ..?e(END) "
+ "?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t";
+static const char M_proto[] =
+ "?f%f .?n?m(%T %i of %m) ..?"
+ "ltlines %lt-%lb?L/%L. :byte %bB?s/%s. .?e(END)"
+ " ?x- Next\\: %x.:?pB%pB\\%..%t";
+static const char e_proto[] =
+ "?f%f .?m(%T %i of %m) .?ltlines "
+ "%lt-%lb?L/%L. .byte %bB?s/%s. ?e(END) :?pB%pB\\%..%t";
+static const char h_proto[] =
+ "HELP -- ?eEND -- Press g to see it again:"
+ "Press RETURN for more., or q when done";
+static const char w_proto[] =
+ "Waiting for data";
+static const char more_proto[] =
+ "%f (?eEND ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t)";
+static const char more_M_proto[] =
+ "%f (?eEND ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t)"
+ "[Press space to continue, q to quit, h for help]";
+
+char *prproto[3];
+char const *eqproto = e_proto;
+char const *hproto = h_proto;
+char const *wproto = w_proto;
static char message[PROMPT_SIZE];
static char *mp;
@@ -63,12 +74,12 @@ static char *mp;
/*
* Initialize the prompt prototype strings.
*/
- public void
-init_prompt()
+void
+init_prompt(void)
{
prproto[0] = save(s_proto);
- prproto[1] = save(m_proto);
- prproto[2] = save(M_proto);
+ prproto[1] = save(less_is_more ? more_proto : m_proto);
+ prproto[2] = save(less_is_more ? more_M_proto : M_proto);
eqproto = save(e_proto);
hproto = save(h_proto);
wproto = save(w_proto);
@@ -77,16 +88,15 @@ init_prompt()
/*
* Append a string to the end of the message.
*/
- static void
-ap_str(s)
- char *s;
+static void
+ap_str(char *s)
{
int len;
len = strlen(s);
if (mp + len >= message + PROMPT_SIZE)
len = message + PROMPT_SIZE - mp - 1;
- strncpy(mp, s, len);
+ (void) strncpy(mp, s, len);
mp += len;
*mp = '\0';
}
@@ -94,9 +104,8 @@ ap_str(s)
/*
* Append a character to the end of the message.
*/
- static void
-ap_char(c)
- char c;
+static void
+ap_char(char c)
{
char buf[2];
@@ -106,49 +115,46 @@ ap_char(c)
}
/*
- * Append a POSITION (as a decimal integer) to the end of the message.
+ * Append a off_t (as a decimal integer) to the end of the message.
*/
- static void
-ap_pos(pos)
- POSITION pos;
+static void
+ap_pos(off_t pos)
{
char buf[INT_STRLEN_BOUND(pos) + 2];
- postoa(pos, buf, sizeof(buf));
+ postoa(pos, buf, sizeof buf);
ap_str(buf);
}
/*
* Append a line number to the end of the message.
*/
- static void
-ap_linenum(linenum)
- LINENUM linenum;
+static void
+ap_linenum(LINENUM linenum)
{
char buf[INT_STRLEN_BOUND(linenum) + 2];
- linenumtoa(linenum, buf, sizeof(buf));
+ linenumtoa(linenum, buf, sizeof buf);
ap_str(buf);
}
/*
* Append an integer to the end of the message.
*/
- static void
-ap_int(num)
- int num;
+static void
+ap_int(int num)
{
char buf[INT_STRLEN_BOUND(num) + 2];
- inttoa(num, buf, sizeof(buf));
+ inttoa(num, buf, sizeof buf);
ap_str(buf);
}
/*
* Append a question mark to the end of the message.
*/
- static void
-ap_quest()
+static void
+ap_quest(void)
{
ap_str("?");
}
@@ -156,39 +162,35 @@ ap_quest()
/*
* Return the "current" byte offset in the file.
*/
- static POSITION
-curr_byte(where)
- int where;
+static off_t
+curr_byte(int where)
{
- POSITION pos;
+ off_t pos;
pos = position(where);
- while (pos == NULL_POSITION && where >= 0 && where < sc_height-1)
+ while (pos == -1 && where >= 0 && where < sc_height-1)
pos = position(++where);
- if (pos == NULL_POSITION)
+ if (pos == -1)
pos = ch_length();
return (pos);
}
/*
* Return the value of a prototype conditional.
- * A prototype string may include conditionals which consist of a
+ * A prototype string may include conditionals which consist of a
* question mark followed by a single letter.
* Here we decode that letter and return the appropriate boolean value.
*/
- static int
-cond(c, where)
- char c;
- int where;
+static int
+cond(char c, int where)
{
- POSITION len;
+ off_t len;
- switch (c)
- {
+ switch (c) {
case 'a': /* Anything in the message yet? */
return (mp > message);
case 'b': /* Current byte offset known? */
- return (curr_byte(where) != NULL_POSITION);
+ return (curr_byte(where) != -1);
case 'c':
return (hshift != 0);
case 'e': /* At end of file? */
@@ -200,34 +202,22 @@ cond(c, where)
return (linenums);
case 'L': /* Final line number known? */
case 'D': /* Final page number known? */
- return (linenums && ch_length() != NULL_POSITION);
+ return (linenums && ch_length() != -1);
case 'm': /* More than one file? */
-#if TAGS
return (ntags() ? (ntags() > 1) : (nifile() > 1));
-#else
- return (nifile() > 1);
-#endif
case 'n': /* First prompt in a new file? */
-#if TAGS
return (ntags() ? 1 : new_file);
-#else
- return (new_file);
-#endif
case 'p': /* Percent into file (bytes) known? */
- return (curr_byte(where) != NULL_POSITION &&
- ch_length() > 0);
+ return (curr_byte(where) != -1 && ch_length() > 0);
case 'P': /* Percent into file (lines) known? */
return (currline(where) != 0 &&
- (len = ch_length()) > 0 &&
- find_linenum(len) != 0);
+ (len = ch_length()) > 0 && find_linenum(len) != 0);
case 's': /* Size of file known? */
case 'B':
- return (ch_length() != NULL_POSITION);
+ return (ch_length() != -1);
case 'x': /* Is there a "next" file? */
-#if TAGS
if (ntags())
return (0);
-#endif
return (next_ifile(curr_ifile) != NULL_IFILE);
}
return (0);
@@ -240,27 +230,23 @@ cond(c, where)
* Here we decode that letter and take the appropriate action,
* usually by appending something to the message being built.
*/
- static void
-protochar(c, where, iseditproto)
- int c;
- int where;
- int iseditproto;
+static void
+protochar(int c, int where)
{
- POSITION pos;
- POSITION len;
+ off_t pos;
+ off_t len;
int n;
LINENUM linenum;
LINENUM last_linenum;
IFILE h;
-#undef PAGE_NUM
-#define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1)
+#undef PAGE_NUM
+#define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1)
- switch (c)
- {
+ switch (c) {
case 'b': /* Current byte offset */
pos = curr_byte(where);
- if (pos != NULL_POSITION)
+ if (pos != -1)
ap_pos(pos);
else
ap_quest();
@@ -278,25 +264,22 @@ protochar(c, where, iseditproto)
case 'D': /* Final page number */
/* Find the page number of the last byte in the file (len-1). */
len = ch_length();
- if (len == NULL_POSITION)
+ if (len == -1) {
ap_quest();
- else if (len == 0)
+ } else if (len == 0) {
/* An empty file has no pages. */
ap_linenum(0);
- else
- {
+ } else {
linenum = find_linenum(len - 1);
if (linenum <= 0)
ap_quest();
- else
+ else
ap_linenum(PAGE_NUM(linenum));
}
break;
-#if EDITOR
case 'E': /* Editor name */
ap_str(editor);
break;
-#endif
case 'f': /* File name */
ap_str(get_filename(curr_ifile));
break;
@@ -304,11 +287,9 @@ protochar(c, where, iseditproto)
ap_str(last_component(get_filename(curr_ifile)));
break;
case 'i': /* Index into list of files */
-#if TAGS
if (ntags())
ap_int(curr_tag());
else
-#endif
ap_int(get_index(curr_ifile));
break;
case 'l': /* Current line number */
@@ -320,33 +301,31 @@ protochar(c, where, iseditproto)
break;
case 'L': /* Final line number */
len = ch_length();
- if (len == NULL_POSITION || len == ch_zero() ||
+ if (len == -1 || len == ch_zero() ||
(linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_linenum(linenum-1);
break;
case 'm': /* Number of files */
-#if TAGS
n = ntags();
if (n)
ap_int(n);
else
-#endif
ap_int(nifile());
break;
case 'p': /* Percent into file (bytes) */
pos = curr_byte(where);
len = ch_length();
- if (pos != NULL_POSITION && len > 0)
- ap_int(percentage(pos,len));
+ if (pos != -1 && len > 0)
+ ap_int(percentage(pos, len));
else
ap_quest();
break;
case 'P': /* Percent into file (lines) */
linenum = currline(where);
if (linenum == 0 ||
- (len = ch_length()) == NULL_POSITION || len == ch_zero() ||
+ (len = ch_length()) == -1 || len == ch_zero() ||
(last_linenum = find_linenum(len)) <= 0)
ap_quest();
else
@@ -355,7 +334,7 @@ protochar(c, where, iseditproto)
case 's': /* Size of file */
case 'B':
len = ch_length();
- if (len != NULL_POSITION)
+ if (len != -1)
ap_pos(len);
else
ap_quest();
@@ -366,11 +345,9 @@ protochar(c, where, iseditproto)
*mp = '\0';
break;
case 'T': /* Type of list */
-#if TAGS
if (ntags())
ap_str("tag");
else
-#endif
ap_str("file");
break;
case 'x': /* Name of next file */
@@ -385,16 +362,15 @@ protochar(c, where, iseditproto)
/*
* Skip a false conditional.
- * When a false condition is found (either a false IF or the ELSE part
+ * When a false condition is found (either a false IF or the ELSE part
* of a true IF), this routine scans the prototype string to decide
* where to resume parsing the string.
* We must keep track of nested IFs and skip them properly.
*/
- static constant char *
-skipcond(p)
- register constant char *p;
+static const char *
+skipcond(const char *p)
{
- register int iflevel;
+ int iflevel;
/*
* We came in here after processing a ? or :,
@@ -402,45 +378,46 @@ skipcond(p)
*/
iflevel = 1;
- for (;;) switch (*++p)
- {
- case '?':
- /*
- * Start of a nested IF.
- */
- iflevel++;
- break;
- case ':':
- /*
- * Else.
- * If this matches the IF we came in here with,
- * then we're done.
- */
- if (iflevel == 1)
- return (p);
- break;
- case '.':
- /*
- * Endif.
- * If this matches the IF we came in here with,
- * then we're done.
- */
- if (--iflevel == 0)
- return (p);
- break;
- case '\\':
- /*
- * Backslash escapes the next character.
- */
- ++p;
- break;
- case '\0':
- /*
- * Whoops. Hit end of string.
- * This is a malformed conditional, but just treat it
- * as if all active conditionals ends here.
- */
- return (p-1);
+ for (;;) {
+ switch (*++p) {
+ case '?':
+ /*
+ * Start of a nested IF.
+ */
+ iflevel++;
+ break;
+ case ':':
+ /*
+ * Else.
+ * If this matches the IF we came in here with,
+ * then we're done.
+ */
+ if (iflevel == 1)
+ return (p);
+ break;
+ case '.':
+ /*
+ * Endif.
+ * If this matches the IF we came in here with,
+ * then we're done.
+ */
+ if (--iflevel == 0)
+ return (p);
+ break;
+ case '\\':
+ /*
+ * Backslash escapes the next character.
+ */
+ ++p;
+ break;
+ case '\0':
+ /*
+ * Whoops. Hit end of string.
+ * This is a malformed conditional, but just treat it
+ * as if all active conditionals ends here.
+ */
+ return (p-1);
+ }
}
/*NOTREACHED*/
}
@@ -448,16 +425,12 @@ skipcond(p)
/*
* Decode a char that represents a position on the screen.
*/
- static constant char *
-wherechar(p, wp)
- char constant *p;
- int *wp;
+static const char *
+wherechar(const char *p, int *wp)
{
- switch (*p)
- {
+ switch (*p) {
case 'b': case 'd': case 'l': case 'p': case 'P':
- switch (*++p)
- {
+ switch (*++p) {
case 't': *wp = TOP; break;
case 'm': *wp = MIDDLE; break;
case 'b': *wp = BOTTOM; break;
@@ -472,13 +445,11 @@ wherechar(p, wp)
/*
* Construct a message based on a prototype string.
*/
- public char *
-pr_expand(proto, maxwidth)
- constant char *proto;
- int maxwidth;
+char *
+pr_expand(const char *proto, int maxwidth)
{
- register constant char *p;
- register int c;
+ const char *p;
+ int c;
int where;
mp = message;
@@ -486,10 +457,8 @@ pr_expand(proto, maxwidth)
if (*proto == '\0')
return ("");
- for (p = proto; *p != '\0'; p++)
- {
- switch (*p)
- {
+ for (p = proto; *p != '\0'; p++) {
+ switch (*p) {
default: /* Just put the character in the message */
ap_char(*p);
break;
@@ -498,10 +467,9 @@ pr_expand(proto, maxwidth)
ap_char(*p);
break;
case '?': /* Conditional (IF) */
- if ((c = *++p) == '\0')
+ if ((c = *++p) == '\0') {
--p;
- else
- {
+ } else {
where = 0;
p = wherechar(p, &where);
if (!cond(c, where))
@@ -514,19 +482,12 @@ pr_expand(proto, maxwidth)
case '.': /* ENDIF */
break;
case '%': /* Percent escape */
- if ((c = *++p) == '\0')
+ if ((c = *++p) == '\0') {
--p;
- else
- {
+ } else {
where = 0;
p = wherechar(p, &where);
- protochar(c, where,
-#if EDITOR
- (proto == editproto));
-#else
- 0);
-#endif
-
+ protochar(c, where);
}
break;
}
@@ -534,8 +495,7 @@ pr_expand(proto, maxwidth)
if (mp == message)
return ("");
- if (maxwidth > 0 && mp >= message + maxwidth)
- {
+ if (maxwidth > 0 && mp >= message + maxwidth) {
/*
* Message is too long.
* Return just the final portion of it.
@@ -548,8 +508,8 @@ pr_expand(proto, maxwidth)
/*
* Return a message suitable for printing by the "=" command.
*/
- public char *
-eq_message()
+char *
+eq_message(void)
{
return (pr_expand(eqproto, 0));
}
@@ -560,16 +520,15 @@ eq_message()
* If we can't come up with an appropriate prompt, return NULL
* and the caller will prompt with a colon.
*/
- public char *
-pr_string()
+char *
+prompt_string(void)
{
char *prompt;
int type;
- type = (!less_is_more) ? pr_type : pr_type ? 0 : 1;
+ type = pr_type;
prompt = pr_expand((ch_getflags() & CH_HELPFILE) ?
- hproto : prproto[type],
- sc_width-so_s_width-so_e_width-2);
+ hproto : prproto[type], sc_width-so_s_width-so_e_width-2);
new_file = 0;
return (prompt);
}
@@ -577,8 +536,8 @@ pr_string()
/*
* Return a message suitable for printing while waiting in the F command.
*/
- public char *
-wait_message()
+char *
+wait_message(void)
{
return (pr_expand(wproto, sc_width-so_s_width-so_e_width-2));
}
diff --git a/usr.bin/less/regexp.c b/usr.bin/less/regexp.c
deleted file mode 100644
index 9fd72e1991d..00000000000
--- a/usr.bin/less/regexp.c
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
- * regcomp and regexec -- regsub and regerror are elsewhere
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- *
- * *** NOTE: this code has been altered slightly for use in Tcl. ***
- * Slightly modified by David MacKenzie to undo most of the changes for TCL.
- * Added regexec2 with notbol parameter. -- 4/19/99 Mark Nudelman
- */
-
-#include "less.h"
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-#include "regexp.h"
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that regcomp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in regexec() needs it and regcomp() is
- * computing it anyway.
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "next" pointer, possibly plus an operand. "Next" pointers of
- * all nodes except BRANCH implement concatenation; a "next" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#undef EOL
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this string. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define OPEN 20 /* no Mark this point in input as start of #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE 30 /* no Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-/*
- * A node is one char of opcode followed by two chars of "next" pointer.
- * "Next" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "next" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- */
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
-
-/*
- * See regmagic.h for one further detail of program structure.
- */
-
-
-/*
- * Utility definitions.
- */
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-
-#define FAIL(m) { regerror(m); return(NULL); }
-#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
-#define META "^$.[()|?+*\\"
-
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
-
-/*
- * Global work variables for regcomp().
- */
-static char *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
-static char regdummy;
-static char *regcode; /* Code-emit pointer; &regdummy = don't. */
-static long regsize; /* Code size. */
-
-/*
- * The first byte of the regexp internal "program" is actually this magic
- * number; the start node begins in the second byte.
- */
-#define MAGIC 0234
-
-
-/*
- * Forward declarations for regcomp()'s friends.
- */
-#ifndef STATIC
-#define STATIC static
-#endif
-STATIC char *reg();
-STATIC char *regbranch();
-STATIC char *regpiece();
-STATIC char *regatom();
-STATIC char *regnode();
-STATIC char *regnext();
-STATIC void regc();
-STATIC void reginsert();
-STATIC void regtail();
-STATIC void regoptail();
-#ifdef STRCSPN
-STATIC int strcspn();
-#endif
-
-/*
- - regcomp - compile a regular expression into internal code
- *
- * We can't allocate space until we know how big the compiled form will be,
- * but we can't compile it (and thus know how big it is) until we've got a
- * place to put the code. So we cheat: we compile it twice, once with code
- * generation turned off and size counting turned on, and once "for real".
- * This also means that we don't allocate space until we are sure that the
- * thing really will compile successfully, and we never have to move the
- * code and thus invalidate pointers into it. (Note that it has to be in
- * one piece because free() must be able to free it all.)
- *
- * Beware that the optimization-preparation code in here knows about some
- * of the structure of the compiled regexp.
- */
-regexp *
-regcomp(exp)
-char *exp;
-{
- register regexp *r;
- register char *scan;
- register char *longest;
- register int len;
- int flags;
-
- if (exp == NULL)
- FAIL("NULL argument");
-
- /* First pass: determine size, legality. */
- regparse = exp;
- regnpar = 1;
- regsize = 0L;
- regcode = &regdummy;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Small enough for pointer-storage convention? */
- if (regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize);
- if (r == NULL)
- FAIL("out of space");
-
- /* Second pass: emit code. */
- regparse = exp;
- regnpar = 1;
- regcode = r->program;
- regc(MAGIC);
- if (reg(0, &flags) == NULL) {
- free(r);
- return(NULL);
- }
-
- /* Dig out information for optimizations. */
- r->regstart = '\0'; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = NULL;
- r->regmlen = 0;
- scan = r->program+1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
- scan = OPERAND(scan);
-
- /* Starting-point info. */
- if (OP(scan) == EXACTLY)
- r->regstart = *OPERAND(scan);
- else if (OP(scan) == BOL)
- r->reganch++;
-
- /*
- * If there's something expensive in the r.e., find the
- * longest literal string that must appear and make it the
- * regmust. Resolve ties in favor of later strings, since
- * the regstart check works with the beginning of the r.e.
- * and avoiding duplication strengthens checking. Not a
- * strong reason, but sufficient in the absence of others.
- */
- if (flags&SPSTART) {
- longest = NULL;
- len = 0;
- for (; scan != NULL; scan = regnext(scan))
- if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
- longest = OPERAND(scan);
- len = strlen(OPERAND(scan));
- }
- r->regmust = longest;
- r->regmlen = len;
- }
- }
-
- return(r);
-}
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *
-reg(paren, flagp)
-int paren; /* Parenthesized? */
-int *flagp;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno = 0;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = regnpar;
- regnpar++;
- ret = regnode(OPEN+parno);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*regparse == '|') {
- regparse++;
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE+parno : END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != ')') {
- FAIL("unmatched ()");
- } else if (!paren && *regparse != '\0') {
- if (*regparse == ')') {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end"); /* "Can't happen". */
- /* NOTREACHED */
- }
-
- return(ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *
-regbranch(flagp)
-int *flagp;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = NULL;
- while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
- latest = regpiece(&flags);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING);
-
- return(ret);
-}
-
-/*
- - regpiece - something followed by possible [*+?]
- *
- * Note that the branching code sequences used for ? and the general cases
- * of * and + are somewhat optimized: they use the same NOTHING node as
- * both the endmarker for their branch list and the body of the last branch.
- * It might seem that this node could be dispensed with entirely, but the
- * endmarker role is not redundant.
- */
-static char *
-regpiece(flagp)
-int *flagp;
-{
- register char *ret;
- register char op;
- register char *next;
- int flags;
-
- ret = regatom(&flags);
- if (ret == NULL)
- return(NULL);
-
- op = *regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("*+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- regparse++;
- if (ISMULT(*regparse))
- FAIL("nested *?+");
-
- return(ret);
-}
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run. Backslashed characters are exceptions, each becoming a
- * separate node; the code is simpler that way and it's not worth fixing.
- */
-static char *
-regatom(flagp)
-int *flagp;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*regparse++) {
- case '^':
- ret = regnode(BOL);
- break;
- case '$':
- ret = regnode(EOL);
- break;
- case '.':
- ret = regnode(ANY);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[': {
- register int clss;
- register int classend;
-
- if (*regparse == '^') { /* Complement of range. */
- ret = regnode(ANYBUT);
- regparse++;
- } else
- ret = regnode(ANYOF);
- if (*regparse == ']' || *regparse == '-')
- regc(*regparse++);
- while (*regparse != '\0' && *regparse != ']') {
- if (*regparse == '-') {
- regparse++;
- if (*regparse == ']' || *regparse == '\0')
- regc('-');
- else {
- clss = UCHARAT(regparse-2)+1;
- classend = UCHARAT(regparse);
- if (clss > classend+1)
- FAIL("invalid [] range");
- for (; clss <= classend; clss++)
- regc(clss);
- regparse++;
- }
- } else
- regc(*regparse++);
- }
- regc('\0');
- if (*regparse != ']')
- FAIL("unmatched []");
- regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- }
- break;
- case '(':
- ret = reg(1, &flags);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '\0':
- case '|':
- case ')':
- FAIL("internal urp"); /* Supposed to be caught earlier. */
- /* NOTREACHED */
- break;
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing");
- /* NOTREACHED */
- break;
- case '\\':
- if (*regparse == '\0')
- FAIL("trailing \\");
- ret = regnode(EXACTLY);
- regc(*regparse++);
- regc('\0');
- *flagp |= HASWIDTH|SIMPLE;
- break;
- default: {
- register int len;
- register char ender;
-
- regparse--;
- len = strcspn(regparse, META);
- if (len <= 0)
- FAIL("internal disaster");
- ender = *(regparse+len);
- if (len > 1 && ISMULT(ender))
- len--; /* Back off clear of ?+* operand. */
- *flagp |= HASWIDTH;
- if (len == 1)
- *flagp |= SIMPLE;
- ret = regnode(EXACTLY);
- while (len > 0) {
- regc(*regparse++);
- len--;
- }
- regc('\0');
- }
- break;
- }
-
- return(ret);
-}
-
-/*
- - regnode - emit a node
- */
-static char * /* Location. */
-regnode(op)
-char op;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == &regdummy) {
- regsize += 3;
- return(ret);
- }
-
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
-
- return(ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void
-regc(b)
-char b;
-{
- if (regcode != &regdummy)
- *regcode++ = b;
- else
- regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void
-reginsert(op, opnd)
-char op;
-char *opnd;
-{
- register char *src;
- register char *dst;
- register char *place;
-
- if (regcode == &regdummy) {
- regsize += 3;
- return;
- }
-
- src = regcode;
- regcode += 3;
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = op;
- *place++ = '\0';
- *place++ = '\0';
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void
-regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == &regdummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (offset>>8)&0377;
- *(scan+2) = offset&0377;
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void
-regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == &regdummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
-}
-
-/*
- * regexec and friends
- */
-
-/*
- * Global work variables for regexec().
- */
-static char *reginput; /* String-input pointer. */
-static char *regbol; /* Beginning of input, for ^ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
-
-/*
- * Forwards.
- */
-STATIC int regtry();
-STATIC int regmatch();
-STATIC int regrepeat();
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump();
-STATIC char *regprop();
-#endif
-
-/*
- - regexec - match a regexp against a string
- */
-int
-regexec2(prog, string, notbol)
-register regexp *prog;
-register char *string;
-int notbol;
-{
- register char *s;
-
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- regerror("NULL parameter");
- return(0);
- }
-
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("corrupted program");
- return(0);
- }
-
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != NULL) {
- s = string;
- while ((s = strchr(s, prog->regmust[0])) != NULL) {
- if (strncmp(s, prog->regmust, prog->regmlen) == 0)
- break; /* Found it. */
- s++;
- }
- if (s == NULL) /* Not present. */
- return(0);
- }
-
- /* Mark beginning of line for ^ . */
- if (notbol)
- regbol = NULL;
- else
- regbol = string;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch)
- return(regtry(prog, string));
-
- /* Messy cases: unanchored match. */
- s = string;
- if (prog->regstart != '\0')
- /* We know what char it must start with. */
- while ((s = strchr(s, prog->regstart)) != NULL) {
- if (regtry(prog, s))
- return(1);
- s++;
- }
- else
- /* We don't -- general case. */
- do {
- if (regtry(prog, s))
- return(1);
- } while (*s++ != '\0');
-
- /* Failure. */
- return(0);
-}
-
-int
-regexec(prog, string)
-register regexp *prog;
-register char *string;
-{
- return regexec2(prog, string, 0);
-}
-
-/*
- - regtry - try match at specific point
- */
-static int /* 0 failure, 1 success */
-regtry(prog, string)
-regexp *prog;
-char *string;
-{
- register int i;
- register char **sp;
- register char **ep;
-
- reginput = string;
- regstartp = prog->startp;
- regendp = prog->endp;
-
- sp = prog->startp;
- ep = prog->endp;
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- if (regmatch(prog->program + 1)) {
- prog->startp[0] = string;
- prog->endp[0] = reginput;
- return(1);
- } else
- return(0);
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-static int /* 0 failure, 1 success */
-regmatch(prog)
-char *prog;
-{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
-
- scan = prog;
-#ifdef DEBUG
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != NULL) {
-#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
- next = regnext(scan);
-
- switch (OP(scan)) {
- case BOL:
- if (reginput != regbol)
- return(0);
- break;
- case EOL:
- if (*reginput != '\0')
- return(0);
- break;
- case ANY:
- if (*reginput == '\0')
- return(0);
- reginput++;
- break;
- case EXACTLY: {
- register int len;
- register char *opnd;
-
- opnd = OPERAND(scan);
- /* Inline the first character, for speed. */
- if (*opnd != *reginput)
- return(0);
- len = strlen(opnd);
- if (len > 1 && strncmp(opnd, reginput, len) != 0)
- return(0);
- reginput += len;
- }
- break;
- case ANYOF:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
- return(0);
- reginput++;
- break;
- case ANYBUT:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
- return(0);
- reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - OPEN;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set startp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regstartp[no] == NULL)
- regstartp[no] = save;
- return(1);
- } else
- return(0);
- }
- /* NOTREACHED */
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - CLOSE;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regendp[no] == NULL)
- regendp[no] = save;
- return(1);
- } else
- return(0);
- }
- /* NOTREACHED */
- break;
- case BRANCH: {
- register char *save;
-
- if (OP(next) != BRANCH) /* No choice. */
- next = OPERAND(scan); /* Avoid recursion. */
- else {
- do {
- save = reginput;
- if (regmatch(OPERAND(scan)))
- return(1);
- reginput = save;
- scan = regnext(scan);
- } while (scan != NULL && OP(scan) == BRANCH);
- return(0);
- /* NOTREACHED */
- }
- }
- /* NOTREACHED */
- break;
- case STAR:
- case PLUS: {
- register char nextch;
- register int no;
- register char *save;
- register int min;
-
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- nextch = '\0';
- if (OP(next) == EXACTLY)
- nextch = *OPERAND(next);
- min = (OP(scan) == STAR) ? 0 : 1;
- save = reginput;
- no = regrepeat(OPERAND(scan));
- while (no >= min) {
- /* If it could work, try it. */
- if (nextch == '\0' || *reginput == nextch)
- if (regmatch(next))
- return(1);
- /* Couldn't or didn't -- back up. */
- no--;
- reginput = save + no;
- }
- return(0);
- }
- /* NOTREACHED */
- break;
- case END:
- return(1); /* Success! */
- /* NOTREACHED */
- break;
- default:
- regerror("memory corruption");
- return(0);
- /* NOTREACHED */
- break;
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- regerror("corrupted pointers");
- return(0);
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-static int
-regrepeat(p)
-char *p;
-{
- register int count = 0;
- register char *scan;
- register char *opnd;
-
- scan = reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- regerror("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- reginput = scan;
-
- return(count);
-}
-
-/*
- - regnext - dig the "next" pointer out of a node
- */
-static char *
-regnext(p)
-register char *p;
-{
- register int offset;
-
- if (p == &regdummy)
- return(NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
-}
-
-#ifdef DEBUG
-
-STATIC char *regprop();
-
-/*
- - regdump - dump a regexp onto stdout in vaguely comprehensible form
- */
-void
-regdump(r)
-regexp *r;
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- if (next == NULL) /* Next ptr. */
- printf("(0)");
- else
- printf("(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-static char *
-regprop(op)
-char *op;
-{
- register char *p;
- static char buf[50];
-
- (void) strlcpy(buf, ":", sizeof(buf));
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9:
- snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf),
- "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9:
- snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf),
- "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- default:
- regerror("corrupted opcode");
- break;
- }
- if (p != NULL)
- (void) strlcat(buf, p, sizeof(buf));
- return(buf);
-}
-#endif
-
-/*
- * The following is provided for those people who do not have strcspn() in
- * their C libraries. They should get off their butts and do something
- * about it; at least one public-domain implementation of those (highly
- * useful) string routines has been published on Usenet.
- */
-#ifdef STRCSPN
-/*
- * strcspn - find length of initial segment of s1 consisting entirely
- * of characters not from s2
- */
-
-static int
-strcspn(s1, s2)
-char *s1;
-char *s2;
-{
- register char *scan1;
- register char *scan2;
- register int count;
-
- count = 0;
- for (scan1 = s1; *scan1 != '\0'; scan1++) {
- for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
- if (*scan1 == *scan2++)
- return(count);
- count++;
- }
- return(count);
-}
-#endif
diff --git a/usr.bin/less/regexp.h b/usr.bin/less/regexp.h
deleted file mode 100644
index bcef6d1ebc7..00000000000
--- a/usr.bin/less/regexp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Definitions etc. for regexp(3) routines.
- *
- * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
- * not the System V one.
- */
-
-#ifndef _REGEXP
-#define _REGEXP 1
-
-#define NSUBEXP 10
-typedef struct regexp {
- char *startp[NSUBEXP];
- char *endp[NSUBEXP];
- char regstart; /* Internal use only. */
- char reganch; /* Internal use only. */
- char *regmust; /* Internal use only. */
- int regmlen; /* Internal use only. */
- char program[1]; /* Unwarranted chumminess with compiler. */
-} regexp;
-
-#if defined(__STDC__) || defined(__cplusplus)
-# define _ANSI_ARGS_(x) x
-#else
-# define _ANSI_ARGS_(x) ()
-#endif
-
-extern regexp *regcomp _ANSI_ARGS_((char *exp));
-extern int regexec _ANSI_ARGS_((regexp *prog, char *string));
-extern int regexec2 _ANSI_ARGS_((regexp *prog, char *string, int notbol));
-extern void regsub _ANSI_ARGS_((regexp *prog, char *source, char *dest));
-extern void regerror _ANSI_ARGS_((char *msg));
-
-#endif /* REGEXP */
diff --git a/usr.bin/less/screen.c b/usr.bin/less/screen.c
index 6a5d6a784f8..e188e79f1d7 100644
--- a/usr.bin/less/screen.c
+++ b/usr.bin/less/screen.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines which deal with the characteristics of the terminal.
@@ -16,149 +19,15 @@
#include "less.h"
#include "cmd.h"
-#if MSDOS_COMPILER
-#include "pckeys.h"
-#if MSDOS_COMPILER==MSOFTC
-#include <graph.h>
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
-#include <conio.h>
-#if MSDOS_COMPILER==DJGPPC
-#include <pc.h>
-extern int fd0;
-#endif
-#else
-#if MSDOS_COMPILER==WIN32C
-#include <windows.h>
-#endif
-#endif
-#endif
-#include <time.h>
-
-#else
-
-#if HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
#include <termios.h>
-#else
-#if HAVE_TERMIO_H
-#include <termio.h>
-#else
-#if HAVE_SGSTAT_H
-#include <sgstat.h>
-#else
-#include <sgtty.h>
-#endif
-#endif
-#endif
-
-#if HAVE_TERMCAP_H
-#include <termcap.h>
-#endif
-#ifdef _OSK
-#include <signal.h>
-#endif
-#if OS2
-#include <sys/signal.h>
-#include "pckeys.h"
-#endif
-#if HAVE_SYS_STREAM_H
-#include <sys/stream.h>
-#endif
-#if HAVE_SYS_PTEM_H
-#include <sys/ptem.h>
-#endif
-
-#endif /* MSDOS_COMPILER */
-
-/*
- * Check for broken termios package that forces you to manually
- * set the line discipline.
- */
-#ifdef __ultrix__
-#define MUST_SET_LINE_DISCIPLINE 1
-#else
-#define MUST_SET_LINE_DISCIPLINE 0
-#endif
+#include <term.h>
-#if OS2
-#define DEFAULT_TERM "ansi"
-static char *windowid;
-#else
#define DEFAULT_TERM "unknown"
-#endif
-
-#if MSDOS_COMPILER==MSOFTC
-static int videopages;
-static long msec_loops;
-static int flash_created = 0;
-#define SETCOLORS(fg,bg) { _settextcolor(fg); _setbkcolor(bg); }
-#endif
-
-#if MSDOS_COMPILER==BORLANDC
-static unsigned short *whitescreen;
-static int flash_created = 0;
-#endif
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
-#define _settextposition(y,x) gotoxy(x,y)
-#define _clearscreen(m) clrscr()
-#define _outtext(s) cputs(s)
-#define SETCOLORS(fg,bg) { textcolor(fg); textbackground(bg); }
-extern int sc_height;
-#endif
-
-#if MSDOS_COMPILER==WIN32C
-struct keyRecord
-{
- int ascii;
- int scan;
-} currentKey;
-
-static int keyCount = 0;
-static WORD curr_attr;
-static int pending_scancode = 0;
-static WORD *whitescreen;
-
-static HANDLE con_out_save = INVALID_HANDLE_VALUE; /* previous console */
-static HANDLE con_out_ours = INVALID_HANDLE_VALUE; /* our own */
-HANDLE con_out = INVALID_HANDLE_VALUE; /* current console */
-
-extern int quitting;
-static void win32_init_term();
-static void win32_deinit_term();
-
-#define FG_COLORS (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY)
-#define BG_COLORS (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY)
-#define MAKEATTR(fg,bg) ((WORD)((fg)|((bg)<<4)))
-#define SETCOLORS(fg,bg) { curr_attr = MAKEATTR(fg,bg); \
- if (SetConsoleTextAttribute(con_out, curr_attr) == 0) \
- error("SETCOLORS failed"); }
-#endif
-
-#if MSDOS_COMPILER
-public int nm_fg_color; /* Color of normal text */
-public int nm_bg_color;
-public int bo_fg_color; /* Color of bold text */
-public int bo_bg_color;
-public int ul_fg_color; /* Color of underlined text */
-public int ul_bg_color;
-public int so_fg_color; /* Color of standout text */
-public int so_bg_color;
-public int bl_fg_color; /* Color of blinking text */
-public int bl_bg_color;
-static int sy_fg_color; /* Color of system text (before less) */
-static int sy_bg_color;
-
-#else
/*
* Strings passed to tputs() to do various terminal functions.
*/
static char
- *sc_pad, /* Pad string */
*sc_home, /* Cursor home */
*sc_addline, /* Add line, scroll down following lines */
*sc_lower_left, /* Cursor to last line, first column */
@@ -181,46 +50,30 @@ static char
*sc_e_keypad, /* End keypad mode */
*sc_init, /* Startup terminal initialization */
*sc_deinit; /* Exit terminal de-initialization */
-#endif
static int init_done = 0;
-public int auto_wrap; /* Terminal does \r\n when write past margin */
-public int ignaw; /* Terminal ignores \n immediately after wrap */
-public int erase_char; /* The user's erase char */
-public int erase2_char; /* The user's other erase char */
-public int kill_char; /* The user's line-kill char */
-public int werase_char; /* The user's word-erase char */
-public int sc_width, sc_height; /* Height & width of screen */
-public int bo_s_width, bo_e_width; /* Printing width of boldface seq */
-public int ul_s_width, ul_e_width; /* Printing width of underline seq */
-public int so_s_width, so_e_width; /* Printing width of standout seq */
-public int bl_s_width, bl_e_width; /* Printing width of blink seq */
-public int above_mem, below_mem; /* Memory retained above/below screen */
-public int can_goto_line; /* Can move cursor to any line */
-public int clear_bg; /* Clear fills with background color */
-public int missing_cap = 0; /* Some capability is missing */
+int auto_wrap; /* Terminal does \r\n when write past margin */
+int ignaw; /* Terminal ignores \n immediately after wrap */
+int erase_char; /* The user's erase char */
+int erase2_char; /* The user's other erase char */
+int kill_char; /* The user's line-kill char */
+int werase_char; /* The user's word-erase char */
+int sc_width, sc_height; /* Height & width of screen */
+int bo_s_width, bo_e_width; /* Printing width of boldface seq */
+int ul_s_width, ul_e_width; /* Printing width of underline seq */
+int so_s_width, so_e_width; /* Printing width of standout seq */
+int bl_s_width, bl_e_width; /* Printing width of blink seq */
+int can_goto_line; /* Can move cursor to any line */
+int missing_cap = 0; /* Some capability is missing */
+static int above_mem; /* Memory retained above screen */
+static int below_mem; /* Memory retained below screen */
static int attrmode = AT_NORMAL;
extern int binattr;
-#if !MSDOS_COMPILER
-static char *cheaper();
-static void tmodes();
-#endif
-
-/*
- * These two variables are sometimes defined in,
- * and needed by, the termcap library.
- */
-#if MUST_DEFINE_OSPEED
-extern short ospeed; /* Terminal output baud rate */
-extern char PC; /* Pad character */
-#endif
-#ifdef _OSK
-short ospeed;
-char PC_, *UP, *BC;
-#endif
+static char *cheaper(char *, char *, char *);
+static void tmodes(char *, char *, char **, char **, char *, char *);
extern int quiet; /* If VERY_QUIET, use visual bell for bell */
extern int no_back_scroll;
@@ -233,115 +86,45 @@ extern int screen_trashed;
extern int tty;
extern int top_scroll;
extern int oldbot;
-#if HILITE_SEARCH
extern int hilite_search;
-#endif
-
-extern char *tgetstr();
-extern char *tgoto();
-
/*
* Change terminal to "raw mode", or restore to "normal" mode.
- * "Raw mode" means
+ * "Raw mode" means
* 1. An outstanding read will complete on receipt of a single keystroke.
- * 2. Input is not echoed.
+ * 2. Input is not echoed.
* 3. On output, \n is mapped to \r\n.
* 4. \t is NOT expanded into spaces.
* 5. Signal-causing characters such as ctrl-C (interrupt),
* etc. are NOT disabled.
* It doesn't matter whether an input \n is mapped to \r, or vice versa.
*/
- public void
-raw_mode(on)
- int on;
+void
+raw_mode(int on)
{
static int curr_on = 0;
+ struct termios s;
+ static struct termios save_term;
+ static int saved_term = 0;
if (on == curr_on)
return;
erase2_char = '\b'; /* in case OS doesn't know about erase2 */
-#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
- {
- struct termios s;
- static struct termios save_term;
- static int saved_term = 0;
- if (on)
- {
+ if (on) {
/*
* Get terminal modes.
*/
- tcgetattr(tty, &s);
+ (void) tcgetattr(tty, &s);
/*
* Save modes and set certain variables dependent on modes.
*/
- if (!saved_term)
- {
+ if (!saved_term) {
save_term = s;
saved_term = 1;
}
-#if HAVE_OSPEED
- switch (cfgetospeed(&s))
- {
-#ifdef B0
- case B0: ospeed = 0; break;
-#endif
-#ifdef B50
- case B50: ospeed = 1; break;
-#endif
-#ifdef B75
- case B75: ospeed = 2; break;
-#endif
-#ifdef B110
- case B110: ospeed = 3; break;
-#endif
-#ifdef B134
- case B134: ospeed = 4; break;
-#endif
-#ifdef B150
- case B150: ospeed = 5; break;
-#endif
-#ifdef B200
- case B200: ospeed = 6; break;
-#endif
-#ifdef B300
- case B300: ospeed = 7; break;
-#endif
-#ifdef B600
- case B600: ospeed = 8; break;
-#endif
-#ifdef B1200
- case B1200: ospeed = 9; break;
-#endif
-#ifdef B1800
- case B1800: ospeed = 10; break;
-#endif
-#ifdef B2400
- case B2400: ospeed = 11; break;
-#endif
-#ifdef B4800
- case B4800: ospeed = 12; break;
-#endif
-#ifdef B9600
- case B9600: ospeed = 13; break;
-#endif
-#ifdef EXTA
- case EXTA: ospeed = 14; break;
-#endif
-#ifdef EXTB
- case EXTB: ospeed = 15; break;
-#endif
-#ifdef B57600
- case B57600: ospeed = 16; break;
-#endif
-#ifdef B115200
- case B115200: ospeed = 17; break;
-#endif
- default: ;
- }
-#endif
+
erase_char = s.c_cc[VERASE];
#ifdef VERASE2
erase2_char = s.c_cc[VERASE2];
@@ -349,65 +132,18 @@ raw_mode(on)
kill_char = s.c_cc[VKILL];
#ifdef VWERASE
werase_char = s.c_cc[VWERASE];
-#else
- werase_char = CONTROL('W');
#endif
/*
* Set the modes to the way we want them.
*/
- s.c_lflag &= ~(0
-#ifdef ICANON
- | ICANON
-#endif
-#ifdef ECHO
- | ECHO
-#endif
-#ifdef ECHOE
- | ECHOE
-#endif
-#ifdef ECHOK
- | ECHOK
-#endif
-#if ECHONL
- | ECHONL
-#endif
- );
-
- s.c_oflag |= (0
-#ifdef OXTABS
- | OXTABS
-#else
-#ifdef TAB3
- | TAB3
-#else
-#ifdef XTABS
- | XTABS
-#endif
-#endif
-#endif
-#ifdef OPOST
- | OPOST
-#endif
-#ifdef ONLCR
- | ONLCR
-#endif
- );
+ s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
- s.c_oflag &= ~(0
-#ifdef ONOEOT
- | ONOEOT
-#endif
-#ifdef OCRNL
- | OCRNL
-#endif
-#ifdef ONOCR
- | ONOCR
-#endif
-#ifdef ONLRET
- | ONLRET
+#ifndef TAB3
+#define TAB3 0 /* Its a lie, but TAB3 isn't defined by POSIX. */
#endif
- );
+ s.c_oflag |= (TAB3 | OPOST | ONLCR);
+ s.c_oflag &= ~(OCRNL | ONOCR | ONLRET);
s.c_cc[VMIN] = 1;
s.c_cc[VTIME] = 0;
#ifdef VLNEXT
@@ -416,393 +152,56 @@ raw_mode(on)
#ifdef VDSUSP
s.c_cc[VDSUSP] = 0;
#endif
-#if MUST_SET_LINE_DISCIPLINE
- /*
- * System's termios is broken; need to explicitly
- * request TERMIODISC line discipline.
- */
- s.c_line = TERMIODISC;
-#endif
- } else
- {
- /*
- * Restore saved modes.
- */
- s = save_term;
- }
- tcsetattr(tty, TCSASOFT | TCSADRAIN, &s);
-#if HAVE_FSYNC
- fsync(tty);
-#endif
-#if MUST_SET_LINE_DISCIPLINE
- if (!on)
- {
- /*
- * Broken termios *ignores* any line discipline
- * except TERMIODISC. A different old line discipline
- * is therefore not restored, yet. Restore the old
- * line discipline by hand.
- */
- ioctl(tty, TIOCSETD, &save_term.c_line);
- }
-#endif
- }
-#else
-#ifdef TCGETA
- {
- struct termio s;
- static struct termio save_term;
- static int saved_term = 0;
-
- if (on)
- {
- /*
- * Get terminal modes.
- */
- ioctl(tty, TCGETA, &s);
-
- /*
- * Save modes and set certain variables dependent on modes.
- */
- if (!saved_term)
- {
- save_term = s;
- saved_term = 1;
- }
-#if HAVE_OSPEED
- ospeed = s.c_cflag & CBAUD;
-#endif
- erase_char = s.c_cc[VERASE];
- kill_char = s.c_cc[VKILL];
-#ifdef VWERASE
- werase_char = s.c_cc[VWERASE];
-#else
- werase_char = CONTROL('W');
-#endif
-
- /*
- * Set the modes to the way we want them.
- */
- s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
- s.c_oflag |= (OPOST|ONLCR|TAB3);
- s.c_oflag &= ~(OCRNL|ONOCR|ONLRET);
- s.c_cc[VMIN] = 1;
- s.c_cc[VTIME] = 0;
- } else
- {
+ } else {
/*
* Restore saved modes.
*/
s = save_term;
}
- ioctl(tty, TCSETAW, &s);
- }
-#else
-#ifdef TIOCGETP
- {
- struct sgttyb s;
- static struct sgttyb save_term;
- static int saved_term = 0;
-
- if (on)
- {
- /*
- * Get terminal modes.
- */
- ioctl(tty, TIOCGETP, &s);
-
- /*
- * Save modes and set certain variables dependent on modes.
- */
- if (!saved_term)
- {
- save_term = s;
- saved_term = 1;
- }
-#if HAVE_OSPEED
- ospeed = s.sg_ospeed;
-#endif
- erase_char = s.sg_erase;
- kill_char = s.sg_kill;
- werase_char = CONTROL('W');
-
- /*
- * Set the modes to the way we want them.
- */
- s.sg_flags |= CBREAK;
- s.sg_flags &= ~(ECHO|XTABS);
- } else
- {
- /*
- * Restore saved modes.
- */
- s = save_term;
- }
- ioctl(tty, TIOCSETN, &s);
- }
-#else
-#ifdef _OSK
- {
- struct sgbuf s;
- static struct sgbuf save_term;
- static int saved_term = 0;
-
- if (on)
- {
- /*
- * Get terminal modes.
- */
- _gs_opt(tty, &s);
-
- /*
- * Save modes and set certain variables dependent on modes.
- */
- if (!saved_term)
- {
- save_term = s;
- saved_term = 1;
- }
- erase_char = s.sg_bspch;
- kill_char = s.sg_dlnch;
- werase_char = CONTROL('W');
-
- /*
- * Set the modes to the way we want them.
- */
- s.sg_echo = 0;
- s.sg_eofch = 0;
- s.sg_pause = 0;
- s.sg_psch = 0;
- } else
- {
- /*
- * Restore saved modes.
- */
- s = save_term;
- }
- _ss_opt(tty, &s);
- }
-#else
- /* MS-DOS, Windows, or OS2 */
-#if OS2
- /* OS2 */
- LSIGNAL(SIGINT, SIG_IGN);
-#endif
- erase_char = '\b';
-#if MSDOS_COMPILER==DJGPPC
- kill_char = CONTROL('U');
- /*
- * So that when we shell out or run another program, its
- * stdin is in cooked mode. We do not switch stdin to binary
- * mode if fd0 is zero, since that means we were called before
- * tty was reopened in open_getchr, in which case we would be
- * changing the original stdin device outside less.
- */
- if (fd0 != 0)
- setmode(0, on ? O_BINARY : O_TEXT);
-#else
- kill_char = ESC;
-#endif
- werase_char = CONTROL('W');
-#endif
-#endif
-#endif
-#endif
+ (void) tcsetattr(tty, TCSASOFT | TCSADRAIN, &s);
+ (void) fsync(tty);
curr_on = on;
}
-#if !MSDOS_COMPILER
/*
* Some glue to prevent calling termcap functions if tgetent() failed.
*/
static int hardcopy;
- static char *
-ltget_env(capname)
- char *capname;
-{
- char name[16];
- char *s;
-
- s = lgetenv("LESS_TERMCAP_DEBUG");
- if (s != NULL && *s != '\0')
- {
- struct env { struct env *next; char *name; char *value; };
- static struct env *envs = NULL;
- struct env *p;
- size_t len;
- for (p = envs; p != NULL; p = p->next)
- if (strcmp(p->name, capname) == 0)
- return p->value;
- p = (struct env *) ecalloc(1, sizeof(struct env));
- p->name = save(capname);
- len = strlen(capname) + 3;
- p->value = (char *) ecalloc(len, sizeof(char));
- snprintf(p->value, len, "<%s>", capname);
- p->next = envs;
- envs = p;
- return p->value;
- }
- strlcpy(name, "LESS_TERMCAP_", sizeof(name));
- strlcat(name, capname, sizeof(name));
- return (lgetenv(name));
-}
-
- static int
-ltgetflag(capname)
- char *capname;
-{
- char *s;
-
- if ((s = ltget_env(capname)) != NULL)
- return (*s != '\0' && *s != '0');
- if (hardcopy)
- return (0);
- return (tgetflag(capname));
-}
-
- static int
-ltgetnum(capname)
- char *capname;
-{
- char *s;
-
- if ((s = ltget_env(capname)) != NULL)
- return (atoi(s));
- if (hardcopy)
- return (-1);
- return (tgetnum(capname));
-}
-
- static char *
-ltgetstr(capname, pp)
- char *capname;
- char **pp;
-{
- char *s;
-
- if ((s = ltget_env(capname)) != NULL)
- return (s);
- if (hardcopy)
- return (NULL);
- return (tgetstr(capname, pp));
-}
-#endif /* MSDOS_COMPILER */
-
/*
* Get size of the output screen.
*/
- public void
-scrsize()
+static void
+scrsize(void)
{
- register char *s;
+ char *s;
int sys_height;
int sys_width;
-#if !MSDOS_COMPILER
int n;
+#ifdef TIOCGWINSIZE
+ struct winsize w;
#endif
#define DEF_SC_WIDTH 80
-#if MSDOS_COMPILER
-#define DEF_SC_HEIGHT 25
-#else
#define DEF_SC_HEIGHT 24
-#endif
-
sys_width = sys_height = 0;
-#if MSDOS_COMPILER==MSOFTC
- {
- struct videoconfig w;
- _getvideoconfig(&w);
- sys_height = w.numtextrows;
- sys_width = w.numtextcols;
- }
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- {
- struct text_info w;
- gettextinfo(&w);
- sys_height = w.screenheight;
- sys_width = w.screenwidth;
+#ifdef TIOCGWINSIZE
+ if (ioctl(2, TIOCGWINSZ, &w) == 0) {
+ if (w.ws_row > 0)
+ sys_height = w.ws_row;
+ if (w.ws_col > 0)
+ sys_width = w.ws_col;
}
-#else
-#if MSDOS_COMPILER==WIN32C
- {
- CONSOLE_SCREEN_BUFFER_INFO scr;
- GetConsoleScreenBufferInfo(con_out, &scr);
- sys_height = scr.srWindow.Bottom - scr.srWindow.Top + 1;
- sys_width = scr.srWindow.Right - scr.srWindow.Left + 1;
- }
-#else
-#if OS2
- {
- int s[2];
- _scrsize(s);
- sys_width = s[0];
- sys_height = s[1];
- /*
- * When using terminal emulators for XFree86/OS2, the
- * _scrsize function does not work well.
- * Call the scrsize.exe program to get the window size.
- */
- windowid = getenv("WINDOWID");
- if (windowid != NULL)
- {
- FILE *fd = popen("scrsize", "rt");
- if (fd != NULL)
- {
- int w, h;
- fscanf(fd, "%i %i", &w, &h);
- if (w > 0 && h > 0)
- {
- sys_width = w;
- sys_height = h;
- }
- pclose(fd);
- }
- }
- }
-#else
-#ifdef TIOCGWINSZ
- {
- struct winsize w;
- if (ioctl(2, TIOCGWINSZ, &w) == 0)
- {
- if (w.ws_row > 0)
- sys_height = w.ws_row;
- if (w.ws_col > 0)
- sys_width = w.ws_col;
- }
- }
-#else
-#ifdef WIOCGETD
- {
- struct uwdata w;
- if (ioctl(2, WIOCGETD, &w) == 0)
- {
- if (w.uw_height > 0)
- sys_height = w.uw_height / w.uw_vs;
- if (w.uw_width > 0)
- sys_width = w.uw_width / w.uw_hs;
- }
- }
-#endif
-#endif
-#endif
-#endif
-#endif
#endif
if (sys_height > 0)
sc_height = sys_height;
else if ((s = lgetenv("LINES")) != NULL)
sc_height = atoi(s);
-#if !MSDOS_COMPILER
- else if ((n = ltgetnum("li")) > 0)
- sc_height = n;
-#endif
+ else if (!hardcopy && (n = lines) > 0)
+ sc_height = n;
if (sc_height <= 0)
sc_height = DEF_SC_HEIGHT;
@@ -810,239 +209,57 @@ scrsize()
sc_width = sys_width;
else if ((s = lgetenv("COLUMNS")) != NULL)
sc_width = atoi(s);
-#if !MSDOS_COMPILER
- else if ((n = ltgetnum("co")) > 0)
- sc_width = n;
-#endif
+ else if (!hardcopy && (n = columns) > 0)
+ sc_width = n;
if (sc_width <= 0)
sc_width = DEF_SC_WIDTH;
}
-#if MSDOS_COMPILER==MSOFTC
-/*
- * Figure out how many empty loops it takes to delay a millisecond.
- */
- static void
-get_clock()
-{
- clock_t start;
-
- /*
- * Get synchronized at the start of a tick.
- */
- start = clock();
- while (clock() == start)
- ;
- /*
- * Now count loops till the next tick.
- */
- start = clock();
- msec_loops = 0;
- while (clock() == start)
- msec_loops++;
- /*
- * Convert from (loops per clock) to (loops per millisecond).
- */
- msec_loops *= CLOCKS_PER_SEC;
- msec_loops /= 1000;
-}
-
-/*
- * Delay for a specified number of milliseconds.
- */
- static void
-dummy_func()
-{
- static long delay_dummy = 0;
- delay_dummy++;
-}
-
- static void
-delay(msec)
- int msec;
-{
- long i;
-
- while (msec-- > 0)
- {
- for (i = 0; i < msec_loops; i++)
- {
- /*
- * Make it look like we're doing something here,
- * so the optimizer doesn't remove the whole loop.
- */
- dummy_func();
- }
- }
-}
-#endif
-
/*
* Return the characters actually input by a "special" key.
*/
- public char *
-special_key_str(key)
- int key;
+char *
+special_key_str(int key)
{
- static char tbuf[40];
char *s;
-#if MSDOS_COMPILER || OS2
- static char k_right[] = { '\340', PCK_RIGHT, 0 };
- static char k_left[] = { '\340', PCK_LEFT, 0 };
- static char k_ctl_right[] = { '\340', PCK_CTL_RIGHT, 0 };
- static char k_ctl_left[] = { '\340', PCK_CTL_LEFT, 0 };
- static char k_insert[] = { '\340', PCK_INSERT, 0 };
- static char k_delete[] = { '\340', PCK_DELETE, 0 };
- static char k_ctl_delete[] = { '\340', PCK_CTL_DELETE, 0 };
- static char k_ctl_backspace[] = { '\177', 0 };
- static char k_home[] = { '\340', PCK_HOME, 0 };
- static char k_end[] = { '\340', PCK_END, 0 };
- static char k_up[] = { '\340', PCK_UP, 0 };
- static char k_down[] = { '\340', PCK_DOWN, 0 };
- static char k_backtab[] = { '\340', PCK_SHIFT_TAB, 0 };
- static char k_pagedown[] = { '\340', PCK_PAGEDOWN, 0 };
- static char k_pageup[] = { '\340', PCK_PAGEUP, 0 };
- static char k_f1[] = { '\340', PCK_F1, 0 };
-#endif
-#if !MSDOS_COMPILER
- char *sp = tbuf;
-#endif
+ static char ctrlk[] = { CONTROL('K'), 0 };
- switch (key)
- {
-#if OS2
- /*
- * If windowid is not NULL, assume less is executed in
- * the XFree86 environment.
- */
- case SK_RIGHT_ARROW:
- s = windowid ? ltgetstr("kr", &sp) : k_right;
- break;
- case SK_LEFT_ARROW:
- s = windowid ? ltgetstr("kl", &sp) : k_left;
- break;
- case SK_UP_ARROW:
- s = windowid ? ltgetstr("ku", &sp) : k_up;
- break;
- case SK_DOWN_ARROW:
- s = windowid ? ltgetstr("kd", &sp) : k_down;
- break;
- case SK_PAGE_UP:
- s = windowid ? ltgetstr("kP", &sp) : k_pageup;
- break;
- case SK_PAGE_DOWN:
- s = windowid ? ltgetstr("kN", &sp) : k_pagedown;
- break;
- case SK_HOME:
- s = windowid ? ltgetstr("kh", &sp) : k_home;
- break;
- case SK_END:
- s = windowid ? ltgetstr("@7", &sp) : k_end;
- break;
- case SK_DELETE:
- if (windowid)
- {
- s = ltgetstr("kD", &sp);
- if (s == NULL)
- {
- tbuf[0] = '\177';
- tbuf[1] = '\0';
- s = tbuf;
- }
- } else
- s = k_delete;
- break;
-#endif
-#if MSDOS_COMPILER
- case SK_RIGHT_ARROW:
- s = k_right;
- break;
- case SK_LEFT_ARROW:
- s = k_left;
- break;
- case SK_UP_ARROW:
- s = k_up;
- break;
- case SK_DOWN_ARROW:
- s = k_down;
- break;
- case SK_PAGE_UP:
- s = k_pageup;
- break;
- case SK_PAGE_DOWN:
- s = k_pagedown;
- break;
- case SK_HOME:
- s = k_home;
- break;
- case SK_END:
- s = k_end;
- break;
- case SK_DELETE:
- s = k_delete;
- break;
-#endif
-#if MSDOS_COMPILER || OS2
- case SK_INSERT:
- s = k_insert;
- break;
- case SK_CTL_LEFT_ARROW:
- s = k_ctl_left;
- break;
- case SK_CTL_RIGHT_ARROW:
- s = k_ctl_right;
- break;
- case SK_CTL_BACKSPACE:
- s = k_ctl_backspace;
- break;
- case SK_CTL_DELETE:
- s = k_ctl_delete;
- break;
- case SK_F1:
- s = k_f1;
- break;
- case SK_BACKTAB:
- s = k_backtab;
- break;
-#else
+ if (hardcopy)
+ return (NULL);
+
+ switch (key) {
case SK_RIGHT_ARROW:
- s = ltgetstr("kr", &sp);
+ s = key_right;
break;
case SK_LEFT_ARROW:
- s = ltgetstr("kl", &sp);
+ s = key_left;
break;
case SK_UP_ARROW:
- s = ltgetstr("ku", &sp);
+ s = key_up;
break;
case SK_DOWN_ARROW:
- s = ltgetstr("kd", &sp);
+ s = key_down;
break;
case SK_PAGE_UP:
- s = ltgetstr("kP", &sp);
+ s = key_ppage;
break;
case SK_PAGE_DOWN:
- s = ltgetstr("kN", &sp);
+ s = key_npage;
break;
case SK_HOME:
- s = ltgetstr("kh", &sp);
+ s = key_home;
break;
case SK_END:
- s = ltgetstr("@7", &sp);
+ s = key_end;
break;
case SK_DELETE:
- s = ltgetstr("kD", &sp);
- if (s == NULL)
- {
- tbuf[0] = '\177';
- tbuf[1] = '\0';
- s = tbuf;
+ s = key_dc;
+ if (s == NULL) {
+ s = "\177\0";
}
break;
-#endif
case SK_CONTROL_K:
- tbuf[0] = CONTROL('K');
- tbuf[1] = '\0';
- s = tbuf;
+ s = ctrlk;
break;
default:
return (NULL);
@@ -1053,105 +270,23 @@ special_key_str(key)
/*
* Get terminal capabilities via termcap.
*/
- public void
-get_term()
+void
+get_term(void)
{
-#if MSDOS_COMPILER
- auto_wrap = 1;
- ignaw = 0;
- can_goto_line = 1;
- clear_bg = 1;
- /*
- * Set up default colors.
- * The xx_s_width and xx_e_width vars are already initialized to 0.
- */
-#if MSDOS_COMPILER==MSOFTC
- sy_bg_color = _getbkcolor();
- sy_fg_color = _gettextcolor();
- get_clock();
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- {
- struct text_info w;
- gettextinfo(&w);
- sy_bg_color = (w.attribute >> 4) & 0x0F;
- sy_fg_color = (w.attribute >> 0) & 0x0F;
- }
-#else
-#if MSDOS_COMPILER==WIN32C
- {
- DWORD nread;
- CONSOLE_SCREEN_BUFFER_INFO scr;
-
- con_out_save = con_out = GetStdHandle(STD_OUTPUT_HANDLE);
- /*
- * Always open stdin in binary. Note this *must* be done
- * before any file operations have been done on fd0.
- */
- SET_BINARY(0);
- GetConsoleScreenBufferInfo(con_out, &scr);
- ReadConsoleOutputAttribute(con_out, &curr_attr,
- 1, scr.dwCursorPosition, &nread);
- sy_bg_color = (curr_attr & BG_COLORS) >> 4; /* normalize */
- sy_fg_color = curr_attr & FG_COLORS;
- }
-#endif
-#endif
-#endif
- nm_fg_color = sy_fg_color;
- nm_bg_color = sy_bg_color;
- bo_fg_color = 11;
- bo_bg_color = 0;
- ul_fg_color = 9;
- ul_bg_color = 0;
- so_fg_color = 15;
- so_bg_color = 9;
- bl_fg_color = 15;
- bl_bg_color = 0;
-
- /*
- * Get size of the screen.
- */
- scrsize();
- pos_init();
-
-
-#else /* !MSDOS_COMPILER */
-
- char *sp;
- register char *t1, *t2;
+ char *t1, *t2;
char *term;
- char termbuf[TERMBUF_SIZE];
-
- static char sbuf[TERMSBUF_SIZE];
-#if OS2
- /*
- * Make sure the termcap database is available.
- */
- sp = lgetenv("TERMCAP");
- if (sp == NULL || *sp == '\0')
- {
- char *termcap;
- if ((sp = homefile("termcap.dat")) != NULL)
- {
- size_t len = strlen(sp) + 9;
- termcap = (char *) ecalloc(len, sizeof(char));
- snprintf(termcap, len, "TERMCAP=%s", sp);
- free(sp);
- putenv(termcap);
- }
- }
-#endif
/*
* Find out what kind of terminal this is.
*/
- if ((term = lgetenv("TERM")) == NULL)
- term = DEFAULT_TERM;
+ if ((term = lgetenv("TERM")) == NULL)
+ term = DEFAULT_TERM;
hardcopy = 0;
- if (tgetent(termbuf, term) != TGETENT_OK)
- hardcopy = 1;
- if (ltgetflag("hc"))
+
+ if (setupterm(term, 1, NULL) < 0) {
+ hardcopy = 1;
+ }
+ if (hard_copy == 1)
hardcopy = 1;
/*
@@ -1160,11 +295,10 @@ get_term()
scrsize();
pos_init();
- auto_wrap = ltgetflag("am");
- ignaw = ltgetflag("xn");
- above_mem = ltgetflag("da");
- below_mem = ltgetflag("db");
- clear_bg = ltgetflag("ut");
+ auto_wrap = hardcopy ? 0 : auto_right_margin;
+ ignaw = hardcopy ? 0 : eat_newline_glitch;
+ above_mem = hardcopy ? 0 : memory_above;
+ below_mem = hardcopy ? 0 : memory_below;
/*
* Assumes termcap variable "sg" is the printing width of:
@@ -1172,7 +306,7 @@ get_term()
* the underline sequence, the end underline sequence,
* the boldface sequence, and the end boldface sequence.
*/
- if ((so_s_width = ltgetnum("sg")) < 0)
+ if (hardcopy || (so_s_width = magic_cookie_glitch) < 0)
so_s_width = 0;
so_e_width = so_s_width;
@@ -1180,110 +314,93 @@ get_term()
ul_s_width = ul_e_width = so_s_width;
bl_s_width = bl_e_width = so_s_width;
-#if HILITE_SEARCH
if (so_s_width > 0 || so_e_width > 0)
/*
* Disable highlighting by default on magic cookie terminals.
* Turning on highlighting might change the displayed width
* of a line, causing the display to get messed up.
- * The user can turn it back on with -g,
+ * The user can turn it back on with -g,
* but she won't like the results.
*/
hilite_search = 0;
-#endif
/*
* Get various string-valued capabilities.
*/
- sp = sbuf;
-
-#if HAVE_OSPEED
- sc_pad = ltgetstr("pc", &sp);
- if (sc_pad != NULL)
- PC = *sc_pad;
-#endif
- sc_s_keypad = ltgetstr("ks", &sp);
- if (sc_s_keypad == NULL)
+ sc_s_keypad = keypad_xmit;
+ if (hardcopy || sc_s_keypad == NULL)
sc_s_keypad = "";
- sc_e_keypad = ltgetstr("ke", &sp);
- if (sc_e_keypad == NULL)
+ sc_e_keypad = keypad_local;
+ if (hardcopy || sc_e_keypad == NULL)
sc_e_keypad = "";
-
- sc_init = ltgetstr("ti", &sp);
- if (sc_init == NULL)
+
+ sc_init = enter_ca_mode;
+ if (hardcopy || sc_init == NULL)
sc_init = "";
- sc_deinit= ltgetstr("te", &sp);
- if (sc_deinit == NULL)
+ sc_deinit = exit_ca_mode;
+ if (hardcopy || sc_deinit == NULL)
sc_deinit = "";
- sc_eol_clear = ltgetstr("ce", &sp);
- if (sc_eol_clear == NULL || *sc_eol_clear == '\0')
- {
+ sc_eol_clear = clr_eol;
+ if (hardcopy || sc_eol_clear == NULL || *sc_eol_clear == '\0') {
missing_cap = 1;
sc_eol_clear = "";
}
- sc_eos_clear = ltgetstr("cd", &sp);
- if (below_mem && (sc_eos_clear == NULL || *sc_eos_clear == '\0'))
- {
+ sc_eos_clear = clr_eos;
+ if (below_mem &&
+ (hardcopy || sc_eos_clear == NULL || *sc_eos_clear == '\0')) {
missing_cap = 1;
sc_eos_clear = "";
}
- sc_clear = ltgetstr("cl", &sp);
- if (sc_clear == NULL || *sc_clear == '\0')
- {
+ sc_clear = clear_screen;
+ if (hardcopy || sc_clear == NULL || *sc_clear == '\0') {
missing_cap = 1;
sc_clear = "\n\n";
}
- sc_move = ltgetstr("cm", &sp);
- if (sc_move == NULL || *sc_move == '\0')
- {
+ sc_move = cursor_address;
+ if (hardcopy || sc_move == NULL || *sc_move == '\0') {
/*
- * This is not an error here, because we don't
+ * This is not an error here, because we don't
* always need sc_move.
* We need it only if we don't have home or lower-left.
*/
sc_move = "";
can_goto_line = 0;
- } else
+ } else {
can_goto_line = 1;
+ }
- tmodes("so", "se", &sc_s_in, &sc_s_out, "", "", &sp);
- tmodes("us", "ue", &sc_u_in, &sc_u_out, sc_s_in, sc_s_out, &sp);
- tmodes("md", "me", &sc_b_in, &sc_b_out, sc_s_in, sc_s_out, &sp);
- tmodes("mb", "me", &sc_bl_in, &sc_bl_out, sc_s_in, sc_s_out, &sp);
+ tmodes(enter_standout_mode, exit_standout_mode, &sc_s_in, &sc_s_out,
+ "", "");
+ tmodes(enter_underline_mode, exit_underline_mode, &sc_u_in, &sc_u_out,
+ sc_s_in, sc_s_out);
+ tmodes(enter_bold_mode, exit_attribute_mode, &sc_b_in, &sc_b_out,
+ sc_s_in, sc_s_out);
+ tmodes(enter_blink_mode, exit_attribute_mode, &sc_bl_in, &sc_bl_out,
+ sc_s_in, sc_s_out);
- sc_visual_bell = ltgetstr("vb", &sp);
- if (sc_visual_bell == NULL)
+ sc_visual_bell = flash_screen;
+ if (hardcopy || sc_visual_bell == NULL)
sc_visual_bell = "";
- if (ltgetflag("bs"))
- sc_backspace = "\b";
- else
- {
- sc_backspace = ltgetstr("bc", &sp);
- if (sc_backspace == NULL || *sc_backspace == '\0')
- sc_backspace = "\b";
- }
+ sc_backspace = "\b";
/*
* Choose between using "ho" and "cm" ("home" and "cursor move")
* to move the cursor to the upper left corner of the screen.
*/
- t1 = ltgetstr("ho", &sp);
- if (t1 == NULL)
+ t1 = cursor_home;
+ if (hardcopy || t1 == NULL)
t1 = "";
- if (*sc_move == '\0')
+ if (*sc_move == '\0') {
t2 = "";
- else
- {
- strlcpy(sp, tgoto(sc_move, 0, 0), sbuf + sizeof(sbuf) - sp);
- t2 = sp;
- sp += strlen(sp) + 1;
+ } else {
+ t2 = estrdup(tparm(sc_move, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
sc_home = cheaper(t1, t2, "|\b^");
@@ -1291,57 +408,46 @@ get_term()
* Choose between using "ll" and "cm" ("lower left" and "cursor move")
* to move the cursor to the lower left corner of the screen.
*/
- t1 = ltgetstr("ll", &sp);
- if (t1 == NULL)
+ t1 = cursor_to_ll;
+ if (hardcopy || t1 == NULL)
t1 = "";
- if (*sc_move == '\0')
+ if (*sc_move == '\0') {
t2 = "";
- else
- {
- strlcpy(sp, tgoto(sc_move, 0, sc_height-1),
- sbuf + sizeof(sbuf) - sp);
- t2 = sp;
- sp += strlen(sp) + 1;
+ } else {
+ t2 = estrdup(tparm(sc_move, sc_height-1,
+ 0, 0, 0, 0, 0, 0, 0, 0));
}
sc_lower_left = cheaper(t1, t2, "\r");
/*
* Get carriage return string.
*/
- sc_return = ltgetstr("cr", &sp);
- if (sc_return == NULL)
+ sc_return = carriage_return;
+ if (hardcopy || sc_return == NULL)
sc_return = "\r";
/*
- * Choose between using "al" or "sr" ("add line" or "scroll reverse")
+ * Choose between using insert_line or scroll_reverse
* to add a line at the top of the screen.
*/
- t1 = ltgetstr("al", &sp);
- if (t1 == NULL)
+ t1 = insert_line;
+ if (hardcopy || t1 == NULL)
t1 = "";
- t2 = ltgetstr("sr", &sp);
- if (t2 == NULL)
+ t2 = scroll_reverse;
+ if (hardcopy || t2 == NULL)
t2 = "";
-#if OS2
- if (*t1 == '\0' && *t2 == '\0')
- sc_addline = "";
- else
-#endif
if (above_mem)
sc_addline = t1;
else
sc_addline = cheaper(t1, t2, "");
- if (*sc_addline == '\0')
- {
+ if (*sc_addline == '\0') {
/*
* Force repaint on any backward movement.
*/
no_back_scroll = 1;
}
-#endif /* MSDOS_COMPILER */
}
-#if !MSDOS_COMPILER
/*
* Return the cost of displaying a termcap string.
* We use the trick of calling tputs, but as a char printing function
@@ -1351,36 +457,30 @@ get_term()
*/
static int costcount;
-/*ARGSUSED*/
- static int
-inc_costcount(c)
- int c;
+static int
+inc_costcount(int c)
{
costcount++;
return (c);
}
- static int
-cost(t)
- char *t;
+static int
+cost(char *t)
{
costcount = 0;
- tputs(t, sc_height, inc_costcount);
+ (void) tputs(t, sc_height, inc_costcount);
return (costcount);
}
/*
* Return the "best" of the two given termcap strings.
- * The best, if both exist, is the one with the lower
+ * The best, if both exist, is the one with the lower
* cost (see cost() function).
*/
- static char *
-cheaper(t1, t2, def)
- char *t1, *t2;
- char *def;
+static char *
+cheaper(char *t1, char *t2, char *def)
{
- if (*t1 == '\0' && *t2 == '\0')
- {
+ if (*t1 == '\0' && *t2 == '\0') {
missing_cap = 1;
return (def);
}
@@ -1393,156 +493,50 @@ cheaper(t1, t2, def)
return (t2);
}
- static void
-tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp)
- char *incap;
- char *outcap;
- char **instr;
- char **outstr;
- char *def_instr;
- char *def_outstr;
- char **spp;
+static void
+tmodes(char *incap, char *outcap, char **instr, char **outstr,
+ char *def_instr, char *def_outstr)
{
- *instr = ltgetstr(incap, spp);
- if (*instr == NULL)
- {
+ if (hardcopy) {
+ *instr = "";
+ *outstr = "";
+ return;
+ }
+
+ *instr = incap;
+ *outstr = outcap;
+
+ if (*instr == NULL) {
/* Use defaults. */
*instr = def_instr;
*outstr = def_outstr;
return;
}
- *outstr = ltgetstr(outcap, spp);
if (*outstr == NULL)
- /* No specific out capability; use "me". */
- *outstr = ltgetstr("me", spp);
+ /* No specific out capability; use exit_attribute_mode. */
+ *outstr = exit_attribute_mode;
if (*outstr == NULL)
- /* Don't even have "me"; use a null string. */
+ /* Don't even have that, use an empty string */
*outstr = "";
}
-#endif /* MSDOS_COMPILER */
-
-
/*
- * Below are the functions which perform all the
+ * Below are the functions which perform all the
* terminal-specific screen manipulation.
*/
-
-#if MSDOS_COMPILER
-
-#if MSDOS_COMPILER==WIN32C
- static void
-_settextposition(int row, int col)
-{
- COORD cpos;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- GetConsoleScreenBufferInfo(con_out, &csbi);
- cpos.X = csbi.srWindow.Left + (col - 1);
- cpos.Y = csbi.srWindow.Top + (row - 1);
- SetConsoleCursorPosition(con_out, cpos);
-}
-#endif
-
-/*
- * Initialize the screen to the correct color at startup.
- */
- static void
-initcolor()
-{
- SETCOLORS(nm_fg_color, nm_bg_color);
-#if 0
- /*
- * This clears the screen at startup. This is different from
- * the behavior of other versions of less. Disable it for now.
- */
- char *blanks;
- int row;
- int col;
-
- /*
- * Create a complete, blank screen using "normal" colors.
- */
- SETCOLORS(nm_fg_color, nm_bg_color);
- blanks = (char *) ecalloc(width+1, sizeof(char));
- for (col = 0; col < sc_width; col++)
- blanks[col] = ' ';
- blanks[sc_width] = '\0';
- for (row = 0; row < sc_height; row++)
- _outtext(blanks);
- free(blanks);
-#endif
-}
-#endif
-
-#if MSDOS_COMPILER==WIN32C
-
-/*
- * Termcap-like init with a private win32 console.
- */
- static void
-win32_init_term()
-{
- CONSOLE_SCREEN_BUFFER_INFO scr;
- COORD size;
-
- if (con_out_save == INVALID_HANDLE_VALUE)
- return;
-
- GetConsoleScreenBufferInfo(con_out_save, &scr);
-
- if (con_out_ours == INVALID_HANDLE_VALUE)
- {
- /*
- * Create our own screen buffer, so that we
- * may restore the original when done.
- */
- con_out_ours = CreateConsoleScreenBuffer(
- GENERIC_WRITE | GENERIC_READ,
- FILE_SHARE_WRITE | FILE_SHARE_READ,
- (LPSECURITY_ATTRIBUTES) NULL,
- CONSOLE_TEXTMODE_BUFFER,
- (LPVOID) NULL);
- }
-
- size.X = scr.srWindow.Right - scr.srWindow.Left + 1;
- size.Y = scr.srWindow.Bottom - scr.srWindow.Top + 1;
- SetConsoleScreenBufferSize(con_out_ours, size);
- SetConsoleActiveScreenBuffer(con_out_ours);
- con_out = con_out_ours;
-}
-
-/*
- * Restore the startup console.
- */
-static void
-win32_deinit_term()
-{
- if (con_out_save == INVALID_HANDLE_VALUE)
- return;
- if (quitting)
- (void) CloseHandle(con_out_ours);
- SetConsoleActiveScreenBuffer(con_out_save);
- con_out = con_out_save;
-}
-
-#endif
-
/*
* Initialize terminal
*/
- public void
-init()
+void
+init(void)
{
-#if !MSDOS_COMPILER
if (!no_init)
- tputs(sc_init, sc_height, putchr);
+ (void) tputs(sc_init, sc_height, putchr);
if (!no_keypad)
- tputs(sc_s_keypad, sc_height, putchr);
- if (top_scroll)
- {
+ (void) tputs(sc_s_keypad, sc_height, putchr);
+ if (top_scroll) {
int i;
/*
@@ -1552,511 +546,99 @@ init()
* screen to ourself.
*/
for (i = 1; i < sc_height; i++)
- putchr('\n');
+ (void) putchr('\n');
} else
line_left();
-#else
-#if MSDOS_COMPILER==WIN32C
- if (!no_init)
- win32_init_term();
-#endif
- initcolor();
- flush();
-#endif
init_done = 1;
}
/*
* Deinitialize terminal
*/
- public void
-deinit()
+void
+deinit(void)
{
if (!init_done)
return;
-#if !MSDOS_COMPILER
if (!no_keypad)
- tputs(sc_e_keypad, sc_height, putchr);
+ (void) tputs(sc_e_keypad, sc_height, putchr);
if (!no_init)
- tputs(sc_deinit, sc_height, putchr);
-#else
- /* Restore system colors. */
- SETCOLORS(sy_fg_color, sy_bg_color);
-#if MSDOS_COMPILER==WIN32C
- if (!no_init)
- win32_deinit_term();
-#else
- /* Need clreol to make SETCOLORS take effect. */
- clreol();
-#endif
-#endif
+ (void) tputs(sc_deinit, sc_height, putchr);
init_done = 0;
}
/*
* Home cursor (move to upper left corner of screen).
*/
- public void
-home()
+void
+home(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_home, 1, putchr);
-#else
- flush();
- _settextposition(1,1);
-#endif
+ (void) tputs(sc_home, 1, putchr);
}
/*
* Add a blank line (called with cursor at home).
* Should scroll the display down.
*/
- public void
-add_line()
+void
+add_line(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_addline, sc_height, putchr);
-#else
- flush();
-#if MSDOS_COMPILER==MSOFTC
- _scrolltextwindow(_GSCROLLDOWN);
- _settextposition(1,1);
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- movetext(1,1, sc_width,sc_height-1, 1,2);
- gotoxy(1,1);
- clreol();
-#else
-#if MSDOS_COMPILER==WIN32C
- {
- CHAR_INFO fillchar;
- SMALL_RECT rcSrc, rcClip;
- COORD new_org;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- GetConsoleScreenBufferInfo(con_out,&csbi);
-
- /* The clip rectangle is the entire visible screen. */
- rcClip.Left = csbi.srWindow.Left;
- rcClip.Top = csbi.srWindow.Top;
- rcClip.Right = csbi.srWindow.Right;
- rcClip.Bottom = csbi.srWindow.Bottom;
-
- /* The source rectangle is the visible screen minus the last line. */
- rcSrc = rcClip;
- rcSrc.Bottom--;
-
- /* Move the top left corner of the source window down one row. */
- new_org.X = rcSrc.Left;
- new_org.Y = rcSrc.Top + 1;
-
- /* Fill the right character and attributes. */
- fillchar.Char.AsciiChar = ' ';
- curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
- fillchar.Attributes = curr_attr;
- ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
- _settextposition(1,1);
- }
-#endif
-#endif
-#endif
-#endif
-}
-
-#if 0
-/*
- * Remove the n topmost lines and scroll everything below it in the
- * window upward. This is needed to stop leaking the topmost line
- * into the scrollback buffer when we go down-one-line (in WIN32).
- */
- public void
-remove_top(n)
- int n;
-{
-#if MSDOS_COMPILER==WIN32C
- SMALL_RECT rcSrc, rcClip;
- CHAR_INFO fillchar;
- COORD new_org;
- CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
-
- if (n >= sc_height - 1)
- {
- clear();
- home();
- return;
- }
-
- flush();
-
- GetConsoleScreenBufferInfo(con_out, &csbi);
-
- /* Get the extent of all-visible-rows-but-the-last. */
- rcSrc.Left = csbi.srWindow.Left;
- rcSrc.Top = csbi.srWindow.Top + n;
- rcSrc.Right = csbi.srWindow.Right;
- rcSrc.Bottom = csbi.srWindow.Bottom;
-
- /* Get the clip rectangle. */
- rcClip.Left = rcSrc.Left;
- rcClip.Top = csbi.srWindow.Top;
- rcClip.Right = rcSrc.Right;
- rcClip.Bottom = rcSrc.Bottom ;
-
- /* Move the source window up n rows. */
- new_org.X = rcSrc.Left;
- new_org.Y = rcSrc.Top - n;
-
- /* Fill the right character and attributes. */
- fillchar.Char.AsciiChar = ' ';
- curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
- fillchar.Attributes = curr_attr;
-
- ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
-
- /* Position cursor on first blank line. */
- goto_line(sc_height - n - 1);
-#endif
+ (void) tputs(sc_addline, sc_height, putchr);
}
-#endif
-
-#if MSDOS_COMPILER==WIN32C
-/*
- * Clear the screen.
- */
- static void
-win32_clear()
-{
- /*
- * This will clear only the currently visible rows of the NT
- * console buffer, which means none of the precious scrollback
- * rows are touched making for faster scrolling. Note that, if
- * the window has fewer columns than the console buffer (i.e.
- * there is a horizontal scrollbar as well), the entire width
- * of the visible rows will be cleared.
- */
- COORD topleft;
- DWORD nchars;
- DWORD winsz;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- /* get the number of cells in the current buffer */
- GetConsoleScreenBufferInfo(con_out, &csbi);
- winsz = csbi.dwSize.X * (csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
- topleft.X = 0;
- topleft.Y = csbi.srWindow.Top;
-
- curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
- FillConsoleOutputCharacter(con_out, ' ', winsz, topleft, &nchars);
- FillConsoleOutputAttribute(con_out, curr_attr, winsz, topleft, &nchars);
-}
-
-/*
- * Remove the n topmost lines and scroll everything below it in the
- * window upward.
- */
- public void
-win32_scroll_up(n)
- int n;
-{
- SMALL_RECT rcSrc, rcClip;
- CHAR_INFO fillchar;
- COORD topleft;
- COORD new_org;
- DWORD nchars;
- DWORD size;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- if (n <= 0)
- return;
-
- if (n >= sc_height - 1)
- {
- win32_clear();
- _settextposition(1,1);
- return;
- }
-
- /* Get the extent of what will remain visible after scrolling. */
- GetConsoleScreenBufferInfo(con_out, &csbi);
- rcSrc.Left = csbi.srWindow.Left;
- rcSrc.Top = csbi.srWindow.Top + n;
- rcSrc.Right = csbi.srWindow.Right;
- rcSrc.Bottom = csbi.srWindow.Bottom;
-
- /* Get the clip rectangle. */
- rcClip.Left = rcSrc.Left;
- rcClip.Top = csbi.srWindow.Top;
- rcClip.Right = rcSrc.Right;
- rcClip.Bottom = rcSrc.Bottom ;
-
- /* Move the source text to the top of the screen. */
- new_org.X = rcSrc.Left;
- new_org.Y = rcClip.Top;
-
- /* Fill the right character and attributes. */
- fillchar.Char.AsciiChar = ' ';
- fillchar.Attributes = MAKEATTR(nm_fg_color, nm_bg_color);
-
- /* Scroll the window. */
- SetConsoleTextAttribute(con_out, fillchar.Attributes);
- ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
-
- /* Clear remaining lines at bottom. */
- topleft.X = csbi.dwCursorPosition.X;
- topleft.Y = rcSrc.Bottom - n;
- size = (n * csbi.dwSize.X) + (rcSrc.Right - topleft.X);
- FillConsoleOutputCharacter(con_out, ' ', size, topleft,
- &nchars);
- FillConsoleOutputAttribute(con_out, fillchar.Attributes, size, topleft,
- &nchars);
- SetConsoleTextAttribute(con_out, curr_attr);
-
- /* Move cursor n lines up from where it was. */
- csbi.dwCursorPosition.Y -= n;
- SetConsoleCursorPosition(con_out, csbi.dwCursorPosition);
-}
-#endif
/*
* Move cursor to lower left corner of screen.
*/
- public void
-lower_left()
+void
+lower_left(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_lower_left, 1, putchr);
-#else
- flush();
- _settextposition(sc_height, 1);
-#endif
+ (void) tputs(sc_lower_left, 1, putchr);
}
/*
* Move cursor to left position of current line.
*/
- public void
-line_left()
-{
-#if !MSDOS_COMPILER
- tputs(sc_return, 1, putchr);
-#else
- int row;
- flush();
-#if MSDOS_COMPILER==WIN32C
- {
- CONSOLE_SCREEN_BUFFER_INFO scr;
- GetConsoleScreenBufferInfo(con_out, &scr);
- row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1;
- }
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- row = wherey();
-#else
- {
- struct rccoord tpos = _gettextposition();
- row = tpos.row;
- }
-#endif
-#endif
- _settextposition(row, 1);
-#endif
-}
-
-/*
- * Check if the console size has changed and reset internals
- * (in lieu of SIGWINCH for WIN32).
- */
- public void
-check_winch()
+void
+line_left(void)
{
-#if MSDOS_COMPILER==WIN32C
- CONSOLE_SCREEN_BUFFER_INFO scr;
- COORD size;
-
- if (con_out == INVALID_HANDLE_VALUE)
- return;
-
- flush();
- GetConsoleScreenBufferInfo(con_out, &scr);
- size.Y = scr.srWindow.Bottom - scr.srWindow.Top + 1;
- size.X = scr.srWindow.Right - scr.srWindow.Left + 1;
- if (size.Y != sc_height || size.X != sc_width)
- {
- sc_height = size.Y;
- sc_width = size.X;
- if (!no_init && con_out_ours == con_out)
- SetConsoleScreenBufferSize(con_out, size);
- pos_init();
- wscroll = (sc_height + 1) / 2;
- screen_trashed = 1;
- }
-#endif
+ (void) tputs(sc_return, 1, putchr);
}
/*
* Goto a specific line on the screen.
*/
- public void
-goto_line(slinenum)
- int slinenum;
-{
-#if !MSDOS_COMPILER
- tputs(tgoto(sc_move, 0, slinenum), 1, putchr);
-#else
- flush();
- _settextposition(slinenum+1, 1);
-#endif
-}
-
-#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
-/*
- * Create an alternate screen which is all white.
- * This screen is used to create a "flash" effect, by displaying it
- * briefly and then switching back to the normal screen.
- * {{ Yuck! There must be a better way to get a visual bell. }}
- */
- static void
-create_flash()
+void
+goto_line(int slinenum)
{
-#if MSDOS_COMPILER==MSOFTC
- struct videoconfig w;
- char *blanks;
- int row, col;
-
- _getvideoconfig(&w);
- videopages = w.numvideopages;
- if (videopages < 2)
- {
- at_enter(AT_STANDOUT);
- at_exit();
- } else
- {
- _setactivepage(1);
- at_enter(AT_STANDOUT);
- blanks = (char *) ecalloc(w.numtextcols, sizeof(char));
- for (col = 0; col < w.numtextcols; col++)
- blanks[col] = ' ';
- for (row = w.numtextrows; row > 0; row--)
- _outmem(blanks, w.numtextcols);
- _setactivepage(0);
- _setvisualpage(0);
- free(blanks);
- at_exit();
- }
-#else
-#if MSDOS_COMPILER==BORLANDC
- register int n;
-
- whitescreen = (unsigned short *)
- malloc(sc_width * sc_height * sizeof(short));
- if (whitescreen == NULL)
- return;
- for (n = 0; n < sc_width * sc_height; n++)
- whitescreen[n] = 0x7020;
-#else
-#if MSDOS_COMPILER==WIN32C
- register int n;
-
- whitescreen = (WORD *)
- malloc(sc_height * sc_width * sizeof(WORD));
- if (whitescreen == NULL)
- return;
- /* Invert the standard colors. */
- for (n = 0; n < sc_width * sc_height; n++)
- whitescreen[n] = (WORD)((nm_fg_color << 4) | nm_bg_color);
-#endif
-#endif
-#endif
- flash_created = 1;
+ (void) tputs(tparm(sc_move, slinenum, 0, 0, 0, 0, 0, 0, 0, 0), 1,
+ putchr);
}
-#endif /* MSDOS_COMPILER */
/*
* Output the "visual bell", if there is one.
*/
- public void
-vbell()
+void
+vbell(void)
{
-#if !MSDOS_COMPILER
if (*sc_visual_bell == '\0')
return;
- tputs(sc_visual_bell, sc_height, putchr);
-#else
-#if MSDOS_COMPILER==DJGPPC
- ScreenVisualBell();
-#else
-#if MSDOS_COMPILER==MSOFTC
- /*
- * Create a flash screen on the second video page.
- * Switch to that page, then switch back.
- */
- if (!flash_created)
- create_flash();
- if (videopages < 2)
- return;
- _setvisualpage(1);
- delay(100);
- _setvisualpage(0);
-#else
-#if MSDOS_COMPILER==BORLANDC
- unsigned short *currscreen;
-
- /*
- * Get a copy of the current screen.
- * Display the flash screen.
- * Then restore the old screen.
- */
- if (!flash_created)
- create_flash();
- if (whitescreen == NULL)
- return;
- currscreen = (unsigned short *)
- malloc(sc_width * sc_height * sizeof(short));
- if (currscreen == NULL) return;
- gettext(1, 1, sc_width, sc_height, currscreen);
- puttext(1, 1, sc_width, sc_height, whitescreen);
- delay(100);
- puttext(1, 1, sc_width, sc_height, currscreen);
- free(currscreen);
-#else
-#if MSDOS_COMPILER==WIN32C
- /* paint screen with an inverse color */
- clear();
-
- /* leave it displayed for 100 msec. */
- Sleep(100);
-
- /* restore with a redraw */
- repaint();
-#endif
-#endif
-#endif
-#endif
-#endif
+ (void) tputs(sc_visual_bell, sc_height, putchr);
}
/*
* Make a noise.
*/
- static void
-beep()
+static void
+beep(void)
{
-#if !MSDOS_COMPILER
- putchr(CONTROL('G'));
-#else
-#if MSDOS_COMPILER==WIN32C
- MessageBeep(0);
-#else
- write(STDOUT_FILENO, "\7", 1);
-#endif
-#endif
+ (void) putchr(CONTROL('G'));
}
/*
* Ring the terminal bell.
*/
- public void
-bell()
+void
+ring_bell(void)
{
if (quiet == VERY_QUIET)
vbell();
@@ -2067,103 +649,41 @@ bell()
/*
* Clear the screen.
*/
- public void
-clear()
+void
+do_clear(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_clear, sc_height, putchr);
-#else
- flush();
-#if MSDOS_COMPILER==WIN32C
- win32_clear();
-#else
- _clearscreen(_GCLEARSCREEN);
-#endif
-#endif
+ (void) tputs(sc_clear, sc_height, putchr);
}
/*
* Clear from the cursor to the end of the cursor's line.
* {{ This must not move the cursor. }}
*/
- public void
-clear_eol()
+void
+clear_eol(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_eol_clear, 1, putchr);
-#else
-#if MSDOS_COMPILER==MSOFTC
- short top, left;
- short bot, right;
- struct rccoord tpos;
-
- flush();
- /*
- * Save current state.
- */
- tpos = _gettextposition();
- _gettextwindow(&top, &left, &bot, &right);
- /*
- * Set a temporary window to the current line,
- * from the cursor's position to the right edge of the screen.
- * Then clear that window.
- */
- _settextwindow(tpos.row, tpos.col, tpos.row, sc_width);
- _clearscreen(_GWINDOW);
- /*
- * Restore state.
- */
- _settextwindow(top, left, bot, right);
- _settextposition(tpos.row, tpos.col);
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- flush();
- clreol();
-#else
-#if MSDOS_COMPILER==WIN32C
- DWORD nchars;
- COORD cpos;
- CONSOLE_SCREEN_BUFFER_INFO scr;
-
- flush();
- memset(&scr, 0, sizeof(scr));
- GetConsoleScreenBufferInfo(con_out, &scr);
- cpos.X = scr.dwCursorPosition.X;
- cpos.Y = scr.dwCursorPosition.Y;
- curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
- FillConsoleOutputAttribute(con_out, curr_attr,
- scr.dwSize.X - cpos.X, cpos, &nchars);
- FillConsoleOutputCharacter(con_out, ' ',
- scr.dwSize.X - cpos.X, cpos, &nchars);
-#endif
-#endif
-#endif
-#endif
+ (void) tputs(sc_eol_clear, 1, putchr);
}
/*
* Clear the current line.
* Clear the screen if there's off-screen memory below the display.
*/
- static void
-clear_eol_bot()
+static void
+clear_eol_bot(void)
{
-#if MSDOS_COMPILER
- clear_eol();
-#else
if (below_mem)
- tputs(sc_eos_clear, 1, putchr);
+ (void) tputs(sc_eos_clear, 1, putchr);
else
- tputs(sc_eol_clear, 1, putchr);
-#endif
+ (void) tputs(sc_eol_clear, 1, putchr);
}
/*
* Clear the bottom line of the display.
* Leave the cursor at the beginning of the bottom line.
*/
- public void
-clear_bot()
+void
+clear_bot(void)
{
/*
* If we're in a non-normal attribute mode, temporarily exit
@@ -2187,84 +707,54 @@ clear_bot()
}
}
- public void
-at_enter(attr)
- int attr;
+void
+at_enter(int attr)
{
attr = apply_at_specials(attr);
-#if !MSDOS_COMPILER
/* The one with the most priority is last. */
if (attr & AT_UNDERLINE)
- tputs(sc_u_in, 1, putchr);
+ (void) tputs(sc_u_in, 1, putchr);
if (attr & AT_BOLD)
- tputs(sc_b_in, 1, putchr);
+ (void) tputs(sc_b_in, 1, putchr);
if (attr & AT_BLINK)
- tputs(sc_bl_in, 1, putchr);
+ (void) tputs(sc_bl_in, 1, putchr);
if (attr & AT_STANDOUT)
- tputs(sc_s_in, 1, putchr);
-#else
- flush();
- /* The one with the most priority is first. */
- if (attr & AT_STANDOUT)
- {
- SETCOLORS(so_fg_color, so_bg_color);
- } else if (attr & AT_BLINK)
- {
- SETCOLORS(bl_fg_color, bl_bg_color);
- }
- else if (attr & AT_BOLD)
- {
- SETCOLORS(bo_fg_color, bo_bg_color);
- }
- else if (attr & AT_UNDERLINE)
- {
- SETCOLORS(ul_fg_color, ul_bg_color);
- }
-#endif
+ (void) tputs(sc_s_in, 1, putchr);
attrmode = attr;
}
- public void
-at_exit()
+void
+at_exit(void)
{
-#if !MSDOS_COMPILER
/* Undo things in the reverse order we did them. */
if (attrmode & AT_STANDOUT)
- tputs(sc_s_out, 1, putchr);
+ (void) tputs(sc_s_out, 1, putchr);
if (attrmode & AT_BLINK)
- tputs(sc_bl_out, 1, putchr);
+ (void) tputs(sc_bl_out, 1, putchr);
if (attrmode & AT_BOLD)
- tputs(sc_b_out, 1, putchr);
+ (void) tputs(sc_b_out, 1, putchr);
if (attrmode & AT_UNDERLINE)
- tputs(sc_u_out, 1, putchr);
-#else
- flush();
- SETCOLORS(nm_fg_color, nm_bg_color);
-#endif
+ (void) tputs(sc_u_out, 1, putchr);
attrmode = AT_NORMAL;
}
- public void
-at_switch(attr)
- int attr;
+void
+at_switch(int attr)
{
int new_attrmode = apply_at_specials(attr);
int ignore_modes = AT_ANSI;
- if ((new_attrmode & ~ignore_modes) != (attrmode & ~ignore_modes))
- {
+ if ((new_attrmode & ~ignore_modes) != (attrmode & ~ignore_modes)) {
at_exit();
at_enter(attr);
}
}
- public int
-is_at_equiv(attr1, attr2)
- int attr1;
- int attr2;
+int
+is_at_equiv(int attr1, int attr2)
{
attr1 = apply_at_specials(attr1);
attr2 = apply_at_specials(attr2);
@@ -2272,9 +762,8 @@ is_at_equiv(attr1, attr2)
return (attr1 == attr2);
}
- public int
-apply_at_specials(attr)
- int attr;
+int
+apply_at_specials(int attr)
{
if (attr & AT_BINARY)
attr |= binattr;
@@ -2282,224 +771,14 @@ apply_at_specials(attr)
attr |= AT_STANDOUT;
attr &= ~(AT_BINARY|AT_HILITE);
- return attr;
-}
-
-#if 0 /* No longer used */
-/*
- * Erase the character to the left of the cursor
- * and move the cursor left.
- */
- public void
-backspace()
-{
-#if !MSDOS_COMPILER
- /*
- * Erase the previous character by overstriking with a space.
- */
- tputs(sc_backspace, 1, putchr);
- putchr(' ');
- tputs(sc_backspace, 1, putchr);
-#else
-#if MSDOS_COMPILER==MSOFTC
- struct rccoord tpos;
-
- flush();
- tpos = _gettextposition();
- if (tpos.col <= 1)
- return;
- _settextposition(tpos.row, tpos.col-1);
- _outtext(" ");
- _settextposition(tpos.row, tpos.col-1);
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- cputs("\b");
-#else
-#if MSDOS_COMPILER==WIN32C
- COORD cpos;
- DWORD cChars;
- CONSOLE_SCREEN_BUFFER_INFO scr;
-
- flush();
- GetConsoleScreenBufferInfo(con_out, &scr);
- cpos = scr.dwCursorPosition;
- if (cpos.X <= 0)
- return;
- cpos.X--;
- SetConsoleCursorPosition(con_out, cpos);
- FillConsoleOutputCharacter(con_out, (TCHAR)' ', 1, cpos, &cChars);
- SetConsoleCursorPosition(con_out, cpos);
-#endif
-#endif
-#endif
-#endif
+ return (attr);
}
-#endif /* 0 */
/*
* Output a plain backspace, without erasing the previous char.
*/
- public void
-putbs()
+void
+putbs(void)
{
-#if !MSDOS_COMPILER
- tputs(sc_backspace, 1, putchr);
-#else
- int row, col;
-
- flush();
- {
-#if MSDOS_COMPILER==MSOFTC
- struct rccoord tpos;
- tpos = _gettextposition();
- row = tpos.row;
- col = tpos.col;
-#else
-#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- row = wherey();
- col = wherex();
-#else
-#if MSDOS_COMPILER==WIN32C
- CONSOLE_SCREEN_BUFFER_INFO scr;
- GetConsoleScreenBufferInfo(con_out, &scr);
- row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1;
- col = scr.dwCursorPosition.X - scr.srWindow.Left + 1;
-#endif
-#endif
-#endif
- }
- if (col <= 1)
- return;
- _settextposition(row, col-1);
-#endif /* MSDOS_COMPILER */
+ (void) tputs(sc_backspace, 1, putchr);
}
-
-#if MSDOS_COMPILER==WIN32C
-/*
- * Determine whether an input character is waiting to be read.
- */
- static int
-win32_kbhit(tty)
- HANDLE tty;
-{
- INPUT_RECORD ip;
- DWORD read;
-
- if (keyCount > 0)
- return (TRUE);
-
- currentKey.ascii = 0;
- currentKey.scan = 0;
-
- /*
- * Wait for a real key-down event, but
- * ignore SHIFT and CONTROL key events.
- */
- do
- {
- PeekConsoleInput(tty, &ip, 1, &read);
- if (read == 0)
- return (FALSE);
- ReadConsoleInput(tty, &ip, 1, &read);
- } while (ip.EventType != KEY_EVENT ||
- ip.Event.KeyEvent.bKeyDown != TRUE ||
- ip.Event.KeyEvent.wVirtualScanCode == 0 ||
- ip.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT ||
- ip.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL ||
- ip.Event.KeyEvent.wVirtualKeyCode == VK_MENU);
-
- currentKey.ascii = ip.Event.KeyEvent.uChar.AsciiChar;
- currentKey.scan = ip.Event.KeyEvent.wVirtualScanCode;
- keyCount = ip.Event.KeyEvent.wRepeatCount;
-
- if (ip.Event.KeyEvent.dwControlKeyState &
- (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
- {
- switch (currentKey.scan)
- {
- case PCK_ALT_E: /* letter 'E' */
- currentKey.ascii = 0;
- break;
- }
- } else if (ip.Event.KeyEvent.dwControlKeyState &
- (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
- {
- switch (currentKey.scan)
- {
- case PCK_RIGHT: /* right arrow */
- currentKey.scan = PCK_CTL_RIGHT;
- break;
- case PCK_LEFT: /* left arrow */
- currentKey.scan = PCK_CTL_LEFT;
- break;
- case PCK_DELETE: /* delete */
- currentKey.scan = PCK_CTL_DELETE;
- break;
- }
- }
- return (TRUE);
-}
-
-/*
- * Read a character from the keyboard.
- */
- public char
-WIN32getch(tty)
- int tty;
-{
- int ascii;
-
- if (pending_scancode)
- {
- pending_scancode = 0;
- return ((char)(currentKey.scan & 0x00FF));
- }
-
- while (win32_kbhit((HANDLE)tty) == FALSE)
- {
- Sleep(20);
- if (ABORT_SIGS())
- return ('\003');
- continue;
- }
- keyCount --;
- ascii = currentKey.ascii;
- /*
- * On PC's, the extended keys return a 2 byte sequence beginning
- * with '00', so if the ascii code is 00, the next byte will be
- * the lsb of the scan code.
- */
- pending_scancode = (ascii == 0x00);
- return ((char)ascii);
-}
-#endif
-
-#if MSDOS_COMPILER
-/*
- */
- public void
-WIN32setcolors(fg, bg)
- int fg;
- int bg;
-{
- SETCOLORS(fg, bg);
-}
-
-/*
- */
- public void
-WIN32textout(text, len)
- char *text;
- int len;
-{
-#if MSDOS_COMPILER==WIN32C
- DWORD written;
- WriteConsole(con_out, text, len, &written, NULL);
-#else
- char c = text[len];
- text[len] = '\0';
- cputs(text);
- text[len] = c;
-#endif
-}
-#endif
diff --git a/usr.bin/less/scrsize.c b/usr.bin/less/scrsize.c
deleted file mode 100644
index 9af7e345cae..00000000000
--- a/usr.bin/less/scrsize.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 1984-2002 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.
- */
-
-/*
- * This program is used to determine the screen dimensions on OS/2 systems.
- * Adapted from code written by Kyosuke Tokoro (NBG01720@nifty.ne.jp).
- */
-
-/*
- * When I wrote this routine, I consulted some part of the source code
- * of the xwininfo utility by X Consortium.
- *
- * Copyright (c) 1987, X Consortium
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the X Consortium shall not
- * be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization from the X
- * Consortium.
- */
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-static int get_winsize(dpy, window, p_width, p_height)
- Display *dpy;
- Window window;
- int *p_width;
- int *p_height;
-{
- XWindowAttributes win_attributes;
- XSizeHints hints;
- long longjunk;
-
- if (!XGetWindowAttributes(dpy, window, &win_attributes))
- return 1;
- if (!XGetWMNormalHints(dpy, window, &hints, &longjunk))
- return 1;
- if (!(hints.flags & PResizeInc))
- return 1;
- if (hints.width_inc == 0 || hints.height_inc == 0)
- return 1;
- if (!(hints.flags & (PBaseSize|PMinSize)))
- return 1;
- if (hints.flags & PBaseSize)
- {
- win_attributes.width -= hints.base_width;
- win_attributes.height -= hints.base_height;
- } else
- {
- win_attributes.width -= hints.min_width;
- win_attributes.height -= hints.min_height;
- }
- *p_width = win_attributes.width / hints.width_inc;
- *p_height = win_attributes.height / hints.height_inc;
- return 0;
-}
-
-int main(argc, argv)
- int argc;
- char *argv[];
-{
- char *cp;
- Display *dpy;
- int size[2];
-
- _scrsize(size);
- cp = getenv("WINDOWID");
- if (cp != NULL)
- {
- dpy = XOpenDisplay(NULL);
- if (dpy != NULL)
- {
- get_winsize(dpy, (Window) atol(cp), &size[0], &size[1]);
- XCloseDisplay(dpy);
- }
- }
- printf("%i %i\n", size[0], size[1]);
- return (0);
-}
diff --git a/usr.bin/less/search.c b/usr.bin/less/search.c
index 770a0623ced..871d2e46948 100644
--- a/usr.bin/less/search.c
+++ b/usr.bin/less/search.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines to search a file for a pattern.
@@ -17,8 +20,8 @@
#include "position.h"
#include "charset.h"
-#define MINPOS(a,b) (((a) < (b)) ? (a) : (b))
-#define MAXPOS(a,b) (((a) > (b)) ? (a) : (b))
+#define MINPOS(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXPOS(a, b) (((a) > (b)) ? (a) : (b))
extern volatile sig_atomic_t sigs;
extern int how_search;
@@ -29,67 +32,57 @@ extern int jump_sline;
extern int bs_mode;
extern int ctldisp;
extern int status_col;
-extern void * constant ml_search;
-extern POSITION start_attnpos;
-extern POSITION end_attnpos;
+extern void *const ml_search;
+extern off_t start_attnpos;
+extern off_t end_attnpos;
extern int utf_mode;
extern int screen_trashed;
-#if HILITE_SEARCH
extern int hilite_search;
extern int size_linebuf;
extern int squished;
extern int can_goto_line;
-extern int less_is_more;
static int hide_hilite;
-static POSITION prep_startpos;
-static POSITION prep_endpos;
+static off_t prep_startpos;
+static off_t prep_endpos;
static int is_caseless;
static int is_ucase_pattern;
-struct hilite
-{
+struct hilite {
struct hilite *hl_next;
- POSITION hl_startpos;
- POSITION hl_endpos;
+ off_t hl_startpos;
+ off_t hl_endpos;
};
-static struct hilite hilite_anchor = { NULL, NULL_POSITION, NULL_POSITION };
-static struct hilite filter_anchor = { NULL, NULL_POSITION, NULL_POSITION };
+static struct hilite hilite_anchor = { NULL, -1, -1 };
+static struct hilite filter_anchor = { NULL, -1, -1 };
#define hl_first hl_next
-#endif
/*
* These are the static variables that represent the "remembered"
* search pattern and filter pattern.
*/
struct pattern_info {
- DEFINE_PATTERN(compiled);
- char* text;
+ regex_t *compiled;
+ char *text;
int search_type;
};
-#if NO_REGEX
-#define info_compiled(info) ((void*)0)
-#else
-#define info_compiled(info) ((info)->compiled)
-#endif
-
+#define info_compiled(info) ((info)->compiled)
+
static struct pattern_info search_info;
static struct pattern_info filter_info;
/*
* Are there any uppercase letters in this string?
*/
- static int
-is_ucase(str)
- char *str;
+static int
+is_ucase(char *str)
{
char *str_end = str + strlen(str);
LWCHAR ch;
- while (str < str_end)
- {
+ while (str < str_end) {
ch = step_char(&str, +1, str_end);
- if (IS_UPPER(ch))
+ if (isupper(ch))
return (1);
}
return (0);
@@ -98,24 +91,20 @@ is_ucase(str)
/*
* Compile and save a search pattern.
*/
- static int
-set_pattern(info, pattern, search_type)
- struct pattern_info *info;
- char *pattern;
- int search_type;
+static int
+set_pattern(struct pattern_info *info, char *pattern, int search_type)
{
-#if !NO_REGEX
if (pattern == NULL)
- CLEAR_PATTERN(info->compiled);
+ info->compiled = NULL;
else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
- return -1;
-#endif
+ return (-1);
/* Pattern compiled successfully; save the text too. */
if (info->text != NULL)
free(info->text);
info->text = NULL;
- if (pattern != NULL)
- info->text = save(pattern);
+ if (pattern != NULL) {
+ info->text = estrdup(pattern);
+ }
info->search_type = search_type;
/*
@@ -123,36 +112,32 @@ set_pattern(info, pattern, search_type)
* -i is set AND the pattern is all lowercase.
*/
is_ucase_pattern = is_ucase(pattern);
- if (is_ucase_pattern && caseless != OPT_ONPLUS && (caseless != OPT_ON || !less_is_more))
+ if (is_ucase_pattern && caseless != OPT_ONPLUS)
is_caseless = 0;
else
is_caseless = caseless;
- return 0;
+ return (0);
}
/*
* Discard a saved pattern.
*/
- static void
-clear_pattern(info)
- struct pattern_info *info;
+static void
+clear_pattern(struct pattern_info *info)
{
if (info->text != NULL)
free(info->text);
info->text = NULL;
-#if !NO_REGEX
uncompile_pattern(&info->compiled);
-#endif
}
/*
* Initialize saved pattern to nothing.
*/
- static void
-init_pattern(info)
- struct pattern_info *info;
+static void
+init_pattern(struct pattern_info *info)
{
- CLEAR_PATTERN(info->compiled);
+ info->compiled = NULL;
info->text = NULL;
info->search_type = 0;
}
@@ -160,8 +145,8 @@ init_pattern(info)
/*
* Initialize search variables.
*/
- public void
-init_search()
+void
+init_search(void)
{
init_pattern(&search_info);
init_pattern(&filter_info);
@@ -170,20 +155,18 @@ init_search()
/*
* Determine which text conversions to perform before pattern matching.
*/
- static int
-get_cvt_ops()
+static int
+get_cvt_ops(void)
{
int ops = 0;
- if (is_caseless || bs_mode == BS_SPECIAL)
- {
- if (is_caseless)
+ if (is_caseless || bs_mode == BS_SPECIAL) {
+ if (is_caseless)
ops |= CVT_TO_LC;
if (bs_mode == BS_SPECIAL)
ops |= CVT_BS;
if (bs_mode != BS_CONTROL)
ops |= CVT_CRLF;
- } else if (bs_mode != BS_CONTROL)
- {
+ } else if (bs_mode != BS_CONTROL) {
ops |= CVT_CRLF;
}
if (ctldisp == OPT_ONPLUS)
@@ -194,56 +177,46 @@ get_cvt_ops()
/*
* Is there a previous (remembered) search pattern?
*/
- static int
-prev_pattern(info)
- struct pattern_info *info;
+static int
+prev_pattern(struct pattern_info *info)
{
-#if !NO_REGEX
if ((info->search_type & SRCH_NO_REGEX) == 0)
return (!is_null_pattern(info->compiled));
-#endif
return (info->text != NULL);
}
-#if HILITE_SEARCH
/*
* Repaint the hilites currently displayed on the screen.
* Repaint each line which contains highlighted text.
* If on==0, force all hilites off.
*/
- public void
-repaint_hilite(on)
- int on;
+void
+repaint_hilite(int on)
{
int slinenum;
- POSITION pos;
- POSITION epos;
+ off_t pos;
int save_hide_hilite;
if (squished)
repaint();
save_hide_hilite = hide_hilite;
- if (!on)
- {
+ if (!on) {
if (hide_hilite)
return;
hide_hilite = 1;
}
- if (!can_goto_line)
- {
+ if (!can_goto_line) {
repaint();
hide_hilite = save_hide_hilite;
return;
}
- for (slinenum = TOP; slinenum < TOP + sc_height-1; slinenum++)
- {
+ for (slinenum = TOP; slinenum < TOP + sc_height-1; slinenum++) {
pos = position(slinenum);
- if (pos == NULL_POSITION)
+ if (pos == -1)
continue;
- epos = position(slinenum+1);
(void) forw_line(pos);
goto_line(slinenum);
put_line();
@@ -255,39 +228,36 @@ repaint_hilite(on)
/*
* Clear the attn hilite.
*/
- public void
-clear_attn()
+void
+clear_attn(void)
{
int slinenum;
- POSITION old_start_attnpos;
- POSITION old_end_attnpos;
- POSITION pos;
- POSITION epos;
+ off_t old_start_attnpos;
+ off_t old_end_attnpos;
+ off_t pos;
+ off_t epos;
int moved = 0;
- if (start_attnpos == NULL_POSITION)
+ if (start_attnpos == -1)
return;
old_start_attnpos = start_attnpos;
old_end_attnpos = end_attnpos;
- start_attnpos = end_attnpos = NULL_POSITION;
+ start_attnpos = end_attnpos = -1;
- if (!can_goto_line)
- {
+ if (!can_goto_line) {
repaint();
return;
}
if (squished)
repaint();
- for (slinenum = TOP; slinenum < TOP + sc_height-1; slinenum++)
- {
+ for (slinenum = TOP; slinenum < TOP + sc_height-1; slinenum++) {
pos = position(slinenum);
- if (pos == NULL_POSITION)
+ if (pos == -1)
continue;
epos = position(slinenum+1);
if (pos < old_end_attnpos &&
- (epos == NULL_POSITION || epos > old_start_attnpos))
- {
+ (epos == -1 || epos > old_start_attnpos)) {
(void) forw_line(pos);
goto_line(slinenum);
put_line();
@@ -297,53 +267,46 @@ clear_attn()
if (moved)
lower_left();
}
-#endif
/*
* Hide search string highlighting.
*/
- public void
-undo_search()
+void
+undo_search(void)
{
- if (!prev_pattern(&search_info))
- {
+ if (!prev_pattern(&search_info)) {
error("No previous regular expression", NULL_PARG);
return;
}
-#if HILITE_SEARCH
hide_hilite = !hide_hilite;
repaint_hilite(1);
-#endif
}
-#if HILITE_SEARCH
/*
* Clear the hilite list.
*/
- public void
-clr_hlist(anchor)
- struct hilite *anchor;
+static void
+clr_hlist(struct hilite *anchor)
{
struct hilite *hl;
struct hilite *nexthl;
- for (hl = anchor->hl_first; hl != NULL; hl = nexthl)
- {
+ for (hl = anchor->hl_first; hl != NULL; hl = nexthl) {
nexthl = hl->hl_next;
free((void*)hl);
}
anchor->hl_first = NULL;
- prep_startpos = prep_endpos = NULL_POSITION;
+ prep_startpos = prep_endpos = -1;
}
- public void
-clr_hilite()
+void
+clr_hilite(void)
{
clr_hlist(&hilite_anchor);
}
- public void
-clr_filter()
+static void
+clr_filter(void)
{
clr_hlist(&filter_anchor);
}
@@ -352,30 +315,26 @@ clr_filter()
* Should any characters in a specified range be highlighted?
*/
static int
-is_hilited_range(pos, epos)
- POSITION pos;
- POSITION epos;
+is_hilited_range(off_t pos, off_t epos)
{
struct hilite *hl;
/*
* Look at each highlight and see if any part of it falls in the range.
*/
- for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next)
- {
+ for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next) {
if (hl->hl_endpos > pos &&
- (epos == NULL_POSITION || epos > hl->hl_startpos))
+ (epos == -1 || epos > hl->hl_startpos))
return (1);
}
return (0);
}
-/*
+/*
* Is a line "filtered" -- that is, should it be hidden?
*/
- public int
-is_filtered(pos)
- POSITION pos;
+int
+is_filtered(off_t pos)
{
struct hilite *hl;
@@ -386,8 +345,7 @@ is_filtered(pos)
* Look at each filter and see if the start position
* equals the start position of the line.
*/
- for (hl = filter_anchor.hl_first; hl != NULL; hl = hl->hl_next)
- {
+ for (hl = filter_anchor.hl_first; hl != NULL; hl = hl->hl_next) {
if (hl->hl_startpos == pos)
return (1);
}
@@ -398,12 +356,8 @@ is_filtered(pos)
* Should any characters in a specified range be highlighted?
* If nohide is nonzero, don't consider hide_hilite.
*/
- public int
-is_hilited(pos, epos, nohide, p_matches)
- POSITION pos;
- POSITION epos;
- int nohide;
- int *p_matches;
+int
+is_hilited(off_t pos, off_t epos, int nohide, int *p_matches)
{
int match;
@@ -411,9 +365,9 @@ is_hilited(pos, epos, nohide, p_matches)
*p_matches = 0;
if (!status_col &&
- start_attnpos != NULL_POSITION &&
+ start_attnpos != -1 &&
pos < end_attnpos &&
- (epos == NULL_POSITION || epos > start_attnpos))
+ (epos == -1 || epos > start_attnpos))
/*
* The attn line overlaps this range.
*/
@@ -447,10 +401,8 @@ is_hilited(pos, epos, nohide, p_matches)
/*
* Add a new hilite to a hilite list.
*/
- static void
-add_hilite(anchor, hl)
- struct hilite *anchor;
- struct hilite *hl;
+static void
+add_hilite(struct hilite *anchor, struct hilite *hl)
{
struct hilite *ihl;
@@ -471,9 +423,9 @@ add_hilite(anchor, hl)
if (ihl != anchor)
hl->hl_startpos = MAXPOS(hl->hl_startpos, ihl->hl_endpos);
if (ihl->hl_next != NULL)
- hl->hl_endpos = MINPOS(hl->hl_endpos, ihl->hl_next->hl_startpos);
- if (hl->hl_startpos >= hl->hl_endpos)
- {
+ hl->hl_endpos = MINPOS(hl->hl_endpos,
+ ihl->hl_next->hl_startpos);
+ if (hl->hl_startpos >= hl->hl_endpos) {
/*
* Hilite was truncated out of existence.
*/
@@ -487,18 +439,14 @@ add_hilite(anchor, hl)
/*
* Hilight every character in a range of displayed characters.
*/
- static void
-create_hilites(linepos, start_index, end_index, chpos)
- POSITION linepos;
- int start_index;
- int end_index;
- int *chpos;
+static void
+create_hilites(off_t linepos, int start_index, int end_index, int *chpos)
{
struct hilite *hl;
int i;
/* Start the first hilite. */
- hl = (struct hilite *) ecalloc(1, sizeof(struct hilite));
+ hl = ecalloc(1, sizeof (struct hilite));
hl->hl_startpos = linepos + chpos[start_index];
/*
@@ -509,16 +457,13 @@ create_hilites(linepos, start_index, end_index, chpos)
* Otherwise (there are backspaces or something involved),
* finish the current hilite and start a new one.
*/
- for (i = start_index+1; i <= end_index; i++)
- {
- if (chpos[i] != chpos[i-1] + 1 || i == end_index)
- {
+ for (i = start_index+1; i <= end_index; i++) {
+ if (chpos[i] != chpos[i-1] + 1 || i == end_index) {
hl->hl_endpos = linepos + chpos[i-1] + 1;
add_hilite(&hilite_anchor, hl);
/* Start new hilite unless this is the last char. */
- if (i < end_index)
- {
- hl = (struct hilite *) ecalloc(1, sizeof(struct hilite));
+ if (i < end_index) {
+ hl = ecalloc(1, sizeof (struct hilite));
hl->hl_startpos = linepos + chpos[i];
}
}
@@ -526,19 +471,13 @@ create_hilites(linepos, start_index, end_index, chpos)
}
/*
- * Make a hilite for each string in a physical line which matches
+ * Make a hilite for each string in a physical line which matches
* the current pattern.
* sp,ep delimit the first match already found.
*/
- static void
-hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
- POSITION linepos;
- char *line;
- int line_len;
- int *chpos;
- char *sp;
- char *ep;
- int cvt_ops;
+static void
+hilite_line(off_t linepos, char *line, int line_len, int *chpos,
+ char *sp, char *ep)
{
char *searchp;
char *line_end = line + line_len;
@@ -557,7 +496,8 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
*/
searchp = line;
do {
- create_hilites(linepos, sp-line, ep-line, chpos);
+ create_hilites(linepos, (intptr_t)sp - (intptr_t)line,
+ (intptr_t)ep - (intptr_t)line, chpos);
/*
* If we matched more than zero characters,
* move to the first char after the string we matched.
@@ -570,16 +510,16 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
else /* end of line */
break;
} while (match_pattern(info_compiled(&search_info), search_info.text,
- searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type));
+ searchp, (intptr_t)line_end - (intptr_t)searchp, &sp, &ep, 1,
+ search_info.search_type));
}
-#endif
/*
- * Change the caseless-ness of searches.
+ * Change the caseless-ness of searches.
* Updates the internal search state to reflect a change in the -i flag.
*/
- public void
-chg_caseless()
+void
+chg_caseless(void)
{
if (!is_ucase_pattern)
/*
@@ -595,17 +535,16 @@ chg_caseless()
clear_pattern(&search_info);
}
-#if HILITE_SEARCH
/*
* Find matching text which is currently on screen and highlight it.
*/
- static void
-hilite_screen()
+static void
+hilite_screen(void)
{
struct scrpos scrpos;
get_scrpos(&scrpos);
- if (scrpos.pos == NULL_POSITION)
+ if (scrpos.pos == -1)
return;
prep_hilite(scrpos.pos, position(BOTTOM_PLUS_ONE), -1);
repaint_hilite(1);
@@ -614,8 +553,8 @@ hilite_screen()
/*
* Change highlighting parameters.
*/
- public void
-chg_hilite()
+void
+chg_hilite(void)
{
/*
* Erase any highlights currently on screen.
@@ -629,46 +568,38 @@ chg_hilite()
*/
hilite_screen();
}
-#endif
/*
* Figure out where to start a search.
*/
- static POSITION
-search_pos(search_type)
- int search_type;
+static off_t
+search_pos(int search_type)
{
- POSITION pos;
+ off_t pos;
int linenum;
- if (empty_screen())
- {
+ if (empty_screen()) {
/*
* Start at the beginning (or end) of the file.
- * The empty_screen() case is mainly for
+ * The empty_screen() case is mainly for
* command line initiated searches;
* for example, "+/xyz" on the command line.
* Also for multi-file (SRCH_PAST_EOF) searches.
*/
- if (search_type & SRCH_FORW)
- {
+ if (search_type & SRCH_FORW) {
pos = ch_zero();
- } else
- {
+ } else {
pos = ch_length();
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
(void) ch_end_seek();
pos = ch_length();
}
}
linenum = 0;
- } else
- {
+ } else {
int add_one = 0;
- if (how_search == OPT_ON)
- {
+ if (how_search == OPT_ON) {
/*
* Search does not include current screen.
*/
@@ -676,8 +607,8 @@ search_pos(search_type)
linenum = BOTTOM_PLUS_ONE;
else
linenum = TOP;
- } else if (how_search == OPT_ONPLUS && !(search_type & SRCH_AFTER_TARGET))
- {
+ } else if (how_search == OPT_ONPLUS &&
+ !(search_type & SRCH_AFTER_TARGET)) {
/*
* Search includes all of displayed screen.
*/
@@ -685,42 +616,39 @@ search_pos(search_type)
linenum = TOP;
else
linenum = BOTTOM_PLUS_ONE;
- } else
- {
+ } else {
/*
- * Search includes the part of current screen beyond the jump target.
- * It starts at the jump target (if searching backwards),
- * or at the jump target plus one (if forwards).
+ * Search includes the part of current screen beyond
+ * the jump target.
+ * It starts at the jump target (if searching
+ * backwards), or at the jump target plus one
+ * (if forwards).
*/
linenum = jump_sline;
- if (search_type & SRCH_FORW)
- add_one = 1;
+ if (search_type & SRCH_FORW)
+ add_one = 1;
}
linenum = adjsline(linenum);
pos = position(linenum);
if (add_one)
- pos = forw_raw_line(pos, (char **)NULL, (int *)NULL);
+ pos = forw_raw_line(pos, NULL, NULL);
}
/*
* If the line is empty, look around for a plausible starting place.
*/
- if (search_type & SRCH_FORW)
- {
- while (pos == NULL_POSITION)
- {
- if (++linenum >= sc_height)
- break;
- pos = position(linenum);
- }
- } else
- {
- while (pos == NULL_POSITION)
- {
- if (--linenum < 0)
- break;
- pos = position(linenum);
- }
+ if (search_type & SRCH_FORW) {
+ while (pos == -1) {
+ if (++linenum >= sc_height)
+ break;
+ pos = position(linenum);
+ }
+ } else {
+ while (pos == -1) {
+ if (--linenum < 0)
+ break;
+ pos = position(linenum);
+ }
}
return (pos);
}
@@ -728,15 +656,9 @@ search_pos(search_type)
/*
* Search a subset of the file, specified by start/end position.
*/
- static int
-search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
- POSITION pos;
- POSITION endpos;
- int search_type;
- int matches;
- int maxlines;
- POSITION *plinepos;
- POSITION *pendpos;
+static int
+search_range(off_t pos, off_t endpos, int search_type, int matches,
+ int maxlines, off_t *plinepos, off_t *pendpos)
{
char *line;
char *cline;
@@ -747,27 +669,25 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
int cvt_ops;
int cvt_len;
int *chpos;
- POSITION linepos, oldpos;
+ off_t linepos, oldpos;
linenum = find_linenum(pos);
oldpos = pos;
- for (;;)
- {
+ for (;;) {
/*
* Get lines until we find a matching one or until
- * we hit end-of-file (or beginning-of-file if we're
+ * we hit end-of-file (or beginning-of-file if we're
* going backwards), or until we hit the end position.
*/
- if (ABORT_SIGS())
- {
+ if (ABORT_SIGS()) {
/*
* A signal aborts the search.
*/
return (-1);
}
- if ((endpos != NULL_POSITION && pos >= endpos) || maxlines == 0)
- {
+ if ((endpos != -1 && pos >= endpos) ||
+ maxlines == 0) {
/*
* Reached end position without a match.
*/
@@ -778,18 +698,16 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
if (maxlines > 0)
maxlines--;
- if (search_type & SRCH_FORW)
- {
+ if (search_type & SRCH_FORW) {
/*
- * Read the next line, and save the
+ * Read the next line, and save the
* starting position of that line in linepos.
*/
linepos = pos;
pos = forw_raw_line(pos, &line, &line_len);
if (linenum != 0)
linenum++;
- } else
- {
+ } else {
/*
* Read the previous line and save the
* starting position of that line in linepos.
@@ -800,8 +718,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
linenum--;
}
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* Reached EOF/BOF without a match.
*/
@@ -830,71 +747,68 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* If we're doing backspace processing, delete backspaces.
*/
cvt_ops = get_cvt_ops();
- cvt_len = cvt_length(line_len, cvt_ops);
- cline = (char *) ecalloc(1, cvt_len);
+ cvt_len = cvt_length(line_len);
+ cline = ecalloc(1, cvt_len);
chpos = cvt_alloc_chpos(cvt_len);
cvt_text(cline, line, chpos, &line_len, cvt_ops);
-#if HILITE_SEARCH
/*
* Check to see if the line matches the filter pattern.
* If so, add an entry to the filter list.
*/
- if ((search_type & SRCH_FIND_ALL) && prev_pattern(&filter_info)) {
- int line_filter = match_pattern(info_compiled(&filter_info), filter_info.text,
- cline, line_len, &sp, &ep, 0, filter_info.search_type);
- if (line_filter)
- {
- struct hilite *hl = (struct hilite *)
- ecalloc(1, sizeof(struct hilite));
+ if ((search_type & SRCH_FIND_ALL) &&
+ prev_pattern(&filter_info)) {
+ int line_filter =
+ match_pattern(info_compiled(&filter_info),
+ filter_info.text, cline, line_len, &sp, &ep, 0,
+ filter_info.search_type);
+ if (line_filter) {
+ struct hilite *hl =
+ ecalloc(1, sizeof (struct hilite));
hl->hl_startpos = linepos;
hl->hl_endpos = pos;
add_hilite(&filter_anchor, hl);
}
}
-#endif
/*
* Test the next line to see if we have a match.
* We are successful if we either want a match and got one,
* or if we want a non-match and got one.
*/
- if (prev_pattern(&search_info))
- {
- line_match = match_pattern(info_compiled(&search_info), search_info.text,
- cline, line_len, &sp, &ep, 0, search_type);
- if (line_match)
- {
+ if (prev_pattern(&search_info)) {
+ line_match = match_pattern(info_compiled(&search_info),
+ search_info.text, cline, line_len, &sp, &ep, 0,
+ search_type);
+ if (line_match) {
/*
* Got a match.
*/
- if (search_type & SRCH_FIND_ALL)
- {
-#if HILITE_SEARCH
+ if (search_type & SRCH_FIND_ALL) {
/*
- * We are supposed to find all matches in the range.
- * Just add the matches in this line to the
- * hilite list and keep searching.
+ * We are supposed to find all matches
+ * in the range.
+ * Just add the matches in this line
+ * to the hilite list and keep
+ * searching.
*/
- hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
-#endif
- } else if (--matches <= 0)
- {
+ hilite_line(linepos, cline, line_len,
+ chpos, sp, ep);
+ } else if (--matches <= 0) {
/*
- * Found the one match we're looking for.
- * Return it.
+ * Found the one match we're looking
+ * for. Return it.
*/
-#if HILITE_SEARCH
- if (hilite_search == OPT_ON)
- {
+ if (hilite_search == OPT_ON) {
/*
- * Clear the hilite list and add only
+ * Clear the hilite list and
+ * add only
* the matches in this one line.
*/
clr_hilite();
- hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
+ hilite_line(linepos, cline,
+ line_len, chpos, sp, ep);
}
-#endif
free(cline);
free(chpos);
if (plinepos != NULL)
@@ -911,11 +825,9 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
/*
* search for a pattern in history. If found, compile that pattern.
*/
- static int
-hist_pattern(search_type)
- int search_type;
+static int
+hist_pattern(int search_type)
{
-#if CMD_HISTORY
char *pattern;
set_mlist(ml_search, 0);
@@ -926,62 +838,48 @@ hist_pattern(search_type)
if (set_pattern(&search_info, pattern, search_type) < 0)
return (0);
-#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS && !hide_hilite)
hilite_screen();
-#endif
return (1);
-#else /* CMD_HISTORY */
- return (0);
-#endif /* CMD_HISTORY */
}
/*
- * Search for the n-th occurrence of a specified pattern,
+ * Search for the n-th occurrence of a specified pattern,
* either forward or backward.
* Return the number of matches not yet found in this file
* (that is, n minus the number of matches found).
* Return -1 if the search should be aborted.
- * Caller may continue the search in another file
+ * Caller may continue the search in another file
* if less than n matches are found in this file.
*/
- public int
-search(search_type, pattern, n)
- int search_type;
- char *pattern;
- int n;
+int
+search(int search_type, char *pattern, int n)
{
- POSITION pos;
+ off_t pos;
- if (pattern == NULL || *pattern == '\0')
- {
+ if (pattern == NULL || *pattern == '\0') {
/*
* A null pattern means use the previously compiled pattern.
*/
search_type |= SRCH_AFTER_TARGET;
- if (!prev_pattern(&search_info) && !hist_pattern(search_type))
- {
+ if (!prev_pattern(&search_info) && !hist_pattern(search_type)) {
error("No previous regular expression", NULL_PARG);
return (-1);
}
- if ((search_type & SRCH_NO_REGEX) !=
- (search_info.search_type & SRCH_NO_REGEX))
- {
+ if ((search_type & SRCH_NO_REGEX) !=
+ (search_info.search_type & SRCH_NO_REGEX)) {
error("Please re-enter search pattern", NULL_PARG);
- return -1;
+ return (-1);
}
-#if HILITE_SEARCH
- if (hilite_search == OPT_ON)
- {
+ if (hilite_search == OPT_ON) {
/*
* Erase the highlights currently on screen.
* If the search fails, we'll redisplay them later.
*/
repaint_hilite(0);
}
- if (hilite_search == OPT_ONPLUS && hide_hilite)
- {
+ if (hilite_search == OPT_ONPLUS && hide_hilite) {
/*
* Highlight any matches currently on screen,
* before we actually start the search.
@@ -990,17 +888,13 @@ search(search_type, pattern, n)
hilite_screen();
}
hide_hilite = 0;
-#endif
- } else
- {
+ } else {
/*
* Compile the pattern.
*/
if (set_pattern(&search_info, pattern, search_type) < 0)
return (-1);
-#if HILITE_SEARCH
- if (hilite_search)
- {
+ if (hilite_search) {
/*
* Erase the highlights currently on screen.
* Also permanently delete them from the hilite list.
@@ -1009,23 +903,20 @@ search(search_type, pattern, n)
hide_hilite = 0;
clr_hilite();
}
- if (hilite_search == OPT_ONPLUS)
- {
+ if (hilite_search == OPT_ONPLUS) {
/*
* Highlight any matches currently on screen,
* before we actually start the search.
*/
hilite_screen();
}
-#endif
}
/*
* Figure out where to start the search.
*/
pos = search_pos(search_type);
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* Can't find anyplace to start searching from.
*/
@@ -1036,63 +927,52 @@ search(search_type, pattern, n)
return (-1);
}
- n = search_range(pos, NULL_POSITION, search_type, n, -1,
- &pos, (POSITION*)NULL);
- if (n != 0)
- {
+ n = search_range(pos, -1, search_type, n, -1, &pos, NULL);
+ if (n != 0) {
/*
* Search was unsuccessful.
*/
-#if HILITE_SEARCH
if (hilite_search == OPT_ON && n > 0)
/*
* Redisplay old hilites.
*/
repaint_hilite(1);
-#endif
return (n);
}
- if (!(search_type & SRCH_NO_MOVE))
- {
+ if (!(search_type & SRCH_NO_MOVE)) {
/*
* Go to the matching line.
*/
jump_loc(pos, jump_sline);
}
-#if HILITE_SEARCH
if (hilite_search == OPT_ON)
/*
* Display new hilites in the matching line.
*/
repaint_hilite(1);
-#endif
return (0);
}
-#if HILITE_SEARCH
/*
* Prepare hilites in a given range of the file.
*
* The pair (prep_startpos,prep_endpos) delimits a contiguous region
* of the file that has been "prepared"; that is, scanned for matches for
* the current search pattern, and hilites have been created for such matches.
- * If prep_startpos == NULL_POSITION, the prep region is empty.
- * If prep_endpos == NULL_POSITION, the prep region extends to EOF.
+ * If prep_startpos == -1, the prep region is empty.
+ * If prep_endpos == -1, the prep region extends to EOF.
* prep_hilite asks that the range (spos,epos) be covered by the prep region.
*/
- public void
-prep_hilite(spos, epos, maxlines)
- POSITION spos;
- POSITION epos;
- int maxlines;
+void
+prep_hilite(off_t spos, off_t epos, int maxlines)
{
- POSITION nprep_startpos = prep_startpos;
- POSITION nprep_endpos = prep_endpos;
- POSITION new_epos;
- POSITION max_epos;
+ off_t nprep_startpos = prep_startpos;
+ off_t nprep_endpos = prep_endpos;
+ off_t new_epos;
+ off_t max_epos;
int result;
int i;
@@ -1109,13 +989,12 @@ prep_hilite(spos, epos, maxlines)
* If we're limited to a max number of lines, figure out the
* file position we should stop at.
*/
- if (maxlines < 0)
- max_epos = NULL_POSITION;
- else
- {
+ if (maxlines < 0) {
+ max_epos = -1;
+ } else {
max_epos = spos;
- for (i = 0; i < maxlines; i++)
- max_epos = forw_raw_line(max_epos, (char **)NULL, (int *)NULL);
+ for (i = 0; i < maxlines; i++)
+ max_epos = forw_raw_line(max_epos, NULL, NULL);
}
/*
@@ -1124,51 +1003,45 @@ prep_hilite(spos, epos, maxlines)
* the "prep" region will then cover (nprep_startpos,nprep_endpos).
*/
- if (prep_startpos == NULL_POSITION ||
- (epos != NULL_POSITION && epos < prep_startpos) ||
- spos > prep_endpos)
- {
+ if (prep_startpos == -1 ||
+ (epos != -1 && epos < prep_startpos) ||
+ spos > prep_endpos) {
/*
* New range is not contiguous with old prep region.
* Discard the old prep region and start a new one.
*/
clr_hilite();
clr_filter();
- if (epos != NULL_POSITION)
+ if (epos != -1)
epos += SEARCH_MORE;
nprep_startpos = spos;
- } else
- {
+ } else {
/*
* New range partially or completely overlaps old prep region.
*/
- if (epos == NULL_POSITION)
- {
- /*
- * New range goes to end of file.
- */
- ;
- } else if (epos > prep_endpos)
- {
- /*
- * New range ends after old prep region.
- * Extend prep region to end at end of new range.
- */
- epos += SEARCH_MORE;
- } else /* (epos <= prep_endpos) */
- {
- /*
- * New range ends within old prep region.
- * Truncate search to end at start of old prep region.
- */
- epos = prep_startpos;
+ if (epos != -1) {
+ if (epos > prep_endpos) {
+ /*
+ * New range ends after old prep region.
+ * Extend prep region to end at end of new
+ * range.
+ */
+ epos += SEARCH_MORE;
+
+ } else {
+ /*
+ * New range ends within old prep region.
+ * Truncate search to end at start of old prep
+ * region.
+ */
+ epos = prep_startpos;
+ }
}
- if (spos < prep_startpos)
- {
+ if (spos < prep_startpos) {
/*
* New range starts before old prep region.
- * Extend old prep region backwards to start at
+ * Extend old prep region backwards to start at
* start of new range.
*/
if (spos < SEARCH_MORE)
@@ -1176,8 +1049,7 @@ prep_hilite(spos, epos, maxlines)
else
spos -= SEARCH_MORE;
nprep_startpos = spos;
- } else /* (spos >= prep_startpos) */
- {
+ } else { /* (spos >= prep_startpos) */
/*
* New range starts within or after old prep region.
* Trim search to start at end of old prep region.
@@ -1186,22 +1058,21 @@ prep_hilite(spos, epos, maxlines)
}
}
- if (epos != NULL_POSITION && max_epos != NULL_POSITION &&
+ if (epos != -1 && max_epos != -1 &&
epos > max_epos)
/*
* Don't go past the max position we're allowed.
*/
epos = max_epos;
- if (epos == NULL_POSITION || epos > spos)
- {
+ if (epos == -1 || epos > spos) {
int search_type = SRCH_FORW | SRCH_FIND_ALL;
search_type |= (search_info.search_type & SRCH_NO_REGEX);
result = search_range(spos, epos, search_type, 0,
- maxlines, (POSITION*)NULL, &new_epos);
+ maxlines, NULL, &new_epos);
if (result < 0)
return;
- if (prep_endpos == NULL_POSITION || new_epos > prep_endpos)
+ if (prep_endpos == -1 || new_epos > prep_endpos)
nprep_endpos = new_epos;
}
prep_startpos = nprep_startpos;
@@ -1211,44 +1082,24 @@ prep_hilite(spos, epos, maxlines)
/*
* Set the pattern to be used for line filtering.
*/
- public void
-set_filter_pattern(pattern, search_type)
- char *pattern;
- int search_type;
+void
+set_filter_pattern(char *pattern, int search_type)
{
clr_filter();
if (pattern == NULL || *pattern == '\0')
clear_pattern(&filter_info);
else
- set_pattern(&filter_info, pattern, search_type);
+ (void) set_pattern(&filter_info, pattern, search_type);
screen_trashed = 1;
}
/*
* Is there a line filter in effect?
*/
- public int
-is_filtering()
+int
+is_filtering(void)
{
if (ch_getflags() & CH_HELPFILE)
return (0);
- return prev_pattern(&filter_info);
-}
-#endif
-
-#if HAVE_V8_REGCOMP
-/*
- * This function is called by the V8 regcomp to report
- * errors in regular expressions.
- */
- void
-regerror(s)
- char *s;
-{
- PARG parg;
-
- parg.p_string = s;
- error("%s", &parg);
+ return (prev_pattern(&filter_info));
}
-#endif
-
diff --git a/usr.bin/less/signal.c b/usr.bin/less/signal.c
index b21772d3e4e..e8e35fd43e8 100644
--- a/usr.bin/less/signal.c
+++ b/usr.bin/less/signal.c
@@ -6,7 +6,10 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2015 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines dealing with signals.
@@ -22,11 +25,10 @@
/*
* "sigs" contains bits indicating signals which need to be processed.
*/
-public volatile sig_atomic_t sigs;
+volatile sig_atomic_t sigs;
extern int sc_width, sc_height;
extern int screen_trashed;
-extern int lnloop;
extern int linenums;
extern int wscroll;
extern int quit_on_intr;
@@ -35,137 +37,55 @@ extern long jump_sline_fraction;
/*
* Interrupt signal handler.
*/
- /* ARGSUSED*/
- static RETSIGTYPE
-u_interrupt(type)
- int type;
+/* ARGSUSED */
+static void
+u_interrupt(int type)
{
-#if OS2
- LSIGNAL(SIGINT, SIG_ACK);
-#endif
sigs |= S_INTERRUPT;
-#if MSDOS_COMPILER==DJGPPC
- /*
- * If a keyboard has been hit, it must be Ctrl-C
- * (as opposed to Ctrl-Break), so consume it.
- * (Otherwise, Less will beep when it sees Ctrl-C from keyboard.)
- */
- if (kbhit())
- getkey();
-#endif
}
-#ifdef SIGTSTP
/*
* "Stop" (^Z) signal handler.
*/
- /* ARGSUSED*/
- static RETSIGTYPE
-stop(type)
- int type;
+/* ARGSUSED */
+static void
+stop(int type)
{
sigs |= S_STOP;
}
-#endif
-#ifdef SIGWINCH
-/*
- * "Window" change handler
- */
- /* ARGSUSED*/
- public RETSIGTYPE
-winch(type)
- int type;
-{
- sigs |= S_WINCH;
-}
-#else
-#ifdef SIGWIND
/*
* "Window" change handler
*/
- /* ARGSUSED*/
- public RETSIGTYPE
-winch(type)
- int type;
+/* ARGSUSED */
+void
+sigwinch(int type)
{
sigs |= S_WINCH;
}
-#endif
-#endif
-
-#if MSDOS_COMPILER==WIN32C
-/*
- * Handle CTRL-C and CTRL-BREAK keys.
- */
-#include "windows.h"
-
- static BOOL WINAPI
-wbreak_handler(dwCtrlType)
- DWORD dwCtrlType;
-{
- switch (dwCtrlType)
- {
- case CTRL_C_EVENT:
- case CTRL_BREAK_EVENT:
- sigs |= S_INTERRUPT;
- return (TRUE);
- default:
- break;
- }
- return (FALSE);
-}
-#endif
/*
* Set up the signal handlers.
*/
- public void
-init_signals(on)
- int on;
+void
+init_signals(int on)
{
- if (on)
- {
+ if (on) {
/*
* Set signal handlers.
*/
(void) LSIGNAL(SIGINT, u_interrupt);
-#if MSDOS_COMPILER==WIN32C
- SetConsoleCtrlHandler(wbreak_handler, TRUE);
-#endif
-#ifdef SIGTSTP
(void) LSIGNAL(SIGTSTP, stop);
-#endif
-#ifdef SIGWINCH
- (void) LSIGNAL(SIGWINCH, winch);
-#endif
-#ifdef SIGWIND
- (void) LSIGNAL(SIGWIND, winch);
-#endif
-#ifdef SIGQUIT
+ (void) LSIGNAL(SIGWINCH, sigwinch);
(void) LSIGNAL(SIGQUIT, SIG_IGN);
-#endif
- } else
- {
+ } else {
/*
* Restore signals to defaults.
*/
(void) LSIGNAL(SIGINT, SIG_DFL);
-#if MSDOS_COMPILER==WIN32C
- SetConsoleCtrlHandler(wbreak_handler, FALSE);
-#endif
-#ifdef SIGTSTP
(void) LSIGNAL(SIGTSTP, SIG_DFL);
-#endif
-#ifdef SIGWINCH
(void) LSIGNAL(SIGWINCH, SIG_IGN);
-#endif
-#ifdef SIGWIND
- (void) LSIGNAL(SIGWIND, SIG_IGN);
-#endif
-#ifdef SIGQUIT
(void) LSIGNAL(SIGQUIT, SIG_DFL);
-#endif
}
}
@@ -173,8 +93,8 @@ init_signals(on)
* Process any signals we have received.
* A received signal cause a bit to be set in "sigs".
*/
- public void
-psignals()
+void
+psignals(void)
{
register int tsignals;
@@ -182,22 +102,16 @@ psignals()
return;
sigs = 0;
-#ifdef SIGTSTP
- if (tsignals & S_STOP)
- {
+ if (tsignals & S_STOP) {
/*
* Clean up the terminal.
*/
-#ifdef SIGTTOU
LSIGNAL(SIGTTOU, SIG_IGN);
-#endif
clear_bot();
deinit();
flush();
raw_mode(0);
-#ifdef SIGTTOU
LSIGNAL(SIGTTOU, SIG_DFL);
-#endif
LSIGNAL(SIGTSTP, SIG_DFL);
kill(getpid(), SIGTSTP);
/*
@@ -212,10 +126,7 @@ psignals()
screen_trashed = 1;
tsignals |= S_WINCH;
}
-#endif
-#ifdef S_WINCH
- if (tsignals & S_WINCH)
- {
+ if (tsignals & S_WINCH) {
int old_width, old_height;
/*
* Re-execute scrsize() to read the new window size.
@@ -223,18 +134,15 @@ psignals()
old_width = sc_width;
old_height = sc_height;
get_term();
- if (sc_width != old_width || sc_height != old_height)
- {
+ if (sc_width != old_width || sc_height != old_height) {
wscroll = (sc_height + 1) / 2;
calc_jump_sline();
calc_shift_count();
screen_trashed = 1;
}
}
-#endif
- if (tsignals & S_INTERRUPT)
- {
- bell();
+ if (tsignals & S_INTERRUPT) {
+ ring_bell();
if (quit_on_intr)
quit(QUIT_INTERRUPT);
}
@@ -243,16 +151,14 @@ psignals()
/*
* Custom version of signal() that causes syscalls to be interrupted.
*/
- public void
-(*lsignal(s, a))()
- int s;
- void (*a) ();
+void *
+lsignal(int s, void (*a)(int))
{
struct sigaction sa, osa;
sa.sa_handler = a;
sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0; /* don't restart system calls */
+ sa.sa_flags = 0; /* don't restart system calls */
if (sigaction(s, &sa, &osa) != 0)
return (SIG_ERR);
return (osa.sa_handler);
diff --git a/usr.bin/less/tags.c b/usr.bin/less/tags.c
index e1beec5bdf7..b3c9e8f2b31 100644
--- a/usr.bin/less/tags.c
+++ b/usr.bin/less/tags.c
@@ -6,15 +6,16 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
#include "less.h"
-#define WHITESP(c) ((c)==' ' || (c)=='\t')
+#define WHITESP(c) ((c) == ' ' || (c) == '\t')
-#if TAGS
-
-public char *tags = "tags";
+char *tags = "tags";
static int total;
static int curseq;
@@ -46,8 +47,8 @@ static enum tag_result findctag();
static enum tag_result findgtag();
static char *nextgtag();
static char *prevgtag();
-static POSITION ctagsearch();
-static POSITION gtagsearch();
+static off_t ctagsearch();
+static off_t gtagsearch();
static int getentry();
/*
@@ -62,42 +63,41 @@ struct taglist {
struct tag *tl_first;
struct tag *tl_last;
};
-#define TAG_END ((struct tag *) &taglist)
+#define TAG_END ((struct tag *)&taglist)
static struct taglist taglist = { TAG_END, TAG_END };
struct tag {
struct tag *next, *prev; /* List links */
char *tag_file; /* Source file containing the tag */
LINENUM tag_linenum; /* Appropriate line number in source file */
char *tag_pattern; /* Pattern used to find the tag */
- char tag_endline; /* True if the pattern includes '$' */
+ int tag_endline; /* True if the pattern includes '$' */
};
static struct tag *curtag;
-#define TAG_INS(tp) \
+#define TAG_INS(tp) \
(tp)->next = TAG_END; \
(tp)->prev = taglist.tl_last; \
taglist.tl_last->next = (tp); \
taglist.tl_last = (tp);
-#define TAG_RM(tp) \
+#define TAG_RM(tp) \
(tp)->next->prev = (tp)->prev; \
(tp)->prev->next = (tp)->next;
/*
* Delete tag structures.
*/
- public void
-cleantags()
+void
+cleantags(void)
{
- register struct tag *tp;
+ struct tag *tp;
/*
* Delete any existing tag list.
* {{ Ideally, we wouldn't do this until after we know that we
* can load some other tag information. }}
*/
- while ((tp = taglist.tl_first) != TAG_END)
- {
+ while ((tp = taglist.tl_first) != TAG_END) {
TAG_RM(tp);
free(tp);
}
@@ -108,17 +108,12 @@ cleantags()
/*
* Create a new tag entry.
*/
- static struct tag *
-maketagent(name, file, linenum, pattern, endline)
- char *name;
- char *file;
- LINENUM linenum;
- char *pattern;
- int endline;
+static struct tag *
+maketagent(char *file, LINENUM linenum, char *pattern, int endline)
{
- register struct tag *tp;
+ struct tag *tp;
- tp = (struct tag *) ecalloc(sizeof(struct tag), 1);
+ tp = ecalloc(sizeof (struct tag), 1);
tp->tag_file = save(file);
tp->tag_linenum = linenum;
tp->tag_endline = endline;
@@ -132,28 +127,27 @@ maketagent(name, file, linenum, pattern, endline)
/*
* Get tag mode.
*/
- public int
-gettagtype()
+static int
+gettagtype(void)
{
int f;
if (strcmp(tags, "GTAGS") == 0)
- return T_GTAGS;
+ return (T_GTAGS);
if (strcmp(tags, "GRTAGS") == 0)
- return T_GRTAGS;
+ return (T_GRTAGS);
if (strcmp(tags, "GSYMS") == 0)
- return T_GSYMS;
+ return (T_GSYMS);
if (strcmp(tags, "GPATH") == 0)
- return T_GPATH;
+ return (T_GPATH);
if (strcmp(tags, "-") == 0)
- return T_CTAGS_X;
+ return (T_CTAGS_X);
f = open(tags, OPEN_READ);
- if (f >= 0)
- {
- close(f);
- return T_CTAGS;
+ if (f >= 0) {
+ (void) close(f);
+ return (T_CTAGS);
}
- return T_GTAGS;
+ return (T_GTAGS);
}
/*
@@ -163,9 +157,8 @@ gettagtype()
* and "tagpattern" to the search pattern which should be used
* to find the tag.
*/
- public void
-findtag(tag)
- register char *tag;
+void
+findtag(char *tag)
{
int type = gettagtype();
enum tag_result result;
@@ -174,8 +167,7 @@ findtag(tag)
result = findctag(tag);
else
result = findgtag(tag, type);
- switch (result)
- {
+ switch (result) {
case TAG_FOUND:
case TAG_INTR:
break;
@@ -194,64 +186,62 @@ findtag(tag)
/*
* Search for a tag.
*/
- public POSITION
-tagsearch()
+off_t
+tagsearch(void)
{
if (curtag == NULL)
- return (NULL_POSITION); /* No gtags loaded! */
+ return (-1); /* No gtags loaded! */
if (curtag->tag_linenum != 0)
- return gtagsearch();
+ return (gtagsearch());
else
- return ctagsearch();
+ return (ctagsearch());
}
/*
* Go to the next tag.
*/
- public char *
-nexttag(n)
- int n;
+char *
+nexttag(int n)
{
- char *tagfile = (char *) NULL;
+ char *tagfile = NULL;
while (n-- > 0)
tagfile = nextgtag();
- return tagfile;
+ return (tagfile);
}
/*
* Go to the previous tag.
*/
- public char *
-prevtag(n)
- int n;
+char *
+prevtag(int n)
{
- char *tagfile = (char *) NULL;
+ char *tagfile = NULL;
while (n-- > 0)
tagfile = prevgtag();
- return tagfile;
+ return (tagfile);
}
/*
* Return the total number of tags.
*/
- public int
-ntags()
+int
+ntags(void)
{
- return total;
+ return (total);
}
/*
* Return the sequence number of current tag.
*/
- public int
-curr_tag()
+int
+curr_tag(void)
{
- return curseq;
+ return (curseq);
}
-/*****************************************************************************
+/*
* ctags
*/
@@ -259,13 +249,12 @@ curr_tag()
* Find tags in the "tags" file.
* Sets curtag to the first tag entry.
*/
- static enum tag_result
-findctag(tag)
- register char *tag;
+static enum tag_result
+findctag(char *tag)
{
char *p;
- register FILE *f;
- register int taglen;
+ FILE *f;
+ int taglen;
LINENUM taglinenum;
char *tagfile;
char *tagpattern;
@@ -279,7 +268,7 @@ findctag(tag)
f = fopen(p, "r");
free(p);
if (f == NULL)
- return TAG_NOFILE;
+ return (TAG_NOFILE);
cleantags();
total = 0;
@@ -288,8 +277,7 @@ findctag(tag)
/*
* Search the tags file for the desired tag.
*/
- while (fgets(tline, sizeof(tline), f) != NULL)
- {
+ while (fgets(tline, sizeof (tline), f) != NULL) {
if (tline[0] == '!')
/* Skip header of extended format. */
continue;
@@ -300,7 +288,7 @@ findctag(tag)
* Found it.
* The line contains the tag, the filename and the
* location in the file, separated by white space.
- * The location is either a decimal line number,
+ * The location is either a decimal line number,
* or a search pattern surrounded by a pair of delimiters.
* Parse the line and extract these parts.
*/
@@ -328,15 +316,14 @@ findctag(tag)
continue;
/*
- * First see if it is a line number.
+ * First see if it is a line number.
*/
tagendline = 0;
taglinenum = getnum(&p, 0, &err);
- if (err)
- {
+ if (err) {
/*
* No, it must be a pattern.
- * Delete the initial "^" (if present) and
+ * Delete the initial "^" (if present) and
* the final "$" from the pattern.
* Delete any backslash in the pattern.
*/
@@ -345,8 +332,7 @@ findctag(tag)
if (*p == '^')
p++;
tagpattern = p;
- while (*p != search_char && *p != '\0')
- {
+ while (*p != search_char && *p != '\0') {
if (*p == '\\')
p++;
p++;
@@ -356,23 +342,23 @@ findctag(tag)
p--;
*p = '\0';
}
- tp = maketagent(tag, tagfile, taglinenum, tagpattern, tagendline);
+ tp = maketagent(tagfile, taglinenum, tagpattern, tagendline);
TAG_INS(tp);
total++;
}
fclose(f);
if (total == 0)
- return TAG_NOTAG;
+ return (TAG_NOTAG);
curtag = taglist.tl_first;
curseq = 1;
- return TAG_FOUND;
+ return (TAG_FOUND);
}
/*
* Edit current tagged file.
*/
- public int
-edit_tagfile()
+int
+edit_tagfile(void)
{
if (curtag == NULL)
return (1);
@@ -385,13 +371,13 @@ edit_tagfile()
* We don't use search() for several reasons:
* - We don't want to blow away any search string we may have saved.
* - The various regular-expression functions (from different systems:
- * regcmp vs. re_comp) behave differently in the presence of
+ * regcmp vs. re_comp) behave differently in the presence of
* parentheses (which are almost always found in a tag).
*/
- static POSITION
-ctagsearch()
+static off_t
+ctagsearch(void)
{
- POSITION pos, linepos;
+ off_t pos, linepos;
LINENUM linenum;
int len;
char *line;
@@ -399,17 +385,16 @@ ctagsearch()
pos = ch_zero();
linenum = find_linenum(pos);
- for (;;)
- {
+ for (;;) {
/*
- * Get lines until we find a matching one or
+ * Get lines until we find a matching one or
* until we hit end-of-file.
*/
if (ABORT_SIGS())
- return (NULL_POSITION);
+ return (-1);
/*
- * Read the next line, and save the
+ * Read the next line, and save the
* starting position of that line in linepos.
*/
linepos = pos;
@@ -417,13 +402,12 @@ ctagsearch()
if (linenum != 0)
linenum++;
- if (pos == NULL_POSITION)
- {
+ if (pos == -1) {
/*
* We hit EOF without a match.
*/
error("Tag not found", NULL_PARG);
- return (NULL_POSITION);
+ return (-1);
}
/*
@@ -443,8 +427,8 @@ ctagsearch()
*/
len = strlen(curtag->tag_pattern);
if (strncmp(curtag->tag_pattern, line, len) == 0 &&
- (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r'))
- {
+ (!curtag->tag_endline || line[len] == '\0' ||
+ line[len] == '\r')) {
curtag->tag_linenum = find_linenum(linepos);
break;
}
@@ -453,7 +437,7 @@ ctagsearch()
return (linepos);
}
-/*******************************************************************************
+/*
* gtags
*/
@@ -464,18 +448,15 @@ ctagsearch()
* for future use by gtagsearch().
* Sets curtag to the first tag entry.
*/
- static enum tag_result
-findgtag(tag, type)
- char *tag; /* tag to load */
- int type; /* tags type */
+static enum tag_result
+findgtag(char *tag, int type)
{
char buf[256];
FILE *fp;
struct tag *tp;
- size_t len;
if (type != T_CTAGS_X && tag == NULL)
- return TAG_NOFILE;
+ return (TAG_NOFILE);
cleantags();
total = 0;
@@ -484,28 +465,22 @@ findgtag(tag, type)
* If type == T_CTAGS_X then read ctags's -x format from stdin
* else execute global(1) and read from it.
*/
- if (type == T_CTAGS_X)
- {
+ if (type == T_CTAGS_X) {
fp = stdin;
/* Set tag default because we cannot read stdin again. */
tags = "tags";
- } else
- {
-#if !HAVE_POPEN
- return TAG_NOFILE;
-#else
+ } else {
char *command;
char *flag;
char *qtag;
char *cmd = lgetenv("LESSGLOBALTAGS");
if (cmd == NULL || *cmd == '\0')
- return TAG_NOFILE;
+ return (TAG_NOFILE);
/* Get suitable flag value for global(1). */
- switch (type)
- {
+ switch (type) {
case T_GTAGS:
- flag = "" ;
+ flag = "";
break;
case T_GRTAGS:
flag = "r";
@@ -517,49 +492,40 @@ findgtag(tag, type)
flag = "P";
break;
default:
- return TAG_NOTYPE;
+ return (TAG_NOTYPE);
}
/* Get our data from global(1). */
qtag = shell_quote(tag);
if (qtag == NULL)
qtag = tag;
- len = strlen(cmd) + strlen(flag) + strlen(qtag) + 5;
- command = (char *) ecalloc(len, sizeof(char));
- snprintf(command, len, "%s -x%s %s", cmd, flag, qtag);
+ command = easprintf("%s -x%s %s", cmd, flag, qtag);
if (qtag != tag)
free(qtag);
fp = popen(command, "r");
free(command);
-#endif
}
- if (fp != NULL)
- {
- while (fgets(buf, sizeof(buf), fp))
- {
+ if (fp != NULL) {
+ while (fgets(buf, sizeof (buf), fp)) {
char *name, *file, *line;
+ int len;
- if (sigs)
- {
-#if HAVE_POPEN
+ if (sigs) {
if (fp != stdin)
pclose(fp);
-#endif
- return TAG_INTR;
+ return (TAG_INTR);
}
len = strlen(buf);
- if (len > 0 && buf[len-1] == '\n')
+ if (len > 0 && buf[len-1] == '\n') {
buf[len-1] = '\0';
- else
- {
+ } else {
int c;
do {
c = fgetc(fp);
} while (c != '\n' && c != EOF);
}
- if (getentry(buf, &name, &file, &line))
- {
+ if (getentry(buf, &name, &file, &line)) {
/*
* Couldn't parse this line for some reason.
* We'll just pretend it never happened.
@@ -568,17 +534,15 @@ findgtag(tag, type)
}
/* Make new entry and add to list. */
- tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0);
+ tp = maketagent(file, (LINENUM) atoi(line), NULL, 0);
TAG_INS(tp);
total++;
}
- if (fp != stdin)
- {
- if (pclose(fp))
- {
+ if (fp != stdin) {
+ if (pclose(fp)) {
curtag = NULL;
total = curseq = 0;
- return TAG_NOFILE;
+ return (TAG_NOFILE);
}
}
}
@@ -586,10 +550,10 @@ findgtag(tag, type)
/* Check to see if we found anything. */
tp = taglist.tl_first;
if (tp == TAG_END)
- return TAG_NOTAG;
+ return (TAG_NOTAG);
curtag = tp;
curseq = 1;
- return TAG_FOUND;
+ return (TAG_FOUND);
}
static int circular = 0; /* 1: circular tag structure */
@@ -599,25 +563,23 @@ static int circular = 0; /* 1: circular tag structure */
* by findgtag(). The next call to gtagsearch() will try to position at the
* appropriate tag.
*/
- static char *
-nextgtag()
+static char *
+nextgtag(void)
{
struct tag *tp;
if (curtag == NULL)
/* No tag loaded */
- return NULL;
+ return (NULL);
tp = curtag->next;
- if (tp == TAG_END)
- {
+ if (tp == TAG_END) {
if (!circular)
- return NULL;
+ return (NULL);
/* Wrapped around to the head of the queue */
curtag = taglist.tl_first;
curseq = 1;
- } else
- {
+ } else {
curtag = tp;
curseq++;
}
@@ -629,25 +591,23 @@ nextgtag()
* setup by findgtat(). The next call to gtagsearch() will try to position
* at the appropriate tag.
*/
- static char *
-prevgtag()
+static char *
+prevgtag(void)
{
struct tag *tp;
if (curtag == NULL)
/* No tag loaded */
- return NULL;
+ return (NULL);
tp = curtag->prev;
- if (tp == TAG_END)
- {
+ if (tp == TAG_END) {
if (!circular)
- return NULL;
+ return (NULL);
/* Wrapped around to the tail of the queue */
curtag = taglist.tl_last;
curseq = total;
- } else
- {
+ } else {
curtag = tp;
curseq--;
}
@@ -659,11 +619,11 @@ prevgtag()
* using either findtag() or one of nextgtag() and prevgtag(). Returns -1
* if it was unable to position at the tag, 0 if successful.
*/
- static POSITION
-gtagsearch()
+static off_t
+gtagsearch(void)
{
if (curtag == NULL)
- return (NULL_POSITION); /* No gtags loaded! */
+ return (-1); /* No gtags loaded! */
return (find_pos(curtag->tag_linenum));
}
@@ -695,21 +655,17 @@ gtagsearch()
* The tag, file, and line will each be NUL-terminated pointers
* into buf.
*/
- static int
-getentry(buf, tag, file, line)
- char *buf; /* standard or extended ctags -x format data */
- char **tag; /* name of the tag we actually found */
- char **file; /* file in which to find this tag */
- char **line; /* line number of file where this tag is found */
+static int
+getentry(char *buf, char **tag, char **file, char **line)
{
char *p = buf;
- for (*tag = p; *p && !IS_SPACE(*p); p++) /* tag name */
+ for (*tag = p; *p && !isspace(*p); p++) /* tag name */
;
if (*p == 0)
return (-1);
*p++ = 0;
- for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
;
if (*p == 0)
return (-1);
@@ -717,27 +673,26 @@ getentry(buf, tag, file, line)
* If the second part begin with other than digit,
* it is assumed tag type. Skip it.
*/
- if (!IS_DIGIT(*p))
- {
- for ( ; *p && !IS_SPACE(*p); p++) /* (skip tag type) */
+ if (!isdigit(*p)) {
+ for (; *p && !isspace(*p); p++) /* (skip tag type) */
;
- for (; *p && IS_SPACE(*p); p++) /* (skip blanks) */
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
;
}
- if (!IS_DIGIT(*p))
+ if (!isdigit(*p))
return (-1);
*line = p; /* line number */
- for (*line = p; *p && !IS_SPACE(*p); p++)
+ for (*line = p; *p && !isspace(*p); p++)
;
if (*p == 0)
return (-1);
*p++ = 0;
- for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
;
if (*p == 0)
return (-1);
*file = p; /* file name */
- for (*file = p; *p && !IS_SPACE(*p); p++)
+ for (*file = p; *p && !isspace(*p); p++)
;
if (*p == 0)
return (-1);
@@ -748,5 +703,3 @@ getentry(buf, tag, file, line)
return (0);
return (-1);
}
-
-#endif
diff --git a/usr.bin/less/ttyin.c b/usr.bin/less/ttyin.c
index 34d0ae3e930..f6139a636ea 100644
--- a/usr.bin/less/ttyin.c
+++ b/usr.bin/less/ttyin.c
@@ -6,171 +6,73 @@
*
* For more information, see the README file.
*/
-
+/*
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
/*
* Routines dealing with getting input from the keyboard (i.e. from the user).
*/
#include "less.h"
-#if OS2
-#include "cmd.h"
-#include "pckeys.h"
-#endif
-#if MSDOS_COMPILER==WIN32C
-#include "windows.h"
-extern char WIN32getch();
-static DWORD console_mode;
-#endif
-public int tty;
+int tty;
extern volatile sig_atomic_t sigs;
extern int utf_mode;
/*
* Open keyboard for input.
*/
- public void
-open_getchr()
+void
+open_getchr(void)
{
-#if MSDOS_COMPILER==WIN32C
- /* Need this to let child processes inherit our console handle */
- SECURITY_ATTRIBUTES sa;
- memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES));
- sa.nLength = sizeof(SECURITY_ATTRIBUTES);
- sa.bInheritHandle = TRUE;
- tty = (int) CreateFile("CONIN$", GENERIC_READ,
- FILE_SHARE_READ, &sa,
- OPEN_EXISTING, 0L, NULL);
- GetConsoleMode((HANDLE)tty, &console_mode);
- /* Make sure we get Ctrl+C events. */
- SetConsoleMode((HANDLE)tty, ENABLE_PROCESSED_INPUT);
-#else
-#if MSDOS_COMPILER
- extern int fd0;
- /*
- * Open a new handle to CON: in binary mode
- * for unbuffered keyboard read.
- */
- fd0 = dup(0);
- close(0);
- tty = open("CON", OPEN_READ);
-#if MSDOS_COMPILER==DJGPPC
- /*
- * Setting stdin to binary causes Ctrl-C to not
- * raise SIGINT. We must undo that side-effect.
- */
- (void) __djgpp_set_ctrl_c(1);
-#endif
-#else
/*
* Try /dev/tty.
* If that doesn't work, use file descriptor 2,
* which in Unix is usually attached to the screen,
* but also usually lets you read from the keyboard.
*/
-#if OS2
- /* The __open() system call translates "/dev/tty" to "con". */
- tty = __open("/dev/tty", OPEN_READ);
-#else
tty = open("/dev/tty", OPEN_READ);
-#endif
if (tty < 0)
tty = 2;
-#endif
-#endif
}
/*
* Close the keyboard.
*/
- public void
-close_getchr()
+void
+close_getchr(void)
{
-#if MSDOS_COMPILER==WIN32C
- SetConsoleMode((HANDLE)tty, console_mode);
- CloseHandle((HANDLE)tty);
-#endif
}
/*
* Get a character from the keyboard.
*/
- public int
-getchr()
+int
+getchr(void)
{
- char c;
+ unsigned char c;
int result;
- do
- {
-#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
- /*
- * In raw read, we don't see ^C so look here for it.
- */
- flush();
-#if MSDOS_COMPILER==WIN32C
- if (ABORT_SIGS())
- return (READ_INTR);
- c = WIN32getch(tty);
-#else
- c = getch();
-#endif
- result = 1;
- if (c == '\003')
- return (READ_INTR);
-#else
- result = iread(tty, &c, sizeof(char));
+ do {
+ result = iread(tty, &c, sizeof (char));
if (result == READ_INTR)
return (READ_INTR);
- if (result < 0)
- {
+ if (result < 0) {
/*
* Don't call error() here,
* because error calls getchr!
*/
quit(QUIT_ERROR);
}
-#endif
-#if 0 /* allow entering arbitrary hex chars for testing */
- /* ctrl-A followed by two hex chars makes a byte */
- {
- int hex_in = 0;
- int hex_value = 0;
- if (c == CONTROL('A'))
- {
- hex_in = 2;
- result = 0;
- continue;
- }
- if (hex_in > 0)
- {
- int v;
- if (c >= '0' && c <= '9')
- v = c - '0';
- else if (c >= 'a' && c <= 'f')
- v = c - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
- v = c - 'A' + 10;
- else
- hex_in = 0;
- hex_value = (hex_value << 4) | v;
- if (--hex_in > 0)
- {
- result = 0;
- continue;
- }
- c = hex_value;
- }
- }
-#endif
/*
* Various parts of the program cannot handle
* an input character of '\0'.
* If a '\0' was actually typed, convert it to '\340' here.
*/
if (c == '\0')
- c = '\340';
+ c = 0340;
} while (result != 1);
return (c & 0xFF);
diff --git a/usr.bin/less/version.c b/usr.bin/less/version.c
index d3ecd14fd71..db4ee8492f8 100644
--- a/usr.bin/less/version.c
+++ b/usr.bin/less/version.c
@@ -6,762 +6,11 @@
*
* For more information, see the README file.
*/
-
-
/*
------------------------ CHANGE HISTORY --------------------------
-
- 1/29/84 Allowed use on standard input
- 2/1/84 Added E, N, P commands
- 4/17/84 Added '=' command, 'stop' signal handling
- 4/20/84 Added line folding
-v2 4/27/84 Fixed '=' command to use BOTTOM_PLUS_ONE,
- instead of TOP, added 'p' & 'v' commands
-v3 5/3/84 Added -m and -t options, '-' command
-v4 5/3/84 Added LESS environment variable
-v5 5/3/84 New comments, fixed '-' command slightly
-v6 5/15/84 Added -Q, visual bell
-v7 5/24/84 Fixed jump_back(n) bug: n should count real
- lines, not folded lines. Also allow number on G command.
-v8 5/30/84 Re-do -q and -Q commands
-v9 9/25/84 Added "+<cmd>" argument
-v10 10/10/84 Fixed bug in -b<n> argument processing
-v11 10/18/84 Made error() ring bell if \n not entered.
------------------------------------------------------------------
-v12 2/13/85 Reorganized signal handling and made portable to 4.2bsd.
-v13 2/16/85 Reword error message for '-' command.
-v14 2/22/85 Added -bf and -bp variants of -b.
-v15 2/25/85 Miscellaneous changes.
-v16 3/13/85 Added -u flag for backspace processing.
-v17 4/13/85 Added j and k commands, changed -t default.
-v18 4/20/85 Rewrote signal handling code.
-v19 5/2/85 Got rid of "verbose" eq_message().
- Made search() scroll in some cases.
-v20 5/21/85 Fixed screen.c ioctls for System V.
-v21 5/23/85 Fixed some first_cmd bugs.
-v22 5/24/85 Added support for no RECOMP nor REGCMP.
-v23 5/25/85 Miscellanous changes and prettying up.
- Posted to USENET.
------------------------------------------------------------------
-v24 6/3/85 Added ti,te terminal init & de-init.
- (Thanks to Mike Kersenbrock)
-v25 6/8/85 Added -U flag, standout mode underlining.
-v26 6/9/85 Added -M flag.
- Use underline termcap (us) if it exists.
-v27 6/15/85 Renamed some variables to make unique in
- 6 chars. Minor fix to -m.
-v28 6/28/85 Fixed right margin bug.
-v29 6/28/85 Incorporated M.Rose's changes to signal.c
-v30 6/29/85 Fixed stupid bug in argument processing.
-v31 7/15/85 Added -p flag, changed repaint algorithm.
- Added kludge for magic cookie terminals.
-v32 7/16/85 Added cat_file if output not a tty.
-v33 7/23/85 Added -e flag and EDITOR.
-v34 7/26/85 Added -s flag.
-v35 7/27/85 Rewrote option handling; added option.c.
-v36 7/29/85 Fixed -e flag to work if not last file.
-v37 8/10/85 Added -x flag.
-v38 8/19/85 Changed prompting; created prompt.c.
-v39 8/24/85 (Not -p) does not initially clear screen.
-v40 8/26/85 Added "skipping" indicator in forw().
- Posted to USENET.
------------------------------------------------------------------
-v41 9/17/85 ONLY_RETURN, control char commands,
- faster search, other minor fixes.
-v42 9/25/85 Added ++ command line syntax;
- ch_fsize for pipes.
-v43 10/15/85 Added -h flag, changed prim.c algorithms.
-v44 10/16/85 Made END print in all cases of eof;
- ignore SIGTTOU after receiv ing SIGTSTP.
-v45 10/16/85 Never print backspaces unless -u.
-v46 10/24/85 Backwards scroll in jump_loc.
-v47 10/30/85 Fixed bug in edit(): *first_cmd==0
-v48 11/16/85 Use TIOCSETN instead of TIOCSETP.
- Added marks (m and ' commands).
- Posted to USENET.
------------------------------------------------------------------
-v49 1/9/86 Fixed bug: signal didn't clear mcc.
-v50 1/15/86 Added ' (quote) to gomark.
-v51 1/16/86 Added + cmd, fixed problem if first_cmd
- fails, made g cmd sort of "work" on pipes
- ev en if bof is no longer buffered.
-v52 1/17/86 Made short files work better.
-v53 1/20/86 Added -P option.
-v54 1/20/86 Changed help to use HELPFILE.
-v55 1/23/86 Messages work better if not tty output.
-v56 1/24/86 Added -l option.
-v57 1/31/86 Fixed -l to get confirmation before
- ov erwriting an existing file.
-v58 8/28/86 Added filename globbing.
-v59 9/15/86 Fixed some bugs with very long filenames.
-v60 9/26/86 Incorporated changes from Leith (Casey)
- Leedom for boldface and -z option.
-v61 9/26/86 Got rid of annoying repaints after ! cmd.
- Posted to USENET.
------------------------------------------------------------------
-v62 12/23/86 Added is_directory(); change -z default to
- -1 instead of 24; cat-and-exit if -e and
- file is less than a screenful.
-v63 1/8/87 Fixed bug in cat-and-exit if > 1 file.
-v64 1/12/87 Changed puts/putstr, putc/putchr,
- getc/getchr to av oid name conflict with
- stdio functions.
-v65 1/26/87 Allowed '-' command to change NUMBER
- v alued options (thanks to Gary Puckering)
-v66 2/13/87 Fixed bug: prepaint should use force=1.
-v67 2/24/87 Added !! and % expansion to ! command.
-v68 2/25/87 Added SIGWINCH and TIOCGWINSZ support;
- changed is_directory to bad_file.
- (thanks to J. Robert Ward)
-v69 2/25/87 Added SIGWIND and WIOCGETD (for Unix PC).
-v70 3/13/87 Changed help cmd from 'h' to 'H'; better
- error msgs in bad_file, errno_message.
-v71 5/11/87 Changed -p to -c, made triple -c/-C
- for clear-eol like more's -c.
-v72 6/26/87 Added -E, -L, use $SHELL in lsystem().
- (thanks to Stev e Spearman)
-v73 6/26/87 Allow Examine "#" for previous file.
- Posted to USENET 8/25/87.
------------------------------------------------------------------
-v74 9/18/87 Fix conflict in EOF symbol with stdio.h,
- Make os.c more portable to BSD.
-v75 9/23/87 Fix problems in get_term (thanks to
- Paul Eggert); new backwards scrolling in
- jump_loc (thanks to Marion Hakanson).
-v76 9/23/87 Added -i flag; allow single "!" to
- inv oke a shell (thanks to Franco Barber).
-v77 9/24/87 Added -n flag and line number support.
-v78 9/25/87 Fixed problem with prompts longer than
- the screen width.
-v79 9/29/87 Added the _ command.
-v80 10/6/87 Allow signal to break out of linenum scan.
-v81 10/6/87 Allow -b to be changed from within less.
-v82 10/7/87 Add cmd_decode to use a table for key
- binding (thanks to Dav id Nason).
-v83 10/9/87 Allow .less file for user-defined keys.
-v84 10/11/87 Fix -e/-E problems (thanks to Felix Lee).
-v85 10/15/87 Search now keeps track of line numbers.
-v86 10/20/87 Added -B option and autobuf; fixed
- "pipe error" bug.
-v87 3/1/88 Fix bug re BSD signals while reading file.
-v88 3/12/88 Use new format for -P option (thanks to
- der Mouse), allow "+-c" without message,
- fix bug re BSD hangup.
-v89 3/18/88 Turn off line numbers if linenum scan
- is interrupted.
-v90 3/30/88 Allow -P from within less.
-v91 3/30/88 Added tags file support (new -t option)
- (thanks to Brian Campbell).
-v92 4/4/88 Added -+option syntax.
-v93 4/11/88 Add support for slow input (thanks to
- Joe Orost & apologies for taking almost
- 3 years to get this in!)
-v94 4/11/88 Redo reading/signal stuff.
-v95 4/20/88 Repaint screen better after signal.
-v96 4/21/88 Add /! and ?! commands.
-v97 5/17/88 Allow -l/-L from within less.
- Eliminate some static arrays (use calloc).
- Posted to USENET.
------------------------------------------------------------------
-v98 10/14/88 Fix incorrect calloc call; uninitialized
- var in exec_mca; core dump on unknown TERM.
- Make v cmd work if past last line of file.
- Fix some signal bugs.
-v99 10/29/88 Allow space between -X and string,
- when X is a string-valued option.
-v100 1/5/89 Fix globbing bug when $SHELL not set;
- allow spaces after -t command.
-v101 1/6/89 Fix problem with long (truncated) lines
- in tags file (thanks to Neil Dixon).
-v102 1/6/89 Fix bug with E# when no prev file;
- allow spaces after -l command.
-v103 3/14/89 Add -N, -f and -? options. Add z and w
- commands. Add %L for prompt strings.
-v104 3/16/89 Added EDITPROTO.
-v105 3/20/89 Fix bug in find_linenum which cached
- incorrectly on long lines.
-v106 3/31/89 Added -k option and multiple lesskey
- files.
-v107 4/27/89 Add 8-bit char support and -g option.
- Split option code into 3 files.
-v108 5/5/89 Allocate position table dynamically
- (thanks to Paul Eggert); change % command
- from "percent" to vi-style brace finder.
-v109 5/10/89 Added ESC-% command, split prim.c.
-v110 5/24/89 Fixed bug in + option; fixed repaint bug
- under Sun windows (thanks to Paul Eggert).
-v111 5/25/89 Generalized # and % expansion; use
- calloc for some error messages.
-v112 5/30/89 Get rid of ESC-%, add {}()[] commands.
-v113 5/31/89 Optimize lseeks (thanks to Paul Eggert).
-v114 7/25/89 Added ESC-/ and ESC-/! commands.
-v115 7/26/89 Added ESC-n command.
-v116 7/31/89 Added find_pos to optimize g command.
-v117 8/1/89 Change -f option to -r.
-v118 8/2/89 Save positions for all previous files,
- not just the immediately previous one.
-v119 8/7/89 Save marks across file boundaries.
- Add file handle stuff.
-v120 8/11/89 Add :ta command.
-v121 8/16/89 Add -f option.
-v122 8/30/89 Fix performance with many buffers.
-v123 8/31/89 Verbose prompts for string options.
- Posted beta to USENET.
------------------------------------------------------------------
-v124 9/18/89 Reorganize search commands,
- N = rev, ESC-n = span, add ESC-N.
-v125 9/18/89 Fix tab bug (thanks to Alex Liu).
- Fix EOF bug when both -w and -c.
-v126 10/25/89 Add -j option.
-v127 10/27/89 Fix problems with blank lines before BOF.
-v128 10/27/89 Add %bj, etc. to prompt strings.
-v129 11/3/89 Add -+,-- commands; add set-option and
- unset-option to lesskey.
-v130 11/6/89 Generalize A_EXTRA to string, remove
- set-option, unset-option from lesskey.
-v131 11/7/89 Changed name of EDITPROTO to LESSEDIT.
-v132 11/8/89 Allow editing of command prefix.
-v133 11/16/89 Add -y option (thanks to Jeff Sullivan).
-v134 12/1/89 Glob filenames in the -l command.
-v135 12/5/89 Combined {}()[] commands into one, and
- added ESC-^F and ESC-^B commands.
-v136 1/20/90 Added -S, -R flags. Added | command.
- Added warning for binary files. (thanks
- to Richard Brittain and J. Sullivan).
-v137 1/21/90 Rewrote horrible pappend code.
- Added * notation for hi-bit chars.
-v138 1/24/90 Fix magic cookie terminal handling.
- Get rid of "cleanup" loop in ch_get.
-v139 1/27/90 Added MSDOS support. (many thanks
- to Richard Brittain).
-v140 2/7/90 Editing a new file adds it to the
- command line list.
-v141 2/8/90 Add edit_list for editing >1 file.
-v142 2/10/90 Add :x command.
-v143 2/11/90 Add * and @ modifies to search cmds.
- Change ESC-/ cmd from /@* to / *.
-v144 3/1/90 Messed around with ch_zero;
- no real change.
-v145 3/2/90 Added -R and -v/-V for MSDOS;
- renamed FILENAME to avoid conflict.
-v146 3/5/90 Pull cmdbuf functions out of command.c
-v147 3/7/90 Implement ?@; fix multi-file edit bugs.
-v148 3/29/90 Fixed bug in :e<file> then :e#.
-v149 4/3/90 Change error,ierror,query to use PARG.
-v150 4/6/90 Add LESS_CHARSET, LESS_CHARDEF.
-v151 4/13/90 Remove -g option; clean up ispipe.
-v152 4/14/90 lsystem() closes input file, for
- editors which require exclusive open.
-v153 4/18/90 Fix bug if SHELL unset;
- fix bug in overstrike control char.
-v154 4/25/90 Output to fd 2 via buffer.
-v155 4/30/90 Ignore -i if uppercase in pattern
- (thanks to Michael Rendell.)
-v156 5/3/90 Remove scroll limits in forw() & back();
- causes problems with -c.
-v157 5/4/90 Forward search starts at next real line
- (not screen line) after jump target.
-v158 6/14/90 Added F command.
-v159 7/29/90 Fix bug in exiting: output not flushed.
-v160 7/29/90 Clear screen before initial output w/ -c.
-v161 7/29/90 Add -T flag.
-v162 8/14/90 Fix bug with +F on command line.
-v163 8/21/90 Added LESSBINFMT variable.
-v164 9/5/90 Added -p, LINES, COLUMNS and
- unset mark ' == BOF, for 1003.2 D5.
-v165 9/6/90 At EOF with -c set, don't display empty
- screen when try to page forward.
-v166 9/6/90 Fix G when final line in file wraps.
-v167 9/11/90 Translate CR/LF -> LF for 1003.2.
-v168 9/13/90 Return to curr file if "tag not found".
-v169 12/12/90 G goes to EOF even if file has grown.
-v170 1/17/91 Add optimization for BSD _setjmp;
- fix #include ioctl.h TERMIO problem.
- (thanks to Paul Eggert)
- Posted to USENET.
------------------------------------------------------------------
-v171 3/6/91 Fix -? bug in get_filename.
-v172 3/15/91 Fix G bug in empty file.
- Fix bug with ?\n and -i and uppercase
- pattern at EOF!
- (thanks to Paul Eggert)
-v173 3/17/91 Change N cmd to not permanently change
- direction. (thanks to Brian Matthews)
-v174 3/18/91 Fix bug with namelogfile not getting
- cleared when change files.
-v175 3/18/91 Fix bug with ++cmd on command line.
- (thanks to Jim Meyering)
-v176 4/2/91 Change | to not force current screen,
- include marked line, start/end from
- top of screen. Improve search speed.
- (thanks to Don Mears)
-v177 4/2/91 Add LESSHELP variable.
- Fix bug with F command with -e.
- Try /dev/tty for input before using fd 2.
- Patches posted to USENET 4/2/91.
------------------------------------------------------------------
-v178 4/8/91 Fixed bug in globbing logfile name.
- (thanks to Jim Meyering)
-v179 4/9/91 Allow negative -z for screen-relative.
-v180 4/9/91 Clear to eos rather than eol if "db";
- don't use "sr" if "da".
- (thanks to Tor Lillqvist)
-v181 4/18/91 Fixed bug with "negative" chars 80 - FF.
- (thanks to Benny Sander Hofmann)
-v182 5/16/91 Fixed bug with attribute at EOL.
- (thanks to Brian Matthews)
-v183 6/1/91 Rewrite linstall to do smart config.
-v184 7/11/91 Process \b in searches based on -u
- rather than -i.
-v185 7/11/91 -Pxxx sets short prompt; assume SIGWINCH
- after a SIGSTOP. (thanks to Ken Laprade)
------------------------------------------------------------------
-v186 4/20/92 Port to MS-DOS (Microsoft C).
-v187 4/23/92 Added -D option & TAB_COMPLETE_FILENAME.
-v188 4/28/92 Added command line editing features.
-v189 12/8/92 Fix mem overrun in anscreen.c:init;
- fix edit_list to recover from bin file.
-v190 2/13/93 Make TAB enter one filename at a time;
- create ^L with old TAB functionality.
-v191 3/10/93 Defer creating "flash" page for MS-DOS.
-v192 9/6/93 Add BACK-TAB.
-v193 9/17/93 Simplify binary_file handling.
-v194 1/4/94 Add rudiments of alt_filename handling.
-v195 1/11/94 Port back to Unix; support keypad.
------------------------------------------------------------------
-v196 6/7/94 Fix bug with bad filename; fix IFILE
- type problem. (thanks to David MacKenzie)
-v197 6/7/94 Fix bug with .less tables inserted wrong.
-v198 6/23/94 Use autoconf installation technology.
- (thanks to David MacKenzie)
-v199 6/29/94 Fix MS-DOS build (thanks to Tim Wiegman).
-v200 7/25/94 Clean up copyright, minor fixes.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v201 7/27/94 Check for no memcpy; add casts to calloc;
- look for regcmp in libgen.a.
- (thanks to Kaveh Ghazi).
-v202 7/28/94 Fix bug in edit_next/edit_prev with
- non-existent files.
-v203 8/2/94 Fix a variety of configuration bugs on
- various systems. (thanks to Sakai
- Kiyotaka, Harald Koenig, Bjorn Brox,
- Teemu Rantanen, and Thorsten Lockert)
-v204 8/3/94 Use strerror if available.
- (thanks to J.T. Conklin)
-v205 8/5/94 Fix bug in finding "me" termcap entry.
- (thanks to Andreas Stolcke)
-8/10/94 v205+: Change BUFSIZ to LBUFSIZE to avoid name
- conflict with stdio.h.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v206 8/10/94 Use initial_scrpos for -t to avoid
- displaying first page before init().
- (thanks to Dominique Petitpierre)
-v207 8/12/94 Fix bug if stdout is not tty.
-v208 8/16/94 Fix bug in close_altfile if goto err1
- in edit_ifile. (Thanks to M.J. Hewitt)
-v209 8/16/94 Change scroll to wscroll to avoid
- conflict with library function.
-v210 8/16/94 Fix bug with bold on 8 bit chars.
- (thanks to Vitor Duarte)
-v211 8/16/94 Don't quit on EOI in jump_loc / forw.
-v212 8/18/94 Use time_t if available.
-v213 8/20/94 Allow ospeed to be defined in termcap.h.
-v214 8/20/94 Added HILITE_SEARCH, -F, ESC-u cmd.
- (thanks to Paul Lew and Bob Byrnes)
-v215 8/23/94 Fix -i toggle behavior.
-v216 8/23/94 Process BS in all searches, not only -u.
-v217 8/24/94 Added -X flag.
-v218 8/24/94 Reimplement undo_search.
-v219 8/24/94 Find tags marked with line number
- instead of pattern.
-v220 8/24/94 Stay at same position after SIG_WINCH.
-v221 8/24/94 Fix bug in file percentage in big file.
-v222 8/25/94 Do better if can't reopen current file.
-v223 8/27/94 Support setlocale.
- (thanks to Robert Joop)
-v224 8/29/94 Revert v216: process BS in search
- only if -u.
-v225 9/6/94 Rewrite undo_search again: toggle.
-v226 9/15/94 Configuration fixes.
- (thanks to David MacKenzie)
-v227 9/19/94 Fixed strerror config problem.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v228 9/21/94 Fix bug in signals: repeated calls to
- get_editkeys overflowed st_edittable.
-v229 9/21/94 Fix "Nothing to search" error if -a
- and SRCH_PAST_EOF.
-v230 9/21/94 Don't print extra error msg in search
- after regerror().
-v231 9/22/94 Fix hilite bug if search matches 0 chars.
- (thanks to John Polstra)
-v232 9/23/94 Deal with weird systems that have
- termios.h but not tcgetattr().
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v233 9/26/94 Use get_term() instead of pos_init() in
- psignals to re-get lower_left termcap.
- (Thanks to John Malecki)
-v234 9/26/94 Make MIDDLE closer to middle of screen.
-v235 9/27/94 Use local strchr if system doesn't have.
-v236 9/28/94 Don't use libucb; use libterm if
- libtermcap & libcurses doesn't work.
- (Fix for Solaris; thanks to Frank Kaefer)
-v237 9/30/94 Use system isupper() etc if provided.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v238 10/6/94 Make binary non-blinking if LESSBINFMT
- is set to a string without a *.
-v239 10/7/94 Don't let delimit_word run back past
- beginning of cmdbuf.
-v240 10/10/94 Don't write into termcap buffer.
- (Thanks to Benoit Speckel)
-v241 10/13/94 New lesskey file format.
- Don't expand filenames in search command.
-v242 10/14/94 Allow lesskey specification of "literal".
-v243 10/14/94 Add #stop command to lesskey.
-v244 10/16/94 Add -f flag to lesskey.
-v245 10/25/94 Allow TAB_COMPLETE_FILENAME to be undefd.
-v246 10/27/94 Move help file to /usr/local/share.
-v247 10/27/94 Add -V option.
-v248 11/5/94 Add -V option to lesskey.
-v249 11/5/94 Remove -f flag from lesskey; default
- input file is ~/.lesskey.in, not stdin.
-v250 11/7/94 Lesskey input file "-" means stdin.
-v251 11/9/94 Convert cfgetospeed result to ospeed.
- (Thanks to Andrew Chernov)
-v252 11/16/94 Change default lesskey input file from
- .lesskey.in to .lesskey.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v253 11/21/94 Fix bug when tags file has a backslash.
-v254 12/6/94 Fix -k option.
-v255 12/8/94 Add #define EXAMINE to disable :e etc.
-v256 12/10/94 Change highlighting: only highlite search
- results (but now it is reliable).
-v257 12/10/94 Add goto_line and repaint_highlight
- to optimize highlight repaints.
-v258 12/12/94 Fixup in hilite_line if BS_SPECIAL.
-v259 12/12/94 Convert to autoconf 2.0.
-v260 12/13/94 Add SECURE define.
-v261 12/14/94 Use system WERASE char as EC_W_BACKSPACE.
-v262 12/16/94 Add -g/-G flag and screen_hilite.
-v263 12/20/94 Reimplement/optimize -G flag behavior.
-v264 12/23/94 Allow EXTRA string after line-edit cmd
- in lesskey file.
-v265 12/24/94 Add LESSOPEN=|cmd syntax.
-v266 12/26/94 Add -I flag.
-v267 12/28/94 Formalize the four-byte header emitted
- by a LESSOPEN pipe.
-v268 12/28/94 Get rid of four-byte header.
-v269 1/2/95 Close alt file before open new one.
- Avoids multiple popen().
-v270 1/3/95 Use VISUAL; use S_ISDIR/S_ISREG; fix
- config problem with Solaris POSIX regcomp.
-v271 1/4/95 Don't quit on read error.
-v272 1/5/95 Get rid of -L.
-v273 1/6/95 Fix ch_ungetchar bug; don't call
- LESSOPEN on a pipe.
-v274 1/6/95 Ported to OS/2 (thanks to Kai Uwe Rommel)
-v275 1/18/95 Fix bug if toggle -G at EOF.
-v276 1/30/95 Fix OS/2 version.
-v277 1/31/95 Add "next" charset; don't display ^X
- for X > 128.
-v278 2/14/95 Change default for -G.
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v279 2/22/95 Add GNU options --help, --version.
- Minor config fixes.
-v280 2/24/95 Clean up calls to glob(); don't set #
- if we can't open the new file.
-v281 2/24/95 Repeat search should turn on hilites.
-v282 3/2/95 Minor fixes.
-v283 3/2/95 Fix homefile; make OS2 look in $HOME.
-v284 3/2/95 Error if "v" on LESSOPENed file;
- "%" figures out file size on pipe.
-v285 3/7/95 Don't set # in lsystem;
- lesskey try $HOME first.
-v286 3/7/95 Reformat change history (too much free time?).
-v287 3/8/95 Fix hilite bug if overstrike multiple chars.
-v288 3/8/95 Allow lesskey to override get_editkey keys.
-v289 3/9/95 Fix adj_hilite bug when line gets processed by
- hilite_line more than once.
-v290 3/9/95 Make configure automatically. Fix Sequent problem
- with incompatible sigsetmask().
- Posted to prep.ai.mit.edu
------------------------------------------------------------------
-v291 3/21/95 Add #env to lesskey. Fix MS-DOS build.
- Posted to simtel.
------------------------------------------------------------------
-v292 4/24/95 Add MS-DOS support for Borland C.
- Fix arrow keys in MS-DOS versions.
-v293 4/28/95 Add auto-versioning stuff to make dist.
-v294 5/12/95 Fix Borland build.
-v295 1/20/96 Fix search on squished file; add /@@.
-v296 1/23/96 Allow cmdbuf larger than screen width.
-v297 1/24/96 Don't call termcap if tgetent fails;
- add #defines for buffers.
-v298 1/24/96 Change @@ to ^K.
- Add alternate search modifiers ^N, ^F, ^E.
-v299 1/25/96 Fix percent overflow in jump_percent (thanks to Brent Wiese);
- don't send "ti" after shell command till RETURN pressed.
-v300 1/25/96 Change -U to print tabs as ^I.
-v301 1/30/96 Make hilites work in cmd F output.
-v302 1/31/96 Fix cmd F to notice window-change signals.
-v303 1/31/96 Add ESC-SPACE command.
-v304 2/1/96 Add ^R search modifier; add LESSSECURE.
-v305 2/2/96 Workaround Linux /proc kernel bug; add LESSKEY.
-v306 3/16/96 Minor fixes.
-v307 3/25/96 Allow cmd line arg "--"; fix DOS & OS/2 defines.h.
-v308 4/4/96 Port to OS-9 (thanks to Boisy Pitre); fix -d.
-v309 4/9/96 Fix OS-9 version; fix tags bug with "$".
-v310 4/10/96 Get rid of HELPFILE.
-v311 4/22/96 Add Windows32 support; merge doscreen.c into screen.c.
-v312 4/24/96 Don't quit after "cannot reopen" error.
-v313 4/25/96 Added horizontal scrolling.
-v314 4/26/96 Modified -e to quit on reaching end of a squished file.
-v315 4/26/96 Fix "!;TAB" bug.
-v316 5/2/96 Make "|a" when (a < curr screen) go to end of curr screen.
-v317 5/14/96 Various fixes for the MS-DOS and OS/2 builds.
- Added ## and %% handling for filenames
-v318 5/29/96 Port to OS-9 Microware compiler; minor fixes
- (thanks to Martin Gregorie).
-v319 7/8/96 Fix Windows port (thanks to Jeff Paquette).
-v320 7/11/96 Final fixes for Windows port.
-v321 7/18/96 Minor fixes.
- Posted to Web page.
------------------------------------------------------------------
-v322 8/13/96 Fix bug in shell escape from help file; add support for
- Microsoft Visual C under Windows; numerous small fixes.
-v323 8/19/96 Fixes for Windows version (thanks to Simon Munton);
- fix for Linux library weirdness (thanks to Jim Diamond);
- port to DJGPP (thanks to Eli Zaretskii).
-v324 8/21/96 Add support for spaces in filenames (thanks to Simon Munton).
-v325 8/21/96 Add lessecho, for spaces in filenames under Unix.
-v326 8/27/96 Fix DJGPP version.
-v327 9/1/96 Reorganize lglob, make spaces in filenames work better in Unix.
-v328 10/7/96 Append / to directory name in filename completion.
- Fix MS-DOS and OS-9 versions.
-v329 10/11/96 Fix more MS-DOS bugs; add LESSSEPARATOR; add -" option.
- Add LESSMETACHARS, LESSMETAESCAPE.
-v330 10/21/96 Minor fixes.
- Posted to Web page.
------------------------------------------------------------------
-v331 4/22/97 Various Windows fixes (thanks to Gurusamy Sarathy).
-v332 4/22/97 Enter filenames from cmd line into edit history.
- Posted to Web page.
------------------------------------------------------------------
-v333 3/4/99 Changed -w to highlite new line after forward movement.
-v334 3/9/99 Avoid overflowing prompt buffer; add %d and %D.
-v335 3/20/99 Add EBCDIC support (thanks to Thomas Dorner).
- Use HOMEDRIVE/HOMEPATH on Windows (thanks to Preston Bannister).
- Posted to Web page.
------------------------------------------------------------------
-v336 4/8/99 Fix installation bugs.
-v337 4/9/99 Fix another installation bug.
- Posted to Web page.
------------------------------------------------------------------
-v338 4/13/99 Add support for long option names.
-v339 4/18/99 Add \k, long option names to lesskey. Add -^P. Add :d.
-v340 4/21/99 Add regexec2. Fix Windows build.
- Posted to Web page.
------------------------------------------------------------------
-v341 5/6/99 Add -F option; %c & ?c prompt escapes.
- (Thanks to Michele Maltoni)
-v342 7/22/99 Add system-wide lesskey file; allow GPL or Less License.
-v343 9/23/99 Support UTF-8 (Thanks to Robert Brady).
- Add %P and ?P in prompts.
-v344 10/27/99 -w highlights target line of g and p commands.
-v345 10/29/99 Make -R pass thru ESC but not other control chars.
- Posted to Web page.
------------------------------------------------------------------
-v346 11/4/99 Fix bugs in long option processing; R cmd should clear hilites.
- Posted to Web page.
------------------------------------------------------------------
-v347 12/13/99 Fixes for DJGPP version (thanks to Eli Zaretskii).
-v348 12/28/99 Fix deleting file with marks (thanks to Dimitar Jekov).
- Fix color problem in DJGPP version (thanks to Eli Zaretskii).
-v349 1/24/00 Fix minor DJGPP bugs; check environment vars for UTF-8;
- add --with-editor (thanks to Eli, Markus Kuhn, Thomas Schoepf).
-v350 3/1/00 Fix clear-while-standout bug.
-v351 3/5/00 Change -M and = prompts to show top & bottom line number.
- Posted to Web page.
------------------------------------------------------------------
-v352 3/8/00 Fix scan_option NULL dereference.
------------------------------------------------------------------
-v353 3/20/00 Fix SECURE compile bug, allow space after numeric option.
-v354 3/23/00 Add support for PCRE; add --with-regex configure option.
------------------------------------------------------------------
-v355 6/28/00 Add -# option (thanks to Andy Levinson).
-v356 7/5/00 Add -J option.
-v357 7/6/00 Support sigprocmask.
------------------------------------------------------------------
-v358 7/8/00 Fix problems with #stop in lesskey file.
- Posted to Web page.
------------------------------------------------------------------
-v359 9/10/00 Fixes for Win32 display problems (thanks to Maurizio Vairani).
-v360 1/17/01 Move sysless to etc.
-v361 12/4/01 Add IBM-1047 charset & EBCDIC fixes (thanks to Thomas Dorner).
- Fix 32 bit dependencies (thanks to Paul Eggert).
- Fix UTF-8 overstriking (thanks to Robert Brady).
-v362 12/4/01 Make status column show search targets.
-v363 12/6/01 Add --no-keypad option.
- Add variable width tabstops (thanks to Peter Samuelson).
-v364 12/10/01 Better handling of very long lines in input;
- Fix horizontal shifting of colored text.
-v365 12/11/01 Fix overstriking of tabs;
- Add support for global(1) and multiple tag matches
- (thanks to Shigio Yamaguchi and Tim Vanderhoek).
-v366 12/11/01 Fixes for OS/2 (thanks to Kyosuke Tokoro).
-v367 12/13/01 Allow -D and -x options to terminate without dollar sign;
- Right/left arrow when entering N are shift cmds, not line edit.
-v368 12/18/01 Update lesskey commands.
-v370 12/23/01 Fix tags error messages.
- Posted to Web page.
------------------------------------------------------------------
-v371 12/26/01 Fix new_file bug; use popen in Windows version;
- fix some compiler warnings.
-v372 12/29/01 Make -b be in units of 1K.
-v373 1/14/02 Improve handling of filenames containing shell metachars.
-v374 2/7/02 Fix memory leak; fix bug in -x argument parsing.
-v375 4/7/02 Fix searching for SGR sequences; fix SECURE build;
- add SGR support to DJGPP version (thanks to Eli Zaretskii).
-v376 6/10/02 Fix bug in overstriking mulitbyte UTF-8 characters
- (thanks to Jungshik Shin).
- Posted to Web page.
------------------------------------------------------------------
-v377 9/10/02 Fix bug in Windows version when file contains CR;
- fix bug in search highlights with -R;
- make initial buffer limit really be 64K not unlimited.
-v378 9/30/02 Misc bug fixes and compiler warning cleanup.
- Posted to Web page.
------------------------------------------------------------------
-v379 11/23/02 Add -L option; fix bug with ctrl-K in lesskey files;
- improve UTF-8 overstriking and underscore overstriking;
- fix minor man page problems; change to autoconf 2.54.
-v380 11/24/02 Make LINENUM same as POSITION.
-v381 11/28/02 Make -N use 7 columns for line number if possible.
------------------------------------------------------------------
-v382 2/3/04 Remove copyrighted code.
------------------------------------------------------------------
-v383 2/16/04 Add history file; add -K option; improve UTF-8 handling;
- fix some signed char bugs (thanks to Christian Biere);
- fix some upper/lower case bugs (thanks to Bjoern Jacke);
- add erase2 char (thanks to David Lawrence);
- add windows charset (thanks to Dimitar Zhekov).
-v384 2/20/04 Improvements in UTF-8 handling.
-v385 2/23/04 Fix UTF-8 output bug.
------------------------------------------------------------------
-v386 9/13/05 Improvements to UTF-8 shift & color (thanks to Charles Levert);
- protect against invalid LESSOPEN and LESSCLOSE values.
-v387 9/14/05 Update Charles Levert's UTF-8 patch.
-v388 9/14/05 Change history behavior; change most sprintf calls to snprintf.
-v389 9/14/05 Fix copy & paste with long lines; improve performance of
- expand_linebuf; fix crash in init_mlist;
-v390 9/15/05 Show search matches in status column even if -G is set.
------------------------------------------------------------------
-v391 9/17/05 Fix bugs.
-v392 10/14/05 Fix line wrapping bug.
-v393 10/19/05 Allow multiple attributes per char; fix bold+underline bug
- (thanks again to Charles Levert).
-v394 11/8/05 Fix prompt bug; fix compile problem in Windows build.
------------------------------------------------------------------
-v395 1/12/07 Update Unicode tables (thanks to Charles Levert);
- don't chmod if LESSHISTFILE = /dev/null;
- make -f work for directories; support DESTDIR in Makefile;
- fix sigset_t detection in configure;
- make "t" cmd traverse tags in correct order
-v396 1/13/07 Add compatibility with POSIX more.
-v397 3/21/07 Allow decimal point in number for % command;
- Allow decimal point in number for -j option;
- Allow n command to fetch last search pattern from history
- (thanks to arno).
-v398 3/22/07 Don't rewrite history file if not necessary;
- fix bug when filenames contain "$".
-v399 3/22/07 Don't move to bottom of screen at startup;
- don't output extraneous newlines.
-v400 3/23/07 Allow search to find pattern after null byte (PCRE and no-regex)
- (thanks to Michael Constant).
------------------------------------------------------------------
-v401 3/24/07 Minor documentation fixes.
-v402 3/30/07 Fix autoconf bug when memcpy etc are inline;
- fix bug in terminating number following -j option.
-v403 5/25/07 Fix Windows build.
-v404 6/5/07 Fix display bug with F command and long lines.
-v405 6/17/07 Fix display bug when using -w option.
-v406 6/17/07 Fix secure build.
-v407 8/16/07 Fix bugs; support CSI chars.
-v408 10/1/07 Fix bug in -i with non-ASCII chars.
-v409 10/12/07 Fix crash when viewing text with invalid UTF-8 sequences.
-v411 11/6/07 Fix case-insensitive searching with non-ASCII text.
-v412 11/6/07 Use symbolic SEEK constants.
-v413 11/6/07 Fix search highlight bug with non-ASCII text.
-v414 11/6/07 Fix display bug with no-wrap terminals.
-v415 11/14/07 Add --follow-name option.
-v416 11/22/07 Fix crash when searching text with invalid UTF-8 sequences.
-v417 12/31/07 Don't support single-char CSI in UTF-8 mode;
- fix bug with -R and invalid CSI sequences;
- fix bug searching text with SGR sequences with -r;
- emulate SGR sequences in WIN32 build.
-v418 12/31/07 Clean up.
------------------------------------------------------------------
-v419 1/16/08 Make CSI char 0x9B work in UTF-8 mode (thanks to Colin Watson).
-v420 2/24/08 Add & command; fix -F option; fix '' after G.
-v421 2/24/08 Ignore filtered lines when searching.
-v422 3/2/08 Output CR at startup.
-v423 5/27/08 Clean up.
-v424 6/16/08 Fix compile bug with pcre; don't filter help file.
-v425 7/14/08 Fix non-ANSI code in list handling in ch.c.
-v426 10/27/08 Fix ignaw terminal handling (thanks to Per Hedeland);
- fix binary file detection in UTF-8 mode.
-v427 3/16/09 A few Win32 fixes (thanks to Jason Hood).
-v428 3/30/09 Add "|-" syntax to LESSOPEN.
-v429 4/10/09 Fix search highlighting bug with underlined text.
------------------------------------------------------------------
-v430 4/22/09 Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
-v431 4/29/09 Fix highlight bug when match is at end of line.
-v432 6/27/09 Better fix for highlight bugs;
- fix new problems with ignaw terminals.
-v433 6/28/09 Cleanup search code.
-v434 6/29/09 More cleanup.
-v435 7/04/09 Fix bugs with non-regex filtering.
-v436 7/05/09 Fix memory leak.
------------------------------------------------------------------
-v437 7/14/09 Fix bug in handling some long option names;
- make percentage calculation more accurate.
-v438 12/29/10 Fix bugs with -i/-I and & filtering;
- exit with status 2 on ctrl-C with -K.
-v439 12/31/10 Add -A option.
-v440 1/5/11 Fix bug displaying prompt after = command.
-v441 1/21/11 Fix semi-infinite loop if no newlines in file;
- make new -A behavior the default.
------------------------------------------------------------------
-v442 3/2/11 Fix search bug.
- Add ctrl-G line edit command.
-v443 4/9/11 Fix Windows build.
-v444 6/8/11 Fix ungetc bug; remove vestiges of obsolete -l option.
------------------------------------------------------------------
-v445 10/19/11 Fix hilite bug in backwards scroll with -J.
- Fix hilite bug with backspaces.
- Fix bugs handling SGR sequences in Win32 (thanks to Eric Lee).
- Add support for GNU regex (thanks to Reuben Thomas).
-v446 5/15/12 Up/down arrows in cmd editing search for matching cmd.
-v447 5/21/12 Add ESC-F command, two-pipe LESSOPEN syntax.
-v448 6/15/12 Print name of regex library in version message.
-v449 6/23/12 Allow config option --with-regex=none.
-v450 7/4/12 Fix EOF bug with ESC-F.
-v451 7/20/12 Fix typo.
------------------------------------------------------------------
-v452 10/19/12 Fix --with-regex=none, fix "stty 0", fix Win32.
- Don't quit if errors in cmd line options.
-v453 10/27/12 Increase buffer sizes.
-v454 11/5/12 Fix typo.
-v455 11/5/12 Fix typo.
-v456 11/8/12 Fix option string incompatibility.
-v457 12/8/12 Use new option string syntax only after --use-backslash.
-v458 4/4/13 Fix display bug in using up/down in cmd buffer.
-*/
-
-char version[] = "458";
+ * Modified for use with illumos.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
+/*
+ * This records the base version, plus our own details.
+ */
+char version[] = "(OpenBSD)";