diff --git a/Makefile.aut b/Makefile.aut index 75bc603..b45b5b7 100644 --- a/Makefile.aut +++ b/Makefile.aut @@ -114,15 +114,17 @@ wide.uni: unicode/EastAsianWidth.txt unicode/UnicodeData.txt: mkdir -p unicode - curl -s -u 'anonymous:${EMAIL}' -o $@ ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt + lftp -c 'open -u "anonymous:${EMAIL}" ftp.unicode.org ; get Public/UNIDATA/UnicodeData.txt -o $@' + touch $@ unicode/EastAsianWidth.txt: mkdir -p unicode - curl -s -u 'anonymous:${EMAIL}' -o $@ ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt + lftp -c 'open -u "anonymous:${EMAIL}" ftp.unicode.org ; get Public/UNIDATA/EastAsianWidth.txt -o $@' + touch $@ distfiles: ${DISTFILES} echo_distfiles: - @echo ${DISTFILES} + @echo $(subst .nro,.nro.VER,${DISTFILES}) dist: ${DISTFILES} if [ ! -d ${srcdir}/release ]; then mkdir ${srcdir}/release; fi diff --git a/Makefile.wng b/Makefile.wng index 40c7ddd..324df5e 100644 --- a/Makefile.wng +++ b/Makefile.wng @@ -39,13 +39,13 @@ MINGW_ROOT_PATH = /mingw-w64/mingw64 # REGEX_PACKAGE ?= posix ifeq (${REGEX_PACKAGE},regcomp-local) - MINGW_DEFINES += -DUSE_REGEXP_C + MINGW_DEFINES += -DUSE_REGEXP_C else ifeq (${REGEX_PACKAGE},posix) - MINGW_DEFINES += -DUSE_POSIX_REGCOMP + MINGW_DEFINES += -DUSE_POSIX_REGCOMP else ifeq (${REGEX_PACKAGE},gnu) - MINGW_DEFINES += -DUSE_GNU_REGEX + MINGW_DEFINES += -DUSE_GNU_REGEX else - $(error REGEX_PACKAGE must be posix, gnu or regcomp-local) + $(error REGEX_PACKAGE must be posix, gnu or regcomp-local) endif MINGW_REGEX_IPATH = -I${MINGW_ROOT_PATH}/opt/include @@ -80,7 +80,7 @@ LESS_SRC = brac.c ch.c charset.c cmdbuf.c command.c \ ifile.c input.c jump.c line.c linenum.c \ lsystem.c main.c mark.c optfunc.c option.c \ opttbl.c os.c output.c pattern.c position.c \ - prompt.c screen.c scrsize.c search.c \ + prompt.c screen.c scrsize.c search.c \ signal.c tags.c ttyin.c version.c xbuf.c ifeq (${REGEX_PACKAGE},regcomp-local) LESS_SRC += regexp.c diff --git a/NEWS.upstream b/NEWS.upstream index 0e51b75..9714046 100644 --- a/NEWS.upstream +++ b/NEWS.upstream @@ -11,7 +11,7 @@ ====================================================================== - Major changes between "less" versions 590 and 603 + Major changes between "less" versions 590 and 608 * Add the --header option (github #43). @@ -56,6 +56,8 @@ * Fix buffer overflow when invoking lessecho with more than 63 -m/-n options (github #198). +* Fix buffer overflow in bin_file (github #271). + * Fix bug restoring color at end of highlighted text. * Fix bug in parsing lesskey file. @@ -64,6 +66,16 @@ * Suppress TAB filename expansion in some cases where it doesn't make sense. +* Fix termlib detection when compiler doesn't accept + calls to undeclared functions. + +* Fix bug in input of non-ASCII characters on Windows (github #247) + +* Escape filenames when invoking LESSCLOSE. + +* Fix bug using multibyte UTF-8 char in search string + with --incsearch (github #273). + ====================================================================== Major changes between "less" versions 581 and 590 diff --git a/cmdbuf.c b/cmdbuf.c index c3d6a15..c167c02 100644 --- a/cmdbuf.c +++ b/cmdbuf.c @@ -1378,6 +1378,9 @@ cmd_int(frac) public char * get_cmdbuf(VOID_PARAM) { + if (cmd_mbc_buf_index < cmd_mbc_buf_len) + /* Don't return buffer containing an incomplete multibyte char. */ + return (NULL); return (cmdbuf); } diff --git a/command.c b/command.c index 6797501..ef20878 100644 --- a/command.c +++ b/command.c @@ -242,6 +242,8 @@ exec_mca(VOID_PARAM) cmd_exec(); cbuf = get_cmdbuf(); + if (cbuf == NULL) + return; switch (mca) { @@ -423,6 +425,8 @@ mca_opt_nonfirst_char(c) if (cmd_char(c) == CC_QUIT) return (MCA_DONE); p = get_cmdbuf(); + if (p == NULL) + return (MCA_MORE); opt_lower = ASCII_IS_LOWER(p[0]); err = 0; curropt = findopt_name(&p, &oname, &err); @@ -478,6 +482,8 @@ mca_opt_char(c) if (curropt == NULL) { parg.p_string = get_cmdbuf(); + if (parg.p_string == NULL) + return (MCA_MORE); error("There is no --%s option", &parg); return (MCA_DONE); } @@ -699,15 +705,18 @@ mca_char(c) case A_B_SEARCH: if (incr_search) { + int save_updown_match = 0; /* Incremental search: do a search after every input char. */ int st = (search_type & (SRCH_FORW|SRCH_BACK|SRCH_NO_MATCH|SRCH_NO_REGEX|SRCH_NO_MOVE|SRCH_WRAP)); char *pattern = get_cmdbuf(); + if (pattern == NULL) + return (MCA_MORE); /* * Must save updown_match because mca_search * reinits it. That breaks history scrolling. * {{ This is ugly. mca_search probably shouldn't call set_mlist. }} */ - int save_updown_match = updown_match; + save_updown_match = updown_match; cmd_exec(); if (*pattern == '\0') { @@ -1308,6 +1317,8 @@ commands(VOID_PARAM) if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0) continue; cbuf = get_cmdbuf(); + if (cbuf == NULL) + continue; } else { /* diff --git a/compose.uni b/compose.uni index 1235232..1752606 100644 --- a/compose.uni +++ b/compose.uni @@ -1,4 +1,4 @@ -/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Tue May 19 14:47:34 PDT 2020 */ +/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:16 PDT 2022 */ { 0x0300, 0x036f }, /* Mn */ { 0x0483, 0x0487 }, /* Mn */ { 0x0488, 0x0489 }, /* Me */ @@ -24,7 +24,8 @@ { 0x0825, 0x0827 }, /* Mn */ { 0x0829, 0x082d }, /* Mn */ { 0x0859, 0x085b }, /* Mn */ - { 0x08d3, 0x08e1 }, /* Mn */ + { 0x0898, 0x089f }, /* Mn */ + { 0x08ca, 0x08e1 }, /* Mn */ { 0x08e3, 0x0902 }, /* Mn */ { 0x093a, 0x093a }, /* Mn */ { 0x093c, 0x093c }, /* Mn */ @@ -65,6 +66,7 @@ { 0x0bcd, 0x0bcd }, /* Mn */ { 0x0c00, 0x0c00 }, /* Mn */ { 0x0c04, 0x0c04 }, /* Mn */ + { 0x0c3c, 0x0c3c }, /* Mn */ { 0x0c3e, 0x0c40 }, /* Mn */ { 0x0c46, 0x0c48 }, /* Mn */ { 0x0c4a, 0x0c4d }, /* Mn */ @@ -115,7 +117,7 @@ { 0x1160, 0x11ff }, /* Mn */ { 0x135d, 0x135f }, /* Mn */ { 0x1712, 0x1714 }, /* Mn */ - { 0x1732, 0x1734 }, /* Mn */ + { 0x1732, 0x1733 }, /* Mn */ { 0x1752, 0x1753 }, /* Mn */ { 0x1772, 0x1773 }, /* Mn */ { 0x17b4, 0x17b5 }, /* Mn */ @@ -124,6 +126,7 @@ { 0x17c9, 0x17d3 }, /* Mn */ { 0x17dd, 0x17dd }, /* Mn */ { 0x180b, 0x180d }, /* Mn */ + { 0x180f, 0x180f }, /* Mn */ { 0x1885, 0x1886 }, /* Mn */ { 0x18a9, 0x18a9 }, /* Mn */ { 0x1920, 0x1922 }, /* Mn */ @@ -141,7 +144,7 @@ { 0x1a7f, 0x1a7f }, /* Mn */ { 0x1ab0, 0x1abd }, /* Mn */ { 0x1abe, 0x1abe }, /* Me */ - { 0x1abf, 0x1ac0 }, /* Mn */ + { 0x1abf, 0x1ace }, /* Mn */ { 0x1b00, 0x1b03 }, /* Mn */ { 0x1b34, 0x1b34 }, /* Mn */ { 0x1b36, 0x1b3a }, /* Mn */ @@ -164,8 +167,7 @@ { 0x1ced, 0x1ced }, /* Mn */ { 0x1cf4, 0x1cf4 }, /* Mn */ { 0x1cf8, 0x1cf9 }, /* Mn */ - { 0x1dc0, 0x1df9 }, /* Mn */ - { 0x1dfb, 0x1dff }, /* Mn */ + { 0x1dc0, 0x1dff }, /* Mn */ { 0x20d0, 0x20dc }, /* Mn */ { 0x20dd, 0x20e0 }, /* Me */ { 0x20e1, 0x20e1 }, /* Mn */ @@ -229,11 +231,15 @@ { 0x10d24, 0x10d27 }, /* Mn */ { 0x10eab, 0x10eac }, /* Mn */ { 0x10f46, 0x10f50 }, /* Mn */ + { 0x10f82, 0x10f85 }, /* Mn */ { 0x11001, 0x11001 }, /* Mn */ { 0x11038, 0x11046 }, /* Mn */ + { 0x11070, 0x11070 }, /* Mn */ + { 0x11073, 0x11074 }, /* Mn */ { 0x1107f, 0x11081 }, /* Mn */ { 0x110b3, 0x110b6 }, /* Mn */ { 0x110b9, 0x110ba }, /* Mn */ + { 0x110c2, 0x110c2 }, /* Mn */ { 0x11100, 0x11102 }, /* Mn */ { 0x11127, 0x1112b }, /* Mn */ { 0x1112d, 0x11134 }, /* Mn */ @@ -313,6 +319,8 @@ { 0x16f8f, 0x16f92 }, /* Mn */ { 0x16fe4, 0x16fe4 }, /* Mn */ { 0x1bc9d, 0x1bc9e }, /* Mn */ + { 0x1cf00, 0x1cf2d }, /* Mn */ + { 0x1cf30, 0x1cf46 }, /* Mn */ { 0x1d167, 0x1d169 }, /* Mn */ { 0x1d17b, 0x1d182 }, /* Mn */ { 0x1d185, 0x1d18b }, /* Mn */ diff --git a/configure b/configure index 9a1bb1d..a499490 100644 --- a/configure +++ b/configure @@ -4048,434 +4048,143 @@ if test "$ac_res" != no; then : fi -# Checks for terminal libraries -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working terminal libraries" >&5 -$as_echo_n "checking for working terminal libraries... " >&6; } -TERMLIBS= - -# Check for systems where curses is broken. -curses_broken=0 -if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then -if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then - curses_broken=1 -fi -if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then - curses_broken=1 -fi -fi - -if test $curses_broken = 0; then - -# -- Try tinfo. -if test "x$TERMLIBS" = x; then - if test $have_tinfo = yes; then - TERMLIBS="-ltinfo" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +# Checks for header files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#include +#include int main () { -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes else - termok=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi + ac_cv_header_stdc=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# -- Try tinfow. -if test "x$TERMLIBS" = x; then - if test $have_tinfow = yes; then - TERMLIBS="-ltinfow" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + else - termok=no + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi +rm -f conftest* + fi -# -- Try xcurses. -if test "x$TERMLIBS" = x; then - if test $have_xcurses = yes; then - TERMLIBS="-lxcurses" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + else - termok=no + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi +rm -f conftest* + fi -# -- Try ncursesw. -if test "x$TERMLIBS" = x; then - if test $have_ncursesw = yes; then - TERMLIBS="-lncursesw" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes +if ac_fn_c_try_run "$LINENO"; then : + else - termok=no + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -# -- Try ncurses. -if test "x$TERMLIBS" = x; then - if test $have_ncurses = yes; then - TERMLIBS="-lncurses" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes -else - termok=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then -# -- Try curses. -if test "x$TERMLIBS" = x; then - if test $have_curses = yes; then - TERMLIBS="-lcurses" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +$as_echo "#define STDC_HEADERS 1" >>confdefs.h -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes -else - termok=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + fi -# -- Try curses & termcap. -if test "x$TERMLIBS" = x; then - if test $have_curses = yes; then - if test $have_termcap = yes; then - TERMLIBS="-lcurses -ltermcap" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +done -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes -else - termok=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi - fi -fi -fi - -# -- Try termcap. -if test "x$TERMLIBS" = x; then - if test $have_termcap = yes; then - TERMLIBS="-ltermcap" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes -else - termok=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi -fi - -# -- Try termlib. -if test "x$TERMLIBS" = x; then - if test $have_termlib = yes; then - TERMLIBS="-lcurses -ltermlib" - SAVE_LIBS=$LIBS - LIBS="$LIBS $TERMLIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - termok=yes -else - termok=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$SAVE_LIBS - if test $termok = no; then TERMLIBS=""; fi - fi -fi - -if test "x$TERMLIBS" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Cannot find terminal libraries - configure failed" >&5 -$as_echo "Cannot find terminal libraries - configure failed" >&6; } - exit 1 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TERMLIBS" >&5 -$as_echo "using $TERMLIBS" >&6; } -LIBS="$LIBS $TERMLIBS" - -# Checks for header files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 + +for ac_header in ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -4665,6 +4374,299 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi +# Checks for terminal libraries +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working terminal libraries" >&5 +$as_echo_n "checking for working terminal libraries... " >&6; } +TERMLIBS= +include_termcap_h= +if test "x$ac_cv_header_termcap_h" = xyes; then include_termcap_h="#include "; fi + +# Check for systems where curses is broken. +curses_broken=0 +if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then +if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then + curses_broken=1 +fi +if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then + curses_broken=1 +fi +fi + +if test $curses_broken = 0; then + +# -- Try tinfo. +if test "x$TERMLIBS" = x; then + if test $have_tinfo = yes; then + TERMLIBS="-ltinfo" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try tinfow. +if test "x$TERMLIBS" = x; then + if test $have_tinfow = yes; then + TERMLIBS="-ltinfow" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try xcurses. +if test "x$TERMLIBS" = x; then + if test $have_xcurses = yes; then + TERMLIBS="-lxcurses" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try ncursesw. +if test "x$TERMLIBS" = x; then + if test $have_ncursesw = yes; then + TERMLIBS="-lncursesw" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try ncurses. +if test "x$TERMLIBS" = x; then + if test $have_ncurses = yes; then + TERMLIBS="-lncurses" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try curses. +if test "x$TERMLIBS" = x; then + if test $have_curses = yes; then + TERMLIBS="-lcurses" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try curses & termcap. +if test "x$TERMLIBS" = x; then + if test $have_curses = yes; then + if test $have_termcap = yes; then + TERMLIBS="-lcurses -ltermcap" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi + fi +fi +fi + +# -- Try termcap. +if test "x$TERMLIBS" = x; then + if test $have_termcap = yes; then + TERMLIBS="-ltermcap" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +# -- Try termlib. +if test "x$TERMLIBS" = x; then + if test $have_termlib = yes; then + TERMLIBS="-lcurses -ltermlib" + SAVE_LIBS=$LIBS + LIBS="$LIBS $TERMLIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$include_termcap_h +int +main () +{ +tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + termok=yes +else + termok=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$SAVE_LIBS + if test $termok = no; then TERMLIBS=""; fi + fi +fi + +if test "x$TERMLIBS" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Cannot find terminal libraries - configure failed" >&5 +$as_echo "Cannot find terminal libraries - configure failed" >&6; } + exit 1 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TERMLIBS" >&5 +$as_echo "using $TERMLIBS" >&6; } +LIBS="$LIBS $TERMLIBS" + # Autoheader templates for symbols defined later by AC_DEFINE. diff --git a/configure.ac b/configure.ac index 98db05e..2ff5d01 100644 --- a/configure.ac +++ b/configure.ac @@ -35,9 +35,22 @@ AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no]) # at least on Solaris 10 (2.10)) and in -lintl on SCO Unix. AC_SEARCH_LIBS([regcmp], [gen intl PW]) +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STAT +AC_C_CONST +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_HEADER_TIME + # Checks for terminal libraries AC_MSG_CHECKING([for working terminal libraries]) TERMLIBS= +include_termcap_h= +if test "x$ac_cv_header_termcap_h" = xyes; then include_termcap_h="#include "; fi # Check for systems where curses is broken. curses_broken=0 @@ -58,7 +71,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-ltinfo" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -71,7 +84,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-ltinfow" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -84,7 +97,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lxcurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -97,7 +110,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lncursesw" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -110,7 +123,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lncurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK([#include ], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -123,7 +136,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -137,7 +150,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses -ltermcap" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -152,7 +165,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-ltermcap" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -165,7 +178,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses -ltermlib" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], + AC_TRY_LINK([$include_termcap_h], [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);], [termok=yes], [termok=no]) LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi @@ -179,17 +192,6 @@ fi AC_MSG_RESULT(using $TERMLIBS) LIBS="$LIBS $TERMLIBS" -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STAT -AC_C_CONST -AC_TYPE_OFF_T -AC_TYPE_SIZE_T -AC_HEADER_TIME - # Autoheader templates for symbols defined later by AC_DEFINE. AH_TEMPLATE([HAVE_GNU_REGEX], [GNU regex library]) diff --git a/filename.c b/filename.c index 957b2d6..5b3d005 100644 --- a/filename.c +++ b/filename.c @@ -477,7 +477,7 @@ bin_file(f) edata = &data[n]; for (p = data; p < edata; ) { - if (utf_mode && !is_utf8_well_formed(p, edata-data)) + if (utf_mode && !is_utf8_well_formed(p, edata-p)) { bin_count++; utf_skip_to_lead(&p, edata); @@ -972,6 +972,8 @@ close_altfile(altfilename, filename) { #if HAVE_POPEN char *lessclose; + char *qfilename; + char *qaltfilename; FILE *fd; char *cmd; int len; @@ -986,9 +988,13 @@ close_altfile(altfilename, filename) error("LESSCLOSE ignored; must contain no more than 2 %%s", NULL_PARG); return; } - len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2); + qfilename = shell_quote(filename); + qaltfilename = shell_quote(altfilename); + len = (int) (strlen(lessclose) + strlen(qfilename) + strlen(qaltfilename) + 2); cmd = (char *) ecalloc(len, sizeof(char)); - SNPRINTF2(cmd, len, lessclose, filename, altfilename); + SNPRINTF2(cmd, len, lessclose, qfilename, qaltfilename); + free(qaltfilename); + free(qfilename); fd = shellcmd(cmd); free(cmd); if (fd != NULL) diff --git a/fmt.uni b/fmt.uni index 6766505..bb36fb0 100644 --- a/fmt.uni +++ b/fmt.uni @@ -1,9 +1,10 @@ -/* Generated by "./mkutable -f2 Cf -- unicode/UnicodeData.txt" on Tue May 19 14:47:34 PDT 2020 */ +/* Generated by "./mkutable -f2 Cf -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:17 PDT 2022 */ { 0x00ad, 0x00ad }, /* Cf */ { 0x0600, 0x0605 }, /* Cf */ { 0x061c, 0x061c }, /* Cf */ { 0x06dd, 0x06dd }, /* Cf */ { 0x070f, 0x070f }, /* Cf */ + { 0x0890, 0x0891 }, /* Cf */ { 0x08e2, 0x08e2 }, /* Cf */ { 0x180e, 0x180e }, /* Cf */ { 0x200b, 0x200f }, /* Cf */ diff --git a/help.c b/help.c index eab7101..75a91d1 100644 --- a/help.c +++ b/help.c @@ -1,4 +1,4 @@ -/* This file was generated by mkhelp.pl from less.hlp at 20:55 on 2022/3/14 */ +/* This file was generated by mkhelp.pl from less.hlp at 19:26 on 2022/7/22 */ #include "less.h" constant char helpdata[] = { '\n', @@ -79,7 +79,7 @@ constant char helpdata[] = { ' ',' ','\'','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','a',' ','p','r','e','v','i','o','u','s','l','y',' ','m','a','r','k','e','d',' ','p','o','s','i','t','i','o','n','.','\n', ' ',' ','\'','\'',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','o','s','i','t','i','o','n','.','\n', ' ',' ','^','X','^','X',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','m','e',' ','a','s',' ','\'','.','\n', -' ',' ','E','S','C','-','M','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ','C','l','e','a','r',' ','a',' ','m','a','r','k','.','\n', +' ',' ','E','S','C','-','m','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ','C','l','e','a','r',' ','a',' ','m','a','r','k','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', ' ',' ',' ',' ',' ',' ',' ',' ','A',' ','m','a','r','k',' ','i','s',' ','a','n','y',' ','u','p','p','e','r','-','c','a','s','e',' ','o','r',' ','l','o','w','e','r','-','c','a','s','e',' ','l','e','t','t','e','r','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','C','e','r','t','a','i','n',' ','m','a','r','k','s',' ','a','r','e',' ','p','r','e','d','e','f','i','n','e','d',':','\n', diff --git a/less.hlp b/less.hlp index eeef52f..e4c5769 100644 --- a/less.hlp +++ b/less.hlp @@ -76,7 +76,7 @@ '_<_l_e_t_t_e_r_> Go to a previously marked position. '' Go to the previous position. ^X^X Same as '. - ESC-M_<_l_e_t_t_e_r_> Clear a mark. + ESC-m_<_l_e_t_t_e_r_> Clear a mark. --------------------------------------------------- A mark is any upper-case or lower-case letter. Certain marks are predefined: diff --git a/less.man b/less.man index 25b429d..92aa61a 100644 --- a/less.man +++ b/less.man @@ -1877,7 +1877,7 @@ LESS(1) General Commands Manual LESS(1) lesskey(1) COPYRIGHT - Copyright (C) 1984-2021 Mark Nudelman + Copyright (C) 1984-2022 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- @@ -1902,4 +1902,4 @@ LESS(1) General Commands Manual LESS(1) - Version 603: 14 Mar 2022 LESS(1) + Version 608: 22 Jul 2022 LESS(1) diff --git a/less.nro b/less.nro index ad4c136..254c1cf 100644 --- a/less.nro +++ b/less.nro @@ -1,5 +1,5 @@ '\" t -.TH LESS 1 "Version 603: 14 Mar 2022" +.TH LESS 1 "Version 608: 22 Jul 2022" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -2054,7 +2054,7 @@ The name of the editor (used for the v command). .BR lesskey (1) . .SH COPYRIGHT -Copyright (C) 1984-2021 Mark Nudelman +Copyright (C) 1984-2022 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.man b/lessecho.man index f9cea13..e18b7fb 100644 --- a/lessecho.man +++ b/lessecho.man @@ -51,4 +51,4 @@ LESSECHO(1) General Commands Manual LESSECHO(1) - Version 603: 14 Mar 2022 LESSECHO(1) + Version 608: 22 Jul 2022 LESSECHO(1) diff --git a/lessecho.nro b/lessecho.nro index ccba753..5b16d4a 100644 --- a/lessecho.nro +++ b/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 603: 14 Mar 2022" +.TH LESSECHO 1 "Version 608: 22 Jul 2022" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/lesskey.man b/lesskey.man index 8d87a47..9c83d28 100644 --- a/lesskey.man +++ b/lesskey.man @@ -115,7 +115,8 @@ LESSKEY(1) General Commands Manual LESSKEY(1) EXAMPLE The following input file describes the set of default command keys used - by less: + by less. Documentation on each command can be found in the man page, + under the key sequence which invokes the command. #command @@ -142,8 +143,8 @@ LESSKEY(1) General Commands Manual LESSKEY(1) f forw-screen ^F forw-screen ^V forw-screen - \kD forw-screen + \kD forw-screen b back-screen ^B back-screen \ev back-screen @@ -208,14 +209,16 @@ LESSKEY(1) General Commands Manual LESSKEY(1) ^X^V examine :n next-file :p prev-file - t next-tag + t next-tag T prev-tag :x index-file :d remove-file - toggle-option :t toggle-option t s toggle-option o + ## Use a long option name by starting the extra string with ONE dash; eg: + ## s toggle-option -log-file _ display-option | pipe v visual @@ -242,20 +245,20 @@ LESSKEY(1) General Commands Manual LESSKEY(1) PRECEDENCE - Commands specified by lesskey take precedence over the default com- - mands. A default command key may be disabled by including it in the - input file with the action "invalid". Alternatively, a key may be de- + Commands specified by lesskey take precedence over the default com- + mands. A default command key may be disabled by including it in the + input file with the action "invalid". Alternatively, a key may be de- fined to do nothing by using the action "noaction". "noaction" is sim- - ilar to "invalid", but less will give an error beep for an "invalid" - command, but not for a "noaction" command. In addition, ALL default + ilar to "invalid", but less will give an error beep for an "invalid" + command, but not for a "noaction" command. In addition, ALL default commands may be disabled by adding this control line to the input file: #stop - This will cause all default commands to be ignored. The #stop line + This will cause all default commands to be ignored. The #stop line should be the last line in that section of the file. - Be aware that #stop can be dangerous. Since all default commands are + Be aware that #stop can be dangerous. Since all default commands are disabled, you must provide sufficient commands before the #stop line to enable all necessary actions. For example, failure to provide a "quit" command can lead to frustration. @@ -265,9 +268,9 @@ LESSKEY(1) General Commands Manual LESSKEY(1) #line-edit - This section specifies new key bindings for the line editing commands, - in a manner similar to the way key bindings for ordinary commands are - specified in the #command section. The line-editing section consists + This section specifies new key bindings for the line editing commands, + in a manner similar to the way key bindings for ordinary commands are + specified in the #command section. The line-editing section consists of a list of keys and actions, one per line as in the example below. EXAMPLE @@ -275,7 +278,6 @@ LESSKEY(1) General Commands Manual LESSKEY(1) used by less: - #line-edit \t forw-complete \17 back-complete @@ -312,30 +314,30 @@ LESSKEY(1) General Commands Manual LESSKEY(1) #env - Following this line is a list of environment variable assignments. - Each line consists of an environment variable name, an equals sign (=) - and the value to be assigned to the environment variable. White space - before and after the equals sign is ignored. Variables assigned in - this way are visible only to less. If a variable is specified in the + Following this line is a list of environment variable assignments. + Each line consists of an environment variable name, an equals sign (=) + and the value to be assigned to the environment variable. White space + before and after the equals sign is ignored. Variables assigned in + this way are visible only to less. If a variable is specified in the system environment and also in a lesskey file, the value in the lesskey file takes precedence. If the variable name is followed by += rather than =, the string is ap- - pended to the variable's existing value. This currently works only if + pended to the variable's existing value. This currently works only if any += lines immediately follow the same variable's original definition - (with an = line), without any intervening definitions of other vari- - ables. It can append only to a variable defined earlier in the file; + (with an = line), without any intervening definitions of other vari- + ables. It can append only to a variable defined earlier in the file; it cannot append to a variable in the system environment. CONDITIONAL CONFIGURATION - If a line begins with #version followed by a relational operator and a - version number, the remainder of the line is parsed if and only if the + If a line begins with #version followed by a relational operator and a + version number, the remainder of the line is parsed if and only if the running version of less (or lesskey) matches the operator. This can be helpful if a lesskey file is used by different versions of less. - For example, suppose that a new command named 'sideways-search' is - added in less version 777. Then the following line would assign the - command to the Q key, but only in versions of less which support it. + For example, suppose that a new command named 'sideways-search' is + added in less version 777. Then the following line would assign the + command to the Q key, but only in versions of less which support it. The line would be ignored by versions earlier than 777. #version >= 777 Q sideways-search @@ -349,7 +351,7 @@ LESSKEY(1) General Commands Manual LESSKEY(1) = Equal to != Not equal to - The #version feature is not supported in less and lesskey before ver- + The #version feature is not supported in less and lesskey before ver- sion 594. In those older versions, all #version lines are ignored. EXAMPLE @@ -364,26 +366,26 @@ LESSKEY(1) General Commands Manual LESSKEY(1) less(1) WARNINGS - On MS-DOS and OS/2 systems, certain keys send a sequence of characters - which start with a NUL character (0). This NUL character should be + On MS-DOS and OS/2 systems, certain keys send a sequence of characters + which start with a NUL character (0). This NUL character should be represented as \340 in a lesskey file. COPYRIGHT - Copyright (C) 1984-2021 Mark Nudelman + Copyright (C) 1984-2022 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- - eral Public License as published by the Free Software Foundation; or + 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- + eral Public License as published by the Free Software Foundation; or (2) the Less License. See the file README in the less distribution for more details regarding redistribution. You should have received a copy - of the GNU General Public License along with the source for less; see - the file COPYING. If not, write to the Free Software Foundation, 59 - Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also + of the GNU General Public License along with the source for less; see + the file COPYING. If not, write to the Free Software Foundation, 59 + Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also have received a copy of the Less License; see the file LICENSE. less is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- - NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- + NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. AUTHOR @@ -392,4 +394,4 @@ LESSKEY(1) General Commands Manual LESSKEY(1) - Version 603: 14 Mar 2022 LESSKEY(1) + Version 608: 22 Jul 2022 LESSKEY(1) diff --git a/lesskey.nro b/lesskey.nro index c63e86a..a9d195a 100644 --- a/lesskey.nro +++ b/lesskey.nro @@ -1,5 +1,5 @@ '\" t -.TH LESSKEY 1 "Version 603: 14 Mar 2022" +.TH LESSKEY 1 "Version 608: 22 Jul 2022" .SH NAME lesskey \- customize key bindings for less .SH "SYNOPSIS (deprecated)" @@ -149,7 +149,10 @@ quits, the first character of the extra string is used as its exit status. .SH EXAMPLE The following input file describes the set of default command keys used by -.IR less : +.IR less . +Documentation on each command can be found in the +.less +man page, under the key sequence which invokes the command. .sp .RS 5m .TS @@ -250,6 +253,8 @@ T prev-tag - toggle-option :t toggle-option t s toggle-option o + ## Use a long option name by starting the extra string with ONE dash; eg: + ## s toggle-option -log-file\n \&_ display-option | pipe v visual @@ -438,7 +443,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-2021 Mark Nudelman +Copyright (C) 1984-2022 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/line.c b/line.c index 411aec8..d5c0e59 100644 --- a/line.c +++ b/line.c @@ -1036,15 +1036,13 @@ store_ansi(ch, rep, pos) switch (ansi_step(line_ansi, ch)) { case ANSI_MID: - if (!in_hilite) - STORE_CHAR(ch, AT_ANSI, rep, pos); + STORE_CHAR(ch, AT_ANSI, rep, pos); if (line_ansi->hlink) hlink_in_line = 1; xbuf_add(&last_ansi, ch); break; case ANSI_END: - if (!in_hilite) - STORE_CHAR(ch, AT_ANSI, rep, pos); + STORE_CHAR(ch, AT_ANSI, rep, pos); ansi_done(line_ansi); line_ansi = NULL; xbuf_add(&last_ansi, ch); @@ -1053,7 +1051,6 @@ store_ansi(ch, rep, pos) curr_last_ansi = (curr_last_ansi + 1) % NUM_LAST_ANSIS; break; case ANSI_ERR: - if (!in_hilite) { /* Remove whole unrecognized sequence. */ char *start = (cshift < hshift) ? shifted_ansi.data : linebuf.buf; diff --git a/screen.c b/screen.c index aac24cd..227ef83 100644 --- a/screen.c +++ b/screen.c @@ -134,8 +134,10 @@ extern int sc_height; #endif #if MSDOS_COMPILER==WIN32C +#define UTF8_MAX_LENGTH 4 struct keyRecord { + WCHAR unicode; int ascii; int scan; } currentKey; @@ -2857,10 +2859,10 @@ win32_kbhit(VOID_PARAM) */ do { - PeekConsoleInput(tty, &ip, 1, &read); + PeekConsoleInputW(tty, &ip, 1, &read); if (read == 0) return (FALSE); - ReadConsoleInput(tty, &ip, 1, &read); + ReadConsoleInputW(tty, &ip, 1, &read); /* generate an X11 mouse sequence from the mouse event */ if (mousecap && ip.EventType == MOUSE_EVENT && ip.Event.MouseEvent.dwEventFlags != MOUSE_MOVED) @@ -2891,11 +2893,13 @@ win32_kbhit(VOID_PARAM) } } while (ip.EventType != KEY_EVENT || ip.Event.KeyEvent.bKeyDown != TRUE || - ip.Event.KeyEvent.wVirtualScanCode == 0 || + (ip.Event.KeyEvent.wVirtualScanCode == 0 && ip.Event.KeyEvent.uChar.UnicodeChar == 0) || + ip.Event.KeyEvent.wVirtualKeyCode == VK_KANJI || ip.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT || ip.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL || ip.Event.KeyEvent.wVirtualKeyCode == VK_MENU); + currentKey.unicode = ip.Event.KeyEvent.uChar.UnicodeChar; currentKey.ascii = ip.Event.KeyEvent.uChar.AsciiChar; currentKey.scan = ip.Event.KeyEvent.wVirtualScanCode; keyCount = ip.Event.KeyEvent.wRepeatCount; @@ -2943,7 +2947,18 @@ win32_kbhit(VOID_PARAM) public char WIN32getch(VOID_PARAM) { - int ascii; + char ascii; + static unsigned char utf8[UTF8_MAX_LENGTH]; + static int utf8_size = 0; + static int utf8_next_byte = 0; + + // Return the rest of multibyte character from the prior call + if (utf8_next_byte < utf8_size) + { + ascii = utf8[utf8_next_byte++]; + return ascii; + } + utf8_size = 0; if (pending_scancode) { @@ -2960,7 +2975,16 @@ WIN32getch(VOID_PARAM) continue; } keyCount --; - ascii = currentKey.ascii; + // If multibyte character, return its first byte + if (currentKey.ascii != currentKey.unicode) + { + utf8_size = WideCharToMultiByte(CP_UTF8, 0, ¤tKey.unicode, 1, (LPSTR)&utf8, sizeof(utf8), NULL, NULL); + if (utf8_size == 0 ) + return '\0'; + ascii = utf8[0]; + utf8_next_byte = 1; + } else + ascii = currentKey.ascii; /* * On PC's, the extended keys return a 2 byte sequence beginning * with '00', so if the ascii code is 00, the next byte will be @@ -2970,7 +2994,7 @@ WIN32getch(VOID_PARAM) } while (pending_scancode && (currentKey.scan == PCK_CAPS_LOCK || currentKey.scan == PCK_NUM_LOCK)); - return ((char)ascii); + return ascii; } #endif diff --git a/ubin.uni b/ubin.uni index 7391121..dc00187 100644 --- a/ubin.uni +++ b/ubin.uni @@ -1,4 +1,4 @@ -/* Generated by "./mkutable -f2 Cc Cs Co Zl Zp -- unicode/UnicodeData.txt" on Tue May 19 14:47:34 PDT 2020 */ +/* Generated by "./mkutable -f2 Cc Cs Co Zl Zp -- unicode/UnicodeData.txt" on Tue Jul 19 12:45:17 PDT 2022 */ { 0x0000, 0x0007 }, /* Cc */ { 0x000b, 0x000b }, /* Cc */ { 0x000e, 0x001f }, /* Cc */ diff --git a/version.c b/version.c index 8980e92..8f48efc 100644 --- a/version.c +++ b/version.c @@ -948,6 +948,12 @@ v600 1/7/22 Use /dev/tty if cannot open ttyname(). v601 1/31/22 Add --exit-follow-on-close option. v602 3/1/22 Doc changes. v603 3/14/22 Fix --header. +v604 5/14/22 Fix termlib detection; fix non-ASCII input on Windows. +v605 6/14/22 Update version number. +v606 7/17/22 Fix bug with multibyte chars and --incsearch; + escape filenames in LESSCLOSE; fix bin_file overrun. +v607 7/19/22 Update Unicode tables. +v608 7/22/22 Fix highlighting on colored text boundaries. */ -char version[] = "603"; +char version[] = "608"; diff --git a/wide.uni b/wide.uni index 54d7b2d..6afa86f 100644 --- a/wide.uni +++ b/wide.uni @@ -1,4 +1,4 @@ -/* Generated by "./mkutable -f1 W F -- unicode/EastAsianWidth.txt" on Tue May 19 14:47:35 PDT 2020 */ +/* Generated by "./mkutable -f1 W F -- unicode/EastAsianWidth.txt" on Tue Jul 19 12:45:19 PDT 2022 */ { 0x1100, 0x115f }, /* W */ { 0x231a, 0x231b }, /* W */ { 0x2329, 0x232a }, /* W */ @@ -64,7 +64,10 @@ { 0x17000, 0x187f7 }, /* W */ { 0x18800, 0x18cd5 }, /* W */ { 0x18d00, 0x18d08 }, /* W */ - { 0x1b000, 0x1b11e }, /* W */ + { 0x1aff0, 0x1aff3 }, /* W */ + { 0x1aff5, 0x1affb }, /* W */ + { 0x1affd, 0x1affe }, /* W */ + { 0x1b000, 0x1b122 }, /* W */ { 0x1b150, 0x1b152 }, /* W */ { 0x1b164, 0x1b167 }, /* W */ { 0x1b170, 0x1b2fb }, /* W */ @@ -99,20 +102,22 @@ { 0x1f6cc, 0x1f6cc }, /* W */ { 0x1f6d0, 0x1f6d2 }, /* W */ { 0x1f6d5, 0x1f6d7 }, /* W */ + { 0x1f6dd, 0x1f6df }, /* W */ { 0x1f6eb, 0x1f6ec }, /* W */ { 0x1f6f4, 0x1f6fc }, /* W */ { 0x1f7e0, 0x1f7eb }, /* W */ + { 0x1f7f0, 0x1f7f0 }, /* W */ { 0x1f90c, 0x1f93a }, /* W */ { 0x1f93c, 0x1f945 }, /* W */ - { 0x1f947, 0x1f978 }, /* W */ - { 0x1f97a, 0x1f9cb }, /* W */ - { 0x1f9cd, 0x1f9ff }, /* W */ + { 0x1f947, 0x1f9ff }, /* W */ { 0x1fa70, 0x1fa74 }, /* W */ - { 0x1fa78, 0x1fa7a }, /* W */ + { 0x1fa78, 0x1fa7c }, /* W */ { 0x1fa80, 0x1fa86 }, /* W */ - { 0x1fa90, 0x1faa8 }, /* W */ - { 0x1fab0, 0x1fab6 }, /* W */ - { 0x1fac0, 0x1fac2 }, /* W */ - { 0x1fad0, 0x1fad6 }, /* W */ + { 0x1fa90, 0x1faac }, /* W */ + { 0x1fab0, 0x1faba }, /* W */ + { 0x1fac0, 0x1fac5 }, /* W */ + { 0x1fad0, 0x1fad9 }, /* W */ + { 0x1fae0, 0x1fae7 }, /* W */ + { 0x1faf0, 0x1faf6 }, /* W */ { 0x20000, 0x2fffd }, /* W */ { 0x30000, 0x3fffd }, /* W */