From 6f90225e8378d85045013553763bd7483670441c Mon Sep 17 00:00:00 2001 From: Xin LI Date: Sat, 29 Apr 2017 06:30:21 +0000 Subject: Vendor import of less v491. --- Makefile.aut | 4 +- Makefile.dsg | 4 - NEWS | 14 ++ README | 4 +- brac.c | 10 +- ch.c | 44 ++--- charset.c | 37 ++-- charset.h | 2 +- cmd.h | 2 +- cmdbuf.c | 40 ++-- command.c | 24 +-- configure | 24 +++ configure.ac | 10 + cvt.c | 4 +- decode.c | 32 ++-- defines.ds | 7 +- defines.h.in | 5 + defines.o2 | 7 +- defines.o9 | 7 +- defines.wn | 7 +- edit.c | 10 +- filename.c | 20 +- forwback.c | 24 ++- funcs.h | 599 ++++++++++++++++++++++++++++++----------------------------- ifile.c | 18 +- input.c | 4 +- jump.c | 4 +- less.h | 13 +- less.man | 4 +- less.nro | 4 +- lessecho.c | 2 +- lessecho.man | 2 +- lessecho.nro | 2 +- lesskey.c | 30 +-- lesskey.h | 2 +- lesskey.man | 4 +- lesskey.nro | 4 +- lglob.h | 2 +- line.c | 20 +- linenum.c | 22 +-- lsystem.c | 12 +- main.c | 33 +++- mark.c | 10 +- mkfuncs.awk | 9 - mkfuncs.pl | 27 +++ mkhelp.c | 2 +- optfunc.c | 22 +-- option.c | 20 +- option.h | 4 +- opttbl.c | 12 +- os.c | 13 +- output.c | 22 +-- pattern.c | 144 +++++++------- pattern.h | 20 +- pckeys.h | 2 +- position.c | 14 +- position.h | 2 +- prompt.c | 10 +- screen.c | 18 +- scrsize.c | 2 +- search.c | 9 +- signal.c | 4 +- tags.c | 18 +- ttyin.c | 8 +- version.c | 14 +- 65 files changed, 831 insertions(+), 698 deletions(-) delete mode 100644 mkfuncs.awk create mode 100644 mkfuncs.pl diff --git a/Makefile.aut b/Makefile.aut index 9cc04cea2735..24ee3f200901 100644 --- a/Makefile.aut +++ b/Makefile.aut @@ -32,7 +32,7 @@ DISTFILES = \ install.sh defines.h.in mkinstalldirs \ less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \ less.hlp \ - mkfuncs.awk mkhelp.c \ + mkfuncs.pl mkhelp.c \ mkutable $(UNICODE_FILES) \ ${DISTFILES_W} @@ -61,7 +61,7 @@ ${srcdir}/configure: ${srcdir}/configure.ac \ funcs.h: ${SRC:%=${srcdir}/%} -mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old - awk -f ${srcdir}/mkfuncs.awk ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h + perl ${srcdir}/mkfuncs.pl ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h if cmp -s funcs.h funcs.h.old; then mv -f funcs.h.old funcs.h; fi lint: diff --git a/Makefile.dsg b/Makefile.dsg index b921b5dec9be..4c11be0e6464 100644 --- a/Makefile.dsg +++ b/Makefile.dsg @@ -73,10 +73,6 @@ installcheck: TAGS: etags *.c *.h -newfuncs: - command.com /c if exist funcs.h del funcs.h - ${AWK} -f mkfuncs.awk ${OBJ:.${O}=.c} > funcs.h - clean: command.com /c for %f in (*.${O} less lesskey lessecho *.exe) do if exist %f del %f diff --git a/NEWS b/NEWS index ebdce64b4d01..e8bb6efc0019 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,20 @@ To report bugs, suggestions or comments, send email to bug-less@gnu.org +====================================================================== + + Major changes between "less" versions 487 and 491 + +* Don't output terminal init sequence if using -F and file fits on one screen. + +* Use ANSI prototypes in funcs.h declarations. + +* Fix some const mismatches. + +* Remove "register" in variable declarations. + +* Fix some memory leaks. + ====================================================================== Major changes between "less" versions 481 and 487 diff --git a/README b/README index ee8903dec2b0..81bb95ab7962 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ - Less, version 487 + Less, version 491 - This is the distribution of less, version 487, released 25 Oct 2016. + This is the distribution of less, version 491, released 07 Apr 2017. This program is part of the GNU project (http://www.gnu.org). This program is free software. You may redistribute it and/or diff --git a/brac.c b/brac.c index 5119f4e59f0b..44f240361cbd 100644 --- a/brac.c +++ b/brac.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,13 +25,13 @@ */ public void match_brac(obrac, cbrac, forwdir, n) - register int obrac; - register int cbrac; + int obrac; + int cbrac; int forwdir; int n; { - register int c; - register int nest; + int c; + int nest; POSITION pos; int (*chget)(); diff --git a/ch.c b/ch.c index ddebb73a9cb0..0fc65aca2848 100644 --- a/ch.c +++ b/ch.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -146,11 +146,11 @@ static int ch_addbuf(); int ch_get() { - register struct buf *bp; - register struct bufnode *bn; - register int n; - register int slept; - register int h; + struct buf *bp; + struct bufnode *bn; + int n; + int slept; + int h; POSITION pos; POSITION len; @@ -419,8 +419,8 @@ end_logfile() public void sync_logfile() { - register struct buf *bp; - register struct bufnode *bn; + struct buf *bp; + struct bufnode *bn; int warned = FALSE; BLOCKNUM block; BLOCKNUM nblocks; @@ -457,9 +457,9 @@ sync_logfile() buffered(block) BLOCKNUM block; { - register struct buf *bp; - register struct bufnode *bn; - register int h; + struct buf *bp; + struct bufnode *bn; + int h; h = BUFHASH(block); FOR_BUFS_IN_CHAIN(h, bn) @@ -477,7 +477,7 @@ buffered(block) */ public int ch_seek(pos) - register POSITION pos; + POSITION pos; { BLOCKNUM new_block; POSITION len; @@ -544,8 +544,8 @@ ch_end_seek() public int ch_end_buffer_seek() { - register struct buf *bp; - register struct bufnode *bn; + struct buf *bp; + struct bufnode *bn; POSITION buf_pos; POSITION end_pos; @@ -572,8 +572,8 @@ ch_end_buffer_seek() public int ch_beg_seek() { - register struct bufnode *bn; - register struct bufnode *firstbn; + struct bufnode *bn; + struct bufnode *firstbn; /* * Try a plain ch_seek first. @@ -632,7 +632,7 @@ ch_tell() public int ch_forw_get() { - register int c; + int c; if (thisfile == NULL) return (EOI); @@ -695,7 +695,7 @@ ch_setbufspace(bufspace) public void ch_flush() { - register struct bufnode *bn; + struct bufnode *bn; if (thisfile == NULL) return; @@ -762,8 +762,8 @@ ch_flush() static int ch_addbuf() { - register struct buf *bp; - register struct bufnode *bn; + struct buf *bp; + struct bufnode *bn; /* * Allocate and initialize a new buffer and link it @@ -787,7 +787,7 @@ ch_addbuf() static void init_hashtbl() { - register int h; + int h; for (h = 0; h < BUFHASH_SIZE; h++) { @@ -802,7 +802,7 @@ init_hashtbl() static void ch_delbufs() { - register struct bufnode *bn; + struct bufnode *bn; while (ch_bufhead != END_OF_CHAIN) { diff --git a/charset.c b/charset.c index 16613cc79396..7aec0ea140e8 100644 --- a/charset.c +++ b/charset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -135,9 +135,9 @@ public int binattr = AT_STANDOUT; ichardef(s) char *s; { - register char *cp; - register int n; - register char v; + char *cp; + int n; + char v; n = 0; v = 0; @@ -190,11 +190,11 @@ ichardef(s) */ static int icharset(name, no_error) - register char *name; + char *name; int no_error; { - register struct charset *p; - register struct cs_alias *a; + struct charset *p; + struct cs_alias *a; if (name == NULL || *name == '\0') return (0); @@ -234,7 +234,7 @@ icharset(name, no_error) static void ilocale() { - register int c; + int c; for (c = 0; c < (int) sizeof(chardef); c++) { @@ -486,7 +486,7 @@ prutfchar(ch) */ public int utf_len(ch) - char ch; + unsigned char ch; { if ((ch & 0x80) == 0) return 1; @@ -508,17 +508,18 @@ utf_len(ch) * Does the parameter point to the lead byte of a well-formed UTF-8 character? */ public int -is_utf8_well_formed(s, slen) - unsigned char *s; +is_utf8_well_formed(ss, slen) + char *ss; int slen; { int i; int len; + unsigned char *s = (unsigned char *) ss; if (IS_UTF8_INVALID(s[0])) return (0); - len = utf_len((char) s[0]); + len = utf_len(s[0]); if (len > slen) return (0); if (len == 1) @@ -546,7 +547,7 @@ is_utf8_well_formed(s, slen) */ public int utf_bin_count(data, len) - unsigned char *data; + char *data; int len; { int bin_count = 0; @@ -554,7 +555,7 @@ utf_bin_count(data, len) { if (is_utf8_well_formed(data, len)) { - int clen = utf_len(*data); + int clen = utf_len(*data & 0377); data += clen; len -= clen; } else @@ -564,7 +565,7 @@ utf_bin_count(data, len) do { ++data; --len; - } while (len > 0 && !IS_UTF8_LEAD(*data)); + } while (len > 0 && !IS_UTF8_LEAD(*data & 0377)); } } return (bin_count); @@ -575,7 +576,7 @@ utf_bin_count(data, len) */ public LWCHAR get_wchar(p) - char *p; + constant char *p; { switch (utf_len(p[0])) { @@ -679,7 +680,7 @@ put_wchar(pp, ch) step_char(pp, dir, limit) char **pp; signed int dir; - char *limit; + constant char *limit; { LWCHAR ch; int len; @@ -698,7 +699,7 @@ step_char(pp, dir, limit) if (p + len > limit) { ch = 0; - p = limit; + p = (char *) limit; } else { ch = get_wchar(p); diff --git a/charset.h b/charset.h index a4e3bf1d96b4..1e3f0691069a 100644 --- a/charset.h +++ b/charset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 dd07ff8fd5fb..0c221b83459a 100644 --- a/cmd.h +++ b/cmd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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/cmdbuf.c b/cmdbuf.c index 540b84d4d709..02fa231f2e29 100644 --- a/cmdbuf.c +++ b/cmdbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -76,25 +76,25 @@ struct mlist */ struct mlist mlist_search = { &mlist_search, &mlist_search, &mlist_search, NULL, 0 }; -public void * constant ml_search = (void *) &mlist_search; +public void *ml_search = (void *) &mlist_search; struct mlist mlist_examine = { &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 }; -public void * constant ml_examine = (void *) &mlist_examine; +public void *ml_examine = (void *) &mlist_examine; #if SHELL_ESCAPE || PIPEC struct mlist mlist_shell = { &mlist_shell, &mlist_shell, &mlist_shell, NULL, 0 }; -public void * constant ml_shell = (void *) &mlist_shell; +public void *ml_shell = (void *) &mlist_shell; #endif #else /* CMD_HISTORY */ /* If CMD_HISTORY is off, these are just flags. */ -public void * constant ml_search = (void *)1; -public void * constant ml_examine = (void *)2; +public void *ml_search = (void *)1; +public void *ml_examine = (void *)2; #if SHELL_ESCAPE || PIPEC -public void * constant ml_shell = (void *)3; +public void *ml_shell = (void *)3; #endif #endif /* CMD_HISTORY */ @@ -141,14 +141,14 @@ clear_cmd() */ public void cmd_putstr(s) - char *s; + constant char *s; { LWCHAR prev_ch = 0; LWCHAR ch; - char *endline = s + strlen(s); + constant char *endline = s + strlen(s); while (*s != '\0') { - char *ns = s; + char *ns = (char *) s; int width; ch = step_char(&ns, +1, endline); while (s < ns) @@ -262,7 +262,7 @@ cmd_step_left(pp, pwidth, bswidth) */ static void cmd_repaint(old_cp) - char *old_cp; + constant char *old_cp; { /* * Repaint the line from the current position. @@ -323,8 +323,8 @@ cmd_home() static void cmd_lshift() { - char *s; - char *save_cp; + constant char *s; + constant char *save_cp; int cols; /* @@ -342,7 +342,7 @@ cmd_lshift() while (*s != '\0') { int width; - char *ns = s; + constant char *ns = s; cmd_step_right(&ns, &width, NULL); if (width > 0) break; @@ -361,8 +361,8 @@ cmd_lshift() static void cmd_rshift() { - char *s; - char *save_cp; + constant char *s; + constant char *save_cp; int cols; /* @@ -493,7 +493,7 @@ cmd_ichar(cs, clen) static int cmd_erase() { - register char *s; + char *s; int clen; if (cp == cmdbuf) @@ -661,7 +661,7 @@ set_mlist(mlist, cmdflags) cmd_updown(action) int action; { - char *s; + constant char *s; struct mlist *ml; if (curr_mlist == NULL) @@ -723,7 +723,7 @@ cmd_updown(action) public void cmd_addhist(mlist, cmd, modified) struct mlist *mlist; - char *cmd; + constant char *cmd; int modified; { #if CMD_HISTORY @@ -940,7 +940,7 @@ delimit_word() char *p; int delim_quoted = 0; int meta_quoted = 0; - char *esc = get_meta_escape(); + constant char *esc = get_meta_escape(); int esclen = (int) strlen(esc); #endif diff --git a/command.c b/command.c index 955a18fbdeac..56d22c688361 100644 --- a/command.c +++ b/command.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,10 @@ extern char *curr_altfilename; extern char version[]; extern struct scrpos initial_scrpos; extern IFILE curr_ifile; -extern void constant *ml_search; -extern void constant *ml_examine; +extern void *ml_search; +extern void *ml_examine; #if SHELL_ESCAPE || PIPEC -extern void constant *ml_shell; +extern void *ml_shell; #endif #if EDITOR extern char *editor; @@ -106,7 +106,7 @@ cmd_exec() start_mca(action, prompt, mlist, cmdflags) int action; constant char *prompt; - constant void *mlist; + void *mlist; int cmdflags; { mca = action; @@ -206,7 +206,7 @@ mca_opt_toggle() static void exec_mca() { - register char *cbuf; + char *cbuf; cmd_exec(); cbuf = get_cmdbuf(); @@ -685,7 +685,7 @@ make_display() static void prompt() { - register constant char *p; + constant char *p; if (ungot != NULL && !ungot->ug_end_command) { @@ -849,7 +849,7 @@ ungetcc(c) ungetsc(s) char *s; { - register char *p; + char *p; for (p = s + strlen(s) - 1; p >= s; p--) ungetcc(*p); @@ -866,7 +866,7 @@ multi_search(pattern, n, silent) int n; int silent; { - register int nomore; + int nomore; IFILE save_ifile; int changed_file; @@ -1001,9 +1001,9 @@ forw_loop(until_hilite) public void commands() { - register int c; - register int action; - register char *cbuf; + int c; + int action; + char *cbuf; int newaction; int save_search_type; char *extra; diff --git a/configure b/configure index 53b4634d07ab..10a0305e7282 100755 --- a/configure +++ b/configure @@ -4713,6 +4713,30 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Checks for ANSI function prototypes. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI function prototypes" >&5 +$as_echo_n "checking for ANSI function prototypes... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +int f(int a) { return a; } + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_ANSI_PROTOS 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_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; } diff --git a/configure.ac b/configure.ac index 42bdd6b2cbd0..383f840c5335 100644 --- a/configure.ac +++ b/configure.ac @@ -251,6 +251,11 @@ AC_TRY_COMPILE([#include [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)]) +# 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)]) + # Checks for library functions. AC_TYPE_SIGNAL AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod]) @@ -620,6 +625,11 @@ AH_TOP([ */ #define TGETENT_OK 1 +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/cvt.c b/cvt.c index dc20b9c7b22a..54473e0c0863 100644 --- a/cvt.c +++ b/cvt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -65,7 +65,7 @@ cvt_text(odst, osrc, chpos, lenp, ops) char *dst; char *edst = odst; char *src; - register char *src_end; + char *src_end; LWCHAR ch; if (lenp != NULL) diff --git a/decode.c b/decode.c index a24f6efb7acf..851672a1b0df 100644 --- a/decode.c +++ b/decode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,9 @@ expand_special_keys(table, len) char *table; int len; { - register char *fm; - register char *to; - register int a; + char *fm; + char *to; + int a; char *repl; int klen; @@ -329,7 +329,7 @@ add_cmd_table(tlist, buf, len) char *buf; int len; { - register struct tablelist *t; + struct tablelist *t; if (len == 0) return (0); @@ -397,9 +397,9 @@ cmd_search(cmd, table, endtable, sp) char *endtable; char **sp; { - register char *p; - register char *q; - register int a; + char *p; + char *q; + int a; *sp = NULL; for (p = table, q = cmd; p < endtable; p++, q++) @@ -488,8 +488,8 @@ cmd_decode(tlist, cmd, sp) char *cmd; char **sp; { - register struct tablelist *t; - register int action = A_INVALID; + struct tablelist *t; + int action = A_INVALID; /* * Search thru all the command tables. @@ -599,8 +599,8 @@ new_lesskey(buf, len, sysvar) int sysvar; { char *p; - register int c; - register int n; + int c; + int n; /* * New-style lesskey file. @@ -651,10 +651,10 @@ lesskey(filename, sysvar) char *filename; int sysvar; { - register char *buf; - register POSITION len; - register long n; - register int f; + char *buf; + POSITION len; + long n; + int f; if (secure) return (1); diff --git a/defines.ds b/defines.ds index 6009129db2a5..80a2d7b1b659 100644 --- a/defines.ds +++ b/defines.ds @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -145,6 +145,11 @@ */ #define PATHNAME_SEP "\\" +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/defines.h.in b/defines.h.in index 46232c0e4510..161f928e1027 100644 --- a/defines.h.in +++ b/defines.h.in @@ -133,6 +133,11 @@ */ #define TGETENT_OK 1 +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/defines.o2 b/defines.o2 index 615686b8a80a..4dba1423c080 100644 --- a/defines.o2 +++ b/defines.o2 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -126,6 +126,11 @@ */ #define PATHNAME_SEP "\\" +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/defines.o9 b/defines.o9 index 2e7b95745713..99983d726a97 100644 --- a/defines.o9 +++ b/defines.o9 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -129,6 +129,11 @@ */ #define PATHNAME_SEP "/" +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/defines.wn b/defines.wn index 6d6e242df0cb..98ca9905862a 100644 --- a/defines.wn +++ b/defines.wn @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -127,6 +127,11 @@ */ #define PATHNAME_SEP "\\" +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + /* * HAVE_SYS_TYPES_H is 1 if your system has . */ diff --git a/edit.c b/edit.c index c508f94aaf02..f2a74a049200 100644 --- a/edit.c +++ b/edit.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,7 +26,7 @@ extern int sigs; extern IFILE curr_ifile; extern IFILE old_ifile; extern struct scrpos initial_scrpos; -extern void constant *ml_examine; +extern void *ml_examine; #if SPACES_IN_FILENAMES extern char openquote; extern char closequote; @@ -716,7 +716,7 @@ edit_stdin() public void cat_file() { - register int c; + int c; while ((c = ch_forw_get()) != EOI) putchr(c); @@ -734,8 +734,8 @@ cat_file() use_logfile(filename) char *filename; { - register int exists; - register int answer; + int exists; + int answer; PARG parg; if (ch_getflags() & CH_CANSEEK) diff --git a/filename.c b/filename.c index 62cc6e5a1134..a153207ba635 100644 --- a/filename.c +++ b/filename.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -264,7 +264,7 @@ dirfile(dirname, filename) homefile(filename) char *filename; { - register char *pathname; + char *pathname; /* * Try $HOME/filename. @@ -314,9 +314,9 @@ homefile(filename) fexpand(s) char *s; { - register char *fr, *to; - register int n; - register char *e; + char *fr, *to; + int n; + char *e; IFILE ifile; #define fchar_ifile(c) \ @@ -690,9 +690,9 @@ lglob(filename) * The globbing function returns a single name, and * is called multiple times to walk thru all names. */ - register char *p; - register int len; - register int n; + char *p; + int len; + int n; char *pathname; char *qpathname; DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) @@ -1018,7 +1018,7 @@ is_dir(filename) #else #ifdef _OSK { - register int f; + int f; f = open(filename, S_IREAD | S_IFDIR); if (f >= 0) @@ -1040,7 +1040,7 @@ is_dir(filename) bad_file(filename) char *filename; { - register char *m = NULL; + char *m = NULL; filename = shell_unquote(filename); if (!force_open && is_dir(filename)) diff --git a/forwback.c b/forwback.c index 83ae78efb28c..dc6cac98afbb 100644 --- a/forwback.c +++ b/forwback.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -124,7 +124,7 @@ squish_check() */ public void forw(n, pos, force, only_last, nblank) - register int n; + int n; POSITION pos; int force; int only_last; @@ -298,7 +298,7 @@ forw(n, pos, force, only_last, nblank) */ public void back(n, pos, force, only_last) - register int n; + int n; POSITION pos; int force; int only_last; @@ -444,3 +444,21 @@ get_back_scroll() return (sc_height - 2); return (10000); /* infinity */ } + +/* + * Get line count of file up to the screen height + 1 char + */ + public int +get_line_count() +{ + int nlines; + POSITION pos; + + pos = ch_zero(); + for (nlines = 0; nlines <= sc_height; nlines++) + { + pos = forw_line(pos); + if (pos == NULL_POSITION) break; + } + return nlines; +} diff --git a/funcs.h b/funcs.h index ac63c371bc77..1fe28c849474 100644 --- a/funcs.h +++ b/funcs.h @@ -1,299 +1,300 @@ - public char * save (); - public VOID_POINTER ecalloc (); - public char * skipsp (); - public int sprefix (); - public void quit (); - public void raw_mode (); - public void scrsize (); - public char * special_key_str (); - public void get_term (); - public void init (); - public void deinit (); - public void home (); - public void add_line (); - public void remove_top (); - public void win32_scroll_up (); - public void lower_left (); - public void line_left (); - public void check_winch (); - public void goto_line (); - public void vbell (); - public void bell (); - public void clear (); - public void clear_eol (); - public void clear_bot (); - public void at_enter (); - public void at_exit (); - public void at_switch (); - public int is_at_equiv (); - public int apply_at_specials (); - public void backspace (); - public void putbs (); - public char WIN32getch (); - public void WIN32setcolors (); - public void WIN32textout (); - public void match_brac (); - public void ch_ungetchar (); - public void end_logfile (); - public void sync_logfile (); - public int ch_seek (); - public int ch_end_seek (); - public int ch_end_buffer_seek (); - public int ch_beg_seek (); - public POSITION ch_length (); - public POSITION ch_tell (); - public int ch_forw_get (); - public int ch_back_get (); - public void ch_setbufspace (); - public void ch_flush (); - public int seekable (); - public void ch_set_eof (); - public void ch_init (); - public void ch_close (); - public int ch_getflags (); - public void ch_dump (); - public void init_charset (); - public int binary_char (); - public int control_char (); - public char * prchar (); - public char * prutfchar (); - public int utf_len (); - public int is_utf8_well_formed (); - public int utf_bin_count (); - public LWCHAR get_wchar (); - public void put_wchar (); - public LWCHAR step_char (); - public int is_composing_char (); - public int is_ubin_char (); - public int is_wide_char (); - public int is_combining_char (); - public void cmd_reset (); - public void clear_cmd (); - public void cmd_putstr (); - public int len_cmdbuf (); - public void set_mlist (); - public void cmd_addhist (); - public void cmd_accept (); - public int cmd_char (); - public LINENUM cmd_int (); - public char * get_cmdbuf (); - public char * cmd_lastpattern (); - public void init_cmdhist (); - public void save_cmdhist (); - public int in_mca (); - public void dispversion (); - public int getcc (); - public void ungetcc (); - public void ungetsc (); - public void commands (); - public int cvt_length (); - public int * cvt_alloc_chpos (); - public void cvt_text (); - public void init_cmds (); - public void add_fcmd_table (); - public void add_ecmd_table (); - public int fcmd_decode (); - public int ecmd_decode (); - public char * lgetenv (); - public int lesskey (); - public void add_hometable (); - public int editchar (); - public void init_textlist (); - public char * forw_textlist (); - public char * back_textlist (); - public int edit (); - public int edit_ifile (); - public int edit_list (); - public int edit_first (); - public int edit_last (); - public int edit_next (); - public int edit_prev (); - public int edit_index (); - public IFILE save_curr_ifile (); - public void unsave_ifile (); - public void reedit_ifile (); - public void reopen_curr_ifile (); - public int edit_stdin (); - public void cat_file (); - public void use_logfile (); - public char * shell_unquote (); - public char * get_meta_escape (); - public char * shell_quote (); - public char * homefile (); - public char * fexpand (); - public char * fcomplete (); - public int bin_file (); - public char * lglob (); - public char * open_altfile (); - public void close_altfile (); - public int is_dir (); - public char * bad_file (); - public POSITION filesize (); - public char * shell_coption (); - public char * last_component (); - public int eof_displayed (); - public int entire_file_displayed (); - public void squish_check (); - public void forw (); - public void back (); - public void forward (); - public void backward (); - public int get_back_scroll (); - public void del_ifile (); - public IFILE next_ifile (); - public IFILE prev_ifile (); - public IFILE getoff_ifile (); - public int nifile (); - public IFILE get_ifile (); - public char * get_filename (); - public int get_index (); - public void store_pos (); - public void get_pos (); - public void set_open (); - public int opened (); - public void hold_ifile (); - public int held_ifile (); - public void * get_filestate (); - public void set_filestate (); - public void if_dump (); - public POSITION forw_line (); - public POSITION back_line (); - public void set_attnpos (); - public void jump_forw (); - public void jump_forw_buffered (); - public void jump_back (); - public void repaint (); - public void jump_percent (); - public void jump_line_loc (); - public void jump_loc (); - public void init_line (); - public int is_ascii_char (); - public void prewind (); - public void plinenum (); - public void pshift_all (); - public int is_ansi_end (); - public int is_ansi_middle (); - public int pappend (); - public int pflushmbc (); - public void pdone (); - public void set_status_col (); - public int gline (); - public void null_line (); - public POSITION forw_raw_line (); - public POSITION back_raw_line (); - public int rrshift (); - public void clr_linenum (); - public void add_lnum (); - public LINENUM find_linenum (); - public POSITION find_pos (); - public LINENUM currline (); - public void lsystem (); - public int pipe_mark (); - public int pipe_data (); - public void init_mark (); - public int badmark (); - public void setmark (); - public void lastmark (); - public void gomark (); - public POSITION markpos (); - public void unmark (); - public void opt_o (); - public void opt__O (); - public void opt_j (); - public void calc_jump_sline (); - public void opt_shift (); - public void calc_shift_count (); - public void opt_k (); - public void opt_t (); - public void opt__T (); - public void opt_p (); - public void opt__P (); - public void opt_b (); - public void opt_i (); - public void opt__V (); - public void opt_D (); - public void opt_x (); - public void opt_quote (); - public void opt_query (); - public int get_swindow (); - public char * propt (); - public void scan_option (); - public void toggle_option (); - public int opt_has_param (); - public char * opt_prompt (); - public int isoptpending (); - public void nopendopt (); - public int getnum (); - public long getfraction (); - public int get_quit_at_eof (); - public void init_option (); - public struct loption * findopt (); - public struct loption * findopt_name (); - public int iread (); - public void intread (); - public time_type get_time (); - public char * errno_message (); - public int percentage (); - public POSITION percent_pos (); - public int os9_signal (); - public void put_line (); - public void flush (); - public int putchr (); - public void putstr (); - public void get_return (); - public void error (); - public void ierror (); - public int query (); - public int compile_pattern (); - public void uncompile_pattern (); - public int valid_pattern (); - public int is_null_pattern (); - public int match_pattern (); - public POSITION position (); - public void add_forw_pos (); - public void add_back_pos (); - public void pos_clear (); - public void pos_init (); - public int onscreen (); - public int empty_screen (); - public int empty_lines (); - public void get_scrpos (); - public int adjsline (); - public void init_prompt (); - public char * pr_expand (); - public char * eq_message (); - public char * pr_string (); - public char * wait_message (); - public void init_search (); - public void repaint_hilite (); - public void clear_attn (); - public void undo_search (); - public void clr_hlist (); - public void clr_hilite (); - public void clr_filter (); - public int is_filtered (); - public POSITION next_unfiltered (); - public POSITION prev_unfiltered (); - public int is_hilited (); - public void chg_hilite (); - public void chg_caseless (); - public int search (); - public void prep_hilite (); - public void set_filter_pattern (); - public int is_filtering (); - public RETSIGTYPE winch (); - public RETSIGTYPE winch (); - public void init_signals (); - public void psignals (); - public void cleantags (); - public int gettagtype (); - public void findtag (); - public POSITION tagsearch (); - public char * nexttag (); - public char * prevtag (); - public int ntags (); - public int curr_tag (); - public int edit_tagfile (); - public void open_getchr (); - public void close_getchr (); - public int getchr (); +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 LESSPARAMS((VOID_PARAM)); +public void deinit 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 slinenum)); +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 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 backspace LESSPARAMS((VOID_PARAM)); +public void putbs LESSPARAMS((VOID_PARAM)); +public char WIN32getch LESSPARAMS((int tty)); +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 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((unsigned char ch)); +public int is_utf8_well_formed LESSPARAMS((char *ss, int slen)); +public int utf_bin_count LESSPARAMS((char *data, int len)); +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 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 void dispversion LESSPARAMS((VOID_PARAM)); +public int getcc LESSPARAMS((VOID_PARAM)); +public void ungetcc LESSPARAMS((int c)); +public void ungetsc LESSPARAMS((char *s)); +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 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 lesskey LESSPARAMS((char *filename, int sysvar)); +public void add_hometable LESSPARAMS((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 * 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 * open_altfile LESSPARAMS((char *filename, int *pf, void **pfd)); +public void close_altfile LESSPARAMS((char *altfilename, char *filename, void *pipefd)); +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 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_line_count 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 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 if_dump LESSPARAMS((VOID_PARAM)); +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 plinenum LESSPARAMS((POSITION pos)); +public void pshift_all LESSPARAMS((VOID_PARAM)); +public int is_ansi_end LESSPARAMS((LWCHAR ch)); +public int is_ansi_middle LESSPARAMS((LWCHAR ch)); +public int pappend LESSPARAMS((unsigned char c, POSITION pos)); +public int pflushmbc LESSPARAMS((VOID_PARAM)); +public void pdone LESSPARAMS((int endline, int forw)); +public void set_status_col LESSPARAMS((char c)); +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 int rrshift LESSPARAMS((VOID_PARAM)); +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 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)); +public void lastmark LESSPARAMS((VOID_PARAM)); +public void gomark LESSPARAMS((int c)); +public POSITION markpos LESSPARAMS((int c)); +public void unmark LESSPARAMS((IFILE ifile)); +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_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_query LESSPARAMS((int type, char *s)); +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 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 put_line LESSPARAMS((VOID_PARAM)); +public void flush LESSPARAMS((VOID_PARAM)); +public int putchr LESSPARAMS((int c)); +public void putstr LESSPARAMS((constant char *s)); +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, 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 POSITION position LESSPARAMS((int where)); +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)); +public int adjsline LESSPARAMS((int sline)); +public void init_prompt LESSPARAMS((VOID_PARAM)); +public char * pr_expand LESSPARAMS((constant char *proto, int maxwidth)); +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((VOID_PARAM)); +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 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 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 void open_getchr LESSPARAMS((VOID_PARAM)); +public void close_getchr LESSPARAMS((VOID_PARAM)); +public int getchr LESSPARAMS((VOID_PARAM)); diff --git a/ifile.c b/ifile.c index c73333274da7..53a280c406c4 100644 --- a/ifile.c +++ b/ifile.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -50,7 +50,7 @@ static int ifiles = 0; static void incr_index(p, incr) - register struct ifile *p; + struct ifile *p; int incr; { for (; p != &anchor; p = p->h_next) @@ -107,7 +107,7 @@ new_ifile(filename, prev) char *filename; struct ifile *prev; { - register struct ifile *p; + struct ifile *p; /* * Allocate and initialize structure. @@ -129,7 +129,7 @@ new_ifile(filename, prev) del_ifile(h) IFILE h; { - register struct ifile *p; + struct ifile *p; if (h == NULL_IFILE) return; @@ -153,7 +153,7 @@ del_ifile(h) next_ifile(h) IFILE h; { - register struct ifile *p; + struct ifile *p; p = (h == NULL_IFILE) ? &anchor : int_ifile(h); if (p->h_next == &anchor) @@ -168,7 +168,7 @@ next_ifile(h) prev_ifile(h) IFILE h; { - register struct ifile *p; + struct ifile *p; p = (h == NULL_IFILE) ? &anchor : int_ifile(h); if (p->h_prev == &anchor) @@ -208,7 +208,7 @@ nifile() find_ifile(filename) char *filename; { - register struct ifile *p; + struct ifile *p; for (p = anchor.h_next; p != &anchor; p = p->h_next) if (strcmp(filename, p->h_filename) == 0) @@ -226,7 +226,7 @@ get_ifile(filename, prev) char *filename; IFILE prev; { - register struct ifile *p; + struct ifile *p; if ((p = find_ifile(filename)) == NULL) p = new_ifile(filename, int_ifile(prev)); @@ -332,7 +332,7 @@ set_filestate(ifile, filestate) public void if_dump() { - register struct ifile *p; + struct ifile *p; for (p = anchor.h_next; p != &anchor; p = p->h_next) { diff --git a/input.c b/input.c index 26ab7c022a65..34689bf6a5a5 100644 --- a/input.c +++ b/input.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -47,7 +47,7 @@ forw_line(curr_pos) { POSITION base_pos; POSITION new_pos; - register int c; + int c; int blankline; int endline; int backchars; diff --git a/jump.c b/jump.c index b5ec9dd8f339..618d0b87105b 100644 --- a/jump.c +++ b/jump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -200,7 +200,7 @@ jump_loc(pos, sline) POSITION pos; int sline; { - register int nline; + int nline; POSITION tpos; POSITION bpos; diff --git a/less.h b/less.h index 79ce721870f7..69576bbde4cd 100644 --- a/less.h +++ b/less.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,10 +39,17 @@ /* * 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 @@ -525,6 +532,10 @@ struct wchar_range_table #define time_type long #endif +struct mlist; +struct loption; +struct hilite_tree; +#include "pattern.h" #include "funcs.h" /* Functions not included in funcs.h */ diff --git a/less.man b/less.man index 0705407007ca..bb2016573f00 100644 --- a/less.man +++ b/less.man @@ -1617,7 +1617,7 @@ LESS(1) General Commands Manual LESS(1) COPYRIGHT - Copyright (C) 1984-2016 Mark Nudelman + Copyright (C) 1984-2017 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- @@ -1645,4 +1645,4 @@ LESS(1) General Commands Manual LESS(1) - Version 487: 25 Oct 2016 LESS(1) + Version 491: 07 Apr 2017 LESS(1) diff --git a/less.nro b/less.nro index c08ffd64436e..2f7bb7faa1de 100644 --- a/less.nro +++ b/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 487: 25 Oct 2016" +.TH LESS 1 "Version 491: 07 Apr 2017" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -1745,7 +1745,7 @@ The name of the editor (used for the v command). lesskey(1) .SH COPYRIGHT -Copyright (C) 1984-2016 Mark Nudelman +Copyright (C) 1984-2017 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 ec7e0803163a..4ed4830e1641 100644 --- a/lessecho.c +++ b/lessecho.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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/lessecho.man b/lessecho.man index 5f26d4aff315..466e4c68baab 100644 --- a/lessecho.man +++ b/lessecho.man @@ -51,4 +51,4 @@ LESSECHO(1) General Commands Manual LESSECHO(1) - Version 487: 25 Oct 2016 LESSECHO(1) + Version 491: 07 Apr 2017 LESSECHO(1) diff --git a/lessecho.nro b/lessecho.nro index d1302c838c4d..f5922fa4ab79 100644 --- a/lessecho.nro +++ b/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 487: 25 Oct 2016" +.TH LESSECHO 1 "Version 491: 07 Apr 2017" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/lesskey.c b/lesskey.c index f565ec62f764..686f6e4ffdad 100644 --- a/lesskey.c +++ b/lesskey.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -361,9 +361,9 @@ tstr(pp, xlate) char **pp; int xlate; { - register char *p; - register char ch; - register int i; + char *p; + char ch; + int i; static char buf[10]; static char tstr_control_k[] = { SK_SPECIAL_KEY, SK_CONTROL_K, 6, 1, 1, 1, '\0' }; @@ -423,7 +423,7 @@ tstr(pp, xlate) case 'e': ch = SK_END; break; case 'x': ch = SK_DELETE; break; default: - error("illegal char after \\k"); + error("illegal char after \\k", NULL_PARG); *pp = p+1; return (""); } @@ -474,7 +474,7 @@ tstr(pp, xlate) */ public char * skipsp(s) - register char *s; + char *s; { while (*s == ' ' || *s == '\t') s++; @@ -486,7 +486,7 @@ skipsp(s) */ public char * skipnsp(s) - register char *s; + char *s; { while (*s != '\0' && *s != ' ' && *s != '\t') s++; @@ -501,7 +501,7 @@ skipnsp(s) clean_line(s) char *s; { - register int i; + int i; s = skipsp(s); for (i = 0; s[i] != '\n' && s[i] != '\r' && s[i] != '\0'; i++) @@ -520,7 +520,7 @@ add_cmd_char(c) { if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD) { - error("too many commands"); + error("too many commands", NULL_PARG); exit(1); } *(currtable->pbuffer)++ = c; @@ -620,16 +620,18 @@ findaction(actname) for (i = 0; currtable->names[i].cn_name != NULL; i++) if (strcmp(currtable->names[i].cn_name, actname) == 0) return (currtable->names[i].cn_action); - error("unknown action"); + error("unknown action", NULL_PARG); return (A_INVALID); } void -error(s) +error(s, parg) char *s; + PARG *parg; { fprintf(stderr, "line %d: %s\n", linenum, s); errors++; + (void) parg; } @@ -652,7 +654,7 @@ parse_cmdline(p) s = tstr(&p, 1); cmdlen += (int) strlen(s); if (cmdlen > MAX_CMDLEN) - error("command too long"); + error("command too long", NULL_PARG); else add_cmd_str(s); } while (*p != ' ' && *p != '\t' && *p != '\0'); @@ -669,7 +671,7 @@ parse_cmdline(p) p = skipsp(p); if (*p == '\0') { - error("missing action"); + error("missing action", NULL_PARG); return; } actname = p; @@ -722,7 +724,7 @@ parse_varline(p) p = skipsp(p); if (*p++ != '=') { - error("missing ="); + error("missing =", NULL_PARG); return; } diff --git a/lesskey.h b/lesskey.h index 1b6f350b0715..92d4d93af179 100644 --- a/lesskey.h +++ b/lesskey.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 9811e8e9a705..0deca67f18a4 100644 --- a/lesskey.man +++ b/lesskey.man @@ -335,7 +335,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1) COPYRIGHT - Copyright (C) 1984-2016 Mark Nudelman + Copyright (C) 1984-2017 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- @@ -359,4 +359,4 @@ LESSKEY(1) General Commands Manual LESSKEY(1) - Version 487: 25 Oct 2016 LESSKEY(1) + Version 491: 07 Apr 2017 LESSKEY(1) diff --git a/lesskey.nro b/lesskey.nro index 252496cac8ac..a13be9329c97 100644 --- a/lesskey.nro +++ b/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 487: 25 Oct 2016" +.TH LESSKEY 1 "Version 491: 07 Apr 2017" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS @@ -361,7 +361,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-2016 Mark Nudelman +Copyright (C) 1984-2017 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/lglob.h b/lglob.h index 0ebf1f62dd6f..0d9fb5b989bc 100644 --- a/lglob.h +++ b/lglob.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 f09a13a963ca..3715d5805af4 100644 --- a/line.c +++ b/line.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -170,8 +170,8 @@ prewind() plinenum(pos) POSITION pos; { - register LINENUM linenum = 0; - register int i; + LINENUM linenum = 0; + int i; if (linenums == OPT_ONPLUS) { @@ -851,7 +851,7 @@ do_append(ch, rep, pos) char *rep; POSITION pos; { - register int a; + int a; LWCHAR prev_ch; a = AT_NORMAL; @@ -1096,8 +1096,8 @@ set_status_col(c) */ public int gline(i, ap) - register int i; - register int *ap; + int i; + int *ap; { if (is_null_line) { @@ -1144,8 +1144,8 @@ forw_raw_line(curr_pos, linep, line_lenp) char **linep; int *line_lenp; { - register int n; - register int c; + int n; + int c; POSITION new_pos; if (curr_pos == NULL_POSITION || ch_seek(curr_pos) || @@ -1193,8 +1193,8 @@ back_raw_line(curr_pos, linep, line_lenp) char **linep; int *line_lenp; { - register int n; - register int c; + int n; + int c; POSITION new_pos; if (curr_pos == NULL_POSITION || curr_pos <= ch_zero() || diff --git a/linenum.c b/linenum.c index c1a8128f14d1..4e726377e38d 100644 --- a/linenum.c +++ b/linenum.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,7 +75,7 @@ extern int screen_trashed; public void clr_linenum() { - register struct linenum_info *p; + struct linenum_info *p; /* * Put all the entries on the free list. @@ -102,7 +102,7 @@ clr_linenum() */ static void calcgap(p) - register struct linenum_info *p; + struct linenum_info *p; { /* * Don't bother to compute a gap for the anchor. @@ -125,11 +125,11 @@ add_lnum(linenum, pos) LINENUM linenum; POSITION pos; { - register struct linenum_info *p; - register struct linenum_info *new; - register struct linenum_info *nextp; - register struct linenum_info *prevp; - register POSITION mingap; + struct linenum_info *p; + struct linenum_info *new; + struct linenum_info *nextp; + struct linenum_info *prevp; + POSITION mingap; /* * Find the proper place in the list for the new one. @@ -265,8 +265,8 @@ abort_long() find_linenum(pos) POSITION pos; { - register struct linenum_info *p; - register LINENUM linenum; + struct linenum_info *p; + LINENUM linenum; POSITION cpos; if (!linenums) @@ -380,7 +380,7 @@ find_linenum(pos) find_pos(linenum) LINENUM linenum; { - register struct linenum_info *p; + struct linenum_info *p; POSITION cpos; LINENUM clinenum; diff --git a/lsystem.c b/lsystem.c index ea3cfb0159d1..10911ebe15d4 100644 --- a/lsystem.c +++ b/lsystem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,10 @@ lsystem(cmd, donemsg) char *cmd; char *donemsg; { - register int inp; + int inp; #if HAVE_SHELL - register char *shell; - register char *p; + char *shell; + char *p; #endif IFILE save_ifile; #if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C @@ -289,8 +289,8 @@ pipe_data(cmd, spos, epos) POSITION spos; POSITION epos; { - register FILE *f; - register int c; + FILE *f; + int c; extern FILE *popen(); /* diff --git a/main.c b/main.c index 960d1203e1c2..b44d88a506fe 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -53,10 +53,12 @@ extern int jump_sline; static char consoleTitle[256]; #endif +public int line_count; extern int less_is_more; extern int missing_cap; extern int know_dumb; extern int pr_type; +extern int quit_if_one_screen; /* @@ -273,10 +275,25 @@ main(argc, argv) { if (edit_stdin()) /* Edit standard input */ quit(QUIT_ERROR); + if (quit_if_one_screen) + line_count = get_line_count(); } else { if (edit_first()) /* Edit first valid file in cmd line */ quit(QUIT_ERROR); + /* + * In case that we have only one file and -F, have to get a line + * count fot init(). If the line count is less then a height of a term, + * the content of the file is printed out and then less quits. Otherwise + * -F can not be used + */ + if (quit_if_one_screen) + { + if (nifile() == 1) + line_count = get_line_count(); + else /* In case more than one file, -F can not be used */ + quit_if_one_screen = FALSE; + } } init(); @@ -292,9 +309,9 @@ main(argc, argv) */ public char * save(s) - char *s; + constant char *s; { - register char *p; + char *p; p = (char *) ecalloc(strlen(s)+1, sizeof(char)); strcpy(p, s); @@ -310,7 +327,7 @@ ecalloc(count, size) int count; unsigned int size; { - register VOID_POINTER p; + VOID_POINTER p; p = (VOID_POINTER) calloc(count, size); if (p != NULL) @@ -326,7 +343,7 @@ ecalloc(count, size) */ public char * skipsp(s) - register char *s; + char *s; { while (*s == ' ' || *s == '\t') s++; @@ -344,9 +361,9 @@ sprefix(ps, s, uppercase) char *s; int uppercase; { - register int c; - register int sc; - register int len = 0; + int c; + int sc; + int len = 0; for ( ; *s != '\0'; s++, ps++) { diff --git a/mark.c b/mark.c index 9d3e04963644..12a0b6c159ff 100644 --- a/mark.c +++ b/mark.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -61,7 +61,7 @@ getumark(c) getmark(c) int c; { - register struct mark *m; + struct mark *m; static struct mark sm; switch (c) @@ -137,7 +137,7 @@ badmark(c) setmark(c) int c; { - register struct mark *m; + struct mark *m; struct scrpos scrpos; m = getumark(c); @@ -172,7 +172,7 @@ lastmark() gomark(c) int c; { - register struct mark *m; + struct mark *m; struct scrpos scrpos; m = getmark(c); @@ -220,7 +220,7 @@ gomark(c) markpos(c) int c; { - register struct mark *m; + struct mark *m; m = getmark(c); if (m == NULL) diff --git a/mkfuncs.awk b/mkfuncs.awk deleted file mode 100644 index dea28acebf52..000000000000 --- a/mkfuncs.awk +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN { FS="("; state = 0 } - -/^ public/ { ftype = $0; state = 1 } - -{ if (state == 1) - state = 2 - else if (state == 2) - { print ftype,$1,"();"; state = 0 } -} diff --git a/mkfuncs.pl b/mkfuncs.pl new file mode 100644 index 000000000000..87875f9a1acf --- /dev/null +++ b/mkfuncs.pl @@ -0,0 +1,27 @@ +#! /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/mkhelp.c b/mkhelp.c index fb486ef9bd05..16275d4bcf13 100644 --- a/mkhelp.c +++ b/mkhelp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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/optfunc.c b/optfunc.c index 44f8e5fa7038..4c79fe3f16b9 100644 --- a/optfunc.c +++ b/optfunc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -47,9 +47,9 @@ extern char *every_first_cmd; extern IFILE curr_ifile; extern char version[]; extern int jump_sline; -extern int jump_sline_fraction; +extern long jump_sline_fraction; extern int shift_count; -extern int shift_count_fraction; +extern long shift_count_fraction; extern int less_is_more; #if LOGFILE extern char *namelogfile; @@ -180,7 +180,7 @@ opt_j(type, s) } else { - sprintf(buf, ".%06d", jump_sline_fraction); + sprintf(buf, ".%06ld", jump_sline_fraction); len = (int) strlen(buf); while (len > 2 && buf[len-1] == '0') len--; @@ -245,7 +245,7 @@ opt_shift(type, s) } else { - sprintf(buf, ".%06d", shift_count_fraction); + sprintf(buf, ".%06ld", shift_count_fraction); len = (int) strlen(buf); while (len > 2 && buf[len-1] == '0') len--; @@ -362,7 +362,7 @@ opt__T(type, s) public void opt_p(type, s) int type; - register char *s; + char *s; { switch (type) { @@ -398,9 +398,9 @@ opt_p(type, s) public void opt__P(type, s) int type; - register char *s; + char *s; { - register char **proto; + char **proto; PARG parg; switch (type) @@ -518,7 +518,7 @@ opt__V(type, s) putstr("no "); #endif putstr("regular expressions)\n"); - putstr("Copyright (C) 1984-2016 Mark Nudelman\n\n"); + putstr("Copyright (C) 1984-2017 Mark Nudelman\n\n"); putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); @@ -624,7 +624,7 @@ opt_D(type, s) public void opt_x(type, s) int type; - register char *s; + char *s; { extern int tabstops[]; extern int ntabstops; @@ -682,7 +682,7 @@ opt_x(type, s) public void opt_quote(type, s) int type; - register char *s; + char *s; { char buf[3]; PARG parg; diff --git a/option.c b/option.c index f0f3b3010402..8ba67bce3187 100644 --- a/option.c +++ b/option.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -69,8 +69,8 @@ propt(c) scan_option(s) char *s; { - register struct loption *o; - register int optc; + struct loption *o; + int optc; char *optname; char *printopt; char *str; @@ -305,7 +305,7 @@ toggle_option(o, lower, s, how_toggle) char *s; int how_toggle; { - register int num; + int num; int no_prompt; int err; PARG parg; @@ -568,8 +568,8 @@ optstring(s, p_str, printopt, validchars) char *printopt; char *validchars; { - register char *p; - register char *out; + char *p; + char *out; if (*s == '\0') { @@ -632,9 +632,9 @@ getnum(sp, printopt, errp) char *printopt; int *errp; { - register char *s; - register int n; - register int neg; + char *s; + int n; + int neg; s = skipsp(*sp); neg = FALSE; @@ -669,7 +669,7 @@ getfraction(sp, printopt, errp) char *printopt; int *errp; { - register char *s; + char *s; long frac = 0; int fraclen = 0; diff --git a/option.h b/option.h index 38e08f75aba3..6adcdde27dbe 100644 --- a/option.h +++ b/option.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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)(); /* Pointer to special handling function */ + void (*ofunc) LESSPARAMS((int, char*)); /* Pointer to special handling function */ char *odesc[3]; /* Description of each value */ }; diff --git a/opttbl.c b/opttbl.c index 03838374c958..58ec347f4b68 100644 --- a/opttbl.c +++ b/opttbl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -466,7 +466,7 @@ static struct loption option[] = public void init_option() { - register struct loption *o; + struct loption *o; char *p; p = lgetenv("LESS_IS_MORE"); @@ -492,7 +492,7 @@ init_option() findopt(c) int c; { - register struct loption *o; + struct loption *o; for (o = option; o->oletter != '\0'; o++) { @@ -533,9 +533,9 @@ findopt_name(p_optname, p_oname, p_err) int *p_err; { char *optname = *p_optname; - register struct loption *o; - register struct optname *oname; - register int len; + struct loption *o; + struct optname *oname; + int len; int uppercase; struct loption *maxo = NULL; struct optname *maxoname = NULL; diff --git a/os.c b/os.c index 61f116bf8562..df117610d82f 100644 --- a/os.c +++ b/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,10 +62,10 @@ extern int sigs; public int iread(fd, buf, len) int fd; - char *buf; + unsigned char *buf; unsigned int len; { - register int n; + int n; start: #if MSDOS_COMPILER==WIN32C @@ -226,8 +226,8 @@ strerror(err) errno_message(filename) char *filename; { - register char *p; - register char *m; + char *p; + char *m; int len; #if HAVE_ERRNO #if MUST_DEFINE_ERRNO @@ -271,7 +271,8 @@ muldiv(val, num, den) */ public int percentage(num, den) - POSITION num, den; + POSITION num; + POSITION den; { return (int) muldiv(num, (POSITION) 100, den); } diff --git a/output.c b/output.c index 77e6b3957d54..cd9ccc25e7e1 100644 --- a/output.c +++ b/output.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,8 +46,8 @@ extern int sgr_mode; public void put_line() { - register int c; - register int i; + int c; + int i; int a; if (ABORT_SIGS()) @@ -96,8 +96,8 @@ static char *ob = obuf; public void flush() { - register int n; - register int fd; + int n; + int fd; n = (int) (ob - obuf); if (n == 0) @@ -436,7 +436,7 @@ putchr(c) */ public void putstr(s) - register char *s; + constant char *s; { while (*s != '\0') putchr(*s++); @@ -453,7 +453,7 @@ void funcname(num, buf) \ { \ int neg = (num < 0); \ char tbuf[INT_STRLEN_BOUND(num)+2]; \ - register char *s = tbuf + sizeof(tbuf); \ + char *s = tbuf + sizeof(tbuf); \ if (neg) num = -num; \ *--s = '\0'; \ do { \ @@ -501,11 +501,11 @@ iprint_linenum(num) */ static int less_printf(fmt, parg) - register char *fmt; + char *fmt; PARG *parg; { - register char *s; - register int col; + char *s; + int col; col = 0; while (*fmt != '\0') @@ -645,7 +645,7 @@ query(fmt, parg) char *fmt; PARG *parg; { - register int c; + int c; int col = 0; if (any_display && is_tty) diff --git a/pattern.c b/pattern.c index 97a73e9b0e27..563bde0cc697 100644 --- a/pattern.c +++ b/pattern.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -12,7 +12,6 @@ */ #include "less.h" -#include "pattern.h" extern int caseless; @@ -23,7 +22,7 @@ extern int caseless; compile_pattern2(pattern, search_type, comp_pattern, show_error) char *pattern; int search_type; - void **comp_pattern; + PATTERN_TYPE *comp_pattern; int show_error; { if (search_type & SRCH_NO_REGEX) @@ -32,8 +31,6 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) #if HAVE_GNU_REGEX struct re_pattern_buffer *comp = (struct re_pattern_buffer *) ecalloc(1, sizeof(struct re_pattern_buffer)); - struct re_pattern_buffer **pcomp = - (struct re_pattern_buffer **) comp_pattern; re_set_syntax(RE_SYNTAX_POSIX_EXTENDED); if (re_compile_pattern(pattern, strlen(pattern), comp)) { @@ -42,13 +39,15 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) error("Invalid pattern", NULL_PARG); return (-1); } - if (*pcomp != NULL) - regfree(*pcomp); - *pcomp = comp; + if (*comp_pattern != NULL) + { + regfree(*comp_pattern); + free(*comp_pattern); + } + *comp_pattern = comp; #endif #if HAVE_POSIX_REGCOMP regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t)); - regex_t **pcomp = (regex_t **) comp_pattern; if (regcomp(comp, pattern, REGCOMP_FLAG)) { free(comp); @@ -56,13 +55,15 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) error("Invalid pattern", NULL_PARG); return (-1); } - if (*pcomp != NULL) - regfree(*pcomp); - *pcomp = comp; + if (*comp_pattern != NULL) + { + regfree(*comp_pattern); + free(*comp_pattern); + } + *comp_pattern = comp; #endif #if HAVE_PCRE pcre *comp; - pcre **pcomp = (pcre **) comp_pattern; constant char *errstring; int erroffset; PARG parg; @@ -75,35 +76,32 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) error("%s", &parg); return (-1); } - *pcomp = comp; + *comp_pattern = comp; #endif #if HAVE_RE_COMP PARG parg; - int *pcomp = (int *) comp_pattern; if ((parg.p_string = re_comp(pattern)) != NULL) { if (show_error) error("%s", &parg); return (-1); } - *pcomp = 1; + *comp_pattern = 1; #endif #if HAVE_REGCMP char *comp; - char **pcomp = (char **) comp_pattern; if ((comp = regcmp(pattern, 0)) == NULL) { if (show_error) error("Invalid pattern", NULL_PARG); return (-1); } - if (pcomp != NULL) - free(*pcomp); - *pcomp = comp; + if (comp_pattern != NULL) + free(*comp_pattern); + *comp_pattern = comp; #endif #if HAVE_V8_REGCOMP struct regexp *comp; - struct regexp **pcomp = (struct regexp **) comp_pattern; reg_show_error = show_error; comp = regcomp(pattern); reg_show_error = 1; @@ -115,9 +113,9 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) */ return (-1); } - if (*pcomp != NULL) - free(*pcomp); - *pcomp = comp; + if (*comp_pattern != NULL) + free(*comp_pattern); + *comp_pattern = comp; #endif } return (0); @@ -130,7 +128,7 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error) compile_pattern(pattern, search_type, comp_pattern) char *pattern; int search_type; - void **comp_pattern; + PATTERN_TYPE *comp_pattern; { char *cvt_pattern; int result; @@ -153,41 +151,41 @@ compile_pattern(pattern, search_type, comp_pattern) */ public void uncompile_pattern(pattern) - void **pattern; + PATTERN_TYPE *pattern; { #if HAVE_GNU_REGEX - struct re_pattern_buffer **pcomp = (struct re_pattern_buffer **) pattern; - if (*pcomp != NULL) - regfree(*pcomp); - *pcomp = NULL; + if (*pattern != NULL) + { + regfree(*pattern); + free(*pattern); + } + *pattern = NULL; #endif #if HAVE_POSIX_REGCOMP - regex_t **pcomp = (regex_t **) pattern; - if (*pcomp != NULL) - regfree(*pcomp); - *pcomp = NULL; + if (*pattern != NULL) + { + regfree(*pattern); + free(*pattern); + } + *pattern = NULL; #endif #if HAVE_PCRE - pcre **pcomp = (pcre **) pattern; - if (*pcomp != NULL) - pcre_free(*pcomp); - *pcomp = NULL; + if (*pattern != NULL) + pcre_free(*pattern); + *pattern = NULL; #endif #if HAVE_RE_COMP - int *pcomp = (int *) pattern; - *pcomp = 0; + *pattern = 0; #endif #if HAVE_REGCMP - char **pcomp = (char **) pattern; - if (*pcomp != NULL) - free(*pcomp); - *pcomp = NULL; + if (*pattern != NULL) + free(*pattern); + *pattern = NULL; #endif #if HAVE_V8_REGCOMP - struct regexp **pcomp = (struct regexp **) pattern; - if (*pcomp != NULL) - free(*pcomp); - *pcomp = NULL; + if (*pattern != NULL) + free(*pattern); + *pattern = NULL; #endif } @@ -198,7 +196,7 @@ uncompile_pattern(pattern) valid_pattern(pattern) char *pattern; { - void *comp_pattern; + PATTERN_TYPE comp_pattern; int result; CLEAR_PATTERN(comp_pattern); @@ -214,7 +212,7 @@ valid_pattern(pattern) */ public int is_null_pattern(pattern) - void *pattern; + PATTERN_TYPE pattern; { #if HAVE_GNU_REGEX return (pattern == NULL); @@ -251,9 +249,9 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend) int buf_len; char **pfound, **pend; { - register char *pp, *lp; - register char *pattern_end = pattern + pattern_len; - register char *buf_end = buf + buf_len; + char *pp, *lp; + char *pattern_end = pattern + pattern_len; + char *buf_end = buf + buf_len; for ( ; buf < buf_end; buf++) { @@ -286,7 +284,7 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend) */ public int match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) - void *pattern; + PATTERN_TYPE pattern; char *tpattern; char *line; int line_len; @@ -296,24 +294,6 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) int search_type; { int matched; -#if HAVE_GNU_REGEX - struct re_pattern_buffer *spattern = (struct re_pattern_buffer *) pattern; -#endif -#if HAVE_POSIX_REGCOMP - regex_t *spattern = (regex_t *) pattern; -#endif -#if HAVE_PCRE - pcre *spattern = (pcre *) pattern; -#endif -#if HAVE_RE_COMP - int spattern = (int) pattern; -#endif -#if HAVE_REGCMP - char *spattern = (char *) pattern; -#endif -#if HAVE_V8_REGCOMP - struct regexp *spattern = (struct regexp *) pattern; -#endif *sp = *ep = NULL; #if NO_REGEX @@ -326,9 +306,9 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) #if HAVE_GNU_REGEX { struct re_registers search_regs; - spattern->not_bol = notbol; - spattern->regs_allocated = REGS_UNALLOCATED; - matched = re_search(spattern, line, line_len, 0, line_len, &search_regs) >= 0; + pattern->not_bol = notbol; + pattern->regs_allocated = REGS_UNALLOCATED; + matched = re_search(pattern, line, line_len, 0, line_len, &search_regs) >= 0; if (matched) { *sp = line + search_regs.start[0]; @@ -345,7 +325,7 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) rm.rm_so = 0; rm.rm_eo = line_len; #endif - matched = !regexec(spattern, line, 1, &rm, flags); + matched = !regexec(pattern, line, 1, &rm, flags); if (matched) { #ifndef __WATCOMC__ @@ -362,7 +342,7 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) { int flags = (notbol) ? PCRE_NOTBOL : 0; int ovector[3]; - matched = pcre_exec(spattern, NULL, line, line_len, + matched = pcre_exec(pattern, NULL, line, line_len, 0, flags, ovector, 3) >= 0; if (matched) { @@ -379,21 +359,21 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) *sp = *ep = NULL; #endif #if HAVE_REGCMP - *ep = regex(spattern, line); + *ep = regex(pattern, line); matched = (*ep != NULL); if (matched) *sp = __loc1; #endif #if HAVE_V8_REGCOMP #if HAVE_REGEXEC2 - matched = regexec2(spattern, line, notbol); + matched = regexec2(pattern, line, notbol); #else - matched = regexec(spattern, line); + matched = regexec(pattern, line); #endif if (matched) { - *sp = spattern->startp[0]; - *ep = spattern->endp[0]; + *sp = pattern->startp[0]; + *ep = pattern->endp[0]; } #endif } diff --git a/pattern.h b/pattern.h index 67035952af24..a2a4e0c660d6 100644 --- a/pattern.h +++ b/pattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -10,31 +10,31 @@ #if HAVE_GNU_REGEX #define __USE_GNU 1 #include -#define DEFINE_PATTERN(name) struct re_pattern_buffer *name +#define PATTERN_TYPE struct re_pattern_buffer * #define CLEAR_PATTERN(name) name = NULL #endif #if HAVE_POSIX_REGCOMP #include #ifdef REG_EXTENDED -#define REGCOMP_FLAG REG_EXTENDED +#define REGCOMP_FLAG REG_EXTENDED #else -#define REGCOMP_FLAG 0 +#define REGCOMP_FLAG 0 #endif -#define DEFINE_PATTERN(name) regex_t *name +#define PATTERN_TYPE regex_t * #define CLEAR_PATTERN(name) name = NULL #endif #if HAVE_PCRE #include -#define DEFINE_PATTERN(name) pcre *name +#define PATTERN_TYPE pcre * #define CLEAR_PATTERN(name) name = NULL #endif #if HAVE_RE_COMP char *re_comp(); int re_exec(); -#define DEFINE_PATTERN(name) int name +#define PATTERN_TYPE int #define CLEAR_PATTERN(name) name = 0 #endif @@ -42,18 +42,18 @@ int re_exec(); char *regcmp(); char *regex(); extern char *__loc1; -#define DEFINE_PATTERN(name) char *name +#define PATTERN_TYPE char ** #define CLEAR_PATTERN(name) name = NULL #endif #if HAVE_V8_REGCOMP #include "regexp.h" extern int reg_show_error; -#define DEFINE_PATTERN(name) struct regexp *name +#define PATTERN_TYPE struct regexp * #define CLEAR_PATTERN(name) name = NULL #endif #if NO_REGEX -#define DEFINE_PATTERN(name) +#define PATTERN_TYPE void * #define CLEAR_PATTERN(name) #endif diff --git a/pckeys.h b/pckeys.h index 61493ecbde3a..e0d86e7bdf36 100644 --- a/pckeys.h +++ b/pckeys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 4f8e60f48c24..d5e949e2919c 100644 --- a/position.c +++ b/position.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 @@ position(where) add_forw_pos(pos) POSITION pos; { - register int i; + int i; /* * Scroll the position table up. @@ -77,7 +77,7 @@ add_forw_pos(pos) add_back_pos(pos) POSITION pos; { - register int i; + int i; /* * Scroll the position table down. @@ -93,7 +93,7 @@ add_back_pos(pos) public void pos_clear() { - register int i; + int i; for (i = 0; i < sc_height; i++) table[i] = NULL_POSITION; @@ -135,7 +135,7 @@ pos_init() onscreen(pos) POSITION pos; { - register int i; + int i; if (pos < table[0]) return (-1); @@ -159,7 +159,7 @@ empty_lines(s, e) int s; int e; { - register int i; + int i; for (i = s; i <= e; i++) if (table[i] != NULL_POSITION && table[i] != 0) @@ -179,7 +179,7 @@ empty_lines(s, e) get_scrpos(scrpos) struct scrpos *scrpos; { - register int i; + int i; /* * Find the first line on the screen which has something on it, diff --git a/position.h b/position.h index a0b20c5b6f3a..30678962ccc7 100644 --- a/position.h +++ b/position.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 bd2213ca02e2..bf4f7291df28 100644 --- a/prompt.c +++ b/prompt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -394,9 +394,9 @@ protochar(c, where, iseditproto) */ static constant char * skipcond(p) - register constant char *p; + constant char *p; { - register int iflevel; + int iflevel; /* * We came in here after processing a ? or :, @@ -479,8 +479,8 @@ pr_expand(proto, maxwidth) constant char *proto; int maxwidth; { - register constant char *p; - register int c; + constant char *p; + int c; int where; mp = message; diff --git a/screen.c b/screen.c index ad3fca1639dd..5b3682731d10 100644 --- a/screen.c +++ b/screen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -204,6 +204,7 @@ public int missing_cap = 0; /* Some capability is missing */ static int attrmode = AT_NORMAL; extern int binattr; +extern int line_count; #if !MSDOS_COMPILER static char *cheaper(); @@ -233,6 +234,7 @@ extern int wscroll; extern int screen_trashed; extern int tty; extern int top_scroll; +extern int quit_if_one_screen; extern int oldbot; #if HILITE_SEARCH extern int hilite_search; @@ -694,7 +696,7 @@ ltgetstr(capname, pp) public void scrsize() { - register char *s; + char *s; int sys_height; int sys_width; #if !MSDOS_COMPILER @@ -1119,7 +1121,7 @@ get_term() #else /* !MSDOS_COMPILER */ char *sp; - register char *t1, *t2; + char *t1, *t2; char *term; char termbuf[TERMBUF_SIZE]; @@ -1538,7 +1540,9 @@ win32_deinit_term() init() { #if !MSDOS_COMPILER - if (!no_init) + if (quit_if_one_screen && line_count >= sc_height) + quit_if_one_screen = FALSE; + if (!no_init && !quit_if_one_screen) tputs(sc_init, sc_height, putchr); if (!no_keypad) tputs(sc_s_keypad, sc_height, putchr); @@ -1578,7 +1582,7 @@ deinit() #if !MSDOS_COMPILER if (!no_keypad) tputs(sc_e_keypad, sc_height, putchr); - if (!no_init) + if (!no_init && !quit_if_one_screen) tputs(sc_deinit, sc_height, putchr); #else /* Restore system colors. */ @@ -1946,7 +1950,7 @@ create_flash() } #else #if MSDOS_COMPILER==BORLANDC - register int n; + int n; whitescreen = (unsigned short *) malloc(sc_width * sc_height * sizeof(short)); @@ -1956,7 +1960,7 @@ create_flash() whitescreen[n] = 0x7020; #else #if MSDOS_COMPILER==WIN32C - register int n; + int n; whitescreen = (WORD *) malloc(sc_height * sc_width * sizeof(WORD)); diff --git a/scrsize.c b/scrsize.c index c928ebae8f47..001c55ace385 100644 --- a/scrsize.c +++ b/scrsize.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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 750b74a10298..84f9288a229c 100644 --- a/search.c +++ b/search.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,7 +13,6 @@ */ #include "less.h" -#include "pattern.h" #include "position.h" #include "charset.h" @@ -29,7 +28,7 @@ extern int jump_sline; extern int bs_mode; extern int ctldisp; extern int status_col; -extern void * constant ml_search; +extern void *ml_search; extern POSITION start_attnpos; extern POSITION end_attnpos; extern int utf_mode; @@ -103,7 +102,7 @@ static struct hilite_tree filter_anchor = HILITE_INITIALIZER(); * search pattern and filter pattern. */ struct pattern_info { - DEFINE_PATTERN(compiled); + PATTERN_TYPE compiled; char* text; int search_type; }; @@ -1271,6 +1270,8 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) hl.hl_startpos = linepos; hl.hl_endpos = pos; add_hilite(&filter_anchor, &hl); + free(cline); + free(chpos); continue; } } diff --git a/signal.c b/signal.c index 24f78f102c2e..03c389c39e89 100644 --- a/signal.c +++ b/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -192,7 +192,7 @@ init_signals(on) public void psignals() { - register int tsignals; + int tsignals; if ((tsignals = sigs) == 0) return; diff --git a/tags.c b/tags.c index 0566be718713..f59d25b411f4 100644 --- a/tags.c +++ b/tags.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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,8 +63,6 @@ struct taglist { struct tag *tl_first; struct tag *tl_last; }; -#define TAG_END ((struct tag *) &taglist) -static struct taglist taglist = { TAG_END, TAG_END }; struct tag { struct tag *next, *prev; /* List links */ char *tag_file; /* Source file containing the tag */ @@ -72,6 +70,8 @@ struct tag { char *tag_pattern; /* Pattern used to find the tag */ char tag_endline; /* True if the pattern includes '$' */ }; +#define TAG_END ((struct tag *) &taglist) +static struct taglist taglist = { TAG_END, TAG_END }; static struct tag *curtag; #define TAG_INS(tp) \ @@ -90,7 +90,7 @@ static struct tag *curtag; public void cleantags() { - register struct tag *tp; + struct tag *tp; /* * Delete any existing tag list. @@ -117,7 +117,7 @@ maketagent(name, file, linenum, pattern, endline) char *pattern; int endline; { - register struct tag *tp; + struct tag *tp; tp = (struct tag *) ecalloc(sizeof(struct tag), 1); tp->tag_file = (char *) ecalloc(strlen(file) + 1, sizeof(char)); @@ -170,7 +170,7 @@ gettagtype() */ public void findtag(tag) - register char *tag; + char *tag; { int type = gettagtype(); enum tag_result result; @@ -266,11 +266,11 @@ curr_tag() */ static enum tag_result findctag(tag) - register char *tag; + char *tag; { char *p; - register FILE *f; - register int taglen; + FILE *f; + int taglen; LINENUM taglinenum; char *tagfile; char *tagpattern; diff --git a/ttyin.c b/ttyin.c index 58892e145619..87cffc28eb26 100644 --- a/ttyin.c +++ b/ttyin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -120,7 +120,11 @@ getchr() if (c == '\003') return (READ_INTR); #else - result = iread(tty, &c, sizeof(char)); + { + unsigned char uc; + result = iread(tty, &uc, sizeof(char)); + c = (char) uc; + } if (result == READ_INTR) return (READ_INTR); if (result < 0) diff --git a/version.c b/version.c index dde1af0dd6e0..3240d4b2ce25 100644 --- a/version.c +++ b/version.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2016 Mark Nudelman + * Copyright (C) 1984-2017 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. @@ -800,11 +800,17 @@ v484 9/20/16 Update to Unicode 9.0.0 database. v485 10/21/16 Fix "nothing to search" bug when top/bottom line is empty; Display line numbers in bold. (thanks to Jason Hood); Fix incorrect display when entering double-width chars in - search string. + search string. v486 10/22/16 New commands ESC-{ and ESC-} to shift to start/end of displayed lines; new option -Da in Windows version to - enable SGR mode (thanks to Jason Hood). + enable SGR mode (thanks to Jason Hood). v487 10/23/16 configure --help formatting. +----------------------------------------------------------------- +v488 2/23/17 Fix memory leaks in search (thanks to John Brooks). +v489 3/30/17 Make -F not do init/deinit if file fits on one screen + (thanks to Jindrich Novy). +v490 4/5/17 Switch to ANSI prototypes in funcs.h; remove "register". +v491 4/7/17 Fix signed char bug. */ -char version[] = "487"; +char version[] = "491"; -- cgit v1.2.3