Date: Mon, 2 Aug 2021 08:29:12 GMT From: Xin LI <delphij@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: f5536286dbc3 - stable/13 - less: upgrade to v590. Message-ID: <202108020829.1728TCa1035108@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=f5536286dbc34733322ee28d97ca3c0fda9a0839 commit f5536286dbc34733322ee28d97ca3c0fda9a0839 Author: Xin LI <delphij@FreeBSD.org> AuthorDate: 2021-07-18 05:20:44 +0000 Commit: Xin LI <delphij@FreeBSD.org> CommitDate: 2021-08-02 08:28:42 +0000 less: upgrade to v590. (cherry picked from commit 30a1828c5196c415c8afc0d50f9131885d0c6b43) (cherry picked from commit 4bcc6d14e23d1443a275fc3a494094274a2f8382) --- contrib/less/NEWS | 30 ++- contrib/less/README | 9 +- contrib/less/ch.c | 2 +- contrib/less/cmdbuf.c | 31 ++- contrib/less/command.c | 1 + contrib/less/decode.c | 93 +++++-- contrib/less/edit.c | 4 +- contrib/less/filename.c | 57 ++-- contrib/less/funcs.h | 12 +- contrib/less/help.c | 4 +- contrib/less/less.h | 1 + contrib/less/less.hlp | 2 + contrib/less/less.nro | 102 +++++--- contrib/less/lessecho.nro | 2 +- contrib/less/lesskey.c | 607 ++++--------------------------------------- contrib/less/lesskey.h | 24 ++ contrib/less/lesskey.nro | 51 ++-- contrib/less/lesskey_parse.c | 580 +++++++++++++++++++++++++++++++++++++++++ contrib/less/line.c | 85 +++--- contrib/less/linenum.c | 23 ++ contrib/less/optfunc.c | 61 ++++- contrib/less/opttbl.c | 23 +- contrib/less/output.c | 15 +- contrib/less/screen.c | 15 +- contrib/less/tags.c | 18 +- contrib/less/version.c | 15 +- contrib/less/xbuf.c | 52 ++++ contrib/less/xbuf.h | 15 ++ usr.bin/less/Makefile | 5 +- usr.bin/less/defines.h | 6 +- usr.bin/lesskey/Makefile | 2 +- 31 files changed, 1184 insertions(+), 763 deletions(-) diff --git a/contrib/less/NEWS b/contrib/less/NEWS index bc5afd655ddc..a403c5d8a875 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -3,8 +3,7 @@ ====================================================================== - For the latest news about less, see the "less" Web page: - https://greenwoodsoftware.com/less + For the latest news about less, see https://greenwoodsoftware.com/less You can also download the latest version of less from there. Report bugs, suggestions or comments at @@ -12,7 +11,32 @@ ====================================================================== - Major changes between "less" versions 563 and 581.2 + Major changes between "less" versions 581 and 590 + +* Make less able to read lesskey source files (deprecating lesskey). + +* If XDG_CONFIG_HOME is set, find lesskey source file + in $XDG_CONFIG_HOME/lesskey rather than $HOME/.lesskey. + +* If XDG_DATA_HOME is set, find and store history file + in $XDG_DATA_HOME/lesshst rather than $HOME/.lesshst. + +* Add the --lesskey-src option. + +* Add the --file-size option. + +* With -F, if screen is resized to make file fit on one screen, don't exit. + +* Fix bug which could leave terminal in mouse-reporting mode + after exiting less. + +* Fix bug which caused failure to respond to window resize. + +* Fix backslash bug searching in tag file. + +====================================================================== + + Major changes between "less" versions 563 and 581 * Change ESC-u command to toggle, not disable, highlighting per man page. diff --git a/contrib/less/README b/contrib/less/README index 2acbd00d762a..4a5aa62a44ee 100644 --- a/contrib/less/README +++ b/contrib/less/README @@ -7,9 +7,7 @@ ************************************************************************** ************************************************************************** - Less, version 581.2 - - This is the distribution of less, version 581.2, released 28 Apr 2021. + This is the source code distribution of "less". This program is part of the GNU project (http://www.gnu.org). This program is free software. You may redistribute it and/or @@ -27,6 +25,11 @@ ========================================================================= +You should build from a clone of a git repository +ONLY IF you are doing development on the less source itself. +If you are merely using less as a tool, you should download a release +from http://greenwoodsoftware.com and NOT from github. + The formatted manual page is in less.man. The manual page nroff source is in less.nro. Major changes made since the last posted version are in NEWS. diff --git a/contrib/less/ch.c b/contrib/less/ch.c index bab0692f7437..379dd84c41b8 100644 --- a/contrib/less/ch.c +++ b/contrib/less/ch.c @@ -860,7 +860,7 @@ ch_init(f, flags) * Allocate and initialize a new filestate. */ thisfile = (struct filestate *) - calloc(1, sizeof(struct filestate)); + ecalloc(1, sizeof(struct filestate)); thisfile->buflist.next = thisfile->buflist.prev = END_OF_CHAIN; thisfile->nbufs = 0; thisfile->flags = flags; diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c index 9cc1f3e94977..dd135382aa11 100644 --- a/contrib/less/cmdbuf.c +++ b/contrib/less/cmdbuf.c @@ -1401,11 +1401,12 @@ mlist_size(ml) * Get the name of the history file. */ static char * -histfile_name(VOID_PARAM) +histfile_name(must_exist) + int must_exist; { char *home; + char *xdg; char *name; - int len; /* See if filename is explicitly specified by $LESSHISTFILE. */ name = lgetenv("LESSHISTFILE"); @@ -1421,19 +1422,25 @@ histfile_name(VOID_PARAM) if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0) return (NULL); - /* Otherwise, file is in $HOME. */ + /* Try in $XDG_DATA_HOME first, then in $HOME. */ + xdg = lgetenv("XDG_DATA_HOME"); home = lgetenv("HOME"); - if (isnullenv(home)) - { #if OS2 + if (isnullenv(home)) home = lgetenv("INIT"); - if (isnullenv(home)) #endif - return (NULL); + name = NULL; + if (!must_exist) + { + /* If we're writing the file and the file already exists, use it. */ + name = dirfile(xdg, &LESSHISTFILE[1], 1); + if (name == NULL) + name = dirfile(home, LESSHISTFILE, 1); } - len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2); - name = (char *) ecalloc(len, sizeof(char)); - SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE); + if (name == NULL) + name = dirfile(xdg, &LESSHISTFILE[1], must_exist); + if (name == NULL) + name = dirfile(home, LESSHISTFILE, must_exist); return (name); } @@ -1454,7 +1461,7 @@ read_cmdhist2(action, uparam, skip_search, skip_shell) char *p; int *skip = NULL; - filename = histfile_name(); + filename = histfile_name(1); if (filename == NULL) return; f = fopen(filename, "r"); @@ -1700,7 +1707,7 @@ save_cmdhist(VOID_PARAM) if (!histfile_modified()) return; - histname = histfile_name(); + histname = histfile_name(0); if (histname == NULL) return; tempname = make_tempname(histname); diff --git a/contrib/less/command.c b/contrib/less/command.c index ae59181c2827..171788f2e750 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -797,6 +797,7 @@ prompt(VOID_PARAM) entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) && next_ifile(curr_ifile) == NULL_IFILE) quit(QUIT_OK); + quit_if_one_screen = FALSE; /* only get one chance at this */ #if MSDOS_COMPILER==WIN32C /* diff --git a/contrib/less/decode.c b/contrib/less/decode.c index f3bfb7a8ead2..7e9b167bc786 100644 --- a/contrib/less/decode.c +++ b/contrib/less/decode.c @@ -339,21 +339,41 @@ init_cmds(VOID_PARAM) add_fcmd_table((char*)cmdtable, sizeof(cmdtable)); add_ecmd_table((char*)edittable, sizeof(edittable)); #if USERFILE +#ifdef BINDIR /* For backwards compatibility */ + /* Try to add tables in the OLD system lesskey file. */ + add_hometable(lesskey, NULL, BINDIR "/.sysless", 1); +#endif /* - * For backwards compatibility, - * try to add tables in the OLD system lesskey file. + * Try to load lesskey source file or binary file. + * If the source file succeeds, don't load binary file. + * The binary file is likely to have been generated from + * a (possibly out of date) copy of the src file, + * so loading it is at best redundant. */ -#ifdef BINDIR - add_hometable(NULL, BINDIR "/.sysless", 1); -#endif /* - * Try to add the tables in the system lesskey file. + * Try to add tables in system lesskey src file. */ - add_hometable("LESSKEY_SYSTEM", LESSKEYFILE_SYS, 1); +#if HAVE_LESSKEYSRC + if (add_hometable(lesskey_src, "LESSKEYIN_SYSTEM", LESSKEYINFILE_SYS, 1) != 0) +#endif + { + /* + * Try to add the tables in the system lesskey binary file. + */ + add_hometable(lesskey, "LESSKEY_SYSTEM", LESSKEYFILE_SYS, 1); + } /* - * Try to add the tables in the standard lesskey file "$HOME/.less". + * Try to add tables in the lesskey src file "$HOME/.lesskey". */ - add_hometable("LESSKEY", LESSKEYFILE, 0); +#if HAVE_LESSKEYSRC + if (add_hometable(lesskey_src, "LESSKEYIN", DEF_LESSKEYINFILE, 0) != 0) +#endif + { + /* + * Try to add the tables in the standard lesskey binary file "$HOME/.less". + */ + add_hometable(lesskey, "LESSKEY", LESSKEYFILE, 0); + } #endif } @@ -877,32 +897,63 @@ lesskey(filename, sysvar) return (new_lesskey(buf, (int)len, sysvar)); } +#if HAVE_LESSKEYSRC + public int +lesskey_src(filename, sysvar) + char *filename; + int sysvar; +{ + static struct lesskey_tables tables; + int r = parse_lesskey(filename, &tables); + if (r != 0) + return (r); + add_fcmd_table(tables.cmdtable.buf.data, tables.cmdtable.buf.end); + add_ecmd_table(tables.edittable.buf.data, tables.edittable.buf.end); + add_var_table(sysvar ? &list_sysvar_tables : &list_var_tables, + tables.vartable.buf.data, tables.vartable.buf.end); + return (0); +} + + void +lesskey_parse_error(s) + char *s; +{ + PARG parg; + parg.p_string = s; + error("%s", &parg); +} +#endif /* HAVE_LESSKEYSRC */ + /* - * Add the standard lesskey file "$HOME/.less" + * Add a lesskey file. */ - public void -add_hometable(envname, def_filename, sysvar) + public int +add_hometable(call_lesskey, envname, def_filename, sysvar) + int (*call_lesskey)(char *, int); char *envname; char *def_filename; int sysvar; { char *filename; - PARG parg; + int r; if (envname != NULL && (filename = lgetenv(envname)) != NULL) filename = save(filename); - else if (sysvar) + else if (sysvar) /* def_filename is full path */ filename = save(def_filename); - else - filename = homefile(def_filename); - if (filename == NULL) - return; - if (lesskey(filename, sysvar) < 0) + else /* def_filename is just basename */ { - parg.p_string = filename; - error("Cannot use lesskey file \"%s\"", &parg); + char *xdg = lgetenv("XDG_CONFIG_HOME"); + if (!isnullenv(xdg)) + filename = dirfile(xdg, def_filename+1, 1); + if (filename == NULL) + filename = homefile(def_filename); } + if (filename == NULL) + return -1; + r = (*call_lesskey)(filename, sysvar); free(filename); + return (r); } #endif diff --git a/contrib/less/edit.c b/contrib/less/edit.c index 12631dba6bac..529ed75b0afe 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -26,6 +26,7 @@ extern int force_open; extern int is_tty; extern int sigs; extern int hshift; +extern int want_filesize; extern IFILE curr_ifile; extern IFILE old_ifile; extern struct scrpos initial_scrpos; @@ -487,7 +488,8 @@ edit_ifile(ifile) cmd_addhist(ml_examine, qfilename, 1); free(qfilename); } - + if (want_filesize) + scan_eof(); } free(filename); return (0); diff --git a/contrib/less/filename.c b/contrib/less/filename.c index 177cb946364a..aba8d3a362e3 100644 --- a/contrib/less/filename.c +++ b/contrib/less/filename.c @@ -216,10 +216,11 @@ shell_quote(s) * Return a pathname that points to a specified file in a specified directory. * Return NULL if the file does not exist in the directory. */ - static char * -dirfile(dirname, filename) + public char * +dirfile(dirname, filename, must_exist) char *dirname; char *filename; + int must_exist; { char *pathname; int len; @@ -235,17 +236,20 @@ dirfile(dirname, filename) if (pathname == NULL) return (NULL); SNPRINTF3(pathname, len, "%s%s%s", dirname, PATHNAME_SEP, filename); - /* - * Make sure the file exists. - */ - f = open(pathname, OPEN_READ); - if (f < 0) + if (must_exist) { - free(pathname); - pathname = NULL; - } else - { - close(f); + /* + * Make sure the file exists. + */ + f = open(pathname, OPEN_READ); + if (f < 0) + { + free(pathname); + pathname = NULL; + } else + { + close(f); + } } return (pathname); } @@ -259,25 +263,19 @@ homefile(filename) { char *pathname; - /* - * Try $HOME/filename. - */ - pathname = dirfile(lgetenv("HOME"), filename); + /* Try $HOME/filename. */ + pathname = dirfile(lgetenv("HOME"), filename, 1); if (pathname != NULL) return (pathname); #if OS2 - /* - * Try $INIT/filename. - */ - pathname = dirfile(lgetenv("INIT"), filename); + /* Try $INIT/filename. */ + pathname = dirfile(lgetenv("INIT"), filename, 1); if (pathname != NULL) return (pathname); #endif #if MSDOS_COMPILER || OS2 - /* - * Look for the file anywhere on search path. - */ - pathname = (char *) calloc(_MAX_PATH, sizeof(char)); + /* Look for the file anywhere on search path. */ + pathname = (char *) ecalloc(_MAX_PATH, sizeof(char)); #if MSDOS_COMPILER==DJGPPC { char *res = searchpath(filename); @@ -517,6 +515,7 @@ seek_filesize(f) return ((POSITION) spos); } +#if HAVE_POPEN /* * Read a string from a file. * Return a pointer to the string in memory. @@ -560,10 +559,6 @@ readfd(fd) return (buf); } - - -#if HAVE_POPEN - /* * Execute a shell command. * Return a pointer to a pipe connected to the shell command's standard output. @@ -812,6 +807,7 @@ lrealpath(path) return (save(path)); } +#if HAVE_POPEN /* * Return number of %s escapes in a string. * Return a large number if there are any other % escapes besides %s. @@ -837,6 +833,7 @@ num_pct_s(lessopen) } return (num); } +#endif /* * See if we should open a "replacement file" @@ -953,10 +950,13 @@ open_altfile(filename, pf, pfd) cmd = readfd(fd); pclose(fd); if (*cmd == '\0') + { /* * Pipe is empty. This means there is no alt file. */ + free(cmd); return (NULL); + } return (cmd); #endif /* HAVE_POPEN */ } @@ -1122,4 +1122,3 @@ last_component(name) } return (name); } - diff --git a/contrib/less/funcs.h b/contrib/less/funcs.h index 12930356c938..330540ac2156 100644 --- a/contrib/less/funcs.h +++ b/contrib/less/funcs.h @@ -106,7 +106,8 @@ public int ecmd_decode LESSPARAMS ((char *cmd, char **sp)); public char * lgetenv LESSPARAMS ((char *var)); public int isnullenv LESSPARAMS ((char* s)); public int lesskey LESSPARAMS ((char *filename, int sysvar)); -public void add_hometable LESSPARAMS ((char *envname, char *def_filename, int sysvar)); +public int lesskey_src LESSPARAMS ((char *filename, int sysvar)); +public int add_hometable LESSPARAMS ((int (*call_lesskey)(char *, int), char *envname, char *def_filename, int sysvar)); public int editchar LESSPARAMS ((int c, int flags)); public void init_textlist LESSPARAMS ((struct textlist *tlist, char *str)); public char * forw_textlist LESSPARAMS ((struct textlist *tlist, char *prev)); @@ -129,6 +130,7 @@ public void use_logfile LESSPARAMS ((char *filename)); public char * shell_unquote LESSPARAMS ((char *str)); public char * get_meta_escape LESSPARAMS ((VOID_PARAM)); public char * shell_quote LESSPARAMS ((char *s)); +public char * dirfile LESSPARAMS ((char *dirname, char *filename, int must_exist)); public char * homefile LESSPARAMS ((char *filename)); public char * fexpand LESSPARAMS ((char *s)); public char * fcomplete LESSPARAMS ((char *s)); @@ -213,6 +215,7 @@ public void add_lnum LESSPARAMS ((LINENUM linenum, POSITION pos)); public LINENUM find_linenum LESSPARAMS ((POSITION pos)); public POSITION find_pos LESSPARAMS ((LINENUM linenum)); public LINENUM currline LESSPARAMS ((int where)); +public void scan_eof LESSPARAMS ((VOID_PARAM)); public void lsystem LESSPARAMS ((char *cmd, char *donemsg)); public int pipe_mark LESSPARAMS ((int c, char *cmd)); public int pipe_data LESSPARAMS ((char *cmd, POSITION spos, POSITION epos)); @@ -235,6 +238,7 @@ public void calc_jump_sline LESSPARAMS ((VOID_PARAM)); public void opt_shift LESSPARAMS ((int type, char *s)); public void calc_shift_count LESSPARAMS ((VOID_PARAM)); public void opt_k LESSPARAMS ((int type, char *s)); +public void opt_ks LESSPARAMS ((int type, char *s)); public void opt_t LESSPARAMS ((int type, char *s)); public void opt__T LESSPARAMS ((int type, char *s)); public void opt_p LESSPARAMS ((int type, char *s)); @@ -251,6 +255,7 @@ public void opt_mousecap LESSPARAMS ((int type, char *s)); public void opt_wheel_lines LESSPARAMS ((int type, char *s)); public void opt_linenum_width LESSPARAMS ((int type, char *s)); public void opt_status_col_width LESSPARAMS ((int type, char *s)); +public void opt_filesize LESSPARAMS ((int type, char *s)); public void opt_ttyin_name LESSPARAMS ((int type, char *s)); public void opt_rstat LESSPARAMS ((int type, char *s)); public int get_swindow LESSPARAMS ((VOID_PARAM)); @@ -280,6 +285,7 @@ public void put_line LESSPARAMS ((VOID_PARAM)); public void flush LESSPARAMS ((VOID_PARAM)); public void set_output LESSPARAMS ((int fd)); public int putchr LESSPARAMS ((int c)); +public void clear_bot_if_needed LESSPARAMS ((VOID_PARAM)); public void putstr LESSPARAMS ((constant char *s)); public int less_printf LESSPARAMS ((char *fmt, PARG *parg)); public void get_return LESSPARAMS ((VOID_PARAM)); @@ -342,3 +348,7 @@ public void close_getchr LESSPARAMS ((VOID_PARAM)); public int default_wheel_lines LESSPARAMS ((VOID_PARAM)); public void rstat LESSPARAMS ((char st)); public int getchr LESSPARAMS ((VOID_PARAM)); +public void xbuf_init LESSPARAMS ((struct xbuffer *xbuf)); +public void xbuf_deinit LESSPARAMS ((struct xbuffer *xbuf)); +public void xbuf_reset LESSPARAMS ((struct xbuffer *xbuf)); +public void xbuf_add LESSPARAMS ((struct xbuffer *xbuf, char ch)); diff --git a/contrib/less/help.c b/contrib/less/help.c index f5b4aa1fbf1a..9dabd43ca221 100644 --- a/contrib/less/help.c +++ b/contrib/less/help.c @@ -1,4 +1,4 @@ -/* This file was generated by mkhelp.pl from less.hlp at 14:59 on 2021/4/28 */ +/* This file was generated by mkhelp.pl from less.hlp at 17:45 on 2021/6/3 */ #include "less.h" constant char helpdata[] = { '\n', @@ -208,6 +208,8 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','d','i','s','p','l','a','y',' ','t','i','l','d','e','s',' ','a','f','t','e','r',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n', ' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','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', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','f','i','l','e','-','s','i','z','e','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','A','u','t','o','m','a','t','i','c','a','l','l','y',' ','d','e','t','e','r','m','i','n','e',' ','t','h','e',' ','s','i','z','e',' ','o','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e','.','\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', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','i','n','c','s','e','a','r','c','h','\n', diff --git a/contrib/less/less.h b/contrib/less/less.h index 4751976bac18..83e31514be3e 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -571,6 +571,7 @@ struct loption; struct hilite_tree; struct ansi_state; #include "pattern.h" +#include "xbuf.h" #include "funcs.h" /* Functions not included in funcs.h */ diff --git a/contrib/less/less.hlp b/contrib/less/less.hlp index 1e1ebf447711..333a0b576c5e 100644 --- a/contrib/less/less.hlp +++ b/contrib/less/less.hlp @@ -205,6 +205,8 @@ Don't display tildes after end of file. -# [_N] .... --shift=[_N] Set horizontal scroll amount (0 = one half screen width). + --file-size + Automatically determine the size of the input file. --follow-name The F command changes files if the input file is renamed. --incsearch diff --git a/contrib/less/less.nro b/contrib/less/less.nro index f148ccb76d98..7c8372b500c6 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,5 +1,5 @@ '\" t -.TH LESS 1 "Version 581.2: 28 Apr 2021" +.TH LESS 1 "Version 590: 03 Jun 2021" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -759,13 +759,38 @@ Causes .I less to open and interpret the named file as a .IR lesskey (1) -file. +binary file. Multiple \-k options may be specified. If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or if a lesskey file is found in a standard place (see KEY BINDINGS), it is also used as a .I lesskey file. +.IP "\-\-lesskey-src=\fIfilename\fP" +Causes +.I less +to open and interpret the named file as a +.IR lesskey (1) +source file. +If the LESSKEYIN or LESSKEYIN_SYSTEM environment variable is set, or +if a lesskey source file is found in a standard place (see KEY BINDINGS), +it is also used as a +.I "lesskey source" +file. +Prior to version 582, the +.I lesskey +program needed to be run to convert a +.I "lesskey source" +file to a +.I "lesskey binary" +file for +.I less +to use. +Newer versions of +.I less +read the +.I "lesskey source" +file directly and ignore the binary file if the source file exists. .IP "\-K or \-\-quit-on-intr" Causes .I less @@ -1054,6 +1079,12 @@ 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 "\-\-file-size" +If \-\-file-size is specified, +.I less +will determine the size of the file +immediately after opening the file. +Normally this is not done, because it can be slow if the input file is large. .IP "\-\-follow-name" Normally, if the input file is renamed while an F command is executing, .I less @@ -1222,57 +1253,61 @@ Delete the entire command line and return to the main prompt. .SH "KEY BINDINGS" You may define your own .I less -commands by using the program -.IR lesskey (1) -to create a lesskey file. +commands by creating a lesskey source file. This file specifies a set of command keys and an action associated with each key. -You may also use -.I lesskey -to change the line-editing keys (see LINE EDITING), +You may also change the line-editing keys (see LINE EDITING), and to set environment variables. -If the environment variable LESSKEY is set, +If the environment variable LESSKEYIN is set, .I less -uses that as the name of the lesskey file. +uses that as the name of the lesskey source file. Otherwise, .I less -looks in a standard place for the lesskey file: +looks in a standard place for the lesskey source file: On Unix systems, .I less -looks for a lesskey file called "$HOME/.less". +looks for a lesskey file called "$XDG_CONFIG_HOME/lesskey" or "$HOME/.lesskey". On MS-DOS and Windows systems, .I less -looks for a lesskey file called "$HOME/_less", and if it is not found there, -then looks for a lesskey file called "_less" in any directory specified +looks for a lesskey file called "$HOME/_lesskey", and if it is not found there, +then looks for a lesskey file called "_lesskey" in any directory specified in the PATH environment variable. On OS/2 systems, .I less -looks for a lesskey file called "$HOME/less.ini", and if it is not found, -then looks for a lesskey file called "less.ini" in any directory specified +looks for a lesskey file called "$HOME/lesskey.ini", and if it is not found, +then looks for a lesskey file called "lesskey.ini" in any directory specified in the INIT environment variable, and if it not found there, -then looks for a lesskey file called "less.ini" in any directory specified +then looks for a lesskey file called "lesskey.ini" in any directory specified in the PATH environment variable. See the .I lesskey manual page for more details. -.P -A system-wide lesskey file may also be set up to provide key bindings. +.PP +A system-wide lesskey source file may also be set up to provide key bindings. If a key is defined in both a local lesskey file and in the system-wide file, key bindings in the local file take precedence over those in the system-wide file. -If the environment variable LESSKEY_SYSTEM is set, +If the environment variable LESSKEYIN_SYSTEM is set, .I less uses that as the name of the system-wide lesskey file. Otherwise, .I less looks in a standard place for the system-wide lesskey file: -On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless. +On Unix systems, the system-wide lesskey file is /usr/local/etc/syslesskey. (However, if .I less was built with a different sysconf directory than /usr/local/etc, that directory is where the sysless file is found.) -On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless. -On OS/2 systems, the system-wide lesskey file is c:\esysless.ini. +On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_syslesskey. +On OS/2 systems, the system-wide lesskey file is c:\esyslesskey.ini. +.PP +Previous versions of +.I less +(before v582) used lesskey files with a binary format, produced by the +.I lesskey +program. It is no longer necessary to use the +.I lesskey +program. . .SH "INPUT PREPROCESSOR" You may define an "input preprocessor" for @@ -1890,20 +1925,29 @@ Name of the history file used to remember search commands and shell commands between invocations of .IR less . If set to "\-" or "/dev/null", a history file is not used. -The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on -DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" +The default is "$XDG_DATA_HOME/lesshst" or "$HOME/.lesshst" on Unix systems, +"$HOME/_lesshst" on DOS and Windows systems, +or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" on OS/2 systems. .IP LESSHISTSIZE The maximum number of commands to save in the history file. The default is 100. +.IP LESSKEYIN +Name of the default +.I "lesskey source" +file. .IP LESSKEY Name of the default -.IR lesskey (1) +.I "lesskey binary" +file. (Not used if "$LESSKEYIN" exists.) +.IP LESSKEYIN_SYSTEM +Name of the default system-wide +.I "lesskey source" file. .IP LESSKEY_SYSTEM Name of the default system-wide -.IR lesskey (1) -file. +.I "lesskey binary" +file. (Not used if "$LESSKEYIN_SYSTEM" exists.) .IP LESSMETACHARS List of characters which are considered "metacharacters" by the shell. .IP LESSMETAESCAPE @@ -1981,4 +2025,4 @@ Report bugs at https://github.com/gwsw/less/issues. .br For more information, see the less homepage at .br -https://greenwoodsoftware.com/less. +https://greenwoodsoftware.com/less diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index 484efa135d34..4733a93edd68 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 581.2: 28 Apr 2021" +.TH LESSECHO 1 "Version 590: 03 Jun 2021" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/contrib/less/lesskey.c b/contrib/less/lesskey.c index de7a9bfc8311..b5130cccb8f7 100644 --- a/contrib/less/lesskey.c +++ b/contrib/less/lesskey.c @@ -80,121 +80,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "less.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> #include "lesskey.h" #include "cmd.h" - -struct cmdname -{ - char *cn_name; - int cn_action; -}; - -struct cmdname cmdnames[] = -{ - { "back-bracket", A_B_BRACKET }, - { "back-line", A_B_LINE }, - { "back-line-force", A_BF_LINE }, - { "back-screen", A_B_SCREEN }, - { "back-scroll", A_B_SCROLL }, - { "back-search", A_B_SEARCH }, - { "back-window", A_B_WINDOW }, - { "clear-mark", A_CLRMARK }, - { "debug", A_DEBUG }, - { "digit", A_DIGIT }, - { "display-flag", A_DISP_OPTION }, - { "display-option", A_DISP_OPTION }, - { "end", A_GOEND }, - { "end-scroll", A_RRSHIFT }, - { "examine", A_EXAMINE }, - { "filter", A_FILTER }, - { "first-cmd", A_FIRSTCMD }, - { "firstcmd", A_FIRSTCMD }, - { "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 }, - { "forw-screen-force", A_FF_SCREEN }, - { "forw-scroll", A_F_SCROLL }, - { "forw-search", A_F_SEARCH }, - { "forw-window", A_F_WINDOW }, - { "goto-end", A_GOEND }, - { "goto-end-buffered", A_GOEND_BUF }, - { "goto-line", A_GOLINE }, - { "goto-mark", A_GOMARK }, - { "help", A_HELP }, - { "index-file", A_INDEX_FILE }, - { "invalid", A_UINVALID }, - { "left-scroll", A_LSHIFT }, - { "next-file", A_NEXT_FILE }, - { "next-tag", A_NEXT_TAG }, - { "noaction", A_NOACTION }, - { "no-scroll", A_LLSHIFT }, - { "percent", A_PERCENT }, - { "pipe", A_PIPE }, - { "prev-file", A_PREV_FILE }, - { "prev-tag", A_PREV_TAG }, - { "quit", A_QUIT }, - { "remove-file", A_REMOVE_FILE }, - { "repaint", A_REPAINT }, - { "repaint-flush", A_FREPAINT }, - { "repeat-search", A_AGAIN_SEARCH }, - { "repeat-search-all", A_T_AGAIN_SEARCH }, - { "reverse-search", A_REVERSE_SEARCH }, - { "reverse-search-all", A_T_REVERSE_SEARCH }, - { "right-scroll", A_RSHIFT }, - { "set-mark", A_SETMARK }, - { "set-mark-bottom", A_SETMARKBOT }, - { "shell", A_SHELL }, - { "status", A_STAT }, - { "toggle-flag", A_OPT_TOGGLE }, - { "toggle-option", A_OPT_TOGGLE }, - { "undo-hilite", A_UNDO_SEARCH }, - { "clear-search", A_CLR_SEARCH }, - { "version", A_VERSION }, - { "visual", A_VISUAL }, - { NULL, 0 } -}; - -struct cmdname editnames[] = -{ - { "back-complete", EC_B_COMPLETE }, - { "backspace", EC_BACKSPACE }, - { "delete", EC_DELETE }, - { "down", EC_DOWN }, - { "end", EC_END }, - { "expand", EC_EXPAND }, - { "forw-complete", EC_F_COMPLETE }, - { "home", EC_HOME }, - { "insert", EC_INSERT }, - { "invalid", EC_UINVALID }, - { "kill-line", EC_LINEKILL }, - { "abort", EC_ABORT }, - { "left", EC_LEFT }, - { "literal", EC_LITERAL }, - { "right", EC_RIGHT }, - { "up", EC_UP }, - { "word-backspace", EC_W_BACKSPACE }, - { "word-delete", EC_W_DELETE }, - { "word-left", EC_W_LEFT }, - { "word-right", EC_W_RIGHT }, - { NULL, 0 } -}; - -struct table -{ - struct cmdname *names; - char *pbuffer; - char buffer[MAX_USERCMD]; -}; - -struct table cmdtable; -struct table edittable; -struct table vartable; -struct table *currtable = &cmdtable; +#include "defines.h" char fileheader[] = { C0_LESSKEY_MAGIC, @@ -215,26 +106,44 @@ char endsection[1] = { END_SECTION }; char *infile = NULL; char *outfile = NULL ; -int linenum; -int errors; - extern char version[]; - void -usage(VOID_PARAM) + static void +usage(void) { fprintf(stderr, "usage: lesskey [-o output] [input]\n"); exit(1); } - char * + void +lesskey_parse_error(s) + char *s; +{ + fprintf(stderr, "%s\n", s); +} + + void * +ecalloc(count, size) + int count; + unsigned int size; +{ + void *p; + + p = calloc(count, size); + if (p != NULL) + return (p); + fprintf(stderr, "lesskey: cannot allocate %d bytes of memory\n", count*size); + exit(1); +} + + static char * mkpathname(dirname, filename) char *dirname; char *filename; { char *pathname; *** 1959 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108020829.1728TCa1035108>