| 1 | /* |
| 2 | * Copyright (c) 1988 Mark Nudleman |
| 3 | * Copyright (c) 1988 Regents of the University of California. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This code is derived from software contributed to Berkeley by |
| 7 | * Mark Nudleman. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms are permitted |
| 10 | * provided that the above copyright notice and this paragraph are |
| 11 | * duplicated in all such forms and that any documentation, |
| 12 | * advertising materials, and other materials related to such |
| 13 | * distribution and use acknowledge that the software was developed |
| 14 | * by the University of California, Berkeley. The name of the |
| 15 | * University may not be used to endorse or promote products derived |
| 16 | * from this software without specific prior written permission. |
| 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 18 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | */ |
| 21 | |
| 22 | #ifndef lint |
| 23 | static char sccsid[] = "@(#)version.c 5.1 (Berkeley) %G%"; |
| 24 | #endif /* not lint */ |
| 25 | |
| 26 | /* |
| 27 | * less |
| 28 | * Copyright (c) 1984,1985 Mark Nudelman |
| 29 | * |
| 30 | * This program may be freely used and/or modified, |
| 31 | * with the following provisions: |
| 32 | * 1. This notice and the above copyright notice must remain intact. |
| 33 | * 2. Neither this program, nor any modification of it, |
| 34 | * may be sold for profit without written consent of the author. |
| 35 | * |
| 36 | * ----------------------------------------------------------------- |
| 37 | * |
| 38 | * This program is a paginator similar to "more", |
| 39 | * but allows you to move both forward and backward in the file. |
| 40 | * Commands are based on "more" and "vi". |
| 41 | * |
| 42 | * ----------------------- CHANGES --------------------------------- |
| 43 | * |
| 44 | * Allowed use on standard input 1/29/84 markn |
| 45 | * Added E, N, P commands 2/1/84 markn |
| 46 | * Added '=' command, 'stop' signal handling 4/17/84 markn |
| 47 | * Added line folding 4/20/84 markn |
| 48 | * v2: Fixed '=' command to use BOTTOM_PLUS_ONE, |
| 49 | * instead of TOP, added 'p' & 'v' commands 4/27/84 markn |
| 50 | * v3: Added -m and -t options, '-' command 5/3/84 markn |
| 51 | * v4: Added LESS environment variable 5/3/84 markn |
| 52 | * v5: New comments, fixed '-' command slightly 5/3/84 markn |
| 53 | * v6: Added -Q, visual bell 5/15/84 markn |
| 54 | * v7: Fixed jump_back(n) bug: n should count real |
| 55 | * lines, not folded lines. Also allow number |
| 56 | * on G command. 5/24/84 markn |
| 57 | * v8: Re-do -q and -Q commands 5/30/84 markn |
| 58 | * v9: Added "+<cmd>" argument 9/25/84 markn |
| 59 | * v10: Fixed bug in -b<n> argument processing 10/10/84 markn |
| 60 | * v11: Made error() ring bell if \n not entered. 10/18/84 markn |
| 61 | * ----------------------------------------------------------------- |
| 62 | * v12: Reorganized signal handling and made |
| 63 | * portable to 4.2bsd. 2/13/85 mark |
| 64 | * v13: Reword error message for '-' command. 2/16/85 mark |
| 65 | * v14: Added -bf and -bp variants of -b. 2/22/85 mark |
| 66 | * v15: Miscellaneous changes. 2/25/85 mark |
| 67 | * v16: Added -u flag for backspace processing. 3/13/85 mark |
| 68 | * v17: Added j and k commands, |
| 69 | * changed -t default. 4/13/85 mark |
| 70 | * v18: Rewrote signal handling code. 4/20/85 mark |
| 71 | * v19: Got rid of "verbose" eq_message(). 5/2/85 mark |
| 72 | * Made search() scroll in some cases. |
| 73 | * v20: Fixed screen.c ioctls for System V. 5/21/85 mark |
| 74 | * v21: Fixed some first_cmd bugs. 5/23/85 mark |
| 75 | * v22: Added support for no RECOMP nor REGCMP. 5/24/85 mark |
| 76 | * v23: Miscellanous changes and prettying up. 5/25/85 mark |
| 77 | * Posted to USENET. |
| 78 | * ----------------------------------------------------------------- |
| 79 | * v24: Added ti,te terminal init & de-init 6/3/85 Mike Kersenbrock |
| 80 | * v25: Added -U flag, standout mode underlining. 6/8/85 mark |
| 81 | * v26: Added -M flag. 6/9/85 mark |
| 82 | * Use underline termcap (us) if it exists. |
| 83 | * v27: Renamed some variables to make unique in 6/15/85 mark |
| 84 | * 6 chars. Minor fix to -m. |
| 85 | * v28: Fixed right margin bug. 6/28/85 mark |
| 86 | * v29: Incorporated M.Rose's changes to signal.c 6/28/85 mark |
| 87 | * v30: Fixed stupid bug in argument processing. 6/29/85 mark |
| 88 | * v31: Added -p flag, changed repaint algorithm. 7/15/85 mark |
| 89 | * Added kludge for magic cookie terminals. |
| 90 | * v32: Added cat_file if output not a tty. 7/16/85 mark |
| 91 | * v33: Added -e flag and EDITOR. 7/23/85 mark |
| 92 | * v34: Added -s flag. 7/26/85 mark |
| 93 | * v35: Rewrote option handling; added option.c. 7/27/85 mark |
| 94 | * v36: Fixed -e flag to work if not last file. 7/29/85 mark |
| 95 | * v37: Added -x flag. 8/10/85 mark |
| 96 | * v38: Changed prompting; created prompt.c. 8/19/85 mark |
| 97 | * v39: (Not -p) does not initially clear screen. 8/24/85 mark |
| 98 | * v40: Added "skipping" indicator in forw(). 8/26/85 mark |
| 99 | * Posted to USENET. |
| 100 | * ----------------------------------------------------------------- |
| 101 | * v41: ONLY_RETURN, control char commands, 9/17/85 mark |
| 102 | * faster search, other minor fixes. |
| 103 | * v42: Added ++ command line syntax; 9/25/85 mark |
| 104 | * ch_fsize for pipes. |
| 105 | * v43: Added -h flag, changed prim.c algorithms. 10/15/85 mark |
| 106 | * v44: Made END print in all cases of eof; 10/16/85 mark |
| 107 | * ignore SIGTTOU after receiving SIGTSTP. |
| 108 | * v45: Never print backspaces unless -u. 10/16/85 mark |
| 109 | * v46: Backwards scroll in jump_loc. 10/24/85 mark |
| 110 | * v47: Fixed bug in edit(): *first_cmd==0 10/30/85 mark |
| 111 | * v48: Use TIOCSETN instead of TIOCSETP. 11/16/85 mark |
| 112 | * Added marks (m and ' commands). |
| 113 | * Posted to USENET. |
| 114 | * ----------------------------------------------------------------- |
| 115 | * v49: Fixed bug: signal didn't clear mcc. 1/9/86 mark |
| 116 | * v50: Added ' (quote) to gomark. 1/15/86 mark |
| 117 | * v51: Added + cmd, fixed problem if first_cmd |
| 118 | * fails, made g cmd sort of "work" on pipes |
| 119 | * even if bof is no longer buffered. 1/16/86 mark |
| 120 | * v52: Made short files work better. 1/17/86 mark |
| 121 | * v53: Added -P option. 1/20/86 mark |
| 122 | * v54: Changed help to use HELPFILE. 1/20/86 mark |
| 123 | * v55: Messages work better if not tty output. 1/23/86 mark |
| 124 | * v56: Added -l option. 1/24/86 mark |
| 125 | * v57: Fixed -l to get confirmation before |
| 126 | * overwriting an existing file. 1/31/86 mark |
| 127 | * v58: Added filename globbing. 8/28/86 mark |
| 128 | * v59: Fixed some bugs with very long filenames. 9/15/86 mark |
| 129 | * v60: Incorporated changes from Leith (Casey) |
| 130 | * Leedom for boldface and -z option. 9/26/86 mark |
| 131 | * v61: Got rid of annoying repaints after ! cmd. 9/26/86 mark |
| 132 | * Posted to USENET. |
| 133 | * ----------------------------------------------------------------- |
| 134 | * v62: Added is_directory(); change -z default to |
| 135 | * -1 instead of 24; cat-and-exit if -e and |
| 136 | * file is less than a screenful. 12/23/86 mark |
| 137 | * v63: Fixed bug in cat-and-exit if > 1 file. 1/8/87 mark |
| 138 | * v64: Changed puts/putstr, putc/putchr, |
| 139 | * getc/getchr to avoid name conflict with |
| 140 | * stdio functions. 1/12/87 mark |
| 141 | * v65: Allowed '-' command to change NUMBER |
| 142 | * valued options (thanks to Gary Puckering) 1/26/87 mark |
| 143 | * v66: Fixed bug: prepaint should use force=1. 2/13/87 mark |
| 144 | * v67: Added !! and % expansion to ! command. 2/24/87 mark |
| 145 | * v68: Added SIGWINCH and TIOCGWINSZ support; |
| 146 | * changed is_directory to bad_file. |
| 147 | * (thanks to J. Robert Ward) 2/25/87 mark |
| 148 | * v69: Added SIGWIND and WIOCGETD (for Unix PC). 2/25/87 mark |
| 149 | * v70: Changed help cmd from 'h' to 'H'; better |
| 150 | * error msgs in bad_file, errno_message. 3/13/87 mark |
| 151 | * v71: Changed -p to -c, made triple -c/-C |
| 152 | * for clear-eol like more's -c. 5/11/87 mark |
| 153 | * v72: Added -E, -L, use $SHELL in lsystem(). 6/26/87 mark |
| 154 | * (thanks to Steve Spearman) |
| 155 | * v73: Allow Examine "#" for previous file. 6/26/87 mark |
| 156 | * Posted to USENET 8/25/87. |
| 157 | * ----------------------------------------------------------------- |
| 158 | * v74: Fix conflict in EOF symbol with stdio.h, 9/18/87 mark |
| 159 | * Make os.c more portable to BSD. |
| 160 | * v75: Fix problems in get_term (thanks to 9/23/87 mark |
| 161 | * Paul Eggert); new backwards scrolling in |
| 162 | * jump_loc (thanks to Marion Hakanson). |
| 163 | * v76: Added -i flag; allow single "!" to 9/23/87 mark |
| 164 | * invoke a shell (thanks to Franco Barber). |
| 165 | * v77: Added -n flag and line number support. 9/24/87 mark |
| 166 | * v78: Fixed problem with prompts longer than 9/25/87 mark |
| 167 | * the screen width. |
| 168 | * v79: Added the _ command. 9/29/87 mark |
| 169 | * v80: Allow signal to break out of linenum scan. 10/6/87 mark |
| 170 | * v81: Allow -b to be changed from within less. 10/6/87 mark |
| 171 | * v82: Add cmd_decode to use a table for key 10/7/87 mark |
| 172 | * binding (thanks to David Nason). |
| 173 | * v83: Allow .less file for user-defined keys. 10/9/87 mark |
| 174 | * v84: Fix -e/-E problems (thanks to Felix Lee). 10/11/87 mark |
| 175 | * v85: Search now keeps track of line numbers. 10/15/87 mark |
| 176 | * v86: Added -B option and autobuf; fixed 10/20/87 mark |
| 177 | * "pipe error" bug. |
| 178 | * v87: Fix bug re BSD signals while reading file. 3/1/88 mark |
| 179 | * v88: Use new format for -P option (thanks to 3/12/88 mark |
| 180 | * der Mouse), allow "+-c" without message, |
| 181 | * fix bug re BSD hangup. |
| 182 | * v89: Turn off line numbers if linenum scan 3/18/88 mark |
| 183 | * is interrupted. |
| 184 | * v90: Allow -P from within less. 3/30/88 mark |
| 185 | * v91: Added tags file support (new -t option) 3/30/88 mark |
| 186 | * (thanks to Brian Campbell). |
| 187 | * v92: Added -+option syntax. 4/4/88 mark |
| 188 | * v93: Add support for slow input (thanks to 4/11/88 mark |
| 189 | * Joe Orost & apologies for taking almost |
| 190 | * 3 years to get this in!) |
| 191 | * v94: Redo reading/signal stuff. 4/11/88 mark |
| 192 | * v95: Repaint screen better after signal. 4/20/88 mark |
| 193 | * v96: Add /! and ?! commands. 4/21/88 mark |
| 194 | * v97: Allow -l/-L from within less. 5/17/88 mark |
| 195 | * Eliminate some static arrays (use calloc). |
| 196 | */ |
| 197 | |
| 198 | char version[] = "@(#) less version 97"; |