diff -U2 --new-file less-200/NEWS less-205/NEWS --- less-200/NEWS Tue Jul 26 17:00:54 1994 +++ less-205/NEWS Tue Aug 9 16:26:02 1994 @@ -1,4 +1,4 @@ - Major changes between "less" versions 170 and 200 + Major changes between "less" versions 170 and 205 * Ported to MS-DOS. diff -U2 --new-file less-200/README less-205/README --- less-200/README Tue Jul 26 16:58:32 1994 +++ less-205/README Tue Aug 9 18:15:45 1994 @@ -1,4 +1,4 @@ ======================================================================= -=== NOTE: THIS IS A BETA DISTRIBUTION OF less (version 200) === +=== NOTE: THIS IS A BETA DISTRIBUTION OF less (version 205) === === PLEASE REPORT ANY PROBLEMS TO THE AUTHOR. === ======================================================================= @@ -19,5 +19,9 @@ 3. It is a good idea to look over the generated Makefile and defines.h - and make sure they look ok. + and make sure they look ok. If you know of any peculiarities of + your system that configure might not have detected, you may fix the + Makefile now. For example, if you have both libtermcap and libcurses, + configure will choose libtermcap. But if your libtermcap has bugs, + you may wish to edit the Makefile to choose libcurses instead. If you wish, you may edit defines.h to remove some optional features. diff -U2 --new-file less-200/acconfig.h less-205/acconfig.h --- less-200/acconfig.h Mon Jul 25 20:40:08 1994 +++ less-205/acconfig.h Wed Aug 3 20:37:54 1994 @@ -40,2 +40,14 @@ #undef HAVE_V8_REGCOMP #undef NO_REGEX + +/* Define HAVE_VOID if your compiler supports the "void" type. */ +#undef HAVE_VOID + +/* Define HAVE_STRERROR if you have the strerror() function. */ +#undef HAVE_STRERROR + +/* 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 diff -U2 --new-file less-200/ch.c less-205/ch.c --- less-200/ch.c Mon Jul 25 20:40:08 1994 +++ less-205/ch.c Wed Aug 10 16:18:37 1994 @@ -40,10 +40,10 @@ * Pool of buffers holding the most recently used blocks of the input file. */ -#define BUFSIZ 1024 +#define LBUFSIZE 1024 struct buf { struct buf *next, *prev; /* Must be first to match struct filestate */ long block; unsigned int datasize; - unsigned char data[BUFSIZ]; + unsigned char data[LBUFSIZE]; }; @@ -151,5 +151,5 @@ read_more: - pos = (ch_block * BUFSIZ) + bp->datasize; + pos = (ch_block * LBUFSIZE) + bp->datasize; if ((len = ch_length()) != NULL_POSITION && pos >= len) /* @@ -181,5 +181,5 @@ */ n = iread(file, &bp->data[bp->datasize], - (unsigned int)(BUFSIZ - bp->datasize)); + (unsigned int)(LBUFSIZE - bp->datasize)); if (n == READ_INTR) return (EOI); @@ -288,5 +288,5 @@ long last_block; - last_block = (ch_fpos + BUFSIZ - 1) / BUFSIZ; + last_block = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE; for (block = 0; block <= last_block; block++) for (bp = buf_head; bp != END_OF_CHAIN; bp = bp->next) @@ -330,5 +330,5 @@ return (1); - new_block = pos / BUFSIZ; + new_block = pos / LBUFSIZE; if (ispipe && pos != ch_fpos && !buffered(new_block)) return (1); @@ -337,5 +337,5 @@ */ ch_block = new_block; - ch_offset = pos % BUFSIZ; + ch_offset = pos % LBUFSIZE; return (0); } @@ -410,5 +410,5 @@ * Return the current position in the file. */ -#define tellpos(blk,off) ((POSITION)((((long)(blk)) * BUFSIZ) + (off))) +#define tellpos(blk,off) ((POSITION)((((long)(blk)) * LBUFSIZE) + (off))) public POSITION @@ -429,5 +429,5 @@ if (c == EOI) return (EOI); - if (ch_offset < BUFSIZ-1) + if (ch_offset < LBUFSIZE-1) ch_offset++; else @@ -455,5 +455,5 @@ { #if __ZOFFSET /* NOT WORKING */ - if (tellpos(ch_block-1, BUFSIZ-1) < ch_zero()) + if (tellpos(ch_block-1, LBUFSIZE-1) < ch_zero()) return (EOI); #else @@ -464,5 +464,5 @@ return (EOI); ch_block--; - ch_offset = BUFSIZ-1; + ch_offset = LBUFSIZE-1; } return (ch_get()); @@ -527,6 +527,6 @@ */ ch_fpos = 0; - ch_block = ch_fpos / BUFSIZ; - ch_offset = ch_fpos % BUFSIZ; + ch_block = ch_fpos / LBUFSIZE; + ch_offset = ch_fpos % LBUFSIZE; if (lseek(file, (off_t)0, 0) == BAD_LSEEK) @@ -651,5 +651,5 @@ p += bc; ch_offset += bc + 1; - if (ch_offset >= BUFSIZ) + if (ch_offset >= LBUFSIZE) { ch_offset = 0; diff -U2 --new-file less-200/charset.c less-205/charset.c --- less-200/charset.c Mon Jul 25 20:40:09 1994 +++ less-205/charset.c Thu Jul 28 17:13:02 1994 @@ -78,4 +78,5 @@ n = 0; + v = 0; cp = chardef; while (*s != '\0') diff -U2 --new-file less-200/cmdbuf.c less-205/cmdbuf.c --- less-200/cmdbuf.c Mon Jul 25 20:40:09 1994 +++ less-205/cmdbuf.c Thu Jul 28 17:13:34 1994 @@ -467,5 +467,4 @@ { int action; - char *p; /* @@ -721,5 +720,5 @@ if (tk_original != NULL) free(tk_original); - tk_original = ecalloc(cp-word+1, sizeof(char)); + tk_original = (char *) ecalloc(cp-word+1, sizeof(char)); strncpy(tk_original, word, cp-word); /* diff -U2 --new-file less-200/command.c less-205/command.c --- less-200/command.c Mon Jul 25 20:40:09 1994 +++ less-205/command.c Thu Jul 28 17:14:06 1994 @@ -169,5 +169,4 @@ { register char *cbuf; - register char *s; cmd_exec(); diff -U2 --new-file less-200/configure less-205/configure --- less-200/configure Thu Jun 23 19:56:29 1994 +++ less-205/configure Thu Aug 4 00:45:01 1994 @@ -512,4 +512,29 @@ fi +# Regular expressions (regcmp) are in -lgen on Solaris 2. +ac_save_LIBS="${LIBS}" +LIBS="${LIBS} -lgen" +ac_have_lib="" +test -n "$silent" || echo "checking for -lgen" +cat > conftest.${ac_ext} < conftest.${ac_ext} <> confdefs.h +DEFS="$DEFS -DHAVE_VOID=1" +ac_sed_defs="${ac_sed_defs}\${ac_dA}HAVE_VOID\${ac_dB}HAVE_VOID\${ac_dC}1\${ac_dD} +\${ac_uA}HAVE_VOID\${ac_uB}HAVE_VOID\${ac_uC}1\${ac_uD} +\${ac_eA}HAVE_VOID\${ac_eB}HAVE_VOID\${ac_eC}1\${ac_eD} +" +} + + +fi +rm -f conftest* + test -n "$silent" || echo "checking for return type of signal handlers" @@ -679,5 +729,5 @@ -for ac_func in _setjmp system sigsetmask +for ac_func in _setjmp system sigsetmask memcpy do ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` @@ -717,11 +767,89 @@ done +test -n "$silent" || echo "checking for strerror" +cat > conftest.${ac_ext} < + #include +int main() { return 0; } +int t() { static int x,y; x=strerror(y);; return 0; } +EOF +if eval $ac_compile; then + rm -rf conftest* + +{ +test -n "$verbose" && \ +echo " defining HAVE_STRERROR" +echo "#define" HAVE_STRERROR "1" >> confdefs.h +DEFS="$DEFS -DHAVE_STRERROR=1" +ac_sed_defs="${ac_sed_defs}\${ac_dA}HAVE_STRERROR\${ac_dB}HAVE_STRERROR\${ac_dC}1\${ac_dD} +\${ac_uA}HAVE_STRERROR\${ac_uB}HAVE_STRERROR\${ac_uC}1\${ac_uD} +\${ac_eA}HAVE_STRERROR\${ac_eB}HAVE_STRERROR\${ac_eC}1\${ac_eD} +" +} + + +fi +rm -f conftest* + +cat > conftest.${ac_ext} <> confdefs.h +DEFS="$DEFS -DHAVE_SYS_ERRLIST=1" +ac_sed_defs="${ac_sed_defs}\${ac_dA}HAVE_SYS_ERRLIST\${ac_dB}HAVE_SYS_ERRLIST\${ac_dC}1\${ac_dD} +\${ac_uA}HAVE_SYS_ERRLIST\${ac_uB}HAVE_SYS_ERRLIST\${ac_uC}1\${ac_uD} +\${ac_eA}HAVE_SYS_ERRLIST\${ac_eB}HAVE_SYS_ERRLIST\${ac_eC}1\${ac_eD} +" +} + + +fi +rm -f conftest* + +cat > conftest.${ac_ext} <> confdefs.h +DEFS="$DEFS -DHAVE_ERRNO=1" +ac_sed_defs="${ac_sed_defs}\${ac_dA}HAVE_ERRNO\${ac_dB}HAVE_ERRNO\${ac_dC}1\${ac_dD} +\${ac_uA}HAVE_ERRNO\${ac_uB}HAVE_ERRNO\${ac_uC}1\${ac_uD} +\${ac_eA}HAVE_ERRNO\${ac_eB}HAVE_ERRNO\${ac_eC}1\${ac_eD} +" +} + + +fi +rm -f conftest* + have_regex=no test -n "$silent" || echo "checking for POSIX regex.h" -echo '#include "confdefs.h" -#include ' > conftest.${ac_ext} -eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1" -if egrep "regex_t" conftest.out >/dev/null 2>&1; then +cat > conftest.${ac_ext} < +#include +int main() { return 0; } +int t() { regex_t *r; regfree(r);; return 0; } +EOF +if eval $ac_compile; then rm -rf conftest* diff -U2 --new-file less-200/configure.in less-205/configure.in --- less-200/configure.in Thu Jun 23 19:56:29 1994 +++ less-205/configure.in Thu Aug 4 00:42:08 1994 @@ -13,20 +13,34 @@ [LIBS="$LIBS -ltermcap"; AC_VERBOSE(using -ltermcap)], [LIBS="$LIBS -lcurses"; AC_VERBOSE(using -lcurses)]) +# Regular expressions (regcmp) are in -lgen on Solaris 2. +AC_HAVE_LIBRARY(gen, [LIBS="$LIBS -lgen"; AC_VERBOSE(using -lgen)]) + dnl Checks for header files. AC_STDC_HEADERS -AC_HAVE_HEADERS(termio.h sys/stream.h sys/ptem.h) +AC_HAVE_HEADERS(fcntl.h stdio.h termcap.h termio.h termios.h time.h unistd.h sys/stream.h sys/ptem.h) dnl Checks for identifiers. AC_OFF_T +AC_COMPILE_CHECK(void, , [void *foo = 0;], [AC_DEFINE(HAVE_VOID)]) -dnl Checks for functions. +dnl Checks for functions and external variables. AC_RETSIGTYPE -AC_HAVE_FUNCS(_setjmp system sigsetmask) +AC_HAVE_FUNCS(_setjmp system sigsetmask memcpy) +AC_COMPILE_CHECK(strerror, [#include + #include ], [static int x,y; x=strerror(y);], + [AC_DEFINE(HAVE_STRERROR)]) +AC_COMPILE_CHECK(, , [extern int sys_errlist; static int x; x = sys_errlist;], + [AC_DEFINE(HAVE_SYS_ERRLIST)]) +AC_COMPILE_CHECK(, , [extern int errno; static int x; x = errno;], + [AC_DEFINE(HAVE_ERRNO)]) dnl Checks for regular expression functions. have_regex=no AC_CHECKING(for POSIX regex.h) -AC_HEADER_EGREP(regex_t, regex.h, AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes) +AC_COMPILE_CHECK(, [#include +#include ], + [regex_t *r; regfree(r);], + AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes) if test $have_regex = no; then AC_FUNC_CHECK(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes) diff -U2 --new-file less-200/decode.c less-205/decode.c --- less-200/decode.c Mon Jul 25 20:40:09 1994 +++ less-205/decode.c Thu Jul 28 17:14:47 1994 @@ -211,5 +211,5 @@ { register struct tablelist *t; - register int action; + register int action = A_INVALID; /* diff -U2 --new-file less-200/defines.dos less-205/defines.dos --- less-200/defines.dos Mon Jul 25 20:40:09 1994 +++ less-205/defines.dos Tue Aug 9 16:28:15 1994 @@ -166,7 +166,22 @@ #define NO_REGEX 1 +/* Define HAVE_VOID if your compiler supports the "void" type. */ +#define HAVE_VOID 1 + +/* Define HAVE_STRERROR if you have the strerror() function. */ +#define HAVE_STRERROR 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 if you have _setjmp. */ #define HAVE__SETJMP 0 +/* Define if you have memcpy. */ +#define HAVE_MEMCPY 1 + /* Define if you have sigsetmask. */ #define HAVE_SIGSETMASK 0 @@ -175,4 +190,7 @@ #define HAVE_SYSTEM 1 +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + /* Define if you have the header file. */ #define HAVE_SYS_PTEM_H 0 @@ -181,7 +199,16 @@ #define HAVE_SYS_STREAM_H 0 +/* Define if you have the header file. */ +/* #undef HAVE_TERMCAP_H */ + /* Define if you have the header file. */ #define HAVE_TERMIO_H 0 -/* Define if you have the termcap library (-ltermcap). */ -#define HAVE_LIBTERMCAP 0 +/* Define if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 diff -U2 --new-file less-200/defines.h.in less-205/defines.h.in --- less-200/defines.h.in Thu Jun 23 19:56:30 1994 +++ less-205/defines.h.in Fri Aug 5 17:13:32 1994 @@ -6,4 +6,8 @@ * 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. */ @@ -137,7 +141,22 @@ #undef NO_REGEX +/* Define HAVE_VOID if your compiler supports the "void" type. */ +#undef HAVE_VOID + +/* Define HAVE_STRERROR if you have the strerror() function. */ +#undef HAVE_STRERROR + +/* 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 if you have _setjmp. */ #undef HAVE__SETJMP +/* Define if you have memcpy. */ +#undef HAVE_MEMCPY + /* Define if you have sigsetmask. */ #undef HAVE_SIGSETMASK @@ -146,4 +165,10 @@ #undef HAVE_SYSTEM +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_STDIO_H + /* Define if you have the header file. */ #undef HAVE_SYS_PTEM_H @@ -152,7 +177,16 @@ #undef HAVE_SYS_STREAM_H +/* Define if you have the header file. */ +#undef HAVE_TERMCAP_H + /* Define if you have the header file. */ #undef HAVE_TERMIO_H -/* Define if you have the termcap library (-ltermcap). */ -#undef HAVE_LIBTERMCAP +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H diff -U2 --new-file less-200/defines.h.top less-205/defines.h.top --- less-200/defines.h.top Thu Jun 23 19:56:30 1994 +++ less-205/defines.h.top Mon Aug 1 20:22:41 1994 @@ -5,4 +5,8 @@ * 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. */ diff -U2 --new-file less-200/doscreen.c less-205/doscreen.c --- less-200/doscreen.c Mon Jul 25 20:40:10 1994 +++ less-205/doscreen.c Wed Jul 27 16:05:02 1994 @@ -211,5 +211,5 @@ _setactivepage(1); so_enter(); - blanks = ecalloc(w.numtextcols, sizeof(char)); + blanks = (char *) ecalloc(w.numtextcols, sizeof(char)); for (col = 0; col < w.numtextcols; col++) blanks[col] = ' '; diff -U2 --new-file less-200/edit.c less-205/edit.c --- less-200/edit.c Mon Jul 25 20:40:10 1994 +++ less-205/edit.c Tue Aug 2 20:43:30 1994 @@ -28,5 +28,5 @@ #include "less.h" -#if MSOFTC +#if HAVE_FCNTL_H #include #endif @@ -188,5 +188,4 @@ IFILE ifile; { - char *altfile; int f; int answer; @@ -257,5 +256,4 @@ if (answer != 'y' && answer != 'Y') { - err2: close(f); goto err1; @@ -423,4 +421,5 @@ { IFILE h; + IFILE next; h = curr_ifile; @@ -428,11 +427,20 @@ * Skip n filenames, then try to edit each filename. */ - while (--n >= 0 || edit_ifile(h)) + for (;;) { - if ((h = next_ifile(h)) == NULL_IFILE) + next = next_ifile(h); + if (--n < 0) + { + if (edit_ifile(h) == 0) + break; + } + if (next == NULL_IFILE) + { /* * Reached end of the ifile list. */ return (1); + } + h = next; } /* @@ -450,4 +458,5 @@ { IFILE h; + IFILE next; h = curr_ifile; @@ -455,11 +464,20 @@ * Skip n filenames, then try to edit each filename. */ - while (--n >= 0 || edit_ifile(h)) + for (;;) { - if ((h = prev_ifile(h)) == NULL_IFILE) + 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; } /* diff -U2 --new-file less-200/filename.c less-205/filename.c --- less-200/filename.c Mon Jul 25 20:40:10 1994 +++ less-205/filename.c Tue Aug 2 20:41:38 1994 @@ -31,5 +31,4 @@ */ -#include #include "less.h" #if MSOFTC @@ -231,5 +230,5 @@ * This is just a guess, and we need not try too hard to make it accurate. */ - int + public int bin_file(f) int f; @@ -322,5 +321,5 @@ * Read the output of <$SHELL -c "cmd">. */ - scmd2 = (char *) ecalloc(strlen(shell) + strlen(scmd) + 6, + scmd2 = (char *) ecalloc(strlen(shell) + strlen(scmd) + 7, sizeof(char)); sprintf(scmd2, "%s -c \"%s\"", shell, scmd); @@ -339,5 +338,4 @@ { FILE *fd; - char *cmd; char *gfilename; diff -U2 --new-file less-200/funcs.h less-205/funcs.h --- less-200/funcs.h Mon Jul 25 20:40:10 1994 +++ less-205/funcs.h Thu Jul 28 17:54:08 1994 @@ -1,47 +1,2 @@ -/* - * 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. - */ - - - public int edit (); - public int edit_list (); - public int edit_first (); - public int edit_last (); - public int edit_next (); - public int edit_prev (); - public int edit_index (); - public int edit_stdin (); - public void cat_file (); - public void use_logfile (); - public IFILE next_ifile (); - public IFILE prev_ifile (); - public int nifile (); - public IFILE get_ifile (); - public char * get_filename (); - public int get_index (); - public void store_pos (); - public void get_pos (); public void match_brac (); public void end_logfile (); @@ -124,4 +79,5 @@ public char * fexpand (); public char * fcomplete (); + public int bin_file (); public char * glob (); public char * open_altfile (); @@ -219,5 +175,5 @@ public void put_line (); public void flush (); - public void putchr (); + public int putchr (); public void putstr (); public void error (); diff -U2 --new-file less-200/ifile.c less-205/ifile.c --- less-200/ifile.c Mon Jul 25 20:40:10 1994 +++ less-205/ifile.c Thu Jul 28 17:20:57 1994 @@ -115,5 +115,4 @@ { register struct ifile *p; - register struct ifile *np; /* diff -U2 --new-file less-200/less.h less-205/less.h --- less-200/less.h Mon Jul 25 20:40:11 1994 +++ less-205/less.h Tue Aug 9 19:22:02 1994 @@ -39,5 +39,5 @@ * Language details. */ -#ifdef __STDC__ +#if HAVE_VOID #define VOID_POINTER void * #else @@ -53,14 +53,29 @@ #include #endif +#if HAVE_STDIO_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif #if STDC_HEADERS #include #include -#else +#endif + +#if !STDC_HEADERS char *getenv(); off_t lseek(); VOID_POINTER calloc(); void free(); +#endif + #ifndef NULL #define NULL 0 +#endif + +#ifndef HAVE_MEMCPY +#ifndef memcpy +#define memcpy(to,from,len) bcopy((from),(to),(len)) #endif #endif diff -U2 --new-file less-200/less.man less-205/less.man --- less-200/less.man Mon Jul 11 18:41:28 1994 +++ less-205/less.man Tue Aug 9 18:47:29 1994 @@ -867,30 +867,41 @@ -INPUT FILTERS - You may define an "input filter" for _l_e_s_s. When _l_e_s_s opens a - file, it first passes the filename to your input filter, - which is simply an executable program (or shell script). - The filter may modify the contents of the file in any way it - wishes, and write the result to a new file (called the - replacement file). It must then output the filename of the - replacement file to its standard output. _L_e_s_s will then - open the replacement file instead of the original one, - although it will appear to the user as if the original file - is opened; that is, the name of the current file will appear - as the original filename. If the input filter does not out- - put a replacement filename, the original file is opened. - When _l_e_s_s closes a file opened in such a way, it will pass - both the original filename and the name of the replacement - file to another program, which may perform any desired - clean-up action (such as deleting the replacement file). - - An input filter is set up by setting the LESSOPEN environ- - ment variable to the name of the input filter program. The - position of the filename should be marked with a "%s". - Similarly, the LESSCLOSE environment variable may be set to - the name of the program to invoke when a file is closed. - There should be two "%s" strings in LESSCLOSE; the first is - replaced with the original name of the file and the second - with the name of the replacement file. +INPUT PREPROCESSOR + You may define an "input preprocessor" for _l_e_s_s. Before _l_e_s_s + opens a file, it first gives your input preprocessor a + chance to modify the way the contents of the file are + displayed. An input preprocessor is simply an executable + program (or shell script), which writes the contents of the + file to a different file, called the replacement file. The + contents of the replacement file are then displayed in place + of the contents of the original file. However, it will + appear to the user as if the original file is opened; that + is, _l_e_s_s will display the original filename as the name of + the current file. + + An input preprocessor receives one command line argument, + the original filename, as entered by the user. It should + create the replacement file, and when finished, print the + name of the replacement file to its standard output. If the + input preprocessor does not output a replacement filename, + _l_e_s_s uses the original file, as normal. To set up an input + preprocessor, set the LESSOPEN environment variable to a + command line which will invoke your input preprocessor. + This command line should include one occurence of the string + "%s", which will be replaced by the filename when the input + preprocessor command is invoked. + + When _l_e_s_s closes a file opened in such a way, it will call + another program, called the input postprocessor, which may + perform any desired clean-up action (such as deleting the + replacement file created by LESSOPEN). This program + receives two command line arguments, the original filename + as entered by the user, and the name of the replacement + file. To set up an input postprocessor, set the LESSCLOSE + environment variable to a command line which will invoke + your input postprocessor. It may include two occurences of + the string "%s"; the first is replaced with the original + name of the file and the second with the name of the + replacement file, which was output by LESSOPEN. For example, on many Unix systems, these two scripts will @@ -906,27 +917,31 @@ fi - lessclose.sh: - rm $2 - To use these scripts, set LESSOPEN="lessopen.sh %s", and - LESSCLOSE="lessclose.sh %s %s". + 14 -NATIONAL CHARACTER SETS - There are three types of characters in the input file: - 14 +LESS(1) USER COMMANDS LESS(1) + lessclose.sh: + #! /bin/sh + rm $2 - -LESS(1) USER COMMANDS LESS(1) + To use these scripts, put them both where they can be exe- + cuted and set LESSOPEN="lessopen.sh %s", and + LESSCLOSE="lessclose.sh %s %s". More complex LESSOPEN and + LESSCLOSE scripts may be written to also accept the filename + either with or without the .Z suffix, or to accept other + types of compressed files, and so on. +NATIONAL CHARACTER SETS + There are three types of characters in the input file: normal characters @@ -967,4 +982,18 @@ character set.) + + + + 15 + + + + + + +LESS(1) USER COMMANDS LESS(1) + + + Setting LESSCHARDEF to "8bcccbcc18b95.b" is the same as set- ting LESSCHARSET to "ascii". Setting LESSCHARDEF to @@ -982,18 +1011,4 @@ blinking mode display of control and binary characters can be changed or disabled by preceding the LESSBINFMT format - - - - 15 - - - - - - -LESS(1) USER COMMANDS LESS(1) - - - string with a "*" and one character to select the mode: "*k" is blinking, "*d" is bold, "*u" is underlined, and "*n" is @@ -1033,32 +1048,33 @@ %f Replaced by the name of the current input file. - %i Replaced by the index of the current file in the list - of input files. - %l_X Replaced by the line number of a line in the input - file. The line to be used is determined by the _X, as - with the %b option. - %L Replaced by the line number of the last line in the - input file. - %m Replaced by the total number of input files. + 16 - %p_X Replaced by the percent into the current input file. - The line used is determined by the _X as with the %b - option. - 16 +LESS(1) USER COMMANDS LESS(1) + %i Replaced by the index of the current file in the list + of input files. + + %l_X Replaced by the line number of a line in the input + file. The line to be used is determined by the _X, as + with the %b option. -LESS(1) USER COMMANDS LESS(1) + %L Replaced by the line number of the last line in the + input file. + %m Replaced by the total number of input files. + %p_X Replaced by the percent into the current input file. + The line used is determined by the _X as with the %b + option. %s Same as %B. @@ -1098,33 +1114,34 @@ is not a pipe). - ?l_X True if the line number of the specified line is known. - ?L True if the line number of the last line in the file is - known. - ?m True if there is more than one input file. - ?n True if this is the first prompt in a new input file. + 17 - ?p_X True if the percent into the current input file of the - specified line is known. - ?s Same as "?B". - ?x True if there is a next input file (that is, if the - current input file is not the last one). - 17 +LESS(1) USER COMMANDS LESS(1) + ?l_X True if the line number of the specified line is known. + ?L True if the line number of the last line in the file is + known. + ?m True if there is more than one input file. -LESS(1) USER COMMANDS LESS(1) + ?n True if this is the first prompt in a new input file. + ?p_X True if the percent into the current input file of the + specified line is known. + ?s Same as "?B". + + ?x True if there is a next input file (that is, if the + current input file is not the last one). Any characters other than the special ones (question mark, @@ -1163,4 +1180,18 @@ ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.: + + + + 18 + + + + + + +LESS(1) USER COMMANDS LESS(1) + + + ?pB%pB\%:byte %bB?s/%s...%t @@ -1181,17 +1212,4 @@ %E ?lm+%lm. %f - - - 18 - - - - - - -LESS(1) USER COMMANDS LESS(1) - - - Note that this expands to the editor name, followed by a + and the line number, followed by the file name. If your @@ -1228,35 +1246,37 @@ Selects a predefined character set. - LESSCLOSE - Name of the (optional) input-filter close command. - LESSEDIT - Editor prototype string (used for the v command). See - discussion under PROMPTS. - LESSHELP - Name of the help file. - LESSOPEN - Name of the (optional) input-filter open command. + 19 - LINES - Sets the number of lines on the screen. Takes pre- - cedence over the number of lines specified by the TERM - variable. - 19 +LESS(1) USER COMMANDS LESS(1) + LESSCLOSE + Command line to invoke the (optional) input- + postprocessor. + LESSEDIT + Editor prototype string (used for the v command). See + discussion under PROMPTS. -LESS(1) USER COMMANDS LESS(1) + LESSHELP + Name of the help file. + LESSOPEN + Command line to invoke the (optional) input- + preprocessor. + LINES + Sets the number of lines on the screen. Takes pre- + cedence over the number of lines specified by the TERM + variable. SHELL @@ -1290,24 +1310,4 @@ COPYRIGHT Copyright (c) 1984,1985,1989,1994 Mark Nudelman - - - - - - - - - - - - - - - - - - - - diff -U2 --new-file less-200/less.nro less-205/less.nro --- less-200/less.nro Wed Jul 6 18:14:49 1994 +++ less-205/less.nro Tue Aug 9 18:45:53 1994 @@ -739,36 +739,48 @@ manual page for more details. -.SH "INPUT FILTERS" -You may define an "input filter" for +.SH "INPUT PREPROCESSOR" +You may define an "input preprocessor" for .I less. -When +Before .I less -opens a file, it first passes the filename to your input filter, -which is simply an executable program (or shell script). -The filter may modify the contents of the file in any way it wishes, -and write the result to a new file (called the replacement file). -It must then output the filename of the replacement file to its standard output. -.I Less -will then open the replacement file instead of the original one, -although it will -appear to the user as if the original file is opened; -that is, the name of the current file will appear as the original filename. -If the input filter does not output a replacement filename, -the original file is opened. +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), +which writes the contents of the file to a different file, +called the replacement file. +The contents of the replacement file are then displayed +in place of the contents of the original file. +However, it will appear to the user as if the original file is opened; +that is, +.I less +will display the original filename as the name of the current file. +.PP +An input preprocessor receives one command line argument, the original filename, +as entered by the user. +It should create the replacement file, and when finished, +print the name of the replacement file to its standard output. +If the input preprocessor does not output a replacement filename, +.I less +uses the original file, as normal. +To set up an input preprocessor, set the LESSOPEN environment variable +to a command line which will invoke your input preprocessor. +This command line should include one occurence of the string "%s", +which will be replaced by the filename +when the input preprocessor command is invoked. +.PP When .I less -closes a file opened in such a way, it will pass both the -original filename and the name of the replacement file to another program, +closes a file opened in such a way, it will call another program, +called the input postprocessor, which may perform any desired clean-up action (such as deleting the -replacement file). -.PP -An input filter is set up by setting the LESSOPEN environment variable -to the name of the input filter program. -The position of the filename should be marked with a "%s". -Similarly, the LESSCLOSE environment variable may be set to the name -of the program to invoke when a file is closed. -There should be two "%s" strings in LESSCLOSE; the first is replaced -with the original name of the file and the second with the name of the -replacement file. +replacement file created by LESSOPEN). +This program receives two command line arguments, the original filename +as entered by the user, and the name of the replacement file. +To set up an input postprocessor, set the LESSCLOSE environment variable +to a command line which will invoke your input postprocessor. +It may include two occurences of the string "%s"; +the first is replaced with the original name of the file and +the second with the name of the replacement file, +which was output by LESSOPEN. .PP For example, on many Unix systems, these two scripts will allow you @@ -793,8 +805,14 @@ lessclose.sh: .br + #! /bin/sh +.br rm $2 .PP -To use these scripts, set LESSOPEN="lessopen.sh %s", and -LESSCLOSE="lessclose.sh %s %s". +To use these scripts, put them both where they can be executed and +set LESSOPEN="lessopen.sh\ %s", and +LESSCLOSE="lessclose.sh\ %s\ %s". +More complex LESSOPEN and LESSCLOSE scripts may be written +to also accept the filename either with or without the .Z suffix, +or to accept other types of compressed files, and so on. .SH "NATIONAL CHARACTER SETS" @@ -1041,5 +1059,5 @@ Selects a predefined character set. .IP LESSCLOSE -Name of the (optional) input-filter close command. +Command line to invoke the (optional) input-postprocessor. .IP LESSEDIT Editor prototype string (used for the v command). @@ -1048,5 +1066,5 @@ Name of the help file. .IP LESSOPEN -Name of the (optional) input-filter open command. +Command line to invoke the (optional) input-preprocessor. .IP LINES Sets the number of lines on the screen. diff -U2 --new-file less-200/lesskey.c less-205/lesskey.c --- less-200/lesskey.c Mon Jul 25 20:40:11 1994 +++ less-205/lesskey.c Tue Aug 2 20:41:41 1994 @@ -72,5 +72,4 @@ */ -#include #include "less.h" #include "cmd.h" @@ -135,4 +134,48 @@ }; +/* + * Parse one character of a string. + */ +int +tchar(pp) + char **pp; +{ + register char *p; + register char ch; + register int i; + + p = *pp; + switch (*p) + { + case '\\': + if (*++p >= '0' && *p <= '7') + { + /* + * Parse an octal number. + */ + ch = 0; + i = 0; + do + ch = 8*ch + (*p - '0'); + while (*++p >= '0' && *p <= '7' && ++i < 3); + *pp = p; + return (ch); + } + /* + * Backslash followed by a char just means that char. + */ + *pp = p+1; + return (*p); + case '^': + /* + * Carat means CONTROL. + */ + *pp = p+2; + return (CONTROL(p[1])); + } + *pp = p+1; + return (*p); +} + main(argc, argv) int argc; @@ -331,47 +374,4 @@ fwrite((char *)usertable, 1, up-usertable, out); exit(0); -} - -/* - * Parse one character of a string. - */ -tchar(pp) - char **pp; -{ - register char *p; - register char ch; - register int i; - - p = *pp; - switch (*p) - { - case '\\': - if (*++p >= '0' && *p <= '7') - { - /* - * Parse an octal number. - */ - ch = 0; - i = 0; - do - ch = 8*ch + (*p - '0'); - while (*++p >= '0' && *p <= '7' && ++i < 3); - *pp = p; - return (ch); - } - /* - * Backslash followed by a char just means that char. - */ - *pp = p+1; - return (*p); - case '^': - /* - * Carat means CONTROL. - */ - *pp = p+2; - return (CONTROL(p[1])); - } - *pp = p+1; - return (*p); } diff -U2 --new-file less-200/lsystem.c less-205/lsystem.c --- less-200/lsystem.c Mon Jul 25 20:40:11 1994 +++ less-205/lsystem.c Tue Aug 2 20:44:02 1994 @@ -31,13 +31,13 @@ */ -#include #include - #include "less.h" #include "position.h" +#if HAVE_FCNTL_H +#include +#endif #if MSOFTC #include -#include #endif @@ -267,4 +267,5 @@ #endif + c = EOI; while (epos == NULL_POSITION || spos++ <= epos) { diff -U2 --new-file less-200/main.c less-205/main.c --- less-200/main.c Mon Jul 25 20:40:11 1994 +++ less-205/main.c Thu Jul 28 17:36:43 1994 @@ -75,4 +75,5 @@ * Entry point. */ +int main(argc, argv) int argc; @@ -269,5 +270,5 @@ register VOID_POINTER p; - p = calloc(count, size); + p = (VOID_POINTER) calloc(count, size); if (p != NULL) return (p); diff -U2 --new-file less-200/os.c less-205/os.c --- less-200/os.c Mon Jul 25 20:40:13 1994 +++ less-205/os.c Wed Aug 3 20:41:18 1994 @@ -38,7 +38,9 @@ */ -#include #include #include +#if HAVE_TIME_H +#include +#endif #include "less.h" @@ -130,16 +132,31 @@ #endif + +#if !HAVE_STRERROR /* - * errno_message: Return an error message based on the value of "errno". + * Local version of strerror, if not available from the system. */ - -#if HAVE_PERROR - -#if !MSOFTC -extern char *sys_errlist[]; -extern int sys_nerr; -extern int errno; + static char * +strerror(err) + int err; +{ +#if HAVE_SYS_ERRLIST + static char buf[16]; + extern char *sys_errlist[]; + extern int sys_nerr; + + if (err < sys_nerr) + return sys_errlist[err]; + sprintf(buf, "Error %d", err); + return buf; +#else + return ("cannot open"); +#endif +} #endif +/* + * errno_message: Return an error message based on the value of "errno". + */ public char * errno_message(filename) @@ -148,32 +165,12 @@ register char *p; register char *m; - char msg[16]; - - if (errno < sys_nerr) - p = sys_errlist[errno]; - else - { - sprintf(msg, "Error %d", errno); - p = msg; - } +#if HAVE_ERRNO + extern int errno; + p = strerror(errno); +#else + p = "cannot open"; +#endif m = (char *) ecalloc(strlen(filename) + strlen(p) + 3, sizeof(char)); sprintf(m, "%s: %s", filename, p); return (m); } - -#else - - public char * -errno_message(filename) - char *filename; -{ - register char *m; - static char msg[] = ": cannot open"; - - m = (char *) ecalloc(strlen(filename) + sizeof(msg), sizeof(char)); - strcpy(m, filename); - strcat(m, msg); - return (m); -} - -#endif diff -U2 --new-file less-200/output.c less-205/output.c --- less-200/output.c Mon Jul 25 20:40:13 1994 +++ less-205/output.c Thu Jul 28 17:20:30 1994 @@ -145,5 +145,5 @@ * Output a character. */ - public void + public int putchr(c) int c; @@ -161,4 +161,5 @@ #endif *ob++ = c; + return (c); } diff -U2 --new-file less-200/screen.c less-205/screen.c --- less-200/screen.c Mon Jul 25 20:40:13 1994 +++ less-205/screen.c Fri Aug 5 16:40:30 1994 @@ -36,12 +36,20 @@ #include "cmd.h" +#if HAVE_TERMIOS_H +#include +#else #if HAVE_TERMIO_H #include #else #include -#ifdef TIOCGWINSZ +#if defined(TIOCGWINSZ) || defined(TCGETA) || defined(TIOCGETP) || defined(WIOCGETD) #include #endif #endif +#endif + +#if HAVE_TERMCAP_H +#include +#endif #ifndef TIOCGWINSZ @@ -141,4 +149,50 @@ if (on == curr_on) return; +#if HAVE_TERMIOS_H + { + struct termios s; + static struct termios save_term; + + if (on) + { + /* + * Get terminal modes. + */ + tcgetattr(2, &s); + + /* + * Save modes and set certain variables dependent on modes. + */ + save_term = s; + ospeed = cfgetospeed(&s); + erase_char = s.c_cc[VERASE]; + kill_char = s.c_cc[VKILL]; + + /* + * Set the modes to the way we want them. + */ + s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); +#ifdef OXTABS + s.c_oflag |= (OPOST|ONLCR|OXTABS); +#else + s.c_oflag |= (OPOST|ONLCR|TAB3); +#endif +#ifdef ONOEOT + s.c_oflag &= ~(ONOEOT); +#else + s.c_oflag &= ~(OCRNL|ONOCR|ONLRET); +#endif + s.c_cc[VMIN] = 1; + s.c_cc[VTIME] = 0; + } else + { + /* + * Restore saved modes. + */ + s = save_term; + } + tcsetattr(2, TCSADRAIN, &s); + } +#else #ifdef TCGETA { @@ -213,4 +267,5 @@ } #endif +#endif curr_on = on; } @@ -551,5 +606,7 @@ } else { - sc_bl_out = sc_b_out; + sc_bl_out = tgetstr("me", &sp); + if (hard || sc_bl_out == NULL) + sc_bl_out = ""; } @@ -637,9 +694,10 @@ /*ARGSUSED*/ - static void + static int inc_costcount(c) int c; { costcount++; + return (c); } diff -U2 --new-file less-200/search.c less-205/search.c --- less-200/search.c Mon Jul 25 20:40:13 1994 +++ less-205/search.c Thu Jul 28 17:38:17 1994 @@ -46,5 +46,4 @@ extern int bs_mode; -static int match(); /* @@ -89,4 +88,5 @@ static char lpbuf[100]; static char *last_pattern = NULL; + static int match(); #endif diff -U2 --new-file less-200/tags.c less-205/tags.c --- less-200/tags.c Mon Jul 25 20:40:14 1994 +++ less-205/tags.c Tue Aug 2 20:42:05 1994 @@ -26,5 +26,4 @@ -#include #include "less.h" diff -U2 --new-file less-200/ttyin.c less-205/ttyin.c --- less-200/ttyin.c Mon Jul 25 20:40:14 1994 +++ less-205/ttyin.c Tue Aug 2 20:43:17 1994 @@ -31,6 +31,5 @@ #include "less.h" -#if MSOFTC -#include +#if HAVE_FCNTL_H #include #endif diff -U2 --new-file less-200/version.c less-205/version.c --- less-200/version.c Mon Jul 25 20:43:36 1994 +++ less-205/version.c Fri Aug 5 17:17:59 1994 @@ -356,5 +356,20 @@ * v199: Fix MS-DOS build (thanks to Tim Wiegman). 6/29/94 * v200: Clean up copyright, minor fixes. 7/25/94 + * Posted to prep.ai.mit.edu + * ----------------------------------------------------------------- + * v201: Check for no memcpy; add casts to calloc; 7/27/94 + * look for regcmp in libgen.a. + * (thanks to Kaveh Ghazi). + * v202: Fix bug in edit_next/edit_prev with 7/28/94 + * non-existant files. + * v203: Fix a variety of configuration bugs on 8/2/94 + * various systems. (thanks to Sakai + * Kiyotaka, Harald Koenig, Bjorn Brox, + * Teemu Rantanen, and Thorsten Lockert) + * v204: Use strerror if available. 8/3/94 + * (thanks to J.T. Conklin) + * v205: Fix bug in finding "me" termcap entry. 8/5/94 + * (thanks to Andreas Stolcke) */ -char version[] = "@(#) less version 200"; +char version[] = "@(#) less version 205";