diff options
56 files changed, 15618 insertions, 6890 deletions
diff --git a/usr.bin/less/Makefile.bsd-wrapper b/usr.bin/less/Makefile.bsd-wrapper index b4caf55c921..d79ba865396 100644 --- a/usr.bin/less/Makefile.bsd-wrapper +++ b/usr.bin/less/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.18 1999/02/03 23:36:45 millert Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.19 2003/04/13 18:26:25 millert Exp $ # # less config @@ -6,7 +6,6 @@ PREFIX= /usr BINDIR= ${PREFIX}/bin DATADIR= ${PREFIX}/share/misc -LESS_HLP= more.help LIBS= -lcurses LINKS= ${BINDIR}/less ${BINDIR}/more ${BINDIR}/less ${BINDIR}/page MAN= less.1 lesskey.1 @@ -16,9 +15,7 @@ CLEANFILES= config.cache config.log $(MAN) # # Wrapped flags # -WCC= CC="${CC}" -WCFLAGS= CFLAGS="${CFLAGS} ${COPTS}" -WLDFLAGS= LDFLAGS="${LDSTATIC}" +XCFLAGS= CC="${CC}" CFLAGS="${CFLAGS} ${COPTS}" LDFLAGS="${LDFLAGS} ${LDSTATIC}" all: config.status gnu_build @@ -38,8 +35,8 @@ OBJS= main.o screen.o brac.o ch.o charset.o cmdbuf.o \ tags.o ttyin.o version.o .SUFFIXES: .o .c .c.o: config.status - @$(MAKE) ${WCC} ${WCFLAGS} ${WLDFLAGS} LIBS=${LIBS} \ - datadir=${DATADIR} LESS_HLP=${LESS_HLP} ${.TARGET} + @$(MAKE) ${XCFLAGS} LIBS=${LIBS} \ + datadir=${DATADIR} ${.TARGET} .FORCE: .IGNORE @@ -48,25 +45,26 @@ OBJS= main.o screen.o brac.o ch.o charset.o cmdbuf.o \ .ifdef GLOBAL_AUTOCONF_CACHE CF= --cache-file=${GLOBAL_AUTOCONF_CACHE} .else -CF= +CF= --cache-file=config.cache .endif config: .FORCE .ifndef GLOBAL_AUTOCONF_CACHE -rm -f config.cache .endif - PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ + ${XCFLAGS} PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \ - /bin/sh ${.CURDIR}/configure --prefix=/usr ${CF} + TERMLIBS=-lcurses /bin/sh ${.CURDIR}/configure \ + --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc ${CF} config.status: - PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ + ${XCFLAGS} PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \ - /bin/sh ${.CURDIR}/configure --prefix=/usr ${CF} + TERMLIBS=-lcurses /bin/sh ${.CURDIR}/configure \ + --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc ${CF} gnu_build: - ${MAKE} ${WCC} ${WCFLAGS} ${WLDFLAGS} LIBS=${LIBS} datadir=${DATADIR} \ - LESS_HLP=${LESS_HLP} + ${MAKE} ${XCFLAGS} LIBS=${LIBS} datadir=${DATADIR} .ifdef NOMAN maninstall: @@ -88,8 +86,8 @@ install: gnu_install maninstall _SUBDIRUSE .endif gnu_install: - ${MAKE} ${WCC} ${WCFLAGS} ${WLDFLAGS} LIBS=${LIBS} \ - LESS_HLP=${LESS_HLP} bindir=${DESTDIR}${BINDIR} \ + ${MAKE} ${XCFLAGS} LIBS=${LIBS} \ + bindir=${DESTDIR}${BINDIR} \ datadir=${DESTDIR}${PREFIX}/share/misc \ INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444" \ diff --git a/usr.bin/less/Makefile.dos b/usr.bin/less/Makefile.dos deleted file mode 100644 index 3136f270a2a..00000000000 --- a/usr.bin/less/Makefile.dos +++ /dev/null @@ -1,56 +0,0 @@ -# $OpenBSD: Makefile.dos,v 1.2 2001/01/29 01:57:59 niklas Exp $ - -# Makefile for less. -# MS-DOS version - -#### Start of system configuration section. #### - -CC = cl -LIBDIR = \msc6.0\lib - -CFLAGS = -O /Alfw -LDFLAGS = -O -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. ${CPPFLAGS} ${CFLAGS} $< - -SRC = main.c doscreen.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 -OBJ = main.obj doscreen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \ - decode.obj edit.obj filename.obj forwback.obj help.obj ifile.obj \ - input.obj jump.obj line.obj linenum.obj lsystem.obj \ - mark.obj optfunc.obj option.obj opttbl.obj os.obj output.obj \ - position.obj prompt.obj search.obj signal.obj tags.obj \ - ttyin.obj version.obj - -all: less lesskey - -# This is really horrible, but the command line is too long for -# MS-DOS if we try to link $(OBJ). -less: $(OBJ) - -del lesskey.obj - $(CC) $(LDFLAGS) -o $@ *.obj $(LIBS) - -lesskey: lesskey.obj version.obj - $(CC) $(LDFLAGS) -o $@ lesskey.obj version.obj $(LIBS) - -defines.h: defines.dos - -del defines.h - -copy defines.dos 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 index ff9aed5d793..5a3d4e74aa9 100644 --- a/usr.bin/less/Makefile.in +++ b/usr.bin/less/Makefile.in @@ -1,5 +1,3 @@ -# $OpenBSD: Makefile.in,v 1.4 2001/01/29 01:58:00 niklas Exp $ - # Makefile for less. #### Start of system configuration section. #### @@ -12,14 +10,6 @@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ -# -# XXX - OpenBSD modificatations -# -INSTALL_MAN=install_man -MANPAGES=less.nro lesskey.nro -INSTALLDIRS=installdirs -LESS_HLP=more.help - CFLAGS = @CFLAGS@ CFLAGS_COMPILE_ONLY = -c LDFLAGS = @LDFLAGS@ @@ -31,13 +21,12 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ # Where the installed binary goes. -bindir = ${exec_prefix}/bin +bindir = @bindir@ binprefix = -# Where the help file goes. -datadir = ${prefix}/share +sysconfdir = @sysconfdir@ -mandir = ${prefix}/man/man${manext} +mandir = @mandir@ manext = 1 manprefix = @@ -48,30 +37,16 @@ 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} ${CPPFLAGS} ${CFLAGS} $< - -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 + ${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} decode.${O} edit.${O} filename.${O} forwback.${O} \ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \ output.${O} position.${O} prompt.${O} search.${O} signal.${O} \ tags.${O} ttyin.${O} version.${O} @REGEX_O@ -DISTFILES = ${SRC} regexp.c regexp.h \ - INSTALL Makefile.in README NEWS \ - configure configure.in acconfig.h lesskey.c \ - cmd.h funcs.h less.h lesskey.h option.h position.h \ - install.sh defines.h.in defines.h.top mkinstalldirs \ - less.nro lesskey.nro less.man lesskey.man less.hlp \ - Makefile.dos defines.dos doscreen.c \ - Makefile.os2 defines.os2 -all: less lesskey +all: less lesskey lessecho less: ${OBJ} ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS} @@ -79,27 +54,25 @@ less: ${OBJ} lesskey: lesskey.${O} version.${O} ${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O} -${OBJ}: less.h defines.h funcs.h +lessecho: lessecho.${O} version.${O} + ${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O} -filename.${O}: filename.c - ${CC} -c -DHELPFILE=\"${datadir}/${LESS_HLP}\" -I. ${CPPFLAGS} ${CFLAGS} ${srcdir}/filename.c +${OBJ}: ${srcdir}/less.h ${srcdir}/funcs.h defines.h -install: all less.hlp $(INSTALL_MAN) $(INSTALLDIRS) +install: all ${srcdir}/lesskey.nro ${INSTALL_PROGRAM} less ${bindir}/${binprefix}less ${INSTALL_PROGRAM} lesskey ${bindir}/${binprefix}lesskey - ${INSTALL_DATA} ${srcdir}/less.hlp ${datadir}/${LESS_HLP} + ${INSTALL_PROGRAM} lessecho ${bindir}/${binprefix}lessecho -installdirs: mkinstalldirs - ${srcdir}/mkinstalldirs ${bindir} ${datadir} ${mandir} +install-strip: + ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install -install_man: ${MANPAGES} - ${INSTALL_DATA} ${srcdir}/less.nro ${mandir}/${manprefix}less.${manext} - ${INSTALL_DATA} ${srcdir}/lesskey.nro ${mandir}/${manprefix}lesskey.${manext} +#installdirs: mkinstalldirs +# sh ${srcdir}/mkinstalldirs ${bindir} ${mandir}/man${manext} uninstall: - rm -f ${bindir}/${binprefix}less ${bindir}/${binprefix}lesskey - rm -f ${datadir}/${LESS_HLP} - rm -f ${mandir}/less.${manext} ${mandir}/lesskey.${manext} + rm -f ${bindir}/${binprefix}less ${bindir}/${binprefix}lesskey ${bindir}/${binprefix}lessecho + rm -f ${mandir}/man${manext}/${manprefix}less.${manext} ${mandir}/man${manext}/${manprefix}lesskey.${manext} info: install-info: @@ -116,22 +89,16 @@ 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: Makefile.in config.status +Makefile: ${srcdir}/Makefile.in config.status CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status config.status: ${srcdir}/configure ./config.status --recheck -configure: configure.in - autoheader - autoconf +#${srcdir}/configure: ${srcdir}/configure.ac +# cd ${srcdir}; autoheader; autoconf -lint: - lint -I. ${CPPFLAGS} ${SRC} -newfuncs: - mv -f funcs.h funcs.h.old - awk -f mkfuncs.awk ${SRC} >funcs.h clean: - rm -f *.${O} core less lesskey + rm -f *.${O} core less lesskey lessecho mostlyclean: clean @@ -141,20 +108,3 @@ distclean: clean realclean: distclean rm -f TAGS -dist: ${DISTFILES} - if [ ! -d release ]; then mkdir release; fi - @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 "Creating release/$$REL/$$REL.tar.gz"; \ - rm -rf $$REL; mkdir $$REL; \ - for file in ${DISTFILES}; do \ - ln $$file $$REL || \ - { echo "cannot link, copying $$file"; cp -p $$file $$REL; }; \ - done; \ - tar -chf - $$REL | gzip -c >release/$$REL/$$REL.tar.gz; \ - rm -rf $$REL - -tagall: - @REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/v\1/' -e q version.c`; \ - echo "tagging $$REL"; \ - $(RCS) -N$$REL: RCS/*,v diff --git a/usr.bin/less/Makefile.os2 b/usr.bin/less/Makefile.os2 deleted file mode 100644 index fb1ea1c8895..00000000000 --- a/usr.bin/less/Makefile.os2 +++ /dev/null @@ -1,41 +0,0 @@ -# $OpenBSD: Makefile.os2,v 1.2 2001/01/29 01:58:00 niklas Exp $ - -# Makefile for less. -# OS/2 version, for emx+gcc compiler - -#### Start of system configuration section. #### - -CC = gcc -Zomf -CFLAGS = -I. -O -LDFLAGS = -s -Zcrtdll -Zstack 512 -LIBS = -ltermcap -O = obj - -#### End of system configuration section. #### - -.SUFFIXES: .c .$(O) - -# This rule allows us to supply the necessary -D options -# in addition to whatever the user asks for. -.c.$(O): - ${CC} -c ${CPPFLAGS} ${CFLAGS} $< - -OBJ = main.$(O) screen.$(O) brac.$(O) ch.$(O) charset.$(O) cmdbuf.$(O) \ - command.$(O) decode.$(O) edit.$(O) filename.$(O) forwback.$(O) \ - help.$(O) ifile.$(O) input.$(O) jump.$(O) line.$(O) linenum.$(O) \ - lsystem.$(O) mark.$(O) optfunc.$(O) option.$(O) opttbl.$(O) os.$(O) \ - output.$(O) position.$(O) prompt.$(O) search.$(O) signal.$(O) \ - tags.$(O) ttyin.$(O) version.$(O) regexp.$(O) - -all: less.exe lesskey.exe - -less.exe: $(OBJ) - $(CC) $(OBJ) -o $@ $(LDFLAGS) $(LIBS) - -lesskey.exe: lesskey.$(O) version.$(O) - $(CC) $(CFLAGS) lesskey.$(O) version.$(O) -o $@ $(LDFLAGS) - -$(OBJ): defines.h less.h - -defines.h: defines.os2 - copy defines.os2 defines.h diff --git a/usr.bin/less/acconfig.h b/usr.bin/less/acconfig.h deleted file mode 100644 index 33c5a0a7497..00000000000 --- a/usr.bin/less/acconfig.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: acconfig.h,v 1.2 2001/01/29 01:58:00 niklas Exp $ */ - -/* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * 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 -#undef NO_REGEX - -/* Define HAVE_VOID if your compiler supports the "void" type. */ -#undef HAVE_VOID - -/* Define HAVE_TIME_T if your system supports the "time_t" type. */ -#undef HAVE_TIME_T - -/* Define HAVE_STRERROR if you have the strerror() function. */ -#undef HAVE_STRERROR - -/* Define HAVE_FILENO if you have the fileno() macro. */ -#undef HAVE_FILENO - -/* Define HAVE_ERRNO if you have the errno variable */ -#undef HAVE_ERRNO - -/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */ -#undef HAVE_SYS_ERRLIST - -/* Define HAVE_OSPEED if your termcap library has the ospeed variable */ -#undef HAVE_OSPEED -/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined - * in termcap.h. */ -#undef MUST_DEFINE_OSPEED - -/* Define HAVE_LOCALE if you have locale.h and setlocale. */ -#undef HAVE_LOCALE - -/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */ -#undef HAVE_TERMIOS_FUNCS - -/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */ -#undef HAVE_UPPER_LOWER diff --git a/usr.bin/less/brac.c b/usr.bin/less/brac.c index 7765055d878..43c9dacb247 100644 --- a/usr.bin/less/brac.c +++ b/usr.bin/less/brac.c @@ -1,29 +1,11 @@ -/* $OpenBSD: brac.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -44,13 +26,13 @@ */ public void match_brac(obrac, cbrac, forwdir, n) - int obrac; - int cbrac; + register int obrac; + register int cbrac; int forwdir; int n; { - int c; - int nest; + register int c; + register int nest; POSITION pos; int (*chget)(); diff --git a/usr.bin/less/ch.c b/usr.bin/less/ch.c index 762cf8a74c9..0446a2c2292 100644 --- a/usr.bin/less/ch.c +++ b/usr.bin/less/ch.c @@ -1,29 +1,11 @@ -/* $OpenBSD: ch.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -34,6 +16,12 @@ */ #include "less.h" +#if MSDOS_COMPILER==WIN32C +#include <errno.h> +#include <windows.h> +#endif + +typedef POSITION BLOCKNUM; public int ignore_eoi; @@ -43,34 +31,38 @@ public int ignore_eoi; * in order from most- to least-recently used. * The circular list is anchored by the file state "thisfile". */ -#define LBUFSIZE 1024 +#define LBUFSIZE 8192 struct buf { - struct buf *next, *prev; /* Must be first to match struct filestate */ - long block; + struct buf *next, *prev; + struct buf *hnext, *hprev; + BLOCKNUM block; unsigned int datasize; unsigned char data[LBUFSIZE]; }; +struct buflist { + /* -- Following members must match struct buf */ + struct buf *buf_next, *buf_prev; + struct buf *buf_hnext, *buf_hprev; +}; + /* * The file state is maintained in a filestate structure. * A pointer to the filestate is kept in the ifile structure. */ +#define BUFHASH_SIZE 64 struct filestate { - /* -- Following members must match struct buf */ struct buf *buf_next, *buf_prev; - long buf_block; - /* -- End of struct buf copy */ + struct buflist hashtbl[BUFHASH_SIZE]; int file; int flags; POSITION fpos; int nbufs; - long block; - int offset; + BLOCKNUM block; + unsigned int offset; POSITION fsize; }; - -#define END_OF_CHAIN ((struct buf *)thisfile) #define ch_bufhead thisfile->buf_next #define ch_buftail thisfile->buf_prev #define ch_nbufs thisfile->nbufs @@ -81,12 +73,33 @@ struct filestate { #define ch_flags thisfile->flags #define ch_file thisfile->file +#define END_OF_CHAIN ((struct buf *)&thisfile->buf_next) +#define END_OF_HCHAIN(h) ((struct buf *)&thisfile->hashtbl[h]) +#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1)) + +#define FOR_BUFS_IN_CHAIN(h,bp) \ + for (bp = thisfile->hashtbl[h].buf_hnext; \ + bp != END_OF_HCHAIN(h); bp = bp->hnext) + +#define HASH_RM(bp) \ + (bp)->hnext->hprev = (bp)->hprev; \ + (bp)->hprev->hnext = (bp)->hnext; + +#define HASH_INS(bp,h) \ + (bp)->hnext = thisfile->hashtbl[h].buf_hnext; \ + (bp)->hprev = END_OF_HCHAIN(h); \ + thisfile->hashtbl[h].buf_hnext->hprev = (bp); \ + thisfile->hashtbl[h].buf_hnext = (bp); + static struct filestate *thisfile; static int ch_ungotchar = -1; +static int maxbufs = -1; extern int autobuf; extern int sigs; -extern int cbufs; +extern int secure; +extern constant char helpdata[]; +extern constant int size_helpdata; extern IFILE curr_ifile; #if LOGFILE extern int logfile; @@ -108,9 +121,10 @@ static int ch_addbuf(); int fch_get() { - struct buf *bp; - int n; - int slept; + register struct buf *bp; + register int n; + register int slept; + register int h; POSITION pos; POSITION len; @@ -119,7 +133,9 @@ fch_get() /* * Look for a buffer holding the desired block. */ - for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next) + h = BUFHASH(ch_block); + FOR_BUFS_IN_CHAIN(h, bp) + { if (bp->block == ch_block) { if (ch_offset >= bp->datasize) @@ -129,6 +145,7 @@ fch_get() goto read_more; goto found; } + } /* * Block is not in a buffer. * Take the least recently used buffer @@ -136,7 +153,7 @@ fch_get() * If the LRU buffer has data in it, * then maybe allocate a new buffer. */ - if (ch_buftail == END_OF_CHAIN || ch_buftail->block != (long)(-1)) + if (ch_buftail == END_OF_CHAIN || ch_buftail->block != -1) { /* * There is no empty buffer to use. @@ -145,7 +162,7 @@ fch_get() * 2. We haven't allocated the max buffers for this file yet. */ if ((autobuf && !(ch_flags & CH_CANSEEK)) || - (cbufs == -1 || ch_nbufs < cbufs)) + (maxbufs < 0 || ch_nbufs < maxbufs)) if (ch_addbuf()) /* * Allocation failed: turn off autobuf. @@ -153,8 +170,10 @@ fch_get() autobuf = OPT_OFF; } bp = ch_buftail; + HASH_RM(bp); /* Remove from old hash chain. */ bp->block = ch_block; bp->datasize = 0; + HASH_INS(bp, h); /* Insert into new hash chain. */ read_more: pos = (ch_block * LBUFSIZE) + bp->datasize; @@ -187,23 +206,32 @@ fch_get() * 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) - { - n = iread(ch_file, &bp->data[bp->datasize], - (unsigned int)(LBUFSIZE - bp->datasize)); - } else + if (ch_ungotchar != -1) { bp->data[bp->datasize] = ch_ungotchar; n = 1; ch_ungotchar = -1; + } else if (ch_flags & CH_HELPFILE) + { + bp->data[bp->datasize] = helpdata[ch_fpos]; + n = 1; + } else + { + n = iread(ch_file, &bp->data[bp->datasize], + (unsigned int)(LBUFSIZE - bp->datasize)); } if (n == READ_INTR) return (EOI); if (n < 0) { - error("read error", NULL_PARG); - clear_eol(); +#if MSDOS_COMPILER==WIN32C + if (errno != EPIPE) +#endif + { + error("read error", NULL_PARG); + clear_eol(); + } n = 0; } @@ -211,7 +239,7 @@ fch_get() /* * If we have a log file, write the new data to it. */ - if (logfile >= 0 && n > 0) + if (!secure && logfile >= 0 && n > 0) write(logfile, (char *) &bp->data[bp->datasize], n); #endif @@ -232,13 +260,21 @@ fch_get() * Wait a while, then try again. */ if (!slept) - ierror("Waiting for data", NULL_PARG); -#if !MSOFTC + { + PARG parg; + parg.p_string = wait_message(); + ierror("%s", &parg); + } +#if !MSDOS_COMPILER sleep(1); +#else +#if MSDOS_COMPILER==WIN32C + Sleep(1000); +#endif #endif slept = TRUE; } - if (ABORT_SIGS()) + if (sigs) return (EOI); } @@ -251,11 +287,16 @@ fch_get() */ bp->next->prev = bp->prev; bp->prev->next = bp->next; - bp->next = ch_bufhead; bp->prev = END_OF_CHAIN; ch_bufhead->prev = bp; ch_bufhead = bp; + + /* + * Move to head of hash chain too. + */ + HASH_RM(bp); + HASH_INS(bp, h); } if (ch_offset >= bp->datasize) @@ -314,10 +355,10 @@ end_logfile() public void sync_logfile() { - struct buf *bp; + register struct buf *bp; int warned = FALSE; - long block; - long nblocks; + BLOCKNUM block; + BLOCKNUM nblocks; nblocks = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE; for (block = 0; block < nblocks; block++) @@ -350,13 +391,17 @@ sync_logfile() */ static int buffered(block) - long block; + BLOCKNUM block; { - struct buf *bp; + register struct buf *bp; + register int h; - for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next) + h = BUFHASH(block); + FOR_BUFS_IN_CHAIN(h, bp) + { if (bp->block == block) return (TRUE); + } return (FALSE); } @@ -366,9 +411,9 @@ buffered(block) */ public int ch_seek(pos) - POSITION pos; + register POSITION pos; { - long new_block; + BLOCKNUM new_block; POSITION len; len = ch_length(); @@ -429,7 +474,7 @@ ch_end_seek() public int ch_beg_seek() { - struct buf *bp, *firstbp; + register struct buf *bp, *firstbp; /* * Try a plain ch_seek first. @@ -460,18 +505,18 @@ ch_length() { if (ignore_eoi) return (NULL_POSITION); + if (ch_flags & CH_HELPFILE) + return (size_helpdata); return (ch_fsize); } /* * Return the current position in the file. */ -#define tellpos(blk,off) ((POSITION)((((long)(blk)) * LBUFSIZE) + (off))) - public POSITION ch_tell() { - return (tellpos(ch_block, ch_offset)); + return (ch_block * LBUFSIZE) + ch_offset; } /* @@ -480,7 +525,7 @@ ch_tell() public int ch_forw_get() { - int c; + register int c; c = ch_get(); if (c == EOI) @@ -516,32 +561,21 @@ ch_back_get() } /* - * Allocate buffers. - * Caller wants us to have a total of at least want_nbufs buffers. + * Set max amount of buffer space. + * bufspace is in units of 1024 bytes. -1 mean no limit. */ - public int -ch_nbuf(want_nbufs) - int want_nbufs; + public void +ch_setbufspace(bufspace) + int bufspace; { - PARG parg; - - while (ch_nbufs < want_nbufs) + if (bufspace < 0) + maxbufs = -1; + else { - if (ch_addbuf()) - { - /* - * Cannot allocate enough buffers. - * If we don't have ANY, then quit. - * Otherwise, just report the error and return. - */ - parg.p_int = want_nbufs - ch_nbufs; - error("Cannot allocate %d buffers", &parg); - if (ch_nbufs == 0) - quit(QUIT_ERROR); - break; - } + maxbufs = ((bufspace * 1024) + LBUFSIZE-1) / LBUFSIZE; + if (maxbufs < 1) + maxbufs = 1; } - return (ch_nbufs); } /* @@ -550,7 +584,7 @@ ch_nbuf(want_nbufs) public void ch_flush() { - struct buf *bp; + register struct buf *bp; if (!(ch_flags & CH_CANSEEK)) { @@ -566,7 +600,7 @@ ch_flush() * Initialize all the buffers. */ for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next) - bp->block = (long)(-1); + bp->block = -1; /* * Figure out the size of the file, if we can. @@ -580,6 +614,20 @@ ch_flush() ch_block = 0; /* ch_fpos / LBUFSIZE; */ ch_offset = 0; /* ch_fpos % LBUFSIZE; */ +#if 1 + /* + * This is a kludge to workaround a Linux kernel bug: files in + * /proc have a size of 0 according to fstat() but have readable + * data. They are sometimes, but not always, seekable. + * Force them to be non-seekable here. + */ + if (ch_fsize == 0) + { + ch_fsize = NULL_POSITION; + ch_flags &= ~CH_CANSEEK; + } +#endif + if (lseek(ch_file, (off_t)0, 0) == BAD_LSEEK) { /* @@ -598,7 +646,7 @@ ch_flush() static int ch_addbuf() { - struct buf *bp; + register struct buf *bp; /* * Allocate and initialize a new buffer and link it @@ -608,21 +656,37 @@ ch_addbuf() if (bp == NULL) return (1); ch_nbufs++; - bp->block = (long)(-1); + bp->block = -1; bp->next = END_OF_CHAIN; bp->prev = ch_buftail; ch_buftail->next = bp; ch_buftail = bp; + HASH_INS(bp, 0); return (0); } /* + * + */ + static void +init_hashtbl() +{ + register int h; + + for (h = 0; h < BUFHASH_SIZE; h++) + { + thisfile->hashtbl[h].buf_hnext = END_OF_HCHAIN(h); + thisfile->hashtbl[h].buf_hprev = END_OF_HCHAIN(h); + } +} + +/* * Delete all buffers for this file. */ static void ch_delbufs() { - struct buf *bp; + register struct buf *bp; while (ch_bufhead != END_OF_CHAIN) { @@ -632,6 +696,7 @@ ch_delbufs() free(bp); } ch_nbufs = 0; + init_hashtbl(); } /* @@ -641,6 +706,17 @@ ch_delbufs() seekable(f) int f; { +#if MSDOS_COMPILER + extern int fd0; + if (f == fd0 && !isatty(fd0)) + { + /* + * In MS-DOS, pipes are seekable. Check for + * standard input, and pretend it is not seekable. + */ + return (0); + } +#endif return (lseek(f, (off_t)1, 0) != BAD_LSEEK); } @@ -664,7 +740,6 @@ ch_init(f, flags) thisfile = (struct filestate *) calloc(1, sizeof(struct filestate)); thisfile->buf_next = thisfile->buf_prev = END_OF_CHAIN; - thisfile->buf_block = (long)(-1); thisfile->nbufs = 0; thisfile->flags = 0; thisfile->fpos = 0; @@ -673,11 +748,12 @@ ch_init(f, flags) thisfile->file = -1; thisfile->fsize = NULL_POSITION; ch_flags = flags; + init_hashtbl(); /* * Try to seek; set CH_CANSEEK if it works. */ - if (seekable(f)) - ch_flags |= CH_CANSEEK; + if ((flags & CH_CANSEEK) && !seekable(f)) + ch_flags &= ~CH_CANSEEK; set_filestate(curr_ifile, (void *) thisfile); } if (thisfile->file == -1) @@ -693,7 +769,7 @@ ch_close() { int keepstate = FALSE; - if (ch_flags & (CH_CANSEEK|CH_POPENED)) + if (ch_flags & (CH_CANSEEK|CH_POPENED|CH_HELPFILE)) { /* * We can seek or re-open, so we don't need to keep buffers. @@ -709,7 +785,7 @@ ch_close() * But don't really close it if it was opened via popen(), * because pclose() wants to close it. */ - if (!(ch_flags & CH_POPENED)) + if (!(ch_flags & (CH_POPENED|CH_HELPFILE))) close(ch_file); ch_file = -1; } else diff --git a/usr.bin/less/charset.c b/usr.bin/less/charset.c index 979435e283b..8f4a9c31ad2 100644 --- a/usr.bin/less/charset.c +++ b/usr.bin/less/charset.c @@ -1,29 +1,11 @@ -/* $OpenBSD: charset.c,v 1.4 2003/03/13 09:09:32 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -38,20 +20,35 @@ #include <ctype.h> #endif +public int utf_mode = 0; + /* * Predefined character sets, * selected by the LESSCHARSET environment variable. */ struct charset { char *name; + int *p_flag; char *desc; } charsets[] = { - { "ascii", "8bcccbcc18b95.b" }, - { "latin1", "8bcccbcc18b95.33b." }, - { "dos", "8bcccbcc12bc5b95.b." }, - { "koi8-r", "8bcccbcc18b95.b128." }, - { "next", "8bcccbcc18b95.bb125.bb" }, - { NULL } + { "ascii", NULL, "8bcccbcc18b95.b" }, + { "dos", NULL, "8bcccbcc12bc5b223.b" }, + { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." }, + { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" }, + { "iso8859", NULL, "8bcccbcc18b95.33b." }, + { "koi8-r", NULL, "8bcccbcc18b95.b128." }, + { "next", NULL, "8bcccbcc18b95.bb125.bb" }, + { "utf-8", &utf_mode, "8bcccbcc18b." }, + { NULL, NULL, NULL } +}; + +struct cs_alias { + char *name; + char *oname; +} cs_aliases[] = { + { "latin1", "iso8859" }, + { "latin9", "iso8859" }, + { NULL, NULL } }; #define IS_BINARY_CHAR 01 @@ -80,9 +77,9 @@ public int binattr = AT_STANDOUT; ichardef(s) char *s; { - char *cp; - int n; - char v; + register char *cp; + register int n; + register char v; n = 0; v = 0; @@ -135,18 +132,31 @@ ichardef(s) */ static int icharset(name) - char *name; + register char *name; { - struct charset *p; + register struct charset *p; + register 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) + { + name = a->oname; + break; + } + } + for (p = charsets; p->name != NULL; p++) { if (strcmp(name, p->name) == 0) { ichardef(p->desc); + if (p->p_flag != NULL) + *(p->p_flag) = 1; return (1); } } @@ -154,6 +164,7 @@ icharset(name) error("invalid charset name", NULL_PARG); quit(QUIT_ERROR); /*NOTREACHED*/ + return (0); } #if HAVE_LOCALE @@ -163,10 +174,10 @@ icharset(name) static void ilocale() { - int c; + register int c; - setlocale(LC_CTYPE, ""); - for (c = 0; c < sizeof(chardef); c++) + setlocale(LC_ALL, ""); + for (c = 0; c < (int) sizeof(chardef); c++) { if (isprint(c)) chardef[c] = 0; @@ -211,36 +222,58 @@ setbinfmt(s) public void init_charset() { - char *s; + register char *s; - s = getenv("LESSBINFMT"); + s = lgetenv("LESSBINFMT"); setbinfmt(s); /* * See if environment variable LESSCHARSET is defined. */ - s = getenv("LESSCHARSET"); + s = lgetenv("LESSCHARSET"); if (icharset(s)) return; /* * LESSCHARSET is not defined: try LESSCHARDEF. */ - s = getenv("LESSCHARDEF"); + s = lgetenv("LESSCHARDEF"); if (s != NULL && *s != '\0') { ichardef(s); return; } + +#if HAVE_STRSTR + /* + * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used. + */ + if ((s = lgetenv("LC_ALL")) != NULL || + (s = lgetenv("LC_CTYPE")) != NULL || + (s = lgetenv("LANG")) != NULL) + { + if (strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL) + if (icharset("utf-8")) + return; + } +#endif + #if HAVE_LOCALE /* * Use setlocale. */ ilocale(); #else +#if MSDOS_COMPILER /* - * Default to "ascii". + * Default to "dos". */ - (void) icharset("ascii"); + (void) icharset("dos"); +#else + /* + * Default to "latin1". + */ + (void) icharset("latin1"); +#endif #endif } @@ -249,7 +282,7 @@ init_charset() */ public int binary_char(c) - int c; + unsigned char c; { c &= 0377; return (chardef[c] & IS_BINARY_CHAR); @@ -278,12 +311,26 @@ prchar(c) c &= 0377; if (!control_char(c)) - snprintf(buf, sizeof buf, "%c", c); + snprintf(buf, sizeof(buf), "%c", c); else if (c == ESC) - snprintf(buf, sizeof buf, "ESC"); - else if (c < 128 && !control_char(c ^ 0100)) - snprintf(buf, sizeof buf, "^%c", c ^ 0100); + snprintf(buf, sizeof(buf), "ESC"); +#if IS_EBCDIC_HOST + else if (!binary_char(c) && c < 64) + snprintf(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)) + snprintf(buf, sizeof(buf), "^%c", c ^ 0100); +#endif else - snprintf(buf, sizeof buf, binfmt, c); + snprintf(buf, sizeof(buf), binfmt, c); return (buf); } diff --git a/usr.bin/less/cmd.h b/usr.bin/less/cmd.h index f9c58d693b6..8f300dbe029 100644 --- a/usr.bin/less/cmd.h +++ b/usr.bin/less/cmd.h @@ -1,29 +1,11 @@ -/* $OpenBSD: cmd.h,v 1.2 2001/01/29 01:58:00 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -68,9 +50,9 @@ #define A_PIPE 37 #define A_INDEX_FILE 38 #define A_UNDO_SEARCH 39 - - - +#define A_FF_SCREEN 40 +#define A_LSHIFT 41 +#define A_RSHIFT 42 #define A_AGAIN_SEARCH 43 #define A_T_AGAIN_SEARCH 44 #define A_REVERSE_SEARCH 45 @@ -80,11 +62,17 @@ #define A_OPT_UNSET 49 #define A_F_FOREVER 50 #define A_GOPOS 51 +#define A_REMOVE_FILE 52 +#define A_NEXT_TAG 53 +#define A_PREV_TAG 54 #define A_INVALID 100 #define A_NOACTION 101 #define A_UINVALID 102 #define A_END_LIST 103 +#define A_SPECIAL_KEY 104 + +#define A_SKIP 127 #define A_EXTRA 0200 @@ -110,10 +98,34 @@ #define EC_B_COMPLETE 18 #define EC_LITERAL 19 +#define EC_NOACTION 101 #define EC_UINVALID 102 /* Flags for editchar() */ #define EC_PEEK 01 #define EC_NOHISTORY 02 #define EC_NOCOMPLETE 04 +#define EC_NORIGHTLEFT 010 + +/* Environment variable stuff */ +#define EV_OK 01 +/* Special keys (keys which output different strings on different terminals) */ +#define SK_SPECIAL_KEY CONTROL('K') +#define SK_RIGHT_ARROW 1 +#define SK_LEFT_ARROW 2 +#define SK_UP_ARROW 3 +#define SK_DOWN_ARROW 4 +#define SK_PAGE_UP 5 +#define SK_PAGE_DOWN 6 +#define SK_HOME 7 +#define SK_END 8 +#define SK_DELETE 9 +#define SK_INSERT 10 +#define SK_CTL_LEFT_ARROW 11 +#define SK_CTL_RIGHT_ARROW 12 +#define SK_CTL_DELETE 13 +#define SK_F1 14 +#define SK_BACKTAB 15 +#define SK_CTL_BACKSPACE 16 +#define SK_CONTROL_K 40 diff --git a/usr.bin/less/cmdbuf.c b/usr.bin/less/cmdbuf.c index 7eac8c71525..dbf5f2afccc 100644 --- a/usr.bin/less/cmdbuf.c +++ b/usr.bin/less/cmdbuf.c @@ -1,29 +1,11 @@ -/* $OpenBSD: cmdbuf.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -37,10 +19,12 @@ extern int sc_width; -static char cmdbuf[120]; /* Buffer for holding a multi-char command */ -static int cmd_col; /* Current column of the multi-char command */ +static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */ +static int cmd_col; /* Current column of the cursor */ +static int prompt_col; /* Column of cursor just after prompt */ static char *cp; /* Pointer into cmdbuf */ -static int literal; +static int cmd_offset; /* Index into cmdbuf of first displayed char */ +static int literal; /* Next input char should not be interpreted */ #if TAB_COMPLETE_FILENAME static int cmd_complete(); @@ -55,6 +39,14 @@ static char *tk_trial; static struct textlist tk_tlist; #endif +static int cmd_left(); +static int cmd_right(); + +#if SPACES_IN_FILENAMES +public char openquote = '"'; +public char closequote = '"'; +#endif + #if CMD_HISTORY /* * A mlist structure represents a command history. @@ -72,22 +64,35 @@ struct mlist */ struct mlist mlist_search = { &mlist_search, &mlist_search, &mlist_search, NULL }; -public void *ml_search = (void *) &mlist_search; +public void * constant ml_search = (void *) &mlist_search; + struct mlist mlist_examine = { &mlist_examine, &mlist_examine, &mlist_examine, NULL }; -public void *ml_examine = (void *) &mlist_examine; +public void * constant ml_examine = (void *) &mlist_examine; + #if SHELL_ESCAPE || PIPEC struct mlist mlist_shell = { &mlist_shell, &mlist_shell, &mlist_shell, NULL }; -public void *ml_shell = (void *) &mlist_shell; -#endif /* SHELL_ESCAPE || PIPEC */ +public void * constant ml_shell = (void *) &mlist_shell; +#endif + +#else /* CMD_HISTORY */ + +/* If CMD_HISTORY is off, these are just flags. */ +public void * constant ml_search = (void *)1; +public void * constant ml_examine = (void *)2; +#if SHELL_ESCAPE || PIPEC +public void * constant ml_shell = (void *)3; +#endif + +#endif /* CMD_HISTORY */ /* * History for the current command. */ static struct mlist *curr_mlist = NULL; +static int curr_cmdflags; -#endif /* CMD_HISTORY */ /* * Reset command buffer (to empty). @@ -98,10 +103,33 @@ cmd_reset() cp = cmdbuf; *cp = '\0'; cmd_col = 0; + cmd_offset = 0; literal = 0; } /* + * Clear command line on display. + */ + public void +clear_cmd() +{ + clear_bot(); + cmd_col = prompt_col = 0; +} + +/* + * Display a string, usually as a prompt for input into the command buffer. + */ + public void +cmd_putstr(s) + char *s; +{ + putstr(s); + cmd_col += strlen(s); + prompt_col += strlen(s); +} + +/* * How many characters are in the command buffer? */ public int @@ -111,15 +139,195 @@ len_cmdbuf() } /* + * Repaint the line from cp onwards. + * Then position the cursor just after the char old_cp (a pointer into cmdbuf). + */ + static void +cmd_repaint(old_cp) + char *old_cp; +{ + char *p; + + /* + * Repaint the line from the current position. + */ + clear_eol(); + for ( ; *cp != '\0'; cp++) + { + p = prchar(*cp); + if (cmd_col + (int)strlen(p) >= sc_width) + break; + putstr(p); + cmd_col += strlen(p); + } + + /* + * Back up the cursor to the correct position. + */ + while (cp > old_cp) + cmd_left(); +} + +/* + * Put the cursor at "home" (just after the prompt), + * and set cp to the corresponding char in cmdbuf. + */ + static void +cmd_home() +{ + while (cmd_col > prompt_col) + { + putbs(); + cmd_col--; + } + + cp = &cmdbuf[cmd_offset]; +} + +/* + * Shift the cmdbuf display left a half-screen. + */ + static void +cmd_lshift() +{ + char *s; + char *save_cp; + int cols; + + /* + * Start at the first displayed char, count how far to the + * right we'd have to move to reach the center of the screen. + */ + s = cmdbuf + cmd_offset; + cols = 0; + while (cols < (sc_width - prompt_col) / 2 && *s != '\0') + cols += strlen(prchar(*s++)); + + cmd_offset = s - cmdbuf; + save_cp = cp; + cmd_home(); + cmd_repaint(save_cp); +} + +/* + * Shift the cmdbuf display right a half-screen. + */ + static void +cmd_rshift() +{ + char *s; + char *p; + char *save_cp; + int cols; + + /* + * Start at the first displayed char, count how far to the + * left we'd have to move to traverse a half-screen width + * of displayed characters. + */ + s = cmdbuf + cmd_offset; + cols = 0; + while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf) + { + p = prchar(*--s); + cols += strlen(p); + } + + cmd_offset = s - cmdbuf; + save_cp = cp; + cmd_home(); + cmd_repaint(save_cp); +} + +/* + * Move cursor right one character. + */ + static int +cmd_right() +{ + char *p; + + if (*cp == '\0') + { + /* + * Already at the end of the line. + */ + return (CC_OK); + } + p = prchar(*cp); + if (cmd_col + (int)strlen(p) >= sc_width) + cmd_lshift(); + else if (cmd_col + (int)strlen(p) == sc_width - 1 && cp[1] != '\0') + cmd_lshift(); + cp++; + putstr(p); + cmd_col += strlen(p); + return (CC_OK); +} + +/* + * Move cursor left one character. + */ + static int +cmd_left() +{ + char *p; + + if (cp <= cmdbuf) + { + /* Already at the beginning of the line */ + return (CC_OK); + } + p = prchar(cp[-1]); + if (cmd_col < prompt_col + (int)strlen(p)) + cmd_rshift(); + cp--; + cmd_col -= strlen(p); + while (*p++ != '\0') + putbs(); + return (CC_OK); +} + +/* + * Insert a char into the command buffer, at the current position. + */ + static int +cmd_ichar(c) + int c; +{ + char *s; + + if (strlen(cmdbuf) >= sizeof(cmdbuf)-2) + { + /* + * No room in the command buffer for another char. + */ + bell(); + return (CC_ERROR); + } + + /* + * Insert the character into the buffer. + */ + for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--) + s[1] = s[0]; + *cp = c; + /* + * Reprint the tail of the line from the inserted char. + */ + cmd_repaint(cp); + cmd_right(); + return (CC_OK); +} + +/* * Backspace in the command buffer. * Delete the char to the left of the cursor. */ static int cmd_erase() { - char *s; - char *p; - int col; + register char *s; if (cp == cmdbuf) { @@ -130,57 +338,24 @@ cmd_erase() return (CC_QUIT); } /* - * Back up the pointer. + * Move cursor left (to the char being erased). */ - --cp; - /* - * Remember the current cursor column and - * set it back the width of the char being erased. - */ - col = cmd_col; - p = prchar(*cp); - cmd_col -= strlen(p); + cmd_left(); /* - * Shift left the buffer after the erased char. + * Remove the char from the buffer (shift the buffer left). */ for (s = cp; *s != '\0'; s++) s[0] = s[1]; /* - * Back up the cursor to the position of the erased char, - * clear the tail of the line, - * and reprint the line after the erased char. - */ - while (col > cmd_col) - { - putbs(); - col--; - } - clear_eol(); - for (s = cp; *s != '\0'; s++) - { - p = prchar(*s); - putstr(p); - col += strlen(p); - } - /* - * Back up the cursor again. + * Repaint the buffer after the erased char. */ - while (col > cmd_col) - { - putbs(); - col--; - } + cmd_repaint(cp); /* - * This is rather weird. * We say that erasing the entire command string causes us - * to abort the current command, BUT ONLY IF there is no history - * for this type of command. This causes commands like search (/) - * and edit (:e) to stay active even if we erase the entire string, - * but commands like <digit> and - go away when we erase the string. - * (See same thing in cmd_kill.) + * to abort the current command, if CF_QUIT_ON_ERASE is set. */ - if (curr_mlist == NULL && cp == cmdbuf && *cp == '\0') + if ((curr_cmdflags & CF_QUIT_ON_ERASE) && cp == cmdbuf && *cp == '\0') return (CC_QUIT); return (CC_OK); } @@ -191,8 +366,6 @@ cmd_erase() static int cmd_delete() { - char *p; - if (*cp == '\0') { /* @@ -203,10 +376,7 @@ cmd_delete() /* * Move right, then use cmd_erase. */ - p = prchar(*cp); - cp++; - putstr(p); - cmd_col += strlen(p); + cmd_right(); cmd_erase(); return (CC_OK); } @@ -264,28 +434,6 @@ cmd_wdelete() } /* - * Move cursor to start of command buffer. - */ - static int -cmd_home() -{ - char *p; - - /* - * Back up until we hit start of buffer. - */ - while (cp > cmdbuf) - { - cp--; - p = prchar(*cp); - cmd_col -= strlen(p); - while (*p++ != '\0') - putbs(); - } - return (CC_OK); -} - -/* * Delete all chars in the command buffer. */ static int @@ -298,72 +446,33 @@ cmd_kill() */ return (CC_QUIT); } - (void) cmd_home(); + cmd_offset = 0; + cmd_home(); *cp = '\0'; - clear_eol(); + cmd_repaint(cp); + /* - * Same weirdness as in cmd_erase. - * If the current command has no history, abort the current command. + * We say that erasing the entire command string causes us + * to abort the current command, if CF_QUIT_ON_ERASE is set. */ - if (curr_mlist == NULL) + if (curr_cmdflags & CF_QUIT_ON_ERASE) return (CC_QUIT); return (CC_OK); } /* - * Move cursor right one character. - */ - static int -cmd_right() -{ - char *p; - - if (*cp == '\0') - { - /* - * Already at the end of the line. - */ - return (CC_OK); - } - p = prchar(*cp); - cp++; - putstr(p); - cmd_col += strlen(p); - return (CC_OK); -} - -/* - * Move cursor left one character. - */ - static int -cmd_left() -{ - char *p; - - if (cp <= cmdbuf) - { - /* Already at the beginning of the line */ - return (CC_OK); - } - cp--; - p = prchar(*cp); - cmd_col -= strlen(p); - while (*p++ != '\0') - putbs(); - return (CC_OK); -} - -#if CMD_HISTORY -/* * Select an mlist structure to be the current command history. */ public void -set_mlist(mlist) +set_mlist(mlist, cmdflags) void *mlist; + int cmdflags; { curr_mlist = (struct mlist *) mlist; + curr_cmdflags = cmdflags; } +#if CMD_HISTORY /* * Move up or down in the currently selected command history list. */ @@ -371,7 +480,6 @@ set_mlist(mlist) cmd_updown(action) int action; { - char *p; char *s; if (curr_mlist == NULL) @@ -397,65 +505,79 @@ cmd_updown(action) s = curr_mlist->curr_mp->string; if (s == NULL) s = ""; - for (cp = cmdbuf; *s != '\0'; s++, cp++) + for (cp = cmdbuf; *s != '\0'; s++) { *cp = *s; - p = prchar(*cp); - cmd_col += strlen(p); - putstr(p); + cmd_right(); } *cp = '\0'; return (CC_OK); } +#endif /* - * Accept the command in the command buffer. - * Add it to the currently selected history list. + * Add a string to a history list. */ public void -cmd_accept() +cmd_addhist(mlist, cmd) + struct mlist *mlist; + char *cmd; { +#if CMD_HISTORY struct mlist *ml; /* - * Nothing to do if there is no currently selected history list. - */ - if (curr_mlist == NULL) - return; - /* * Don't save a trivial command. */ - if (strlen(cmdbuf) == 0) + if (strlen(cmd) == 0) return; /* - * Don't save if a duplicate of a command which is already in the history. + * Don't save if a duplicate of a command which is already + * in the history. * But select the one already in the history to be current. */ - for (ml = curr_mlist->next; ml != curr_mlist; ml = ml->next) + for (ml = mlist->next; ml != mlist; ml = ml->next) { - if (strcmp(ml->string, cmdbuf) == 0) + if (strcmp(ml->string, cmd) == 0) break; } - if (ml == curr_mlist) + if (ml == mlist) { /* * Did not find command in history. * Save the command and put it at the end of the history list. */ ml = (struct mlist *) ecalloc(1, sizeof(struct mlist)); - ml->string = save(cmdbuf); - ml->next = curr_mlist; - ml->prev = curr_mlist->prev; - curr_mlist->prev->next = ml; - curr_mlist->prev = ml; + ml->string = save(cmd); + ml->next = mlist; + ml->prev = mlist->prev; + mlist->prev->next = ml; + mlist->prev = ml; } /* * Point to the cmd just after the just-accepted command. * Thus, an UPARROW will always retrieve the previous command. */ - curr_mlist->curr_mp = ml->next; + mlist->curr_mp = ml->next; +#endif } + +/* + * Accept the command in the command buffer. + * Add it to the currently selected history list. + */ + public void +cmd_accept() +{ +#if CMD_HISTORY + /* + * Nothing to do if there is no currently selected history list. + */ + if (curr_mlist == NULL) + return; + cmd_addhist(curr_mlist, cmdbuf); #endif +} /* * Try to perform a line-edit function on the command buffer, @@ -482,16 +604,20 @@ cmd_edit(c) * 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; - if (curr_mlist == &mlist_search) +#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); @@ -519,7 +645,10 @@ cmd_edit(c) return (CC_OK); case EC_HOME: not_in_completion(); - return (cmd_home()); + cmd_offset = 0; + cmd_home(); + cmd_repaint(cp); + return (CC_OK); case EC_END: not_in_completion(); while (*cp != '\0') @@ -558,90 +687,14 @@ cmd_edit(c) case EC_EXPAND: return (cmd_complete(action)); #endif + case EC_NOACTION: + return (CC_OK); default: not_in_completion(); return (CC_PASS); } } -/* - * Insert a char into the command buffer, at the current position. - */ - static int -cmd_ichar(c) - int c; -{ - int col; - char *p; - char *s; - - if (strlen(cmdbuf) >= sizeof(cmdbuf)-2) - { - /* - * No room in the command buffer for another char. - */ - bell(); - return (CC_ERROR); - } - - /* - * Remember the current cursor column and - * move it forward the width of the char being inserted. - */ - col = cmd_col; - p = prchar(c); - cmd_col += strlen(p); - if (cmd_col >= sc_width-1) - { - cmd_col -= strlen(p); - bell(); - return (CC_ERROR); - } - /* - * Insert the character in the string. - * First, make room for the new char. - */ - for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--) - s[1] = s[0]; - *cp++ = c; - /* - * Reprint the tail of the line after the inserted char. - */ - clear_eol(); - for (s = cp-1; *s != '\0'; s++) - { - p = prchar(*s); - col += strlen(p); - if (col >= sc_width-1) - { - /* - * Oops. There is no room on the screen - * for the new char. Back up the cursor to - * just after the inserted char and erase it. - */ - col -= strlen(p); - while (col > cmd_col) - { - putbs(); - col--; - } - (void) cmd_erase(); - bell(); - return (CC_ERROR); - } - putstr(p); - } - /* - * Back up the cursor to just after the inserted char. - */ - while (col > cmd_col) - { - putbs(); - col--; - } - return (CC_OK); -} - #if TAB_COMPLETE_FILENAME /* * Insert a string into the command buffer, at the current position. @@ -675,6 +728,13 @@ cmd_istr(str) delimit_word() { 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. @@ -694,6 +754,7 @@ delimit_word() * We're already at the end of the word. */ ; +#if 0 } else { /* @@ -701,15 +762,47 @@ delimit_word() * Huh? There's no word here. */ return (NULL); +#endif } /* - * Search backwards for beginning of the word. + * Find the beginning of the word which the cursor is in. */ if (cp == cmdbuf) return (NULL); - for (word = cp-1; word > cmdbuf; word--) - if (word[-1] == ' ') +#if SPACES_IN_FILENAMES + /* + * If we have an unbalanced quote (that is, an open quote + * without a corresponding close quote), we return everything + * from the open quote, including spaces. + */ + for (word = cmdbuf; word < cp; word++) + if (*word != ' ') break; + if (word >= cp) + return (cp); + for (p = cmdbuf; p < cp; p++) + { + if (meta_quoted) + { + meta_quoted = 0; + } else if (esclen > 0 && p + esclen < cp && + strncmp(p, esc, esclen) == 0) + { + meta_quoted = 1; + p += esclen - 1; + } else if (delim_quoted) + { + if (*p == closequote) + delim_quoted = 0; + } else /* (!delim_quoted) */ + { + if (*p == openquote) + delim_quoted = 1; + else if (*p == ' ') + word = p+1; + } + } +#endif return (word); } @@ -757,7 +850,20 @@ init_compl() */ c = *cp; *cp = '\0'; - tk_text = fcomplete(word); + if (*word != openquote) + { + tk_text = fcomplete(word); + } else + { + char *qword = shell_quote(word+1); + if (qword == NULL) + tk_text = fcomplete(word+1); + else + { + tk_text = fcomplete(qword); + free(qword); + } + } *cp = c; } @@ -766,7 +872,7 @@ init_compl() */ static char * next_compl(action, prev) - int action; + int action; char *prev; { switch (action) @@ -775,10 +881,9 @@ next_compl(action, prev) return (forw_textlist(&tk_tlist, prev)); case EC_B_COMPLETE: return (back_textlist(&tk_tlist, prev)); - default: - /* Cannot happen */ - return ("?"); } + /* Cannot happen */ + return ("?"); } /* @@ -791,6 +896,7 @@ next_compl(action, prev) cmd_complete(action) int action; { + char *s; if (!in_completion || action == EC_EXPAND) { @@ -851,6 +957,19 @@ cmd_complete(action) */ if (cmd_istr(tk_trial) != CC_OK) goto fail; + /* + * If it is a directory, append a slash. + */ + if (is_dir(tk_trial)) + { + if (cp > cmdbuf && cp[-1] == closequote) + (void) cmd_erase(); + s = lgetenv("LESSSEPARATOR"); + if (s == NULL) + s = PATHNAME_SEP; + if (cmd_istr(s) != CC_OK) + goto fail; + } } return (CC_OK); @@ -905,30 +1024,21 @@ cmd_char(c) /* * Insert the char into the command buffer. */ - action = cmd_ichar(c); - if (action != CC_OK) - return (action); - return (CC_OK); + return (cmd_ichar(c)); } /* * Return the number currently in the command buffer. */ - public int + public LINENUM cmd_int() { - return (atoi(cmdbuf)); -} + register char *p; + LINENUM n = 0; -/* - * Display a string, usually as a prompt for input into the command buffer. - */ - public void -cmd_putstr(s) - char *s; -{ - putstr(s); - cmd_col += strlen(s); + for (p = cmdbuf; *p != '\0'; p++) + n = (10 * n) + (*p - '0'); + return (n); } /* diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c index fca0f7bec13..587dbc4fa25 100644 --- a/usr.bin/less/command.c +++ b/usr.bin/less/command.c @@ -1,29 +1,11 @@ -/* $OpenBSD: command.c,v 1.5 2003/04/10 15:53:30 millert Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,6 +14,9 @@ */ #include "less.h" +#if MSDOS_COMPILER==WIN32C +#include <windows.h> +#endif #include "position.h" #include "option.h" #include "cmd.h" @@ -39,6 +24,8 @@ extern int erase_char, kill_char; extern int sigs; extern int quit_at_eof; +extern int quit_if_one_screen; +extern int squished; extern int hit_eof; extern int sc_width; extern int sc_height; @@ -46,45 +33,42 @@ extern int swindow; extern int jump_sline; extern int quitting; extern int wscroll; -extern int nohelp; extern int top_scroll; extern int ignore_eoi; +extern int secure; +extern int hshift; +extern int show_attn; extern char *every_first_cmd; extern char *curr_altfilename; extern char version[]; extern struct scrpos initial_scrpos; extern IFILE curr_ifile; -#if CMD_HISTORY -extern void *ml_search; -extern void *ml_examine; +extern void constant *ml_search; +extern void constant *ml_examine; #if SHELL_ESCAPE || PIPEC -extern void *ml_shell; -#endif -#else -/* No CMD_HISTORY */ -#define ml_search NULL -#define ml_examine NULL -#define ml_shell NULL +extern void constant *ml_shell; #endif #if EDITOR extern char *editor; extern char *editproto; #endif extern int screen_trashed; /* The screen has been overwritten */ +extern int shift_count; extern int be_helpful; -public int helpprompt; - -static char ungot[100]; +static char ungot[UNGOT_SIZE]; static char *ungotp = NULL; #if SHELL_ESCAPE static char *shellcmd = NULL; /* For holding last shell command for "!!" */ #endif static int mca; /* The multicharacter command (action) */ static int search_type; /* The previous type of search */ -static int number; /* The number typed by the user */ +static LINENUM number; /* The number typed by the user */ static char optchar; static int optflag; +static int optgetname; +static POSITION bottompos; +static char *help_prompt; #if PIPEC static char pipec; #endif @@ -99,6 +83,7 @@ static void multi_search(); static void cmd_exec() { + clear_attn(); lower_left(); flush(); } @@ -107,17 +92,16 @@ cmd_exec() * Set up the display to start a new multi-character command. */ static void -start_mca(action, prompt, mlist) +start_mca(action, prompt, mlist, cmdflags) int action; char *prompt; void *mlist; + int cmdflags; { mca = action; - clear_bot(); + clear_cmd(); cmd_putstr(prompt); -#if CMD_HISTORY - set_mlist(mlist); -#endif + set_mlist(mlist, cmdflags); } public int @@ -137,24 +121,57 @@ mca_search() else mca = A_B_SEARCH; - clear_bot(); + clear_cmd(); + if (search_type & SRCH_NO_MATCH) + cmd_putstr("Non-match "); if (search_type & SRCH_FIRST_FILE) - cmd_putstr("@"); - + cmd_putstr("First-file "); if (search_type & SRCH_PAST_EOF) - cmd_putstr("*"); - - if (search_type & SRCH_NOMATCH) - cmd_putstr("!"); + cmd_putstr("EOF-ignore "); + if (search_type & SRCH_NO_MOVE) + cmd_putstr("Keep-pos "); + if (search_type & SRCH_NO_REGEX) + cmd_putstr("Regex-off "); if (search_type & SRCH_FORW) cmd_putstr("/"); else cmd_putstr("?"); -#if CMD_HISTORY - set_mlist(ml_search); -#endif + set_mlist(ml_search, 0); +} + +/* + * Set up the display to start a new toggle-option command. + */ + static void +mca_opt_toggle() +{ + int no_prompt; + int flag; + char *dash; + + no_prompt = (optflag & OPT_NO_PROMPT); + flag = (optflag & ~OPT_NO_PROMPT); + dash = (flag == OPT_NO_TOGGLE) ? "_" : "-"; + + mca = A_OPT_TOGGLE; + clear_cmd(); + cmd_putstr(dash); + if (optgetname) + cmd_putstr(dash); + if (no_prompt) + cmd_putstr("(P)"); + switch (flag) + { + case OPT_UNSET: + cmd_putstr("+"); + break; + case OPT_SET: + cmd_putstr("!"); + break; + } + set_mlist(NULL, 0); } /* @@ -163,7 +180,7 @@ mca_search() static void exec_mca() { - char *cbuf; + register char *cbuf; cmd_exec(); cbuf = get_cmdbuf(); @@ -172,7 +189,7 @@ exec_mca() { case A_F_SEARCH: case A_B_SEARCH: - multi_search(cbuf, number); + multi_search(cbuf, (int) number); break; case A_FIRSTCMD: /* @@ -192,14 +209,20 @@ exec_mca() optchar = '\0'; break; case A_F_BRACKET: - match_brac(cbuf[0], cbuf[1], 1, number); + match_brac(cbuf[0], cbuf[1], 1, (int) number); break; case A_B_BRACKET: - match_brac(cbuf[1], cbuf[0], 0, number); + match_brac(cbuf[1], cbuf[0], 0, (int) number); break; #if EXAMINE case A_EXAMINE: + if (secure) + break; edit_list(cbuf); +#if TAGS + /* If tag structure is loaded then clean it up. */ + cleantags(); +#endif break; #endif #if SHELL_ESCAPE @@ -216,15 +239,18 @@ exec_mca() shellcmd = fexpand(cbuf); } + if (secure) + break; if (shellcmd == NULL) - lsystem(""); + lsystem("", "!done"); else - lsystem(shellcmd); - error("!done", NULL_PARG); + lsystem(shellcmd, "!done"); break; #endif #if PIPEC case A_PIPE: + if (secure) + break; (void) pipe_mark(pipec, cbuf); error("|done", NULL_PARG); break; @@ -242,6 +268,7 @@ mca_char(c) char *p; int flag; char buf[3]; + PARG parg; switch (mca) { @@ -266,7 +293,7 @@ mca_char(c) * Terminated by a non-digit. */ if ((c < '0' || c > '9') && - editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE) == A_INVALID) + editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID) { /* * Not part of the number. @@ -287,35 +314,137 @@ mca_char(c) * so user doesn't have to hit RETURN. * If the first char is + or -, this indicates * OPT_UNSET or OPT_SET respectively, instead of OPT_TOGGLE. + * "--" begins inputting a long option name. */ - if (c == erase_char || c == kill_char) - break; - if (optchar != '\0' && optchar != '+' && optchar != '-') + if (optchar == '\0' && len_cmdbuf() == 0) + { + flag = (optflag & ~OPT_NO_PROMPT); + if (flag == OPT_NO_TOGGLE) + { + switch (c) + { + case '_': + /* "__" = long option name. */ + optgetname = TRUE; + mca_opt_toggle(); + return (MCA_MORE); + } + } else + { + switch (c) + { + case '+': + /* "-+" = UNSET. */ + optflag = (flag == OPT_UNSET) ? + OPT_TOGGLE : OPT_UNSET; + mca_opt_toggle(); + return (MCA_MORE); + case '!': + /* "-!" = SET */ + optflag = (flag == OPT_SET) ? + OPT_TOGGLE : OPT_SET; + mca_opt_toggle(); + return (MCA_MORE); + case CONTROL('P'): + optflag ^= OPT_NO_PROMPT; + mca_opt_toggle(); + return (MCA_MORE); + case '-': + /* "--" = long option name. */ + optgetname = TRUE; + mca_opt_toggle(); + return (MCA_MORE); + } + } + } + if (optgetname) + { /* - * We already have the option letter. + * We're getting a long option name. + * See if we've matched an option name yet. + * If so, display the complete name and stop + * accepting chars until user hits RETURN. */ - break; - switch (c) - { - case '+': - optflag = OPT_UNSET; - break; - case '-': - optflag = OPT_SET; - break; - default: - optchar = c; - if (optflag != OPT_TOGGLE || single_char_option(c)) + struct loption *o; + char *oname; + int lc; + + if (c == '\n' || c == '\r') + { + /* + * When the user hits RETURN, make sure + * we've matched an option name, then + * pretend he just entered the equivalent + * option letter. + */ + if (optchar == '\0') + { + parg.p_string = get_cmdbuf(); + error("There is no --%s option", &parg); + return (MCA_DONE); + } + optgetname = FALSE; + cmd_reset(); + c = optchar; + } else { - toggle_option(c, "", optflag); - return (MCA_DONE); + if (optchar != '\0') + { + /* + * Already have a match for the name. + * Don't accept anything but erase/kill. + */ + if (c == erase_char || c == kill_char) + return (MCA_DONE); + return (MCA_MORE); + } + /* + * Add char to cmd buffer and try to match + * the option name. + */ + if (cmd_char(c) == CC_QUIT) + return (MCA_DONE); + p = get_cmdbuf(); + lc = islower(p[0]); + o = findopt_name(&p, &oname, NULL); + if (o != NULL) + { + /* + * Got a match. + * Remember the option letter and + * display the full option name. + */ + optchar = o->oletter; + if (!lc && islower(optchar)) + optchar = toupper(optchar); + cmd_reset(); + mca_opt_toggle(); + for (p = oname; *p != '\0'; p++) + { + c = *p; + if (!lc && islower(c)) + c = toupper(c); + if (cmd_char(c) != CC_OK) + return (MCA_DONE); + } + } + return (MCA_MORE); } - break; + } else + { + if (c == erase_char || c == kill_char) + break; + if (optchar != '\0') + /* We already have the option letter. */ + break; } - if (optchar == '+' || optchar == '-') + + optchar = c; + if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE || + single_char_option(c)) { - optchar = c; - break; + toggle_option(c, "", optflag); + return (MCA_DONE); } /* * Display a prompt appropriate for the option letter. @@ -327,7 +456,7 @@ mca_char(c) buf[2] = '\0'; p = buf; } - start_mca(A_OPT_TOGGLE, p, (void*)NULL); + start_mca(A_OPT_TOGGLE, p, (void*)NULL, 0); return (MCA_MORE); case A_F_SEARCH: @@ -336,7 +465,7 @@ mca_char(c) * Special case for search commands. * Certain characters as the first char of * the pattern have special meaning: - * ! Toggle the NOMATCH flag + * ! Toggle the NO_MATCH flag * * Toggle the PAST_EOF flag * @ Toggle the FIRST_FILE flag */ @@ -349,14 +478,23 @@ mca_char(c) flag = 0; switch (c) { - case '!': - flag = SRCH_NOMATCH; + case CONTROL('E'): /* ignore END of file */ + case '*': + flag = SRCH_PAST_EOF; break; + case CONTROL('F'): /* FIRST file */ case '@': flag = SRCH_FIRST_FILE; break; - case '*': - flag = SRCH_PAST_EOF; + case CONTROL('K'): /* KEEP position */ + flag = SRCH_NO_MOVE; + break; + case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */ + flag = SRCH_NO_REGEX; + break; + case CONTROL('N'): /* NOT match */ + case '!': + flag = SRCH_NO_MATCH; break; } if (flag != 0) @@ -380,6 +518,7 @@ mca_char(c) exec_mca(); return (MCA_DONE); } + /* * Append the char to the command buffer. */ @@ -407,22 +546,11 @@ mca_char(c) } /* - * Display the appropriate prompt. + * Make sure the screen is displayed. */ static void -prompt() +make_display() { - char *p; - - if (ungotp != NULL && ungotp > ungot) - { - /* - * No prompt necessary if commands are from - * ungotten chars rather than from the user. - */ - return; - } - /* * If nothing is displayed yet, display starting from initial_scrpos. */ @@ -446,45 +574,84 @@ prompt() repaint(); top_scroll = save_top_scroll; } +} + +/* + * Display the appropriate prompt. + */ + static void +prompt() +{ + register char *p; + + if (ungotp != NULL && ungotp > ungot) + { + /* + * No prompt necessary if commands are from + * ungotten chars rather than from the user. + */ + return; + } + + /* + * Make sure the screen is displayed. + */ + make_display(); + bottompos = position(BOTTOM_PLUS_ONE); /* * If the -E flag is set and we've hit EOF on the last file, quit. */ - if (quit_at_eof == OPT_ONPLUS && hit_eof && + if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) && + hit_eof && !(ch_getflags() & CH_HELPFILE) && next_ifile(curr_ifile) == NULL_IFILE) quit(QUIT_OK); + quit_if_one_screen = FALSE; +#if 0 /* This doesn't work well because some "te"s clear the screen. */ + /* + * If the -e flag is set and we've hit EOF on the last file, + * and the file is squished (shorter than the screen), quit. + */ + if (quit_at_eof && squished && + next_ifile(curr_ifile) == NULL_IFILE) + quit(QUIT_OK); +#endif +#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. */ - clear_bot(); - if (helpprompt) { + clear_cmd(); + p = help_prompt ? help_prompt : pr_string(); + if (p == NULL) + putchr(':'); + else + { so_enter(); - putstr("[Press 'h' for instructions.]"); + putstr(p); + if (be_helpful && !help_prompt && strlen(p) + 40 < sc_width) + putstr(" [Press space to continue, 'q' to quit.]"); so_exit(); - helpprompt = 0; - } else { - p = pr_string(); - if (p == NULL) - putchr(':'); - else - { - so_enter(); - putstr(p); - if (be_helpful && strlen(p) + 40 < sc_width) - putstr(" [Press space to continue, 'q' to quit.]"); - so_exit(); - } } + help_prompt = NULL; } +/* + * Display the less version message. + */ public void dispversion() { PARG parg; parg.p_string = version; - error("less version %s", &parg); + error("less %s", &parg); } /* @@ -566,7 +733,7 @@ ungetcc(c) ungetsc(s) char *s; { - char *p; + register char *p; for (p = s + strlen(s) - 1; p >= s; p--) ungetcc(*p); @@ -582,12 +749,12 @@ multi_search(pattern, n) char *pattern; int n; { - int nomore; + register int nomore; IFILE save_ifile; int changed_file; changed_file = 0; - save_ifile = curr_ifile; + save_ifile = save_curr_ifile(); if (search_type & SRCH_FIRST_FILE) { @@ -600,18 +767,31 @@ multi_search(pattern, n) else nomore = edit_last(); if (nomore) + { + unsave_ifile(save_ifile); return; + } changed_file = 1; search_type &= ~SRCH_FIRST_FILE; } for (;;) { - if ((n = search(search_type, pattern, n)) == 0) + n = search(search_type, pattern, n); + /* + * The SRCH_NO_MOVE flag doesn't "stick": it gets cleared + * after being used once. This allows "n" to work after + * using a /@@ search. + */ + search_type &= ~SRCH_NO_MOVE; + if (n == 0) + { /* * Found it. */ + unsave_ifile(save_ifile); return; + } if (n < 0) /* @@ -650,8 +830,7 @@ multi_search(pattern, n) /* * Restore the file we were originally viewing. */ - if (edit_ifile(save_ifile)) - quit(QUIT_ERROR); + reedit_ifile(save_ifile); } } @@ -662,16 +841,21 @@ multi_search(pattern, n) public void commands() { - int c; - int action; - char *cbuf; + register int c; + register int action; + register char *cbuf; + int newaction; int save_search_type; - char *s; + char *extra; char tbuf[2]; PARG parg; + IFILE old_ifile; + IFILE new_ifile; + char *tagfile; search_type = SRCH_FORW; wscroll = (sc_height + 1) / 2; + newaction = A_NOACTION; for (;;) { @@ -689,7 +873,13 @@ commands() 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. */ @@ -697,77 +887,85 @@ commands() prompt(); if (sigs) continue; - c = getcc(); + if (newaction == A_NOACTION) + c = getcc(); again: if (sigs) continue; - /* - * 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)) + if (newaction != A_NOACTION) + { + action = newaction; + newaction = A_NOACTION; + } else + { + /* + * If we are in a multicharacter command, call mca_char. + * Otherwise we call fcmd_decode to determine the + * action to be performed. + */ + if (mca) + switch (mca_char(c)) + { + case MCA_MORE: + /* + * Need another character. + */ + c = getcc(); + goto again; + case MCA_DONE: + /* + * Command has been handled by mca_char. + * Start clean with a prompt. + */ + continue; + case NO_MCA: + /* + * Not a multi-char command + * (at least, not anymore). + */ + break; + } + + /* + * Decode the command character and decide what to do. + */ + if (mca) { - case MCA_MORE: /* - * Need another character. + * We're in a multichar command. + * Add the character to the command buffer + * and display it on the screen. + * If the user backspaces past the start + * of the line, abort the command. */ - c = getcc(); - goto again; - case MCA_DONE: - /* - * Command has been handled by mca_char. - * Start clean with a prompt. - */ - continue; - case NO_MCA: + if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0) + continue; + cbuf = get_cmdbuf(); + } else + { /* - * Not a multi-char command - * (at least, not anymore). + * Don't use cmd_char if we're starting fresh + * at the beginning of a command, because we + * don't want to echo the command until we know + * it is a multichar command. We also don't + * want erase_char/kill_char to be treated + * as line editing characters. */ - break; + tbuf[0] = c; + tbuf[1] = '\0'; + cbuf = tbuf; } - - /* - * Decode the command character and decide what to do. - */ - if (mca) - { + extra = NULL; + action = fcmd_decode(cbuf, &extra); /* - * We're in a multichar command. - * Add the character to the command buffer - * and display it on the screen. - * If the user backspaces past the start - * of the line, abort the command. + * If an "extra" string was returned, + * process it as a string of command characters. */ - if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0) - continue; - cbuf = get_cmdbuf(); - } else - { - /* - * Don't use cmd_char if we're starting fresh - * at the beginning of a command, because we - * don't want to echo the command until we know - * it is a multichar command. We also don't - * want erase_char/kill_char to be treated - * as line editing characters. - */ - tbuf[0] = c; - tbuf[1] = '\0'; - cbuf = tbuf; + if (extra != NULL) + ungetsc(extra); } - s = NULL; - action = fcmd_decode(cbuf, &s); - /* - * If an "extra" string was returned, - * process it as a string of command characters. - */ - if (s != NULL) - ungetsc(s); /* * Clear the cmdbuf string. * (But not if we're in the prefix of a command, @@ -782,7 +980,7 @@ commands() /* * First digit of a number. */ - start_mca(A_DIGIT, ":", (void*)NULL); + start_mca(A_DIGIT, ":", (void*)NULL, CF_QUIT_ON_ERASE); goto again; case A_F_WINDOW: @@ -790,7 +988,7 @@ commands() * Forward one window (and set the window size). */ if (number > 0) - swindow = number; + swindow = (int) number; /* FALLTHRU */ case A_F_SCREEN: /* @@ -799,7 +997,9 @@ commands() if (number <= 0) number = get_swindow(); cmd_exec(); - forward(number, 0, 1); + if (show_attn) + set_attnpos(bottompos); + forward((int) number, 0, 1); break; case A_B_WINDOW: @@ -807,7 +1007,7 @@ commands() * Backward one window (and set the window size). */ if (number > 0) - swindow = number; + swindow = (int) number; /* FALLTHRU */ case A_B_SCREEN: /* @@ -816,7 +1016,7 @@ commands() if (number <= 0) number = get_swindow(); cmd_exec(); - backward(number, 0, 1); + backward((int) number, 0, 1); break; case A_F_LINE: @@ -826,7 +1026,9 @@ commands() if (number <= 0) number = 1; cmd_exec(); - forward(number, 0, 0); + if (show_attn == OPT_ONPLUS && number > 1) + set_attnpos(bottompos); + forward((int) number, 0, 0); break; case A_B_LINE: @@ -836,7 +1038,7 @@ commands() if (number <= 0) number = 1; cmd_exec(); - backward(number, 0, 0); + backward((int) number, 0, 0); break; case A_FF_LINE: @@ -846,7 +1048,9 @@ commands() if (number <= 0) number = 1; cmd_exec(); - forward(number, 1, 0); + if (show_attn == OPT_ONPLUS && number > 1) + set_attnpos(bottompos); + forward((int) number, 1, 0); break; case A_BF_LINE: @@ -856,20 +1060,40 @@ commands() if (number <= 0) number = 1; cmd_exec(); - backward(number, 1, 0); + backward((int) number, 1, 0); break; + case A_FF_SCREEN: + /* + * Force forward one screen. + */ + if (number <= 0) + number = get_swindow(); + cmd_exec(); + if (show_attn == OPT_ONPLUS) + set_attnpos(bottompos); + forward((int) number, 1, 0); + break; + case A_F_FOREVER: /* * Forward forever, ignoring EOF. */ + if (ch_getflags() & CH_HELPFILE) + break; cmd_exec(); jump_forw(); ignore_eoi = 1; hit_eof = 0; - while (!ABORT_SIGS()) + while (!sigs) forward(1, 0, 0); ignore_eoi = 0; + /* + * This gets us back in "F mode" after processing + * a non-abort signal (e.g. window-change). + */ + if (sigs && !ABORT_SIGS()) + newaction = A_F_FOREVER; break; case A_F_SCROLL: @@ -878,8 +1102,10 @@ commands() * (default same as last 'd' or 'u' command). */ if (number > 0) - wscroll = number; + wscroll = (int) number; cmd_exec(); + if (show_attn == OPT_ONPLUS) + set_attnpos(bottompos); forward(wscroll, 0, 0); break; @@ -889,7 +1115,7 @@ commands() * (default same as last 'd' or 'u' command). */ if (number > 0) - wscroll = number; + wscroll = (int) number; cmd_exec(); backward(wscroll, 0, 0); break; @@ -903,6 +1129,9 @@ commands() { ch_flush(); clr_linenum(); +#if HILITE_SEARCH + clr_hilite(); +#endif } /* FALLTHRU */ case A_REPAINT: @@ -932,7 +1161,7 @@ commands() if (number > 100) number = 100; cmd_exec(); - jump_percent(number); + jump_percent((int) number); break; case A_GOEND: @@ -953,18 +1182,20 @@ commands() cmd_exec(); if (number < 0) number = 0; - jump_line_loc((POSITION)number, jump_sline); + jump_line_loc((POSITION) number, jump_sline); break; case A_STAT: /* * Print file name, etc. */ + if (ch_getflags() & CH_HELPFILE) + break; cmd_exec(); parg.p_string = eq_message(); error("%s", &parg); break; - + case A_VERSION: /* * Print version number, without the "@(#)". @@ -977,7 +1208,21 @@ commands() /* * Exit. */ + if (curr_ifile != NULL_IFILE && + ch_getflags() & CH_HELPFILE) + { + /* + * Quit while viewing the help file + * just means return to viewing the + * previous file. + */ + if (edit_prev(1) == 0) + break; + } + if (extra != NULL) + quit(*extra); quit(QUIT_OK); + break; /* * Define abbreviation for a commonly used sequence below. @@ -985,7 +1230,7 @@ commands() #define DO_SEARCH() if (number <= 0) number = 1; \ mca_search(); \ cmd_exec(); \ - multi_search((char *)NULL, number); + multi_search((char *)NULL, (int) number); case A_F_SEARCH: @@ -1057,15 +1302,10 @@ commands() /* * Help. */ - if (nohelp) - { - bell(); + if (ch_getflags() & CH_HELPFILE) break; - } - clear_bot(); - putstr(" help"); cmd_exec(); - help(0); + (void) edit(FAKE_HELPFILE); break; case A_EXAMINE: @@ -1073,7 +1313,12 @@ commands() /* * Edit a new file. Get the filename. */ - start_mca(A_EXAMINE, "Examine: ", ml_examine); + if (secure) + { + error("Command not available", NULL_PARG); + break; + } + start_mca(A_EXAMINE, "Examine: ", ml_examine, 0); c = getcc(); goto again; #else @@ -1086,6 +1331,13 @@ commands() * Invoke an editor on the input file. */ #if EDITOR + if (secure) + { + error("Command not available", NULL_PARG); + break; + } + if (ch_getflags() & CH_HELPFILE) + break; if (strcmp(get_filename(curr_ifile), "-") == 0) { error("Cannot edit standard input", NULL_PARG); @@ -1097,19 +1349,16 @@ commands() NULL_PARG); break; } + start_mca(A_SHELL, "!", ml_shell, 0); /* * Expand the editor prototype string * and pass it to the system to execute. + * (Make sure the screen is displayed so the + * expansion of "+%lm" works.) */ + make_display(); cmd_exec(); - lsystem(pr_expand(editproto, 0)); - /* - * Re-edit the file, since data may have changed. - * Some editors even recreate the file, so flushing - * buffers is not sufficient. - */ - if (edit_ifile(curr_ifile)) - quit(QUIT_ERROR); + lsystem(pr_expand(editproto, 0), (char*)NULL); break; #else error("Command not available", NULL_PARG); @@ -1120,11 +1369,19 @@ commands() /* * Examine next file. */ +#if TAGS + if (ntags()) + { + error("No next file", NULL_PARG); + break; + } +#endif if (number <= 0) number = 1; - if (edit_next(number)) + if (edit_next((int) number)) { - if (quit_at_eof && hit_eof) + if (quit_at_eof && hit_eof && + !(ch_getflags() & CH_HELPFILE)) quit(QUIT_OK); parg.p_string = (number > 1) ? "(N-th) " : ""; error("No %snext file", &parg); @@ -1135,28 +1392,96 @@ commands() /* * Examine previous file. */ +#if TAGS + if (ntags()) + { + error("No previous file", NULL_PARG); + break; + } +#endif if (number <= 0) number = 1; - if (edit_prev(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) + { + error("No next tag", NULL_PARG); + break; + } + if (edit(tagfile) == 0) + { + POSITION pos = tagsearch(); + if (pos != NULL_POSITION) + 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) + { + error("No previous tag", NULL_PARG); + break; + } + if (edit(tagfile) == 0) + { + POSITION pos = tagsearch(); + if (pos != NULL_POSITION) + jump_loc(pos, jump_sline); + } +#else + error("Command not available", NULL_PARG); +#endif + break; + case A_INDEX_FILE: /* * Examine a particular file. */ if (number <= 0) number = 1; - if (edit_index(number)) + if (edit_index((int) number)) error("No such file", NULL_PARG); break; + case A_REMOVE_FILE: + if (ch_getflags() & CH_HELPFILE) + break; + old_ifile = curr_ifile; + new_ifile = getoff_ifile(curr_ifile); + if (new_ifile == NULL_IFILE) + { + bell(); + break; + } + if (edit_ifile(new_ifile) != 0) + { + reedit_ifile(old_ifile); + break; + } + del_ifile(old_ifile); + break; + case A_OPT_TOGGLE: - start_mca(A_OPT_TOGGLE, "-", (void*)NULL); optflag = OPT_TOGGLE; + optgetname = FALSE; + mca_opt_toggle(); c = getcc(); goto again; @@ -1164,18 +1489,17 @@ commands() /* * Report a flag setting. */ - start_mca(A_DISP_OPTION, "_", (void*)NULL); + optflag = OPT_NO_TOGGLE; + optgetname = FALSE; + mca_opt_toggle(); c = getcc(); - if (c == erase_char || c == kill_char) - break; - toggle_option(c, "", OPT_NO_TOGGLE); - break; + goto again; case A_FIRSTCMD: /* * Set an initial command for new files. */ - start_mca(A_FIRSTCMD, "+", (void*)NULL); + start_mca(A_FIRSTCMD, "+", (void*)NULL, 0); c = getcc(); goto again; @@ -1184,7 +1508,12 @@ commands() * Shell escape. */ #if SHELL_ESCAPE - start_mca(A_SHELL, "!", ml_shell); + if (secure) + { + error("Command not available", NULL_PARG); + break; + } + start_mca(A_SHELL, "!", ml_shell, 0); c = getcc(); goto again; #else @@ -1196,7 +1525,9 @@ commands() /* * Set a mark. */ - start_mca(A_SETMARK, "mark: ", (void*)NULL); + if (ch_getflags() & CH_HELPFILE) + break; + start_mca(A_SETMARK, "mark: ", (void*)NULL, 0); c = getcc(); if (c == erase_char || c == kill_char || c == '\n' || c == '\r') @@ -1208,7 +1539,7 @@ commands() /* * Go to a mark. */ - start_mca(A_GOMARK, "goto mark: ", (void*)NULL); + start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0); c = getcc(); if (c == erase_char || c == kill_char || c == '\n' || c == '\r') @@ -1218,7 +1549,12 @@ commands() case A_PIPE: #if PIPEC - start_mca(A_PIPE, "|mark: ", (void*)NULL); + if (secure) + { + error("Command not available", NULL_PARG); + break; + } + start_mca(A_PIPE, "|mark: ", (void*)NULL, 0); c = getcc(); if (c == erase_char || c == kill_char) break; @@ -1227,7 +1563,7 @@ commands() if (badmark(c)) break; pipec = c; - start_mca(A_PIPE, "!", ml_shell); + start_mca(A_PIPE, "!", ml_shell, 0); c = getcc(); goto again; #else @@ -1237,10 +1573,32 @@ commands() case A_B_BRACKET: case A_F_BRACKET: - start_mca(action, "Brackets: ", (void*)NULL); + start_mca(action, "Brackets: ", (void*)NULL, 0); c = getcc(); goto again; + case A_LSHIFT: + if (number > 0) + shift_count = number; + else + number = (shift_count > 0) ? + shift_count : sc_width / 2; + if (number > hshift) + number = hshift; + hshift -= number; + screen_trashed = 1; + break; + + case A_RSHIFT: + if (number > 0) + shift_count = number; + else + number = (shift_count > 0) ? + shift_count : sc_width / 2; + hshift += number; + screen_trashed = 1; + break; + case A_PREFIX: /* * The command is incomplete (more chars are needed). @@ -1249,8 +1607,9 @@ commands() */ if (mca != A_PREFIX) { - start_mca(A_PREFIX, " ", (void*)NULL); cmd_reset(); + start_mca(A_PREFIX, " ", (void*)NULL, + CF_QUIT_ON_ERASE); (void) cmd_char(c); } c = getcc(); @@ -1261,7 +1620,7 @@ commands() default: if (be_helpful) - helpprompt = 1; + help_prompt = "[Press 'h' for instructions.]"; else bell(); break; diff --git a/usr.bin/less/configure b/usr.bin/less/configure index 61fd1299b24..6264a36eb75 100644 --- a/usr.bin/less/configure +++ b/usr.bin/less/configure @@ -1,26 +1,321 @@ -#!/bin/sh - +#! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.1 -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# Generated by GNU Autoconf 2.54 for less 1. # +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# 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 Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE LC_NUMERIC LC_MESSAGES LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; 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 + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH="/nonexistent;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac -# Defaults: -ac_help= + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# ac_default_prefix=/usr/local -# Any additions from configure.in: +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='less' +PACKAGE_TARNAME='less' +PACKAGE_VERSION='1' +PACKAGE_STRING='less 1' +PACKAGE_BUGREPORT='' + +ac_unique_file="forwback.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA REGEX_O LIBOBJS LTLIBOBJS' +ac_subst_files='' # Initialize some variables set by options. +ac_init_help= +ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. -build=NONE -cache_file=./config.cache +cache_file=/dev/null exec_prefix=NONE -host=NONE no_create= -nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE @@ -29,18 +324,31 @@ program_transform_name=s,x,x, silent= site= srcdir= -target=NONE verbose= x_includes=NONE x_libraries=NONE -# Initialize some other variables. -subdirs= +# 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. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' ac_prev= for ac_option do - # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -48,48 +356,59 @@ do continue fi - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case "$ac_option" in + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; - -build | --build | --buil | --bui | --bu | --b) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) - build="$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" ;; + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "enable_${ac_feature}='$ac_optarg'" ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -98,83 +417,101 @@ do -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; + exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=PREFIX install architecture-dependent files in PREFIX - [same as prefix] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR ---enable and --with options recognized:$ac_help -EOF - exit 0 ;; + -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 ;; + ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) + | --no-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" ;; + 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_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_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ @@ -191,55 +528,78 @@ EOF | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; + program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; + site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; + 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 ;; + ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; + target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.1" - exit 0 ;; + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "with_${ac_package}='$ac_optarg'" ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -250,95 +610,110 @@ EOF 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_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" ;; + x_libraries=$ac_optarg ;; - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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 - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 unused; standard input -# 1 file creation -# 2 errors and warnings -# 3 unused; some systems may open it to /dev/tty -# 4 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 4>/dev/null -else - exec 4>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac done -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi +# 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 + 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 -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=forwback.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + 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=.. @@ -348,13 +723,407 @@ else fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } fi fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# 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 \`..'] + +_ACEOF + + cat <<_ACEOF +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] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --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] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_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-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-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} 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> + CPPFLAGS 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. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style 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 + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +less configure 1 +generated by GNU Autoconf 2.54 + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +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 0 +fi +exec 5>config.log +cat >&5 <<_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.54. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +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` +hostinfo = `(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=. + echo "PATH: $as_dir" +done + +} >&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. +# Also quote any args containing shell meta-characters. +ac_configure_args= +ac_sep= +for ac_arg +do + case $ac_arg in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n ) continue ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " +done + +# 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: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# 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 + + +# Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then @@ -365,232 +1134,1290 @@ if test -z "$CONFIG_SITE"; then fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi else - echo "creating cache $cache_file" - > $cache_file + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +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 `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; 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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`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. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&5 2>&5' -ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&5 2>&5' - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - ac_n= ac_c='\c' ac_t= + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&4 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$ac_t""no" 1>&4 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else - ac_cv_prog_gcc=no + 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 $as_executable_p "$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" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +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 -echo "$ac_t""$ac_cv_prog_gcc" 1>&4 -if test $ac_cv_prog_gcc = yes; then - GCC=yes - if test "${CFLAGS+set}" != set; then - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_gcc_g=yes + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else - ac_cv_prog_gcc_g=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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi -rm -f conftest* +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done fi - echo "$ac_t""$ac_cv_prog_gcc_g" 1>&4 - if test $ac_cv_prog_gcc_g = yes; then - CFLAGS="-g -O" +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH" >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe" +# 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. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + a.out ) # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool --akim. + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +check \`config.log' for details." >&5 +echo "$as_me: error: C compiler cannot create executables +check \`config.log' for details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes else - CFLAGS="-O" + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&2;} + { (exit 1); exit 1; }; } fi fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link" >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile" >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_compiler_gnu=no fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu -echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&4 -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - echo "$ac_t""yes" 1>&4 - ISC=yes # If later tests want to check for ISC. - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 - CC="$CC -posix" + CFLAGS="-O2" else - CC="$CC -Xp" + CFLAGS= fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "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; +} +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 +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <stdlib.h> +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +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 + + +echo "$as_me:$LINENO: checking for library containing strerror" >&5 +echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6 +if test "${ac_cv_search_strerror+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_strerror=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="none required" else - echo "$ac_t""no" 1>&4 - ISC= + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_strerror" = no; then + for ac_lib in cposix; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS fi +echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 +echo "${ECHO_T}$ac_cv_search_strerror" >&6 +if test "$ac_cv_search_strerror" != no; then + test "$ac_cv_search_strerror" = "none required" || LIBS="$ac_cv_search_strerror $LIBS" -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&4 +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 +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '${'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" + # 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. # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 511 "configure" + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - echo "$ac_err" >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 525 "configure" + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f 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 +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$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. + # 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - echo "$ac_err" >&5 - rm -rf conftest* - CPP=/lib/cpp + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Broken: fails on valid input. +continue fi -rm -f conftest* +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check" >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} + { (exit 1); exit 1; }; } 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 + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi fi -CPP="$ac_cv_prog_CPP" -echo "$ac_t""$CPP" 1>&4 +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep -if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + +if test $ac_cv_c_compiler_gnu = yes; then + echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6 +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" - cat > conftest.$ac_ext <<EOF -#line 555 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else - rm -rf conftest* ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then - cat > conftest.$ac_ext <<EOF -#line 573 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi - echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&4 +echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$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 ${GNUSYSTEM_AUX_DIR} $srcdir $srcdir/.. $srcdir/../..; do +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" @@ -599,14 +2426,20 @@ for ac_dir in ${GNUSYSTEM_AUX_DIR} $srcdir $srcdir/.. $srcdir/../..; do 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 - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -615,365 +2448,1151 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # 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" # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&4 +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then -if eval "test \"`echo '${'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - case "$ac_dir" in - ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi + 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/* | \ + /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 $as_executable_p "$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 + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done - ;; - esac - done - IFS="$ac_save_ifs" - # As a last resort, use the slow shell script. - test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh" + done + ;; +esac +done + + fi - INSTALL="$ac_cv_path_install" + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi fi -echo "$ac_t""$INSTALL" 1>&4 +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$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' -TERMLIBS= -echo $ac_n "checking for -lcurses""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_curses'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# Checks for compilation model. +# Check whether --enable-largefile or --disable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval="$enable_largefile" + +fi; +if test "$enable_largefile" != no; then + + echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -lcurses " -cat > conftest.$ac_ext <<EOF -#line 672 "configure" + 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" - -int main() { return 0; } -int t() { -initscr() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_curses=yes" +#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 + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break else - rm -rf conftest* - eval "ac_cv_lib_curses=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 fi -rm -f conftest* -LIBS="$ac_save_LIBS" +rm -f conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_CC=' -n32'; break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_file_offset_bits=no + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "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 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 fi -if eval "test \"`echo '$ac_cv_lib_'curses`\" = yes"; then - echo "$ac_t""yes" 1>&4 - TERMLIBS="$TERMLIBS -lcurses" +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "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 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_file_offset_bits=64; break else - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 fi +rm -f conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 +if test "$ac_cv_sys_file_offset_bits" != no; then -echo $ac_n "checking for -ltermcap""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_termcap'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF + +fi +rm -f conftest* + echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -ltermcap " -cat > conftest.$ac_ext <<EOF -#line 705 "configure" + while :; do + ac_cv_sys_large_files=no + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" - -int main() { return 0; } -int t() { -tgetent() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_termcap=yes" +#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 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "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 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_large_files=1; break else - rm -rf conftest* - eval "ac_cv_lib_termcap=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6 +if test "$ac_cv_sys_large_files" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF + fi rm -f conftest* -LIBS="$ac_save_LIBS" +fi + +# Checks for general libraries. +echo "$as_me:$LINENO: checking for initscr in -lxcurses" >&5 +echo $ECHO_N "checking for initscr in -lxcurses... $ECHO_C" >&6 +if test "${ac_cv_lib_xcurses_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lxcurses $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_xcurses_initscr=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_xcurses_initscr=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'termcap`\" = yes"; then - echo "$ac_t""yes" 1>&4 - TERMLIBS="$TERMLIBS -ltermcap" +echo "$as_me:$LINENO: result: $ac_cv_lib_xcurses_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_xcurses_initscr" >&6 +if test $ac_cv_lib_xcurses_initscr = yes; then + have_xcurses=yes else - echo "$ac_t""no" 1>&4 + have_xcurses=no fi -echo $ac_n "checking for -ltermlib""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_termlib'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 +echo $ECHO_N "checking for initscr in -lncurses... $ECHO_C" >&6 +if test "${ac_cv_lib_ncurses_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -ltermlib " -cat > conftest.$ac_ext <<EOF -#line 738 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { -tgetent() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_termlib=yes" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ncurses_initscr=yes else - rm -rf conftest* - eval "ac_cv_lib_termlib=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_ncurses_initscr=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'termlib`\" = yes"; then - echo "$ac_t""yes" 1>&4 - have_termlib=yes +echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_ncurses_initscr" >&6 +if test $ac_cv_lib_ncurses_initscr = yes; then + have_ncurses=yes else - echo "$ac_t""no" 1>&4 -have_termlib=no + have_ncurses=no fi -echo $ac_n "checking for -lgen""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_gen'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo "$as_me:$LINENO: checking for initscr in -lcurses" >&5 +echo $ECHO_N "checking for initscr in -lcurses... $ECHO_C" >&6 +if test "${ac_cv_lib_curses_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -lgen " -cat > conftest.$ac_ext <<EOF -#line 772 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { -regcmp() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_gen=yes" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_curses_initscr=yes else - rm -rf conftest* - eval "ac_cv_lib_gen=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_curses_initscr=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_curses_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_curses_initscr" >&6 +if test $ac_cv_lib_curses_initscr = yes; then + have_curses=yes +else + have_curses=no +fi + +echo "$as_me:$LINENO: checking for tgetent in -ltermcap" >&5 +echo $ECHO_N "checking for tgetent in -ltermcap... $ECHO_C" >&6 +if test "${ac_cv_lib_termcap_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltermcap $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_termcap_tgetent=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_termcap_tgetent=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_termcap_tgetent" >&6 +if test $ac_cv_lib_termcap_tgetent = yes; then + have_termcap=yes +else + have_termcap=no fi -if eval "test \"`echo '$ac_cv_lib_'gen`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_lib=HAVE_LIB`echo gen | tr '[a-z]' '[A-Z]'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF - LIBS="$LIBS -lgen" +echo "$as_me:$LINENO: checking for tgetent in -ltermlib" >&5 +echo $ECHO_N "checking for tgetent in -ltermlib... $ECHO_C" >&6 +if test "${ac_cv_lib_termlib_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltermlib $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_termlib_tgetent=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_termlib_tgetent=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_termlib_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_termlib_tgetent" >&6 +if test $ac_cv_lib_termlib_tgetent = yes; then + have_termlib=yes else - echo "$ac_t""no" 1>&4 + have_termlib=no fi -echo $ac_n "checking for -lintl""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_intl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# Regular expressions (regcmp) are in -lgen on Solaris 2, +# and in -lintl on SCO Unix. + +echo "$as_me:$LINENO: checking for regcmp in -lgen" >&5 +echo $ECHO_N "checking for regcmp in -lgen... $ECHO_C" >&6 +if test "${ac_cv_lib_gen_regcmp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -lintl " -cat > conftest.$ac_ext <<EOF -#line 811 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgen $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { -regcmp() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_intl=yes" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char regcmp (); +int +main () +{ +regcmp (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_gen_regcmp=yes else - rm -rf conftest* - eval "ac_cv_lib_intl=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_gen_regcmp=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_gen_regcmp" >&5 +echo "${ECHO_T}$ac_cv_lib_gen_regcmp" >&6 +if test $ac_cv_lib_gen_regcmp = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGEN 1 +_ACEOF + + LIBS="-lgen $LIBS" fi -if eval "test \"`echo '$ac_cv_lib_'intl`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_lib=HAVE_LIB`echo intl | tr '[a-z]' '[A-Z]'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF - LIBS="$LIBS -lintl" +echo "$as_me:$LINENO: checking for regcmp in -lintl" >&5 +echo $ECHO_N "checking for regcmp in -lintl... $ECHO_C" >&6 +if test "${ac_cv_lib_intl_regcmp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$ac_t""no" 1>&4 + ac_check_lib_save_LIBS=$LIBS +LIBS="-lintl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char regcmp (); +int +main () +{ +regcmp (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_intl_regcmp=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_intl_regcmp=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi +echo "$as_me:$LINENO: result: $ac_cv_lib_intl_regcmp" >&5 +echo "${ECHO_T}$ac_cv_lib_intl_regcmp" >&6 +if test $ac_cv_lib_intl_regcmp = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBINTL 1 +_ACEOF + + LIBS="-lintl $LIBS" + +fi + -echo $ac_n "checking for -lPW""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_PW'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo "$as_me:$LINENO: checking for regcmp in -lPW" >&5 +echo $ECHO_N "checking for regcmp in -lPW... $ECHO_C" >&6 +if test "${ac_cv_lib_PW_regcmp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -lPW " -cat > conftest.$ac_ext <<EOF -#line 850 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lPW $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { -regcmp() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_PW=yes" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char regcmp (); +int +main () +{ +regcmp (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_PW_regcmp=yes else - rm -rf conftest* - eval "ac_cv_lib_PW=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_PW_regcmp=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_PW_regcmp" >&5 +echo "${ECHO_T}$ac_cv_lib_PW_regcmp" >&6 +if test $ac_cv_lib_PW_regcmp = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPW 1 +_ACEOF + + LIBS="-lPW $LIBS" fi -if eval "test \"`echo '$ac_cv_lib_'PW`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_lib=HAVE_LIB`echo PW | tr '[a-z]' '[A-Z]'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF - LIBS="$LIBS -lPW" -else - echo "$ac_t""no" 1>&4 +# Checks for terminal libraries +echo "$as_me:$LINENO: checking for working terminal libraries" >&5 +echo $ECHO_N "checking for working terminal libraries... $ECHO_C" >&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 xcurses. +if test "x$TERMLIBS" = x; then + if test $have_xcurses = yes; then + TERMLIBS="-lxcurses" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" -echo $ac_n "checking for working terminal libraries""... $ac_c" 1>&4 -SAVE_LIBS=$LIBS -LIBS="$LIBS $TERMLIBS" -cat > conftest.$ac_ext <<EOF -#line 887 "configure" +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + termok=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no +fi +rm -f 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { -tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then termok=yes else - rm -rf conftest* - termok=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi fi -rm -f conftest* -if test $termok = yes; then - echo "$ac_t""using $TERMLIBS" 1>&4 +# -- Try curses. +if test "x$TERMLIBS" = x; then + if test $have_curses = yes; then + TERMLIBS="-lcurses" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + termok=yes else - LIBS="$SAVE_LIBS" - if test $have_termlib = yes; then - LIBS="$LIBS -ltermlib" - echo "$ac_t""using -ltermlib" 1>&4 - else - echo "$ac_t""TERMINAL LIBRARY BROKEN - configure failed" 1>&4 - exit 1 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi fi fi -# If we cannot run a trivial program, we must be cross compiling. -echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_cross'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# -- 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + termok=yes else - if test "$cross_compiling" = yes; then - ac_cv_cross=yes + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no +fi +rm -f 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + termok=yes else -cat > conftest.$ac_ext <<EOF -#line 926 "configure" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no +fi +rm -f 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 >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -main(){return(0);} -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - ac_cv_c_cross=no + +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + termok=yes else - ac_cv_c_cross=yes + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +termok=no fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi fi -rm -fr conftest* + +if test "x$TERMLIBS" = x; then + echo "$as_me:$LINENO: result: Cannot find terminal libraries - configure failed" >&5 +echo "${ECHO_T}Cannot find terminal libraries - configure failed" >&6 + exit 1 fi -cross_compiling=$ac_cv_c_cross -echo "$ac_t""$ac_cv_c_cross" 1>&4 +echo "$as_me:$LINENO: result: using $TERMLIBS" >&5 +echo "${ECHO_T}using $TERMLIBS" >&6 +LIBS="$LIBS $TERMLIBS" -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# Checks for header files. +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 947 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <float.h> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_cv_header_stdc=yes else - echo "$ac_err" >&5 - rm -rf conftest* + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 ac_cv_header_stdc=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 969 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <string.h> -EOF + +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then + $EGREP "memchr" >/dev/null 2>&1; then : else - rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* @@ -982,16 +3601,16 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 987 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <stdlib.h> -EOF + +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then + $EGREP "free" >/dev/null 2>&1; then : else - rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* @@ -1000,308 +3619,1026 @@ 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 - ac_cv_header_stdc=no + if test "$cross_compiling" = yes; then + : else -cat > conftest.$ac_ext <<EOF -#line 1008 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <ctype.h> -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } +#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 -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then : else - ac_cv_header_stdc=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -rm -fr conftest* fi fi -echo "$ac_t""$ac_cv_header_stdc" 1>&4 +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 -EOF +_ACEOF + +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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_Header=no" fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + -for ac_hdr in ctype.h errno.h fcntl.h stdio.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h + + + + + + + + + + + + +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 sys/ptem.h do -ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1045 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -rm -f conftest* +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes else - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + fi + done -echo $ac_n "checking for off_t""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_off_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# Checks for typedefs, structures, and compiler characteristics. +echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5 +echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6 +if test "${ac_cv_header_stat_broken+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1079 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sys/types.h> -#if STDC_HEADERS -#include <stdlib.h> +#include <sys/stat.h> + +#if defined(S_ISBLK) && defined(S_IFDIR) +# if S_ISBLK (S_IFDIR) +You lose. +# endif +#endif + +#if defined(S_ISBLK) && defined(S_IFCHR) +# if S_ISBLK (S_IFCHR) +You lose. +# endif +#endif + +#if defined(S_ISLNK) && defined(S_IFREG) +# if S_ISLNK (S_IFREG) +You lose. +# endif #endif -EOF + +#if defined(S_ISSOCK) && defined(S_IFREG) +# if S_ISSOCK (S_IFREG) +You lose. +# endif +#endif + +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "off_t" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_type_off_t=yes + $EGREP "You lose" >/dev/null 2>&1; then + ac_cv_header_stat_broken=yes else - rm -rf conftest* - ac_cv_type_off_t=no + ac_cv_header_stat_broken=no fi rm -f conftest* fi -echo "$ac_t""$ac_cv_type_off_t" 1>&4 -if test $ac_cv_type_off_t = no; then - cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: $ac_cv_header_stat_broken" >&5 +echo "${ECHO_T}$ac_cv_header_stat_broken" >&6 +if test $ac_cv_header_stat_broken = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STAT_MACROS_BROKEN 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* 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"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 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; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_const=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_off_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 +if test $ac_cv_type_off_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF #define off_t long -EOF +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_size_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF fi -echo $ac_n "checking for void""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1107 "configure" +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" +#include <sys/types.h> +#include <sys/time.h> +#include <time.h> + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_header_time=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + -int main() { return 0; } -int t() { +# Autoheader templates for symbols defined later by AC_DEFINE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Checks for identifiers. +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_off_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 +if test $ac_cv_type_off_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define off_t long +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for void" >&5 +echo $ECHO_N "checking for void... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +int +main () +{ void *foo = 0; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_VOID 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: checking for const" >&5 +echo $ECHO_N "checking for const... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" -echo $ac_n "checking for time_t""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1129 "configure" +int +main () +{ +const int foo = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF +#define HAVE_CONST 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: checking for time_t" >&5 +echo $ECHO_N "checking for time_t... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <time.h> -int main() { return 0; } -int t() { +int +main () +{ time_t t = 0; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_TIME_T 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext - -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +# Checks for library functions. +echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1155 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> #ifdef signal -#undef signal +# undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); #endif -extern void (*signal ()) (); -int main() { return 0; } -int t() { + +int +main () +{ int i; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_type_signal=void else - rm -rf conftest* - ac_cv_type_signal=int + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_signal=int fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$ac_cv_type_signal" 1>&4 -cat >> confdefs.h <<EOF +echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 + +cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal -EOF +_ACEOF + + -for ac_func in _setjmp system sigsetmask memcpy strchr + + + + + + + + +for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1191 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ -char $ac_func(); - -int main() { return 0; } -int t() { - +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +int +main () +{ /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +f = $ac_func; #endif -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" else - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&4 +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + fi done -echo $ac_n "checking for tcgetattr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_tcgetattr'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + +# Some systems have termios.h but not the corresponding functions. +echo "$as_me:$LINENO: checking for tcgetattr" >&5 +echo $ECHO_N "checking for tcgetattr... $ECHO_C" >&6 +if test "${ac_cv_func_tcgetattr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1238 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char tcgetattr (); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ -char tcgetattr(); - -int main() { return 0; } -int t() { - +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char tcgetattr (); +char (*f) (); + +int +main () +{ /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_tcgetattr) || defined (__stub___tcgetattr) choke me #else -tcgetattr(); +f = tcgetattr; #endif -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_tcgetattr=yes" + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_tcgetattr=yes else - rm -rf conftest* - eval "ac_cv_func_tcgetattr=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_tcgetattr=no fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_func_'tcgetattr`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: $ac_cv_func_tcgetattr" >&5 +echo "${ECHO_T}$ac_cv_func_tcgetattr" >&6 +if test $ac_cv_func_tcgetattr = yes; then + cat >>confdefs.h <<\_ACEOF #define HAVE_TERMIOS_FUNCS 1 -EOF +_ACEOF -else - echo "$ac_t""no" 1>&4 fi -echo $ac_n "checking for fileno""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1280 "configure" + +echo "$as_me:$LINENO: checking for fileno" >&5 +echo $ECHO_N "checking for fileno... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #if HAVE_STDIO_H #include <stdio.h> #endif -int main() { return 0; } -int t() { +int +main () +{ static int x; x = fileno(stdin); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_FILENO 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -echo $ac_n "checking for strerror""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1305 "configure" +echo "$as_me:$LINENO: checking for strerror" >&5 +echo $ECHO_N "checking for strerror... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #if HAVE_STDIO_H @@ -1313,120 +4650,332 @@ cat > conftest.$ac_ext <<EOF #if HAVE_ERRNO_H #include <errno.h> #endif -int main() { return 0; } -int t() { +int +main () +{ static char *x; x = strerror(0); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_STRERROR 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -echo $ac_n "checking for sys_errlist""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1336 "configure" +echo "$as_me:$LINENO: checking for sys_errlist" >&5 +echo $ECHO_N "checking for sys_errlist... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { +int +main () +{ extern char *sys_errlist[]; static char **x; x = sys_errlist; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_ERRLIST 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + +echo "$as_me:$LINENO: checking for sigset_t" >&5 +echo $ECHO_N "checking for sigset_t... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include <signal.h> + +int +main () +{ +sigset_t s; s = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGSET_T 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + +echo "$as_me:$LINENO: checking for sigemptyset" >&5 +echo $ECHO_N "checking for sigemptyset... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include <signal.h> + +int +main () +{ +sigset_t s; sigemptyset(&s); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGEMPTYSET 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + +have_errno=no +echo "$as_me:$LINENO: checking for errno" >&5 +echo $ECHO_N "checking for errno... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" -echo $ac_n "checking for errno""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1358 "configure" +#if HAVE_ERRNO_H +#include <errno.h> +#endif +int +main () +{ +static int x; x = errno; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes - in errno.h" >&5 +echo "${ECHO_T}yes - in errno.h" >&6; cat >>confdefs.h <<\_ACEOF +#define HAVE_ERRNO 1 +_ACEOF + have_errno=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test $have_errno = no; then +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { +#if HAVE_ERRNO_H +#include <errno.h> +#endif +int +main () +{ extern int errno; static int x; x = errno; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes - must define" >&5 +echo "${ECHO_T}yes - must define" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_ERRNO 1 -EOF +_ACEOF + cat >>confdefs.h <<\_ACEOF +#define MUST_DEFINE_ERRNO 1 +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -rm -f conftest* -echo $ac_n "checking for locale""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1380 "configure" +echo "$as_me:$LINENO: checking for locale" >&5 +echo $ECHO_N "checking for locale... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <locale.h> #include <ctype.h> -int main() { return 0; } -int t() { +int +main () +{ setlocale(LC_CTYPE,""); isprint(0); iscntrl(0); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_LOCALE 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* - -echo $ac_n "checking for ctype functions""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1403 "configure" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +echo "$as_me:$LINENO: checking for ctype functions" >&5 +echo $ECHO_N "checking for ctype functions... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #if HAVE_CTYPE_H #include <ctype.h> #endif -int main() { return 0; } -int t() { +int +main () +{ static int x; x = isupper(x); x = tolower(x); x = toupper(x); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_UPPER_LOWER 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +# Checks for external variable ospeed in the termcap library. have_ospeed=no -echo $ac_n "checking termcap for ospeed""... $ac_c" 1>&4 -cat > conftest.$ac_ext <<EOF -#line 1430 "configure" +echo "$as_me:$LINENO: checking termcap for ospeed" >&5 +echo $ECHO_N "checking termcap for ospeed... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sys/types.h> @@ -1436,499 +4985,1527 @@ cat > conftest.$ac_ext <<EOF #if HAVE_TERMCAP_H #include <termcap.h> #endif -int main() { return 0; } -int t() { +int +main () +{ ospeed = 0; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes - in termcap.h" >&5 +echo "${ECHO_T}yes - in termcap.h" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_OSPEED 1 -EOF +_ACEOF have_ospeed=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test $have_ospeed = no; then -cat > conftest.$ac_ext <<EOF -#line 1456 "configure" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -int main() { return 0; } -int t() { +int +main () +{ extern short ospeed; ospeed = 0; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""yes" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes - must define" >&5 +echo "${ECHO_T}yes - must define" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_OSPEED 1 -EOF - cat >> confdefs.h <<\EOF +_ACEOF + cat >>confdefs.h <<\_ACEOF #define MUST_DEFINE_OSPEED 1 -EOF +_ACEOF else - rm -rf conftest* - echo "$ac_t""no" 1>&4 + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi +# Checks for regular expression functions. have_regex=no have_posix_regex=unknown -echo "checking for regular expression library" 1>&4 +echo "$as_me:$LINENO: checking for regcomp" >&5 +echo $ECHO_N "checking for regcomp... $ECHO_C" >&6 + +WANT_REGEX=auto + +# Check whether --with-regex or --without-regex was given. +if test "${with_regex+set}" = set; then + withval="$with_regex" + WANT_REGEX="$withval" +fi; + +if test $have_regex = no; then +if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then +# 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. if test "$cross_compiling" = yes; then have_posix_regex=unknown else -cat > conftest.$ac_ext <<EOF -#line 1488 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sys/types.h> #include <regex.h> -main() { regex_t r; regmatch_t rm; +main() { regex_t r; regmatch_t rm; char *text = "xabcy"; if (regcomp(&r, "abc", 0)) exit(1); -if (regexec(&r, "xabcy", 1, &rm, 0)) exit(1); +if (regexec(&r, text, 1, &rm, 0)) exit(1); +#ifndef __WATCOMC__ +if (rm.rm_so != 1) exit(1); /* check for correct offset */ +#else +if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */ +#endif exit(0); } -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then have_posix_regex=yes else - have_posix_regex=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +have_posix_regex=no fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -rm -fr conftest* if test $have_posix_regex = yes; then - echo "$ac_t""using POSIX regcomp" 1>&4 - cat >> confdefs.h <<\EOF + echo "$as_me:$LINENO: result: using POSIX regcomp" >&5 +echo "${ECHO_T}using POSIX regcomp" >&6 + cat >>confdefs.h <<\_ACEOF #define HAVE_POSIX_REGCOMP 1 -EOF +_ACEOF have_regex=yes elif test $have_posix_regex = unknown; then - cat > conftest.$ac_ext <<EOF -#line 1515 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include <sys/types.h> #include <regex.h> -int main() { return 0; } -int t() { +int +main () +{ regex_t *r; regfree(r); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""using POSIX regcomp" 1>&4 - cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: using POSIX regcomp" >&5 +echo "${ECHO_T}using POSIX regcomp" >&6 + cat >>confdefs.h <<\_ACEOF #define HAVE_POSIX_REGCOMP 1 -EOF +_ACEOF have_regex=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* - fi +fi + if test $have_regex = no; then -echo $ac_n "checking for regcmp""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_regcmp'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then +echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6 +if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1542 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcre $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ + /* Override any gcc2 internal prototype to avoid an error. */ -char regcmp(); +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcre_compile (); +int +main () +{ +pcre_compile (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pcre_pcre_compile=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_pcre_pcre_compile=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6 +if test $ac_cv_lib_pcre_pcre_compile = yes; then + echo "$as_me:$LINENO: result: using pcre" >&5 +echo "${ECHO_T}using pcre" >&6; cat >>confdefs.h <<\_ACEOF +#define HAVE_PCRE 1 +_ACEOF + LIBS="$LIBS -lpcre" have_regex=yes +fi -int main() { return 0; } -int t() { +fi +fi +if test $have_regex = no; then +if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then +echo "$as_me:$LINENO: checking for regcmp" >&5 +echo $ECHO_N "checking for regcmp... $ECHO_C" >&6 +if test "${ac_cv_func_regcmp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char regcmp (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char regcmp (); +char (*f) (); + +int +main () +{ /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_regcmp) || defined (__stub___regcmp) choke me #else -regcmp(); +f = regcmp; #endif -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_regcmp=yes" + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_regcmp=yes else - rm -rf conftest* - eval "ac_cv_func_regcmp=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_regcmp=no fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_func_'regcmp`\" = yes"; then - echo "$ac_t""yes" 1>&4 - echo "$ac_t""using regcmp" 1>&4; cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: $ac_cv_func_regcmp" >&5 +echo "${ECHO_T}$ac_cv_func_regcmp" >&6 +if test $ac_cv_func_regcmp = yes; then + echo "$as_me:$LINENO: result: using regcmp" >&5 +echo "${ECHO_T}using regcmp" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_REGCMP 1 -EOF +_ACEOF have_regex=yes -else - echo "$ac_t""no" 1>&4 fi fi +fi + if test $have_regex = no; then -cat > conftest.$ac_ext <<EOF -#line 1585 "configure" +if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" #include "regexp.h" -int main() { return 0; } -int t() { +int +main () +{ regcomp(""); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - echo "$ac_t""using V8 regcomp" 1>&4; cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: using V8 regcomp" >&5 +echo "${ECHO_T}using V8 regcomp" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_V8_REGCOMP 1 -EOF +_ACEOF have_regex=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -if test $have_regex = no && test -f ${srcdir}/regex.c; then -echo "$ac_t""using POSIX regcomp -- local source" 1>&4; cat >> confdefs.h <<\EOF -#define HAVE_POSIX_REGCOMP 1 -EOF - REGEX_O='regex.$(O)' have_regex=yes fi + if test $have_regex = no && test -f ${srcdir}/regexp.c; then -echo "$ac_t""using V8 regcomp -- local source" 1>&4; cat >> confdefs.h <<\EOF +if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then +echo "$as_me:$LINENO: result: using V8 regcomp -- local source" >&5 +echo "${ECHO_T}using V8 regcomp -- local source" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_V8_REGCOMP 1 -EOF +_ACEOF + cat >>confdefs.h <<\_ACEOF +#define HAVE_REGEXEC2 1 +_ACEOF REGEX_O='regexp.$(O)' have_regex=yes fi +fi + if test $have_regex = no; then -echo "$ac_t""using re_comp" 1>&4; echo $ac_n "checking for re_comp""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_re_comp'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then +echo "$as_me:$LINENO: result: using re_comp" >&5 +echo "${ECHO_T}using re_comp" >&6; echo "$as_me:$LINENO: checking for re_comp" >&5 +echo $ECHO_N "checking for re_comp... $ECHO_C" >&6 +if test "${ac_cv_func_re_comp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1622 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char re_comp (); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ -char re_comp(); - -int main() { return 0; } -int t() { - +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char re_comp (); +char (*f) (); + +int +main () +{ /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_re_comp) || defined (__stub___re_comp) choke me #else -re_comp(); +f = re_comp; #endif -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_re_comp=yes" + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_re_comp=yes else - rm -rf conftest* - eval "ac_cv_func_re_comp=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_re_comp=no fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_func_'re_comp`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: $ac_cv_func_re_comp" >&5 +echo "${ECHO_T}$ac_cv_func_re_comp" >&6 +if test $ac_cv_func_re_comp = yes; then + cat >>confdefs.h <<\_ACEOF #define HAVE_RE_COMP 1 -EOF +_ACEOF have_regex=yes -else - echo "$ac_t""no" 1>&4 fi fi +fi + if test $have_regex = no; then -echo "$ac_t""cannot find regular expression library" 1>&4; cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: cannot find regular expression library" >&5 +echo "${ECHO_T}cannot find regular expression library" >&6; cat >>confdefs.h <<\_ACEOF #define NO_REGEX 1 -EOF +_ACEOF fi -trap '' 1 2 15 -if test -w $cache_file; then -echo "updating cache $cache_file" -cat > $cache_file <<\EOF + +# Check whether --with-editor or --without-editor was given. +if test "${with_editor+set}" = set; then + withval="$with_editor" + cat >>confdefs.h <<_ACEOF +#define EDIT_PGM "$withval" +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define EDIT_PGM "vi" +_ACEOF + +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. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. +# 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. # -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. # -EOF -# Ultrix sh set writes to stderr and can't be redirected directly. -(set) 2>&1 | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/: \${\1='\2'}/p" \ - >> $cache_file -else -echo "not updating unwritable cache $cache_file" +# `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, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *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 \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi fi - -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ 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[ ]*=[^:]*$/d' + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' fi -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - DEFS=-DHAVE_CONFIG_H -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#!/bin/sh -# Generated automatically by configure. +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. # Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# # Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. +# configure, is in config.log if it exists. + +debug=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE LC_NUMERIC LC_MESSAGES LC_TIME do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.1" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi done -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi -trap 'rm -fr Makefile defines.h conftest*; exit 1' 1 2 15 +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF -$ac_vpsub -$extrasub -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@REGEX_O@%$REGEX_O%g -CEOF -EOF -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"Makefile"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH="/nonexistent;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; esac - # Adjust relative srcdir, etc. for subdirectories. + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/$ac_dir" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' else - ac_dir_suffix= ac_dots= + as_ln_s='ln -s' fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by less $as_me 1, which was +generated by GNU Autoconf 2.54. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -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 <bug-autoconf@gnu.org>." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +less config.status 1 +configured by $0, generated by GNU Autoconf 2.54, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +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=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" + exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "defines.h" ) CONFIG_HEADERS="$CONFIG_HEADERS defines.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; 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 + +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/cs$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@REGEX_O@,$REGEX_O,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file -fi; done -rm -f conftest.subs + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # 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. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;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,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -CONFIG_HEADERS=${CONFIG_HEADERS-"defines.h"} -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - cp $ac_given_srcdir/$ac_file_in conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. -# Maximum number of lines to put in a single here document. -ac_max_here_lines=12 +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail -while : +while grep . conftest.undefs >/dev/null do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # 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. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h else - rm -f $ac_file - mv conftest.h $ac_file + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi -fi; done - + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if cmp -s $ac_file $tmp/config.h 2>/dev/null; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -exit 0 -EOF +{ (exit 0); exit 0; } +_ACEOF chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || 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 || { (exit 1); exit 1; } +fi diff --git a/usr.bin/less/configure.in b/usr.bin/less/configure.in deleted file mode 100644 index 9c7326450fa..00000000000 --- a/usr.bin/less/configure.in +++ /dev/null @@ -1,161 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(forwback.c) -AC_CONFIG_HEADER(defines.h) - -dnl Checks for programs. -AC_PROG_CC -AC_ISC_POSIX -AC_PROG_GCC_TRADITIONAL -AC_PROG_INSTALL - -dnl Checks for libraries. -TERMLIBS= -AC_CHECK_LIB(curses, initscr, [TERMLIBS="$TERMLIBS -lcurses"]) -AC_CHECK_LIB(termcap, tgetent, [TERMLIBS="$TERMLIBS -ltermcap"]) -AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no]) -dnl Regular expressions (regcmp) are in -lgen on Solaris 2, -dnl and in -lintl on SCO Unix. -AC_CHECK_LIB(gen, regcmp) -AC_CHECK_LIB(intl, regcmp) -AC_CHECK_LIB(PW, regcmp) - -dnl Solaris has curses & termcap, but they don't work without libucb -dnl which is broken, so we use termlib. -AC_MSG_CHECKING(for working terminal libraries) -SAVE_LIBS=$LIBS -LIBS="$LIBS $TERMLIBS" -AC_TRY_LINK(, [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);], - [termok=yes], [termok=no]) -if test $termok = yes; then - AC_MSG_RESULT(using $TERMLIBS) -else - LIBS="$SAVE_LIBS" - if test $have_termlib = yes; then - LIBS="$LIBS -ltermlib" - AC_MSG_RESULT(using -ltermlib) - else - AC_MSG_RESULT(TERMINAL LIBRARY BROKEN - configure failed) - exit 1 - fi -fi - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(ctype.h errno.h fcntl.h stdio.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h) - -dnl Checks for identifiers. -AC_TYPE_OFF_T -AC_MSG_CHECKING(for void) -AC_TRY_COMPILE(, [void *foo = 0;], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for time_t) -AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)]) - -dnl Checks for functions and external variables. -AC_TYPE_SIGNAL -AC_CHECK_FUNCS(_setjmp system sigsetmask memcpy strchr) -dnl Some systems have termios.h but not the corresponding functions. -AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS)) -AC_MSG_CHECKING(for fileno) -AC_TRY_LINK([ -#if HAVE_STDIO_H -#include <stdio.h> -#endif], [static int x; x = fileno(stdin);], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for strerror) -AC_TRY_LINK([ -#if HAVE_STDIO_H -#include <stdio.h> -#endif -#if HAVE_STRING_H -#include <string.h> -#endif -#if HAVE_ERRNO_H -#include <errno.h> -#endif], [static char *x; x = strerror(0);], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for sys_errlist) -AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for errno) -AC_TRY_LINK(, [extern int errno; static int x; x = errno;], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ERRNO)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for locale) -AC_TRY_LINK([#include <locale.h> -#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for ctype functions) -AC_TRY_LINK([ -#if HAVE_CTYPE_H -#include <ctype.h> -#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)]) - -dnl Checks for external variable ospeed in the termcap library. -have_ospeed=no -AC_MSG_CHECKING(termcap for ospeed) -AC_TRY_LINK([ -#include <sys/types.h> -#if HAVE_TERMIOS_H -#include <termios.h> -#endif -#if HAVE_TERMCAP_H -#include <termcap.h> -#endif], [ospeed = 0;], -[AC_MSG_RESULT(yes); 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); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)], - [AC_MSG_RESULT(no)]) -fi - -dnl Checks for regular expression functions. -have_regex=no -have_posix_regex=unknown -AC_CHECKING(for regular expression library) -dnl Some versions of Solaris have a regcomp() function, but it doesn't work! -dnl So we run a test program. If we're cross-compiling, do it the old way. -AC_TRY_RUN([ -#include <sys/types.h> -#include <regex.h> -main() { regex_t r; regmatch_t rm; -if (regcomp(&r, "abc", 0)) exit(1); -if (regexec(&r, "xabcy", 1, &rm, 0)) exit(1); -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) -fi -if test $have_regex = no; then -AC_CHECK_FUNC(regcmp, -AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes) -fi -if test $have_regex = no; then -AC_TRY_LINK([ -#include "regexp.h"], [regcomp("");], -AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes) -fi -if test $have_regex = no && test -f ${srcdir}/regex.c; then -AC_MSG_RESULT(using POSIX regcomp -- local source); AC_DEFINE(HAVE_POSIX_REGCOMP) REGEX_O='regex.$(O)' AC_SUBST(REGEX_O) have_regex=yes -fi -if test $have_regex = no && test -f ${srcdir}/regexp.c; then -AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes -fi -if test $have_regex = no; then -AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes) -fi -if test $have_regex = no; then -AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX) -fi - -AC_OUTPUT(Makefile) diff --git a/usr.bin/less/decode.c b/usr.bin/less/decode.c index 07d4fd2b6e3..1737327855f 100644 --- a/usr.bin/less/decode.c +++ b/usr.bin/less/decode.c @@ -1,29 +1,11 @@ -/* $OpenBSD: decode.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -53,24 +35,30 @@ #include "lesskey.h" extern int erase_char, kill_char; +extern int secure; +#define SK(k) \ + SK_SPECIAL_KEY, (k), 6, 1, 1, 1 /* * Command table is ordered roughly according to expected * frequency of use, so the common commands are near the beginning. */ + static unsigned char cmdtable[] = { '\r',0, A_F_LINE, '\n',0, A_F_LINE, 'e',0, A_F_LINE, 'j',0, A_F_LINE, + SK(SK_DOWN_ARROW),0, A_F_LINE, CONTROL('E'),0, A_F_LINE, CONTROL('N'),0, A_F_LINE, 'k',0, A_B_LINE, 'y',0, A_B_LINE, CONTROL('Y'),0, A_B_LINE, - CONTROL('K'),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, @@ -82,11 +70,14 @@ static unsigned char cmdtable[] = 'f',0, A_F_SCREEN, CONTROL('F'),0, A_F_SCREEN, CONTROL('V'),0, A_F_SCREEN, + SK(SK_PAGE_DOWN),0, A_F_SCREEN, 'b',0, A_B_SCREEN, CONTROL('B'),0, A_B_SCREEN, ESC,'v',0, A_B_SCREEN, + SK(SK_PAGE_UP),0, A_B_SCREEN, 'z',0, A_F_WINDOW, 'w',0, A_B_WINDOW, + ESC,' ',0, A_FF_SCREEN, 'F',0, A_F_FOREVER, 'R',0, A_FREPAINT, 'r',0, A_REPAINT, @@ -94,10 +85,17 @@ static unsigned char cmdtable[] = 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, @@ -109,6 +107,7 @@ static unsigned char cmdtable[] = '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, @@ -141,7 +140,10 @@ static unsigned char cmdtable[] = 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, @@ -153,8 +155,10 @@ static unsigned char cmdtable[] = '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 @@ -162,24 +166,40 @@ static unsigned char cmdtable[] = static unsigned char edittable[] = { - '\t',0, EC_F_COMPLETE, /* TAB */ - '\17',0, EC_B_COMPLETE, /* BACKTAB */ - '\14',0, EC_EXPAND, /* CTRL-L */ - CONTROL('V'),0, EC_LITERAL, /* BACKSLASH */ - CONTROL('A'),0, EC_LITERAL, /* BACKSLASH */ - ESC,'l',0, EC_RIGHT, /* ESC l */ - ESC,'h',0, EC_LEFT, /* ESC h */ - ESC,'b',0, EC_W_LEFT, /* ESC b */ - ESC,'w',0, EC_W_RIGHT, /* ESC w */ - ESC,'i',0, EC_INSERT, /* ESC i */ - ESC,'x',0, EC_DELETE, /* ESC x */ - ESC,'X',0, EC_W_DELETE, /* ESC X */ - ESC,'\b',0, EC_W_BACKSPACE, /* ESC BACKSPACE */ - ESC,'0',0, EC_HOME, /* ESC 0 */ - ESC,'$',0, EC_END, /* ESC $ */ - ESC,'k',0, EC_UP, /* ESC k */ - ESC,'j',0, EC_DOWN, /* ESC j */ - ESC,'\t',0, EC_B_COMPLETE /* ESC TAB */ + '\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 */ }; /* @@ -197,9 +217,72 @@ struct tablelist */ static struct tablelist *list_fcmd_tables = NULL; static struct tablelist *list_ecmd_tables = NULL; +static struct tablelist *list_var_tables = NULL; +static struct tablelist *list_sysvar_tables = NULL; /* + * Expand special key abbreviations in a command table. + */ + static void +expand_special_keys(table, len) + char *table; + int len; +{ + register char *fm; + register char *to; + register int a; + char *repl; + int klen; + + for (fm = table; fm < table + len; ) + { + /* + * Rewrite each command in the table with any + * special key abbreviations expanded. + */ + for (to = fm; *fm != '\0'; ) + { + if (*fm != SK_SPECIAL_KEY) + { + *to++ = *fm++; + continue; + } + /* + * After SK_SPECIAL_KEY, next byte is the type + * of special key (one of the SK_* contants), + * and the byte after that is the number of bytes, + * N, reserved by the abbreviation (including the + * SK_SPECIAL_KEY and key type bytes). + * Replace all N bytes with the actual bytes + * output by the special key on this terminal. + */ + repl = special_key_str(fm[1]); + klen = fm[2] & 0377; + fm += klen; + if (repl == NULL || (int) strlen(repl) > klen) + repl = "\377"; + while (*repl != '\0') + *to++ = *repl++; + } + *to++ = '\0'; + /* + * Fill any unused bytes between end of command and + * the action byte with A_SKIP. + */ + while (to <= fm) + *to++ = A_SKIP; + fm++; + a = *fm++ & 0377; + if (a & A_EXTRA) + { + while (*fm++ != '\0') + continue; + } + } +} + +/* * Initialize the command lists. */ public void @@ -210,17 +293,27 @@ init_cmds() */ add_fcmd_table((char*)cmdtable, sizeof(cmdtable)); add_ecmd_table((char*)edittable, sizeof(edittable)); - get_editkeys(); #if USERFILE /* + * For backwards compatibility, + * try to add tables in the OLD system lesskey file. + */ +#ifdef BINDIR + add_hometable(NULL, BINDIR "/.sysless", 1); +#endif + /* + * Try to add the tables in the system lesskey file. + */ + add_hometable("LESSKEY_SYSTEM", LESSKEYFILE_SYS, 1); + /* * Try to add the tables in the standard lesskey file "$HOME/.less". */ - add_hometable(); + add_hometable("LESSKEY", LESSKEYFILE, 0); #endif } /* - * + * Add a command table. */ static int add_cmd_table(tlist, buf, len) @@ -228,7 +321,7 @@ add_cmd_table(tlist, buf, len) char *buf; int len; { - struct tablelist *t; + register struct tablelist *t; if (len == 0) return (0); @@ -241,6 +334,7 @@ add_cmd_table(tlist, buf, len) { return (-1); } + expand_special_keys(buf, len); t->t_start = buf; t->t_end = buf + len; t->t_next = *tlist; @@ -273,19 +367,33 @@ 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; +{ + if (add_cmd_table(tlist, buf, len) < 0) + error("Warning: environment variables from lesskey file unavailable", NULL_PARG); +} + +/* * Search a single command table for the command string in cmd. */ - public int + static int cmd_search(cmd, table, endtable, sp) char *cmd; char *table; char *endtable; char **sp; { - char *p; - char *q; - int a; + register char *p; + register char *q; + register int a; + *sp = NULL; for (p = table, q = cmd; p < endtable; p++, q++) { if (*p == *q) @@ -300,6 +408,8 @@ cmd_search(cmd, table, endtable, sp) if (*p == '\0') { a = *++p & 0377; + while (a == A_SKIP) + a = *++p & 0377; if (a == A_END_LIST) { /* @@ -317,8 +427,7 @@ cmd_search(cmd, table, endtable, sp) { *sp = ++p; a &= ~A_EXTRA; - } else - *sp = NULL; + } return (a); } } else if (*q == '\0') @@ -345,9 +454,13 @@ cmd_search(cmd, table, endtable, sp) */ return (A_UINVALID); } - while (*p++ != '\0') ; + while (*p++ != '\0') + continue; + while (*p == A_SKIP) + p++; if (*p & A_EXTRA) - while (*++p != '\0') ; + while (*++p != '\0') + continue; q = cmd-1; } } @@ -367,8 +480,8 @@ cmd_decode(tlist, cmd, sp) char *cmd; char **sp; { - struct tablelist *t; - int action = A_INVALID; + register struct tablelist *t; + register int action = A_INVALID; /* * Search thru all the command tables. @@ -380,6 +493,8 @@ cmd_decode(tlist, cmd, sp) if (action != A_INVALID) break; } + if (action == A_UINVALID) + action = A_INVALID; return (action); } @@ -405,7 +520,35 @@ ecmd_decode(cmd, sp) return (cmd_decode(list_ecmd_tables, cmd, sp)); } +/* + * Get the value of an environment variable. + * Looks first in the lesskey file, then in the real environment. + */ + public char * +lgetenv(var) + char *var; +{ + int a; + char *s; + + a = cmd_decode(list_var_tables, var, &s); + if (a == EV_OK) + return (s); + s = getenv(var); + if (s != NULL && *s != '\0') + return (s); + a = cmd_decode(list_sysvar_tables, var, &s); + if (a == EV_OK) + return (s); + return (NULL); +} + #if USERFILE +/* + * Get an "integer" from a lesskey file. + * Integers are stored in a funny format: + * two bytes, low order first, in radix KRADIX. + */ static int gint(sp) char **sp; @@ -417,6 +560,9 @@ gint(sp) return (n); } +/* + * Process an old (pre-v241) lesskey file. + */ static int old_lesskey(buf, len) char *buf; @@ -435,15 +581,18 @@ old_lesskey(buf, len) return (0); } +/* + * Process a new (post-v241) lesskey file. + */ static int -new_lesskey(buf, len) +new_lesskey(buf, len, sysvar) char *buf; int len; + int sysvar; { char *p; - int c; - int done; - int n; + register int c; + register int n; /* * New-style lesskey file. @@ -454,8 +603,7 @@ new_lesskey(buf, len) buf[len-1] != C2_END_LESSKEY_MAGIC) return (-1); p = buf + 4; - done = 0; - while (!done) + for (;;) { c = *p++; switch (c) @@ -470,33 +618,44 @@ new_lesskey(buf, len) add_ecmd_table(p, n); p += n; break; - case END_SECTION: - done = 1; + case VAR_SECTION: + n = gint(&p); + add_var_table((sysvar) ? + &list_sysvar_tables : &list_var_tables, p, n); + p += n; break; + case END_SECTION: + return (0); default: - free(buf); + /* + * Unrecognized section type. + */ return (-1); } } - return (0); } /* * Set up a user command table, based on a "lesskey" file. */ public int -lesskey(filename) +lesskey(filename, sysvar) char *filename; + int sysvar; { - char *buf; - POSITION len; - long n; - int f; + register char *buf; + register POSITION len; + register long n; + register int f; + if (secure) + return (1); /* * Try to open the lesskey file. */ + filename = shell_unquote(filename); f = open(filename, OPEN_READ); + free(filename); if (f < 0) return (1); @@ -543,22 +702,30 @@ lesskey(filename) if (buf[0] != C0_LESSKEY_MAGIC || buf[1] != C1_LESSKEY_MAGIC || buf[2] != C2_LESSKEY_MAGIC || buf[3] != C3_LESSKEY_MAGIC) return (old_lesskey(buf, (int)len)); - return (new_lesskey(buf, (int)len)); + return (new_lesskey(buf, (int)len, sysvar)); } /* * Add the standard lesskey file "$HOME/.less" */ public void -add_hometable() +add_hometable(envname, def_filename, sysvar) + char *envname; + char *def_filename; + int sysvar; { char *filename; PARG parg; - filename = homefile(LESSKEYFILE); + if (envname != NULL && (filename = lgetenv(envname)) != NULL) + filename = save(filename); + else if (sysvar) + filename = save(def_filename); + else + filename = homefile(def_filename); if (filename == NULL) return; - if (lesskey(filename) < 0) + if (lesskey(filename, sysvar) < 0) { parg.p_string = filename; error("Cannot use lesskey file \"%s\"", &parg); @@ -606,6 +773,17 @@ editchar(c, flags) action = ecmd_decode(usercmd, &s); } while (action == A_PREFIX); + if (flags & EC_NORIGHTLEFT) + { + switch (action) + { + case EC_RIGHT: + case EC_LEFT: + action = A_INVALID; + break; + } + } +#if CMD_HISTORY if (flags & EC_NOHISTORY) { /* @@ -620,6 +798,8 @@ editchar(c, flags) break; } } +#endif +#if TAB_COMPLETE_FILENAME if (flags & EC_NOCOMPLETE) { /* @@ -635,6 +815,7 @@ editchar(c, flags) break; } } +#endif if ((flags & EC_PEEK) || action == A_INVALID) { /* @@ -643,7 +824,8 @@ editchar(c, flags) * This does NOT include the original character that was * passed in as a parameter. */ - while (nch > 1) { + while (nch > 1) + { ungetcc(usercmd[--nch]); } } else diff --git a/usr.bin/less/defines.dos b/usr.bin/less/defines.dos deleted file mode 100644 index be5d01edaca..00000000000 --- a/usr.bin/less/defines.dos +++ /dev/null @@ -1,281 +0,0 @@ -/* $OpenBSD: defines.dos,v 1.2 2001/01/29 01:58:01 niklas Exp $ */ - -/* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* DOS definition file for less. */ -/* - * This file has 2 sections: - * User preferences. - * Settings always true for the Microsoft C compiler 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. - */ -#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 0 - -/* - * 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). - * DEF_LESSKEYINFILE is the filename of the default lesskey input - * (in the HOME directory). - */ -#define LESSKEYFILE "_less" -#define DEF_LESSKEYINFILE "_lesskey" - -/* - * HELPFILE is the full pathname of the help file. - */ -#define HELPFILE "less.hlp" - -/* Settings always true for the Microsoft C compiler for MS-DOS systems. */ - -/* - * Define MSOFTC if compiling under Microsoft C. - */ -#define MSOFTC 1 - -/* - * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>. - */ -#define HAVE_SYS_TYPES_H 1 - -/* - * HAVE_STAT is 1 if your system has the stat() call. - */ -#define HAVE_STAT 1 - -/* - * 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 - -/* Define to `long' if <sys/types.h> doesn't define. */ -/* #define off_t long */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 -#define __STDC__ 1 - -/* - * 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 */ -#define NO_REGEX 1 - -/* Define HAVE_VOID if your compiler supports the "void" type. */ -#define HAVE_VOID 1 - -/* Define HAVE_TIME_T if your system supports the "time_t" type. */ -#define HAVE_TIME_T 0 - -/* Define HAVE_STRERROR if you have the strerror() function. */ -#define HAVE_STRERROR 0 - -/* Define HAVE_FILENO if you have the fileno() macro. */ -#define HAVE_FILENO 0 - -/* Define HAVE_ERRNO if you have the errno variable */ -#define HAVE_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 HAVE_OSPEED 0 -/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined - * in termcap.h. */ -#define MUST_DEFINE_OSPEED 0 - -/* Define HAVE_LOCALE if you have locale.h and setlocale. */ -#define HAVE_LOCALE 0 - -/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */ -#define HAVE_TERMIOS_FUNCS 0 - -/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */ -#define HAVE_UPPER_LOWER 1 - -/* Define if you have the _setjmp function. */ -#define HAVE__SETJMP 0 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 0 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the system function. */ -#define HAVE_SYSTEM 1 - -/* Define if you have the <ctype.h> header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the <errno.h> header file. */ -#define HAVE_ERRNO_H 0 - -/* Define if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the <stdio.h> header file. */ -#define HAVE_STDIO_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. */ -/* #undef HAVE_TERMCAP_H */ - -/* 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 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.h.top b/usr.bin/less/defines.h.top deleted file mode 100644 index 56d6e1a5589..00000000000 --- a/usr.bin/less/defines.h.top +++ /dev/null @@ -1,145 +0,0 @@ -/* $OpenBSD: defines.h.top,v 1.2 2001/01/29 01:58:01 niklas Exp $ */ - -/* 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) -#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). - * DEF_LESSKEYINFILE is the filename of the default lesskey input - * (in the HOME directory). - */ -#define LESSKEYFILE ".less" -#define DEF_LESSKEYINFILE ".lesskey" - - -/* Settings always true on Unix. */ - -/* - * Define MSOFTC if compiling under Microsoft C. - */ -#define MSOFTC 0 - -/* - * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>. - */ -#define HAVE_SYS_TYPES_H 1 - -/* - * HAVE_STAT is 1 if your system has the stat() call. - */ -#define HAVE_STAT 1 - -/* - * 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 - -/* Settings automatically determined by configure. */ diff --git a/usr.bin/less/defines.os2 b/usr.bin/less/defines.os2 deleted file mode 100644 index 253b5524246..00000000000 --- a/usr.bin/less/defines.os2 +++ /dev/null @@ -1,277 +0,0 @@ -/* $OpenBSD: defines.os2,v 1.2 2001/01/29 01:58:01 niklas Exp $ */ - -/* - * Copyright (c) 1984,1985,1989,1994 Mark Nudelman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* OS/2 definition file for less. */ -/* - * This file has 2 sections: - * User preferences. - * Settings always true for the emx compiler for OS/2 systems. - */ - - -/* User preferences. */ - -/* - * SECURE is 1 if you wish to disable a bunch of features in order to - * be safe to run by unprivileged users. - */ -#define SECURE 0 - -/* - * SHELL_ESCAPE is 1 if you wish to allow shell escapes. - * (This is possible only if your system supplies the system() function.) - */ -#define SHELL_ESCAPE (!SECURE) - -/* - * EXAMINE is 1 if you wish to allow examining files by name from within less. - */ -#define EXAMINE (!SECURE) - -/* - * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key - * to complete filenames at prompts. - */ -#define TAB_COMPLETE_FILENAME (!SECURE) - -/* - * CMD_HISTORY is 1 if you wish to allow keys to cycle through - * previous commands at prompts. - */ -#define CMD_HISTORY 1 - -/* - * HILITE_SEARCH is 1 if you wish to have search targets to be - * displayed in standout mode. - */ -#define HILITE_SEARCH 1 - -/* - * EDITOR is 1 if you wish to allow editor invocation (the "v" command). - * (This is possible only if your system supplies the system() function.) - * EDIT_PGM is the name of the (default) editor to be invoked. - */ -#define EDITOR (!SECURE) -#define EDIT_PGM "me" - -/* - * TAGS is 1 if you wish to support tag files. - */ -#define TAGS (!SECURE) - -/* - * USERFILE is 1 if you wish to allow a .less file to specify - * user-defined key bindings. - */ -#define USERFILE (!SECURE) - -/* - * GLOB is 1 if you wish to have shell metacharacters expanded in filenames. - * This will generally work if your system provides the "popen" function - * and the "echo" shell command. - */ -#define GLOB (!SECURE) - -/* - * PIPEC is 1 if you wish to have the "|" command - * which allows the user to pipe data into a shell command. - */ -#define PIPEC (!SECURE) - -/* - * LOGFILE is 1 if you wish to allow the -l option (to create log files). - */ -#define LOGFILE (!SECURE) - -/* - * GNU_OPTIONS is 1 if you wish to support the GNU-style command - * line options --help and --version. - */ -#define GNU_OPTIONS 1 - -/* - * ONLY_RETURN is 1 if you want RETURN to be the only input which - * will continue past an error message. - * Otherwise, any key will continue past an error message. - */ -#define ONLY_RETURN 0 - -/* - * LESSKEYFILE is the filename of the default lesskey output file - * (in the HOME directory). - * DEF_LESSKEYINFILE is the filename of the default lesskey input - * (in the HOME directory). - */ -#define LESSKEYFILE "less.ini" -#define DEF_LESSKEYINFILE "lesskey.ini" - - -/* - * HELPFILE is the full pathname of the help file. - */ -#define HELPFILE "less.hlp" - -/* Settings always true for the emx compiler for OS/2 systems. */ -#define OS2 1 - -/* - * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>. - */ -#define HAVE_SYS_TYPES_H 1 - -/* - * HAVE_STAT is 1 if your system has the stat() call. - */ -#define HAVE_STAT 1 - -/* - * 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 - -/* Define to `long' if <sys/types.h> doesn't define. */ -/* #define off_t long */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* - * 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_VOID if your compiler supports the "void" type. */ -#define HAVE_VOID 1 - -/* Define HAVE_TIME_T if your system supports the "time_t" type. */ -#define HAVE_TIME_T 0 - -/* Define HAVE_STRERROR if you have the strerror() function. */ -#define HAVE_STRERROR 1 - -/* Define HAVE_FILENO if you have the fileno() macro. */ -#define HAVE_FILENO 1 - -/* Define HAVE_ERRNO if you have the errno variable */ -#define HAVE_ERRNO 1 - -/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */ -#define HAVE_SYS_ERRLIST 1 - -/* Define HAVE_OSPEED if your termcap library has the ospeed variable */ -#define HAVE_OSPEED 0 -/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined - * in termcap.h. */ -#define MUST_DEFINE_OSPEED 0 - -/* Define HAVE_LOCALE if you have locale.h and setlocale. */ -#define HAVE_LOCALE 0 - -/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */ -#define HAVE_TERMIOS_FUNCS 0 - -/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */ -#define HAVE_UPPER_LOWER 1 - -/* Define if you have the _setjmp function. */ -#define HAVE__SETJMP 0 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 0 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the system function. */ -#define HAVE_SYSTEM 1 - -/* Define if you have the <ctype.h> header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the <errno.h> header file. */ -#define HAVE_ERRNO_H 0 - -/* Define if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the <stdio.h> header file. */ -#define HAVE_STDIO_H 1 - -/* Define if you have the <sys/ioctl.h> header file. */ -#define HAVE_SYS_IOCTL_H 0 - -/* Define if you have the <sys/ptem.h> header file. */ -#define HAVE_SYS_PTEM_H 0 - -/* Define if you have the <sys/stream.h> header file. */ -#define HAVE_SYS_STREAM_H 0 - -/* Define if you have the <termcap.h> header file. */ -#define HAVE_TERMCAP_H 0 - -/* Define if you have the <termio.h> header file. */ -#define HAVE_TERMIO_H 0 - -/* Define if you have the <termios.h> header file. */ -#define HAVE_TERMIOS_H 0 - -/* Define if you have the <time.h> header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the <values.h> header file. */ -#define HAVE_VALUES_H 0 diff --git a/usr.bin/less/doscreen.c b/usr.bin/less/doscreen.c deleted file mode 100644 index 9281f0a8710..00000000000 --- a/usr.bin/less/doscreen.c +++ /dev/null @@ -1,573 +0,0 @@ -/* $OpenBSD: doscreen.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - -/* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * Routines which deal with the characteristics of the terminal. - * - * This file is specific to MS-DOS and uses Microsoft C graphics functions. - */ - -#include "less.h" -#include "cmd.h" - -#include <graph.h> -#include <time.h> - -static int init_done = 0; -static int videopages; -static long msec_loops; - -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, kill_char; /* The user's erase and line-kill chars */ -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 nm_fg_color = 7; /* Color of normal text */ -public int nm_bg_color = 0; -public int bo_fg_color = 15; /* Color of bold text */ -public int bo_bg_color = 0; -public int ul_fg_color = 9; /* Color of underlined text */ -public int ul_bg_color = 0; -public int so_fg_color = 0; /* Color of standout text */ -public int so_bg_color = 7; -public int bl_fg_color = 12; /* Color of blinking text */ -public int bl_bg_color = 0; - -static int sy_fg_color; -static int sy_bg_color; -static int flash_created = 0; - -extern int quiet; /* If VERY_QUIET, use visual bell for bell */ -extern int know_dumb; /* Don't complain about a dumb terminal */ -extern int back_scroll; -extern int swindow; -extern char *getenv(); - -/* - * Change terminal to "raw mode", or restore to "normal" mode. - * "Raw mode" means - * 1. An outstanding read will complete on receipt of a single keystroke. - * 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; -{ - static int curr_on = 0; - - if (on == curr_on) - return; - erase_char = CONTROL('h'); - kill_char = '\33'; /* ESC */ - curr_on = on; -} - -/* - * Get size of the output screen. - */ - public void -scrsize(p_height, p_width) - int *p_height; - int *p_width; -{ - char *s; - struct videoconfig w; - - _getvideoconfig(&w); - - if (w.numtextrows) - *p_height = w.numtextrows; - else if ((s = getenv("LINES")) != NULL && *s != '\0') - *p_height = atoi(s); - if (*p_height <= 0) - *p_height = 24; - - if (w.numtextcols > 0) - *p_width = w.numtextcols; - else if ((s = getenv("COLUMNS")) != NULL) - *p_width = atoi(s); - if (*p_width <= 0) - *p_width = 80; -} - -/* - * 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; -} - - public void -get_editkeys() -{ -} - -/* - * Get terminal capabilities via termcap. - */ - public void -get_term() -{ - scrsize(&sc_height, &sc_width); - pos_init(); - auto_wrap = 1; - ignaw = 0; - so_e_width = so_s_width = 0; - bo_s_width = bo_e_width = 0; - ul_s_width = ul_e_width = 0; - bl_s_width = bl_e_width = 0; - get_clock(); -} - - -/* - * Below are the functions which perform all the - * terminal-specific screen manipulation. - */ - - -/* - * Initialize terminal - */ - public void -init() -{ - /* {{ What could we take no_init (-X) to mean? }} */ - sy_bg_color = _getbkcolor(); - sy_fg_color = _gettextcolor(); - flush(); - init_done = 1; -} - -/* - * 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() -{ - struct videoconfig w; - char *blanks; - int row, col; - - _getvideoconfig(&w); - videopages = w.numvideopages; - if (videopages < 2) - { - so_enter(); - so_exit(); - } else - { - _setactivepage(1); - so_enter(); - 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); - so_exit(); - } - flash_created = 1; -} - -/* - * Deinitialize terminal - */ - public void -deinit() -{ - if (!init_done) - return; - _setbkcolor(sy_bg_color); - _settextcolor(sy_fg_color); - putstr("\n"); - init_done = 0; -} - -/* - * Home cursor (move to upper left corner of screen). - */ - public void -home() -{ - flush(); - _settextposition(1,1); -} - -/* - * Add a blank line (called with cursor at home). - * Should scroll the display down. - */ - public void -add_line() -{ - flush(); - _scrolltextwindow(_GSCROLLDOWN); - _settextposition(1,1); -} - -/* - * Move cursor to lower left corner of screen. - */ - public void -lower_left() -{ - flush(); - _settextposition(sc_height,1); -} - -/* - * 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(); - } - } -} - -/* - * Make a noise. - */ - static void -beep() -{ - write(1, "\7", 1); -} - -/* - * Output the "visual bell", if there is one. - */ - public void -vbell() -{ - if (!flash_created) - /* - * Create a "flash" on the second video page. - */ - create_flash(); - if (videopages < 2) - /* - * There is no "second video page". - */ - return; - _setvisualpage(1); - /* - * Leave it displayed for 100 msec. - */ - delay(100); - _setvisualpage(0); -} - -/* - * Ring the terminal bell. - */ - public void -bell() -{ - if (quiet == VERY_QUIET) - vbell(); - else - beep(); -} - -/* - * Clear the screen. - */ - public void -clear() -{ - flush(); - _clearscreen(_GCLEARSCREEN); -} - -/* - * Clear from the cursor to the end of the cursor's line. - * {{ This must not move the cursor. }} - */ - public void -clear_eol() -{ - 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); -} - -/* - * Clear the bottom line of the display. - * Leave the cursor at the beginning of the bottom line. - */ - public void -clear_bot() -{ - lower_left(); - clear_eol(); -} - -/* - * Begin "standout" (bold, underline, or whatever). - */ - public void -so_enter() -{ - flush(); - _setbkcolor(so_bg_color); - _settextcolor(so_fg_color); -} - -/* - * End "standout". - */ - public void -so_exit() -{ - flush(); - _setbkcolor(nm_bg_color); - _settextcolor(nm_fg_color); -} - -/* - * Begin "underline" (hopefully real underlining, - * otherwise whatever the terminal provides). - */ - public void -ul_enter() -{ - flush(); - _setbkcolor(ul_bg_color); - _settextcolor(ul_fg_color); -} - -/* - * End "underline". - */ - public void -ul_exit() -{ - flush(); - _setbkcolor(nm_bg_color); - _settextcolor(nm_fg_color); -} - -/* - * Begin "bold" - */ - public void -bo_enter() -{ - flush(); - _setbkcolor(bo_bg_color); - _settextcolor(bo_fg_color); -} - -/* - * End "bold". - */ - public void -bo_exit() -{ - flush(); - _setbkcolor(nm_bg_color); - _settextcolor(nm_fg_color); -} - -/* - * Begin "blink" - */ - public void -bl_enter() -{ - flush(); - _setbkcolor(bl_bg_color); - _settextcolor(bl_fg_color); -} - -/* - * End "blink". - */ - public void -bl_exit() -{ - flush(); - _setbkcolor(nm_bg_color); - _settextcolor(nm_fg_color); -} - -/* - * Erase the character to the left of the cursor - * and move the cursor left. - */ - public void -backspace() -{ - struct rccoord tpos; - - /* - * Erase the previous character by overstriking with a space. - */ - flush(); - tpos = _gettextposition(); - if (tpos.col <= 1) - return; - _settextposition(tpos.row, tpos.col-1); - _outtext(" "); - _settextposition(tpos.row, tpos.col-1); -} - -/* - * Output a plain backspace, without erasing the previous char. - */ - public void -putbs() -{ - struct rccoord tpos; - - flush(); - tpos = _gettextposition(); - if (tpos.col <= 1) - return; - _settextposition(tpos.row, tpos.col-1); -} - -/* - * Table of line editting characters, for editchar() in decode.c. - */ -char edittable[] = { - '\340','\115',0, EC_RIGHT, /* RIGHTARROW */ - '\340','\113',0, EC_LEFT, /* LEFTARROW */ - '\340','\163',0, EC_W_LEFT, /* CTRL-LEFTARROW */ - '\340','\164',0, EC_W_RIGHT, /* CTRL-RIGHTARROW */ - '\340','\122',0, EC_INSERT, /* INSERT */ - '\340','\123',0, EC_DELETE, /* DELETE */ - '\340','\223',0, EC_W_DELETE, /* CTRL-DELETE */ - '\177',0, EC_W_BACKSPACE, /* CTRL-BACKSPACE */ - '\340','\107',0, EC_HOME, /* HOME */ - '\340','\117',0, EC_END, /* END */ - '\340','\110',0, EC_UP, /* UPARROW */ - '\340','\120',0, EC_DOWN, /* DOWNARROW */ - '\t',0, EC_F_COMPLETE, /* TAB */ - '\17',0, EC_B_COMPLETE, /* BACKTAB (?) */ - '\340','\17',0, EC_B_COMPLETE, /* BACKTAB */ - '\14',0, EC_EXPAND, /* CTRL-L */ - 0 /* Extra byte to terminate; subtracted from size, below */ -}; - -int sz_edittable = sizeof(edittable) -1; - - -char kcmdtable[] = -{ - /* - * PC function keys. - * Note that '\0' is converted to '\340' on input. - */ - '\340','\120',0, A_F_LINE, /* down arrow */ - '\340','\121',0, A_F_SCREEN, /* page down */ - '\340','\110',0, A_B_LINE, /* up arrow */ - '\340','\111',0, A_B_SCREEN, /* page up */ - '\340','\107',0, A_GOLINE, /* home */ - '\340','\117',0, A_GOEND, /* end */ - '\340','\073',0, A_HELP, /* F1 */ - '\340','\022',0, A_EXAMINE, /* Alt-E */ - 0 -}; -int sz_kcmdtable = sizeof(kcmdtable) - 1; diff --git a/usr.bin/less/edit.c b/usr.bin/less/edit.c index 47e1f0bfbca..4873c1f212d 100644 --- a/usr.bin/less/edit.c +++ b/usr.bin/less/edit.c @@ -1,29 +1,11 @@ -/* $OpenBSD: edit.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -33,15 +15,20 @@ public int fd0 = 0; extern int new_file; extern int errmsgs; -extern int quit_at_eof; extern int cbufs; extern char *every_first_cmd; extern int any_display; extern int force_open; extern int is_tty; +extern int sigs; extern IFILE curr_ifile; extern IFILE old_ifile; extern struct scrpos initial_scrpos; +extern void constant *ml_examine; +#if SPACES_IN_FILENAMES +extern char openquote; +extern char closequote; +#endif #if LOGFILE extern int logfile; @@ -66,13 +53,41 @@ init_textlist(tlist, str) 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) + { + meta_quoted = 0; + } else if (esclen > 0 && s + esclen < tlist->endstring && + strncmp(s, esc, esclen) == 0) + { + meta_quoted = 1; + s += esclen - 1; + } else if (delim_quoted) + { + if (*s == closequote) + delim_quoted = 0; + } else /* (!delim_quoted) */ + { + if (*s == openquote) + delim_quoted = 1; + else if (*s == ' ') + *s = '\0'; + } +#else if (*s == ' ') *s = '\0'; +#endif } } @@ -136,6 +151,7 @@ close_file() if (curr_ifile == NULL_IFILE) return; + /* * Save the current position so that we can return to * the same position if we edit this file again. @@ -157,7 +173,7 @@ close_file() if (curr_altfilename != NULL) { close_altfile(curr_altfilename, get_filename(curr_ifile), - curr_altpipe); + curr_altpipe); free(curr_altfilename); curr_altfilename = NULL; } @@ -192,6 +208,7 @@ edit_ifile(ifile) int chflags; char *filename; char *open_filename; + char *qopen_filename; char *alt_filename; void *alt_pipe; IFILE was_curr_ifile; @@ -215,10 +232,19 @@ edit_ifile(ifile) #if LOGFILE end_logfile(); #endif - was_curr_ifile = curr_ifile; + was_curr_ifile = save_curr_ifile(); if (curr_ifile != NULL_IFILE) { + chflags = ch_getflags(); close_file(); + if ((chflags & CH_HELPFILE) && held_ifile(was_curr_ifile) <= 1) + { + /* + * Don't keep the help file in the ifile list. + */ + del_ifile(was_curr_ifile); + was_curr_ifile = old_ifile; + } } if (ifile == NULL_IFILE) @@ -229,16 +255,18 @@ edit_ifile(ifile) * you're supposed to have saved curr_ifile yourself, * and you'll restore it if necessary.) */ + unsave_ifile(was_curr_ifile); return (0); } - filename = get_filename(ifile); + filename = save(get_filename(ifile)); /* * See if LESSOPEN specifies an "alternate" file to open. */ alt_pipe = NULL; alt_filename = open_altfile(filename, &f, &alt_pipe); open_filename = (alt_filename != NULL) ? alt_filename : filename; + qopen_filename = shell_unquote(open_filename); chflags = 0; if (alt_pipe != NULL) @@ -259,6 +287,22 @@ edit_ifile(ifile) */ f = fd0; chflags |= CH_KEEPOPEN; + /* + * Must switch stdin to BINARY mode. + */ + SET_BINARY(f); +#if MSDOS_COMPILER==DJGPPC + /* + * Setting stdin to binary by default causes + * Ctrl-C to not raise SIGINT. We must undo + * that side-effect. + */ + __djgpp_set_ctrl_c(1); +#endif + } else if (strcmp(open_filename, FAKE_HELPFILE) == 0) + { + f = -1; + chflags |= CH_HELPFILE; } else if ((parg.p_string = bad_file(open_filename)) != NULL) { /* @@ -273,12 +317,14 @@ edit_ifile(ifile) free(alt_filename); } del_ifile(ifile); + free(qopen_filename); + free(filename); /* * Re-open the current file. */ - (void) edit_ifile(was_curr_ifile); + reedit_ifile(was_curr_ifile); return (1); - } else if ((f = open(open_filename, OPEN_READ)) < 0) + } else if ((f = open(qopen_filename, OPEN_READ)) < 0) { /* * Got an error trying to open it. @@ -287,27 +333,36 @@ edit_ifile(ifile) error("%s", &parg); free(parg.p_string); goto err1; - } else if (!force_open && !opened(ifile) && bin_file(f)) + } else { - /* - * 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') + chflags |= CH_CANSEEK; + if (!force_open && !opened(ifile) && bin_file(f)) { - close(f); - goto err1; + /* + * Looks like a binary file. + * Ask user if we should proceed. + */ + parg.p_string = filename; + answer = query("\"%s\" may be a binary file. See it anyway? ", + &parg); + if (answer != 'y' && answer != 'Y') + { + close(f); + goto err1; + } } } + free(qopen_filename); /* * Get the new ifile. * Get the saved position for the file. */ if (was_curr_ifile != NULL_IFILE) + { old_ifile = was_curr_ifile; + unsave_ifile(was_curr_ifile); + } curr_ifile = ifile; curr_altfilename = alt_filename; curr_altpipe = alt_pipe; @@ -315,13 +370,16 @@ edit_ifile(ifile) get_pos(curr_ifile, &initial_scrpos); new_file = TRUE; ch_init(f, chflags); + + if (!(chflags & CH_HELPFILE)) + { #if LOGFILE - if (namelogfile != NULL && is_tty) - use_logfile(namelogfile); + if (namelogfile != NULL && is_tty) + use_logfile(namelogfile); #endif - - if (every_first_cmd != NULL) - ungetsc(every_first_cmd); + if (every_first_cmd != NULL) + ungetsc(every_first_cmd); + } no_display = !any_display; flush(); @@ -341,6 +399,7 @@ edit_ifile(ifile) #if HILITE_SEARCH clr_hilite(); #endif + cmd_addhist(ml_examine, filename); if (no_display && errmsgs > 0) { /* @@ -353,6 +412,7 @@ edit_ifile(ifile) error("%s", &parg); } } + free(filename); return (0); } @@ -365,7 +425,7 @@ edit_ifile(ifile) edit_list(filelist) char *filelist; { - IFILE save_curr_ifile; + IFILE save_ifile; char *good_filename; char *filename; char *gfilelist; @@ -373,7 +433,7 @@ edit_list(filelist) struct textlist tl_files; struct textlist tl_gfiles; - save_curr_ifile = curr_ifile; + save_ifile = save_curr_ifile(); good_filename = NULL; /* @@ -386,7 +446,7 @@ edit_list(filelist) filename = NULL; while ((filename = forw_textlist(&tl_files, filename)) != NULL) { - gfilelist = glob(filename); + gfilelist = lglob(filename); init_textlist(&tl_gfiles, gfilelist); gfilename = NULL; while ((gfilename = forw_textlist(&tl_gfiles, gfilename)) != NULL) @@ -400,14 +460,19 @@ edit_list(filelist) * Edit the first valid filename in the list. */ if (good_filename == NULL) + { + unsave_ifile(save_ifile); return (1); + } if (get_ifile(good_filename, curr_ifile) == curr_ifile) + { /* * Trying to edit the current file; don't reopen it. */ + unsave_ifile(save_ifile); return (0); - if (edit_ifile(save_curr_ifile)) - quit(QUIT_ERROR); + } + reedit_ifile(save_ifile); return (edit(good_filename)); } @@ -433,22 +498,22 @@ edit_last() /* - * Edit the next file in the command line (ifile) list. + * Edit the next or previous file in the command line (ifile) list. */ - public int -edit_next(n) + static int +edit_istep(h, n, dir) + IFILE h; int n; + int dir; { - IFILE h; IFILE next; - h = curr_ifile; /* * Skip n filenames, then try to edit each filename. */ for (;;) { - next = next_ifile(h); + next = (dir > 0) ? next_ifile(h) : prev_ifile(h); if (--n < 0) { if (edit_ifile(h) == 0) @@ -461,6 +526,14 @@ edit_next(n) */ return (1); } + if (ABORT_SIGS()) + { + /* + * Interrupt breaks out, if we're in a long + * list of files that can't be opened. + */ + return (1); + } h = next; } /* @@ -469,41 +542,34 @@ edit_next(n) return (0); } -/* - * Edit the previous file in the command line list. - */ + static int +edit_inext(h, n) + IFILE h; + int n; +{ + return (edit_istep(h, n, 1)); +} + public int -edit_prev(n) +edit_next(n) int n; { + return edit_istep(curr_ifile, n, 1); +} + + static int +edit_iprev(h, n) IFILE h; - IFILE next; + int n; +{ + return (edit_istep(h, n, -1)); +} - h = curr_ifile; - /* - * Skip n filenames, then try to edit each filename. - */ - for (;;) - { - next = prev_ifile(h); - if (--n < 0) - { - if (edit_ifile(h) == 0) - break; - } - if (next == NULL_IFILE) - { - /* - * Reached beginning of the ifile list. - */ - return (1); - } - h = next; - } - /* - * Found a file that we can edit. - */ - return (0); + public int +edit_prev(n) + int n; +{ + return edit_istep(curr_ifile, n, -1); } /* @@ -530,6 +596,59 @@ edit_index(n) return (edit_ifile(h)); } + public IFILE +save_curr_ifile() +{ + if (curr_ifile != NULL_IFILE) + hold_ifile(curr_ifile, 1); + return (curr_ifile); +} + + public void +unsave_ifile(save_ifile) + IFILE save_ifile; +{ + if (save_ifile != NULL_IFILE) + hold_ifile(save_ifile, -1); +} + +/* + * Reedit the ifile which was previously open. + */ + public void +reedit_ifile(save_ifile) + IFILE save_ifile; +{ + IFILE next; + IFILE prev; + + /* + * Try to reopen the ifile. + * Note that opening it may fail (maybe the file was removed), + * in which case the ifile will be deleted from the list. + * So save the next and prev ifiles first. + */ + unsave_ifile(save_ifile); + next = next_ifile(save_ifile); + prev = prev_ifile(save_ifile); + if (edit_ifile(save_ifile) == 0) + return; + /* + * If can't reopen it, open the next input file in the list. + */ + if (next != NULL_IFILE && edit_inext(next, 0) == 0) + return; + /* + * If can't open THAT one, open the previous input file in the list. + */ + if (prev != NULL_IFILE && edit_iprev(prev, 0) == 0) + return; + /* + * If can't even open that, we're stuck. Just quit. + */ + quit(QUIT_ERROR); +} + /* * Edit standard input. */ @@ -538,11 +657,7 @@ edit_stdin() { if (isatty(fd0)) { -#if MSOFTC || OS2 - error("Missing filename (\"less -?\" for help)", NULL_PARG); -#else - error("Missing filename (\"less -\\?\" for help)", NULL_PARG); -#endif + error("Missing filename (\"less --help\" for help)", NULL_PARG); quit(QUIT_OK); } return (edit("-")); @@ -555,7 +670,7 @@ edit_stdin() public void cat_file() { - int c; + register int c; while ((c = ch_forw_get()) != EOI) putchr(c); @@ -573,8 +688,8 @@ cat_file() use_logfile(filename) char *filename; { - int exists; - int answer; + register int exists; + register int answer; PARG parg; if (ch_getflags() & CH_CANSEEK) @@ -586,6 +701,7 @@ use_logfile(filename) /* * {{ We could use access() here. }} */ + filename = shell_unquote(filename); exists = open(filename, OPEN_READ); close(exists); exists = (exists >= 0); @@ -633,6 +749,7 @@ loop: /* * Don't do anything. */ + free(filename); return; case 'q': quit(QUIT_OK); @@ -652,7 +769,11 @@ loop: */ parg.p_string = filename; error("Cannot write to \"%s\"", &parg); + free(filename); + return; } + free(filename); + SET_BINARY(logfile); } #endif diff --git a/usr.bin/less/filename.c b/usr.bin/less/filename.c index 27516514d3f..8f136a97265 100644 --- a/usr.bin/less/filename.c +++ b/usr.bin/less/filename.c @@ -1,29 +1,11 @@ -/* $OpenBSD: filename.c,v 1.7 2003/04/06 23:38:06 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -33,13 +15,205 @@ */ #include "less.h" -#if MSOFTC +#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 + extern int force_open; +extern int secure; +extern int use_lessopen; 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 *name; + char *p; + + name = p = (char *) ecalloc(strlen(str)+1, sizeof(char)); + if (*str == openquote) + { + str++; + while (*str != '\0') + { + if (*str == closequote) + { + if (str[1] != closequote) + break; + str++; + } + *p++ = *str++; + } + } else + { + char *esc = get_meta_escape(); + int esclen = strlen(esc); + while (*str != '\0') + { + if (esclen > 0 && strncmp(str, esc, esclen) == 0) + str += esclen; + *p++ = *str++; + } + } + *p = '\0'; + return (name); +} + +/* + * Get the shell's escape character. + */ + public char * +get_meta_escape() +{ + char *s; + + s = lgetenv("LESSMETAESCAPE"); + if (s == NULL) + s = DEF_METAESCAPE; + return (s); +} + +/* + * Get the characters which the shell considers to be "metacharacters". + */ + static char * +metachars() +{ + static char *mchars = NULL; + + if (mchars == NULL) + { + mchars = lgetenv("LESSMETACHARS"); + if (mchars == NULL) + mchars = DEF_METACHARS; + } + return (mchars); +} + +/* + * Is this a shell metacharacter? + */ + static int +metachar(c) + char c; +{ + return (strchr(metachars(), c) != NULL); +} + +/* + * Insert a backslash before each metacharacter in a string. + */ + public char * +shell_quote(s) + char *s; +{ + char *p; + char *newstr; + int len; + char *esc = get_meta_escape(); + int esclen = strlen(esc); + int use_quotes = 0; + int have_quotes = 0; + + /* + * Determine how big a string we need to allocate. + */ + len = 1; /* Trailing null byte */ + for (p = s; *p != '\0'; p++) + { + len++; + if (*p == openquote || *p == closequote) + have_quotes = 1; + if (metachar(*p)) + { + if (esclen == 0) + { + /* + * We've got a metachar, but this shell + * doesn't support escape chars. Use quotes. + */ + use_quotes = 1; + } else + { + /* + * Allow space for the escape char. + */ + len += esclen; + } + } + } + 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) + { + snprintf(newstr, len, "%c%s%c", openquote, s, closequote); + } else + { + while (*s != '\0') + { + if (metachar(*s)) + { + /* + * Add the escape char. + */ + strlcpy(p, esc, newstr + len - p); + p += esclen; + } + *p++ = *s++; + } + *p = '\0'; + } + return (newstr); +} /* * Return a pathname that points to a specified file in a specified directory. @@ -51,7 +225,9 @@ dirfile(dirname, filename) char *filename; { char *pathname; - int f, len; + char *qpathname; + int f; + size_t len; if (dirname == NULL || *dirname == '\0') return (NULL); @@ -62,23 +238,21 @@ dirfile(dirname, filename) pathname = (char *) calloc(len, sizeof(char)); if (pathname == NULL) return (NULL); -#if MSOFTC || OS2 - snprintf(pathname, len, "%s\\%s", dirname, filename); -#else - snprintf(pathname, len, "%s/%s", dirname, filename); -#endif + snprintf(pathname, len, "%s%s%s", dirname, PATHNAME_SEP, filename); /* * Make sure the file exists. */ - f = open(pathname, OPEN_READ); + qpathname = shell_unquote(pathname); + f = open(qpathname, OPEN_READ); if (f < 0) { free(pathname); pathname = NULL; } else { - close (f); + close(f); } + free(qpathname); return (pathname); } @@ -89,28 +263,38 @@ dirfile(dirname, filename) homefile(filename) char *filename; { - char *pathname; + register char *pathname; /* * Try $HOME/filename. */ - pathname = dirfile(getenv("HOME"), filename); + pathname = dirfile(lgetenv("HOME"), filename); if (pathname != NULL) return (pathname); #if OS2 /* * Try $INIT/filename. */ - pathname = dirfile(getenv("INIT"), filename); + pathname = dirfile(lgetenv("INIT"), filename); if (pathname != NULL) return (pathname); #endif -#if MSOFTC || OS2 +#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); @@ -119,34 +303,24 @@ homefile(filename) } /* - * Find out where the help file is. - */ - public char * -find_helpfile() -{ - char *helpfile; - - if ((helpfile = getenv("LESSHELP")) != NULL) - return (save(helpfile)); -#if MSOFTC || OS2 - return (homefile(HELPFILE)); -#else - return (save(HELPFILE)); -#endif -} - -/* * Expand a string, substituting any "%" with the current filename, * and any "#" with the previous filename. + * But a string of N "%"s is just replaced with N-1 "%"s. + * Likewise for a string of N "#"s. * {{ This is a lot of work just to support % and #. }} */ public char * fexpand(s) char *s; { - char *fr, *to; - int n; - char *e; + register char *fr, *to; + register int n; + register char *e; + IFILE ifile; + +#define fchar_ifile(c) \ + ((c) == '%' ? curr_ifile : \ + (c) == '#' ? old_ifile : NULL_IFILE) /* * Make one pass to see how big a buffer we @@ -158,20 +332,29 @@ fexpand(s) switch (*fr) { case '%': - if (curr_ifile == NULL_IFILE) - { - /* error("No current file", NULL_PARG); */ - return (save(s)); - } - n += strlen(get_filename(curr_ifile)); - break; case '#': - if (old_ifile == NULL_IFILE) + 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) { - /* error("No previous file", NULL_PARG); */ - return (save(s)); + /* + * Single char (not repeated). Treat specially. + */ + ifile = fchar_ifile(*fr); + if (ifile == NULL_IFILE) + n++; + else + n += strlen(get_filename(ifile)); } - n += strlen(get_filename(old_ifile)); + /* + * Else it is the first char in a string of + * identical chars. Just discard it. + */ break; default: n++; @@ -190,12 +373,22 @@ fexpand(s) switch (*fr) { case '%': - strlcpy(to, get_filename(curr_ifile), e + n + 1 - to); - to += strlen(to); - break; case '#': - strlcpy(to, get_filename(old_ifile), e + n + 1 - to); - to += strlen(to); + if (fr > s && fr[-1] == *fr) + { + *to++ = *fr; + } else if (fr[1] != *fr) + { + ifile = fchar_ifile(*fr); + if (ifile == NULL_IFILE) + *to++ = *fr; + else + { + strlcpy(to, get_filename(ifile), + e + n + 1 - to); + to += strlen(to); + } + } break; default: *to++ = *fr; @@ -217,12 +410,15 @@ fcomplete(s) char *s; { char *fpat; - size_t l; + char *qs; + size_t len; + if (secure) + return (NULL); /* * Complete the filename "s" by globbing "s*". */ -#if MSOFTC +#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 @@ -230,32 +426,36 @@ fcomplete(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 == '/' || *slash == '\\') - break; - l = strlen(s)+4; - fpat = (char *) ecalloc(l, sizeof(char)); - if (strchr(slash, '.') == NULL) - snprintf(fpat, l, "%s*.*", s); - else - snprintf(fpat, l, "%s*", s); + { + 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) + snprintf(fpat, len, "%s*.*", s); + else + snprintf(fpat, len, "%s*", s); + } #else - l = strlen(s)+2; - fpat = (char *) ecalloc(l, sizeof(char)); - snprintf(fpat, l, "%s*", s); + len = strlen(s) + 2; + fpat = (char *) ecalloc(len, sizeof(char)); + snprintf(fpat, len, "%s*", s); #endif - s = glob(fpat); + qs = lglob(fpat); + s = shell_unquote(qs); if (strcmp(s,fpat) == 0) { /* * The filename didn't expand. */ - free(s); - s = NULL; + free(qs); + qs = NULL; } + free(s); free(fpat); - return (s); + return (qs); } #endif @@ -297,10 +497,6 @@ seek_filesize(f) return ((POSITION) spos); } -#if GLOB - -FILE *popen(); - /* * Read a string from a file. * Return a pointer to the string in memory. @@ -344,103 +540,254 @@ readfd(fd) 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, s1, s2) +shellcmd(cmd) char *cmd; - char *s1; - char *s2; { - char *scmd; - char *scmd2; - char *shell; FILE *fd; - int len; - - len = strlen(cmd) + - (s1 == NULL ? 0 : strlen(s1)) + - (s2 == NULL ? 0 : strlen(s2)) + 1; - scmd = (char *) ecalloc(len, sizeof(char)); - snprintf(scmd, len, cmd, s1, s2); + size_t len; + #if HAVE_SHELL - shell = getenv("SHELL"); + char *shell; + + shell = lgetenv("SHELL"); 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. */ - len = strlen(shell) + strlen(scmd) + 7; - scmd2 = (char *) ecalloc(len, sizeof(char)); - snprintf(scmd2, len, "%s -c \"%s\"", shell, scmd); - free(scmd); - scmd = scmd2; - } + esccmd = shell_quote(cmd); + if (esccmd == NULL) + { + fd = popen(cmd, "r"); + } else + { + len = strlen(shell) + strlen(esccmd) + 5; + scmd = (char *) ecalloc(len, sizeof(char)); + snprintf(scmd, len, "%s %s %s", shell, shell_coption(), + esccmd); + free(esccmd); + fd = popen(scmd, "r"); + free(scmd); + } + } else #endif - fd = popen(scmd, "r"); - free(scmd); + { + fd = popen(cmd, "r"); + } + /* + * Redirection in `popen' might have messed with the + * standard devices. Restore binary input mode. + */ + SET_BINARY(0); return (fd); } +#endif /* HAVE_POPEN */ + + /* - * Expand a filename, doing any shell-level substitutions. + * Expand a filename, doing any system-specific metacharacter substitutions. */ public char * -glob(filename) +lglob(filename) char *filename; { char *gfilename; + char *ofilename; - filename = fexpand(filename); -#if OS2 + ofilename = fexpand(filename); + if (secure) + return (ofilename); + filename = shell_unquote(ofilename); + +#ifdef DECL_GLOB_LIST { - char **list; - int cnt; + /* + * The globbing function returns a list of names. + */ int length; + char *p; + char *qfilename; + DECL_GLOB_LIST(list) - list = _fnexplode(filename); - if (list == NULL) - return (filename); - length = 0; - for (cnt = 0; list[cnt] != NULL; cnt++) - length += strlen(list[cnt]) + 1; + GLOB_LIST(filename, list); + if (GLOB_LIST_FAILED(list)) + { + free(filename); + return (ofilename); + } + length = 1; /* Room for trailing null byte */ + for (SCAN_GLOB_LIST(list, p)) + { + INIT_GLOB_LIST(list, p); + qfilename = shell_quote(p); + if (qfilename != NULL) + { + length += strlen(qfilename) + 1; + free(qfilename); + } + } gfilename = (char *) ecalloc(length, sizeof(char)); - for (cnt = 0; list[cnt] != NULL; cnt++) + for (SCAN_GLOB_LIST(list, p)) { - strlcat(gfilename, list[cnt], length); - strlcat(gfilename, " ", length); + INIT_GLOB_LIST(list, p); + qfilename = shell_quote(p); + if (qfilename != NULL) + { + snprintf(gfilename + strlen(gfilename), + length - strlen(gfilename), "%s ", qfilename); + free(qfilename); + } } - _fnexplodefree(list); + /* + * Overwrite the final trailing space with a null terminator. + */ + *--p = '\0'; + GLOB_LIST_DONE(list); } #else +#ifdef DECL_GLOB_NAME { - FILE *fd; + /* + * 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)); + snprintf(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); + } + strlcpy(p, qpathname, gfilename + len - p); + free(qpathname); + p += n; + *p++ = ' '; + } + } while (GLOB_NEXT_NAME(handle, &fnd) == 0); /* - * We get the shell to expand the filename for us by passing + * 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. */ - fd = shellcmd("echo %s", filename, (char*)NULL); + 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)); + snprintf(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. */ - return (filename); + free(filename); + return (ofilename); } gfilename = readfd(fd); pclose(fd); if (*gfilename == '\0') { free(gfilename); - return (filename); + free(filename); + return (ofilename); } - free(filename); } +#else + /* + * No globbing functions at all. Just use the fexpanded filename. + */ + gfilename = save(filename); +#endif +#endif #endif + free(filename); + free(ofilename); return (gfilename); } @@ -454,13 +801,21 @@ open_altfile(filename, pf, pfd) int *pf; void **pfd; { +#if !HAVE_POPEN + return (NULL); +#else char *lessopen; - char *gfilename; - int returnfd = 0; + char *cmd; FILE *fd; + size_t len; +#if HAVE_FILENO + int returnfd = 0; +#endif + if (!use_lessopen || secure) + return (NULL); ch_ungetchar(-1); - if ((lessopen = getenv("LESSOPEN")) == NULL) + if ((lessopen = lgetenv("LESSOPEN")) == NULL) return (NULL); if (strcmp(filename, "-") == 0) return (NULL); @@ -470,10 +825,20 @@ open_altfile(filename, pf, pfd) * If LESSOPEN starts with a |, it indicates * a "pipe preprocessor". */ +#if HAVE_FILENO lessopen++; returnfd = 1; +#else + error("LESSOPEN pipe is not supported", NULL_PARG); + return (NULL); +#endif } - fd = shellcmd(lessopen, filename, (char*)NULL); + + len = strlen(lessopen) + strlen(filename) + 2; + cmd = (char *) ecalloc(len, sizeof(char)); + snprintf(cmd, len, lessopen, filename); + fd = shellcmd(cmd); + free(cmd); if (fd == NULL) { /* @@ -481,9 +846,9 @@ open_altfile(filename, pf, pfd) */ return (NULL); } +#if HAVE_FILENO if (returnfd) { -#if HAVE_FILENO int f; char c; @@ -492,6 +857,7 @@ 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) { /* @@ -504,19 +870,17 @@ open_altfile(filename, pf, pfd) *pfd = (void *) fd; *pf = f; return (save("-")); -#else - error("LESSOPEN pipe is not supported", NULL_PARG); - return (NULL); -#endif } - gfilename = readfd(fd); +#endif + cmd = readfd(fd); pclose(fd); - if (*gfilename == '\0') + if (*cmd == '\0') /* * Pipe is empty. This means there is no alt file. */ return (NULL); - return (gfilename); + return (cmd); +#endif /* HAVE_POPEN */ } /* @@ -528,114 +892,70 @@ close_altfile(altfilename, filename, pipefd) 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 ((lessclose = getenv("LESSCLOSE")) == NULL) + } + if ((lessclose = lgetenv("LESSCLOSE")) == NULL) return; - fd = shellcmd(lessclose, filename, altfilename); - pclose(fd); + len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2; + cmd = (char *) ecalloc(len, sizeof(char)); + snprintf(cmd, len, lessclose, filename, altfilename); + fd = shellcmd(cmd); + free(cmd); + if (fd != NULL) + pclose(fd); +#endif } -#else -#if MSOFTC - - public char * -glob(filename) - char *filename; -{ - char *gfilename; - char *p; - int len; - int n; - struct find_t fnd; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - - filename = fexpand(filename); - if (_dos_findfirst(filename, ~0, &fnd) != 0) - return (filename); - - _splitpath(filename, drive, dir, fname, ext); - len = 100; - gfilename = (char *) ecalloc(len, sizeof(char)); - p = gfilename; - do { - n = strlen(drive) + strlen(dir) + strlen(fnd.name); - while (p - gfilename + n+2 >= len) - { - len *= 2; - *p = '\0'; - p = (char *) ecalloc(len, sizeof(char)); - strlcpy(p, gfilename, len); - free(gfilename); - gfilename = p; - p = gfilename + strlen(gfilename); - } - sprintf(p, "%s%s%s", drive, dir, fnd.name); - p += n; - *p++ = ' '; - } while (_dos_findnext(&fnd) == 0); - - *--p = '\0'; - return (gfilename); -} - - public char * -open_altfile(filename) +/* + * Is the specified file a directory? + */ + public int +is_dir(filename) char *filename; { - return (NULL); -} + int isdir = 0; - public void -close_altfile(altfilename, filename) - char *altfilename; - char *filename; + filename = shell_unquote(filename); +#if HAVE_STAT { -} - -#else + int r; + struct stat statbuf; - public char * -glob(filename) - char *filename; -{ - return (fexpand(filename)); + r = stat(filename, &statbuf); + isdir = (r >= 0 && S_ISDIR(statbuf.st_mode)); } - - - public char * -open_altfile(filename) - char *filename; +#else +#ifdef _OSK { - return (NULL); -} + register int f; - public void -close_altfile(altfilename, filename) - char *altfilename; - char *filename; -{ + f = open(filename, S_IREAD | S_IFDIR); + if (f >= 0) + close(f); + isdir = (f >= 0); } - #endif #endif - - -#if HAVE_STAT - -#include <sys/stat.h> -#ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif -#ifndef S_ISREG -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif + free(filename); + return (isdir); +} /* * Returns NULL if the file can be opened and @@ -646,39 +966,43 @@ close_altfile(altfilename, filename) bad_file(filename) char *filename; { - char *m; - struct stat statbuf; - - if (stat(filename, &statbuf) < 0) - return (errno_message(filename)); + register char *m = NULL; + size_t len; - if (force_open) - return (NULL); - - if (S_ISDIR(statbuf.st_mode)) + filename = shell_unquote(filename); + if (is_dir(filename)) { - static char is_dir[] = " is a directory"; - size_t len; + static char is_a_dir[] = " is a directory"; - len = strlen(filename) + sizeof(is_dir); + len = strlen(filename) + sizeof(is_a_dir); m = (char *) ecalloc(len, sizeof(char)); strlcpy(m, filename, len); - strlcat(m, is_dir, len); - return (m); - } - if (!S_ISREG(statbuf.st_mode)) + strlcat(m, is_a_dir, len); + } else { - static char not_reg[] = " is not a regular file"; - size_t len; +#if HAVE_STAT + int r; + struct stat statbuf; - len = strlen(filename) + sizeof(not_reg); - m = (char *) ecalloc(len, sizeof(char)); - strlcpy(m, filename, len); - strlcat(m, not_reg, len); - return (m); + r = stat(filename, &statbuf); + if (r < 0) + { + m = errno_message(filename); + } else if (force_open) + { + m = NULL; + } else if (!S_ISREG(statbuf.st_mode)) + { + static char not_reg[] = " is not a regular file (use -f to see it)"; + len = strlen(filename) + sizeof(not_reg); + m = (char *) ecalloc(len, sizeof(char)); + strlcpy(m, filename, len); + strlcat(m, not_reg, len); + } +#endif } - - return (NULL); + free(filename); + return (m); } /* @@ -689,37 +1013,27 @@ bad_file(filename) filesize(f) int f; { +#if HAVE_STAT struct stat statbuf; - if (fstat(f, &statbuf) < 0) - /* - * Can't stat; try seeking to the end. - */ - return (seek_filesize(f)); - - return ((POSITION) statbuf.st_size); -} - + if (fstat(f, &statbuf) >= 0) + return ((POSITION) statbuf.st_size); #else +#ifdef _OSK + long size; -/* - * If we have no way to find out, just say the file is good. - */ - public char * -bad_file(filename) - char *filename; -{ - return (NULL); + if ((size = (long) _gs_size(f)) >= 0) + return ((POSITION) size); +#endif +#endif + return (seek_filesize(f)); } /* - * We can find the file size by seeking. + * */ - public POSITION -filesize(f) - int f; + public char * +shell_coption() { - return (seek_filesize(f)); + return ("-c"); } - -#endif diff --git a/usr.bin/less/forwback.c b/usr.bin/less/forwback.c index d316ce74b59..29a52bff90a 100644 --- a/usr.bin/less/forwback.c +++ b/usr.bin/less/forwback.c @@ -1,29 +1,11 @@ -/* $OpenBSD: forwback.c,v 1.4 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -38,18 +20,19 @@ public int hit_eof; /* Keeps track of how many times we hit end of file */ public int screen_trashed; public int squished; +public int no_back_scroll = 0; extern int sigs; extern int top_scroll; extern int quiet; extern int sc_width, sc_height; extern int quit_at_eof; -extern int less_mode; extern int plusoption; extern int forw_scroll; extern int back_scroll; -extern int need_clr; extern int ignore_eoi; +extern int clear_bg; +extern int final_attr; #if TAGS extern char *tagoption; #endif @@ -114,7 +97,7 @@ squish_check() */ public void forw(n, pos, force, only_last, nblank) - int n; + register int n; POSITION pos; int force; int only_last; @@ -141,6 +124,13 @@ forw(n, pos, force, only_last, nblank) if (!do_repaint) { + /* + * Forget any current line shift we might have + * (from the last line of the previous screenful). + */ + extern int cshift; + cshift = 0; + if (top_scroll && n >= sc_height - 1 && pos != ch_length()) { /* @@ -149,10 +139,12 @@ forw(n, pos, force, only_last, nblank) * to hit eof in the middle of this screen, * but we don't yet know if that will happen. }} */ + pos_clear(); + add_forw_pos(pos); + force = 1; if (top_scroll == OPT_ONPLUS || first_time) clear(); home(); - force = 1; } else { clear_bot(); @@ -206,10 +198,16 @@ forw(n, pos, force, only_last, nblank) /* * End of file: stop here unless the top line * is still empty, or "force" is true. + * Even if force is true, stop when the last + * line in the file reaches the top of screen. */ eof = 1; if (!force && position(TOP) != NULL_POSITION) break; + if (!empty_lines(0, 0) && + !empty_lines(1, 1) && + empty_lines(2, sc_height-1)) + break; } } /* @@ -239,9 +237,20 @@ forw(n, pos, force, only_last, nblank) squished = 1; continue; } - if (top_scroll == 1) + if (top_scroll == OPT_ON) clear_eol(); put_line(); + if (clear_bg && final_attr != AT_NORMAL) + { + /* + * Writing the last character on the last line + * of the display may have scrolled the screen. + * If we were in standout mode, clear_bg terminals + * will fill the new line with the standout color. + * Now we're in normal mode again, so clear the line. + */ + clear_eol(); + } } if (ignore_eoi) @@ -263,7 +272,7 @@ forw(n, pos, force, only_last, nblank) */ public void back(n, pos, force, only_last) - int n; + register int n; POSITION pos; int force; int only_last; @@ -322,7 +331,7 @@ forward(n, force, only_last) { POSITION pos; - if (quit_at_eof && hit_eof) + if (quit_at_eof && hit_eof && !(ch_getflags() & CH_HELPFILE)) { /* * If the -e flag is set and we're trying to go @@ -353,7 +362,8 @@ forward(n, force, only_last) pos = position(BOTTOM_PLUS_ONE); } while (pos == NULL_POSITION); } - } else { + } else + { eof_bell(); hit_eof++; return; @@ -392,6 +402,8 @@ backward(n, force, only_last) public int get_back_scroll() { + if (no_back_scroll) + return (0); if (back_scroll >= 0) return (back_scroll); if (top_scroll) diff --git a/usr.bin/less/funcs.h b/usr.bin/less/funcs.h index 01c8d4a48f4..01b6c12a87a 100644 --- a/usr.bin/less/funcs.h +++ b/usr.bin/less/funcs.h @@ -1,23 +1,23 @@ -/* $OpenBSD: funcs.h,v 1.2 2001/01/29 01:58:01 niklas Exp $ */ - - public void strtcpy (); public char * save (); public VOID_POINTER ecalloc (); public char * skipsp (); + public int sprefix (); public void quit (); public void raw_mode (); public void scrsize (); - public void scrsize (); - public void get_editkeys (); + 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 check_winch (); public void goto_line (); - public void bell (); public void vbell (); + public void bell (); public void clear (); public void clear_eol (); public void clear_bot (); @@ -31,6 +31,7 @@ public void bl_exit (); public void backspace (); public void putbs (); + public char WIN32getch (); public void match_brac (); public void ch_ungetchar (); public void end_logfile (); @@ -42,7 +43,7 @@ public POSITION ch_tell (); public int ch_forw_get (); public int ch_back_get (); - public int ch_nbuf (); + public void ch_setbufspace (); public void ch_flush (); public int seekable (); public void ch_init (); @@ -54,12 +55,14 @@ public int control_char (); public char * prchar (); public void cmd_reset (); + public void clear_cmd (); + public void cmd_putstr (); public int len_cmdbuf (); public void set_mlist (); + public void cmd_addhist (); public void cmd_accept (); public int cmd_char (); - public int cmd_int (); - public void cmd_putstr (); + public LINENUM cmd_int (); public char * get_cmdbuf (); public int in_mca (); public void dispversion (); @@ -70,9 +73,9 @@ public void init_cmds (); public void add_fcmd_table (); public void add_ecmd_table (); - public int cmd_search (); public int fcmd_decode (); public int ecmd_decode (); + public char * lgetenv (); public int lesskey (); public void add_hometable (); public int editchar (); @@ -87,33 +90,31 @@ public int edit_next (); public int edit_prev (); public int edit_index (); + public IFILE save_curr_ifile (); + public void unsave_ifile (); + public void reedit_ifile (); public int edit_stdin (); public void cat_file (); public void use_logfile (); + public char * shell_unquote (); + public char * get_meta_escape (); + public char * shell_quote (); public char * homefile (); - public char * find_helpfile (); public char * fexpand (); public char * fcomplete (); public int bin_file (); - public char * glob (); + public char * lglob (); public char * open_altfile (); public void close_altfile (); - public char * glob (); - public char * open_altfile (); - public void close_altfile (); - public char * glob (); - public char * open_altfile (); - public void close_altfile (); - public char * bad_file (); - public POSITION filesize (); + public int is_dir (); public char * bad_file (); public POSITION filesize (); + public char * shell_coption (); public void forw (); public void back (); public void forward (); public void backward (); public int get_back_scroll (); - public void help (); public void del_ifile (); public IFILE next_ifile (); public IFILE prev_ifile (); @@ -126,19 +127,24 @@ public void get_pos (); public void set_open (); public int opened (); + public void hold_ifile (); + public int held_ifile (); public void * get_filestate (); public void set_filestate (); public void if_dump (); public POSITION forw_line (); public POSITION back_line (); + public void set_attnpos (); public void jump_forw (); public void jump_back (); public void repaint (); public void jump_percent (); public void jump_line_loc (); public void jump_loc (); + public void init_line (); public void prewind (); public void plinenum (); + public int is_ansi_end (); public int pappend (); public void pdone (); public int gline (); @@ -147,9 +153,9 @@ public POSITION back_raw_line (); public void clr_linenum (); public void add_lnum (); - public int find_linenum (); + public LINENUM find_linenum (); public POSITION find_pos (); - public int currline (); + public LINENUM currline (); public void lsystem (); public int pipe_mark (); public int pipe_data (); @@ -159,6 +165,7 @@ public void lastmark (); public void gomark (); public POSITION markpos (); + public void unmark (); public void opt_o (); public void opt__O (); public void opt_l (); @@ -171,6 +178,8 @@ 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 void scan_option (); @@ -181,16 +190,20 @@ public void nopendopt (); public int getnum (); public void init_option (); - public struct option * findopt (); + public struct loption * findopt (); + public struct loption * findopt_name (); public int iread (); public void intread (); public long get_time (); public char * errno_message (); public int percentage (); + public POSITION percent_pos (); + public int os9_signal (); public 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 (); @@ -208,7 +221,9 @@ public char * pr_expand (); public char * eq_message (); public char * pr_string (); + public char * wait_message (); public void repaint_hilite (); + public void clear_attn (); public void undo_search (); public void clr_hilite (); public int is_hilited (); @@ -220,7 +235,15 @@ 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 (); diff --git a/usr.bin/less/help.c b/usr.bin/less/help.c index b22bb481619..11e4b978b78 100644 --- a/usr.bin/less/help.c +++ b/usr.bin/less/help.c @@ -1,91 +1,225 @@ -/* $OpenBSD: help.c,v 1.3 2003/04/06 23:38:07 deraadt Exp $ */ - -/* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * Display some help. - * Just invoke another "less" to display the help file. - * - * {{ This makes this function very simple, and makes changing the - * help file very easy, but it may present difficulties on - * (non-Unix) systems which do not supply the "system()" function. }} - */ - -#include "less.h" - -extern char *progname; - - public void -help(nomsg) - int nomsg; -{ - char *helpfile; - char *cmd; - size_t len; - - helpfile = find_helpfile(); - if (helpfile == NULL) - { - error("Cannot find help file", NULL_PARG); - return; - } -#if !HAVE_SYSTEM - /* - * Just examine the help file. - */ - (void) edit(helpfile); -#else - /* - * Use lsystem() to invoke a new instance of less - * to view the help file. - */ -#if MSOFTC - putenv("LESS=-m -H -+E -+s -PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done"); - len = strlen(helpfile) + strlen(progname) + 3; - cmd = (char *) ecalloc(len, sizeof(char)); - snprintf(cmd, len, "-%s %s", progname, helpfile); -#else - len = strlen(helpfile) + strlen(progname) + 150; - cmd = (char *) ecalloc(len, sizeof(char)); -#if OS2 - snprintf(cmd, len, - "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s", - progname, helpfile); -#else - snprintf(cmd, len, - "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s", - progname, helpfile); -#endif -#endif - free(helpfile); - lsystem(cmd); - if (!nomsg) - error("End of help", NULL_PARG); - free(cmd); -#endif -} +/* 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',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n', +'\n', +' ',' ',' ',' ',' ',' ','C','o','m','m','a','n','d','s',' ','m','a','r','k','e','d',' ','w','i','t','h',' ','*',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','n','u','m','b','e','r',',',' ','_','\b','N','.','\n', +' ',' ',' ',' ',' ',' ','N','o','t','e','s',' ','i','n',' ','p','a','r','e','n','t','h','e','s','e','s',' ','i','n','d','i','c','a','t','e',' ','t','h','e',' ','b','e','h','a','v','i','o','r',' ','i','f',' ','_','\b','N',' ','i','s',' ','g','i','v','e','n','.','\n', +'\n', +' ',' ','h',' ',' ','H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','i','s',' ','h','e','l','p','.','\n', +' ',' ','q',' ',' ',':','q',' ',' ','Q',' ',' ',':','Q',' ',' ','Z','Z',' ',' ',' ',' ',' ','E','x','i','t','.','\n', +' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', +'\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','\b','M','O','\b','O','V','\b','V','I','\b','I','N','\b','N','G','\b','G','\n', +'\n', +' ',' ','e',' ',' ','^','E',' ',' ','j',' ',' ','^','N',' ',' ','C','R',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n', +' ',' ','y',' ',' ','^','Y',' ',' ','k',' ',' ','^','K',' ',' ','^','P',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n', +' ',' ','f',' ',' ','^','F',' ',' ','^','V',' ',' ','S','P','A','C','E',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n', +' ',' ','b',' ',' ','^','B',' ',' ','E','S','C','-','v',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n', +' ',' ','z',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n', +' ',' ','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n', +' ',' ','E','S','C','-','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',',',' ','b','u','t',' ','d','o','n','\'','t',' ','s','t','o','p',' ','a','t',' ','e','n','d','-','o','f','-','f','i','l','e','.','\n', +' ',' ','d',' ',' ','^','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n', +' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n', +' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','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', +' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', +' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','p','a','t','t','e','r','n','s',' ','m','a','y',' ','b','e',' ','m','o','d','i','f','i','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n', +' ',' ',' ',' ',' ',' ',' ',' ','^','N',' ','o','r',' ','!',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','N','O','N','-','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ','^','E',' ','o','r',' ','*',' ',' ','S','e','a','r','c','h',' ','m','u','l','t','i','p','l','e',' ','f','i','l','e','s',' ','(','p','a','s','s',' ','t','h','r','u',' ','E','N','D',' ','O','F',' ','F','I','L','E',')','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ','^','F',' ','o','r',' ','@',' ',' ','S','t','a','r','t',' ','s','e','a','r','c','h',' ','a','t',' ','F','I','R','S','T',' ','f','i','l','e',' ','(','f','o','r',' ','/',')',' ','o','r',' ','l','a','s','t',' ','f','i','l','e',' ','(','f','o','r',' ','?',')','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ','^','K',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','m','a','t','c','h','e','s',',',' ','b','u','t',' ','d','o','n','\'','t',' ','m','o','v','e',' ','(','K','E','E','P',' ','p','o','s','i','t','i','o','n',')','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ','^','R',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','R','E','G','U','L','A','R',' ','E','X','P','R','E','S','S','I','O','N','S','.','\n', +' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', +'\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','J','\b','J','U','\b','U','M','\b','M','P','\b','P','I','\b','I','N','\b','N','G','\b','G','\n', +'\n', +' ',' ','g',' ',' ','<',' ',' ','E','S','C','-','<',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','f','i','r','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n', +' ',' ','G',' ',' ','>',' ',' ','E','S','C','-','>',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','l','a','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n', +' ',' ','p',' ',' ','%',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','b','e','g','i','n','n','i','n','g',' ','o','f',' ','f','i','l','e',' ','(','o','r',' ','_','\b','N',' ','p','e','r','c','e','n','t',' ','i','n','t','o',' ','f','i','l','e',')','.','\n', +' ',' ','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','e','d','e','d',' ','b','y',' ','-','-','.','\n', +'\n', +' ',' ','-','?',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','e','l','p','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n', +' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n', +' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n', +' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','a','u','t','o','m','a','t','i','c','a','l','l','y',' ','a','l','l','o','c','a','t','e',' ','b','u','f','f','e','r','s',' ','f','o','r',' ','p','i','p','e','s','.','\n', +' ',' ','-','c',' ',' ','-','C',' ',' ','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n',' ',' ','-','-','C','L','E','A','R','-','S','C','R','E','E','N','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','s','c','r','o','l','l','i','n','g','/','c','l','e','a','r','i','n','g','.','\n', +' ',' ','-','d',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','d','u','m','b','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','u','m','b',' ','t','e','r','m','i','n','a','l','.','\n', +' ',' ','-','D',' ','[','_','\b','x','_','\b','n','_','\b','.','_','\b','n',']',' ',' ','.',' ',' ','-','-','c','o','l','o','r','=','_','\b','x','_','\b','n','_','\b','.','_','\b','n','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','c','r','e','e','n',' ','c','o','l','o','r','s','.',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')','\n', +' ',' ','-','e',' ',' ','-','E',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','t','-','a','t','-','e','o','f',' ',' ','-','-','Q','U','I','T','-','A','T','-','E','O','F','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','a','t',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n', +' ',' ','-','f',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','r','c','e','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','c','e',' ','o','p','e','n',' ','n','o','n','-','r','e','g','u','l','a','r',' ','f','i','l','e','s','.','\n', +' ',' ','-','F',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','q','u','i','t','-','i','f','-','o','n','e','-','s','c','r','e','e','n','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','i','f',' ','e','n','t','i','r','e',' ','f','i','l','e',' ','f','i','t','s',' ','o','n',' ','f','i','r','s','t',' ','s','c','r','e','e','n','.','\n', +' ',' ','-','g',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','s','e','a','r','c','h','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','o','n','l','y',' ','l','a','s','t',' ','m','a','t','c','h',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n', +' ',' ','-','G',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','S','E','A','R','C','H','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','h','i','g','h','l','i','g','h','t',' ','a','n','y',' ','m','a','t','c','h','e','s',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n', +' ',' ','-','h',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','b','a','c','k','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n', +' ',' ','-','i',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','i','g','n','o','r','e','-','c','a','s','e','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','s','e','a','r','c','h','e','s',' ','t','h','a','t',' ','d','o',' ','n','o','t',' ','c','o','n','t','a','i','n',' ','u','p','p','e','r','c','a','s','e','.','\n', +' ',' ','-','I',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','I','G','N','O','R','E','-','C','A','S','E','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','a','l','l',' ','s','e','a','r','c','h','e','s','.','\n', +' ',' ','-','j',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','j','u','m','p','-','t','a','r','g','e','t','=','[','_','\b','N',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','c','r','e','e','n',' ','p','o','s','i','t','i','o','n',' ','o','f',' ','t','a','r','g','e','t',' ','l','i','n','e','s','.','\n', +' ',' ','-','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', +' ',' ','-','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', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n', +' ',' ','-','o',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','o','g','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','s','t','a','n','d','a','r','d',' ','i','n','p','u','t',' ','o','n','l','y',')','.','\n', +' ',' ','-','O',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','L','O','G','-','F','I','L','E','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','u','n','c','o','n','d','i','t','i','o','n','a','l','l','y',' ','o','v','e','r','w','r','i','t','e',')','.','\n', +' ',' ','-','p',' ','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']',' ',' ','-','-','p','a','t','t','e','r','n','=','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','t','a','r','t',' ','a','t',' ','p','a','t','t','e','r','n',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n', +' ',' ','-','P',' ','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']',' ',' ',' ','-','-','p','r','o','m','p','t','=','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','i','n','e',' ','n','e','w',' ','p','r','o','m','p','t','.','\n', +' ',' ','-','q',' ',' ','-','Q',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','e','t',' ',' ','-','-','Q','U','I','E','T',' ',' ','-','-','s','i','l','e','n','t',' ','-','-','S','I','L','E','N','T','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','e','t',' ','t','h','e',' ','t','e','r','m','i','n','a','l',' ','b','e','l','l','.','\n', +' ',' ','-','r',' ',' ','-','R',' ',' ','.','.','.','.',' ',' ','-','-','r','a','w','-','c','o','n','t','r','o','l','-','c','h','a','r','s',' ',' ','-','-','R','A','W','-','C','O','N','T','R','O','L','-','C','H','A','R','S','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','O','u','t','p','u','t',' ','"','r','a','w','"',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n', +' ',' ','-','s',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','q','u','e','e','z','e','-','b','l','a','n','k','-','l','i','n','e','s','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','q','u','e','e','z','e',' ','m','u','l','t','i','p','l','e',' ','b','l','a','n','k',' ','l','i','n','e','s','.','\n', +' ',' ','-','S',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','h','o','p','-','l','o','n','g','-','l','i','n','e','s','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','l','o','n','g',' ','l','i','n','e','s','.','\n', +' ',' ','-','t',' ','[','_','\b','t','_','\b','a','_','\b','g',']',' ',' ','.','.',' ',' ','-','-','t','a','g','=','[','_','\b','t','_','\b','a','_','\b','g',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','i','n','d',' ','a',' ','t','a','g','.','\n', +' ',' ','-','T',' ','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ','-','-','t','a','g','-','f','i','l','e','=','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a','n',' ','a','l','t','e','r','n','a','t','e',' ','t','a','g','s',' ','f','i','l','e','.','\n', +' ',' ','-','u',' ',' ','-','U',' ',' ','.','.','.','.',' ',' ','-','-','u','n','d','e','r','l','i','n','e','-','s','p','e','c','i','a','l',' ',' ','-','-','U','N','D','E','R','L','I','N','E','-','S','P','E','C','I','A','L','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','a','n','g','e',' ','h','a','n','d','l','i','n','g',' ','o','f',' ','b','a','c','k','s','p','a','c','e','s','.','\n', +' ',' ','-','V',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','v','e','r','s','i','o','n','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n', +' ',' ','-','w',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','u','n','r','e','a','d','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','f','o','r','w','a','r','d','-','s','c','r','e','e','n','.','\n', +' ',' ','-','W',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','U','N','R','E','A','D','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','a','n','y',' ','f','o','r','w','a','r','d',' ','m','o','v','e','m','e','n','t','.','\n', +' ',' ','-','x',' ','[','_','\b','N','[',',','.','.','.',']',']',' ',' ','-','-','t','a','b','s','=','[','_','\b','N','[',',','.','.','.',']',']','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','a','b',' ','s','t','o','p','s','.','\n', +' ',' ','-','X',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','i','n','i','t','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','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', +' ',' ','-','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', +' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', +'\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','\b','L','I','\b','I','N','\b','N','E','\b','E',' ','E','\b','E','D','\b','D','I','\b','I','T','\b','T','I','\b','I','N','\b','N','G','\b','G','\n', +'\n', +' ',' ',' ',' ',' ',' ',' ',' ','T','h','e','s','e',' ','k','e','y','s',' ','c','a','n',' ','b','e',' ','u','s','e','d',' ','t','o',' ','e','d','i','t',' ','t','e','x','t',' ','b','e','i','n','g',' ','e','n','t','e','r','e','d',' ','\n', +' ',' ',' ',' ',' ',' ',' ',' ','o','n',' ','t','h','e',' ','"','c','o','m','m','a','n','d',' ','l','i','n','e','"',' ','a','t',' ','t','h','e',' ','b','o','t','t','o','m',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n','.','\n', +'\n', +' ','R','i','g','h','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','l',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', +' ','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','h',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', +' ','C','N','T','L','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n', +' ','C','N','T','L','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n', +' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n', +' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n', +' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', +' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', +' ','C','N','T','L','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', +' ','C','N','T','L','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', +' ','C','N','T','L','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n', +' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', +' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', +' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n', +' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n', +' ','C','N','T','L','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n', +'\n', + 0 }; +constant int size_helpdata = sizeof(helpdata) - 1; diff --git a/usr.bin/less/ifile.c b/usr.bin/less/ifile.c index c71bc79cb40..694621eaf41 100644 --- a/usr.bin/less/ifile.c +++ b/usr.bin/less/ifile.c @@ -1,29 +1,11 @@ -/* $OpenBSD: ifile.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -48,7 +30,8 @@ struct ifile { char *h_filename; /* Name of the file */ void *h_filestate; /* File state (used in ch.c) */ int h_index; /* Index within command line list */ - int h_opened; /* Only need one bit */ + int h_hold; /* Hold count */ + char h_opened; /* Has this ifile been opened? */ struct scrpos h_scrpos; /* Saved position within the file */ }; @@ -62,18 +45,22 @@ struct ifile { /* * Anchor for linked list. */ -static struct ifile anchor = { &anchor, &anchor, 0 }; +static struct ifile anchor = { &anchor, &anchor, NULL, NULL, 0, 0, '\0', + { NULL_POSITION, 0 } }; static int ifiles = 0; static void incr_index(p, incr) - struct ifile *p; + register struct ifile *p; int incr; { for (; p != &anchor; p = p->h_next) p->h_index += incr; } +/* + * Link an ifile into the ifile list. + */ static void link_ifile(p, prev) struct ifile *p; @@ -97,6 +84,9 @@ link_ifile(p, prev) ifiles++; } +/* + * Unlink an ifile from the ifile list. + */ static void unlink_ifile(p) struct ifile *p; @@ -118,7 +108,7 @@ new_ifile(filename, prev) char *filename; struct ifile *prev; { - struct ifile *p; + register struct ifile *p; /* * Allocate and initialize structure. @@ -127,6 +117,8 @@ new_ifile(filename, prev) p->h_filename = save(filename); p->h_scrpos.pos = NULL_POSITION; p->h_opened = 0; + p->h_hold = 0; + p->h_filestate = NULL; link_ifile(p, prev); return (p); } @@ -138,7 +130,7 @@ new_ifile(filename, prev) del_ifile(h) IFILE h; { - struct ifile *p; + register struct ifile *p; if (h == NULL_IFILE) return; @@ -146,6 +138,7 @@ del_ifile(h) * If the ifile we're deleting is the currently open ifile, * move off it. */ + unmark(h); if (h == curr_ifile) curr_ifile = getoff_ifile(curr_ifile); p = int_ifile(h); @@ -161,7 +154,7 @@ del_ifile(h) next_ifile(h) IFILE h; { - struct ifile *p; + register struct ifile *p; p = (h == NULL_IFILE) ? &anchor : int_ifile(h); if (p->h_next == &anchor) @@ -176,7 +169,7 @@ next_ifile(h) prev_ifile(h) IFILE h; { - struct ifile *p; + register struct ifile *p; p = (h == NULL_IFILE) ? &anchor : int_ifile(h); if (p->h_prev == &anchor) @@ -216,7 +209,7 @@ nifile() find_ifile(filename) char *filename; { - struct ifile *p; + register struct ifile *p; for (p = anchor.h_next; p != &anchor; p = p->h_next) if (strcmp(filename, p->h_filename) == 0) @@ -234,7 +227,7 @@ get_ifile(filename, prev) char *filename; IFILE prev; { - struct ifile *p; + register struct ifile *p; if ((p = find_ifile(filename)) == NULL) p = new_ifile(filename, int_ifile(prev)); @@ -306,6 +299,21 @@ opened(ifile) return (int_ifile(ifile)->h_opened); } + public void +hold_ifile(ifile, incr) + IFILE ifile; + int incr; +{ + int_ifile(ifile)->h_hold += incr; +} + + public int +held_ifile(ifile) + IFILE ifile; +{ + return (int_ifile(ifile)->h_hold); +} + public void * get_filestate(ifile) IFILE ifile; @@ -325,7 +333,7 @@ set_filestate(ifile, filestate) public void if_dump() { - struct ifile *p; + register struct ifile *p; for (p = anchor.h_next; p != &anchor; p = p->h_next) { diff --git a/usr.bin/less/input.c b/usr.bin/less/input.c index 750f50a647a..a20ce051e04 100644 --- a/usr.bin/less/input.c +++ b/usr.bin/less/input.c @@ -1,29 +1,11 @@ -/* $OpenBSD: input.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -41,7 +23,12 @@ extern int squeeze; extern int chopline; +extern int hshift; +extern int quit_if_one_screen; extern int sigs; +extern int ignore_eoi; +extern POSITION start_attnpos; +extern POSITION end_attnpos; #if HILITE_SEARCH extern int hilite_search; extern int size_linebuf; @@ -59,7 +46,7 @@ forw_line(curr_pos) POSITION curr_pos; { POSITION new_pos; - int c; + register int c; int blankline; int endline; @@ -70,7 +57,15 @@ forw_line(curr_pos) } #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) - prep_hilite(curr_pos, curr_pos + 3*size_linebuf); + /* + * If we are ignoring EOI (command F), only prepare + * one line ahead, to avoid getting stuck waiting for + * slow data without displaying the data we already have. + * If we're not ignoring EOI, we *could* do the same, but + * for efficiency we prepare several lines ahead at once. + */ + prep_hilite(curr_pos, curr_pos + 3*size_linebuf, + ignore_eoi ? 1 : -1); #endif if (ch_seek(curr_pos)) { @@ -103,7 +98,7 @@ forw_line(curr_pos) * End of the line. */ new_pos = ch_tell(); - endline = 1; + endline = TRUE; break; } @@ -117,18 +112,19 @@ forw_line(curr_pos) * is too long to print in the screen width. * End the line here. */ - if (chopline) + if (chopline || hshift > 0) { do { c = ch_forw_get(); } while (c != '\n' && c != EOI); new_pos = ch_tell(); - endline = 1; + endline = TRUE; + quit_if_one_screen = FALSE; } else { new_pos = ch_tell() - 1; - endline = 0; + endline = FALSE; } break; } @@ -180,7 +176,7 @@ back_line(curr_pos) #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) prep_hilite((curr_pos < 3*size_linebuf) ? - 0 : curr_pos - 3*size_linebuf, curr_pos); + 0 : curr_pos - 3*size_linebuf, curr_pos, -1); #endif if (ch_seek(curr_pos-1)) { @@ -266,7 +262,7 @@ back_line(curr_pos) null_line(); return (NULL_POSITION); } - endline = 0; + endline = FALSE; loop: begin_new_pos = new_pos; prewind(); @@ -284,7 +280,7 @@ back_line(curr_pos) new_pos++; if (c == '\n') { - endline = 1; + endline = TRUE; break; } if (pappend(c, ch_tell()-1)) @@ -294,9 +290,10 @@ back_line(curr_pos) * reached our curr_pos yet. Discard the line * and start a new one. */ - if (chopline) + if (chopline || hshift > 0) { - endline = 1; + endline = TRUE; + quit_if_one_screen = FALSE; break; } pdone(0); @@ -310,3 +307,37 @@ back_line(curr_pos) return (begin_new_pos); } + +/* + * Set attnpos. + */ + public void +set_attnpos(pos) + POSITION pos; +{ + int c; + + if (pos != NULL_POSITION) + { + if (ch_seek(pos)) + return; + for (;;) + { + c = ch_forw_get(); + if (c == EOI) + return; + if (c != '\n' && c != '\r') + break; + pos++; + } + } + start_attnpos = pos; + for (;;) + { + c = ch_forw_get(); + pos++; + if (c == EOI || c == '\n' || c == '\r') + break; + } + end_attnpos = pos; +} diff --git a/usr.bin/less/install.sh b/usr.bin/less/install.sh index f5ebcc1052c..0ff4b6a08e8 100644 --- a/usr.bin/less/install.sh +++ b/usr.bin/less/install.sh @@ -1,6 +1,4 @@ #!/bin/sh -# $OpenBSD: install.sh,v 1.2 2001/01/29 01:58:02 niklas Exp $ - # # install - install a program, script, or datafile diff --git a/usr.bin/less/jump.c b/usr.bin/less/jump.c index c93fb0af34c..b919b2549f7 100644 --- a/usr.bin/less/jump.c +++ b/usr.bin/less/jump.c @@ -1,29 +1,11 @@ -/* $OpenBSD: jump.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -39,6 +21,7 @@ extern int jump_sline; extern int squished; extern int screen_trashed; extern int sc_width, sc_height; +extern int show_attn; /* * Jump to the end of the file. @@ -69,8 +52,8 @@ jump_forw() * Jump to line n in the file. */ public void -jump_back(n) - int n; +jump_back(linenum) + LINENUM linenum; { POSITION pos; PARG parg; @@ -81,18 +64,20 @@ jump_back(n) * If we can't seek, but we're trying to go to line number 1, * use ch_beg_seek() to get as close as we can. */ - pos = find_pos(n); + pos = find_pos(linenum); if (pos != NULL_POSITION && ch_seek(pos) == 0) { + if (show_attn) + set_attnpos(pos); jump_loc(pos, jump_sline); - } else if (n <= 1 && ch_beg_seek() == 0) + } else if (linenum <= 1 && ch_beg_seek() == 0) { jump_loc(ch_tell(), jump_sline); error("Cannot seek to beginning of file", NULL_PARG); } else { - parg.p_int = n; - error("Cannot seek to line number %d", &parg); + parg.p_linenum = linenum; + error("Cannot seek to line number %n", &parg); } } @@ -135,10 +120,7 @@ jump_percent(percent) error("Don't know length of file", NULL_PARG); return; } - /* - * {{ This calculation may overflow! }} - */ - pos = (percent * len) / 100; + pos = percent_pos(len, percent); if (pos >= len) pos = len-1; @@ -168,6 +150,8 @@ jump_line_loc(pos, sline) (void) ch_forw_get(); pos = ch_tell(); } + if (show_attn) + set_attnpos(pos); jump_loc(pos, sline); } @@ -181,7 +165,7 @@ jump_loc(pos, sline) POSITION pos; int sline; { - int nline; + register int nline; POSITION tpos; POSITION bpos; @@ -201,6 +185,8 @@ jump_loc(pos, sline) forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); else back(-nline, position(TOP), 1, 0); + if (show_attn) + repaint_hilite(1); return; } @@ -238,6 +224,8 @@ jump_loc(pos, sline) * that we can just scroll there after all. */ forw(sc_height-sline+nline-1, bpos, 1, 0, 0); + if (show_attn) + repaint_hilite(1); return; } pos = back_line(pos); @@ -285,6 +273,8 @@ jump_loc(pos, sline) * that we can just scroll there after all. */ back(nline+1, tpos, 1, 0); + if (show_attn) + repaint_hilite(1); return; } } diff --git a/usr.bin/less/less.h b/usr.bin/less/less.h index cbeeed43cb0..059a6dab55b 100644 --- a/usr.bin/less/less.h +++ b/usr.bin/less/less.h @@ -1,29 +1,11 @@ -/* $OpenBSD: less.h,v 1.3 2001/01/29 01:58:02 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,6 +14,14 @@ */ /* + * Defines for MSDOS_COMPILER. + */ +#define MSOFTC 1 /* Microsoft C */ +#define BORLANDC 2 /* Borland C */ +#define WIN32C 3 /* Windows (Borland C or Microsoft C) */ +#define DJGPPC 4 /* DJGPP C */ + +/* * Include the file of compile-time options. * The <> make cc search for it in -I., not srcdir. */ @@ -55,6 +45,11 @@ #define VOID_POINTER char * #define void int #endif +#if HAVE_CONST +#define constant const +#else +#define constant +#endif #define public /* PUBLIC FUNCTION */ @@ -75,23 +70,50 @@ #if HAVE_CTYPE_H #include <ctype.h> #endif -#if STDC_HEADERS +#if HAVE_LIMITS_H +#include <limits.h> +#endif +#if HAVE_STDLIB_H #include <stdlib.h> +#endif +#if HAVE_STRING_H #include <string.h> #endif +#ifdef _OSK +#include <modes.h> +#include <strings.h> +#endif +#if MSDOS_COMPILER==WIN32C || OS2 +#include <io.h> +#endif +#if MSDOS_COMPILER==DJGPPC +#include <io.h> +#include <sys/exceptn.h> +#include <conio.h> +#include <pc.h> +#endif -#if !STDC_HEADERS +#if !HAVE_STDLIB_H char *getenv(); off_t lseek(); VOID_POINTER calloc(); void free(); #endif +/* + * Simple lowercase test which can be used during option processing + * (before options are parsed which might tell us what charset to use). + */ +#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') +#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') +#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A') +#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a') + #if !HAVE_UPPER_LOWER -#define isupper(c) ((c) >= 'A' && (c) <= 'Z') -#define islower(c) ((c) >= 'a' && (c) <= 'z') -#define toupper(c) ((c) - 'a' + 'A') -#define tolower(c) ((c) - 'A' + 'a') +#define isupper(c) SIMPLE_IS_UPPER(c) +#define islower(c) SIMPLE_IS_LOWER(c) +#define toupper(c) SIMPLE_TO_UPPER(c) +#define tolower(c) SIMPLE_TO_LOWER(c) #endif #ifndef NULL @@ -109,7 +131,7 @@ void free(); #define OPT_ON 1 #define OPT_ONPLUS 2 -#ifndef HAVE_MEMCPY +#if !HAVE_MEMCPY #ifndef memcpy #define memcpy(to,from,len) bcopy((from),(to),(len)) #endif @@ -117,38 +139,77 @@ void free(); #define BAD_LSEEK ((off_t)-1) +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + /* - * Special types and constants. + * Upper bound on the string length of an integer converted to string. + * 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. */ -typedef off_t POSITION; +#define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1) + /* - * {{ Warning: if POSITION is changed to other than "long", - * you may have to change some of the printfs which use "%ld" - * to print a variable of type POSITION. }} + * Special types and constants. */ +typedef off_t POSITION; +typedef off_t LINENUM; +#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */ #define NULL_POSITION ((POSITION)(-1)) /* * Flags for open() */ -#if MSOFTC || OS2 +#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 -#if MSOFTC || OS2 +#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 -#if MSOFTC || OS2 -#define OPEN_TTYIN() open("CON", O_BINARY|O_RDONLY) +/* + * 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 OPEN_TTYIN() open("/dev/tty", 0) +#define SHELL_META_QUEST 1 #endif +#define SPACES_IN_FILENAMES 1 + /* * An IFILE represents an input file. */ @@ -172,6 +233,7 @@ typedef union parg { char *p_string; int p_int; + LINENUM p_linenum; } PARG; #define NULL_PARG ((PARG *)NULL) @@ -202,12 +264,14 @@ struct textlist #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ /* How should we search? */ -#define SRCH_FORW 0001 /* Search forward from current position */ -#define SRCH_BACK 0002 /* Search backward from current position */ -#define SRCH_FIND_ALL 0010 /* Find and highlight all matches */ -#define SRCH_NOMATCH 0100 /* Search for non-matching lines */ -#define SRCH_PAST_EOF 0200 /* Search past end-of-file, into next file */ -#define SRCH_FIRST_FILE 0400 /* Search starting at the first file */ +#define SRCH_FORW 000001 /* Search forward from current position */ +#define SRCH_BACK 000002 /* Search backward from current position */ +#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */ +#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */ +#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */ +#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */ +#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */ +#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */ #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ (((t) & ~SRCH_FORW) | SRCH_BACK) : \ @@ -223,6 +287,8 @@ 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 */ + /* Special chars used to tell put_line() to do something special */ #define AT_NORMAL (0) #define AT_UNDERLINE (1) @@ -231,10 +297,99 @@ struct textlist #define AT_INVIS (4) #define AT_STANDOUT (5) +#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 SIGNAL(sig,func) signal(sig,func) +#if _OSK_MWC32 +#define LSIGNAL(sig,func) os9_signal(sig,func) +#else +#define LSIGNAL(sig,func) signal(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 S_INTERRUPT 01 #define S_STOP 02 @@ -249,7 +404,15 @@ struct textlist #define CH_CANSEEK 001 #define CH_KEEPOPEN 002 #define CH_POPENED 004 +#define CH_HELPFILE 010 #define ch_zero() ((POSITION)0) +#define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@" + #include "funcs.h" + +/* Functions not included in funcs.h */ +void postoa(); +void linenumtoa(); +void inttoa(); diff --git a/usr.bin/less/less.hlp b/usr.bin/less/less.hlp index d3b1647bbff..dd98a78a35e 100644 --- a/usr.bin/less/less.hlp +++ b/usr.bin/less/less.hlp @@ -1,27 +1,36 @@ - SUMMARY OF COMMANDS + SSUUMMMMAARRYY OOFF CCOOMMMMAANNDDSS Commands marked with * may be preceded by a number, _N. Notes in parentheses indicate the behavior if _N is given. h H Display this help. - q :q :Q ZZ Exit. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- - e ^E j ^N CR * Forward one line (or _N lines). - y ^Y k ^K ^P * Backward one line (or _N lines). + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). f ^F ^V SPACE * Forward one window (or _N lines). b ^B ESC-v * Backward one window (or _N lines). z * Forward one window (and set window to _N). w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. d ^D * Forward one half-window (and set half-window to _N). u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Left one half screen width (or _N positions). + ESC-( LeftArrow * Right one half screen width (or _N positions). F Forward forever; like "tail -f". r ^R ^L Repaint screen. R Repaint screen, discarding buffered input. --------------------------------------------------- Default "window" is the screen height. Default "half-window" is half of the screen height. - --------------------------------------------------- + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. n * Repeat previous search (for _N-th occurrence). @@ -31,79 +40,181 @@ ESC-u Undo (toggle) search highlighting. --------------------------------------------------- Search patterns may be modified by one or more of: - ! search for NON-matching lines. - * search multiple files. - @ start search at first file (for /) or last file (for ?). - --------------------------------------------------- + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + g < ESC-< * Go to first line in file (or line _N). G > ESC-> * Go to last line in file (or line _N). p % * Go to beginning of file (or _N percent into file). - { * Go to the } matching the (_N-th) { in the top line. - } * Go to the { matching the (_N-th) } in the bottom line. - ( * Go to the ) matching the (_N-th) ( in the top line. - ) * Go to the ( matching the (_N-th) ) in the bottom line. - [ * Go to the ] matching the (_N-th) [ in the top line. - ] * Go to the [ matching the (_N-th) ] in the bottom line. - ESC-^F _<_c_1_> _<_c_2_> * Go to the _c_1 matching the (_N-th) _c_2 in the top line - ESC-^B _<_c_1_> _<_c_2_> * Go to the _c_2 matching the (_N-th) _c_1 in the bottom line. + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_> + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + m_<_l_e_t_t_e_r_> Mark the current position with <letter>. '_<_l_e_t_t_e_r_> Go to a previously marked position. '' Go to the previous position. ^X^X Same as '. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS :e [_f_i_l_e] Examine a new file. ^X^V Same as :e. :n * Examine the (_N-th) next file from the command line. :p * Examine the (_N-th) previous file from the command line. :x * Examine the first (or _N-th) file from the command line. + :d Delete the current file from the command line list. = ^G :f Print current file name. - V Print version number of "less". + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS - -_<_f_l_a_g_> Toggle a command line flag [see FLAGS below]. - __<_f_l_a_g_> Display the setting of a command line flag. + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. +_c_m_d Execute the less cmd each time a new file is examined. - !_c_o_m_m_a_n_d Passes the command to $SHELL to be executed. + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. v Edit the current file with $VISUAL or $EDITOR. - --------------------------------------------------- - FLAGS - - Most flags may be changed either on the command line, - or from within less by using the - command. - - -? Display help (from command line). - -a Forward search skips current screen. - -b [_N] Number of buffers. - -B Don't automatically allocate buffers for pipes. - -c -C Repaint by scrolling/clearing. - -d Dumb terminal. - -e -E Quit at end of file. - -f Force open non-regular files. - -g Don't highlight matches for previous search pattern. - -G Highlight ALL matches for previous search pattern. - -h [_N] Backward scroll limit. - -i Ignore case in searches. - -I Ignore case in searches and in search patterns. - -j [_N] Screen position of target lines. - -k [_f_i_l_e] Use a lesskey file. - -m -M Set prompt style. - -n -N Use line numbers. - -o [_f_i_l_e] Log file. - -O [_f_i_l_e] Log file (unconditionally overwrite). - -p [_p_a_t_t_e_r_n] Start at pattern (from command line). - -P [_p_r_o_m_p_t] Define new prompt. - -q -Q Quiet the terminal bell. - -r Output "raw" control characters. - -s Squeeze multiple blank lines. - -S Chop long lines. - -t [_t_a_g] Find a tag. - -T [_t_a_g_s_f_i_l_e] Use an alternate tags file. - -u -U Change handling of backspaces. - -V Display the version number of "less". - -w Display ~ for lines after end-of-file. - -x [_N] Set tab stops. - -X Don't use termcap init/deinit strings. - -y [_N] Forward scroll limit. - -z [_N] Set size of window. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceeded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Forward search skips current screen. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c -C .... --clear-screen --CLEAR-SCREEN + Repaint by scrolling/clearing. + -d ........ --dumb + Dumb terminal. + -D [_x_n_._n] . --color=_x_n_._n + Set screen colors. (MS-DOS only) + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] + Use a lesskey file. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n -N .... --line-numbers --LINE-NUMBERS + Use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop long lines. + -t [_t_a_g] .. --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + --no-keypad + Don't use termcap keypad init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Horizontal scroll amount (0 = one half screen width) + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ESC-l Move cursor right one character. + LeftArrow ESC-h Move cursor left one character. + CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word. + CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word. + HOME ESC-0 Move cursor to start of line. + END ESC-$ Move cursor to end of line. + BACKSPACE Delete char to left of cursor. + DELETE ESC-x Delete char under cursor. + CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor. + CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor. + CNTL-U ESC (MS-DOS only) Delete entire line. + UpArrow ESC-k Retrieve previous command line. + DownArrow ESC-j Retrieve next command line. + TAB Complete filename & cycle. + SHIFT-TAB ESC-TAB Complete filename & reverse cycle. + CNTL-L Complete filename, list all. diff --git a/usr.bin/less/less.nro b/usr.bin/less/less.nro index 9b9f2ee3b93..aee1011b81f 100644 --- a/usr.bin/less/less.nro +++ b/usr.bin/less/less.nro @@ -1,20 +1,28 @@ -.TH LESS 1 +.TH LESS 1 "Version 390: 17 Jan 2003" .SH NAME less, more \- view files on a crt .SH SYNOPSIS .B "less|more -?" .br +.B "less|more --help" +.br .B "less|more -V" .br -.B "less|more [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]" +.B "less|more --version" +.br +.B "less|more [-[+]aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~]" .br -.B " [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]" +.B " [-b \fIspace\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]" .br -.B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]" +.B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP]" .br -.B " [-T \fItagsfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]" +.B " [-t \fItag\fP] [-T \fItagsfile\fP] [-x \fItab\fP,...] [-y \fIlines\fP]" .br -.B " [+[+]\fIcmd\fP] [\fIfilename\fP]..." +.B " [-[z] \fIlines\fP] [-# \fIshift\fP] [+[+]\fIcmd\fP] [--]" +.br +.B " [\fIfilename\fP]..." +.sp +(See the OPTIONS section for alternate option syntax with long option names.) .SH DESCRIPTION .I Less @@ -59,48 +67,52 @@ two character sequence "ESCAPE", then "v". .IP "h or H" Help: display a summary of these commands. If you forget all the other commands, remember this one. -.PP .IP "SPACE or ^V or f or ^F" Scroll forward N lines, default one window (see option -z below). If N is more than the screen size, only the final screenful is displayed. Warning: some systems use ^V as a special literalization character. -.PP .IP "z" Like SPACE, but if N is specified, it becomes the new window size. -.PP +.IP "ESC-SPACE" +Like SPACE, but scrolls a full screenful, even if it reaches +end-of-file in the process. .IP "RETURN or ^N or e or ^E or j or ^J" Scroll forward N lines, default 1. The entire N lines are displayed, even if N is more than the screen size. -.PP .IP "d or ^D" Scroll forward N lines, default one half of the screen size. If N is specified, it becomes the new default for subsequent d and u commands. -.PP .IP "b or ^B or ESC-v" Scroll backward N lines, default one window (see option -z below). If N is more than the screen size, only the final screenful is displayed. -.PP .IP "w" Like ESC-v, but if N is specified, it becomes the new window size. -.PP .IP "y or ^Y or ^P or k or ^K" Scroll backward N lines, default 1. The entire N lines are displayed, even if N is more than the screen size. Warning: some systems use ^Y as a special job control character. -.PP .IP "u or ^U" Scroll backward N lines, default one half of the screen size. If N is specified, it becomes the new default for subsequent d and u commands. -.PP +.IP "ESC-) or RIGHTARROW" +Scroll horizontally right N characters, default half the screen width +(see the -# option). +If a number N is specified, it becomes the default for future RIGHTARROW +and LEFTARROW commands. +While the text is scrolled, it acts as though the -S option +(chop lines) were in effect. +.IP "ESC-( or LEFTARROW" +Scroll horizontally left N characters, default half the screen width +(see the -# option). +If a number N is specified, it becomes the default for future RIGHTARROW +and LEFTARROW commands. .IP "r or ^R or ^L" Repaint the screen. -.PP .IP R Repaint the screen, discarding any buffered input. Useful if the file is changing while it is being viewed. -.PP .IP "F" Scroll forward, and keep trying to read when the end of file is reached. @@ -108,25 +120,17 @@ Normally this command would be used when already at the end of the file. It is a way to monitor the tail of a file which is growing while it is being viewed. (The behavior is similar to the "tail -f" command.) -.PP .IP "g or < or ESC-<" Go to line N in the file, default 1 (beginning of file). (Warning: this may be slow if N is large.) -.PP .IP "G or > or ESC->" Go to line N in the file, default the end of the file. (Warning: this may be slow if N is large, or if N is not specified and standard input, rather than a file, is being read.) -.PP .IP "p or %" Go to a position N percent into the file. N should be between 0 and 100. -(This works if standard input is being read, but only if -.I less -has already read to the end of the file. -It is always fast, but not always useful.) -.PP .IP "{" If a left curly bracket appears in the top line displayed on the screen, @@ -135,7 +139,6 @@ The matching right curly bracket is positioned on the bottom line of the screen. If there is more than one left curly bracket on the top line, a number N may be used to specify the N-th bracket on the line. -.PP .IP "}" If a right curly bracket appears in the bottom line displayed on the screen, @@ -144,19 +147,14 @@ The matching left curly bracket is positioned on the top line of the screen. If there is more than one right curly bracket on the top line, a number N may be used to specify the N-th bracket on the line. -.PP .IP "(" Like {, but applies to parentheses rather than curly brackets. -.PP .IP ")" Like }, but applies to parentheses rather than curly brackets. -.PP .IP "[" Like {, but applies to square brackets rather than curly brackets. -.PP .IP "]" Like }, but applies to square brackets rather than curly brackets. -.PP .IP "ESC-^F" Followed by two characters, acts like {, but uses the two characters as open and close brackets, @@ -172,7 +170,6 @@ go backward to the < which matches the > in the bottom displayed line. .IP m Followed by any lowercase letter, marks the current position with that letter. -.PP .IP "'" (Single quote.) Followed by any lowercase letter, returns to the position which @@ -183,10 +180,8 @@ Followed by a ^ or $, jumps to the beginning or end of the file respectively. Marks are preserved when a new file is examined, so the ' command can be used to switch between input files. -.PP .IP "^X^X" Same as single quote. -.PP .IP /pattern Search forward in the file for the N-th line containing the pattern. N defaults to 1. @@ -199,74 +194,77 @@ Certain characters are special if entered at the beginning of the pattern; they modify the type of search rather than become part of the pattern: .RS -.IP ! +.IP "^N or !" Search for lines which do NOT match the pattern. -.IP * +.IP "^E or *" Search multiple files. -That is, if the search reaches the end of the current file +That is, if the search reaches the END of the current file without finding a match, the search continues in the next file in the command line list. -.IP @ -Begin the search at the first line of the first file +.IP "^F or @" +Begin the search at the first line of the FIRST file in the command line list, regardless of what is currently displayed on the screen or the settings of the -a or -j options. +.IP "^K" +Highlight any text which matches the pattern on the current screen, +but don't move to the first match (KEEP current position). +.IP "^R" +Don't interpret regular expression metacharacters; +that is, do a simple textual comparison. .RE -.PP .IP ?pattern Search backward in the file for the N-th line containing the pattern. The search starts at the line immediately before the top line displayed. .sp Certain characters are special as in the / command: .RS -.IP ! +.IP "^N or !" Search for lines which do NOT match the pattern. -.IP * +.IP "^E or *" Search multiple files. That is, if the search reaches the beginning of the current file without finding a match, the search continues in the previous file in the command line list. -.IP @ +.IP "^F or @" Begin the search at the last line of the last file in the command line list, regardless of what is currently displayed on the screen or the settings of the -a or -j options. +.IP "^K" +As in forward searches. +.IP "^R" +As in forward searches. .RE -.PP .IP "ESC-/pattern" Same as "/*". -.PP .IP "ESC-?pattern" Same as "?*". -.PP .IP n Repeat previous search, for N-th line containing the last pattern. -If the previous search was modified by !, the search is made for the +If the previous search was modified by ^N, the search is made for the N-th line NOT containing the pattern. -If the previous search was modified by *, the search continues +If the previous search was modified by ^E, the search continues in the next (or previous) file if not satisfied in the current file. -There is no effect if the previous search was modified by @. -.PP +If the previous search was modified by ^R, the search is done +without using regular expressions. +There is no effect if the previous search was modified by ^F or ^K. .IP N Repeat previous search, but in the reverse direction. -.PP .IP "ESC-n" Repeat previous search, but crossing file boundaries. The effect is as if the previous search were modified by *. -.PP .IP "ESC-N" Repeat previous search, but in the reverse direction and crossing file boundaries. -.PP .IP "ESC-u" Undo search highlighting. Turn off highlighting of strings matching the current search pattern. If highlighting is already off because of a previous ESC-u command, turn highlighting back on. Any search command will also turn highlighting back on. -(Highlighting can also be disabled by toggling the -G flag; +(Highlighting can also be disabled by toggling the -G option; in that case search commands do not turn highlighting back on.) -.PP .IP ":e [filename]" Examine a new file. If the filename is missing, the "current" file (see the :n and :p commands @@ -274,30 +272,40 @@ below) from the list of files in the command line is re-examined. A percent sign (%) in the filename is replaced by the name of the current file. A pound sign (#) is replaced by the name of the previously examined file. +However, two consecutive percent signs are simply +replaced with a single percent sign. +This allows you to enter a filename that contains a percent sign +in the name. +Similarly, two consecutive pound signs are replaced with a single pound sign. The filename is inserted into the command line list of files so that it can be seen by subsequent :n and :p commands. If the filename consists of several files, they are all inserted into the list of files and the first one is examined. -.PP +If the filename contains one or more spaces, +the entire filename should be enclosed in double quotes +(also see the -" option). .IP "^X^V or E" Same as :e. Warning: some systems use ^V as a special literalization character. -.PP +On such systems, you may not be able to use ^V. .IP ":n" Examine the next file (from the list of files given in the command line). If a number N is specified, the N-th next file is examined. -.PP .IP ":p" Examine the previous file in the command line list. If a number N is specified, the N-th previous file is examined. -.PP .IP ":t" -Go to supplied tag. -.PP +Go to the specified tag. .IP ":x" Examine the first file in the command line list. If a number N is specified, the N-th file in the list is examined. -.PP +.IP ":d" +Remove the current file from the list of files. +.IP "t" +Go to the next tag, if there were more than one matches for the current tag. +See the \-t option for more details about tags. +.IP "T" +Go to the previous tag, if there were more than one matches for the current tag. .IP "= or ^G or :f" Prints some information about the file being viewed, including its name @@ -305,57 +313,67 @@ and the line number and byte offset of the bottom line being displayed. If possible, it also prints the length of the file, the number of lines in the file and the percent of the file above the last displayed line. -.PP .IP \- -Followed by one of the command line option letters (see below), +Followed by one of the command line option letters (see OPTIONS below), this will change the setting of that option and print a message describing the new setting. +If a ^P (CONTROL-P) is entered immediately after the dash, +the setting of the option is changed but no message is printed. If the option letter has a numeric value (such as -b or -h), or a string value (such as -P or -t), a new value may be entered after the option letter. If no new value is entered, a message describing the current setting is printed and nothing is changed. -.PP +.IP \-\- +Like the \- command, but takes a long option name (see OPTIONS below) +rather than a single option letter. +You must press RETURN after typing the option name. +A ^P immediately after the second dash suppresses printing of a +message describing the new setting, as in the \- command. .IP \-+ -Followed by one of the command line option letters (see below), +Followed by one of the command line option letters this will reset the option to its default setting and print a message describing the new setting. (The "\-+\fIX\fP" command does the same thing as "\-+\fIX\fP" on the command line.) This does not work for string-valued options. -.PP -.IP \-\- -Followed by one of the command line option letters (see below), +.IP \-\-+ +Like the \-+ command, but takes a long option name +rather than a single option letter. +.IP \-! +Followed by one of the command line option letters, this will reset the option to the "opposite" of its default setting and print a message describing the new setting. -(The "\-\-\fIX\fP" command does the same thing -as "\-\fIX\fP" on the command line.) This does not work for numeric or string-valued options. -.PP +.IP \-\-! +Like the \-! command, but takes a long option name +rather than a single option letter. .IP _ (Underscore.) -Followed by one of the command line option letters (see below), +Followed by one of the command line option letters, this will print a message describing the current setting of that option. The setting of the option is not changed. -.PP +.IP __ +(Double underscore.) +Like the _ (underscore) command, but takes a long option name +rather than a single option letter. +You must press RETURN after typing the option name. .IP +cmd Causes the specified cmd to be executed each time a new file is examined. For example, +G causes .I less to initially display each file starting at the end rather than the beginning. -.PP .IP V Prints the version number of .I less being run. -.PP -.IP "q or :q or :Q or ZZ" +.IP "q or Q or :q or :Q or ZZ" Exits .I less. .PP The following -three +four commands may or may not be valid, depending on your particular installation. .PP .IP v @@ -364,7 +382,6 @@ The editor is taken from the environment variable VISUAL if defined, or EDITOR if VISUAL is not defined, or defaults to "vi" if neither VISUAL nor EDITOR is defined. See also the discussion of LESSEDIT under the section on PROMPTS below. -.PP .IP "! shell-command" Invokes a shell to run the shell-command given. A percent sign (%) in the command is replaced by the name of the @@ -372,9 +389,9 @@ current file. A pound sign (#) is replaced by the name of the previously examined file. "!!" repeats the last shell command. "!" with no shell command simply invokes a shell. -In all cases, the shell is taken from the environment variable SHELL, +On Unix systems, the shell is taken from the environment variable SHELL, or defaults to "sh". -.PP +On MS-DOS and OS/2 systems, the shell is the normal command processor. .IP "| <m> shell-command" <m> represents any mark letter. Pipes a section of the input file to the given shell command. @@ -382,6 +399,9 @@ The section of the file to be piped is between the first line on the current screen and the position marked by the letter. <m> may also be ^ or $ to indicate beginning or end of file respectively. If <m> is . or newline, the current screen is piped. +.IP "s filename" +Save the input to a file. +This only works if the input is a pipe, not an ordinary file. .PP .SH OPTIONS Command line options are described below. @@ -389,11 +409,24 @@ Most options may be changed while .I less is running, via the "\-" command. .PP -Options are also taken from the environment variable "LESS" if the -command is -.I less -, or from the environment variable "MORE" if the command is -.I more. +Most options may be given in one of two forms: +either a dash followed by a single letter, +or two dashes followed by a long option name. +A long option name may be abbreviated as long as +the abbreviation is unambiguous. +For example, --quit-at-eof may be abbreviated --quit, but not +--qui, since both --quit-at-eof and --quiet begin with --qui. +Some long option names are in uppercase, such as --QUIT-AT-EOF, as +distinct from --quit-at-eof. +Such option names need only have their first letter capitalized; +the remainder of the name may be in either case. +For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF. +.PP +Options are also taken from the environment variable "LESS" +if the command is +.IR less , +or from the environment variable "MORE" if the command is +.IR more . For example, to avoid typing "less -options ..." each time .I less @@ -407,61 +440,80 @@ or if you use .sp LESS="-options"; export LESS .sp +On MS-DOS, you don't need the quotes, but you should replace any +percent signs in the options string by double percent signs. +.sp The environment variable is parsed before the command line, so command line options override the LESS environment variable. If an option appears in the LESS variable, it can be reset -to its default on the command line by beginning the command -line option with "-+". +to its default value on the command line by beginning the command +line option with "\-+". .sp -A dollar sign ($) may be used to signal the end of an option string. -This is important only for options like -P which take a -following string. -.IP -? +For options like -P or -D which take a following string, +a dollar sign ($) must be used to signal the end of the string. +For example, to set two -D options on MS-DOS, you must have +a dollar sign between them, like this: +.sp +LESS="-Dn9.1$-Ds4.1" +.sp +.IP "-? or --help" This option displays a summary of the commands accepted by .I less (the same as the h command). -If this option is given, all other options are ignored, and -.I less -exits after the help screen is viewed. (Depending on how your shell interprets the question mark, -it may be necessary to quote the question mark, thus: "-\\?".) -.IP -a +it may be necessary to quote the question mark, thus: "-\e?".) +.IP "-a or --search-skip-screen" Causes searches to start after the last line displayed on the screen, thus skipping all lines displayed on the screen. By default, searches start at the second line on the screen (or after the last found line; see the -j option). -.IP -b\fIn\fP -Specifies the number of buffers +.IP "-b\fIn\fP or --buffers=\fIn\fP" +Specifies the amount of buffer space .I less -will use for each file. -Buffers are 1K, and by default 10 buffers are used for each file -(except if the file is a pipe; see the -B option). -The number \fIn\fP specifies a different number of buffers to use. -.IP -B +will use for each file, in units of kilobytes (1024 bytes). +By default 64K of buffer space is used for each file +(unless the file is a pipe; see the -B option). +The -b option specifies instead that \fIn\fP kilobytes of +buffer space should be used for each file. +If \fIn\fP is -1, buffer space is unlimited; that is, +the entire file is read into memory. +.IP "-B or --auto-buffers" By default, when data is read from a pipe, buffers are allocated automatically as needed. If a large amount of data is read from the pipe, this can cause a large amount of memory to be allocated. The -B option disables this automatic allocation of buffers for pipes, -so that only the number of buffers specified by the -b option are used. +so that only 64K +(or the amount of space specified by the -b option) +is used for the pipe. Warning: use of -B can result in erroneous display, since only the most recently viewed part of the file is kept in memory; any earlier data is lost. -.IP -c +.IP "-c or --clear-screen" Causes full screen repaints to be painted from the top line down. By default, full screen repaints are done by scrolling from the bottom of the screen. -.IP -C +.IP "-C or --CLEAR-SCREEN" The -C option is like -c, but the screen is cleared before it is repainted. -.IP -d -The -d option causes the default prompt to include the basic directions -``[Press space to continue, 'q' to quit.]''. The -d +.IP "-d or --dumb (less only)" +The -d option suppresses the error message +normally displayed if the terminal is dumb; +that is, lacks some important capability, +such as the ability to clear the screen or scroll backward. +The -d option does not otherwise change the behavior of +.I less +on a dumb terminal. +This option is on by default when invoked as +.IR more . +.IP "-d (more only)" +The -d option causes the default prompt to include the +basic directions ``[Press space to continue, 'q' to quit.]''. The -d option also causes the message ``[Press 'h' for instructions.]'' to be displayed when an invalid command is entered (normally, the bell is rung). This option is useful in environments where users may not be experienced with pagers. -.IP -D\fBx\fP\fIcolor\fP +.IP "-D\fBx\fP\fIcolor\fP or --color=\fBx\fP\fIcolor\fP" [MS-DOS only] Sets the color of the text displayed. \fBx\fP is a single character which selects the type of text whose color is @@ -470,57 +522,58 @@ being set: n=normal, s=standout, d=bold, u=underlined, k=blink. The first number selects the foreground color and the second selects the background color of the text. A single number \fIN\fP is the same as \fIN.0\fP. -.IP -e +.IP "-e or --quit-at-eof" Causes .I less to automatically exit the second time it reaches end-of-file. By default, the only way to exit .I less -is via the "q" command, except in -.I more -mode, where -.I less -will exit at the end of a file. -.IP -E +is via the "q" command. +.IP "-E or --QUIT-AT-EOF" Causes .I less to automatically exit the first time it reaches end-of-file. -.IP -f +.IP "-f or --force" Forces non-regular files to be opened. (A non-regular file is a directory or a device special file.) Also suppresses the warning message when a binary file is opened. By default, .I less will refuse to open non-regular files. -.IP -g +.IP "-F or --quit-if-one-screen" +Causes +.I less +to automatically exit +if the entire file can be displayed on the first screen. +.IP "-g or --hilite-search" Normally, .I less will highlight ALL strings which match the last search command. -The -g flag changes this behavior to highlight only the particular string +The -g option changes this behavior to highlight only the particular string which was found by the last search command. This can cause .I less to run somewhat faster than the default. -.IP -G -The -G flag suppresses all highlighting of strings found by search commands. -.IP -h\fIn\fP +.IP "-G or --HILITE-SEARCH" +The -G option suppresses all highlighting of strings found by search commands. +.IP "-h\fIn\fP or ---max-back-scroll=\fIn\fP" Specifies a maximum number of lines to scroll backward. If it is necessary to scroll backward more than \fIn\fP lines, the screen is repainted in a forward direction instead. (If the terminal does not have the ability to scroll backward, -h0 is implied.) -.IP -i +.IP "-i or --ignore-case" Causes searches to ignore case; that is, uppercase and lowercase are considered identical. This option is ignored if any uppercase letters appear in the search pattern; in other words, if a pattern contains uppercase letters, then that search does not ignore case. -.IP -I +.IP "-I or --IGNORE-CASE" Like -i, but searches ignore case even if the pattern contains uppercase letters. -.IP -j\fIn\fP +.IP "-j\fIn\fP or --jump-target=\fIn\fP" Specifies a line on the screen where the "target" line is to be positioned. A target line is the object of a text search, @@ -536,18 +589,32 @@ after the target line. For example, if "-j4" is used, the target line is the fourth line on the screen, so searches begin at the fifth line on the screen. -.IP -k\fIfilename\fP +.IP "-J or --status-column" +Displays a status column at the left edge of the screen. +The status column shows the lines that matched the current search. +The status column is also used if the -w or -W option is in effect. +.IP "-k\fIfilename\fP or --lesskey-file=\fIfilename\fP" Causes .I less to open and interpret the named file as a .I lesskey (1) file. Multiple -k options may be specified. -If a file called .less exists in the user's home directory, this -file is also used as a +If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or +if a lesskey file is found in a standard place (see KEY BINDINGS), +it is also used as a .I lesskey file. -.IP -m +.IP "-L or --no-lessopen" +Ignore the LESSOPEN environment variable +(see the INPUT PREPROCESSOR section below). +This option can be set from within \fIless\fP, +but it will apply only to files opened subsequently, not to the +file which is currently open. +When invoked as +.IR more , +the LESSOPEN environment variable is ignored by default. +.IP "-m or --long-prompt" Causes .I less to prompt verbosely (like \fImore\fP), @@ -555,25 +622,25 @@ with the percent into the file. By default, .I less prompts with a colon. -.IP -M +.IP "-M or --LONG-PROMPT" Causes .I less to prompt even more verbosely than .I more. -.IP -n +.IP "-n or --line-numbers" Suppresses line numbers. The default (to use line numbers) may cause .I less to run more slowly in some cases, especially with a very large input file. -Suppressing line numbers with the -n flag will avoid this problem. +Suppressing line numbers with the -n option will avoid this problem. Using line numbers means: the line number will be displayed in the verbose prompt and in the = command, and the v command will pass the current line number to the editor (see also the discussion of LESSEDIT in PROMPTS below). -.IP -N +.IP "-N or --LINE-NUMBERS" Causes a line number to be displayed at the beginning of each line in the display. -.IP -o\fIfilename\fP +.IP "-o\fIfilename\fP or --log-file=\fIfilename\fP" Causes .I less to copy its input to the named file as it is being viewed. @@ -582,7 +649,7 @@ not an ordinary file. If the file already exists, .I less will ask for confirmation before overwriting it. -.IP -O\fIfilename\fP +.IP "-O\fIfilename\fP or --LOG-FILE=\fIfilename\fP" The -O option is like -o, but it will overwrite an existing file without asking for confirmation. .sp @@ -593,13 +660,13 @@ to specify a log file. Without a file name, they will simply report the name of the log file. The "s" command is equivalent to specifying -o from within .I less. -.IP -p\fIpattern\fP +.IP "-p\fIpattern\fP or --pattern=\fIpattern\fP" The -p option on the command line is equivalent to specifying +/\fIpattern\fP; that is, it tells .I less to start at the first occurrence of \fIpattern\fP in the file. -.IP -P\fIprompt\fP +.IP "-P\fIprompt\fP or --prompt=\fIprompt\fP" Provides a way to tailor the three prompt styles to your own preference. This option would normally be put in the LESS environment @@ -608,14 +675,17 @@ variable, rather than being typed in with each command. Such an option must either be the last option in the LESS variable, or be terminated by a dollar sign. --P followed by a string changes the default (short) prompt to that string. --Pm changes the medium (-m) prompt to the string, and +-Ps followed by a string changes the default (short) prompt +to that string. +-Pm changes the medium (-m) prompt. -PM changes the long (-M) prompt. -Also, -P= changes the message printed by the = command to the given string. +-Ph changes the prompt for the help screen. +-P= changes the message printed by the = command. +-Pw changes the message printed while waiting for data (in the F command). All prompt strings consist of a sequence of letters and special escape sequences. See the section on PROMPTS for more details. -.IP -q +.IP "-q or --quiet or --silent" Causes moderately "quiet" operation: the terminal bell is not rung if an attempt is made to scroll past the end of the file @@ -624,50 +694,74 @@ If the terminal has a "visual bell", it is used instead. The bell will be rung on certain other errors, such as typing an invalid character. The default is to ring the terminal bell in all such cases. -.IP -Q +.IP "-Q or --QUIET or --SILENT" Causes totally "quiet" operation: the terminal bell is never rung. -.IP -r +.IP "-r or --raw-control-chars" Causes "raw" control characters to be displayed. The default is to display control characters using the caret notation; for example, a control-A (octal 001) is displayed as "^A". -Warning: when the -r flag is used, +Warning: when the -r option is used, .I less cannot keep track of the actual appearance of the screen (since this depends on how the screen responds to each type of control character). Thus, various display problems may result, such as long lines being split in the wrong place. -.IP -s +.IP "-R or --RAW-CONTROL-CHARS" +Like -r, but tries to keep track of the screen appearance where possible. +This works only if the input consists of normal text and possibly some +ANSI "color" escape sequences, which are sequences of the form: +.sp + ESC [ ... m +.sp +where the "..." is zero or more characters other than "m". +For the purpose of keeping track of screen appearance, +all control characters and all ANSI color escape sequences are +assumed to not move the cursor. +You can make +.I less +think that characters other than "m" can end ANSI color escape sequences +by setting the environment variable LESSANSIENDCHARS to the list of +characters which can end a color escape sequence. +.IP "-s or --squeeze-blank-lines" Causes consecutive blank lines to be squeezed into a single blank line. This is useful when viewing .I nroff output. -.IP -S +.IP "-S or --chop-long-lines" Causes lines longer than the screen width to be chopped rather than folded. -That is, the remainder of a long line is simply discarded. +That is, the portion of a long line that does not fit in +the screen width is not shown. The default is to fold long lines; that is, display the remainder on the next line. -.IP -t\fItag\fP +.IP "-t\fItag\fP or --tag=\fItag\fP" The -t option, followed immediately by a TAG, will edit the file containing that tag. -For this to work, there must be a file called "tags" in the -current directory, which was previously built by the +For this to work, tag information must be available; +for example, there may be a file in the current directory called "tags", +which was previously built by .I ctags -(1) command. -This option may also be specified from within +(1) or an equivalent command. +If the environment variable LESSGLOBALTAGS is set, it is taken to be +the name of a command compatible with +.I global +(1), and that command is executed to find the tag. +(See http://www.gnu.org/software/global/global.html). +The -t option may also be specified from within .I less (using the \- command) as a way of examining a new file. The command ":t" is equivalent to specifying -t from within .I less. -.IP -T\fItagsfile\fP +.IP "-T\fItagsfile\fP or --tag-file=\fItagsfile\fP" Specifies a tags file to be used instead of "tags". -.IP -u +.IP "-u or --underline-special" Causes backspaces and carriage returns to be treated as printable characters; that is, they are sent to the terminal when they appear in the input. -.IP -U -Causes backspaces and carriage returns to be treated as control characters; +.IP "-U or --UNDERLINE-SPECIAL" +Causes backspaces, tabs and carriage returns to be +treated as control characters; that is, they are handled as specified by the -r option. .sp By default, if neither -u nor -U is given, @@ -681,33 +775,50 @@ the overstruck text is printed using the terminal's hardware boldface capability. Other backspaces are deleted, along with the preceding character. Carriage returns immediately followed by a newline are deleted. -Other carriage returns are handled as specified by the -r option. +other carriage returns are handled as specified by the -r option. Text which is overstruck or underlined can be searched for if neither -u nor -U is in effect. -.IP -V +.IP "-V or --version" Displays the version number of .I less. -.IP -w -Causes blank lines to be used to represent lines -past the end of the file. -By default, -a tilde character (~) is used. -.IP -x\fIn\fP -Sets tab stops every \fIn\fP positions. +.IP "-w or --hilite-unread" +Temporarily highlights the first "new" line after a forward movement +of a full page. +The first "new" line is the line immediately following the line previously +at the bottom of the screen. +Also highlights the target line after a g or p command. +The highlight is removed at the next command which causes movement. +The entire line is highlighted, unless the -J option is in effect, +in which case only the status column is highlighted. +.IP "-W or --HILITE-UNREAD" +Like -w, but temporarily highlights the first new line after any +forward movement command larger than one line. +.IP "-x\fIn\fP,... or --tabs=\fIn\fP,..." +Sets tab stops. +If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP. +If multiple values separated by commas are specified, tab stops +are set at those positions, and then continue with the same spacing as the +last two. +For example, \fI-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc. The default for \fIn\fP is 8. -.IP -X +.IP "-X or --no-init" Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen. -.IP -y\fIn\fP +.IP "--no-keypad" +Disables sending the keypad initialization and deinitialization strings +to the terminal. +This is sometimes useful if the keypad strings make the numeric +keypad behave in an undesirable manner. +.IP "-y\fIn\fP or --max-forw-scroll=\fIn\fP" Specifies a maximum number of lines to scroll forward. If it is necessary to scroll forward more than \fIn\fP lines, the screen is repainted instead. The -c or -C option may be used to repaint from the top of the screen if desired. By default, any forward movement causes scrolling. -.IP -[z]\fIn\fP +.IP "-[z]\fIn\fP or --window=\fIn\fP" Changes the default scrolling window size to \fIn\fP lines. The default is one screenful. The z and w commands can also be used to change the window size. @@ -721,6 +832,32 @@ lines less than the current screen size. For example, if the screen is 24 lines, \fI-z-4\fP sets the scrolling window to 20 lines. If the screen is resized to 40 lines, the scrolling window automatically changes to 36 lines. +.IP "-\fI\(dqcc\fP\ or\ --quotes=\fIcc\fP" +Changes the filename quoting character. +This may be necessary if you are trying to name a file +which contains both spaces and quote characters. +Followed by a single character, this changes the quote character to that +character. +Filenames containing a space should then be surrounded by that character +rather than by double quotes. +Followed by two characters, changes the open quote to the first character, +and the close quote to the second character. +Filenames containing a space should then be preceded by the open quote +character and followed by the close quote character. +Note that even after the quote characters are changed, this option +remains -" (a dash followed by a double quote). +.IP "-~ or --tilde" +Normally lines after end of file are displayed as a single tilde (~). +This option causes lines after end of file to be displayed as blank lines. +.IP "-# or --shift" +Specifies the default number of positions to scroll horizontally +in the RIGHTARROW and LEFTARROW commands. +If the number specified is zero, it sets the default number of +positions to one half of the screen width. +.IP -- +A command line argument of "--" marks the end of option arguments. +Any arguments following this are interpreted as filenames. +This can be useful when viewing a file whose name begins with a "-" or "+". .IP + If a command line option begins with \fB+\fP, the remainder of that option is taken to be an initial command to @@ -782,13 +919,17 @@ Complete the partial filename to the left of the cursor. If it matches more than one filename, the first match is entered into the command line. Repeated TABs will cycle thru the other matching filenames. +If the completed filename is a directory, a "/" is appended to the filename. +(On MS-DOS systems, a "\e" is appended.) +The environment variable LESSSEPARATOR can be used to specify a +different character to append to a directory name. .IP "BACKTAB [ ESC-TAB ]" -Like TAB, but cycles in the reverse direction thru the matching filenames. +Like, TAB, but cycles in the reverse direction thru the matching filenames. .IP "^L" Complete the partial filename to the left of the cursor. If it matches more than one filename, all matches are entered into the command line (if they fit). -.IP "^U (Unix) or ESC (MS-DOS)" +.IP "^U (Unix and OS/2) or ESC (MS-DOS)" Delete the entire command line, or cancel the command if the command line is empty. If you have changed your line-kill character in Unix to something @@ -800,15 +941,55 @@ You may define your own commands by using the program .I lesskey (1) -to create a file called ".less" in your home directory. +to create a lesskey file. This file specifies a set of command keys and an action associated with each key. You may also use .I lesskey -to change the line-editing keys (see LINE EDITING). +to change the line-editing keys (see LINE EDITING), +and to set environment variables. +If the environment variable LESSKEY is set, +.I less +uses that as the name of the lesskey file. +Otherwise, +.I less +looks in a standard place for the lesskey file: +On Unix systems, +.I less +looks for a lesskey file called "$HOME/.less". +On MS-DOS and Windows systems, +.I less +looks for a lesskey file called "$HOME/_less", and if it is not found there, +then looks for a lesskey file called "_less" in any directory specified +in the PATH environment variable. +On OS/2 systems, +.I less +looks for a lesskey file called "$HOME/less.ini", and if it is not found, +then looks for a lesskey file called "less.ini" in any directory specified +in the INIT environment variable, and if it not found there, +then looks for a lesskey file called "less.ini" in any directory specified +in the PATH environment variable. See the .I lesskey manual page for more details. +.P +A system-wide lesskey file may also be set up to provide key bindings. +If a key is defined in both a local lesskey file and in the +system-wide file, key bindings in the local file take precedence over +those in the system-wide file. +If the environment variable LESSKEY_SYSTEM is set, +.I less +uses that as the name of the system-wide lesskey file. +Otherwise, +.I less +looks in a standard place for the system-wide lesskey file: +On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless. +(However, if +.I less +was built with a different sysconf directory than /usr/local/etc, +that directory is where the sysless file is found.) +On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless. +On OS/2 systems, the system-wide lesskey file is c:\esysless.ini. .SH "INPUT PREPROCESSOR" You may define an "input preprocessor" for @@ -817,7 +998,7 @@ Before .I less opens a file, it first gives your input preprocessor a chance to modify the way the contents of the file are displayed. -An input preprocessor is simply an executable program (or shell script) +An input preprocessor is simply an executable program (or shell script), which writes the contents of the file to a different file, called the replacement file. The contents of the replacement file are then displayed @@ -867,17 +1048,15 @@ lessopen.sh: .br case "$1" in .br - *.Z|*.gz) TFILE=`mktemp /tmp/less.XXXXXX` || exit 1 + *.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null .br - gunzip -c $1 >${TFILE} 2>/dev/null + if [ -s /tmp/less.$$ ]; then .br - if [ -s ${TFILE} ]; then -.br - echo ${TFILE} + echo /tmp/less.$$ .br else .br - rm -f ${TFILE} + rm -f /tmp/less.$$ .br fi .br @@ -920,7 +1099,7 @@ previous example scripts: .PP lesspipe.sh: .br - !# /bin/sh + #! /bin/sh .br case "$1" in .br @@ -955,20 +1134,32 @@ be considered normal, control, and binary. The LESSCHARSET environment variable may be used to select a character set. Possible values for LESSCHARSET are: .IP ascii -The default character set. BS, TAB, NL, CR, and formfeed are control characters, -all chars with values between 127 and 255 are binary, -and all others are normal. -.IP latin1 -Selects the ISO 8859/1 character set. -latin-1 is the same as ASCII, except characters between 161 and 255 are +all chars with values between 32 and 126 are normal, +and all others are binary. +.IP iso8859 +Selects an ISO 8859 character set. +This is the same as ASCII, except characters between 160 and 255 are treated as normal characters. +.IP latin1 +Same as iso8859. +.IP latin9 +Same as iso8859. .IP dos Selects a character set appropriate for MS-DOS. +.IP ebcdic +Selects an EBCDIC character set. +.IP IBM-1047 +Selects an EBCDIC character set used by OS/390 Unix Services. +This is the EBCDIC analogue of latin1. You get similar results +by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US +in your environment. .IP koi8-r Selects a Russian character set. .IP next Selects a character set appropriate for NeXT computers. +.IP utf-8 +Selects the UTF-8 encoding of the ISO 10646 character set. .PP In special cases, it may be desired to tailor .I less @@ -992,21 +1183,39 @@ to each of the possible values for LESSCHARSET: .sp ascii\ 8bcccbcc18b95.b .br - latin1 8bcccbcc18b95.33b. -.br dos\ \ \ 8bcccbcc12bc5b95.b. .br + ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b +.br + \ \ \ \ \ \ 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b. +.br + IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc +.br + \ \ \ \ \ \ 191.b +.br + iso8859 8bcccbcc18b95.33b. +.br koi8-r 8bcccbcc18b95.b128. .br + latin1 8bcccbcc18b95.33b. +.br next\ \ 8bcccbcc18b95.bb125.bb .PP -If neither LESSCHARSET nor LESSCHARDEF is set, -but your system supports the +If neither LESSCHARSET nor LESSCHARDEF is set, +but the string "UTF-8" is found in the LC_ALL, LC_TYPE or LANG +environment variables, then the default character set is utf-8. +.PP +If that string is not found, but your system supports the .I setlocale interface, .I less will use setlocale to determine the character set. -setlocale is controlled by setting the LANG or LC_CTYPE environment variables. +setlocale is controlled by setting the LANG or LC_CTYPE environment +variables. +.PP +Finally, if the +.I setlocale +interface is also not available, the default character set is latin1. .PP Control and binary characters are displayed in standout (reverse video). Each such character is displayed in caret notation if possible @@ -1017,13 +1226,14 @@ This format can be changed by setting the LESSBINFMT environment variable. LESSBINFMT may begin with a "*" and one character to select the display attribute: -"*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout. +"*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout, +and "*n" is normal. If LESSBINFMT does not begin with a "*", normal attribute is assumed. The remainder of LESSBINFMT is a string which may include one printf-style escape sequence (a % followed by x, X, o, d, etc.). For example, if LESSBINFMT is "*u[%x]", binary characters are displayed in underlined hexadecimal surrounded by brackets. -The default if no LESSBINFMT is specified is "*d<%X>". +The default if no LESSBINFMT is specified is "*s<%X>". .SH "PROMPTS" The -P option allows you to tailor the prompt to your preference. @@ -1047,6 +1257,15 @@ a "B" means use the line just after the bottom line, and a "j" means use the "target" line, as specified by the -j option. .IP "%B" Replaced by the size of the current input file. +.IP "%c" +Replaced by the column number of the text appearing in the first +column of the screen. +.IP "%d\fIX\fP" +Replaced by the page number of a line in the input file. +The line to be used is determined by the \fIX\fP, as with the %b option. +.IP "%D" +Replaced by the number of pages in the input file, +or equivalently, the page number of the last line in the input file. .IP "%E" Replaced by the name of the editor (from the VISUAL environment variable, or the EDITOR environment variable if VISUAL is not defined). @@ -1064,7 +1283,10 @@ Replaced by the line number of the last line in the input file. .IP "%m" Replaced by the total number of input files. .IP "%p\fIX\fP" -Replaced by the percent into the current input file. +Replaced by the percent into the current input file, based on byte offsets. +The line used is determined by the \fIX\fP as with the %b option. +.IP "%P\fIX\fP" +Replaced by the percent into the current input file, based on line numbers. The line used is determined by the \fIX\fP as with the %b option. .IP "%s" Same as %B. @@ -1095,6 +1317,10 @@ True if any characters have been included in the prompt so far. True if the byte offset of the specified line is known. .IP "?B" True if the size of current input file is known. +.IP "?c" +True if the text is horizontally shifted (%c is not zero). +.IP "?d\fIX\fP" +True if the page number of the specified line is known. .IP "?e" True if at end-of-file. .IP "?f" @@ -1109,7 +1335,10 @@ True if there is more than one input file. .IP "?n" True if this is the first prompt in a new input file. .IP "?p\fIX\fP" -True if the percent into the current input file +True if the percent into the current input file, based on byte offsets, +of the specified line is known. +.IP "?P\fIX\fP" +True if the percent into the current input file, based on line numbers, of the specified line is known. .IP "?s" Same as "?B". @@ -1130,7 +1359,7 @@ Some examples: This prompt prints the filename, if known; otherwise the string "Standard input". .sp -?f%f .?ltLine %lt:?pt%pt\\%:?btByte %bt:-... +?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-... .sp This prompt would print the filename, if known. The filename is followed by the line number, if known, @@ -1140,7 +1369,7 @@ Notice how each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash. .sp -?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t +?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t .sp This prints the filename if this is the first prompt in a file, followed by the "file N of N" message if there is more @@ -1154,18 +1383,18 @@ the other two prompts (-m and -M respectively). Each is broken into two lines here for readability only. .nf .sp -?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.: - ?pB%pB\\%:byte\ %bB?s/%s...%t +?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.: + ?pB%pB\e%:byte\ %bB?s/%s...%t .sp -?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt?L/%L.\ :byte\ %bB?s/%s.\ . - ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t +?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ : + byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t .sp .fi And here is the default message produced by the = command: .nf .sp -?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt?L/%L.\ . - byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t +?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ . + byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t .fi .PP The prompt expansion features are also used for another purpose: @@ -1184,7 +1413,43 @@ If your editor does not accept the "+linenumber" syntax, or has other differences in invocation syntax, the LESSEDIT variable can be changed to modify this default. +.SH SECURITY +When the environment variable LESSSECURE is set to 1, +.I less +runs in a "secure" mode. +This means these features are disabled: +.RS +.IP "!" +the shell command +.IP "|" +the pipe command +.IP ":e" +the examine command. +.IP "v" +the editing command +.IP "s -o" +log files +.IP "-k" +use of lesskey files +.IP "-t" +use of tags files +.IP " " +metacharacters in filenames, such as * +.IP " " +filename completion (TAB, ^L) +.RE +.PP +Less can also be compiled to be permanently in "secure" mode. + .SH "ENVIRONMENT VARIABLES" +Environment variables may be specified either in the system environment +as usual, or in a +.I lesskey +(1) file. +If environment variables are defined in more than one place, +variables defined in a local lesskey file take precedence over +variables defined in the system environment, which take precedence +over variables defined in the system-wide lesskey file. .IP COLUMNS Sets the number of columns on the screen. Takes precedence over the number of columns specified by the TERM variable. @@ -1194,19 +1459,25 @@ LINES and COLUMNS environment variables.) .IP EDITOR The name of the editor (used for the v command). .IP HOME -Name of the user's home directory (used to find a .less file). +Name of the user's home directory +(used to find a lesskey file on Unix and OS/2 systems). +.IP "HOMEDRIVE, HOMEPATH" +Concatenation of the HOMEDRIVE and HOMEPATH environment variables is +the name of the user's home directory if the HOME variable is not set +(only in the Windows version). +.IP INIT +Name of the user's init directory (used to find a lesskey file on OS/2 systems). .IP LANG Language for determining the character set. .IP LC_CTYPE Language for determining the character set. .IP LESS -Flags which are passed to +Options which are passed to .I less automatically. -.IP MORE -Flags which are passed to -.I more -automatically. +.IP LESSANSIENDCHARS +Characters which are assumed to end an ANSI color escape sequence +(default "m"). .IP LESSBINFMT Format for displaying non-printable, non-control characters. .IP LESSCHARDEF @@ -1215,16 +1486,45 @@ Defines a character set. Selects a predefined character set. .IP LESSCLOSE Command line to invoke the (optional) input-postprocessor. +.IP LESSECHO +Name of the lessecho program (default "lessecho"). +The lessecho program is needed to expand metacharacters, such as * and ?, +in filenames on Unix systems. .IP LESSEDIT Editor prototype string (used for the v command). See discussion under PROMPTS. -.IP LESSHELP -Name of the help file. +.IP LESSGLOBALTAGS +Name of the command used by the -t option to find global tags. +Normally should be set to "global" if your system has the +.I global +(1) command. If not set, global tags are not used. +.IP LESSKEY +Name of the default lesskey(1) file. +.IP LESSKEY_SYSTEM +Name of the default system-wide lesskey(1) file. +.IP LESSMETACHARS +List of characters which are considered "metacharacters" by the shell. +.IP LESSMETAESCAPE +Prefix which less will add before each metacharacter in a +command sent to the shell. +If LESSMETAESCAPE is an empty string, commands containing +metacharacters will not be passed to the shell. .IP LESSOPEN Command line to invoke the (optional) input-preprocessor. +.IP LESSSECURE +Runs less in "secure" mode. +See discussion under SECURITY. +.IP LESSSEPARATOR +String to be appended to a directory name in filename completion. .IP LINES Sets the number of lines on the screen. Takes precedence over the number of lines specified by the TERM variable. +(But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD, +the window system's idea of the screen size takes precedence over the +LINES and COLUMNS environment variables.) +.IP PATH +User's search path (used to find a lesskey file +on MS-DOS and OS/2 systems). .IP SHELL The shell used to execute the ! command, as well as to expand filenames. .IP TERM @@ -1239,8 +1539,8 @@ lesskey(1) .SH WARNINGS The = command and prompts (unless changed by -P) -report the line number of the line at the top of the screen, -but the byte and percent of the line at the bottom of the screen. +report the line numbers of the lines at the top and bottom of the screen, +but the byte and percent of the line after the one at the bottom of the screen. .PP If the :e command is used to name more than one file, and one of the named files has been viewed previously, @@ -1254,7 +1554,53 @@ to avoid possible problems. In certain cases, when search highlighting is enabled and a search pattern begins with a ^, more text than the matching string may be highlighted. - +(This problem does not occur when less is compiled to use the POSIX +regular expression package.) +.PP +When viewing text containing ANSI color escape sequences using the -R option, +searching will not find text containing an embedded escape sequence. +Also, search highlighting may change the color of some of the text +which follows the highlighted text. +.PP +On some systems, +.I setlocale +claims that ASCII characters 0 thru 31 are control characters +rather than binary characters. +This causes +.I less +to treat some binary files as ordinary, non-binary files. +To workaround this problem, set the environment variable +LESSCHARSET to "ascii" (or whatever character set is appropriate). +.PP +See http://www.greenwoodsoftware.com/less for the latest list of known bugs in this +version of less. .SH COPYRIGHT -Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman +Copyright (C) 2002 Mark Nudelman +.PP +less is part of the GNU project and is free software. +You can redistribute it and/or modify it +under the terms of either +(1) the GNU General Public License as published by +the Free Software Foundation; or (2) the Less License. +See the file README in the less distribution for more details +regarding redistribution. +You should have received a copy of the GNU General Public License +along with the source for less; see the file COPYING. +If not, write to the Free Software Foundation, 59 Temple Place, +Suite 330, Boston, MA 02111-1307, USA. +You should also have received a copy of the Less License; +see the file LICENSE. +.PP +less is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +.SH AUTHOR +.PP +Mark Nudelman <markn@greenwoodsoftware.com> +.br +Send bug reports or comments to the above address or to bug-less@gnu.org. +.br +For more information, see the less homepage at http://www.greenwoodsoftware.com/less. diff --git a/usr.bin/less/lessecho.c b/usr.bin/less/lessecho.c index 35685780456..0c766f073bb 100644 --- a/usr.bin/less/lessecho.c +++ b/usr.bin/less/lessecho.c @@ -28,7 +28,7 @@ #include "less.h" -static char *version = "$Revision: 1.1 $"; +static char *version = "$Revision: 1.2 $"; static int quote_all = 0; static char openquote = '"'; diff --git a/usr.bin/less/lesskey.c b/usr.bin/less/lesskey.c index 7d360954017..9c31c9c1b4b 100644 --- a/usr.bin/less/lesskey.c +++ b/usr.bin/less/lesskey.c @@ -1,29 +1,11 @@ -/* $OpenBSD: lesskey.c,v 1.4 2003/04/05 01:03:35 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -65,8 +47,12 @@ * * Blank lines and lines which start with # are ignored, * except for the special control lines: + * #command Signals the beginning of the command + * keys section. * #line-edit Signals the beginning of the line-editing * keys section. + * #env Signals the beginning of the environment + * variable section. * #stop Stops command parsing in less; * causes all default keys to be disabled. * @@ -107,80 +93,87 @@ struct cmdname 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, - "display-flag", A_DISP_OPTION, - "display-option", A_DISP_OPTION, - "end", A_GOEND, - "examine", A_EXAMINE, - "first-cmd", A_FIRSTCMD, - "firstcmd", A_FIRSTCMD, - "flush-repaint", A_FREPAINT, - "forw-bracket", A_F_BRACKET, - "forw-forever", A_F_FOREVER, - "forw-line", A_F_LINE, - "forw-line-force", A_FF_LINE, - "forw-screen", A_F_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, - "next-file", A_NEXT_FILE, - "noaction", A_NOACTION, - "percent", A_PERCENT, - "pipe", A_PIPE, - "prev-file", A_PREV_FILE, - "quit", A_QUIT, - "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, - "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 }, + { "first-cmd", A_FIRSTCMD }, + { "firstcmd", A_FIRSTCMD }, + { "flush-repaint", A_FREPAINT }, + { "forw-bracket", A_F_BRACKET }, + { "forw-forever", A_F_FOREVER }, + { "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 } }; struct cmdname editnames[] = { - "back-complete", EC_B_COMPLETE, - "backspace", EC_BACKSPACE, - "delete", EC_DELETE, - "down", EC_DOWN, - "end", EC_END, - "expand", EC_EXPAND, - "forw-complete", EC_F_COMPLETE, - "home", EC_HOME, - "insert", EC_INSERT, - "invalid", EC_UINVALID, - "kill-line", EC_LINEKILL, - "left", EC_LEFT, - "literal", EC_LITERAL, - "right", EC_RIGHT, - "up", EC_UP, - "word-backspace", EC_W_BACKSPACE, - "word-delete", EC_W_DELETE, - "word-left", EC_W_RIGHT, - "word-right", EC_W_LEFT, - NULL, 0 + { "back-complete", EC_B_COMPLETE }, + { "backspace", EC_BACKSPACE }, + { "delete", EC_DELETE }, + { "down", EC_DOWN }, + { "end", EC_END }, + { "expand", EC_EXPAND }, + { "forw-complete", EC_F_COMPLETE }, + { "home", EC_HOME }, + { "insert", EC_INSERT }, + { "invalid", EC_UINVALID }, + { "kill-line", EC_LINEKILL }, + { "left", EC_LEFT }, + { "literal", EC_LITERAL }, + { "right", EC_RIGHT }, + { "up", EC_UP }, + { "word-backspace", EC_W_BACKSPACE }, + { "word-delete", EC_W_DELETE }, + { "word-left", EC_W_LEFT }, + { "word-right", EC_W_RIGHT }, + { NULL, 0 } }; struct table @@ -192,6 +185,7 @@ struct table struct table cmdtable; struct table edittable; +struct table vartable; struct table *currtable = &cmdtable; char fileheader[] = { @@ -207,6 +201,7 @@ char filetrailer[] = { }; char cmdsection[1] = { CMD_SECTION }; char editsection[1] = { EDIT_SECTION }; +char varsection[1] = { VAR_SECTION }; char endsection[1] = { END_SECTION }; char *infile = NULL; @@ -217,6 +212,13 @@ int errors; extern char version[]; + void +usage() +{ + fprintf(stderr, "usage: lesskey [-o output] [input]\n"); + exit(1); +} + char * mkpathname(dirname, filename) char *dirname; @@ -228,11 +230,7 @@ mkpathname(dirname, filename) len = strlen(dirname) + strlen(filename) + 2; pathname = calloc(len, sizeof(char)); strlcpy(pathname, dirname, len); -#if MSOFTC || OS2 - strlcat(pathname, "\\", len); -#else - strlcat(pathname, "/", len); -#endif + strlcat(pathname, PATHNAME_SEP, len); strlcat(pathname, filename, len); return (pathname); } @@ -269,13 +267,47 @@ parse_args(argc, argv) int argc; char **argv; { + char *arg; + outfile = NULL; - while (--argc > 0 && **(++argv) == '-' && argv[0][1] != '\0') + while (--argc > 0) { - switch (argv[0][1]) + arg = *++argv; + if (arg[0] != '-') + /* Arg does not start with "-"; it's not an option. */ + break; + if (arg[1] == '\0') + /* "-" means standard input. */ + break; + if (arg[1] == '-' && arg[2] == '\0') { + /* "--" means end of options. */ + argc--; + argv++; + break; + } + switch (arg[1]) + { + case '-': + if (strncmp(arg, "--output", 8) == 0) + { + if (arg[8] == '\0') + outfile = &arg[8]; + else if (arg[8] == '=') + outfile = &arg[9]; + else + usage(); + goto opt_o; + } + if (strcmp(arg, "--version") == 0) + { + goto opt_V; + } + usage(); + break; case 'o': outfile = &argv[0][2]; + opt_o: if (*outfile == '\0') { if (--argc <= 0) @@ -284,6 +316,7 @@ parse_args(argc, argv) } break; case 'V': + opt_V: printf("lesskey version %s\n", version); exit(0); default: @@ -312,18 +345,25 @@ init_tables() edittable.names = editnames; edittable.pbuffer = edittable.buffer; + + vartable.names = NULL; + vartable.pbuffer = vartable.buffer; } /* * Parse one character of a string. */ - int -tchar(pp) + char * +tstr(pp, xlate) char **pp; + int xlate; { - char *p; - char ch; - int i; + register char *p; + register char ch; + register 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) @@ -343,39 +383,87 @@ tchar(pp) ch = 8*ch + (*p - '0'); while (*++p >= '0' && *p <= '7' && ++i < 3); *pp = p; - return (ch); + if (xlate && ch == CONTROL('K')) + return tstr_control_k; + buf[0] = ch; + buf[1] = '\0'; + return (buf); case 'b': *pp = p+1; - return ('\r'); + return ("\b"); case 'e': *pp = p+1; - return (ESC); + buf[0] = ESC; + buf[1] = '\0'; + return (buf); case 'n': *pp = p+1; - return ('\n'); + return ("\n"); case 'r': *pp = p+1; - return ('\r'); + return ("\r"); case 't': *pp = p+1; - return ('\t'); + return ("\t"); + case 'k': + 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; + case 'l': ch = SK_LEFT_ARROW; break; + case 'U': ch = SK_PAGE_UP; break; + case 'D': ch = SK_PAGE_DOWN; break; + case 'h': ch = SK_HOME; break; + case 'e': ch = SK_END; break; + case 'x': ch = SK_DELETE; break; + default: + error("illegal char after \\k"); + *pp = p+1; + return (""); + } + *pp = p+1; + buf[0] = SK_SPECIAL_KEY; + buf[1] = ch; + buf[2] = 6; + buf[3] = 1; + buf[4] = 1; + buf[5] = 1; + buf[6] = '\0'; + return (buf); + } + /* FALLTHRU */ default: /* * Backslash followed by any other char * just means that char. */ *pp = p+1; - return (*p); + buf[0] = *p; + buf[1] = '\0'; + if (xlate && buf[0] == CONTROL('K')) + return tstr_control_k; + return (buf); } case '^': /* * Carat means CONTROL. */ *pp = p+2; - return (CONTROL(p[1])); + buf[0] = CONTROL(p[1]); + buf[1] = '\0'; + if (buf[0] == CONTROL('K')) + return tstr_control_k; + return (buf); } *pp = p+1; - return (*p); + buf[0] = *p; + buf[1] = '\0'; + if (xlate && buf[0] == CONTROL('K')) + return tstr_control_k; + return (buf); } /* @@ -383,7 +471,7 @@ tchar(pp) */ public char * skipsp(s) - char *s; + register char *s; { while (*s == ' ' || *s == '\t') s++; @@ -395,7 +483,7 @@ skipsp(s) */ public char * skipnsp(s) - char *s; + register char *s; { while (*s != '\0' && *s != ' ' && *s != '\t') s++; @@ -410,10 +498,10 @@ skipnsp(s) clean_line(s) char *s; { - int i; + register int i; s = skipsp(s); - for (i = 0; s[i] != '\n' && s[i] != '\0'; i++) + for (i = 0; s[i] != '\n' && s[i] != '\r' && s[i] != '\0'; i++) if (s[i] == '#' && (i == 0 || s[i-1] != '\\')) break; s[i] = '\0'; @@ -436,6 +524,17 @@ add_cmd_char(c) } /* + * Add a string to the output command table. + */ + void +add_cmd_str(s) + char *s; +{ + for ( ; *s != '\0'; s++) + add_cmd_char(*s); +} + +/* * See if we have a special "control" line. */ int @@ -454,6 +553,11 @@ control_line(s) currtable = &cmdtable; return (1); } + if (PREFIX(s, "#env")) + { + currtable = &vartable; + return (1); + } if (PREFIX(s, "#stop")) { add_cmd_char('\0'); @@ -517,12 +621,6 @@ findaction(actname) return (A_INVALID); } -usage() -{ - fprintf(stderr, "usage: lesskey [-o output] [input]\n"); - exit(1); -} - void error(s) char *s; @@ -532,32 +630,15 @@ error(s) } -/* - * Parse a line from the lesskey file. - */ void -parse_line(line) - char *line; -{ +parse_cmdline(p) char *p; +{ int cmdlen; char *actname; int action; - int c; - - /* - * See if it is a control line. - */ - if (control_line(line)) - return; - /* - * Skip leading white space. - * Replace the final newline with a null byte. - * Ignore blank lines and comments. - */ - p = clean_line(line); - if (*p == '\0') - return; + char *s; + char c; /* * Parse the command string and store it in the current table. @@ -565,11 +646,12 @@ parse_line(line) cmdlen = 0; do { - c = tchar(&p); - if (++cmdlen > MAX_CMDLEN) + s = tstr(&p, 1); + cmdlen += strlen(s); + if (cmdlen > MAX_CMDLEN) error("command too long"); else - add_cmd_char(c); + add_cmd_str(s); } while (*p != ' ' && *p != '\t' && *p != '\0'); /* * Terminate the command string with a null byte. @@ -613,18 +695,103 @@ parse_line(line) */ add_cmd_char(action | A_EXTRA); while (*p != '\0') - add_cmd_char(tchar(&p)); + add_cmd_str(tstr(&p, 0)); add_cmd_char('\0'); } } + void +parse_varline(p) + char *p; +{ + char *s; + + do + { + s = tstr(&p, 0); + add_cmd_str(s); + } while (*p != ' ' && *p != '\t' && *p != '=' && *p != '\0'); + /* + * Terminate the variable name with a null byte. + */ + add_cmd_char('\0'); + + p = skipsp(p); + if (*p++ != '=') + { + error("missing ="); + return; + } + + add_cmd_char(EV_OK|A_EXTRA); + + p = skipsp(p); + while (*p != '\0') + { + s = tstr(&p, 0); + add_cmd_str(s); + } + add_cmd_char('\0'); +} + +/* + * Parse a line from the lesskey file. + */ + void +parse_line(line) + char *line; +{ + char *p; + + /* + * See if it is a control line. + */ + if (control_line(line)) + return; + /* + * Skip leading white space. + * Replace the final newline with a null byte. + * Ignore blank lines and comments. + */ + p = clean_line(line); + if (*p == '\0') + return; + + if (currtable == &vartable) + parse_varline(p); + else + parse_cmdline(p); +} + + int main(argc, argv) int argc; char *argv[]; { FILE *desc; FILE *out; - char line[200]; + 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. @@ -639,8 +806,12 @@ main(argc, argv) desc = stdin; else if ((desc = fopen(infile, "r")) == NULL) { +#if HAVE_PERROR perror(infile); - exit(1); +#else + fprintf(stderr, "Cannot open %s\n", infile); +#endif + usage(); } /* @@ -665,10 +836,16 @@ main(argc, argv) } if (outfile == NULL) + outfile = getenv("LESSKEY"); + if (outfile == NULL) outfile = homefile(LESSKEYFILE); if ((out = fopen(outfile, "wb")) == NULL) { +#if HAVE_PERROR perror(outfile); +#else + fprintf(stderr, "Cannot open %s\n", outfile); +#endif exit(1); } @@ -684,8 +861,13 @@ main(argc, argv) fputint(out, edittable.pbuffer - edittable.buffer); fputbytes(out, (char *)edittable.buffer, edittable.pbuffer-edittable.buffer); + /* Environment variable section */ + fputbytes(out, varsection, sizeof(varsection)); + fputint(out, 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)); - exit(0); + return (0); } diff --git a/usr.bin/less/lesskey.h b/usr.bin/less/lesskey.h index c8a7dcb931d..dc33c584462 100644 --- a/usr.bin/less/lesskey.h +++ b/usr.bin/less/lesskey.h @@ -1,4 +1,13 @@ -/* $OpenBSD: lesskey.h,v 1.2 2001/01/29 01:58:02 niklas Exp $ */ +/* + * 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. + */ + /* * Format of a lesskey file: @@ -20,6 +29,7 @@ #define CMD_SECTION 'c' #define EDIT_SECTION 'e' +#define VAR_SECTION 'v' #define END_SECTION 'x' #define C0_END_LESSKEY_MAGIC 'E' diff --git a/usr.bin/less/line.c b/usr.bin/less/line.c index bc143fca982..773693c0c44 100644 --- a/usr.bin/less/line.c +++ b/usr.bin/less/line.c @@ -1,29 +1,11 @@ -/* $OpenBSD: line.c,v 1.4 2003/04/06 23:38:07 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -35,33 +17,88 @@ #include "less.h" -public char linebuf[1024]; /* Buffer which holds the current output line */ -public int size_linebuf = sizeof(linebuf); +#define IS_CONT(c) (((c) & 0xC0) == 0x80) + +public 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) */ + +public 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 */ -static char attr[1024]; /* Extension of linebuf to hold attributes */ static int curr; /* Index into linebuf */ static int column; /* Printable length, accounting for backspaces, etc. */ -static int lno_indent; /* Number of chars used for line number */ 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 int hilites; /* Number of hilites in this line */ static char pendc; static POSITION pendpos; +static char *end_ansi_chars; static int do_append(); extern int bs_mode; -extern int tabstop; extern int linenums; extern int ctldisp; extern int twiddle; extern int binattr; +extern int status_col; extern int auto_wrap, ignaw; extern int bo_s_width, bo_e_width; extern int ul_s_width, ul_e_width; 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; + +/* + * Initialize from environment variables. + */ + public void +init_line() +{ + end_ansi_chars = lgetenv("LESSANSIENDCHARS"); + if (end_ansi_chars == NULL || *end_ansi_chars == '\0') + end_ansi_chars = "m"; + linebuf = (char *) ecalloc(LINEBUF_SIZE, sizeof(char)); + attr = (char *) ecalloc(LINEBUF_SIZE, sizeof(char)); + size_linebuf = LINEBUF_SIZE; +} + +/* + * Expand the line buffer. + */ + static int +expand_linebuf() +{ + int new_size = size_linebuf + LINEBUF_SIZE; + char *new_buf = (char *) calloc(new_size, sizeof(char)); + char *new_attr = (char *) calloc(new_size, sizeof(char)); + if (new_buf == NULL || new_attr == NULL) + { + if (new_attr != NULL) + free(new_attr); + if (new_buf != NULL) + free(new_buf); + return 1; + } + memcpy(new_buf, linebuf, size_linebuf * sizeof(char)); + memcpy(new_attr, attr, size_linebuf * sizeof(char)); + free(attr); + free(linebuf); + linebuf = new_buf; + attr = new_attr; + size_linebuf = new_size; + return 0; +} /* * Rewind the line buffer. @@ -73,8 +110,13 @@ prewind() column = 0; overstrike = 0; is_null_line = 0; - lno_indent = 0; pendc = '\0'; + lmargin = 0; + if (status_col) + lmargin += 1; +#if HILITE_SEARCH + hilites = 0; +#endif } /* @@ -84,52 +126,163 @@ prewind() plinenum(pos) POSITION pos; { - int lno; - int i; - int n; + register LINENUM linenum = 0; + register int i; + + 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 + * of plinenum to re-seek if necessary. }} + * {{ Since forw_raw_line modifies linebuf, we must + * do this first, before storing anything in linebuf. }} + */ + linenum = find_linenum(pos); + } /* - * We display the line number at the start of each line - * only if the -N option is set. + * Display a status column if the -J option is set. */ - if (linenums != OPT_ONPLUS) - return; - + if (status_col) + { + linebuf[curr] = ' '; + if (start_attnpos != NULL_POSITION && + pos >= start_attnpos && pos < end_attnpos) + attr[curr] = AT_STANDOUT; + else + attr[curr] = 0; + curr++; + column++; + } /* - * 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 - * of plinenum to re-seek if necessary. }} + * Display the line number at the start of each line + * if the -N option is set. */ - lno = find_linenum(pos); - - snprintf(&linebuf[curr], sizeof linebuf - curr, "%6d", lno); - n = strlen(&linebuf[curr]); - column += n; - for (i = 0; i < n; i++) - attr[curr++] = 0; + if (linenums == OPT_ONPLUS) + { + char buf[INT_STRLEN_BOUND(pos) + 2]; + int n; + + linenumtoa(linenum, buf, sizeof(buf)); + n = strlen(buf); + if (n < MIN_LINENUM_WIDTH) + n = MIN_LINENUM_WIDTH; + snprintf(linebuf+curr, sizeof(linebuf)-curr, "%*s ", n, buf); + n++; /* One space after the line number. */ + for (i = 0; i < n; i++) + attr[curr+i] = AT_NORMAL; + curr += n; + column += n; + lmargin += n; + } /* - * Append enough spaces to bring us to the next tab stop. - * {{ We could avoid this at the cost of adding some - * complication to the tab stop logic in pappend(). }} + * Append enough spaces to bring us to the lmargin. */ - if (tabstop == 0) - tabstop = 1; - do + while (column < lmargin) { linebuf[curr] = ' '; attr[curr++] = AT_NORMAL; column++; - } while ((column % tabstop) != 0); - lno_indent = column; + } +} + +/* + * Determine how many characters are required to shift N columns. + */ + static int +shift_chars(s, len) + char *s; + int len; +{ + char *p = s; + + /* + * Each char counts for one column, except ANSI color escape + * sequences use no columns since they don't move the cursor. + */ + while (*p != '\0' && len > 0) + { + if (*p++ != ESC) + { + len--; + } else + { + while (*p != '\0') + { + if (is_ansi_end(*p++)) + break; + } + } + } + return (p - s); +} + +/* + * Determine how many characters are required to shift N columns (UTF version). + * {{ FIXME: what about color escape sequences in UTF mode? }} + */ + static int +utf_shift_chars(s, len) + char *s; + int len; +{ + int ulen = 0; + + while (*s != '\0' && len > 0) + { + if (!IS_CONT(*s)) + len--; + s++; + ulen++; + } + while (IS_CONT(*s)) + { + s++; + ulen++; + } + return (ulen); +} + +/* + * Shift the input line left. + * This means discarding N printable chars at the start of the buffer. + */ + static void +pshift(shift) + int shift; +{ + int i; + int nchars; + + if (shift > column - lmargin) + shift = column - lmargin; + if (shift > curr - lmargin) + shift = curr - lmargin; + + if (utf_mode) + nchars = utf_shift_chars(linebuf + lmargin, shift); + else + nchars = shift_chars(linebuf + lmargin, shift); + if (nchars > curr) + nchars = curr; + for (i = 0; i < curr - nchars; i++) + { + linebuf[lmargin + i] = linebuf[lmargin + i + nchars]; + attr[lmargin + i] = attr[lmargin + i + nchars]; + } + curr -= nchars; + column -= shift; + cshift += shift; } /* * Return the printing width of the start (enter) sequence * for a given character attribute. */ - int + static int attr_swidth(a) int a; { @@ -147,7 +300,7 @@ attr_swidth(a) * Return the printing width of the end (exit) sequence * for a given character attribute. */ - int + static int attr_ewidth(a) int a; { @@ -172,7 +325,10 @@ pwidth(c, a) int c; int a; { - int w; + register int w; + + if (utf_mode && IS_CONT(c)) + return (0); if (c == '\b') /* @@ -211,36 +367,83 @@ backc() } /* + * Are we currently within a recognized ANSI escape sequence? + */ + static int +in_ansi_esc_seq() +{ + int i; + + /* + * 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 (i = curr-1; i >= 0; i--) + { + if (linebuf[i] == ESC) + return (1); + if (is_ansi_end(linebuf[i])) + return (0); + } + return (0); +} + +/* + * Is a character the end of an ANSI escape sequence? + */ + public int +is_ansi_end(c) + char c; +{ + return (strchr(end_ansi_chars, c) != NULL); +} + +/* * Append a character and attribute to the line buffer. */ +#define STORE_CHAR(c,a,pos) \ + do { if (store_char((c),(a),(pos))) return (1); else curr++; } while (0) + static int -storec(c, a, pos) +store_char(c, a, pos) int c; int a; POSITION pos; { - int w; + register int w; + if (a != AT_NORMAL) + last_overstrike = a; #if HILITE_SEARCH if (is_hilited(pos, pos+1, 0)) + { /* * This character should be highlighted. * Override the attribute passed in. */ a = AT_STANDOUT; + hilites++; + } #endif - w = pwidth(c, a); - if (ctldisp > 0 && column + w + attr_ewidth(a) > sc_width) + if (ctldisp == OPT_ONPLUS && in_ansi_esc_seq()) + w = 0; + else + w = pwidth(c, a); + if (ctldisp != OPT_ON && column + w + attr_ewidth(a) > sc_width) /* * Won't fit on screen. */ return (1); - if (curr >= sizeof(linebuf)-2) + if (curr >= size_linebuf-2) + { /* * Won't fit in line buffer. + * Try to expand it. */ - return (1); + if (expand_linebuf()) + return (1); + } /* * Special handling for "magic cookie" terminals. @@ -282,15 +485,49 @@ storec(c, a, 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) + + static int +store_tab(attr, pos) + int attr; + POSITION 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 + { + for (i = ntabstops - 2; i >= 0; i--) + if (to_tab >= tabstops[i]) + break; + to_tab = tabstops[i+1] - to_tab; + } + + do { + STORE_CHAR(' ', attr, pos); + } while (--to_tab > 0); + return 0; +} + +/* * 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) - int c; + register int c; POSITION pos; { + int r; + if (pendc) { if (do_append(pendc, pendpos)) @@ -314,21 +551,54 @@ pappend(c, pos) return (0); } - return (do_append(c, pos)); + r = do_append(c, pos); + /* + * If we need to shift the line, do it. + * But wait until we get to at least the middle of the screen, + * 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) + { + linebuf[curr] = '\0'; + pshift(hshift - cshift); + } + return (r); } +#define IS_UTF8_4BYTE(c) ( ((c) & 0xf8) == 0xf0 ) +#define IS_UTF8_3BYTE(c) ( ((c) & 0xf0) == 0xe0 ) +#define IS_UTF8_2BYTE(c) ( ((c) & 0xe0) == 0xc0 ) +#define IS_UTF8_TRAIL(c) ( ((c) & 0xc0) == 0x80 ) + static int do_append(c, pos) int c; POSITION pos; { - char *s; - int a; + register char *s; + register int a; -#define STOREC(c,a) \ - if (storec((c),(a),pos)) return (1); else curr++ +#define STOREC(c,a) \ + if ((c) == '\t') STORE_TAB((a),pos); else STORE_CHAR((c),(a),pos) - if (overstrike) + if (c == '\b') + { + switch (bs_mode) + { + case BS_NORMAL: + STORE_CHAR(c, AT_NORMAL, pos); + break; + case BS_CONTROL: + goto do_control_char; + case BS_SPECIAL: + if (curr == 0) + break; + backc(); + overstrike = 1; + break; + } + } else if (overstrike) { /* * Overstrike the character at the current position @@ -337,53 +607,93 @@ do_append(c, pos) * bold (if an identical character is overstruck), * or just deletion of the character in the buffer. */ - overstrike = 0; - if ((char)c == linebuf[curr]) - STOREC(linebuf[curr], AT_BOLD); - else if (c == '_') + overstrike--; + if (utf_mode && IS_UTF8_4BYTE(c) && curr > 2 && (char)c == linebuf[curr-3]) + { + backc(); + backc(); + backc(); + STORE_CHAR(linebuf[curr], AT_BOLD, pos); + overstrike = 3; + } else if (utf_mode && (IS_UTF8_3BYTE(c) || (overstrike==2 && IS_UTF8_TRAIL(c))) && curr > 1 && (char)c == linebuf[curr-2]) + { + backc(); + backc(); + STORE_CHAR(linebuf[curr], AT_BOLD, pos); + overstrike = 2; + } else if (utf_mode && curr > 0 && (IS_UTF8_2BYTE(c) || (overstrike==1 && IS_UTF8_TRAIL(c))) && (char)c == linebuf[curr-1]) + { + backc(); + STORE_CHAR(linebuf[curr], AT_BOLD, pos); + overstrike = 1; + } else if (utf_mode && curr > 0 && IS_UTF8_TRAIL(c) && attr[curr-1] == AT_UNDERLINE) + { + STOREC(c, AT_UNDERLINE); + } else if ((char)c == linebuf[curr]) + { + /* + * Overstriking a char with itself means make it bold. + * But overstriking an underscore with itself is + * ambiguous. It could mean make it bold, or + * it could mean make it underlined. + * Use the previous overstrike to resolve it. + */ + if (c == '_' && last_overstrike != AT_NORMAL) + STOREC(c, last_overstrike); + else + STOREC(c, AT_BOLD); + } else if (c == '_') + { + if (utf_mode) + { + int i; + for (i = 0; i < 5; i++) + { + if (curr <= i || !IS_CONT(linebuf[curr-i])) + break; + attr[curr-i-1] = AT_UNDERLINE; + } + } STOREC(linebuf[curr], AT_UNDERLINE); - else if (linebuf[curr] == '_') + } else if (linebuf[curr] == '_') + { + if (utf_mode) + { + if (IS_UTF8_2BYTE(c)) + overstrike = 1; + else if (IS_UTF8_3BYTE(c)) + overstrike = 2; + else if (IS_UTF8_4BYTE(c)) + overstrike = 3; + } STOREC(c, AT_UNDERLINE); - else if (control_char(c)) + } else if (control_char(c)) goto do_control_char; else STOREC(c, AT_NORMAL); - } else if (c == '\b') + } else if (c == '\t') { + /* + * Expand a tab into spaces. + */ switch (bs_mode) { - case BS_NORMAL: - STOREC(c, AT_NORMAL); - break; case BS_CONTROL: goto do_control_char; + case BS_NORMAL: case BS_SPECIAL: - if (curr == 0) - break; - backc(); - overstrike = 1; + STORE_TAB(AT_NORMAL, pos); break; } - } else if (c == '\t') - { - /* - * Expand a tab into spaces. - */ - if (tabstop == 0) - tabstop = 1; - do - { - STOREC(' ', AT_NORMAL); - } while ((column % tabstop) != 0); } else if (control_char(c)) { do_control_char: - if (ctldisp == 0) + if (ctldisp == OPT_ON || (ctldisp == OPT_ONPLUS && c == ESC)) { /* * Output as a normal character. */ - STOREC(c, AT_NORMAL); + STORE_CHAR(c, AT_NORMAL, pos); } else { /* @@ -401,7 +711,7 @@ do_append(c, pos) return (1); for ( ; *s != 0; s++) - STOREC(*s, a); + STORE_CHAR(*s, a, pos); } } else { @@ -427,10 +737,16 @@ pdone(endline) (void) do_append(pendc, pendpos); /* + * Make sure we've shifted the line, if we need to. + */ + if (cshift < hshift) + pshift(hshift - cshift); + + /* * Add a newline if necessary, * and append a '\0' to the end of the line. */ - if (column < sc_width || !auto_wrap || ignaw || ctldisp == 0) + if (column < sc_width || !auto_wrap || ignaw || ctldisp == OPT_ON) { linebuf[curr] = '\n'; attr[curr] = AT_NORMAL; @@ -438,6 +754,19 @@ pdone(endline) } linebuf[curr] = '\0'; attr[curr] = AT_NORMAL; + +#if HILITE_SEARCH + if (status_col && hilites > 0) + { + linebuf[0] = '*'; + attr[0] = AT_STANDOUT; + } +#endif + /* + * If we are done with this line, reset the current shift. + */ + if (endline) + cshift = 0; } /* @@ -447,8 +776,8 @@ pdone(endline) */ public int gline(i, ap) - int i; - int *ap; + register int i; + register int *ap; { char *s; @@ -458,7 +787,7 @@ gline(i, ap) * If there is no current line, we pretend the line is * either "~" or "", depending on the "twiddle" flag. */ - *ap = AT_NORMAL; + *ap = AT_BOLD; s = (twiddle) ? "~\n" : "\n"; return (s[i]); } @@ -474,9 +803,9 @@ gline(i, ap) null_line() { is_null_line = 1; + cshift = 0; } -#if 1 /* * Analogous to forw_line(), but deals with "raw lines": * lines which are not split for screen width. @@ -487,16 +816,15 @@ forw_raw_line(curr_pos, linep) POSITION curr_pos; char **linep; { - char *p; - int c; + register int n; + register int c; POSITION new_pos; if (curr_pos == NULL_POSITION || ch_seek(curr_pos) || (c = ch_forw_get()) == EOI) return (NULL_POSITION); - p = linebuf; - + n = 0; for (;;) { if (c == '\n' || c == EOI) @@ -504,21 +832,22 @@ forw_raw_line(curr_pos, linep) new_pos = ch_tell(); break; } - if (p >= &linebuf[sizeof(linebuf)-1]) + if (n >= size_linebuf-1) { - /* - * Overflowed the input buffer. - * Pretend the line ended here. - * {{ The line buffer is supposed to be big - * enough that this never happens. }} - */ - new_pos = ch_tell() - 1; - break; + if (expand_linebuf()) + { + /* + * Overflowed the input buffer. + * Pretend the line ended here. + */ + new_pos = ch_tell() - 1; + break; + } } - *p++ = c; + linebuf[n++] = c; c = ch_forw_get(); } - *p = '\0'; + linebuf[n] = '\0'; if (linep != NULL) *linep = linebuf; return (new_pos); @@ -533,17 +862,16 @@ back_raw_line(curr_pos, linep) POSITION curr_pos; char **linep; { - char *p; - int c; + register int n; + register int c; POSITION new_pos; if (curr_pos == NULL_POSITION || curr_pos <= ch_zero() || ch_seek(curr_pos-1)) return (NULL_POSITION); - p = &linebuf[sizeof(linebuf)]; - *--p = '\0'; - + n = size_linebuf; + linebuf[--n] = '\0'; for (;;) { c = ch_back_get(); @@ -566,19 +894,32 @@ back_raw_line(curr_pos, linep) new_pos = ch_zero(); break; } - if (p <= linebuf) + if (n <= 0) { + int old_size_linebuf = size_linebuf; + char *fm; + char *to; + if (expand_linebuf()) + { + /* + * Overflowed the input buffer. + * Pretend the line ended here. + */ + new_pos = ch_tell() + 1; + break; + } /* - * Overflowed the input buffer. - * Pretend the line ended here. + * Shift the data to the end of the new linebuf. */ - new_pos = ch_tell() + 1; - break; + for (fm = linebuf + old_size_linebuf, + to = linebuf + size_linebuf; + fm >= linebuf; fm--, to--) + *to = *fm; + n = size_linebuf - old_size_linebuf; } - *--p = c; + linebuf[--n] = c; } if (linep != NULL) - *linep = p; + *linep = &linebuf[n]; return (new_pos); } -#endif diff --git a/usr.bin/less/linenum.c b/usr.bin/less/linenum.c index 6aae1a7ae0a..24026fa327b 100644 --- a/usr.bin/less/linenum.c +++ b/usr.bin/less/linenum.c @@ -1,29 +1,11 @@ -/* $OpenBSD: linenum.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -52,19 +34,18 @@ */ #include "less.h" -#include "position.h" /* * Structure to keep track of a line number and the associated file position. * A doubly-linked circular list of line numbers is kept ordered by line number. */ -struct linenum +struct linenum_info { - struct linenum *next; /* Link to next in the list */ - struct linenum *prev; /* Line to previous in the list */ + 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 */ - int line; /* Line number */ + LINENUM line; /* Line number */ }; /* * "gap" needs some explanation: the gap of any particular line number @@ -81,10 +62,10 @@ struct linenum public int lnloop = 0; /* Are we in the line num loop? */ -static struct linenum anchor; /* Anchor of the list */ -static struct linenum *freelist; /* Anchor of the unused entries */ -static struct linenum pool[NPOOL]; /* The pool itself */ -static struct linenum *spare; /* We always keep one spare entry */ +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 */ extern int linenums; extern int sigs; @@ -96,7 +77,7 @@ extern int sc_height; public void clr_linenum() { - struct linenum *p; + register struct linenum_info *p; /* * Put all the entries on the free list. @@ -123,7 +104,7 @@ clr_linenum() */ static void calcgap(p) - struct linenum *p; + register struct linenum_info *p; { /* * Don't bother to compute a gap for the anchor. @@ -142,22 +123,22 @@ calcgap(p) * FIRST character in the specified line. */ public void -add_lnum(lno, pos) - int lno; +add_lnum(linenum, pos) + LINENUM linenum; POSITION pos; { - struct linenum *p; - struct linenum *new; - struct linenum *nextp; - struct linenum *prevp; - POSITION mingap; + register struct linenum_info *p; + register struct linenum_info *new; + register struct linenum_info *nextp; + register struct linenum_info *prevp; + register POSITION mingap; /* * Find the proper place in the list for the new one. * The entries are sorted by position. */ for (p = anchor.next; p != &anchor && p->pos < pos; p = p->next) - if (p->line == lno) + if (p->line == linenum) /* We already have this one. */ return; nextp = p; @@ -188,7 +169,7 @@ add_lnum(lno, pos) new->next = nextp; new->prev = prevp; new->pos = pos; - new->line = lno; + new->line = linenum; nextp->prev = new; prevp->next = new; @@ -272,12 +253,12 @@ longish() * Find the line number associated with a given position. * Return 0 if we can't figure it out. */ - public int + public LINENUM find_linenum(pos) POSITION pos; { - struct linenum *p; - int lno; + register struct linenum_info *p; + register LINENUM linenum; POSITION cpos; if (!linenums) @@ -316,7 +297,6 @@ find_linenum(pos) * The decision is based on which way involves * traversing fewer bytes in the file. */ - flush(); #if HAVE_TIME startime = get_time(); #endif @@ -329,7 +309,7 @@ find_linenum(pos) if (ch_seek(p->pos)) return (0); loopcount = 0; - for (lno = p->line, cpos = p->pos; cpos < pos; lno++) + for (linenum = p->line, cpos = p->pos; cpos < pos; linenum++) { /* * Allow a signal to abort this loop. @@ -343,13 +323,13 @@ find_linenum(pos) /* * We might as well cache it. */ - add_lnum(lno, cpos); + add_lnum(linenum, cpos); /* * If the given position is not at the start of a line, * make sure we return the correct line number. */ if (cpos > pos) - lno--; + linenum--; } else { /* @@ -358,7 +338,7 @@ find_linenum(pos) if (ch_seek(p->pos)) return (0); loopcount = 0; - for (lno = p->line, cpos = p->pos; cpos > pos; lno--) + for (linenum = p->line, cpos = p->pos; cpos > pos; linenum--) { /* * Allow a signal to abort this loop. @@ -372,10 +352,10 @@ find_linenum(pos) /* * We might as well cache it. */ - add_lnum(lno, cpos); + add_lnum(linenum, cpos); } - return (lno); + return (linenum); } /* @@ -383,14 +363,14 @@ find_linenum(pos) * Return NULL_POSITION if we can't figure it out. */ public POSITION -find_pos(lno) - int lno; +find_pos(linenum) + LINENUM linenum; { - struct linenum *p; + register struct linenum_info *p; POSITION cpos; - int clno; + LINENUM clinenum; - if (lno <= 1) + if (linenum <= 1) /* * Line number 1 is beginning of file. */ @@ -399,14 +379,13 @@ find_pos(lno) /* * Find the entry nearest to the line number we want. */ - for (p = anchor.next; p != &anchor && p->line < lno; p = p->next) + for (p = anchor.next; p != &anchor && p->line < linenum; p = p->next) continue; - if (p->line == lno) + if (p->line == linenum) /* Found it exactly. */ return (p->pos); - flush(); - if (p == &anchor || lno - p->prev->line < p->line - lno) + if (p == &anchor || linenum - p->prev->line < p->line - linenum) { /* * Go forward. @@ -414,7 +393,7 @@ find_pos(lno) p = p->prev; if (ch_seek(p->pos)) return (NULL_POSITION); - for (clno = p->line, cpos = p->pos; clno < lno; clno++) + for (clinenum = p->line, cpos = p->pos; clinenum < linenum; clinenum++) { /* * Allow a signal to abort this loop. @@ -430,7 +409,7 @@ find_pos(lno) */ if (ch_seek(p->pos)) return (NULL_POSITION); - for (clno = p->line, cpos = p->pos; clno > lno; clno--) + for (clinenum = p->line, cpos = p->pos; clinenum > linenum; clinenum--) { /* * Allow a signal to abort this loop. @@ -443,7 +422,7 @@ find_pos(lno) /* * We might as well cache it. */ - add_lnum(clno, cpos); + add_lnum(clinenum, cpos); return (cpos); } @@ -452,13 +431,13 @@ find_pos(lno) * The argument "where" tells which line is to be considered * the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc). */ - public int + public LINENUM currline(where) int where; { POSITION pos; POSITION len; - int lnum; + LINENUM linenum; pos = position(where); len = ch_length(); @@ -466,8 +445,8 @@ currline(where) pos = position(++where); if (pos == NULL_POSITION) pos = len; - lnum = find_linenum(pos); + linenum = find_linenum(pos); if (pos == len) - lnum--; - return (lnum); + linenum--; + return (linenum); } diff --git a/usr.bin/less/lsystem.c b/usr.bin/less/lsystem.c index 9e39a8ed1fe..8fa4683215e 100644 --- a/usr.bin/less/lsystem.c +++ b/usr.bin/less/lsystem.c @@ -1,29 +1,11 @@ -/* $OpenBSD: lsystem.c,v 1.4 2003/04/06 23:38:07 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,12 +14,18 @@ * Necessarily very OS dependent. */ -#include <signal.h> #include "less.h" +#include <signal.h> #include "position.h" -#if MSOFTC +#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; @@ -51,16 +39,19 @@ extern IFILE curr_ifile; * Like plain "system()", but handles resetting terminal modes, etc. */ public void -lsystem(cmd) +lsystem(cmd, donemsg) char *cmd; + char *donemsg; { - int inp; -#if MSOFTC || OS2 - int inp2; + register int inp; +#if HAVE_SHELL + register char *shell; + register char *p; #endif - char *shell; - char *p; IFILE save_ifile; +#if MSDOS_COMPILER + char cwd[FILENAME_MAX+1]; +#endif /* * Print the command which is to be executed, @@ -76,10 +67,21 @@ lsystem(cmd) putstr("\n"); } +#if MSDOS_COMPILER + /* + * 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 + /* * Close the current input file. */ - save_ifile = curr_ifile; + save_ifile = save_curr_ifile(); (void) edit_ifile(NULL_IFILE); /* @@ -88,12 +90,16 @@ lsystem(cmd) 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 @@ -101,8 +107,14 @@ lsystem(cmd) */ inp = dup(0); close(0); - if (OPEN_TTYIN() < 0) +#if OS2 + /* The __open() system call translates "/dev/tty" to "con". */ + if (__open("/dev/tty", OPEN_READ) < 0) +#else + if (open("/dev/tty", OPEN_READ) < 0) +#endif dup(inp); +#endif /* * Pass the command to the system to be executed. @@ -112,15 +124,21 @@ lsystem(cmd) */ #if HAVE_SHELL p = NULL; - if ((shell = getenv("SHELL")) != NULL && *shell != '\0') + if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0') { if (*cmd == '\0') p = save(shell); else { - size_t l = strlen(shell) + strlen(cmd) + 7; - p = (char *) ecalloc(l, sizeof(char)); - snprintf(p, l, "%s -c \"%s\"", shell, cmd); + char *esccmd = shell_quote(cmd); + if (esccmd != NULL) + { + size_t len = strlen(shell) + strlen(esccmd) + 5; + p = (char *) ecalloc(len, sizeof(char)); + snprintf(p, len, "%s %s %s", shell, + shell_coption(), esccmd); + free(esccmd); + } } } if (p == NULL) @@ -130,34 +148,76 @@ lsystem(cmd) else p = save(cmd); } - system(p); free(p); #else -#if OS2 - if (*cmd == '\0') - cmd = "cmd.exe"; -#endif +#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 +#if MSDOS_COMPILER==WIN32C + open_getchr(); +#endif init_signals(1); raw_mode(1); + if (donemsg != NULL) + { + putstr(donemsg); + putstr(" (press RETURN)"); + get_return(); + putchr('\n'); + flush(); + } init(); screen_trashed = 1; +#if MSDOS_COMPILER + /* + * 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. */ - if (edit_ifile(save_ifile)) - quit(QUIT_ERROR); + reedit_ifile(save_ifile); #if defined(SIGWINCH) || defined(SIGWIND) /* @@ -179,10 +239,12 @@ lsystem(cmd) * The section to be piped is the section "between" the current * position and the position marked by the given letter. * - * The "current" position means the top line displayed if the mark - * is after the current screen, or the bottom line displayed if - * the mark is before the current screen. - * If the mark is on the current screen, the whole screen is displayed. + * If the mark is after the current screen, the section between + * the top line displayed and the mark is piped. + * If the mark is before the current screen, the section between + * the mark and the bottom line displayed is piped. + * 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) @@ -207,7 +269,7 @@ pipe_mark(c, cmd) if (c == '.') return (pipe_data(cmd, tpos, bpos)); else if (mpos <= tpos) - return (pipe_data(cmd, mpos, tpos)); + return (pipe_data(cmd, mpos, bpos)); else if (bpos == NULL_POSITION) return (pipe_data(cmd, tpos, bpos)); else @@ -224,8 +286,8 @@ pipe_data(cmd, spos, epos) POSITION spos; POSITION epos; { - FILE *f; - int c; + register FILE *f; + register int c; extern FILE *popen(); /* @@ -254,8 +316,11 @@ pipe_data(cmd, spos, epos) flush(); raw_mode(0); init_signals(0); +#if MSDOS_COMPILER==WIN32C + close_getchr(); +#endif #ifdef SIGPIPE - SIGNAL(SIGPIPE, SIG_IGN); + LSIGNAL(SIGPIPE, SIG_IGN); #endif c = EOI; @@ -286,7 +351,10 @@ pipe_data(cmd, spos, epos) pclose(f); #ifdef SIGPIPE - SIGNAL(SIGPIPE, SIG_DFL); + LSIGNAL(SIGPIPE, SIG_DFL); +#endif +#if MSDOS_COMPILER==WIN32C + open_getchr(); #endif init_signals(1); raw_mode(1); @@ -300,3 +368,143 @@ pipe_data(cmd, spos, epos) } #endif + +#ifdef _OSK +/* + * Popen, and Pclose, for OS-9. + * + * Based on code copyright (c) 1988 by Wolfgang Ocker, Puchheim, + * Ulli Dessauer, Germering and + * Reimer Mellin, Muenchen + * (W-Germany) + * + * These functions can be copied and distributed freely for any + * non-commercial purposes. It can only be incorporated into + * commercial software with the written permission of the authors. + * + * TOP-specific code stripped out and adapted for less by M.Gregorie, 1996 + * + * address: Wolfgang Ocker + * Lochhauserstrasse 35a + * D-8039 Puchheim + * West Germany + * + * e-mail: weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP + * pyramid!tmpmbx!recco!weo + * pyramid!tmpmbx!nitmar!ud + * pyramid!tmpmbx!ramsys!ram + * + * Martin Gregorie + * 10 Sadlers Mead + * Harlow + * Essex, CM18 6HG + * U.K. + * + * gregorie@logica.com + */ +#include <strings.h> +#include <errno.h> +extern char **environ; +extern char *getenv(); +extern int os9forkc(); +static int pids[_NFILE] = { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; +/* + * p o p e n + */ +FILE *popen(name, mode) + char *name; + char *mode; +{ + int fd, fd2, fdsav, pid; + static char *argv[] = {NULL, NULL, NULL }; + static char cmd[200]; + static char cmd_path[200]; + char *cp; + char *shell; + FILE *r; + if ((shell = getenv("SHELL")) == NULL) + return(NULL); + cp = name; + while (*cp == ' ') + cp++; + strlcpy(cmd_path, cp, sizeof(cmd_path)); + if (cp = index(cmd_path, ' ')) + *cp++ = '\0'; + strlcpy(cmd, "ex ", sizeof(cmd)); + strlcat(cmd, cmd_path, sizeof(cmd)); + if (cp) + { + strlcat(cmd, " ", sizeof(cmd)); + strlcat(cmd, cp, sizeof(cmd)); + } + argv[0] = shell; + argv[1] = cmd; + /* + mode is "r" (stdout) or "w" (stdin) + */ + switch(mode[0]) + { + case 'w': fd = 0; + break; + case 'r': fd = 1; + break; + default: return(NULL); + } + if (fd == 1) + fflush(stdout); + fdsav = dup(fd); + close(fd); + + creat("/pipe", S_IWRITE+S_IREAD); + pid = os9exec(os9forkc, argv[0], argv, environ, 0, 0, 3); + fd2 = dup(fd); + close(fd); + dup(fdsav); + close(fdsav); + if (pid > 0) + { + pids[fd2] = pid; + r = fdopen(fd2, mode); + } + else + { + close(fd2); + r = NULL; + } + return(r); +} + +/* + * p c l o s e + */ +int pclose(fp) + FILE *fp; +{ + unsigned int status; + int pid; + int fd, + i; + fd = fileno(fp); + if (pids[fd] == 0) + return(-1); + fflush(fp); + fclose(fp); + while ((pid = wait(&status)) != -1) + if (pid == pids[fd]) + break; + else + for (i = 0; i < _NFILE; i++) + if (pids[i] == pid) + { + pids[i] = 0; + break; + } + if (pid == -1) + status = -1; + pids[fd] = 0; + return(status); +} +#endif /* _OSK */ diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c index ee69c713d57..644f07253df 100644 --- a/usr.bin/less/main.c +++ b/usr.bin/less/main.c @@ -1,29 +1,11 @@ -/* $OpenBSD: main.c,v 1.6 2003/04/05 01:03:35 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,7 +14,9 @@ */ #include "less.h" -#include "position.h" +#if MSDOS_COMPILER==WIN32C +#include <windows.h> +#endif public char * every_first_cmd = NULL; public int new_file; @@ -41,16 +25,14 @@ 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 more_mode = 0; - -extern int quit_at_eof; -extern int cbufs; -extern int errmsgs; -extern int screen_trashed; -extern int force_open; +public int secure; +public int dohelp; +public int ismore; #if LOGFILE public int logfile = -1; @@ -64,12 +46,19 @@ public char * editproto; #endif #if TAGS -extern char * tagfile; +extern char * tags; extern char * tagoption; extern int jump_sline; #endif +#ifdef WIN32 +static char consoleTitle[256]; +#endif +extern int missing_cap; +extern int know_dumb; + +extern char * __progname; /* * Entry point. @@ -80,7 +69,7 @@ main(argc, argv) char *argv[]; { IFILE ifile; - extern char *__progname; + char *s; #ifdef __EMX__ _response(&argc, &argv); @@ -88,48 +77,65 @@ main(argc, argv) #endif progname = *argv++; + argc--; + + 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. */ - if (strcmp(__progname, "more") == 0) - more_mode = 1; - + ismore = !strcmp(__progname, "more"); + is_tty = isatty(1); get_term(); init_cmds(); init_prompt(); init_charset(); + init_line(); init_option(); - - if (more_mode) { + if (ismore) { scan_option("-E"); - scan_option("-m"); scan_option("-G"); - scan_option(getenv("MORE")); + scan_option("-L"); + s = lgetenv("MORE"); } else - scan_option(getenv("LESS")); + s = lgetenv("LESS"); + if (s != NULL) + scan_option(save(s)); -#if GNU_OPTIONS - /* - * Special case for "less --help" and "less --version". - */ - if (argc == 2) - { - if (strcmp(argv[0], "--help") == 0) - scan_option("-?"); - if (strcmp(argv[0], "--version") == 0) - scan_option("-V"); - } -#endif #define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0') - while (--argc > 0 && (isoptstring(argv[0]) || isoptpending())) { - if (strcmp(argv[0], "--") == 0) { - argv++; - argc--; + while (argc > 0 && (isoptstring(*argv) || isoptpending())) + { + s = *argv++; + argc--; + if (strcmp(s, "--") == 0) break; - } - scan_option(*argv++); + scan_option(s); } #undef isoptstring @@ -144,14 +150,14 @@ main(argc, argv) } #if EDITOR - editor = getenv("VISUAL"); + editor = lgetenv("VISUAL"); if (editor == NULL || *editor == '\0') { - editor = getenv("EDITOR"); + editor = lgetenv("EDITOR"); if (editor == NULL || *editor == '\0') editor = EDIT_PGM; } - editproto = getenv("LESSEDIT"); + editproto = lgetenv("LESSEDIT"); if (editproto == NULL || *editproto == '\0') editproto = "%E ?lm+%lm. %f"; #endif @@ -161,9 +167,12 @@ main(argc, argv) * to "register" them with the ifile system. */ ifile = NULL_IFILE; - while (--argc >= 0) + if (dohelp) + ifile = get_ifile(FAKE_HELPFILE, ifile); + while (argc-- > 0) { -#if MSOFTC || OS2 + 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 @@ -172,28 +181,35 @@ main(argc, argv) */ struct textlist tlist; char *gfilename; - char *filename; - gfilename = glob(*argv++); + gfilename = lglob(*argv++); init_textlist(&tlist, gfilename); filename = NULL; while ((filename = forw_textlist(&tlist, filename)) != NULL) - ifile = get_ifile(filename, ifile); + { + (void) get_ifile(filename, ifile); + ifile = prev_ifile(NULL_IFILE); + } free(gfilename); #else - ifile = get_ifile(*argv++, ifile); + filename = shell_quote(*argv); + if (filename == NULL) + filename = *argv; + argv++; + (void) get_ifile(filename, ifile); + ifile = prev_ifile(NULL_IFILE); #endif } /* * Set up terminal, etc. */ - is_tty = isatty(1); if (!is_tty) { /* * Output is not a tty. * Just copy the input file(s) to output. */ + SET_BINARY(1); if (nifile() == 0) { if (edit_stdin() == 0) @@ -207,16 +223,18 @@ main(argc, argv) quit(QUIT_OK); } + if (missing_cap && !know_dumb && !ismore) + error("WARNING: terminal is not fully functional", NULL_PARG); init_mark(); - raw_mode(1); open_getchr(); + raw_mode(1); init_signals(1); /* * Select the first file to examine. */ #if TAGS - if (tagoption != NULL) + if (tagoption != NULL || strcmp(tags, "-") == 0) { /* * A -t option was given. @@ -230,9 +248,7 @@ main(argc, argv) quit(QUIT_ERROR); } findtag(tagoption); - if (tagfile == NULL) - quit(QUIT_ERROR); - if (edit(tagfile)) /* Edit file which contains the tag */ + if (edit_tagfile()) /* Edit file which contains the tag */ quit(QUIT_ERROR); /* * Search for the line which contains the tag. @@ -258,20 +274,7 @@ main(argc, argv) commands(); quit(QUIT_OK); /*NOTREACHED*/ -} - -/* - * Copy a string, truncating to the specified length if necessary. - * Unlike strncpy(), the resulting string is guaranteed to be null-terminated. - */ - public void -strtcpy(to, from, len) - char *to; - char *from; - unsigned int len; -{ - strncpy(to, from, len); - to[len-1] = '\0'; + return (0); } /* @@ -282,10 +285,10 @@ strtcpy(to, from, len) save(s) char *s; { - char *p; + register char *p; size_t len; - len = strlen(s)+1; + len = strlen(s)+1, sizeof(char); p = (char *) ecalloc(len, sizeof(char)); strlcpy(p, s, len); return (p); @@ -300,7 +303,7 @@ ecalloc(count, size) int count; unsigned int size; { - VOID_POINTER p; + register VOID_POINTER p; p = (VOID_POINTER) calloc(count, size); if (p != NULL) @@ -308,6 +311,7 @@ ecalloc(count, size) error("Cannot allocate memory", NULL_PARG); quit(QUIT_ERROR); /*NOTREACHED*/ + return (NULL); } /* @@ -315,7 +319,7 @@ ecalloc(count, size) */ public char * skipsp(s) - char *s; + register char *s; { while (*s == ' ' || *s == '\t') s++; @@ -323,6 +327,41 @@ skipsp(s) } /* + * 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; +{ + register int c; + register int sc; + register int len = 0; + + for ( ; *s != '\0'; s++, ps++) + { + c = *ps; + if (uppercase) + { + if (len == 0 && SIMPLE_IS_LOWER(c)) + return (-1); + if (SIMPLE_IS_UPPER(c)) + c = SIMPLE_TO_LOWER(c); + } + sc = *s; + if (len > 0 && SIMPLE_IS_UPPER(sc)) + sc = SIMPLE_TO_LOWER(sc); + if (c != sc) + break; + len++; + } + return (len); +} + +/* * Exit the program. */ public void @@ -341,12 +380,12 @@ quit(status) save_status = status; quitting = 1; edit((char*)NULL); - if (is_tty && any_display) + if (any_display && is_tty) clear_bot(); deinit(); flush(); raw_mode(0); -#if MSOFTC +#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC /* * If we don't close 2, we get some garbage from * 2's buffer when it flushes automatically. @@ -355,5 +394,9 @@ quit(status) */ close(2); #endif +#if WIN32 + SetConsoleTitle(consoleTitle); +#endif + close_getchr(); exit(status); } diff --git a/usr.bin/less/mark.c b/usr.bin/less/mark.c index 4641a29385b..04f97885d10 100644 --- a/usr.bin/less/mark.c +++ b/usr.bin/less/mark.c @@ -1,34 +1,15 @@ -/* $OpenBSD: mark.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ #include "less.h" -#include "position.h" extern IFILE curr_ifile; extern int sc_height; @@ -45,16 +26,13 @@ struct mark { /* * The table of marks. * Each mark is identified by a lowercase or uppercase letter. + * The final one is lmark, for the "last mark"; addressed by the apostrophe. */ -#define NMARKS (2*26) /* a-z, A-Z */ +#define NMARKS ((2*26)+1) /* a-z, A-Z, lastmark */ +#define LASTMARK (NMARKS-1) static struct mark marks[NMARKS]; /* - * Special mark for the "last mark"; addressed by the apostrophe. - */ -static struct mark lmark; - -/* * Initialize the mark table to show no marks are set. */ public void @@ -64,7 +42,6 @@ init_mark() for (i = 0; i < NMARKS; i++) marks[i].m_scrpos.pos = NULL_POSITION; - lmark.m_scrpos.pos = NULL_POSITION; } /* @@ -93,7 +70,7 @@ getumark(c) getmark(c) int c; { - struct mark *m; + register struct mark *m; static struct mark sm; switch (c) @@ -126,15 +103,14 @@ getmark(c) * Current position in the current file. */ m = &sm; - m->m_scrpos.pos = ch_tell(); - m->m_scrpos.ln = 0; + get_scrpos(&m->m_scrpos); m->m_ifile = curr_ifile; break; case '\'': /* * The "last mark". */ - m = &lmark; + m = &marks[LASTMARK]; break; default: /* @@ -170,7 +146,7 @@ badmark(c) setmark(c) int c; { - struct mark *m; + register struct mark *m; struct scrpos scrpos; m = getumark(c); @@ -189,11 +165,13 @@ lastmark() { struct scrpos scrpos; + if (ch_getflags() & CH_HELPFILE) + return; get_scrpos(&scrpos); if (scrpos.pos == NULL_POSITION) return; - lmark.m_scrpos = scrpos; - lmark.m_ifile = curr_ifile; + marks[LASTMARK].m_scrpos = scrpos; + marks[LASTMARK].m_ifile = curr_ifile; } /* @@ -203,7 +181,7 @@ lastmark() gomark(c) int c; { - struct mark *m; + register struct mark *m; struct scrpos scrpos; m = getmark(c); @@ -215,7 +193,7 @@ gomark(c) * it has not been set to anything yet, * set it to the beginning of the current file. */ - if (m == &lmark && m->m_scrpos.pos == NULL_POSITION) + if (m == &marks[LASTMARK] && m->m_scrpos.pos == NULL_POSITION) { m->m_ifile = curr_ifile; m->m_scrpos.pos = ch_zero(); @@ -251,7 +229,7 @@ gomark(c) markpos(c) int c; { - struct mark *m; + register struct mark *m; m = getmark(c); if (m == NULL) @@ -264,3 +242,17 @@ markpos(c) } return (m->m_scrpos.pos); } + +/* + * Clear the marks associated with a specified ifile. + */ + public void +unmark(ifile) + IFILE ifile; +{ + int i; + + for (i = 0; i < NMARKS; i++) + if (marks[i].m_ifile == ifile) + marks[i].m_scrpos.pos = NULL_POSITION; +} diff --git a/usr.bin/less/mkinstalldirs b/usr.bin/less/mkinstalldirs index e1d56188b33..91f6d04e17c 100644 --- a/usr.bin/less/mkinstalldirs +++ b/usr.bin/less/mkinstalldirs @@ -1,6 +1,4 @@ #!/bin/sh -# $OpenBSD: mkinstalldirs,v 1.2 2001/01/29 01:58:03 niklas Exp $ - # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman <friedman@prep.ai.mit.edu> # Created: 1993-05-16 diff --git a/usr.bin/less/optfunc.c b/usr.bin/less/optfunc.c index c228612022e..077168886d3 100644 --- a/usr.bin/less/optfunc.c +++ b/usr.bin/less/optfunc.c @@ -1,29 +1,11 @@ -/* $OpenBSD: optfunc.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -47,16 +29,22 @@ #include "option.h" extern int nbufs; -extern int cbufs; +extern int bufspace; extern int pr_type; -extern int nohelp; extern int plusoption; extern int swindow; extern int sc_height; +extern int secure; +extern int dohelp; extern int any_display; +extern char openquote; +extern char closequote; extern char *prproto[]; extern char *eqproto; +extern char *hproto; +extern char *wproto; extern IFILE curr_ifile; +extern char version[]; #if LOGFILE extern char *namelogfile; extern int force_logfile; @@ -64,11 +52,10 @@ extern int logfile; #endif #if TAGS public char *tagoption = NULL; -extern char *tagfile; extern char *tags; extern int jump_sline; #endif -#if MSOFTC +#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; @@ -88,6 +75,11 @@ opt_o(type, s) { PARG parg; + if (secure) + { + error("log file support is not available", NULL_PARG); + return; + } switch (type) { case INIT: @@ -105,7 +97,7 @@ opt_o(type, s) return; } s = skipsp(s); - namelogfile = glob(s); + namelogfile = lglob(s); use_logfile(namelogfile); sync_logfile(); break; @@ -150,7 +142,7 @@ opt_l(type, s) { case INIT: t = s; - n = getnum(&t, 'l', &err); + n = getnum(&t, "l", &err); if (err || n <= 0) { error("Line number is required after -l", NULL_PARG); @@ -173,7 +165,7 @@ opt_k(type, s) switch (type) { case INIT: - if (lesskey(s)) + if (lesskey(s, 0)) { parg.p_string = s; error("Cannot use lesskey file \"%s\"", &parg); @@ -202,18 +194,21 @@ opt_t(type, s) /* Do the rest in main() */ break; case TOGGLE: - findtag(skipsp(s)); - if (tagfile == NULL) + if (secure) + { + error("tags support is not available", NULL_PARG); break; - save_ifile = curr_ifile; - if (edit(tagfile)) + } + findtag(skipsp(s)); + save_ifile = save_curr_ifile(); + if (edit_tagfile()) break; if ((pos = tagsearch()) == NULL_POSITION) { - if (edit_ifile(save_ifile)) - quit(QUIT_ERROR); + reedit_ifile(save_ifile); break; } + unsave_ifile(save_ifile); jump_loc(pos, jump_sline); break; } @@ -236,7 +231,7 @@ opt__T(type, s) break; case TOGGLE: s = skipsp(s); - tags = glob(s); + tags = lglob(s); break; case QUERY: parg.p_string = tags; @@ -252,7 +247,7 @@ opt__T(type, s) public void opt_p(type, s) int type; - char *s; + register char *s; { switch (type) { @@ -275,9 +270,9 @@ opt_p(type, s) public void opt__P(type, s) int type; - char *s; + register char *s; { - char **proto; + register char **proto; PARG parg; switch (type) @@ -289,9 +284,12 @@ opt__P(type, 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; case '=': proto = &eqproto; s++; break; + case 'h': proto = &hproto; s++; break; + case 'w': proto = &wproto; s++; break; default: proto = &prproto[PR_SHORT]; break; } free(*proto); @@ -315,14 +313,14 @@ opt_b(type, s) { switch (type) { + case INIT: case TOGGLE: - case QUERY: /* - * Allocate the new number of buffers. + * Set the new number of buffers. */ - cbufs = ch_nbuf(cbufs); + ch_setbufspace(bufspace); break; - case INIT: + case QUERY: break; } } @@ -360,17 +358,28 @@ opt__V(type, s) { case TOGGLE: case QUERY: - case INIT: dispversion(); - if (type == INIT) - quit(QUIT_OK); + break; + case INIT: + /* + * Force output to stdout per GNU standard for --version output. + */ + any_display = 1; + putstr("less "); + putstr(version); + putstr("\nCopyright (C) 2002 Mark Nudelman\n\n"); + putstr("less comes with NO WARRANTY, 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"); + quit(QUIT_OK); break; } } -#if MSOFTC +#if MSDOS_COMPILER /* - * + * Parse an MSDOS color descriptor. */ static void colordesc(s, fg_color, bg_color) @@ -381,7 +390,7 @@ colordesc(s, fg_color, bg_color) int fg, bg; int err; - fg = getnum(&s, 'D', &err); + fg = getnum(&s, "D", &err); if (err) { error("Missing fg color in -D", NULL_PARG); @@ -392,13 +401,15 @@ colordesc(s, fg_color, bg_color) else { s++; - bg = getnum(&s, 'D', &err); + bg = getnum(&s, "D", &err); if (err) { error("Missing fg 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; } @@ -450,6 +461,108 @@ opt_D(type, s) #endif /* + * Handler for the -x option. + */ + public void +opt_x(type, s) + int type; + register char *s; +{ + extern int tabstops[]; + extern int ntabstops; + extern int tabdefault; + char msg[60+(4*TABSTOP_MAX)]; + int i; + PARG p; + + switch (type) + { + case INIT: + case TOGGLE: + /* Start at 1 because tabstops[0] is always zero. */ + for (i = 1; i < TABSTOP_MAX; ) + { + int n = 0; + s = skipsp(s); + while (*s >= '0' && *s <= '9') + n = (10 * n) + (*s++ - '0'); + if (n > tabstops[i-1]) + tabstops[i++] = n; + s = skipsp(s); + if (*s++ != ',') + break; + } + if (i < 2) + return; + ntabstops = i; + 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++) + { + if (i > 1) + strlcat(msg, ",", sizeof(msg)); + snprintf(msg+strlen(msg), + sizeof(msg)-strlen(msg), "%d", tabstops[i]); + } + snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), + " and then "); + } + snprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), + "every %d spaces", + tabdefault); + p.p_string = msg; + error("%s", &p); + break; + } +} + + +/* + * Handler for the -" option. + */ + public void +opt_quote(type, s) + int type; + register char *s; +{ + char buf[3]; + PARG parg; + + switch (type) + { + case INIT: + case TOGGLE: + 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); + return; + } + openquote = s[0]; + if (s[1] == '\0') + closequote = openquote; + else + closequote = s[1]; + break; + case QUERY: + buf[0] = openquote; + buf[1] = closequote; + buf[2] = '\0'; + parg.p_string = buf; + error("quotes %s", &parg); + break; + } +} + +/* * "-?" means display a help message. * If from the command line, exit immediately. */ @@ -459,8 +572,6 @@ opt_query(type, s) int type; char *s; { - if (nohelp) - return; switch (type) { case QUERY: @@ -468,20 +579,7 @@ opt_query(type, s) error("Use \"h\" for help", NULL_PARG); break; case INIT: - /* - * This is "less -?". - * It rather ungracefully grabs control, - * does the initializations normally done in main, - * shows the help file and exits. - */ - raw_mode(1); - get_term(); - open_getchr(); - init(); - any_display = TRUE; - help(1); - quit(QUIT_OK); - /*NOTREACHED*/ + dohelp = 1; } } diff --git a/usr.bin/less/option.c b/usr.bin/less/option.c index 694c2baac70..a56a56fb53d 100644 --- a/usr.bin/less/option.c +++ b/usr.bin/less/option.c @@ -1,29 +1,11 @@ -/* $OpenBSD: option.c,v 1.4 2003/03/13 09:09:32 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -39,7 +21,7 @@ #include "less.h" #include "option.h" -static struct option *pendopt; +static struct loption *pendopt; public int plusoption = FALSE; static char *propt(); @@ -57,36 +39,51 @@ extern char *every_first_cmd; scan_option(s) char *s; { - struct option *o; - int c; + register struct loption *o; + register int optc; + char *optname; + char *printopt; char *str; int set_default; + int lc; + int err; PARG parg; if (s == NULL) return; /* - * If we have a pending string-valued option, handle it now. + * If we have a pending option which requires an argument, + * handle it now. * This happens if the previous option was, for example, "-P" * without a following string. In that case, the current - * option is simply the string for the previous option. + * option is simply the argument for the previous option. */ if (pendopt != NULL) { - (*pendopt->ofunc)(INIT, s); + switch (pendopt->otype & OTYPE) + { + case STRING: + (*pendopt->ofunc)(INIT, s); + break; + case NUMBER: + printopt = propt(pendopt->oletter); + *(pendopt->ovar) = getnum(&s, printopt, (int*)NULL); + break; + } pendopt = NULL; return; } set_default = FALSE; + optname = NULL; while (*s != '\0') { /* * Check some special cases first. */ - switch (c = *s++) + switch (optc = *s++) { case ' ': case '\t': @@ -94,11 +91,20 @@ scan_option(s) continue; case '-': /* + * "--" indicates an option name instead of a letter. + */ + if (*s == '-') + { + optname = ++s; + break; + } + /* * "-+" means set these options back to their defaults. * (They may have been set otherwise by previous * options.) */ - if (set_default = (*s == '+')) + set_default = (*s == '+'); + if (set_default) s++; continue; case '+': @@ -110,11 +116,11 @@ scan_option(s) * EVERY input file. */ plusoption = TRUE; - if (*s == '+') - every_first_cmd = save(++s); + s = optstring(s, &str, propt('+'), NULL); + if (*str == '+') + every_first_cmd = save(++str); else - ungetsc(s); - s = optstring(s, c); + ungetsc(str); continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -124,7 +130,7 @@ scan_option(s) * window size. */ s--; - c = 'z'; + optc = 'z'; break; } @@ -132,20 +138,62 @@ scan_option(s) * Not a special case. * Look up the option letter in the option table. */ - o = findopt(c); + err = 0; + if (optname == NULL) + { + printopt = propt(optc); + lc = SIMPLE_IS_LOWER(optc); + o = findopt(optc); + } else + { + printopt = optname; + lc = SIMPLE_IS_LOWER(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". + */ + if (o != NULL && + (o->otype & OTYPE) != STRING && + (o->otype & OTYPE) != NUMBER) + { + parg.p_string = printopt; + error("The %s option should not be followed by =", + &parg); + quit(QUIT_ERROR); + } + s++; + } else + { + /* + * The specified name is longer than the + * real option name. + */ + o = NULL; + } + } if (o == NULL) { - parg.p_string = propt(c); -#if MSOFTC || OS2 - error("There is no %s flag (\"less -?\" for help)", - &parg); -#else - error("There is no %s flag (\"less -\\?\" for help)", - &parg); -#endif + 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); quit(QUIT_ERROR); } + str = NULL; switch (o->otype & OTYPE) { case BOOL: @@ -158,8 +206,7 @@ scan_option(s) if (set_default) *(o->ovar) = o->odefault; else - *(o->ovar) = flip_triple(o->odefault, - (o->oletter == c)); + *(o->ovar) = flip_triple(o->odefault, lc); break; case STRING: if (*s == '\0') @@ -177,11 +224,17 @@ scan_option(s) * All processing of STRING options is done by * the handling function. */ - str = s; - s = optstring(s, c); + while (*s == ' ') + s++; + s = optstring(s, &str, printopt, o->odesc[1]); break; case NUMBER: - *(o->ovar) = getnum(&s, c, (int*)NULL); + if (*s == '\0') + { + pendopt = o; + return; + } + *(o->ovar) = getnum(&s, printopt, (int*)NULL); break; } /* @@ -207,11 +260,15 @@ toggle_option(c, s, how_toggle) char *s; int how_toggle; { - struct option *o; - int num; + register struct loption *o; + register int num; + int no_prompt; int err; PARG parg; + no_prompt = (how_toggle & OPT_NO_PROMPT); + how_toggle &= ~OPT_NO_PROMPT; + /* * Look up the option letter in the option table. */ @@ -219,21 +276,21 @@ toggle_option(c, s, how_toggle) if (o == NULL) { parg.p_string = propt(c); - error("There is no %s flag", &parg); + error("There is no %s option", &parg); return; } if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE)) { parg.p_string = propt(c); - error("Cannot change the %s flag", &parg); + error("Cannot change the %s option", &parg); return; } if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY)) { parg.p_string = propt(c); - error("Cannot query the %s flag", &parg); + error("Cannot query the %s option", &parg); return; } @@ -293,14 +350,14 @@ toggle_option(c, s, how_toggle) { case OPT_TOGGLE: *(o->ovar) = flip_triple(*(o->ovar), - o->oletter == c); + islower(c)); break; case OPT_UNSET: *(o->ovar) = o->odefault; break; case OPT_SET: *(o->ovar) = flip_triple(o->odefault, - o->oletter == c); + islower(c)); break; } break; @@ -313,7 +370,7 @@ toggle_option(c, s, how_toggle) { case OPT_SET: case OPT_UNSET: - error("Can't use \"-+\" or \"--\" for a string flag", + error("Cannot use \"-+\" or \"--\" for a string option", NULL_PARG); return; } @@ -325,7 +382,7 @@ toggle_option(c, s, how_toggle) switch (how_toggle) { case OPT_TOGGLE: - num = getnum(&s, '\0', &err); + num = getnum(&s, NULL, &err); if (!err) *(o->ovar) = num; break; @@ -333,7 +390,7 @@ toggle_option(c, s, how_toggle) *(o->ovar) = o->odefault; break; case OPT_SET: - error("Can't use \"--\" for a numeric flag", + error("Can't use \"-!\" for a numeric option", NULL_PARG); return; } @@ -353,31 +410,34 @@ toggle_option(c, s, how_toggle) chg_hilite(); #endif - /* - * Print a message describing the new setting. - */ - switch (o->otype & OTYPE) + if (!no_prompt) { - case BOOL: - case TRIPLE: - /* - * Print the odesc message. - */ - error(o->odesc[*(o->ovar)], NULL_PARG); - break; - case NUMBER: /* - * The message is in odesc[1] and has a %d for - * the value of the variable. + * Print a message describing the new setting. */ - parg.p_int = *(o->ovar); - error(o->odesc[1], &parg); - break; - case STRING: - /* - * Message was already printed by the handling function. - */ - break; + switch (o->otype & OTYPE) + { + case BOOL: + case TRIPLE: + /* + * Print the odesc message. + */ + error(o->odesc[*(o->ovar)], NULL_PARG); + break; + case NUMBER: + /* + * The message is in odesc[1] and has a %d for + * the value of the variable. + */ + parg.p_int = *(o->ovar); + error(o->odesc[1], &parg); + break; + case STRING: + /* + * Message was already printed by the handling function. + */ + break; + } } if (how_toggle != OPT_NO_TOGGLE && (o->otype & REPAINT)) @@ -408,7 +468,7 @@ propt(c) { static char buf[8]; - snprintf(buf, sizeof buf, "-%s", prchar(c)); + snprintf(buf, sizeof(buf), "-%s", prchar(c)); return (buf); } @@ -420,7 +480,7 @@ propt(c) single_char_option(c) int c; { - struct option *o; + register struct loption *o; o = findopt(c); if (o == NULL) @@ -436,7 +496,7 @@ single_char_option(c) opt_prompt(c) int c; { - struct option *o; + register struct loption *o; o = findopt(c); if (o == NULL || (o->otype & (STRING|NUMBER)) == 0) @@ -461,12 +521,12 @@ isoptpending() * Print error message about missing string. */ static void -nostring(c) - int c; +nostring(printopt) + char *printopt; { PARG parg; - parg.p_string = propt(c); - error("String is required after %s", &parg); + parg.p_string = printopt; + error("Value is required after %s", &parg); } /* @@ -475,7 +535,7 @@ nostring(c) public void nopendopt() { - nostring(pendopt->oletter); + nostring(propt(pendopt->oletter)); } /* @@ -484,23 +544,42 @@ nopendopt() * Return a pointer to the remainder of the string, if any. */ static char * -optstring(s, c) +optstring(s, p_str, printopt, validchars) char *s; - int c; + char **p_str; + char *printopt; + char *validchars; { - char *p; + register char *p; if (*s == '\0') { - nostring(c); + nostring(printopt); quit(QUIT_ERROR); } + *p_str = s; for (p = s; *p != '\0'; p++) - if (*p == END_OPTION_STRING) + { + if (*p == END_OPTION_STRING || + (validchars != NULL && strchr(validchars, *p) == NULL)) { - *p = '\0'; - return (p+1); + switch (*p) + { + case END_OPTION_STRING: + case ' ': case '\t': case '-': + /* Replace the char with a null to terminate string. */ + *p++ = '\0'; + break; + default: + /* Cannot replace char; make a copy of the string. */ + *p_str = (char *) ecalloc(p-s+1, sizeof(char)); + strncpy(*p_str, s, p-s); + (*p_str)[p-s] = '\0'; + break; + } + break; } + } return (p); } @@ -510,14 +589,14 @@ optstring(s, c) * the char * to point after the translated number. */ public int -getnum(sp, c, errp) +getnum(sp, printopt, errp) char **sp; - int c; + char *printopt; int *errp; { - char *s; - int n; - int neg; + register char *s; + register int n; + register int neg; PARG parg; s = skipsp(*sp); @@ -534,8 +613,11 @@ getnum(sp, c, errp) *errp = TRUE; return (-1); } - parg.p_string = propt(c); - error("Number is required after %s", &parg); + if (printopt != NULL) + { + parg.p_string = printopt; + error("Number is required after %s", &parg); + } quit(QUIT_ERROR); } diff --git a/usr.bin/less/option.h b/usr.bin/less/option.h index d24fedc5da9..8749d9359b5 100644 --- a/usr.bin/less/option.h +++ b/usr.bin/less/option.h @@ -1,29 +1,11 @@ -/* $OpenBSD: option.h,v 1.2 2001/01/29 01:58:03 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -41,6 +23,7 @@ #define NO_TOGGLE 0100 /* Option cannot be toggled with "-" cmd */ #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 OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR) @@ -56,10 +39,21 @@ #define OPT_TOGGLE 1 #define OPT_UNSET 2 #define OPT_SET 3 +#define OPT_NO_PROMPT 0100 + +/* Error code from findopt_name */ +#define OPT_AMBIG 1 + +struct optname +{ + char *oname; /* Long (GNU-style) option name */ + struct optname *onext; /* List of synonymous option names */ +}; -struct option +struct loption { char oletter; /* The controlling letter (a-z) */ + struct optname *onames; /* Long (GNU-style) option name */ int otype; /* Type of the option */ int odefault; /* Default value */ int *ovar; /* Pointer to the associated variable */ diff --git a/usr.bin/less/opttbl.c b/usr.bin/less/opttbl.c index 6b9fdbd95a0..d1c23c3eecf 100644 --- a/usr.bin/less/opttbl.c +++ b/usr.bin/less/opttbl.c @@ -1,29 +1,11 @@ -/* $OpenBSD: opttbl.c,v 1.5 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -45,204 +27,398 @@ 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 be_helpful; /* more(1) style -d */ +public int quit_if_one_screen; /* Quit if EOF on first screen */ public int squeeze; /* Squeeze multiple blank lines into one */ +public int be_helpful; /* more(1) style -d */ 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 twiddle; /* Display "~" for lines after EOF */ public int caseless; /* Do "caseless" searches */ public int linenums; /* Use line numbers */ -public int cbufs; /* Current number of buffers */ public int autobuf; /* Automatically allocate buffers as needed */ -public int nohelp; /* Disable the HELP command */ +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 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 */ #if HILITE_SEARCH public int hilite_search; /* Highlight matched search patterns? */ #endif /* + * Long option names. + */ +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 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 }; + + +/* * Table of all options and their semantics. + * + * 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 + * 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 option option[] = +static struct loption option[] = { - { 'a', BOOL, OPT_OFF, &how_search, NULL, - "Search includes displayed screen", - "Search skips displayed screen", - NULL - }, - { 'b', NUMBER, 10, &cbufs, opt_b, - "Buffers: ", - "%d buffers", - NULL - }, - { 'B', BOOL, OPT_ON, &autobuf, NULL, - "Don't automatically allocate buffers", - "Automatically allocate buffers when needed", - NULL - }, - { 'c', TRIPLE, OPT_OFF, &top_scroll, NULL, - "Repaint by scrolling from bottom of screen", - "Repaint by clearing each line", - "Repaint by painting from top of screen" - }, -#if 0 - { 'd', BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, - "Assume intelligent terminal", - "Assume dumb terminal", - NULL - }, -#else - { 'd', BOOL, OPT_OFF, &be_helpful, NULL, - "Be less helpful in prompts", - "Be helpful in prompts", - NULL, + { 'a', &a_optname, + BOOL, OPT_OFF, &how_search, NULL, + { + "Search includes displayed screen", + "Search skips displayed screen", + NULL + } }, -#endif -#if MSOFTC - { 'D', STRING|REPAINT, 0, NULL, opt_D, - "color desc: ", NULL, NULL + + { 'b', &b_optname, + NUMBER|INIT_HANDLER, 64, &bufspace, opt_b, + { + "Max buffer space per file (K): ", + "Max buffer space per file: %dK", + NULL + } + }, + { 'B', &B__optname, + BOOL, OPT_ON, &autobuf, NULL, + { + "Don't automatically allocate buffers", + "Automatically allocate buffers when needed", + NULL + } + }, + { 'c', &c_optname, + TRIPLE, OPT_OFF, &top_scroll, NULL, + { + "Repaint by scrolling from bottom of screen", + "Repaint by clearing each line", + "Repaint by painting from top of screen" + } + }, + { 'd', &d_optname, + BOOL|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', TRIPLE, OPT_OFF, &quit_at_eof, NULL, - "Don't quit at end-of-file", - "Quit at end-of-file", - "Quit immediately at end-of-file" - }, - { 'f', BOOL, OPT_OFF, &force_open, NULL, - "Open only regular files", - "Open even non-regular files", - NULL + { 'e', &e_optname, + TRIPLE, OPT_OFF, &quit_at_eof, NULL, + { + "Don't quit at end-of-file", + "Quit at end-of-file", + "Quit immediately at end-of-file" + } + }, + { 'f', &f_optname, + BOOL, OPT_OFF, &force_open, NULL, + { + "Open only regular files", + "Open even non-regular files", + NULL + } + }, + { 'F', &F__optname, + BOOL, OPT_OFF, &quit_if_one_screen, NULL, + { + "Don't quit if end-of-file on first screen", + "Quit if end-of-file on first screen", + NULL + } }, #if HILITE_SEARCH - { 'g', TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL, - "Don't highlight search matches", - "Highlight matches for previous search only", - "Highlight all matches for previous search pattern", + { 'g', &g_optname, + TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL, + { + "Don't highlight search matches", + "Highlight matches for previous search only", + "Highlight all matches for previous search pattern", + } }, #endif - { 'h', NUMBER, -1, &back_scroll, NULL, - "Backwards scroll limit: ", - "Backwards scroll limit is %d lines", - NULL - }, - { 'H', BOOL|NO_TOGGLE, OPT_OFF, &nohelp, NULL, - "Allow help command", - "Don't allow help command", - NULL - }, - { 'i', TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i, - "Case is significant in searches", - "Ignore case in searches", - "Ignore case in searches and in patterns" - }, - { 'j', NUMBER, 1, &jump_sline, NULL, - "Target line: ", - "Position target at screen line %d", - NULL + { 'h', &h_optname, + NUMBER, -1, &back_scroll, NULL, + { + "Backwards scroll limit: ", + "Backwards scroll limit is %d lines", + NULL + } + }, + { 'i', &i_optname, + TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i, + { + "Case is significant in searches", + "Ignore case in searches", + "Ignore case in searches and in patterns" + } + }, + { 'j', &j_optname, + NUMBER, 1, &jump_sline, NULL, + { + "Target line: ", + "Position target at screen line %d", + NULL + } + }, + { 'J', &J__optname, + BOOL|REPAINT, OPT_OFF, &status_col, NULL, + { + "Don't display a status column", + "Display a status column", + NULL + } }, #if USERFILE - { 'k', STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k, - NULL, NULL, NULL + { 'k', &k_optname, + STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k, + { NULL, NULL, NULL } }, #endif - { 'l', STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l, - NULL, NULL, NULL - }, - { 'm', TRIPLE, OPT_OFF, &pr_type, NULL, - "Short prompt", - "Medium prompt", - "Long prompt" - }, - { 'n', TRIPLE|REPAINT, OPT_ON, &linenums, NULL, - "Don't use line numbers", - "Use line numbers", - "Constantly display line numbers" + { 'l', NULL, + STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l, + { NULL, NULL, NULL } + }, + { 'L', &L__optname, + BOOL, OPT_ON, &use_lessopen, NULL, + { + "Don't use the LESSOPEN filter", + "Use the LESSOPEN filter", + NULL + } + }, + { 'm', &m_optname, + TRIPLE, OPT_OFF, &pr_type, NULL, + { + "Short prompt", + "Medium prompt", + "Long prompt" + } + }, + { 'n', &n_optname, + TRIPLE|REPAINT, OPT_ON, &linenums, NULL, + { + "Don't use line numbers", + "Use line numbers", + "Constantly display line numbers" + } }, #if LOGFILE - { 'o', STRING, 0, NULL, opt_o, - "log file: ", NULL, NULL + { 'o', &o_optname, + STRING, 0, NULL, opt_o, + { "log file: ", NULL, NULL } }, - { 'O', STRING, 0, NULL, opt__O, - "Log file: ", NULL, NULL + { 'O', &O__optname, + STRING, 0, NULL, opt__O, + { "Log file: ", NULL, NULL } }, #endif - { 'p', STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p, - NULL, NULL, NULL - }, - { 'P', STRING, 0, NULL, opt__P, - "prompt: ", NULL, NULL - }, - { 'q', TRIPLE, OPT_OFF, &quiet, NULL, - "Ring the bell for errors AND at eof/bof", - "Ring the bell for errors but not at eof/bof", - "Never ring the bell" - }, - { 'r', BOOL|REPAINT, OPT_ON, &ctldisp, NULL, - "Display control characters directly", - "Display control characters as ^X", - NULL - }, - { 's', BOOL|REPAINT, OPT_OFF, &squeeze, NULL, - "Display all blank lines", - "Squeeze multiple blank lines", - NULL - }, - { 'S', BOOL|REPAINT, OPT_OFF, &chopline, NULL, - "Fold long lines", - "Chop long lines", - NULL + { 'p', &p_optname, + STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p, + { NULL, NULL, NULL } + }, + { 'P', &P__optname, + STRING, 0, NULL, opt__P, + { "prompt: ", NULL, NULL } + }, + { 'q', &q_optname, + TRIPLE, OPT_OFF, &quiet, NULL, + { + "Ring the bell for errors AND at eof/bof", + "Ring the bell for errors but not at eof/bof", + "Never ring the bell" + } + }, + { 'r', &r_optname, + TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL, + { + "Display control characters as ^X", + "Display control characters directly", + "Display control characters directly, processing ANSI sequences" + } + }, + { 's', &s_optname, + BOOL|REPAINT, OPT_OFF, &squeeze, NULL, + { + "Display all blank lines", + "Squeeze multiple blank lines", + NULL + } + }, + { 'S', &S__optname, + BOOL|REPAINT, OPT_OFF, &chopline, NULL, + { + "Fold long lines", + "Chop long lines", + NULL + } }, #if TAGS - { 't', STRING|NO_QUERY, 0, NULL, opt_t, - "tag: ", NULL, NULL + { 't', &t_optname, + STRING|NO_QUERY, 0, NULL, opt_t, + { "tag: ", NULL, NULL } }, - { 'T', STRING, 0, NULL, opt__T, - "tags file: ", NULL, NULL + { 'T', &T__optname, + STRING, 0, NULL, opt__T, + { "tags file: ", NULL, NULL } }, #endif - { 'u', TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL, - "Display underlined text in underline mode", - "Backspaces cause overstrike", - "Print backspace as ^H" - }, - { 'V', NOVAR, 0, NULL, opt__V, - NULL, NULL, NULL - }, - { 'w', BOOL|REPAINT, OPT_ON, &twiddle, NULL, - "Display nothing for lines after end-of-file", - "Display ~ for lines after end-of-file", - NULL - }, - { 'x', NUMBER|REPAINT, 8, &tabstop, NULL, - "Tab stops: ", - "Tab stops every %d spaces", - NULL - }, - { 'X', BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL, - "Send init/deinit strings to terminal", - "Don't use init/deinit strings", - NULL - }, - { 'y', NUMBER, -1, &forw_scroll, NULL, - "Forward scroll limit: ", - "Forward scroll limit is %d lines", - NULL - }, - { 'z', NUMBER, -1, &swindow, NULL, - "Scroll window size: ", - "Scroll window size is %d lines", - NULL - }, - { '?', NOVAR, 0, NULL, opt_query, - NULL, NULL, NULL - }, - { '\0' } + { 'u', &u_optname, + TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL, + { + "Display underlined text in underline mode", + "Backspaces cause overstrike", + "Print backspace as ^H" + } + }, + { 'V', &V__optname, + NOVAR, 0, NULL, opt__V, + { NULL, NULL, NULL } + }, + { 'w', &w_optname, + TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL, + { + "Don't highlight first unread line", + "Highlight first unread line after forward-screen", + "Highlight first unread line after any forward movement", + } + }, + { 'x', &x_optname, + STRING|REPAINT, 0, NULL, opt_x, + { + "Tab stops: ", + "0123456789,", + NULL + } + }, + { 'X', &X__optname, + BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL, + { + "Send init/deinit strings to terminal", + "Don't use init/deinit strings", + NULL + } + }, + { 'y', &y_optname, + NUMBER, -1, &forw_scroll, NULL, + { + "Forward scroll limit: ", + "Forward scroll limit is %d lines", + NULL + } + }, + { 'z', &z_optname, + NUMBER, -1, &swindow, NULL, + { + "Scroll window size: ", + "Scroll window size is %d lines", + NULL + } + }, + { '"', "e_optname, + STRING, 0, NULL, opt_quote, + { "quotes: ", NULL, NULL } + }, + { '~', &tilde_optname, + BOOL|REPAINT, OPT_ON, &twiddle, NULL, + { + "Don't show tildes after end of file", + "Show tildes after end of file", + NULL + } + }, + { '?', &query_optname, + NOVAR, 0, NULL, opt_query, + { NULL, NULL, NULL } + }, + { '#', £_optname, + NUMBER, 0, &shift_count, NULL, + { + "Horizontal shift: ", + "Horizontal shift %d positions", + NULL + } + }, + { '.', &keypad_optname, + BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL, + { + "Use keypad mode", + "Don't use keypad mode", + NULL + } + }, + { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } } }; @@ -252,26 +428,44 @@ static struct option option[] = public void init_option() { - struct option *o; + register struct loption *o; + extern int ismore; for (o = option; o->oletter != '\0'; o++) { /* + * Replace less's -d option if invoked as more + */ + if (ismore && o->oletter == 'd') + { + o->onames = NULL; + o->otype = BOOL; + o->odefault = OPT_OFF; + o->ovar = &be_helpful; + o->ofunc = NULL; + o->odesc[0] = "Be less helpful in prompts"; + o->odesc[1] = "Be helpful in prompts"; + o->odesc[2] = NULL; + } + + /* * Set each variable to its default. */ if (o->ovar != NULL) *(o->ovar) = o->odefault; + if (o->otype & INIT_HANDLER) + (*(o->ofunc))(INIT, (char *) NULL); } } /* - * Find an option in the option table. + * Find an option in the option table, given its option letter. */ - public struct option * + public struct loption * findopt(c) int c; { - struct option *o; + register struct loption *o; for (o = option; o->oletter != '\0'; o++) { @@ -282,3 +476,106 @@ findopt(c) } return (NULL); } + +/* + * + */ + static int +is_optchar(c) + char c; +{ + if (SIMPLE_IS_UPPER(c)) + return 1; + if (SIMPLE_IS_LOWER(c)) + return 1; + if (c == '-') + return 1; + return 0; +} + +/* + * 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; +{ + char *optname = *p_optname; + register struct loption *o; + register struct optname *oname; + register int len; + int uppercase; + struct loption *maxo = NULL; + struct optname *maxoname = NULL; + int maxlen = 0; + int ambig = 0; + int exact = 0; + + /* + * Check all options. + */ + for (o = option; o->oletter != '\0'; o++) + { + /* + * Check all names for this option. + */ + 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++) + { + len = sprefix(optname, oname->oname, uppercase); + if (len <= 0 || is_optchar(optname[len])) + { + /* + * We didn't use all of the option name. + */ + continue; + } + 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) + { + /* + * Found a better match than + * the one we had. + */ + maxo = o; + maxoname = oname; + maxlen = len; + ambig = 0; + exact = (len == (int)strlen(oname->oname)); + } + if (!(o->otype & TRIPLE)) + break; + } + } + } + if (ambig) + { + /* + * Name matched more than one option. + */ + if (p_err != NULL) + *p_err = OPT_AMBIG; + return (NULL); + } + *p_optname = optname + maxlen; + if (p_oname != NULL) + *p_oname = maxoname == NULL ? NULL : maxoname->oname; + return (maxo); +} diff --git a/usr.bin/less/os.c b/usr.bin/less/os.c index c4235f81979..ac63960df95 100644 --- a/usr.bin/less/os.c +++ b/usr.bin/less/os.c @@ -1,29 +1,11 @@ -/* $OpenBSD: os.c,v 1.5 2003/03/13 09:09:32 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -40,7 +22,6 @@ */ #include "less.h" -#include <limits.h> #include <signal.h> #include <setjmp.h> #if HAVE_TIME_H @@ -78,6 +59,8 @@ public int reading; static jmp_buf read_label; +extern int sigs; + /* * Like read() system call, but is deliberately interruptible. * A call to intread() from a signal handler will interrupt @@ -89,9 +72,13 @@ iread(fd, buf, len) char *buf; unsigned int len; { - int n; + register int n; -#if MSOFTC +#if MSDOS_COMPILER==WIN32C + if (ABORT_SIGS()) + return (READ_INTR); +#else +#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC if (kbhit()) { int c; @@ -102,21 +89,71 @@ iread(fd, buf, len) ungetch(c); } #endif +#endif if (SET_JUMP(read_label)) { /* * We jumped here from intread. */ reading = 0; +#if HAVE_SIGPROCMASK + { + sigset_t mask; + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + } +#else #if HAVE_SIGSETMASK sigsetmask(0); +#else +#ifdef _OSK + sigmask(~0); +#endif +#endif #endif return (READ_INTR); } flush(); reading = 1; +#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 reading = 0; if (n < 0) return (-1); @@ -162,7 +199,7 @@ strerror(err) if (err < sys_nerr) return sys_errlist[err]; - snprintf(buf, sizeof buf, "Error %d", err); + snprintf(buf, sizeof(buf), "Error %d", err); return buf; #else return ("cannot open"); @@ -177,11 +214,13 @@ strerror(err) errno_message(filename) char *filename; { - char *p; - char *m; - int len; + 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"; @@ -193,48 +232,98 @@ errno_message(filename) } /* - * Return the largest possible number that can fit in a POSITION. + * Return the ratio of two POSITIONS, as a percentage. + * {{ Assumes a POSITION is a long int. }} */ -#ifdef QUAD_MAX - static POSITION -get_maxpos() + public int +percentage(num, den) + POSITION num, den; { - return (QUAD_MAX); + POSITION num100 = num * 100; + + if (num100 / 100 == num) + return (num100 / den); + else + return (num / (den / 100)); } -#else - static POSITION -get_maxpos() + +/* + * Return the specified percentage of a POSITION. + */ + public POSITION +percent_pos(pos, percent) + POSITION pos; + int percent; { - POSITION n, n2; + POSITION result100; - /* - * Keep doubling n until we overflow. - * {{ This actually only returns the largest power of two that - * can fit in a POSITION, but percentage() doesn't really need - * it any more accurate than that. }} - */ - n2 = 128; /* Hopefully no maxpos is less than 128! */ - do { - n = n2; - n2 *= 2; - } while (n2 / 2 == n); - return (n); + if (percent == 0) + return (0); + else if ((result100 = pos * percent) / percent == pos) + return (result100 / 100); + else + return (percent * (pos / 100)); +} + +#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 + /* - * Return the ratio of two POSITIONs, as a percentage. + * This implements an ANSI-style intercept setup for Microware C 3.2 */ - public int -percentage(num, den) - POSITION num, den; + public int +os9_signal(type, handler) + int type; + RETSIGTYPE (*handler)(); { - static POSITION maxpos100 = 0; - - if (maxpos100 == 0) - maxpos100 = get_maxpos() / 100; - if (num > maxpos100) - return (num / (den/100)); - else - return (100*num / den); + 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); +} + +#endif diff --git a/usr.bin/less/output.c b/usr.bin/less/output.c index e44e8d614fe..6f9d2350dc4 100644 --- a/usr.bin/less/output.c +++ b/usr.bin/less/output.c @@ -1,29 +1,11 @@ -/* $OpenBSD: output.c,v 1.4 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,15 +14,29 @@ */ #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; extern int sigs; extern int sc_width; extern int so_s_width, so_e_width; extern int screen_trashed; extern int any_display; +extern int is_tty; + +#if 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 /* * Display the line which is in the line buffer. @@ -48,8 +44,8 @@ extern int any_display; public void put_line() { - int c; - int i; + register int c; + register int i; int a; int curr_attr; @@ -104,9 +100,10 @@ put_line() case AT_BLINK: bl_exit(); break; case AT_STANDOUT: so_exit(); break; } + final_attr = curr_attr; } -static char obuf[1024]; +static char obuf[OUTBUF_SIZE]; static char *ob = obuf; /* @@ -128,22 +125,233 @@ static char *ob = obuf; public void flush() { - int n; - int fd; + register int n; + register int fd; -#if MSOFTC - *ob = '\0'; - _outtext(obuf); - ob = obuf; -#else n = ob - obuf; if (n == 0) return; +#if MSDOS_COMPILER==WIN32C + if (is_tty && any_display) + { + char *op; + DWORD nwritten = 0; + CONSOLE_SCREEN_BUFFER_INFO scr; + int row; + int col; + int olen; + extern HANDLE con_out; + + olen = ob - obuf; + /* + * There is a bug in Win32 WriteConsole() if we're + * writing in the last cell with a different color. + * To avoid color problems in the bottom line, + * we scroll the screen manually, before writing. + */ + GetConsoleScreenBufferInfo(con_out, &scr); + col = scr.dwCursorPosition.X; + row = scr.dwCursorPosition.Y; + for (op = obuf; op < obuf + olen; op++) + { + if (*op == '\n') + { + col = 0; + row++; + } else if (*op == '\r') + { + col = 0; + } else + { + col++; + if (col >= sc_width) + { + col = 0; + row++; + } + } + } + if (row > scr.srWindow.Bottom) + win32_scroll_up(row - scr.srWindow.Bottom); + WriteConsole(con_out, obuf, olen, &nwritten, NULL); + ob = obuf; + return; + } +#else +#if MSDOS_COMPILER==MSOFTC + if (is_tty && any_display) + { + *ob = '\0'; + _outtext(obuf); + ob = obuf; + return; + } +#else +#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC + if (is_tty && any_display) + { + *ob = '\0'; + if (ctldisp != OPT_ONPLUS) + cputs(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; + int buflen = ob - obuf; + unsigned char fg, bg, norm_attr; + /* + * Only dark colors mentioned here, so that + * bold has visible effect. + */ + static enum COLORS screen_color[] = { + BLACK, RED, GREEN, BROWN, + BLUE, MAGENTA, CYAN, LIGHTGRAY + }; + + /* Normal text colors are used as baseline. */ + bg = nm_bg_color & 0xf; + fg = nm_fg_color & 0xf; + norm_attr = (bg << 4) | fg; + for (anchor = p_next = obuf; + (p_next = memchr (p_next, ESC, + buflen - (p_next - obuf))) + != NULL; ) + { + p = p_next; + + /* + * Handle the null escape sequence + * (ESC-[m), which is used to restore + * the original color. + */ + if (p[1] == '[' && is_ansi_end(p[2])) + { + textattr(norm_attr); + p += 3; + anchor = p_next = p; + continue; + } + + if (p[1] == '[') /* "Esc-[" sequence */ + { + /* + * If some chars seen since + * the last escape sequence, + * write it out to the screen + * using current text attributes. + */ + if (p > anchor) + { + *p = '\0'; + cputs (anchor); + *p = ESC; + anchor = p; + } + p += 2; + p_next = p; + while (!is_ansi_end(*p)) + { + char *q; + long code = strtol(p, &q, 10); + + if (!*q) + { + /* + * Incomplete sequence. + * Leave it unprocessed + * in the buffer. + */ + int slop = q - anchor; + 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) + { + case 1: /* bold on */ + fg = bo_fg_color; + bg = bo_bg_color; + break; + case 3: /* italic on */ + fg = so_fg_color; + bg = so_bg_color; + break; + case 4: /* underline on */ + fg = ul_fg_color; + bg = ul_bg_color; + break; + case 8: /* concealed on */ + fg = (bg & 7) | 8; + break; + case 0: /* all attrs off */ + case 22:/* bold off */ + case 23:/* italic off */ + case 24:/* underline off */ + fg = nm_fg_color; + bg = nm_bg_color; + 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) + { + bg &= 15; + fg &= 15; + textattr ((bg << 4)| fg); + p_next = anchor = p + 1; + } else + break; + } else + p_next++; + } + + /* Output what's left in the buffer. */ + cputs (anchor); + } + ob = obuf; + return; + } +#endif +#endif +#endif fd = (any_display) ? 1 : 2; if (write(fd, obuf, n) != n) screen_trashed = 1; ob = obuf; -#endif } /* @@ -153,17 +361,29 @@ flush() putchr(c) int c; { - if (ob >= &obuf[sizeof(obuf)]) - flush(); if (need_clr) { need_clr = 0; clear_bot(); } -#if MSOFTC - if (c == '\n') +#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]) + flush(); *ob++ = c; return (c); } @@ -173,7 +393,7 @@ putchr(c) */ public void putstr(s) - char *s; + register char *s; { while (*s != '\0') putchr(*s++); @@ -181,34 +401,56 @@ putstr(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); \ +} + +TYPE_TO_A_FUNC(postoa, POSITION) +TYPE_TO_A_FUNC(linenumtoa, LINENUM) +TYPE_TO_A_FUNC(inttoa, int) + +/* * Output an integer in a given radix. */ static int -iprintnum(num, radix) +iprint_int(num) int num; - int radix; { - char *s; - int r; - int neg; - char buf[10]; - - if (neg = (num < 0)) - num = -num; + char buf[INT_STRLEN_BOUND(num)]; - s = buf; - do - { - *s++ = (num % radix) + '0'; - } while ((num /= radix) != 0); + inttoa(num, buf, sizeof(buf)); + putstr(buf); + return (strlen(buf)); +} - if (neg) - *s++ = '-'; - r = s - buf; +/* + * Output a line number in a given radix. + */ + static int +iprint_linenum(num) + LINENUM num; +{ + char buf[INT_STRLEN_BOUND(num)]; - while (s > buf) - putchr(*--s); - return (r); + linenumtoa(num, buf, sizeof(buf)); + putstr(buf); + return (strlen(buf)); } /* @@ -216,13 +458,12 @@ iprintnum(num, radix) * using a more portable argument list mechanism than printf's. */ static int -iprintf(fmt, parg) - char *fmt; +less_printf(fmt, parg) + register char *fmt; PARG *parg; { - char *s; - int n; - int col; + register char *s; + register int col; col = 0; while (*fmt != '\0') @@ -234,7 +475,8 @@ iprintf(fmt, parg) } else { ++fmt; - switch (*fmt++) { + switch (*fmt++) + { case 's': s = parg->p_string; parg++; @@ -245,9 +487,12 @@ iprintf(fmt, parg) } break; case 'd': - n = parg->p_int; + col += iprint_int(parg->p_int); + parg++; + break; + case 'n': + col += iprint_linenum(parg->p_linenum); parg++; - col += iprintnum(n, 10); break; } } @@ -256,6 +501,28 @@ iprintf(fmt, parg) } /* + * Get a RETURN. + * If some other non-trivial char is pressed, unget it, so it will + * become the next command. + */ + public void +get_return() +{ + int c; + +#if ONLY_RETURN + while ((c = getchr()) != '\n' && c != '\r') + bell(); +#else + c = getchr(); + if (c == 'q') + quit(QUIT_OK); + 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. */ @@ -264,22 +531,21 @@ error(fmt, parg) char *fmt; PARG *parg; { - int c; int col = 0; static char return_to_continue[] = " (press RETURN)"; errmsgs++; - if (any_display) + if (any_display && is_tty) { clear_bot(); so_enter(); col += so_s_width; } - col += iprintf(fmt, parg); + col += less_printf(fmt, parg); - if (!any_display) + if (!(any_display && is_tty)) { putchr('\n'); return; @@ -289,16 +555,7 @@ error(fmt, parg) so_exit(); col += sizeof(return_to_continue) + so_e_width; -#if ONLY_RETURN - while ((c = getchr()) != '\n' && c != '\r') - bell(); -#else - c = getchr(); - if (c == 'q') - quit(QUIT_OK); - if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR) - ungetcc(c); -#endif + get_return(); lower_left(); if (col >= sc_width) @@ -327,7 +584,7 @@ ierror(fmt, parg) { clear_bot(); so_enter(); - (void) iprintf(fmt, parg); + (void) less_printf(fmt, parg); putstr(intr_to_abort); so_exit(); flush(); @@ -343,16 +600,16 @@ query(fmt, parg) char *fmt; PARG *parg; { - int c; + register int c; int col = 0; - if (any_display) + if (any_display && is_tty) clear_bot(); - (void) iprintf(fmt, parg); + (void) less_printf(fmt, parg); c = getchr(); - if (!any_display) + if (!(any_display && is_tty)) { putchr('\n'); return (c); diff --git a/usr.bin/less/position.c b/usr.bin/less/position.c index 13869affb0b..7c10068856d 100644 --- a/usr.bin/less/position.c +++ b/usr.bin/less/position.c @@ -1,29 +1,11 @@ -/* $OpenBSD: position.c,v 1.4 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -58,9 +40,6 @@ extern int sc_width, sc_height; position(where) int where; { - if (where >= table_size) - where = BOTTOM; - switch (where) { case BOTTOM: @@ -82,7 +61,7 @@ position(where) add_forw_pos(pos) POSITION pos; { - int i; + register int i; /* * Scroll the position table up. @@ -99,7 +78,7 @@ add_forw_pos(pos) add_back_pos(pos) POSITION pos; { - int i; + register int i; /* * Scroll the position table down. @@ -115,7 +94,7 @@ add_back_pos(pos) public void pos_clear() { - int i; + register int i; for (i = 0; i < sc_height; i++) table[i] = NULL_POSITION; @@ -157,7 +136,7 @@ pos_init() onscreen(pos) POSITION pos; { - int i; + register int i; if (pos < table[0]) return (-1); @@ -181,7 +160,7 @@ empty_lines(s, e) int s; int e; { - int i; + register int i; for (i = s; i <= e; i++) if (table[i] != NULL_POSITION) @@ -201,7 +180,7 @@ empty_lines(s, e) get_scrpos(scrpos) struct scrpos *scrpos; { - int i; + register int i; /* * Find the first line on the screen which has something on it, diff --git a/usr.bin/less/position.h b/usr.bin/less/position.h index 68f7f17dae2..29a90d91c79 100644 --- a/usr.bin/less/position.h +++ b/usr.bin/less/position.h @@ -1,29 +1,11 @@ -/* $OpenBSD: position.h,v 1.2 2001/01/29 01:58:03 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ diff --git a/usr.bin/less/prompt.c b/usr.bin/less/prompt.c index 5a7159b18ce..9a257809fab 100644 --- a/usr.bin/less/prompt.c +++ b/usr.bin/less/prompt.c @@ -1,29 +1,11 @@ -/* $OpenBSD: prompt.c,v 1.6 2003/04/06 23:38:07 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -45,30 +27,41 @@ extern int new_file; extern int sc_width; extern int so_s_width, so_e_width; extern int linenums; +extern int hshift; +extern int ismore; extern int sc_height; extern int jump_sline; 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 char s_proto[] = - "?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\\: %x..%t"; -static char m_proto[] = - "?f%f .?m(file %i of %m) .?e(END) ?x- Next\\: %x.:(?pB%pB\\%:byte %bB?s/%s..).%t"; -static char M_proto[] = - "?f%f .?n?m(file %i of %m) ..?ltline %lt?L/%L. :byte %bB?s/%s. .?e(END) ?x- Next\\: %x.:?pB%pB\\%..%t"; -static char e_proto[] = - "?f%f .?m(file %i of %m) .?ltline %lt?L/%L. .byte %bB?s/%s. ?e(END) :?pB%pB\\%..%t"; +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 more_proto[] = + "--More--.?e(END) ?x- Next\\: %x.:(?pB%pB\\%:byte %bB?s/%s..).%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 *eqproto = e_proto; +public char constant *eqproto = e_proto; +public char constant *hproto = h_proto; +public char constant *wproto = w_proto; -static char message[250]; +static char message[PROMPT_SIZE]; static char *mp; /* @@ -77,20 +70,43 @@ static char *mp; public void init_prompt() { - prproto[0] = save(s_proto); + prproto[0] = save(ismore ? more_proto : s_proto); prproto[1] = save(m_proto); prproto[2] = save(M_proto); eqproto = save(e_proto); + hproto = save(h_proto); + wproto = save(w_proto); } /* - * Set the message pointer to the end of the message string. + * Append a string to the end of the message. */ static void -setmp() +ap_str(s) + char *s; { - while (*mp != '\0') - mp++; + int len; + + len = strlen(s); + if (mp + len >= message + PROMPT_SIZE) + len = message + PROMPT_SIZE - mp - 1; + strncpy(mp, s, len); + mp += len; + *mp = '\0'; +} + +/* + * Append a character to the end of the message. + */ + static void +ap_char(c) + char c; +{ + char buf[2]; + + buf[0] = c; + buf[1] = '\0'; + ap_str(buf); } /* @@ -100,30 +116,36 @@ setmp() ap_pos(pos) POSITION pos; { - snprintf(mp, message + sizeof message - mp, "%qd", pos); - setmp(); + char buf[INT_STRLEN_BOUND(pos) + 2]; + + postoa(pos, buf, sizeof(buf)); + ap_str(buf); } /* - * Append an integer to the end of the message. + * Append a line number to the end of the message. */ - static void -ap_int(n) - int n; + static void +ap_linenum(linenum) + LINENUM linenum; { - snprintf(mp, message + sizeof message - mp, "%d", n); - setmp(); + char buf[INT_STRLEN_BOUND(linenum) + 2]; + + linenumtoa(linenum, buf, sizeof(buf)); + ap_str(buf); } /* - * Append a string to the end of the message. + * Append an integer to the end of the message. */ static void -ap_str(s) - char *s; +ap_int(num) + int num; { - strtcpy(mp, s, (unsigned int)(&message[sizeof(message)] - mp)); - setmp(); + char buf[INT_STRLEN_BOUND(num) + 2]; + + inttoa(num, buf, sizeof(buf)); + ap_str(buf); } /* @@ -132,8 +154,7 @@ ap_str(s) static void ap_quest() { - if (mp < message + sizeof message - 1) - *mp++ = '?'; + ap_str("?"); } /* @@ -164,31 +185,53 @@ cond(c, where) char c; int where; { + POSITION len; + switch (c) { case 'a': /* Anything in the message yet? */ return (mp > message); case 'b': /* Current byte offset known? */ return (curr_byte(where) != NULL_POSITION); + case 'c': + return (hshift != 0); case 'e': /* At end of file? */ return (hit_eof); case 'f': /* Filename known? */ return (strcmp(get_filename(curr_ifile), "-") != 0); case 'l': /* Line number known? */ + case 'd': /* Same as l */ return (linenums); case 'L': /* Final line number known? */ + case 'D': /* Same as L */ return (linenums && ch_length() != NULL_POSITION); 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); - case 'p': /* Percent into file known? */ +#endif + case 'p': /* Percent into file (bytes) known? */ return (curr_byte(where) != NULL_POSITION && ch_length() > 0); + case 'P': /* Percent into file (lines) known? */ + return (currline(where) != 0 && + (len = ch_length()) > 0 && + find_linenum(len) != 0); case 's': /* Size of file known? */ case 'B': return (ch_length() != NULL_POSITION); case 'x': /* Is there a "next" file? */ +#if TAGS + if (ntags()) + return (0); +#endif return (next_ifile(curr_ifile) != NULL_IFILE); } return (0); @@ -202,13 +245,16 @@ cond(c, where) * usually by appending something to the message being built. */ static void -protochar(c, where) +protochar(c, where, iseditproto) int c; int where; + int iseditproto; { POSITION pos; POSITION len; int n; + LINENUM linenum; + LINENUM last_linenum; IFILE h; switch (c) @@ -220,6 +266,24 @@ protochar(c, where) else ap_quest(); break; + case 'c': + ap_int(hshift); + break; + case 'd': /* Current page number */ + linenum = currline(where); + if (linenum > 0 && sc_height > 1) + ap_linenum(((linenum - 1) / (sc_height - 1)) + 1); + else + ap_quest(); + break; + case 'D': /* Last page number */ + len = ch_length(); + if (len == NULL_POSITION || len == ch_zero() || + (linenum = find_linenum(len)) <= 0) + ap_quest(); + else + ap_linenum(((linenum - 1) / (sc_height - 1)) + 1); + break; #if EDITOR case 'E': /* Editor name */ ap_str(editor); @@ -229,27 +293,38 @@ protochar(c, where) ap_str(get_filename(curr_ifile)); break; case 'i': /* Index into list of files */ - ap_int(get_index(curr_ifile)); +#if TAGS + if (ntags()) + ap_int(curr_tag()); + else +#endif + ap_int(get_index(curr_ifile)); break; case 'l': /* Current line number */ - n = currline(where); - if (n != 0) - ap_int(n); + linenum = currline(where); + if (linenum != 0) + ap_linenum(linenum); else ap_quest(); break; case 'L': /* Final line number */ len = ch_length(); if (len == NULL_POSITION || len == ch_zero() || - (n = find_linenum(len)) <= 0) + (linenum = find_linenum(len)) <= 0) ap_quest(); else - ap_int(n-1); + ap_linenum(linenum-1); break; case 'm': /* Number of files */ - ap_int(nifile()); +#if TAGS + n = ntags(); + if (n) + ap_int(n); + else +#endif + ap_int(nifile()); break; - case 'p': /* Percent into file */ + case 'p': /* Percent into file (bytes) */ pos = curr_byte(where); len = ch_length(); if (pos != NULL_POSITION && len > 0) @@ -257,6 +332,15 @@ protochar(c, where) else ap_quest(); break; + case 'P': /* Percent into file (lines) */ + linenum = currline(where); + if (linenum == 0 || + (len = ch_length()) == NULL_POSITION || len == ch_zero() || + (last_linenum = find_linenum(len)) <= 0) + ap_quest(); + else + ap_int(percentage(linenum, last_linenum)); + break; case 's': /* Size of file */ case 'B': len = ch_length(); @@ -269,6 +353,14 @@ protochar(c, where) while (mp > message && mp[-1] == ' ') mp--; 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 */ h = next_ifile(curr_ifile); if (h != NULL_IFILE) @@ -288,9 +380,9 @@ protochar(c, where) */ static char * skipcond(p) - char *p; + register char *p; { - int iflevel; + register int iflevel; /* * We came in here after processing a ? or :, @@ -341,6 +433,9 @@ skipcond(p) /*NOTREACHED*/ } +/* + * Decode a char that represents a position on the screen. + */ static char * wherechar(p, wp) char *p; @@ -348,7 +443,7 @@ wherechar(p, wp) { switch (*p) { - case 'b': case 'l': case 'p': + case 'b': case 'd': case 'l': case 'p': case 'P': switch (*++p) { case 't': *wp = TOP; break; @@ -370,8 +465,8 @@ pr_expand(proto, maxwidth) char *proto; int maxwidth; { - char *p; - int c; + register char *p; + register int c; int where; mp = message; @@ -384,17 +479,18 @@ pr_expand(proto, maxwidth) switch (*p) { default: /* Just put the character in the message */ - *mp++ = *p; + ap_char(*p); break; case '\\': /* Backslash escapes the next character */ p++; - *mp++ = *p; + ap_char(*p); break; case '?': /* Conditional (IF) */ if ((c = *++p) == '\0') --p; else { + where = 0; p = wherechar(p, &where); if (!cond(c, where)) p = skipcond(p); @@ -410,17 +506,22 @@ pr_expand(proto, maxwidth) --p; else { + where = 0; p = wherechar(p, &where); - protochar(c, where); + protochar(c, where, +#if EDITOR + (proto == editproto)); +#else + 0); +#endif + } break; } } - new_file = 0; if (mp == message) return (NULL); - *mp = '\0'; if (maxwidth > 0 && mp >= message + maxwidth) { /* @@ -450,5 +551,20 @@ eq_message() public char * pr_string() { - return (pr_expand(prproto[pr_type], sc_width-so_s_width-so_e_width-2)); + char *prompt; + + prompt = pr_expand((ch_getflags() & CH_HELPFILE) ? + hproto : prproto[pr_type], + sc_width-so_s_width-so_e_width-2); + new_file = 0; + return (prompt); +} + +/* + * Return a message suitable for printing while waiting in the F command. + */ + public char * +wait_message() +{ + 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 index 65863bdc97c..8d221ae1d0d 100644 --- a/usr.bin/less/regexp.c +++ b/usr.bin/less/regexp.c @@ -1,5 +1,3 @@ -/* $OpenBSD: regexp.c,v 1.6 2003/04/06 23:38:07 deraadt Exp $ */ - /* * regcomp and regexec -- regsub and regerror are elsewhere * @@ -26,11 +24,20 @@ * * *** 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" -char *strchr(); /* * The "internal use only" fields in regexp.h are present to pass info from @@ -69,6 +76,7 @@ char *strchr(); */ /* 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. */ @@ -202,10 +210,10 @@ regexp * regcomp(exp) char *exp; { - regexp *r; - char *scan; - char *longest; - int len; + register regexp *r; + register char *scan; + register char *longest; + register int len; int flags; if (exp == NULL) @@ -290,10 +298,10 @@ reg(paren, flagp) int paren; /* Parenthesized? */ int *flagp; { - char *ret; - char *br; - char *ender; - int parno = 0; + register char *ret; + register char *br; + register char *ender; + register int parno = 0; int flags; *flagp = HASWIDTH; /* Tentatively. */ @@ -361,9 +369,9 @@ static char * regbranch(flagp) int *flagp; { - char *ret; - char *chain; - char *latest; + register char *ret; + register char *chain; + register char *latest; int flags; *flagp = WORST; /* Tentatively. */ @@ -400,9 +408,9 @@ static char * regpiece(flagp) int *flagp; { - char *ret; - char op; - char *next; + register char *ret; + register char op; + register char *next; int flags; ret = regatom(&flags); @@ -464,7 +472,7 @@ static char * regatom(flagp) int *flagp; { - char *ret; + register char *ret; int flags; *flagp = WORST; /* Tentatively. */ @@ -481,8 +489,8 @@ int *flagp; *flagp |= HASWIDTH|SIMPLE; break; case '[': { - int clss; - int classend; + register int clss; + register int classend; if (*regparse == '^') { /* Complement of range. */ ret = regnode(ANYBUT); @@ -542,8 +550,8 @@ int *flagp; *flagp |= HASWIDTH|SIMPLE; break; default: { - int len; - char ender; + register int len; + register char ender; regparse--; len = strcspn(regparse, META); @@ -575,8 +583,8 @@ static char * /* Location. */ regnode(op) char op; { - char *ret; - char *ptr; + register char *ret; + register char *ptr; ret = regcode; if (ret == ®dummy) { @@ -616,9 +624,9 @@ reginsert(op, opnd) char op; char *opnd; { - char *src; - char *dst; - char *place; + register char *src; + register char *dst; + register char *place; if (regcode == ®dummy) { regsize += 3; @@ -645,9 +653,9 @@ regtail(p, val) char *p; char *val; { - char *scan; - char *temp; - int offset; + register char *scan; + register char *temp; + register int offset; if (p == ®dummy) return; @@ -712,11 +720,12 @@ STATIC char *regprop(); - regexec - match a regexp against a string */ int -regexec(prog, string) -regexp *prog; -char *string; +regexec2(prog, string, notbol) +register regexp *prog; +register char *string; +int notbol; { - char *s; + register char *s; /* Be paranoid... */ if (prog == NULL || string == NULL) { @@ -743,7 +752,10 @@ char *string; } /* Mark beginning of line for ^ . */ - regbol = string; + if (notbol) + regbol = NULL; + else + regbol = string; /* Simplest case: anchored match need be tried only once. */ if (prog->reganch) @@ -769,6 +781,14 @@ char *string; return(0); } +int +regexec(prog, string) +register regexp *prog; +register char *string; +{ + return regexec2(prog, string, 0); +} + /* - regtry - try match at specific point */ @@ -777,9 +797,9 @@ regtry(prog, string) regexp *prog; char *string; { - int i; - char **sp; - char **ep; + register int i; + register char **sp; + register char **ep; reginput = string; regstartp = prog->startp; @@ -813,7 +833,7 @@ static int /* 0 failure, 1 success */ regmatch(prog) char *prog; { - char *scan; /* Current node. */ + register char *scan; /* Current node. */ char *next; /* Next node. */ scan = prog; @@ -843,8 +863,8 @@ char *prog; reginput++; break; case EXACTLY: { - int len; - char *opnd; + register int len; + register char *opnd; opnd = OPERAND(scan); /* Inline the first character, for speed. */ @@ -879,8 +899,8 @@ char *prog; case OPEN+7: case OPEN+8: case OPEN+9: { - int no; - char *save; + register int no; + register char *save; no = OP(scan) - OPEN; save = reginput; @@ -908,8 +928,8 @@ char *prog; case CLOSE+7: case CLOSE+8: case CLOSE+9: { - int no; - char *save; + register int no; + register char *save; no = OP(scan) - CLOSE; save = reginput; @@ -929,7 +949,7 @@ char *prog; /* NOTREACHED */ break; case BRANCH: { - char *save; + register char *save; if (OP(next) != BRANCH) /* No choice. */ next = OPERAND(scan); /* Avoid recursion. */ @@ -949,10 +969,10 @@ char *prog; break; case STAR: case PLUS: { - char nextch; - int no; - char *save; - int min; + register char nextch; + register int no; + register char *save; + register int min; /* * Lookahead to avoid useless match attempts @@ -1006,9 +1026,9 @@ static int regrepeat(p) char *p; { - int count = 0; - char *scan; - char *opnd; + register int count = 0; + register char *scan; + register char *opnd; scan = reginput; opnd = OPERAND(p); @@ -1050,9 +1070,9 @@ char *p; */ static char * regnext(p) -char *p; +register char *p; { - int offset; + register int offset; if (p == ®dummy) return(NULL); @@ -1078,9 +1098,9 @@ void regdump(r) regexp *r; { - char *s; - char op = EXACTLY; /* Arbitrary non-END op. */ - char *next; + register char *s; + register char op = EXACTLY; /* Arbitrary non-END op. */ + register char *next; s = r->program + 1; @@ -1121,10 +1141,10 @@ static char * regprop(op) char *op; { - char *p; + register char *p; static char buf[50]; - (void) strlcpy(buf, ":", sizeof buf); + (void) strlcpy(buf, ":", sizeof(buf)); switch (OP(op)) { case BOL: @@ -1166,7 +1186,7 @@ char *op; case OPEN+7: case OPEN+8: case OPEN+9: - snprintf(buf+strlen(buf), sizeof buf - strlen(buf), + snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "OPEN%d", OP(op)-OPEN); p = NULL; break; @@ -1179,7 +1199,7 @@ char *op; case CLOSE+7: case CLOSE+8: case CLOSE+9: - snprintf(buf+strlen(buf), sizeof buf - strlen(buf), + snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "CLOSE%d", OP(op)-CLOSE); p = NULL; break; @@ -1194,7 +1214,7 @@ char *op; break; } if (p != NULL) - (void) strlcat(buf, p, sizeof buf); + (void) strlcat(buf, p, sizeof(buf)); return(buf); } #endif @@ -1216,9 +1236,9 @@ strcspn(s1, s2) char *s1; char *s2; { - char *scan1; - char *scan2; - int count; + register char *scan1; + register char *scan2; + register int count; count = 0; for (scan1 = s1; *scan1 != '\0'; scan1++) { diff --git a/usr.bin/less/regexp.h b/usr.bin/less/regexp.h index 6c6e71fb52a..bcef6d1ebc7 100644 --- a/usr.bin/less/regexp.h +++ b/usr.bin/less/regexp.h @@ -1,5 +1,3 @@ -/* $OpenBSD: regexp.h,v 1.2 2001/01/29 01:58:04 niklas Exp $ */ - /* * Definitions etc. for regexp(3) routines. * @@ -29,6 +27,7 @@ typedef struct regexp { 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)); diff --git a/usr.bin/less/screen.c b/usr.bin/less/screen.c index cd5a0c2b6e3..784c1f44dcd 100644 --- a/usr.bin/less/screen.c +++ b/usr.bin/less/screen.c @@ -1,42 +1,43 @@ -/* $OpenBSD: screen.c,v 1.10 2003/04/06 23:38:07 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ /* * Routines which deal with the characteristics of the terminal. * Uses termcap to be as terminal-independent as possible. - * - * {{ Maybe someday this should be rewritten to use curses or terminfo. }} */ #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_TERMIOS_H && HAVE_TERMIOS_FUNCS #include <termios.h> #if HAVE_SYS_IOCTL_H && !defined(TIOCGWINSZ) @@ -46,28 +47,27 @@ #if HAVE_TERMIO_H #include <termio.h> #else +#if HAVE_SGSTAT_H +#include <sgstat.h> +#else #include <sgtty.h> +#endif #if HAVE_SYS_IOCTL_H && (defined(TIOCGWINSZ) || defined(TCGETA) || defined(TIOCGETP) || defined(WIOCGETD)) #include <sys/ioctl.h> #endif #endif #endif + #if HAVE_TERMCAP_H #include <termcap.h> #endif - -#ifndef TIOCGWINSZ -/* - * For the Unix PC (ATT 7300 & 3B1): - * Since WIOCGETD is defined in sys/window.h, we can't use that to decide - * whether to include sys/window.h. Use SIGPHONE from sys/signal.h instead. - */ -#include <sys/signal.h> -#ifdef SIGPHONE -#include <sys/window.h> +#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 @@ -75,12 +75,88 @@ #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 + #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. */ @@ -107,9 +183,9 @@ 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; -static int tty_fd = -1; public int auto_wrap; /* Terminal does \r\n when write past margin */ public int ignaw; /* Terminal ignores \n immediately after wrap */ @@ -122,8 +198,15 @@ 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 */ + +static int attrmode = AT_NORMAL; +#if !MSDOS_COMPILER static char *cheaper(); +static void tmodes(); +#endif /* * These two variables are sometimes defined in, @@ -133,14 +216,22 @@ static char *cheaper(); extern short ospeed; /* Terminal output baud rate */ extern char PC; /* Pad character */ #endif +#ifdef _OSK +short ospeed; +char PC_, *UP, *BC; +#endif extern int quiet; /* If VERY_QUIET, use visual bell for bell */ -extern int know_dumb; /* Don't complain about a dumb terminal */ -extern int back_scroll; +extern int no_back_scroll; extern int swindow; extern int no_init; +extern int no_keypad; +extern int sigs; +extern int wscroll; +extern int screen_trashed; +extern int tty; extern int quit_at_eof; -extern int more_mode; +extern int ismore; #if HILITE_SEARCH extern int hilite_search; #endif @@ -168,32 +259,27 @@ raw_mode(on) if (on == curr_on) return; - - if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0) - tty_fd = 2; - -#if OS2 - signal(SIGINT, SIG_IGN); - erase_char = '\b'; - kill_char = '\033'; -#else #if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS { struct termios s; static struct termios save_term; + static int saved_term = 0; if (on) { /* * Get terminal modes. */ - if (tcgetattr(tty_fd, &s) == -1) - return; + tcgetattr(tty, &s); /* * Save modes and set certain variables dependent on modes. */ - save_term = s; + if (!saved_term) + { + save_term = s; + saved_term = 1; + } #if HAVE_OSPEED switch (cfgetospeed(&s)) { @@ -259,7 +345,7 @@ raw_mode(on) #ifdef VWERASE werase_char = s.c_cc[VWERASE]; #else - werase_char = 0; + werase_char = CONTROL('W'); #endif /* @@ -284,14 +370,14 @@ raw_mode(on) ); s.c_oflag |= (0 -#ifdef XTABS - | XTABS +#ifdef OXTABS + | OXTABS #else #ifdef TAB3 | TAB3 #else -#ifdef OXTABS - | OXTABS +#ifdef XTABS + | XTABS #endif #endif #endif @@ -319,6 +405,19 @@ raw_mode(on) ); s.c_cc[VMIN] = 1; s.c_cc[VTIME] = 0; +#ifdef VLNEXT + s.c_cc[VLNEXT] = 0; +#endif +#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 { /* @@ -326,26 +425,45 @@ raw_mode(on) */ s = save_term; } - if (tcsetattr(tty_fd, TCSANOW, &s) == -1) - return; +#if HAVE_FSYNC + fsync(tty); +#endif + tcsetattr(tty, TCSADRAIN, &s); +#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_fd, TCGETA, &s); + ioctl(tty, TCGETA, &s); /* * Save modes and set certain variables dependent on modes. */ - save_term = s; + if (!saved_term) + { + save_term = s; + saved_term = 1; + } #if HAVE_OSPEED ospeed = s.c_cflag & CBAUD; #endif @@ -354,7 +472,7 @@ raw_mode(on) #ifdef VWERASE werase_char = s.c_cc[VWERASE]; #else - werase_char = 0; + werase_char = CONTROL('W'); #endif /* @@ -372,30 +490,36 @@ raw_mode(on) */ s = save_term; } - ioctl(tty_fd, TCSETAW, &s); + 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_fd, TIOCGETP, &s); + ioctl(tty, TIOCGETP, &s); /* * Save modes and set certain variables dependent on modes. */ - save_term = s; + 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 = 0; + werase_char = CONTROL('W'); /* * Set the modes to the way we want them. @@ -409,262 +533,497 @@ raw_mode(on) */ s = save_term; } - ioctl(tty_fd, TIOCSETN, &s); + 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 curr_on = on; } - static void -cannot(s) - char *s; +#if !MSDOS_COMPILER +/* + * Some glue to prevent calling termcap functions if tgetent() failed. + */ +static int hardcopy; + + static char * +ltget_env(capname) + char *capname; { - PARG parg; + char name[16]; - if (know_dumb || more_mode) - /* - * User knows this is a dumb terminal, so don't tell him. - * more doesn't complain about these, either. - */ - return; + strlcpy(name, "LESS_TERMCAP_", sizeof(name)); + strlcat(name, capname, sizeof(name)); + return (lgetenv(name)); +} + + static int +ltgetflag(capname) + char *capname; +{ + char *s; - parg.p_string = s; - error("WARNING: terminal cannot %s", &parg); + if ((s = ltget_env(capname)) != NULL) + return (*s != '\0' && *s != '0'); + if (hardcopy) + return (0); + return (tgetflag(capname)); } -/* - * Get size of the output screen. - */ -#if OS2 - public void -scrsize() + static int +ltgetnum(capname) + char *capname; { - int s[2]; + char *s; - _scrsize(s); - sc_width = s[0]; - sc_height = s[1]; + if ((s = ltget_env(capname)) != NULL) + return (atoi(s)); + if (hardcopy) + return (-1); + return (tgetnum(capname)); } -#else + 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() { - char *s; -#ifdef TIOCGWINSZ - struct winsize w; -#else -#ifdef WIOCGETD - struct uwdata w; + register char *s; + int sys_height; + int sys_width; +#if !MSDOS_COMPILER + int n; #endif + +#define DEF_SC_WIDTH 80 +#if MSDOS_COMPILER +#define DEF_SC_HEIGHT 25 +#else +#define DEF_SC_HEIGHT 24 #endif - if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0) - tty_fd = 2; + 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; + } +#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 - if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_row > 0) - sc_height = w.ws_row; - else + { + 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 - if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_height > 0) - sc_height = w.uw_height/w.uw_vs; - else + { + 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 - if ((s = getenv("LINES")) != NULL) +#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 - sc_height = tgetnum("li"); + sc_height = DEF_SC_HEIGHT; - if (sc_height <= 0) - sc_height = 24; - -#ifdef TIOCGWINSZ - if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_col > 0) - sc_width = w.ws_col; - else -#ifdef WIOCGETD - if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_width > 0) - sc_width = w.uw_width/w.uw_hs; - else -#endif -#endif - if ((s = getenv("COLUMNS")) != NULL) + if (sys_width > 0) + 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 - sc_width = tgetnum("co"); - - if (sc_width <= 0) - sc_width = 80; + sc_width = DEF_SC_WIDTH; } -#endif /* OS2 */ +#if MSDOS_COMPILER==MSOFTC /* - * Take care of the "variable" keys. - * Certain keys send escape sequences which differ on different terminals - * (such as the arrow keys, INSERT, DELETE, etc.) - * Construct the commands based on these keys. + * Figure out how many empty loops it takes to delay a millisecond. */ - public void -get_editkeys() + static void +get_clock() { - char *sp; - char *s; - char tbuf[40]; - - static char kfcmdtable[400]; - int sz_kfcmdtable = 0; - static char kecmdtable[400]; - int sz_kecmdtable = 0; - -#define put_cmd(str,action,tbl,sz) { \ - strcpy(tbl+sz, str); \ - sz += strlen(str) + 1; \ - tbl[sz++] = action; } -#define put_esc_cmd(str,action,tbl,sz) { \ - tbl[sz++] = ESC; \ - put_cmd(str,action,tbl,sz); } - -#define put_fcmd(str,action) put_cmd(str,action,kfcmdtable,sz_kfcmdtable) -#define put_ecmd(str,action) put_cmd(str,action,kecmdtable,sz_kecmdtable) -#define put_esc_fcmd(str,action) put_esc_cmd(str,action,kfcmdtable,sz_kfcmdtable) -#define put_esc_ecmd(str,action) put_esc_cmd(str,action,kecmdtable,sz_kecmdtable) - + clock_t start; + /* - * Look at some interesting keys and see what strings they send. - * Create commands (both command keys and line-edit keys). + * 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; +} - /* RIGHT ARROW */ - sp = tbuf; - if ((s = tgetstr("kr", &sp)) != NULL) - { - put_ecmd(s, EC_RIGHT); - put_esc_ecmd(s, EC_W_RIGHT); - } - - /* LEFT ARROW */ - sp = tbuf; - if ((s = tgetstr("kl", &sp)) != NULL) - { - put_ecmd(s, EC_LEFT); - put_esc_ecmd(s, EC_W_LEFT); - } - - /* UP ARROW */ - sp = tbuf; - if ((s = tgetstr("ku", &sp)) != NULL) - { - put_ecmd(s, EC_UP); - put_fcmd(s, A_B_LINE); - } - - /* DOWN ARROW */ - sp = tbuf; - if ((s = tgetstr("kd", &sp)) != NULL) - { - put_ecmd(s, EC_DOWN); - put_fcmd(s, A_F_LINE); - } - - /* PAGE UP */ - sp = tbuf; - if ((s = tgetstr("kP", &sp)) != NULL) - { - put_fcmd(s, A_B_SCREEN); - } +/* + * Delay for a specified number of milliseconds. + */ + static void +dummy_func() +{ + static long delay_dummy = 0; + delay_dummy++; +} - /* PAGE DOWN */ - sp = tbuf; - if ((s = tgetstr("kN", &sp)) != NULL) - { - put_fcmd(s, A_F_SCREEN); - } + static void +delay(msec) + int msec; +{ + long i; - /* HOME */ - sp = tbuf; - if ((s = tgetstr("kh", &sp)) != NULL) + while (msec-- > 0) { - put_ecmd(s, EC_HOME); - } - - /* END */ - sp = tbuf; - if ((s = tgetstr("@7", &sp)) != NULL) - { - put_ecmd(s, EC_END); + 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 - /* DELETE */ - sp = tbuf; - if ((s = tgetstr("kD", &sp)) == NULL) - { - /* Use DEL (\177) if no "kD" termcap. */ - tbuf[1] = '\177'; - tbuf[2] = '\0'; - s = tbuf+1; - } - put_ecmd(s, EC_DELETE); - put_esc_ecmd(s, EC_W_DELETE); - - /* BACKSPACE */ - tbuf[0] = ESC; - tbuf[1] = erase_char; - tbuf[2] = '\0'; - put_ecmd(tbuf, EC_W_BACKSPACE); +/* + * Return the characters actually input by a "special" key. + */ + public char * +special_key_str(key) + 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 - if (werase_char != 0) + switch (key) { - tbuf[0] = werase_char; - tbuf[1] = '\0'; - put_ecmd(tbuf, EC_W_BACKSPACE); - } - +#if OS2 /* - * Register the two tables. + * If windowid is not NULL, assume less is executed in + * the XFree86 environment. */ - add_fcmd_table(kfcmdtable, sz_kfcmdtable); - add_ecmd_table(kecmdtable, sz_kecmdtable); -} - -#if DEBUG - static void -get_debug_term() -{ - auto_wrap = 1; - ignaw = 1; - so_s_width = so_e_width = 0; - bo_s_width = bo_e_width = 0; - ul_s_width = ul_e_width = 0; - bl_s_width = bl_e_width = 0; - sc_s_keypad = "(InitKey)"; - sc_e_keypad = "(DeinitKey)"; - sc_init = "(InitTerm)"; - sc_deinit = "(DeinitTerm)"; - sc_eol_clear = "(ClearEOL)"; - sc_eos_clear = "(ClearEOS)"; - sc_clear = "(ClearScreen)"; - sc_move = "(Move<%d,%d>)"; - sc_s_in = "(SO+)"; - sc_s_out = "(SO-)"; - sc_u_in = "(UL+)"; - sc_u_out = "(UL-)"; - sc_b_in = "(BO+)"; - sc_b_out = "(BO-)"; - sc_bl_in = "(BL+)"; - sc_bl_out = "(BL-)"; - sc_visual_bell ="(VBell)"; - sc_backspace = "(BS)"; - sc_home = "(Home)"; - sc_lower_left = "(LL)"; - sc_addline = "(AddLine)"; -} + 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 + case SK_RIGHT_ARROW: + s = ltgetstr("kr", &sp); + break; + case SK_LEFT_ARROW: + s = ltgetstr("kl", &sp); + break; + case SK_UP_ARROW: + s = ltgetstr("ku", &sp); + break; + case SK_DOWN_ARROW: + s = ltgetstr("kd", &sp); + break; + case SK_PAGE_UP: + s = ltgetstr("kP", &sp); + break; + case SK_PAGE_DOWN: + s = ltgetstr("kN", &sp); + break; + case SK_HOME: + s = ltgetstr("kh", &sp); + break; + case SK_END: + s = ltgetstr("@7", &sp); + break; + case SK_DELETE: + s = ltgetstr("kD", &sp); + if (s == NULL) + { + tbuf[0] = '\177'; + tbuf[1] = '\0'; + s = tbuf; + } + break; #endif + case SK_CONTROL_K: + tbuf[0] = CONTROL('K'); + tbuf[1] = '\0'; + s = tbuf; + break; + default: + return (NULL); + } + return (s); +} /* * Get terminal capabilities via termcap. @@ -672,27 +1031,88 @@ get_debug_term() public void get_term() { +#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; - char *t1, *t2; - int hard; + register char *t1, *t2; char *term; - char termbuf[2048]; + char termbuf[TERMBUF_SIZE]; - static char sbuf[1024]; + static char sbuf[TERMSBUF_SIZE]; -#ifdef OS2 +#if OS2 /* * Make sure the termcap database is available. */ - sp = getenv("TERMCAP"); + sp = lgetenv("TERMCAP"); if (sp == NULL || *sp == '\0') { char *termcap; if ((sp = homefile("termcap.dat")) != NULL) { - size_t l = strlen(sp)+9; - termcap = (char *) ecalloc(l, sizeof(char)); - snprintf(termcap, l, "TERMCAP=%s", sp); + size_t len = strlen(sp) + 9; + termcap = (char *) ecalloc(len, sizeof(char)); + snprintf(termcap, len, "TERMCAP=%s", sp); free(sp); putenv(termcap); } @@ -701,12 +1121,13 @@ get_term() /* * Find out what kind of terminal this is. */ - if ((term = getenv("TERM")) == NULL) + if ((term = lgetenv("TERM")) == NULL) term = DEFAULT_TERM; + hardcopy = 0; if (tgetent(termbuf, term) <= 0) - strlcpy(termbuf, "dumb:hc:", sizeof termbuf); - - hard = tgetflag("hc"); + hardcopy = 1; + if (ltgetflag("hc")) + hardcopy = 1; /* * Get size of the screen. @@ -714,18 +1135,11 @@ get_term() scrsize(); pos_init(); -#if DEBUG - if (strncmp(term,"LESSDEBUG",9) == 0) - { - get_debug_term(); - return; - } -#endif /* DEBUG */ - - auto_wrap = tgetflag("am"); - ignaw = tgetflag("xn"); - above_mem = tgetflag("da"); - below_mem = tgetflag("db"); + auto_wrap = ltgetflag("am"); + ignaw = ltgetflag("xn"); + above_mem = ltgetflag("da"); + below_mem = ltgetflag("db"); + clear_bg = ltgetflag("ut"); /* * Assumes termcap variable "sg" is the printing width of: @@ -733,7 +1147,7 @@ get_term() * the underline sequence, the end underline sequence, * the boldface sequence, and the end boldface sequence. */ - if ((so_s_width = tgetnum("sg")) < 0) + if ((so_s_width = ltgetnum("sg")) < 0) so_s_width = 0; so_e_width = so_s_width; @@ -759,15 +1173,15 @@ get_term() sp = sbuf; #if HAVE_OSPEED - sc_pad = tgetstr("pc", &sp); + sc_pad = ltgetstr("pc", &sp); if (sc_pad != NULL) PC = *sc_pad; #endif - sc_s_keypad = tgetstr("ks", &sp); + sc_s_keypad = ltgetstr("ks", &sp); if (sc_s_keypad == NULL) sc_s_keypad = ""; - sc_e_keypad = tgetstr("ke", &sp); + sc_e_keypad = ltgetstr("ke", &sp); if (sc_e_keypad == NULL) sc_e_keypad = ""; @@ -776,39 +1190,39 @@ get_term() * that switch to/from an alternate screen, and we're in quit_at_eof * (eg, more(1)). */ - if (!quit_at_eof && !more_mode) { - sc_init = tgetstr("ti", &sp); - sc_deinit = tgetstr("te", &sp); + if (!quit_at_eof && !ismore) { + sc_init = ltgetstr("ti", &sp); + sc_deinit= ltgetstr("te", &sp); } if (sc_init == NULL) sc_init = ""; + if (sc_deinit == NULL) sc_deinit = ""; - sc_eol_clear = tgetstr("ce", &sp); - if (hard || sc_eol_clear == NULL || *sc_eol_clear == '\0') + sc_eol_clear = ltgetstr("ce", &sp); + if (sc_eol_clear == NULL || *sc_eol_clear == '\0') { - cannot("clear to end of line"); + missing_cap = 1; sc_eol_clear = ""; } - sc_eos_clear = tgetstr("cd", &sp); - if (below_mem && - (hard || sc_eos_clear == NULL || *sc_eos_clear == '\0')) + sc_eos_clear = ltgetstr("cd", &sp); + if (below_mem && (sc_eos_clear == NULL || *sc_eos_clear == '\0')) { - cannot("clear to end of screen"); + missing_cap = 1; sc_eol_clear = ""; } - sc_clear = tgetstr("cl", &sp); - if (hard || sc_clear == NULL || *sc_clear == '\0') + sc_clear = ltgetstr("cl", &sp); + if (sc_clear == NULL || *sc_clear == '\0') { - cannot("clear screen"); + missing_cap = 1; sc_clear = "\n\n"; } - sc_move = tgetstr("cm", &sp); - if (hard || sc_move == NULL || *sc_move == '\0') + sc_move = ltgetstr("cm", &sp); + if (sc_move == NULL || *sc_move == '\0') { /* * This is not an error here, because we don't @@ -820,55 +1234,20 @@ get_term() } else can_goto_line = 1; - sc_s_in = tgetstr("so", &sp); - if (hard || sc_s_in == NULL) - sc_s_in = ""; - - sc_s_out = tgetstr("se", &sp); - if (hard || sc_s_out == NULL) - sc_s_out = ""; - - sc_u_in = tgetstr("us", &sp); - if (hard || sc_u_in == NULL) - sc_u_in = sc_s_in; - - sc_u_out = tgetstr("ue", &sp); - if (hard || sc_u_out == NULL) - sc_u_out = sc_s_out; - - sc_b_in = tgetstr("md", &sp); - if (hard || sc_b_in == NULL) - { - sc_b_in = sc_s_in; - sc_b_out = sc_s_out; - } else - { - sc_b_out = tgetstr("me", &sp); - if (hard || sc_b_out == NULL) - sc_b_out = ""; - } - - sc_bl_in = tgetstr("mb", &sp); - if (hard || sc_bl_in == NULL) - { - sc_bl_in = sc_s_in; - sc_bl_out = sc_s_out; - } else - { - sc_bl_out = tgetstr("me", &sp); - if (hard || sc_bl_out == NULL) - sc_bl_out = ""; - } + 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); - sc_visual_bell = tgetstr("vb", &sp); - if (hard || sc_visual_bell == NULL) + sc_visual_bell = ltgetstr("vb", &sp); + if (sc_visual_bell == NULL) sc_visual_bell = ""; - if (tgetflag("bs")) + if (ltgetflag("bs")) sc_backspace = "\b"; else { - sc_backspace = tgetstr("bc", &sp); + sc_backspace = ltgetstr("bc", &sp); if (sc_backspace == NULL || *sc_backspace == '\0') sc_backspace = "\b"; } @@ -877,46 +1256,46 @@ get_term() * Choose between using "ho" and "cm" ("home" and "cursor move") * to move the cursor to the upper left corner of the screen. */ - t1 = tgetstr("ho", &sp); - if (hard || t1 == NULL) + t1 = ltgetstr("ho", &sp); + if (t1 == NULL) t1 = ""; if (*sc_move == '\0') t2 = ""; else { - strlcpy(sp, tgoto(sc_move, 0, 0), sbuf + sizeof sbuf - sp); + strlcpy(sp, tgoto(sc_move, 0, 0), sbuf + sizeof(sbuf) - sp); t2 = sp; sp += strlen(sp) + 1; } - sc_home = cheaper(t1, t2, "home cursor", "|\b^"); + sc_home = cheaper(t1, t2, "|\b^"); /* * Choose between using "ll" and "cm" ("lower left" and "cursor move") * to move the cursor to the lower left corner of the screen. */ - t1 = tgetstr("ll", &sp); - if (hard || t1 == NULL) + t1 = ltgetstr("ll", &sp); + if (t1 == NULL) t1 = ""; if (*sc_move == '\0') t2 = ""; else { - strlcpy(sp, tgoto(sc_move, 0, sc_height-1), sbuf + sizeof sbuf - sp); + strlcpy(sp, tgoto(sc_move, 0, sc_height-1), + sbuf + sizeof(sbuf) - sp); t2 = sp; sp += strlen(sp) + 1; } - sc_lower_left = cheaper(t1, t2, - "move cursor to lower left of screen", "\r"); + sc_lower_left = cheaper(t1, t2, "\r"); /* * Choose between using "al" or "sr" ("add line" or "scroll reverse") * to add a line at the top of the screen. */ - t1 = tgetstr("al", &sp); - if (hard || t1 == NULL) + t1 = ltgetstr("al", &sp); + if (t1 == NULL) t1 = ""; - t2 = tgetstr("sr", &sp); - if (hard || t2 == NULL) + t2 = ltgetstr("sr", &sp); + if (t2 == NULL) t2 = ""; #if OS2 if (*t1 == '\0' && *t2 == '\0') @@ -926,16 +1305,18 @@ get_term() if (above_mem) sc_addline = t1; else - sc_addline = cheaper(t1, t2, "scroll backwards", ""); + sc_addline = cheaper(t1, t2, ""); if (*sc_addline == '\0') { /* * Force repaint on any backward movement. */ - back_scroll = 0; + 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 @@ -969,14 +1350,13 @@ cost(t) * cost (see cost() function). */ static char * -cheaper(t1, t2, doit, def) +cheaper(t1, t2, def) char *t1, *t2; - char *doit; char *def; { if (*t1 == '\0' && *t2 == '\0') { - cannot(doit); + missing_cap = 1; return (def); } if (*t1 == '\0') @@ -988,6 +1368,36 @@ cheaper(t1, t2, doit, 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; +{ + *instr = ltgetstr(incap, spp); + 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); + if (*outstr == NULL) + /* Don't even have "me"; use a null string. */ + *outstr = ""; +} + +#endif /* MSDOS_COMPILER */ + /* * Below are the functions which perform all the @@ -995,16 +1405,125 @@ cheaper(t1, t2, doit, def) */ +#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() { - if (no_init) - return; - tputs(sc_init, sc_height, putchr); - tputs(sc_s_keypad, sc_height, putchr); +#if !MSDOS_COMPILER + if (!no_init) + tputs(sc_init, sc_height, putchr); + if (!no_keypad) + tputs(sc_s_keypad, sc_height, putchr); +#else +#if MSDOS_COMPILER==WIN32C + if (!no_init) + win32_init_term(); +#endif + initcolor(); + flush(); +#endif init_done = 1; } @@ -1014,12 +1533,24 @@ init() public void deinit() { - if (no_init) - return; if (!init_done) return; - tputs(sc_e_keypad, sc_height, putchr); - tputs(sc_deinit, sc_height, putchr); +#if !MSDOS_COMPILER + if (!no_keypad) + 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 init_done = 0; } @@ -1029,7 +1560,12 @@ deinit() public void home() { +#if !MSDOS_COMPILER tputs(sc_home, 1, putchr); +#else + flush(); + _settextposition(1,1); +#endif } /* @@ -1039,16 +1575,252 @@ home() public void add_line() { +#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 +} +#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 = 0; + + /* 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() { +#if !MSDOS_COMPILER tputs(sc_lower_left, 1, putchr); +#else + flush(); + _settextposition(sc_height, 1); +#endif +} + +/* + * Check if the console size has changed and reset internals + * (in lieu of SIGWINCH for WIN32). + */ + public void +check_winch() +{ +#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 } /* @@ -1058,23 +1830,76 @@ lower_left() goto_line(slinenum) int slinenum; { - char *sc_goto; - - sc_goto = tgoto(sc_move, 0, slinenum); - tputs(sc_goto, 1, putchr); +#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 /* - * Ring the terminal bell. + * 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. }} */ - public void -bell() + static void +create_flash() { - if (quiet == VERY_QUIET) - vbell(); - else - putchr('\7'); +#if MSDOS_COMPILER==MSOFTC + struct videoconfig w; + char *blanks; + int row, col; + + _getvideoconfig(&w); + videopages = w.numvideopages; + if (videopages < 2) + { + so_enter(); + so_exit(); + } else + { + _setactivepage(1); + so_enter(); + 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); + so_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; } +#endif /* MSDOS_COMPILER */ /* * Output the "visual bell", if there is one. @@ -1082,9 +1907,91 @@ bell() public void vbell() { +#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 +} + +/* + * Make a noise. + */ + static void +beep() +{ +#if !MSDOS_COMPILER + putchr(CONTROL('G')); +#else +#if MSDOS_COMPILER==WIN32C + MessageBeep(0); +#else + write(1, "\7", 1); +#endif +#endif +} + +/* + * Ring the terminal bell. + */ + public void +bell() +{ + if (quiet == VERY_QUIET) + vbell(); + else + beep(); } /* @@ -1093,7 +2000,16 @@ vbell() public void clear() { +#if !MSDOS_COMPILER tputs(sc_clear, sc_height, putchr); +#else + flush(); +#if MSDOS_COMPILER==WIN32C + win32_clear(); +#else + _clearscreen(_GCLEARSCREEN); +#endif +#endif } /* @@ -1103,7 +2019,73 @@ clear() public void clear_eol() { +#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 +} + +/* + * Clear the current line. + * Clear the screen if there's off-screen memory below the display. + */ + static void +clear_eol_bot() +{ +#if MSDOS_COMPILER + clear_eol(); +#else + if (below_mem) + tputs(sc_eos_clear, 1, putchr); + else + tputs(sc_eol_clear, 1, putchr); +#endif } /* @@ -1113,11 +2095,38 @@ clear_eol() public void clear_bot() { + /* + * If we're in a non-normal attribute mode, temporarily exit + * the mode while we do the clear. Some terminals fill the + * cleared area with the current attribute. + */ lower_left(); - if (below_mem) - tputs(sc_eos_clear, 1, putchr); - else - tputs(sc_eol_clear, 1, putchr); + switch (attrmode) + { + case AT_STANDOUT: + so_exit(); + clear_eol_bot(); + so_enter(); + break; + case AT_UNDERLINE: + ul_exit(); + clear_eol_bot(); + ul_enter(); + break; + case AT_BOLD: + bo_exit(); + clear_eol_bot(); + bo_enter(); + break; + case AT_BLINK: + bl_exit(); + clear_eol_bot(); + bl_enter(); + break; + default: + clear_eol_bot(); + break; + } } /* @@ -1126,7 +2135,13 @@ clear_bot() public void so_enter() { +#if !MSDOS_COMPILER tputs(sc_s_in, 1, putchr); +#else + flush(); + SETCOLORS(so_fg_color, so_bg_color); +#endif + attrmode = AT_STANDOUT; } /* @@ -1135,7 +2150,13 @@ so_enter() public void so_exit() { +#if !MSDOS_COMPILER tputs(sc_s_out, 1, putchr); +#else + flush(); + SETCOLORS(nm_fg_color, nm_bg_color); +#endif + attrmode = AT_NORMAL; } /* @@ -1145,7 +2166,13 @@ so_exit() public void ul_enter() { +#if !MSDOS_COMPILER tputs(sc_u_in, 1, putchr); +#else + flush(); + SETCOLORS(ul_fg_color, ul_bg_color); +#endif + attrmode = AT_UNDERLINE; } /* @@ -1154,7 +2181,13 @@ ul_enter() public void ul_exit() { +#if !MSDOS_COMPILER tputs(sc_u_out, 1, putchr); +#else + flush(); + SETCOLORS(nm_fg_color, nm_bg_color); +#endif + attrmode = AT_NORMAL; } /* @@ -1163,7 +2196,13 @@ ul_exit() public void bo_enter() { +#if !MSDOS_COMPILER tputs(sc_b_in, 1, putchr); +#else + flush(); + SETCOLORS(bo_fg_color, bo_bg_color); +#endif + attrmode = AT_BOLD; } /* @@ -1172,7 +2211,13 @@ bo_enter() public void bo_exit() { +#if !MSDOS_COMPILER tputs(sc_b_out, 1, putchr); +#else + flush(); + SETCOLORS(nm_fg_color, nm_bg_color); +#endif + attrmode = AT_NORMAL; } /* @@ -1181,7 +2226,13 @@ bo_exit() public void bl_enter() { +#if !MSDOS_COMPILER tputs(sc_bl_in, 1, putchr); +#else + flush(); + SETCOLORS(bl_fg_color, bl_bg_color); +#endif + attrmode = AT_BLINK; } /* @@ -1190,9 +2241,16 @@ bl_enter() public void bl_exit() { +#if !MSDOS_COMPILER tputs(sc_bl_out, 1, putchr); +#else + flush(); + SETCOLORS(nm_fg_color, nm_bg_color); +#endif + attrmode = AT_NORMAL; } +#if 0 /* No longer used */ /* * Erase the character to the left of the cursor * and move the cursor left. @@ -1200,13 +2258,48 @@ bl_exit() public void backspace() { +#if !MSDOS_COMPILER /* - * Try to erase the previous character by overstriking with a space. + * 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 } +#endif /* 0 */ /* * Output a plain backspace, without erasing the previous char. @@ -1214,5 +2307,134 @@ backspace() public void putbs() { +#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 */ } + +#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 diff --git a/usr.bin/less/search.c b/usr.bin/less/search.c index 67ce87efb8d..2756090bde0 100644 --- a/usr.bin/less/search.c +++ b/usr.bin/less/search.c @@ -1,29 +1,11 @@ -/* $OpenBSD: search.c,v 1.4 2003/04/06 23:38:07 deraadt Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -39,6 +21,14 @@ #if HAVE_POSIX_REGCOMP #include <regex.h> +#ifdef REG_EXTENDED +#define REGCOMP_FLAG REG_EXTENDED +#else +#define REGCOMP_FLAG 0 +#endif +#endif +#if HAVE_PCRE +#include <pcre.h> #endif #if HAVE_RE_COMP char *re_comp(); @@ -52,9 +42,8 @@ extern char *__loc1; #if HAVE_V8_REGCOMP #include "regexp.h" #endif -#if NO_REGEX + static int match(); -#endif extern int sigs; extern int how_search; @@ -63,10 +52,16 @@ extern int linenums; extern int sc_height; extern int jump_sline; extern int bs_mode; +extern int ctldisp; +extern int status_col; +extern POSITION start_attnpos; +extern POSITION end_attnpos; #if HILITE_SEARCH extern int hilite_search; extern int screen_trashed; extern int size_linebuf; +extern int squished; +extern int can_goto_line; static int hide_hilite; static POSITION prep_startpos; static POSITION prep_endpos; @@ -77,7 +72,7 @@ struct hilite POSITION hl_startpos; POSITION hl_endpos; }; -static struct hilite hilite_anchor = { NULL }; +static struct hilite hilite_anchor = { NULL, NULL_POSITION, NULL_POSITION }; #define hl_first hl_next #endif @@ -88,6 +83,9 @@ static struct hilite hilite_anchor = { NULL }; #if HAVE_POSIX_REGCOMP static regex_t *regpattern = NULL; #endif +#if HAVE_PCRE +pcre *regpattern = NULL; +#endif #if HAVE_RE_COMP int re_pattern = 0; #endif @@ -97,18 +95,19 @@ static char *cpattern = NULL; #if HAVE_V8_REGCOMP static struct regexp *regpattern = NULL; #endif -#if NO_REGEX -static char *last_pattern = NULL; -#endif static int is_caseless; static int is_ucase_pattern; +static int last_search_type; +static char *last_pattern = NULL; /* * Convert text. Perform one or more of these transformations: */ #define CVT_TO_LC 01 /* Convert upper-case to lower-case */ #define CVT_BS 02 /* Do backspace processing */ +#define CVT_CRLF 04 /* Remove CR after LF */ +#define CVT_ANSI 010 /* Remove ANSI escape sequences */ static void cvt_text(odst, osrc, ops) @@ -116,35 +115,67 @@ cvt_text(odst, osrc, ops) char *osrc; int ops; { - char *dst; - char *src; + register char *dst; + register char *src; - for (src = osrc, dst = odst; *src != '\0'; src++, dst++) + for (src = osrc, dst = odst; *src != '\0'; src++) { - if ((ops & CVT_TO_LC) && isupper(*src)) + if ((ops & CVT_TO_LC) && isupper((unsigned char) *src)) /* Convert uppercase to lowercase. */ - *dst = tolower(*src); + *dst++ = tolower((unsigned char) *src); else if ((ops & CVT_BS) && *src == '\b' && dst > odst) /* Delete BS and preceding char. */ - dst -= 2; - else + dst--; + else if ((ops & CVT_ANSI) && *src == ESC) + { + /* Skip to end of ANSI escape sequence. */ + while (src[1] != '\0') + if (is_ansi_end(*++src)) + break; + } else /* Just copy. */ - *dst = *src; + *dst++ = *src; } + if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') + dst--; *dst = '\0'; } /* + * Determine which conversions to perform. + */ + static int +get_cvt_ops() +{ + int ops = 0; + 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) + { + ops |= CVT_CRLF; + } + if (ctldisp == OPT_ONPLUS) + ops |= CVT_ANSI; + return (ops); +} + +/* * Are there any uppercase letters in this string? */ static int is_ucase(s) char *s; { - char *p; + register char *p; for (p = s; *p != '\0'; p++) - if (isupper(*p)) + if (isupper((unsigned char) *p)) return (1); return (0); } @@ -155,9 +186,14 @@ is_ucase(s) static int prev_pattern() { + if (last_search_type & SRCH_NO_REGEX) + return (last_pattern != NULL); #if HAVE_POSIX_REGCOMP return (regpattern != NULL); #endif +#if HAVE_PCRE + return (regpattern != NULL); +#endif #if HAVE_RE_COMP return (re_pattern != 0); #endif @@ -186,7 +222,9 @@ repaint_hilite(on) POSITION pos; POSITION epos; int save_hide_hilite; - extern int can_goto_line; + + if (squished) + repaint(); save_hide_hilite = hide_hilite; if (!on) @@ -222,6 +260,48 @@ repaint_hilite(on) } hide_hilite = save_hide_hilite; } + +/* + * Clear the attn hilite. + */ + public void +clear_attn() +{ + int slinenum; + POSITION old_start_attnpos; + POSITION old_end_attnpos; + POSITION pos; + POSITION epos; + + if (start_attnpos == NULL_POSITION) + return; + old_start_attnpos = start_attnpos; + old_end_attnpos = end_attnpos; + start_attnpos = end_attnpos = NULL_POSITION; + + if (!can_goto_line) + { + repaint(); + return; + } + if (squished) + repaint(); + + for (slinenum = TOP; slinenum < TOP + sc_height-1; slinenum++) + { + pos = position(slinenum); + if (pos == NULL_POSITION) + continue; + epos = position(slinenum+1); + if (pos < old_end_attnpos && + (epos == NULL_POSITION || epos > old_start_attnpos)) + { + (void) forw_line(pos); + goto_line(slinenum); + put_line(); + } + } +} #endif /* @@ -245,59 +325,80 @@ undo_search() * Compile a search pattern, for future use by match_pattern. */ static int -compile_pattern(pattern) +compile_pattern(pattern, search_type) char *pattern; + int search_type; { -#if HAVE_POSIX_REGCOMP - regex_t *s = (regex_t *) ecalloc(1, sizeof(regex_t)); - if (regcomp(s, pattern, 0)) + if ((search_type & SRCH_NO_REGEX) == 0) { - free(s); - error("Invalid pattern", NULL_PARG); - return (-1); - } - if (regpattern != NULL) - regfree(regpattern); - regpattern = s; +#if HAVE_POSIX_REGCOMP + regex_t *s = (regex_t *) ecalloc(1, sizeof(regex_t)); + if (regcomp(s, pattern, REGCOMP_FLAG)) + { + free(s); + error("Invalid pattern", NULL_PARG); + return (-1); + } + if (regpattern != NULL) + regfree(regpattern); + regpattern = s; +#endif +#if HAVE_PCRE + pcre *comp; + const 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); + } + regpattern = comp; #endif #if HAVE_RE_COMP - PARG parg; - if ((parg.p_string = re_comp(pattern)) != NULL) - { - error("%s", &parg); - return (-1); - } - re_pattern = 1; + PARG parg; + if ((parg.p_string = re_comp(pattern)) != NULL) + { + error("%s", &parg); + return (-1); + } + re_pattern = 1; #endif #if HAVE_REGCMP - char *s; - if ((s = regcmp(pattern, 0)) == NULL) - { - error("Invalid pattern", NULL_PARG); - return (-1); - } - if (cpattern != NULL) - free(cpattern); - cpattern = s; + char *s; + if ((s = regcmp(pattern, 0)) == NULL) + { + error("Invalid pattern", NULL_PARG); + return (-1); + } + if (cpattern != NULL) + free(cpattern); + cpattern = s; #endif #if HAVE_V8_REGCOMP - struct regexp *s; - if ((s = regcomp(pattern)) == NULL) - { - /* - * regcomp has already printed error message via regerror(). - */ - return (-1); - } - if (regpattern != NULL) - free(regpattern); - regpattern = s; -#endif -#if NO_REGEX - static char lpbuf[100]; - strlcpy(lpbuf, pattern, sizeof lbuf); - last_pattern = lpbuf; + struct regexp *s; + if ((s = regcomp(pattern)) == NULL) + { + /* + * regcomp has already printed an error message + * via regerror(). + */ + return (-1); + } + if (regpattern != NULL) + free(regpattern); + regpattern = s; #endif + } + + if (last_pattern != NULL) + free(last_pattern); + last_pattern = save(pattern); + + last_search_type = search_type; return (0); } @@ -312,6 +413,11 @@ uncompile_pattern() regfree(regpattern); regpattern = NULL; #endif +#if HAVE_PCRE + if (regpattern != NULL) + pcre_free(regpattern); + regpattern = NULL; +#endif #if HAVE_RE_COMP re_pattern = 0; #endif @@ -325,9 +431,7 @@ uncompile_pattern() free(regpattern); regpattern = NULL; #endif -#if NO_REGEX last_pattern = NULL; -#endif } /* @@ -335,19 +439,44 @@ uncompile_pattern() * Set sp and ep to the start and end of the matched string. */ static int -match_pattern(line, sp, ep) +match_pattern(line, sp, ep, notbol) char *line; char **sp; char **ep; + int notbol; { int matched; + + if (last_search_type & SRCH_NO_REGEX) + return (match(last_pattern, line, sp, ep)); + #if HAVE_POSIX_REGCOMP - regmatch_t rm; - matched = !regexec(regpattern, line, 1, &rm, 0); - if (!matched) - return (0); - *sp = line + rm.rm_so; - *ep = line + rm.rm_eo; + { + regmatch_t rm; + int flags = (notbol) ? REG_NOTBOL : 0; + matched = !regexec(regpattern, line, 1, &rm, flags); + if (!matched) + return (0); +#ifndef __WATCOMC__ + *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(regpattern, NULL, line, strlen(line), + 0, flags, ovector, 3) >= 0; + if (!matched) + return (0); + *sp = line + ovector[0]; + *ep = line + ovector[1]; + } #endif #if HAVE_RE_COMP matched = (re_exec(line) == 1); @@ -364,7 +493,11 @@ match_pattern(line, sp, ep) *sp = __loc1; #endif #if HAVE_V8_REGCOMP +#if HAVE_REGEXEC2 + matched = regexec2(regpattern, line, notbol); +#else matched = regexec(regpattern, line); +#endif if (!matched) return (0); *sp = regpattern->startp[0]; @@ -407,6 +540,15 @@ is_hilited(pos, epos, nohide) { struct hilite *hl; + if (!status_col && + start_attnpos != NULL_POSITION && + pos < end_attnpos && + (epos == NULL_POSITION || epos > start_attnpos)) + /* + * The attn line overlaps this range. + */ + return (1); + if (hilite_search == 0) /* * Not doing highlighting. @@ -475,9 +617,10 @@ add_hilite(anchor, hl) * Adjust hl_startpos & hl_endpos to account for backspace processing. */ static void -adj_hilite(anchor, linepos) +adj_hilite(anchor, linepos, cvt_ops) struct hilite *anchor; POSITION linepos; + int cvt_ops; { char *line; struct hilite *hl; @@ -519,18 +662,39 @@ adj_hilite(anchor, linepos) } if (*line == '\0') break; + if (cvt_ops & CVT_ANSI) + { + while (line[0] == ESC) + { + /* + * Found an ESC. The file position moves + * forward past the entire ANSI escape sequence. + */ + line++; + npos++; + while (*line != '\0') + { + npos++; + if (is_ansi_end(*line++)) + break; + } + } + } opos++; npos++; line++; - while (line[0] == '\b' && line[1] != '\0') + if (cvt_ops & CVT_BS) { - /* - * Found a backspace. The file position moves - * forward by 2 relative to the processed line - * which was searched in hilite_line. - */ - npos += 2; - line += 2; + while (line[0] == '\b' && line[1] != '\0') + { + /* + * Found a backspace. The file position moves + * forward by 2 relative to the processed line + * which was searched in hilite_line. + */ + npos += 2; + line += 2; + } } } } @@ -541,11 +705,12 @@ adj_hilite(anchor, linepos) * sp,ep delimit the first match already found. */ static void -hilite_line(linepos, line, sp, ep) +hilite_line(linepos, line, sp, ep, cvt_ops) POSITION linepos; char *line; char *sp; char *ep; + int cvt_ops; { char *searchp; struct hilite *hl; @@ -559,7 +724,9 @@ hilite_line(linepos, line, sp, ep) * look for further matches and mark them. * {{ This technique, of calling match_pattern on subsequent * substrings of the line, may mark more than is correct - * if, for example, the pattern starts with "^". }} + * if the pattern starts with "^". This bug is fixed + * for those regex functions that accept a notbol parameter + * (currently POSIX and V8-with-regexec2). }} */ searchp = line; /* @@ -590,17 +757,15 @@ hilite_line(linepos, line, sp, ep) searchp++; else /* end of line */ break; - } while (match_pattern(searchp, &sp, &ep)); + } while (match_pattern(searchp, &sp, &ep, 1)); + + /* + * If there were backspaces in the original line, they + * were removed, and hl_startpos/hl_endpos are not correct. + * {{ This is very ugly. }} + */ + adj_hilite(&hilites, linepos, cvt_ops); - if (bs_mode == BS_SPECIAL) - { - /* - * If there were backspaces in the original line, they - * were removed, and hl_startpos/hl_endpos are not correct. - * {{ This is very ugly. }} - */ - adj_hilite(&hilites, linepos); - } /* * Now put the hilites into the real list. */ @@ -645,7 +810,7 @@ hilite_screen() get_scrpos(&scrpos); if (scrpos.pos == NULL_POSITION) return; - prep_hilite(scrpos.pos, position(BOTTOM_PLUS_ONE)); + prep_hilite(scrpos.pos, position(BOTTOM_PLUS_ONE), -1); repaint_hilite(1); } @@ -722,7 +887,23 @@ search_pos(search_type) linenum = adjsline(jump_sline); pos = position(linenum); if (search_type & SRCH_FORW) + { pos = forw_raw_line(pos, (char **)NULL); + while (pos == NULL_POSITION) + { + if (++linenum >= sc_height) + break; + pos = position(linenum); + } + } else + { + while (pos == NULL_POSITION) + { + if (--linenum < 0) + break; + pos = position(linenum); + } + } } return (pos); } @@ -731,18 +912,20 @@ search_pos(search_type) * Search a subset of the file, specified by start/end position. */ static int -search_range(pos, endpos, search_type, n, plinepos, pendpos) +search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) POSITION pos; POSITION endpos; int search_type; - int n; + int matches; + int maxlines; POSITION *plinepos; POSITION *pendpos; { char *line; - int linenum; + LINENUM linenum; char *sp, *ep; int line_match; + int cvt_ops; POSITION linepos, oldpos; linenum = find_linenum(pos); @@ -762,15 +945,17 @@ search_range(pos, endpos, search_type, n, plinepos, pendpos) return (-1); } - if (endpos != NULL_POSITION && pos >= endpos) + if ((endpos != NULL_POSITION && pos >= endpos) || maxlines == 0) { /* * Reached end position without a match. */ if (pendpos != NULL) *pendpos = pos; - return (n); + return (matches); } + if (maxlines > 0) + maxlines--; if (search_type & SRCH_FORW) { @@ -800,8 +985,8 @@ search_range(pos, endpos, search_type, n, plinepos, pendpos) * Reached EOF/BOF without a match. */ if (pendpos != NULL) - *pendpos = NULL_POSITION; - return (n); + *pendpos = oldpos; + return (matches); } /* @@ -813,33 +998,24 @@ search_range(pos, endpos, search_type, n, plinepos, pendpos) * we're "far" from the last place we remembered it. */ if (linenums && abs((int)(pos - oldpos)) > 1024) - { add_lnum(linenum, pos); - oldpos = pos; - } + oldpos = pos; /* * If it's a caseless search, convert the line to lowercase. * If we're doing backspace processing, delete backspaces. */ - if (is_caseless || bs_mode == BS_SPECIAL) - { - int ops = 0; - if (is_caseless) - ops |= CVT_TO_LC; - if (bs_mode == BS_SPECIAL) - ops |= CVT_BS; - cvt_text(line, line, ops); - } + cvt_ops = get_cvt_ops(); + cvt_text(line, line, cvt_ops); /* * 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. */ - line_match = match_pattern(line, &sp, &ep); - line_match = (!(search_type & SRCH_NOMATCH) && line_match) || - ((search_type & SRCH_NOMATCH) && !line_match); + line_match = match_pattern(line, &sp, &ep, 0); + line_match = (!(search_type & SRCH_NO_MATCH) && line_match) || + ((search_type & SRCH_NO_MATCH) && !line_match); if (!line_match) continue; /* @@ -854,9 +1030,9 @@ search_range(pos, endpos, search_type, n, plinepos, pendpos) * hilite list and keep searching. */ if (line_match) - hilite_line(linepos, line, sp, ep); + hilite_line(linepos, line, sp, ep, cvt_ops); #endif - } else if (--n <= 0) + } else if (--matches <= 0) { /* * Found the one match we're looking for. @@ -871,7 +1047,7 @@ search_range(pos, endpos, search_type, n, plinepos, pendpos) */ clr_hilite(); if (line_match) - hilite_line(linepos, line, sp, ep); + hilite_line(linepos, line, sp, ep, cvt_ops); } #endif if (plinepos != NULL) @@ -909,6 +1085,12 @@ search(search_type, pattern, n) error("No previous regular expression", NULL_PARG); return (-1); } + if ((search_type & SRCH_NO_REGEX) != + (last_search_type & SRCH_NO_REGEX)) + { + error("Please re-enter search pattern", NULL_PARG); + return -1; + } #if HILITE_SEARCH if (hilite_search == OPT_ON) { @@ -937,7 +1119,7 @@ search(search_type, pattern, n) ucase = is_ucase(pattern); if (caseless == OPT_ONPLUS) cvt_text(pattern, pattern, CVT_TO_LC); - if (compile_pattern(pattern) < 0) + if (compile_pattern(pattern, search_type) < 0) return (-1); /* * Ignore case if -I is set OR @@ -981,11 +1163,12 @@ search(search_type, pattern, n) */ if (search_type & SRCH_PAST_EOF) return (n); + /* repaint(); -- why was this here? */ error("Nothing to search", NULL_PARG); return (-1); } - n = search_range(pos, NULL_POSITION, search_type, n, + n = search_range(pos, NULL_POSITION, search_type, n, -1, &pos, (POSITION*)NULL); if (n != 0) { @@ -1002,10 +1185,13 @@ search(search_type, pattern, n) return (n); } - /* - * Go to the matching line. - */ - jump_loc(pos, jump_sline); + if (!(search_type & SRCH_NO_MOVE)) + { + /* + * Go to the matching line. + */ + jump_loc(pos, jump_sline); + } #if HILITE_SEARCH if (hilite_search == OPT_ON) @@ -1017,24 +1203,30 @@ search(search_type, pattern, n) 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 + * 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. * prep_hilite asks that the range (spos,epos) be covered by the prep region. */ public void -prep_hilite(spos, epos) +prep_hilite(spos, epos, maxlines) POSITION spos; POSITION epos; + int maxlines; { POSITION nprep_startpos = prep_startpos; POSITION nprep_endpos = prep_endpos; + POSITION new_epos; + POSITION max_epos; + int result; + int i; /* * Search beyond where we're asked to search, so the prep region covers * more than we need. Do one big search instead of a bunch of small ones. @@ -1043,6 +1235,20 @@ prep_hilite(spos, epos) if (!prev_pattern()) return; + + /* + * 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 + { + max_epos = spos; + for (i = 0; i < maxlines; i++) + max_epos = forw_raw_line(max_epos, (char **)NULL); + } + /* * Find two ranges: * The range that we need to search (spos,epos); and the range that @@ -1051,7 +1257,7 @@ prep_hilite(spos, epos) if (prep_startpos == NULL_POSITION || (epos != NULL_POSITION && epos < prep_startpos) || - (prep_endpos != NULL_POSITION && spos > prep_endpos)) + spos > prep_endpos) { /* * New range is not contiguous with old prep region. @@ -1061,7 +1267,6 @@ prep_hilite(spos, epos) if (epos != NULL_POSITION) epos += SEARCH_MORE; nprep_startpos = spos; - nprep_endpos = epos; } else { /* @@ -1072,7 +1277,7 @@ prep_hilite(spos, epos) /* * New range goes to end of file. */ - nprep_endpos = NULL_POSITION; + ; } else if (epos > prep_endpos) { /* @@ -1080,7 +1285,6 @@ prep_hilite(spos, epos) * Extend prep region to end at end of new range. */ epos += SEARCH_MORE; - nprep_endpos = epos; } else /* (epos <= prep_endpos) */ { /* @@ -1106,36 +1310,35 @@ prep_hilite(spos, epos) { /* * New range starts within or after old prep region. - * Trim search to start near end of old prep region - * (actually, one linebuf before end of old range). + * Trim search to start at end of old prep region. */ - if (prep_endpos == NULL_POSITION) - return; - else if (prep_endpos < size_linebuf) - spos = 0; - else - spos = prep_endpos - size_linebuf; + spos = prep_endpos; } } + if (epos != NULL_POSITION && max_epos != NULL_POSITION && + epos > max_epos) + /* + * Don't go past the max position we're allowed. + */ + epos = max_epos; + if (epos == NULL_POSITION || epos > spos) { - if (search_range(spos, epos, SRCH_FORW|SRCH_FIND_ALL, 0, - (POSITION*)NULL, &epos) >= 0) - { - if (epos == NULL_POSITION || epos > nprep_endpos) - nprep_endpos = epos; - } + result = search_range(spos, epos, SRCH_FORW|SRCH_FIND_ALL, 0, + maxlines, (POSITION*)NULL, &new_epos); + if (result < 0) + return; + if (prep_endpos == NULL_POSITION || new_epos > prep_endpos) + nprep_endpos = new_epos; } prep_startpos = nprep_startpos; prep_endpos = nprep_endpos; } #endif -#if NO_REGEX /* - * We have no pattern matching function from the library. - * We use this function to do simple pattern matching. + * Simple pattern matching function. * It supports no metacharacters like *, etc. */ static int @@ -1143,7 +1346,7 @@ match(pattern, buf, pfound, pend) char *pattern, *buf; char **pfound, **pend; { - char *pp, *lp; + register char *pp, *lp; for ( ; *buf != '\0'; buf++) { @@ -1161,7 +1364,6 @@ match(pattern, buf, pfound, pend) } return (0); } -#endif #if HAVE_V8_REGCOMP /* @@ -1179,21 +1381,3 @@ regerror(s) } #endif -#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 - diff --git a/usr.bin/less/signal.c b/usr.bin/less/signal.c index a7728f6b7ab..a641d99ee9d 100644 --- a/usr.bin/less/signal.c +++ b/usr.bin/less/signal.c @@ -1,29 +1,11 @@ -/* $OpenBSD: signal.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -61,10 +43,19 @@ u_interrupt(type) int type; { #if OS2 - SIGNAL(SIGINT, SIG_ACK); + LSIGNAL(SIGINT, SIG_ACK); #endif - SIGNAL(SIGINT, u_interrupt); + LSIGNAL(SIGINT, u_interrupt); 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 if (reading) intread(); } @@ -78,7 +69,7 @@ u_interrupt(type) stop(type) int type; { - SIGNAL(SIGTSTP, stop); + LSIGNAL(SIGTSTP, stop); sigs |= S_STOP; if (reading) intread(); @@ -94,7 +85,7 @@ stop(type) winch(type) int type; { - SIGNAL(SIGWINCH, winch); + LSIGNAL(SIGWINCH, winch); sigs |= S_WINCH; if (reading) intread(); @@ -109,7 +100,7 @@ winch(type) winch(type) int type; { - SIGNAL(SIGWIND, winch); + LSIGNAL(SIGWIND, winch); sigs |= S_WINCH; if (reading) intread(); @@ -117,6 +108,29 @@ winch(type) #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. */ @@ -129,15 +143,21 @@ init_signals(on) /* * Set signal handlers. */ - (void) SIGNAL(SIGINT, u_interrupt); + (void) LSIGNAL(SIGINT, u_interrupt); +#if MSDOS_COMPILER==WIN32C + SetConsoleCtrlHandler(wbreak_handler, TRUE); +#endif #ifdef SIGTSTP - (void) SIGNAL(SIGTSTP, stop); + (void) LSIGNAL(SIGTSTP, stop); #endif #ifdef SIGWINCH - (void) SIGNAL(SIGWINCH, winch); + (void) LSIGNAL(SIGWINCH, winch); #else #ifdef SIGWIND - (void) SIGNAL(SIGWIND, winch); + (void) LSIGNAL(SIGWIND, winch); +#endif +#ifdef SIGQUIT + (void) LSIGNAL(SIGQUIT, SIG_IGN); #endif #endif } else @@ -145,15 +165,21 @@ init_signals(on) /* * Restore signals to defaults. */ - (void) SIGNAL(SIGINT, SIG_DFL); + (void) LSIGNAL(SIGINT, SIG_DFL); +#if MSDOS_COMPILER==WIN32C + SetConsoleCtrlHandler(wbreak_handler, FALSE); +#endif #ifdef SIGTSTP - (void) SIGNAL(SIGTSTP, SIG_DFL); + (void) LSIGNAL(SIGTSTP, SIG_DFL); #endif #ifdef SIGWINCH - (void) SIGNAL(SIGWINCH, SIG_IGN); + (void) LSIGNAL(SIGWINCH, SIG_IGN); #endif #ifdef SIGWIND - (void) SIGNAL(SIGWIND, SIG_IGN); + (void) LSIGNAL(SIGWIND, SIG_IGN); +#endif +#ifdef SIGQUIT + (void) LSIGNAL(SIGQUIT, SIG_DFL); #endif } } @@ -165,7 +191,7 @@ init_signals(on) public void psignals() { - int tsignals; + register int tsignals; if ((tsignals = sigs) == 0) return; @@ -178,16 +204,16 @@ psignals() * Clean up the terminal. */ #ifdef SIGTTOU - SIGNAL(SIGTTOU, SIG_IGN); + LSIGNAL(SIGTTOU, SIG_IGN); #endif clear_bot(); deinit(); flush(); raw_mode(0); #ifdef SIGTTOU - SIGNAL(SIGTTOU, SIG_DFL); + LSIGNAL(SIGTTOU, SIG_DFL); #endif - SIGNAL(SIGTSTP, SIG_DFL); + LSIGNAL(SIGTSTP, SIG_DFL); kill(getpid(), SIGTSTP); /* * ... Bye bye. ... @@ -195,7 +221,7 @@ psignals() * Reset the terminal and arrange to repaint the * screen when we get back to the main command loop. */ - SIGNAL(SIGTSTP, stop); + LSIGNAL(SIGTSTP, stop); raw_mode(1); init(); screen_trashed = 1; diff --git a/usr.bin/less/tags.c b/usr.bin/less/tags.c index f7f05bdc1d1..96e0a6c64f1 100644 --- a/usr.bin/less/tags.c +++ b/usr.bin/less/tags.c @@ -1,29 +1,11 @@ -/* $OpenBSD: tags.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -33,41 +15,275 @@ #if TAGS -public char *tagfile; public char *tags = "tags"; -static char *tagpattern; -static int taglinenum; +static int total; +static int curseq; extern int linenums; extern int sigs; -extern int jump_sline; + +enum tag_result { + TAG_FOUND, + TAG_NOFILE, + TAG_NOTAG, + TAG_NOTYPE, + TAG_INTR +}; + +/* + * Tag type + */ +enum { + T_CTAGS, /* 'tags': standard and extended format (ctags) */ + T_CTAGS_X, /* stdin: cross reference format (ctags) */ + T_GTAGS, /* 'GTAGS': function defenition (global) */ + T_GRTAGS, /* 'GRTAGS': function reference (global) */ + T_GSYMS, /* 'GSYMS': other symbols (global) */ + T_GPATH /* 'GPATH': path name (global) */ +}; + +static enum tag_result findctag(); +static enum tag_result findgtag(); +static char *nextgtag(); +static char *prevgtag(); +static POSITION ctagsearch(); +static POSITION gtagsearch(); +static int getentry(); + +/* + * The list of tags generated by the last findgtag() call. + * + * Use either pattern or line number. + * findgtag() always uses line number, so pattern is always NULL. + * findctag() usually either pattern (in which case line number is 0), + * or line number (in which case pattern is NULL). + */ +struct taglist { + struct tag *tl_first; + struct tag *tl_last; +}; +#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 '$' */ +}; +static struct tag *curtag; + +#define TAG_INS(tp) \ + (tp)->next = taglist.tl_first; \ + (tp)->prev = TAG_END; \ + taglist.tl_first->prev = (tp); \ + taglist.tl_first = (tp); + +#define TAG_RM(tp) \ + (tp)->next->prev = (tp)->prev; \ + (tp)->prev->next = (tp)->next; + +/* + * Delete tag structures. + */ + public void +cleantags() +{ + register 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) + { + TAG_RM(tp); + free(tp); + } + curtag = NULL; + total = curseq = 0; +} /* + * Create a new tag entry. + */ + static struct tag * +maketagent(name, file, linenum, pattern, endline) + char *name; + char *file; + LINENUM linenum; + char *pattern; + int endline; +{ + register struct tag *tp; + + tp = (struct tag *) ecalloc(sizeof(struct tag), 1); + tp->tag_file = save(file); + tp->tag_linenum = linenum; + tp->tag_endline = endline; + if (pattern == NULL) + tp->tag_pattern = NULL; + else + tp->tag_pattern = save(pattern); + return (tp); +} + +/* + * Get tag mode. + */ + public int +gettagtype() +{ + int f; + + if (strcmp(tags, "GTAGS") == 0) + return T_GTAGS; + if (strcmp(tags, "GRTAGS") == 0) + return T_GRTAGS; + if (strcmp(tags, "GSYMS") == 0) + return T_GSYMS; + if (strcmp(tags, "GPATH") == 0) + return T_GPATH; + if (strcmp(tags, "-") == 0) + return T_CTAGS_X; + f = open(tags, OPEN_READ); + if (f >= 0) + { + close(f); + return T_CTAGS; + } + return T_GTAGS; +} + +/* + * Find tags in tag file. * Find a tag in the "tags" file. - * Sets "tagfile" to the name of the file containing the tag, + * Sets "tag_file" to the name of the file containing the tag, * and "tagpattern" to the search pattern which should be used * to find the tag. */ public void findtag(tag) - char *tag; + register char *tag; { - char *p; - char *q; - FILE *f; - int taglen; - int search_char; - int err; - static char tline[200]; + int type = gettagtype(); + enum tag_result result; - if ((f = fopen(tags, "r")) == NULL) + if (type == T_CTAGS) + result = findctag(tag); + else + result = findgtag(tag, type); + switch (result) { + case TAG_FOUND: + case TAG_INTR: + break; + case TAG_NOFILE: error("No tags file", NULL_PARG); - tagfile = NULL; - return; + break; + case TAG_NOTAG: + error("No such tag in tags file", NULL_PARG); + break; + case TAG_NOTYPE: + error("unknown tag type", NULL_PARG); + break; } +} + +/* + * Search for a tag. + */ + public POSITION +tagsearch() +{ + if (curtag == NULL) + return (NULL_POSITION); /* No gtags loaded! */ + if (curtag->tag_linenum != 0) + return gtagsearch(); + else + return ctagsearch(); +} + +/* + * Go to the next tag. + */ + public char * +nexttag(n) + int n; +{ + char *tagfile = (char *) NULL; + + while (n-- > 0) + tagfile = nextgtag(); + return tagfile; +} + +/* + * Go to the previous tag. + */ + public char * +prevtag(n) + int n; +{ + char *tagfile = (char *) NULL; + + while (n-- > 0) + tagfile = prevgtag(); + return tagfile; +} + +/* + * Return the total number of tags. + */ + public int +ntags() +{ + return total; +} + +/* + * Return the sequence number of current tag. + */ + public int +curr_tag() +{ + return curseq; +} + +/***************************************************************************** + * ctags + */ + +/* + * Find tags in the "tags" file. + * Sets curtag to the first tag entry. + */ + static enum tag_result +findctag(tag) + register char *tag; +{ + char *p; + register FILE *f; + register int taglen; + LINENUM taglinenum; + char *tagfile; + char *tagpattern; + int tagendline; + int search_char; + int err; + char tline[TAGLINE_SIZE]; + struct tag *tp; + + p = shell_unquote(tags); + f = fopen(p, "r"); + free(p); + if (f == NULL) + return TAG_NOFILE; + cleantags(); + total = 0; taglen = strlen(tag); /* @@ -75,6 +291,9 @@ findtag(tag) */ while (fgets(tline, sizeof(tline), f) != NULL) { + if (tline[0] == '!') + /* Skip header of extended format. */ + continue; if (strncmp(tag, tline, taglen) != 0 || !WHITESP(tline[taglen])) continue; @@ -86,8 +305,7 @@ findtag(tag) * or a search pattern surrounded by a pair of delimiters. * Parse the line and extract these parts. */ - tagfile = tagpattern = NULL; - taglinenum = 0; + tagpattern = NULL; /* * Skip over the whitespace after the tag name. @@ -113,6 +331,7 @@ findtag(tag) /* * First see if it is a line number. */ + tagendline = 0; taglinenum = getnum(&p, 0, &err); if (err) { @@ -126,24 +345,39 @@ findtag(tag) search_char = *p++; if (*p == '^') p++; - tagpattern = q = p; + tagpattern = p; while (*p != search_char && *p != '\0') { if (*p == '\\') p++; - *q++ = *p++; + p++; } - if (q[-1] == '$') - q--; - *q = '\0'; + tagendline = (p[-1] == '$'); + if (tagendline) + p--; + *p = '\0'; } - - fclose(f); - return; + tp = maketagent(tag, tagfile, taglinenum, tagpattern, tagendline); + TAG_INS(tp); + total++; } fclose(f); - error("No such tag in tags file", NULL_PARG); - tagfile = NULL; + if (total == 0) + return TAG_NOTAG; + curtag = taglist.tl_first; + curseq = 1; + return TAG_FOUND; +} + +/* + * Edit current tagged file. + */ + public int +edit_tagfile() +{ + if (curtag == NULL) + return (1); + return (edit(curtag->tag_file)); } /* @@ -155,20 +389,14 @@ findtag(tag) * regcmp vs. re_comp) behave differently in the presence of * parentheses (which are almost always found in a tag). */ - public POSITION -tagsearch() + static POSITION +ctagsearch() { POSITION pos, linepos; - int linenum; + LINENUM linenum; + int len; char *line; - /* - * If we have the line number of the tag instead of the pattern, - * just use find_pos. - */ - if (taglinenum) - return (find_pos(taglinenum)); - pos = ch_zero(); linenum = find_linenum(pos); @@ -211,12 +439,319 @@ tagsearch() * Test the line to see if we have a match. * Use strncmp because the pattern may be * truncated (in the tags file) if it is too long. + * If tagendline is set, make sure we match all + * the way to end of line (no extra chars after the match). */ - if (strncmp(tagpattern, line, strlen(tagpattern)) == 0) + len = strlen(curtag->tag_pattern); + if (strncmp(curtag->tag_pattern, line, len) == 0 && + (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r')) + { + curtag->tag_linenum = find_linenum(linepos); break; + } } return (linepos); } +/******************************************************************************* + * gtags + */ + +/* + * Find tags in the GLOBAL's tag file. + * The findgtag() will try and load information about the requested tag. + * It does this by calling "global -x tag" and storing the parsed output + * 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 */ +{ + char buf[256]; + FILE *fp; + struct tag *tp; + + if (type != T_CTAGS_X && tag == NULL) + return TAG_NOFILE; + + cleantags(); + total = 0; + + /* + * 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) + { + fp = stdin; + /* Set tag default because we cannot read stdin again. */ + tags = "tags"; + } else + { +#if !HAVE_POPEN + return TAG_NOFILE; +#else + char command[512]; + char *flag; + char *qtag; + char *cmd = lgetenv("LESSGLOBALTAGS"); + + if (cmd == NULL || *cmd == '\0') + return TAG_NOFILE; + /* Get suitable flag value for global(1). */ + switch (type) + { + case T_GTAGS: + flag = "" ; + break; + case T_GRTAGS: + flag = "r"; + break; + case T_GSYMS: + flag = "s"; + break; + case T_GPATH: + flag = "P"; + break; + default: + return TAG_NOTYPE; + } + + /* Get our data from global(1). */ + qtag = shell_quote(tag); + if (qtag == NULL) + qtag = tag; + snprintf(command, sizeof(command), "%s -x%s %s", cmd, + flag, qtag); + if (qtag != tag) + free(qtag); + fp = popen(command, "r"); +#endif + } + if (fp != NULL) + { + while (fgets(buf, sizeof(buf), fp)) + { + char *name, *file, *line; + + if (sigs) + { +#if HAVE_POPEN + if (fp != stdin) + pclose(fp); +#endif + return TAG_INTR; + } + if (buf[strlen(buf) - 1] == '\n') + buf[strlen(buf) - 1] = 0; + else + { + int c; + do { + c = fgetc(fp); + } while (c != '\n' && c != EOF); + } + + if (getentry(buf, &name, &file, &line)) + { + /* + * Couldn't parse this line for some reason. + * We'll just pretend it never happened. + */ + break; + } + + /* Make new entry and add to list. */ + tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0); + TAG_INS(tp); + total++; + } + if (fp != stdin) + { + if (pclose(fp)) + { + curtag = NULL; + total = curseq = 0; + return TAG_NOFILE; + } + } + } + + /* Check to see if we found anything. */ + tp = taglist.tl_first; + if (tp == TAG_END) + return TAG_NOTAG; + curtag = tp; + curseq = 1; + return TAG_FOUND; +} + +static int circular = 0; /* 1: circular tag structure */ + +/* + * Return the filename required for the next gtag in the queue that was setup + * by findgtag(). The next call to gtagsearch() will try to position at the + * appropriate tag. + */ + static char * +nextgtag() +{ + struct tag *tp; + + if (curtag == NULL) + /* No tag loaded */ + return NULL; + + tp = curtag->next; + if (tp == TAG_END) + { + if (!circular) + return NULL; + /* Wrapped around to the head of the queue */ + curtag = taglist.tl_first; + curseq = 1; + } else + { + curtag = tp; + curseq++; + } + return (curtag->tag_file); +} + +/* + * Return the filename required for the previous gtag in the queue that was + * setup by findgtat(). The next call to gtagsearch() will try to position + * at the appropriate tag. + */ + static char * +prevgtag() +{ + struct tag *tp; + + if (curtag == NULL) + /* No tag loaded */ + return NULL; + + tp = curtag->prev; + if (tp == TAG_END) + { + if (!circular) + return NULL; + /* Wrapped around to the tail of the queue */ + curtag = taglist.tl_last; + curseq = total; + } else + { + curtag = tp; + curseq--; + } + return (curtag->tag_file); +} + +/* + * Position the current file at at what is hopefully the tag that was chosen + * using either findtag() or one of nextgtag() and prevgtag(). Returns -1 + * if it was unable to position at the tag, 0 if succesful. + */ + static POSITION +gtagsearch() +{ + if (curtag == NULL) + return (NULL_POSITION); /* No gtags loaded! */ + return (find_pos(curtag->tag_linenum)); +} + +/* + * The getentry() parses both standard and extended ctags -x format. + * + * [standard format] + * <tag> <lineno> <file> <image> + * +------------------------------------------------ + * |main 30 main.c main(argc, argv) + * |func 21 subr.c func(arg) + * + * The following commands write this format. + * o Traditinal Ctags with -x option + * o Global with -x option + * See <http://www.gnu.org/software/global/global.html> + * + * [extended format] + * <tag> <type> <lineno> <file> <image> + * +---------------------------------------------------------- + * |main function 30 main.c main(argc, argv) + * |func function 21 subr.c func(arg) + * + * The following commands write this format. + * o Exuberant Ctags with -x option + * See <http://ctags.sourceforge.net> + * + * Returns 0 on success, -1 on error. + * The tag, file, and line will each be NUL-terminated pointers + * into buf. + */ + +#ifndef isspace +#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f') +#endif +#ifndef isdigit +#define isdigit(c) ((c) >= '0' && (c <= '9')) +#endif + + 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 */ +{ + char *p = buf; + + for (*tag = p; *p && !isspace(*p); p++) /* tag name */ + ; + if (*p == 0) + return (-1); + *p++ = 0; + for ( ; *p && isspace(*p); p++) /* (skip blanks) */ + ; + if (*p == 0) + return (-1); + /* + * If the second part begin with other than digit, + * it is assumed tag type. Skip it. + */ + if (!isdigit(*p)) + { + for ( ; *p && !isspace(*p); p++) /* (skip tag type) */ + ; + for (; *p && isspace(*p); p++) /* (skip blanks) */ + ; + } + if (!isdigit(*p)) + return (-1); + *line = p; /* line number */ + for (*line = p; *p && !isspace(*p); p++) + ; + if (*p == 0) + return (-1); + *p++ = 0; + for ( ; *p && isspace(*p); p++) /* (skip blanks) */ + ; + if (*p == 0) + return (-1); + *file = p; /* file name */ + for (*file = p; *p && !isspace(*p); p++) + ; + if (*p == 0) + return (-1); + *p = 0; + + /* value check */ + if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0) + return (0); + return (-1); +} + #endif diff --git a/usr.bin/less/ttyin.c b/usr.bin/less/ttyin.c index cc0302f4ac6..5d99d335e9e 100644 --- a/usr.bin/less/ttyin.c +++ b/usr.bin/less/ttyin.c @@ -1,29 +1,11 @@ -/* $OpenBSD: ttyin.c,v 1.2 2001/01/29 01:58:04 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -32,8 +14,18 @@ */ #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 -static int tty; +public int tty; +extern int sigs; /* * Open keyboard for input. @@ -41,7 +33,20 @@ static int tty; public void open_getchr() { -#if MSOFTC || OS2 +#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 @@ -49,7 +54,14 @@ open_getchr() */ fd0 = dup(0); close(0); - tty = OPEN_TTYIN(); + 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. @@ -57,10 +69,28 @@ open_getchr() * which in Unix is usually attached to the screen, * but also usually lets you read from the keyboard. */ - tty = OPEN_TTYIN(); +#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() +{ +#if MSDOS_COMPILER==WIN32C + SetConsoleMode((HANDLE)tty, console_mode); + CloseHandle((HANDLE)tty); +#endif } /* @@ -74,24 +104,22 @@ getchr() do { -#if MSOFTC +#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 -#if OS2 - flush(); - while (_read_kbd(0, 0, 0) != -1) - continue; - if ((c = _read_kbd(0, 1, 0)) == -1) - return (READ_INTR); - result = 1; -#else result = iread(tty, &c, sizeof(char)); if (result == READ_INTR) return (READ_INTR); @@ -104,7 +132,6 @@ getchr() quit(QUIT_ERROR); } #endif -#endif /* * Various parts of the program cannot handle * an input character of '\0'. diff --git a/usr.bin/less/version.c b/usr.bin/less/version.c index 22ed6a3bdbb..46dea70afc8 100644 --- a/usr.bin/less/version.c +++ b/usr.bin/less/version.c @@ -1,506 +1,488 @@ -/* $OpenBSD: version.c,v 1.2 2001/01/29 01:58:04 niklas Exp $ */ - /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, 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 + 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 + 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. +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(). +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. +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. +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 +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. +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(). +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, +v41 9/17/85 ONLY_RETURN, control char commands, faster search, other minor fixes. -v42 9/25/85 Added ++ command line syntax; +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; +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. +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. +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. + 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. + 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. + 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. + 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. + 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. + 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). + (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. + 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(). + 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. +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, +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 +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 +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 +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 +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 +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 +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 +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) +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 +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. +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 +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, +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; +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 +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; +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 +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 +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. +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 +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 +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, +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. +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. +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, +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). +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 +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 +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 +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. +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. +v137 1/21/90 Rewrote horrible pappend code. Added * notation for hi-bit chars. -v138 1/24/90 Fix magic cookie terminal handling. +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 +v139 1/27/90 Added MSDOS support. (many thanks to Richard Brittain). -v140 2/7/90 Editing a new file adds it to the +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. +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; +v144 3/1/90 Messed around with ch_zero; no real change. -v145 3/2/90 Added -R and -v/-V for MSDOS; +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 +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; +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 +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(); +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 +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 +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 +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; +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. +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 +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 +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. +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, +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. +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. +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"; +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. +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. +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 +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 +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; +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; +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. +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 +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. +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. +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; +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 +v202 7/28/94 Fix bug in edit_next/edit_prev with non-existant files. -v203 8/2/94 Fix a variety of configuration bugs on +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. +v204 8/3/94 Use strerror if available. (thanks to J.T. Conklin) -v205 8/5/94 Fix bug in finding "me" termcap entry. +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 +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 +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 +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 +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. +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. +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 +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. +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 +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. +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. +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 +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 +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 +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. +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 +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 +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 +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. +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 +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 +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. +v240 10/10/94 Don't write into termcap buffer. (Thanks to Benoit Speckel) -v241 10/13/94 New lesskey file format. +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 +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. +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 +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 +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 +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 +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 +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. +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 +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 +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 +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. +v278 2/14/95 Change default for -G. Posted to prep.ai.mit.edu ----------------------------------------------------------------- -v279 2/22/95 Add GNU options --help, --version. +v279 2/22/95 Add GNU options --help, --version. Minor config fixes. -v280 2/24/95 Clean up calls to glob(); don't set # +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; +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; +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. @@ -509,7 +491,159 @@ 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. */ -char version[] = "290"; +char version[] = "381"; |