From: John Marino Date: Sat, 11 May 2013 20:01:33 +0000 (+0200) Subject: Update less from version 444 to 458 on the vendor branch X-Git-Tag: v3.7.0~1120^2 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/e639dc3174fb8ce20de0c0f641499e8d2cf89a84 Update less from version 444 to 458 on the vendor branch --- diff --git a/contrib/less/LICENSE b/contrib/less/LICENSE index c7168e7182..3fe715f170 100644 --- a/contrib/less/LICENSE +++ b/contrib/less/LICENSE @@ -2,7 +2,7 @@ ------------ Less -Copyright (C) 1984-2011 Mark Nudelman +Copyright (C) 1984-2012 Mark Nudelman Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/contrib/less/NEWS b/contrib/less/NEWS index eb38025cbf..e03f35af35 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -7,8 +7,53 @@ http://www.greenwoodsoftware.com/less You can also download the latest version of less from there. - To report bugs, suggestions or comments, send email to - bug-less@gnu.org or markn@greenwoodsoftware.com. + To report bugs, suggestions or comments, send email to bug-less@gnu.org. + +====================================================================== + + Major changes between "less" versions 451 and 458 + +* Allow backslash escaping of metacharacters in LESS environment variable + after the --use-backslash option. + +* Don't quit if syntax errors are found in command line options. + +* Increase sizes of some internal buffers. + +* Fix configure bug with --with-regex=none. + +* Fix crash with "stty rows 0". + +* Fix Win32 attribute display bug. + +* Fix display bug when using up/down arrow on the command line. + +====================================================================== + + Major changes between "less" versions 444 and 451 + +* Add ESC-F command to keep reading data until a pattern is found. + +* Use exit code of LESSOPEN script if LESSOPEN starts with "||". + +* When up/down arrow is used on the command line immediately after + typing text, the next command starting with that text is found. + +* Add support for GNU regex. + +* Add configure option --with-regex=none and fix compile errors + when compiling with no regex library. + +* Fix bugs handling SGR sequences in Win32. + +* Fix possible crashes caused by malformed LESSOPEN or + LESSCLOSE variables. + +* Fix bug highlighting text which is discontiguous in the file + due to backspace processing. + +* Fix bug in displaying status column when scrolling backwards + with -J and -S in effect. ====================================================================== diff --git a/contrib/less/README.DELETED b/contrib/less/README.DELETED deleted file mode 100644 index 857ed04601..0000000000 --- a/contrib/less/README.DELETED +++ /dev/null @@ -1,30 +0,0 @@ -INSTALL -Makefile.aut -Makefile.dsb -Makefile.dsg -Makefile.dsu -Makefile.in -Makefile.o2e -Makefile.o9c -Makefile.o9u -Makefile.wnb -Makefile.wnm -README -configure -configure.ac -defines.ds -defines.h.in -defines.o2 -defines.o9 -defines.wn -install.sh -less.hlp -less.man -lessecho.man -lesskey.man -mkfuncs.awk -mkhelp.c -mkinstalldirs -regexp.c -regexp.h -scrsize.c diff --git a/contrib/less/brac.c b/contrib/less/brac.c index 22c71ebfc8..70a7771ee3 100644 --- a/contrib/less/brac.c +++ b/contrib/less/brac.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/ch.c b/contrib/less/ch.c index 1b84ec1618..2e2ded7d17 100644 --- a/contrib/less/ch.c +++ b/contrib/less/ch.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -582,6 +581,8 @@ ch_length() return (NULL_POSITION); if (ch_flags & CH_HELPFILE) return (size_helpdata); + if (ch_flags & CH_NODATA) + return (0); return (ch_fsize); } @@ -805,6 +806,17 @@ seekable(f) return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK); } +/* + * Force EOF to be at the current read position. + * This is used after an ignore_eof read, during which the EOF may change. + */ + public void +ch_set_eof() +{ + ch_fsize = ch_fpos; +} + + /* * Initialize file state for a new file. */ diff --git a/contrib/less/charset.c b/contrib/less/charset.c index 12b59d6b73..03b38e0364 100644 --- a/contrib/less/charset.c +++ b/contrib/less/charset.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/charset.h b/contrib/less/charset.h index 8ccf748df0..7df4df62c2 100644 --- a/contrib/less/charset.h +++ b/contrib/less/charset.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 2005-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ #define IS_ASCII_OCTET(c) (((c) & 0x80) == 0) diff --git a/contrib/less/cmd.h b/contrib/less/cmd.h index 3176b91722..9a721602db 100644 --- a/contrib/less/cmd.h +++ b/contrib/less/cmd.h @@ -1,15 +1,14 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ -#define MAX_USERCMD 500 +#define MAX_USERCMD 1000 #define MAX_CMDLEN 16 #define A_B_LINE 2 @@ -66,6 +65,7 @@ #define A_NEXT_TAG 53 #define A_PREV_TAG 54 #define A_FILTER 55 +#define A_F_UNTIL_HILITE 56 #define A_INVALID 100 #define A_NOACTION 101 @@ -78,7 +78,7 @@ #define A_EXTRA 0200 -/* Line editting characters */ +/* Line editing characters */ #define EC_BACKSPACE 1 #define EC_LINEKILL 2 diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c index 74a74ffe9b..e387ccce8e 100644 --- a/contrib/less/cmdbuf.c +++ b/contrib/less/cmdbuf.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -30,6 +29,7 @@ static int prompt_col; /* Column of cursor just after prompt */ static char *cp; /* Pointer into cmdbuf */ static int cmd_offset; /* Index into cmdbuf of first displayed char */ static int literal; /* Next input char should not be interpreted */ +static int updown_match = -1; /* Prefix length in up/down movement */ #if TAB_COMPLETE_FILENAME static int cmd_complete(); @@ -122,6 +122,7 @@ cmd_reset() cmd_offset = 0; literal = 0; cmd_mbc_buf_len = 0; + updown_match = -1; } /* @@ -132,6 +133,7 @@ clear_cmd() { cmd_col = prompt_col = 0; cmd_mbc_buf_len = 0; + updown_match = -1; } /* @@ -504,6 +506,7 @@ cmd_ichar(cs, clen) /* * Reprint the tail of the line from the inserted char. */ + updown_match = -1; cmd_repaint(cp); cmd_right(); return (CC_OK); @@ -547,6 +550,7 @@ cmd_erase() /* * Repaint the buffer after the erased char. */ + updown_match = -1; cmd_repaint(cp); /* @@ -643,6 +647,7 @@ cmd_kill() cmd_offset = 0; cmd_home(); *cp = '\0'; + updown_match = -1; cmd_repaint(cp); /* @@ -675,12 +680,15 @@ set_mlist(mlist, cmdflags) #if CMD_HISTORY /* * Move up or down in the currently selected command history list. + * Only consider entries whose first updown_match chars are equal to + * cmdbuf's corresponding chars. */ static int cmd_updown(action) int action; { char *s; + struct mlist *ml; if (curr_mlist == NULL) { @@ -690,24 +698,47 @@ cmd_updown(action) bell(); return (CC_OK); } - cmd_home(); - clear_eol(); + + if (updown_match < 0) + { + updown_match = cp - cmdbuf; + } + /* - * Move curr_mp to the next/prev entry. + * Find the next history entry which matches. */ - if (action == EC_UP) - curr_mlist->curr_mp = curr_mlist->curr_mp->prev; - else - curr_mlist->curr_mp = curr_mlist->curr_mp->next; + for (ml = curr_mlist->curr_mp;;) + { + ml = (action == EC_UP) ? ml->prev : ml->next; + if (ml == curr_mlist) + { + /* + * We reached the end (or beginning) of the list. + */ + break; + } + if (strncmp(cmdbuf, ml->string, updown_match) == 0) + { + /* + * This entry matches; stop here. + * Copy the entry into cmdbuf and echo it on the screen. + */ + curr_mlist->curr_mp = ml; + s = ml->string; + if (s == NULL) + s = ""; + cmd_home(); + clear_eol(); + strcpy(cmdbuf, s); + for (cp = cmdbuf; *cp != '\0'; ) + cmd_right(); + return (CC_OK); + } + } /* - * Copy the entry into cmdbuf and echo it on the screen. + * We didn't find a history entry that matches. */ - s = curr_mlist->curr_mp->string; - if (s == NULL) - s = ""; - strcpy(cmdbuf, s); - for (cp = cmdbuf; *cp != '\0'; ) - cmd_right(); + bell(); return (CC_OK); } #endif @@ -1056,7 +1087,11 @@ init_compl() tk_text = fcomplete(word); } else { +#if MSDOS_COMPILER + char *qword = NULL; +#else char *qword = shell_quote(word+1); +#endif if (qword == NULL) tk_text = fcomplete(word+1); else @@ -1457,9 +1492,6 @@ save_cmdhist() FILE *f; int modified = 0; - filename = histfile_name(); - if (filename == NULL) - return; if (mlist_search.modified) modified = 1; #if SHELL_ESCAPE || PIPEC @@ -1468,6 +1500,9 @@ save_cmdhist() #endif if (!modified) return; + filename = histfile_name(); + if (filename == NULL) + return; f = fopen(filename, "w"); free(filename); if (f == NULL) diff --git a/contrib/less/command.c b/contrib/less/command.c index bacb058a5e..ed5b323859 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -36,6 +35,7 @@ extern int ignore_eoi; extern int secure; extern int hshift; extern int show_attn; +extern POSITION highest_hilite; extern char *every_first_cmd; extern char *curr_altfilename; extern char version[]; @@ -102,8 +102,8 @@ cmd_exec() static void start_mca(action, prompt, mlist, cmdflags) int action; - char *prompt; - void *mlist; + constant char *prompt; + constant void *mlist; int cmdflags; { mca = action; @@ -680,7 +680,7 @@ make_display() static void prompt() { - register char *p; + register constant char *p; if (ungot != NULL) { @@ -955,6 +955,46 @@ multi_search(pattern, n) } } +/* + * Forward forever, or until a highlighted line appears. + */ + static int +forw_loop(until_hilite) + int until_hilite; +{ + POSITION curr_len; + + if (ch_getflags() & CH_HELPFILE) + return (A_NOACTION); + + cmd_exec(); + jump_forw(); + curr_len = ch_length(); + highest_hilite = until_hilite ? curr_len : NULL_POSITION; + ignore_eoi = 1; + while (!sigs) + { + if (until_hilite && highest_hilite > curr_len) + { + bell(); + break; + } + make_display(); + forward(1, 0, 0); + } + ignore_eoi = 0; + ch_set_eof(); + + /* + * This gets us back in "F mode" after processing + * a non-abort signal (e.g. window-change). + */ + if (sigs && !ABORT_SIGS()) + return (until_hilite ? A_F_UNTIL_HILITE : A_F_FOREVER); + + return (A_NOACTION); +} + /* * Main command processor. * Accept and execute commands until a quit command. @@ -973,6 +1013,7 @@ commands() IFILE old_ifile; IFILE new_ifile; char *tagfile; + int until_hilite = 0; search_type = SRCH_FORW; wscroll = (sc_height + 1) / 2; @@ -1200,23 +1241,11 @@ commands() /* * Forward forever, ignoring EOF. */ - if (ch_getflags() & CH_HELPFILE) - break; - cmd_exec(); - jump_forw(); - ignore_eoi = 1; - while (!sigs) - { - make_display(); - 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; + newaction = forw_loop(0); + break; + + case A_F_UNTIL_HILITE: + newaction = forw_loop(1); break; case A_F_SCROLL: diff --git a/contrib/less/cvt.c b/contrib/less/cvt.c index 74439847e0..c3b3e6e742 100644 --- a/contrib/less/cvt.c +++ b/contrib/less/cvt.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ /* @@ -64,6 +63,7 @@ cvt_text(odst, osrc, chpos, lenp, ops) int ops; { char *dst; + char *edst = odst; char *src; register char *src_end; LWCHAR ch; @@ -98,23 +98,17 @@ cvt_text(odst, osrc, chpos, lenp, ops) if ((ops & CVT_TO_LC) && IS_UPPER(ch)) ch = TO_LOWER(ch); put_wchar(&dst, ch); - /* - * Record the original position of the char. - * But if we've already recorded a position - * for this char (due to a backspace), leave - * it alone; if multiple source chars map to - * one destination char, we want the position - * of the first one. - */ - if (chpos != NULL && chpos[dst_pos] < 0) + /* Record the original position of the char. */ + if (chpos != NULL) chpos[dst_pos] = src_pos; } + if (dst > edst) + edst = dst; } - if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') - dst--; - *dst = '\0'; + if ((ops & CVT_CRLF) && edst > odst && edst[-1] == '\r') + edst--; + *edst = '\0'; if (lenp != NULL) - *lenp = dst - odst; - if (chpos != NULL) - chpos[dst - odst] = src - osrc; + *lenp = edst - odst; + /* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */ } diff --git a/contrib/less/decode.c b/contrib/less/decode.c index 65d65bb656..6d0312d889 100644 --- a/contrib/less/decode.c +++ b/contrib/less/decode.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -79,6 +78,7 @@ static unsigned char cmdtable[] = 'w',0, A_B_WINDOW, ESC,' ',0, A_FF_SCREEN, 'F',0, A_F_FOREVER, + ESC,'F',0, A_F_UNTIL_HILITE, 'R',0, A_FREPAINT, 'r',0, A_REPAINT, CONTROL('R'),0, A_REPAINT, diff --git a/contrib/less/edit.c b/contrib/less/edit.c index 4781d95988..5f4e679fd1 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -310,6 +309,10 @@ edit_ifile(ifile) */ __djgpp_set_ctrl_c(1); #endif + } else if (strcmp(open_filename, FAKE_EMPTYFILE) == 0) + { + f = -1; + chflags |= CH_NODATA; } else if (strcmp(open_filename, FAKE_HELPFILE) == 0) { f = -1; diff --git a/contrib/less/filename.c b/contrib/less/filename.c index 0bbe82ab21..14e85e32cc 100644 --- a/contrib/less/filename.c +++ b/contrib/less/filename.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -806,6 +805,27 @@ lglob(filename) return (gfilename); } +/* + * Return number of %s escapes in a string. + * Return a large number if there are any other % escapes besides %s. + */ + static int +num_pct_s(lessopen) + char *lessopen; +{ + int num; + + for (num = 0;; num++) + { + lessopen = strchr(lessopen, '%'); + if (lessopen == NULL) + break; + if (*++lessopen != 's') + return (999); + } + return (num); +} + /* * See if we should open a "replacement file" * instead of the file we're about to open. @@ -832,7 +852,7 @@ open_altfile(filename, pf, pfd) ch_ungetchar(-1); if ((lessopen = lgetenv("LESSOPEN")) == NULL) return (NULL); - if (*lessopen == '|') + while (*lessopen == '|') { /* * If LESSOPEN starts with a |, it indicates @@ -843,7 +863,7 @@ open_altfile(filename, pf, pfd) return (NULL); #else lessopen++; - returnfd = 1; + returnfd++; #endif } if (*lessopen == '-') { @@ -855,6 +875,11 @@ open_altfile(filename, pf, pfd) if (strcmp(filename, "-") == 0) return (NULL); } + if (num_pct_s(lessopen) > 1) + { + error("Invalid LESSOPEN variable", NULL_PARG); + return (NULL); + } len = strlen(lessopen) + strlen(filename) + 2; cmd = (char *) ecalloc(len, sizeof(char)); @@ -883,9 +908,18 @@ open_altfile(filename, pf, pfd) if (read(f, &c, 1) != 1) { /* - * Pipe is empty. This means there is no alt file. + * Pipe is empty. + * If more than 1 pipe char was specified, + * the exit status tells whether the file itself + * is empty, or if there is no alt file. + * If only one pipe char, just assume no alt file. */ - pclose(fd); + int status = pclose(fd); + if (returnfd > 1 && status == 0) { + *pfd = NULL; + *pf = -1; + return (save(FAKE_EMPTYFILE)); + } return (NULL); } ch_ungetchar(c); @@ -935,6 +969,11 @@ close_altfile(altfilename, filename, pipefd) } if ((lessclose = lgetenv("LESSCLOSE")) == NULL) return; + if (num_pct_s(lessclose) > 2) + { + error("Invalid LESSCLOSE variable"); + return; + } len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2; cmd = (char *) ecalloc(len, sizeof(char)); SNPRINTF2(cmd, len, lessclose, filename, altfilename); diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c index ebe422d944..21b500c2d5 100644 --- a/contrib/less/forwback.c +++ b/contrib/less/forwback.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/funcs.h b/contrib/less/funcs.h index 6595232e3d..325ba0e1f7 100644 --- a/contrib/less/funcs.h +++ b/contrib/less/funcs.h @@ -46,6 +46,7 @@ public void ch_setbufspace (); public void ch_flush (); public int seekable (); + public void ch_set_eof (); public void ch_init (); public void ch_close (); public int ch_getflags (); diff --git a/contrib/less/help.c b/contrib/less/help.c index 85b0a4adf9..46b8ff1ec3 100644 --- a/contrib/less/help.c +++ b/contrib/less/help.c @@ -6,6 +6,7 @@ constant char helpdata[] = { '\n', ' ',' ',' ',' ',' ',' ','C','o','m','m','a','n','d','s',' ','m','a','r','k','e','d',' ','w','i','t','h',' ','*',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','n','u','m','b','e','r',',',' ','_','\b','N','.','\n', ' ',' ',' ',' ',' ',' ','N','o','t','e','s',' ','i','n',' ','p','a','r','e','n','t','h','e','s','e','s',' ','i','n','d','i','c','a','t','e',' ','t','h','e',' ','b','e','h','a','v','i','o','r',' ','i','f',' ','_','\b','N',' ','i','s',' ','g','i','v','e','n','.','\n', +' ',' ',' ',' ',' ',' ','A',' ','k','e','y',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','c','a','r','e','t',' ','i','n','d','i','c','a','t','e','s',' ','t','h','e',' ','C','t','r','l',' ','k','e','y',';',' ','t','h','u','s',' ','^','K',' ','i','s',' ','c','t','r','l','-','K','.','\n', '\n', ' ',' ','h',' ',' ','H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','i','s',' ','h','e','l','p','.','\n', ' ',' ','q',' ',' ',':','q',' ',' ','Q',' ',' ',':','Q',' ',' ','Z','Z',' ',' ',' ',' ',' ','E','x','i','t','.','\n', @@ -43,7 +44,7 @@ constant char helpdata[] = { ' ',' ','E','S','C','-','u',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','n','d','o',' ','(','t','o','g','g','l','e',')',' ','s','e','a','r','c','h',' ','h','i','g','h','l','i','g','h','t','i','n','g','.','\n', ' ',' ','&','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','s','p','l','a','y',' ','o','n','l','y',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','\n', ' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', -' ',' ',' ',' ',' ',' ',' ',' ','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', +' ',' ',' ',' ',' ',' ',' ',' ','A',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n', ' ',' ',' ',' ',' ',' ',' ',' ','^','N',' ','o','r',' ','!',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','N','O','N','-','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','^','E',' ','o','r',' ','*',' ',' ','S','e','a','r','c','h',' ','m','u','l','t','i','p','l','e',' ','f','i','l','e','s',' ','(','p','a','s','s',' ','t','h','r','u',' ','E','N','D',' ','O','F',' ','F','I','L','E',')','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','^','F',' ','o','r',' ','@',' ',' ','S','t','a','r','t',' ','s','e','a','r','c','h',' ','a','t',' ','F','I','R','S','T',' ','f','i','l','e',' ','(','f','o','r',' ','/',')',' ','o','r',' ','l','a','s','t',' ','f','i','l','e',' ','(','f','o','r',' ','?',')','.','\n', @@ -109,14 +110,14 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ','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', +' ',' ',' ',' ',' ',' ',' ',' ','c','h','a','r','a','c','t','e','r',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','-',',',' ','o','r',' ','a',' ','n','a','m','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','-','-','.','\n', '\n', ' ',' ','-','?',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','e','l','p','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n', ' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n', -' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','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', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n', ' ',' ','-','A',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','S','E','A','R','C','H','-','S','K','I','P','-','S','C','R','E','E','N','\n', -' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','a','l','w','a','y','s',' ','s','k','i','p','s',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','s','t','a','r','t','s',' ','j','u','s','t',' ','a','f','t','e','r',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\n', ' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n', ' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n', @@ -172,7 +173,7 @@ constant char helpdata[] = { ' ',' ','-','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', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','(','t','r','u','n','c','a','t','e',')',' ','l','o','n','g',' ','l','i','n','e','s',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','w','r','a','p','p','i','n','g','.','\n', ' ',' ','-','t',' ','[','_','\b','t','_','\b','a','_','\b','g',']',' ',' ','.','.',' ',' ','-','-','t','a','g','=','[','_','\b','t','_','\b','a','_','\b','g',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','i','n','d',' ','a',' ','t','a','g','.','\n', ' ',' ','-','T',' ','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ','-','-','t','a','g','-','f','i','l','e','=','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', @@ -189,8 +190,6 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','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', @@ -202,7 +201,7 @@ constant char helpdata[] = { ' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','o','r','i','z','o','n','t','a','l',' ','s','c','r','o','l','l',' ','a','m','o','u','n','t',' ','(','0',' ','=',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',')','\n', ' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n', -' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','e','q','u','e','n','c','e','.','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n', ' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n', '\n', @@ -216,20 +215,20 @@ constant char helpdata[] = { '\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', +' ','c','t','r','l','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n', +' ','c','t','r','l','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n', ' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n', ' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n', ' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', ' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', -' ','C','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', +' ','c','t','r','l','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', +' ','c','t','r','l','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', +' ','c','t','r','l','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n', ' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', ' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', ' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n', ' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n', -' ','C','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', +' ','c','t','r','l','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n', '\n', '\n', 0 }; diff --git a/contrib/less/ifile.c b/contrib/less/ifile.c index 971e3b5e25..3e5e855cdf 100644 --- a/contrib/less/ifile.c +++ b/contrib/less/ifile.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/input.c b/contrib/less/input.c index b82868bca4..b211323e50 100644 --- a/contrib/less/input.c +++ b/contrib/less/input.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -416,7 +415,7 @@ get_back_line: goto get_back_line; } - if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL)) + if (status_col && curr_pos > 0 && is_hilited(base_pos, curr_pos-1, 1, NULL)) set_status_col('*'); #endif diff --git a/contrib/less/jump.c b/contrib/less/jump.c index d7ec77046f..075aa64d59 100644 --- a/contrib/less/jump.c +++ b/contrib/less/jump.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/less.h b/contrib/less/less.h index d013345222..fada51331c 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ #define NEWBOT 1 @@ -485,10 +484,13 @@ struct textlist #define CH_KEEPOPEN 002 #define CH_POPENED 004 #define CH_HELPFILE 010 +#define CH_NODATA 020 /* Special case for zero length files */ + #define ch_zero() ((POSITION)0) #define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@" +#define FAKE_EMPTYFILE "@/\\less/\\empty/\\file/\\@" /* Flags for cvt_text */ #define CVT_TO_LC 01 /* Convert upper-case to lower-case */ diff --git a/contrib/less/less.nro b/contrib/less/less.nro index 0bc21b505c..eba98eee03 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 444: 09 Jun 2011" +.TH LESS 1 "Version 458: 04 Apr 2013" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -109,6 +109,10 @@ 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.) +.IP "ESC-F" +Like F, but as soon as a line is found which matches +the last search pattern, the terminal bell is rung +and forward scrolling stops. .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.) @@ -451,13 +455,18 @@ If an option appears in the LESS variable, it can be reset to its default value on the command line by beginning the command line option with "\-+". .sp -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: +Some options like \-k or \-D require a string to follow the option letter. +The string for that option is considered to end when a dollar sign ($) is found. +For example, you can set two \-D options on MS-DOS like this: .sp -LESS="-Dn9.1$-Ds4.1" +LESS="Dn9.1$Ds4.1" .sp +If the --use-backslash option appears earlier in the options, then +a dollar sign or backslash may be included literally in an option string +by preceding it with a backslash. +If the --use-backslash option is not in effect, then backslashes are +not treated specially, and there is no way to include a dollar sign +in the option string. .IP "\-? or \-\-help" This option displays a summary of the commands accepted by .I less @@ -761,10 +770,10 @@ This is useful when viewing output. .IP "\-S or \-\-chop-long-lines" Causes lines longer than the screen width to be -chopped rather than folded. +chopped (truncated) rather than wrapped. 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 +The default is to wrap long lines; that is, display the remainder on the next line. .IP "\-t\fItag\fP or \-\-tag=\fItag\fP" The \-t option, followed immediately by a TAG, @@ -805,7 +814,7 @@ 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 or \-\-version" @@ -886,11 +895,6 @@ If the number is specified as a fraction, the actual number of scroll positions is recalculated if the terminal window is resized, so that the actual scroll remains at the specified fraction of the screen width. -.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 "\-\-follow-name" Normally, if the input file is renamed while an F command is executing, .I less @@ -904,6 +908,16 @@ If the reopen succeeds and the file is a different file from the original with the same name as the original (now renamed) file), .I less will display the contents of that new file. +.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 "\-\-use-backslash" +This option changes the interpretations of options which follow this one. +After the \-\-use-backslash option, any backslash in an option string is +removed and the following character is taken literally. +This allows a dollar sign to be included in option strings. .IP \-\- A command line argument of "\-\-" marks the end of option arguments. Any arguments following this are interpreted as filenames. @@ -963,8 +977,12 @@ Delete the word to the left of the cursor. Delete the word under the cursor. .IP "UPARROW [ ESC-k ]" Retrieve the previous command line. +If you first enter some text and then press UPARROW, +it will retrieve the previous command which begins with that text. .IP "DOWNARROW [ ESC-j ]" Retrieve the next command line. +If you first enter some text and then press DOWNARROW, +it will retrieve the next command which begins with that text. .IP "TAB" Complete the partial filename to the left of the cursor. If it matches more than one filename, the first match @@ -1157,14 +1175,33 @@ lesspipe.sh: case "$1" in .br *.Z) uncompress \-c $1 2>/dev/null +.br + *) exit 1 .br ;; .br esac +.br + exit $? .br .PP To use this script, put it where it can be executed and set LESSOPEN="|lesspipe.sh %s". +.PP +Note that a preprocessor cannot output an empty file, since that +is interpreted as meaning there is no replacement, and +the original file is used. +To avoid this, if LESSOPEN starts with two vertical bars, +the exit status of the script becomes meaningful. +If the exit status is zero, the output is considered to be +replacement text, even if it empty. +If the exit status is nonzero, any output is ignored and the +original file is used. +For compatibility with previous versions of +.I less, +if LESSOPEN starts with only one vertical bar, the exit status +of the preprocessor is ignored. +.PP When an input pipe is used, a LESSCLOSE postprocessor can be used, but it is usually not necessary since there is no replacement file to clean up. @@ -1183,7 +1220,8 @@ the preprocessor command. If standard input is being viewed, the input preprocessor is passed a file name consisting of a single dash. Similarly, if the first two characters of LESSOPEN are vertical bar and dash -(|\-), the input pipe is used on standard input as well as other files. +(|\-) or two vertical bars and a dash (||\-), +the input pipe is used on standard input as well as other files. Again, in this case the dash is not considered to be part of the input pipe command. @@ -1666,6 +1704,12 @@ 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 MORE +Options which are passed to +.I less +automatically when running in +.I more +compatible mode. .IP PATH User's search path (used to find a lesskey file on MS-DOS and OS/2 systems). @@ -1682,7 +1726,7 @@ The name of the editor (used for the v command). lesskey(1) .SH COPYRIGHT -Copyright (C) 1984-2011 Mark Nudelman +Copyright (C) 1984-2012 Mark Nudelman .PP less is part of the GNU project and is free software. You can redistribute it and/or modify it @@ -1705,9 +1749,9 @@ See the GNU General Public License for more details. .SH AUTHOR .PP -Mark Nudelman +Mark Nudelman .br -Send bug reports or comments to the above address or to bug-less@gnu.org. +Send bug reports or comments to .br See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less. .br diff --git a/contrib/less/lessecho.c b/contrib/less/lessecho.c index 6dcaf6c820..7098f2d447 100644 --- a/contrib/less/lessecho.c +++ b/contrib/less/lessecho.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -28,7 +27,7 @@ #include "less.h" -static char *version = "$Revision: 1.14 $"; +static char *version = "$Revision: 1.15 $"; static int quote_all = 0; static char openquote = '"'; diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index 46540e8bcc..d7fb390993 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 444: 09 Jun 2011" +.TH LESSECHO 1 "Version 458: 04 Apr 2013" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS @@ -7,12 +7,19 @@ lessecho \- expand metacharacters .SH "DESCRIPTION" .I lessecho is a program that simply echos its arguments on standard output. -But any argument containing spaces is enclosed in quotes. +But any metacharacter in the output is preceded by an "escape" +character, which by default is a backslash. .SH OPTIONS A summary of options is included below. .TP +.B \-ex +Specifies "x", rather than backslash, to be the escape char for metachars. +If x is "-", no escape char is used and arguments containing metachars +are surrounded by quotes instead. +.TP .B \-ox -Specifies "x" to be the open quote character. +Specifies "x", rather than double-quote, to be the open quote character, +which is used if the -e- option is specified. .TP .B \-cx Specifies "x" to be the close quote character. @@ -25,19 +32,17 @@ Specifies "n" to be the close quote character, as an integer. .TP .B \-mx Specifies "x" to be a metachar. +By default, no characters are considered metachars. .TP .B \-nn Specifies "n" to be a metachar, as an integer. .TP -.B \-ex -Specifies "x" to be the escape char for metachars. -.TP .B \-fn Specifies "n" to be the escape char for metachars, as an integer. .TP .B \-a Specifies that all arguments are to be quoted. -The default is that only arguments containing spaces are quoted. +The default is that only arguments containing metacharacters are quoted .SH "SEE ALSO" less(1) .SH AUTHOR diff --git a/contrib/less/lesskey.c b/contrib/less/lesskey.c index 1ee2c40402..3d7571ecb4 100644 --- a/contrib/less/lesskey.c +++ b/contrib/less/lesskey.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -112,6 +111,7 @@ struct cmdname cmdnames[] = { "flush-repaint", A_FREPAINT }, { "forw-bracket", A_F_BRACKET }, { "forw-forever", A_F_FOREVER }, + { "forw-until-hilite", A_F_UNTIL_HILITE }, { "forw-line", A_F_LINE }, { "forw-line-force", A_FF_LINE }, { "forw-screen", A_F_SCREEN }, @@ -449,7 +449,7 @@ tstr(pp, xlate) } case '^': /* - * Carat means CONTROL. + * Caret means CONTROL. */ *pp = p+2; buf[0] = CONTROL(p[1]); diff --git a/contrib/less/lesskey.h b/contrib/less/lesskey.h index 9a457a924f..91098a59aa 100644 --- a/contrib/less/lesskey.h +++ b/contrib/less/lesskey.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/lesskey.nro b/contrib/less/lesskey.nro index d305b957ce..2bbd887859 100644 --- a/contrib/less/lesskey.nro +++ b/contrib/less/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 444: 09 Jun 2011" +.TH LESSKEY 1 "Version 458: 04 Apr 2013" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS @@ -162,6 +162,7 @@ default command keys used by less: w back-window \ee\e40 forw-screen-force F forw-forever + \eeF forw-until-hilite R repaint-flush r repaint ^R repaint @@ -355,7 +356,7 @@ which start with a NUL character (0). This NUL character should be represented as \e340 in a lesskey file. .SH COPYRIGHT -Copyright (C) 2000-2011 Mark Nudelman +Copyright (C) 2000-2012 Mark Nudelman .PP lesskey is part of the GNU project and is free software; you can redistribute it and/or modify it @@ -375,7 +376,6 @@ Suite 330, Boston, MA 02111-1307, USA. .SH AUTHOR .PP -Mark Nudelman +Mark Nudelman .br -Send bug reports or comments to the above address or to bug-less@gnu.org. - +Send bug reports or comments to bug-less@gnu.org. diff --git a/contrib/less/lglob.h b/contrib/less/lglob.h index e2427e3abb..b08d24c159 100644 --- a/contrib/less/lglob.h +++ b/contrib/less/lglob.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/line.c b/contrib/less/line.c index 798d4f2670..1eb3914901 100644 --- a/contrib/less/line.c +++ b/contrib/less/line.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -27,6 +26,7 @@ public int hshift; /* Desired left-shift of output line buffer */ public int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */ public int ntabstops = 1; /* Number of tabstops */ public int tabdefault = 8; /* Default repeated tabstops */ +public POSITION highest_hilite; /* Pos of last hilite in file found so far */ static int curr; /* Index into linebuf */ static int column; /* Printable length, accounting for @@ -585,7 +585,12 @@ store_char(ch, a, rep, pos) * Override the attribute passed in. */ if (a != AT_ANSI) + { + if (highest_hilite != NULL_POSITION && + pos > highest_hilite) + highest_hilite = pos; a |= AT_HILITE; + } } } #endif diff --git a/contrib/less/linenum.c b/contrib/less/linenum.c index 4369f87b26..4f45be8748 100644 --- a/contrib/less/linenum.c +++ b/contrib/less/linenum.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/lsystem.c b/contrib/less/lsystem.c index 0a8ca52ea5..674e5a28e1 100644 --- a/contrib/less/lsystem.c +++ b/contrib/less/lsystem.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/main.c b/contrib/less/main.c index 0af176299f..da61b6bbef 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -211,6 +210,7 @@ main(argc, argv) argv++; (void) get_ifile(filename, ifile); ifile = prev_ifile(NULL_IFILE); + free(filename); #endif } /* diff --git a/contrib/less/mark.c b/contrib/less/mark.c index 585b412b49..c61ce034cb 100644 --- a/contrib/less/mark.c +++ b/contrib/less/mark.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/optfunc.c b/contrib/less/optfunc.c index a0aa10a81c..e3cd57f96d 100644 --- a/contrib/less/optfunc.c +++ b/contrib/less/optfunc.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -481,7 +480,30 @@ opt__V(type, s) any_display = 1; putstr("less "); putstr(version); - putstr("\nCopyright (C) 1984-2009 Mark Nudelman\n\n"); + putstr(" ("); +#if HAVE_GNU_REGEX + putstr("GNU "); +#endif +#if HAVE_POSIX_REGCOMP + putstr("POSIX "); +#endif +#if HAVE_PCRE + putstr("PCRE "); +#endif +#if HAVE_RE_COMP + putstr("BSD "); +#endif +#if HAVE_REGCMP + putstr("V8 "); +#endif +#if HAVE_V8_REGCOMP + putstr("Spencer V8 "); +#endif +#if !HAVE_GNU_REGEX && !HAVE_POSIX_REGCOMP && !HAVE_PCRE && !HAVE_RE_COMP && !HAVE_REGCMP && !HAVE_V8_REGCOMP + putstr("no "); +#endif + putstr("regular expressions)\n"); + putstr("Copyright (C) 1984-2012 Mark Nudelman\n\n"); putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); diff --git a/contrib/less/option.c b/contrib/less/option.c index acb8962527..2c26dc6950 100644 --- a/contrib/less/option.c +++ b/contrib/less/option.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -31,6 +30,7 @@ extern int screen_trashed; extern int less_is_more; extern int quit_at_eof; extern char *every_first_cmd; +extern int opt_use_backslash; /* * Return a printable description of an option. @@ -147,10 +147,13 @@ scan_option(s) */ plusoption = TRUE; s = optstring(s, &str, propt('+'), NULL); + if (s == NULL) + return; if (*str == '+') - every_first_cmd = save(++str); + every_first_cmd = save(str+1); else ungetsc(str); + free(str); continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -203,7 +206,7 @@ scan_option(s) parg.p_string = printopt; error("The %s option should not be followed by =", &parg); - quit(QUIT_ERROR); + return; } s++; } else @@ -224,7 +227,7 @@ scan_option(s) else error("There is no %s option (\"less --help\" for help)", &parg); - quit(QUIT_ERROR); + return; } str = NULL; @@ -261,6 +264,8 @@ scan_option(s) while (*s == ' ') s++; s = optstring(s, &str, printopt, o->odesc[1]); + if (s == NULL) + return; break; case NUMBER: if (*s == '\0') @@ -276,6 +281,8 @@ scan_option(s) */ if (o->ofunc != NULL) (*o->ofunc)(INIT, str); + if (str != NULL) + free(str); } } @@ -559,35 +566,33 @@ optstring(s, p_str, printopt, validchars) char *validchars; { register char *p; + register char *out; if (*s == '\0') { nostring(printopt); - quit(QUIT_ERROR); + return (NULL); } - *p_str = s; + /* Alloc could be more than needed, but not worth trimming. */ + *p_str = (char *) ecalloc(strlen(s)+1, sizeof(char)); + out = *p_str; + for (p = s; *p != '\0'; p++) { - if (*p == END_OPTION_STRING || - (validchars != NULL && strchr(validchars, *p) == NULL)) + if (opt_use_backslash && *p == '\\' && p[1] != '\0') { - 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'; + /* Take next char literally. */ + ++p; + } else + { + if (*p == END_OPTION_STRING || + (validchars != NULL && strchr(validchars, *p) == NULL)) + /* End of option string. */ break; - } - break; } + *out++ = *p; } + *out = '\0'; return (p); } @@ -610,8 +615,6 @@ num_error(printopt, errp) parg.p_string = printopt; error("Number is required after %s", &parg); } - quit(QUIT_ERROR); - /* NOTREACHED */ return (-1); } diff --git a/contrib/less/option.h b/contrib/less/option.h index a32139eea6..c11ad3b4f0 100644 --- a/contrib/less/option.h +++ b/contrib/less/option.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/opttbl.c b/contrib/less/opttbl.c index 63f6889955..6f582bf50b 100644 --- a/contrib/less/opttbl.c +++ b/contrib/less/opttbl.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -53,6 +52,7 @@ public int use_lessopen; /* Use the LESSOPEN filter */ public int quit_on_intr; /* Quit on interrupt */ public int follow_mode; /* F cmd Follows file desc or file name? */ public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */ +public int opt_use_backslash; /* Use backslash escaping in option parsing */ #if HILITE_SEARCH public int hilite_search; /* Highlight matched search patterns? */ #endif @@ -116,6 +116,7 @@ static struct optname pound_optname = { "shift", NULL }; static struct optname keypad_optname = { "no-keypad", NULL }; static struct optname oldbot_optname = { "old-bot", NULL }; static struct optname follow_optname = { "follow-name", NULL }; +static struct optname use_backslash_optname = { "use-backslash", NULL }; /* @@ -447,6 +448,14 @@ static struct loption option[] = NULL } }, + { OLETTER_NONE, &use_backslash_optname, + BOOL, OPT_OFF, &opt_use_backslash, NULL, + { + "Use backslash escaping in command line parameters", + "Don't use backslash escaping in command line parameters", + NULL + } + }, { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } } }; diff --git a/contrib/less/os.c b/contrib/less/os.c index dbb52fe3b8..eb75bbae46 100644 --- a/contrib/less/os.c +++ b/contrib/less/os.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/output.c b/contrib/less/output.c index a4fdada1ba..e1f2cff12a 100644 --- a/contrib/less/output.c +++ b/contrib/less/output.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -174,6 +173,7 @@ flush() */ p++; anchor = p_next = p; + at = 0; WIN32setcolors(nm_fg_color, nm_bg_color); continue; } @@ -272,20 +272,33 @@ flush() break; if (at & 1) { + /* + * If \e[1m use defined bold + * color, else set intensity. + */ + if (p[-2] == '[') + { +#if MSDOS_COMPILER==WIN32C + fg |= FOREGROUND_INTENSITY; + bg |= BACKGROUND_INTENSITY; +#else fg = bo_fg_color; bg = bo_bg_color; +#endif + } else + fg |= 8; } else if (at & 2) { - fg = so_fg_color; - bg = so_bg_color; + fg = so_fg_color; + bg = so_bg_color; } else if (at & 4) { - fg = ul_fg_color; - bg = ul_bg_color; + fg = ul_fg_color; + bg = ul_bg_color; } else if (at & 8) { - fg = bl_fg_color; - bg = bl_bg_color; + fg = bl_fg_color; + bg = bl_bg_color; } fg &= 0xf; bg &= 0xf; diff --git a/contrib/less/pattern.c b/contrib/less/pattern.c index ca349b6c19..fa26b99379 100644 --- a/contrib/less/pattern.c +++ b/contrib/less/pattern.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ /* @@ -26,75 +25,92 @@ compile_pattern2(pattern, search_type, comp_pattern) int search_type; void **comp_pattern; { - if ((search_type & SRCH_NO_REGEX) == 0) + if (search_type & SRCH_NO_REGEX) + return (0); + { +#if HAVE_GNU_REGEX + struct re_pattern_buffer *comp = (struct re_pattern_buffer *) + ecalloc(1, sizeof(struct re_pattern_buffer)); + struct re_pattern_buffer **pcomp = + (struct re_pattern_buffer **) comp_pattern; + re_set_syntax(RE_SYNTAX_POSIX_EXTENDED); + if (re_compile_pattern(pattern, strlen(pattern), comp)) { + free(comp); + error("Invalid pattern", NULL_PARG); + return (-1); + } + if (*pcomp != NULL) + regfree(*pcomp); + *pcomp = comp; +#endif #if HAVE_POSIX_REGCOMP - regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t)); - regex_t **pcomp = (regex_t **) comp_pattern; - if (regcomp(comp, pattern, REGCOMP_FLAG)) - { - free(comp); - error("Invalid pattern", NULL_PARG); - return (-1); - } - if (*pcomp != NULL) - regfree(*pcomp); - *pcomp = comp; + regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t)); + regex_t **pcomp = (regex_t **) comp_pattern; + if (regcomp(comp, pattern, REGCOMP_FLAG)) + { + free(comp); + error("Invalid pattern", NULL_PARG); + return (-1); + } + if (*pcomp != NULL) + regfree(*pcomp); + *pcomp = comp; #endif #if HAVE_PCRE - pcre *comp; - pcre **pcomp = (pcre **) comp_pattern; - 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); - } - *pcomp = comp; + pcre *comp; + pcre **pcomp = (pcre **) comp_pattern; + constant char *errstring; + int erroffset; + PARG parg; + comp = pcre_compile(pattern, 0, + &errstring, &erroffset, NULL); + if (comp == NULL) + { + parg.p_string = (char *) errstring; + error("%s", &parg); + return (-1); + } + *pcomp = comp; #endif #if HAVE_RE_COMP - PARG parg; - int *pcomp = (int *) comp_pattern; - if ((parg.p_string = re_comp(pattern)) != NULL) - { - error("%s", &parg); - return (-1); - } - *pcomp = 1; + PARG parg; + int *pcomp = (int *) comp_pattern; + if ((parg.p_string = re_comp(pattern)) != NULL) + { + error("%s", &parg); + return (-1); + } + *pcomp = 1; #endif #if HAVE_REGCMP - char *comp; - char **pcomp = (char **) comp_pattern; - if ((comp = regcmp(pattern, 0)) == NULL) - { - error("Invalid pattern", NULL_PARG); - return (-1); - } - if (pcomp != NULL) - free(*pcomp); - *pcomp = comp; + char *comp; + char **pcomp = (char **) comp_pattern; + if ((comp = regcmp(pattern, 0)) == NULL) + { + error("Invalid pattern", NULL_PARG); + return (-1); + } + if (pcomp != NULL) + free(*pcomp); + *pcomp = comp; #endif #if HAVE_V8_REGCOMP - struct regexp *comp; - struct regexp **pcomp = (struct regexp **) comp_pattern; - if ((comp = regcomp(pattern)) == NULL) - { - /* - * regcomp has already printed an error message - * via regerror(). - */ - return (-1); - } - if (*pcomp != NULL) - free(*pcomp); - *pcomp = comp; -#endif + struct regexp *comp; + struct regexp **pcomp = (struct regexp **) comp_pattern; + if ((comp = regcomp(pattern)) == NULL) + { + /* + * regcomp has already printed an error message + * via regerror(). + */ + return (-1); } + if (*pcomp != NULL) + free(*pcomp); + *pcomp = comp; +#endif + } return (0); } @@ -130,6 +146,12 @@ compile_pattern(pattern, search_type, comp_pattern) uncompile_pattern(pattern) void **pattern; { +#if HAVE_GNU_REGEX + struct re_pattern_buffer **pcomp = (struct re_pattern_buffer **) pattern; + if (*pcomp != NULL) + regfree(*pcomp); + *pcomp = NULL; +#endif #if HAVE_POSIX_REGCOMP regex_t **pcomp = (regex_t **) pattern; if (*pcomp != NULL) @@ -167,6 +189,9 @@ uncompile_pattern(pattern) is_null_pattern(pattern) void *pattern; { +#if HAVE_GNU_REGEX + return (pattern == NULL); +#endif #if HAVE_POSIX_REGCOMP return (pattern == NULL); #endif @@ -182,9 +207,6 @@ is_null_pattern(pattern) #if HAVE_V8_REGCOMP return (pattern == NULL); #endif -#if NO_REGEX - return (search_pattern != NULL); -#endif } /* @@ -236,6 +258,9 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) int search_type; { int matched; +#if HAVE_GNU_REGEX + struct re_pattern_buffer *spattern = (struct re_pattern_buffer *) pattern; +#endif #if HAVE_POSIX_REGCOMP regex_t *spattern = (regex_t *) pattern; #endif @@ -252,10 +277,30 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) struct regexp *spattern = (struct regexp *) pattern; #endif +#if NO_REGEX + search_type |= SRCH_NO_REGEX; +#endif if (search_type & SRCH_NO_REGEX) matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep); else { +#if HAVE_GNU_REGEX + { + struct re_registers search_regs; + regoff_t *starts = (regoff_t *) ecalloc(1, sizeof (regoff_t)); + regoff_t *ends = (regoff_t *) ecalloc(1, sizeof (regoff_t)); + spattern->not_bol = notbol; + re_set_registers(spattern, &search_regs, 1, starts, ends); + matched = re_search(spattern, line, line_len, 0, line_len, &search_regs) >= 0; + if (matched) + { + *sp = line + search_regs.start[0]; + *ep = line + search_regs.end[0]; + } + free(starts); + free(ends); + } +#endif #if HAVE_POSIX_REGCOMP { regmatch_t rm; @@ -310,9 +355,6 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) *sp = spattern->startp[0]; *ep = spattern->endp[0]; } -#endif -#if NO_REGEX - matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep); #endif } matched = (!(search_type & SRCH_NO_MATCH) && matched) || diff --git a/contrib/less/pattern.h b/contrib/less/pattern.h index 3b44e2dded..7d05fdeb88 100644 --- a/contrib/less/pattern.h +++ b/contrib/less/pattern.h @@ -1,13 +1,19 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ +#if HAVE_GNU_REGEX +#define __USE_GNU 1 +#include +#define DEFINE_PATTERN(name) struct re_pattern_buffer *name +#define CLEAR_PATTERN(name) name = NULL +#endif + #if HAVE_POSIX_REGCOMP #include #ifdef REG_EXTENDED @@ -46,3 +52,7 @@ extern char *__loc1; #define CLEAR_PATTERN(name) name = NULL #endif +#if NO_REGEX +#define DEFINE_PATTERN(name) +#define CLEAR_PATTERN(name) +#endif diff --git a/contrib/less/pckeys.h b/contrib/less/pckeys.h index 3708d85f43..b673756830 100644 --- a/contrib/less/pckeys.h +++ b/contrib/less/pckeys.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/position.c b/contrib/less/position.c index 8c05c5dd12..b655f077e3 100644 --- a/contrib/less/position.c +++ b/contrib/less/position.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -163,7 +162,7 @@ empty_lines(s, e) register int i; for (i = s; i <= e; i++) - if (table[i] != NULL_POSITION) + if (table[i] != NULL_POSITION && table[i] != 0) return (0); return (1); } diff --git a/contrib/less/position.h b/contrib/less/position.h index 146972ca79..3b96637067 100644 --- a/contrib/less/position.h +++ b/contrib/less/position.h @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/prompt.c b/contrib/less/prompt.c index dce34f3272..f374101cfa 100644 --- a/contrib/less/prompt.c +++ b/contrib/less/prompt.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -393,9 +392,9 @@ protochar(c, where, iseditproto) * where to resume parsing the string. * We must keep track of nested IFs and skip them properly. */ - static char * + static constant char * skipcond(p) - register char *p; + register constant char *p; { register int iflevel; @@ -451,9 +450,9 @@ skipcond(p) /* * Decode a char that represents a position on the screen. */ - static char * + static constant char * wherechar(p, wp) - char *p; + char constant *p; int *wp; { switch (*p) @@ -477,10 +476,10 @@ wherechar(p, wp) */ public char * pr_expand(proto, maxwidth) - char *proto; + constant char *proto; int maxwidth; { - register char *p; + register constant char *p; register int c; int where; diff --git a/contrib/less/screen.c b/contrib/less/screen.c index b8bc66671b..a79eba2c4b 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -802,7 +801,7 @@ scrsize() else if ((n = ltgetnum("li")) > 0) sc_height = n; #endif - else + if (sc_height <= 0) sc_height = DEF_SC_HEIGHT; if (sys_width > 0) @@ -813,7 +812,7 @@ scrsize() else if ((n = ltgetnum("co")) > 0) sc_width = n; #endif - else + if (sc_width <= 0) sc_width = DEF_SC_WIDTH; } diff --git a/contrib/less/search.c b/contrib/less/search.c index 143779ee06..24d4210a01 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -66,6 +65,12 @@ struct pattern_info { char* text; int search_type; }; + +#if NO_REGEX +#define info_compiled(info) ((void*)0) +#else +#define info_compiled(info) ((info)->compiled) +#endif static struct pattern_info search_info; static struct pattern_info filter_info; @@ -98,10 +103,12 @@ set_pattern(info, pattern, search_type) char *pattern; int search_type; { +#if !NO_REGEX if (pattern == NULL) - CLEAR_PATTERN(search_info.compiled); + CLEAR_PATTERN(info->compiled); else if (compile_pattern(pattern, search_type, &info->compiled) < 0) return -1; +#endif /* Pattern compiled successfully; save the text too. */ if (info->text != NULL) free(info->text); @@ -135,7 +142,9 @@ clear_pattern(info) if (info->text != NULL) free(info->text); info->text = NULL; +#if !NO_REGEX uncompile_pattern(&info->compiled); +#endif } /* @@ -191,9 +200,11 @@ get_cvt_ops() prev_pattern(info) struct pattern_info *info; { - if (info->search_type & SRCH_NO_REGEX) - return (info->text != NULL); - return (!is_null_pattern(info->compiled)); +#if !NO_REGEX + if ((info->search_type & SRCH_NO_REGEX) == 0) + return (!is_null_pattern(info->compiled)); +#endif + return (info->text != NULL); } #if HILITE_SEARCH @@ -475,6 +486,47 @@ add_hilite(anchor, hl) ihl->hl_next = hl; } +/* + * Hilight every character in a range of displayed characters. + */ + static void +create_hilites(linepos, start_index, end_index, chpos) + POSITION linepos; + int start_index; + int end_index; + int *chpos; +{ + struct hilite *hl; + int i; + + /* Start the first hilite. */ + hl = (struct hilite *) ecalloc(1, sizeof(struct hilite)); + hl->hl_startpos = linepos + chpos[start_index]; + + /* + * Step through the displayed chars. + * If the source position (before cvt) of the char is one more + * than the source pos of the previous char (the usual case), + * just increase the size of the current hilite by one. + * Otherwise (there are backspaces or something involved), + * finish the current hilite and start a new one. + */ + for (i = start_index+1; i <= end_index; i++) + { + if (chpos[i] != chpos[i-1] + 1 || i == end_index) + { + hl->hl_endpos = linepos + chpos[i-1] + 1; + add_hilite(&hilite_anchor, hl); + /* Start new hilite unless this is the last char. */ + if (i < end_index) + { + hl = (struct hilite *) ecalloc(1, sizeof(struct hilite)); + hl->hl_startpos = linepos + chpos[i]; + } + } + } +} + /* * Make a hilite for each string in a physical line which matches * the current pattern. @@ -492,7 +544,6 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) { char *searchp; char *line_end = line + line_len; - struct hilite *hl; if (sp == NULL || ep == NULL) return; @@ -508,13 +559,7 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) */ searchp = line; do { - if (ep > sp) - { - hl = (struct hilite *) ecalloc(1, sizeof(struct hilite)); - hl->hl_startpos = linepos + chpos[sp-line]; - hl->hl_endpos = linepos + chpos[ep-line]; - add_hilite(&hilite_anchor, hl); - } + create_hilites(linepos, sp-line, ep-line, chpos); /* * If we matched more than zero characters, * move to the first char after the string we matched. @@ -526,7 +571,7 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) searchp++; else /* end of line */ break; - } while (match_pattern(search_info.compiled, search_info.text, + } while (match_pattern(info_compiled(&search_info), search_info.text, searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type)); } #endif @@ -798,7 +843,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) * If so, add an entry to the filter list. */ if ((search_type & SRCH_FIND_ALL) && prev_pattern(&filter_info)) { - int line_filter = match_pattern(filter_info.compiled, filter_info.text, + int line_filter = match_pattern(info_compiled(&filter_info), filter_info.text, cline, line_len, &sp, &ep, 0, filter_info.search_type); if (line_filter) { @@ -818,7 +863,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) */ if (prev_pattern(&search_info)) { - line_match = match_pattern(search_info.compiled, search_info.text, + line_match = match_pattern(info_compiled(&search_info), search_info.text, cline, line_len, &sp, &ep, 0, search_type); if (line_match) { diff --git a/contrib/less/signal.c b/contrib/less/signal.c index 0fbaf7e6fd..7bf5b51919 100644 --- a/contrib/less/signal.c +++ b/contrib/less/signal.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/tags.c b/contrib/less/tags.c index c00f9d488d..51fbb568e4 100644 --- a/contrib/less/tags.c +++ b/contrib/less/tags.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c index 00f2c9e4ad..db6e72e0ba 100644 --- a/contrib/less/ttyin.c +++ b/contrib/less/ttyin.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ diff --git a/contrib/less/version.c b/contrib/less/version.c index dc5bb0c4f2..d3ecd14fd7 100644 --- a/contrib/less/version.c +++ b/contrib/less/version.c @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -343,7 +342,7 @@ v201 7/27/94 Check for no memcpy; add casts to calloc; look for regcmp in libgen.a. (thanks to Kaveh Ghazi). v202 7/28/94 Fix bug in edit_next/edit_prev with - non-existant files. + non-existent files. v203 8/2/94 Fix a variety of configuration bugs on various systems. (thanks to Sakai Kiyotaka, Harald Koenig, Bjorn Brox, @@ -743,6 +742,26 @@ v442 3/2/11 Fix search bug. Add ctrl-G line edit command. v443 4/9/11 Fix Windows build. v444 6/8/11 Fix ungetc bug; remove vestiges of obsolete -l option. +----------------------------------------------------------------- +v445 10/19/11 Fix hilite bug in backwards scroll with -J. + Fix hilite bug with backspaces. + Fix bugs handling SGR sequences in Win32 (thanks to Eric Lee). + Add support for GNU regex (thanks to Reuben Thomas). +v446 5/15/12 Up/down arrows in cmd editing search for matching cmd. +v447 5/21/12 Add ESC-F command, two-pipe LESSOPEN syntax. +v448 6/15/12 Print name of regex library in version message. +v449 6/23/12 Allow config option --with-regex=none. +v450 7/4/12 Fix EOF bug with ESC-F. +v451 7/20/12 Fix typo. +----------------------------------------------------------------- +v452 10/19/12 Fix --with-regex=none, fix "stty 0", fix Win32. + Don't quit if errors in cmd line options. +v453 10/27/12 Increase buffer sizes. +v454 11/5/12 Fix typo. +v455 11/5/12 Fix typo. +v456 11/8/12 Fix option string incompatibility. +v457 12/8/12 Use new option string syntax only after --use-backslash. +v458 4/4/13 Fix display bug in using up/down in cmd buffer. */ -char version[] = "444"; +char version[] = "458";