From c612c3607b183ae654d6c920c729de5444fdb899 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Fri, 6 Sep 2019 15:30:05 -0400 Subject: [PATCH] commit readline-20190906 snapshot --- CHANGELOG | 12 ++++++++++++ NEWS | 21 +++++++++++++++++++++ colors.c | 2 +- complete.c | 17 ++++++++++++++++- configure | 4 +++- configure.ac | 2 +- examples/autoconf/RL_LIB_READLINE_VERSION | 1 + terminal.c | 23 ++++++++++++++++------- 8 files changed, 71 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cfe97b3..71e9e4f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1364,3 +1364,15 @@ readline.pc.in ---- configure.ac - hpux: add -DTGETENT_BROKEN to LOCAL_CFLAGS + + 8/28 + ---- +configure.ac + - hpux: add -DTGETFLAG_BROKEN to LOCAL_CFLAGS + + 9/6 + --- +examples/autoconf/RL_LIB_READLINE_VERSION + - include in the AC_TRY_RUN block to accommodate compilers + that treat functions without an existing prototype as fatal errors. + Report and fix from Florian Weimer diff --git a/NEWS b/NEWS index 42be21e..47a0534 100644 --- a/NEWS +++ b/NEWS @@ -178,6 +178,27 @@ n. New application-settable variable: rl_signal_event_hook; function that is called when readline is reading terminal input and read(2) is interrupted by a signal. Currently not called for SIGHUP or SIGTERM. +------------------------------------------------------------------------------- +This is a terse description of the new features added to readline-6.2 since +the release of readline-6.1. + +a. The history library does not try to write the history filename in the + current directory if $HOME is unset. This closes a potential security + problem if the application does not specify a history filename. + +b. New bindable variable `completion-display-width' to set the number of + columns used when displaying completions. + +c. New bindable variable `completion-case-map' to cause case-insensitive + completion to treat `-' and `_' as identical. + +d. There are new bindable vi-mode command names to avoid readline's case- + insensitive matching not allowing them to be bound separately. + +e. New bindable variable `menu-complete-display-prefix' causes the menu + completion code to display the common prefix of the possible completions + before cycling through the list, instead of after. + ------------------------------------------------------------------------------- This is a terse description of the new features added to readline-6.1 since the release of readline-6.0. diff --git a/colors.c b/colors.c index 53758e0..81aecfe 100644 --- a/colors.c +++ b/colors.c @@ -175,7 +175,7 @@ _rl_print_color_indicator (const char *f) if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL) colored_filetype = C_MISSING; - else if (linkok == 0 && S_ISLNK(mode) && _rl_color_indicator[C_ORPHAN].string != NULL) + else if (linkok == 0 && _rl_color_indicator[C_ORPHAN].string != NULL) colored_filetype = C_ORPHAN; /* dangling symlink */ else if(stat_ok != 0) { diff --git a/complete.c b/complete.c index 7da8ee9..bd82ab9 100644 --- a/complete.c +++ b/complete.c @@ -429,7 +429,11 @@ rl_complete (int ignore, int invoking_key) if (rl_inhibit_completion) return (_rl_insert_char (ignore, invoking_key)); +#if 0 else if (rl_last_func == rl_complete && completion_changed_buffer == 0 && last_completion_failed == 0) +#else + else if (rl_last_func == rl_complete && completion_changed_buffer == 0) +#endif return (rl_complete_internal ('?')); else if (_rl_complete_show_all) return (rl_complete_internal ('!')); @@ -1987,10 +1991,12 @@ rl_complete_internal (int what_to_do) int start, end, delimiter, found_quote, i, nontrivial_lcd; char *text, *saved_line_buffer; char quote_char; - int tlen, mlen; + int tlen, mlen, saved_last_completion_failed; RL_SETSTATE(RL_STATE_COMPLETING); + saved_last_completion_failed = last_completion_failed; + set_completion_defaults (what_to_do); saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; @@ -2104,6 +2110,15 @@ rl_complete_internal (int what_to_do) break; case '?': + /* Let's try to insert a single match here if the last completion failed + but this attempt returned a single match. */ + if (saved_last_completion_failed && matches[0] && *matches[0] && matches[1] == 0) + { + insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); + append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd); + break; + } + if (rl_completion_display_matches_hook == 0) { _rl_sigcleanup = _rl_complete_sigcleanup; diff --git a/configure b/configure index b4c8460..16b30bc 100755 --- a/configure +++ b/configure @@ -5320,6 +5320,7 @@ else #ifdef HAVE_UNISTD_H #include #endif +#include typedef RETSIGTYPE sigfunc(); @@ -5400,6 +5401,7 @@ else #include #include #include +#include main() { @@ -6807,7 +6809,7 @@ esac case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; -hpux*) LOCAL_CFLAGS=-DTGETENT_BROKEN ;; +hpux*) LOCAL_CFLAGS="-DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;; esac # shared library configuration section diff --git a/configure.ac b/configure.ac index 5f56b44..cf74a32 100644 --- a/configure.ac +++ b/configure.ac @@ -215,7 +215,7 @@ esac case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; -hpux*) LOCAL_CFLAGS=-DTGETENT_BROKEN ;; +hpux*) LOCAL_CFLAGS="-DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;; esac # shared library configuration section diff --git a/examples/autoconf/RL_LIB_READLINE_VERSION b/examples/autoconf/RL_LIB_READLINE_VERSION index 883942c..cc158a8 100644 --- a/examples/autoconf/RL_LIB_READLINE_VERSION +++ b/examples/autoconf/RL_LIB_READLINE_VERSION @@ -35,6 +35,7 @@ AC_CACHE_VAL(ac_cv_rl_version, [AC_TRY_RUN([ #include #include +#include extern int rl_gnu_readline_p; diff --git a/terminal.c b/terminal.c index fa00438..86299f5 100644 --- a/terminal.c +++ b/terminal.c @@ -177,6 +177,19 @@ static char *_rl_term_kI; static char *_rl_term_vs; /* very visible */ static char *_rl_term_ve; /* normal */ +/* It's not clear how HPUX is so broken here. */ +#ifdef TGETENT_BROKEN +# define TGETENT_SUCCESS 0 +#else +# define TGETENT_SUCCESS 1 +#endif +#ifdef TGETFLAG_BROKEN +# define TGETFLAG_SUCCESS 0 +#else +# define TGETFLAG_SUCCESS 1 +#endif +#define TGETFLAG(cap) (tgetflag (cap) == TGETFLAG_SUCCESS) + static void bind_termcap_arrow_keys PARAMS((Keymap)); /* Variables that hold the screen dimensions, used by the display code. */ @@ -483,11 +496,7 @@ _rl_init_terminal_io (const char *terminal_name) tgetent_ret = tgetent (term_buffer, term); } -#ifdef TGETENT_BROKEN - if (tgetent_ret < 0) -#else - if (tgetent_ret <= 0) -#endif + if (tgetent_ret != TGETENT_SUCCESS) { FREE (term_string_buffer); FREE (term_buffer); @@ -548,7 +557,7 @@ _rl_init_terminal_io (const char *terminal_name) if (!_rl_term_cr) _rl_term_cr = "\r"; - _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn"); + _rl_term_autowrap = TGETFLAG ("am") && TGETFLAG ("xn"); /* Allow calling application to set default height and width, using rl_set_screen_size */ @@ -563,7 +572,7 @@ _rl_init_terminal_io (const char *terminal_name) /* Check to see if this terminal has a meta key and clear the capability variables if there is none. */ - term_has_meta = tgetflag ("km") != 0; + term_has_meta = TGETFLAG ("km"); if (term_has_meta == 0) _rl_term_mm = _rl_term_mo = (char *)NULL; #endif /* !__MSDOS__ */ -- 2.47.2