aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2023-05-01 08:22:19 +0000
committerXin LI <delphij@FreeBSD.org>2023-05-01 08:22:19 +0000
commit159d764c16684166cab1428d7aebd0c0f3666cd3 (patch)
tree4964e28a9d48c96e0f735eeb60fa830e51649fc1
parent2b6624fffa5fac26d860898ddb335f852cfeb6b5 (diff)
downloadsrc-159d764c16684166cab1428d7aebd0c0f3666cd3.tar.gz
src-159d764c16684166cab1428d7aebd0c0f3666cd3.zip
Vendor import of less v632.vendor/less/v632
-rw-r--r--LICENSE2
-rw-r--r--Makefile.aut22
-rw-r--r--Makefile.in9
-rw-r--r--Makefile.wng5
-rw-r--r--NEWS79
-rw-r--r--brac.c9
-rw-r--r--ch.c321
-rw-r--r--charset.c234
-rw-r--r--charset.h2
-rw-r--r--cmd.h3
-rw-r--r--cmdbuf.c211
-rw-r--r--command.c200
-rw-r--r--compose.uni14
-rwxr-xr-xconfigure347
-rw-r--r--configure.ac169
-rw-r--r--cvt.c19
-rw-r--r--decode.c144
-rw-r--r--defines.ds5
-rw-r--r--defines.h.in24
-rw-r--r--defines.o22
-rw-r--r--defines.o92
-rw-r--r--defines.wn5
-rw-r--r--edit.c355
-rw-r--r--filename.c137
-rw-r--r--fmt.uni4
-rw-r--r--forwback.c64
-rw-r--r--funcs.h748
-rw-r--r--help.c46
-rw-r--r--ifile.c118
-rw-r--r--input.c203
-rw-r--r--jump.c37
-rw-r--r--less.h89
-rw-r--r--less.hlp44
-rw-r--r--less.man938
-rw-r--r--less.nro677
-rw-r--r--lessecho.c44
-rw-r--r--lessecho.man22
-rw-r--r--lessecho.nro38
-rw-r--r--lesskey.c66
-rw-r--r--lesskey.h2
-rw-r--r--lesskey.man54
-rw-r--r--lesskey.nro62
-rw-r--r--lesskey_parse.c111
-rw-r--r--lglob.h2
-rw-r--r--line.c467
-rw-r--r--linenum.c53
-rw-r--r--lsystem.c18
-rw-r--r--main.c54
-rw-r--r--mark.c84
-rwxr-xr-xmkfuncs.pl27
-rwxr-xr-xmkfuncs.py26
-rwxr-xr-xmkhelp.pl2
-rwxr-xr-xmkutable15
-rw-r--r--optfunc.c314
-rw-r--r--option.c105
-rw-r--r--option.h4
-rw-r--r--opttbl.c116
-rw-r--r--os.c231
-rw-r--r--output.c135
-rw-r--r--pattern.c176
-rw-r--r--pattern.h10
-rw-r--r--pckeys.h2
-rw-r--r--position.c41
-rw-r--r--position.h2
-rw-r--r--prompt.c78
-rw-r--r--screen.c562
-rw-r--r--scrsize.c2
-rw-r--r--search.c370
-rw-r--r--signal.c29
-rw-r--r--tags.c87
-rw-r--r--ttyin.c52
-rw-r--r--ubin.uni16
-rw-r--r--version.c31
-rw-r--r--wide.uni22
-rw-r--r--xbuf.c150
-rw-r--r--xbuf.h7
76 files changed, 4529 insertions, 4448 deletions
diff --git a/LICENSE b/LICENSE
index 65bce4288972..d22cc6070c51 100644
--- a/LICENSE
+++ b/LICENSE
@@ -2,7 +2,7 @@
------------
Less
-Copyright (C) 1984-2022 Mark Nudelman
+Copyright (C) 1984-2023 Mark Nudelman
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
diff --git a/Makefile.aut b/Makefile.aut
index 948532e2f193..8906bdfbbe53 100644
--- a/Makefile.aut
+++ b/Makefile.aut
@@ -11,10 +11,8 @@ REL := $(shell sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q $
ifeq ($(USE_PYTHON),1)
MKHELP = mkhelp.py
- MKFUNCS = mkfuncs.py
else
MKHELP = mkhelp.pl
- MKFUNCS = mkfuncs.pl
endif
SRC = \
@@ -41,15 +39,15 @@ DISTFILES = \
install.sh defines.h.in mkinstalldirs \
less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \
less.hlp \
- mkfuncs.pl mkhelp.pl \
- mkfuncs.py mkhelp.py \
+ mkhelp.pl \
+ mkhelp.py \
mkutable $(UNICODE_FILES) \
${DISTFILES_W}
all: help.c funcs.h $(UNICODE_FILES) ${srcdir}/configure
release: .FORCE
- @if grep -s 'Major changes between .*${REL}' NEWS ; then :; else echo '*** NEWS is not updated for ${REL}'; exit 1; fi
+ @if ${srcdir}/ready_to_release -d ${srcdir}; then :; else exit 1; fi
${MAKE} -f Makefile.aut tagall
${MAKE} -f Makefile.aut all
${MAKE} -f Makefile.aut clean
@@ -68,7 +66,7 @@ ${srcdir}/configure ${srcdir}/defines.h.in: ${srcdir}/configure.ac ${srcdir}/Mak
funcs.h: ${SRC:%=${srcdir}/%}
-mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old
- ${srcdir}/${MKFUNCS} ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h
+ grep -h '^public [^;]*$$' ${SRC:%=${srcdir}/%} | sed 's/$$/;/' >${srcdir}/funcs.h
lint:
lint -I. ${CPPFLAGS} ${SRC}
@@ -112,6 +110,12 @@ ubin.uni: unicode/UnicodeData.txt
wide.uni: unicode/EastAsianWidth.txt
./mkutable -f1 W F -- unicode/EastAsianWidth.txt > $@
+unicode-check:
+ rm -rf unicode-old
+ mv -f unicode unicode-old
+ ${MAKE} -f Makefile.aut unicode/UnicodeData.txt unicode/EastAsianWidth.txt
+ @if diff -q unicode-old unicode >/dev/null; then rm -rf unicode; mv -f unicode-old unicode; echo "unicode files already up to date"; else echo "unicode files updated"; fi
+
unicode/UnicodeData.txt:
mkdir -p unicode
lftp -c 'open -u "anonymous:${EMAIL}" ftp.unicode.org ; get Public/UNIDATA/UnicodeData.txt -o $@'
@@ -152,10 +156,10 @@ tagall:
gnu_upload:
@if [ -z "${REL}" ]; then echo "Please set REL=nnn"; exit 1; fi; \
LESSREL=less-${REL} && RELDIR=release/$$LESSREL && \
- TARF=$$LESSREL-release.tar.gz && \
+ TARF=$$LESSREL.tar.gz && \
if [ ! -s $$RELDIR/$$TARF ]; then echo "$$RELDIR/$$TARF does not exist"; exit 1; fi; \
cd $$RELDIR && \
gpg -b $$TARF && \
( echo "version: 1.2"; echo "directory: less"; echo "filename: $$TARF" ) > $$TARF.directive && \
- gpg --clearsign $$TARF.directive
- @echo "upload ready: cd $$RELDIR; ftp ftp-upload.gnu.org; cd /incoming/ftp; put $$TARF $$TARF.sig $$TARF.directive.asc"
+ gpg --clearsign $$TARF.directive && \
+ echo "upload ready: cd $$RELDIR; ftp ftp-upload.gnu.org; cd /incoming/ftp; put $$TARF $$TARF.sig $$TARF.directive.asc"
diff --git a/Makefile.in b/Makefile.in
index d087e9e06a08..af73ad7998eb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,6 +16,9 @@ LDFLAGS = @LDFLAGS@
CPPFLAGS = @CPPFLAGS@
EXEEXT = @EXEEXT@
O=o
+ifneq ($(strip $(LESSTEST)),)
+CPPFLAGS += -DLESSTEST
+endif
LIBS = @LIBS@
@@ -96,9 +99,12 @@ uninstall:
info:
install-info:
dvi:
-check:
installcheck:
+check:
+ if [ -x less$(EXEEXT) ] && ./less$(EXEEXT) -V | grep -q LESSTEST; then :; else ${MAKE} clean; ${MAKE} LESSTEST=1; fi
+ objdir=$$(pwd); rflags=""; if [ -z "${VERBOSE}" ]; then rflags=-e; fi; cd $(srcdir)/lesstest && ${MAKE} && ./runtest $$rflags -l "$$objdir/less" lt
+
TAGS:
cd ${srcdir} && etags *.c *.h
@@ -126,4 +132,3 @@ distclean: clean
realclean: distclean
rm -f TAGS
-
diff --git a/Makefile.wng b/Makefile.wng
index d33378dba7d0..9a8e57078d1c 100644
--- a/Makefile.wng
+++ b/Makefile.wng
@@ -112,8 +112,9 @@ lessecho: lessecho.o version.o
defines.h: defines.wn
copy $< $@
-funcs.h:
- perl mkfuncs.pl ${LESS_SRC} > $@
+funcs.h: ${LESS_SRC}
+ -move funcs.h funcs.h.old
+ grep -h "^public [^;]*$$" ${LESS_SRC} | sed "s/$$/;/" >funcs.h
help.c: less.hlp
perl mkhelp.pl < $< > $@
diff --git a/NEWS b/NEWS
index bcfe4c6c9e38..468f59441b28 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,77 @@
======================================================================
+ Major changes between "less" versions 608 and 632
+
+* Add LESSUTFCHARDEF environment variable (github #275).
+
+* Add # command (github #330).
+
+* Add ^S search modifier (github #196).
+
+* Add --wordwrap option (github #113).
+
+* Add --no-vbell option (github #304).
+
+* Add --no-search-headers option (github #44).
+
+* Add --modelines option (github #89).
+
+* Add --intr option (github #224).
+
+* Add --proc-backspace, --proc-tab and --proc-return options (github #335).
+
+* Add --show-preproc-errors option (github #258).
+
+* Add LESS_LINES and LESS_COLUMNS environment variables (github #84).
+
+* Add LESS_DATA_DELAY environment variable (github #337).
+
+* Allow empty "lines" field in --header option.
+
+* Update Unicode tables.
+
+* Improve ability of ^X to interrupt F command (github #49).
+
+* Status column (-J) shows off-screen matches.
+
+* Parenthesized sub-patterns in searches are colored with unique colors,
+ if supported by the regular expression library (github #196).
+
+* Don't allow opening a tty as file input unless -f is set (github #309).
+
+* Don't require newline input after +&... option (github #339).
+
+* Fix incorrect handling of some Private Use Unicode characters.
+
+* Fix ANSI color bug when overstriking with colored chars (github #276).
+
+* Fix compiler const warning (github #279).
+
+* Fix signal race in iread (github #280).
+
+* Fix reading procfs files on Linux (github #282).
+
+* Fix --ignore-case with ctrl-R (no regex) search (github #300).
+
+* Fix bug doing repeat search after setting & filter (github #299).
+
+* Fix bug doing repeat search before non-repeat search.
+
+* Fix crash with -R and certain line lengths (github #338).
+
+* Fix input of Windows dead keys (github #352).
+
+* Don't retain search options from a cancelled search (github #302).
+
+* Don't call realpath on fake filenames like "-" (github #289).
+
+* Implement lesstest test suite.
+
+* Convert function parameter definitions from K&R to C89 (github #316).
+
+======================================================================
+
Major changes between "less" versions 590 and 608
* Add the --header option (github #43).
@@ -241,7 +312,7 @@
* Update Unicode tables to 2017-03-08.
-* Pass-thru Unicode formating chars (Cf type) instead of treating them
+* Pass-thru Unicode formatting chars (Cf type) instead of treating them
as binary chars. But treat them as binary if -U is set.
* Fix erroneous binary file warning when UTF-8 file contains ANSI SGR sequences.
@@ -433,7 +504,7 @@
* Fix problem interrupting the line number calculation for initial prompt.
-* Fix SGR emulation when dealing with multiple attributes (eg. bold+underline).
+* Fix SGR emulation when dealing with multiple attributes (e.g. bold+underline).
* Fix highlight bug when searching for underlined/overstruck text.
@@ -515,7 +586,7 @@
* The -c option has been made identical with the -C option.
-* Allow "/dev/null" as synomym for "-" in LESSHISTFILE to indicate
+* Allow "/dev/null" as synonym for "-" in LESSHISTFILE to indicate
that no history file should be used.
* Search can now find text which follows a null byte, if the PCRE
@@ -665,7 +736,7 @@
* Improved performance in reading very large pipes.
-* Eliminated some dependencies on file offets being 32 bits.
+* Eliminated some dependencies on file offsets being 32 bits.
* Fixed problems when viewing files with very long lines.
diff --git a/brac.c b/brac.c
index 58ecf172ae4e..da4efab8605e 100644
--- a/brac.c
+++ b/brac.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -23,12 +23,7 @@
* The characters which serve as "open bracket" and
* "close bracket" are given.
*/
- public void
-match_brac(obrac, cbrac, forwdir, n)
- int obrac;
- int cbrac;
- int forwdir;
- int n;
+public void match_brac(char obrac, char cbrac, int forwdir, int n)
{
int c;
int nest;
diff --git a/ch.c b/ch.c
index bfad09c719f6..b297e7483e7b 100644
--- a/ch.c
+++ b/ch.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -20,14 +20,11 @@
#include <windows.h>
#endif
-#if HAVE_STAT_INO
-#include <sys/stat.h>
-extern dev_t curr_dev;
-extern ino_t curr_ino;
-#endif
-
#if HAVE_PROCFS
#include <sys/statfs.h>
+#if HAVE_LINUX_MAGIC_H
+#include <linux/magic.h>
+#endif
#endif
typedef POSITION BLOCKNUM;
@@ -133,6 +130,7 @@ extern int sigs;
extern int secure;
extern int screen_trashed;
extern int follow_mode;
+extern int waiting_for_data;
extern constant char helpdata[];
extern constant int size_helpdata;
extern IFILE curr_ifile;
@@ -147,13 +145,12 @@ static int ch_addbuf();
/*
* Get the character pointed to by the read pointer.
*/
- int
-ch_get(VOID_PARAM)
+static int ch_get(void)
{
struct buf *bp;
struct bufnode *bn;
int n;
- int slept;
+ int read_again;
int h;
POSITION pos;
POSITION len;
@@ -172,11 +169,10 @@ ch_get(VOID_PARAM)
return bp->data[ch_offset];
}
- slept = FALSE;
-
/*
* Look for a buffer holding the desired block.
*/
+ waiting_for_data = FALSE;
h = BUFHASH(ch_block);
FOR_BUFS_IN_CHAIN(h, bn)
{
@@ -225,149 +221,139 @@ ch_get(VOID_PARAM)
BUF_HASH_INS(bn, h); /* Insert into new hash chain. */
}
- read_more:
- pos = (ch_block * LBUFSIZE) + bp->datasize;
- if ((len = ch_length()) != NULL_POSITION && pos >= len)
- /*
- * At end of file.
- */
- return (EOI);
-
- if (pos != ch_fpos)
+ for (;;)
{
+ pos = (ch_block * LBUFSIZE) + bp->datasize;
+ if ((len = ch_length()) != NULL_POSITION && pos >= len)
+ /*
+ * At end of file.
+ */
+ return (EOI);
+
+ if (pos != ch_fpos)
+ {
+ /*
+ * Not at the correct position: must seek.
+ * If input is a pipe, we're in trouble (can't seek on a pipe).
+ * Some data has been lost: just return "?".
+ */
+ if (!(ch_flags & CH_CANSEEK))
+ return ('?');
+ if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
+ {
+ error("seek error", NULL_PARG);
+ clear_eol();
+ return (EOI);
+ }
+ ch_fpos = pos;
+ }
+
/*
- * Not at the correct position: must seek.
- * If input is a pipe, we're in trouble (can't seek on a pipe).
- * Some data has been lost: just return "?".
+ * Read the block.
+ * If we read less than a full block, that's ok.
+ * We use partial block and pick up the rest next time.
*/
- if (!(ch_flags & CH_CANSEEK))
- return ('?');
- if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
+ if (ch_ungotchar != -1)
{
- error("seek error", NULL_PARG);
- clear_eol();
- return (EOI);
+ bp->data[bp->datasize] = ch_ungotchar;
+ n = 1;
+ ch_ungotchar = -1;
+ } else if (ch_flags & CH_HELPFILE)
+ {
+ bp->data[bp->datasize] = helpdata[ch_fpos];
+ n = 1;
+ } else
+ {
+ n = iread(ch_file, &bp->data[bp->datasize],
+ (unsigned int)(LBUFSIZE - bp->datasize));
}
- ch_fpos = pos;
- }
-
- /*
- * Read the block.
- * If we read less than a full block, that's ok.
- * We use partial block and pick up the rest next time.
- */
- if (ch_ungotchar != -1)
- {
- bp->data[bp->datasize] = ch_ungotchar;
- n = 1;
- ch_ungotchar = -1;
- } else if (ch_flags & CH_HELPFILE)
- {
- bp->data[bp->datasize] = helpdata[ch_fpos];
- n = 1;
- } else
- {
- n = iread(ch_file, &bp->data[bp->datasize],
- (unsigned int)(LBUFSIZE - bp->datasize));
- }
- if (n == READ_INTR)
- return (EOI);
- if (n < 0)
- {
+ read_again = FALSE;
+ if (n == READ_INTR)
+ {
+ ch_fsize = pos;
+ return (EOI);
+ }
+ if (n == READ_AGAIN)
+ {
+ read_again = TRUE;
+ n = 0;
+ }
+ if (n < 0)
+ {
#if MSDOS_COMPILER==WIN32C
- if (errno != EPIPE)
+ if (errno != EPIPE)
#endif
- {
- error("read error", NULL_PARG);
- clear_eol();
+ {
+ error("read error", NULL_PARG);
+ clear_eol();
+ }
+ n = 0;
}
- n = 0;
- }
#if LOGFILE
- /*
- * If we have a log file, write the new data to it.
- */
- if (!secure && logfile >= 0 && n > 0)
- write(logfile, (char *) &bp->data[bp->datasize], n);
+ /*
+ * If we have a log file, write the new data to it.
+ */
+ if (!secure && logfile >= 0 && n > 0)
+ write(logfile, (char *) &bp->data[bp->datasize], n);
#endif
- ch_fpos += n;
- bp->datasize += n;
+ ch_fpos += n;
+ bp->datasize += n;
- /*
- * If we have read to end of file, set ch_fsize to indicate
- * the position of the end of file.
- */
- if (n == 0)
- {
- ch_fsize = pos;
- if (ignore_eoi)
+ if (n == 0)
{
- /*
- * We are ignoring EOF.
- * Wait a while, then try again.
- */
- if (!slept)
- {
- PARG parg;
- parg.p_string = wait_message();
- ierror("%s", &parg);
- }
- sleep_ms(2); /* Reduce system load */
- slept = TRUE;
-
-#if HAVE_STAT_INO
- if (follow_mode == FOLLOW_NAME)
+ /* Either end of file or no data available.
+ * read_again indicates the latter. */
+ if (!read_again)
+ ch_fsize = pos;
+ if (ignore_eoi || read_again)
{
- /* 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 ||
- (curr_pos != NULL_POSITION && st.st_size < curr_pos)))
+ /* Wait a while, then try again. */
+ if (!waiting_for_data)
{
- /* screen_trashed=2 causes
- * make_display to reopen the file. */
- screen_trashed = 2;
- return (EOI);
+ PARG parg;
+ parg.p_string = wait_message();
+ ixerror("%s", &parg);
+ waiting_for_data = TRUE;
}
+ sleep_ms(50); /* Reduce system load */
}
-#endif
+ if (ignore_eoi && follow_mode == FOLLOW_NAME && curr_ifile_changed())
+ {
+ /* screen_trashed=2 causes make_display to reopen the file. */
+ screen_trashed = 2;
+ return (EOI);
+ }
+ if (sigs)
+ return (EOI);
}
- if (sigs)
- return (EOI);
- }
- found:
- if (ch_bufhead != bn)
- {
- /*
- * Move the buffer to the head of the buffer chain.
- * This orders the buffer chain, most- to least-recently used.
- */
- BUF_RM(bn);
- BUF_INS_HEAD(bn);
+ found:
+ if (ch_bufhead != bn)
+ {
+ /*
+ * Move the buffer to the head of the buffer chain.
+ * This orders the buffer chain, most- to least-recently used.
+ */
+ BUF_RM(bn);
+ BUF_INS_HEAD(bn);
- /*
- * Move to head of hash chain too.
- */
- BUF_HASH_RM(bn);
- BUF_HASH_INS(bn, h);
- }
+ /*
+ * Move to head of hash chain too.
+ */
+ BUF_HASH_RM(bn);
+ BUF_HASH_INS(bn, h);
+ }
- if (ch_offset >= bp->datasize)
+ if (ch_offset < bp->datasize)
+ break;
/*
* After all that, we still don't have enough data.
* Go back and try again.
*/
- goto read_more;
-
+ }
return (bp->data[ch_offset]);
}
@@ -375,9 +361,7 @@ ch_get(VOID_PARAM)
* ch_ungetchar is a rather kludgy and limited way to push
* a single char onto an input file descriptor.
*/
- public void
-ch_ungetchar(c)
- int c;
+public void ch_ungetchar(int c)
{
if (c != -1 && ch_ungotchar != -1)
error("ch_ungetchar overrun", NULL_PARG);
@@ -389,8 +373,7 @@ ch_ungetchar(c)
* Close the logfile.
* If we haven't read all of standard input into it, do that now.
*/
- public void
-end_logfile(VOID_PARAM)
+public void end_logfile(void)
{
static int tried = FALSE;
@@ -415,8 +398,7 @@ end_logfile(VOID_PARAM)
* Invoked from the - command; see toggle_option().
* Write all the existing buffered data to the log file.
*/
- public void
-sync_logfile(VOID_PARAM)
+public void sync_logfile(void)
{
struct buf *bp;
struct bufnode *bn;
@@ -452,9 +434,7 @@ sync_logfile(VOID_PARAM)
/*
* Determine if a specific block is currently in one of the buffers.
*/
- static int
-buffered(block)
- BLOCKNUM block;
+static int buffered(BLOCKNUM block)
{
struct buf *bp;
struct bufnode *bn;
@@ -474,9 +454,7 @@ buffered(block)
* Seek to a specified position in the file.
* Return 0 if successful, non-zero if can't seek there.
*/
- public int
-ch_seek(pos)
- POSITION pos;
+public int ch_seek(POSITION pos)
{
BLOCKNUM new_block;
POSITION len;
@@ -513,8 +491,7 @@ ch_seek(pos)
/*
* Seek to the end of the file.
*/
- public int
-ch_end_seek(VOID_PARAM)
+public int ch_end_seek(void)
{
POSITION len;
@@ -540,8 +517,7 @@ ch_end_seek(VOID_PARAM)
/*
* Seek to the last position in the file that is currently buffered.
*/
- public int
-ch_end_buffer_seek(VOID_PARAM)
+public int ch_end_buffer_seek(void)
{
struct buf *bp;
struct bufnode *bn;
@@ -568,8 +544,7 @@ ch_end_buffer_seek(VOID_PARAM)
* We may not be able to seek there if input is a pipe and the
* beginning of the pipe is no longer buffered.
*/
- public int
-ch_beg_seek(VOID_PARAM)
+public int ch_beg_seek(void)
{
struct bufnode *bn;
struct bufnode *firstbn;
@@ -600,8 +575,7 @@ ch_beg_seek(VOID_PARAM)
/*
* Return the length of the file, if known.
*/
- public POSITION
-ch_length(VOID_PARAM)
+public POSITION ch_length(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
@@ -617,8 +591,7 @@ ch_length(VOID_PARAM)
/*
* Return the current position in the file.
*/
- public POSITION
-ch_tell(VOID_PARAM)
+public POSITION ch_tell(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
@@ -628,8 +601,7 @@ ch_tell(VOID_PARAM)
/*
* Get the current char and post-increment the read pointer.
*/
- public int
-ch_forw_get(VOID_PARAM)
+public int ch_forw_get(void)
{
int c;
@@ -651,8 +623,7 @@ ch_forw_get(VOID_PARAM)
/*
* Pre-decrement the read pointer and get the new current char.
*/
- public int
-ch_back_get(VOID_PARAM)
+public int ch_back_get(void)
{
if (thisfile == NULL)
return (EOI);
@@ -674,15 +645,14 @@ ch_back_get(VOID_PARAM)
* Set max amount of buffer space.
* bufspace is in units of 1024 bytes. -1 mean no limit.
*/
- public void
-ch_setbufspace(bufspace)
- int bufspace;
+public void ch_setbufspace(int bufspace)
{
if (bufspace < 0)
maxbufs = -1;
else
{
- maxbufs = ((bufspace * 1024) + LBUFSIZE-1) / LBUFSIZE;
+ int lbufk = LBUFSIZE / 1024;
+ maxbufs = bufspace / lbufk + (bufspace % lbufk != 0);
if (maxbufs < 1)
maxbufs = 1;
}
@@ -691,8 +661,7 @@ ch_setbufspace(bufspace)
/*
* Flush (discard) any saved file state, including buffer contents.
*/
- public void
-ch_flush(VOID_PARAM)
+public void ch_flush(void)
{
struct bufnode *bn;
@@ -765,8 +734,7 @@ ch_flush(VOID_PARAM)
* Allocate a new buffer.
* The buffer is added to the tail of the buffer chain.
*/
- static int
-ch_addbuf(VOID_PARAM)
+static int ch_addbuf(void)
{
struct buf *bp;
struct bufnode *bn;
@@ -790,8 +758,7 @@ ch_addbuf(VOID_PARAM)
/*
*
*/
- static void
-init_hashtbl(VOID_PARAM)
+static void init_hashtbl(void)
{
int h;
@@ -805,8 +772,7 @@ init_hashtbl(VOID_PARAM)
/*
* Delete all buffers for this file.
*/
- static void
-ch_delbufs(VOID_PARAM)
+static void ch_delbufs(void)
{
struct bufnode *bn;
@@ -823,9 +789,7 @@ ch_delbufs(VOID_PARAM)
/*
* Is it possible to seek on a file descriptor?
*/
- public int
-seekable(f)
- int f;
+public int seekable(int f)
{
#if MSDOS_COMPILER
extern int fd0;
@@ -845,8 +809,7 @@ seekable(f)
* 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(VOID_PARAM)
+public void ch_set_eof(void)
{
if (ch_fsize != NULL_POSITION && ch_fsize < ch_fpos)
ch_fsize = ch_fpos;
@@ -856,10 +819,7 @@ ch_set_eof(VOID_PARAM)
/*
* Initialize file state for a new file.
*/
- public void
-ch_init(f, flags)
- int f;
- int flags;
+public void ch_init(int f, int flags)
{
/*
* See if we already have a filestate for this file.
@@ -896,8 +856,7 @@ ch_init(f, flags)
/*
* Close a filestate.
*/
- public void
-ch_close(VOID_PARAM)
+public void ch_close(void)
{
int keepstate = FALSE;
@@ -939,8 +898,7 @@ ch_close(VOID_PARAM)
/*
* Return ch_flags for the current file.
*/
- public int
-ch_getflags(VOID_PARAM)
+public int ch_getflags(void)
{
if (thisfile == NULL)
return (0);
@@ -948,8 +906,7 @@ ch_getflags(VOID_PARAM)
}
#if 0
- public void
-ch_dump(struct filestate *fs)
+static void ch_dump(struct filestate *fs)
{
struct buf *bp;
struct bufnode *bn;
diff --git a/charset.c b/charset.c
index 5e9a2d6427b8..881ebafd02cf 100644
--- a/charset.c
+++ b/charset.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -21,6 +21,7 @@
#endif
#include "charset.h"
+#include "xbuf.h"
#if MSDOS_COMPILER==WIN32C
#define WIN32_LEAN_AND_MEAN
@@ -123,6 +124,108 @@ static char *binfmt = NULL;
static char *utfbinfmt = NULL;
public int binattr = AT_STANDOUT|AT_COLOR_BIN;
+static struct xbuffer user_wide_array;
+static struct xbuffer user_ubin_array;
+static struct xbuffer user_compose_array;
+static struct xbuffer user_prt_array;
+static struct wchar_range_table user_wide_table;
+static struct wchar_range_table user_ubin_table;
+static struct wchar_range_table user_compose_table;
+static struct wchar_range_table user_prt_table;
+
+/*
+ * Set a wchar_range_table to the table in an xbuffer.
+ */
+static void wchar_range_table_set(struct wchar_range_table *tbl, struct xbuffer *arr)
+{
+ tbl->table = (struct wchar_range *) arr->data;
+ tbl->count = arr->end / sizeof(struct wchar_range);
+}
+
+/*
+ * Skip over a "U" or "U+" prefix before a hex codepoint.
+ */
+static char * skip_uprefix(char *s)
+{
+ if (*s == 'U' || *s == 'u')
+ if (*++s == '+') ++s;
+ return s;
+}
+
+/*
+ * Parse a dash-separated range of hex values.
+ */
+static void wchar_range_get(char **ss, struct wchar_range *range)
+{
+ char *s = skip_uprefix(*ss);
+ range->first = lstrtoul(s, &s, 16);
+ if (s[0] == '-')
+ {
+ s = skip_uprefix(&s[1]);
+ range->last = lstrtoul(s, &s, 16);
+ } else
+ {
+ range->last = range->first;
+ }
+ *ss = s;
+}
+
+/*
+ * Parse the LESSUTFCHARDEF variable.
+ */
+static void ichardef_utf(char *s)
+{
+ xbuf_init(&user_wide_array);
+ xbuf_init(&user_ubin_array);
+ xbuf_init(&user_compose_array);
+ xbuf_init(&user_prt_array);
+
+ if (s != NULL)
+ {
+ while (s[0] != '\0')
+ {
+ struct wchar_range range;
+ wchar_range_get(&s, &range);
+ if (range.last == 0)
+ {
+ error("invalid hex number(s) in LESSUTFCHARDEF", NULL_PARG);
+ quit(QUIT_ERROR);
+ }
+ if (*s++ != ':')
+ {
+ error("missing colon in LESSUTFCHARDEF", NULL_PARG);
+ quit(QUIT_ERROR);
+ }
+ switch (*s++)
+ {
+ case 'b':
+ xbuf_add_data(&user_ubin_array, (unsigned char *) &range, sizeof(range));
+ break;
+ case 'c':
+ xbuf_add_data(&user_compose_array, (unsigned char *) &range, sizeof(range));
+ break;
+ case 'w':
+ xbuf_add_data(&user_wide_array, (unsigned char *) &range, sizeof(range));
+ xbuf_add_data(&user_prt_array, (unsigned char *) &range, sizeof(range));
+ break;
+ case 'p': case '.':
+ xbuf_add_data(&user_prt_array, (unsigned char *) &range, sizeof(range));
+ break;
+ case '\0':
+ s--;
+ break;
+ default:
+ /* Ignore unknown character attribute. */
+ break;
+ }
+ if (s[0] == ',') ++s;
+ }
+ }
+ wchar_range_table_set(&user_wide_table, &user_wide_array);
+ wchar_range_table_set(&user_ubin_table, &user_ubin_array);
+ wchar_range_table_set(&user_compose_table, &user_compose_array);
+ wchar_range_table_set(&user_prt_table, &user_prt_array);
+}
/*
* Define a charset, given a description string.
@@ -138,9 +241,7 @@ public int binattr = AT_STANDOUT|AT_COLOR_BIN;
* b binary character
* c control character
*/
- static void
-ichardef(s)
- char *s;
+static void ichardef(char *s)
{
char *cp;
int n;
@@ -165,10 +266,12 @@ ichardef(s)
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- n = (10 * n) + (s[-1] - '0');
+ if (ckd_mul(&n, n, 10) || ckd_add(&n, n, s[-1] - '0'))
+ goto invalid_chardef;
continue;
default:
+ invalid_chardef:
error("invalid chardef", NULL_PARG);
quit(QUIT_ERROR);
/*NOTREACHED*/
@@ -195,10 +298,7 @@ ichardef(s)
* Define a charset, given a charset name.
* The valid charset names are listed in the "charsets" array.
*/
- static int
-icharset(name, no_error)
- char *name;
- int no_error;
+static int icharset(char *name, int no_error)
{
struct charset *p;
struct cs_alias *a;
@@ -244,8 +344,7 @@ icharset(name, no_error)
/*
* Define a charset, given a locale name.
*/
- static void
-ilocale(VOID_PARAM)
+static void ilocale(void)
{
int c;
@@ -264,12 +363,7 @@ ilocale(VOID_PARAM)
/*
* Define the printing format for control (or binary utf) chars.
*/
- public void
-setfmt(s, fmtvarptr, attrptr, default_fmt)
- char *s;
- char **fmtvarptr;
- int *attrptr;
- char *default_fmt;
+public void setfmt(char *s, char **fmtvarptr, int *attrptr, char *default_fmt, int for_printf)
{
if (s && utf_mode)
{
@@ -286,10 +380,12 @@ setfmt(s, fmtvarptr, attrptr, default_fmt)
}
}
- /* %n is evil */
- if (s == NULL || *s == '\0' ||
- (*s == '*' && (s[1] == '\0' || s[2] == '\0' || strchr(s + 2, 'n'))) ||
- (*s != '*' && strchr(s, 'n')))
+ if (s == NULL || *s == '\0')
+ s = default_fmt;
+ else if (for_printf &&
+ ((*s == '*' && (s[1] == '\0' || s[2] == '\0' || strchr(s + 2, 'n'))) ||
+ (*s != '*' && strchr(s, 'n'))))
+ /* %n is evil */
s = default_fmt;
/*
@@ -314,8 +410,7 @@ setfmt(s, fmtvarptr, attrptr, default_fmt)
/*
*
*/
- static void
-set_charset(VOID_PARAM)
+static void set_charset(void)
{
char *s;
@@ -327,6 +422,9 @@ set_charset(VOID_PARAM)
if (icharset("utf-8", 1))
return;
#endif
+
+ ichardef_utf(lgetenv("LESSUTFCHARDEF"));
+
/*
* See if environment variable LESSCHARSET is defined.
*/
@@ -394,8 +492,7 @@ set_charset(VOID_PARAM)
/*
* Initialize charset data structures.
*/
- public void
-init_charset(VOID_PARAM)
+public void init_charset(void)
{
char *s;
@@ -406,18 +503,16 @@ init_charset(VOID_PARAM)
set_charset();
s = lgetenv("LESSBINFMT");
- setfmt(s, &binfmt, &binattr, "*s<%02X>");
+ setfmt(s, &binfmt, &binattr, "*s<%02X>", TRUE);
s = lgetenv("LESSUTFBINFMT");
- setfmt(s, &utfbinfmt, &binattr, "<U+%04lX>");
+ setfmt(s, &utfbinfmt, &binattr, "<U+%04lX>", TRUE);
}
/*
* Is a given character a "binary" character?
*/
- public int
-binary_char(c)
- LWCHAR c;
+public int binary_char(LWCHAR c)
{
if (utf_mode)
return (is_ubin_char(c));
@@ -428,9 +523,7 @@ binary_char(c)
/*
* Is a given character a "control" character?
*/
- public int
-control_char(c)
- LWCHAR c;
+public int control_char(LWCHAR c)
{
c &= 0377;
return (chardef[c] & IS_CONTROL_CHAR);
@@ -440,9 +533,7 @@ control_char(c)
* Return the printable form of a character.
* For example, in the "ascii" charset '\3' is printed as "^C".
*/
- public char *
-prchar(c)
- LWCHAR c;
+public char * prchar(LWCHAR c)
{
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
static char buf[MAX_PRCHAR_LEN+1];
@@ -476,9 +567,7 @@ prchar(c)
/*
* Return the printable form of a UTF-8 character.
*/
- public char *
-prutfchar(ch)
- LWCHAR ch;
+public char * prutfchar(LWCHAR ch)
{
static char buf[MAX_PRCHAR_LEN+1];
@@ -507,9 +596,7 @@ prutfchar(ch)
/*
* Get the length of a UTF-8 character in bytes.
*/
- public int
-utf_len(ch)
- int ch;
+public int utf_len(int ch)
{
if ((ch & 0x80) == 0)
return 1;
@@ -530,10 +617,7 @@ utf_len(ch)
/*
* Does the parameter point to the lead byte of a well-formed UTF-8 character?
*/
- public int
-is_utf8_well_formed(ss, slen)
- char *ss;
- int slen;
+public int is_utf8_well_formed(char *ss, int slen)
{
int i;
int len;
@@ -568,10 +652,7 @@ is_utf8_well_formed(ss, slen)
/*
* Skip bytes until a UTF-8 lead byte (11xxxxxx) or ASCII byte (0xxxxxxx) is found.
*/
- public void
-utf_skip_to_lead(pp, limit)
- char **pp;
- char *limit;
+public void utf_skip_to_lead(char **pp, char *limit)
{
do {
++(*pp);
@@ -582,9 +663,7 @@ utf_skip_to_lead(pp, limit)
/*
* Get the value of a UTF-8 character.
*/
- public LWCHAR
-get_wchar(p)
- constant char *p;
+public LWCHAR get_wchar(constant char *p)
{
switch (utf_len(p[0]))
{
@@ -634,10 +713,7 @@ get_wchar(p)
/*
* Store a character into a UTF-8 string.
*/
- public void
-put_wchar(pp, ch)
- char **pp;
- LWCHAR ch;
+public void put_wchar(char **pp, LWCHAR ch)
{
if (!utf_mode || ch < 0x80)
{
@@ -684,11 +760,7 @@ put_wchar(pp, ch)
/*
* Step forward or backward one character in a string.
*/
- public LWCHAR
-step_char(pp, dir, limit)
- char **pp;
- signed int dir;
- constant char *limit;
+public LWCHAR step_char(char **pp, signed int dir, constant char *limit)
{
LWCHAR ch;
int len;
@@ -758,16 +830,13 @@ static struct wchar_range comb_table[] = {
};
- static int
-is_in_table(ch, table)
- LWCHAR ch;
- struct wchar_range_table *table;
+static int is_in_table(LWCHAR ch, struct wchar_range_table *table)
{
int hi;
int lo;
/* Binary search in the table. */
- if (ch < table->table[0].first)
+ if (table->table == NULL || table->count == 0 || ch < table->table[0].first)
return 0;
lo = 0;
hi = table->count - 1;
@@ -788,34 +857,32 @@ is_in_table(ch, table)
* Is a character a UTF-8 composing character?
* If a composing character follows any char, the two combine into one glyph.
*/
- public int
-is_composing_char(ch)
- LWCHAR ch;
+public int is_composing_char(LWCHAR ch)
{
- return is_in_table(ch, &compose_table) ||
+ if (is_in_table(ch, &user_prt_table)) return 0;
+ return is_in_table(ch, &user_compose_table) ||
+ is_in_table(ch, &compose_table) ||
(bs_mode != BS_CONTROL && is_in_table(ch, &fmt_table));
}
/*
* Should this UTF-8 character be treated as binary?
*/
- public int
-is_ubin_char(ch)
- LWCHAR ch;
+public int is_ubin_char(LWCHAR ch)
{
- int ubin = is_in_table(ch, &ubin_table) ||
- (bs_mode == BS_CONTROL && is_in_table(ch, &fmt_table));
- return ubin;
+ if (is_in_table(ch, &user_prt_table)) return 0;
+ return is_in_table(ch, &user_ubin_table) ||
+ is_in_table(ch, &ubin_table) ||
+ (bs_mode == BS_CONTROL && is_in_table(ch, &fmt_table));
}
/*
* Is this a double width UTF-8 character?
*/
- public int
-is_wide_char(ch)
- LWCHAR ch;
+public int is_wide_char(LWCHAR ch)
{
- return is_in_table(ch, &wide_table);
+ return is_in_table(ch, &user_wide_table) ||
+ is_in_table(ch, &wide_table);
}
/*
@@ -823,10 +890,7 @@ is_wide_char(ch)
* A combining char acts like an ordinary char, but if it follows
* a specific char (not any char), the two combine into one glyph.
*/
- public int
-is_combining_char(ch1, ch2)
- LWCHAR ch1;
- LWCHAR ch2;
+public int is_combining_char(LWCHAR ch1, LWCHAR ch2)
{
/* The table is small; use linear search. */
int i;
diff --git a/charset.h b/charset.h
index aa6273dfda6c..4312113a58f8 100644
--- a/charset.h
+++ b/charset.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/cmd.h b/cmd.h
index b0f3fdb14b1e..a927a3d3657b 100644
--- a/cmd.h
+++ b/cmd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -75,6 +75,7 @@
#define A_B_MOUSE 67
/* Note "X116" refers to extended (1006) X11 mouse reporting. */
#define A_X116MOUSE_IN 68
+#define A_PSHELL 69
#define A_CLR_SEARCH 70
/* These values must not conflict with any A_* or EC_* value. */
diff --git a/cmdbuf.c b/cmdbuf.c
index 5b5704602d8d..c81328387824 100644
--- a/cmdbuf.c
+++ b/cmdbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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,7 +35,7 @@ static int literal; /* Next input char should not be interpreted */
public int updown_match = -1; /* Prefix length in up/down movement */
#if TAB_COMPLETE_FILENAME
-static int cmd_complete LESSPARAMS((int action));
+static int cmd_complete(int action);
/*
* These variables are statics used by cmd_complete.
*/
@@ -117,8 +117,7 @@ static int cmd_mbc_buf_index;
/*
* Reset command buffer (to empty).
*/
- public void
-cmd_reset(VOID_PARAM)
+public void cmd_reset(void)
{
cp = cmdbuf;
*cp = '\0';
@@ -132,8 +131,7 @@ cmd_reset(VOID_PARAM)
/*
* Clear command line.
*/
- public void
-clear_cmd(VOID_PARAM)
+public void clear_cmd(void)
{
cmd_col = prompt_col = 0;
cmd_mbc_buf_len = 0;
@@ -143,9 +141,7 @@ clear_cmd(VOID_PARAM)
/*
* Display a string, usually as a prompt for input into the command buffer.
*/
- public void
-cmd_putstr(s)
- constant char *s;
+public void cmd_putstr(constant char *s)
{
LWCHAR prev_ch = 0;
LWCHAR ch;
@@ -172,8 +168,7 @@ cmd_putstr(s)
/*
* How many characters are in the command buffer?
*/
- public int
-len_cmdbuf(VOID_PARAM)
+public int len_cmdbuf(void)
{
char *s = cmdbuf;
char *endline = s + strlen(s);
@@ -192,13 +187,7 @@ len_cmdbuf(VOID_PARAM)
* {{ Returning pwidth and bswidth separately is a historical artifact
* since they're always the same. Maybe clean this up someday. }}
*/
- static char *
-cmd_step_common(p, ch, len, pwidth, bswidth)
- char *p;
- LWCHAR ch;
- int len;
- int *pwidth;
- int *bswidth;
+static char * cmd_step_common(char *p, LWCHAR ch, int len, int *pwidth, int *bswidth)
{
char *pr;
int width;
@@ -233,11 +222,7 @@ cmd_step_common(p, ch, len, pwidth, bswidth)
/*
* Step a pointer one character right in the command buffer.
*/
- static char *
-cmd_step_right(pp, pwidth, bswidth)
- char **pp;
- int *pwidth;
- int *bswidth;
+static char * cmd_step_right(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, +1, p + strlen(p));
@@ -248,11 +233,7 @@ cmd_step_right(pp, pwidth, bswidth)
/*
* Step a pointer one character left in the command buffer.
*/
- static char *
-cmd_step_left(pp, pwidth, bswidth)
- char **pp;
- int *pwidth;
- int *bswidth;
+static char * cmd_step_left(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, -1, cmdbuf);
@@ -264,8 +245,7 @@ cmd_step_left(pp, pwidth, bswidth)
* Put the cursor at "home" (just after the prompt),
* and set cp to the corresponding char in cmdbuf.
*/
- static void
-cmd_home(VOID_PARAM)
+static void cmd_home(void)
{
while (cmd_col > prompt_col)
{
@@ -284,9 +264,7 @@ cmd_home(VOID_PARAM)
* Repaint the line from cp onwards.
* Then position the cursor just after the char old_cp (a pointer into cmdbuf).
*/
- public void
-cmd_repaint(old_cp)
- constant char *old_cp;
+public void cmd_repaint(constant char *old_cp)
{
/*
* Repaint the line from the current position.
@@ -329,8 +307,7 @@ cmd_repaint(old_cp)
/*
* Shift the cmdbuf display left a half-screen.
*/
- static void
-cmd_lshift(VOID_PARAM)
+static void cmd_lshift(void)
{
char *s;
char *save_cp;
@@ -367,8 +344,7 @@ cmd_lshift(VOID_PARAM)
/*
* Shift the cmdbuf display right a half-screen.
*/
- static void
-cmd_rshift(VOID_PARAM)
+static void cmd_rshift(void)
{
char *s;
char *save_cp;
@@ -397,8 +373,7 @@ cmd_rshift(VOID_PARAM)
/*
* Move cursor right one character.
*/
- static int
-cmd_right(VOID_PARAM)
+static int cmd_right(void)
{
char *pr;
char *ncp;
@@ -432,8 +407,7 @@ cmd_right(VOID_PARAM)
/*
* Move cursor left one character.
*/
- static int
-cmd_left(VOID_PARAM)
+static int cmd_left(void)
{
char *ncp;
int width = 0;
@@ -463,10 +437,7 @@ cmd_left(VOID_PARAM)
/*
* Insert a char into the command buffer, at the current position.
*/
- static int
-cmd_ichar(cs, clen)
- char *cs;
- int clen;
+static int cmd_ichar(char *cs, int clen)
{
char *s;
@@ -500,8 +471,7 @@ cmd_ichar(cs, clen)
* Backspace in the command buffer.
* Delete the char to the left of the cursor.
*/
- static int
-cmd_erase(VOID_PARAM)
+static int cmd_erase(void)
{
char *s;
int clen;
@@ -549,8 +519,7 @@ cmd_erase(VOID_PARAM)
/*
* Delete the char under the cursor.
*/
- static int
-cmd_delete(VOID_PARAM)
+static int cmd_delete(void)
{
if (*cp == '\0')
{
@@ -568,8 +537,7 @@ cmd_delete(VOID_PARAM)
/*
* Delete the "word" to the left of the cursor.
*/
- static int
-cmd_werase(VOID_PARAM)
+static int cmd_werase(void)
{
if (cp > cmdbuf && cp[-1] == ' ')
{
@@ -594,8 +562,7 @@ cmd_werase(VOID_PARAM)
/*
* Delete the "word" under the cursor.
*/
- static int
-cmd_wdelete(VOID_PARAM)
+static int cmd_wdelete(void)
{
if (*cp == ' ')
{
@@ -620,8 +587,7 @@ cmd_wdelete(VOID_PARAM)
/*
* Delete all chars in the command buffer.
*/
- static int
-cmd_kill(VOID_PARAM)
+static int cmd_kill(void)
{
if (cmdbuf[0] == '\0')
{
@@ -646,10 +612,7 @@ cmd_kill(VOID_PARAM)
/*
* Select an mlist structure to be the current command history.
*/
- public void
-set_mlist(mlist, cmdflags)
- void *mlist;
- int cmdflags;
+public void set_mlist(void *mlist, int cmdflags)
{
#if CMD_HISTORY
curr_mlist = (struct mlist *) mlist;
@@ -667,9 +630,7 @@ set_mlist(mlist, cmdflags)
* Only consider entries whose first updown_match chars are equal to
* cmdbuf's corresponding chars.
*/
- static int
-cmd_updown(action)
- int action;
+static int cmd_updown(int action)
{
constant char *s;
struct mlist *ml;
@@ -731,10 +692,7 @@ cmd_updown(action)
/*
*
*/
- static void
-ml_link(mlist, ml)
- struct mlist *mlist;
- struct mlist *ml;
+static void ml_link(struct mlist *mlist, struct mlist *ml)
{
ml->next = mlist;
ml->prev = mlist->prev;
@@ -745,9 +703,7 @@ ml_link(mlist, ml)
/*
*
*/
- static void
-ml_unlink(ml)
- struct mlist *ml;
+static void ml_unlink(struct mlist *ml)
{
ml->prev->next = ml->next;
ml->next->prev = ml->prev;
@@ -756,11 +712,7 @@ ml_unlink(ml)
/*
* Add a string to an mlist.
*/
- public void
-cmd_addhist(mlist, cmd, modified)
- struct mlist *mlist;
- constant char *cmd;
- int modified;
+public void cmd_addhist(struct mlist *mlist, constant char *cmd, int modified)
{
#if CMD_HISTORY
struct mlist *ml;
@@ -814,8 +766,7 @@ cmd_addhist(mlist, cmd, modified)
* Accept the command in the command buffer.
* Add it to the currently selected history list.
*/
- public void
-cmd_accept(VOID_PARAM)
+public void cmd_accept(void)
{
#if CMD_HISTORY
/*
@@ -836,9 +787,7 @@ cmd_accept(VOID_PARAM)
* CC_OK Line edit function done.
* CC_QUIT The char requests the current command to be aborted.
*/
- static int
-cmd_edit(c)
- int c;
+static int cmd_edit(int c)
{
int action;
int flags;
@@ -846,7 +795,7 @@ cmd_edit(c)
#if TAB_COMPLETE_FILENAME
#define not_in_completion() in_completion = 0
#else
-#define not_in_completion(VOID_PARAM)
+#define not_in_completion(void)
#endif
/*
@@ -953,9 +902,7 @@ cmd_edit(c)
/*
* Insert a string into the command buffer, at the current position.
*/
- static int
-cmd_istr(str)
- char *str;
+static int cmd_istr(char *str)
{
char *s;
int action;
@@ -978,8 +925,7 @@ cmd_istr(str)
* Return pointer to the beginning of the word and put the
* cursor at the end of the word.
*/
- static char *
-delimit_word(VOID_PARAM)
+static char * delimit_word(void)
{
char *word;
#if SPACES_IN_FILENAMES
@@ -1065,8 +1011,7 @@ delimit_word(VOID_PARAM)
* Expand the word under the cursor into a list of filenames
* which start with that word, and set tk_text to that list.
*/
- static void
-init_compl(VOID_PARAM)
+static void init_compl(void)
{
char *word;
char c;
@@ -1128,10 +1073,7 @@ init_compl(VOID_PARAM)
/*
* Return the next word in the current completion list.
*/
- static char *
-next_compl(action, prev)
- int action;
- char *prev;
+static char * next_compl(int action, char *prev)
{
switch (action)
{
@@ -1150,9 +1092,7 @@ next_compl(action, prev)
* remembers whether this call is the first time (create the list),
* or a subsequent time (step thru the list).
*/
- static int
-cmd_complete(action)
- int action;
+static int cmd_complete(int action)
{
char *s;
@@ -1248,9 +1188,7 @@ fail:
* CC_QUIT The char requests the command to be aborted.
* CC_ERROR The char could not be accepted due to an error.
*/
- public int
-cmd_char(c)
- int c;
+public int cmd_char(int c)
{
int action;
int len;
@@ -1345,9 +1283,7 @@ cmd_char(c)
/*
* Return the number currently in the command buffer.
*/
- public LINENUM
-cmd_int(frac)
- long *frac;
+public LINENUM cmd_int(long *frac)
{
char *p;
LINENUM n = 0;
@@ -1355,13 +1291,11 @@ cmd_int(frac)
for (p = cmdbuf; *p >= '0' && *p <= '9'; p++)
{
- LINENUM nn = (n * 10) + (*p - '0');
- if (nn < n)
+ if (ckd_mul(&n, n, 10) || ckd_add(&n, n, *p - '0'))
{
error("Integer is too big", NULL_PARG);
return (0);
}
- n = nn;
}
*frac = 0;
if (*p++ == '.')
@@ -1375,8 +1309,7 @@ cmd_int(frac)
/*
* Return a pointer to the command buffer.
*/
- public char *
-get_cmdbuf(VOID_PARAM)
+public char * get_cmdbuf(void)
{
if (cmd_mbc_buf_index < cmd_mbc_buf_len)
/* Don't return buffer containing an incomplete multibyte char. */
@@ -1388,8 +1321,7 @@ get_cmdbuf(VOID_PARAM)
/*
* Return the last (most recent) string in the current command history.
*/
- public char *
-cmd_lastpattern(VOID_PARAM)
+public char * cmd_lastpattern(void)
{
if (curr_mlist == NULL)
return (NULL);
@@ -1400,9 +1332,7 @@ cmd_lastpattern(VOID_PARAM)
#if CMD_HISTORY
/*
*/
- static int
-mlist_size(ml)
- struct mlist *ml;
+static int mlist_size(struct mlist *ml)
{
int size = 0;
for (ml = ml->next; ml->string != NULL; ml = ml->next)
@@ -1413,9 +1343,7 @@ mlist_size(ml)
/*
* Get the name of the history file.
*/
- static char *
-histfile_find(must_exist)
- int must_exist;
+static char * histfile_find(int must_exist)
{
char *home = lgetenv("HOME");
char *name = NULL;
@@ -1442,9 +1370,7 @@ histfile_find(must_exist)
return (name);
}
- static char *
-histfile_name(must_exist)
- int must_exist;
+static char * histfile_name(int must_exist)
{
char *name;
@@ -1476,12 +1402,7 @@ histfile_name(must_exist)
/*
* Read a .lesshst file and call a callback for each line in the file.
*/
- static void
-read_cmdhist2(action, uparam, skip_search, skip_shell)
- void (*action)(void*,struct mlist*,char*);
- void *uparam;
- int skip_search;
- int skip_shell;
+static void read_cmdhist2(void (*action)(void*,struct mlist*,char*), void *uparam, int skip_search, int skip_shell)
{
struct mlist *ml = NULL;
char line[CMDBUF_SIZE];
@@ -1546,12 +1467,7 @@ read_cmdhist2(action, uparam, skip_search, skip_shell)
fclose(f);
}
- static void
-read_cmdhist(action, uparam, skip_search, skip_shell)
- void (*action)(void*,struct mlist*,char*);
- void *uparam;
- int skip_search;
- int skip_shell;
+static void read_cmdhist(void (*action)(void*,struct mlist*,char*), void *uparam, int skip_search, int skip_shell)
{
if (secure)
return;
@@ -1559,11 +1475,7 @@ read_cmdhist(action, uparam, skip_search, skip_shell)
(*action)(uparam, NULL, NULL); /* signal end of file */
}
- static void
-addhist_init(uparam, ml, string)
- void *uparam;
- struct mlist *ml;
- char constant *string;
+static void addhist_init(void *uparam, struct mlist *ml, char *string)
{
if (ml != NULL)
cmd_addhist(ml, string, 0);
@@ -1575,8 +1487,7 @@ addhist_init(uparam, ml, string)
/*
* Initialize history from a .lesshist file.
*/
- public void
-init_cmdhist(VOID_PARAM)
+public void init_cmdhist(void)
{
#if CMD_HISTORY
read_cmdhist(&addhist_init, NULL, 0, 0);
@@ -1587,10 +1498,7 @@ init_cmdhist(VOID_PARAM)
* Write the header for a section of the history file.
*/
#if CMD_HISTORY
- static void
-write_mlist_header(ml, f)
- struct mlist *ml;
- FILE *f;
+static void write_mlist_header(struct mlist *ml, FILE *f)
{
if (ml == &mlist_search)
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
@@ -1603,10 +1511,7 @@ write_mlist_header(ml, f)
/*
* Write all modified entries in an mlist to the history file.
*/
- static void
-write_mlist(ml, f)
- struct mlist *ml;
- FILE *f;
+static void write_mlist(struct mlist *ml, FILE *f)
{
for (ml = ml->next; ml->string != NULL; ml = ml->next)
{
@@ -1621,9 +1526,7 @@ write_mlist(ml, f)
/*
* Make a temp name in the same directory as filename.
*/
- static char *
-make_tempname(filename)
- char *filename;
+static char * make_tempname(char *filename)
{
char lastch;
char *tempname = ecalloc(1, strlen(filename)+1);
@@ -1644,11 +1547,7 @@ struct save_ctx
* At the end of each mlist, append any new entries
* created during this session.
*/
- static void
-copy_hist(uparam, ml, string)
- void *uparam;
- struct mlist *ml;
- char constant *string;
+static void copy_hist(void *uparam, struct mlist *ml, char *string)
{
struct save_ctx *ctx = (struct save_ctx *) uparam;
@@ -1689,9 +1588,7 @@ copy_hist(uparam, ml, string)
/*
* Make a file readable only by its owner.
*/
- static void
-make_file_private(f)
- FILE *f;
+static void make_file_private(FILE *f)
{
#if HAVE_FCHMOD
int do_chmod = 1;
@@ -1711,8 +1608,7 @@ make_file_private(f)
* Does the history file need to be updated?
*/
#if CMD_HISTORY
- static int
-histfile_modified(VOID_PARAM)
+static int histfile_modified(void)
{
if (mlist_search.modified)
return 1;
@@ -1729,8 +1625,7 @@ histfile_modified(VOID_PARAM)
/*
* Update the .lesshst file.
*/
- public void
-save_cmdhist(VOID_PARAM)
+public void save_cmdhist(void)
{
#if CMD_HISTORY
char *histname;
diff --git a/command.c b/command.c
index 524b93892991..c28ae5682246 100644
--- a/command.c
+++ b/command.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -23,6 +23,7 @@
extern int erase_char, erase2_char, kill_char;
extern int sigs;
extern int quit_if_one_screen;
+extern int one_screen;
extern int squished;
extern int sc_width;
extern int sc_height;
@@ -36,6 +37,7 @@ extern int ignore_eoi;
extern int secure;
extern int hshift;
extern int bs_mode;
+extern int proc_backspace;
extern int show_attn;
extern int status_col;
extern POSITION highest_hilite;
@@ -63,6 +65,7 @@ extern int shift_count;
extern int oldbot;
extern int forw_prompt;
extern int incr_search;
+extern int full_screen;
#if MSDOS_COMPILER==WIN32C
extern int utf_mode;
#endif
@@ -72,6 +75,7 @@ static char *shellcmd = NULL; /* For holding last shell command for "!!" */
#endif
static int mca; /* The multicharacter command (action) */
static int search_type; /* The previous type of search */
+static int last_search_type; /* Type of last executed search */
static LINENUM number; /* The number typed by the user */
static long fraction; /* The fractional part of the number */
static struct loption *curropt;
@@ -81,6 +85,7 @@ static int optgetname;
static POSITION bottompos;
static int save_hshift;
static int save_bs_mode;
+static int save_proc_backspace;
#if PIPEC
static char pipec;
#endif
@@ -92,15 +97,14 @@ struct ungot {
};
static struct ungot* ungot = NULL;
-static void multi_search LESSPARAMS((char *pattern, int n, int silent));
+static void multi_search (char *pattern, int n, int silent);
/*
* Move the cursor to start of prompt line before executing a command.
* This looks nicer if the command takes a long time before
* updating the screen.
*/
- static void
-cmd_exec(VOID_PARAM)
+static void cmd_exec(void)
{
clear_attn();
clear_bot();
@@ -110,9 +114,7 @@ cmd_exec(VOID_PARAM)
/*
* Indicate we are reading a multi-character command.
*/
- static void
-set_mca(action)
- int action;
+static void set_mca(int action)
{
mca = action;
clear_bot();
@@ -122,8 +124,7 @@ set_mca(action)
/*
* Indicate we are not reading a multi-character command.
*/
- static void
-clear_mca(VOID_PARAM)
+static void clear_mca(void)
{
if (mca == 0)
return;
@@ -133,20 +134,14 @@ clear_mca(VOID_PARAM)
/*
* Set up the display to start a new multi-character command.
*/
- static void
-start_mca(action, prompt, mlist, cmdflags)
- int action;
- constant char *prompt;
- void *mlist;
- int cmdflags;
+static void start_mca(int action, constant char *prompt, void *mlist, int cmdflags)
{
set_mca(action);
cmd_putstr(prompt);
set_mlist(mlist, cmdflags);
}
- public int
-in_mca(VOID_PARAM)
+public int in_mca(void)
{
return (mca != 0 && mca != A_PREFIX);
}
@@ -154,9 +149,10 @@ in_mca(VOID_PARAM)
/*
* Set up the display to start a new search command.
*/
- static void
-mca_search1(VOID_PARAM)
+static void mca_search1(void)
{
+ int i;
+
#if HILITE_SEARCH
if (search_type & SRCH_FILTER)
set_mca(A_FILTER);
@@ -179,6 +175,15 @@ mca_search1(VOID_PARAM)
cmd_putstr("Regex-off ");
if (search_type & SRCH_WRAP)
cmd_putstr("Wrap ");
+ for (i = 1; i <= NUM_SEARCH_COLORS; i++)
+ {
+ if (search_type & SRCH_SUBSEARCH(i))
+ {
+ char buf[8];
+ SNPRINTF1(buf, sizeof(buf), "Sub-%d ", i);
+ cmd_putstr(buf);
+ }
+ }
#if HILITE_SEARCH
if (search_type & SRCH_FILTER)
@@ -192,8 +197,7 @@ mca_search1(VOID_PARAM)
forw_prompt = 0;
}
- static void
-mca_search(VOID_PARAM)
+static void mca_search(void)
{
mca_search1();
set_mlist(ml_search, 0);
@@ -202,8 +206,7 @@ mca_search(VOID_PARAM)
/*
* Set up the display to start a new toggle-option command.
*/
- static void
-mca_opt_toggle(VOID_PARAM)
+static void mca_opt_toggle(void)
{
int no_prompt;
int flag;
@@ -235,8 +238,7 @@ mca_opt_toggle(VOID_PARAM)
/*
* Execute a multicharacter command.
*/
- static void
-exec_mca(VOID_PARAM)
+static void exec_mca(void)
{
char *cbuf;
@@ -312,6 +314,11 @@ exec_mca(VOID_PARAM)
else
lsystem(shellcmd, "!done");
break;
+ case A_PSHELL:
+ if (secure)
+ break;
+ lsystem(pr_expand(cbuf), "#done");
+ break;
#endif
#if PIPEC
case A_PIPE:
@@ -327,9 +334,7 @@ exec_mca(VOID_PARAM)
/*
* Is a character an erase or kill char?
*/
- static int
-is_erase_char(c)
- int c;
+static int is_erase_char(int c)
{
return (c == erase_char || c == erase2_char || c == kill_char);
}
@@ -337,9 +342,7 @@ is_erase_char(c)
/*
* Is a character a carriage return or newline?
*/
- static int
-is_newline_char(c)
- int c;
+static int is_newline_char(int c)
{
return (c == '\n' || c == '\r');
}
@@ -347,9 +350,7 @@ is_newline_char(c)
/*
* Handle the first char of an option (after the initial dash).
*/
- static int
-mca_opt_first_char(c)
- int c;
+static int mca_opt_first_char(int c)
{
int no_prompt = (optflag & OPT_NO_PROMPT);
int flag = (optflag & ~OPT_NO_PROMPT);
@@ -400,9 +401,7 @@ mca_opt_first_char(c)
* If so, display the complete name and stop
* accepting chars until user hits RETURN.
*/
- static int
-mca_opt_nonfirst_char(c)
- int c;
+static int mca_opt_nonfirst_char(int c)
{
char *p;
char *oname;
@@ -457,9 +456,7 @@ mca_opt_nonfirst_char(c)
/*
* Handle a char of an option toggle command.
*/
- static int
-mca_opt_char(c)
- int c;
+static int mca_opt_char(int c)
{
PARG parg;
@@ -526,9 +523,7 @@ mca_opt_char(c)
/*
* Normalize search type.
*/
- public int
-norm_search_type(st)
- int st;
+public int norm_search_type(int st)
{
/* WRAP and PAST_EOF are mutually exclusive. */
if ((st & (SRCH_PAST_EOF|SRCH_WRAP)) == (SRCH_PAST_EOF|SRCH_WRAP))
@@ -539,9 +534,7 @@ norm_search_type(st)
/*
* Handle a char of a search command.
*/
- static int
-mca_search_char(c)
- int c;
+static int mca_search_char(int c)
{
int flag = 0;
@@ -571,6 +564,18 @@ mca_search_char(c)
if (mca != A_FILTER)
flag = SRCH_NO_MOVE;
break;
+ case CONTROL('S'): { /* SUBSEARCH */
+ char buf[32];
+ SNPRINTF1(buf, sizeof(buf), "Sub-pattern (1-%d):", NUM_SEARCH_COLORS);
+ clear_bot();
+ cmd_putstr(buf);
+ flush();
+ c = getcc();
+ if (c >= '1' && c <= '0'+NUM_SEARCH_COLORS)
+ flag = SRCH_SUBSEARCH(c-'0');
+ else
+ flag = -1; /* calls mca_search() below to repaint */
+ break; }
case CONTROL('W'): /* WRAP around */
if (mca != A_FILTER)
flag = SRCH_WRAP;
@@ -586,7 +591,8 @@ mca_search_char(c)
if (flag != 0)
{
- search_type = norm_search_type(search_type ^ flag);
+ if (flag != -1)
+ search_type = norm_search_type(search_type ^ flag);
mca_search();
return (MCA_MORE);
}
@@ -596,9 +602,7 @@ mca_search_char(c)
/*
* Handle a character of a multi-character command.
*/
- static int
-mca_char(c)
- int c;
+static int mca_char(int c)
{
int ret;
@@ -706,7 +710,7 @@ mca_char(c)
if (incr_search)
{
/* Incremental search: do a search after every input char. */
- int st = (search_type & (SRCH_FORW|SRCH_BACK|SRCH_NO_MATCH|SRCH_NO_REGEX|SRCH_NO_MOVE|SRCH_WRAP));
+ int st = (search_type & (SRCH_FORW|SRCH_BACK|SRCH_NO_MATCH|SRCH_NO_REGEX|SRCH_NO_MOVE|SRCH_WRAP|SRCH_SUBSEARCH_ALL));
char *pattern = get_cmdbuf();
if (pattern == NULL)
return (MCA_MORE);
@@ -728,6 +732,11 @@ mca_char(c)
undo_search(1);
}
/* Redraw the search prompt and search string. */
+ if (!full_screen)
+ {
+ clear();
+ repaint();
+ }
mca_search1();
updown_match = save_updown_match;
cmd_repaint(NULL);
@@ -744,8 +753,7 @@ mca_char(c)
/*
* Discard any buffered file data.
*/
- static void
-clear_buffers(VOID_PARAM)
+static void clear_buffers(void)
{
if (!(ch_getflags() & CH_CANSEEK))
return;
@@ -759,10 +767,15 @@ clear_buffers(VOID_PARAM)
/*
* Make sure the screen is displayed.
*/
- static void
-make_display(VOID_PARAM)
+static void make_display(void)
{
/*
+ * If not full_screen, we can't rely on scrolling to fill the screen.
+ * We need to clear and repaint screen before any change.
+ */
+ if (!full_screen && !(quit_if_one_screen && one_screen))
+ clear();
+ /*
* If nothing is displayed yet, display starting from initial_scrpos.
*/
if (empty_screen())
@@ -771,7 +784,7 @@ make_display(VOID_PARAM)
jump_loc(ch_zero(), 1);
else
jump_loc(initial_scrpos.pos, initial_scrpos.ln);
- } else if (screen_trashed)
+ } else if (screen_trashed || !full_screen)
{
int save_top_scroll = top_scroll;
int save_ignore_eoi = ignore_eoi;
@@ -793,8 +806,7 @@ make_display(VOID_PARAM)
/*
* Display the appropriate prompt.
*/
- static void
-prompt(VOID_PARAM)
+static void prompt(void)
{
constant char *p;
@@ -889,8 +901,7 @@ prompt(VOID_PARAM)
/*
* Display the less version message.
*/
- public void
-dispversion(VOID_PARAM)
+public void dispversion(void)
{
PARG parg;
@@ -901,8 +912,7 @@ dispversion(VOID_PARAM)
/*
* Return a character to complete a partial command, if possible.
*/
- static LWCHAR
-getcc_end_command(VOID_PARAM)
+static LWCHAR getcc_end_command(void)
{
switch (mca)
{
@@ -911,6 +921,7 @@ getcc_end_command(VOID_PARAM)
return ('g');
case A_F_SEARCH:
case A_B_SEARCH:
+ case A_FILTER:
/* We have "/string" but no newline. Add the \n. */
return ('\n');
default:
@@ -925,8 +936,7 @@ getcc_end_command(VOID_PARAM)
* but may come from ungotten characters
* (characters previously given to ungetcc or ungetsc).
*/
- static LWCHAR
-getccu(VOID_PARAM)
+static LWCHAR getccu(void)
{
LWCHAR c = 0;
while (c == 0)
@@ -956,12 +966,7 @@ getccu(VOID_PARAM)
* Get a command character, but if we receive the orig sequence,
* convert it to the repl sequence.
*/
- static LWCHAR
-getcc_repl(orig, repl, gr_getc, gr_ungetc)
- char constant* orig;
- char constant* repl;
- LWCHAR (*gr_getc)(VOID_PARAM);
- void (*gr_ungetc)(LWCHAR);
+static LWCHAR getcc_repl(char constant *orig, char constant *repl, LWCHAR (*gr_getc)(void), void (*gr_ungetc)(LWCHAR))
{
LWCHAR c;
LWCHAR keys[16];
@@ -1000,8 +1005,7 @@ getcc_repl(orig, repl, gr_getc, gr_ungetc)
/*
* Get command character.
*/
- public int
-getcc(VOID_PARAM)
+public int getcc(void)
{
/* Replace kent (keypad Enter) with a newline. */
return getcc_repl(kent, "\n", getccu, ungetcc);
@@ -1011,9 +1015,7 @@ getcc(VOID_PARAM)
* "Unget" a command character.
* The next getcc() will return this character.
*/
- public void
-ungetcc(c)
- LWCHAR c;
+public void ungetcc(LWCHAR c)
{
struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
@@ -1026,9 +1028,7 @@ ungetcc(c)
* "Unget" a command character.
* If any other chars are already ungotten, put this one after those.
*/
- public void
-ungetcc_back(c)
- LWCHAR c;
+public void ungetcc_back(LWCHAR c)
{
struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
ug->ug_char = c;
@@ -1048,9 +1048,7 @@ ungetcc_back(c)
* Unget a whole string of command characters.
* The next sequence of getcc()'s will return this string.
*/
- public void
-ungetsc(s)
- char *s;
+public void ungetsc(char *s)
{
while (*s != '\0')
ungetcc_back(*s++);
@@ -1059,8 +1057,7 @@ ungetsc(s)
/*
* Peek the next command character, without consuming it.
*/
- public LWCHAR
-peekcc(VOID_PARAM)
+public LWCHAR peekcc(void)
{
LWCHAR c = getcc();
ungetcc(c);
@@ -1072,11 +1069,7 @@ peekcc(VOID_PARAM)
* If SRCH_FIRST_FILE is set, begin searching at the first file.
* If SRCH_PAST_EOF is set, continue the search thru multiple files.
*/
- static void
-multi_search(pattern, n, silent)
- char *pattern;
- int n;
- int silent;
+static void multi_search(char *pattern, int n, int silent)
{
int nomore;
IFILE save_ifile;
@@ -1085,6 +1078,8 @@ multi_search(pattern, n, silent)
changed_file = 0;
save_ifile = save_curr_ifile();
+ if ((search_type & (SRCH_FORW|SRCH_BACK)) == 0)
+ search_type |= SRCH_FORW;
if (search_type & SRCH_FIRST_FILE)
{
/*
@@ -1113,6 +1108,7 @@ multi_search(pattern, n, silent)
* using a /@@ search.
*/
search_type &= ~SRCH_NO_MOVE;
+ last_search_type = search_type;
if (n == 0)
{
/*
@@ -1169,9 +1165,7 @@ multi_search(pattern, n, silent)
/*
* Forward forever, or until a highlighted line appears.
*/
- static int
-forw_loop(until_hilite)
- int until_hilite;
+static int forw_loop(int until_hilite)
{
POSITION curr_len;
@@ -1210,8 +1204,7 @@ forw_loop(until_hilite)
* Main command processor.
* Accept and execute commands until a quit command.
*/
- public void
-commands(VOID_PARAM)
+public void commands(void)
{
int c;
int action;
@@ -1618,6 +1611,7 @@ commands(VOID_PARAM)
*/
hshift = save_hshift;
bs_mode = save_bs_mode;
+ proc_backspace = save_proc_backspace;
if (edit_prev(1) == 0)
break;
}
@@ -1635,7 +1629,6 @@ commands(VOID_PARAM)
cmd_exec(); \
multi_search((char *)NULL, (int) number, 0);
-
case A_F_SEARCH:
/*
* Search forward for a pattern.
@@ -1675,6 +1668,7 @@ commands(VOID_PARAM)
/*
* Repeat previous search.
*/
+ search_type = last_search_type;
DO_SEARCH();
break;
@@ -1682,7 +1676,7 @@ commands(VOID_PARAM)
/*
* Repeat previous search, multiple files.
*/
- search_type |= SRCH_PAST_EOF;
+ search_type = last_search_type | SRCH_PAST_EOF;
DO_SEARCH();
break;
@@ -1690,10 +1684,10 @@ commands(VOID_PARAM)
/*
* Repeat previous search, in reverse direction.
*/
- save_search_type = search_type;
+ save_search_type = search_type = last_search_type;
search_type = SRCH_REVERSE(search_type);
DO_SEARCH();
- search_type = save_search_type;
+ last_search_type = save_search_type;
break;
case A_T_REVERSE_SEARCH:
@@ -1701,11 +1695,10 @@ commands(VOID_PARAM)
* Repeat previous search,
* multiple files in reverse direction.
*/
- save_search_type = search_type;
- search_type = SRCH_REVERSE(search_type);
- search_type |= SRCH_PAST_EOF;
+ save_search_type = search_type = last_search_type;
+ search_type = SRCH_REVERSE(search_type) | SRCH_PAST_EOF;
DO_SEARCH();
- search_type = save_search_type;
+ last_search_type = save_search_type;
break;
case A_UNDO_SEARCH:
@@ -1727,6 +1720,8 @@ commands(VOID_PARAM)
hshift = 0;
save_bs_mode = bs_mode;
bs_mode = BS_SPECIAL;
+ save_proc_backspace = proc_backspace;
+ proc_backspace = OPT_OFF;
(void) edit(FAKE_HELPFILE);
break;
@@ -1939,13 +1934,14 @@ commands(VOID_PARAM)
goto again;
case A_SHELL:
+ case A_PSHELL:
/*
* Shell escape.
*/
#if SHELL_ESCAPE
if (!secure)
{
- start_mca(A_SHELL, "!", ml_shell, 0);
+ start_mca(action, (action == A_SHELL) ? "!" : "#", ml_shell, 0);
c = getcc();
goto again;
}
diff --git a/compose.uni b/compose.uni
index cc7ddcf02bb9..d650016939f8 100644
--- a/compose.uni
+++ b/compose.uni
@@ -1,4 +1,4 @@
-/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:16 PDT 2022 */
+/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Mon Nov 14 18:19:23 PST 2022 */
{ 0x0300, 0x036f }, /* Mn */
{ 0x0483, 0x0487 }, /* Mn */
{ 0x0488, 0x0489 }, /* Me */
@@ -92,7 +92,7 @@
{ 0x0e47, 0x0e4e }, /* Mn */
{ 0x0eb1, 0x0eb1 }, /* Mn */
{ 0x0eb4, 0x0ebc }, /* Mn */
- { 0x0ec8, 0x0ecd }, /* Mn */
+ { 0x0ec8, 0x0ece }, /* Mn */
{ 0x0f18, 0x0f19 }, /* Mn */
{ 0x0f35, 0x0f35 }, /* Mn */
{ 0x0f37, 0x0f37 }, /* Mn */
@@ -230,6 +230,7 @@
{ 0x10ae5, 0x10ae6 }, /* Mn */
{ 0x10d24, 0x10d27 }, /* Mn */
{ 0x10eab, 0x10eac }, /* Mn */
+ { 0x10efd, 0x10eff }, /* Mn */
{ 0x10f46, 0x10f50 }, /* Mn */
{ 0x10f82, 0x10f85 }, /* Mn */
{ 0x11001, 0x11001 }, /* Mn */
@@ -252,6 +253,7 @@
{ 0x11234, 0x11234 }, /* Mn */
{ 0x11236, 0x11237 }, /* Mn */
{ 0x1123e, 0x1123e }, /* Mn */
+ { 0x11241, 0x11241 }, /* Mn */
{ 0x112df, 0x112df }, /* Mn */
{ 0x112e3, 0x112ea }, /* Mn */
{ 0x11300, 0x11301 }, /* Mn */
@@ -313,6 +315,12 @@
{ 0x11d95, 0x11d95 }, /* Mn */
{ 0x11d97, 0x11d97 }, /* Mn */
{ 0x11ef3, 0x11ef4 }, /* Mn */
+ { 0x11f00, 0x11f01 }, /* Mn */
+ { 0x11f36, 0x11f3a }, /* Mn */
+ { 0x11f40, 0x11f40 }, /* Mn */
+ { 0x11f42, 0x11f42 }, /* Mn */
+ { 0x13440, 0x13440 }, /* Mn */
+ { 0x13447, 0x13455 }, /* Mn */
{ 0x16af0, 0x16af4 }, /* Mn */
{ 0x16b30, 0x16b36 }, /* Mn */
{ 0x16f4f, 0x16f4f }, /* Mn */
@@ -337,9 +345,11 @@
{ 0x1e01b, 0x1e021 }, /* Mn */
{ 0x1e023, 0x1e024 }, /* Mn */
{ 0x1e026, 0x1e02a }, /* Mn */
+ { 0x1e08f, 0x1e08f }, /* Mn */
{ 0x1e130, 0x1e136 }, /* Mn */
{ 0x1e2ae, 0x1e2ae }, /* Mn */
{ 0x1e2ec, 0x1e2ef }, /* Mn */
+ { 0x1e4ec, 0x1e4ef }, /* Mn */
{ 0x1e8d0, 0x1e8d6 }, /* Mn */
{ 0x1e944, 0x1e94a }, /* Mn */
{ 0xe0100, 0xe01ef }, /* Mn */
diff --git a/configure b/configure
index eb346f8a3463..c45683cc58f2 100755
--- a/configure
+++ b/configure
@@ -583,6 +583,7 @@ PACKAGE_BUGREPORT=''
PACKAGE_URL=''
ac_unique_file="forwback.c"
+ac_header_list=
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
@@ -680,7 +681,6 @@ ac_user_opts='
enable_option_checking
enable_largefile
with_secure
-with_no_float
with_regex
with_editor
'
@@ -1319,7 +1319,6 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-secure Compile in secure mode
- --with-no-float Do not use floating point
--with-regex=LIB select regular expression library (LIB is one of auto,none,gnu,pcre,pcre2,posix,regcmp,re_comp,regcomp,regcomp-local) [auto]
--with-editor=PROGRAM use PROGRAM as the default editor [vi]
@@ -1534,6 +1533,37 @@ fi
} # ac_fn_c_try_cpp
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
@@ -1576,124 +1606,6 @@ fi
} # ac_fn_c_try_run
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if eval \${$3+:} false; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
- # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_header_compiler=yes
-else
- ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- ac_header_preproc=yes
-else
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
- yes:no: )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
- no:yes:* )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
-esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -2098,6 +2010,27 @@ $as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
+as_fn_append ac_header_list " ctype.h"
+as_fn_append ac_header_list " errno.h"
+as_fn_append ac_header_list " fcntl.h"
+as_fn_append ac_header_list " inttypes.h"
+as_fn_append ac_header_list " limits.h"
+as_fn_append ac_header_list " stdckdint.h"
+as_fn_append ac_header_list " stdio.h"
+as_fn_append ac_header_list " stdlib.h"
+as_fn_append ac_header_list " string.h"
+as_fn_append ac_header_list " termcap.h"
+as_fn_append ac_header_list " termio.h"
+as_fn_append ac_header_list " termios.h"
+as_fn_append ac_header_list " time.h"
+as_fn_append ac_header_list " unistd.h"
+as_fn_append ac_header_list " values.h"
+as_fn_append ac_header_list " linux/magic.h"
+as_fn_append ac_header_list " sys/ioctl.h"
+as_fn_append ac_header_list " sys/stream.h"
+as_fn_append ac_header_list " sys/types.h"
+as_fn_append ac_header_list " sys/wait.h"
+as_fn_append ac_header_list " wctype.h"
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
@@ -4178,10 +4111,14 @@ fi
done
-for ac_header in ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h
+
+
+
+ for ac_header in $ac_header_list
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
@@ -4192,6 +4129,49 @@ fi
done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Checks for typedefs, structures, and compiler characteristics.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5
$as_echo_n "checking whether stat file-mode macros are broken... " >&6; }
@@ -4338,41 +4318,6 @@ _ACEOF
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
-$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
-if ${ac_cv_header_time+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_time=yes
-else
- ac_cv_header_time=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
-$as_echo "$ac_cv_header_time" >&6; }
-if test $ac_cv_header_time = yes; then
-
-$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-
# Checks for terminal libraries
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working terminal libraries" >&5
@@ -4698,19 +4643,7 @@ LIBS="$LIBS $TERMLIBS"
-
# Checks for identifiers.
-ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
-if test "x$ac_cv_type_off_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define off_t long int
-_ACEOF
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for void" >&5
$as_echo_n "checking for void... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4805,6 +4738,9 @@ $as_echo_n "checking for procfs... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/statfs.h>
+#if HAVE_LINUX_MAGIC_H
+#include <linux/magic.h>
+#endif
int
main ()
{
@@ -4848,40 +4784,7 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Checks for library functions.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
-$as_echo_n "checking return type of signal handlers... " >&6; }
-if ${ac_cv_type_signal+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-
-int
-main ()
-{
-return *(signal (0, 0)) (0) == 1;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_type_signal=int
-else
- ac_cv_type_signal=void
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
-$as_echo "$ac_cv_type_signal" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define RETSIGTYPE $ac_cv_type_signal
-_ACEOF
-
-
-for ac_func in fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep
+for ac_func in fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat strsignal system ttyname usleep
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -5305,44 +5208,6 @@ else
fi
-# Should we use floating point?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for floating point" >&5
-$as_echo_n "checking for floating point... " >&6; }
-
-# Check whether --with-no-float was given.
-if test "${with_no_float+set}" = set; then :
- withval=$with_no_float; WANT_NO_FLOAT=1
-else
- WANT_NO_FLOAT=0
-fi
-
-if test $WANT_NO_FLOAT = 0; then
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-double f1 = 12.5; double f2 = f1*f1/2.5;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled by user" >&5
-$as_echo "disabled by user" >&6; }
-fi
-
# Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
diff --git a/configure.ac b/configure.ac
index f7c648142d43..b591183d6fd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1984-2022 Mark Nudelman
+# Copyright (C) 1984-2023 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.
@@ -9,13 +9,13 @@
# contact the author, see the README file.
# Autoconf initialization.
-AC_INIT(less, 1)
+AC_INIT([less],[1])
AC_CONFIG_SRCDIR([forwback.c])
-AC_CONFIG_HEADER([defines.h])
+AC_CONFIG_HEADERS([defines.h])
# Checks for programs.
AC_PROG_CC
-AC_ISC_POSIX
+AC_SEARCH_LIBS([strerror],[cposix])
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
@@ -36,15 +36,13 @@ AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
AC_SEARCH_LIBS([regcmp], [gen intl PW])
# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h])
+AC_CHECK_HEADERS_ONCE([ctype.h errno.h fcntl.h inttypes.h limits.h stdckdint.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h linux/magic.h sys/ioctl.h sys/stream.h sys/types.h sys/wait.h time.h wctype.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
-AC_HEADER_TIME
# Checks for terminal libraries
AC_MSG_CHECKING([for working terminal libraries])
@@ -71,8 +69,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-ltinfo"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -84,8 +81,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-ltinfow"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -97,8 +93,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lxcurses"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -110,8 +105,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lncursesw"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -123,8 +117,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lncurses"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -136,8 +129,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lcurses"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -150,8 +142,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lcurses -ltermcap"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -165,8 +156,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-ltermcap"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -178,8 +168,7 @@ if test "x$TERMLIBS" = x; then
TERMLIBS="-lcurses -ltermlib"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
- AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
- [termok=yes], [termok=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$include_termcap_h]], [[tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);]])],[termok=yes],[termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
@@ -213,8 +202,6 @@ AH_TEMPLATE([HAVE_REGEXEC2],
[])
AH_TEMPLATE([HAVE_VOID],
[Define HAVE_VOID if your compiler supports the "void" type.])
-AH_TEMPLATE([HAVE_FLOAT],
- [Define HAVE_FLOAT if your compiler supports the "double" type.])
AH_TEMPLATE([HAVE_CONST],
[Define HAVE_CONST if your compiler supports the "const" modifier.])
AH_TEMPLATE([HAVE_STAT_INO],
@@ -255,69 +242,58 @@ AH_TEMPLATE([SECURE_COMPILE],
[Define SECURE_COMPILE=1 to build a secure version of less.])
# Checks for identifiers.
-AC_TYPE_OFF_T
AC_MSG_CHECKING(for void)
-AC_TRY_COMPILE(, [void *foo = 0;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void *foo = 0;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for const)
-AC_TRY_COMPILE(, [const int foo = 0;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[const int foo = 0;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for time_t)
-AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t t = 0;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for st_ino in struct stat)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>],
- [struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
+#include <sys/stat.h>]], [[struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for procfs)
-AC_TRY_COMPILE([#include <sys/statfs.h>],
- [struct statfs s; s.f_type = PROC_SUPER_MAGIC; (void) fstatfs(0,&s); ],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PROCFS)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statfs.h>
+#if HAVE_LINUX_MAGIC_H
+#include <linux/magic.h>
+#endif]], [[struct statfs s; s.f_type = PROC_SUPER_MAGIC; (void) fstatfs(0,&s); ]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PROCFS)],[AC_MSG_RESULT(no)])
# Checks for ANSI function prototypes.
AC_MSG_CHECKING(for ANSI function prototypes)
-AC_TRY_COMPILE([], [int f(int a) { return a; }],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ANSI_PROTOS)], [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int f(int a) { return a; }]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ANSI_PROTOS)],[AC_MSG_RESULT(no)])
# Checks for library functions.
-AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep])
+AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat strsignal system ttyname usleep])
# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
AC_MSG_CHECKING(for memcpy)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_STRING_H
#include <string.h>
-#endif], [memcpy(0,0,0);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
+#endif]], [[memcpy(0,0,0);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strchr)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_STRING_H
#include <string.h>
-#endif], [strchr("x",'x');],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
+#endif]], [[strchr("x",'x');]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strstr)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_STRING_H
#include <string.h>
-#endif], [strstr("x","x");],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
+#endif]], [[strstr("x","x");]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)],[AC_MSG_RESULT(no)])
# Some systems have termios.h but not the corresponding functions.
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
AC_MSG_CHECKING(for fileno)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_STDIO_H
#include <stdio.h>
-#endif], [static int x; x = fileno(stdin);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
+#endif]], [[static int x; x = fileno(stdin);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strerror)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_STDIO_H
#include <stdio.h>
#endif
@@ -326,70 +302,58 @@ AC_TRY_LINK([
#endif
#if HAVE_ERRNO_H
#include <errno.h>
-#endif], [static char *x; x = strerror(0);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
+#endif]], [[static char *x; x = strerror(0);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for sys_errlist)
-AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *sys_errlist[]; static char **x; x = sys_errlist;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)],[AC_MSG_RESULT(no)])
AC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
AC_MSG_CHECKING(for sigemptyset)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <signal.h>
-], [sigset_t s; sigemptyset(&s);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
+]], [[sigset_t s; sigemptyset(&s);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)],[AC_MSG_RESULT(no)])
have_errno=no
AC_MSG_CHECKING(for errno)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_ERRNO_H
#include <errno.h>
-#endif], [static int x; x = errno;],
- [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
+#endif]], [[static int x; x = errno;]])],[AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes],[])
if test $have_errno = no; then
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_ERRNO_H
#include <errno.h>
-#endif], [extern int errno; static int x; x = errno;],
- [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
- [AC_MSG_RESULT(no)])
+#endif]], [[extern int errno; static int x; x = errno;]])],[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],[AC_MSG_RESULT(no)])
fi
AC_MSG_CHECKING(for locale)
-AC_TRY_LINK([#include <locale.h>
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <locale.h>
#include <ctype.h>
-#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
+#include <langinfo.h>]], [[setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for ctype functions)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if HAVE_CTYPE_H
#include <ctype.h>
-#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
+#endif]], [[static int x; x = isupper(x); x = tolower(x); x = toupper(x);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for wctype functions)
-AC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <wctype.h>]], [[iswlower(0); iswupper(0); towlower(0); towupper(0);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)],[AC_MSG_RESULT(no)])
# Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
#if HAVE_TERMCAP_H
#include <termcap.h>
-#endif], [ospeed = 0;],
-[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
+#endif]], [[ospeed = 0;]])],[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes],[])
if test $have_ospeed = no; then
-AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
- [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
- [AC_MSG_RESULT(no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern short ospeed; ospeed = 0;]])],[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],[AC_MSG_RESULT(no)])
fi
# Compile in secure mode?
@@ -399,18 +363,6 @@ AC_ARG_WITH(secure,
AC_SUBST(SECURE_COMPILE,1), AC_DEFINE(SECURE_COMPILE, 0)
AC_SUBST(SECURE_COMPILE,0))
-# Should we use floating point?
-AC_MSG_CHECKING(for floating point)
-AC_ARG_WITH(no-float,
- [ --with-no-float Do not use floating point],
- WANT_NO_FLOAT=1, WANT_NO_FLOAT=0)
-if test $WANT_NO_FLOAT = 0; then
- AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;],
- [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT)], [AC_MSG_RESULT(no)])
-else
- AC_MSG_RESULT(disabled by user)
-fi
-
# Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
@@ -427,7 +379,7 @@ if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
# Some versions of Solaris have a regcomp() function, but it doesn't work!
# So we run a test program. If we're cross-compiling, do it the old way.
AC_MSG_CHECKING(for POSIX regcomp)
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <regex.h>
int main() { regex_t r; regmatch_t rm; char *text = "xabcy";
@@ -438,19 +390,16 @@ if (rm.rm_so != 1) return (1); /* check for correct offset */
#else
if (rm.rm_sp != text + 1) return (1); /* check for correct offset */
#endif
-return (0); }],
- have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
+return (0); }]])],[have_posix_regex=yes],[have_posix_regex=no],[have_posix_regex=unknown])
if test $have_posix_regex = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_POSIX_REGCOMP) supported_regex="$supported_regex posix"
have_regex=yes
elif test $have_posix_regex = unknown; then
- AC_TRY_LINK([
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
-#include <regex.h>],
- [regex_t *r; regfree(r);],
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes; supported_regex="$supported_regex posix")
+#include <regex.h>]], [[regex_t *r; regfree(r);]])],[AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes; supported_regex="$supported_regex posix"],[])
else
AC_MSG_RESULT(no)
fi
@@ -488,9 +437,8 @@ fi
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
AC_MSG_CHECKING(for V8 regcomp)
-AC_TRY_LINK([
-#include "regexp.h"], [regcomp("");],
-[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes; supported_regex="$supported_regex regcomp"],[AC_MSG_RESULT(no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include "regexp.h"]], [[regcomp("");]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes; supported_regex="$supported_regex regcomp"],[AC_MSG_RESULT(no)])
fi
fi
@@ -738,6 +686,9 @@ AH_TOP([
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
#endif
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
/* Settings automatically determined by configure. */
])
diff --git a/cvt.c b/cvt.c
index bb4649264f12..b9997ffbc7cb 100644
--- a/cvt.c
+++ b/cvt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -19,10 +19,7 @@ extern int utf_mode;
/*
* Get the length of a buffer needed to convert a string.
*/
- public int
-cvt_length(len, ops)
- int len;
- int ops;
+public int cvt_length(int len, int ops)
{
if (utf_mode)
/*
@@ -37,9 +34,7 @@ cvt_length(len, ops)
/*
* Allocate a chpos array for use by cvt_text.
*/
- public int *
-cvt_alloc_chpos(len)
- int len;
+public int * cvt_alloc_chpos(int len)
{
int i;
int *chpos = (int *) ecalloc(sizeof(int), len);
@@ -54,13 +49,7 @@ cvt_alloc_chpos(len)
* Returns converted text in odst. The original offset of each
* odst character (when it was in osrc) is returned in the chpos array.
*/
- public void
-cvt_text(odst, osrc, chpos, lenp, ops)
- char *odst;
- char *osrc;
- int *chpos;
- int *lenp;
- int ops;
+public void cvt_text(char *odst, char *osrc, int *chpos, int *lenp, int ops)
{
char *dst;
char *edst = odst;
diff --git a/decode.c b/decode.c
index 0444cab399c9..e7969a886d39 100644
--- a/decode.c
+++ b/decode.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -166,6 +166,7 @@ static unsigned char cmdtable[] =
'|',0, A_PIPE,
'v',0, A_VISUAL,
'!',0, A_SHELL,
+ '#',0, A_PSHELL,
'+',0, A_FIRSTCMD,
'H',0, A_HELP,
@@ -242,10 +243,7 @@ static struct tablelist *list_sysvar_tables = NULL;
/*
* Expand special key abbreviations in a command table.
*/
- static void
-expand_special_keys(table, len)
- char *table;
- int len;
+static void expand_special_keys(char *table, int len)
{
char *fm;
char *to;
@@ -303,9 +301,7 @@ expand_special_keys(table, len)
/*
* Expand special key abbreviations in a list of command tables.
*/
- static void
-expand_cmd_table(tlist)
- struct tablelist *tlist;
+static void expand_cmd_table(struct tablelist *tlist)
{
struct tablelist *t;
for (t = tlist; t != NULL; t = t->t_next)
@@ -317,8 +313,7 @@ expand_cmd_table(tlist)
/*
* Expand special key abbreviations in all command tables.
*/
- public void
-expand_cmd_tables(VOID_PARAM)
+public void expand_cmd_tables(void)
{
expand_cmd_table(list_fcmd_tables);
expand_cmd_table(list_ecmd_tables);
@@ -330,8 +325,7 @@ expand_cmd_tables(VOID_PARAM)
/*
* Initialize the command lists.
*/
- public void
-init_cmds(VOID_PARAM)
+public void init_cmds(void)
{
/*
* Add the default command tables.
@@ -380,11 +374,7 @@ init_cmds(VOID_PARAM)
/*
* Add a command table.
*/
- static int
-add_cmd_table(tlist, buf, len)
- struct tablelist **tlist;
- char *buf;
- int len;
+static int add_cmd_table(struct tablelist **tlist, char *buf, int len)
{
struct tablelist *t;
@@ -409,10 +399,7 @@ add_cmd_table(tlist, buf, len)
/*
* Add a command table.
*/
- public void
-add_fcmd_table(buf, len)
- char *buf;
- int len;
+public void add_fcmd_table(char *buf, int len)
{
if (add_cmd_table(&list_fcmd_tables, buf, len) < 0)
error("Warning: some commands disabled", NULL_PARG);
@@ -421,10 +408,7 @@ add_fcmd_table(buf, len)
/*
* Add an editing command table.
*/
- public void
-add_ecmd_table(buf, len)
- char *buf;
- int len;
+public void add_ecmd_table(char *buf, int len)
{
if (add_cmd_table(&list_ecmd_tables, buf, len) < 0)
error("Warning: some edit commands disabled", NULL_PARG);
@@ -433,11 +417,7 @@ add_ecmd_table(buf, len)
/*
* Add an environment variable table.
*/
- static void
-add_var_table(tlist, buf, len)
- struct tablelist **tlist;
- char *buf;
- int len;
+static void add_var_table(struct tablelist **tlist, char *buf, int len)
{
if (add_cmd_table(tlist, buf, len) < 0)
error("Warning: environment variables from lesskey file unavailable", NULL_PARG);
@@ -446,8 +426,7 @@ add_var_table(tlist, buf, len)
/*
* Return action for a mouse wheel down event.
*/
- static int
-mouse_wheel_down(VOID_PARAM)
+static int mouse_wheel_down(void)
{
return ((mousecap == OPT_ONPLUS) ? A_B_MOUSE : A_F_MOUSE);
}
@@ -455,8 +434,7 @@ mouse_wheel_down(VOID_PARAM)
/*
* Return action for a mouse wheel up event.
*/
- static int
-mouse_wheel_up(VOID_PARAM)
+static int mouse_wheel_up(void)
{
return ((mousecap == OPT_ONPLUS) ? A_F_MOUSE : A_B_MOUSE);
}
@@ -464,10 +442,7 @@ mouse_wheel_up(VOID_PARAM)
/*
* Return action for a mouse button release event.
*/
- static int
-mouse_button_rel(x, y)
- int x;
- int y;
+static int mouse_button_rel(int x, int y)
{
/*
* {{ It would be better to return an action and then do this
@@ -484,9 +459,7 @@ mouse_button_rel(x, y)
/*
* Read a decimal integer. Return the integer and set *pterm to the terminating char.
*/
- static int
-getcc_int(pterm)
- char* pterm;
+static int getcc_int(char *pterm)
{
int num = 0;
int digits = 0;
@@ -500,7 +473,8 @@ getcc_int(pterm)
return (-1);
return (num);
}
- num = (10 * num) + (ch - '0');
+ if (ckd_mul(&num, num, 10) || ckd_add(&num, num, ch - '0'))
+ return -1;
++digits;
}
}
@@ -509,9 +483,7 @@ getcc_int(pterm)
* Read suffix of mouse input and return the action to take.
* The prefix ("\e[M") has already been read.
*/
- static int
-x11mouse_action(skip)
- int skip;
+static int x11mouse_action(int skip)
{
int b = getcc() - X11MOUSE_OFFSET;
int x = getcc() - X11MOUSE_OFFSET-1;
@@ -534,9 +506,7 @@ x11mouse_action(skip)
* Read suffix of mouse input and return the action to take.
* The prefix ("\e[<") has already been read.
*/
- static int
-x116mouse_action(skip)
- int skip;
+static int x116mouse_action(int skip)
{
char ch;
int x, y;
@@ -562,12 +532,7 @@ x116mouse_action(skip)
/*
* Search a single command table for the command string in cmd.
*/
- static int
-cmd_search(cmd, table, endtable, sp)
- char *cmd;
- char *table;
- char *endtable;
- char **sp;
+static int cmd_search(char *cmd, char *table, char *endtable, char **sp)
{
char *p;
char *q;
@@ -658,11 +623,7 @@ cmd_search(cmd, table, endtable, sp)
* Decode a command character and return the associated action.
* The "extra" string, if any, is returned in sp.
*/
- static int
-cmd_decode(tlist, cmd, sp)
- struct tablelist *tlist;
- char *cmd;
- char **sp;
+static int cmd_decode(struct tablelist *tlist, char *cmd, char **sp)
{
struct tablelist *t;
int action = A_INVALID;
@@ -685,10 +646,7 @@ cmd_decode(tlist, cmd, sp)
/*
* Decode a command from the cmdtables list.
*/
- public int
-fcmd_decode(cmd, sp)
- char *cmd;
- char **sp;
+public int fcmd_decode(char *cmd, char **sp)
{
return (cmd_decode(list_fcmd_tables, cmd, sp));
}
@@ -696,10 +654,7 @@ fcmd_decode(cmd, sp)
/*
* Decode a command from the edittables list.
*/
- public int
-ecmd_decode(cmd, sp)
- char *cmd;
- char **sp;
+public int ecmd_decode(char *cmd, char **sp)
{
return (cmd_decode(list_ecmd_tables, cmd, sp));
}
@@ -708,9 +663,7 @@ ecmd_decode(cmd, sp)
* Get the value of an environment variable.
* Looks first in the lesskey file, then in the real environment.
*/
- public char *
-lgetenv(var)
- char *var;
+public char * lgetenv(char *var)
{
int a;
char *s;
@@ -730,9 +683,7 @@ lgetenv(var)
/*
* Is a string null or empty?
*/
- public int
-isnullenv(s)
- char* s;
+public int isnullenv(char *s)
{
return (s == NULL || *s == '\0');
}
@@ -743,9 +694,7 @@ isnullenv(s)
* Integers are stored in a funny format:
* two bytes, low order first, in radix KRADIX.
*/
- static int
-gint(sp)
- char **sp;
+static int gint(char **sp)
{
int n;
@@ -757,10 +706,7 @@ gint(sp)
/*
* Process an old (pre-v241) lesskey file.
*/
- static int
-old_lesskey(buf, len)
- char *buf;
- int len;
+static int old_lesskey(char *buf, int len)
{
/*
* Old-style lesskey file.
@@ -778,11 +724,7 @@ old_lesskey(buf, len)
/*
* Process a new (post-v241) lesskey file.
*/
- static int
-new_lesskey(buf, len, sysvar)
- char *buf;
- int len;
- int sysvar;
+static int new_lesskey(char *buf, int len, int sysvar)
{
char *p;
char *end;
@@ -840,10 +782,7 @@ new_lesskey(buf, len, sysvar)
/*
* Set up a user command table, based on a "lesskey" file.
*/
- public int
-lesskey(filename, sysvar)
- char *filename;
- int sysvar;
+public int lesskey(char *filename, int sysvar)
{
char *buf;
POSITION len;
@@ -907,25 +846,20 @@ lesskey(filename, sysvar)
}
#if HAVE_LESSKEYSRC
- public int
-lesskey_src(filename, sysvar)
- char *filename;
- int sysvar;
+public int lesskey_src(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_fcmd_table(xbuf_char_data(&tables.cmdtable.buf), tables.cmdtable.buf.end);
+ add_ecmd_table(xbuf_char_data(&tables.edittable.buf), tables.edittable.buf.end);
add_var_table(sysvar ? &list_sysvar_tables : &list_var_tables,
- tables.vartable.buf.data, tables.vartable.buf.end);
+ xbuf_char_data(&tables.vartable.buf), tables.vartable.buf.end);
return (0);
}
- void
-lesskey_parse_error(s)
- char *s;
+void lesskey_parse_error(char *s)
{
PARG parg;
parg.p_string = s;
@@ -936,12 +870,7 @@ lesskey_parse_error(s)
/*
* Add a lesskey file.
*/
- public int
-add_hometable(call_lesskey, envname, def_filename, sysvar)
- int (*call_lesskey)(char *, int);
- char *envname;
- char *def_filename;
- int sysvar;
+public int add_hometable(int (*call_lesskey)(char *, int), char *envname, char *def_filename, int sysvar)
{
char *filename;
int r;
@@ -980,10 +909,7 @@ add_hometable(call_lesskey, envname, def_filename, sysvar)
/*
* See if a char is a special line-editing command.
*/
- public int
-editchar(c, flags)
- int c;
- int flags;
+public int editchar(int c, int flags)
{
int action;
int nch;
diff --git a/defines.ds b/defines.ds
index d358fec5e524..5b900c5bdd5c 100644
--- a/defines.ds
+++ b/defines.ds
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -342,9 +342,6 @@
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define HAVE_FLOAT if your compiler supports the "double" type. */
-#define HAVE_FLOAT 1
-
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
diff --git a/defines.h.in b/defines.h.in
index e5559d1153f9..ec5a50b562d9 100644
--- a/defines.h.in
+++ b/defines.h.in
@@ -213,6 +213,9 @@
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
#endif
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
/* Settings automatically determined by configure. */
@@ -240,9 +243,6 @@
/* Define HAVE_FILENO if you have the fileno() macro. */
#undef HAVE_FILENO
-/* Define HAVE_FLOAT if your compiler supports the "double" type. */
-#undef HAVE_FLOAT
-
/* Define to 1 if you have the `fsync' function. */
#undef HAVE_FSYNC
@@ -255,6 +255,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
+/* Define to 1 if you have the <linux/magic.h> header file. */
+#undef HAVE_LINUX_MAGIC_H
+
/* Define HAVE_LOCALE if you have locale.h and setlocale. */
#undef HAVE_LOCALE
@@ -319,6 +322,9 @@
/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
#undef HAVE_STAT_INO
+/* Define to 1 if you have the <stdckdint.h> header file. */
+#undef HAVE_STDCKDINT_H
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -337,6 +343,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strsignal' function. */
+#undef HAVE_STRSIGNAL
+
/* Define to 1 if you have the `system' function. */
#undef HAVE_SYSTEM
@@ -355,6 +364,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
/* Define to 1 if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
@@ -432,9 +444,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
/* Define SECURE_COMPILE=1 to build a secure version of less. */
#undef SECURE_COMPILE
@@ -444,9 +453,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
diff --git a/defines.o2 b/defines.o2
index 9438bb2634c4..a1ee53adf92a 100644
--- a/defines.o2
+++ b/defines.o2
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/defines.o9 b/defines.o9
index 28a93d66954c..a0303cd129bc 100644
--- a/defines.o9
+++ b/defines.o9
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/defines.wn b/defines.wn
index 30592cad3785..a72caea42d5e 100644
--- a/defines.wn
+++ b/defines.wn
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -327,9 +327,6 @@
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define HAVE_FLOAT if your compiler supports the "double" type. */
-#define HAVE_FLOAT 1
-
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
diff --git a/edit.c b/edit.c
index 151ac744f7b5..a367f161fe53 100644
--- a/edit.c
+++ b/edit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -13,6 +13,9 @@
#if HAVE_STAT
#include <sys/stat.h>
#endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
#if OS2
#include <signal.h>
#endif
@@ -28,6 +31,8 @@ extern int sigs;
extern int hshift;
extern int want_filesize;
extern int consecutive_nulls;
+extern int modelines;
+extern int show_preproc_error;
extern IFILE curr_ifile;
extern IFILE old_ifile;
extern struct scrpos initial_scrpos;
@@ -55,10 +60,7 @@ public ino_t curr_ino;
* words, returning each one as a standard null-terminated string.
* back_textlist does the same, but runs thru the list backwards.
*/
- public void
-init_textlist(tlist, str)
- struct textlist *tlist;
- char *str;
+public void init_textlist(struct textlist *tlist, char *str)
{
char *s;
#if SPACES_IN_FILENAMES
@@ -99,10 +101,7 @@ init_textlist(tlist, str)
}
}
- public char *
-forw_textlist(tlist, prev)
- struct textlist *tlist;
- char *prev;
+public char * forw_textlist(struct textlist *tlist, char *prev)
{
char *s;
@@ -123,10 +122,7 @@ forw_textlist(tlist, prev)
return (s);
}
- public char *
-back_textlist(tlist, prev)
- struct textlist *tlist;
- char *prev;
+public char * back_textlist(struct textlist *tlist, char *prev)
{
char *s;
@@ -150,11 +146,128 @@ back_textlist(tlist, prev)
}
/*
+ * Parse a single option setting in a modeline.
+ */
+static void modeline_option(char *str, int opt_len)
+{
+ struct mloption { char *opt_name; void (*opt_func)(char*,int); };
+ struct mloption options[] = {
+ { "ts=", set_tabs },
+ { "tabstop=", set_tabs },
+ { NULL, NULL }
+ };
+ struct mloption *opt;
+ for (opt = options; opt->opt_name != NULL; opt++)
+ {
+ int name_len = strlen(opt->opt_name);
+ if (opt_len > name_len && strncmp(str, opt->opt_name, name_len) == 0)
+ {
+ (*opt->opt_func)(str + name_len, opt_len - name_len);
+ break;
+ }
+ }
+}
+
+/*
+ * String length, terminated by option separator (space or colon).
+ * Space/colon can be escaped with backspace.
+ */
+static int modeline_option_len(char *str)
+{
+ int esc = FALSE;
+ char *s;
+ for (s = str; *s != '\0'; s++)
+ {
+ if (esc)
+ esc = FALSE;
+ else if (*s == '\\')
+ esc = TRUE;
+ else if (*s == ' ' || *s == ':') /* separator */
+ break;
+ }
+ return (s - str);
+}
+
+/*
+ * Parse colon- or space-separated option settings in a modeline.
+ */
+static void modeline_options(char *str, char end_char)
+{
+ for (;;)
+ {
+ int opt_len;
+ str = skipsp(str);
+ if (*str == '\0' || *str == end_char)
+ break;
+ opt_len = modeline_option_len(str);
+ modeline_option(str, opt_len);
+ str += opt_len;
+ if (*str != '\0')
+ str += 1; /* skip past the separator */
+ }
+}
+
+/*
+ * See if there is a modeline string in a line.
+ */
+static void check_modeline(char *line)
+{
+#if HAVE_STRSTR
+ static char *pgms[] = { "less:", "vim:", "vi:", "ex:", NULL };
+ char **pgm;
+ for (pgm = pgms; *pgm != NULL; ++pgm)
+ {
+ char *pline = line;
+ for (;;)
+ {
+ char *str;
+ pline = strstr(pline, *pgm);
+ if (pline == NULL) /* pgm is not in this line */
+ break;
+ str = skipsp(pline + strlen(*pgm));
+ if (pline == line || pline[-1] == ' ')
+ {
+ if (strncmp(str, "set ", 4) == 0)
+ modeline_options(str+4, ':');
+ else if (pgm != &pgms[0]) /* "less:" requires "set" */
+ modeline_options(str, '\0');
+ break;
+ }
+ /* Continue searching the rest of the line. */
+ pline = str;
+ }
+ }
+#endif /* HAVE_STRSTR */
+}
+
+/*
+ * Read lines from start of file and check if any are modelines.
+ */
+static void check_modelines(void)
+{
+ POSITION pos = ch_zero();
+ int i;
+ for (i = 0; i < modelines; i++)
+ {
+ char *line;
+ int line_len;
+ if (ABORT_SIGS())
+ return;
+ pos = forw_raw_line(pos, &line, &line_len);
+ if (pos == NULL_POSITION)
+ break;
+ check_modeline(line);
+ }
+}
+
+/*
* Close a pipe opened via popen.
*/
- static void
-close_pipe(FILE *pipefd)
+static void close_pipe(FILE *pipefd)
{
+ int status;
+ PARG parg;
+
if (pipefd == NULL)
return;
#if OS2
@@ -164,18 +277,79 @@ close_pipe(FILE *pipefd)
*/
kill(pipefd->_pid, SIGINT);
#endif
- pclose(pipefd);
+ status = pclose(pipefd);
+ if (status == -1)
+ {
+ /* An internal error in 'less', not a preprocessor error. */
+ parg.p_string = errno_message("pclose");
+ error("%s", &parg);
+ free(parg.p_string);
+ return;
+ }
+ if (!show_preproc_error)
+ return;
+#if defined WIFEXITED && defined WEXITSTATUS
+ if (WIFEXITED(status))
+ {
+ int s = WEXITSTATUS(status);
+ if (s != 0)
+ {
+ parg.p_int = s;
+ error("Input preprocessor failed (status %d)", &parg);
+ }
+ return;
+ }
+#endif
+#if defined WIFSIGNALED && defined WTERMSIG && HAVE_STRSIGNAL
+ if (WIFSIGNALED(status))
+ {
+ int sig = WTERMSIG(status);
+ if (sig != SIGPIPE || ch_length() != NULL_POSITION)
+ {
+ parg.p_string = signal_message(sig);
+ error("Input preprocessor terminated: %s", &parg);
+ }
+ return;
+ }
+#endif
+ if (status != 0)
+ {
+ parg.p_int = status;
+ error("Input preprocessor exited with status %x", &parg);
+ }
+}
+
+/*
+ * Drain and close an input pipe if needed.
+ */
+public void close_altpipe(IFILE ifile)
+{
+ FILE *altpipe = get_altpipe(ifile);
+ if (altpipe != NULL && !(ch_getflags() & CH_KEEPOPEN))
+ {
+ close_pipe(altpipe);
+ set_altpipe(ifile, NULL);
+ }
+}
+
+/*
+ * Check for error status from the current altpipe.
+ * May or may not close the pipe.
+ */
+public void check_altpipe_error(void)
+{
+ if (!show_preproc_error)
+ return;
+ if (curr_ifile != NULL_IFILE && get_altfilename(curr_ifile) != NULL)
+ close_altpipe(curr_ifile);
}
/*
* Close the current input file.
*/
- static void
-close_file(VOID_PARAM)
+static void close_file(void)
{
struct scrpos scrpos;
- int chflags;
- FILE *altpipe;
char *altfilename;
if (curr_ifile == NULL_IFILE)
@@ -194,7 +368,6 @@ close_file(VOID_PARAM)
/*
* Close the file descriptor, unless it is a pipe.
*/
- chflags = ch_getflags();
ch_close();
/*
* If we opened a file using an alternate name,
@@ -203,12 +376,7 @@ close_file(VOID_PARAM)
altfilename = get_altfilename(curr_ifile);
if (altfilename != NULL)
{
- altpipe = get_altpipe(curr_ifile);
- if (altpipe != NULL && !(chflags & CH_KEEPOPEN))
- {
- close_pipe(altpipe);
- set_altpipe(curr_ifile, NULL);
- }
+ close_altpipe(curr_ifile);
close_altfile(altfilename, get_filename(curr_ifile));
set_altfilename(curr_ifile, NULL);
}
@@ -223,9 +391,7 @@ close_file(VOID_PARAM)
* Filename == "-" means standard input.
* Filename == NULL means just close the current file.
*/
- public int
-edit(filename)
- char *filename;
+public int edit(char *filename)
{
if (filename == NULL)
return (edit_ifile(NULL_IFILE));
@@ -233,12 +399,38 @@ edit(filename)
}
/*
+ * Clean up what edit_ifile did before error return.
+ */
+static int edit_error(char *filename, char *alt_filename, void *altpipe, IFILE ifile, IFILE was_curr_ifile)
+{
+ if (alt_filename != NULL)
+ {
+ close_pipe(altpipe);
+ close_altfile(alt_filename, filename);
+ free(alt_filename);
+ }
+ del_ifile(ifile);
+ free(filename);
+ /*
+ * Re-open the current file.
+ */
+ if (was_curr_ifile == ifile)
+ {
+ /*
+ * Whoops. The "current" ifile is the one we just deleted.
+ * Just give up.
+ */
+ quit(QUIT_ERROR);
+ }
+ reedit_ifile(was_curr_ifile);
+ return (1);
+}
+
+/*
* Edit a new file (given its IFILE).
* ifile == NULL means just close the current file.
*/
- public int
-edit_ifile(ifile)
- IFILE ifile;
+public int edit_ifile(IFILE ifile)
{
int f;
int answer;
@@ -371,28 +563,7 @@ edit_ifile(ifile)
*/
error("%s", &parg);
free(parg.p_string);
- err1:
- if (alt_filename != NULL)
- {
- close_pipe(altpipe);
- close_altfile(alt_filename, filename);
- free(alt_filename);
- }
- del_ifile(ifile);
- free(filename);
- /*
- * Re-open the current file.
- */
- if (was_curr_ifile == ifile)
- {
- /*
- * Whoops. The "current" ifile is the one we just deleted.
- * Just give up.
- */
- quit(QUIT_ERROR);
- }
- reedit_ifile(was_curr_ifile);
- return (1);
+ return edit_error(filename, alt_filename, altpipe, ifile, was_curr_ifile);
} else if ((f = open(open_filename, OPEN_READ)) < 0)
{
/*
@@ -401,7 +572,7 @@ edit_ifile(ifile)
parg.p_string = errno_message(filename);
error("%s", &parg);
free(parg.p_string);
- goto err1;
+ return edit_error(filename, alt_filename, altpipe, ifile, was_curr_ifile);
} else
{
chflags |= CH_CANSEEK;
@@ -417,11 +588,18 @@ edit_ifile(ifile)
if (answer != 'y' && answer != 'Y')
{
close(f);
- goto err1;
+ return edit_error(filename, alt_filename, altpipe, ifile, was_curr_ifile);
}
}
}
}
+ if (!force_open && f >= 0 && isatty(f))
+ {
+ PARG parg;
+ parg.p_string = filename;
+ error("%s is a terminal (use -f to open it)", &parg);
+ return edit_error(filename, alt_filename, altpipe, ifile, was_curr_ifile);
+ }
/*
* Get the new ifile.
@@ -440,6 +618,7 @@ edit_ifile(ifile)
new_file = TRUE;
ch_init(f, chflags);
consecutive_nulls = 0;
+ check_modelines();
if (!(chflags & CH_HELPFILE))
{
@@ -502,9 +681,7 @@ edit_ifile(ifile)
* For each filename in the list, enter it into the ifile list.
* Then edit the first one.
*/
- public int
-edit_list(filelist)
- char *filelist;
+public int edit_list(char *filelist)
{
IFILE save_ifile;
char *good_filename;
@@ -563,8 +740,7 @@ edit_list(filelist)
/*
* Edit the first file in the command line (ifile) list.
*/
- public int
-edit_first(VOID_PARAM)
+public int edit_first(void)
{
if (nifile() == 0)
return (edit_stdin());
@@ -575,8 +751,7 @@ edit_first(VOID_PARAM)
/*
* Edit the last file in the command line (ifile) list.
*/
- public int
-edit_last(VOID_PARAM)
+public int edit_last(void)
{
curr_ifile = NULL_IFILE;
return (edit_prev(1));
@@ -586,11 +761,7 @@ edit_last(VOID_PARAM)
/*
* Edit the n-th next or previous file in the command line (ifile) list.
*/
- static int
-edit_istep(h, n, dir)
- IFILE h;
- int n;
- int dir;
+static int edit_istep(IFILE h, int n, int dir)
{
IFILE next;
@@ -628,32 +799,22 @@ edit_istep(h, n, dir)
return (0);
}
- static int
-edit_inext(h, n)
- IFILE h;
- int n;
+static int edit_inext(IFILE h, int n)
{
return (edit_istep(h, n, +1));
}
- public int
-edit_next(n)
- int n;
+public int edit_next(int n)
{
return edit_istep(curr_ifile, n, +1);
}
- static int
-edit_iprev(h, n)
- IFILE h;
- int n;
+static int edit_iprev(IFILE h, int n)
{
return (edit_istep(h, n, -1));
}
- public int
-edit_prev(n)
- int n;
+public int edit_prev(int n)
{
return edit_istep(curr_ifile, n, -1);
}
@@ -661,9 +822,7 @@ edit_prev(n)
/*
* Edit a specific file in the command line (ifile) list.
*/
- public int
-edit_index(n)
- int n;
+public int edit_index(int n)
{
IFILE h;
@@ -682,17 +841,14 @@ edit_index(n)
return (edit_ifile(h));
}
- public IFILE
-save_curr_ifile(VOID_PARAM)
+public IFILE save_curr_ifile(void)
{
if (curr_ifile != NULL_IFILE)
hold_ifile(curr_ifile, 1);
return (curr_ifile);
}
- public void
-unsave_ifile(save_ifile)
- IFILE save_ifile;
+public void unsave_ifile(IFILE save_ifile)
{
if (save_ifile != NULL_IFILE)
hold_ifile(save_ifile, -1);
@@ -701,9 +857,7 @@ unsave_ifile(save_ifile)
/*
* Reedit the ifile which was previously open.
*/
- public void
-reedit_ifile(save_ifile)
- IFILE save_ifile;
+public void reedit_ifile(IFILE save_ifile)
{
IFILE next;
IFILE prev;
@@ -735,8 +889,7 @@ reedit_ifile(save_ifile)
quit(QUIT_ERROR);
}
- public void
-reopen_curr_ifile(VOID_PARAM)
+public void reopen_curr_ifile(void)
{
IFILE save_ifile = save_curr_ifile();
close_file();
@@ -746,8 +899,7 @@ reopen_curr_ifile(VOID_PARAM)
/*
* Edit standard input.
*/
- public int
-edit_stdin(VOID_PARAM)
+public int edit_stdin(void)
{
if (isatty(fd0))
{
@@ -761,8 +913,7 @@ edit_stdin(VOID_PARAM)
* Copy a file directly to standard output.
* Used if standard output is not a tty.
*/
- public void
-cat_file(VOID_PARAM)
+public void cat_file(void)
{
int c;
@@ -780,9 +931,7 @@ cat_file(VOID_PARAM)
* is standard input, create the log file.
* We take care not to blindly overwrite an existing file.
*/
- public void
-use_logfile(filename)
- char *filename;
+public void use_logfile(char *filename)
{
int exists;
int answer;
diff --git a/filename.c b/filename.c
index 6d29753c3d2b..a8726dc26e34 100644
--- a/filename.c
+++ b/filename.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -54,13 +54,15 @@ extern IFILE old_ifile;
extern char openquote;
extern char closequote;
#endif
+#if HAVE_STAT_INO
+extern ino_t curr_ino;
+extern dev_t curr_dev;
+#endif
/*
* Remove quotes around a filename.
*/
- public char *
-shell_unquote(str)
- char *str;
+public char * shell_unquote(char *str)
{
char *name;
char *p;
@@ -97,8 +99,7 @@ shell_unquote(str)
/*
* Get the shell's escape character.
*/
- public char *
-get_meta_escape(VOID_PARAM)
+public char * get_meta_escape(void)
{
char *s;
@@ -111,8 +112,7 @@ get_meta_escape(VOID_PARAM)
/*
* Get the characters which the shell considers to be "metacharacters".
*/
- static char *
-metachars(VOID_PARAM)
+static char * metachars(void)
{
static char *mchars = NULL;
@@ -128,9 +128,7 @@ metachars(VOID_PARAM)
/*
* Is this a shell metacharacter?
*/
- static int
-metachar(c)
- char c;
+static int metachar(char c)
{
return (strchr(metachars(), c) != NULL);
}
@@ -138,9 +136,7 @@ metachar(c)
/*
* Insert a backslash before each metacharacter in a string.
*/
- public char *
-shell_quote(s)
- char *s;
+public char * shell_quote(char *s)
{
char *p;
char *newstr;
@@ -216,11 +212,7 @@ 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.
*/
- public char *
-dirfile(dirname, filename, must_exist)
- char *dirname;
- char *filename;
- int must_exist;
+public char * dirfile(char *dirname, char *filename, int must_exist)
{
char *pathname;
int len;
@@ -257,9 +249,7 @@ dirfile(dirname, filename, must_exist)
/*
* Return the full pathname of the given file in the "home directory".
*/
- public char *
-homefile(filename)
- char *filename;
+public char * homefile(char *filename)
{
char *pathname;
@@ -301,9 +291,7 @@ homefile(filename)
* Likewise for a string of N "#"s.
* {{ This is a lot of work just to support % and #. }}
*/
- public char *
-fexpand(s)
- char *s;
+public char * fexpand(char *s)
{
char *fr, *to;
int n;
@@ -397,9 +385,7 @@ fexpand(s)
* Return a blank-separated list of filenames which "complete"
* the given string.
*/
- public char *
-fcomplete(s)
- char *s;
+public char * fcomplete(char *s)
{
char *fpat;
char *qs;
@@ -457,9 +443,7 @@ fcomplete(s)
* Try to determine if a file is "binary".
* This is just a guess, and we need not try too hard to make it accurate.
*/
- public int
-bin_file(f)
- int f;
+public int bin_file(int f)
{
int n;
int bin_count = 0;
@@ -503,9 +487,7 @@ bin_file(f)
/*
* Try to determine the size of a file by seeking to the end.
*/
- static POSITION
-seek_filesize(f)
- int f;
+static POSITION seek_filesize(int f)
{
off_t spos;
@@ -520,9 +502,7 @@ seek_filesize(f)
* Read a string from a file.
* Return a pointer to the string in memory.
*/
- static char *
-readfd(fd)
- FILE *fd;
+static char * readfd(FILE *fd)
{
int len;
int ch;
@@ -563,9 +543,7 @@ readfd(fd)
* Execute a shell command.
* Return a pointer to a pipe connected to the shell command's standard output.
*/
- static FILE *
-shellcmd(cmd)
- char *cmd;
+static FILE * shellcmd(char *cmd)
{
FILE *fd;
@@ -614,9 +592,7 @@ shellcmd(cmd)
/*
* Expand a filename, doing any system-specific metacharacter substitutions.
*/
- public char *
-lglob(filename)
- char *filename;
+public char * lglob(char *filename)
{
char *gfilename;
@@ -794,17 +770,27 @@ lglob(filename)
}
/*
+ * Does path not represent something in the file system?
+ */
+public int is_fake_pathname(char *path)
+{
+ return (strcmp(path, "-") == 0 ||
+ strcmp(path, FAKE_HELPFILE) == 0 || strcmp(path, FAKE_EMPTYFILE) == 0);
+}
+
+/*
* Return canonical pathname.
*/
- public char *
-lrealpath(path)
- char *path;
+public char * lrealpath(char *path)
{
+ if (!is_fake_pathname(path))
+ {
#if HAVE_REALPATH
- char rpath[PATH_MAX];
- if (realpath(path, rpath) != NULL)
- return (save(rpath));
+ char rpath[PATH_MAX];
+ if (realpath(path, rpath) != NULL)
+ return (save(rpath));
#endif
+ }
return (save(path));
}
@@ -813,9 +799,7 @@ lrealpath(path)
* 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;
+static int num_pct_s(char *lessopen)
{
int num = 0;
@@ -840,11 +824,7 @@ num_pct_s(lessopen)
* See if we should open a "replacement file"
* instead of the file we're about to open.
*/
- public char *
-open_altfile(filename, pf, pfd)
- char *filename;
- int *pf;
- void **pfd;
+public char * open_altfile(char *filename, int *pf, void **pfd)
{
#if !HAVE_POPEN
return (NULL);
@@ -965,10 +945,7 @@ open_altfile(filename, pf, pfd)
/*
* Close a replacement file.
*/
- public void
-close_altfile(altfilename, filename)
- char *altfilename;
- char *filename;
+public void close_altfile(char *altfilename, char *filename)
{
#if HAVE_POPEN
char *lessclose;
@@ -1005,9 +982,7 @@ close_altfile(altfilename, filename)
/*
* Is the specified file a directory?
*/
- public int
-is_dir(filename)
- char *filename;
+public int is_dir(char *filename)
{
int isdir = 0;
@@ -1039,9 +1014,7 @@ is_dir(filename)
* is an ordinary file, otherwise an error message
* (if it cannot be opened or is a directory, etc.)
*/
- public char *
-bad_file(filename)
- char *filename;
+public char * bad_file(char *filename)
{
char *m = NULL;
@@ -1083,9 +1056,7 @@ bad_file(filename)
* Return the size of a file, as cheaply as possible.
* In Unix, we can stat the file.
*/
- public POSITION
-filesize(f)
- int f;
+public POSITION filesize(int f)
{
#if HAVE_STAT
struct stat statbuf;
@@ -1103,11 +1074,29 @@ filesize(f)
return (seek_filesize(f));
}
+public int curr_ifile_changed(void)
+{
+#if HAVE_STAT_INO
+ /*
+ * If the file's i-number or device has changed,
+ * or if the file is smaller than it previously was,
+ * the file must be different.
+ */
+ 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 ||
+ (curr_pos != NULL_POSITION && st.st_size < curr_pos)))
+ return (TRUE);
+#endif
+ return (FALSE);
+}
+
/*
*
*/
- public char *
-shell_coption(VOID_PARAM)
+public char * shell_coption(void)
{
return ("-c");
}
@@ -1115,9 +1104,7 @@ shell_coption(VOID_PARAM)
/*
* Return last component of a pathname.
*/
- public char *
-last_component(name)
- char *name;
+public char * last_component(char *name)
{
char *slash;
diff --git a/fmt.uni b/fmt.uni
index c4822942a166..d873c7d27db3 100644
--- a/fmt.uni
+++ b/fmt.uni
@@ -1,4 +1,4 @@
-/* Generated by "./mkutable -f2 Cf -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:17 PDT 2022 */
+/* Generated by "./mkutable -f2 Cf -- unicode/UnicodeData.txt" on Mon Nov 14 18:19:23 PST 2022 */
{ 0x00ad, 0x00ad }, /* Cf */
{ 0x0600, 0x0605 }, /* Cf */
{ 0x061c, 0x061c }, /* Cf */
@@ -15,7 +15,7 @@
{ 0xfff9, 0xfffb }, /* Cf */
{ 0x110bd, 0x110bd }, /* Cf */
{ 0x110cd, 0x110cd }, /* Cf */
- { 0x13430, 0x13438 }, /* Cf */
+ { 0x13430, 0x1343f }, /* Cf */
{ 0x1bca0, 0x1bca3 }, /* Cf */
{ 0x1d173, 0x1d17a }, /* Cf */
{ 0xe0001, 0xe0001 }, /* Cf */
diff --git a/forwback.c b/forwback.c
index 6f0b118c4b0c..8e84409d9788 100644
--- a/forwback.c
+++ b/forwback.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -36,6 +36,7 @@ extern int clear_bg;
extern int final_attr;
extern int header_lines;
extern int header_cols;
+extern int full_screen;
#if HILITE_SEARCH
extern int size_linebuf;
extern int hilite_search;
@@ -48,8 +49,7 @@ extern char *tagoption;
/*
* Sound the bell to indicate user is trying to move past end of file.
*/
- static void
-eof_bell(VOID_PARAM)
+public void eof_bell(void)
{
#if HAVE_TIME
static time_type last_eof_bell = 0;
@@ -67,8 +67,7 @@ eof_bell(VOID_PARAM)
/*
* Check to see if the end of file is currently displayed.
*/
- public int
-eof_displayed(VOID_PARAM)
+public int eof_displayed(void)
{
POSITION pos;
@@ -94,8 +93,7 @@ eof_displayed(VOID_PARAM)
/*
* Check to see if the entire file is currently displayed.
*/
- public int
-entire_file_displayed(VOID_PARAM)
+public int entire_file_displayed(void)
{
POSITION pos;
@@ -114,8 +112,7 @@ entire_file_displayed(VOID_PARAM)
* of the screen; this can happen when we display a short file
* for the first time.
*/
- public void
-squish_check(VOID_PARAM)
+public void squish_check(void)
{
if (!squished)
return;
@@ -127,11 +124,7 @@ squish_check(VOID_PARAM)
* Read the first pfx columns of the next line.
* If skipeol==0 stop there, otherwise read and discard chars to end of line.
*/
- static POSITION
-forw_line_pfx(pos, pfx, skipeol)
- POSITION pos;
- int pfx;
- int skipeol;
+static POSITION forw_line_pfx(POSITION pos, int pfx, int skipeol)
{
int save_sc_width = sc_width;
int save_auto_wrap = auto_wrap;
@@ -152,9 +145,7 @@ forw_line_pfx(pos, pfx, skipeol)
* Underline last line of headers, but not at beginning of file
* (where there is no gap between the last header line and the next line).
*/
- static void
-set_attr_header(ln)
- int ln;
+static void set_attr_header(int ln)
{
set_attr_line(AT_COLOR_HEADER);
if (ln+1 == header_lines && position(0) != ch_zero())
@@ -165,8 +156,7 @@ set_attr_header(ln)
* Display file headers, overlaying text already drawn
* at top and left of screen.
*/
- public int
-overlay_header(VOID_PARAM)
+public int overlay_header(void)
{
POSITION pos = ch_zero(); /* header lines are at beginning of file */
int ln;
@@ -220,13 +210,7 @@ overlay_header(VOID_PARAM)
* real line. If nblank > 0, the pos must be NULL_POSITION.
* The first real line after the blanks will start at ch_zero().
*/
- public void
-forw(n, pos, force, only_last, nblank)
- int n;
- POSITION pos;
- int force;
- int only_last;
- int nblank;
+public void forw(int n, POSITION pos, int force, int only_last, int nblank)
{
int nlines = 0;
int do_repaint;
@@ -283,7 +267,7 @@ forw(n, pos, force, only_last, nblank)
{
clear();
home();
- } else if (!first_time && !is_filtering())
+ } else if (!first_time && !is_filtering() && full_screen)
{
putstr("...skipping...\n");
}
@@ -349,6 +333,7 @@ forw(n, pos, force, only_last, nblank)
* and it is not appropriate to squish in that case.
*/
if (first_time && pos == NULL_POSITION && !top_scroll &&
+ header_lines == 0 && header_cols == 0 &&
#if TAGS
tagoption == NULL &&
#endif
@@ -410,12 +395,7 @@ forw(n, pos, force, only_last, nblank)
/*
* Display n lines, scrolling backward.
*/
- public void
-back(n, pos, force, only_last)
- int n;
- POSITION pos;
- int force;
- int only_last;
+public void back(int n, POSITION pos, int force, int only_last)
{
int nlines = 0;
int do_repaint;
@@ -474,11 +454,7 @@ back(n, pos, force, only_last)
* Display n more lines, forward.
* Start just after the line currently displayed at the bottom of the screen.
*/
- public void
-forward(n, force, only_last)
- int n;
- int force;
- int only_last;
+public void forward(int n, int force, int only_last)
{
POSITION pos;
@@ -526,11 +502,7 @@ forward(n, force, only_last)
* Display n more lines, backward.
* Start just before the line currently displayed at the top of the screen.
*/
- public void
-backward(n, force, only_last)
- int n;
- int force;
- int only_last;
+public void backward(int n, int force, int only_last)
{
POSITION pos;
@@ -549,8 +521,7 @@ backward(n, force, only_last)
* back_scroll, because the default case depends on sc_height and
* top_scroll, as well as back_scroll.
*/
- public int
-get_back_scroll(VOID_PARAM)
+public int get_back_scroll(void)
{
if (no_back_scroll)
return (0);
@@ -564,8 +535,7 @@ get_back_scroll(VOID_PARAM)
/*
* Will the entire file fit on one screen?
*/
- public int
-get_one_screen(VOID_PARAM)
+public int get_one_screen(void)
{
int nlines;
POSITION pos = ch_zero();
diff --git a/funcs.h b/funcs.h
index 146dffdc0cae..071e80b050a7 100644
--- a/funcs.h
+++ b/funcs.h
@@ -1,364 +1,384 @@
-public char * save LESSPARAMS ((constant char *s));
-public VOID_POINTER ecalloc LESSPARAMS ((int count, unsigned int size));
-public char * skipsp LESSPARAMS ((char *s));
-public int sprefix LESSPARAMS ((char *ps, char *s, int uppercase));
-public void quit LESSPARAMS ((int status));
-public void raw_mode LESSPARAMS ((int on));
-public void scrsize LESSPARAMS ((VOID_PARAM));
-public char * special_key_str LESSPARAMS ((int key));
-public void get_term LESSPARAMS ((VOID_PARAM));
-public void init_mouse LESSPARAMS ((VOID_PARAM));
-public void deinit_mouse LESSPARAMS ((VOID_PARAM));
-public void init LESSPARAMS ((VOID_PARAM));
-public void deinit LESSPARAMS ((VOID_PARAM));
-public int interactive LESSPARAMS ((VOID_PARAM));
-public void home LESSPARAMS ((VOID_PARAM));
-public void add_line LESSPARAMS ((VOID_PARAM));
-public void remove_top LESSPARAMS ((int n));
-public void win32_scroll_up LESSPARAMS ((int n));
-public void lower_left LESSPARAMS ((VOID_PARAM));
-public void line_left LESSPARAMS ((VOID_PARAM));
-public void check_winch LESSPARAMS ((VOID_PARAM));
-public void goto_line LESSPARAMS ((int sindex));
-public void vbell LESSPARAMS ((VOID_PARAM));
-public void bell LESSPARAMS ((VOID_PARAM));
-public void clear LESSPARAMS ((VOID_PARAM));
-public void clear_eol LESSPARAMS ((VOID_PARAM));
-public void clear_bot LESSPARAMS ((VOID_PARAM));
-public COLOR_TYPE parse_color LESSPARAMS ((char *str, int *p_fg, int *p_bg));
-public void at_enter LESSPARAMS ((int attr));
-public void at_exit LESSPARAMS ((VOID_PARAM));
-public void at_switch LESSPARAMS ((int attr));
-public int is_at_equiv LESSPARAMS ((int attr1, int attr2));
-public int apply_at_specials LESSPARAMS ((int attr));
-public void putbs LESSPARAMS ((VOID_PARAM));
-public int win32_kbhit LESSPARAMS ((VOID_PARAM));
-public char WIN32getch LESSPARAMS ((VOID_PARAM));
-public void WIN32setcolors LESSPARAMS ((int fg, int bg));
-public void WIN32textout LESSPARAMS ((char *text, int len));
-public void match_brac LESSPARAMS ((int obrac, int cbrac, int forwdir, int n));
-public void ch_ungetchar LESSPARAMS ((int c));
-public void end_logfile LESSPARAMS ((VOID_PARAM));
-public void sync_logfile LESSPARAMS ((VOID_PARAM));
-public int ch_seek LESSPARAMS ((POSITION pos));
-public int ch_end_seek LESSPARAMS ((VOID_PARAM));
-public int ch_end_buffer_seek LESSPARAMS ((VOID_PARAM));
-public int ch_beg_seek LESSPARAMS ((VOID_PARAM));
-public POSITION ch_length LESSPARAMS ((VOID_PARAM));
-public POSITION ch_tell LESSPARAMS ((VOID_PARAM));
-public int ch_forw_get LESSPARAMS ((VOID_PARAM));
-public int ch_back_get LESSPARAMS ((VOID_PARAM));
-public void ch_setbufspace LESSPARAMS ((int bufspace));
-public void ch_flush LESSPARAMS ((VOID_PARAM));
-public int seekable LESSPARAMS ((int f));
-public void ch_set_eof LESSPARAMS ((VOID_PARAM));
-public void ch_init LESSPARAMS ((int f, int flags));
-public void ch_close LESSPARAMS ((VOID_PARAM));
-public int ch_getflags LESSPARAMS ((VOID_PARAM));
-public void ch_dump LESSPARAMS ((VOID_PARAM));
-public void setfmt LESSPARAMS ((char *s, char **fmtvarptr, int *attrptr, char *default_fmt));
-public void init_charset LESSPARAMS ((VOID_PARAM));
-public int binary_char LESSPARAMS ((LWCHAR c));
-public int control_char LESSPARAMS ((LWCHAR c));
-public char * prchar LESSPARAMS ((LWCHAR c));
-public char * prutfchar LESSPARAMS ((LWCHAR ch));
-public int utf_len LESSPARAMS ((int ch));
-public int is_utf8_well_formed LESSPARAMS ((char *ss, int slen));
-public void utf_skip_to_lead LESSPARAMS ((char **pp, char *limit));
-public LWCHAR get_wchar LESSPARAMS ((constant char *p));
-public void put_wchar LESSPARAMS ((char **pp, LWCHAR ch));
-public LWCHAR step_char LESSPARAMS ((char **pp, signed int dir, constant char *limit));
-public int is_composing_char LESSPARAMS ((LWCHAR ch));
-public int is_ubin_char LESSPARAMS ((LWCHAR ch));
-public int is_wide_char LESSPARAMS ((LWCHAR ch));
-public int is_combining_char LESSPARAMS ((LWCHAR ch1, LWCHAR ch2));
-public void cmd_reset LESSPARAMS ((VOID_PARAM));
-public void clear_cmd LESSPARAMS ((VOID_PARAM));
-public void cmd_putstr LESSPARAMS ((constant char *s));
-public int len_cmdbuf LESSPARAMS ((VOID_PARAM));
-public void cmd_repaint LESSPARAMS ((constant char *old_cp));
-public void set_mlist LESSPARAMS ((void *mlist, int cmdflags));
-public void cmd_addhist LESSPARAMS ((struct mlist *mlist, constant char *cmd, int modified));
-public void cmd_accept LESSPARAMS ((VOID_PARAM));
-public int cmd_char LESSPARAMS ((int c));
-public LINENUM cmd_int LESSPARAMS ((long *frac));
-public char * get_cmdbuf LESSPARAMS ((VOID_PARAM));
-public char * cmd_lastpattern LESSPARAMS ((VOID_PARAM));
-public void init_cmdhist LESSPARAMS ((VOID_PARAM));
-public void save_cmdhist LESSPARAMS ((VOID_PARAM));
-public int in_mca LESSPARAMS ((VOID_PARAM));
-public int norm_search_type LESSPARAMS ((int st));
-public void dispversion LESSPARAMS ((VOID_PARAM));
-public int getcc LESSPARAMS ((VOID_PARAM));
-public void ungetcc LESSPARAMS ((LWCHAR c));
-public void ungetcc_back LESSPARAMS ((LWCHAR c));
-public void ungetsc LESSPARAMS ((char *s));
-public LWCHAR peekcc LESSPARAMS ((VOID_PARAM));
-public void commands LESSPARAMS ((VOID_PARAM));
-public int cvt_length LESSPARAMS ((int len, int ops));
-public int * cvt_alloc_chpos LESSPARAMS ((int len));
-public void cvt_text LESSPARAMS ((char *odst, char *osrc, int *chpos, int *lenp, int ops));
-public void expand_cmd_tables LESSPARAMS ((VOID_PARAM));
-public void init_cmds LESSPARAMS ((VOID_PARAM));
-public void add_fcmd_table LESSPARAMS ((char *buf, int len));
-public void add_ecmd_table LESSPARAMS ((char *buf, int len));
-public int fcmd_decode LESSPARAMS ((char *cmd, char **sp));
-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 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));
-public char * back_textlist LESSPARAMS ((struct textlist *tlist, char *prev));
-public int edit LESSPARAMS ((char *filename));
-public int edit_ifile LESSPARAMS ((IFILE ifile));
-public int edit_list LESSPARAMS ((char *filelist));
-public int edit_first LESSPARAMS ((VOID_PARAM));
-public int edit_last LESSPARAMS ((VOID_PARAM));
-public int edit_next LESSPARAMS ((int n));
-public int edit_prev LESSPARAMS ((int n));
-public int edit_index LESSPARAMS ((int n));
-public IFILE save_curr_ifile LESSPARAMS ((VOID_PARAM));
-public void unsave_ifile LESSPARAMS ((IFILE save_ifile));
-public void reedit_ifile LESSPARAMS ((IFILE save_ifile));
-public void reopen_curr_ifile LESSPARAMS ((VOID_PARAM));
-public int edit_stdin LESSPARAMS ((VOID_PARAM));
-public void cat_file LESSPARAMS ((VOID_PARAM));
-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));
-public int bin_file LESSPARAMS ((int f));
-public char * lglob LESSPARAMS ((char *filename));
-public char * lrealpath LESSPARAMS ((char *path));
-public char * open_altfile LESSPARAMS ((char *filename, int *pf, void **pfd));
-public void close_altfile LESSPARAMS ((char *altfilename, char *filename));
-public int is_dir LESSPARAMS ((char *filename));
-public char * bad_file LESSPARAMS ((char *filename));
-public POSITION filesize LESSPARAMS ((int f));
-public char * shell_coption LESSPARAMS ((VOID_PARAM));
-public char * last_component LESSPARAMS ((char *name));
-public int eof_displayed LESSPARAMS ((VOID_PARAM));
-public int entire_file_displayed LESSPARAMS ((VOID_PARAM));
-public void squish_check LESSPARAMS ((VOID_PARAM));
-public int overlay_header LESSPARAMS ((VOID_PARAM));
-public void forw LESSPARAMS ((int n, POSITION pos, int force, int only_last, int nblank));
-public void back LESSPARAMS ((int n, POSITION pos, int force, int only_last));
-public void forward LESSPARAMS ((int n, int force, int only_last));
-public void backward LESSPARAMS ((int n, int force, int only_last));
-public int get_back_scroll LESSPARAMS ((VOID_PARAM));
-public int get_one_screen LESSPARAMS ((VOID_PARAM));
-public void del_ifile LESSPARAMS ((IFILE h));
-public IFILE next_ifile LESSPARAMS ((IFILE h));
-public IFILE prev_ifile LESSPARAMS ((IFILE h));
-public IFILE getoff_ifile LESSPARAMS ((IFILE ifile));
-public int nifile LESSPARAMS ((VOID_PARAM));
-public IFILE get_ifile LESSPARAMS ((char *filename, IFILE prev));
-public char * get_filename LESSPARAMS ((IFILE ifile));
-public char * get_real_filename LESSPARAMS ((IFILE ifile));
-public int get_index LESSPARAMS ((IFILE ifile));
-public void store_pos LESSPARAMS ((IFILE ifile, struct scrpos *scrpos));
-public void get_pos LESSPARAMS ((IFILE ifile, struct scrpos *scrpos));
-public void set_open LESSPARAMS ((IFILE ifile));
-public int opened LESSPARAMS ((IFILE ifile));
-public void hold_ifile LESSPARAMS ((IFILE ifile, int incr));
-public int held_ifile LESSPARAMS ((IFILE ifile));
-public void * get_filestate LESSPARAMS ((IFILE ifile));
-public void set_filestate LESSPARAMS ((IFILE ifile, void *filestate));
-public void set_altpipe LESSPARAMS ((IFILE ifile, void *p));
-public void * get_altpipe LESSPARAMS ((IFILE ifile));
-public void set_altfilename LESSPARAMS ((IFILE ifile, char *altfilename));
-public char * get_altfilename LESSPARAMS ((IFILE ifile));
-public void if_dump LESSPARAMS ((VOID_PARAM));
-public POSITION forw_line_seg LESSPARAMS ((POSITION curr_pos, int skipeol, int rscroll, int nochop));
-public POSITION forw_line LESSPARAMS ((POSITION curr_pos));
-public POSITION back_line LESSPARAMS ((POSITION curr_pos));
-public void set_attnpos LESSPARAMS ((POSITION pos));
-public void jump_forw LESSPARAMS ((VOID_PARAM));
-public void jump_forw_buffered LESSPARAMS ((VOID_PARAM));
-public void jump_back LESSPARAMS ((LINENUM linenum));
-public void repaint LESSPARAMS ((VOID_PARAM));
-public void jump_percent LESSPARAMS ((int percent, long fraction));
-public void jump_line_loc LESSPARAMS ((POSITION pos, int sline));
-public void jump_loc LESSPARAMS ((POSITION pos, int sline));
-public void init_line LESSPARAMS ((VOID_PARAM));
-public int is_ascii_char LESSPARAMS ((LWCHAR ch));
-public void prewind LESSPARAMS ((VOID_PARAM));
-public void plinestart LESSPARAMS ((POSITION pos));
-public int line_pfx_width LESSPARAMS ((VOID_PARAM));
-public void pshift_all LESSPARAMS ((VOID_PARAM));
-public int pwidth LESSPARAMS ((LWCHAR ch, int a, LWCHAR prev_ch, int prev_a));
-public int is_ansi_end LESSPARAMS ((LWCHAR ch));
-public int is_ansi_middle LESSPARAMS ((LWCHAR ch));
-public void skip_ansi LESSPARAMS ((struct ansi_state *pansi, char **pp, constant char *limit));
-public struct ansi_state * ansi_start LESSPARAMS ((LWCHAR ch));
-public int ansi_step LESSPARAMS ((struct ansi_state *pansi, LWCHAR ch));
-public void ansi_done LESSPARAMS ((struct ansi_state *pansi));
-public int pappend LESSPARAMS ((int c, POSITION pos));
-public int pflushmbc LESSPARAMS ((VOID_PARAM));
-public void pdone LESSPARAMS ((int endline, int chopped, int forw));
-public void set_attr_line LESSPARAMS ((int a));
-public void set_status_col LESSPARAMS ((int c, int attr));
-public int gline LESSPARAMS ((int i, int *ap));
-public void null_line LESSPARAMS ((VOID_PARAM));
-public POSITION forw_raw_line LESSPARAMS ((POSITION curr_pos, char **linep, int *line_lenp));
-public POSITION back_raw_line LESSPARAMS ((POSITION curr_pos, char **linep, int *line_lenp));
-public void load_line LESSPARAMS ((constant char *str));
-public int rrshift LESSPARAMS ((VOID_PARAM));
-public int set_color_map LESSPARAMS ((int attr, char *colorstr));
-public char * get_color_map LESSPARAMS ((int attr));
-public void clr_linenum LESSPARAMS ((VOID_PARAM));
-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 LINENUM vlinenum LESSPARAMS ((LINENUM linenum));
-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));
-public void init_mark LESSPARAMS ((VOID_PARAM));
-public int badmark LESSPARAMS ((int c));
-public void setmark LESSPARAMS ((int c, int where));
-public void clrmark LESSPARAMS ((int c));
-public void lastmark LESSPARAMS ((VOID_PARAM));
-public void gomark LESSPARAMS ((int c));
-public POSITION markpos LESSPARAMS ((int c));
-public char posmark LESSPARAMS ((POSITION pos));
-public void unmark LESSPARAMS ((IFILE ifile));
-public void mark_check_ifile LESSPARAMS ((IFILE ifile));
-public void save_marks LESSPARAMS ((FILE *fout, char *hdr));
-public void restore_mark LESSPARAMS ((char *line));
-public void opt_o LESSPARAMS ((int type, char *s));
-public void opt__O LESSPARAMS ((int type, char *s));
-public void opt_j LESSPARAMS ((int type, char *s));
-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));
-public void opt__P LESSPARAMS ((int type, char *s));
-public void opt_b LESSPARAMS ((int type, char *s));
-public void opt_i LESSPARAMS ((int type, char *s));
-public void opt__V LESSPARAMS ((int type, char *s));
-public void opt_D LESSPARAMS ((int type, char *s));
-public void opt_x LESSPARAMS ((int type, char *s));
-public void opt_quote LESSPARAMS ((int type, char *s));
-public void opt_rscroll LESSPARAMS ((int type, char *s));
-public void opt_query LESSPARAMS ((int type, char *s));
-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_header LESSPARAMS ((int type, char *s));
-public void opt_search_type 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 chop_line LESSPARAMS ((VOID_PARAM));
-public int get_swindow LESSPARAMS ((VOID_PARAM));
-public char * propt LESSPARAMS ((int c));
-public void scan_option LESSPARAMS ((char *s));
-public void toggle_option LESSPARAMS ((struct loption *o, int lower, char *s, int how_toggle));
-public int opt_has_param LESSPARAMS ((struct loption *o));
-public char * opt_prompt LESSPARAMS ((struct loption *o));
-public char * opt_toggle_disallowed LESSPARAMS ((int c));
-public int isoptpending LESSPARAMS ((VOID_PARAM));
-public void nopendopt LESSPARAMS ((VOID_PARAM));
-public int getnum LESSPARAMS ((char **sp, char *printopt, int *errp));
-public long getfraction LESSPARAMS ((char **sp, char *printopt, int *errp));
-public int get_quit_at_eof LESSPARAMS ((VOID_PARAM));
-public void init_option LESSPARAMS ((VOID_PARAM));
-public struct loption * findopt LESSPARAMS ((int c));
-public struct loption * findopt_name LESSPARAMS ((char **p_optname, char **p_oname, int *p_err));
-public int iread LESSPARAMS ((int fd, unsigned char *buf, unsigned int len));
-public void intread LESSPARAMS ((VOID_PARAM));
-public time_type get_time LESSPARAMS ((VOID_PARAM));
-public char * errno_message LESSPARAMS ((char *filename));
-public int percentage LESSPARAMS ((POSITION num, POSITION den));
-public POSITION percent_pos LESSPARAMS ((POSITION pos, int percent, long fraction));
-public int os9_signal LESSPARAMS ((int type, RETSIGTYPE (*handler)()));
-public void sleep_ms LESSPARAMS ((int ms));
-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));
-public void error LESSPARAMS ((char *fmt, PARG *parg));
-public void ierror LESSPARAMS ((char *fmt, PARG *parg));
-public int query LESSPARAMS ((char *fmt, PARG *parg));
-public int compile_pattern LESSPARAMS ((char *pattern, int search_type, int show_error, PATTERN_TYPE *comp_pattern));
-public void uncompile_pattern LESSPARAMS ((PATTERN_TYPE *pattern));
-public int valid_pattern LESSPARAMS ((char *pattern));
-public int is_null_pattern LESSPARAMS ((PATTERN_TYPE pattern));
-public int match_pattern LESSPARAMS ((PATTERN_TYPE pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int notbol, int search_type));
-public char * pattern_lib_name LESSPARAMS ((VOID_PARAM));
-public POSITION position LESSPARAMS ((int sindex));
-public void add_forw_pos LESSPARAMS ((POSITION pos));
-public void add_back_pos LESSPARAMS ((POSITION pos));
-public void pos_clear LESSPARAMS ((VOID_PARAM));
-public void pos_init LESSPARAMS ((VOID_PARAM));
-public int onscreen LESSPARAMS ((POSITION pos));
-public int empty_screen LESSPARAMS ((VOID_PARAM));
-public int empty_lines LESSPARAMS ((int s, int e));
-public void get_scrpos LESSPARAMS ((struct scrpos *scrpos, int where));
-public int sindex_from_sline LESSPARAMS ((int sline));
-public void init_prompt LESSPARAMS ((VOID_PARAM));
-public char * pr_expand LESSPARAMS ((constant char *proto));
-public char * eq_message LESSPARAMS ((VOID_PARAM));
-public char * pr_string LESSPARAMS ((VOID_PARAM));
-public char * wait_message LESSPARAMS ((VOID_PARAM));
-public void init_search LESSPARAMS ((VOID_PARAM));
-public void repaint_hilite LESSPARAMS ((int on));
-public void clear_attn LESSPARAMS ((VOID_PARAM));
-public void undo_search LESSPARAMS ((int clear));
-public void clr_hlist LESSPARAMS ((struct hilite_tree *anchor));
-public void clr_hilite LESSPARAMS ((VOID_PARAM));
-public void clr_filter LESSPARAMS ((VOID_PARAM));
-public int is_filtered LESSPARAMS ((POSITION pos));
-public POSITION next_unfiltered LESSPARAMS ((POSITION pos));
-public POSITION prev_unfiltered LESSPARAMS ((POSITION pos));
-public int is_hilited_attr LESSPARAMS ((POSITION pos, POSITION epos, int nohide, int *p_matches));
-public void chg_hilite LESSPARAMS ((VOID_PARAM));
-public void chg_caseless LESSPARAMS ((VOID_PARAM));
-public int search LESSPARAMS ((int search_type, char *pattern, int n));
-public void prep_hilite LESSPARAMS ((POSITION spos, POSITION epos, int maxlines));
-public void set_filter_pattern LESSPARAMS ((char *pattern, int search_type));
-public int is_filtering LESSPARAMS ((VOID_PARAM));
-public RETSIGTYPE winch LESSPARAMS ((int type));
-public void init_signals LESSPARAMS ((int on));
-public void psignals LESSPARAMS ((VOID_PARAM));
-public void cleantags LESSPARAMS ((VOID_PARAM));
-public int gettagtype LESSPARAMS ((VOID_PARAM));
-public void findtag LESSPARAMS ((char *tag));
-public POSITION tagsearch LESSPARAMS ((VOID_PARAM));
-public char * nexttag LESSPARAMS ((int n));
-public char * prevtag LESSPARAMS ((int n));
-public int ntags LESSPARAMS ((VOID_PARAM));
-public int curr_tag LESSPARAMS ((VOID_PARAM));
-public int edit_tagfile LESSPARAMS ((VOID_PARAM));
-public int open_tty LESSPARAMS ((VOID_PARAM));
-public void open_getchr LESSPARAMS ((VOID_PARAM));
-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, int ch));
-public int xbuf_pop LESSPARAMS ((struct xbuffer *buf));
-public void xbuf_set LESSPARAMS ((struct xbuffer *dst, struct xbuffer *src));
+public char * save(constant char *s);
+public void out_of_memory(void);
+public void * ecalloc(int count, unsigned int size);
+public char * skipsp(char *s);
+public int sprefix(char *ps, char *s, int uppercase);
+public void quit(int status);
+public void raw_mode(int on);
+public void scrsize(void);
+public char * special_key_str(int key);
+public void get_term(void);
+public void init_mouse(void);
+public void deinit_mouse(void);
+public void init(void);
+public void deinit(void);
+public int interactive(void);
+public void home(void);
+public void dump_screen(void);
+public void add_line(void);
+public void remove_top(int n);
+public void win32_scroll_up(int n);
+public void lower_left(void);
+public void line_left(void);
+public void check_winch(void);
+public void goto_line(int sindex);
+public void vbell(void);
+public void bell(void);
+public void clear(void);
+public void clear_eol(void);
+public void clear_bot(void);
+public COLOR_TYPE parse_color(char *str, int *p_fg, int *p_bg);
+public void at_enter(int attr);
+public void at_exit(void);
+public void at_switch(int attr);
+public int is_at_equiv(int attr1, int attr2);
+public int apply_at_specials(int attr);
+public void putbs(void);
+public int win32_kbhit(void);
+public char WIN32getch(void);
+public void WIN32setcolors(int fg, int bg);
+public void WIN32textout(char *text, int len);
+public void match_brac(char obrac, char cbrac, int forwdir, int n);
+public void ch_ungetchar(int c);
+public void end_logfile(void);
+public void sync_logfile(void);
+public int ch_seek(POSITION pos);
+public int ch_end_seek(void);
+public int ch_end_buffer_seek(void);
+public int ch_beg_seek(void);
+public POSITION ch_length(void);
+public POSITION ch_tell(void);
+public int ch_forw_get(void);
+public int ch_back_get(void);
+public void ch_setbufspace(int bufspace);
+public void ch_flush(void);
+public int seekable(int f);
+public void ch_set_eof(void);
+public void ch_init(int f, int flags);
+public void ch_close(void);
+public int ch_getflags(void);
+public void setfmt(char *s, char **fmtvarptr, int *attrptr, char *default_fmt, int for_printf);
+public void init_charset(void);
+public int binary_char(LWCHAR c);
+public int control_char(LWCHAR c);
+public char * prchar(LWCHAR c);
+public char * prutfchar(LWCHAR ch);
+public int utf_len(int ch);
+public int is_utf8_well_formed(char *ss, int slen);
+public void utf_skip_to_lead(char **pp, char *limit);
+public LWCHAR get_wchar(constant char *p);
+public void put_wchar(char **pp, LWCHAR ch);
+public LWCHAR step_char(char **pp, signed int dir, constant char *limit);
+public int is_composing_char(LWCHAR ch);
+public int is_ubin_char(LWCHAR ch);
+public int is_wide_char(LWCHAR ch);
+public int is_combining_char(LWCHAR ch1, LWCHAR ch2);
+public void cmd_reset(void);
+public void clear_cmd(void);
+public void cmd_putstr(constant char *s);
+public int len_cmdbuf(void);
+public void cmd_repaint(constant char *old_cp);
+public void set_mlist(void *mlist, int cmdflags);
+public void cmd_addhist(struct mlist *mlist, constant char *cmd, int modified);
+public void cmd_accept(void);
+public int cmd_char(int c);
+public LINENUM cmd_int(long *frac);
+public char * get_cmdbuf(void);
+public char * cmd_lastpattern(void);
+public void init_cmdhist(void);
+public void save_cmdhist(void);
+public int in_mca(void);
+public int norm_search_type(int st);
+public void dispversion(void);
+public int getcc(void);
+public void ungetcc(LWCHAR c);
+public void ungetcc_back(LWCHAR c);
+public void ungetsc(char *s);
+public LWCHAR peekcc(void);
+public void commands(void);
+public int cvt_length(int len, int ops);
+public int * cvt_alloc_chpos(int len);
+public void cvt_text(char *odst, char *osrc, int *chpos, int *lenp, int ops);
+public void expand_cmd_tables(void);
+public void init_cmds(void);
+public void add_fcmd_table(char *buf, int len);
+public void add_ecmd_table(char *buf, int len);
+public int fcmd_decode(char *cmd, char **sp);
+public int ecmd_decode(char *cmd, char **sp);
+public char * lgetenv(char *var);
+public int isnullenv(char *s);
+public int lesskey(char *filename, int sysvar);
+public int lesskey_src(char *filename, int sysvar);
+public int add_hometable(int (*call_lesskey)(char *, int), char *envname, char *def_filename, int sysvar);
+public int editchar(int c, int flags);
+public void init_textlist(struct textlist *tlist, char *str);
+public char * forw_textlist(struct textlist *tlist, char *prev);
+public char * back_textlist(struct textlist *tlist, char *prev);
+public void close_altpipe(IFILE ifile);
+public void check_altpipe_error(void);
+public int edit(char *filename);
+public int edit_ifile(IFILE ifile);
+public int edit_list(char *filelist);
+public int edit_first(void);
+public int edit_last(void);
+public int edit_next(int n);
+public int edit_prev(int n);
+public int edit_index(int n);
+public IFILE save_curr_ifile(void);
+public void unsave_ifile(IFILE save_ifile);
+public void reedit_ifile(IFILE save_ifile);
+public void reopen_curr_ifile(void);
+public int edit_stdin(void);
+public void cat_file(void);
+public void use_logfile(char *filename);
+public char * shell_unquote(char *str);
+public char * get_meta_escape(void);
+public char * shell_quote(char *s);
+public char * dirfile(char *dirname, char *filename, int must_exist);
+public char * homefile(char *filename);
+public char * fexpand(char *s);
+public char * fcomplete(char *s);
+public int bin_file(int f);
+public char * lglob(char *filename);
+public int is_fake_pathname(char *path);
+public char * lrealpath(char *path);
+public char * open_altfile(char *filename, int *pf, void **pfd);
+public void close_altfile(char *altfilename, char *filename);
+public int is_dir(char *filename);
+public char * bad_file(char *filename);
+public POSITION filesize(int f);
+public int curr_ifile_changed(void);
+public char * shell_coption(void);
+public char * last_component(char *name);
+public void eof_bell(void);
+public int eof_displayed(void);
+public int entire_file_displayed(void);
+public void squish_check(void);
+public int overlay_header(void);
+public void forw(int n, POSITION pos, int force, int only_last, int nblank);
+public void back(int n, POSITION pos, int force, int only_last);
+public void forward(int n, int force, int only_last);
+public void backward(int n, int force, int only_last);
+public int get_back_scroll(void);
+public int get_one_screen(void);
+public void del_ifile(IFILE h);
+public IFILE next_ifile(IFILE h);
+public IFILE prev_ifile(IFILE h);
+public IFILE getoff_ifile(IFILE ifile);
+public int nifile(void);
+public IFILE get_ifile(char *filename, IFILE prev);
+public char * get_filename(IFILE ifile);
+public char * get_real_filename(IFILE ifile);
+public int get_index(IFILE ifile);
+public void store_pos(IFILE ifile, struct scrpos *scrpos);
+public void get_pos(IFILE ifile, struct scrpos *scrpos);
+public void set_open(IFILE ifile);
+public int opened(IFILE ifile);
+public void hold_ifile(IFILE ifile, int incr);
+public int held_ifile(IFILE ifile);
+public void * get_filestate(IFILE ifile);
+public void set_filestate(IFILE ifile, void *filestate);
+public void set_altpipe(IFILE ifile, void *p);
+public void *get_altpipe(IFILE ifile);
+public void set_altfilename(IFILE ifile, char *altfilename);
+public char * get_altfilename(IFILE ifile);
+public void if_dump(void);
+public POSITION forw_line_seg(POSITION curr_pos, int skipeol, int rscroll, int nochop);
+public POSITION forw_line(POSITION curr_pos);
+public POSITION back_line(POSITION curr_pos);
+public void set_attnpos(POSITION pos);
+public void jump_forw(void);
+public void jump_forw_buffered(void);
+public void jump_back(LINENUM linenum);
+public void repaint(void);
+public void jump_percent(int percent, long fraction);
+public void jump_line_loc(POSITION pos, int sline);
+public void jump_loc(POSITION pos, int sline);
+public void init_line(void);
+public int is_ascii_char(LWCHAR ch);
+public POSITION line_position(void);
+public void prewind(void);
+public void plinestart(POSITION pos);
+public int line_pfx_width(void);
+public void pshift_all(void);
+public int pwidth(LWCHAR ch, int a, LWCHAR prev_ch, int prev_a);
+public void savec(void);
+public void loadc(void);
+public int is_ansi_end(LWCHAR ch);
+public int is_ansi_middle(LWCHAR ch);
+public void skip_ansi(struct ansi_state *pansi, char **pp, constant char *limit);
+public struct ansi_state * ansi_start(LWCHAR ch);
+public int ansi_step(struct ansi_state *pansi, LWCHAR ch);
+public void ansi_done(struct ansi_state *pansi);
+public int pappend(int c, POSITION pos);
+public int pflushmbc(void);
+public void pdone(int endline, int chopped, int forw);
+public void set_attr_line(int a);
+public void set_status_col(char c, int attr);
+public int gline(int i, int *ap);
+public void null_line(void);
+public POSITION forw_raw_line(POSITION curr_pos, char **linep, int *line_lenp);
+public POSITION back_raw_line(POSITION curr_pos, char **linep, int *line_lenp);
+public int skip_columns(int cols, char **linep, int *line_lenp);
+public void load_line(constant char *str);
+public int rrshift(void);
+public int set_color_map(int attr, char *colorstr);
+public char * get_color_map(int attr);
+public void clr_linenum(void);
+public void add_lnum(LINENUM linenum, POSITION pos);
+public LINENUM find_linenum(POSITION pos);
+public POSITION find_pos(LINENUM linenum);
+public LINENUM currline(int where);
+public void scan_eof(void);
+public LINENUM vlinenum(LINENUM linenum);
+public void lsystem(char *cmd, char *donemsg);
+public int pipe_mark(int c, char *cmd);
+public int pipe_data(char *cmd, POSITION spos, POSITION epos);
+public void init_mark(void);
+public int badmark(LWCHAR c);
+public void setmark(LWCHAR c, int where);
+public void clrmark(LWCHAR c);
+public void lastmark(void);
+public void gomark(LWCHAR c);
+public POSITION markpos(LWCHAR c);
+public char posmark(POSITION pos);
+public void unmark(IFILE ifile);
+public void mark_check_ifile(IFILE ifile);
+public void save_marks(FILE *fout, char *hdr);
+public void restore_mark(char *line);
+public void opt_o(int type, char *s);
+public void opt__O(int type, char *s);
+public void opt_j(int type, char *s);
+public void calc_jump_sline(void);
+public void opt_shift(int type, char *s);
+public void calc_shift_count(void);
+public void opt_k(int type, char *s);
+public void opt_ks(int type, char *s);
+public void opt_t(int type, char *s);
+public void opt__T(int type, char *s);
+public void opt_p(int type, char *s);
+public void opt__P(int type, char *s);
+public void opt_b(int type, char *s);
+public void opt_i(int type, char *s);
+public void opt__V(int type, char *s);
+public void opt_D(int type, char *s);
+public void set_tabs(char *s, int len);
+public void opt_x(int type, char *s);
+public void opt_quote(int type, char *s);
+public void opt_rscroll(int type, char *s);
+public void opt_query(int type, char *s);
+public void opt_mousecap(int type, char *s);
+public void opt_wheel_lines(int type, char *s);
+public void opt_linenum_width(int type, char *s);
+public void opt_status_col_width(int type, char *s);
+public void opt_filesize(int type, char *s);
+public void opt_intr(int type, char *s);
+public void opt_header(int type, char *s);
+public void opt_search_type(int type, char *s);
+public void opt_ttyin_name(int type, char *s);
+public int chop_line(void);
+public int get_swindow(void);
+public char * propt(int c);
+public void scan_option(char *s);
+public void toggle_option(struct loption *o, int lower, char *s, int how_toggle);
+public int opt_has_param(struct loption *o);
+public char * opt_prompt(struct loption *o);
+public char * opt_toggle_disallowed(int c);
+public int isoptpending(void);
+public void nopendopt(void);
+public int getnum(char **sp, char *printopt, int *errp);
+public long getfraction(char **sp, char *printopt, int *errp);
+public int get_quit_at_eof(void);
+public void init_option(void);
+public struct loption * findopt(int c);
+public struct loption * findopt_name(char **p_optname, char **p_oname, int *p_err);
+public void init_poll(void);
+public int supports_ctrl_x(void);
+public int iread(int fd, unsigned char *buf, unsigned int len);
+public void intread(void);
+public time_type get_time(void);
+public char * errno_message(char *filename);
+public char * signal_message(int sig);
+public uintmax muldiv(uintmax val, uintmax num, uintmax den);
+public int percentage(POSITION num, POSITION den);
+public POSITION percent_pos(POSITION pos, int percent, long fraction);
+public int os9_signal(int type, RETSIGTYPE (*handler)());
+public void sleep_ms(int ms);
+public void put_line(void);
+public void flush(void);
+public void set_output(int fd);
+public int putchr(int c);
+public void clear_bot_if_needed(void);
+public void putstr(constant char *s);
+public int less_printf(char *fmt, PARG *parg);
+public void get_return(void);
+public void error(char *fmt, PARG *parg);
+public void ierror(char *fmt, PARG *parg);
+public void ixerror(char *fmt, PARG *parg);
+public int query(char *fmt, PARG *parg);
+public int compile_pattern(char *pattern, int search_type, int show_error, PATTERN_TYPE *comp_pattern);
+public void uncompile_pattern(PATTERN_TYPE *pattern);
+public int valid_pattern(char *pattern);
+public int is_null_pattern(PATTERN_TYPE pattern);
+public int match_pattern(PATTERN_TYPE pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int nsp, int notbol, int search_type);
+public char * pattern_lib_name(void);
+public POSITION position(int sindex);
+public void add_forw_pos(POSITION pos);
+public void add_back_pos(POSITION pos);
+public void pos_clear(void);
+public void pos_init(void);
+public int onscreen(POSITION pos);
+public int empty_screen(void);
+public int empty_lines(int s, int e);
+public void get_scrpos(struct scrpos *scrpos, int where);
+public int sindex_from_sline(int sline);
+public void init_prompt(void);
+public char * pr_expand(constant char *proto);
+public char * eq_message(void);
+public char * pr_string(void);
+public char * wait_message(void);
+public void init_search(void);
+public void repaint_hilite(int on);
+public void clear_attn(void);
+public void undo_search(int clear);
+public void clr_hlist(struct hilite_tree *anchor);
+public void clr_hilite(void);
+public void clr_filter(void);
+public int is_filtered(POSITION pos);
+public POSITION next_unfiltered(POSITION pos);
+public POSITION prev_unfiltered(POSITION pos);
+public int is_hilited_attr(POSITION pos, POSITION epos, int nohide, int *p_matches);
+public void chg_hilite(void);
+public void chg_caseless(void);
+public int search(int search_type, char *pattern, int n);
+public void prep_hilite(POSITION spos, POSITION epos, int maxlines);
+public void set_filter_pattern(char *pattern, int search_type);
+public int is_filtering(void);
+public RETSIGTYPE winch(int type);
+public void init_signals(int on);
+public void psignals(void);
+public void cleantags(void);
+public int gettagtype(void);
+public void findtag(char *tag);
+public POSITION tagsearch(void);
+public char * nexttag(int n);
+public char * prevtag(int n);
+public int ntags(void);
+public int curr_tag(void);
+public int edit_tagfile(void);
+public int open_tty(void);
+public void open_getchr(void);
+public void close_getchr(void);
+public int pclose(FILE *f);
+public int default_wheel_lines(void);
+public int getchr(void);
+public void xbuf_init(struct xbuffer *xbuf);
+public void xbuf_deinit(struct xbuffer *xbuf);
+public void xbuf_reset(struct xbuffer *xbuf);
+public void xbuf_add_byte(struct xbuffer *xbuf, unsigned char b);
+public void xbuf_add_data(struct xbuffer *xbuf, unsigned char *data, int len);
+public int xbuf_pop(struct xbuffer *buf);
+public void xbuf_set(struct xbuffer *dst, struct xbuffer *src);
+public char * xbuf_char_data(struct xbuffer *xbuf);
+public int help_ckd_add(void *r, uintmax a, uintmax b, int rsize, int rsigned);
+public int help_ckd_mul(void *r, uintmax a, uintmax b, int rsize, int rsigned);
diff --git a/help.c b/help.c
index 75a91d1e1948..363b7eccddf2 100644
--- a/help.c
+++ b/help.c
@@ -1,4 +1,4 @@
-/* This file was generated by mkhelp.pl from less.hlp at 19:26 on 2022/7/22 */
+/* This file was generated by mkhelp.pl from less.hlp at 17:26 on 2023/4/6 */
#include "less.h"
constant char helpdata[] = {
'\n',
@@ -54,6 +54,7 @@ constant char helpdata[] = {
' ',' ',' ',' ',' ',' ',' ',' ','^','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',
' ',' ',' ',' ',' ',' ',' ',' ','^','K',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','m','a','t','c','h','e','s',',',' ','b','u','t',' ','d','o','n','\'','t',' ','m','o','v','e',' ','(','K','E','E','P',' ','p','o','s','i','t','i','o','n',')','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ','^','R',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','R','E','G','U','L','A','R',' ','E','X','P','R','E','S','S','I','O','N','S','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','S',' ','_','\b','n',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','m','a','t','c','h',' ','i','n',' ','_','\b','n','-','t','h',' ','p','a','r','e','n','t','h','e','s','i','z','e','d',' ','s','u','b','p','a','t','t','e','r','n','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ','^','W',' ',' ',' ',' ',' ',' ',' ','W','R','A','P',' ','s','e','a','r','c','h',' ','i','f',' ','n','o',' ','m','a','t','c','h',' ','f','o','u','n','d','.','\n',
' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
'\n',
@@ -107,6 +108,7 @@ constant char helpdata[] = {
' ',' ','+','_','\b','c','_','\b','m','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','l','e','s','s',' ','c','m','d',' ','e','a','c','h',' ','t','i','m','e',' ','a',' ','n','e','w',' ','f','i','l','e',' ','i','s',' ','e','x','a','m','i','n','e','d','.','\n',
'\n',
' ',' ','!','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d',' ','w','i','t','h',' ','$','S','H','E','L','L','.','\n',
+' ',' ','#','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d',',',' ','e','x','p','a','n','d','e','d',' ','l','i','k','e',' ','a',' ','p','r','o','m','p','t','.','\n',
' ',' ','|','X','\b','X','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','i','p','e',' ','f','i','l','e',' ','b','e','t','w','e','e','n',' ','c','u','r','r','e','n','t',' ','p','o','s',' ','&',' ','m','a','r','k',' ','X','\b','X',' ','t','o',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d','.','\n',
' ',' ','s',' ','_','\b','f','_','\b','i','_','\b','l','_','\b','e',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','v','e',' ','i','n','p','u','t',' ','t','o',' ','a',' ','f','i','l','e','.','\n',
' ',' ','v',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','d','i','t',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','w','i','t','h',' ','$','V','I','S','U','A','L',' ','o','r',' ','$','E','D','I','T','O','R','.','\n',
@@ -189,7 +191,7 @@ constant char helpdata[] = {
' ',' ','-','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',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a','n',' ','a','l','t','e','r','n','a','t','e',' ','t','a','g','s',' ','f','i','l','e','.','\n',
' ',' ','-','u',' ',' ','-','U',' ',' ','.','.','.','.',' ',' ','-','-','u','n','d','e','r','l','i','n','e','-','s','p','e','c','i','a','l',' ',' ','-','-','U','N','D','E','R','L','I','N','E','-','S','P','E','C','I','A','L','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','a','n','g','e',' ','h','a','n','d','l','i','n','g',' ','o','f',' ','b','a','c','k','s','p','a','c','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','a','n','g','e',' ','h','a','n','d','l','i','n','g',' ','o','f',' ','b','a','c','k','s','p','a','c','e','s',',',' ','t','a','b','s',' ','a','n','d',' ','c','a','r','r','i','a','g','e',' ','r','e','t','u','r','n','s','.','\n',
' ',' ','-','V',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','v','e','r','s','i','o','n','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
' ',' ','-','w',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','u','n','r','e','a','d','\n',
@@ -210,6 +212,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',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','e','x','i','t','-','f','o','l','l','o','w','-','o','n','-','c','l','o','s','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','i','t',' ','F',' ','c','o','m','m','a','n','d',' ','o','n',' ','a',' ','p','i','p','e',' ','w','h','e','n',' ','w','r','i','t','e','r',' ','c','l','o','s','e','s',' ','p','i','p','e','.','\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',
@@ -218,8 +222,12 @@ constant char helpdata[] = {
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','N',' ','l','i','n','e','s',' ','a','n','d',' ','M',' ','c','o','l','u','m','n','s',' ','t','o',' ','d','i','s','p','l','a','y',' ','f','i','l','e',' ','h','e','a','d','e','r','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','i','n','c','s','e','a','r','c','h','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','f','i','l','e',' ','a','s',' ','e','a','c','h',' ','p','a','t','t','e','r','n',' ','c','h','a','r','a','c','t','e','r',' ','i','s',' ','t','y','p','e','d',' ','i','n','.','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','l','i','n','e','-','n','u','m','-','w','i','d','t','h','=','N','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','h','e',' ','w','i','d','t','h',' ','o','f',' ','t','h','e',' ','-','N',' ','l','i','n','e',' ','n','u','m','b','e','r',' ','f','i','e','l','d',' ','t','o',' ','N',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','i','n','t','r','=','_','\b','C','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','_','\b','C',' ','i','n','s','t','e','a','d',' ','o','f',' ','^','X',' ','t','o',' ','i','n','t','e','r','r','u','p','t',' ','a',' ','r','e','a','d','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','l','i','n','e','-','n','u','m','-','w','i','d','t','h','=','_','\b','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','h','e',' ','w','i','d','t','h',' ','o','f',' ','t','h','e',' ','-','N',' ','l','i','n','e',' ','n','u','m','b','e','r',' ','f','i','e','l','d',' ','t','o',' ','_','\b','N',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','m','o','d','e','l','i','n','e','s','=','_','\b','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','a','d',' ','_','\b','N',' ','l','i','n','e','s',' ','f','r','o','m',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','a','n','d',' ','l','o','o','k',' ','f','o','r',' ','v','i','m',' ','m','o','d','e','l','i','n','e','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','m','o','u','s','e','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','n','a','b','l','e',' ','m','o','u','s','e',' ','i','n','p','u','t','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
@@ -228,24 +236,44 @@ constant char helpdata[] = {
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','m','o','v','e',' ','d','u','p','l','i','c','a','t','e','s',' ','f','r','o','m',' ','c','o','m','m','a','n','d',' ','h','i','s','t','o','r','y','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','n','u','m','b','e','r','-','h','e','a','d','e','r','s','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','g','i','v','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s',' ','t','o',' ','h','e','a','d','e','r',' ','l','i','n','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','s','e','a','r','c','h','-','h','e','a','d','e','r','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','a','r','c','h',' ','i','n',' ','h','e','a','d','e','r',' ','l','i','n','e','s',' ','o','r',' ','c','o','l','u','m','n','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','v','b','e','l','l','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','a','b','l','e',' ','t','h','e',' ','t','e','r','m','i','n','a','l','\'','s',' ','v','i','s','u','a','l',' ','b','e','l','l','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','r','e','d','r','a','w','-','o','n','-','q','u','i','t','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','d','r','a','w',' ','f','i','n','a','l',' ','s','c','r','e','e','n',' ','w','h','e','n',' ','q','u','i','t','t','i','n','g','.','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','r','s','c','r','o','l','l','=','C','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','r','s','c','r','o','l','l','=','_','\b','C','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','h','e',' ','c','h','a','r','a','c','t','e','r',' ','u','s','e','d',' ','t','o',' ','m','a','r','k',' ','t','r','u','n','c','a','t','e','d',' ','l','i','n','e','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','a','v','e','-','m','a','r','k','s','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','t','a','i','n',' ','m','a','r','k','s',' ','a','c','r','o','s','s',' ','i','n','v','o','c','a','t','i','o','n','s',' ','o','f',' ','l','e','s','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','e','a','r','c','h','-','o','p','t','i','o','n','s','=','[','E','F','K','N','R','W','-',']','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','d','e','f','a','u','l','t',' ','o','p','t','i','o','n','s',' ','f','o','r',' ','e','v','e','r','y',' ','s','e','a','r','c','h','.','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','t','a','t','u','s','-','c','o','l','-','w','i','d','t','h','=','N','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','h','e',' ','w','i','d','t','h',' ','o','f',' ','t','h','e',' ','-','J',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','t','o',' ','N',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','h','o','w','-','p','r','e','p','r','o','c','-','e','r','r','o','r','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','m','e','s','s','a','g','e',' ','i','f',' ','p','r','e','p','r','o','c','e','s','s','o','r',' ','e','x','i','t','s',' ','w','i','t','h',' ','a','n',' ','e','r','r','o','r',' ','s','t','a','t','u','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','p','r','o','c','-','b','a','c','k','s','p','a','c','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','o','c','e','s','s',' ','b','a','c','k','s','p','a','c','e','s',' ','f','o','r',' ','b','o','l','d','/','u','n','d','e','r','l','i','n','e','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','S','P','E','C','I','A','L','-','B','A','C','K','S','P','A','C','E','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','r','e','a','t',' ','b','a','c','k','s','p','a','c','e','s',' ','a','s',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','p','r','o','c','-','r','e','t','u','r','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','a','r','r','i','a','g','e',' ','r','e','t','u','r','n','s',' ','b','e','f','o','r','e',' ','n','e','w','l','i','n','e','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','S','P','E','C','I','A','L','-','R','E','T','U','R','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','r','e','a','t',' ','c','a','r','r','i','a','g','e',' ','r','e','t','u','r','n','s',' ','a','s',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','p','r','o','c','-','t','a','b','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','p','a','n','d',' ','t','a','b','s',' ','t','o',' ','s','p','a','c','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','S','P','E','C','I','A','L','-','T','A','B','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','r','e','a','t',' ','t','a','b','s',' ','a','s',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','t','a','t','u','s','-','c','o','l','-','w','i','d','t','h','=','_','\b','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','h','e',' ','w','i','d','t','h',' ','o','f',' ','t','h','e',' ','-','J',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','t','o',' ','_','\b','N',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','s','t','a','t','u','s','-','l','i','n','e','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','o','r',' ','c','o','l','o','r',' ','t','h','e',' ','e','n','t','i','r','e',' ','l','i','n','e',' ','c','o','n','t','a','i','n','i','n','g',' ','a',' ','m','a','r','k','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','u','s','e','-','b','a','c','k','s','l','a','s','h','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','u','b','s','e','q','u','e','n','t',' ','o','p','t','i','o','n','s',' ','u','s','e',' ','b','a','c','k','s','l','a','s','h',' ','a','s',' ','e','s','c','a','p','e',' ','c','h','a','r','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','u','s','e','-','c','o','l','o','r','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','n','a','b','l','e','s',' ','c','o','l','o','r','e','d',' ','t','e','x','t','.','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','w','h','e','e','l','-','l','i','n','e','s','=','N','\n',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','c','l','i','c','k',' ','o','f',' ','t','h','e',' ','m','o','u','s','e',' ','w','h','e','e','l',' ','m','o','v','e','s',' ','N',' ','l','i','n','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','w','h','e','e','l','-','l','i','n','e','s','=','_','\b','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','c','l','i','c','k',' ','o','f',' ','t','h','e',' ','m','o','u','s','e',' ','w','h','e','e','l',' ','m','o','v','e','s',' ','_','\b','N',' ','l','i','n','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','w','o','r','d','w','r','a','p','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','W','r','a','p',' ','l','i','n','e','s',' ','a','t',' ','s','p','a','c','e','s','.','\n',
'\n',
'\n',
' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
diff --git a/ifile.c b/ifile.c
index 6b3d1ce9a5e3..adbe82b0eb6a 100644
--- a/ifile.c
+++ b/ifile.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -51,10 +51,7 @@ static struct ifile anchor = { &anchor, &anchor, NULL, NULL, NULL, 0, 0, '\0',
{ NULL_POSITION, 0 } };
static int ifiles = 0;
- static void
-incr_index(p, incr)
- struct ifile *p;
- int incr;
+static void incr_index(struct ifile *p, int incr)
{
for (; p != &anchor; p = p->h_next)
p->h_index += incr;
@@ -63,10 +60,7 @@ incr_index(p, incr)
/*
* Link an ifile into the ifile list.
*/
- static void
-link_ifile(p, prev)
- struct ifile *p;
- struct ifile *prev;
+static void link_ifile(struct ifile *p, struct ifile *prev)
{
/*
* Link into list.
@@ -89,9 +83,7 @@ link_ifile(p, prev)
/*
* Unlink an ifile from the ifile list.
*/
- static void
-unlink_ifile(p)
- struct ifile *p;
+static void unlink_ifile(struct ifile *p)
{
p->h_next->h_prev = p->h_prev;
p->h_prev->h_next = p->h_next;
@@ -105,10 +97,7 @@ unlink_ifile(p)
* (or at the beginning of the list if "prev" is NULL).
* Return a pointer to the new ifile structure.
*/
- static struct ifile *
-new_ifile(filename, prev)
- char *filename;
- struct ifile *prev;
+static struct ifile * new_ifile(char *filename, struct ifile *prev)
{
struct ifile *p;
@@ -137,9 +126,7 @@ new_ifile(filename, prev)
/*
* Delete an existing ifile structure.
*/
- public void
-del_ifile(h)
- IFILE h;
+public void del_ifile(IFILE h)
{
struct ifile *p;
@@ -162,9 +149,7 @@ del_ifile(h)
/*
* Get the ifile after a given one in the list.
*/
- public IFILE
-next_ifile(h)
- IFILE h;
+public IFILE next_ifile(IFILE h)
{
struct ifile *p;
@@ -177,9 +162,7 @@ next_ifile(h)
/*
* Get the ifile before a given one in the list.
*/
- public IFILE
-prev_ifile(h)
- IFILE h;
+public IFILE prev_ifile(IFILE h)
{
struct ifile *p;
@@ -192,9 +175,7 @@ prev_ifile(h)
/*
* Return a different ifile from the given one.
*/
- public IFILE
-getoff_ifile(ifile)
- IFILE ifile;
+public IFILE getoff_ifile(IFILE ifile)
{
IFILE newifile;
@@ -208,8 +189,7 @@ getoff_ifile(ifile)
/*
* Return the number of ifiles.
*/
- public int
-nifile(VOID_PARAM)
+public int nifile(void)
{
return (ifiles);
}
@@ -217,9 +197,7 @@ nifile(VOID_PARAM)
/*
* Find an ifile structure, given a filename.
*/
- static struct ifile *
-find_ifile(filename)
- char *filename;
+static struct ifile * find_ifile(char *filename)
{
struct ifile *p;
char *rfilename = lrealpath(filename);
@@ -251,10 +229,7 @@ find_ifile(filename)
* If the filename has not been seen before,
* insert the new ifile after "prev" in the list.
*/
- public IFILE
-get_ifile(filename, prev)
- char *filename;
- IFILE prev;
+public IFILE get_ifile(char *filename, IFILE prev)
{
struct ifile *p;
@@ -266,9 +241,7 @@ get_ifile(filename, prev)
/*
* Get the display filename associated with a ifile.
*/
- public char *
-get_filename(ifile)
- IFILE ifile;
+public char * get_filename(IFILE ifile)
{
if (ifile == NULL)
return (NULL);
@@ -278,9 +251,7 @@ get_filename(ifile)
/*
* Get the canonical filename associated with a ifile.
*/
- public char *
-get_real_filename(ifile)
- IFILE ifile;
+public char * get_real_filename(IFILE ifile)
{
if (ifile == NULL)
return (NULL);
@@ -290,9 +261,7 @@ get_real_filename(ifile)
/*
* Get the index of the file associated with a ifile.
*/
- public int
-get_index(ifile)
- IFILE ifile;
+public int get_index(IFILE ifile)
{
return (int_ifile(ifile)->h_index);
}
@@ -300,10 +269,7 @@ get_index(ifile)
/*
* Save the file position to be associated with a given file.
*/
- public void
-store_pos(ifile, scrpos)
- IFILE ifile;
- struct scrpos *scrpos;
+public void store_pos(IFILE ifile, struct scrpos *scrpos)
{
int_ifile(ifile)->h_scrpos = *scrpos;
}
@@ -312,10 +278,7 @@ store_pos(ifile, scrpos)
* Recall the file position associated with a file.
* If no position has been associated with the file, return NULL_POSITION.
*/
- public void
-get_pos(ifile, scrpos)
- IFILE ifile;
- struct scrpos *scrpos;
+public void get_pos(IFILE ifile, struct scrpos *scrpos)
{
*scrpos = int_ifile(ifile)->h_scrpos;
}
@@ -323,9 +286,7 @@ get_pos(ifile, scrpos)
/*
* Mark the ifile as "opened".
*/
- public void
-set_open(ifile)
- IFILE ifile;
+public void set_open(IFILE ifile)
{
int_ifile(ifile)->h_opened = 1;
}
@@ -333,62 +294,42 @@ set_open(ifile)
/*
* Return whether the ifile has been opened previously.
*/
- public int
-opened(ifile)
- IFILE ifile;
+public int opened(IFILE ifile)
{
return (int_ifile(ifile)->h_opened);
}
- public void
-hold_ifile(ifile, incr)
- IFILE ifile;
- int incr;
+public void hold_ifile(IFILE ifile, int incr)
{
int_ifile(ifile)->h_hold += incr;
}
- public int
-held_ifile(ifile)
- IFILE ifile;
+public int held_ifile(IFILE ifile)
{
return (int_ifile(ifile)->h_hold);
}
- public void *
-get_filestate(ifile)
- IFILE ifile;
+public void * get_filestate(IFILE ifile)
{
return (int_ifile(ifile)->h_filestate);
}
- public void
-set_filestate(ifile, filestate)
- IFILE ifile;
- void *filestate;
+public void set_filestate(IFILE ifile, void *filestate)
{
int_ifile(ifile)->h_filestate = filestate;
}
- public void
-set_altpipe(ifile, p)
- IFILE ifile;
- void *p;
+public void set_altpipe(IFILE ifile, void *p)
{
int_ifile(ifile)->h_altpipe = p;
}
- public void *
-get_altpipe(ifile)
- IFILE ifile;
+public void *get_altpipe(IFILE ifile)
{
return (int_ifile(ifile)->h_altpipe);
}
- public void
-set_altfilename(ifile, altfilename)
- IFILE ifile;
- char *altfilename;
+public void set_altfilename(IFILE ifile, char *altfilename)
{
struct ifile *p = int_ifile(ifile);
if (p->h_altfilename != NULL && p->h_altfilename != altfilename)
@@ -396,16 +337,13 @@ set_altfilename(ifile, altfilename)
p->h_altfilename = altfilename;
}
- public char *
-get_altfilename(ifile)
- IFILE ifile;
+public char * get_altfilename(IFILE ifile)
{
return (int_ifile(ifile)->h_altfilename);
}
#if 0
- public void
-if_dump(VOID_PARAM)
+public void if_dump(void)
{
struct ifile *p;
diff --git a/input.c b/input.c
index ffd2f13e3f3f..0e021e1d05e1 100644
--- a/input.c
+++ b/input.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -25,6 +25,7 @@ extern int quit_if_one_screen;
extern int sigs;
extern int ignore_eoi;
extern int status_col;
+extern int wordwrap;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
#if HILITE_SEARCH
@@ -34,26 +35,63 @@ extern int show_attn;
#endif
/*
+ * Set the status column.
+ * base Position of first char in line.
+ * disp First visible char.
+ * Different than base_pos if line is shifted.
+ * edisp Last visible char.
+ * eol End of line. Normally the newline.
+ * Different than edisp if line is chopped.
+ */
+static void init_status_col(POSITION base_pos, POSITION disp_pos, POSITION edisp_pos, POSITION eol_pos)
+{
+ int hl_before = (chop_line() && disp_pos != NULL_POSITION) ?
+ is_hilited_attr(base_pos, disp_pos, TRUE, NULL) : 0;
+ int hl_after = (chop_line()) ?
+ is_hilited_attr(edisp_pos, eol_pos, TRUE, NULL) : 0;
+ int attr;
+ char ch;
+
+ if (hl_before && hl_after)
+ {
+ attr = hl_after;
+ ch = '=';
+ } else if (hl_before)
+ {
+ attr = hl_before;
+ ch = '<';
+ } else if (hl_after)
+ {
+ attr = hl_after;
+ ch = '>';
+ } else
+ {
+ attr = is_hilited_attr(base_pos, eol_pos, TRUE, NULL);
+ ch = '*';
+ }
+ if (attr)
+ set_status_col(ch, attr);
+}
+
+/*
* Get the next line.
* A "current" position is passed and a "new" position is returned.
* The current position is the position of the first character of
* a line. The new position is the position of the first character
* of the NEXT line. The line obtained is the line starting at curr_pos.
*/
- public POSITION
-forw_line_seg(curr_pos, skipeol, rscroll, nochop)
- POSITION curr_pos;
- int skipeol;
- int rscroll;
- int nochop;
+public POSITION forw_line_seg(POSITION curr_pos, int skipeol, int rscroll, int nochop)
{
POSITION base_pos;
POSITION new_pos;
+ POSITION edisp_pos;
int c;
int blankline;
int endline;
int chopped;
int backchars;
+ POSITION wrap_pos;
+ int skipped_leading;
get_forw_line:
if (curr_pos == NULL_POSITION)
@@ -124,6 +162,15 @@ get_forw_line:
if (backchars > 0)
{
pshift_all();
+ if (wordwrap && (c == ' ' || c == '\t'))
+ {
+ do
+ {
+ new_pos++;
+ c = ch_forw_get();
+ } while (c == ' ' || c == '\t');
+ backchars = 1;
+ }
new_pos -= backchars;
while (--backchars >= 0)
(void) ch_back_get();
@@ -142,6 +189,8 @@ get_forw_line:
return (NULL_POSITION);
}
blankline = (c == '\n' || c == '\r');
+ wrap_pos = NULL_POSITION;
+ skipped_leading = FALSE;
/*
* Read each character in the line and append to the line buffer.
@@ -167,6 +216,7 @@ get_forw_line:
endline = FALSE;
} else
endline = TRUE;
+ edisp_pos = new_pos;
break;
}
if (c != '\r')
@@ -186,6 +236,7 @@ get_forw_line:
if (skipeol)
{
/* Read to end of line. */
+ edisp_pos = ch_tell();
do
{
if (ABORT_SIGS())
@@ -201,11 +252,50 @@ get_forw_line:
chopped = TRUE;
} else
{
- new_pos = ch_tell() - backchars;
+ if (!wordwrap)
+ new_pos = ch_tell() - backchars;
+ else
+ {
+ /*
+ * We're word-wrapping, so go back to the last space.
+ * However, if it's the space itself that couldn't fit,
+ * simply ignore it and any subsequent spaces.
+ */
+ if (c == ' ' || c == '\t')
+ {
+ do
+ {
+ new_pos = ch_tell();
+ c = ch_forw_get();
+ } while (c == ' ' || c == '\t');
+ if (c == '\r')
+ c = ch_forw_get();
+ if (c == '\n')
+ new_pos = ch_tell();
+ } else if (wrap_pos == NULL_POSITION)
+ new_pos = ch_tell() - backchars;
+ else
+ {
+ new_pos = wrap_pos;
+ loadc();
+ }
+ }
endline = FALSE;
}
break;
}
+ if (wordwrap)
+ {
+ if (c == ' ' || c == '\t')
+ {
+ if (skipped_leading)
+ {
+ wrap_pos = ch_tell();
+ savec();
+ }
+ } else
+ skipped_leading = TRUE;
+ }
c = ch_forw_get();
}
@@ -228,13 +318,8 @@ get_forw_line:
curr_pos = new_pos;
goto get_forw_line;
}
-
if (status_col)
- {
- int attr = is_hilited_attr(base_pos, ch_tell()-1, 1, NULL);
- if (attr)
- set_status_col('*', attr);
- }
+ init_status_col(base_pos, line_position(), edisp_pos, new_pos);
#endif
if (squeeze && blankline)
@@ -258,9 +343,7 @@ get_forw_line:
return (new_pos);
}
- public POSITION
-forw_line(curr_pos)
- POSITION curr_pos;
+public POSITION forw_line(POSITION curr_pos)
{
return forw_line_seg(curr_pos, (chop_line() || hshift > 0), TRUE, FALSE);
@@ -273,15 +356,18 @@ forw_line(curr_pos)
* a line. The new position is the position of the first character
* of the PREVIOUS line. The line obtained is the one starting at new_pos.
*/
- public POSITION
-back_line(curr_pos)
- POSITION curr_pos;
+public POSITION back_line(POSITION curr_pos)
{
- POSITION new_pos, begin_new_pos, base_pos;
+ POSITION base_pos;
+ POSITION new_pos;
+ POSITION edisp_pos;
+ POSITION begin_new_pos;
int c;
int endline;
int chopped;
int backchars;
+ POSITION wrap_pos;
+ int skipped_leading;
get_back_line:
if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
@@ -383,11 +469,13 @@ get_back_line:
prewind();
plinestart(new_pos);
loop:
+ wrap_pos = NULL_POSITION;
+ skipped_leading = FALSE;
begin_new_pos = new_pos;
(void) ch_seek(new_pos);
chopped = FALSE;
- do
+ for (;;)
{
c = ch_forw_get();
if (c == EOI || ABORT_SIGS())
@@ -405,6 +493,7 @@ get_back_line:
goto shift;
}
endline = TRUE;
+ edisp_pos = new_pos;
break;
}
backchars = pappend(c, ch_tell()-1);
@@ -420,18 +509,65 @@ get_back_line:
endline = TRUE;
chopped = TRUE;
quit_if_one_screen = FALSE;
+ edisp_pos = new_pos;
break;
}
shift:
- pshift_all();
- while (backchars-- > 0)
+ if (!wordwrap)
{
- (void) ch_back_get();
- new_pos--;
+ pshift_all();
+ new_pos -= backchars;
+ } else
+ {
+ if (c == ' ' || c == '\t')
+ {
+ for (;;)
+ {
+ c = ch_forw_get();
+ if (c == ' ' || c == '\t')
+ new_pos++;
+ else
+ {
+ if (c == '\r')
+ {
+ c = ch_forw_get();
+ if (c == '\n')
+ new_pos++;
+ }
+ if (c == '\n')
+ new_pos++;
+ break;
+ }
+ }
+ if (new_pos >= curr_pos)
+ break;
+ pshift_all();
+ } else
+ {
+ pshift_all();
+ if (wrap_pos == NULL_POSITION)
+ new_pos -= backchars;
+ else
+ new_pos = wrap_pos;
+ }
}
goto loop;
}
- } while (new_pos < curr_pos);
+ if (wordwrap)
+ {
+ if (c == ' ' || c == '\t')
+ {
+ if (skipped_leading)
+ wrap_pos = new_pos;
+ } else
+ skipped_leading = TRUE;
+ }
+ if (new_pos >= curr_pos)
+ {
+ edisp_pos = new_pos;
+ break;
+ }
+ }
pdone(endline, chopped, 0);
@@ -445,13 +581,8 @@ get_back_line:
curr_pos = begin_new_pos;
goto get_back_line;
}
-
- if (status_col && curr_pos > 0)
- {
- int attr = is_hilited_attr(base_pos, curr_pos-1, 1, NULL);
- if (attr)
- set_status_col('*', attr);
- }
+ if (status_col)
+ init_status_col(base_pos, line_position(), edisp_pos, new_pos);
#endif
return (begin_new_pos);
@@ -460,9 +591,7 @@ get_back_line:
/*
* Set attnpos.
*/
- public void
-set_attnpos(pos)
- POSITION pos;
+public void set_attnpos(POSITION pos)
{
int c;
diff --git a/jump.c b/jump.c
index ee1b0c632028..2bb4abbc1a09 100644
--- a/jump.c
+++ b/jump.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -25,8 +25,7 @@ extern int top_scroll;
/*
* Jump to the end of the file.
*/
- public void
-jump_forw(VOID_PARAM)
+public void jump_forw(void)
{
POSITION pos;
POSITION end_pos;
@@ -36,6 +35,12 @@ jump_forw(VOID_PARAM)
error("Cannot seek to end of file", NULL_PARG);
return;
}
+ end_pos = ch_tell();
+ if (position(sc_height-1) == end_pos)
+ {
+ eof_bell();
+ return;
+ }
/*
* Note; lastmark will be called later by jump_loc, but it fails
* because the position table has been cleared by pos_clear below.
@@ -48,7 +53,6 @@ jump_forw(VOID_PARAM)
* to get to the beginning of the last line.
*/
pos_clear();
- end_pos = ch_tell();
pos = back_line(end_pos);
if (pos == NULL_POSITION)
jump_loc(ch_zero(), sc_height-1);
@@ -63,8 +67,7 @@ jump_forw(VOID_PARAM)
/*
* Jump to the last buffered line in the file.
*/
- public void
-jump_forw_buffered(VOID_PARAM)
+public void jump_forw_buffered(void)
{
POSITION end;
@@ -81,9 +84,7 @@ jump_forw_buffered(VOID_PARAM)
/*
* Jump to line n in the file.
*/
- public void
-jump_back(linenum)
- LINENUM linenum;
+public void jump_back(LINENUM linenum)
{
POSITION pos;
PARG parg;
@@ -114,8 +115,7 @@ jump_back(linenum)
/*
* Repaint the screen.
*/
- public void
-repaint(VOID_PARAM)
+public void repaint(void)
{
struct scrpos scrpos;
/*
@@ -134,10 +134,7 @@ repaint(VOID_PARAM)
/*
* Jump to a specified percentage into the file.
*/
- public void
-jump_percent(percent, fraction)
- int percent;
- long fraction;
+public void jump_percent(int percent, long fraction)
{
POSITION pos, len;
@@ -167,10 +164,7 @@ jump_percent(percent, fraction)
* Like jump_loc, but the position need not be
* the first character in a line.
*/
- public void
-jump_line_loc(pos, sline)
- POSITION pos;
- int sline;
+public void jump_line_loc(POSITION pos, int sline)
{
int c;
@@ -195,10 +189,7 @@ jump_line_loc(pos, sline)
* The position must be the first character in a line.
* Place the target line on a specified line on the screen.
*/
- public void
-jump_loc(pos, sline)
- POSITION pos;
- int sline;
+public void jump_loc(POSITION pos, int sline)
{
int nline;
int sindex;
diff --git a/less.h b/less.h
index 43e2cc476a7d..4a4f26d83f05 100644
--- a/less.h
+++ b/less.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -39,19 +39,6 @@
/*
* Language details.
*/
-#if HAVE_ANSI_PROTOS
-#define LESSPARAMS(a) a
-#else
-#define LESSPARAMS(a) ()
-#endif
-#if HAVE_VOID
-#define VOID_POINTER void *
-#define VOID_PARAM void
-#else
-#define VOID_POINTER char *
-#define VOID_PARAM
-#define void int
-#endif
#if HAVE_CONST
#define constant const
#else
@@ -83,6 +70,9 @@
#if HAVE_LIMITS_H
#include <limits.h>
#endif
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -90,6 +80,27 @@
#include <string.h>
#endif
+#if HAVE_STDCKDINT_H
+#include <stdckdint.h>
+#else
+/*
+ * These substitutes for C23 stdckdint macros do not set *R on overflow,
+ * and they assume A and B are nonnegative. That is good enough for us.
+ */
+#define ckd_add(r, a, b) help_ckd_add(r, a, b, sizeof *(r), signed_expr(*(r)))
+#define ckd_mul(r, a, b) help_ckd_mul(r, a, b, sizeof *(r), signed_expr(*(r)))
+/* True if the integer expression E, after promotion, is signed. */
+#define signed_expr(e) ((TRUE ? 0 : e) - 1 < 0)
+#endif
+
+#if defined UINTMAX_MAX
+typedef uintmax_t uintmax;
+#elif defined ULLONG_MAX
+typedef unsigned long long uintmax;
+#else
+typedef unsigned long uintmax;
+#endif
+
/* OS-specific includes */
#ifdef _OSK
#include <modes.h>
@@ -114,7 +125,7 @@
#if !HAVE_STDLIB_H
char *getenv();
off_t lseek();
-VOID_POINTER calloc();
+void *calloc();
void free();
#endif
@@ -289,7 +300,7 @@ typedef off_t LINENUM;
/*
* An IFILE represents an input file.
*/
-#define IFILE VOID_POINTER
+#define IFILE void*
#define NULL_IFILE ((IFILE)NULL)
/*
@@ -332,11 +343,20 @@ struct wchar_range_table
int count;
};
+#if HAVE_POLL
+typedef short POLL_EVENTS;
+#endif
+
#define EOI (-1)
+#define READ_ERR (-1)
#define READ_INTR (-2)
+#define READ_AGAIN (-3)
-/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
+/*
+ * A fraction is represented by a long n; the fraction is n/NUM_FRAC_DENOM.
+ * To avoid overflow problems, 0 <= n < NUM_FRAC_DENUM <= LONG_MAX/100.
+ */
#define NUM_FRAC_DENOM 1000000
#define NUM_LOG_FRAC_DENOM 6
@@ -368,6 +388,9 @@ struct wchar_range_table
#define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */
#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
#define SRCH_WRAP (1 << 15) /* Wrap-around search (continue at BOF/EOF) */
+#define SRCH_SUBSEARCH(i) (1 << (16+(i))) /* Search for subpattern */
+/* {{ Depends on NUM_SEARCH_COLORS==5 }} */
+#define SRCH_SUBSEARCH_ALL (SRCH_SUBSEARCH(1)|SRCH_SUBSEARCH(2)|SRCH_SUBSEARCH(3)|SRCH_SUBSEARCH(4)|SRCH_SUBSEARCH(5))
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
@@ -406,8 +429,10 @@ struct wchar_range_table
#define AT_COLOR_MARK (6 << AT_COLOR_SHIFT)
#define AT_COLOR_PROMPT (7 << AT_COLOR_SHIFT)
#define AT_COLOR_RSCROLL (8 << AT_COLOR_SHIFT)
-#define AT_COLOR_SEARCH (9 << AT_COLOR_SHIFT)
-#define AT_COLOR_HEADER (11 << AT_COLOR_SHIFT)
+#define AT_COLOR_HEADER (9 << AT_COLOR_SHIFT)
+#define AT_COLOR_SEARCH (10 << AT_COLOR_SHIFT)
+#define AT_COLOR_SUBSEARCH(i) ((10+(i)) << AT_COLOR_SHIFT)
+#define NUM_SEARCH_COLORS (AT_NUM_COLORS-10-1)
typedef enum { CT_NULL, CT_4BIT, CT_6BIT } COLOR_TYPE;
@@ -527,9 +552,18 @@ typedef enum {
#define S_WINCH 04
#define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
+#ifdef EXIT_SUCCESS
+#define QUIT_OK EXIT_SUCCESS
+#else
#define QUIT_OK 0
+#endif
+#ifdef EXIT_FAILURE
+#define QUIT_ERROR EXIT_FAILURE
+#define QUIT_INTERRUPT (EXIT_FAILURE+1)
+#else
#define QUIT_ERROR 1
#define QUIT_INTERRUPT 2
+#endif
#define QUIT_SAVED_STATUS (-1)
#define FOLLOW_DESC 0
@@ -568,6 +602,10 @@ typedef enum {
#define X11MOUSE_WHEEL_DOWN 0x41 /* Wheel scroll down */
#define X11MOUSE_OFFSET 0x20 /* Added to button & pos bytes to create a char */
+#if LESSTEST
+#define LESS_DUMP_CHAR CONTROL(']')
+#endif
+
struct mlist;
struct loption;
struct hilite_tree;
@@ -577,11 +615,12 @@ struct ansi_state;
#include "funcs.h"
/* Functions not included in funcs.h */
-void postoa LESSPARAMS ((POSITION, char*));
-void linenumtoa LESSPARAMS ((LINENUM, char*));
-void inttoa LESSPARAMS ((int, char*));
-int lstrtoi LESSPARAMS ((char*, char**));
-POSITION lstrtopos LESSPARAMS ((char*, char**));
+void postoa(POSITION, char*, int);
+void linenumtoa(LINENUM, char*, int);
+void inttoa(int, char*, int);
+int lstrtoi(char*, char**, int);
+POSITION lstrtopos(char*, char**, int);
+unsigned long lstrtoul(char*, char**, int);
#if MSDOS_COMPILER==WIN32C
-int pclose LESSPARAMS ((FILE*));
+int pclose(FILE*);
#endif
diff --git a/less.hlp b/less.hlp
index 59725788f609..901a11c2fae5 100644
--- a/less.hlp
+++ b/less.hlp
@@ -51,6 +51,7 @@
^F or @ Start search at FIRST file (for /) or last file (for ?).
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
+ ^S _n Search for match in _n-th parenthesized subpattern.
^W WRAP search if no match found.
---------------------------------------------------------------------------
@@ -104,6 +105,7 @@
+_c_m_d Execute the less cmd each time a new file is examined.
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
+ #_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt.
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
s _f_i_l_e Save input to a file.
v Edit the current file with $VISUAL or $EDITOR.
@@ -186,7 +188,7 @@
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
Use an alternate tags file.
-u -U .... --underline-special --UNDERLINE-SPECIAL
- Change handling of backspaces.
+ Change handling of backspaces, tabs and carriage returns.
-V ........ --version
Display the version number of "less".
-w ........ --hilite-unread
@@ -207,6 +209,8 @@
Don't display tildes after end of file.
-# [_N] .... --shift=[_N]
Set horizontal scroll amount (0 = one half screen width).
+ --exit-follow-on-close
+ Exit F command on a pipe when writer closes pipe.
--file-size
Automatically determine the size of the input file.
--follow-name
@@ -215,8 +219,12 @@
Use N lines and M columns to display file headers.
--incsearch
Search file as each pattern character is typed in.
- --line-num-width=N
- Set the width of the -N line number field to N characters.
+ --intr=_C
+ Use _C instead of ^X to interrupt a read.
+ --line-num-width=_N
+ Set the width of the -N line number field to _N characters.
+ --modelines=_N
+ Read _N lines from the input file and look for vim modelines.
--mouse
Enable mouse input.
--no-keypad
@@ -225,24 +233,44 @@
Remove duplicates from command history.
--no-number-headers
Don't give line numbers to header lines.
+ --no-search-headers
+ Don't search in header lines or columns.
+ --no-vbell
+ Disable the terminal's visual bell.
--redraw-on-quit
Redraw final screen when quitting.
- --rscroll=C
+ --rscroll=_C
Set the character used to mark truncated lines.
--save-marks
Retain marks across invocations of less.
--search-options=[EFKNRW-]
Set default options for every search.
- --status-col-width=N
- Set the width of the -J status column to N characters.
+ --show-preproc-errors
+ Display a message if preprocessor exits with an error status.
+ --proc-backspace
+ Process backspaces for bold/underline.
+ --SPECIAL-BACKSPACE
+ Treat backspaces as control characters.
+ --proc-return
+ Delete carriage returns before newline.
+ --SPECIAL-RETURN
+ Treat carriage returns as control characters.
+ --proc-tab
+ Expand tabs to spaces.
+ --SPECIAL-TAB
+ Treat tabs as control characters.
+ --status-col-width=_N
+ Set the width of the -J status column to _N characters.
--status-line
Highlight or color the entire line containing a mark.
--use-backslash
Subsequent options use backslash as escape char.
--use-color
Enables colored text.
- --wheel-lines=N
- Each click of the mouse wheel moves N lines.
+ --wheel-lines=_N
+ Each click of the mouse wheel moves _N lines.
+ --wordwrap
+ Wrap lines at spaces.
---------------------------------------------------------------------------
diff --git a/less.man b/less.man
index f5f90f11f484..70c050596bb6 100644
--- a/less.man
+++ b/less.man
@@ -19,16 +19,16 @@ LESS(1) General Commands Manual LESS(1)
names.)
DESCRIPTION
- Less is a program similar to more(1), but which allows backward move-
- ment in the file as well as forward movement. Also, less does not have
+ Less is a program similar to more(1), but which allows backward move-
+ ment in the file as well as forward movement. Also, less does not have
to read the entire input file before starting, so with large input
- files it starts up faster than text editors like vi(1). Less uses
+ files it starts up faster than text editors like vi(1). Less uses
termcap (or terminfo on some systems), so it can run on a variety of
terminals. There is even limited support for hardcopy terminals. (On
a hardcopy terminal, lines which should be printed at the top of the
screen are prefixed with a caret.)
- Commands are based on both more and vi. Commands may be preceded by a
+ Commands are based on both more and vi. Commands may be preceded by a
decimal number, called N in the descriptions below. The number is used
by some commands, as indicated.
@@ -116,14 +116,15 @@ LESS(1) General Commands Manual LESS(1)
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.) To stop waiting for more
- data, enter the interrupt character (usually ^C). On some sys-
- tems you can also use ^X. If the input is a pipe and the
- --exit-follow-on-close option is in effect, less will automati-
- cally stop waiting for data when the input side of the pipe is
+ data, enter the interrupt character (usually ^C). On systems
+ which support poll(1) you can also use ^X or the character spec-
+ ified by the --intr option. If the input is a pipe and the
+ --exit-follow-on-close option is in effect, less will automati-
+ cally stop waiting for data when the input side of the pipe is
closed.
- 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
+ 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.
g or < or ESC-<
@@ -131,12 +132,12 @@ LESS(1) General Commands Manual LESS(1)
ing: this may be slow if N is large.)
G or > or ESC->
- Go to line N in the file, default the end of the file. (Warn-
- ing: this may be slow if N is large, or if N is not specified
+ Go to line N in the file, default the end of the file. (Warn-
+ ing: this may be slow if N is large, or if N is not specified
and standard input, rather than a file, is being read.)
- ESC-G Same as G, except if no number N is specified and the input is
- standard input, goes to the last line which is currently
+ ESC-G Same as G, except if no number N is specified and the input is
+ standard input, goes to the last line which is currently
buffered.
p or % Go to a position N percent into the file. N should be between 0
@@ -145,93 +146,100 @@ LESS(1) General Commands Manual LESS(1)
P Go to the line containing byte offset N in the file.
{ If a left curly bracket appears in the top line displayed on the
- screen, the { command will go to the matching right curly
- bracket. The matching right curly bracket is positioned on the
+ screen, the { command will go to the matching right curly
+ bracket. The matching right curly bracket is positioned on the
bottom line of the screen. If there is more than one left curly
- bracket on the top line, a number N may be used to specify the
+ bracket on the top line, a number N may be used to specify the
N-th bracket on the line.
} If a right curly bracket appears in the bottom line displayed on
- the screen, the } command will go to the matching left curly
- bracket. The matching left curly bracket is positioned on the
- top line of the screen. If there is more than one right curly
- bracket on the bottom line, a number N may be used to specify
+ the screen, the } command will go to the matching left curly
+ bracket. The matching left curly bracket is positioned on the
+ top line of the screen. If there is more than one right curly
+ bracket on the bottom line, a number N may be used to specify
the N-th bracket on the line.
( Like {, but applies to parentheses rather than curly brackets.
) Like }, but applies to parentheses rather than curly brackets.
- [ Like {, but applies to square brackets rather than curly brack-
+ [ Like {, but applies to square brackets rather than curly brack-
ets.
- ] Like }, but applies to square brackets rather than curly brack-
+ ] Like }, but applies to square brackets rather than curly brack-
ets.
- ESC-^F Followed by two characters, acts like {, but uses the two char-
- acters as open and close brackets, respectively. For example,
- "ESC ^F < >" could be used to go forward to the > which matches
+ ESC-^F Followed by two characters, acts like {, but uses the two char-
+ acters as open and close brackets, respectively. For example,
+ "ESC ^F < >" could be used to go forward to the > which matches
the < in the top displayed line.
- ESC-^B Followed by two characters, acts like }, but uses the two char-
- acters as open and close brackets, respectively. For example,
+ ESC-^B Followed by two characters, acts like }, but uses the two char-
+ acters as open and close brackets, respectively. For example,
"ESC ^B < >" could be used to go backward to the < which matches
the > in the bottom displayed line.
- m Followed by any lowercase or uppercase letter, marks the first
- displayed line with that letter. If the status column is en-
- abled via the -J option, the status column shows the marked
+ m Followed by any lowercase or uppercase letter, marks the first
+ displayed line with that letter. If the status column is en-
+ abled via the -J option, the status column shows the marked
line.
- M Acts like m, except the last displayed line is marked rather
+ M Acts like m, except the last displayed line is marked rather
than the first displayed line.
- ' (Single quote.) Followed by any lowercase or uppercase letter,
- returns to the position which was previously marked with that
- letter. Followed by another single quote, returns to the posi-
- tion at which the last "large" movement command was executed.
- Followed by a ^ or $, jumps to the beginning or end of the file
- respectively. Marks are preserved when a new file is examined,
+ ' (Single quote.) Followed by any lowercase or uppercase letter,
+ returns to the position which was previously marked with that
+ letter. Followed by another single quote, returns to the posi-
+ tion at which the last "large" movement command was executed.
+ Followed by a ^ or $, jumps to the beginning or end of the file
+ respectively. Marks are preserved when a new file is examined,
so the ' command can be used to switch between input files.
^X^X Same as single quote.
- ESC-m Followed by any lowercase or uppercase letter, clears the mark
+ ESC-m Followed by any lowercase or uppercase letter, clears the mark
identified by that letter.
/pattern
Search forward in the file for the N-th line containing the pat-
tern. N defaults to 1. The pattern is a regular expression, as
- recognized by the regular expression library supplied by your
- system. The search starts at the first line displayed (but see
+ recognized by the regular expression library supplied by your
+ system. The search starts at the first line displayed (but see
the -a and -j options, which change this).
- Certain characters are special if entered at the beginning of
- the pattern; they modify the type of search rather than become
+ Certain characters are special if entered at the beginning of
+ the pattern; they modify the type of search rather than become
part of the pattern:
^N or !
Search for lines which do NOT match the pattern.
^E or *
- Search multiple files. That is, if the search reaches
- the END of the current file without finding a match, the
- search continues in the next file in the command line
+ Search multiple files. That is, if the search reaches
+ the END of the current file without finding a match, the
+ search continues in the next file in the command line
list.
^F or @
- Begin the search at the first line of the FIRST file in
- the command line list, regardless of what is currently
- displayed on the screen or the settings of the -a or -j
+ Begin the search at the first line of the FIRST file in
+ the command line list, regardless of what is currently
+ displayed on the screen or the settings of the -a or -j
options.
- ^K Highlight any text which matches the pattern on the cur-
+ ^K Highlight any text which matches the pattern on the cur-
rent screen, but don't move to the first match (KEEP cur-
rent position).
- ^R Don't interpret regular expression metacharacters; that
+ ^R Don't interpret regular expression metacharacters; that
is, do a simple textual comparison.
+ ^S Followed by a digit N between 1 and 5. Only text which
+ has a non-empty match for the N-th parenthesized SUB-PAT-
+ TERN will be considered to match the pattern. (Supported
+ only if less is built with one of the regular expression
+ libraries posix, pcre, or pcre2.) Multiple ^S modifiers
+ can be specified, to match more than one sub-pattern.
+
^W WRAP around the current file. That is, if the search
reaches the end of the current file without finding a
match, the search continues from the first line of the
@@ -264,6 +272,8 @@ LESS(1) General Commands Manual LESS(1)
^R As in forward searches.
+ ^S As in forward searches.
+
^W WRAP around the current file. That is, if the search
reaches the beginning of the current file without finding
a match, the search continues from the last line of the
@@ -410,15 +420,15 @@ LESS(1) General Commands Manual LESS(1)
press ENTER or RETURN after typing the option name.
+cmd Causes the specified cmd to be executed each time a new file is
- examined. For example, +G causes less to initially display each
+ examined. For example, +G causes less to initially display each
file starting at the end rather than the beginning.
- V Prints the version number of less being run.
+ V Prints the version number of less being run.
q or Q or :q or :Q or ZZ
- Exits less.
+ Exits less.
- The following four commands may or may not be valid, depending on your
+ The following six commands may or may not be valid, depending on your
particular installation.
v Invokes an editor to edit the current file being viewed. The
@@ -437,6 +447,11 @@ LESS(1) General Commands Manual LESS(1)
to "sh". On MS-DOS and OS/2 systems, the shell is the normal
command processor.
+ # shell-command
+ Similar to the "!" command, except that the command is expanded
+ in the same way as prompt strings. For example, the name of the
+ current file would be given as "%f".
+
| <m> shell-command
<m> represents any mark letter. Pipes a section of the input
file to the given shell command. The section of the file to be
@@ -448,14 +463,24 @@ LESS(1) General Commands Manual LESS(1)
is piped.
s filename
- Save the input to a file. This only works if the input is a
+ Save the input to a file. This works only if the input is a
pipe, not an ordinary file.
+ ^X When the "Waiting for data" message is displayed, such as while
+ in the F command, pressing ^X will stop less from waiting and
+ return to a prompt. This may cause less to think that the file
+ ends at the current position, so it may be necessary to use the
+ R or F command to see more data. The --intr option can be used
+ to specify a different character to use instead of ^X. This
+ command works only on systems that support the poll(1) function.
+ On systems without poll(1), the interrupt character (usually ^C)
+ can be used instead.
+
OPTIONS
Command line options are described below. Most options may be changed
- while less is running, via the "-" command.
+ while less is running, via the "-" command.
- Most options may be given in one of two forms: either a dash followed
+ Some options may be given in one of two forms: either a dash followed
by a single letter, or two dashes followed by a long option name. A
long option name may be abbreviated as long as the abbreviation is un-
ambiguous. For example, --quit-at-eof may be abbreviated --quit, but
@@ -466,12 +491,12 @@ LESS(1) General Commands Manual LESS(1)
example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
Options are also taken from the environment variable "LESS". For exam-
- ple, to avoid typing "less -options ..." each time less is invoked, you
- might tell csh:
+ ple, to avoid typing "less -options ..." each time less is invoked, you
+ might tell csh:
setenv LESS "-options"
- or if you use sh:
+ or if you use sh:
LESS="-options"; export LESS
@@ -485,80 +510,79 @@ LESS(1) General Commands Manual LESS(1)
Some options like -k or -D require a string to follow the option let-
ter. 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:
+ sign ($) is found. For example, you can set two -D options like this:
LESS="Dn9.1$Ds4.1"
- If the --use-backslash option appears earlier in the options, then a
- dollar sign or backslash may be included literally in an option string
+ 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
+ in effect, then backslashes are not treated specially, and there is no
way to include a dollar sign in the option string.
-? or --help
- This option displays a summary of the commands accepted by less
- (the same as the h command). (Depending on how your shell in-
- terprets the question mark, it may be necessary to quote the
+ This option displays a summary of the commands accepted by less
+ (the same as the h command). (Depending on how your shell in-
+ terprets the question mark, it may be necessary to quote the
question mark, thus: "-\?".)
-a or --search-skip-screen
- By default, forward searches start at the top of the displayed
- screen and backwards searches start at the bottom of the dis-
- played screen (except for repeated searches invoked by the n or
- N commands, which start after or before the "target" line re-
- spectively; see the -j option for more about the target line).
- The -a option causes forward searches to instead start at the
- bottom of the screen and backward searches to start at the top
+ By default, forward searches start at the top of the displayed
+ screen and backwards searches start at the bottom of the dis-
+ played screen (except for repeated searches invoked by the n or
+ N commands, which start after or before the "target" line re-
+ spectively; see the -j option for more about the target line).
+ The -a option causes forward searches to instead start at the
+ bottom of the screen and backward searches to start at the top
of the screen, thus skipping all lines displayed on the screen.
-A or --SEARCH-SKIP-SCREEN
- Causes all forward searches (not just non-repeated searches) to
- start just after the target line, and all backward searches to
- start just before the target line. Thus, forward searches will
+ Causes all forward searches (not just non-repeated searches) to
+ start just after the target line, and all backward searches to
+ start just before the target line. Thus, forward searches will
skip part of the displayed screen (from the first line up to and
- including the target line). Similarly backwards searches will
+ including the target line). Similarly backwards searches will
skip the displayed screen from the last line up to and including
the target line. This was the default behavior in less versions
prior to 441.
-bn or --buffers=n
- Specifies the amount of buffer space less will use for each
- file, in units of kilobytes (1024 bytes). By default 64 KB of
- buffer space is used for each file (unless the file is a pipe;
- see the -B option). The -b option specifies instead that n
+ Specifies the amount of buffer space less will use for each
+ file, in units of kilobytes (1024 bytes). By default 64 KB of
+ buffer space is used for each file (unless the file is a pipe;
+ see the -B option). The -b option specifies instead that n
kilobytes of buffer space should be used for each file. If n is
- -1, buffer space is unlimited; that is, the entire file can be
+ -1, buffer space is unlimited; that is, the entire file can be
read into memory.
-B or --auto-buffers
By default, when data is read from a pipe, buffers are allocated
automatically as needed. If a large amount of data is read from
- the pipe, this can cause a large amount of memory to be allo-
+ the pipe, this can cause a large amount of memory to be allo-
cated. The -B option disables this automatic allocation of buf-
fers for pipes, so that only 64 KB (or the amount of space spec-
- ified by the -b option) is used for the pipe. Warning: use of
+ ified by the -b option) is used for the pipe. Warning: use of
-B can result in erroneous display, since only the most recently
- viewed part of the piped data is kept in memory; any earlier
- data is lost.
+ viewed part of the piped data is kept in memory; any earlier
+ data is lost. Lost characters are displayed as question marks.
-c or --clear-screen
- Causes full screen repaints to be painted from the top line
- down. By default, full screen repaints are done by scrolling
+ Causes full screen repaints to be painted from the top line
+ down. By default, full screen repaints are done by scrolling
from the bottom of the screen.
-C or --CLEAR-SCREEN
- Same as -c, for compatibility with older versions of less.
+ Same as -c, for compatibility with older versions of less.
-d or --dumb
The -d option suppresses the error message normally displayed if
- the terminal is dumb; that is, lacks some important capability,
+ the terminal is dumb; that is, lacks some important capability,
such as the ability to clear the screen or scroll backward. The
- -d option does not otherwise change the behavior of less on a
+ -d option does not otherwise change the behavior of less on a
dumb terminal.
-Dxcolor or --color=xcolor
- Changes the color of different parts of the displayed text. x
+ Changes the color of different parts of the displayed text. x
is a single character which selects the type of text whose color
is being set:
@@ -580,6 +604,11 @@ LESS(1) General Commands Manual LESS(1)
S Search results.
+ 1-5 The text in a search result which matches the first
+ through fifth parenthesized sub-pattern. Sub-pattern
+ coloring works only if less is built with one of the reg-
+ ular expression libraries posix, pcre, or pcre2.
+
W The highlight enabled via the -w option.
d Bold text.
@@ -590,16 +619,16 @@ LESS(1) General Commands Manual LESS(1)
u Underlined text.
- The uppercase letters can be used only when the --use-color op-
- tion is enabled. When text color is specified by both an upper-
- case letter and a lowercase letter, the uppercase letter takes
- precedence. For example, error messages are normally displayed
- as standout text. So if both "s" and "E" are given a color, the
- "E" color applies to error messages, and the "s" color applies
- to other standout text. The "d" and "u" letters refer to bold
- and underline text formed by overstriking with backspaces (see
- the -u option), not to text using ANSI escape sequences with the
- -R option.
+ The uppercase letters and digits can be used only when the
+ --use-color option is enabled. When text color is specified by
+ both an uppercase letter and a lowercase letter, the uppercase
+ letter takes precedence. For example, error messages are nor-
+ mally displayed as standout text. So if both "s" and "E" are
+ given a color, the "E" color applies to error messages, and the
+ "s" color applies to other standout text. The "d" and "u" let-
+ ters refer to bold and underline text formed by overstriking
+ with backspaces (see the -U option), not to text using ANSI es-
+ cape sequences with the -R option.
A lowercase letter may be followed by a + to indicate that the
normal format change and the specified color should both be
@@ -630,7 +659,7 @@ LESS(1) General Commands Manual LESS(1)
y Yellow
- The corresponding upper-case letter denotes a brighter shade of
+ The corresponding uppercase letter denotes a brighter shade of
the color. For example, -DNGk displays line numbers as bright
green text on a black background, and -DEbR displays error mes-
sages as blue text on a bright red background. If either char-
@@ -644,36 +673,36 @@ LESS(1) General Commands Manual LESS(1)
color value (see
https://en.wikipedia.org/wiki/ANSI_escape_code#SGR) If either
integer is a "-" or is omitted, the corresponding color is set
- to that of normal text. On MS-DOS versions of less, 8-bit color
+ to that of normal text. On MS-DOS versions of less, 8-bit color
is not supported; instead, decimal values are interpreted as
4-bit CHAR_INFO.Attributes values (see
https://docs.microsoft.com/en-us/windows/console/char-info-str).
-e or --quit-at-eof
- Causes less to automatically exit the second time it reaches
- end-of-file. By default, the only way to exit less is via the
+ Causes less to automatically exit the second time it reaches
+ end-of-file. By default, the only way to exit less is via the
"q" command.
-E or --QUIT-AT-EOF
- Causes less to automatically exit the first time it reaches end-
+ Causes less to automatically exit the first time it reaches end-
of-file.
-f or --force
Forces non-regular files to be opened. (A non-regular file is a
directory or a device special file.) Also suppresses the warn-
- ing message when a binary file is opened. By default, less will
+ ing message when a binary file is opened. By default, less will
refuse to open non-regular files. Note that some operating sys-
tems will not allow directories to be read, even if -f is set.
-F or --quit-if-one-screen
- Causes less to automatically exit if the entire file can be dis-
+ Causes less to automatically exit if the entire file can be dis-
played on the first screen.
-g or --hilite-search
- Normally, less will highlight ALL strings which match the last
+ Normally, less will highlight ALL strings which match the last
search command. The -g option changes this behavior to high-
light only the particular string which was found by the last
- search command. This can cause less to run somewhat faster than
+ search command. This can cause less to run somewhat faster than
the default.
-G or --HILITE-SEARCH
@@ -710,64 +739,79 @@ LESS(1) General Commands Manual LESS(1)
the screen, starting with a decimal point: .5 is in the middle
of the screen, .3 is three tenths down from the first line, and
so on. If the line is specified as a fraction, the actual line
- number is recalculated if the terminal window is resized, so
- that the target line remains at the specified fraction of the
- screen height. If any form of the -j option is used, repeated
- forward searches (invoked with "n" or "N") begin at the line im-
- mediately after the target line, and repeated backward searches
- begin at the target line, unless changed by -a or -A. For exam-
- ple, if "-j4" is used, the target line is the fourth line on the
- screen, so forward searches begin at the fifth line on the
- screen. However nonrepeated searches (invoked with "/" or "?")
- always begin at the start or end of the current screen respec-
- tively.
+ number is recalculated if the terminal window is resized. If
+ any form of the -j option is used, repeated forward searches
+ (invoked with "n" or "N") begin at the line immediately after
+ the target line, and repeated backward searches begin at the
+ target line, unless changed by -a or -A. For example, if "-j4"
+ is used, the target line is the fourth line on the screen, so
+ forward searches begin at the fifth line on the screen. However
+ nonrepeated searches (invoked with "/" or "?") always begin at
+ the start or end of the current screen respectively.
-J or --status-column
Displays a status column at the left edge of the screen. The
- status column shows the lines that matched the current search,
- and any lines that are marked (via the m or M command).
+ character displayed in the status column may be one of:
+
+ > The line is chopped with the -S option, and the text that
+ is chopped off beyond the right edge of the screen con-
+ tains a match for the current search.
+
+ < The line is horizontally shifted, and the text that is
+ shifted beyond the left side of the screen contains a
+ match for the current search.
+
+ = The line is both chopped and shifted, and there are
+ matches beyond both sides of the screen.
+
+ * There are matches in the visible part of the line but
+ none to the right or left of it.
+
+ a-z, A-Z
+ The line has been marked with the corresponding letter
+ via the m command.
-kfilename or --lesskey-file=filename
- Causes less to open and interpret the named file as a lesskey(1)
+ Causes less to open and interpret the named file as a lesskey(1)
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 lesskey file.
+ is also used as a lesskey file.
--lesskey-src=filename
- Causes less to open and interpret the named file as a lesskey(1)
+ Causes less to open and interpret the named file as a lesskey(1)
source file. If the LESSKEYIN or LESSKEYIN_SYSTEM environment
variable is set, or if a lesskey source file is found in a stan-
dard place (see KEY BINDINGS), it is also used as a lesskey
- source file. Prior to version 582, the lesskey program needed
+ source file. Prior to version 582, the lesskey program needed
to be run to convert a lesskey source file to a lesskey binary
- file for less to use. Newer versions of less read the lesskey
+ file for less to use. Newer versions of less read the lesskey
source file directly and ignore the binary file if the source
file exists.
-K or --quit-on-intr
- Causes less to exit immediately (with status 2) when an inter-
+ Causes less to exit immediately (with status 2) when an inter-
rupt character (usually ^C) is typed. Normally, an interrupt
- character causes less to stop whatever it is doing and return to
+ character causes less to stop whatever it is doing and return to
its command prompt. Note that use of this option makes it im-
possible to return to the command prompt from the "F" command.
-L or --no-lessopen
Ignore the LESSOPEN environment variable (see the INPUT PRE-
PROCESSOR section below). This option can be set from within
- less, but it will apply only to files opened subsequently, not
+ less, but it will apply only to files opened subsequently, not
to the file which is currently open.
-m or --long-prompt
- Causes less to prompt verbosely (like more), with the percent
- into the file. By default, less prompts with a colon.
+ Causes less to prompt verbosely (like more(1)), with the percent
+ into the file. By default, less prompts with a colon.
-M or --LONG-PROMPT
- Causes less to prompt even more verbosely than more.
+ Causes less to prompt even more verbosely than more(1).
-n or --line-numbers
Suppresses line numbers. The default (to use line numbers) may
- cause less to run more slowly in some cases, especially with a
+ cause less to run more slowly in some cases, especially with a
very large input file. Suppressing line numbers with the -n op-
tion will avoid this problem. Using line numbers means: the
line number will be displayed in the verbose prompt and in the =
@@ -780,9 +824,9 @@ LESS(1) General Commands Manual LESS(1)
line in the display.
-ofilename or --log-file=filename
- Causes less to copy its input to the named file as it is being
+ Causes less to copy its input to the named file as it is being
viewed. This applies only when the input file is a pipe, not an
- ordinary file. If the file already exists, less will ask for
+ ordinary file. If the file already exists, less will ask for
confirmation before overwriting it.
-Ofilename or --LOG-FILE=filename
@@ -790,19 +834,19 @@ LESS(1) General Commands Manual LESS(1)
without asking for confirmation.
If no log file has been specified, the -o and -O options can be
- used from within less to specify a log file. Without a file
+ used from within less to specify a log file. Without a file
name, they will simply report the name of the log file. The "s"
- command is equivalent to specifying -o from within less.
+ command is equivalent to specifying -o from within less.
-ppattern or --pattern=pattern
The -p option on the command line is equivalent to specifying
- +/pattern; that is, it tells less to start at the first occur-
+ +/pattern; that is, it tells less to start at the first occur-
rence of pattern in the file.
-Pprompt or --prompt=prompt
Provides a way to tailor the three prompt styles to your own
preference. This option would normally be put in the LESS envi-
- ronment variable, rather than being typed in with each less com-
+ ronment variable, rather than being typed in with each less com-
mand. Such an option must either be the last option in the LESS
variable, or be terminated by a dollar sign.
-Ps followed by a string changes the default (short) prompt to
@@ -833,24 +877,25 @@ LESS(1) General Commands Manual LESS(1)
-r or --raw-control-chars
Causes "raw" control characters to be displayed. The default is
to display control characters using the caret notation; for ex-
- ample, a control-A (octal 001) is displayed as "^A". Warning:
- when the -r option is used, less cannot keep track of the actual
- appearance of the screen (since this depends on how the screen
- responds to each type of control character). Thus, various dis-
- play problems may result, such as long lines being split in the
+ ample, a control-A (octal 001) is displayed as "^A" (with some
+ exceptions as described under the -U option). Warning: when the
+ -r option is used, less cannot keep track of the actual appear-
+ ance of the screen (since this depends on how the screen re-
+ sponds to each type of control character). Thus, various dis-
+ play problems may result, such as long lines being split in the
wrong place.
USE OF THE -r OPTION IS NOT RECOMMENDED.
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences and OSC 8 hyper-
- link sequences are output in "raw" form. Unlike -r, the screen
- appearance is maintained correctly, provided that there are no
- escape sequences in the file other than these types of escape
- sequences. Color escape sequences are only supported when the
- color is changed within one line, not across lines. In other
- words, the beginning of each line is assumed to be normal (non-
- colored), regardless of any escape sequences in previous lines.
+ link sequences are output in "raw" form. Unlike -r, the screen
+ appearance is maintained correctly, provided that there are no
+ escape sequences in the file other than these types of escape
+ sequences. Color escape sequences are only supported when the
+ color is changed within one line, not across lines. In other
+ words, the beginning of each line is assumed to be normal (non-
+ colored), regardless of any escape sequences in previous lines.
For the purpose of keeping track of screen appearance, these es-
cape sequences are assumed to not move the cursor.
@@ -858,45 +903,46 @@ LESS(1) General Commands Manual LESS(1)
ESC ] 8 ; ... \7
- The terminating sequence may be either a BEL character (\7) or
+ The terminating sequence may be either a BEL character (\7) or
the two-character sequence "ESC \".
ANSI color escape sequences are sequences of the form:
ESC [ ... m
- where the "..." is zero or more color specification characters.
- You can make less think that characters other than "m" can end
- ANSI color escape sequences by setting the environment variable
+ where the "..." is zero or more color specification characters.
+ You can make less think that characters other than "m" can end
+ ANSI color escape sequences by setting the environment variable
LESSANSIENDCHARS to the list of characters which can end a color
- escape sequence. And you can make less think that characters
- other than the standard ones may appear between the ESC and the
- m by setting the environment variable LESSANSIMIDCHARS to the
+ escape sequence. And you can make less think that characters
+ other than the standard ones may appear between the ESC and the
+ m by setting the environment variable LESSANSIMIDCHARS to the
list of characters which can appear.
-s or --squeeze-blank-lines
- Causes consecutive blank lines to be squeezed into a single
- blank line. This is useful when viewing nroff output.
+ Causes consecutive blank lines to be squeezed into a single
+ blank line. This is useful when viewing nroff output.
-S or --chop-long-lines
- Causes lines longer than the screen width to be chopped (trun-
+ Causes lines longer than the screen width to be chopped (trun-
cated) rather than wrapped. That is, the portion of a long line
that does not fit in the screen width is not displayed until you
- press RIGHT-ARROW. The default is to wrap long lines; that is,
- display the remainder on the next line.
+ press RIGHT-ARROW. The default is to wrap long lines; that is,
+ display the remainder on the next line. See also the --wordwrap
+ option.
-ttag or --tag=tag
The -t option, followed immediately by a TAG, will edit the file
containing that tag. For this to work, tag information must be
available; for example, there may be a file in the current di-
- rectory called "tags", which was previously built by ctags(1) or
+ rectory called "tags", which was previously built by ctags(1) or
an equivalent command. If the environment variable LESSGLOBALT-
AGS is set, it is taken to be the name of a command compatible
- with global(1), and that command is executed to find the tag.
+ with global(1), and that command is executed to find the tag.
(See http://www.gnu.org/software/global/global.html). The -t
- option may also be specified from within less (using the - com-
+ option may also be specified from within less (using the - com-
mand) as a way of examining a new file. The command ":t" is
- equivalent to specifying -t from within less.
+ equivalent to specifying -t from within less.
-Ttagsfile or --tag-file=tagsfile
Specifies a tags file to be used instead of "tags".
@@ -925,18 +971,21 @@ LESS(1) General Commands Manual LESS(1)
or underlined can be searched for if neither -u nor -U is in ef-
fect.
+ See also the --proc-backspace, --proc-tab, and --proc-return op-
+ tions.
+
-V or --version
- Displays the version number of less.
+ Displays the version number of less.
-w or --hilite-unread
- Temporarily highlights the first "new" line after a forward
+ Temporarily highlights the first "new" line after a forward
movement of a full page. The first "new" line is the line imme-
- diately following the line previously at the bottom of the
+ diately following the line previously at the bottom of the
screen. Also highlights the target line after a g or p command.
- The highlight is removed at the next command which causes move-
+ The highlight is removed at the next command which causes move-
ment. If the --status-line option is in effect, the entire line
- (the width of the screen) is highlighted. Otherwise, only the
- text in the line is highlighted, unless the -J option is in ef-
+ (the width of the screen) is highlighted. Otherwise, only the
+ text in the line is highlighted, unless the -J option is in ef-
fect, in which case only the status column is highlighted.
-W or --HILITE-UNREAD
@@ -944,48 +993,48 @@ LESS(1) General Commands Manual LESS(1)
forward movement command larger than one line.
-xn,... or --tabs=n,...
- Sets tab stops. If only one n is specified, tab stops are set
- at multiples of n. If multiple values separated by commas are
- specified, tab stops are set at those positions, and then con-
- tinue with the same spacing as the last two. For example,
- -x9,17 will set tabs at positions 9, 17, 25, 33, etc. The de-
+ Sets tab stops. If only one n is specified, tab stops are set
+ at multiples of n. If multiple values separated by commas are
+ specified, tab stops are set at those positions, and then con-
+ tinue with the same spacing as the last two. For example,
+ "-x9,17" will set tabs at positions 9, 17, 25, 33, etc. The de-
fault for n is 8.
-X or --no-init
Disables sending the termcap initialization and deinitialization
- strings to the terminal. This is sometimes desirable if the
- deinitialization string does something unnecessary, like clear-
+ strings to the terminal. This is sometimes desirable if the
+ deinitialization string does something unnecessary, like clear-
ing the screen.
-yn or --max-forw-scroll=n
Specifies a maximum number of lines to scroll forward. If it is
necessary to scroll forward more than n lines, the screen is re-
- painted instead. The -c or -C option may be used to repaint
- from the top of the screen if desired. By default, any forward
+ painted instead. The -c or -C option may be used to repaint
+ from the top of the screen if desired. By default, any forward
movement causes scrolling.
-zn or --window=n or -n
- Changes the default scrolling window size to n lines. The de-
- fault is one screenful. The z and w commands can also be used
- to change the window size. The "z" may be omitted for compati-
- bility with some versions of more. If the number n is negative,
- it indicates n lines less than the current screen size. For ex-
- ample, if the screen is 24 lines, -z-4 sets the scrolling window
- to 20 lines. If the screen is resized to 40 lines, the
+ Changes the default scrolling window size to n lines. The de-
+ fault is one screenful. The z and w commands can also be used
+ to change the window size. The "z" may be omitted for compati-
+ bility with some versions of more(1). If the number n is nega-
+ tive, it indicates n lines less than the current screen size.
+ For example, if the screen is 24 lines, -z-4 sets the scrolling
+ window to 20 lines. If the screen is resized to 40 lines, the
scrolling window automatically changes to 36 lines.
-"cc or --quotes=cc
- Changes the filename quoting character. This may be necessary
- if you are trying to name a file which contains both spaces and
- quote characters. Followed by a single character, this changes
- the quote character to that character. Filenames containing a
+ Changes the filename quoting character. This may be necessary
+ if you are trying to name a file which contains both spaces and
+ quote characters. Followed by a single character, this changes
+ the quote character to that character. Filenames containing a
space should then be surrounded by that character rather than by
- double quotes. Followed by two characters, changes the open
- quote to the first character, and the close quote to the second
+ double quotes. Followed by two characters, changes the open
+ quote to the first character, and the close quote to the second
character. Filenames containing a space should then be preceded
- by the open quote character and followed by the close quote
- character. Note that even after the quote characters are
- changed, this option remains -" (a dash followed by a double
+ by the open quote character and followed by the close quote
+ character. Note that even after the quote characters are
+ changed, this option remains -" (a dash followed by a double
quote).
-~ or --tilde
@@ -995,61 +1044,88 @@ LESS(1) General Commands Manual LESS(1)
-# or --shift
Specifies the default number of positions to scroll horizontally
- in the RIGHTARROW and LEFTARROW commands. If the number speci-
- fied is zero, it sets the default number of positions to one
+ in the RIGHTARROW and LEFTARROW commands. If the number speci-
+ fied is zero, it sets the default number of positions to one
half of the screen width. Alternately, the number may be speci-
- fied as a fraction of the width of the screen, starting with a
- decimal point: .5 is half of the screen width, .3 is three
- tenths of the screen width, and so on. If the number is speci-
+ fied as a fraction of the width of the screen, starting with a
+ decimal point: .5 is half of the screen width, .3 is three
+ tenths of the screen width, and so on. If the number is speci-
fied as a fraction, the actual number of scroll positions is re-
- calculated if the terminal window is resized, so that the actual
- scroll remains at the specified fraction of the screen width.
+ calculated if the terminal window is resized.
--exit-follow-on-close
- When using the "F" command on a pipe, less will automatically
+ When using the "F" command on a pipe, less will automatically
stop waiting for more data when the input side of the pipe is
closed.
--file-size
- If --file-size is specified, 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 non-seekable
- (such as a pipe) and is large.
+ If --file-size is specified, less will determine the size of the
+ file immediately after opening the file. Then the "=" command
+ will display the number of lines in the file. Normally this is
+ not done, because it can be slow if the input file is non-seek-
+ able (such as a pipe) and is large.
--follow-name
Normally, if the input file is renamed while an F command is ex-
- ecuting, less will continue to display the contents of the orig-
- inal file despite its name change. If --follow-name is speci-
- fied, during an F command less will periodically attempt to re-
+ ecuting, less will continue to display the contents of the orig-
+ inal file despite its name change. If --follow-name is speci-
+ fied, during an F command less will periodically attempt to re-
open the file by name. If the reopen succeeds and the file is a
- different file from the original (which means that a new file
- has been created with the same name as the original (now re-
- named) file), less will display the contents of that new file.
+ different file from the original (which means that a new file
+ has been created with the same name as the original (now re-
+ named) file), less will display the contents of that new file.
- --header
- Sets the number of header lines and columns displayed on the
- screen. The value may be of the form "N,M" where N and M are
+ --header=N[,M]
+ Sets the number of header lines and columns displayed on the
+ screen. The value may be of the form "N,M" where N and M are
integers, to set the header lines to N and the header columns to
M, or it may be a single integer "N" which sets the header lines
- to N and the header columns to zero. When N is nonzero, the
- first N lines at the top of the screen are replaced with the
- first N lines of the file, regardless of what part of the file
- are being viewed. When M is nonzero, the characters displayed
- at the beginning of each line are replaced with the first M
- characters of the line, even if the rest of the line is scrolled
- horizontally. If either N or M is zero, less stops displaying
- header lines or columns, respectively. (Note that it may be
- necessary to change the setting of the -j option to ensure that
- the target line is not obscured by the header line(s).)
+ to N and the header columns to zero, or it may be ",M" which
+ sets the header columns to M and the header lines to zero. When
+ N is nonzero, the first N lines at the top of the screen are re-
+ placed with the first N lines of the file, regardless of what
+ part of the file are being viewed. When M is nonzero, the char-
+ acters displayed at the beginning of each line are replaced with
+ the first M characters of the line, even if the rest of the line
+ is scrolled horizontally. If either N or M is zero, less stops
+ displaying header lines or columns, respectively. (Note that it
+ may be necessary to change the setting of the -j option to en-
+ sure that the target line is not obscured by the header
+ line(s).)
--incsearch
- Subsequent search commands will be "incremental"; that is, less
- will advance to the next line containing the search pattern as
+ Subsequent search commands will be "incremental"; that is, less
+ will advance to the next line containing the search pattern as
each character of the pattern is typed in.
- --line-num-width
- Sets the minimum width of the line number field when the -N op-
- tion is in effect. The default is 7 characters.
+ --intr=c
+ Use the character c instead of ^X to interrupt a read when the
+ "Waiting for data" message is displayed. c must be an ASCII
+ character; that is, one with a value between 1 and 127 inclu-
+ sive. A caret followed by a single character can be used to
+ specify a control character.
+
+ --line-num-width=n
+ Sets the minimum width of the line number field when the -N op-
+ tion is in effect to n characters. The default is 7.
+
+ --modelines=n
+ Before displaying a file, less will read the first n lines to
+ try to find a vim-compatible modeline. If n is zero, less does
+ not try to find modelines. By using a modeline, the file itself
+ can specify the tab stops that should be used when viewing it.
+
+ A modeline contains, anywhere in the line, a program name ("vi",
+ "vim", "ex", or "less"), followed by a colon, possibly followed
+ by the word "set", and finally followed by zero or more option
+ settings. If the word "set" is used, option settings are sepa-
+ rated by spaces, and end at the first colon. If the word "set"
+ is not used, option settings may be separated by either spaces
+ or colons. The word "set" is required if the program name is
+ "less" but optional if any of the other three names are used.
+ If any option setting is of the form "tabstop=n" or "ts=n", then
+ tab stops are automatically set as if --tabs=n had been given.
+ See the --tabs description for acceptable values of n.
--mouse
Enables mouse input: scrolling the mouse wheel down moves for-
@@ -1058,7 +1134,7 @@ LESS(1) General Commands Manual LESS(1)
line where the mouse is clicked. The number of lines to scroll
when the wheel is moved can be set by the --wheel-lines option.
Mouse input works only on terminals which support X11 mouse re-
- porting, and on the Windows version of less.
+ porting, and on the Windows version of less.
--MOUSE
Like --mouse, except the direction scrolled on mouse wheel move-
@@ -1082,88 +1158,143 @@ LESS(1) General Commands Manual LESS(1)
line numbers. Line number 1 is assigned to the first line after
any header lines.
- --rscroll
- This option changes the character used to mark truncated lines.
- It may begin with a two-character attribute indicator like LESS-
- BINFMT does. If there is no attribute indicator, standout is
- used. If set to "-", truncated lines are not marked.
+ --no-search-headers
+ Searches do not include header lines or header columns.
+
+ --no-vbell
+ Disables the terminal's visual bell.
+
+ --proc-backspace
+ If set, backspaces are handled as if neither the -u option nor
+ the -U option were set. That is, a backspace adjacent to an un-
+ derscore causes text to be displayed in underline mode, and a
+ backspace between identical characters cause text to be dis-
+ played in boldface mode. This option overrides the -u and -U
+ options, so that display of backspaces can be controlled sepa-
+ rate from tabs and carriage returns. If not set, backspace dis-
+ play is controlled by the -u and -U options.
+
+ --PROC-BACKSPACE
+ If set, backspaces are handled as if the -U option were set;
+ that is backspaces are treated as control characters.
+
+ --proc-return
+ If set, carriage returns are handled as if neither the -u option
+ nor the -U option were set. That is, a carriage return immedi-
+ ately before a newline is deleted. This option overrides the -u
+ and -U options, so that display of carriage returns can be con-
+ trolled separate from that of backspaces and tabs. If not set,
+ carriage return display is controlled by the -u and -U options.
+
+ --PROC-RETURN
+ If set, carriage returns are handled as if the -U option were
+ set; that is carriage returns are treated as control characters.
+
+ --proc-tab
+ If set, tabs are handled as if the -U option were not set. That
+ is, tabs are expanded to spaces. This option overrides the -U
+ option, so that display of tabs can be controlled separate from
+ that of backspaces and carriage returns. If not set, tab dis-
+ play is controlled by the -U options.
+
+ --PROC-TAB
+ If set, tabs are handled as if the -U option were set; that is
+ tabs are treated as control characters.
--redraw-on-quit
When quitting, after sending the terminal deinitialization
string, redraws the entire last screen. On terminals whose ter-
minal deinitialization string causes the terminal to switch from
an alternate screen, this makes the last screenful of the cur-
- rent file remain visible after less has quit.
+ rent file remain visible after less has quit.
+
+ --rscroll=c
+ This option changes the character used to mark truncated lines.
+ It may begin with a two-character attribute indicator like LESS-
+ BINFMT does. If there is no attribute indicator, standout is
+ used. If set to "-", truncated lines are not marked.
--save-marks
- Save marks in the history file, so marks are retained across
- different invocations of less.
+ Save marks in the history file, so marks are retained across
+ different invocations of less.
- --search-options
- Sets default search modifiers. The value is a string of one or
+ --search-options=...
+ Sets default search modifiers. The value is a string of one or
more of the characters E, F, K, N, R or W. Setting any of these
- has the same effect as typing that control character at the be-
+ has the same effect as typing that control character at the be-
ginning of every search pattern. For example, setting --search-
- options=W is the same as typing ^W at the beginning of every
- pattern. The value "-" disables all default search modifiers.
+ options=W is the same as typing ^W at the beginning of every
+ pattern. The value may also contain a digit between 1 and 5,
+ which has the same effect as typing ^S followed by that digit at
+ the beginning of every search pattern. The value "-" disables
+ all default search modifiers.
+
+ --show-preproc-errors
+ If a preprocessor produces data, then exits with a non-zero exit
+ code, less will display a warning.
- --status-col-width
+ --status-col-width=n
Sets the width of the status column when the -J option is in ef-
fect. The default is 2 characters.
--status-line
- If a line is marked, the entire line (rather than just the sta-
- tus column) is highlighted. Also lines highlighted due to the
+ If a line is marked, the entire line (rather than just the sta-
+ tus column) is highlighted. Also lines highlighted due to the
-w option will have the entire line highlighted. If --use-color
is set, the line is colored rather than highlighted.
--use-backslash
- This option changes the interpretations of options which follow
+ 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
+ option string is removed and the following character is taken
+ literally. This allows a dollar sign to be included in option
strings.
--use-color
- Enables colored text in various places. The -D option can be
- used to change the colors. Colored text works only if the ter-
- minal supports ANSI color escape sequences (as defined in EC-
+ Enables colored text in various places. The -D option can be
+ used to change the colors. Colored text works only if the ter-
+ minal supports ANSI color escape sequences (as defined in EC-
MA-48 SGR; see
https://www.ecma-international.org/publications-and-
standards/standards/ecma-48).
--wheel-lines=n
- Set the number of lines to scroll when the mouse wheel is
- scrolled and the --mouse or --MOUSE option is in effect. The
+ Set the number of lines to scroll when the mouse wheel is
+ scrolled and the --mouse or --MOUSE option is in effect. The
default is 1 line.
- -- A command line argument of "--" marks the end of option argu-
- ments. Any arguments following this are interpreted as file-
+ --wordwrap
+ When the -S option is not in use, wrap each line at a space or
+ tab if possible, so that a word is not split between two lines.
+ The default is to wrap at any character.
+
+ -- A command line argument of "--" marks the end of option argu-
+ ments. Any arguments following this are interpreted as file-
names. This can be useful when viewing a file whose name begins
with a "-" or "+".
- + If a command line option begins with +, the remainder of that
- option is taken to be an initial command to less. For example,
- +G tells less to start at the end of the file rather than the
- beginning, and +/xyz tells it to start at the first occurrence
- of "xyz" in the file. As a special case, +<number> acts like
+ + If a command line option begins with +, the remainder of that
+ option is taken to be an initial command to less. For example,
+ +G tells less to start at the end of the file rather than the
+ beginning, and +/xyz tells it to start at the first occurrence
+ of "xyz" in the file. As a special case, +<number> acts like
+<number>g; that is, it starts the display at the specified line
- number (however, see the caveat under the "g" command above).
+ number (however, see the caveat under the "g" command above).
If the option starts with ++, the initial command applies to ev-
- ery file being viewed, not just the first one. The + command
+ ery file being viewed, not just the first one. The + command
described previously may also be used to set (or change) an ini-
tial command for every file.
LINE EDITING
- When entering a command line at the bottom of the screen (for example,
- a filename for the :e command, or the pattern for a search command),
+ When entering a command line at the bottom of the screen (for example,
+ a filename for the :e command, or the pattern for a search command),
certain keys can be used to manipulate the command line. Most commands
- have an alternate form in [ brackets ] which can be used if a key does
- not exist on a particular keyboard. (Note that the forms beginning
- with ESC do not work in some MS-DOS and Windows systems because ESC is
- the line erase character.) Any of these special keys may be entered
- literally by preceding it with the "literal" character, either ^V or
- ^A. A backslash itself may also be entered literally by entering two
+ have an alternate form in [ brackets ] which can be used if a key does
+ not exist on a particular keyboard. (Note that the forms beginning
+ with ESC do not work in some MS-DOS and Windows systems because ESC is
+ the line erase character.) Any of these special keys may be entered
+ literally by preceding it with the "literal" character, either ^V or
+ ^A. A backslash itself may also be entered literally by entering two
backslashes.
LEFTARROW [ ESC-h ]
@@ -1173,7 +1304,7 @@ LESS(1) General Commands Manual LESS(1)
Move the cursor one space to the right.
^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
- (That is, CONTROL and LEFTARROW simultaneously.) Move the cur-
+ (That is, CONTROL and LEFTARROW simultaneously.) Move the cur-
sor one word to the left.
^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
@@ -1187,48 +1318,48 @@ LESS(1) General Commands Manual LESS(1)
Move the cursor to the end of the line.
BACKSPACE
- Delete the character to the left of the cursor, or cancel the
+ Delete the character to the left of the cursor, or cancel the
command if the command line is empty.
DELETE or [ ESC-x ]
Delete the character under the cursor.
^BACKSPACE [ ESC-BACKSPACE ]
- (That is, CONTROL and BACKSPACE simultaneously.) Delete the
+ (That is, CONTROL and BACKSPACE simultaneously.) Delete the
word to the left of the cursor.
^DELETE [ ESC-X or ESC-DELETE ]
- (That is, CONTROL and DELETE simultaneously.) Delete the word
+ (That is, CONTROL and DELETE simultaneously.) Delete the word
under the cursor.
UPARROW [ ESC-k ]
- Retrieve the previous command line. If you first enter some
- text and then press UPARROW, it will retrieve the previous com-
+ Retrieve the previous command line. If you first enter some
+ text and then press UPARROW, it will retrieve the previous com-
mand which begins with that text.
DOWNARROW [ ESC-j ]
- Retrieve the next command line. If you first enter some text
- and then press DOWNARROW, it will retrieve the next command
+ 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.
- TAB Complete the partial filename to the left of the cursor. If it
- matches more than one filename, the first match is entered into
- the command line. Repeated TABs will cycle thru the other
+ TAB Complete the partial filename to the left of the cursor. If it
+ matches more than one filename, the first match is entered into
+ the command line. Repeated TABs will cycle thru the other
matching filenames. If the completed filename is a directory, a
- "/" is appended to the filename. (On MS-DOS systems, a "\" is
- appended.) The environment variable LESSSEPARATOR can be used
+ "/" is appended to the filename. (On MS-DOS systems, a "\" is
+ appended.) The environment variable LESSSEPARATOR can be used
to specify a different character to append to a directory name.
BACKTAB [ ESC-TAB ]
Like, TAB, but cycles in the reverse direction thru the matching
filenames.
- ^L Complete the partial filename to the left of the cursor. If it
+ ^L Complete the partial filename to the left of the cursor. If it
matches more than one filename, all matches are entered into the
command line (if they fit).
^U (Unix and OS/2) or ESC (MS-DOS)
- Delete the entire command line, or cancel the command if the
+ Delete the entire command line, or cancel the command if the
command line is empty. If you have changed your line-kill char-
acter in Unix to something other than ^U, that character is used
instead of ^U.
@@ -1236,65 +1367,66 @@ LESS(1) General Commands Manual LESS(1)
^G Delete the entire command line and return to the main prompt.
KEY BINDINGS
- You may define your own less commands by creating a lesskey source
- file. This file specifies a set of command keys and an action associ-
- ated with each key. You may also change the line-editing keys (see
- LINE EDITING), and to set environment variables. If the environment
- variable LESSKEYIN is set, less uses that as the name of the lesskey
- source file. Otherwise, less looks in a standard place for the lesskey
- source file: On Unix systems, less looks for a lesskey file called
- "$XDG_CONFIG_HOME/lesskey" or "$HOME/.config/lesskey" or
- "$HOME/.lesskey". On MS-DOS and Windows systems, less 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 speci-
- fied in the PATH environment variable. On OS/2 systems, less 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 speci-
- fied in the INIT environment variable, and if it not found there, then
- looks for a lesskey file called "lesskey.ini" in any directory speci-
- fied in the PATH environment variable. See the lesskey manual page for
- more details.
+ You may define your own less commands by creating a lesskey source
+ file. This file specifies a set of command keys and an action associ-
+ ated with each key. You may also change the line-editing keys (see
+ LINE EDITING), and set environment variables used by less. See the
+ lesskey(1) manual page for details about the file format.
+
+ If the environment variable LESSKEYIN is set, less uses that as the
+ name of the lesskey source file. Otherwise, less looks in a standard
+ place for the lesskey source file: On Unix systems, less looks for a
+ lesskey file called "$XDG_CONFIG_HOME/lesskey" or "$HOME/.con-
+ fig/lesskey" or "$HOME/.lesskey". On MS-DOS and Windows systems, less
+ 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 di-
+ rectory specified in the PATH environment variable. On OS/2 systems,
+ less 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 "lesskey.ini" in any
+ directory specified in the PATH environment variable.
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
- LESSKEYIN_SYSTEM is set, less uses that as the name of the system-wide
- lesskey file. Otherwise, less looks in a standard place for the sys-
+ LESSKEYIN_SYSTEM is set, less uses that as the name of the system-wide
+ lesskey file. Otherwise, less looks in a standard place for the sys-
tem-wide lesskey file: On Unix systems, the system-wide lesskey file is
- /usr/local/etc/syslesskey. (However, if less was built with a differ-
+ /usr/local/etc/syslesskey. (However, if less was built with a differ-
ent 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:\_syslesskey. On OS/2 systems, the system-wide
lesskey file is c:\syslesskey.ini.
- Previous versions of less (before v582) used lesskey files with a bina-
- ry format, produced by the lesskey program. It is no longer necessary
- to use the lesskey program.
+ Previous versions of less (before v582) used lesskey files with a bina-
+ ry format, produced by the lesskey program. It is no longer necessary
+ to use the lesskey program.
INPUT PREPROCESSOR
- You may define an "input preprocessor" for less. Before less opens a
+ You may define an "input preprocessor" for less. Before less opens a
file, it first gives your input preprocessor a chance to modify the way
the contents of the file are displayed. An input preprocessor is sim-
ply an executable program (or shell script), which writes the contents
of the file to a different file, called the replacement file. The con-
tents of the replacement file are then displayed in place of the con-
tents of the original file. However, it will appear to the user as if
- the original file is opened; that is, less will display the original
+ the original file is opened; that is, less will display the original
filename as the name of the current file.
An input preprocessor receives one command line argument, the original
filename, as entered by the user. It should create the replacement
file, and when finished, print the name of the replacement file to its
standard output. If the input preprocessor does not output a replace-
- ment filename, less uses the original file, as normal. The input pre-
+ ment filename, less uses the original file, as normal. The input pre-
processor is not called when viewing standard input. To set up an in-
put preprocessor, set the LESSOPEN environment variable to a command
line which will invoke your input preprocessor. This command line
should include one occurrence of the string "%s", which will be re-
placed by the filename when the input preprocessor command is invoked.
- When less closes a file opened in such a way, it will call another pro-
+ When less closes a file opened in such a way, it will call another pro-
gram, called the input postprocessor, which may perform any desired
clean-up action (such as deleting the replacement file created by
LESSOPEN). This program receives two command line arguments, the orig-
@@ -1306,7 +1438,7 @@ LESS(1) General Commands Manual LESS(1)
of the replacement file, which was output by LESSOPEN.
For example, on many Unix systems, these two scripts will allow you to
- keep files in compressed format, but still let less view them directly:
+ keep files in compressed format, but still let less view them directly:
lessopen.sh:
#! /bin/sh
@@ -1331,14 +1463,14 @@ LESS(1) General Commands Manual LESS(1)
types of compressed files, and so on.
It is also possible to set up an input preprocessor to pipe the file
- data directly to less, rather than putting the data into a replacement
+ data directly to less, rather than putting the data into a replacement
file. This avoids the need to decompress the entire file before start-
ing to view it. An input preprocessor that works this way is called an
input pipe. An input pipe, instead of writing the name of a replace-
ment file on its standard output, writes the entire contents of the re-
placement file on its standard output. If the input pipe does not
write any characters on its standard output, then there is no replace-
- ment file and less uses the original file, as normal. To use an input
+ ment file and less uses the original file, as normal. To use an input
pipe, make the first character in the LESSOPEN environment variable a
vertical bar (|) to signify that the input preprocessor is an input
pipe. As with non-pipe input preprocessors, the command string must
@@ -1368,7 +1500,7 @@ LESS(1) General Commands Manual LESS(1)
empty. If the output is empty and the exit status is zero, the empty
output is considered to be replacement text. If the output is empty
and the exit status is nonzero, the original file is used. For compat-
- ibility with previous versions of less, if LESSOPEN starts with only
+ ibility with previous versions of less, if LESSOPEN starts with only
one vertical bar, the exit status of the preprocessor is ignored.
When an input pipe is used, a LESSCLOSE postprocessor can be used, but
@@ -1376,8 +1508,8 @@ LESS(1) General Commands Manual LESS(1)
up. In this case, the replacement file name passed to the LESSCLOSE
postprocessor is "-".
- For compatibility with previous versions of less, the input preproces-
- sor or pipe is not used if less is viewing standard input. However, if
+ For compatibility with previous versions of less, the input preproces-
+ sor or pipe is not used if less is viewing standard input. However, if
the first character of LESSOPEN is a dash (-), the input preprocessor
is used on standard input as well as other files. In this case, the
dash is not considered to be part of the preprocessor command. If
@@ -1443,7 +1575,7 @@ LESS(1) General Commands Manual LESS(1)
Selects a character set appropriate for Microsoft Windows (cp
1251).
- In rare cases, it may be desired to tailor less to use a character set
+ In rare cases, it may be desired to tailor less to use a character set
other than the ones definable by LESSCHARSET. In this case, the envi-
ronment variable LESSCHARDEF can be used to define a character set. It
should be set to a string where each character in the string represents
@@ -1474,8 +1606,8 @@ LESS(1) General Commands Manual LESS(1)
"UTF-8", "UTF8", "utf-8" or "utf8" is found in the LC_ALL, LC_CTYPE or
LANG environment variables, then the default character set is utf-8.
- If that string is not found, but your system supports the setlocale in-
- terface, less will use setlocale to determine the character set. set-
+ If that string is not found, but your system supports the setlocale in-
+ terface, less will use setlocale to determine the character set. set-
locale is controlled by setting the LANG or LC_CTYPE environment vari-
ables.
@@ -1511,6 +1643,36 @@ LESS(1) General Commands Manual LESS(1)
trailing octets) are displayed individually using LESSBINFMT so as to
facilitate diagnostic of how the UTF-8 file is ill-formed.
+ When the character set is utf-8, in rare cases it may be desirable to
+ override the Unicode definition of the type of certain characters. For
+ example, characters in a Private Use Area are normally treated as con-
+ trol characters, but if you are using a custom font with printable
+ characters in that range, it may be desirable to tell less to treat
+ such characters as printable. This can be done by setting the LESSUT-
+ FCHARDEF environment variable to a comma-separated list of character
+ type definitions. Each character type definition consists of either
+ one hexadecimal codepoint or a pair of codepoints separated by a dash,
+ followed by a colon and a type character. Each hexadecimal codepoint
+ may optionally be preceded by a "U" or "U+". If a pair of codepoints
+ is given, the type is set for all characters inclusively between the
+ two values. If there are multiple comma-separated codepoint values,
+ they must be in ascending numerical order. The type character may be
+ one of:
+
+ p A normal printable character.
+
+ w A wide (2-space) printable character.
+
+ b A binary (non-printable) character.
+
+ c A composing (zero width) character.
+
+ For example, setting LESSUTFCHARDEF to
+
+ E000-F8FF:p,F0000-FFFFD:p,100000-10FFFD:p
+
+ would make all Private Use Area characters be treated as printable.
+
PROMPTS
The -P option allows you to tailor the prompt to your preference. The
string given to the -P option replaces the specified prompt string.
@@ -1520,7 +1682,9 @@ LESS(1) General Commands Manual LESS(1)
prompt strings.
A percent sign followed by a single character is expanded according to
- what the following character is:
+ what the following character is. (References to the input file size
+ below refer to the preprocessed size, if an input preprocessor is being
+ used.)
%bX Replaced by the byte offset into the current input file. The b
is followed by a single character (shown as X above) which spec-
@@ -1688,11 +1852,13 @@ LESS(1) General Commands Manual LESS(1)
fault.
SECURITY
- When the environment variable LESSSECURE is set to 1, less runs in a
+ When the environment variable LESSSECURE is set to 1, less runs in a
"secure" mode. This means these features are disabled:
! the shell command
+ # the pshell command
+
| the pipe command
:e the examine command.
@@ -1715,12 +1881,12 @@ LESS(1) General Commands Manual LESS(1)
COMPATIBILITY WITH MORE
If the environment variable LESS_IS_MORE is set to 1, or if the program
- is invoked via a file link named "more", less behaves (mostly) in con-
- formance with the POSIX "more" command specification. In this mode,
+ is invoked via a file link named "more", less behaves (mostly) in con-
+ formance with the POSIX more(1) command specification. In this mode,
less behaves differently in these ways:
- The -e option works differently. If the -e option is not set, less be-
- haves as if the -e option were set. If the -e option is set, less be-
+ The -e option works differently. If the -e option is not set, less be-
+ haves as if the -e option were set. If the -e option is set, less be-
haves as if the -E option were set.
The -m option works differently. If the -m option is not set, the
@@ -1730,7 +1896,7 @@ LESS(1) General Commands Manual LESS(1)
The -n option acts like the -z option. The normal behavior of the -n
option is unavailable in this mode.
- The parameter to the -p option is taken to be a less command rather
+ The parameter to the -p option is taken to be a less command rather
than a search pattern.
The LESS environment variable is ignored, and the MORE environment
@@ -1738,7 +1904,7 @@ LESS(1) General Commands Manual LESS(1)
ENVIRONMENT VARIABLES
Environment variables may be specified either in the system environment
- as usual, or in a lesskey(1) file. If environment variables are de-
+ as usual, or in a lesskey(1) file. If environment variables are de-
fined in more than one place, variables defined in a local lesskey file
take precedence over variables defined in the system environment, which
take precedence over variables defined in the system-wide lesskey file.
@@ -1768,7 +1934,7 @@ LESS(1) General Commands Manual LESS(1)
LC_CTYPE
Language for determining the character set.
- LESS Options which are passed to less automatically.
+ LESS Options which are passed to less automatically.
LESSANSIENDCHARS
Characters which may end an ANSI color escape sequence (default
@@ -1802,17 +1968,23 @@ LESS(1) General Commands Manual LESS(1)
LESSGLOBALTAGS
Name of the command used by the -t option to find global tags.
- Normally should be set to "global" if your system has the glob-
- al(1) command. If not set, global tags are not used.
+ Normally should be set to "global" if your system has the glob-
+ al(1) command. If not set, global tags are not used.
LESSHISTFILE
Name of the history file used to remember search commands and
- shell commands between invocations of less. If set to "-" or
- "/dev/null", a history file is not used. The default is
- "$XDG_STATE_HOME/lesshst" or "$HOME/.local/state/lesshst" or
- "$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.
+ shell commands between invocations of less. If set to "-" or
+ "/dev/null", a history file is not used. The default depends on
+ the operating system, but is usually:
+
+ Linux and Unix
+ "$XDG_STATE_HOME/lesshst" or "$HOME/.local/state/lesshst"
+ or "$XDG_DATA_HOME/lesshst" or "$HOME/.lesshst".
+
+ Windows and MS-DOS
+ "$HOME/_lesshst".
+
+ OS/2 "$HOME/lesshst.ini" or "$INIT/lesshst.ini".
LESSHISTSIZE
The maximum number of commands to save in the history file. The
@@ -1855,33 +2027,73 @@ LESS(1) General Commands Manual LESS(1)
LESSUTFBINFMT
Format for displaying non-printable Unicode code points.
+ LESSUTFCHARDEF
+ Overrides the type of specified Unicode characters.
+
+ LESS_COLUMNS
+ Sets the number of columns on the screen. Unlike COLUMNS, takes
+ precedence over the system's idea of the screen size, so it can
+ be used to make less use less than the full screen width. If
+ set to a negative number, sets the number of columns used to
+ this much less than the actual screen width.
+
+ LESS_LINES
+ Sets the number of lines on the screen. Unlike LINES, takes
+ precedence over the system's idea of the screen size, so it can
+ be used to make less use less than the full screen height. If
+ set to a negative number, sets the number of lines used to this
+ much less than the actual screen height. When set, less re-
+ paints the entire screen on every movement command, so scrolling
+ may be slower.
+
+ LESS_DATA_DELAY
+ Duration (in milliseconds) after starting to read data from the
+ input, after which the "Waiting for data" message will be dis-
+ played. The default is 4000 (4 seconds).
+
LESS_IS_MORE
- Emulate the more(1) command.
+ Emulate the more(1) command.
- LINES Sets the number of lines on the screen. Takes precedence over
+ LESS_TERMCAP_xx
+ Where "xx" is any two characters, overrides the definition of
+ the termcap "xx" capability for the terminal.
+
+ LINES Sets the number of lines on the screen. 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
+ 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.)
- MORE Options which are passed to less automatically when running in
- more compatible mode.
+ MORE Options which are passed to less automatically when running in
+ more-compatible mode.
- PATH User's search path (used to find a lesskey file on MS-DOS and
+ PATH User's search path (used to find a lesskey file on MS-DOS and
OS/2 systems).
- SHELL The shell used to execute the ! command, as well as to expand
+ SHELL The shell used to execute the ! command, as well as to expand
filenames.
- TERM The type of terminal on which less is being run.
+ TERM The type of terminal on which less is being run.
VISUAL The name of the editor (used for the v command).
+ XDG_CONFIG_HOME
+ Possible location of the lesskey file; see the KEY BINDINGS sec-
+ tion.
+
+ XDG_DATA_HOME
+ Possible location of the history file; see the description of
+ the LESSHISTFILE environment variable.
+
+ XDG_STATE_HOME
+ Possible location of the history file; see the description of
+ the LESSHISTFILE environment variable.
+
SEE ALSO
- lesskey(1)
+ lesskey(1), lessecho(1)
COPYRIGHT
- Copyright (C) 1984-2022 Mark Nudelman
+ Copyright (C) 1984-2023 Mark Nudelman
less is part of the GNU project and is free software. You can redis-
tribute it and/or modify it under the terms of either (1) the GNU Gen-
@@ -1906,4 +2118,4 @@ LESS(1) General Commands Manual LESS(1)
- Version 608: 22 Jul 2022 LESS(1)
+ Version 632: 06 Apr 2023 LESS(1)
diff --git a/less.nro b/less.nro
index b6dfa431ec84..c0ef536db8a3 100644
--- a/less.nro
+++ b/less.nro
@@ -1,5 +1,5 @@
'\" t
-.TH LESS 1 "Version 608: 22 Jul 2022"
+.TH LESS 1 "Version 632: 06 Apr 2023"
.SH NAME
less \- opposite of more
.SH SYNOPSIS
@@ -11,7 +11,7 @@ less \- opposite of more
.br
.B "less \-\-version"
.br
-.B "less [\-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]"
+.B "less [\-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX\(ti]"
.br
.B " [\-b \fIspace\/\fP] [\-h \fIlines\/\fP] [\-j \fIline\/\fP] [\-k \fIkeyfile\/\fP]"
.br
@@ -24,17 +24,17 @@ less \- opposite of more
(See the OPTIONS section for alternate option syntax with long option names.)
.
.SH DESCRIPTION
-.I Less
+.B Less
is a program similar to
-.IR more (1),
+.BR more (1),
but which allows backward movement
in the file as well as forward movement.
Also,
-.I less
+.B less
does not have to read the entire input file before starting,
so with large input files it starts up faster than text editors like
-.IR vi (1).
-.I Less
+.BR vi (1).
+.B Less
uses termcap (or terminfo on some systems),
so it can run on a variety of terminals.
There is even limited support for hardcopy terminals.
@@ -42,46 +42,46 @@ There is even limited support for hardcopy terminals.
of the screen are prefixed with a caret.)
.PP
Commands are based on both
-.I more
+.B more
and
-.IR vi .
+.BR vi .
Commands may be preceded by a decimal number,
called N in the descriptions below.
The number is used by some commands, as indicated.
.
.SH COMMANDS
-In the following descriptions, ^X means control-X.
+In the following descriptions, \(haX means control-X.
ESC stands for the ESCAPE key; for example ESC-v means the
two character sequence "ESCAPE", then "v".
.IP "h or H"
Help: display a summary of these commands.
If you forget all the other commands, remember this one.
-.IP "SPACE or ^V or f or ^F"
+.IP "SPACE or \(haV or f or \(haF"
Scroll forward N lines, default one window (see option \-z below).
If N is more than the screen size, only the final screenful is displayed.
-Warning: some systems use ^V as a special literalization character.
+Warning: some systems use \(haV as a special literalization character.
.IP "z"
Like SPACE, but if N is specified, it becomes the new window size.
.IP "ESC-SPACE"
Like SPACE, but scrolls a full screenful, even if it reaches
end-of-file in the process.
-.IP "ENTER or RETURN or ^N or e or ^E or j or ^J"
+.IP "ENTER or RETURN or \(haN or e or \(haE or j or \(haJ"
Scroll forward N lines, default 1.
The entire N lines are displayed, even if N is more than the screen size.
-.IP "d or ^D"
+.IP "d or \(haD"
Scroll forward 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 "b or ^B or ESC-v"
+.IP "b or \(haB or ESC-v"
Scroll backward N lines, default one window (see option \-z below).
If N is more than the screen size, only the final screenful is displayed.
.IP "w"
Like ESC-v, but if N is specified, it becomes the new window size.
-.IP "y or ^Y or ^P or k or ^K"
+.IP "y or \(haY or \(haP or k or \(haK"
Scroll backward N lines, default 1.
The entire N lines are displayed, even if N is more than the screen size.
-Warning: some systems use ^Y as a special job control character.
-.IP "u or ^U"
+Warning: some systems use \(haY as a special job control character.
+.IP "u or \(haU"
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.
@@ -101,11 +101,11 @@ Scroll horizontally left N characters, default half the screen width
(see the \-# option).
If a number N is specified, it becomes the default for future RIGHTARROW
and LEFTARROW commands.
-.IP "ESC-} or ^RIGHTARROW"
+.IP "ESC-} or \(haRIGHTARROW"
Scroll horizontally right to show the end of the longest displayed line.
-.IP "ESC-{ or ^LEFTARROW"
+.IP "ESC-{ or \(haLEFTARROW"
Scroll horizontally left back to the first column.
-.IP "r or ^R or ^L"
+.IP "r or \(haR or \(haL"
Repaint the screen.
.IP R
Repaint the screen, discarding any buffered input.
@@ -118,10 +118,12 @@ 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.)
-To stop waiting for more data, enter the interrupt character (usually ^C).
-On some systems you can also use ^X.
+To stop waiting for more data, enter the interrupt character (usually \(haC).
+On systems which support
+.BR poll (1)
+you can also use \(haX or the character specified by the \-\-intr option.
If the input is a pipe and the \-\-exit-follow-on-close option is in effect,
-.I less
+.B less
will automatically stop waiting for data when the input side
of the pipe is closed.
.IP "ESC-F"
@@ -168,17 +170,17 @@ Like }, but applies to parentheses rather than curly brackets.
Like {, but applies to square brackets rather than curly brackets.
.IP "]"
Like }, but applies to square brackets rather than curly brackets.
-.IP "ESC-^F"
+.IP "ESC-\(haF"
Followed by two characters,
acts like {, but uses the two characters as open and close brackets,
respectively.
-For example, "ESC ^F < >" could be used to
+For example, "ESC \(haF < >" could be used to
go forward to the > which matches the < in the top displayed line.
-.IP "ESC-^B"
+.IP "ESC-\(haB"
Followed by two characters,
acts like }, but uses the two characters as open and close brackets,
respectively.
-For example, "ESC ^B < >" could be used to
+For example, "ESC \(haB < >" could be used to
go backward to the < which matches the > in the bottom displayed line.
.IP m
Followed by any lowercase or uppercase letter,
@@ -188,17 +190,17 @@ the status column shows the marked line.
.IP M
Acts like m, except the last displayed line is marked
rather than the first displayed line.
-.IP "'"
+.IP "\(aq"
(Single quote.)
Followed by any lowercase or uppercase letter, returns to the position which
was previously marked with that letter.
Followed by another single quote, returns to the position at
which the last "large" movement command was executed.
-Followed by a ^ or $, jumps to the beginning or end of the
+Followed by a \(ha or $, jumps to the beginning or end of the
file respectively.
Marks are preserved when a new file is examined,
-so the ' command can be used to switch between input files.
-.IP "^X^X"
+so the \(aq command can be used to switch between input files.
+.IP "\(haX\(haX"
Same as single quote.
.IP "ESC-m"
Followed by any lowercase or uppercase letter,
@@ -215,30 +217,40 @@ Certain characters are special
if entered at the beginning of the pattern;
they modify the type of search rather than become part of the pattern:
.RS
-.IP "^N or !"
+.IP "\(haN or !"
Search for lines which do NOT match the pattern.
-.IP "^E or *"
+.IP "\(haE or *"
Search multiple files.
That is, if the search reaches the END of the current file
without finding a match,
the search continues in the next file in the command line list.
-.IP "^F or @"
+.IP "\(haF or @"
Begin the search at the first line of the FIRST file
in the command line list,
regardless of what is currently displayed on the screen
or the settings of the \-a or \-j options.
-.IP "^K"
+.IP "\(haK"
Highlight any text which matches the pattern on the current screen,
but don't move to the first match (KEEP current position).
-.IP "^R"
+.IP "\(haR"
Don't interpret regular expression metacharacters;
that is, do a simple textual comparison.
-.IP "^W"
+.IP "\(haS"
+Followed by a digit N between 1 and 5.
+Only text which has a non-empty match for the N-th parenthesized SUB-PATTERN
+will be considered to match the pattern.
+(Supported only if
+.B less
+is built with one of the regular expression libraries
+.BR posix ", " pcre ", or " pcre2 ".)"
+Multiple \(haS modifiers can be specified,
+to match more than one sub-pattern.
+.IP "\(haW"
WRAP around the current file.
That is, if the search reaches the end of the current file
without finding a match, the search continues from the first line of the
current file up to the line where it started.
-If the ^W modifier is set, the ^E modifier is ignored.
+If the \(haW modifier is set, the \(haE modifier is ignored.
.RE
.IP ?pattern
Search backward in the file for the N-th line containing the pattern.
@@ -247,23 +259,25 @@ The search starts at the last line displayed
.sp
Certain characters are special as in the / command:
.RS
-.IP "^N or !"
+.IP "\(haN or !"
Search for lines which do NOT match the pattern.
-.IP "^E or *"
+.IP "\(haE or *"
Search multiple files.
That is, if the search reaches the beginning of the current file
without finding a match,
the search continues in the previous file in the command line list.
-.IP "^F or @"
+.IP "\(haF or @"
Begin the search at the last line of the last file
in the command line list,
regardless of what is currently displayed on the screen
or the settings of the \-a or \-j options.
-.IP "^K"
+.IP "\(haK"
As in forward searches.
-.IP "^R"
+.IP "\(haR"
As in forward searches.
-.IP "^W"
+.IP "\(haS"
+As in forward searches.
+.IP "\(haW"
WRAP around the current file.
That is, if the search reaches the beginning of the current file
without finding a match, the search continues from the last line of the
@@ -275,13 +289,13 @@ Same as "/*".
Same as "?*".
.IP n
Repeat previous search, for N-th line containing the last pattern.
-If the previous search was modified by ^N, the search is made for the
+If the previous search was modified by \(haN, the search is made for the
N-th line NOT containing the pattern.
-If the previous search was modified by ^E, the search continues
+If the previous search was modified by \(haE, the search continues
in the next (or previous) file if not satisfied in the current file.
-If the previous search was modified by ^R, the search is done
+If the previous search was modified by \(haR, the search is done
without using regular expressions.
-There is no effect if the previous search was modified by ^F or ^K.
+There is no effect if the previous search was modified by \(haF or \(haK.
.IP N
Repeat previous search, but in the reverse direction.
.IP "ESC-n"
@@ -315,9 +329,9 @@ which match all of the patterns will be displayed.
.sp
Certain characters are special as in the / command:
.RS
-.IP "^N or !"
+.IP "\(haN or !"
Display only lines which do NOT match the pattern.
-.IP "^R"
+.IP "\(haR"
Don't interpret regular expression metacharacters;
that is, do a simple textual comparison.
.RE
@@ -340,10 +354,10 @@ the list of files and the first one is examined.
If the filename contains one or more spaces,
the entire filename should be enclosed in double quotes
(also see the \-" option).
-.IP "^X^V or E"
+.IP "\(haX\(haV or E"
Same as :e.
-Warning: some systems use ^V as a special literalization character.
-On such systems, you may not be able to use ^V.
+Warning: some systems use \(haV as a special literalization character.
+On such systems, you may not be able to use \(haV.
.IP ":n"
Examine the next file (from the list of files given in the command line).
If a number N is specified, the N-th next file is examined.
@@ -360,7 +374,7 @@ Go to the next tag, if there were more than one matches for the current tag.
See the \-t option for more details about tags.
.IP "T"
Go to the previous tag, if there were more than one matches for the current tag.
-.IP "= or ^G or :f"
+.IP "= or \(haG or :f"
Prints some information about the file being viewed,
including its name
and the line number and byte offset of the bottom line being displayed.
@@ -371,7 +385,7 @@ and the percent of the file above the last displayed line.
Followed by one of the command line option letters (see OPTIONS below),
this will change the setting of that option
and print a message describing the new setting.
-If a ^P (CONTROL-P) is entered immediately after the dash,
+If a \(haP (CONTROL-P) is entered immediately after the dash,
the setting of the option is changed but no message is printed.
If the option letter has a numeric value (such as \-b or \-h),
or a string value (such as \-P or \-t),
@@ -382,7 +396,7 @@ the current setting is printed and nothing is changed.
Like the \- command, but takes a long option name (see OPTIONS below)
rather than a single option letter.
You must press ENTER or RETURN after typing the option name.
-A ^P immediately after the second dash suppresses printing of a
+A \(haP immediately after the second dash suppresses printing of a
message describing the new setting, as in the \- command.
.IP \-+
Followed by one of the command line option letters
@@ -415,19 +429,19 @@ You must press ENTER or RETURN after typing the option name.
.IP +cmd
Causes the specified cmd to be executed each time a new file is examined.
For example, +G causes
-.I less
+.B less
to initially display each file starting at the end
rather than the beginning.
.IP V
Prints the version number of
-.I less
+.B less
being run.
.IP "q or Q or :q or :Q or ZZ"
Exits
-.IR less .
+.BR less .
.PP
The following
-four
+six
commands may or may not be valid, depending on your particular installation.
.
.IP v
@@ -446,6 +460,10 @@ A pound sign (#) is replaced by the name of the previously examined file.
On Unix systems, the shell is taken from the environment variable SHELL,
or defaults to "sh".
On MS-DOS and OS/2 systems, the shell is the normal command processor.
+.IP "# shell-command"
+Similar to the "!" command,
+except that the command is expanded in the same way as prompt strings.
+For example, the name of the current file would be given as "%f".
.IP "| <m> shell-command"
<m> represents any mark letter.
Pipes a section of the input file to the given shell command.
@@ -453,19 +471,37 @@ The section of the file to be piped is between the position marked by
the letter and the current screen.
The entire current screen is included, regardless of whether the
marked position is before or after the current screen.
-<m> may also be ^ or $ to indicate beginning or end of file respectively.
+<m> may also be \(ha or $ to indicate beginning or end of file respectively.
If <m> is \&.\& or newline, the current screen is piped.
.IP "s filename"
Save the input to a file.
-This only works if the input is a pipe, not an ordinary file.
+This works only if the input is a pipe, not an ordinary file.
+.IP "\(haX"
+When the "Waiting for data" message is displayed,
+such as while in the F command, pressing \(haX
+will stop
+.B less
+from waiting and return to a prompt.
+This may cause
+.B less
+to think that the file ends at the current position,
+so it may be necessary to use the R or F command to see more data.
+The \-\-intr option can be used to specify a different character
+to use instead of \(haX.
+This command works only on systems that support the
+.BR poll (1)
+function.
+On systems without
+.BR poll (1),
+the interrupt character (usually \(haC) can be used instead.
.
.SH OPTIONS
Command line options are described below.
Most options may be changed while
-.I less
+.B less
is running, via the "\-" command.
.PP
-Most options may be given in one of two forms:
+Some options may be given in one of two forms:
either a dash followed by a single letter,
or two dashes followed by a long option name.
A long option name may be abbreviated as long as
@@ -481,14 +517,14 @@ For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF.
Options are also taken from the environment variable "LESS".
For example,
to avoid typing "less \-options \&...\&" each time
-.I less
+.B less
is invoked, you might tell
-.IR csh :
+.BR csh :
.sp
setenv LESS "\-options"
.sp
or if you use
-.IR sh :
+.BR sh :
.sp
LESS="\-options"; export LESS
.sp
@@ -503,7 +539,7 @@ line option with "\-+".
.sp
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:
+For example, you can set two \-D options like this:
.sp
LESS="Dn9.1$Ds4.1"
.sp
@@ -515,7 +551,7 @@ 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
+.B less
(the same as the h command).
(Depending on how your shell interprets the question mark,
it may be necessary to quote the question mark, thus: "\-\e?".)
@@ -540,7 +576,7 @@ from the last line up to and including the target line.
This was the default behavior in less versions prior to 441.
.IP "\-b\fIn\fP or \-\-buffers=\fIn\fP"
Specifies the amount of buffer space
-.I less
+.B less
will use for each file, in units of kilobytes (1024 bytes).
By default 64\ KB of buffer space is used for each file
(unless the file is a pipe; see the \-B option).
@@ -560,20 +596,21 @@ is used for the pipe.
Warning: use of \-B can result in erroneous display, since only the
most recently viewed part of the piped data is kept in memory;
any earlier data is lost.
+Lost characters are displayed as question marks.
.IP "\-c or \-\-clear-screen"
Causes full screen repaints to be painted from the top line down.
By default,
full screen repaints are done by scrolling from the bottom of the screen.
.IP "\-C or \-\-CLEAR-SCREEN"
Same as \-c, for compatibility with older versions of
-.IR less .
+.BR less .
.IP "\-d or \-\-dumb"
The \-d option suppresses the error message
normally displayed if the terminal is dumb;
that is, lacks some important capability,
such as the ability to clear the screen or scroll backward.
The \-d option does not otherwise change the behavior of
-.I less
+.B less
on a dumb terminal.
.IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP"
Changes the color of different parts of the displayed text.
@@ -598,6 +635,13 @@ Prompts.
The rscroll character.
.IP "S"
Search results.
+.IP "1-5"
+The text in a search result which matches
+the first through fifth parenthesized sub-pattern.
+Sub-pattern coloring works only if
+.B less
+is built with one of the regular expression libraries
+.BR posix ", " pcre ", or " pcre2 .
.IP "W"
The highlight enabled via the \-w option.
.IP "d"
@@ -611,14 +655,14 @@ Underlined text.
.RE
.RS
-The uppercase letters can be used only when the \-\-use-color option is enabled.
+The uppercase letters and digits can be used only when the \-\-use-color option is enabled.
When text color is specified by both an uppercase letter and a lowercase letter,
the uppercase letter takes precedence.
For example, error messages are normally displayed as standout text.
So if both "s" and "E" are given a color, the "E" color applies
to error messages, and the "s" color applies to other standout text.
The "d" and "u" letters refer to bold and underline text formed by
-overstriking with backspaces (see the \-u option),
+overstriking with backspaces (see the \-U option),
not to text using ANSI escape sequences with the \-R option.
.PP
A lowercase letter may be followed by a + to indicate that
@@ -649,7 +693,7 @@ White
.IP "y"
Yellow
.PP
-The corresponding upper-case letter denotes a brighter shade of the color.
+The corresponding uppercase letter denotes a brighter shade of the color.
For example, \-DNGk displays line numbers as bright green text on a black
background, and \-DEbR displays error messages as blue text on a
bright red background.
@@ -668,7 +712,7 @@ https://en.wikipedia.org/wiki/ANSI_escape_code#SGR)
If either integer is a "-" or is omitted,
the corresponding color is set to that of normal text.
On MS-DOS versions of
-.IR less ,
+.BR less ,
8-bit color is not supported; instead, decimal values are interpreted as 4-bit
CHAR_INFO.Attributes values
(see
@@ -679,38 +723,38 @@ https://docs.microsoft.com/en-us/windows/console/char-info-str).
.RE
.IP "\-e or \-\-quit-at-eof"
Causes
-.I less
+.B less
to automatically exit
the second time it reaches end-of-file.
By default, the only way to exit
-.I less
+.B less
is via the "q" command.
.IP "\-E or \-\-QUIT-AT-EOF"
Causes
-.I less
+.B less
to automatically exit the first time it reaches end-of-file.
.IP "\-f or \-\-force"
Forces non-regular files to be opened.
(A non-regular file is a directory or a device special file.)
Also suppresses the warning message when a binary file is opened.
By default,
-.I less
+.B less
will refuse to open non-regular files.
Note that some operating systems will not allow directories
to be read, even if \-f is set.
.IP "\-F or \-\-quit-if-one-screen"
Causes
-.I less
+.B less
to automatically exit
if the entire file can be displayed on the first screen.
.IP "\-g or \-\-hilite-search"
Normally,
-.I less
+.B less
will highlight ALL strings which match the last search command.
The \-g option changes this behavior to highlight only the particular string
which was found by the last search command.
This can cause
-.I less
+.B less
to run somewhat faster than the default.
.IP "\-G or \-\-HILITE-SEARCH"
The \-G option suppresses all highlighting of strings found by search commands.
@@ -745,8 +789,7 @@ Alternately, the screen line may be specified as a fraction of the height
of the screen, starting with a decimal point: \&.5 is in the middle of the
screen, \&.3 is three tenths down from the first line, and so on.
If the line is specified as a fraction, the actual line number
-is recalculated if the terminal window is resized, so that the
-target line remains at the specified fraction of the screen height.
+is recalculated if the terminal window is resized.
If any form of the \-j option is used,
repeated forward searches (invoked with "n" or "N")
begin at the line immediately after the target line,
@@ -759,25 +802,42 @@ However nonrepeated searches (invoked with "/" or "?")
always begin at the start or end of the current screen respectively.
.IP "\-J or \-\-status-column"
Displays a status column at the left edge of the screen.
-The status column shows the lines that matched the current search,
-and any lines that are marked (via the m or M command).
+The character displayed in the status column may be one of:
+.RS
+.IP ">"
+The line is chopped with the \-S option, and
+the text that is chopped off beyond the right edge of the screen
+contains a match for the current search.
+.IP "<"
+The line is horizontally shifted, and
+the text that is shifted beyond the left side of the screen
+contains a match for the current search.
+.IP "="
+The line is both chopped and shifted,
+and there are matches beyond both sides of the screen.
+.IP "*"
+There are matches in the visible part of the line
+but none to the right or left of it.
+.IP "a-z, A-Z"
+The line has been marked with the corresponding letter via the m command.
+.RE
.IP "\-k\fIfilename\fP or \-\-lesskey-file=\fIfilename\fP"
Causes
-.I less
+.B less
to open and interpret the named file as a
-.IR lesskey (1)
+.BR lesskey (1)
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
+.B lesskey
file.
.IP "\-\-lesskey-src=\fIfilename\fP"
Causes
-.I less
+.B less
to open and interpret the named file as a
-.IR lesskey (1)
+.BR 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),
@@ -785,26 +845,26 @@ it is also used as a
.I "lesskey source"
file.
Prior to version 582, the
-.I lesskey
+.B lesskey
program needed to be run to convert a
.I "lesskey source"
file to a
.I "lesskey binary"
file for
-.I less
+.B less
to use.
Newer versions of
-.I less
+.B 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
+.B less
to exit immediately (with status 2)
-when an interrupt character (usually ^C) is typed.
+when an interrupt character (usually \(haC) is typed.
Normally, an interrupt character causes
-.I less
+.B less
to stop whatever it is doing and return to its command prompt.
Note that use of this option makes it impossible to return to the
command prompt from the "F" command.
@@ -812,26 +872,27 @@ command prompt from the "F" command.
Ignore the LESSOPEN environment variable
(see the INPUT PREPROCESSOR section below).
This option can be set from within
-.IR less ,
+.BR less ,
but it will apply only to files opened subsequently, not to the
file which is currently open.
.IP "\-m or \-\-long-prompt"
Causes
-.I less
-to prompt verbosely (like \fImore\fP),
+.B less
+to prompt verbosely (like
+.BR more (1)),
with the percent into the file.
By default,
-.I less
+.B less
prompts with a colon.
.IP "\-M or \-\-LONG-PROMPT"
Causes
-.I less
+.B less
to prompt even more verbosely than
-.IR more .
+.BR more (1).
.IP "\-n or \-\-line-numbers"
Suppresses line numbers.
The default (to use line numbers) may cause
-.I less
+.B less
to run more slowly in some cases, especially with a very large input file.
Suppressing line numbers with the \-n option will avoid this problem.
Using line numbers means: the line number will be displayed in the verbose
@@ -843,12 +904,12 @@ Causes a line number to be displayed at the beginning of
each line in the display.
.IP "\-o\fIfilename\fP or \-\-log-file=\fIfilename\fP"
Causes
-.I less
+.B less
to copy its input to the named file as it is being viewed.
This applies only when the input file is a pipe,
not an ordinary file.
If the file already exists,
-.I less
+.B less
will ask for confirmation before overwriting it.
.IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP"
The \-O option is like \-o, but it will overwrite an existing
@@ -856,23 +917,23 @@ file without asking for confirmation.
.sp
If no log file has been specified,
the \-o and \-O options can be used from within
-.I less
+.B less
to specify a log file.
Without a file name, they will simply report the name of the log file.
The "s" command is equivalent to specifying \-o from within
-.IR less .
+.BR less .
.IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP"
The \-p option on the command line is equivalent to
specifying +/\fIpattern\fP;
that is, it tells
-.I less
+.B less
to start at the first occurrence of \fIpattern\fP in the file.
.IP "\-P\fIprompt\fP or \-\-prompt=\fIprompt\fP"
Provides a way to tailor the three prompt
styles to your own preference.
This option would normally be put in the LESS environment
variable, rather than being typed in with each
-.I less
+.B less
command.
Such an option must either be the last option in the LESS variable,
or be terminated by a dollar sign.
@@ -904,9 +965,10 @@ where the terminal bell would have been rung.
.IP "\-r or \-\-raw-control-chars"
Causes "raw" control characters to be displayed.
The default is to display control characters using the caret notation;
-for example, a control-A (octal 001) is displayed as "^A".
+for example, a control-A (octal 001) is displayed as "\(haA"
+(with some exceptions as described under the \-U option).
Warning: when the \-r option is used,
-.I less
+.B less
cannot keep track of the actual appearance of the screen
(since this depends on how the screen responds to
each type of control character).
@@ -940,19 +1002,19 @@ ANSI color escape sequences are sequences of the form:
.sp
where the "...\&" is zero or more color specification characters.
You can make
-.I less
+.B less
think that characters other than "m" can end ANSI color escape sequences
by setting the environment variable LESSANSIENDCHARS to the list of
characters which can end a color escape sequence.
And you can make
-.I less
+.B less
think that characters other than the standard ones may appear between
the ESC and the m by setting the environment variable LESSANSIMIDCHARS
to the list of characters which can appear.
.IP "\-s or \-\-squeeze-blank-lines"
Causes consecutive blank lines to be squeezed into a single blank line.
This is useful when viewing
-.I nroff
+.B nroff
output.
.IP "\-S or \-\-chop-long-lines"
Causes lines longer than the screen width to be
@@ -961,27 +1023,28 @@ That is, the portion of a long line that does not fit in
the screen width is not displayed until you press RIGHT-ARROW.
The default is to wrap long lines; that is, display the remainder
on the next line.
+See also the \-\-wordwrap option.
.IP "\-t\fItag\fP or \-\-tag=\fItag\fP"
The \-t option, followed immediately by a TAG,
will edit the file containing that tag.
For this to work, tag information must be available;
for example, there may be a file in the current directory called "tags",
which was previously built by
-.IR ctags (1)
+.BR ctags (1)
or an equivalent command.
If the environment variable LESSGLOBALTAGS is set, it is taken to be
the name of a command compatible with
-.IR global (1),
+.BR global (1),
and that command is executed to find the tag.
(See
.nh
http://www.gnu.org/software/global/global.html).
.hy
The \-t option may also be specified from within
-.I less
+.B less
(using the \- command) as a way of examining a new file.
The command ":t" is equivalent to specifying \-t from within
-.IR less .
+.BR less .
.IP "\-T\fItagsfile\fP or \-\-tag-file=\fItagsfile\fP"
Specifies a tags file to be used instead of "tags".
.IP "\-u or \-\-underline-special"
@@ -1008,9 +1071,12 @@ Unicode formatting characters, such as the Byte Order Mark,
are sent to the terminal.
Text which is overstruck or underlined can be searched for
if neither \-u nor \-U is in effect.
+.sp
+See also the \-\-proc-backspace, \-\-proc-tab,
+and \-\-proc-return options.
.IP "\-V or \-\-version"
Displays the version number of
-.IR less .
+.BR less .
.IP "\-w or \-\-hilite-unread"
Temporarily highlights the first "new" line after a forward movement
of a full page.
@@ -1032,7 +1098,7 @@ If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP.
If multiple values separated by commas are specified, tab stops
are set at those positions, and then continue with the same spacing as the
last two.
-For example, \fI\-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc.
+For example, "-x9,17" will set tabs at positions 9, 17, 25, 33, etc.
The default for \fIn\fP is 8.
.IP "\-X or \-\-no-init"
Disables sending the termcap initialization and deinitialization strings
@@ -1051,7 +1117,7 @@ Changes the default scrolling window size to \fIn\fP lines.
The default is one screenful.
The z and w commands can also be used to change the window size.
The "z" may be omitted for compatibility with some versions of
-.IR more .
+.BR more (1).
If the number
.I n
is negative, it indicates
@@ -1074,8 +1140,8 @@ Filenames containing a space should then be preceded by the open quote
character and followed by the close quote character.
Note that even after the quote characters are changed, this option
remains \-" (a dash followed by a double quote).
-.IP "\-~ or \-\-tilde"
-Normally lines after end of file are displayed as a single tilde (~).
+.IP "\-\(ti or \-\-tilde"
+Normally lines after end of file are displayed as a single tilde (\(ti).
This option causes lines after end of file to be displayed as blank lines.
.IP "\-# or \-\-shift"
Specifies the default number of positions to scroll horizontally
@@ -1086,40 +1152,41 @@ Alternately, the number may be specified as a fraction of the width
of the screen, starting with a decimal point: \&.5 is half of the
screen width, \&.3 is three tenths of the screen width, and so on.
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.
+scroll positions is recalculated if the terminal window is resized.
.IP "\-\-exit-follow-on-close"
When using the "F" command on a pipe,
-.I less
+.B less
will automatically stop waiting for more data when the input side of the
pipe is closed.
.IP "\-\-file-size"
If \-\-file-size is specified,
-.I less
+.B less
will determine the size of the file
immediately after opening the file.
+Then the "=" command will display the number of lines in the file.
Normally this is not done, because it can be slow if the input file
is non-seekable (such as a pipe) and is large.
.IP "\-\-follow-name"
Normally, if the input file is renamed while an F command is executing,
-.I less
+.B less
will continue to display the contents of the original file despite
its name change.
If \-\-follow-name is specified, during an F command
-.I less
+.B less
will periodically attempt to reopen the file by name.
If the reopen succeeds and the file is a different file from the original
(which means that a new file has been created
with the same name as the original (now renamed) file),
-.I less
+.B less
will display the contents of that new file.
-.IP "\-\-header"
+.IP "\-\-header=\fIN[,M]\fP"
Sets the number of header lines and columns displayed on the screen.
The value may be of the form "N,M" where N and M are integers,
to set the header lines to N and the header columns to M,
or it may be a single integer "N" which sets the header lines to N
-and the header columns to zero.
+and the header columns to zero,
+or it may be ",M" which sets the header columns to M and the
+header lines to zero.
When N is nonzero, the first N lines at the top
of the screen are replaced with the first N lines of the file,
regardless of what part of the file are being viewed.
@@ -1127,18 +1194,53 @@ When M is nonzero, the characters displayed at the
beginning of each line are replaced with the first M characters of the line,
even if the rest of the line is scrolled horizontally.
If either N or M is zero,
-.I less
+.B less
stops displaying header lines or columns, respectively.
(Note that it may be necessary to change the setting of the \-j option
to ensure that the target line is not obscured by the header line(s).)
.IP "\-\-incsearch"
Subsequent search commands will be "incremental"; that is,
-.I less
+.B less
will advance to the next line containing the search pattern
as each character of the pattern is typed in.
-.IP "\-\-line-num-width"
-Sets the minimum width of the line number field when the \-N option is in effect.
-The default is 7 characters.
+.IP "\-\-intr=\fIc\fP"
+Use the character \fIc\fP instead of \(haX to interrupt a read
+when the "Waiting for data" message is displayed.
+\fIc\fP must be an ASCII character; that is, one with a value
+between 1 and 127 inclusive.
+A caret followed by a single character can be used
+to specify a control character.
+.IP "\-\-line-num-width=\fIn\fP"
+Sets the minimum width of the line number field when the \-N option is in effect
+to \fIn\fP characters.
+The default is 7.
+.IP "\-\-modelines=\fIn\fP"
+.RS
+Before displaying a file,
+.B less
+will read the first \fIn\fP lines to try to find a vim-compatible
+.IR modeline .
+If \fIn\fP is zero,
+.B less
+does not try to find modelines.
+By using a modeline, the file itself can specify the tab stops
+that should be used when viewing it.
+.PP
+A modeline contains, anywhere in the line,
+a program name ("vi", "vim", "ex", or "less"),
+followed by a colon,
+possibly followed by the word "set",
+and finally followed by zero or more option settings.
+If the word "set" is used,
+option settings are separated by spaces, and end at the first colon.
+If the word "set" is not used,
+option settings may be separated by either spaces or colons.
+The word "set" is required if the program name is "less"
+but optional if any of the other three names are used.
+If any option setting is of the form "tabstop=\fIn\fP" or "ts=\fIn\fP",
+then tab stops are automatically set as if \-\-tabs=\fIn\fP had been given.
+See the \-\-tabs description for acceptable values of \fIn\fP.
+.RE
.IP "\-\-mouse"
Enables mouse input:
scrolling the mouse wheel down moves forward in the file,
@@ -1149,7 +1251,7 @@ The number of lines to scroll when the wheel is moved
can be set by the \-\-wheel-lines option.
Mouse input works only on terminals which support X11 mouse reporting,
and on the Windows version of
-.IR less .
+.BR less .
.IP "\-\-MOUSE"
Like \-\-mouse, except the direction scrolled
on mouse wheel movement is reversed.
@@ -1167,33 +1269,76 @@ Normally, a string may appear multiple times.
.IP "\-\-no-number-headers"
Header lines (defined via the \-\-header option) are not assigned line numbers.
Line number 1 is assigned to the first line after any header lines.
-.IP "\-\-rscroll"
-This option changes the character used to mark truncated lines.
-It may begin with a two-character attribute indicator like LESSBINFMT does.
-If there is no attribute indicator, standout is used.
-If set to "\-", truncated lines are not marked.
+.IP "\-\-no-search-headers"
+Searches do not include header lines or header columns.
+.IP "\-\-no-vbell"
+Disables the terminal's visual bell.
+.IP "\-\-proc-backspace"
+If set, backspaces are handled as if neither the \-u option
+nor the \-U option were set.
+That is, a backspace adjacent to an underscore causes text to be
+displayed in underline mode, and a backspace between identical
+characters cause text to be displayed in boldface mode.
+This option overrides the \-u and \-U options, so that display of
+backspaces can be controlled separate from tabs and carriage returns.
+If not set, backspace display is controlled by the \-u and \-U options.
+.IP "\-\-PROC-BACKSPACE"
+If set, backspaces are handled as if the \-U option were set;
+that is backspaces are treated as control characters.
+.IP "\-\-proc-return"
+If set, carriage returns are handled as if neither the \-u option
+nor the \-U option were set.
+That is, a carriage return immediately before a newline is deleted.
+This option overrides the \-u and \-U options, so that display of
+carriage returns can be controlled separate from that of backspaces and tabs.
+If not set, carriage return display is controlled by the \-u and \-U options.
+.IP "\-\-PROC-RETURN"
+If set, carriage returns are handled as if the \-U option were set;
+that is carriage returns are treated as control characters.
+.IP "\-\-proc-tab"
+If set, tabs are handled as if the \-U option were not set.
+That is, tabs are expanded to spaces.
+This option overrides the \-U option, so that display of
+tabs can be controlled separate from that of backspaces and carriage returns.
+If not set, tab display is controlled by the \-U options.
+.IP "\-\-PROC-TAB"
+If set, tabs are handled as if the \-U option were set;
+that is tabs are treated as control characters.
.IP "\-\-redraw-on-quit"
When quitting, after sending the terminal deinitialization string,
redraws the entire last screen.
On terminals whose terminal deinitialization string causes the
terminal to switch from an alternate screen,
this makes the last screenful of the current file remain visible after
-.I less
+.B less
has quit.
+.IP "\-\-rscroll=\fIc\fP"
+This option changes the character used to mark truncated lines.
+It may begin with a two-character attribute indicator like LESSBINFMT does.
+If there is no attribute indicator, standout is used.
+If set to "\-", truncated lines are not marked.
.IP "\-\-save-marks"
Save marks in the history file, so marks are retained
across different invocations of
-.IR less .
-.IP "\-\-search-options"
+.BR less .
+.IP "\-\-search-options=\fI...\fP"
Sets default search modifiers.
The value is a string of one or more of the characters
E, F, K, N, R or W.
Setting any of these has the same effect as typing that
control character at the beginning of every search pattern.
For example, setting \-\-search-options=W is the same as
-typing ^W at the beginning of every pattern.
+typing \(haW at the beginning of every pattern.
+The value may also contain a digit between 1 and 5,
+which has the same effect as typing \(haS followed by that digit
+at the beginning of every search pattern.
The value "-" disables all default search modifiers.
-.IP "\-\-status-col-width"
+.IP "\-\-show-preproc-errors"
+If a preprocessor produces data,
+then exits with a non-zero exit code,
+.B less
+will display a warning.
+.IP "\-\-status-col-width=\fIn\fP"
Sets the width of the status column when the \-J option is in effect.
The default is 2 characters.
.IP "\-\-status-line"
@@ -1221,6 +1366,11 @@ https://www.ecma-international.org/publications-and-standards/standards/ecma-48)
Set the number of lines to scroll when the mouse wheel is scrolled
and the \-\-mouse or \-\-MOUSE option is in effect.
The default is 1 line.
+.IP "\-\-wordwrap"
+When the \-S option is not in use,
+wrap each line at a space or tab if possible,
+so that a word is not split between two lines.
+The default is to wrap at any character.
.IP \-\-
A command line argument of "\-\-" marks the end of option arguments.
Any arguments following this are interpreted as filenames.
@@ -1228,9 +1378,9 @@ This can be useful when viewing a file whose name begins with a "\-" or "+".
.IP +
If a command line option begins with \fB+\fP,
the remainder of that option is taken to be an initial command to
-.IR less .
+.BR less .
For example, +G tells
-.I less
+.B less
to start at the end of the file rather than the beginning,
and +/xyz tells it to start at the first occurrence of "xyz" in the file.
As a special case, +<number> acts like +<number>g;
@@ -1251,16 +1401,16 @@ a key does not exist on a particular keyboard.
(Note that the forms beginning with ESC do not work
in some MS-DOS and Windows systems because ESC is the line erase character.)
Any of these special keys may be entered literally by preceding
-it with the "literal" character, either ^V or ^A.
+it with the "literal" character, either \(haV or \(haA.
A backslash itself may also be entered literally by entering two backslashes.
.IP "LEFTARROW [ ESC-h ]"
Move the cursor one space to the left.
.IP "RIGHTARROW [ ESC-l ]"
Move the cursor one space to the right.
-.IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
+.IP "\(haLEFTARROW [ ESC-b or ESC-LEFTARROW ]"
(That is, CONTROL and LEFTARROW simultaneously.)
Move the cursor one word to the left.
-.IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
+.IP "\(haRIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
(That is, CONTROL and RIGHTARROW simultaneously.)
Move the cursor one word to the right.
.IP "HOME [ ESC-0 ]"
@@ -1272,10 +1422,10 @@ Delete the character to the left of the cursor,
or cancel the command if the command line is empty.
.IP "DELETE or [ ESC-x ]"
Delete the character under the cursor.
-.IP "^BACKSPACE [ ESC-BACKSPACE ]"
+.IP "\(haBACKSPACE [ ESC-BACKSPACE ]"
(That is, CONTROL and BACKSPACE simultaneously.)
Delete the word to the left of the cursor.
-.IP "^DELETE [ ESC-X or ESC-DELETE ]"
+.IP "\(haDELETE [ ESC-X or ESC-DELETE ]"
(That is, CONTROL and DELETE simultaneously.)
Delete the word under the cursor.
.IP "UPARROW [ ESC-k ]"
@@ -1297,82 +1447,84 @@ The environment variable LESSSEPARATOR can be used to specify a
different character to append to a directory name.
.IP "BACKTAB [ ESC-TAB ]"
Like, TAB, but cycles in the reverse direction thru the matching filenames.
-.IP "^L"
+.IP "\(haL"
Complete the partial filename to the left of the cursor.
If it matches more than one filename, all matches are entered into
the command line (if they fit).
-.IP "^U (Unix and OS/2) or ESC (MS-DOS)"
+.IP "\(haU (Unix and OS/2) or ESC (MS-DOS)"
Delete the entire command line,
or cancel the command if the command line is empty.
If you have changed your line-kill character in Unix to something
-other than ^U, that character is used instead of ^U.
-.IP "^G"
+other than \(haU, that character is used instead of \(haU.
+.IP "\(haG"
Delete the entire command line and return to the main prompt.
.
.SH "KEY BINDINGS"
You may define your own
-.I less
+.B less
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 change the line-editing keys (see LINE EDITING),
-and to set environment variables.
+and set environment variables used by
+.BR less .
+See the
+.BR lesskey (1)
+manual page for details about the file format.
+.PP
If the environment variable LESSKEYIN is set,
-.I less
+.B less
uses that as the name of the lesskey source file.
Otherwise,
-.I less
+.B less
looks in a standard place for the lesskey source file:
On Unix systems,
-.I less
+.B less
looks for a lesskey file called "$XDG_CONFIG_HOME/lesskey" or "$HOME/.config/lesskey" or "$HOME/.lesskey".
On MS-DOS and Windows systems,
-.I less
+.B less
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
+.B less
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 "lesskey.ini" in any directory specified
in the PATH environment variable.
-See the
-.I lesskey
-manual page for more details.
.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 LESSKEYIN_SYSTEM is set,
-.I less
+.B less
uses that as the name of the system-wide lesskey file.
Otherwise,
-.I less
+.B less
looks in a standard place for the system-wide lesskey file:
On Unix systems, the system-wide lesskey file is /usr/local/etc/syslesskey.
(However, if
-.I less
+.B 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_syslesskey.
On OS/2 systems, the system-wide lesskey file is c:\esyslesskey.ini.
.PP
Previous versions of
-.I less
+.B less
(before v582) used lesskey files with a binary format, produced by the
-.I lesskey
+.B lesskey
program. It is no longer necessary to use the
-.I lesskey
+.B lesskey
program.
.
.SH "INPUT PREPROCESSOR"
You may define an "input preprocessor" for
-.IR less .
+.BR less .
Before
-.I less
+.B less
opens a file, it first gives your input preprocessor a chance to modify the
way the contents of the file are displayed.
An input preprocessor is simply an executable program (or shell script),
@@ -1382,7 +1534,7 @@ The contents of the replacement file are then displayed
in place of the contents of the original file.
However, it will appear to the user as if the original file is opened;
that is,
-.I less
+.B less
will display the original filename as the name of the current file.
.PP
An input preprocessor receives one command line argument, the original filename,
@@ -1390,7 +1542,7 @@ as entered by the user.
It should create the replacement file, and when finished,
print the name of the replacement file to its standard output.
If the input preprocessor does not output a replacement filename,
-.I less
+.B less
uses the original file, as normal.
The input preprocessor is not called when viewing standard input.
To set up an input preprocessor, set the LESSOPEN environment variable
@@ -1400,7 +1552,7 @@ which will be replaced by the filename
when the input preprocessor command is invoked.
.PP
When
-.I less
+.B less
closes a file opened in such a way, it will call another program,
called the input postprocessor,
which may perform any desired clean-up action (such as deleting the
@@ -1416,7 +1568,7 @@ which was output by LESSOPEN.
.PP
For example, on many Unix systems, these two scripts will allow you
to keep files in compressed format, but still let
-.I less
+.B less
view them directly:
.PP
lessopen.sh:
@@ -1457,7 +1609,7 @@ to accept other types of compressed files, and so on.
.PP
It is also possible to set up an input preprocessor to
pipe the file data directly to
-.IR less ,
+.BR less ,
rather than putting the data into a replacement file.
This avoids the need to decompress the entire file before
starting to view it.
@@ -1467,7 +1619,7 @@ its standard output,
writes the entire contents of the replacement file on its standard output.
If the input pipe does not write any characters on its standard output,
then there is no replacement file and
-.I less
+.B less
uses the original file, as normal.
To use an input pipe,
make the first character in the LESSOPEN environment variable a
@@ -1510,7 +1662,7 @@ the empty output is considered to be replacement text.
If the output is empty and the exit status is nonzero,
the original file is used.
For compatibility with previous versions of
-.IR less ,
+.BR less ,
if LESSOPEN starts with only one vertical bar, the exit status
of the preprocessor is ignored.
.PP
@@ -1521,9 +1673,9 @@ In this case, the replacement file name passed to the LESSCLOSE
postprocessor is "\-".
.PP
For compatibility with previous versions of
-.IR less ,
+.BR less ,
the input preprocessor or pipe is not used if
-.I less
+.B less
is viewing standard input.
However, if the first character of LESSOPEN is a dash (\-),
the input preprocessor is used on standard input as well as other files.
@@ -1585,7 +1737,7 @@ It is the only character set that supports multi-byte characters.
Selects a character set appropriate for Microsoft Windows (cp 1251).
.PP
In rare cases, it may be desired to tailor
-.I less
+.B less
to use a character set other than the ones definable by LESSCHARSET.
In this case, the environment variable LESSCHARDEF can be used
to define a character set.
@@ -1626,9 +1778,9 @@ is found in the LC_ALL, LC_CTYPE or LANG
environment variables, then the default character set is utf-8.
.PP
If that string is not found, but your system supports the
-.I setlocale
+.B setlocale
interface,
-.I less
+.B less
will use setlocale to determine the character set.
setlocale is controlled by setting the LANG or LC_CTYPE environment
variables.
@@ -1639,7 +1791,7 @@ interface is also not available, the default character set is latin1.
.PP
Control and binary characters are displayed in standout (reverse video).
Each such character is displayed in caret notation if possible
-(e.g.\& ^A for control-A). Caret notation is used only if
+(e.g.\& \(haA for control-A). Caret notation is used only if
inverting the 0100 bit results in a normal printable character.
Otherwise, the character is displayed as a hex number in angle brackets.
This format can be changed by
@@ -1671,7 +1823,45 @@ octets of a complete but non-shortest form sequence, invalid octets,
and stray trailing octets)
are displayed individually using LESSBINFMT so as to facilitate diagnostic
of how the UTF-8 file is ill-formed.
-.
+.PP
+When the character set is utf-8, in rare cases it may be desirable to
+override the Unicode definition of the type of certain characters.
+For example, characters in a Private Use Area are normally treated as control
+characters, but if you are using a custom font with printable characters
+in that range, it may be desirable to tell
+.B less
+to treat such characters as printable.
+This can be done by setting the LESSUTFCHARDEF environment variable
+to a comma-separated list of
+.I "character type"
+definitions.
+Each character type definition consists of either one hexadecimal codepoint
+or a pair of codepoints separated by a dash,
+followed by a colon and a type character.
+Each hexadecimal codepoint may optionally be preceded by a "U" or "U+".
+If a pair of codepoints is given, the type is set for
+all characters inclusively between the two values.
+If there are multiple comma-separated codepoint values,
+they must be in ascending numerical order.
+The type character may be one of:
+.RS
+.IP "p"
+A normal printable character.
+.IP "w"
+A wide (2-space) printable character.
+.IP "b"
+A binary (non-printable) character.
+.IP "c"
+A composing (zero width) character.
+.RE
+.PP
+For example, setting LESSUTFCHARDEF to
+.nf
+.sp
+ E000-F8FF:p,F0000-FFFFD:p,100000-10FFFD:p
+.sp
+.fi
+would make all Private Use Area characters be treated as printable.
.SH "PROMPTS"
The \-P option allows you to tailor the prompt to your preference.
The string given to the \-P option replaces the specified prompt string.
@@ -1681,7 +1871,9 @@ but the ordinary user need not understand the details of constructing
personalized prompt strings.
.sp
A percent sign followed by a single character is expanded
-according to what the following character is:
+according to what the following character is.
+(References to the input file size below refer to the preprocessed size,
+if an input preprocessor is being used.)
.IP "%b\fIX\fP"
Replaced by the byte offset into the current input file.
The b is followed by a single character (shown as \fIX\fP above)
@@ -1862,12 +2054,14 @@ changed to modify this default.
.
.SH SECURITY
When the environment variable LESSSECURE is set to 1,
-.I less
+.B less
runs in a "secure" mode.
This means these features are disabled:
.RS
.IP "!"
the shell command
+.IP "#"
+the pshell command
.IP "|"
the pipe command
.IP ":e"
@@ -1883,7 +2077,7 @@ use of tags files
.IP
metacharacters in filenames, such as *
.IP
-filename completion (TAB, ^L)
+filename completion (TAB, \(haL)
.IP
history file
.RE
@@ -1893,16 +2087,18 @@ Less can also be compiled to be permanently in "secure" mode.
.SH "COMPATIBILITY WITH MORE"
If the environment variable LESS_IS_MORE is set to 1,
or if the program is invoked via a file link named "more",
-.I less
-behaves (mostly) in conformance with the POSIX "more" command specification.
+.B less
+behaves (mostly) in conformance with the POSIX
+.BR more (1)
+command specification.
In this mode, less behaves differently in these ways:
.PP
The \-e option works differently.
If the \-e option is not set,
-.I less
+.B less
behaves as if the \-e option were set.
If the \-e option is set,
-.I less
+.B less
behaves as if the \-E option were set.
.PP
The \-m option works differently.
@@ -1914,7 +2110,7 @@ The \-n option acts like the \-z option.
The normal behavior of the \-n option is unavailable in this mode.
.PP
The parameter to the \-p option is taken to be a
-.I less
+.B less
command rather than a search pattern.
.PP
The LESS environment variable is ignored,
@@ -1923,7 +2119,7 @@ and the MORE environment variable is used in its place.
.SH "ENVIRONMENT VARIABLES"
Environment variables may be specified either in the system environment
as usual, or in a
-.IR lesskey (1)
+.BR lesskey (1)
file.
If environment variables are defined in more than one place,
variables defined in a local lesskey file take precedence over
@@ -1952,7 +2148,7 @@ Language for determining the character set.
Language for determining the character set.
.IP LESS
Options which are passed to
-.I less
+.B less
automatically.
.IP LESSANSIENDCHARS
Characters which may end an ANSI color escape sequence
@@ -1960,7 +2156,7 @@ Characters which may end an ANSI color escape sequence
.IP LESSANSIMIDCHARS
Characters which may appear between the ESC character and the
end character in an ANSI color escape sequence
-(default "0123456789:;[?!"'#%()*+\ ".
+(default "0123456789:;[?!"\(aq#%()*+\ ".
.IP LESSBINFMT
Format for displaying non-printable, non-control characters.
.IP LESSCHARDEF
@@ -1979,17 +2175,23 @@ See discussion under PROMPTS.
.IP LESSGLOBALTAGS
Name of the command used by the \-t option to find global tags.
Normally should be set to "global" if your system has the
-.IR global (1)
+.BR global (1)
command. If not set, global tags are not used.
.IP LESSHISTFILE
Name of the history file used to remember search commands and
shell commands between invocations of
-.IR less .
+.BR less .
If set to "\-" or "/dev/null", a history file is not used.
-The default is "$XDG_STATE_HOME/lesshst" or "$HOME/.local/state/lesshst" or
-"$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.
+The default depends on the operating system, but is usually:
+.RS
+.IP "Linux and Unix"
+"$XDG_STATE_HOME/lesshst" or "$HOME/.local/state/lesshst" or
+"$XDG_DATA_HOME/lesshst" or "$HOME/.lesshst".
+.IP "Windows and MS-DOS"
+"$HOME/_lesshst".
+.IP "OS/2"
+"$HOME/lesshst.ini" or "$INIT/lesshst.ini".
+.RE
.IP LESSHISTSIZE
The maximum number of commands to save in the history file.
The default is 100.
@@ -2025,10 +2227,39 @@ See discussion under SECURITY.
String to be appended to a directory name in filename completion.
.IP LESSUTFBINFMT
Format for displaying non-printable Unicode code points.
+.IP LESSUTFCHARDEF
+Overrides the type of specified Unicode characters.
+.IP LESS_COLUMNS
+Sets the number of columns on the screen.
+Unlike COLUMNS, takes precedence over the system's idea of the screen size,
+so it can be used to make
+.B less
+use less than the full screen width.
+If set to a negative number, sets the number of columns used to
+this much less than the actual screen width.
+.IP LESS_LINES
+Sets the number of lines on the screen.
+Unlike LINES, takes precedence over the system's idea of the screen size,
+so it can be used to make
+.B less
+use less than the full screen height.
+If set to a negative number, sets the number of lines used to
+this much less than the actual screen height.
+When set,
+.B less
+repaints the entire screen on every movement command,
+so scrolling may be slower.
+.IP LESS_DATA_DELAY
+Duration (in milliseconds) after starting to read data from the input,
+after which the "Waiting for data" message will be displayed.
+The default is 4000 (4 seconds).
.IP LESS_IS_MORE
Emulate the
-.IR more (1)
+.BR more (1)
command.
+.IP LESS_TERMCAP_xx
+Where "xx" is any two characters, overrides the definition
+of the termcap "xx" capability for the terminal.
.IP LINES
Sets the number of lines on the screen.
Takes precedence over the number of lines specified by the TERM variable.
@@ -2037,10 +2268,9 @@ 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
+.B less
automatically when running in
-.I more
-compatible mode.
+.BR more "-compatible mode."
.IP PATH
User's search path (used to find a lesskey file
on MS-DOS and OS/2 systems).
@@ -2048,16 +2278,25 @@ on MS-DOS and OS/2 systems).
The shell used to execute the !\& command, as well as to expand filenames.
.IP TERM
The type of terminal on which
-.I less
+.B less
is being run.
.IP VISUAL
The name of the editor (used for the v command).
+.IP XDG_CONFIG_HOME
+Possible location of the
+.B lesskey
+file; see the KEY BINDINGS section.
+.IP XDG_DATA_HOME
+Possible location of the history file; see the description of the LESSHISTFILE environment variable.
+.IP XDG_STATE_HOME
+Possible location of the history file; see the description of the LESSHISTFILE environment variable.
.
.SH "SEE ALSO"
-.BR lesskey (1)
+.BR lesskey (1),
+.BR lessecho (1)
.
.SH COPYRIGHT
-Copyright (C) 1984-2022 Mark Nudelman
+Copyright (C) 1984-2023 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/lessecho.c b/lessecho.c
index 5cd660db50ba..67bdf9c7130d 100644
--- a/lessecho.c
+++ b/lessecho.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -38,15 +38,13 @@ static char* metachars = NULL;
static int num_metachars = 0;
static int size_metachars = 0;
- static void
-pr_usage(VOID_PARAM)
+static void pr_usage(void)
{
fprintf(stderr,
"usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
}
- static void
-pr_version(VOID_PARAM)
+static void pr_version(void)
{
char *p;
char buf[10];
@@ -61,19 +59,13 @@ pr_version(VOID_PARAM)
printf("%s\n", buf);
}
- static void
-pr_error(s)
- char *s;
+static void pr_error(char *s)
{
fprintf(stderr, "%s\n", s);
exit(1);
}
- static long
-lstrtol(s, radix, pend)
- char *s;
- int radix;
- char **pend;
+static long lstrtol(char *s, char **pend, int radix)
{
int v;
int neg = 0;
@@ -141,9 +133,7 @@ lstrtol(s, radix, pend)
return (n);
}
- static void
-add_metachar(ch)
- int ch;
+static void add_metachar(int ch)
{
if (num_metachars+1 >= size_metachars)
{
@@ -164,18 +154,13 @@ add_metachar(ch)
metachars[num_metachars] = '\0';
}
- static int
-is_metachar(ch)
- int ch;
+static int is_metachar(int ch)
{
return (metachars != NULL && strchr(metachars, ch) != NULL);
}
#if !HAVE_STRCHR
- char *
-strchr(s, c)
- char *s;
- int c;
+char * strchr(char *s, char c)
{
for ( ; *s != '\0'; s++)
if (*s == c)
@@ -186,10 +171,7 @@ strchr(s, c)
}
#endif
- int
-main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
char *arg;
char *s;
@@ -210,7 +192,7 @@ main(argc, argv)
closequote = *++arg;
break;
case 'd':
- closequote = lstrtol(++arg, 0, &s);
+ closequote = lstrtol(++arg, &s, 0);
if (s == arg)
pr_error("Missing number after -d");
break;
@@ -221,7 +203,7 @@ main(argc, argv)
meta_escape = arg;
break;
case 'f':
- meta_escape_buf[0] = lstrtol(++arg, 0, &s);
+ meta_escape_buf[0] = lstrtol(++arg, &s, 0);
meta_escape_buf[1] = '\0';
meta_escape = meta_escape_buf;
if (s == arg)
@@ -231,7 +213,7 @@ main(argc, argv)
openquote = *++arg;
break;
case 'p':
- openquote = lstrtol(++arg, 0, &s);
+ openquote = lstrtol(++arg, &s, 0);
if (s == arg)
pr_error("Missing number after -p");
break;
@@ -239,7 +221,7 @@ main(argc, argv)
add_metachar(*++arg);
break;
case 'n':
- add_metachar(lstrtol(++arg, 0, &s));
+ add_metachar(lstrtol(++arg, &s, 0));
if (s == arg)
pr_error("Missing number after -n");
break;
diff --git a/lessecho.man b/lessecho.man
index e18b7fbacc69..b510f8b847fc 100644
--- a/lessecho.man
+++ b/lessecho.man
@@ -9,32 +9,32 @@ LESSECHO(1) General Commands Manual LESSECHO(1)
lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ...
DESCRIPTION
- lessecho is a program that simply echos its arguments on standard out-
+ lessecho is a program that simply echos its arguments on standard out-
put. But any metacharacter in the output is preceded by an "escape"
character, which by default is a backslash.
OPTIONS
A summary of options is included below.
- -ex Specifies "x", rather than backslash, to be the escape char for
- metachars. If x is "-", no escape char is used and arguments
+ -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.
- -ox Specifies "x", rather than double-quote, to be the open quote
+ -ox Specifies "x", rather than double-quote, to be the open quote
character, which is used if the -e- option is specified.
- -cx Specifies "x" to be the close quote character.
+ -cx Specifies "x" to be the close quote character.
- -pn Specifies "n" to be the open quote character, as an integer.
+ -pn Specifies "n" to be the open quote character, as an integer.
- -dn Specifies "n" to be the close quote character, as an integer.
+ -dn Specifies "n" to be the close quote character, as an integer.
- -mx Specifies "x" to be a metachar. By default, no characters are
+ -mx Specifies "x" to be a metachar. By default, no characters are
considered metachars.
- -nn Specifies "n" to be a metachar, as an integer.
+ -nn Specifies "n" to be a metachar, as an integer.
- -fn Specifies "n" to be the escape char for metachars, as an inte-
+ -fn Specifies "n" to be the escape char for metachars, as an inte-
ger.
-a Specifies that all arguments are to be quoted. The default is
@@ -51,4 +51,4 @@ LESSECHO(1) General Commands Manual LESSECHO(1)
- Version 608: 22 Jul 2022 LESSECHO(1)
+ Version 632: 06 Apr 2023 LESSECHO(1)
diff --git a/lessecho.nro b/lessecho.nro
index 5b16d4aa8530..6637cb947173 100644
--- a/lessecho.nro
+++ b/lessecho.nro
@@ -1,44 +1,44 @@
-.TH LESSECHO 1 "Version 608: 22 Jul 2022"
+.TH LESSECHO 1 "Version 632: 06 Apr 2023"
.SH NAME
lessecho \- expand metacharacters
.SH SYNOPSIS
.B lessecho
.I "[-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ..."
.SH "DESCRIPTION"
-.I lessecho
+.B lessecho
is a program that simply echos its arguments on standard output.
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
+.B \-e\fIx\fP
+Specifies "\fIx\fP", rather than backslash, to be the escape char for metachars.
+If \fIx\fP is "-", no escape char is used and arguments containing metachars
are surrounded by quotes instead.
.TP
-.B \-ox
-Specifies "x", rather than double-quote, to be the open quote character,
+.B \-o\fIx\fP
+Specifies "\fIx\fP", 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.
+.B \-c\fIx\fP
+Specifies "\fIx\fP" to be the close quote character.
.TP
-.B \-pn
-Specifies "n" to be the open quote character, as an integer.
+.B \-p\fIn\fP
+Specifies "\fIn\fP" to be the open quote character, as an integer.
.TP
-.B \-dn
-Specifies "n" to be the close quote character, as an integer.
+.B \-d\fIn\fP
+Specifies "\fIn\fP" to be the close quote character, as an integer.
.TP
-.B \-mx
-Specifies "x" to be a metachar.
+.B \-m\fIx\fP
+Specifies "\fIx\fP" to be a metachar.
By default, no characters are considered metachars.
.TP
-.B \-nn
-Specifies "n" to be a metachar, as an integer.
+.B \-n\fIn\fP
+Specifies "\fIn\fP" to be a metachar, as an integer.
.TP
-.B \-fn
-Specifies "n" to be the escape char for metachars, as an integer.
+.B \-f\fIn\fP
+Specifies "\fIn\fP" to be the escape char for metachars, as an integer.
.TP
.B \-a
Specifies that all arguments are to be quoted.
diff --git a/lesskey.c b/lesskey.c
index 39ebe8b980a9..61311c7ef0c0 100644
--- a/lesskey.c
+++ b/lesskey.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -80,12 +80,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
+#include "defines.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "lesskey.h"
#include "cmd.h"
-#include "defines.h"
char fileheader[] = {
C0_LESSKEY_MAGIC,
@@ -108,46 +108,39 @@ char *outfile = NULL ;
extern char version[];
- static void
-usage(void)
+static void usage(void)
{
fprintf(stderr, "usage: lesskey [-o output] [input]\n");
exit(1);
}
- void
-lesskey_parse_error(s)
- char *s;
+void lesskey_parse_error(char *s)
{
fprintf(stderr, "%s\n", s);
}
- int
-lstrtoi(buf, ebuf)
- char *buf;
- char **ebuf;
+int lstrtoi(char *buf, char **ebuf, int radix)
{
- return (int) strtol(buf, ebuf, 10);
+ return (int) strtol(buf, ebuf, radix);
}
- void *
-ecalloc(count, size)
- int count;
- unsigned int size;
+void out_of_memory(void)
+{
+ fprintf(stderr, "lesskey: cannot allocate memory\n");
+ exit(1);
+}
+
+void * ecalloc(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);
+ if (p == NULL)
+ out_of_memory();
+ return (p);
}
- static char *
-mkpathname(dirname, filename)
- char *dirname;
- char *filename;
+static char * mkpathname(char *dirname, char *filename)
{
char *pathname;
@@ -161,9 +154,7 @@ mkpathname(dirname, filename)
/*
* Figure out the name of a default file (in the user's HOME directory).
*/
- char *
-homefile(filename)
- char *filename;
+char * homefile(char *filename)
{
char *p;
char *pathname;
@@ -185,10 +176,7 @@ homefile(filename)
/*
* Parse command line arguments.
*/
- static void
-parse_args(argc, argv)
- int argc;
- char **argv;
+static void parse_args(int argc, char **argv)
{
char *arg;
@@ -258,11 +246,7 @@ parse_args(argc, argv)
/*
* Output some bytes.
*/
- static void
-fputbytes(fd, buf, len)
- FILE *fd;
- char *buf;
- int len;
+static void fputbytes(FILE *fd, char *buf, int len)
{
while (len-- > 0)
{
@@ -274,10 +258,7 @@ fputbytes(fd, buf, len)
/*
* Output an integer, in special KRADIX form.
*/
- static void
-fputint(fd, val)
- FILE *fd;
- unsigned int val;
+static void fputint(FILE *fd, unsigned int val)
{
char c;
@@ -293,10 +274,7 @@ fputint(fd, val)
fwrite(&c, sizeof(char), 1, fd);
}
- int
-main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
struct lesskey_tables tables;
FILE *out;
diff --git a/lesskey.h b/lesskey.h
index 988c6aa50e17..4a8459ada43b 100644
--- a/lesskey.h
+++ b/lesskey.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/lesskey.man b/lesskey.man
index c5a90a40cc3a..c9d36e62f317 100644
--- a/lesskey.man
+++ b/lesskey.man
@@ -12,19 +12,19 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
lesskey --version
SCOPE
- This document describes the format of the lesskey source file, which is
- used by less version 582 and later. In previous versions of less, a
- separate program called lesskey was used to compile the lesskey source
- file into a format understood by less. This compilation step is no
- longer required and the lesskey program is therefore deprecated, al-
- though the file format remains supported by less itself.
+ This document describes the format of the lesskey source file, which is
+ used by less version 582 and later. In previous versions of less, a
+ separate program called lesskey was used to compile the lesskey source
+ file into a format understood by less. This compilation step is no
+ longer required and the lesskey program is therefore deprecated, al-
+ though the file format remains supported by less itself.
DESCRIPTION
- A lesskey file specifies a set of key bindings and environment vari-
- ables to be used by subsequent invocations of less.
+ A lesskey file specifies a set of key bindings and environment vari-
+ ables to be used by subsequent invocations of less.
FILE FORMAT
- The input file consists of one or more sections. Each section starts
+ The input file consists of one or more sections. Each section starts
with a line that identifies the type of section. Possible sections
are:
@@ -91,17 +91,17 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
by backslash include caret, space, tab and the backslash itself.
An action may be followed by an "extra" string. When such a com-
- mand is entered while running less, the action is performed, and
+ mand is entered while running less, the action is performed, and
then the extra string is parsed, just as if it were typed in to
- less. This feature can be used in certain cases to extend the
+ less. This feature can be used in certain cases to extend the
functionality of a command. For example, see the "{" and ":t"
commands in the example below. The extra string has a special
- meaning for the "quit" action: when less quits, the first charac-
+ meaning for the "quit" action: when less quits, the first charac-
ter of the extra string is used as its exit status.
EXAMPLE
The following input file describes the set of default command keys used
- by less. Documentation on each command can be found in the man page,
+ by less. Documentation on each command can be found in the man page,
under the key sequence which invokes the command.
@@ -203,12 +203,14 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
- toggle-option
:t toggle-option t
s toggle-option o
- ## Use a long option name by starting the extra string with ONE dash; eg:
- ## s toggle-option -log-file
+ ## Use a long option name by starting the
+ ## extra string with ONE dash; eg:
+ ## s toggle-option -log-file\n
_ display-option
| pipe
v visual
! shell
+ # pshell
+ firstcmd
H help
h help
@@ -231,11 +233,11 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
PRECEDENCE
- Commands specified by lesskey take precedence over the default com-
+ Commands specified by lesskey take precedence over the default com-
mands. A default command key may be disabled by including it in the
input file with the action "invalid". Alternatively, a key may be de-
fined to do nothing by using the action "noaction". "noaction" is sim-
- ilar to "invalid", but less will give an error beep for an "invalid"
+ ilar to "invalid", but less will give an error beep for an "invalid"
command, but not for a "noaction" command. In addition, ALL default
commands may be disabled by adding this control line to the input file:
@@ -261,7 +263,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
EXAMPLE
The following input file describes the set of default line-editing keys
- used by less:
+ used by less:
#line-edit
@@ -304,7 +306,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
Each line consists of an environment variable name, an equals sign (=)
and the value to be assigned to the environment variable. White space
before and after the equals sign is ignored. Variables assigned in
- this way are visible only to less. If a variable is specified in the
+ this way are visible only to less. If a variable is specified in the
system environment and also in a lesskey file, the value in the lesskey
file takes precedence.
@@ -318,12 +320,12 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
CONDITIONAL CONFIGURATION
If a line begins with #version followed by a relational operator and a
version number, the remainder of the line is parsed if and only if the
- running version of less (or lesskey) matches the operator. This can be
- helpful if a lesskey file is used by different versions of less.
+ running version of less (or lesskey) matches the operator. This can be
+ helpful if a lesskey file is used by different versions of less.
For example, suppose that a new command named 'sideways-search' is
- added in less version 777. Then the following line would assign the
- command to the Q key, but only in versions of less which support it.
+ added in less version 777. Then the following line would assign the
+ command to the Q key, but only in versions of less which support it.
The line would be ignored by versions earlier than 777.
#version >= 777 Q sideways-search
@@ -337,7 +339,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
= Equal to
!= Not equal to
- The #version feature is not supported in less and lesskey before ver-
+ The #version feature is not supported in less and lesskey before ver-
sion 594. In those older versions, all #version lines are ignored.
EXAMPLE
@@ -357,7 +359,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
represented as \340 in a lesskey file.
COPYRIGHT
- Copyright (C) 1984-2022 Mark Nudelman
+ Copyright (C) 1984-2023 Mark Nudelman
less is part of the GNU project and is free software. You can redis-
tribute it and/or modify it under the terms of either (1) the GNU Gen-
@@ -380,4 +382,4 @@ LESSKEY(1) General Commands Manual LESSKEY(1)
- Version 608: 22 Jul 2022 LESSKEY(1)
+ Version 632: 06 Apr 2023 LESSKEY(1)
diff --git a/lesskey.nro b/lesskey.nro
index 0e8cb1bb96c3..2f7c4864dc2f 100644
--- a/lesskey.nro
+++ b/lesskey.nro
@@ -1,5 +1,5 @@
'\" t
-.TH LESSKEY 1 "Version 608: 22 Jul 2022"
+.TH LESSKEY 1 "Version 632: 06 Apr 2023"
.SH NAME
lesskey \- customize key bindings for less
.SH "SYNOPSIS (deprecated)"
@@ -12,33 +12,33 @@ lesskey \- customize key bindings for less
.B "lesskey \-\-version"
.SH SCOPE
This document describes the format of the
-.I lesskey
+.B lesskey
source file, which is used by
-.I less
+.B less
version 582 and later.
In previous versions of
-.IR less ,
+.BR less ,
a separate program called
-.I lesskey
+.B lesskey
was used to compile the
-.I lesskey
+.B lesskey
source file into a format understood by
-.IR less .
+.BR less .
This compilation step is no longer required and the
-.I lesskey
+.B lesskey
program is therefore deprecated, although the file format remains supported by
-.I less
+.B less
itself.
.PP
.SH DESCRIPTION
A
-.I lesskey
+.B lesskey
file specifies a set of key bindings and environment variables
to be used by subsequent invocations of
-.I less.
+.BR less .
.SH FILE FORMAT
The input file consists of one or more
-.I sections.
+.IR sections .
Each section starts with a line that identifies the type of section.
Possible sections are:
.IP #command
@@ -112,22 +112,22 @@ caret, space, tab and the backslash itself.
.PP
An action may be followed by an "extra" string.
When such a command is entered while running
-.IR less ,
+.BR less ,
the action is performed, and then the extra
string is parsed, just as if it were typed in to
-.IR less .
+.BR less .
This feature can be used in certain cases to extend
the functionality of a command.
For example, see the "{" and ":t" commands in the example below.
The extra string has a special meaning for the "quit" action:
when
-.I less
+.B less
quits, the first character of the extra string is used as its exit status.
.
.SH EXAMPLE
The following input file describes the set of
default command keys used by
-.IR less .
+.BR less .
Documentation on each command can be found in the
.less
man page, under the key sequence which invokes the command.
@@ -231,12 +231,14 @@ T prev-tag
- toggle-option
:t toggle-option t
s toggle-option o
- ## Use a long option name by starting the extra string with ONE dash; eg:
- ## s toggle-option -log-file\n
+ ## Use a long option name by starting the
+ ## extra string with ONE dash; eg:
+ ## s toggle-option -log-file\en
\&_ display-option
| pipe
v visual
! shell
+# pshell
+ firstcmd
H help
h help
@@ -261,14 +263,14 @@ ZZ quit
.sp
.SH PRECEDENCE
Commands specified by
-.I lesskey
+.B lesskey
take precedence over the default commands.
A default command key may be disabled by including it in the
input file with the action "invalid".
Alternatively, a key may be defined
to do nothing by using the action "noaction".
"noaction" is similar to "invalid", but
-.I less
+.B less
will give an error beep for an "invalid" command,
but not for a "noaction" command.
In addition, ALL default commands may be disabled by
@@ -299,7 +301,7 @@ one per line as in the example below.
.SH EXAMPLE
The following input file describes the set of
default line-editing keys used by
-.IR less :
+.BR less :
.sp
.RS 5m
.TS
@@ -347,7 +349,7 @@ Each line consists of an environment variable name, an equals sign (=)
and the value to be assigned to the environment variable.
White space before and after the equals sign is ignored.
Variables assigned in this way are visible only to
-.IR less .
+.BR less .
If a variable is specified in the system environment and also in a
lesskey file, the value in the lesskey file takes precedence.
.
@@ -363,18 +365,18 @@ it cannot append to a variable in the system environment.
.SH CONDITIONAL CONFIGURATION
If a line begins with #version followed by a relational operator and a version number,
the remainder of the line is parsed if and only if the running version of
-.I less
+.B less
(or
-.IR lesskey )
+.BR lesskey )
matches the operator.
This can be helpful if a lesskey file is used by different versions of
-.IR less .
+.BR less .
.sp
For example, suppose that a new command named 'sideways-search' is added in
-.I less
+.B less
version 777.
Then the following line would assign the command to the Q key, but only in versions of
-.I less
+.B less
which support it. The line would be ignored by versions earlier than 777.
.sp
.nf
@@ -395,9 +397,9 @@ l l.
.RE
.sp
The #version feature is not supported in
-.I less
+.B less
and
-.I lesskey
+.B lesskey
before version 594.
In those older versions, all #version lines are ignored.
.
@@ -421,7 +423,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-2022 Mark Nudelman
+Copyright (C) 1984-2023 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/lesskey_parse.c b/lesskey_parse.c
index 7042b6e12708..3f528aa8780a 100644
--- a/lesskey_parse.c
+++ b/lesskey_parse.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -7,13 +7,13 @@
* For more information, see the README file.
*/
+#include "defines.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "lesskey.h"
#include "cmd.h"
#include "xbuf.h"
-#include "defines.h"
#define CONTROL(c) ((c)&037)
#define ESC CONTROL('[')
@@ -21,7 +21,7 @@
extern void lesskey_parse_error(char *msg);
extern char *homefile(char *filename);
extern void *ecalloc(int count, unsigned int size);
-extern int lstrtoi(char *str, char **end);
+extern int lstrtoi(char *str, char **end, int radix);
extern char version[];
static int linenum;
@@ -88,6 +88,7 @@ static struct lesskey_cmdname cmdnames[] =
{ "set-mark", A_SETMARK },
{ "set-mark-bottom", A_SETMARKBOT },
{ "shell", A_SHELL },
+ { "pshell", A_PSHELL },
{ "status", A_STAT },
{ "toggle-flag", A_OPT_TOGGLE },
{ "toggle-option", A_OPT_TOGGLE },
@@ -126,10 +127,7 @@ static struct lesskey_cmdname editnames[] =
/*
* Print a parse error message.
*/
- static void
-parse_error(fmt, arg1)
- char *fmt;
- char *arg1;
+static void parse_error(char *fmt, char *arg1)
{
char buf[1024];
int n = snprintf(buf, sizeof(buf), "%s: line %d: ", lesskey_file, linenum);
@@ -142,9 +140,7 @@ parse_error(fmt, arg1)
/*
* Initialize lesskey_tables.
*/
- static void
-init_tables(tables)
- struct lesskey_tables *tables;
+static void init_tables(struct lesskey_tables *tables)
{
tables->currtable = &tables->cmdtable;
@@ -163,11 +159,7 @@ init_tables(tables)
#define CHAR_STRING_LEN 8
- static char *
-char_string(buf, ch, lit)
- char *buf;
- int ch;
- int lit;
+static char * char_string(char *buf, int ch, int lit)
{
if (lit || (ch >= 0x20 && ch < 0x7f))
{
@@ -183,9 +175,7 @@ char_string(buf, ch, lit)
/*
* Increment char pointer by one up to terminating nul byte.
*/
- static char *
-increment_pointer(p)
- char *p;
+static char * increment_pointer(char *p)
{
if (*p == '\0')
return p;
@@ -195,10 +185,7 @@ increment_pointer(p)
/*
* Parse one character of a string.
*/
- static char *
-tstr(pp, xlate)
- char **pp;
- int xlate;
+static char * tstr(char **pp, int xlate)
{
char *p;
char ch;
@@ -309,9 +296,7 @@ tstr(pp, xlate)
return (buf);
}
- static int
-issp(ch)
- char ch;
+static int issp(char ch)
{
return (ch == ' ' || ch == '\t');
}
@@ -319,9 +304,7 @@ issp(ch)
/*
* Skip leading spaces in a string.
*/
- static char *
-skipsp(s)
- char *s;
+static char * skipsp(char *s)
{
while (issp(*s))
s++;
@@ -331,9 +314,7 @@ skipsp(s)
/*
* Skip non-space characters in a string.
*/
- static char *
-skipnsp(s)
- char *s;
+static char * skipnsp(char *s)
{
while (*s != '\0' && !issp(*s))
s++;
@@ -344,9 +325,7 @@ skipnsp(s)
* Clean up an input line:
* strip off the trailing newline & any trailing # comment.
*/
- static char *
-clean_line(s)
- char *s;
+static char * clean_line(char *s)
{
int i;
@@ -361,17 +340,12 @@ clean_line(s)
/*
* Add a byte to the output command table.
*/
- static void
-add_cmd_char(c, tables)
- int c;
- struct lesskey_tables *tables;
+static void add_cmd_char(unsigned char c, struct lesskey_tables *tables)
{
- xbuf_add(&tables->currtable->buf, c);
+ xbuf_add_byte(&tables->currtable->buf, c);
}
- static void
-erase_cmd_char(tables)
- struct lesskey_tables *tables;
+static void erase_cmd_char(struct lesskey_tables *tables)
{
xbuf_pop(&tables->currtable->buf);
}
@@ -379,10 +353,7 @@ erase_cmd_char(tables)
/*
* Add a string to the output command table.
*/
- static void
-add_cmd_str(s, tables)
- char *s;
- struct lesskey_tables *tables;
+static void add_cmd_str(char *s, struct lesskey_tables *tables)
{
for ( ; *s != '\0'; s++)
add_cmd_char(*s, tables);
@@ -392,10 +363,7 @@ add_cmd_str(s, tables)
* Does a given version number match the running version?
* Operator compares the running version to the given version.
*/
- static int
-match_version(op, ver)
- char op;
- int ver;
+static int match_version(char op, int ver)
{
switch (op)
{
@@ -414,10 +382,7 @@ match_version(op, ver)
* If the version matches, return the part of the line that should be executed.
* Otherwise, return NULL.
*/
- static char *
-version_line(s, tables)
- char *s;
- struct lesskey_tables *tables;
+static char * version_line(char *s, struct lesskey_tables *tables)
{
char op;
int ver;
@@ -439,7 +404,7 @@ version_line(s, tables)
return (NULL);
}
s = skipsp(s);
- ver = lstrtoi(s, &e);
+ ver = lstrtoi(s, &e, 10);
if (e == s)
{
parse_error("non-numeric version number in #version line", "");
@@ -453,10 +418,7 @@ version_line(s, tables)
/*
* See if we have a special "control" line.
*/
- static char *
-control_line(s, tables)
- char *s;
- struct lesskey_tables *tables;
+static char * control_line(char *s, struct lesskey_tables *tables)
{
#define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0)
@@ -491,10 +453,7 @@ control_line(s, tables)
/*
* Find an action, given the name of the action.
*/
- static int
-findaction(actname, tables)
- char *actname;
- struct lesskey_tables *tables;
+static int findaction(char *actname, struct lesskey_tables *tables)
{
int i;
@@ -512,10 +471,7 @@ findaction(actname, tables)
* resulting less action, and EXTRA is an "extra" user
* key sequence injected after the action.
*/
- static void
-parse_cmdline(p, tables)
- char *p;
- struct lesskey_tables *tables;
+static void parse_cmdline(char *p, struct lesskey_tables *tables)
{
char *actname;
int action;
@@ -563,14 +519,14 @@ parse_cmdline(p, tables)
p = skipsp(p);
if (*p == '\0')
{
- add_cmd_char(action, tables);
+ add_cmd_char((unsigned char) action, tables);
} else
{
/*
* OR the special value A_EXTRA into the action byte.
* Put the extra string after the action byte.
*/
- add_cmd_char(action | A_EXTRA, tables);
+ add_cmd_char((unsigned char) (action | A_EXTRA), tables);
while (*p != '\0')
add_cmd_str(tstr(&p, 0), tables);
add_cmd_char('\0', tables);
@@ -581,10 +537,7 @@ parse_cmdline(p, tables)
* Parse a variable definition line, of the form
* NAME = VALUE
*/
- static void
-parse_varline(line, tables)
- char *line;
- struct lesskey_tables *tables;
+static void parse_varline(char *line, struct lesskey_tables *tables)
{
char *s;
char *p = line;
@@ -631,10 +584,7 @@ parse_varline(line, tables)
/*
* Parse a line from the lesskey file.
*/
- static void
-parse_line(line, tables)
- char *line;
- struct lesskey_tables *tables;
+static void parse_line(char *line, struct lesskey_tables *tables)
{
char *p;
@@ -662,10 +612,7 @@ parse_line(line, tables)
/*
* Parse a lesskey source file and store result in tables.
*/
- int
-parse_lesskey(infile, tables)
- char *infile;
- struct lesskey_tables *tables;
+int parse_lesskey(char *infile, struct lesskey_tables *tables)
{
FILE *desc;
char line[1024];
@@ -678,7 +625,7 @@ parse_lesskey(infile, tables)
errors = 0;
linenum = 0;
if (less_version == 0)
- less_version = lstrtoi(version, NULL);
+ less_version = lstrtoi(version, NULL, 10);
/*
* Open the input file.
diff --git a/lglob.h b/lglob.h
index 794488a047e1..45597945f9a7 100644
--- a/lglob.h
+++ b/lglob.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/line.c b/line.c
index 2f1b3fb9d2b2..e3e57804a5e8 100644
--- a/line.c
+++ b/line.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -37,7 +37,7 @@ static struct {
* Buffer of ansi sequences which have been shifted off the left edge
* of the screen.
*/
-struct xbuffer shifted_ansi;
+static struct xbuffer shifted_ansi;
/*
* Ring buffer of last ansi sequences sent.
@@ -61,6 +61,7 @@ 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 POSITION line_pos;
static int end_column; /* Printable length, accounting for backspaces, etc. */
static int right_curr;
@@ -74,12 +75,15 @@ static char *end_ansi_chars;
static char *mid_ansi_chars;
static int in_hilite;
-static int attr_swidth LESSPARAMS ((int a));
-static int attr_ewidth LESSPARAMS ((int a));
-static int do_append LESSPARAMS ((LWCHAR ch, char *rep, POSITION pos));
+static int attr_swidth(int a);
+static int attr_ewidth(int a);
+static int do_append(LWCHAR ch, char *rep, POSITION pos);
extern int sigs;
extern int bs_mode;
+extern int proc_backspace;
+extern int proc_tab;
+extern int proc_return;
extern int linenums;
extern int ctldisp;
extern int twiddle;
@@ -105,23 +109,31 @@ static char mbc_buf[MAX_UTF_CHAR_LEN];
static int mbc_buf_len = 0;
static int mbc_buf_index = 0;
static POSITION mbc_pos;
+static int saved_line_end;
+static int saved_end_column;
/* Configurable color map */
-static char color_map[AT_NUM_COLORS][12] = {
- "Wm", /* AT_COLOR_ATTN */
- "kR", /* AT_COLOR_BIN */
- "kR", /* AT_COLOR_CTRL */
- "kY", /* AT_COLOR_ERROR */
- "c", /* AT_COLOR_LINENUM */
- "Wb", /* AT_COLOR_MARK */
- "kC", /* AT_COLOR_PROMPT */
- "kc", /* AT_COLOR_RSCROLL */
- "kG", /* AT_COLOR_SEARCH */
- "", /* AT_COLOR_HEADER */
- "", /* AT_UNDERLINE */
- "", /* AT_BOLD */
- "", /* AT_BLINK */
- "", /* AT_STANDOUT */
+struct color_map { int attr; char color[12]; };
+static struct color_map color_map[] = {
+ { AT_UNDERLINE, "" },
+ { AT_BOLD, "" },
+ { AT_BLINK, "" },
+ { AT_STANDOUT, "" },
+ { AT_COLOR_ATTN, "Wm" },
+ { AT_COLOR_BIN, "kR" },
+ { AT_COLOR_CTRL, "kR" },
+ { AT_COLOR_ERROR, "kY" },
+ { AT_COLOR_LINENUM, "c" },
+ { AT_COLOR_MARK, "Wb" },
+ { AT_COLOR_PROMPT, "kC" },
+ { AT_COLOR_RSCROLL, "kc" },
+ { AT_COLOR_HEADER, "" },
+ { AT_COLOR_SEARCH, "kG" },
+ { AT_COLOR_SUBSEARCH(1), "ky" },
+ { AT_COLOR_SUBSEARCH(2), "wb" },
+ { AT_COLOR_SUBSEARCH(3), "YM" },
+ { AT_COLOR_SUBSEARCH(4), "Yr" },
+ { AT_COLOR_SUBSEARCH(5), "Wc" },
};
/* State while processing an ANSI escape sequence */
@@ -134,8 +146,7 @@ struct ansi_state {
/*
* Initialize from environment variables.
*/
- public void
-init_line(VOID_PARAM)
+public void init_line(void)
{
int ax;
@@ -160,8 +171,7 @@ init_line(VOID_PARAM)
/*
* Expand the line buffer.
*/
- static int
-expand_linebuf(VOID_PARAM)
+static int expand_linebuf(void)
{
/* Double the size of the line buffer. */
int new_size = size_linebuf * 2;
@@ -191,18 +201,14 @@ expand_linebuf(VOID_PARAM)
/*
* Is a character ASCII?
*/
- public int
-is_ascii_char(ch)
- LWCHAR ch;
+public int is_ascii_char(LWCHAR ch)
{
return (ch <= 0x7F);
}
/*
*/
- static void
-inc_end_column(w)
- int w;
+static void inc_end_column(int w)
{
if (end_column > right_column && w > 0)
{
@@ -212,11 +218,15 @@ inc_end_column(w)
end_column += w;
}
+public POSITION line_position(void)
+{
+ return line_pos;
+}
+
/*
* Rewind the line buffer.
*/
- public void
-prewind(VOID_PARAM)
+public void prewind(void)
{
int ax;
@@ -241,6 +251,7 @@ prewind(VOID_PARAM)
ansi_in_line = 0;
hlink_in_line = 0;
line_mark_attr = 0;
+ line_pos = NULL_POSITION;
xbuf_reset(&shifted_ansi);
xbuf_reset(&last_ansi);
for (ax = 0; ax < NUM_LAST_ANSIS; ax++)
@@ -251,12 +262,17 @@ prewind(VOID_PARAM)
/*
* Set a character in the line buffer.
*/
- static void
-set_linebuf(n, ch, attr)
- int n;
- char ch;
- int attr;
+static void set_linebuf(int n, char ch, int attr)
{
+ if (n >= size_linebuf)
+ {
+ /*
+ * Won't fit in line buffer.
+ * Try to expand it.
+ */
+ if (expand_linebuf())
+ return;
+ }
linebuf.buf[n] = ch;
linebuf.attr[n] = attr;
}
@@ -264,11 +280,7 @@ set_linebuf(n, ch, attr)
/*
* Append a character to the line buffer.
*/
- static void
-add_linebuf(ch, attr, w)
- char ch;
- int attr;
- int w;
+static void add_linebuf(char ch, int attr, int w)
{
set_linebuf(linebuf.end++, ch, attr);
inc_end_column(w);
@@ -277,11 +289,7 @@ add_linebuf(ch, attr, w)
/*
* Append a string to the line buffer.
*/
- static void
-addstr_linebuf(s, attr, cw)
- char *s;
- int attr;
- int cw;
+static void addstr_linebuf(char *s, int attr, int cw)
{
for ( ; *s != '\0'; s++)
add_linebuf(*s, attr, cw);
@@ -290,11 +298,7 @@ addstr_linebuf(s, attr, cw)
/*
* Set a character in the line prefix buffer.
*/
- static void
-set_pfx(n, ch, attr)
- int n;
- char ch;
- int attr;
+static void set_pfx(int n, char ch, int attr)
{
linebuf.pfx[n] = ch;
linebuf.pfx_attr[n] = attr;
@@ -303,10 +307,7 @@ set_pfx(n, ch, attr)
/*
* Append a character to the line prefix buffer.
*/
- static void
-add_pfx(ch, attr)
- char ch;
- int attr;
+static void add_pfx(char ch, int attr)
{
set_pfx(linebuf.pfx_end++, ch, attr);
}
@@ -314,9 +315,7 @@ add_pfx(ch, attr)
/*
* Insert the status column and line number into the line buffer.
*/
- public void
-plinestart(pos)
- POSITION pos;
+public void plinestart(POSITION pos)
{
LINENUM linenum = 0;
int i;
@@ -367,7 +366,7 @@ plinestart(pos)
len = 0;
else
{
- linenumtoa(linenum, buf);
+ linenumtoa(linenum, buf, 10);
len = (int) strlen(buf);
}
for (i = 0; i < linenum_width - len; i++)
@@ -383,8 +382,7 @@ plinestart(pos)
* Return the width of the line prefix (status column and line number).
* {{ Actual line number can be wider than linenum_width. }}
*/
- public int
-line_pfx_width(VOID_PARAM)
+public int line_pfx_width(void)
{
int width = 0;
if (status_col)
@@ -398,13 +396,12 @@ line_pfx_width(VOID_PARAM)
* Shift line left so that the last char is just to the left
* of the first visible column.
*/
- public void
-pshift_all(VOID_PARAM)
+public void pshift_all(void)
{
int i;
for (i = linebuf.print; i < linebuf.end; i++)
if (linebuf.attr[i] == AT_ANSI)
- xbuf_add(&shifted_ansi, linebuf.buf[i]);
+ xbuf_add_byte(&shifted_ansi, (unsigned char) linebuf.buf[i]);
linebuf.end = linebuf.print;
end_column = linebuf.pfx_end;
}
@@ -413,9 +410,7 @@ pshift_all(VOID_PARAM)
* Return the printing width of the start (enter) sequence
* for a given character attribute.
*/
- static int
-attr_swidth(a)
- int a;
+static int attr_swidth(int a)
{
int w = 0;
@@ -437,9 +432,7 @@ attr_swidth(a)
* Return the printing width of the end (exit) sequence
* for a given character attribute.
*/
- static int
-attr_ewidth(a)
- int a;
+static int attr_ewidth(int a)
{
int w = 0;
@@ -463,12 +456,7 @@ attr_ewidth(a)
* Adding a character with a given attribute may cause an enter or exit
* attribute sequence to be inserted, so this must be taken into account.
*/
- public int
-pwidth(ch, a, prev_ch, prev_a)
- LWCHAR ch;
- int a;
- LWCHAR prev_ch;
- int prev_a;
+public int pwidth(LWCHAR ch, int a, LWCHAR prev_ch, int prev_a)
{
int w;
@@ -530,8 +518,7 @@ pwidth(ch, a, prev_ch, prev_a)
/*
* Delete to the previous base character in the line buffer.
*/
- static int
-backc(VOID_PARAM)
+static int backc(void)
{
LWCHAR ch;
char *p;
@@ -558,11 +545,27 @@ backc(VOID_PARAM)
}
/*
+ * Preserve the current position in the line buffer (for word wrapping).
+ */
+public void savec(void)
+{
+ saved_line_end = linebuf.end;
+ saved_end_column = end_column;
+}
+
+/*
+ * Restore the position in the line buffer (start of line for word wrapping).
+ */
+public void loadc(void)
+{
+ linebuf.end = saved_line_end;
+ end_column = saved_end_column;
+}
+
+/*
* Is a character the end of an ANSI escape sequence?
*/
- public int
-is_ansi_end(ch)
- LWCHAR ch;
+public int is_ansi_end(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
@@ -572,9 +575,7 @@ is_ansi_end(ch)
/*
* Can a char appear in an ANSI escape sequence, before the end char?
*/
- public int
-is_ansi_middle(ch)
- LWCHAR ch;
+public int is_ansi_middle(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
@@ -587,11 +588,7 @@ is_ansi_middle(ch)
* Skip past an ANSI escape sequence.
* pp is initially positioned just after the CSI_START char.
*/
- public void
-skip_ansi(pansi, pp, limit)
- struct ansi_state *pansi;
- char **pp;
- constant char *limit;
+public void skip_ansi(struct ansi_state *pansi, char **pp, constant char *limit)
{
LWCHAR c;
do {
@@ -604,9 +601,7 @@ skip_ansi(pansi, pp, limit)
* Determine if a character starts an ANSI escape sequence.
* If so, return an ansi_state struct; otherwise return NULL.
*/
- public struct ansi_state *
-ansi_start(ch)
- LWCHAR ch;
+public struct ansi_state * ansi_start(LWCHAR ch)
{
struct ansi_state *pansi;
@@ -623,18 +618,15 @@ ansi_start(ch)
* Determine whether the next char in an ANSI escape sequence
* ends the sequence.
*/
- public int
-ansi_step(pansi, ch)
- struct ansi_state *pansi;
- LWCHAR ch;
+public int ansi_step(struct ansi_state *pansi, LWCHAR ch)
{
if (pansi->hlink)
{
/* Hyperlink ends with \7 or ESC-backslash. */
if (ch == '\7')
return ANSI_END;
- if (pansi->prev_esc && ch == '\\')
- return ANSI_END;
+ if (pansi->prev_esc)
+ return (ch == '\\') ? ANSI_END : ANSI_ERR;
pansi->prev_esc = (ch == ESC);
return ANSI_MID;
}
@@ -662,9 +654,7 @@ ansi_step(pansi, ch)
/*
* Free an ansi_state structure.
*/
- public void
-ansi_done(pansi)
- struct ansi_state *pansi;
+public void ansi_done(struct ansi_state *pansi)
{
free(pansi);
}
@@ -672,10 +662,7 @@ ansi_done(pansi)
/*
* Will w characters in attribute a fit on the screen?
*/
- static int
-fits_on_screen(w, a)
- int w;
- int a;
+static int fits_on_screen(int w, int a)
{
if (ctldisp == OPT_ON)
/* We're not counting, so say that everything fits. */
@@ -691,12 +678,7 @@ fits_on_screen(w, a)
if (store_char((ch),(a),(rep),(pos))) return (1); \
} while (0)
- static int
-store_char(ch, a, rep, pos)
- LWCHAR ch;
- int a;
- char *rep;
- POSITION pos;
+static int store_char(LWCHAR ch, int a, char *rep, POSITION pos)
{
int w;
int i;
@@ -711,13 +693,13 @@ store_char(ch, a, rep, pos)
{
int matches;
int resend_last = 0;
- int hl_attr;
+ int hl_attr = 0;
if (pos == NULL_POSITION)
{
/* Color the prompt unless it has ansi sequences in it. */
hl_attr = ansi_in_line ? 0 : AT_STANDOUT|AT_COLOR_PROMPT;
- } else
+ } else if (a != AT_ANSI)
{
hl_attr = is_hilited_attr(pos, pos+1, 0, &matches);
if (hl_attr == 0 && status_line)
@@ -729,12 +711,9 @@ store_char(ch, a, rep, pos)
* This character should be highlighted.
* Override the attribute passed in.
*/
- if (a != AT_ANSI)
- {
- if (highest_hilite != NULL_POSITION && pos != NULL_POSITION && pos > highest_hilite)
- highest_hilite = pos;
- a |= hl_attr;
- }
+ a |= hl_attr;
+ if (highest_hilite != NULL_POSITION && pos != NULL_POSITION && pos > highest_hilite)
+ highest_hilite = pos;
in_hilite = 1;
} else
{
@@ -782,23 +761,20 @@ store_char(ch, a, rep, pos)
{
replen = utf_len(rep[0]);
}
- if (linebuf.end + replen >= size_linebuf-6)
- {
- /*
- * Won't fit in line buffer.
- * Try to expand it.
- */
- if (expand_linebuf())
- return (1);
- }
- if (cshift == hshift && shifted_ansi.end > 0)
+ if (cshift == hshift)
{
- /* Copy shifted ANSI sequences to beginning of line. */
- for (i = 0; i < shifted_ansi.end; i++)
- add_linebuf(shifted_ansi.data[i], AT_ANSI, 0);
- xbuf_reset(&shifted_ansi);
+ if (line_pos == NULL_POSITION)
+ line_pos = pos;
+ if (shifted_ansi.end > 0)
+ {
+ /* Copy shifted ANSI sequences to beginning of line. */
+ for (i = 0; i < shifted_ansi.end; i++)
+ add_linebuf(shifted_ansi.data[i], AT_ANSI, 0);
+ xbuf_reset(&shifted_ansi);
+ }
}
+
/* Add the char to the buf, even if we will left-shift it next. */
inc_end_column(w);
for (i = 0; i < replen; i++)
@@ -808,7 +784,7 @@ store_char(ch, a, rep, pos)
{
/* We haven't left-shifted enough yet. */
if (a == AT_ANSI)
- xbuf_add(&shifted_ansi, ch); /* Save ANSI attributes */
+ xbuf_add_byte(&shifted_ansi, (unsigned char) ch); /* Save ANSI attributes */
if (linebuf.end > linebuf.print)
{
/* Shift left enough to put last byte of this char at print-1. */
@@ -838,11 +814,7 @@ store_char(ch, a, rep, pos)
#define STORE_STRING(s,a,pos) \
do { if (store_string((s),(a),(pos))) return (1); } while (0)
- static int
-store_string(s, a, pos)
- char *s;
- int a;
- POSITION pos;
+static int store_string(char *s, int a, POSITION pos)
{
if (!fits_on_screen(strlen(s), a))
return 1;
@@ -858,10 +830,7 @@ store_string(s, a, pos)
#define STORE_TAB(a,pos) \
do { if (store_tab((a),(pos))) return (1); } while (0)
- static int
-store_tab(attr, pos)
- int attr;
- POSITION pos;
+static int store_tab(int attr, POSITION pos)
{
int to_tab = end_column - linebuf.pfx_end;
@@ -886,10 +855,7 @@ store_tab(attr, pos)
#define STORE_PRCHAR(c, pos) \
do { if (store_prchar((c), (pos))) return 1; } while (0)
- static int
-store_prchar(c, pos)
- LWCHAR c;
- POSITION pos;
+static int store_prchar(LWCHAR c, POSITION pos)
{
/*
* Convert to printable representation.
@@ -898,9 +864,7 @@ store_prchar(c, pos)
return 0;
}
- static int
-flush_mbc_buf(pos)
- POSITION pos;
+static int flush_mbc_buf(POSITION pos)
{
int i;
@@ -915,10 +879,7 @@ flush_mbc_buf(pos)
* Expand tabs into spaces, handle underlining, boldfacing, etc.
* Returns 0 if ok, 1 if couldn't fit in buffer.
*/
- public int
-pappend(c, pos)
- int c;
- POSITION pos;
+public int pappend(int c, POSITION pos)
{
int r;
@@ -935,7 +896,7 @@ pappend(c, pos)
pendc = '\0';
}
- if (c == '\r' && bs_mode == BS_SPECIAL)
+ if (c == '\r' && (proc_return == OPT_ON || (bs_mode == BS_SPECIAL && proc_return == OPT_OFF)))
{
if (mbc_buf_len > 0) /* utf_mode must be on. */
{
@@ -1008,11 +969,7 @@ pappend(c, pos)
return (r);
}
- static int
-store_control_char(ch, rep, pos)
- LWCHAR ch;
- char *rep;
- POSITION pos;
+static int store_control_char(LWCHAR ch, char *rep, POSITION pos)
{
if (ctldisp == OPT_ON)
{
@@ -1026,11 +983,7 @@ store_control_char(ch, rep, pos)
return (0);
}
- static int
-store_ansi(ch, rep, pos)
- LWCHAR ch;
- char *rep;
- POSITION pos;
+static int store_ansi(LWCHAR ch, char *rep, POSITION pos)
{
switch (ansi_step(line_ansi, ch))
{
@@ -1038,13 +991,13 @@ store_ansi(ch, rep, pos)
STORE_CHAR(ch, AT_ANSI, rep, pos);
if (line_ansi->hlink)
hlink_in_line = 1;
- xbuf_add(&last_ansi, ch);
+ xbuf_add_byte(&last_ansi, (unsigned char) ch);
break;
case ANSI_END:
STORE_CHAR(ch, AT_ANSI, rep, pos);
ansi_done(line_ansi);
line_ansi = NULL;
- xbuf_add(&last_ansi, ch);
+ xbuf_add_byte(&last_ansi, (unsigned char) ch);
xbuf_set(&last_ansis[curr_last_ansi], &last_ansi);
xbuf_reset(&last_ansi);
curr_last_ansi = (curr_last_ansi + 1) % NUM_LAST_ANSIS;
@@ -1052,7 +1005,7 @@ store_ansi(ch, rep, pos)
case ANSI_ERR:
{
/* Remove whole unrecognized sequence. */
- char *start = (cshift < hshift) ? shifted_ansi.data : linebuf.buf;
+ char *start = (cshift < hshift) ? xbuf_char_data(&shifted_ansi): linebuf.buf;
int *end = (cshift < hshift) ? &shifted_ansi.end : &linebuf.end;
char *p = start + *end;
LWCHAR bch;
@@ -1069,32 +1022,25 @@ store_ansi(ch, rep, pos)
return (0);
}
- static int
-store_bs(ch, rep, pos)
- LWCHAR ch;
- char *rep;
- POSITION pos;
+static int store_bs(LWCHAR ch, char *rep, POSITION pos)
{
- if (bs_mode == BS_CONTROL)
+ if (proc_backspace == OPT_ONPLUS || (bs_mode == BS_CONTROL && proc_backspace == OPT_OFF))
return store_control_char(ch, rep, pos);
if (linebuf.end > 0 &&
((linebuf.end <= linebuf.print && linebuf.buf[linebuf.end-1] == '\0') ||
(linebuf.end > 0 && linebuf.attr[linebuf.end - 1] & (AT_ANSI|AT_BINARY))))
STORE_PRCHAR('\b', pos);
- else if (bs_mode == BS_NORMAL)
+ else if (proc_backspace == OPT_OFF && bs_mode == BS_NORMAL)
STORE_CHAR(ch, AT_NORMAL, NULL, pos);
- else if (bs_mode == BS_SPECIAL)
+ else if (proc_backspace == OPT_ON || (bs_mode == BS_SPECIAL && proc_backspace == OPT_OFF))
overstrike = backc();
return 0;
}
- static int
-do_append(ch, rep, pos)
- LWCHAR ch;
- char *rep;
- POSITION pos;
+static int do_append(LWCHAR ch, char *rep, POSITION pos)
{
int a = AT_NORMAL;
+ int in_overstrike = overstrike;
if (ctldisp == OPT_ONPLUS && line_ansi == NULL)
{
@@ -1103,13 +1049,14 @@ do_append(ch, rep, pos)
ansi_in_line = 1;
}
+ overstrike = 0;
if (line_ansi != NULL)
return store_ansi(ch, rep, pos);
if (ch == '\b')
return store_bs(ch, rep, pos);
- if (overstrike > 0)
+ if (in_overstrike > 0)
{
/*
* Overstrike the character at the current position
@@ -1158,7 +1105,7 @@ do_append(ch, rep, pos)
a |= AT_UNDERLINE;
}
/* Else we replace prev_ch, but we keep its attributes. */
- } else if (overstrike < 0)
+ } else if (in_overstrike < 0)
{
if ( is_composing_char(ch)
|| is_combining_char(get_wchar(&linebuf.buf[linebuf.end]), ch))
@@ -1173,15 +1120,9 @@ do_append(ch, rep, pos)
/*
* Expand a tab into spaces.
*/
- switch (bs_mode)
- {
- case BS_CONTROL:
+ if (proc_tab == OPT_ONPLUS || (bs_mode == BS_CONTROL && proc_tab == OPT_OFF))
return store_control_char(ch, rep, pos);
- case BS_NORMAL:
- case BS_SPECIAL:
- STORE_TAB(a, pos);
- break;
- }
+ STORE_TAB(a, pos);
return (0);
}
if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch))
@@ -1200,8 +1141,7 @@ do_append(ch, rep, pos)
/*
*
*/
- public int
-pflushmbc(VOID_PARAM)
+public int pflushmbc(void)
{
int r = 0;
@@ -1217,8 +1157,7 @@ pflushmbc(VOID_PARAM)
/*
* Switch to normal attribute at end of line.
*/
- static void
-add_attr_normal(VOID_PARAM)
+static void add_attr_normal(void)
{
if (ctldisp != OPT_ONPLUS || !is_ansi_end('m'))
return;
@@ -1230,11 +1169,7 @@ add_attr_normal(VOID_PARAM)
/*
* Terminate the line in the line buffer.
*/
- public void
-pdone(endline, chopped, forw)
- int endline;
- int chopped;
- int forw;
+public void pdone(int endline, int chopped, int forw)
{
(void) pflushmbc();
@@ -1326,23 +1261,19 @@ pdone(endline, chopped, forw)
/*
* Set an attribute on each char of the line in the line buffer.
*/
- public void
-set_attr_line(a)
- int a;
+public void set_attr_line(int a)
{
int i;
for (i = linebuf.print; i < linebuf.end; i++)
- linebuf.attr[i] |= a;
+ if ((linebuf.attr[i] & AT_COLOR) == 0 || (a & AT_COLOR) == 0)
+ linebuf.attr[i] |= a;
}
/*
* Set the char to be displayed in the status column.
*/
- public void
-set_status_col(c, attr)
- int c;
- int attr;
+public void set_status_col(char c, int attr)
{
set_pfx(0, c, attr);
}
@@ -1352,10 +1283,7 @@ set_status_col(c, attr)
* Return the character as the function return value,
* and the character attribute in *ap.
*/
- public int
-gline(i, ap)
- int i;
- int *ap;
+public int gline(int i, int *ap)
{
if (is_null_line)
{
@@ -1390,8 +1318,7 @@ gline(i, ap)
/*
* Indicate that there is no current line.
*/
- public void
-null_line(VOID_PARAM)
+public void null_line(void)
{
is_null_line = 1;
cshift = 0;
@@ -1402,11 +1329,7 @@ null_line(VOID_PARAM)
* lines which are not split for screen width.
* {{ This is supposed to be more efficient than forw_line(). }}
*/
- public POSITION
-forw_raw_line(curr_pos, linep, line_lenp)
- POSITION curr_pos;
- char **linep;
- int *line_lenp;
+public POSITION forw_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
{
int n;
int c;
@@ -1451,11 +1374,7 @@ forw_raw_line(curr_pos, linep, line_lenp)
* Analogous to back_line(), but deals with "raw lines".
* {{ This is supposed to be more efficient than back_line(). }}
*/
- public POSITION
-back_raw_line(curr_pos, linep, line_lenp)
- POSITION curr_pos;
- char **linep;
- int *line_lenp;
+public POSITION back_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
{
int n;
int c;
@@ -1522,11 +1441,42 @@ back_raw_line(curr_pos, linep, line_lenp)
}
/*
+ * Skip cols printable columns at the start of line.
+ * Return number of bytes skipped.
+ */
+public int skip_columns(int cols, char **linep, int *line_lenp)
+{
+ char *line = *linep;
+ char *eline = line + *line_lenp;
+ LWCHAR pch = 0;
+ int bytes;
+
+ while (cols > 0 && line < eline)
+ {
+ LWCHAR ch = step_char(&line, +1, eline);
+ struct ansi_state *pansi = ansi_start(ch);
+ if (pansi != NULL)
+ {
+ skip_ansi(pansi, &line, eline);
+ ansi_done(pansi);
+ pch = 0;
+ } else
+ {
+ int w = pwidth(ch, 0, pch, 0);
+ cols -= w;
+ pch = ch;
+ }
+ }
+ bytes = line - *linep;
+ *linep = line;
+ *line_lenp -= bytes;
+ return (bytes);
+}
+
+/*
* Append a string to the line buffer.
*/
- static int
-pappstr(str)
- constant char *str;
+static int pappstr(constant char *str)
{
while (*str != '\0')
{
@@ -1542,9 +1492,7 @@ pappstr(str)
* If the string is too long to fit on the screen,
* truncate the beginning of the string to fit.
*/
- public void
-load_line(str)
- constant char *str;
+public void load_line(constant char *str)
{
int save_hshift = hshift;
@@ -1568,8 +1516,7 @@ load_line(str)
/*
* Find the shift necessary to show the end of the longest displayed line.
*/
- public int
-rrshift(VOID_PARAM)
+public int rrshift(void)
{
POSITION pos;
int save_width;
@@ -1594,65 +1541,53 @@ rrshift(VOID_PARAM)
/*
* Get the color_map index associated with a given attribute.
*/
- static int
-color_index(attr)
- int attr;
+static int lookup_color_index(int attr)
{
- if (use_color)
- {
- switch (attr & AT_COLOR)
- {
- case AT_COLOR_ATTN: return 0;
- case AT_COLOR_BIN: return 1;
- case AT_COLOR_CTRL: return 2;
- case AT_COLOR_ERROR: return 3;
- case AT_COLOR_LINENUM: return 4;
- case AT_COLOR_MARK: return 5;
- case AT_COLOR_PROMPT: return 6;
- case AT_COLOR_RSCROLL: return 7;
- case AT_COLOR_SEARCH: return 8;
- case AT_COLOR_HEADER: return 9;
- }
- }
+ int cx;
+ for (cx = 0; cx < sizeof(color_map)/sizeof(*color_map); cx++)
+ if (color_map[cx].attr == attr)
+ return cx;
+ return -1;
+}
+
+static int color_index(int attr)
+{
+ if (use_color && (attr & AT_COLOR))
+ return lookup_color_index(attr & AT_COLOR);
if (attr & AT_UNDERLINE)
- return 10;
+ return lookup_color_index(AT_UNDERLINE);
if (attr & AT_BOLD)
- return 11;
+ return lookup_color_index(AT_BOLD);
if (attr & AT_BLINK)
- return 12;
+ return lookup_color_index(AT_BLINK);
if (attr & AT_STANDOUT)
- return 13;
+ return lookup_color_index(AT_STANDOUT);
return -1;
}
/*
* Set the color string to use for a given attribute.
*/
- public int
-set_color_map(attr, colorstr)
- int attr;
- char *colorstr;
+public int set_color_map(int attr, char *colorstr)
{
int cx = color_index(attr);
if (cx < 0)
return -1;
- if (strlen(colorstr)+1 > sizeof(color_map[cx]))
+ if (strlen(colorstr)+1 > sizeof(color_map[cx].color))
return -1;
if (*colorstr != '\0' && parse_color(colorstr, NULL, NULL) == CT_NULL)
return -1;
- strcpy(color_map[cx], colorstr);
+ strcpy(color_map[cx].color, colorstr);
return 0;
}
/*
* Get the color string to use for a given attribute.
*/
- public char *
-get_color_map(attr)
- int attr;
+public char * get_color_map(int attr)
{
int cx = color_index(attr);
if (cx < 0)
return NULL;
- return color_map[cx];
+ return color_map[cx].color;
}
diff --git a/linenum.c b/linenum.c
index 1808ea97851e..7b9fd2363280 100644
--- a/linenum.c
+++ b/linenum.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -62,7 +62,8 @@ struct linenum_info
static struct linenum_info anchor; /* Anchor of the list */
static struct linenum_info *freelist; /* Anchor of the unused entries */
static struct linenum_info pool[NPOOL]; /* The pool itself */
-static struct linenum_info *spare; /* We always keep one spare entry */
+static struct linenum_info *spare; /* We always keep one spare entry */
+public int scanning_eof = FALSE;
extern int linenums;
extern int sigs;
@@ -74,8 +75,7 @@ extern int nonum_headers;
/*
* Initialize the line number structures.
*/
- public void
-clr_linenum(VOID_PARAM)
+public void clr_linenum(void)
{
struct linenum_info *p;
@@ -102,9 +102,7 @@ clr_linenum(VOID_PARAM)
/*
* Calculate the gap for an entry.
*/
- static void
-calcgap(p)
- struct linenum_info *p;
+static void calcgap(struct linenum_info *p)
{
/*
* Don't bother to compute a gap for the anchor.
@@ -122,10 +120,7 @@ calcgap(p)
* The specified position (pos) should be the file position of the
* FIRST character in the specified line.
*/
- public void
-add_lnum(linenum, pos)
- LINENUM linenum;
- POSITION pos;
+public void add_lnum(LINENUM linenum, POSITION pos)
{
struct linenum_info *p;
struct linenum_info *new;
@@ -210,8 +205,7 @@ add_lnum(linenum, pos)
* If we get stuck in a long loop trying to figure out the
* line number, print a message to tell the user what we're doing.
*/
- static void
-longloopmessage(VOID_PARAM)
+static void longloopmessage(void)
{
ierror("Calculating line numbers", NULL_PARG);
}
@@ -221,8 +215,7 @@ static int loopcount;
static time_type startime;
#endif
- static void
-longish(VOID_PARAM)
+static void longish(void)
{
#if HAVE_TIME
if (loopcount >= 0 && ++loopcount > 100)
@@ -247,8 +240,7 @@ longish(VOID_PARAM)
* Turn off line numbers because the user has interrupted
* a lengthy line number calculation.
*/
- static void
-abort_long(VOID_PARAM)
+static void abort_long(void)
{
if (loopcount >= 0)
return;
@@ -265,9 +257,7 @@ abort_long(VOID_PARAM)
* Find the line number associated with a given position.
* Return 0 if we can't figure it out.
*/
- public LINENUM
-find_linenum(pos)
- POSITION pos;
+public LINENUM find_linenum(POSITION pos)
{
struct linenum_info *p;
LINENUM linenum;
@@ -379,9 +369,7 @@ find_linenum(pos)
* Find the position of a given line number.
* Return NULL_POSITION if we can't figure it out.
*/
- public POSITION
-find_pos(linenum)
- LINENUM linenum;
+public POSITION find_pos(LINENUM linenum)
{
struct linenum_info *p;
POSITION cpos;
@@ -452,9 +440,7 @@ find_pos(linenum)
* The argument "where" tells which line is to be considered
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc).
*/
- public LINENUM
-currline(where)
- int where;
+public LINENUM currline(int where)
{
POSITION pos;
POSITION len;
@@ -475,15 +461,19 @@ currline(where)
/*
* Scan entire file, counting line numbers.
*/
- public void
-scan_eof(VOID_PARAM)
+public void scan_eof(void)
{
- POSITION pos = 0;
+ POSITION pos = ch_zero();
LINENUM linenum = 0;
if (ch_seek(0))
return;
ierror("Determining length of file", NULL_PARG);
+ /*
+ * scanning_eof prevents the "Waiting for data" message from
+ * overwriting "Determining length of file".
+ */
+ scanning_eof = TRUE;
while (pos != NULL_POSITION)
{
/* For efficiency, only add one every 256 line numbers. */
@@ -493,15 +483,14 @@ scan_eof(VOID_PARAM)
if (ABORT_SIGS())
break;
}
+ scanning_eof = FALSE;
}
/*
* Return a line number adjusted for display
* (handles the --no-number-headers option).
*/
- public LINENUM
-vlinenum(linenum)
- LINENUM linenum;
+public LINENUM vlinenum(LINENUM linenum)
{
if (nonum_headers)
linenum = (linenum < header_lines) ? 0 : linenum - header_lines;
diff --git a/lsystem.c b/lsystem.c
index d817369e42d0..ebb249d8500d 100644
--- a/lsystem.c
+++ b/lsystem.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -42,10 +42,7 @@ extern IFILE curr_ifile;
* Pass the specified command to a shell to be executed.
* Like plain "system()", but handles resetting terminal modes, etc.
*/
- public void
-lsystem(cmd, donemsg)
- char *cmd;
- char *donemsg;
+public void lsystem(char *cmd, char *donemsg)
{
int inp;
#if HAVE_SHELL
@@ -251,10 +248,7 @@ lsystem(cmd, donemsg)
* If the mark is on the current screen, or if the mark is ".",
* the whole current screen is piped.
*/
- public int
-pipe_mark(c, cmd)
- int c;
- char *cmd;
+public int pipe_mark(int c, char *cmd)
{
POSITION mpos, tpos, bpos;
@@ -285,11 +279,7 @@ pipe_mark(c, cmd)
* Create a pipe to the given shell command.
* Feed it the file contents between the positions spos and epos.
*/
- public int
-pipe_data(cmd, spos, epos)
- char *cmd;
- POSITION spos;
- POSITION epos;
+public int pipe_data(char *cmd, POSITION spos, POSITION epos)
{
FILE *f;
int c;
diff --git a/main.c b/main.c
index b3ec9afe36e1..3fcd57be880f 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -68,10 +68,7 @@ extern int first_time;
/*
* Entry point.
*/
-int
-main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
IFILE ifile;
char *s;
@@ -122,6 +119,7 @@ main(argc, argv)
is_tty = isatty(1);
init_mark();
init_cmds();
+ init_poll();
get_term();
init_charset();
init_line();
@@ -312,9 +310,7 @@ main(argc, argv)
* Copy a string to a "safe" place
* (that is, to a buffer allocated by calloc).
*/
- public char *
-save(s)
- constant char *s;
+public char * save(constant char *s)
{
char *p;
@@ -323,32 +319,30 @@ save(s)
return (p);
}
+public void out_of_memory(void)
+{
+ error("Cannot allocate memory", NULL_PARG);
+ quit(QUIT_ERROR);
+}
+
/*
* Allocate memory.
* Like calloc(), but never returns an error (NULL).
*/
- public VOID_POINTER
-ecalloc(count, size)
- int count;
- unsigned int size;
+public void * ecalloc(int count, unsigned int size)
{
- VOID_POINTER p;
+ void * p;
- p = (VOID_POINTER) calloc(count, size);
- if (p != NULL)
- return (p);
- error("Cannot allocate memory", NULL_PARG);
- quit(QUIT_ERROR);
- /*NOTREACHED*/
- return (NULL);
+ p = (void *) calloc(count, size);
+ if (p == NULL)
+ out_of_memory();
+ return p;
}
/*
* Skip leading spaces in a string.
*/
- public char *
-skipsp(s)
- char *s;
+public char * skipsp(char *s)
{
while (*s == ' ' || *s == '\t')
s++;
@@ -360,11 +354,7 @@ skipsp(s)
* If uppercase is true, the first string must begin with an uppercase
* character; the remainder of the first string may be either case.
*/
- public int
-sprefix(ps, s, uppercase)
- char *ps;
- char *s;
- int uppercase;
+public int sprefix(char *ps, char *s, int uppercase)
{
int c;
int sc;
@@ -393,9 +383,7 @@ sprefix(ps, s, uppercase)
/*
* Exit the program.
*/
- public void
-quit(status)
- int status;
+public void quit(int status)
{
static int save_status;
@@ -407,10 +395,8 @@ quit(status)
status = save_status;
else
save_status = status;
-#if LESSTEST
- rstat('Q');
-#endif /*LESSTEST*/
quitting = 1;
+ check_altpipe_error();
if (interactive())
clear_bot();
deinit();
diff --git a/mark.c b/mark.c
index f3bf0c4f6b55..1749e01b3651 100644
--- a/mark.c
+++ b/mark.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -49,12 +49,7 @@ public int marks_modified = 0;
/*
* Initialize a mark struct.
*/
- static void
-cmark(m, ifile, pos, ln)
- struct mark *m;
- IFILE ifile;
- POSITION pos;
- int ln;
+static void cmark(struct mark *m, IFILE ifile, POSITION pos, int ln)
{
m->m_ifile = ifile;
m->m_scrpos.pos = pos;
@@ -68,8 +63,7 @@ cmark(m, ifile, pos, ln)
/*
* Initialize the mark table to show no marks are set.
*/
- public void
-init_mark(VOID_PARAM)
+public void init_mark(void)
{
int i;
@@ -89,10 +83,7 @@ init_mark(VOID_PARAM)
/*
* Set m_ifile and clear m_filename.
*/
- static void
-mark_set_ifile(m, ifile)
- struct mark *m;
- IFILE ifile;
+static void mark_set_ifile(struct mark *m, IFILE ifile)
{
m->m_ifile = ifile;
/* With m_ifile set, m_filename is no longer needed. */
@@ -103,9 +94,7 @@ mark_set_ifile(m, ifile)
/*
* Populate the m_ifile member of a mark struct from m_filename.
*/
- static void
-mark_get_ifile(m)
- struct mark *m;
+static void mark_get_ifile(struct mark *m)
{
if (m->m_ifile != NULL_IFILE)
return; /* m_ifile is already set */
@@ -115,9 +104,7 @@ mark_get_ifile(m)
/*
* Return the user mark struct identified by a character.
*/
- static struct mark *
-getumark(c)
- int c;
+static struct mark * getumark(LWCHAR c)
{
PARG parg;
if (c >= 'a' && c <= 'z')
@@ -138,9 +125,7 @@ getumark(c)
* The mark struct may either be in the mark table (user mark)
* or may be constructed on the fly for certain characters like ^, $.
*/
- static struct mark *
-getmark(c)
- int c;
+static struct mark * getmark(LWCHAR c)
{
struct mark *m;
static struct mark sm;
@@ -200,9 +185,7 @@ getmark(c)
/*
* Is a mark letter invalid?
*/
- public int
-badmark(c)
- int c;
+public int badmark(LWCHAR c)
{
return (getmark(c) == NULL);
}
@@ -210,10 +193,7 @@ badmark(c)
/*
* Set a user-defined mark.
*/
- public void
-setmark(c, where)
- int c;
- int where;
+public void setmark(LWCHAR c, int where)
{
struct mark *m;
struct scrpos scrpos;
@@ -234,9 +214,7 @@ setmark(c, where)
/*
* Clear a user-defined mark.
*/
- public void
-clrmark(c)
- int c;
+public void clrmark(LWCHAR c)
{
struct mark *m;
@@ -255,8 +233,7 @@ clrmark(c)
/*
* Set lmark (the mark named by the apostrophe).
*/
- public void
-lastmark(VOID_PARAM)
+public void lastmark(void)
{
struct scrpos scrpos;
@@ -272,9 +249,7 @@ lastmark(VOID_PARAM)
/*
* Go to a mark.
*/
- public void
-gomark(c)
- int c;
+public void gomark(LWCHAR c)
{
struct mark *m;
struct scrpos scrpos;
@@ -315,9 +290,7 @@ gomark(c)
* is associated with, but this doesn't matter much,
* because it's always the first non-blank line on the screen.
*/
- public POSITION
-markpos(c)
- int c;
+public POSITION markpos(LWCHAR c)
{
struct mark *m;
@@ -336,9 +309,7 @@ markpos(c)
/*
* Return the mark associated with a given position, if any.
*/
- public char
-posmark(pos)
- POSITION pos;
+public char posmark(POSITION pos)
{
int i;
@@ -358,9 +329,7 @@ posmark(pos)
/*
* Clear the marks associated with a specified ifile.
*/
- public void
-unmark(ifile)
- IFILE ifile;
+public void unmark(IFILE ifile)
{
int i;
@@ -373,9 +342,7 @@ unmark(ifile)
* Check if any marks refer to a specified ifile vi m_filename
* rather than m_ifile.
*/
- public void
-mark_check_ifile(ifile)
- IFILE ifile;
+public void mark_check_ifile(IFILE ifile)
{
int i;
char *filename = get_real_filename(ifile);
@@ -399,10 +366,7 @@ mark_check_ifile(ifile)
/*
* Save marks to history file.
*/
- public void
-save_marks(fout, hdr)
- FILE *fout;
- char *hdr;
+public void save_marks(FILE *fout, char *hdr)
{
int i;
@@ -417,7 +381,7 @@ save_marks(fout, hdr)
char pos_str[INT_STRLEN_BOUND(m->m_scrpos.pos) + 2];
if (m->m_scrpos.pos == NULL_POSITION)
continue;
- postoa(m->m_scrpos.pos, pos_str);
+ postoa(m->m_scrpos.pos, pos_str, 10);
filename = m->m_filename;
if (filename == NULL)
filename = get_real_filename(m->m_ifile);
@@ -430,9 +394,7 @@ save_marks(fout, hdr)
/*
* Restore one mark from the history file.
*/
- public void
-restore_mark(line)
- char *line;
+public void restore_mark(char *line)
{
struct mark *m;
int ln;
@@ -446,13 +408,17 @@ restore_mark(line)
if (m == NULL)
return;
skip_whitespace;
- ln = lstrtoi(line, &line);
+ ln = lstrtoi(line, &line, 10);
+ if (ln < 0)
+ return;
if (ln < 1)
ln = 1;
if (ln > sc_height)
ln = sc_height;
skip_whitespace;
- pos = lstrtopos(line, &line);
+ pos = lstrtopos(line, &line, 10);
+ if (pos < 0)
+ return;
skip_whitespace;
cmark(m, NULL_IFILE, pos, ln);
m->m_filename = save(line);
diff --git a/mkfuncs.pl b/mkfuncs.pl
deleted file mode 100755
index 35417339791f..000000000000
--- a/mkfuncs.pl
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /usr/bin/perl
-use strict;
-
-my $state = 0;
-my $def;
-my $params;
-
-while (<>) {
- if (/^\tpublic\s+(.*)/) {
- $def = "public $1";
- $state = 1;
- $params = 0;
- } elsif ($state == 1 and /(\w+)\s*\(/) {
- $def .= " $1 LESSPARAMS ((";
- $state = 2;
- } elsif ($state == 2) {
- if (/^{/) {
- $def .= 'VOID_PARAM' if not $params;
- print "$def));\n";
- $state = 0;
- } elsif (/^\s*([^;]*)/) {
- $def .= ', ' if substr($def,-1) ne '(';
- $def .= $1;
- $params = 1;
- }
- }
-}
diff --git a/mkfuncs.py b/mkfuncs.py
deleted file mode 100755
index 7a2da5ad19ed..000000000000
--- a/mkfuncs.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-
-import fileinput
-import re
-
-definition = ''
-state = 0
-params = 0
-
-for line in fileinput.input():
- if test := re.search(r'^\tpublic\s+(.*)', line):
- definition = 'public ' + test.group(1)
- state = 1
- params = 0
- elif (state == 1) and (test := re.search(r'(\w+)\s*\(', line)):
- definition = '{0} LESSPARAMS (('.format(test.group(1))
- state = 2
- elif state == 2:
- if re.search(r'^{', line):
- if not params: definition += 'VOID_PARAM'
- print(f'{definition}));')
- state = 0
- elif test := re.search(r'^\s*([^;]*)', line):
- if (definition[-1:] != '('): definition += ', '
- definition += test.group(1)
- params = 1
diff --git a/mkhelp.pl b/mkhelp.pl
index a826e208dca9..e93535b9d6cc 100755
--- a/mkhelp.pl
+++ b/mkhelp.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#! /usr/bin/env perl
use strict;
# Silly little program to generate the help.c source file
diff --git a/mkutable b/mkutable
index 90fe3acc3501..69b497532747 100755
--- a/mkutable
+++ b/mkutable
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
use strict;
my $USAGE = <<__EOF__;
@@ -57,6 +57,7 @@ sub main {
print "/* Generated by \"$0 $args\" on $date */\n";
my $last_code = 0;
+ my $start_range = 0;
while (<>) {
chomp;
s/#.*//;
@@ -70,6 +71,18 @@ sub main {
} else {
$lo_code = $hi_code = hex $codes;
}
+ if ($fields[1] =~ /, First>$/) {
+ die "invalid Unicode data: First with range" if $hi_code != $lo_code;
+ $start_range = $lo_code;
+ next;
+ }
+ if ($fields[1] =~ /, Last>$/) {
+ die "invalid Unicode data: Last without First" if not $start_range;
+ $lo_code = $start_range;
+ $start_range = 0;
+ } elsif ($start_range) {
+ die "invalid Unicode data: First without Last";
+ }
my $type = $fields[$type_field];
$type =~ s/\s//g;
for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) {
diff --git a/optfunc.c b/optfunc.c
index 84333b716ac9..da7e54c3d60a 100644
--- a/optfunc.c
+++ b/optfunc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -63,6 +63,10 @@ extern int header_lines;
extern int header_cols;
extern int def_search_type;
extern int chopline;
+extern int tabstops[];
+extern int ntabstops;
+extern int tabdefault;
+extern char intr_char;
#if LOGFILE
extern char *namelogfile;
extern int force_logfile;
@@ -75,7 +79,6 @@ extern char ztags[];
#endif
#if LESSTEST
extern char *ttyin_name;
-extern int rstat_file;
#endif /*LESSTEST*/
#if MSDOS_COMPILER
extern int nm_fg_color, nm_bg_color;
@@ -96,10 +99,7 @@ extern int sgr_mode;
/*
* Handler for -o option.
*/
- public void
-opt_o(type, s)
- int type;
- char *s;
+public void opt_o(int type, char *s)
{
PARG parg;
char *filename;
@@ -149,10 +149,7 @@ opt_o(type, s)
/*
* Handler for -O option.
*/
- public void
-opt__O(type, s)
- int type;
- char *s;
+public void opt__O(int type, char *s)
{
force_logfile = TRUE;
opt_o(type, s);
@@ -162,10 +159,7 @@ opt__O(type, s)
/*
* Handlers for -j option.
*/
- public void
-opt_j(type, s)
- int type;
- char *s;
+public void opt_j(int type, char *s)
{
PARG parg;
int len;
@@ -215,21 +209,17 @@ opt_j(type, s)
}
}
- public void
-calc_jump_sline(VOID_PARAM)
+public void calc_jump_sline(void)
{
if (jump_sline_fraction < 0)
return;
- jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM;
+ jump_sline = muldiv(sc_height, jump_sline_fraction, NUM_FRAC_DENOM);
}
/*
* Handlers for -# option.
*/
- public void
-opt_shift(type, s)
- int type;
- char *s;
+public void opt_shift(int type, char *s)
{
PARG parg;
int len;
@@ -279,19 +269,15 @@ opt_shift(type, s)
}
}
- public void
-calc_shift_count(VOID_PARAM)
+public void calc_shift_count(void)
{
if (shift_count_fraction < 0)
return;
- shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM;
+ shift_count = muldiv(sc_width, shift_count_fraction, NUM_FRAC_DENOM);
}
#if USERFILE
- public void
-opt_k(type, s)
- int type;
- char *s;
+public void opt_k(int type, char *s)
{
PARG parg;
@@ -308,10 +294,7 @@ opt_k(type, s)
}
#if HAVE_LESSKEYSRC
- public void
-opt_ks(type, s)
- int type;
- char *s;
+public void opt_ks(int type, char *s)
{
PARG parg;
@@ -333,10 +316,7 @@ opt_ks(type, s)
/*
* Handler for -t option.
*/
- public void
-opt_t(type, s)
- int type;
- char *s;
+public void opt_t(int type, char *s)
{
IFILE save_ifile;
POSITION pos;
@@ -374,10 +354,7 @@ opt_t(type, s)
/*
* Handler for -T option.
*/
- public void
-opt__T(type, s)
- int type;
- char *s;
+public void opt__T(int type, char *s)
{
PARG parg;
char *filename;
@@ -406,10 +383,7 @@ opt__T(type, s)
/*
* Handler for -p option.
*/
- public void
-opt_p(type, s)
- int type;
- char *s;
+public void opt_p(int type, char *s)
{
switch (type)
{
@@ -442,10 +416,7 @@ opt_p(type, s)
/*
* Handler for -P option.
*/
- public void
-opt__P(type, s)
- int type;
- char *s;
+public void opt__P(int type, char *s)
{
char **proto;
PARG parg;
@@ -481,10 +452,7 @@ opt__P(type, s)
* Handler for the -b option.
*/
/*ARGSUSED*/
- public void
-opt_b(type, s)
- int type;
- char *s;
+public void opt_b(int type, char *s)
{
switch (type)
{
@@ -504,10 +472,7 @@ opt_b(type, s)
* Handler for the -i option.
*/
/*ARGSUSED*/
- public void
-opt_i(type, s)
- int type;
- char *s;
+public void opt_i(int type, char *s)
{
switch (type)
{
@@ -524,10 +489,7 @@ opt_i(type, s)
* Handler for the -V option.
*/
/*ARGSUSED*/
- public void
-opt__V(type, s)
- int type;
- char *s;
+public void opt__V(int type, char *s)
{
switch (type)
{
@@ -544,7 +506,7 @@ opt__V(type, s)
putstr(" regular expressions)\n");
{
char constant *copyright =
- "Copyright (C) 1984-2022 Mark Nudelman\n\n";
+ "Copyright (C) 1984-2023 Mark Nudelman\n\n";
putstr(copyright);
}
if (version[strlen(version)-1] == 'x')
@@ -553,6 +515,9 @@ opt__V(type, s)
putstr("** and may not function correctly.\n");
putstr("** Obtain release builds from the web page below.\n\n");
}
+#if LESSTEST
+ putstr("This build supports LESSTEST.\n");
+#endif /*LESSTEST*/
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");
@@ -566,11 +531,7 @@ opt__V(type, s)
/*
* Parse an MSDOS color descriptor.
*/
- static void
-colordesc(s, fg_color, bg_color)
- char *s;
- int *fg_color;
- int *bg_color;
+static void colordesc(char *s, int *fg_color, int *bg_color)
{
int fg, bg;
#if MSDOS_COMPILER==WIN32C
@@ -608,9 +569,7 @@ colordesc(s, fg_color, bg_color)
}
#endif
- static int
-color_from_namechar(namechar)
- char namechar;
+static int color_from_namechar(char namechar)
{
switch (namechar)
{
@@ -629,7 +588,10 @@ color_from_namechar(namechar)
case 'd': return AT_BOLD;
case 'u': return AT_UNDERLINE;
case 'k': return AT_BLINK;
- default: return -1;
+ default:
+ if (namechar >= '1' && namechar <= '0'+NUM_SEARCH_COLORS)
+ return AT_COLOR_SUBSEARCH(namechar-'0');
+ return -1;
}
}
@@ -637,10 +599,7 @@ color_from_namechar(namechar)
* Handler for the -D option.
*/
/*ARGSUSED*/
- public void
-opt_D(type, s)
- int type;
- char *s;
+public void opt_D(int type, char *s)
{
PARG p;
int attr;
@@ -714,16 +673,41 @@ opt_D(type, s)
}
/*
+ */
+public void set_tabs(char *s, int len)
+{
+ int i;
+ char *es = s + len;
+ /* Start at 1 because tabstops[0] is always zero. */
+ for (i = 1; i < TABSTOP_MAX; )
+ {
+ int n = 0;
+ int v = FALSE;
+ while (s < es && *s == ' ')
+ s++;
+ for (; s < es && *s >= '0' && *s <= '9'; s++)
+ {
+ v |= ckd_mul(&n, n, 10);
+ v |= ckd_add(&n, n, *s - '0');
+ }
+ if (!v && n > tabstops[i-1])
+ tabstops[i++] = n;
+ while (s < es && *s == ' ')
+ s++;
+ if (s == es || *s++ != ',')
+ break;
+ }
+ if (i < 2)
+ return;
+ ntabstops = i;
+ tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2];
+}
+
+/*
* Handler for the -x option.
*/
- public void
-opt_x(type, s)
- int type;
- char *s;
+public void opt_x(int type, char *s)
{
- extern int tabstops[];
- extern int ntabstops;
- extern int tabdefault;
char msg[60+((INT_STRLEN_BOUND(int)+1)*TABSTOP_MAX)];
int i;
PARG p;
@@ -732,23 +716,7 @@ opt_x(type, s)
{
case INIT:
case TOGGLE:
- /* Start at 1 because tabstops[0] is always zero. */
- for (i = 1; i < TABSTOP_MAX; )
- {
- int n = 0;
- s = skipsp(s);
- while (*s >= '0' && *s <= '9')
- n = (10 * n) + (*s++ - '0');
- if (n > tabstops[i-1])
- tabstops[i++] = n;
- s = skipsp(s);
- if (*s++ != ',')
- break;
- }
- if (i < 2)
- return;
- ntabstops = i;
- tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2];
+ set_tabs(s, strlen(s));
break;
case QUERY:
strcpy(msg, "Tab stops ");
@@ -774,10 +742,7 @@ opt_x(type, s)
/*
* Handler for the -" option.
*/
- public void
-opt_quote(type, s)
- int type;
- char *s;
+public void opt_quote(int type, char *s)
{
char buf[3];
PARG parg;
@@ -816,10 +781,7 @@ opt_quote(type, s)
* Handler for the --rscroll option.
*/
/*ARGSUSED*/
- public void
-opt_rscroll(type, s)
- int type;
- char *s;
+public void opt_rscroll(int type, char *s)
{
PARG p;
@@ -829,7 +791,7 @@ opt_rscroll(type, s)
case TOGGLE: {
char *fmt;
int attr = AT_STANDOUT;
- setfmt(s, &fmt, &attr, "*s>");
+ setfmt(s, &fmt, &attr, "*s>", FALSE);
if (strcmp(fmt, "-") == 0)
{
rscroll_char = 0;
@@ -841,7 +803,7 @@ opt_rscroll(type, s)
break; }
case QUERY: {
p.p_string = rscroll_char ? prchar(rscroll_char) : "-";
- error("rscroll char is %s", &p);
+ error("rscroll character is %s", &p);
break; }
}
}
@@ -851,10 +813,7 @@ opt_rscroll(type, s)
* If from the command line, exit immediately.
*/
/*ARGSUSED*/
- public void
-opt_query(type, s)
- int type;
- char *s;
+public void opt_query(int type, char *s)
{
switch (type)
{
@@ -871,10 +830,7 @@ opt_query(type, s)
* Handler for the --mouse option.
*/
/*ARGSUSED*/
- public void
-opt_mousecap(type, s)
- int type;
- char *s;
+public void opt_mousecap(int type, char *s)
{
switch (type)
{
@@ -894,10 +850,7 @@ opt_mousecap(type, s)
* Handler for the --wheel-lines option.
*/
/*ARGSUSED*/
- public void
-opt_wheel_lines(type, s)
- int type;
- char *s;
+public void opt_wheel_lines(int type, char *s)
{
switch (type)
{
@@ -915,10 +868,7 @@ opt_wheel_lines(type, s)
* Handler for the --line-number-width option.
*/
/*ARGSUSED*/
- public void
-opt_linenum_width(type, s)
- int type;
- char *s;
+public void opt_linenum_width(int type, char *s)
{
PARG parg;
@@ -942,10 +892,7 @@ opt_linenum_width(type, s)
* Handler for the --status-column-width option.
*/
/*ARGSUSED*/
- public void
-opt_status_col_width(type, s)
- int type;
- char *s;
+public void opt_status_col_width(int type, char *s)
{
PARG parg;
@@ -969,10 +916,7 @@ opt_status_col_width(type, s)
* Handler for the --file-size option.
*/
/*ARGSUSED*/
- public void
-opt_filesize(type, s)
- int type;
- char *s;
+public void opt_filesize(int type, char *s)
{
switch (type)
{
@@ -987,13 +931,33 @@ opt_filesize(type, s)
}
/*
+ * Handler for the --intr option.
+ */
+ /*ARGSUSED*/
+public void opt_intr(int type, char *s)
+{
+ PARG p;
+
+ switch (type)
+ {
+ case INIT:
+ case TOGGLE:
+ intr_char = *s;
+ if (intr_char == '^' && s[1] != '\0')
+ intr_char = CONTROL(s[1]);
+ break;
+ case QUERY: {
+ p.p_string = prchar(intr_char);
+ error("interrupt character is %s", &p);
+ break; }
+ }
+}
+
+/*
* Handler for the --header option.
*/
/*ARGSUSED*/
- public void
-opt_header(type, s)
- int type;
- char *s;
+public void opt_header(int type, char *s)
{
int err;
int n;
@@ -1002,22 +966,26 @@ opt_header(type, s)
{
case INIT:
case TOGGLE:
- n = getnum(&s, "header", &err);
- if (err)
- error("invalid number of lines", NULL_PARG);
- else
+ header_lines = 0;
+ header_cols = 0;
+ if (*s != ',')
{
- header_lines = n;
- header_cols = 0;
- if (*s == ',')
+ n = getnum(&s, "header", &err);
+ if (err)
{
- ++s;
- n = getnum(&s, "header", &err);
- if (err)
- error("invalid number of columns", NULL_PARG);
- else
- header_cols = n;
+ error("invalid number of lines", NULL_PARG);
+ return;
}
+ header_lines = n;
+ }
+ if (*s == ',')
+ {
+ ++s;
+ n = getnum(&s, "header", &err);
+ if (err)
+ error("invalid number of columns", NULL_PARG);
+ else
+ header_cols = n;
}
break;
case QUERY:
@@ -1036,15 +1004,13 @@ opt_header(type, s)
* Handler for the --search-options option.
*/
/*ARGSUSED*/
- public void
-opt_search_type(type, s)
- int type;
- char *s;
+public void opt_search_type(int type, char *s)
{
int st;
PARG parg;
char buf[16];
char *bp;
+ int i;
switch (type)
{
@@ -1064,6 +1030,11 @@ opt_search_type(type, s)
case '-': st = 0; break;
case '^': break;
default:
+ if (*s >= '1' && *s <= '0'+NUM_SEARCH_COLORS)
+ {
+ st |= SRCH_SUBSEARCH(*s-'0');
+ break;
+ }
parg.p_char = *s;
error("invalid search option '%c'", &parg);
return;
@@ -1079,6 +1050,9 @@ opt_search_type(type, s)
if (def_search_type & SRCH_NO_MATCH) *bp++ = 'N';
if (def_search_type & SRCH_NO_REGEX) *bp++ = 'R';
if (def_search_type & SRCH_WRAP) *bp++ = 'W';
+ for (i = 1; i <= NUM_SEARCH_COLORS; i++)
+ if (def_search_type & SRCH_SUBSEARCH(i))
+ *bp++ = '0'+i;
if (bp == buf)
*bp++ = '-';
*bp = '\0';
@@ -1093,10 +1067,7 @@ opt_search_type(type, s)
* Handler for the --tty option.
*/
/*ARGSUSED*/
- public void
-opt_ttyin_name(type, s)
- int type;
- char *s;
+public void opt_ttyin_name(int type, char *s)
{
switch (type)
{
@@ -1106,33 +1077,9 @@ opt_ttyin_name(type, s)
break;
}
}
-
-/*
- * Handler for the --rstat option.
- */
- /*ARGSUSED*/
- public void
-opt_rstat(type, s)
- int type;
- char *s;
-{
- switch (type)
- {
- case INIT:
- rstat_file = open(s, O_WRONLY|O_CREAT, 0664);
- if (rstat_file < 0)
- {
- PARG parg;
- parg.p_string = s;
- error("Cannot create rstat file \"%s\"", &parg);
- }
- break;
- }
-}
#endif /*LESSTEST*/
- public int
-chop_line(VOID_PARAM)
+public int chop_line(void)
{
return (chopline || header_cols > 0 || header_lines > 0);
}
@@ -1140,8 +1087,7 @@ chop_line(VOID_PARAM)
/*
* Get the "screen window" size.
*/
- public int
-get_swindow(VOID_PARAM)
+public int get_swindow(void)
{
if (swindow > 0)
return (swindow);
diff --git a/option.c b/option.c
index c4a496eddb4d..c0fbb566c12a 100644
--- a/option.c
+++ b/option.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -23,8 +23,8 @@
static struct loption *pendopt;
public int plusoption = FALSE;
-static char *optstring LESSPARAMS((char *s, char **p_str, char *printopt, char *validchars));
-static int flip_triple LESSPARAMS((int val, int lc));
+static char *optstring(char *s, char **p_str, char *printopt, char *validchars);
+static int flip_triple(int val, int lc);
extern int screen_trashed;
extern int less_is_more;
@@ -35,9 +35,7 @@ extern int opt_use_backslash;
/*
* Return a printable description of an option.
*/
- static char *
-opt_desc(o)
- struct loption *o;
+static char * opt_desc(struct loption *o)
{
static char buf[OPTNAME_MAX + 10];
if (o->oletter == OLETTER_NONE)
@@ -51,9 +49,7 @@ opt_desc(o)
* Return a string suitable for printing as the "name" of an option.
* For example, if the option letter is 'x', just return "-x".
*/
- public char *
-propt(c)
- int c;
+public char * propt(int c)
{
static char buf[MAX_PRCHAR_LEN+2];
@@ -65,9 +61,7 @@ propt(c)
* Scan an argument (either from the command line or from the
* LESS environment variable) and process it.
*/
- public void
-scan_option(s)
- char *s;
+public void scan_option(char *s)
{
struct loption *o;
int optc;
@@ -301,12 +295,7 @@ scan_option(s)
* OPT_UNSET set to the default value
* OPT_SET set to the inverse of the default value
*/
- public void
-toggle_option(o, lower, s, how_toggle)
- struct loption *o;
- int lower;
- char *s;
- int how_toggle;
+public void toggle_option(struct loption *o, int lower, char *s, int how_toggle)
{
int num;
int no_prompt;
@@ -487,10 +476,7 @@ toggle_option(o, lower, s, how_toggle)
/*
* "Toggle" a triple-valued option.
*/
- static int
-flip_triple(val, lc)
- int val;
- int lc;
+static int flip_triple(int val, int lc)
{
if (lc)
return ((val == OPT_ON) ? OPT_OFF : OPT_ON);
@@ -501,9 +487,7 @@ flip_triple(val, lc)
/*
* Determine if an option takes a parameter.
*/
- public int
-opt_has_param(o)
- struct loption *o;
+public int opt_has_param(struct loption *o)
{
if (o == NULL)
return (0);
@@ -516,9 +500,7 @@ opt_has_param(o)
* Return the prompt to be used for a given option letter.
* Only string and number valued options have prompts.
*/
- public char *
-opt_prompt(o)
- struct loption *o;
+public char * opt_prompt(struct loption *o)
{
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
return ("?");
@@ -529,9 +511,7 @@ opt_prompt(o)
* If the specified option can be toggled, return NULL.
* Otherwise return an appropriate error message.
*/
- public char *
-opt_toggle_disallowed(c)
- int c;
+public char * opt_toggle_disallowed(int c)
{
switch (c)
{
@@ -550,8 +530,7 @@ opt_toggle_disallowed(c)
* In that case, the current option is taken to be the string for
* the previous option.
*/
- public int
-isoptpending(VOID_PARAM)
+public int isoptpending(void)
{
return (pendopt != NULL);
}
@@ -559,9 +538,7 @@ isoptpending(VOID_PARAM)
/*
* Print error message about missing string.
*/
- static void
-nostring(printopt)
- char *printopt;
+static void nostring(char *printopt)
{
PARG parg;
parg.p_string = printopt;
@@ -571,8 +548,7 @@ nostring(printopt)
/*
* Print error message if a STRING type option is not followed by a string.
*/
- public void
-nopendopt(VOID_PARAM)
+public void nopendopt(void)
{
nostring(opt_desc(pendopt));
}
@@ -582,12 +558,7 @@ nopendopt(VOID_PARAM)
* In the latter case, replace the char with a null char.
* Return a pointer to the remainder of the string, if any.
*/
- static char *
-optstring(s, p_str, printopt, validchars)
- char *s;
- char **p_str;
- char *printopt;
- char *validchars;
+static char * optstring(char *s, char **p_str, char *printopt, char *validchars)
{
char *p;
char *out;
@@ -622,10 +593,7 @@ optstring(s, p_str, printopt, validchars)
/*
*/
- static int
-num_error(printopt, errp)
- char *printopt;
- int *errp;
+static int num_error(char *printopt, int *errp, int overflow)
{
PARG parg;
@@ -637,7 +605,10 @@ num_error(printopt, errp)
if (printopt != NULL)
{
parg.p_string = printopt;
- error("Number is required after %s", &parg);
+ error((overflow
+ ? "Number too large in '%s'"
+ : "Number is required after %s"),
+ &parg);
}
return (-1);
}
@@ -647,11 +618,7 @@ num_error(printopt, errp)
* Like atoi(), but takes a pointer to a char *, and updates
* the char * to point after the translated number.
*/
- public int
-getnum(sp, printopt, errp)
- char **sp;
- char *printopt;
- int *errp;
+public int getnum(char **sp, char *printopt, int *errp)
{
char *s;
int n;
@@ -665,12 +632,11 @@ getnum(sp, printopt, errp)
s++;
}
if (*s < '0' || *s > '9')
- return (num_error(printopt, errp));
+ return (num_error(printopt, errp, FALSE));
- n = 0;
- while (*s >= '0' && *s <= '9')
- n = 10 * n + *s++ - '0';
- *sp = s;
+ n = lstrtoi(s, sp, 10);
+ if (n < 0)
+ return (num_error(printopt, errp, TRUE));
if (errp != NULL)
*errp = FALSE;
if (neg)
@@ -684,11 +650,7 @@ getnum(sp, printopt, errp)
* The value of the fraction is returned as parts per NUM_FRAC_DENOM.
* That is, if "n" is returned, the fraction intended is n/NUM_FRAC_DENOM.
*/
- public long
-getfraction(sp, printopt, errp)
- char **sp;
- char *printopt;
- int *errp;
+public long getfraction(char **sp, char *printopt, int *errp)
{
char *s;
long frac = 0;
@@ -696,19 +658,17 @@ getfraction(sp, printopt, errp)
s = skipsp(*sp);
if (*s < '0' || *s > '9')
- return (num_error(printopt, errp));
+ return (num_error(printopt, errp, FALSE));
for ( ; *s >= '0' && *s <= '9'; s++)
{
+ if (NUM_LOG_FRAC_DENOM <= fraclen)
+ continue;
frac = (frac * 10) + (*s - '0');
fraclen++;
}
- if (fraclen > NUM_LOG_FRAC_DENOM)
- while (fraclen-- > NUM_LOG_FRAC_DENOM)
- frac /= 10;
- else
- while (fraclen++ < NUM_LOG_FRAC_DENOM)
- frac *= 10;
+ while (fraclen++ < NUM_LOG_FRAC_DENOM)
+ frac *= 10;
*sp = s;
if (errp != NULL)
*errp = FALSE;
@@ -719,8 +679,7 @@ getfraction(sp, printopt, errp)
/*
* Get the value of the -e flag.
*/
- public int
-get_quit_at_eof(VOID_PARAM)
+public int get_quit_at_eof(void)
{
if (!less_is_more)
return quit_at_eof;
diff --git a/option.h b/option.h
index 2ed238323874..afde744c591a 100644
--- a/option.h
+++ b/option.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -60,7 +60,7 @@ struct loption
int otype; /* Type of the option */
int odefault; /* Default value */
int *ovar; /* Pointer to the associated variable */
- void (*ofunc) LESSPARAMS ((int, char*)); /* Pointer to special handling function */
+ void (*ofunc)(int, char*); /* Pointer to special handling function */
char *odesc[3]; /* Description of each value */
};
diff --git a/opttbl.c b/opttbl.c
index 6da2b305b820..9e4aa2aaae6b 100644
--- a/opttbl.c
+++ b/opttbl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -19,6 +19,7 @@
* Variables controlled by command line options.
*/
public int quiet; /* Should we suppress the audible bell? */
+public int no_vbell; /* Should we suppress the visual bell? */
public int how_search; /* Where should forward searches start? */
public int top_scroll; /* Repaint screen from top?
(alternative is scroll from bottom) */
@@ -42,6 +43,7 @@ public int jump_sline; /* Screen line of "jump target" */
public long jump_sline_fraction = -1;
public long shift_count_fraction = -1;
public int chopline; /* Truncate displayed lines at screen width */
+public int wordwrap; /* Wrap lines at space */
public int no_init; /* Disable sending ti/te termcap strings */
public int no_keypad; /* Disable sending ks/ke termcap strings */
public int twiddle; /* Show tildes after EOF */
@@ -68,9 +70,16 @@ public int status_line; /* Highlight entire marked lines */
public int header_lines; /* Freeze header lines at top of screen */
public int header_cols; /* Freeze header columns at left of screen */
public int nonum_headers; /* Don't give headers line numbers */
+public int nosearch_headers; /* Don't search in header lines or columns */
public int redraw_on_quit; /* Redraw last screen after term deinit */
public int def_search_type; /* */
public int exit_F_on_close; /* Exit F command when input closes */
+public int modelines; /* Lines to read looking for modelines */
+public int show_preproc_error; /* Display msg when preproc exits with error */
+public int proc_backspace; /* Special handling of backspace */
+public int proc_tab; /* Special handling of tab */
+public int proc_return; /* Special handling of carriage return */
+public char intr_char = CONTROL('X'); /* Char to interrupt reads */
#if HILITE_SEARCH
public int hilite_search; /* Highlight matched search patterns? */
#endif
@@ -149,12 +158,20 @@ static struct optname want_filesize_optname = { "file-size", NULL };
static struct optname status_line_optname = { "status-line", NULL };
static struct optname header_optname = { "header", NULL };
static struct optname nonum_headers_optname = { "no-number-headers", NULL };
+static struct optname nosearch_headers_optname = { "no-search-headers", NULL };
static struct optname redraw_on_quit_optname = { "redraw-on-quit", NULL };
static struct optname search_type_optname = { "search-options", NULL };
static struct optname exit_F_on_close_optname = { "exit-follow-on-close", NULL };
+static struct optname modelines_optname = { "modelines", NULL };
+static struct optname no_vbell_optname = { "no-vbell", NULL };
+static struct optname intr_optname = { "intr", NULL };
+static struct optname wordwrap_optname = { "wordwrap", NULL };
+static struct optname show_preproc_error_optname = { "show-preproc-errors", NULL };
+static struct optname proc_backspace_optname = { "proc-backspace", NULL };
+static struct optname proc_tab_optname = { "proc-tab", NULL };
+static struct optname proc_return_optname = { "proc-return", NULL };
#if LESSTEST
static struct optname ttyin_name_optname = { "tty", NULL };
-static struct optname rstat_optname = { "rstat", NULL };
#endif /*LESSTEST*/
@@ -392,7 +409,7 @@ static struct loption option[] =
},
#endif
{ 'u', &u_optname,
- TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
+ TRIPLE|REPAINT|HL_REPAINT, OPT_OFF, &bs_mode, NULL,
{
"Display underlined text in underline mode",
"Backspaces cause overstrike",
@@ -501,7 +518,7 @@ static struct loption option[] =
},
{ OLETTER_NONE, &rscroll_optname,
STRING|REPAINT|INIT_HANDLER, 0, NULL, opt_rscroll,
- { "right scroll character: ", NULL, NULL }
+ { "rscroll character: ", NULL, NULL }
},
{ OLETTER_NONE, &nohistdups_optname,
BOOL, OPT_OFF, &no_hist_dups, NULL,
@@ -599,6 +616,14 @@ static struct loption option[] =
NULL
}
},
+ { OLETTER_NONE, &nosearch_headers_optname,
+ BOOL|HL_REPAINT, 0, &nosearch_headers, NULL,
+ {
+ "Search includes header lines",
+ "Search does not include header lines",
+ NULL
+ }
+ },
{ OLETTER_NONE, &redraw_on_quit_optname,
BOOL, OPT_OFF, &redraw_on_quit, NULL,
{
@@ -623,17 +648,69 @@ static struct loption option[] =
NULL
}
},
-#if LESSTEST
- { OLETTER_NONE, &ttyin_name_optname,
- STRING|NO_TOGGLE, 0, NULL, opt_ttyin_name,
+ { OLETTER_NONE, &no_vbell_optname,
+ BOOL, OPT_OFF, &no_vbell, NULL,
{
- NULL,
- NULL,
+ "Display visual bell",
+ "Don't display visual bell",
+ NULL
+ }
+ },
+ { OLETTER_NONE, &modelines_optname,
+ NUMBER, 0, &modelines, NULL,
+ {
+ "Lines to read looking for modelines: ",
+ "Read %d lines looking for modelines",
+ NULL
+ }
+ },
+ { OLETTER_NONE, &intr_optname,
+ STRING, 0, NULL, opt_intr,
+ { "interrupt character: ", NULL, NULL }
+ },
+ { OLETTER_NONE, &wordwrap_optname,
+ BOOL|REPAINT, OPT_OFF, &wordwrap, NULL,
+ {
+ "Wrap lines at any character",
+ "Wrap lines at spaces",
+ NULL
+ }
+ },
+ { OLETTER_NONE, &show_preproc_error_optname,
+ BOOL, OPT_OFF, &show_preproc_error, NULL,
+ {
+ "Don't show error message if preprocessor fails",
+ "Show error message if preprocessor fails",
NULL
}
},
- { OLETTER_NONE, &rstat_optname,
- STRING|NO_TOGGLE, 0, NULL, opt_rstat,
+ { OLETTER_NONE, &proc_backspace_optname,
+ TRIPLE|REPAINT|HL_REPAINT, OPT_OFF, &proc_backspace, NULL,
+ {
+ "Backspace handling is specified by the -U option",
+ "Display underline text in underline mode",
+ "Print backspaces as ^H"
+ }
+ },
+ { OLETTER_NONE, &proc_tab_optname,
+ TRIPLE|REPAINT|HL_REPAINT, OPT_OFF, &proc_tab, NULL,
+ {
+ "Tab handling is specified by the -U option",
+ "Expand tabs to spaces",
+ "Print tabs as ^I"
+ }
+ },
+ { OLETTER_NONE, &proc_return_optname,
+ TRIPLE|REPAINT|HL_REPAINT, OPT_OFF, &proc_return, NULL,
+ {
+ "Carriage return handling is specified by the -U option",
+ "Delete carriage return before newline",
+ "Print carriage return as ^M"
+ }
+ },
+#if LESSTEST
+ { OLETTER_NONE, &ttyin_name_optname,
+ STRING|NO_TOGGLE, 0, NULL, opt_ttyin_name,
{
NULL,
NULL,
@@ -648,8 +725,7 @@ static struct loption option[] =
/*
* Initialize each option to its default value.
*/
- public void
-init_option(VOID_PARAM)
+public void init_option(void)
{
struct loption *o;
char *p;
@@ -673,9 +749,7 @@ init_option(VOID_PARAM)
/*
* Find an option in the option table, given its option letter.
*/
- public struct loption *
-findopt(c)
- int c;
+public struct loption * findopt(int c)
{
struct loption *o;
@@ -692,9 +766,7 @@ findopt(c)
/*
*
*/
- static int
-is_optchar(c)
- char c;
+static int is_optchar(char c)
{
if (ASCII_IS_UPPER(c))
return 1;
@@ -711,11 +783,7 @@ is_optchar(c)
* is updated to point after the matched name.
* p_oname if non-NULL is set to point to the full option name.
*/
- public struct loption *
-findopt_name(p_optname, p_oname, p_err)
- char **p_optname;
- char **p_oname;
- int *p_err;
+public struct loption * findopt_name(char **p_optname, char **p_oname, int *p_err)
{
char *optname = *p_optname;
struct loption *o;
diff --git a/os.c b/os.c
index 22b97de34b1c..56e3bf32ec9e 100644
--- a/os.c
+++ b/os.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -36,8 +36,13 @@
#include <values.h>
#endif
-#if HAVE_POLL && !MSDOS_COMPILER && !defined(__APPLE__)
+#if defined(__APPLE__)
+#include <sys/utsname.h>
+#endif
+
+#if HAVE_POLL && !MSDOS_COMPILER
#define USE_POLL 1
+static int use_poll = TRUE;
#else
#define USE_POLL 0
#endif
@@ -61,44 +66,93 @@
#endif
public int reading;
+public int waiting_for_data;
public int consecutive_nulls = 0;
+/* Milliseconds to wait for data before displaying "waiting for data" message. */
+static int waiting_for_data_delay = 4000;
static jmp_buf read_label;
extern int sigs;
extern int ignore_eoi;
extern int exit_F_on_close;
+extern int follow_mode;
+extern int scanning_eof;
+extern char intr_char;
#if !MSDOS_COMPILER
extern int tty;
#endif
+#if LESSTEST
+extern char *ttyin_name;
+#endif /*LESSTEST*/
+
+public void init_poll(void)
+{
+ char *delay = lgetenv("LESS_DATA_DELAY");
+ int idelay = (delay == NULL) ? 0 : atoi(delay);
+ if (idelay > 0)
+ waiting_for_data_delay = idelay;
+#if USE_POLL
+#if defined(__APPLE__)
+ /* In old versions of MacOS, poll() does not work with /dev/tty. */
+ struct utsname uts;
+ if (uname(&uts) < 0 || lstrtoi(uts.release, NULL, 10) < 20)
+ use_poll = FALSE;
+#endif
+#endif
+}
#if USE_POLL
/*
- * Return true if one of the events has occurred on the specified file.
+ * Check whether data is available, either from a file/pipe or from the tty.
+ * Return READ_AGAIN if no data currently available, but caller should retry later.
+ * Return READ_INTR to abort F command (forw_loop).
+ * Return 0 if safe to read from fd.
*/
- static int
-poll_events(fd, events)
- int fd;
- int events;
+static int check_poll(int fd, int tty)
{
- struct pollfd poller = { fd, events, 0 };
- int n = poll(&poller, 1, 0);
- if (n <= 0)
- return 0;
- return (poller.revents & events);
+ struct pollfd poller[2] = { { fd, POLLIN, 0 }, { tty, POLLIN, 0 } };
+ int timeout = (waiting_for_data && !(scanning_eof && follow_mode == FOLLOW_NAME)) ? -1 : waiting_for_data_delay;
+ poll(poller, 2, timeout);
+#if LESSTEST
+ if (ttyin_name == NULL) /* Check for ^X only on a real tty. */
+#endif /*LESSTEST*/
+ {
+ if (poller[1].revents & POLLIN)
+ {
+ LWCHAR ch = getchr();
+ if (ch == intr_char)
+ /* Break out of "waiting for data". */
+ return (READ_INTR);
+ ungetcc_back(ch);
+ }
+ }
+ if (ignore_eoi && exit_F_on_close && (poller[0].revents & (POLLHUP|POLLIN)) == POLLHUP)
+ /* Break out of F loop on HUP due to --exit-follow-on-close. */
+ return (READ_INTR);
+ if ((poller[0].revents & (POLLIN|POLLHUP|POLLERR)) == 0)
+ /* No data available; let caller take action, then try again. */
+ return (READ_AGAIN);
+ /* There is data (or HUP/ERR) available. Safe to call read() without blocking. */
+ return (0);
+}
+#endif /* USE_POLL */
+
+public int supports_ctrl_x(void)
+{
+#if USE_POLL
+ return (use_poll);
+#else
+ return (FALSE);
+#endif /* USE_POLL */
}
-#endif
/*
* Like read() system call, but is deliberately interruptible.
* A call to intread() from a signal handler will interrupt
* any pending iread().
*/
- public int
-iread(fd, buf, len)
- int fd;
- unsigned char *buf;
- unsigned int len;
+public int iread(int fd, unsigned char *buf, unsigned int len)
{
int n;
@@ -119,7 +173,7 @@ start:
}
#endif
#endif
- if (SET_JUMP(read_label))
+ if (!reading && SET_JUMP(read_label))
{
/*
* We jumped here from intread.
@@ -153,6 +207,7 @@ start:
* available, because that makes some background programs
* believe DOS is busy in a way that prevents those
* programs from working while "less" waits.
+ * {{ This code was added 12 Jan 2007; still needed? }}
*/
fd_set readfds;
@@ -161,30 +216,25 @@ start:
if (select(fd+1, &readfds, 0, 0, 0) == -1)
{
reading = 0;
- return (-1);
+ return (READ_ERR);
}
}
#endif
#if USE_POLL
- if (ignore_eoi && fd != tty)
+ if (fd != tty && use_poll)
{
- int close_events = exit_F_on_close ? POLLERR|POLLHUP : POLLERR;
- if (poll_events(tty, POLLIN) && getchr() == CONTROL('X'))
+ int ret = check_poll(fd, tty);
+ if (ret != 0)
{
- sigs |= S_INTERRUPT;
+ if (ret == READ_INTR)
+ sigs |= S_INTERRUPT;
reading = 0;
- return (READ_INTR);
- }
- if (poll_events(fd, close_events))
- {
- sigs |= S_INTERRUPT;
- reading = 0;
- return (READ_INTR);
+ return (ret);
}
}
#else
#if MSDOS_COMPILER==WIN32C
- if (win32_kbhit() && WIN32getch() == CONTROL('X'))
+ if (win32_kbhit() && WIN32getch() == intr_char)
{
sigs |= S_INTERRUPT;
reading = 0;
@@ -230,7 +280,7 @@ start:
goto start;
#endif
#endif
- return (-1);
+ return (READ_ERR);
}
return (n);
}
@@ -238,8 +288,7 @@ start:
/*
* Interrupt a pending iread().
*/
- public void
-intread(VOID_PARAM)
+public void intread(void)
{
LONG_JUMP(read_label, 1);
}
@@ -248,8 +297,7 @@ intread(VOID_PARAM)
* Return the current time.
*/
#if HAVE_TIME
- public time_type
-get_time(VOID_PARAM)
+public time_type get_time(void)
{
time_type t;
@@ -263,9 +311,7 @@ get_time(VOID_PARAM)
/*
* Local version of strerror, if not available from the system.
*/
- static char *
-strerror(err)
- int err;
+static char * strerror(int err)
{
static char buf[INT_STRLEN_BOUND(int)+12];
#if HAVE_SYS_ERRLIST
@@ -283,9 +329,7 @@ strerror(err)
/*
* errno_message: Return an error message based on the value of "errno".
*/
- public char *
-errno_message(filename)
- char *filename;
+public char * errno_message(char *filename)
{
char *p;
char *m;
@@ -304,65 +348,73 @@ errno_message(filename)
return (m);
}
-/* #define HAVE_FLOAT 0 */
-
- static POSITION
-muldiv(val, num, den)
- POSITION val, num, den;
+/*
+ * Return a description of a signal.
+ * The return value is good until the next call to this function.
+ */
+public char * signal_message(int sig)
{
-#if HAVE_FLOAT
- double v = (((double) val) * num) / den;
- return ((POSITION) (v + 0.5));
-#else
- POSITION v = ((POSITION) val) * num;
+ static char sigbuf[sizeof("Signal ") + INT_STRLEN_BOUND(sig) + 1];
+#if HAVE_STRSIGNAL
+ char *description = strsignal(sig);
+ if (description)
+ return description;
+#endif
+ sprintf(sigbuf, "Signal %d", sig);
+ return sigbuf;
+}
- if (v / num == val)
- /* No overflow */
- return (POSITION) (v / den);
- else
- /* Above calculation overflows;
- * use a method that is less precise but won't overflow. */
- return (POSITION) (val / (den / num));
-#endif
+/*
+ * Return (VAL * NUM) / DEN, where DEN is positive
+ * and min(VAL, NUM) <= DEN so the result cannot overflow.
+ * Round to the nearest integer, breaking ties by rounding to even.
+ */
+public uintmax muldiv(uintmax val, uintmax num, uintmax den)
+{
+ /*
+ * Like round(val * (double) num / den), but without rounding error.
+ * Overflow cannot occur, so there is no need for floating point.
+ */
+ uintmax q = val / den;
+ uintmax r = val % den;
+ uintmax qnum = q * num;
+ uintmax rnum = r * num;
+ uintmax quot = qnum + rnum / den;
+ uintmax rem = rnum % den;
+ return quot + (den / 2 < rem + (quot & ~den & 1));
}
/*
* Return the ratio of two POSITIONS, as a percentage.
* {{ Assumes a POSITION is a long int. }}
*/
- public int
-percentage(num, den)
- POSITION num;
- POSITION den;
+public int percentage(POSITION num, POSITION den)
{
return (int) muldiv(num, (POSITION) 100, den);
}
/*
* Return the specified percentage of a POSITION.
+ * Assume (0 <= POS && 0 <= PERCENT <= 100
+ * && 0 <= FRACTION < (PERCENT == 100 ? 1 : NUM_FRAC_DENOM)),
+ * so the result cannot overflow. Round to even.
*/
- public POSITION
-percent_pos(pos, percent, fraction)
- POSITION pos;
- int percent;
- long fraction;
+public POSITION percent_pos(POSITION pos, int percent, long fraction)
{
- /* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
- POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
+ /*
+ * Change from percent (parts per 100)
+ * to pctden (parts per 100 * NUM_FRAC_DENOM).
+ */
+ POSITION pctden = (percent * NUM_FRAC_DENOM) + fraction;
- if (perden == 0)
- return (0);
- return (POSITION) muldiv(pos, perden, (POSITION) NUM_FRAC_DENOM);
+ return (POSITION) muldiv(pos, pctden, 100 * (POSITION) NUM_FRAC_DENOM);
}
#if !HAVE_STRCHR
/*
* strchr is used by regexp.c.
*/
- char *
-strchr(s, c)
- char *s;
- int c;
+char * strchr(char *s, char c)
{
for ( ; *s != '\0'; s++)
if (*s == c)
@@ -374,11 +426,7 @@ strchr(s, c)
#endif
#if !HAVE_MEMCPY
- VOID_POINTER
-memcpy(dst, src, len)
- VOID_POINTER dst;
- VOID_POINTER src;
- int len;
+void * memcpy(void *dst, void *src, int len)
{
char *dstp = (char *) dst;
char *srcp = (char *) src;
@@ -395,19 +443,14 @@ memcpy(dst, src, len)
/*
* This implements an ANSI-style intercept setup for Microware C 3.2
*/
- public int
-os9_signal(type, handler)
- int type;
- RETSIGTYPE (*handler)();
+public int os9_signal(int type, RETSIGTYPE (*handler)())
{
intercept(handler);
}
#include <sgstat.h>
- int
-isatty(f)
- int f;
+int isatty(int f)
{
struct sgbuf sgbuf;
@@ -418,9 +461,7 @@ isatty(f)
#endif
- public void
-sleep_ms(ms)
- int ms;
+public void sleep_ms(int ms)
{
#if MSDOS_COMPILER==WIN32C
Sleep(ms);
@@ -433,7 +474,7 @@ sleep_ms(ms)
#if HAVE_USLEEP
usleep(ms);
#else
- sleep((ms+999) / 1000);
+ sleep(ms / 1000 + (ms % 1000 != 0));
#endif
#endif
#endif
diff --git a/output.c b/output.c
index 3fed3df3ad33..8a69d29d4b07 100644
--- a/output.c
+++ b/output.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -31,6 +31,7 @@ extern int so_s_width, so_e_width;
extern int screen_trashed;
extern int is_tty;
extern int oldbot;
+extern char intr_char;
#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
extern int ctldisp;
@@ -48,8 +49,7 @@ extern int vt_enabled;
/*
* Display the line which is in the line buffer.
*/
- public void
-put_line(VOID_PARAM)
+public void put_line(void)
{
int c;
int i;
@@ -84,8 +84,7 @@ static char *ob = obuf;
static int outfd = 2; /* stderr */
#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
- static void
-win_flush(VOID_PARAM)
+static void win_flush(void)
{
if (ctldisp != OPT_ONPLUS || (vt_enabled && sgr_mode))
WIN32textout(obuf, ob - obuf);
@@ -361,8 +360,7 @@ win_flush(VOID_PARAM)
* sure these messages can be seen before they are
* overwritten or scrolled away.
*/
- public void
-flush(VOID_PARAM)
+public void flush(void)
{
int n;
@@ -397,9 +395,7 @@ flush(VOID_PARAM)
/*
* Set the output file descriptor (1=stdout or 2=stderr).
*/
- public void
-set_output(fd)
- int fd;
+public void set_output(int fd)
{
flush();
outfd = fd;
@@ -408,9 +404,7 @@ set_output(fd)
/*
* Output a character.
*/
- public int
-putchr(c)
- int c;
+public int putchr(int c)
{
#if 0 /* fake UTF-8 output for testing */
extern int utf_mode;
@@ -455,8 +449,7 @@ putchr(c)
return (c);
}
- public void
-clear_bot_if_needed(VOID_PARAM)
+public void clear_bot_if_needed(void)
{
if (!need_clr)
return;
@@ -467,9 +460,7 @@ clear_bot_if_needed(VOID_PARAM)
/*
* Output a string.
*/
- public void
-putstr(s)
- constant char *s;
+public void putstr(constant char *s)
{
while (*s != '\0')
putchr(*s++);
@@ -480,9 +471,7 @@ putstr(s)
* Convert an integral type to a string.
*/
#define TYPE_TO_A_FUNC(funcname, type) \
-void funcname(num, buf) \
- type num; \
- char *buf; \
+void funcname(type num, char *buf, int radix) \
{ \
int neg = (num < 0); \
char tbuf[INT_STRLEN_BOUND(num)+2]; \
@@ -490,8 +479,8 @@ void funcname(num, buf) \
if (neg) num = -num; \
*--s = '\0'; \
do { \
- *--s = (num % 10) + '0'; \
- } while ((num /= 10) != 0); \
+ *--s = "0123456789ABCDEF"[num % radix]; \
+ } while ((num /= radix) != 0); \
if (neg) *--s = '-'; \
strcpy(buf, s); \
}
@@ -501,53 +490,42 @@ TYPE_TO_A_FUNC(linenumtoa, LINENUM)
TYPE_TO_A_FUNC(inttoa, int)
/*
- * Convert an string to an integral type.
+ * Convert a string to an integral type. Return ((type) -1) on overflow.
*/
#define STR_TO_TYPE_FUNC(funcname, type) \
-type funcname(buf, ebuf) \
- char *buf; \
- char **ebuf; \
+type funcname(char *buf, char **ebuf, int radix) \
{ \
type val = 0; \
+ int v = 0; \
for (;; buf++) { \
char c = *buf; \
- if (c < '0' || c > '9') break; \
- val = 10 * val + c - '0'; \
+ int digit = (c >= '0' && c <= '9') ? c - '0' : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : (c >= 'A' && c <= 'F') ? c - 'A' + 10 : -1; \
+ if (digit < 0 || digit >= radix) break; \
+ v |= ckd_mul(&val, val, radix); \
+ v |= ckd_add(&val, val, digit); \
} \
if (ebuf != NULL) *ebuf = buf; \
- return val; \
+ return v ? -1 : val; \
}
STR_TO_TYPE_FUNC(lstrtopos, POSITION)
STR_TO_TYPE_FUNC(lstrtoi, int)
+STR_TO_TYPE_FUNC(lstrtoul, unsigned long)
/*
- * Output an integer in a given radix.
+ * Print an integral type.
*/
- static int
-iprint_int(num)
- int num;
-{
- char buf[INT_STRLEN_BOUND(num)];
-
- inttoa(num, buf);
- putstr(buf);
- return ((int) strlen(buf));
+#define IPRINT_FUNC(funcname, type, typetoa) \
+static int funcname(type num, int radix) \
+{ \
+ char buf[INT_STRLEN_BOUND(num)]; \
+ typetoa(num, buf, radix); \
+ putstr(buf); \
+ return (int) strlen(buf); \
}
-/*
- * Output a line number in a given radix.
- */
- static int
-iprint_linenum(num)
- LINENUM num;
-{
- char buf[INT_STRLEN_BOUND(num)];
-
- linenumtoa(num, buf);
- putstr(buf);
- return ((int) strlen(buf));
-}
+IPRINT_FUNC(iprint_int, int, inttoa)
+IPRINT_FUNC(iprint_linenum, LINENUM, linenumtoa)
/*
* This function implements printf-like functionality
@@ -556,10 +534,7 @@ iprint_linenum(num)
* {{ This paranoia about the portability of printf dates from experiences
* with systems in the 1980s and is of course no longer necessary. }}
*/
- public int
-less_printf(fmt, parg)
- char *fmt;
- PARG *parg;
+public int less_printf(char *fmt, PARG *parg)
{
char *s;
int col;
@@ -586,11 +561,15 @@ less_printf(fmt, parg)
}
break;
case 'd':
- col += iprint_int(parg->p_int);
+ col += iprint_int(parg->p_int, 10);
+ parg++;
+ break;
+ case 'x':
+ col += iprint_int(parg->p_int, 16);
parg++;
break;
case 'n':
- col += iprint_linenum(parg->p_linenum);
+ col += iprint_linenum(parg->p_linenum, 10);
parg++;
break;
case 'c':
@@ -616,8 +595,7 @@ less_printf(fmt, parg)
* If some other non-trivial char is pressed, unget it, so it will
* become the next command.
*/
- public void
-get_return(VOID_PARAM)
+public void get_return(void)
{
int c;
@@ -635,10 +613,7 @@ get_return(VOID_PARAM)
* Output a message in the lower left corner of the screen
* and wait for carriage return.
*/
- public void
-error(fmt, parg)
- char *fmt;
- PARG *parg;
+public void error(char *fmt, PARG *parg)
{
int col = 0;
static char return_to_continue[] = " (press RETURN)";
@@ -678,37 +653,45 @@ error(fmt, parg)
flush();
}
-static char intr_to_abort[] = "... (interrupt to abort)";
-
/*
* Output a message in the lower left corner of the screen
* and don't wait for carriage return.
* Usually used to warn that we are beginning a potentially
* time-consuming operation.
*/
- public void
-ierror(fmt, parg)
- char *fmt;
- PARG *parg;
+static void ierror_suffix(char *fmt, PARG *parg, char *suffix1, char *suffix2, char *suffix3)
{
at_exit();
clear_bot();
at_enter(AT_STANDOUT|AT_COLOR_ERROR);
(void) less_printf(fmt, parg);
- putstr(intr_to_abort);
+ putstr(suffix1);
+ putstr(suffix2);
+ putstr(suffix3);
at_exit();
flush();
need_clr = 1;
}
+public void ierror(char *fmt, PARG *parg)
+{
+ ierror_suffix(fmt, parg, "... (interrupt to abort)", "", "");
+}
+
+public void ixerror(char *fmt, PARG *parg)
+{
+ if (!supports_ctrl_x())
+ ierror(fmt, parg);
+ else
+ ierror_suffix(fmt, parg,
+ "... (", prchar(intr_char), " or interrupt to abort)");
+}
+
/*
* Output a message in the lower left corner of the screen
* and return a single-character response.
*/
- public int
-query(fmt, parg)
- char *fmt;
- PARG *parg;
+public int query(char *fmt, PARG *parg)
{
int c;
int col = 0;
diff --git a/pattern.c b/pattern.c
index bed36dfd57d1..ed453740b141 100644
--- a/pattern.c
+++ b/pattern.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -20,12 +20,7 @@ extern int utf_mode;
/*
* Compile a search pattern, for future use by match_pattern.
*/
- static int
-compile_pattern2(pattern, search_type, comp_pattern, show_error)
- char *pattern;
- int search_type;
- PATTERN_TYPE *comp_pattern;
- int show_error;
+static int compile_pattern2(char *pattern, int search_type, PATTERN_TYPE *comp_pattern, int show_error)
{
if (search_type & SRCH_NO_REGEX)
return (0);
@@ -147,17 +142,12 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error)
/*
* Like compile_pattern2, but convert the pattern to lowercase if necessary.
*/
- public int
-compile_pattern(pattern, search_type, show_error, comp_pattern)
- char *pattern;
- int search_type;
- int show_error;
- PATTERN_TYPE *comp_pattern;
+public int compile_pattern(char *pattern, int search_type, int show_error, PATTERN_TYPE *comp_pattern)
{
char *cvt_pattern;
int result;
- if (caseless != OPT_ONPLUS || re_handles_caseless)
+ if (caseless != OPT_ONPLUS || (re_handles_caseless && !(search_type & SRCH_NO_REGEX)))
cvt_pattern = pattern;
else
{
@@ -173,9 +163,7 @@ compile_pattern(pattern, search_type, show_error, comp_pattern)
/*
* Forget that we have a compiled pattern.
*/
- public void
-uncompile_pattern(pattern)
- PATTERN_TYPE *pattern;
+public void uncompile_pattern(PATTERN_TYPE *pattern)
{
#if HAVE_GNU_REGEX
if (*pattern != NULL)
@@ -222,9 +210,7 @@ uncompile_pattern(pattern)
/*
* Can a pattern be successfully compiled?
*/
- public int
-valid_pattern(pattern)
- char *pattern;
+public int valid_pattern(char *pattern)
{
PATTERN_TYPE comp_pattern;
int result;
@@ -241,9 +227,7 @@ valid_pattern(pattern)
/*
* Is a compiled pattern null?
*/
- public int
-is_null_pattern(pattern)
- PATTERN_TYPE pattern;
+public int is_null_pattern(PATTERN_TYPE pattern)
{
#if HAVE_GNU_REGEX
return (pattern == NULL);
@@ -270,18 +254,11 @@ is_null_pattern(pattern)
return (pattern == NULL);
#endif
}
-
/*
* Simple pattern matching function.
* It supports no metacharacters like *, etc.
*/
- static int
-match(pattern, pattern_len, buf, buf_len, pfound, pend)
- char *pattern;
- int pattern_len;
- char *buf;
- int buf_len;
- char **pfound, **pend;
+static int match(char *pattern, int pattern_len, char *buf, int buf_len, char ***sp, char ***ep, int nsubs)
{
char *pp, *lp;
char *pattern_end = pattern + pattern_len;
@@ -302,39 +279,30 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend)
}
if (pp == pattern_end)
{
- if (pfound != NULL)
- *pfound = buf;
- if (pend != NULL)
- *pend = lp;
+ *(*sp)++ = buf;
+ *(*ep)++ = lp;
return (1);
}
}
+ **sp = **ep = NULL;
return (0);
}
/*
* Perform a pattern match with the previously compiled pattern.
- * Set sp and ep to the start and end of the matched string.
+ * Set sp[0] and ep[0] to the start and end of the matched string.
+ * Set sp[i] and ep[i] to the start and end of the i-th matched subpattern.
+ * Subpatterns are defined by parentheses in the regex language.
*/
- public int
-match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
- PATTERN_TYPE pattern;
- char *tpattern;
- char *line;
- int line_len;
- char **sp;
- char **ep;
- int notbol;
- int search_type;
+static int match_pattern1(PATTERN_TYPE pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int nsp, int notbol, int search_type)
{
int matched;
- *sp = *ep = NULL;
#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);
+ matched = match(tpattern, strlen(tpattern), line, line_len, &sp, &ep, nsp);
else
{
#if HAVE_GNU_REGEX
@@ -345,57 +313,101 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
matched = re_search(pattern, line, line_len, 0, line_len, &search_regs) >= 0;
if (matched)
{
- *sp = line + search_regs.start[0];
- *ep = line + search_regs.end[0];
+ *sp++ = line + search_regs.start[0];
+ *ep++ = line + search_regs.end[0];
}
}
#endif
#if HAVE_POSIX_REGCOMP
{
- regmatch_t rm;
+ #define RM_COUNT (NUM_SEARCH_COLORS+2)
+ regmatch_t rm[RM_COUNT];
int flags = (notbol) ? REG_NOTBOL : 0;
#ifdef REG_STARTEND
flags |= REG_STARTEND;
- rm.rm_so = 0;
- rm.rm_eo = line_len;
+ rm[0].rm_so = 0;
+ rm[0].rm_eo = line_len;
#endif
- matched = !regexec(pattern, line, 1, &rm, flags);
+ matched = !regexec(pattern, line, RM_COUNT, rm, flags);
if (matched)
{
+ int i;
+ int ecount;
+ for (ecount = RM_COUNT; ecount > 0; ecount--)
+ if (rm[ecount-1].rm_so >= 0)
+ break;
+ if (ecount >= nsp)
+ ecount = nsp-1;
+ for (i = 0; i < ecount; i++)
+ {
+ if (rm[i].rm_so < 0)
+ {
+ *sp++ = *ep++ = line;
+ } else
+ {
#ifndef __WATCOMC__
- *sp = line + rm.rm_so;
- *ep = line + rm.rm_eo;
+ *sp++ = line + rm[i].rm_so;
+ *ep++ = line + rm[i].rm_eo;
#else
- *sp = rm.rm_sp;
- *ep = rm.rm_ep;
+ *sp++ = rm[i].rm_sp;
+ *ep++ = rm[i].rm_ep;
#endif
+ }
+ }
}
}
#endif
#if HAVE_PCRE
{
+ #define OVECTOR_COUNT ((3*NUM_SEARCH_COLORS)+3)
+ int ovector[OVECTOR_COUNT];
int flags = (notbol) ? PCRE_NOTBOL : 0;
- int ovector[3];
- matched = pcre_exec(pattern, NULL, line, line_len,
- 0, flags, ovector, 3) >= 0;
- if (matched)
+ int i;
+ int ecount;
+ int mcount = pcre_exec(pattern, NULL, line, line_len,
+ 0, flags, ovector, OVECTOR_COUNT);
+ matched = (mcount > 0);
+ ecount = nsp-1;
+ if (ecount > mcount) ecount = mcount;
+ for (i = 0; i < ecount*2; )
{
- *sp = line + ovector[0];
- *ep = line + ovector[1];
+ if (ovector[i] < 0 || ovector[i+1] < 0)
+ {
+ *sp++ = *ep++ = line;
+ i += 2;
+ } else
+ {
+ *sp++ = line + ovector[i++];
+ *ep++ = line + ovector[i++];
+ }
}
}
#endif
#if HAVE_PCRE2
{
int flags = (notbol) ? PCRE2_NOTBOL : 0;
- pcre2_match_data *md = pcre2_match_data_create(3, NULL);
- matched = pcre2_match(pattern, (PCRE2_SPTR)line, line_len,
- 0, flags, md, NULL) >= 0;
+ pcre2_match_data *md = pcre2_match_data_create(nsp-1, NULL);
+ int mcount = pcre2_match(pattern, (PCRE2_SPTR)line, line_len,
+ 0, flags, md, NULL);
+ matched = (mcount > 0);
if (matched)
{
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(md);
- *sp = line + ovector[0];
- *ep = line + ovector[1];
+ int i;
+ int ecount = nsp-1;
+ if (ecount > mcount) ecount = mcount;
+ for (i = 0; i < ecount*2; )
+ {
+ if (ovector[i] < 0 || ovector[i+1] < 0)
+ {
+ *sp++ = *ep++ = line;
+ i += 2;
+ } else
+ {
+ *sp++ = line + ovector[i++];
+ *ep++ = line + ovector[i++];
+ }
+ }
}
pcre2_match_data_free(md);
}
@@ -405,13 +417,11 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
/*
* re_exec doesn't seem to provide a way to get the matched string.
*/
- *sp = *ep = NULL;
#endif
#if HAVE_REGCMP
- *ep = regex(pattern, line);
- matched = (*ep != NULL);
+ matched = ((*ep++ = regex(pattern, line)) != NULL);
if (matched)
- *sp = __loc1;
+ *sp++ = __loc1;
#endif
#if HAVE_V8_REGCOMP
#if HAVE_REGEXEC2
@@ -421,21 +431,33 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
#endif
if (matched)
{
- *sp = pattern->startp[0];
- *ep = pattern->endp[0];
+ *sp++ = pattern->startp[0];
+ *ep++ = pattern->endp[0];
}
#endif
}
+ *sp = *ep = NULL;
matched = (!(search_type & SRCH_NO_MATCH) && matched) ||
((search_type & SRCH_NO_MATCH) && !matched);
return (matched);
}
+public int match_pattern(PATTERN_TYPE pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int nsp, int notbol, int search_type)
+{
+ int matched = match_pattern1(pattern, tpattern, line, line_len, sp, ep, nsp, notbol, search_type);
+ int i;
+ for (i = 1; i <= NUM_SEARCH_COLORS; i++)
+ {
+ if ((search_type & SRCH_SUBSEARCH(i)) && ep[i] == sp[i])
+ matched = 0;
+ }
+ return matched;
+}
+
/*
* Return the name of the pattern matching library.
*/
- public char *
-pattern_lib_name(VOID_PARAM)
+public char * pattern_lib_name(void)
{
#if HAVE_GNU_REGEX
return ("GNU");
diff --git a/pattern.h b/pattern.h
index a690b8e9bf51..807883473302 100644
--- a/pattern.h
+++ b/pattern.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -46,16 +46,16 @@
/* ---- RE_COMP ---- */
#if HAVE_RE_COMP
-char *re_comp LESSPARAMS ((char*));
-int re_exec LESSPARAMS ((char*));
+char *re_comp(char*);
+int re_exec(char*);
#define PATTERN_TYPE int
#define SET_NULL_PATTERN(name) name = 0
#endif
/* ---- REGCMP ---- */
#if HAVE_REGCMP
-char *regcmp LESSPARAMS ((char*));
-char *regex LESSPARAMS ((char**, char*));
+char *regcmp(char*);
+char *regex(char**, char*);
extern char *__loc1;
#define PATTERN_TYPE char **
#define SET_NULL_PATTERN(name) name = NULL
diff --git a/pckeys.h b/pckeys.h
index a4f9c25ca88d..8af659cd8458 100644
--- a/pckeys.h
+++ b/pckeys.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/position.c b/position.c
index eabaf7e66dc2..c0f86614bbc8 100644
--- a/position.c
+++ b/position.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -36,9 +36,7 @@ extern int header_lines;
* the bottom line on the screen
* the line after the bottom line on the screen
*/
- public POSITION
-position(sindex)
- int sindex;
+public POSITION position(int sindex)
{
switch (sindex)
{
@@ -58,9 +56,7 @@ position(sindex)
/*
* Add a new file position to the bottom of the position table.
*/
- public void
-add_forw_pos(pos)
- POSITION pos;
+public void add_forw_pos(POSITION pos)
{
int i;
@@ -75,9 +71,7 @@ add_forw_pos(pos)
/*
* Add a new file position to the top of the position table.
*/
- public void
-add_back_pos(pos)
- POSITION pos;
+public void add_back_pos(POSITION pos)
{
int i;
@@ -92,8 +86,7 @@ add_back_pos(pos)
/*
* Initialize the position table, done whenever we clear the screen.
*/
- public void
-pos_clear(VOID_PARAM)
+public void pos_clear(void)
{
int i;
@@ -104,8 +97,7 @@ pos_clear(VOID_PARAM)
/*
* Allocate or reallocate the position table.
*/
- public void
-pos_init(VOID_PARAM)
+public void pos_init(void)
{
struct scrpos scrpos;
@@ -133,9 +125,7 @@ pos_init(VOID_PARAM)
* Check the position table to see if the position falls within its range.
* Return the position table entry if found, -1 if not.
*/
- public int
-onscreen(pos)
- POSITION pos;
+public int onscreen(POSITION pos)
{
int i;
@@ -150,16 +140,12 @@ onscreen(pos)
/*
* See if the entire screen is empty.
*/
- public int
-empty_screen(VOID_PARAM)
+public int empty_screen(void)
{
return (empty_lines(0, sc_height-1));
}
- public int
-empty_lines(s, e)
- int s;
- int e;
+public int empty_lines(int s, int e)
{
int i;
@@ -177,10 +163,7 @@ empty_lines(s, e)
* such that the top few lines are empty, we may have to set
* the screen line to a number > 0.
*/
- public void
-get_scrpos(scrpos, where)
- struct scrpos *scrpos;
- int where;
+public void get_scrpos(struct scrpos *scrpos, int where)
{
int i;
int dir;
@@ -233,9 +216,7 @@ get_scrpos(scrpos, where)
* or it may be in { -1 .. -(sc_height-1) } to refer to lines
* relative to the bottom of the screen.
*/
- public int
-sindex_from_sline(sline)
- int sline;
+public int sindex_from_sline(int sline)
{
/*
* Negative screen line number means
diff --git a/position.h b/position.h
index 85a110fca0f0..650f4701842d 100644
--- a/position.h
+++ b/position.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/prompt.c b/prompt.c
index 5319c40293bf..01265c27df3c 100644
--- a/prompt.c
+++ b/prompt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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,8 +66,7 @@ static char *mp;
/*
* Initialize the prompt prototype strings.
*/
- public void
-init_prompt(VOID_PARAM)
+public void init_prompt(void)
{
prproto[0] = save(s_proto);
prproto[1] = save(less_is_more ? more_proto : m_proto);
@@ -80,9 +79,7 @@ init_prompt(VOID_PARAM)
/*
* Append a string to the end of the message.
*/
- static void
-ap_str(s)
- char *s;
+static void ap_str(char *s)
{
int len;
@@ -97,9 +94,7 @@ ap_str(s)
/*
* Append a character to the end of the message.
*/
- static void
-ap_char(c)
- char c;
+static void ap_char(char c)
{
char buf[2];
@@ -111,47 +106,40 @@ ap_char(c)
/*
* Append a POSITION (as a decimal integer) to the end of the message.
*/
- static void
-ap_pos(pos)
- POSITION pos;
+static void ap_pos(POSITION pos)
{
char buf[INT_STRLEN_BOUND(pos) + 2];
- postoa(pos, buf);
+ postoa(pos, buf, 10);
ap_str(buf);
}
/*
* Append a line number to the end of the message.
*/
- static void
-ap_linenum(linenum)
- LINENUM linenum;
+static void ap_linenum(LINENUM linenum)
{
char buf[INT_STRLEN_BOUND(linenum) + 2];
- linenumtoa(linenum, buf);
+ linenumtoa(linenum, buf, 10);
ap_str(buf);
}
/*
* Append an integer to the end of the message.
*/
- static void
-ap_int(num)
- int num;
+static void ap_int(int num)
{
char buf[INT_STRLEN_BOUND(num) + 2];
- inttoa(num, buf);
+ inttoa(num, buf, 10);
ap_str(buf);
}
/*
* Append a question mark to the end of the message.
*/
- static void
-ap_quest(VOID_PARAM)
+static void ap_quest(void)
{
ap_str("?");
}
@@ -159,9 +147,7 @@ ap_quest(VOID_PARAM)
/*
* Return the "current" byte offset in the file.
*/
- static POSITION
-curr_byte(where)
- int where;
+static POSITION curr_byte(int where)
{
POSITION pos;
@@ -179,10 +165,7 @@ curr_byte(where)
* question mark followed by a single letter.
* Here we decode that letter and return the appropriate boolean value.
*/
- static int
-cond(c, where)
- char c;
- int where;
+static int cond(char c, int where)
{
POSITION len;
@@ -246,11 +229,7 @@ cond(c, where)
* Here we decode that letter and take the appropriate action,
* usually by appending something to the message being built.
*/
- static void
-protochar(c, where, iseditproto)
- int c;
- int where;
- int iseditproto;
+static void protochar(int c, int where, int iseditproto)
{
POSITION pos;
POSITION len;
@@ -402,9 +381,7 @@ protochar(c, where, iseditproto)
* where to resume parsing the string.
* We must keep track of nested IFs and skip them properly.
*/
- static constant char *
-skipcond(p)
- constant char *p;
+static constant char * skipcond(constant char *p)
{
int iflevel;
@@ -444,7 +421,8 @@ skipcond(p)
/*
* Backslash escapes the next character.
*/
- ++p;
+ if (p[1] != '\0')
+ ++p;
break;
case '\0':
/*
@@ -460,10 +438,7 @@ skipcond(p)
/*
* Decode a char that represents a position on the screen.
*/
- static constant char *
-wherechar(p, wp)
- char constant *p;
- int *wp;
+static constant char * wherechar(char constant *p, int *wp)
{
switch (*p)
{
@@ -484,9 +459,7 @@ wherechar(p, wp)
/*
* Construct a message based on a prototype string.
*/
- public char *
-pr_expand(proto)
- constant char *proto;
+public char * pr_expand(constant char *proto)
{
constant char *p;
int c;
@@ -505,8 +478,8 @@ pr_expand(proto)
ap_char(*p);
break;
case '\\': /* Backslash escapes the next character */
- p++;
- ap_char(*p);
+ if (p[1] != '\0')
+ ap_char(*++p);
break;
case '?': /* Conditional (IF) */
if ((c = *++p) == '\0')
@@ -551,8 +524,7 @@ pr_expand(proto)
/*
* Return a message suitable for printing by the "=" command.
*/
- public char *
-eq_message(VOID_PARAM)
+public char * eq_message(void)
{
return (pr_expand(eqproto));
}
@@ -563,8 +535,7 @@ eq_message(VOID_PARAM)
* If we can't come up with an appropriate prompt, return NULL
* and the caller will prompt with a colon.
*/
- public char *
-pr_string(VOID_PARAM)
+public char * pr_string(void)
{
char *prompt;
int type;
@@ -579,8 +550,7 @@ pr_string(VOID_PARAM)
/*
* Return a message suitable for printing while waiting in the F command.
*/
- public char *
-wait_message(VOID_PARAM)
+public char * wait_message(void)
{
return (pr_expand(wproto));
}
diff --git a/screen.c b/screen.c
index 7c903ab61eb1..6b389d7b0df0 100644
--- a/screen.c
+++ b/screen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -237,9 +237,11 @@ public int clear_bg; /* Clear fills with background color */
public int missing_cap = 0; /* Some capability is missing */
public char *kent = NULL; /* Keypad ENTER sequence */
public int term_init_done = FALSE;
+public int full_screen = TRUE;
static int attrmode = AT_NORMAL;
static int termcap_debug = -1;
+static int no_alt_screen; /* sc_init does not switch to alt screen */
extern int binattr;
extern int one_screen;
#if LESSTEST
@@ -247,9 +249,9 @@ extern char *ttyin_name;
#endif /*LESSTEST*/
#if !MSDOS_COMPILER
-static char *cheaper LESSPARAMS((char *t1, char *t2, char *def));
-static void tmodes LESSPARAMS((char *incap, char *outcap, char **instr,
- char **outstr, char *def_instr, char *def_outstr, char **spp));
+static char *cheaper(char *t1, char *t2, char *def);
+static void tmodes(char *incap, char *outcap, char **instr,
+ char **outstr, char *def_instr, char *def_outstr, char **spp);
#endif
/*
@@ -266,6 +268,7 @@ char PC_, *UP, *BC;
#endif
extern int quiet; /* If VERY_QUIET, use visual bell for bell */
+extern int no_vbell;
extern int no_back_scroll;
extern int swindow;
extern int no_init;
@@ -293,9 +296,72 @@ extern DWORD console_mode;
extern int tty;
#endif
-extern char *tgetstr();
-extern char *tgoto();
+#if (HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS) || defined(TCGETA)
+/*
+ * Set termio flags for use by less.
+ */
+static void set_termio_flags(
+#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
+ struct termios *s
+#else
+ struct termio *s
+#endif
+ )
+{
+ s->c_lflag &= ~(0
+#ifdef ICANON
+ | ICANON
+#endif
+#ifdef ECHO
+ | ECHO
+#endif
+#ifdef ECHOE
+ | ECHOE
+#endif
+#ifdef ECHOK
+ | ECHOK
+#endif
+#if ECHONL
+ | ECHONL
+#endif
+ );
+ s->c_oflag |= (0
+#ifdef OXTABS
+ | OXTABS
+#else
+#ifdef TAB3
+ | TAB3
+#else
+#ifdef XTABS
+ | XTABS
+#endif
+#endif
+#endif
+#ifdef OPOST
+ | OPOST
+#endif
+#ifdef ONLCR
+ | ONLCR
+#endif
+ );
+
+ s->c_oflag &= ~(0
+#ifdef ONOEOT
+ | ONOEOT
+#endif
+#ifdef OCRNL
+ | OCRNL
+#endif
+#ifdef ONOCR
+ | ONOCR
+#endif
+#ifdef ONLRET
+ | ONLRET
+#endif
+ );
+}
+#endif
/*
* Change terminal to "raw mode", or restore to "normal" mode.
@@ -308,15 +374,22 @@ extern char *tgoto();
* etc. are NOT disabled.
* It doesn't matter whether an input \n is mapped to \r, or vice versa.
*/
- public void
-raw_mode(on)
- int on;
+public void raw_mode(int on)
{
static int curr_on = 0;
if (on == curr_on)
return;
erase2_char = '\b'; /* in case OS doesn't know about erase2 */
+#if LESSTEST
+ if (ttyin_name != NULL)
+ {
+ /* {{ For consistent conditions when running tests. }} */
+ erase_char = '\b';
+ kill_char = CONTROL('U');
+ werase_char = CONTROL('W');
+ } else
+#endif /*LESSTEST*/
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
{
struct termios s;
@@ -328,157 +401,118 @@ raw_mode(on)
/*
* Get terminal modes.
*/
- tcgetattr(tty, &s);
-
- /*
- * Save modes and set certain variables dependent on modes.
- */
- if (!saved_term)
+ if (tcgetattr(tty, &s) < 0)
{
- save_term = s;
- saved_term = 1;
- }
-#if HAVE_OSPEED
- switch (cfgetospeed(&s))
+ erase_char = '\b';
+ kill_char = CONTROL('U');
+ werase_char = CONTROL('W');
+ } else
{
+ /*
+ * Save modes and set certain variables dependent on modes.
+ */
+ if (!saved_term)
+ {
+ save_term = s;
+ saved_term = 1;
+ }
+#if HAVE_OSPEED
+ switch (cfgetospeed(&s))
+ {
#ifdef B0
- case B0: ospeed = 0; break;
+ case B0: ospeed = 0; break;
#endif
#ifdef B50
- case B50: ospeed = 1; break;
+ case B50: ospeed = 1; break;
#endif
#ifdef B75
- case B75: ospeed = 2; break;
+ case B75: ospeed = 2; break;
#endif
#ifdef B110
- case B110: ospeed = 3; break;
+ case B110: ospeed = 3; break;
#endif
#ifdef B134
- case B134: ospeed = 4; break;
+ case B134: ospeed = 4; break;
#endif
#ifdef B150
- case B150: ospeed = 5; break;
+ case B150: ospeed = 5; break;
#endif
#ifdef B200
- case B200: ospeed = 6; break;
+ case B200: ospeed = 6; break;
#endif
#ifdef B300
- case B300: ospeed = 7; break;
+ case B300: ospeed = 7; break;
#endif
#ifdef B600
- case B600: ospeed = 8; break;
+ case B600: ospeed = 8; break;
#endif
#ifdef B1200
- case B1200: ospeed = 9; break;
+ case B1200: ospeed = 9; break;
#endif
#ifdef B1800
- case B1800: ospeed = 10; break;
+ case B1800: ospeed = 10; break;
#endif
#ifdef B2400
- case B2400: ospeed = 11; break;
+ case B2400: ospeed = 11; break;
#endif
#ifdef B4800
- case B4800: ospeed = 12; break;
+ case B4800: ospeed = 12; break;
#endif
#ifdef B9600
- case B9600: ospeed = 13; break;
+ case B9600: ospeed = 13; break;
#endif
#ifdef EXTA
- case EXTA: ospeed = 14; break;
+ case EXTA: ospeed = 14; break;
#endif
#ifdef EXTB
- case EXTB: ospeed = 15; break;
+ case EXTB: ospeed = 15; break;
#endif
#ifdef B57600
- case B57600: ospeed = 16; break;
+ case B57600: ospeed = 16; break;
#endif
#ifdef B115200
- case B115200: ospeed = 17; break;
+ case B115200: ospeed = 17; break;
#endif
- default: ;
- }
+ default: ;
+ }
#endif
- erase_char = s.c_cc[VERASE];
+ erase_char = s.c_cc[VERASE];
#ifdef VERASE2
- erase2_char = s.c_cc[VERASE2];
+ erase2_char = s.c_cc[VERASE2];
#endif
- kill_char = s.c_cc[VKILL];
+ kill_char = s.c_cc[VKILL];
#ifdef VWERASE
- werase_char = s.c_cc[VWERASE];
-#else
- werase_char = CONTROL('W');
-#endif
-
- /*
- * Set the modes to the way we want them.
- */
- s.c_lflag &= ~(0
-#ifdef ICANON
- | ICANON
-#endif
-#ifdef ECHO
- | ECHO
-#endif
-#ifdef ECHOE
- | ECHOE
-#endif
-#ifdef ECHOK
- | ECHOK
-#endif
-#if ECHONL
- | ECHONL
-#endif
- );
-
- s.c_oflag |= (0
-#ifdef OXTABS
- | OXTABS
+ werase_char = s.c_cc[VWERASE];
#else
-#ifdef TAB3
- | TAB3
-#else
-#ifdef XTABS
- | XTABS
-#endif
-#endif
-#endif
-#ifdef OPOST
- | OPOST
-#endif
-#ifdef ONLCR
- | ONLCR
+ werase_char = CONTROL('W');
#endif
- );
- s.c_oflag &= ~(0
-#ifdef ONOEOT
- | ONOEOT
-#endif
-#ifdef OCRNL
- | OCRNL
-#endif
-#ifdef ONOCR
- | ONOCR
-#endif
-#ifdef ONLRET
- | ONLRET
-#endif
- );
- s.c_cc[VMIN] = 1;
- s.c_cc[VTIME] = 0;
+ /*
+ * Set the modes to the way we want them.
+ */
+ set_termio_flags(&s);
+ s.c_cc[VMIN] = 1;
+ s.c_cc[VTIME] = 0;
#ifdef VLNEXT
- s.c_cc[VLNEXT] = 0;
+ s.c_cc[VLNEXT] = 0;
#endif
#ifdef VDSUSP
- s.c_cc[VDSUSP] = 0;
+ s.c_cc[VDSUSP] = 0;
+#endif
+#ifdef VSTOP
+ s.c_cc[VSTOP] = 0;
+#endif
+#ifdef VSTART
+ s.c_cc[VSTART] = 0;
#endif
#if MUST_SET_LINE_DISCIPLINE
- /*
- * System's termios is broken; need to explicitly
- * request TERMIODISC line discipline.
- */
- s.c_line = TERMIODISC;
+ /*
+ * System's termios is broken; need to explicitly
+ * request TERMIODISC line discipline.
+ */
+ s.c_line = TERMIODISC;
#endif
+ }
} else
{
/*
@@ -539,11 +573,15 @@ raw_mode(on)
/*
* Set the modes to the way we want them.
*/
- s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
- s.c_oflag |= (OPOST|ONLCR|TAB3);
- s.c_oflag &= ~(OCRNL|ONOCR|ONLRET);
+ set_termio_flags(&s);
s.c_cc[VMIN] = 1;
s.c_cc[VTIME] = 0;
+#ifdef VSTOP
+ s.c_cc[VSTOP] = 0;
+#endif
+#ifdef VSTART
+ s.c_cc[VSTART] = 0;
+#endif
} else
{
/*
@@ -673,9 +711,7 @@ raw_mode(on)
*/
static int hardcopy;
- static char *
-ltget_env(capname)
- char *capname;
+static char * ltget_env(char *capname)
{
char name[64];
@@ -699,9 +735,7 @@ ltget_env(capname)
return (lgetenv(name));
}
- static int
-ltgetflag(capname)
- char *capname;
+static int ltgetflag(char *capname)
{
char *s;
@@ -712,9 +746,7 @@ ltgetflag(capname)
return (tgetflag(capname));
}
- static int
-ltgetnum(capname)
- char *capname;
+static int ltgetnum(char *capname)
{
char *s;
@@ -725,10 +757,7 @@ ltgetnum(capname)
return (tgetnum(capname));
}
- static char *
-ltgetstr(capname, pp)
- char *capname;
- char **pp;
+static char * ltgetstr(char *capname, char **pp)
{
char *s;
@@ -743,8 +772,7 @@ ltgetstr(capname, pp)
/*
* Get size of the output screen.
*/
- public void
-scrsize(VOID_PARAM)
+public void scrsize(void)
{
char *s;
int sys_height;
@@ -763,6 +791,10 @@ scrsize(VOID_PARAM)
sys_width = sys_height = 0;
+#if LESSTEST
+ if (ttyin_name != NULL)
+#endif /*LESSTEST*/
+ {
#if MSDOS_COMPILER==MSOFTC
{
struct videoconfig w;
@@ -845,6 +877,7 @@ scrsize(VOID_PARAM)
#endif
#endif
#endif
+ }
if (sys_height > 0)
sc_height = sys_height;
@@ -854,6 +887,12 @@ scrsize(VOID_PARAM)
else if ((n = ltgetnum("li")) > 0)
sc_height = n;
#endif
+ if ((s = lgetenv("LESS_LINES")) != NULL)
+ {
+ int height = atoi(s);
+ sc_height = (height < 0) ? sc_height + height : height;
+ full_screen = FALSE;
+ }
if (sc_height <= 0)
sc_height = DEF_SC_HEIGHT;
@@ -865,6 +904,11 @@ scrsize(VOID_PARAM)
else if ((n = ltgetnum("co")) > 0)
sc_width = n;
#endif
+ if ((s = lgetenv("LESS_COLUMNS")) != NULL)
+ {
+ int width = atoi(s);
+ sc_width = (width < 0) ? sc_width + width : width;
+ }
if (sc_width <= 0)
sc_width = DEF_SC_WIDTH;
}
@@ -873,8 +917,7 @@ scrsize(VOID_PARAM)
/*
* Figure out how many empty loops it takes to delay a millisecond.
*/
- static void
-get_clock(VOID_PARAM)
+static void get_clock(void)
{
clock_t start;
@@ -901,9 +944,7 @@ get_clock(VOID_PARAM)
/*
* Delay for a specified number of milliseconds.
*/
- static void
-delay(msec)
- int msec;
+static void delay(int msec)
{
long i;
@@ -918,9 +959,7 @@ delay(msec)
/*
* Return the characters actually input by a "special" key.
*/
- public char *
-special_key_str(key)
- int key;
+public char * special_key_str(int key)
{
static char tbuf[40];
char *s;
@@ -1100,8 +1139,7 @@ special_key_str(key)
/*
* Get terminal capabilities via termcap.
*/
- public void
-get_term(VOID_PARAM)
+public void get_term(void)
{
termcap_debug = !isnullenv(lgetenv("LESS_TERMCAP_DEBUG"));
#if MSDOS_COMPILER
@@ -1216,6 +1254,7 @@ get_term(VOID_PARAM)
above_mem = ltgetflag("da");
below_mem = ltgetflag("db");
clear_bg = ltgetflag("ut");
+ no_alt_screen = ltgetflag("NR");
/*
* Assumes termcap variable "sg" is the printing width of:
@@ -1351,7 +1390,7 @@ get_term(VOID_PARAM)
* to move the cursor to the lower left corner of the screen.
*/
t1 = ltgetstr("ll", &sp);
- if (t1 == NULL)
+ if (t1 == NULL || !full_screen)
t1 = "";
if (*sc_move == '\0')
t2 = "";
@@ -1411,17 +1450,13 @@ get_term(VOID_PARAM)
static int costcount;
/*ARGSUSED*/
- static int
-inc_costcount(c)
- int c;
+static int inc_costcount(int c)
{
costcount++;
return (c);
}
- static int
-cost(t)
- char *t;
+static int cost(char *t)
{
costcount = 0;
tputs(t, sc_height, inc_costcount);
@@ -1433,10 +1468,7 @@ cost(t)
* The best, if both exist, is the one with the lower
* cost (see cost() function).
*/
- static char *
-cheaper(t1, t2, def)
- char *t1, *t2;
- char *def;
+static char * cheaper(char *t1, char *t2, char *def)
{
if (*t1 == '\0' && *t2 == '\0')
{
@@ -1452,15 +1484,7 @@ cheaper(t1, t2, def)
return (t2);
}
- static void
-tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp)
- char *incap;
- char *outcap;
- char **instr;
- char **outstr;
- char *def_instr;
- char *def_outstr;
- char **spp;
+static void tmodes(char *incap, char *outcap, char **instr, char **outstr, char *def_instr, char *def_outstr, char **spp)
{
*instr = ltgetstr(incap, spp);
if (*instr == NULL)
@@ -1492,8 +1516,7 @@ tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp)
#if MSDOS_COMPILER
#if MSDOS_COMPILER==WIN32C
- static void
-_settextposition(int row, int col)
+static void _settextposition(int row, int col)
{
COORD cpos;
CONSOLE_SCREEN_BUFFER_INFO csbi;
@@ -1508,8 +1531,7 @@ _settextposition(int row, int col)
/*
* Initialize the screen to the correct color at startup.
*/
- static void
-initcolor(VOID_PARAM)
+static void initcolor(void)
{
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
intensevideo();
@@ -1544,8 +1566,7 @@ initcolor(VOID_PARAM)
/*
* Enable virtual terminal processing, if available.
*/
- static void
-win32_init_vt_term(VOID_PARAM)
+static void win32_init_vt_term(void)
{
DWORD output_mode;
@@ -1562,8 +1583,7 @@ win32_init_vt_term(VOID_PARAM)
}
}
- static void
-win32_deinit_vt_term(VOID_PARAM)
+static void win32_deinit_vt_term(void)
{
if (vt_enabled == 1 && con_out == con_out_save)
SetConsoleMode(con_out, init_output_mode);
@@ -1572,8 +1592,7 @@ win32_deinit_vt_term(VOID_PARAM)
/*
* Termcap-like init with a private win32 console.
*/
- static void
-win32_init_term(VOID_PARAM)
+static void win32_init_term(void)
{
CONSOLE_SCREEN_BUFFER_INFO scr;
COORD size;
@@ -1607,8 +1626,7 @@ win32_init_term(VOID_PARAM)
/*
* Restore the startup console.
*/
- static void
-win32_deinit_term(VOID_PARAM)
+static void win32_deinit_term(void)
{
if (con_out_save == INVALID_HANDLE_VALUE)
return;
@@ -1621,14 +1639,10 @@ win32_deinit_term(VOID_PARAM)
#endif
#if !MSDOS_COMPILER
- static void
-do_tputs(str, affcnt, f_putc)
- char *str;
- int affcnt;
- int (*f_putc)(int);
+static void do_tputs(char *str, int affcnt, int (*f_putc)(int))
{
#if LESSTEST
- if (ttyin_name != NULL)
+ if (ttyin_name != NULL && f_putc == putchr)
putstr(str);
else
#endif /*LESSTEST*/
@@ -1639,11 +1653,7 @@ do_tputs(str, affcnt, f_putc)
* Like tputs but we handle $<...> delay strings here because
* some implementations of tputs don't perform delays correctly.
*/
- static void
-ltputs(str, affcnt, f_putc)
- char *str;
- int affcnt;
- int (*f_putc)(int);
+static void ltputs(char *str, int affcnt, int (*f_putc)(int))
{
while (str != NULL && *str != '\0')
{
@@ -1662,9 +1672,10 @@ ltputs(str, affcnt, f_putc)
do_tputs(str2, affcnt, f_putc);
str += slen + 2;
/* Perform the delay. */
- delay = lstrtoi(str, &str);
+ delay = lstrtoi(str, &str, 10);
if (*str == '*')
- delay *= affcnt;
+ if (ckd_mul(&delay, delay, affcnt))
+ delay = INT_MAX;
flush();
sleep_ms(delay);
/* Skip past closing ">" at end of delay string. */
@@ -1686,8 +1697,7 @@ ltputs(str, affcnt, f_putc)
* Configure the termimal so mouse clicks and wheel moves
* produce input to less.
*/
- public void
-init_mouse(VOID_PARAM)
+public void init_mouse(void)
{
#if !MSDOS_COMPILER
ltputs(sc_s_mousecap, sc_height, putchr);
@@ -1704,8 +1714,7 @@ init_mouse(VOID_PARAM)
* Configure the terminal so mouse clicks and wheel moves
* are handled by the system (so text can be selected, etc).
*/
- public void
-deinit_mouse(VOID_PARAM)
+public void deinit_mouse(void)
{
#if !MSDOS_COMPILER
ltputs(sc_e_mousecap, sc_height, putchr);
@@ -1720,8 +1729,7 @@ deinit_mouse(VOID_PARAM)
/*
* Initialize terminal
*/
- public void
-init(VOID_PARAM)
+public void init(void)
{
clear_bot_if_needed();
#if !MSDOS_COMPILER
@@ -1730,6 +1738,14 @@ init(VOID_PARAM)
if (!no_init)
{
ltputs(sc_init, sc_height, putchr);
+ /*
+ * Some terminals leave the cursor unmoved when switching
+ * to the alt screen. To avoid having the text appear at
+ * a seemingly random line on the alt screen, move to
+ * lower left if we are using an alt screen.
+ */
+ if (*sc_init != '\0' && *sc_deinit != '\0' && !no_alt_screen)
+ lower_left();
term_init_done = 1;
}
if (!no_keypad)
@@ -1776,8 +1792,7 @@ init(VOID_PARAM)
/*
* Deinitialize terminal
*/
- public void
-deinit(VOID_PARAM)
+public void deinit(void)
{
if (!init_done)
return;
@@ -1814,14 +1829,12 @@ deinit(VOID_PARAM)
/*
* Are we interactive (ie. writing to an initialized tty)?
*/
- public int
-interactive(VOID_PARAM)
+public int interactive(void)
{
return (is_tty && init_done);
}
- static void
-assert_interactive(VOID_PARAM)
+static void assert_interactive(void)
{
if (interactive()) return;
/* abort(); */
@@ -1830,8 +1843,7 @@ assert_interactive(VOID_PARAM)
/*
* Home cursor (move to upper left corner of screen).
*/
- public void
-home(VOID_PARAM)
+public void home(void)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -1842,12 +1854,21 @@ home(VOID_PARAM)
#endif
}
+#if LESSTEST
+public void dump_screen(void)
+{
+ char dump_cmd[32];
+ SNPRINTF1(dump_cmd, sizeof(dump_cmd), ESCS"0;0;%dR", sc_width * sc_height);
+ ltputs(dump_cmd, sc_height, putchr);
+ flush();
+}
+#endif /*LESSTEST*/
+
/*
* Add a blank line (called with cursor at home).
* Should scroll the display down.
*/
- public void
-add_line(VOID_PARAM)
+public void add_line(void)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -1905,9 +1926,7 @@ add_line(VOID_PARAM)
* window upward. This is needed to stop leaking the topmost line
* into the scrollback buffer when we go down-one-line (in WIN32).
*/
- public void
-remove_top(n)
- int n;
+public void remove_top(int n)
{
#if MSDOS_COMPILER==WIN32C
SMALL_RECT rcSrc, rcClip;
@@ -1959,8 +1978,7 @@ remove_top(n)
/*
* Clear the screen.
*/
- static void
-win32_clear(VOID_PARAM)
+static void win32_clear(void)
{
/*
* This will clear only the currently visible rows of the NT
@@ -1990,9 +2008,7 @@ win32_clear(VOID_PARAM)
* Remove the n topmost lines and scroll everything below it in the
* window upward.
*/
- public void
-win32_scroll_up(n)
- int n;
+public void win32_scroll_up(int n)
{
SMALL_RECT rcSrc, rcClip;
CHAR_INFO fillchar;
@@ -2056,8 +2072,7 @@ win32_scroll_up(n)
/*
* Move cursor to lower left corner of screen.
*/
- public void
-lower_left(VOID_PARAM)
+public void lower_left(void)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -2071,8 +2086,7 @@ lower_left(VOID_PARAM)
/*
* Move cursor to left position of current line.
*/
- public void
-line_left(VOID_PARAM)
+public void line_left(void)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -2106,8 +2120,7 @@ line_left(VOID_PARAM)
* Check if the console size has changed and reset internals
* (in lieu of SIGWINCH for WIN32).
*/
- public void
-check_winch(VOID_PARAM)
+public void check_winch(void)
{
#if MSDOS_COMPILER==WIN32C
CONSOLE_SCREEN_BUFFER_INFO scr;
@@ -2136,9 +2149,7 @@ check_winch(VOID_PARAM)
/*
* Goto a specific line on the screen.
*/
- public void
-goto_line(sindex)
- int sindex;
+public void goto_line(int sindex)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -2156,8 +2167,7 @@ goto_line(sindex)
* briefly and then switching back to the normal screen.
* {{ Yuck! There must be a better way to get a visual bell. }}
*/
- static void
-create_flash(VOID_PARAM)
+static void create_flash(void)
{
#if MSDOS_COMPILER==MSOFTC
struct videoconfig w;
@@ -2203,9 +2213,10 @@ create_flash(VOID_PARAM)
/*
* Output the "visual bell", if there is one.
*/
- public void
-vbell(VOID_PARAM)
+public void vbell(void)
{
+ if (no_vbell)
+ return;
#if !MSDOS_COMPILER
if (*sc_visual_bell == '\0')
return;
@@ -2267,8 +2278,7 @@ vbell(VOID_PARAM)
/*
* Make a noise.
*/
- static void
-beep(VOID_PARAM)
+static void beep(void)
{
#if !MSDOS_COMPILER
putchr(CONTROL('G'));
@@ -2284,8 +2294,7 @@ beep(VOID_PARAM)
/*
* Ring the terminal bell.
*/
- public void
-bell(VOID_PARAM)
+public void bell(void)
{
if (quiet == VERY_QUIET)
vbell();
@@ -2296,8 +2305,7 @@ bell(VOID_PARAM)
/*
* Clear the screen.
*/
- public void
-clear(VOID_PARAM)
+public void clear(void)
{
assert_interactive();
#if !MSDOS_COMPILER
@@ -2316,8 +2324,7 @@ clear(VOID_PARAM)
* Clear from the cursor to the end of the cursor's line.
* {{ This must not move the cursor. }}
*/
- public void
-clear_eol(VOID_PARAM)
+public void clear_eol(void)
{
/* assert_interactive();*/
#if !MSDOS_COMPILER
@@ -2376,8 +2383,7 @@ clear_eol(VOID_PARAM)
* Clear the current line.
* Clear the screen if there's off-screen memory below the display.
*/
- static void
-clear_eol_bot(VOID_PARAM)
+static void clear_eol_bot(void)
{
assert_interactive();
#if MSDOS_COMPILER
@@ -2394,8 +2400,7 @@ clear_eol_bot(VOID_PARAM)
* Clear the bottom line of the display.
* Leave the cursor at the beginning of the bottom line.
*/
- public void
-clear_bot(VOID_PARAM)
+public void clear_bot(void)
{
/*
* If we're in a non-normal attribute mode, temporarily exit
@@ -2428,9 +2433,7 @@ clear_bot(VOID_PARAM)
/*
* Parse a 4-bit color char.
*/
- static int
-parse_color4(ch)
- char ch;
+static int parse_color4(char ch)
{
switch (ch)
{
@@ -2458,9 +2461,7 @@ parse_color4(ch)
/*
* Parse a color as a decimal integer.
*/
- static int
-parse_color6(ps)
- char **ps;
+static int parse_color6(char **ps)
{
if (**ps == '-')
{
@@ -2469,8 +2470,8 @@ parse_color6(ps)
} else
{
char *ops = *ps;
- int color = lstrtoi(ops, ps);
- if (*ps == ops)
+ int color = lstrtoi(ops, ps, 10);
+ if (color < 0 || *ps == ops)
return CV_ERROR;
return color;
}
@@ -2482,11 +2483,7 @@ parse_color6(ps)
* CV_4BIT: fg/bg values are OR of CV_{RGB} bits.
* CV_6BIT: fg/bg values are integers entered by user.
*/
- public COLOR_TYPE
-parse_color(str, p_fg, p_bg)
- char *str;
- int *p_fg;
- int *p_bg;
+public COLOR_TYPE parse_color(char *str, int *p_fg, int *p_bg)
{
int fg;
int bg;
@@ -2515,9 +2512,7 @@ parse_color(str, p_fg, p_bg)
#if !MSDOS_COMPILER
- static int
-sgr_color(color)
- int color;
+static int sgr_color(int color)
{
switch (color)
{
@@ -2543,11 +2538,7 @@ sgr_color(color)
}
}
- static void
-tput_fmt(fmt, color, f_putc)
- char *fmt;
- int color;
- int (*f_putc)(int);
+static void tput_fmt(char *fmt, int color, int (*f_putc)(int))
{
char buf[INT_STRLEN_BOUND(int)+16];
if (color == attrcolor)
@@ -2557,10 +2548,7 @@ tput_fmt(fmt, color, f_putc)
attrcolor = color;
}
- static void
-tput_color(str, f_putc)
- char *str;
- int (*f_putc)(int);
+static void tput_color(char *str, int (*f_putc)(int))
{
int fg;
int bg;
@@ -2590,12 +2578,7 @@ tput_color(str, f_putc)
}
}
- static void
-tput_inmode(mode_str, attr, attr_bit, f_putc)
- char *mode_str;
- int attr;
- int attr_bit;
- int (*f_putc)(int);
+static void tput_inmode(char *mode_str, int attr, int attr_bit, int (*f_putc)(int))
{
char *color_str;
if ((attr & attr_bit) == 0)
@@ -2611,11 +2594,7 @@ tput_inmode(mode_str, attr, attr_bit, f_putc)
tput_color(color_str, f_putc);
}
- static void
-tput_outmode(mode_str, attr_bit, f_putc)
- char *mode_str;
- int attr_bit;
- int (*f_putc)(int);
+static void tput_outmode(char *mode_str, int attr_bit, int (*f_putc)(int))
{
if ((attrmode & attr_bit) == 0)
return;
@@ -2625,10 +2604,7 @@ tput_outmode(mode_str, attr_bit, f_putc)
#else /* MSDOS_COMPILER */
#if MSDOS_COMPILER==WIN32C
- static int
-WIN32put_fmt(fmt, color)
- char *fmt;
- int color;
+static int WIN32put_fmt(char *fmt, int color)
{
char buf[INT_STRLEN_BOUND(int)+16];
int len = SNPRINTF1(buf, sizeof(buf), fmt, color);
@@ -2637,9 +2613,7 @@ WIN32put_fmt(fmt, color)
}
#endif
- static int
-win_set_color(attr)
- int attr;
+static int win_set_color(int attr)
{
int fg;
int bg;
@@ -2683,9 +2657,7 @@ win_set_color(attr)
#endif /* MSDOS_COMPILER */
- public void
-at_enter(attr)
- int attr;
+public void at_enter(int attr)
{
attr = apply_at_specials(attr);
#if !MSDOS_COMPILER
@@ -2721,8 +2693,7 @@ at_enter(attr)
attrmode = attr;
}
- public void
-at_exit(VOID_PARAM)
+public void at_exit(void)
{
#if !MSDOS_COMPILER
/* Undo things in the reverse order we did them. */
@@ -2738,9 +2709,7 @@ at_exit(VOID_PARAM)
attrmode = AT_NORMAL;
}
- public void
-at_switch(attr)
- int attr;
+public void at_switch(int attr)
{
int new_attrmode = apply_at_specials(attr);
int ignore_modes = AT_ANSI;
@@ -2752,10 +2721,7 @@ at_switch(attr)
}
}
- public int
-is_at_equiv(attr1, attr2)
- int attr1;
- int attr2;
+public int is_at_equiv(int attr1, int attr2)
{
attr1 = apply_at_specials(attr1);
attr2 = apply_at_specials(attr2);
@@ -2763,9 +2729,7 @@ is_at_equiv(attr1, attr2)
return (attr1 == attr2);
}
- public int
-apply_at_specials(attr)
- int attr;
+public int apply_at_specials(int attr)
{
if (attr & AT_BINARY)
attr |= binattr;
@@ -2779,8 +2743,7 @@ apply_at_specials(attr)
/*
* Output a plain backspace, without erasing the previous char.
*/
- public void
-putbs(VOID_PARAM)
+public void putbs(void)
{
if (termcap_debug)
putstr("<bs>");
@@ -2823,8 +2786,7 @@ putbs(VOID_PARAM)
/*
* Determine whether an input character is waiting to be read.
*/
- public int
-win32_kbhit(VOID_PARAM)
+public int win32_kbhit(void)
{
INPUT_RECORD ip;
DWORD read;
@@ -2884,6 +2846,7 @@ win32_kbhit(VOID_PARAM)
} while (ip.EventType != KEY_EVENT ||
ip.Event.KeyEvent.bKeyDown != TRUE ||
(ip.Event.KeyEvent.wVirtualScanCode == 0 && ip.Event.KeyEvent.uChar.UnicodeChar == 0) ||
+ ((ip.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_CTRL_PRESSED)) == (RIGHT_ALT_PRESSED|LEFT_CTRL_PRESSED) && ip.Event.KeyEvent.uChar.UnicodeChar == 0) ||
ip.Event.KeyEvent.wVirtualKeyCode == VK_KANJI ||
ip.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT ||
ip.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL ||
@@ -2934,8 +2897,7 @@ win32_kbhit(VOID_PARAM)
/*
* Read a character from the keyboard.
*/
- public char
-WIN32getch(VOID_PARAM)
+public char WIN32getch(void)
{
char ascii;
static unsigned char utf8[UTF8_MAX_LENGTH];
@@ -2991,20 +2953,14 @@ WIN32getch(VOID_PARAM)
#if MSDOS_COMPILER
/*
*/
- public void
-WIN32setcolors(fg, bg)
- int fg;
- int bg;
+public void WIN32setcolors(int fg, int bg)
{
SETCOLORS(fg, bg);
}
/*
*/
- public void
-WIN32textout(text, len)
- char *text;
- int len;
+public void WIN32textout(char *text, int len)
{
#if MSDOS_COMPILER==WIN32C
DWORD written;
diff --git a/scrsize.c b/scrsize.c
index 7ceed58bd755..b0ad197af3f1 100644
--- a/scrsize.c
+++ b/scrsize.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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/search.c b/search.c
index 224bc493df4c..758e4491f1ce 100644
--- a/search.c
+++ b/search.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -26,6 +26,8 @@ extern int linenums;
extern int sc_height;
extern int jump_sline;
extern int bs_mode;
+extern int proc_backspace;
+extern int proc_return;
extern int ctldisp;
extern int status_col;
extern void *ml_search;
@@ -36,6 +38,9 @@ extern int screen_trashed;
extern int sc_width;
extern int sc_height;
extern int hshift;
+extern int nosearch_headers;
+extern int header_lines;
+extern int header_cols;
#if HILITE_SEARCH
extern int hilite_search;
extern int size_linebuf;
@@ -66,6 +71,7 @@ struct hilite
{
POSITION hl_startpos;
POSITION hl_endpos;
+ int hl_attr;
};
struct hilite_node
{
@@ -108,6 +114,7 @@ struct pattern_info {
PATTERN_TYPE compiled;
char* text;
int search_type;
+ int is_ucase_pattern;
struct pattern_info *next;
};
@@ -118,15 +125,12 @@ struct pattern_info {
#endif
static struct pattern_info search_info;
-static int is_ucase_pattern;
public int is_caseless;
/*
* Are there any uppercase letters in this string?
*/
- static int
-is_ucase(str)
- char *str;
+static int is_ucase(char *str)
{
char *str_end = str + strlen(str);
LWCHAR ch;
@@ -143,9 +147,7 @@ is_ucase(str)
/*
* Discard a saved pattern.
*/
- static void
-clear_pattern(info)
- struct pattern_info *info;
+static void clear_pattern(struct pattern_info *info)
{
if (info->text != NULL)
free(info->text);
@@ -158,19 +160,14 @@ clear_pattern(info)
/*
* Compile and save a search pattern.
*/
- static int
-set_pattern(info, pattern, search_type, show_error)
- struct pattern_info *info;
- char *pattern;
- int search_type;
- int show_error;
+static int set_pattern(struct pattern_info *info, char *pattern, int search_type, int show_error)
{
/*
* Ignore case if -I is set OR
* -i is set AND the pattern is all lowercase.
*/
- is_ucase_pattern = (pattern == NULL) ? FALSE : is_ucase(pattern);
- is_caseless = (is_ucase_pattern && caseless != OPT_ONPLUS) ? 0 : caseless;
+ info->is_ucase_pattern = (pattern == NULL) ? FALSE : is_ucase(pattern);
+ is_caseless = (info->is_ucase_pattern && caseless != OPT_ONPLUS) ? 0 : caseless;
#if !NO_REGEX
if (pattern == NULL)
SET_NULL_PATTERN(info->compiled);
@@ -193,9 +190,7 @@ set_pattern(info, pattern, search_type, show_error)
/*
* Initialize saved pattern to nothing.
*/
- static void
-init_pattern(info)
- struct pattern_info *info;
+static void init_pattern(struct pattern_info *info)
{
SET_NULL_PATTERN(info->compiled);
info->text = NULL;
@@ -206,8 +201,7 @@ init_pattern(info)
/*
* Initialize search variables.
*/
- public void
-init_search(VOID_PARAM)
+public void init_search(void)
{
init_pattern(&search_info);
}
@@ -215,16 +209,15 @@ init_search(VOID_PARAM)
/*
* Determine which text conversions to perform before pattern matching.
*/
- static int
-get_cvt_ops(VOID_PARAM)
+static int get_cvt_ops(int search_type)
{
int ops = 0;
- if (is_caseless && !re_handles_caseless)
+ if (is_caseless && (!re_handles_caseless || (search_type & SRCH_NO_REGEX)))
ops |= CVT_TO_LC;
- if (bs_mode == BS_SPECIAL)
+ if (proc_backspace == OPT_ON || (bs_mode == BS_SPECIAL && proc_backspace == OPT_OFF))
ops |= CVT_BS;
- if (bs_mode != BS_CONTROL)
+ if (proc_return == OPT_ON || (bs_mode != BS_CONTROL && proc_backspace == OPT_OFF))
ops |= CVT_CRLF;
if (ctldisp == OPT_ONPLUS)
ops |= CVT_ANSI;
@@ -234,9 +227,7 @@ get_cvt_ops(VOID_PARAM)
/*
* Is there a previous (remembered) search pattern?
*/
- static int
-prev_pattern(info)
- struct pattern_info *info;
+static int prev_pattern(struct pattern_info *info)
{
#if !NO_REGEX
if ((info->search_type & SRCH_NO_REGEX) == 0)
@@ -251,9 +242,7 @@ prev_pattern(info)
* Repaint each line which contains highlighted text.
* If on==0, force all hilites off.
*/
- public void
-repaint_hilite(on)
- int on;
+public void repaint_hilite(int on)
{
int sindex;
POSITION pos;
@@ -284,6 +273,7 @@ repaint_hilite(on)
continue;
(void) forw_line(pos);
goto_line(sindex);
+ clear_eol();
put_line();
}
overlay_header();
@@ -295,8 +285,7 @@ repaint_hilite(on)
/*
* Clear the attn hilite.
*/
- public void
-clear_attn(VOID_PARAM)
+public void clear_attn(void)
{
#if HILITE_SEARCH
int sindex;
@@ -331,6 +320,7 @@ clear_attn(VOID_PARAM)
{
(void) forw_line(pos);
goto_line(sindex);
+ clear_eol();
put_line();
moved = 1;
}
@@ -345,9 +335,7 @@ clear_attn(VOID_PARAM)
/*
* Toggle or clear search string highlighting.
*/
- public void
-undo_search(clear)
- int clear;
+public void undo_search(int clear)
{
clear_pattern(&search_info);
#if HILITE_SEARCH
@@ -371,9 +359,7 @@ undo_search(clear)
/*
* Clear the hilite list.
*/
- public void
-clr_hlist(anchor)
- struct hilite_tree *anchor;
+public void clr_hlist(struct hilite_tree *anchor)
{
struct hilite_storage *hls;
struct hilite_storage *nexthls;
@@ -393,52 +379,23 @@ clr_hlist(anchor)
prep_startpos = prep_endpos = NULL_POSITION;
}
- public void
-clr_hilite(VOID_PARAM)
+public void clr_hilite(void)
{
clr_hlist(&hilite_anchor);
}
- public void
-clr_filter(VOID_PARAM)
+public void clr_filter(void)
{
clr_hlist(&filter_anchor);
}
- struct hilite_node*
-hlist_last(anchor)
- struct hilite_tree *anchor;
-{
- struct hilite_node *n = anchor->root;
- while (n != NULL && n->right != NULL)
- n = n->right;
- return n;
-}
-
- struct hilite_node*
-hlist_next(n)
- struct hilite_node *n;
-{
- return n->next;
-}
-
- struct hilite_node*
-hlist_prev(n)
- struct hilite_node *n;
-{
- return n->prev;
-}
-
/*
* Find the node covering pos, or the node after it if no node covers it,
* or return NULL if pos is after the last range. Remember the found node,
* to speed up subsequent searches for the same or similar positions (if
* we return NULL, remember the last node.)
*/
- struct hilite_node*
-hlist_find(anchor, pos)
- struct hilite_tree *anchor;
- POSITION pos;
+static struct hilite_node* hlist_find(struct hilite_tree *anchor, POSITION pos)
{
struct hilite_node *n, *m;
@@ -528,21 +485,20 @@ hlist_find(anchor, pos)
/*
* Should any characters in a specified range be highlighted?
*/
- static int
-is_hilited_range(pos, epos)
- POSITION pos;
- POSITION epos;
+static int hilited_range_attr(POSITION pos, POSITION epos)
{
struct hilite_node *n = hlist_find(&hilite_anchor, pos);
- return (n != NULL && (epos == NULL_POSITION || epos > n->r.hl_startpos));
+ if (n == NULL)
+ return 0;
+ if (epos != NULL_POSITION && epos <= n->r.hl_startpos)
+ return 0;
+ return n->r.hl_attr;
}
/*
* Is a line "filtered" -- that is, should it be hidden?
*/
- public int
-is_filtered(pos)
- POSITION pos;
+public int is_filtered(POSITION pos)
{
struct hilite_node *n;
@@ -557,9 +513,7 @@ is_filtered(pos)
* If pos is hidden, return the next position which isn't, otherwise
* just return pos.
*/
- public POSITION
-next_unfiltered(pos)
- POSITION pos;
+public POSITION next_unfiltered(POSITION pos)
{
struct hilite_node *n;
@@ -579,9 +533,7 @@ next_unfiltered(pos)
* If pos is hidden, return the previous position which isn't or 0 if
* we're filtered right to the beginning, otherwise just return pos.
*/
- public POSITION
-prev_unfiltered(pos)
- POSITION pos;
+public POSITION prev_unfiltered(POSITION pos)
{
struct hilite_node *n;
@@ -605,14 +557,9 @@ prev_unfiltered(pos)
* Should any characters in a specified range be highlighted?
* If nohide is nonzero, don't consider hide_hilite.
*/
- public int
-is_hilited_attr(pos, epos, nohide, p_matches)
- POSITION pos;
- POSITION epos;
- int nohide;
- int *p_matches;
+public int is_hilited_attr(POSITION pos, POSITION epos, int nohide, int *p_matches)
{
- int match;
+ int attr;
if (p_matches != NULL)
*p_matches = 0;
@@ -626,8 +573,8 @@ is_hilited_attr(pos, epos, nohide, p_matches)
*/
return (AT_HILITE|AT_COLOR_ATTN);
- match = is_hilited_range(pos, epos);
- if (!match)
+ attr = hilited_range_attr(pos, epos);
+ if (attr == 0)
return (0);
if (p_matches == NULL)
@@ -636,7 +583,7 @@ is_hilited_attr(pos, epos, nohide, p_matches)
* hilite in status column. In this case we want to return
* hilite status even if hiliting is disabled or hidden.
*/
- return (AT_HILITE|AT_COLOR_SEARCH);
+ return (attr);
/*
* Report matches, even if we're hiding highlights.
@@ -655,16 +602,14 @@ is_hilited_attr(pos, epos, nohide, p_matches)
*/
return (0);
- return (AT_HILITE|AT_COLOR_SEARCH);
+ return (attr);
}
/*
* Tree node storage: get the current block of nodes if it has spare
* capacity, or create a new one if not.
*/
- static struct hilite_storage*
-hlist_getstorage(anchor)
- struct hilite_tree *anchor;
+static struct hilite_storage * hlist_getstorage(struct hilite_tree *anchor)
{
int capacity = 1;
struct hilite_storage *s;
@@ -693,9 +638,7 @@ hlist_getstorage(anchor)
* Tree node storage: retrieve a new empty node to be inserted into the
* tree.
*/
- static struct hilite_node*
-hlist_getnode(anchor)
- struct hilite_tree *anchor;
+static struct hilite_node * hlist_getnode(struct hilite_tree *anchor)
{
struct hilite_storage *s = hlist_getstorage(anchor);
return &s->nodes[s->used++];
@@ -704,10 +647,7 @@ hlist_getnode(anchor)
/*
* Rotate the tree left around a pivot node.
*/
- static void
-hlist_rotate_left(anchor, n)
- struct hilite_tree *anchor;
- struct hilite_node *n;
+static void hlist_rotate_left(struct hilite_tree *anchor, struct hilite_node *n)
{
struct hilite_node *np = n->parent;
struct hilite_node *nr = n->right;
@@ -735,10 +675,7 @@ hlist_rotate_left(anchor, n)
/*
* Rotate the tree right around a pivot node.
*/
- static void
-hlist_rotate_right(anchor, n)
- struct hilite_tree *anchor;
- struct hilite_node *n;
+static void hlist_rotate_right(struct hilite_tree *anchor, struct hilite_node *n)
{
struct hilite_node *np = n->parent;
struct hilite_node *nl = n->left;
@@ -767,10 +704,7 @@ hlist_rotate_right(anchor, n)
/*
* Add a new hilite to a hilite list.
*/
- static void
-add_hilite(anchor, hl)
- struct hilite_tree *anchor;
- struct hilite *hl;
+static void add_hilite(struct hilite_tree *anchor, struct hilite *hl)
{
struct hilite_node *p, *n, *u;
@@ -799,7 +733,7 @@ add_hilite(anchor, hl)
{
if (hl->hl_startpos < p->r.hl_startpos)
{
- if (hl->hl_endpos > p->r.hl_startpos)
+ if (hl->hl_endpos > p->r.hl_startpos && hl->hl_attr == p->r.hl_attr)
hl->hl_endpos = p->r.hl_startpos;
if (p->left != NULL)
{
@@ -808,7 +742,7 @@ add_hilite(anchor, hl)
}
break;
}
- if (hl->hl_startpos < p->r.hl_endpos) {
+ if (hl->hl_startpos < p->r.hl_endpos && hl->hl_attr == p->r.hl_attr) {
hl->hl_startpos = p->r.hl_endpos;
if (hl->hl_startpos >= hl->hl_endpos)
return;
@@ -827,17 +761,19 @@ add_hilite(anchor, hl)
* insertion. Otherwise insert a new node at the leaf.
*/
if (hl->hl_startpos < p->r.hl_startpos) {
- if (hl->hl_endpos == p->r.hl_startpos)
+ if (hl->hl_attr == p->r.hl_attr)
{
- p->r.hl_startpos = hl->hl_startpos;
- return;
- }
- if (p->prev != NULL && p->prev->r.hl_endpos == hl->hl_startpos)
- {
- p->prev->r.hl_endpos = hl->hl_endpos;
- return;
+ if (hl->hl_endpos == p->r.hl_startpos)
+ {
+ p->r.hl_startpos = hl->hl_startpos;
+ return;
+ }
+ if (p->prev != NULL && p->prev->r.hl_endpos == hl->hl_startpos)
+ {
+ p->prev->r.hl_endpos = hl->hl_endpos;
+ return;
+ }
}
-
p->left = n = hlist_getnode(anchor);
n->next = p;
if (p->prev != NULL)
@@ -847,16 +783,18 @@ add_hilite(anchor, hl)
}
p->prev = n;
} else {
- if (p->r.hl_endpos == hl->hl_startpos)
+ if (hl->hl_attr == p->r.hl_attr)
{
- p->r.hl_endpos = hl->hl_endpos;
- return;
- }
- if (p->next != NULL && hl->hl_endpos == p->next->r.hl_startpos) {
- p->next->r.hl_startpos = hl->hl_startpos;
- return;
+ if (p->r.hl_endpos == hl->hl_startpos)
+ {
+ p->r.hl_endpos = hl->hl_endpos;
+ return;
+ }
+ if (p->next != NULL && hl->hl_endpos == p->next->r.hl_startpos) {
+ p->next->r.hl_startpos = hl->hl_startpos;
+ return;
+ }
}
-
p->right = n = hlist_getnode(anchor);
n->prev = p;
if (p->next != NULL)
@@ -946,18 +884,16 @@ add_hilite(anchor, hl)
/*
* Highlight 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;
+static void create_hilites(POSITION linepos, char *line, char *sp, char *ep, int attr, int *chpos)
{
+ int start_index = sp - line;
+ int end_index = ep - line;
struct hilite hl;
int i;
/* Start the first hilite. */
hl.hl_startpos = linepos + chpos[start_index];
+ hl.hl_attr = attr;
/*
* Step through the displayed chars.
@@ -987,21 +923,13 @@ create_hilites(linepos, start_index, end_index, chpos)
* the current pattern.
* sp,ep delimit the first match already found.
*/
- static void
-hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
- POSITION linepos;
- char *line;
- int line_len;
- int *chpos;
- char *sp;
- char *ep;
- int cvt_ops;
+static void hilite_line(POSITION linepos, char *line, int line_len, int *chpos, char **sp, char **ep, int nsp, int cvt_ops)
{
char *searchp;
char *line_end = line + line_len;
/*
- * sp and ep delimit the first match in the line.
+ * sp[0] and ep[0] delimit the first match in the line.
* Mark the corresponding file positions, then
* look for further matches and mark them.
* {{ This technique, of calling match_pattern on subsequent
@@ -1009,25 +937,42 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
* if the pattern starts with "^". This bug is fixed
* for those regex functions that accept a notbol parameter
* (currently POSIX, PCRE and V8-with-regexec2). }}
+ * sp[i] and ep[i] for i>0 delimit subpattern matches.
+ * Color each of them with its unique color.
*/
searchp = line;
do {
- if (sp == NULL || ep == NULL)
- return;
- create_hilites(linepos, sp-line, ep-line, chpos);
+ char *lep = sp[0];
+ int i;
+ for (i = 1; i < nsp; i++)
+ {
+ if (sp[i] == NULL || ep[i] == NULL)
+ break;
+ if (ep[i] > sp[i])
+ {
+ create_hilites(linepos, line, lep, sp[i],
+ AT_HILITE | AT_COLOR_SEARCH, chpos);
+ create_hilites(linepos, line, sp[i], ep[i],
+ AT_HILITE | AT_COLOR_SUBSEARCH(i), chpos);
+ lep = ep[i];
+ }
+ }
+ create_hilites(linepos, line, lep, ep[0],
+ AT_HILITE | AT_COLOR_SEARCH, chpos);
+
/*
* If we matched more than zero characters,
* move to the first char after the string we matched.
* If we matched zero, just move to the next char.
*/
- if (ep > searchp)
- searchp = ep;
+ if (ep[0] > searchp)
+ searchp = ep[0];
else if (searchp != line_end)
searchp++;
else /* end of line */
break;
} while (match_pattern(info_compiled(&search_info), search_info.text,
- searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type));
+ searchp, line_end - searchp, sp, ep, nsp, 1, search_info.search_type));
}
#endif
@@ -1035,8 +980,7 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
/*
* Find matching text which is currently on screen and highlight it.
*/
- static void
-hilite_screen(VOID_PARAM)
+static void hilite_screen(void)
{
struct scrpos scrpos;
@@ -1050,8 +994,7 @@ hilite_screen(VOID_PARAM)
/*
* Change highlighting parameters.
*/
- public void
-chg_hilite(VOID_PARAM)
+public void chg_hilite(void)
{
/*
* Erase any highlights currently on screen.
@@ -1070,9 +1013,7 @@ chg_hilite(VOID_PARAM)
/*
* Figure out where to start a search.
*/
- static POSITION
-search_pos(search_type)
- int search_type;
+static POSITION search_pos(int search_type)
{
POSITION pos;
int sindex;
@@ -1165,22 +1106,14 @@ search_pos(search_type)
* If so, add an entry to the filter list.
*/
#if HILITE_SEARCH
- static int
-matches_filters(pos, cline, line_len, chpos, linepos, sp, ep)
- POSITION pos;
- char *cline;
- int line_len;
- int *chpos;
- POSITION linepos;
- char **sp;
- char **ep;
+static int matches_filters(POSITION pos, char *cline, int line_len, int *chpos, POSITION linepos, char **sp, char **ep, int nsp)
{
struct pattern_info *filter;
for (filter = filter_infos; filter != NULL; filter = filter->next)
{
int line_filter = match_pattern(info_compiled(filter), filter->text,
- cline, line_len, sp, ep, 0, filter->search_type);
+ cline, line_len, sp, ep, nsp, 0, filter->search_type);
if (line_filter)
{
struct hilite hl;
@@ -1200,11 +1133,7 @@ matches_filters(pos, cline, line_len, chpos, linepos, sp, ep)
* Get the position of the first char in the screen line which
* puts tpos on screen.
*/
- static POSITION
-get_lastlinepos(pos, tpos, sheight)
- POSITION pos;
- POSITION tpos;
- int sheight;
+static POSITION get_lastlinepos(POSITION pos, POSITION tpos, int sheight)
{
int nlines;
@@ -1225,10 +1154,7 @@ get_lastlinepos(pos, tpos, sheight)
* Get the segment index of tpos in the line starting at pos.
* A segment is a string of printable chars that fills the screen width.
*/
- static int
-get_seg(pos, tpos)
- POSITION pos;
- POSITION tpos;
+static int get_seg(POSITION pos, POSITION tpos)
{
int seg;
@@ -1244,31 +1170,32 @@ get_seg(pos, tpos)
/*
* Search a subset of the file, specified by start/end position.
*/
- static int
-search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, plastlinepos)
- POSITION pos;
- POSITION endpos;
- int search_type;
- int matches;
- int maxlines;
- POSITION *plinepos;
- POSITION *pendpos;
- POSITION *plastlinepos;
+static int search_range(POSITION pos, POSITION endpos, int search_type, int matches, int maxlines, POSITION *plinepos, POSITION *pendpos, POSITION *plastlinepos)
{
char *line;
char *cline;
int line_len;
LINENUM linenum;
- char *sp, *ep;
+ #define NSP (NUM_SEARCH_COLORS+2)
+ char *sp[NSP];
+ char *ep[NSP];
int line_match;
int cvt_ops;
int cvt_len;
int *chpos;
POSITION linepos, oldpos;
+ int skip_bytes = 0;
int swidth = sc_width - line_pfx_width();
int sheight = sc_height - sindex_from_sline(jump_sline);
linenum = find_linenum(pos);
+ if (nosearch_headers && linenum <= header_lines)
+ {
+ linenum = header_lines + 1;
+ pos = find_pos(linenum);
+ }
+ if (pos == NULL_POSITION)
+ return (-1);
oldpos = pos;
/* When the search wraps around, end at starting position. */
if ((search_type & SRCH_WRAP) && endpos == NULL_POSITION)
@@ -1379,12 +1306,14 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
if (is_filtered(linepos))
continue;
#endif
+ if (nosearch_headers)
+ skip_bytes = skip_columns(header_cols, &line, &line_len);
/*
* If it's a caseless search, convert the line to lowercase.
* If we're doing backspace processing, delete backspaces.
*/
- cvt_ops = get_cvt_ops();
+ cvt_ops = get_cvt_ops(search_type);
cvt_len = cvt_length(line_len, cvt_ops);
cline = (char *) ecalloc(1, cvt_len);
chpos = cvt_alloc_chpos(cvt_len);
@@ -1398,7 +1327,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
((search_type & SRCH_FIND_ALL) ||
prep_startpos == NULL_POSITION ||
linepos < prep_startpos || linepos >= prep_endpos)) {
- if (matches_filters(pos, cline, line_len, chpos, linepos, &sp, &ep))
+ if (matches_filters(pos, cline, line_len, chpos, linepos, sp, ep, NSP))
continue;
}
#endif
@@ -1411,7 +1340,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
if (prev_pattern(&search_info))
{
line_match = match_pattern(info_compiled(&search_info), search_info.text,
- cline, line_len, &sp, &ep, 0, search_type);
+ cline, line_len, sp, ep, NSP, 0, search_type);
if (line_match)
{
/*
@@ -1425,7 +1354,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
* Just add the matches in this line to the
* hilite list and keep searching.
*/
- hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
+ hilite_line(linepos + skip_bytes, cline, line_len, chpos, sp, ep, NSP, cvt_ops);
#endif
} else if (--matches <= 0)
{
@@ -1441,7 +1370,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
* the matches in this one line.
*/
clr_hilite();
- hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
+ hilite_line(linepos + skip_bytes, cline, line_len, chpos, sp, ep, NSP, cvt_ops);
}
#endif
if (chop_line())
@@ -1450,10 +1379,10 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
* If necessary, shift horizontally to make sure
* search match is fully visible.
*/
- if (sp != NULL && ep != NULL)
+ if (sp[0] != NULL && ep[0] != NULL)
{
- int start_off = sp - cline;
- int end_off = ep - cline;
+ int start_off = sp[0] - cline;
+ int end_off = ep[0] - cline;
int save_hshift = hshift;
int sshift;
int eshift;
@@ -1479,9 +1408,9 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
* of the match appears in the last line on the screen.
* lastlinepos is the position of the first char of that last line.
*/
- if (ep != NULL)
+ if (ep[0] != NULL)
{
- int end_off = ep - cline;
+ int end_off = ep[0] - cline;
if (end_off >= swidth * sheight / 4) /* heuristic */
*plastlinepos = get_lastlinepos(linepos, linepos + chpos[end_off], sheight);
}
@@ -1502,9 +1431,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos, pla
/*
* search for a pattern in history. If found, compile that pattern.
*/
- static int
-hist_pattern(search_type)
- int search_type;
+static int hist_pattern(int search_type)
{
#if CMD_HISTORY
char *pattern;
@@ -1532,10 +1459,9 @@ hist_pattern(search_type)
* Change the caseless-ness of searches.
* Updates the internal search state to reflect a change in the -i flag.
*/
- public void
-chg_caseless(VOID_PARAM)
+public void chg_caseless(void)
{
- if (!is_ucase_pattern)
+ if (!search_info.is_ucase_pattern)
{
/*
* Pattern did not have uppercase.
@@ -1566,11 +1492,7 @@ chg_caseless(VOID_PARAM)
* Caller may continue the search in another file
* if less than n matches are found in this file.
*/
- public int
-search(search_type, pattern, n)
- int search_type;
- char *pattern;
- int n;
+public int search(int search_type, char *pattern, int n)
{
POSITION pos;
POSITION opos;
@@ -1715,11 +1637,7 @@ search(search_type, pattern, n)
* If prep_endpos == NULL_POSITION, the prep region extends to EOF.
* prep_hilite asks that the range (spos,epos) be covered by the prep region.
*/
- public void
-prep_hilite(spos, epos, maxlines)
- POSITION spos;
- POSITION epos;
- int maxlines;
+public void prep_hilite(POSITION spos, POSITION epos, int maxlines)
{
POSITION nprep_startpos = prep_startpos;
POSITION nprep_endpos = prep_endpos;
@@ -1834,7 +1752,7 @@ prep_hilite(spos, epos, maxlines)
if (epos == NULL_POSITION || epos > spos)
{
int search_type = SRCH_FORW | SRCH_FIND_ALL;
- search_type |= (search_info.search_type & SRCH_NO_REGEX);
+ search_type |= (search_info.search_type & (SRCH_NO_REGEX|SRCH_SUBSEARCH_ALL));
for (;;)
{
result = search_range(spos, epos, search_type, 0, maxlines, (POSITION*)NULL, &new_epos, (POSITION*)NULL);
@@ -1885,10 +1803,7 @@ prep_hilite(spos, epos, maxlines)
/*
* Set the pattern to be used for line filtering.
*/
- public void
-set_filter_pattern(pattern, search_type)
- char *pattern;
- int search_type;
+public void set_filter_pattern(char *pattern, int search_type)
{
struct pattern_info *filter;
@@ -1923,8 +1838,7 @@ set_filter_pattern(pattern, search_type)
/*
* Is there a line filter in effect?
*/
- public int
-is_filtering(VOID_PARAM)
+public int is_filtering(void)
{
if (ch_getflags() & CH_HELPFILE)
return (0);
@@ -1939,9 +1853,7 @@ is_filtering(VOID_PARAM)
*/
public int reg_show_error = 1;
- void
-regerror(s)
- char *s;
+void regerror(char *s)
{
PARG parg;
diff --git a/signal.c b/signal.c
index 294fa6a7faf6..41b6a9af868a 100644
--- a/signal.c
+++ b/signal.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -41,9 +41,7 @@ extern long jump_sline_fraction;
*/
#if MSDOS_COMPILER!=WIN32C
/* ARGSUSED*/
- static RETSIGTYPE
-u_interrupt(type)
- int type;
+static RETSIGTYPE u_interrupt(int type)
{
bell();
#if OS2
@@ -73,9 +71,7 @@ u_interrupt(type)
* "Stop" (^Z) signal handler.
*/
/* ARGSUSED*/
- static RETSIGTYPE
-stop(type)
- int type;
+static RETSIGTYPE stop(int type)
{
LSIGNAL(SIGTSTP, stop);
sigs |= S_STOP;
@@ -98,9 +94,7 @@ stop(type)
* "Window" change handler
*/
/* ARGSUSED*/
- public RETSIGTYPE
-winch(type)
- int type;
+public RETSIGTYPE winch(int type)
{
LSIGNAL(SIG_LESSWINDOW, winch);
sigs |= S_WINCH;
@@ -116,9 +110,7 @@ winch(type)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
- static BOOL WINAPI
-wbreak_handler(dwCtrlType)
- DWORD dwCtrlType;
+static BOOL WINAPI wbreak_handler(DWORD dwCtrlType)
{
switch (dwCtrlType)
{
@@ -136,9 +128,7 @@ wbreak_handler(dwCtrlType)
}
#endif
- static RETSIGTYPE
-terminate(type)
- int type;
+static RETSIGTYPE terminate(int type)
{
quit(15);
}
@@ -146,9 +136,7 @@ terminate(type)
/*
* Set up the signal handlers.
*/
- public void
-init_signals(on)
- int on;
+public void init_signals(int on)
{
if (on)
{
@@ -207,8 +195,7 @@ init_signals(on)
* Process any signals we have received.
* A received signal cause a bit to be set in "sigs".
*/
- public void
-psignals(VOID_PARAM)
+public void psignals(void)
{
int tsignals;
diff --git a/tags.c b/tags.c
index 03e29736488a..41f6f220e610 100644
--- a/tags.c
+++ b/tags.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -44,13 +44,13 @@ enum {
T_GPATH /* 'GPATH': path name (global) */
};
-static enum tag_result findctag LESSPARAMS((char *tag));
-static enum tag_result findgtag LESSPARAMS((char *tag, int type));
-static char *nextgtag(VOID_PARAM);
-static char *prevgtag(VOID_PARAM);
-static POSITION ctagsearch(VOID_PARAM);
-static POSITION gtagsearch(VOID_PARAM);
-static int getentry LESSPARAMS((char *buf, char **tag, char **file, char **line));
+static enum tag_result findctag(char *tag);
+static enum tag_result findgtag(char *tag, int type);
+static char *nextgtag(void);
+static char *prevgtag(void);
+static POSITION ctagsearch(void);
+static POSITION gtagsearch(void);
+static int getentry(char *buf, char **tag, char **file, char **line);
/*
* The list of tags generated by the last findgtag() call.
@@ -88,8 +88,7 @@ static struct tag *curtag;
/*
* Delete tag structures.
*/
- public void
-cleantags(VOID_PARAM)
+public void cleantags(void)
{
struct tag *tp;
@@ -112,13 +111,7 @@ cleantags(VOID_PARAM)
/*
* Create a new tag entry.
*/
- static struct tag *
-maketagent(name, file, linenum, pattern, endline)
- char *name;
- char *file;
- LINENUM linenum;
- char *pattern;
- int endline;
+static struct tag * maketagent(char *name, char *file, LINENUM linenum, char *pattern, int endline)
{
struct tag *tp;
@@ -140,8 +133,7 @@ maketagent(name, file, linenum, pattern, endline)
/*
* Get tag mode.
*/
- public int
-gettagtype(VOID_PARAM)
+public int gettagtype(void)
{
int f;
@@ -171,9 +163,7 @@ gettagtype(VOID_PARAM)
* and "tagpattern" to the search pattern which should be used
* to find the tag.
*/
- public void
-findtag(tag)
- char *tag;
+public void findtag(char *tag)
{
int type = gettagtype();
enum tag_result result;
@@ -202,8 +192,7 @@ findtag(tag)
/*
* Search for a tag.
*/
- public POSITION
-tagsearch(VOID_PARAM)
+public POSITION tagsearch(void)
{
if (curtag == NULL)
return (NULL_POSITION); /* No gtags loaded! */
@@ -216,9 +205,7 @@ tagsearch(VOID_PARAM)
/*
* Go to the next tag.
*/
- public char *
-nexttag(n)
- int n;
+public char * nexttag(int n)
{
char *tagfile = (char *) NULL;
@@ -230,9 +217,7 @@ nexttag(n)
/*
* Go to the previous tag.
*/
- public char *
-prevtag(n)
- int n;
+public char * prevtag(int n)
{
char *tagfile = (char *) NULL;
@@ -244,8 +229,7 @@ prevtag(n)
/*
* Return the total number of tags.
*/
- public int
-ntags(VOID_PARAM)
+public int ntags(void)
{
return total;
}
@@ -253,8 +237,7 @@ ntags(VOID_PARAM)
/*
* Return the sequence number of current tag.
*/
- public int
-curr_tag(VOID_PARAM)
+public int curr_tag(void)
{
return curseq;
}
@@ -267,9 +250,7 @@ curr_tag(VOID_PARAM)
* Find tags in the "tags" file.
* Sets curtag to the first tag entry.
*/
- static enum tag_result
-findctag(tag)
- char *tag;
+static enum tag_result findctag(char *tag)
{
char *p;
char *q;
@@ -387,18 +368,14 @@ findctag(tag)
/*
* Edit current tagged file.
*/
- public int
-edit_tagfile(VOID_PARAM)
+public int edit_tagfile(void)
{
if (curtag == NULL)
return (1);
return (edit(curtag->tag_file));
}
- static int
-curtag_match(line, linepos)
- char constant *line;
- POSITION linepos;
+static int curtag_match(char constant *line, POSITION linepos)
{
/*
* Test the line to see if we have a match.
@@ -426,8 +403,7 @@ curtag_match(line, linepos)
* regcmp vs. re_comp) behave differently in the presence of
* parentheses (which are almost always found in a tag).
*/
- static POSITION
-ctagsearch(VOID_PARAM)
+static POSITION ctagsearch(void)
{
POSITION pos, linepos;
LINENUM linenum;
@@ -505,10 +481,7 @@ ctagsearch(VOID_PARAM)
* for future use by gtagsearch().
* Sets curtag to the first tag entry.
*/
- static enum tag_result
-findgtag(tag, type)
- char *tag; /* tag to load */
- int type; /* tags type */
+static enum tag_result findgtag(char *tag, int type)
{
char buf[1024];
FILE *fp;
@@ -640,8 +613,7 @@ static int circular = 0; /* 1: circular tag structure */
* by findgtag(). The next call to gtagsearch() will try to position at the
* appropriate tag.
*/
- static char *
-nextgtag(VOID_PARAM)
+static char * nextgtag(void)
{
struct tag *tp;
@@ -670,8 +642,7 @@ nextgtag(VOID_PARAM)
* setup by findgtat(). The next call to gtagsearch() will try to position
* at the appropriate tag.
*/
- static char *
-prevgtag(VOID_PARAM)
+static char * prevgtag(void)
{
struct tag *tp;
@@ -700,8 +671,7 @@ prevgtag(VOID_PARAM)
* using either findtag() or one of nextgtag() and prevgtag(). Returns -1
* if it was unable to position at the tag, 0 if successful.
*/
- static POSITION
-gtagsearch(VOID_PARAM)
+static POSITION gtagsearch(void)
{
if (curtag == NULL)
return (NULL_POSITION); /* No gtags loaded! */
@@ -736,12 +706,7 @@ gtagsearch(VOID_PARAM)
* The tag, file, and line will each be NUL-terminated pointers
* into buf.
*/
- static int
-getentry(buf, tag, file, line)
- char *buf; /* standard or extended ctags -x format data */
- char **tag; /* name of the tag we actually found */
- char **file; /* file in which to find this tag */
- char **line; /* line number of file where this tag is found */
+static int getentry(char *buf, char **tag, char **file, char **line)
{
char *p = buf;
diff --git a/ttyin.c b/ttyin.c
index 4be4527530d9..96486f53769b 100644
--- a/ttyin.c
+++ b/ttyin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -30,16 +30,13 @@ public int tty;
#endif
#if LESSTEST
public char *ttyin_name = NULL;
-public int rstat_file = -1;
#endif /*LESSTEST*/
extern int sigs;
extern int utf_mode;
extern int wheel_lines;
#if !MSDOS_COMPILER
- static int
-open_tty_device(dev)
- constant char* dev;
+static int open_tty_device(constant char* dev)
{
#if OS2
/* The __open() system call translates "/dev/tty" to "con". */
@@ -55,8 +52,7 @@ open_tty_device(dev)
* In Unix, file descriptor 2 is usually attached to the screen,
* but also usually lets you read from the keyboard.
*/
- public int
-open_tty(VOID_PARAM)
+public int open_tty(void)
{
int fd = -1;
#if LESSTEST
@@ -82,8 +78,7 @@ open_tty(VOID_PARAM)
/*
* Open keyboard for input.
*/
- public void
-open_getchr(VOID_PARAM)
+public void open_getchr(void)
{
#if MSDOS_COMPILER==WIN32C
/* Need this to let child processes inherit our console handle */
@@ -123,8 +118,7 @@ open_getchr(VOID_PARAM)
/*
* Close the keyboard.
*/
- public void
-close_getchr(VOID_PARAM)
+public void close_getchr(void)
{
#if MSDOS_COMPILER==WIN32C
SetConsoleMode(tty, console_mode);
@@ -136,9 +130,7 @@ close_getchr(VOID_PARAM)
/*
* Close the pipe, restoring the keyboard (CMD resets it, losing the mouse).
*/
- int
-pclose(f)
- FILE *f;
+public int pclose(FILE *f)
{
int result;
@@ -151,8 +143,7 @@ pclose(f)
/*
* Get the number of lines to scroll when mouse wheel is moved.
*/
- public int
-default_wheel_lines(VOID_PARAM)
+public int default_wheel_lines(void)
{
int lines = 1;
#if MSDOS_COMPILER==WIN32C
@@ -165,23 +156,10 @@ default_wheel_lines(VOID_PARAM)
return lines;
}
-#if LESSTEST
- public void
-rstat(st)
- char st;
-{
- if (rstat_file < 0)
- return;
- lseek(rstat_file, SEEK_SET, 0);
- write(rstat_file, &st, 1);
-}
-#endif /*LESSTEST*/
-
/*
* Get a character from the keyboard.
*/
- public int
-getchr(VOID_PARAM)
+public int getchr(void)
{
char c;
int result;
@@ -204,17 +182,11 @@ getchr(VOID_PARAM)
if (c == '\003')
return (READ_INTR);
#else
-#if LESSTEST
- rstat('R');
-#endif /*LESSTEST*/
{
unsigned char uc;
result = iread(tty, &uc, sizeof(char));
c = (char) uc;
}
-#if LESSTEST
- rstat('B');
-#endif /*LESSTEST*/
if (result == READ_INTR)
return (READ_INTR);
if (result < 0)
@@ -226,6 +198,14 @@ getchr(VOID_PARAM)
quit(QUIT_ERROR);
}
#endif
+#if LESSTEST
+ if (c == LESS_DUMP_CHAR)
+ {
+ dump_screen();
+ result = 0;
+ continue;
+ }
+#endif
#if 0 /* allow entering arbitrary hex chars for testing */
/* ctrl-A followed by two hex chars makes a byte */
{
diff --git a/ubin.uni b/ubin.uni
index 661cccb03542..14e651997348 100644
--- a/ubin.uni
+++ b/ubin.uni
@@ -1,17 +1,11 @@
-/* Generated by "./mkutable -f2 Cc Cs Co Zl Zp -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:17 PDT 2022 */
+/* Generated by "./mkutable -f2 Cc Cs Co Zl Zp -- unicode/UnicodeData.txt" on Mon Nov 14 18:19:24 PST 2022 */
{ 0x0000, 0x0007 }, /* Cc */
{ 0x000b, 0x000b }, /* Cc */
{ 0x000e, 0x001f }, /* Cc */
{ 0x007f, 0x009f }, /* Cc */
{ 0x2028, 0x2028 }, /* Zl */
{ 0x2029, 0x2029 }, /* Zp */
- { 0xd800, 0xd800 }, /* Cs */
- { 0xdb7f, 0xdb80 }, /* Cs */
- { 0xdbff, 0xdc00 }, /* Cs */
- { 0xdfff, 0xdfff }, /* Cs */
- { 0xe000, 0xe000 }, /* Co */
- { 0xf8ff, 0xf8ff }, /* Co */
- { 0xf0000, 0xf0000 }, /* Co */
- { 0xffffd, 0xffffd }, /* Co */
- { 0x100000, 0x100000 }, /* Co */
- { 0x10fffd, 0x10fffd }, /* Co */
+ { 0xd800, 0xdfff }, /* Cs */
+ { 0xe000, 0xf8ff }, /* Co */
+ { 0xf0000, 0xffffd }, /* Co */
+ { 0x100000, 0x10fffd }, /* Co */
diff --git a/version.c b/version.c
index 44e811604ca6..b0e4e6668da3 100644
--- a/version.c
+++ b/version.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2022 Mark Nudelman
+ * Copyright (C) 1984-2023 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.
@@ -954,6 +954,33 @@ v606 7/17/22 Fix bug with multibyte chars and --incsearch;
escape filenames in LESSCLOSE; fix bin_file overrun.
v607 7/19/22 Update Unicode tables.
v608 7/22/22 Fix highlighting on colored text boundaries.
+v609 11/10/22 Add LESSUTFCHARDEF; fix overstrike color bug;
+ fix procfs bug; fix signal race.
+v610 11/14/22 Update Unicode tables; fix again-search after filter;
+ improve ^X to interrupt F command.
+v611 11/16/22 Fix EOF bug related to ^X change.
+v612 11/18/22 Fix more bugs related to ^X change.
+v613 11/28/22 Even more ^X issues.
+v614 11/28/22 Add ^X to wait message.
+v615 11/30/22 Add --no-vbell option.
+v616 12/9/22 Don't open tty as input file without -f.
+v617 12/10/22 Support poll on newer versions of MacOS.
+v618 12/29/22 Add --no-search-headers option; use C89 function definitions.
+v619 12/30/22 Fix bug using 'n' before '/'.
+v620 1/12/23 Add --modelines option; add --intr option;
+ add subpattern coloring.
+v621 1/15/23 Add --wordwrap option; add LESS_LINES & LESS_COLUMNS.
+v622 1/27/23 Add --show-preproc-errors option.
+v623 2/2/23 Add # command; add ^S search modifier.
+v624 2/11/23 Add --proc-backspace, --proc-tab and --proc-return options.
+v625 2/16/23 Minor fixes.
+v626 2/19/23 Fix rare crash in add_attr_normal.
+v627 2/19/23 Doc.
+v628 2/20/23 Don't require newline after +&...
+v629 2/26/23 Delay "waiting for data" message for 500 ms.
+v630 3/18/23 Add LESS_DATA_DELAY.
+v631 3/26/23 Fix input of dead keys on Windows.
+v632 4/6/23 Make lesstest work on MacOS; minor fixes.
*/
-char version[] = "608";
+char version[] = "632";
diff --git a/wide.uni b/wide.uni
index 0e9922373409..51a762999f57 100644
--- a/wide.uni
+++ b/wide.uni
@@ -1,4 +1,4 @@
-/* Generated by "./mkutable -f1 W F -- unicode/EastAsianWidth.txt" on Tue Jul 19 12:45:19 PDT 2022 */
+/* Generated by "./mkutable -f1 W F -- unicode/EastAsianWidth.txt" on Mon Nov 14 18:19:24 PST 2022 */
{ 0x1100, 0x115f }, /* W */
{ 0x231a, 0x231b }, /* W */
{ 0x2329, 0x232a }, /* W */
@@ -68,7 +68,9 @@
{ 0x1aff5, 0x1affb }, /* W */
{ 0x1affd, 0x1affe }, /* W */
{ 0x1b000, 0x1b122 }, /* W */
+ { 0x1b132, 0x1b132 }, /* W */
{ 0x1b150, 0x1b152 }, /* W */
+ { 0x1b155, 0x1b155 }, /* W */
{ 0x1b164, 0x1b167 }, /* W */
{ 0x1b170, 0x1b2fb }, /* W */
{ 0x1f004, 0x1f004 }, /* W */
@@ -102,7 +104,7 @@
{ 0x1f6cc, 0x1f6cc }, /* W */
{ 0x1f6d0, 0x1f6d2 }, /* W */
{ 0x1f6d5, 0x1f6d7 }, /* W */
- { 0x1f6dd, 0x1f6df }, /* W */
+ { 0x1f6dc, 0x1f6df }, /* W */
{ 0x1f6eb, 0x1f6ec }, /* W */
{ 0x1f6f4, 0x1f6fc }, /* W */
{ 0x1f7e0, 0x1f7eb }, /* W */
@@ -110,14 +112,12 @@
{ 0x1f90c, 0x1f93a }, /* W */
{ 0x1f93c, 0x1f945 }, /* W */
{ 0x1f947, 0x1f9ff }, /* W */
- { 0x1fa70, 0x1fa74 }, /* W */
- { 0x1fa78, 0x1fa7c }, /* W */
- { 0x1fa80, 0x1fa86 }, /* W */
- { 0x1fa90, 0x1faac }, /* W */
- { 0x1fab0, 0x1faba }, /* W */
- { 0x1fac0, 0x1fac5 }, /* W */
- { 0x1fad0, 0x1fad9 }, /* W */
- { 0x1fae0, 0x1fae7 }, /* W */
- { 0x1faf0, 0x1faf6 }, /* W */
+ { 0x1fa70, 0x1fa7c }, /* W */
+ { 0x1fa80, 0x1fa88 }, /* W */
+ { 0x1fa90, 0x1fabd }, /* W */
+ { 0x1fabf, 0x1fac5 }, /* W */
+ { 0x1face, 0x1fadb }, /* W */
+ { 0x1fae0, 0x1fae8 }, /* W */
+ { 0x1faf0, 0x1faf8 }, /* W */
{ 0x20000, 0x2fffd }, /* W */
{ 0x30000, 0x3fffd }, /* W */
diff --git a/xbuf.c b/xbuf.c
index 4e767e34d193..1ed369e175f2 100644
--- a/xbuf.c
+++ b/xbuf.c
@@ -4,43 +4,35 @@
/*
* Initialize an expandable text buffer.
*/
- public void
-xbuf_init(xbuf)
- struct xbuffer *xbuf;
+public void xbuf_init(struct xbuffer *xbuf)
{
xbuf->data = NULL;
xbuf->size = xbuf->end = 0;
}
- public void
-xbuf_deinit(xbuf)
- struct xbuffer *xbuf;
+public void xbuf_deinit(struct xbuffer *xbuf)
{
if (xbuf->data != NULL)
free(xbuf->data);
xbuf_init(xbuf);
}
- public void
-xbuf_reset(xbuf)
- struct xbuffer *xbuf;
+public void xbuf_reset(struct xbuffer *xbuf)
{
xbuf->end = 0;
}
/*
- * Add a char to an expandable text buffer.
+ * Add a byte to an expandable text buffer.
*/
- public void
-xbuf_add(xbuf, ch)
- struct xbuffer *xbuf;
- int ch;
+public void xbuf_add_byte(struct xbuffer *xbuf, unsigned char b)
{
if (xbuf->end >= xbuf->size)
{
- char *data;
- xbuf->size = (xbuf->size == 0) ? 16 : xbuf->size * 2;
- data = (char *) ecalloc(xbuf->size, sizeof(char));
+ unsigned char *data;
+ if (ckd_add(&xbuf->size, xbuf->size, xbuf->size ? xbuf->size : 16))
+ out_of_memory();
+ data = (unsigned char *) ecalloc(xbuf->size, sizeof(unsigned char));
if (xbuf->data != NULL)
{
memcpy(data, xbuf->data, xbuf->end);
@@ -48,26 +40,124 @@ xbuf_add(xbuf, ch)
}
xbuf->data = data;
}
- xbuf->data[xbuf->end++] = ch;
+ xbuf->data[xbuf->end++] = (unsigned char) b;
}
- public int
-xbuf_pop(buf)
- struct xbuffer *buf;
+public void xbuf_add_data(struct xbuffer *xbuf, unsigned char *data, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ xbuf_add_byte(xbuf, data[i]);
+}
+
+public int xbuf_pop(struct xbuffer *buf)
{
if (buf->end == 0)
return -1;
- return buf->data[--(buf->end)];
+ return (int) buf->data[--(buf->end)];
}
- public void
-xbuf_set(dst, src)
- struct xbuffer *dst;
- struct xbuffer *src;
+public void xbuf_set(struct xbuffer *dst, struct xbuffer *src)
{
- int i;
-
xbuf_reset(dst);
- for (i = 0; i < src->end; i++)
- xbuf_add(dst, src->data[i]);
+ xbuf_add_data(dst, src->data, src->end);
+}
+
+public char * xbuf_char_data(struct xbuffer *xbuf)
+{
+ return (char *)(xbuf->data);
+}
+
+
+/*
+ * Helper functions for the ckd_add and ckd_mul macro substitutes.
+ * These helper functions do not set *R on overflow, and assume that
+ * arguments are nonnegative, that INTMAX_MAX <= UINTMAX_MAX, and that
+ * sizeof is a reliable way to distinguish integer representations.
+ * Despite these limitations they are good enough for 'less' on all
+ * known practical platforms. For more-complicated substitutes
+ * without most of these limitations, see Gnulib's stdckdint module.
+ */
+#if !HAVE_STDCKDINT_H
+/*
+ * If the integer *R can represent VAL, store the value and return FALSE.
+ * Otherwise, possibly set *R to an indeterminate value and return TRUE.
+ * R has size RSIZE, and is signed if and only if RSIGNED is nonzero.
+ */
+static int help_fixup(void *r, uintmax val, int rsize, int rsigned)
+{
+ if (rsigned)
+ {
+ if (rsize == sizeof (int))
+ {
+ int *pr = r;
+ if (INT_MAX < val)
+ return TRUE;
+ *pr = val;
+#ifdef LLONG_MAX
+ } else if (rsize == sizeof (long long))
+ {
+ long long *pr = r;
+ if (LLONG_MAX < val)
+ return TRUE;
+ *pr = val;
+#endif
+#ifdef INTMAX_MAX
+ } else if (rsize == sizeof (intmax_t)) {
+ intmax_t *pr = r;
+ if (INTMAX_MAX < val)
+ return TRUE;
+ *pr = val;
+#endif
+ } else /* rsize == sizeof (long) */
+ {
+ long *pr = r;
+ if (LONG_MAX < val)
+ return TRUE;
+ *pr = val;
+ }
+ } else {
+ if (rsize == sizeof (unsigned)) {
+ unsigned *pr = r;
+ if (UINT_MAX < val)
+ return TRUE;
+ *pr = val;
+ } else if (rsize == sizeof (unsigned long)) {
+ unsigned long *pr = r;
+ if (ULONG_MAX < val)
+ return TRUE;
+ *pr = val;
+#ifdef ULLONG_MAX
+ } else if (rsize == sizeof (unsigned long long)) {
+ long long *pr = r;
+ if (ULLONG_MAX < val)
+ return TRUE;
+ *pr = val;
+#endif
+ } else /* rsize == sizeof (uintmax) */
+ {
+ uintmax *pr = r;
+ *pr = val;
+ }
+ }
+ return FALSE;
+}
+/*
+ * If *R can represent the mathematical sum of A and B, store the sum
+ * and return FALSE. Otherwise, possibly set *R to an indeterminate
+ * value and return TRUE. R has size RSIZE, and is signed if and only
+ * if RSIGNED is nonzero.
+ */
+public int help_ckd_add(void *r, uintmax a, uintmax b, int rsize, int rsigned)
+{
+ uintmax sum = a + b;
+ return sum < a || help_fixup(r, sum, rsize, rsigned);
+}
+/* Likewise, but for the product of A and B. */
+public int help_ckd_mul(void *r, uintmax a, uintmax b, int rsize, int rsigned)
+{
+ uintmax product = a * b;
+ return ((b != 0 && a != product / b)
+ || help_fixup(r, product, rsize, rsigned));
}
+#endif
diff --git a/xbuf.h b/xbuf.h
index d317e17868d5..acd5485ca4ef 100644
--- a/xbuf.h
+++ b/xbuf.h
@@ -3,14 +3,17 @@
struct xbuffer
{
- char *data;
+ unsigned char *data;
int end;
int size;
};
void xbuf_init(struct xbuffer *xbuf);
+void xbuf_deinit(struct xbuffer *xbuf);
void xbuf_reset(struct xbuffer *xbuf);
-void xbuf_add(struct xbuffer *xbuf, int ch);
+void xbuf_add_byte(struct xbuffer *xbuf, unsigned char b);
+void xbuf_add_data(struct xbuffer *xbuf, unsigned char *data, int len);
int xbuf_pop(struct xbuffer *xbuf);
+char *xbuf_char_data(struct xbuffer *xbuf);
#endif