From 9b76006665e56dffc7210c587bdfa8fad8661f7a Mon Sep 17 00:00:00 2001 From: John Marino Date: Mon, 29 Aug 2016 14:19:49 -0500 Subject: [PATCH] Update less from version 471 to 481 --- contrib/less/COPYING | 0 contrib/less/LICENSE | 2 +- contrib/less/NEWS | 10 +++++++++- contrib/less/brac.c | 2 +- contrib/less/ch.c | 9 ++++++--- contrib/less/charset.c | 9 ++++++--- contrib/less/charset.h | 2 +- contrib/less/cmd.h | 2 +- contrib/less/cmdbuf.c | 5 +++-- contrib/less/command.c | 4 +++- contrib/less/compose.uni | 0 contrib/less/cvt.c | 2 +- contrib/less/decode.c | 2 +- contrib/less/edit.c | 5 +++-- contrib/less/filename.c | 23 ++++++++++++++--------- contrib/less/forwback.c | 14 ++++++++++---- contrib/less/help.c | 1 + contrib/less/ifile.c | 2 +- contrib/less/input.c | 2 +- contrib/less/jump.c | 8 ++++++-- contrib/less/less.h | 2 +- contrib/less/less.nro | 11 ++++++++--- contrib/less/lessecho.c | 2 +- contrib/less/lessecho.nro | 2 +- contrib/less/lesskey.c | 2 +- contrib/less/lesskey.h | 2 +- contrib/less/lesskey.nro | 6 ++++-- contrib/less/lglob.h | 2 +- contrib/less/line.c | 4 ++-- contrib/less/linenum.c | 2 +- contrib/less/lsystem.c | 2 +- contrib/less/main.c | 2 +- contrib/less/mark.c | 2 +- contrib/less/optfunc.c | 4 ++-- contrib/less/option.c | 2 +- contrib/less/option.h | 2 +- contrib/less/opttbl.c | 2 +- contrib/less/os.c | 2 +- contrib/less/output.c | 2 +- contrib/less/pattern.c | 16 ++++++++++++++-- contrib/less/pattern.h | 2 +- contrib/less/pckeys.h | 2 +- contrib/less/position.c | 2 +- contrib/less/position.h | 2 +- contrib/less/prompt.c | 2 +- contrib/less/screen.c | 2 +- contrib/less/search.c | 24 ++++++++++-------------- contrib/less/signal.c | 2 +- contrib/less/tags.c | 2 +- contrib/less/ttyin.c | 2 +- contrib/less/ubin.uni | 0 contrib/less/version.c | 16 ++++++++++++++-- contrib/less/wide.uni | 0 53 files changed, 147 insertions(+), 86 deletions(-) mode change 100755 => 100644 contrib/less/COPYING mode change 100755 => 100644 contrib/less/LICENSE mode change 100755 => 100644 contrib/less/compose.uni mode change 100755 => 100644 contrib/less/ubin.uni mode change 100755 => 100644 contrib/less/wide.uni diff --git a/contrib/less/COPYING b/contrib/less/COPYING old mode 100755 new mode 100644 diff --git a/contrib/less/LICENSE b/contrib/less/LICENSE old mode 100755 new mode 100644 index 3fe715f170..376b8c8bed --- a/contrib/less/LICENSE +++ b/contrib/less/LICENSE @@ -2,7 +2,7 @@ ------------ Less -Copyright (C) 1984-2012 Mark Nudelman +Copyright (C) 1984-2015 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 8e96273b3f..43f1247377 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -11,12 +11,14 @@ ====================================================================== - Major changes between "less" versions 458 and 471 + Major changes between "less" versions 458 and 481 * Don't overwrite history file; just append to it. * New command ESC-G goes to end of currently buffered data in a pipe. +* Disable history feature when compiled with LESSHISTFILE set to "-". + * In more-compatible mode, make the -p option apply to every file opened, not just the first one. @@ -34,10 +36,16 @@ * Fix bug with ++ commands. +* Fix bug where prompt was sometimes not displayed with +G. + +* Fix possible memory corruption + * Fix bugs and improve performance in ampersand filtering. * Automate construction of Unicode tables from Unicode database. +* Allow %% escape sequence in LESSOPEN variable. + ====================================================================== Major changes between "less" versions 451 and 458 diff --git a/contrib/less/brac.c b/contrib/less/brac.c index 7a1ee83a2d..10a0843caa 100644 --- a/contrib/less/brac.c +++ b/contrib/less/brac.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/ch.c b/contrib/less/ch.c index 4c9eccbb3d..da729c5dec 100644 --- a/contrib/less/ch.c +++ b/contrib/less/ch.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -323,13 +323,16 @@ ch_get() #if HAVE_STAT_INO if (follow_mode == FOLLOW_NAME) { - /* See whether the file's i-number has changed. + /* See whether the file's i-number has changed, + * or the file has shrunk. * If so, force the file to be closed and * reopened. */ struct stat st; + POSITION curr_pos = ch_tell(); int r = stat(get_filename(curr_ifile), &st); if (r == 0 && (st.st_ino != curr_ino || - st.st_dev != curr_dev)) + st.st_dev != curr_dev || + (curr_pos != NULL_POSITION && st.st_size < curr_pos))) { /* screen_trashed=2 causes * make_display to reopen the file. */ diff --git a/contrib/less/charset.c b/contrib/less/charset.c index e5035900f6..4c62664e73 100644 --- a/contrib/less/charset.c +++ b/contrib/less/charset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -506,8 +506,9 @@ utf_len(ch) * Does the parameter point to the lead byte of a well-formed UTF-8 character? */ public int -is_utf8_well_formed(s) +is_utf8_well_formed(s, slen) unsigned char *s; + int slen; { int i; int len; @@ -516,6 +517,8 @@ is_utf8_well_formed(s) return (0); len = utf_len((char) s[0]); + if (len > slen) + return (0); if (len == 1) return (1); if (len == 2) @@ -547,7 +550,7 @@ utf_bin_count(data, len) int bin_count = 0; while (len > 0) { - if (is_utf8_well_formed(data)) + if (is_utf8_well_formed(data, len)) { int clen = utf_len(*data); data += clen; diff --git a/contrib/less/charset.h b/contrib/less/charset.h index af27be67e8..bb1e4376cb 100644 --- a/contrib/less/charset.h +++ b/contrib/less/charset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/cmd.h b/contrib/less/cmd.h index 44fdab1d81..8a943d1522 100644 --- a/contrib/less/cmd.h +++ b/contrib/less/cmd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c index 0407ec7e0f..69d7414e97 100644 --- a/contrib/less/cmdbuf.c +++ b/contrib/less/cmdbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -1264,7 +1264,7 @@ cmd_char(c) cmd_mbc_buf[cmd_mbc_buf_index++] = c; if (cmd_mbc_buf_index < cmd_mbc_buf_len) return (CC_OK); - if (!is_utf8_well_formed(cmd_mbc_buf)) + if (!is_utf8_well_formed(cmd_mbc_buf, cmd_mbc_buf_index)) { /* complete, but not well formed (non-shortest form), sequence */ cmd_mbc_buf_len = 0; @@ -1484,6 +1484,7 @@ read_cmdhist(action, uparam, skip_search, skip_shell) void (*action)(void*,struct mlist*,char*); void *uparam; int skip_search; + int skip_shell; { read_cmdhist2(action, uparam, skip_search, skip_shell); (*action)(uparam, NULL, NULL); /* signal end of file */ diff --git a/contrib/less/command.c b/contrib/less/command.c index 89a390eba9..c31fa81a32 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -161,6 +161,7 @@ mca_search() cmd_putstr("/"); else cmd_putstr("?"); + forw_prompt = 0; set_mlist(ml_search, 0); } @@ -195,6 +196,7 @@ mca_opt_toggle() cmd_putstr("!"); break; } + forw_prompt = 0; set_mlist(NULL, 0); } diff --git a/contrib/less/compose.uni b/contrib/less/compose.uni old mode 100755 new mode 100644 diff --git a/contrib/less/cvt.c b/contrib/less/cvt.c index aa9b7a6bfd..d9836418e1 100644 --- a/contrib/less/cvt.c +++ b/contrib/less/cvt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/decode.c b/contrib/less/decode.c index c44b464078..1cd1599731 100644 --- a/contrib/less/decode.c +++ b/contrib/less/decode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/edit.c b/contrib/less/edit.c index dd4574bb36..2a35adec48 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -436,7 +436,8 @@ edit_ifile(ifile) #if HILITE_SEARCH clr_hilite(); #endif - cmd_addhist(ml_examine, filename, 1); + if (strcmp(filename, FAKE_HELPFILE) && strcmp(filename, FAKE_EMPTYFILE)) + cmd_addhist(ml_examine, filename, 1); if (no_display && errmsgs > 0) { /* diff --git a/contrib/less/filename.c b/contrib/less/filename.c index 290ba232e5..9631f1c2b3 100644 --- a/contrib/less/filename.c +++ b/contrib/less/filename.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -821,15 +821,20 @@ lglob(filename) num_pct_s(lessopen) char *lessopen; { - int num; + int num = 0; - for (num = 0;; num++) + while (*lessopen != '\0') { - lessopen = strchr(lessopen, '%'); - if (lessopen == NULL) - break; - if (*++lessopen != 's') - return (999); + if (*lessopen == '%') + { + if (lessopen[1] == '%') + ++lessopen; + else if (lessopen[1] == 's') + ++num; + else + return (999); + } + ++lessopen; } return (num); } @@ -979,7 +984,7 @@ close_altfile(altfilename, filename, pipefd) return; if (num_pct_s(lessclose) > 2) { - error("Invalid LESSCLOSE variable"); + error("Invalid LESSCLOSE variable", NULL_PARG); return; } len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2); diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c index cc8838ba01..721a0286a7 100644 --- a/contrib/less/forwback.c +++ b/contrib/less/forwback.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -35,6 +35,8 @@ extern int final_attr; extern int oldbot; #if HILITE_SEARCH extern int size_linebuf; +extern int hilite_search; +extern int status_col; #endif #if TAGS extern char *tagoption; @@ -147,8 +149,10 @@ forw(n, pos, force, only_last, nblank) (forw_scroll >= 0 && n > forw_scroll && n != sc_height-1); #if HILITE_SEARCH - prep_hilite(pos, pos + 3*size_linebuf, ignore_eoi ? 1 : -1); - pos = next_unfiltered(pos); + if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) { + prep_hilite(pos, pos + 4*size_linebuf, ignore_eoi ? 1 : -1); + pos = next_unfiltered(pos); + } #endif if (!do_repaint) @@ -305,7 +309,9 @@ back(n, pos, force, only_last) squish_check(); do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1)); #if HILITE_SEARCH - prep_hilite((pos < 3*size_linebuf) ? 0 : pos - 3*size_linebuf, pos, -1); + if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) { + prep_hilite((pos < 3*size_linebuf) ? 0 : pos - 3*size_linebuf, pos, -1); + } #endif while (--n >= 0) { diff --git a/contrib/less/help.c b/contrib/less/help.c index 7c7fb4f678..aba711677f 100644 --- a/contrib/less/help.c +++ b/contrib/less/help.c @@ -26,6 +26,7 @@ constant char helpdata[] = { ' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', ' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', ' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n', +' ',' ','E','S','C','-','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','i','k','e',' ','F',' ','b','u','t',' ','s','t','o','p',' ','w','h','e','n',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','i','s',' ','f','o','u','n','d','.','\n', ' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n', ' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', diff --git a/contrib/less/ifile.c b/contrib/less/ifile.c index 13c612dc5a..fea2ea1ea9 100644 --- a/contrib/less/ifile.c +++ b/contrib/less/ifile.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/input.c b/contrib/less/input.c index db6c1ff054..9419a02711 100644 --- a/contrib/less/input.c +++ b/contrib/less/input.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/jump.c b/contrib/less/jump.c index d7468fe418..8373d8b549 100644 --- a/contrib/less/jump.c +++ b/contrib/less/jump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -66,12 +66,16 @@ jump_forw() public void jump_forw_buffered() { + POSITION end; + if (ch_end_buffer_seek()) { error("Cannot seek to end of buffers", NULL_PARG); return; } - jump_line_loc(ch_tell(), sc_height-1); + end = ch_tell(); + if (end != NULL_POSITION && end > 0) + jump_line_loc(end-1, sc_height-1); } /* diff --git a/contrib/less/less.h b/contrib/less/less.h index 4f5590eecb..f57fb1ecf0 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/less.nro b/contrib/less/less.nro index 9789eafa49..b3d98746aa 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 471: 14 Dec 2014" +.TH LESS 1 "Version 481: 31 Aug 2015" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -85,6 +85,10 @@ Warning: some systems use ^Y as a special job control character. Scroll backward N lines, default one half of the screen size. If N is specified, it becomes the new default for subsequent d and u commands. +.IP "J" +Like j, but continues to scroll beyond the end of the file. +.IP "K or Y" +Like k, but continues to scroll beyond the beginning of the file. .IP "ESC-) or RIGHTARROW" Scroll horizontally right N characters, default half the screen width (see the \-# option). @@ -213,7 +217,8 @@ that is, do a simple textual comparison. .RE .IP ?pattern Search backward in the file for the N-th line containing the pattern. -The search starts at the line immediately before the top line displayed. +The search starts at the last line displayed +(but see the \-a and \-j options, which change this). .sp Certain characters are special as in the / command: .RS @@ -1735,7 +1740,7 @@ The name of the editor (used for the v command). lesskey(1) .SH COPYRIGHT -Copyright (C) 1984-2014 Mark Nudelman +Copyright (C) 1984-2015 Mark Nudelman .PP less is part of the GNU project and is free software. You can redistribute it and/or modify it diff --git a/contrib/less/lessecho.c b/contrib/less/lessecho.c index 99121294f9..fb0b22ddc0 100644 --- a/contrib/less/lessecho.c +++ b/contrib/less/lessecho.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index 02abfab25e..78b893f18d 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 471: 14 Dec 2014" +.TH LESSECHO 1 "Version 481: 31 Aug 2015" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/contrib/less/lesskey.c b/contrib/less/lesskey.c index d91b9b73c8..298748b9a0 100644 --- a/contrib/less/lesskey.c +++ b/contrib/less/lesskey.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/lesskey.h b/contrib/less/lesskey.h index 7b31de306f..34b8c1758c 100644 --- a/contrib/less/lesskey.h +++ b/contrib/less/lesskey.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/lesskey.nro b/contrib/less/lesskey.nro index 4ef416e9c1..826332de5e 100644 --- a/contrib/less/lesskey.nro +++ b/contrib/less/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 471: 14 Dec 2014" +.TH LESSKEY 1 "Version 481: 31 Aug 2015" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS @@ -178,6 +178,8 @@ default command keys used by less: \ee] right-scroll \ee( left-scroll \ee) right-scroll + \ekl left-scroll + \ekr right-scroll { forw-bracket {} } back-bracket {} ( forw-bracket () @@ -357,7 +359,7 @@ which start with a NUL character (0). This NUL character should be represented as \e340 in a lesskey file. .SH COPYRIGHT -Copyright (C) 1984-2014 Mark Nudelman +Copyright (C) 1984-2015 Mark Nudelman .PP less is part of the GNU project and is free software. You can redistribute it and/or modify it diff --git a/contrib/less/lglob.h b/contrib/less/lglob.h index 0585371b5c..87b5fb45cc 100644 --- a/contrib/less/lglob.h +++ b/contrib/less/lglob.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/line.c b/contrib/less/line.c index 89495a382c..e54835d474 100644 --- a/contrib/less/line.c +++ b/contrib/less/line.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -807,7 +807,7 @@ pappend(c, pos) mbc_buf[mbc_buf_index++] = c; if (mbc_buf_index < mbc_buf_len) return (0); - if (is_utf8_well_formed(mbc_buf)) + if (is_utf8_well_formed(mbc_buf, mbc_buf_index)) r = do_append(get_wchar(mbc_buf), mbc_buf, mbc_pos); else /* Complete, but not shortest form, sequence. */ diff --git a/contrib/less/linenum.c b/contrib/less/linenum.c index 6cd9ff2ae6..6d078ec869 100644 --- a/contrib/less/linenum.c +++ b/contrib/less/linenum.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/lsystem.c b/contrib/less/lsystem.c index c87ea26e0e..8a7cb8f2a9 100644 --- a/contrib/less/lsystem.c +++ b/contrib/less/lsystem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/main.c b/contrib/less/main.c index 8a85712c9c..149999cd4b 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/mark.c b/contrib/less/mark.c index e2f0cae0c4..44d606fc9d 100644 --- a/contrib/less/mark.c +++ b/contrib/less/mark.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/optfunc.c b/contrib/less/optfunc.c index b5bad66cd2..c3bb6b2d9e 100644 --- a/contrib/less/optfunc.c +++ b/contrib/less/optfunc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -517,7 +517,7 @@ opt__V(type, s) putstr("no "); #endif putstr("regular expressions)\n"); - putstr("Copyright (C) 1984-2014 Mark Nudelman\n\n"); + putstr("Copyright (C) 1984-2015 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 101b6a02e0..256f5697b6 100644 --- a/contrib/less/option.c +++ b/contrib/less/option.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/option.h b/contrib/less/option.h index dd3d906889..dc97d75f77 100644 --- a/contrib/less/option.h +++ b/contrib/less/option.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/opttbl.c b/contrib/less/opttbl.c index c37edb410f..b896391aa3 100644 --- a/contrib/less/opttbl.c +++ b/contrib/less/opttbl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/os.c b/contrib/less/os.c index f1eec4e92b..530abe19d4 100644 --- a/contrib/less/os.c +++ b/contrib/less/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/output.c b/contrib/less/output.c index a8cdecedb9..d6cfc38267 100644 --- a/contrib/less/output.c +++ b/contrib/less/output.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/pattern.c b/contrib/less/pattern.c index a0f556db0a..71141c7d05 100644 --- a/contrib/less/pattern.c +++ b/contrib/less/pattern.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -234,6 +234,9 @@ is_null_pattern(pattern) #if HAVE_V8_REGCOMP return (pattern == NULL); #endif +#if NO_REGEX + return (pattern == NULL); +#endif } /* @@ -254,9 +257,17 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend) for ( ; buf < buf_end; buf++) { - for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++) + for (pp = pattern, lp = buf; ; pp++, lp++) + { + char cp = *pp; + char cl = *lp; + if (caseless == OPT_ONPLUS && ASCII_IS_UPPER(cp)) + cp = ASCII_TO_LOWER(cp); + if (cp != cl) + break; if (pp == pattern_end || lp == buf_end) break; + } if (pp == pattern_end) { if (pfound != NULL) @@ -304,6 +315,7 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) struct regexp *spattern = (struct regexp *) pattern; #endif + *sp = *ep = NULL; #if NO_REGEX search_type |= SRCH_NO_REGEX; #endif diff --git a/contrib/less/pattern.h b/contrib/less/pattern.h index 0461e43ed3..ca4b8648c6 100644 --- a/contrib/less/pattern.h +++ b/contrib/less/pattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/pckeys.h b/contrib/less/pckeys.h index c5456f69c1..8fb6800902 100644 --- a/contrib/less/pckeys.h +++ b/contrib/less/pckeys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/position.c b/contrib/less/position.c index b9402abd0a..dc80fd6361 100644 --- a/contrib/less/position.c +++ b/contrib/less/position.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/position.h b/contrib/less/position.h index 1322fd6c52..e0e2bff490 100644 --- a/contrib/less/position.h +++ b/contrib/less/position.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/prompt.c b/contrib/less/prompt.c index e86c687b40..50ced97bf7 100644 --- a/contrib/less/prompt.c +++ b/contrib/less/prompt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/screen.c b/contrib/less/screen.c index 73308f346d..8f8a433aff 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/search.c b/contrib/less/search.c index c1aa6a9c06..e824acb4a3 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -74,7 +74,6 @@ struct hilite_node struct hilite_node *prev; struct hilite_node *next; int red; - struct hilite r; }; struct hilite_storage @@ -82,13 +81,13 @@ struct hilite_storage int capacity; int used; struct hilite_storage *next; + struct hilite_node *nodes; }; struct hilite_tree { struct hilite_storage *first; struct hilite_storage *current; struct hilite_node *root; - struct hilite_node *lookaside; }; #define HILITE_INITIALIZER() { NULL, NULL, NULL, NULL } @@ -373,6 +372,7 @@ clr_hlist(anchor) for (hls = anchor->first; hls != NULL; hls = nexthls) { nexthls = hls->next; + free((void*)hls->nodes); free((void*)hls); } anchor->first = NULL; @@ -651,7 +651,6 @@ hlist_getstorage(anchor) struct hilite_tree *anchor; { int capacity = 1; - int allocsize = sizeof(struct hilite_storage); struct hilite_storage *s; if (anchor->current) @@ -660,8 +659,9 @@ hlist_getstorage(anchor) return anchor->current; capacity = anchor->current->capacity * 2; } - allocsize += capacity * sizeof(struct hilite_node); - s = ecalloc(1, allocsize); + + s = (struct hilite_storage *) ecalloc(1, sizeof(struct hilite_storage)); + s->nodes = (struct hilite_node *) ecalloc(capacity, sizeof(struct hilite_node)); s->capacity = capacity; s->used = 0; s->next = NULL; @@ -682,10 +682,7 @@ hlist_getnode(anchor) struct hilite_tree *anchor; { struct hilite_storage *s = hlist_getstorage(anchor); - - struct hilite_node *n = ((struct hilite_node*)(s+1))+s->used; - s->used++; - return n; + return &s->nodes[s->used++]; } /* @@ -987,8 +984,6 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) char *searchp; char *line_end = line + line_len; - if (sp == NULL || ep == NULL) - return; /* * sp and ep delimit the first match in the line. * Mark the corresponding file positions, then @@ -1001,6 +996,8 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) */ searchp = line; do { + if (sp == NULL || ep == NULL) + return; create_hilites(linepos, sp-line, ep-line, chpos); /* * If we matched more than zero characters, @@ -1136,11 +1133,10 @@ search_pos(search_type) * It starts at the jump target (if searching backwards), * or at the jump target plus one (if forwards). */ - linenum = jump_sline; + linenum = adjsline(jump_sline); if (search_type & SRCH_FORW) add_one = 1; } - linenum = adjsline(linenum); pos = position(linenum); if (add_one) pos = forw_raw_line(pos, (char **)NULL, (int *)NULL); diff --git a/contrib/less/signal.c b/contrib/less/signal.c index 194a2bb071..37a9793be4 100644 --- a/contrib/less/signal.c +++ b/contrib/less/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/tags.c b/contrib/less/tags.c index 997bf1d1a4..5acf3747b7 100644 --- a/contrib/less/tags.c +++ b/contrib/less/tags.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c index 17e927e1bd..129eea158b 100644 --- a/contrib/less/ttyin.c +++ b/contrib/less/ttyin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. diff --git a/contrib/less/ubin.uni b/contrib/less/ubin.uni old mode 100755 new mode 100644 diff --git a/contrib/less/version.c b/contrib/less/version.c index 4fd2078672..87b0b42bc8 100644 --- a/contrib/less/version.c +++ b/contrib/less/version.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2014 Mark Nudelman + * Copyright (C) 1984-2015 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. @@ -779,6 +779,18 @@ v469 10/2/14 Allow extra string in command to append to a multichar v470 10/5/14 Fix some compiler warnings. v471 12/14/14 Fix unget issues with prompt. Allow disabling history when compiled value of LESSHISTFILE = "-". +v473 12/19/14 Fix prompt bug with stdin and -^P in lesskey extra string. +v474 1/30/15 Fix bug in backwards search with match on bottom line. + Make follow mode reopen file if file shrinks. +v475 3/2/15 Fix possible buffer overrun with invalid UTF-8; + fix bug when compiled with no regex; fix non-match search. +v476 5/3/15 Update man pages. +v477 5/19/15 Fix off-by-one in jump_forw_buffered; + don't add FAKE_* files to cmd history. +v478 5/21/15 Fix nonportable pointer usage in hilite tree. +v479 7/6/15 Allow %% escapes in LESSOPEN variable. +v480 7/24/15 Fix bug in no-regex searches; support MSVC v1900. +v481 8/20/15 Fix broken -g option. */ -char version[] = "471"; +char version[] = "481"; diff --git a/contrib/less/wide.uni b/contrib/less/wide.uni old mode 100755 new mode 100644 -- 2.11.4.GIT