From: Chet Ramey Date: Thu, 26 Apr 2018 15:43:45 +0000 (-0400) Subject: commit readline-20180426 snapshot X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39cef351237a0d4467d3dc62a7710ea5e619b7e1;p=thirdparty%2Freadline.git commit readline-20180426 snapshot --- diff --git a/CHANGELOG b/CHANGELOG index 9d43a4b..f006fd1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1316,3 +1316,14 @@ configure.ac,config.h.in Makefile.in,examples/Makefile.in - add support for building with address sanitizer, using new target `asan' + + 4/23/2018 + --------- +configure.ac + - TERMCAP_PKG_CONFIG_LIB: new variable, defined from TERMCAP_LIB, + defaults to termcap + +readline.pc.in + - change Requires.private to use TERMCAP_PKG_CONFIG_LIB instead of + hardcoded `tinfo'. Report and fix from Thomas Petazzoni + diff --git a/aclocal.m4 b/aclocal.m4 index 488408e..6ea6f40 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1581,9 +1581,7 @@ fi AC_DEFUN(BASH_CHECK_DEV_STDIN, [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available) AC_CACHE_VAL(bash_cv_dev_stdin, -[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then - bash_cv_dev_stdin=present - elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then +[if (exec test -r /dev/stdin < /dev/null) ; then bash_cv_dev_stdin=present else bash_cv_dev_stdin=absent diff --git a/bind.c b/bind.c index 3077996..2e05b46 100644 --- a/bind.c +++ b/bind.c @@ -80,6 +80,8 @@ static void _rl_init_file_error (const char *, ...) __attribute__((__format__ ( static void _rl_init_file_error (); #endif +static rl_command_func_t *_rl_function_of_keyseq_internal PARAMS((const char *, size_t, Keymap, int *)); + static char *_rl_read_file PARAMS((char *, size_t *)); static int _rl_read_init_file PARAMS((const char *, int)); static int glean_key_from_name PARAMS((char *)); @@ -193,20 +195,18 @@ rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map) int rl_bind_key_if_unbound_in_map (int key, rl_command_func_t *default_func, Keymap kmap) { - char keyseq[2]; + char *keyseq; - keyseq[0] = (unsigned char)key; - keyseq[1] = '\0'; + keyseq = rl_untranslate_keyseq ((unsigned char)key); return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap)); } int rl_bind_key_if_unbound (int key, rl_command_func_t *default_func) { - char keyseq[2]; + char *keyseq; - keyseq[0] = (unsigned char)key; - keyseq[1] = '\0'; + keyseq = rl_untranslate_keyseq ((unsigned char)key); return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap)); } @@ -287,10 +287,21 @@ int rl_bind_keyseq_if_unbound_in_map (const char *keyseq, rl_command_func_t *default_func, Keymap kmap) { rl_command_func_t *func; + char *keys; + int keys_len; if (keyseq) { - func = rl_function_of_keyseq (keyseq, kmap, (int *)NULL); + /* Handle key sequences that require translations and `raw' ones that + don't. This might be a problem with backslashes. */ + keys = (char *)xmalloc (1 + (2 * strlen (keyseq))); + if (rl_translate_keyseq (keyseq, keys, &keys_len)) + { + xfree (keys); + return -1; + } + func = rl_function_of_keyseq_len (keys, keys_len, kmap, (int *)NULL); + xfree (keys); #if defined (VI_MODE) if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode) #else @@ -373,7 +384,8 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) unsigned char uc = keys[i]; int ic; - prevkey = ic; + if (i > 0) + prevkey = ic; ic = uc; if (ic < 0 || ic >= KEYMAP_SIZE) @@ -760,15 +772,15 @@ rl_named_function (const char *string) used. TYPE, if non-NULL, is a pointer to an int which will receive the type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), or ISMACR (macro). */ -rl_command_func_t * -rl_function_of_keyseq (const char *keyseq, Keymap map, int *type) +static rl_command_func_t * +_rl_function_of_keyseq_internal (const char *keyseq, size_t len, Keymap map, int *type) { register int i; if (map == 0) map = _rl_keymap; - for (i = 0; keyseq && keyseq[i]; i++) + for (i = 0; keyseq && i < len; i++) { unsigned char ic = keyseq[i]; @@ -820,6 +832,18 @@ rl_function_of_keyseq (const char *keyseq, Keymap map, int *type) return ((rl_command_func_t *) NULL); } +rl_command_func_t * +rl_function_of_keyseq (const char *keyseq, Keymap map, int *type) +{ + return _rl_function_of_keyseq_internal (keyseq, strlen (keyseq), map, type); +} + +rl_command_func_t * +rl_function_of_keyseq_len (const char *keyseq, size_t len, Keymap map, int *type) +{ + return _rl_function_of_keyseq_internal (keyseq, len, map, type); +} + /* The last key bindings file read. */ static char *last_readline_init_file = (char *)NULL; @@ -839,8 +863,13 @@ _rl_read_file (char *filename, size_t *sizep) char *buffer; int i, file; - if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0) - return ((char *)NULL); + file = -1; + if (((file = open (filename, O_RDONLY, 0666)) < 0) || (fstat (file, &finfo) < 0)) + { + if (file >= 0) + close (file); + return ((char *)NULL); + } file_size = (size_t)finfo.st_size; diff --git a/configure b/configure index be87faf..e304679 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Readline 7.0, version 2.82. +# From configure.ac for Readline 7.0, version 2.83. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for readline 7.0. # @@ -624,6 +624,7 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +TERMCAP_PKG_CONFIG_LIB TERMCAP_LIB LIBVERSION ARFLAGS @@ -6307,6 +6308,14 @@ done fi +case "$TERMCAP_LIB" in +-ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;; +-lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; +-lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; +-ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;; +*) TERMCAP_PKG_CONFIG_LIB=termcap ;; +esac + for ac_header in wctype.h do : @@ -6837,6 +6846,7 @@ esac + ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc" ac_config_commands="$ac_config_commands default" diff --git a/configure.ac b/configure.ac index fd0cec4..64ed9cc 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Readline 7.0, version 2.82]) +AC_REVISION([for Readline 7.0, version 2.83]) AC_INIT(readline, 7.0, bug-readline@gnu.org) @@ -196,6 +196,14 @@ if test "$TERMCAP_LIB" = "-lncurses"; then AC_CHECK_HEADERS(ncurses/termcap.h) fi +case "$TERMCAP_LIB" in +-ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;; +-lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; +-lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; +-ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;; +*) TERMCAP_PKG_CONFIG_LIB=termcap ;; +esac + BASH_CHECK_MULTIBYTE case "$host_cpu" in @@ -292,6 +300,7 @@ AC_SUBST(host_os) AC_SUBST(LIBVERSION) AC_SUBST(TERMCAP_LIB) +AC_SUBST(TERMCAP_PKG_CONFIG_LIB) AC_OUTPUT([Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc], [ diff --git a/display.c b/display.c index 5b2663a..75019ef 100644 --- a/display.c +++ b/display.c @@ -1168,15 +1168,16 @@ rl_redisplay (void) wrap_offset. */ if (linenum == 0 && (mb_cur_max > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT()) _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ - else if (linenum == prompt_last_screen_line && + else if (cpos_adjusted == 0 && + linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth && (mb_cur_max > 1 && rl_byte_oriented == 0) && - cpos_adjusted == 0 && _rl_last_c_pos != o_cpos && _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line)) /* XXX - rethink this last one */ /* This assumes that all the invisible characters are split between the first and last lines of the prompt, if the prompt consumes more than two lines. It's usually right */ + /* XXX - not sure this is ever executed */ _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line); /* If this is the line with the prompt, we might need to diff --git a/doc/._rluserman.pdf b/doc/._rluserman.pdf new file mode 100644 index 0000000..2bbb1ac Binary files /dev/null and b/doc/._rluserman.pdf differ diff --git a/doc/hsuser.texi b/doc/hsuser.texi index 1c25f81..d21f65d 100644 --- a/doc/hsuser.texi +++ b/doc/hsuser.texi @@ -149,8 +149,8 @@ Both @var{first} and @var{last} may be specified as a string (to locate the most recent command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the -current command number). If @var{last} is not specified it is set to -@var{first}. If @var{first} is not specified it is set to the previous +current command number). If @var{last} is not specified, it is set to +@var{first}. If @var{first} is not specified, it is set to the previous command for editing and @minus{}16 for listing. If the @option{-l} flag is given, the commands are listed on standard output. The @option{-n} flag suppresses the command numbers when listing. The @option{-r} flag diff --git a/doc/readline.3 b/doc/readline.3 index 5b555dc..be89c2d 100644 --- a/doc/readline.3 +++ b/doc/readline.3 @@ -378,13 +378,13 @@ in emacs mode and to .B # in vi command mode. .TP -.B completion\-display\-width (-1) +.B completion\-display\-width (\-1) The number of screen columns used to display possible matches when performing completion. The value is ignored if it is less than 0 or greater than the terminal screen width. A value of 0 will cause matches to be displayed one per line. -The default value is -1. +The default value is \-1. .TP .B completion\-ignore\-case (Off) If set to \fBOn\fP, readline performs filename matching and completion @@ -1149,6 +1149,7 @@ and store the definition. .B call\-last\-kbd\-macro (C\-x e) Re-execute the last keyboard macro defined, by making the characters in the macro appear as if typed at the keyboard. +.TP .B print\-last\-kbd\-macro () Print the last keyboard macro defined in a format suitable for the \fIinputrc\fP file. diff --git a/doc/rltech.texi b/doc/rltech.texi index 5e57eab..7d22b2c 100644 --- a/doc/rltech.texi +++ b/doc/rltech.texi @@ -848,6 +848,12 @@ not @code{NULL}, the type of the object is returned in the @code{int} variable it points to (one of @code{ISFUNC}, @code{ISKMAP}, or @code{ISMACR}). @end deftypefun +@deftypefun {rl_command_func_t *} rl_function_of_keyseq_len (const char *keyseq, size_t len Keymap map, int *type) +Return the function invoked by @var{keyseq} of length @var{len} +in keymap @var{map}. Equivalent to @code{rl_function_of_keyseq} with the +addition of the @var{len} parameter. +@end deftypefun + @deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function) Return an array of strings representing the key sequences used to invoke @var{function} in the current keymap. diff --git a/doc/rluser.texi b/doc/rluser.texi index 2d90366..1c9acdc 100644 --- a/doc/rluser.texi +++ b/doc/rluser.texi @@ -1873,7 +1873,9 @@ Next, the string specified as the argument to the @option{-W} option is considered. The string is first split using the characters in the @env{IFS} special variable as delimiters. -Shell quoting is honored. +Shell quoting is honored within the string, in order to provide a +mechanism for the words to contain shell metacharacters or characters +in the value of @env{IFS}. Each word is then expanded using brace expansion, tilde expansion, parameter and variable expansion, command substitution, and arithmetic expansion, diff --git a/readline.c b/readline.c index 64154c5..4842a02 100644 --- a/readline.c +++ b/readline.c @@ -242,7 +242,7 @@ int rl_erase_empty_line = 0; /* Non-zero means to read only this many characters rather than up to a character bound to accept-line. */ -int rl_num_chars_to_read; +int rl_num_chars_to_read = 0; /* Line buffer and maintenance. */ char *rl_line_buffer = (char *)NULL; diff --git a/readline.h b/readline.h index c847e93..2081b19 100644 --- a/readline.h +++ b/readline.h @@ -332,6 +332,7 @@ extern char *rl_untranslate_keyseq PARAMS((int)); extern rl_command_func_t *rl_named_function PARAMS((const char *)); extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *)); +extern rl_command_func_t *rl_function_of_keyseq_len PARAMS((const char *, size_t, Keymap, int *)); extern void rl_list_funmap_names PARAMS((void)); extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap)); diff --git a/readline.pc.in b/readline.pc.in index fbfca8a..a7f2cf3 100644 --- a/readline.pc.in +++ b/readline.pc.in @@ -7,6 +7,6 @@ Name: Readline Description: Gnu Readline library for command line editing URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html Version: @LIBVERSION@ -Requires.private: tinfo +Requires.private: @TERMCAP_PKG_CONFIG_LIB@ Libs: -L${libdir} -lreadline Cflags: -I${includedir}/readline diff --git a/text.c b/text.c index 116a33b..81de2a9 100644 --- a/text.c +++ b/text.c @@ -915,6 +915,7 @@ rl_insert (int count, int c) x = 0; n = (unsigned short)-2; while (_rl_optimize_typeahead && + rl_num_chars_to_read == 0 && (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && _rl_pushed_input_available () == 0 && _rl_input_queued (0) &&