135209Sbostic /* 235209Sbostic * Copyright (c) 1988 Mark Nudleman 335209Sbostic * Copyright (c) 1988 Regents of the University of California. 435209Sbostic * All rights reserved. 535209Sbostic * 635209Sbostic * Redistribution and use in source and binary forms are permitted 735209Sbostic * provided that the above copyright notice and this paragraph are 835209Sbostic * duplicated in all such forms and that any documentation, 935209Sbostic * advertising materials, and other materials related to such 1035209Sbostic * distribution and use acknowledge that the software was developed 11*35283Sbostic * by Mark Nudleman and the University of California, Berkeley. The 12*35283Sbostic * name of Mark Nudleman or the 1335209Sbostic * University may not be used to endorse or promote products derived 1435209Sbostic * from this software without specific prior written permission. 1535209Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1635209Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1735209Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1835209Sbostic */ 1935209Sbostic 2035209Sbostic #ifndef lint 21*35283Sbostic static char sccsid[] = "@(#)version.c 5.2 (Berkeley) 07/25/88"; 2235209Sbostic #endif /* not lint */ 2335209Sbostic 2435209Sbostic /* 2535209Sbostic * less 2635209Sbostic * Copyright (c) 1984,1985 Mark Nudelman 2735209Sbostic * 2835209Sbostic * This program may be freely used and/or modified, 2935209Sbostic * with the following provisions: 3035209Sbostic * 1. This notice and the above copyright notice must remain intact. 3135209Sbostic * 2. Neither this program, nor any modification of it, 3235209Sbostic * may be sold for profit without written consent of the author. 3335209Sbostic * 3435209Sbostic * ----------------------------------------------------------------- 3535209Sbostic * 3635209Sbostic * This program is a paginator similar to "more", 3735209Sbostic * but allows you to move both forward and backward in the file. 3835209Sbostic * Commands are based on "more" and "vi". 3935209Sbostic * 4035209Sbostic * ----------------------- CHANGES --------------------------------- 4135209Sbostic * 4235209Sbostic * Allowed use on standard input 1/29/84 markn 4335209Sbostic * Added E, N, P commands 2/1/84 markn 4435209Sbostic * Added '=' command, 'stop' signal handling 4/17/84 markn 4535209Sbostic * Added line folding 4/20/84 markn 4635209Sbostic * v2: Fixed '=' command to use BOTTOM_PLUS_ONE, 4735209Sbostic * instead of TOP, added 'p' & 'v' commands 4/27/84 markn 4835209Sbostic * v3: Added -m and -t options, '-' command 5/3/84 markn 4935209Sbostic * v4: Added LESS environment variable 5/3/84 markn 5035209Sbostic * v5: New comments, fixed '-' command slightly 5/3/84 markn 5135209Sbostic * v6: Added -Q, visual bell 5/15/84 markn 5235209Sbostic * v7: Fixed jump_back(n) bug: n should count real 5335209Sbostic * lines, not folded lines. Also allow number 5435209Sbostic * on G command. 5/24/84 markn 5535209Sbostic * v8: Re-do -q and -Q commands 5/30/84 markn 5635209Sbostic * v9: Added "+<cmd>" argument 9/25/84 markn 5735209Sbostic * v10: Fixed bug in -b<n> argument processing 10/10/84 markn 5835209Sbostic * v11: Made error() ring bell if \n not entered. 10/18/84 markn 5935209Sbostic * ----------------------------------------------------------------- 6035209Sbostic * v12: Reorganized signal handling and made 6135209Sbostic * portable to 4.2bsd. 2/13/85 mark 6235209Sbostic * v13: Reword error message for '-' command. 2/16/85 mark 6335209Sbostic * v14: Added -bf and -bp variants of -b. 2/22/85 mark 6435209Sbostic * v15: Miscellaneous changes. 2/25/85 mark 6535209Sbostic * v16: Added -u flag for backspace processing. 3/13/85 mark 6635209Sbostic * v17: Added j and k commands, 6735209Sbostic * changed -t default. 4/13/85 mark 6835209Sbostic * v18: Rewrote signal handling code. 4/20/85 mark 6935209Sbostic * v19: Got rid of "verbose" eq_message(). 5/2/85 mark 7035209Sbostic * Made search() scroll in some cases. 7135209Sbostic * v20: Fixed screen.c ioctls for System V. 5/21/85 mark 7235209Sbostic * v21: Fixed some first_cmd bugs. 5/23/85 mark 7335209Sbostic * v22: Added support for no RECOMP nor REGCMP. 5/24/85 mark 7435209Sbostic * v23: Miscellanous changes and prettying up. 5/25/85 mark 7535209Sbostic * Posted to USENET. 7635209Sbostic * ----------------------------------------------------------------- 7735209Sbostic * v24: Added ti,te terminal init & de-init 6/3/85 Mike Kersenbrock 7835209Sbostic * v25: Added -U flag, standout mode underlining. 6/8/85 mark 7935209Sbostic * v26: Added -M flag. 6/9/85 mark 8035209Sbostic * Use underline termcap (us) if it exists. 8135209Sbostic * v27: Renamed some variables to make unique in 6/15/85 mark 8235209Sbostic * 6 chars. Minor fix to -m. 8335209Sbostic * v28: Fixed right margin bug. 6/28/85 mark 8435209Sbostic * v29: Incorporated M.Rose's changes to signal.c 6/28/85 mark 8535209Sbostic * v30: Fixed stupid bug in argument processing. 6/29/85 mark 8635209Sbostic * v31: Added -p flag, changed repaint algorithm. 7/15/85 mark 8735209Sbostic * Added kludge for magic cookie terminals. 8835209Sbostic * v32: Added cat_file if output not a tty. 7/16/85 mark 8935209Sbostic * v33: Added -e flag and EDITOR. 7/23/85 mark 9035209Sbostic * v34: Added -s flag. 7/26/85 mark 9135209Sbostic * v35: Rewrote option handling; added option.c. 7/27/85 mark 9235209Sbostic * v36: Fixed -e flag to work if not last file. 7/29/85 mark 9335209Sbostic * v37: Added -x flag. 8/10/85 mark 9435209Sbostic * v38: Changed prompting; created prompt.c. 8/19/85 mark 9535209Sbostic * v39: (Not -p) does not initially clear screen. 8/24/85 mark 9635209Sbostic * v40: Added "skipping" indicator in forw(). 8/26/85 mark 9735209Sbostic * Posted to USENET. 9835209Sbostic * ----------------------------------------------------------------- 9935209Sbostic * v41: ONLY_RETURN, control char commands, 9/17/85 mark 10035209Sbostic * faster search, other minor fixes. 10135209Sbostic * v42: Added ++ command line syntax; 9/25/85 mark 10235209Sbostic * ch_fsize for pipes. 10335209Sbostic * v43: Added -h flag, changed prim.c algorithms. 10/15/85 mark 10435209Sbostic * v44: Made END print in all cases of eof; 10/16/85 mark 10535209Sbostic * ignore SIGTTOU after receiving SIGTSTP. 10635209Sbostic * v45: Never print backspaces unless -u. 10/16/85 mark 10735209Sbostic * v46: Backwards scroll in jump_loc. 10/24/85 mark 10835209Sbostic * v47: Fixed bug in edit(): *first_cmd==0 10/30/85 mark 10935209Sbostic * v48: Use TIOCSETN instead of TIOCSETP. 11/16/85 mark 11035209Sbostic * Added marks (m and ' commands). 11135209Sbostic * Posted to USENET. 11235209Sbostic * ----------------------------------------------------------------- 11335209Sbostic * v49: Fixed bug: signal didn't clear mcc. 1/9/86 mark 11435209Sbostic * v50: Added ' (quote) to gomark. 1/15/86 mark 11535209Sbostic * v51: Added + cmd, fixed problem if first_cmd 11635209Sbostic * fails, made g cmd sort of "work" on pipes 11735209Sbostic * even if bof is no longer buffered. 1/16/86 mark 11835209Sbostic * v52: Made short files work better. 1/17/86 mark 11935209Sbostic * v53: Added -P option. 1/20/86 mark 12035209Sbostic * v54: Changed help to use HELPFILE. 1/20/86 mark 12135209Sbostic * v55: Messages work better if not tty output. 1/23/86 mark 12235209Sbostic * v56: Added -l option. 1/24/86 mark 12335209Sbostic * v57: Fixed -l to get confirmation before 12435209Sbostic * overwriting an existing file. 1/31/86 mark 12535209Sbostic * v58: Added filename globbing. 8/28/86 mark 12635209Sbostic * v59: Fixed some bugs with very long filenames. 9/15/86 mark 12735209Sbostic * v60: Incorporated changes from Leith (Casey) 12835209Sbostic * Leedom for boldface and -z option. 9/26/86 mark 12935209Sbostic * v61: Got rid of annoying repaints after ! cmd. 9/26/86 mark 13035209Sbostic * Posted to USENET. 13135209Sbostic * ----------------------------------------------------------------- 13235209Sbostic * v62: Added is_directory(); change -z default to 13335209Sbostic * -1 instead of 24; cat-and-exit if -e and 13435209Sbostic * file is less than a screenful. 12/23/86 mark 13535209Sbostic * v63: Fixed bug in cat-and-exit if > 1 file. 1/8/87 mark 13635209Sbostic * v64: Changed puts/putstr, putc/putchr, 13735209Sbostic * getc/getchr to avoid name conflict with 13835209Sbostic * stdio functions. 1/12/87 mark 13935209Sbostic * v65: Allowed '-' command to change NUMBER 14035209Sbostic * valued options (thanks to Gary Puckering) 1/26/87 mark 14135209Sbostic * v66: Fixed bug: prepaint should use force=1. 2/13/87 mark 14235209Sbostic * v67: Added !! and % expansion to ! command. 2/24/87 mark 14335209Sbostic * v68: Added SIGWINCH and TIOCGWINSZ support; 14435209Sbostic * changed is_directory to bad_file. 14535209Sbostic * (thanks to J. Robert Ward) 2/25/87 mark 14635209Sbostic * v69: Added SIGWIND and WIOCGETD (for Unix PC). 2/25/87 mark 14735209Sbostic * v70: Changed help cmd from 'h' to 'H'; better 14835209Sbostic * error msgs in bad_file, errno_message. 3/13/87 mark 14935209Sbostic * v71: Changed -p to -c, made triple -c/-C 15035209Sbostic * for clear-eol like more's -c. 5/11/87 mark 15135209Sbostic * v72: Added -E, -L, use $SHELL in lsystem(). 6/26/87 mark 15235209Sbostic * (thanks to Steve Spearman) 15335209Sbostic * v73: Allow Examine "#" for previous file. 6/26/87 mark 15435209Sbostic * Posted to USENET 8/25/87. 15535209Sbostic * ----------------------------------------------------------------- 15635209Sbostic * v74: Fix conflict in EOF symbol with stdio.h, 9/18/87 mark 15735209Sbostic * Make os.c more portable to BSD. 15835209Sbostic * v75: Fix problems in get_term (thanks to 9/23/87 mark 15935209Sbostic * Paul Eggert); new backwards scrolling in 16035209Sbostic * jump_loc (thanks to Marion Hakanson). 16135209Sbostic * v76: Added -i flag; allow single "!" to 9/23/87 mark 16235209Sbostic * invoke a shell (thanks to Franco Barber). 16335209Sbostic * v77: Added -n flag and line number support. 9/24/87 mark 16435209Sbostic * v78: Fixed problem with prompts longer than 9/25/87 mark 16535209Sbostic * the screen width. 16635209Sbostic * v79: Added the _ command. 9/29/87 mark 16735209Sbostic * v80: Allow signal to break out of linenum scan. 10/6/87 mark 16835209Sbostic * v81: Allow -b to be changed from within less. 10/6/87 mark 16935209Sbostic * v82: Add cmd_decode to use a table for key 10/7/87 mark 17035209Sbostic * binding (thanks to David Nason). 17135209Sbostic * v83: Allow .less file for user-defined keys. 10/9/87 mark 17235209Sbostic * v84: Fix -e/-E problems (thanks to Felix Lee). 10/11/87 mark 17335209Sbostic * v85: Search now keeps track of line numbers. 10/15/87 mark 17435209Sbostic * v86: Added -B option and autobuf; fixed 10/20/87 mark 17535209Sbostic * "pipe error" bug. 17635209Sbostic * v87: Fix bug re BSD signals while reading file. 3/1/88 mark 17735209Sbostic * v88: Use new format for -P option (thanks to 3/12/88 mark 17835209Sbostic * der Mouse), allow "+-c" without message, 17935209Sbostic * fix bug re BSD hangup. 18035209Sbostic * v89: Turn off line numbers if linenum scan 3/18/88 mark 18135209Sbostic * is interrupted. 18235209Sbostic * v90: Allow -P from within less. 3/30/88 mark 18335209Sbostic * v91: Added tags file support (new -t option) 3/30/88 mark 18435209Sbostic * (thanks to Brian Campbell). 18535209Sbostic * v92: Added -+option syntax. 4/4/88 mark 18635209Sbostic * v93: Add support for slow input (thanks to 4/11/88 mark 18735209Sbostic * Joe Orost & apologies for taking almost 18835209Sbostic * 3 years to get this in!) 18935209Sbostic * v94: Redo reading/signal stuff. 4/11/88 mark 19035209Sbostic * v95: Repaint screen better after signal. 4/20/88 mark 19135209Sbostic * v96: Add /! and ?! commands. 4/21/88 mark 19235209Sbostic * v97: Allow -l/-L from within less. 5/17/88 mark 19335209Sbostic * Eliminate some static arrays (use calloc). 19435209Sbostic */ 19535209Sbostic 19635209Sbostic char version[] = "@(#) less version 97"; 197