Commit 6aa86b45 authored by Xin LI's avatar Xin LI
Browse files

Vendor import of less v551.

parent b04073e3
......@@ -2,7 +2,7 @@
------------
Less
Copyright (C) 1984-2016 Mark Nudelman
Copyright (C) 1984-2018 Mark Nudelman
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......
......@@ -112,6 +112,13 @@ ubin.uni: unicode/UnicodeData.txt
wide.uni: unicode/EastAsianWidth.txt
./mkutable -f1 W F -- unicode/EastAsianWidth.txt > $@
unicode/UnicodeData.txt:
mkdir -p unicode
curl -s -o $@ ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
unicode/EastAsianWidth.txt:
mkdir -p unicode
curl -s -o $@ ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
distfiles: ${DISTFILES}
dist: ${DISTFILES}
......@@ -137,4 +144,4 @@ dist: ${DISTFILES}
tagall:
@REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/v\1/' -e q ${srcdir}/version.c`; \
echo "tagging $$REL"; \
$(GIT) tag -f "$$REL"
$(GIT) tag -a -f -m "$$REL" "$$REL"
......@@ -9,6 +9,38 @@
To report bugs, suggestions or comments, send email to bug-less@gnu.org
======================================================================
Major changes between "less" versions 530 and 551
* Add --mouse option.
* Add --wheel-lines option.
* Add --no-histdups option.
* Add --save-marks option.
* Support PCRE2 regular expression library.
* Redraw screen on SIGWINCH even if screen size doesn't change.
* Shell-escape filenames in history so they can be used again.
* Ring bell if user enters invalid long option name.
* Use PCRE_UTF8 flag for pcre regular expressions when in UTF-8 mode.
* Windows: use wide-char string to set console title.
* Don't count lines in initial screen if using -X with -F.
* Support mingw build system.
* Fix bug in v command on empty file.
* Fix bug in v command when filename contains shell metacharacters.
======================================================================
Major changes between "less" versions 487 and 530
......
Less, version 530
Less, version 551
This is the distribution of less, version 530, released 05 Dec 2017.
This is the distribution of less, version 551, released 11 Jun 2019.
This program is part of the GNU project (http://www.gnu.org).
This program is free software. You may redistribute it and/or
......@@ -48,6 +48,7 @@ INSTALLATION (Unix systems only):
finds a regular expression library automatically. Other values are:
gnu Use the GNU regex library.
pcre Use the PCRE library.
pcre2 Use the PCRE2 library.
posix Use the POSIX-compatible regcomp.
regcmp Use the regcmp library.
re_comp Use the re_comp library.
......@@ -55,6 +56,7 @@ INSTALLATION (Unix systems only):
regcomp-local Use Henry Spencer's V8-compatible regcomp
(source is supplied with less).
none No regular expressions, only simple string matching.
--with-secure
Builds a "secure" version of less, with some features disabled
to prevent users from viewing other files, accessing shell
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......@@ -144,7 +144,7 @@ static int ch_addbuf();
* Get the character pointed to by the read pointer.
*/
int
ch_get()
ch_get(VOID_PARAM)
{
struct buf *bp;
struct bufnode *bn;
......@@ -392,7 +392,7 @@ ch_ungetchar(c)
* If we haven't read all of standard input into it, do that now.
*/
public void
end_logfile()
end_logfile(VOID_PARAM)
{
static int tried = FALSE;
......@@ -417,7 +417,7 @@ end_logfile()
* Write all the existing buffered data to the log file.
*/
public void
sync_logfile()
sync_logfile(VOID_PARAM)
{
struct buf *bp;
struct bufnode *bn;
......@@ -515,7 +515,7 @@ ch_seek(pos)
* Seek to the end of the file.
*/
public int
ch_end_seek()
ch_end_seek(VOID_PARAM)
{
POSITION len;
......@@ -542,7 +542,7 @@ ch_end_seek()
* Seek to the last position in the file that is currently buffered.
*/
public int
ch_end_buffer_seek()
ch_end_buffer_seek(VOID_PARAM)
{
struct buf *bp;
struct bufnode *bn;
......@@ -570,7 +570,7 @@ ch_end_buffer_seek()
* beginning of the pipe is no longer buffered.
*/
public int
ch_beg_seek()
ch_beg_seek(VOID_PARAM)
{
struct bufnode *bn;
struct bufnode *firstbn;
......@@ -602,7 +602,7 @@ ch_beg_seek()
* Return the length of the file, if known.
*/
public POSITION
ch_length()
ch_length(VOID_PARAM)
{
if (thisfile == NULL)
return (NULL_POSITION);
......@@ -619,7 +619,7 @@ ch_length()
* Return the current position in the file.
*/
public POSITION
ch_tell()
ch_tell(VOID_PARAM)
{
if (thisfile == NULL)
return (NULL_POSITION);
......@@ -630,7 +630,7 @@ ch_tell()
* Get the current char and post-increment the read pointer.
*/
public int
ch_forw_get()
ch_forw_get(VOID_PARAM)
{
int c;
......@@ -653,7 +653,7 @@ ch_forw_get()
* Pre-decrement the read pointer and get the new current char.
*/
public int
ch_back_get()
ch_back_get(VOID_PARAM)
{
if (thisfile == NULL)
return (EOI);
......@@ -693,7 +693,7 @@ ch_setbufspace(bufspace)
* Flush (discard) any saved file state, including buffer contents.
*/
public void
ch_flush()
ch_flush(VOID_PARAM)
{
struct bufnode *bn;
......@@ -760,7 +760,7 @@ ch_flush()
* The buffer is added to the tail of the buffer chain.
*/
static int
ch_addbuf()
ch_addbuf(VOID_PARAM)
{
struct buf *bp;
struct bufnode *bn;
......@@ -785,7 +785,7 @@ ch_addbuf()
*
*/
static void
init_hashtbl()
init_hashtbl(VOID_PARAM)
{
int h;
......@@ -800,7 +800,7 @@ init_hashtbl()
* Delete all buffers for this file.
*/
static void
ch_delbufs()
ch_delbufs(VOID_PARAM)
{
struct bufnode *bn;
......@@ -840,7 +840,7 @@ seekable(f)
* This is used after an ignore_eof read, during which the EOF may change.
*/
public void
ch_set_eof()
ch_set_eof(VOID_PARAM)
{
ch_fsize = ch_fpos;
}
......@@ -890,7 +890,7 @@ ch_init(f, flags)
* Close a filestate.
*/
public void
ch_close()
ch_close(VOID_PARAM)
{
int keepstate = FALSE;
......@@ -933,7 +933,7 @@ ch_close()
* Return ch_flags for the current file.
*/
public int
ch_getflags()
ch_getflags(VOID_PARAM)
{
if (thisfile == NULL)
return (0);
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......@@ -245,7 +245,7 @@ icharset(name, no_error)
* Define a charset, given a locale name.
*/
static void
ilocale()
ilocale(VOID_PARAM)
{
int c;
......@@ -315,7 +315,7 @@ setfmt(s, fmtvarptr, attrptr, default_fmt)
*
*/
static void
set_charset()
set_charset(VOID_PARAM)
{
char *s;
......@@ -338,7 +338,7 @@ set_charset()
* LESSCHARSET is not defined: try LESSCHARDEF.
*/
s = lgetenv("LESSCHARDEF");
if (s != NULL && *s != '\0')
if (!isnullenv(s))
{
ichardef(s);
return;
......@@ -395,7 +395,7 @@ set_charset()
* Initialize charset data structures.
*/
public void
init_charset()
init_charset(VOID_PARAM)
{
char *s;
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......@@ -71,6 +71,13 @@
#define A_RRSHIFT 59
#define A_CLRMARK 62
#define A_SETMARKBOT 63
#define A_X11MOUSE_IN 64
#define A_X11MOUSE_IGNORE 65
#define A_F_MOUSE 66
#define A_B_MOUSE 67
/* Note "X116" refers to extended (1006) X11 mouse reporting. */
#define A_X116MOUSE_IN 68
#define A_X116MOUSE_IGNORE 69
#define A_INVALID 100
#define A_NOACTION 101
......
/*
* Copyright (C) 1984-2017 Mark Nudelman
* Copyright (C) 1984-2019 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.
......@@ -22,6 +22,8 @@
extern int sc_width;
extern int utf_mode;
extern int no_hist_dups;
extern int marks_modified;
static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
static int cmd_col; /* Current column of the cursor */
......@@ -58,6 +60,7 @@ public char closequote = '"';
#define HISTFILE_FIRST_LINE ".less-history-file:"
#define HISTFILE_SEARCH_SECTION ".search"
#define HISTFILE_SHELL_SECTION ".shell"
#define HISTFILE_MARK_SECTION ".mark"
/*
* A mlist structure represents a command history.
......@@ -114,7 +117,7 @@ static int cmd_mbc_buf_index;
* Reset command buffer (to empty).
*/
public void
cmd_reset()
cmd_reset(VOID_PARAM)
{
cp = cmdbuf;
*cp = '\0';
......@@ -129,7 +132,7 @@ cmd_reset()
* Clear command line.
*/
public void
clear_cmd()
clear_cmd(VOID_PARAM)
{
cmd_col = prompt_col = 0;
cmd_mbc_buf_len = 0;
......@@ -169,7 +172,7 @@ cmd_putstr(s)
* How many characters are in the command buffer?
*/
public int
len_cmdbuf()
len_cmdbuf(VOID_PARAM)
{
char *s = cmdbuf;
char *endline = s + strlen(s);
......@@ -302,7 +305,7 @@ cmd_repaint(old_cp)
* and set cp to the corresponding char in cmdbuf.
*/
static void
cmd_home()
cmd_home(VOID_PARAM)
{
while (cmd_col > prompt_col)
{
......@@ -321,7 +324,7 @@ cmd_home()
* Shift the cmdbuf display left a half-screen.
*/
static void
cmd_lshift()
cmd_lshift(VOID_PARAM)
{
char *s;
char *save_cp;
......@@ -359,7 +362,7 @@ cmd_lshift()
* Shift the cmdbuf display right a half-screen.
*/
static void
cmd_rshift()
cmd_rshift(VOID_PARAM)
{
char *s;
char *save_cp;
......@@ -389,7 +392,7 @@ cmd_rshift()
* Move cursor right one character.
*/
static int
cmd_right()
cmd_right(VOID_PARAM)
{
char *pr;
char *ncp;
......@@ -424,7 +427,7 @@ cmd_right()
* Move cursor left one character.
*/
static int
cmd_left()
cmd_left(VOID_PARAM)
{
char *ncp;
int width = 0;
......@@ -492,7 +495,7 @@ cmd_ichar(cs, clen)
* Delete the char to the left of the cursor.
*/
static int
cmd_erase()
cmd_erase(VOID_PARAM)
{
char *s;
int clen;
......@@ -541,7 +544,7 @@ cmd_erase()
* Delete the char under the cursor.
*/
static int
cmd_delete()
cmd_delete(VOID_PARAM)
{
if (*cp == '\0')
{
......@@ -560,7 +563,7 @@ cmd_delete()
* Delete the "word" to the left of the cursor.
*/
static int
cmd_werase()
cmd_werase(VOID_PARAM)
{
if (cp > cmdbuf && cp[-1] == ' ')
{
......@@ -586,7 +589,7 @@ cmd_werase()
* Delete the "word" under the cursor.
*/
static int
cmd_wdelete()
cmd_wdelete(VOID_PARAM)
{
if (*cp == ' ')
{
......@@ -612,7 +615,7 @@ cmd_wdelete()
* Delete all chars in the command buffer.
*/
static int
cmd_kill()
cmd_kill(VOID_PARAM)
{
if (cmdbuf[0] == '\0')
{
......@@ -702,6 +705,7 @@ cmd_updown(action)
s = ml->string;
if (s == NULL)
s = "";
cmd_offset = 0;
cmd_home();
clear_eol();
strcpy(cmdbuf, s);
......@@ -718,6 +722,31 @@ cmd_updown(action)
}
#endif
/*
*
*/
static void
ml_link(mlist, ml)
struct mlist *mlist;
struct mlist *ml;
{
ml->next = mlist;
ml->prev = mlist->prev;
mlist->prev->next = ml;
mlist->prev = ml;
}
/*
*
*/
static void
ml_unlink(ml)
struct mlist *ml;
{
ml->prev->next = ml->next;
ml->next->prev = ml->prev;
}
/*
* Add a string to an mlist.
*/
......@@ -736,6 +765,21 @@ cmd_addhist(mlist, cmd, modified)
if (strlen(cmd) == 0)
return;
if (no_hist_dups)
{
struct mlist *next = NULL;
for (ml = mlist->next; ml->string != NULL; ml = next)
{
next = ml->next;
if (strcmp(ml->string, cmd) == 0)
{
ml_unlink(ml);
free(ml->string);
free(ml);
}
}
}
/*
* Save the command unless it's a duplicate of the
* last command in the history.
......@@ -750,10 +794,7 @@ cmd_addhist(mlist, cmd, modified)
ml = (struct mlist *) ecalloc(1, sizeof(struct mlist));
ml->string = save(cmd);
ml->modified = modified;
ml->next = mlist;
ml->prev = mlist->prev;
mlist->prev->next = ml;
mlist->prev = ml;
ml_link(mlist, ml);
}
/*
* Point to the cmd just after the just-accepted command.
......@@ -768,13 +809,13 @@ cmd_addhist(mlist, cmd, modified)
* Add it to the currently selected history list.
*/
public void
cmd_accept()
cmd_accept(VOID_PARAM)
{
#if CMD_HISTORY
/*
* Nothing to do if there is no currently selected history list.
*/
if (curr_mlist == NULL)
if (curr_mlist == NULL || curr_mlist == ml_examine)
return;
cmd_addhist(curr_mlist, cmdbuf, 1);
curr_mlist->modified = 1;
......@@ -799,7 +840,7 @@ cmd_edit(c)
#if TAB_COMPLETE_FILENAME
#define not_in_completion() in_completion = 0
#else
#define not_in_completion()
#define not_in_completion(VOID_PARAM)
#endif
/*
......@@ -934,7 +975,7 @@ cmd_istr(str)
* cursor at the end of the word.
*/
static char *
delimit_word()
delimit_word(VOID_PARAM)
{
char *word;
#if SPACES_IN_FILENAMES
......@@ -1021,7 +1062,7 @@ delimit_word()
* which start with that word, and set tk_text to that list.
*/
static void
init_compl()
init_compl(VOID_PARAM)
{
char *word;
char c;
......@@ -1148,9 +1189,9 @@ cmd_complete(action)
tk_trial = next_compl(action, tk_trial);
}
/*
* Remove the original word, or the previous trial completion.
*/
/*
* Remove the original word, or the previous trial completion.
*/
while (cp > tk_ipoint)
(void) cmd_erase();
......@@ -1323,7 +1364,7 @@ cmd_int(frac)
* Return a pointer to the command buffer.
*/
public char *
get_cmdbuf()
get_cmdbuf(VOID_PARAM)
{
return (cmdbuf);
}
......@@ -1333,7 +1374,7 @@ get_cmdbuf()
* Return the last (most recent) string in the current command history.
*/
public char *
cmd_lastpattern()
cmd_lastpattern(VOID_PARAM)
{
if (curr_mlist == NULL)
return (NULL);
......@@ -1358,7 +1399,7 @@ mlist_size(ml)
* Get the name of the history file.
*/
static char *
histfile_name()
histfile_name(VOID_PARAM)
{
char *home;
char *name;
......@@ -1366,7 +1407,7 @@ histfile_name()
/* See if filename is explicitly specified by $LESSHISTFILE. */
name = lgetenv("LESSHISTFILE");
if (name != NULL && *name != '\0')
if (!isnullenv(name))
{
if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
/* $LESSHISTFILE == "-" means don't use a history file. */
......@@ -1380,11 +1421,11 @@ histfile_name()
/* Otherwise, file is in $HOME. */
home = lgetenv("HOME");
if (home == NULL || *home == '\0')
if (isnullenv(home))
{
#if OS2
home = lgetenv("INIT");
if (home == NULL || *home == '\0')
if (isnullenv(home))
#endif
return (NULL);
}
......@@ -1447,6 +1488,9 @@ read_cmdhist2(action, uparam, skip_search, skip_shell)
ml = NULL;
skip = NULL;
#endif
} else if (strcmp(line, HISTFILE_MARK_SECTION) == 0)
{
ml = NULL;
} else if (*line == '"')
{
if (ml != NULL)
......@@ -1456,6 +1500,9 @@ read_cmdhist2(action, uparam, skip_search, skip_shell)
else
(*action)(uparam, ml, line+1);
}
} else if (*line == 'm')
{
(*action)(uparam, NULL, line);
}
}
fclose(f);
......@@ -1475,9 +1522,10 @@ read_cmdhist(action, uparam, skip_search, skip_shell)
static void
addhist_init(void *uparam, struct mlist *ml, char *string)
{
if (ml == NULL || string == NULL)
return;
cmd_addhist(ml, string, 0);
if (ml != NULL)
cmd_addhist(ml, string, 0);
else if (string != NULL)
restore_mark(string);
}
#endif /* CMD_HISTORY */
......@@ -1485,7 +1533,7 @@ addhist_init(void *uparam, struct mlist *ml, char *string)
* Initialize history from a .lesshist file.