]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20180426 snapshot
authorChet Ramey <chet.ramey@case.edu>
Thu, 26 Apr 2018 15:43:45 +0000 (11:43 -0400)
committerChet Ramey <chet.ramey@case.edu>
Thu, 26 Apr 2018 15:43:45 +0000 (11:43 -0400)
15 files changed:
CHANGELOG
aclocal.m4
bind.c
configure
configure.ac
display.c
doc/._rluserman.pdf [new file with mode: 0644]
doc/hsuser.texi
doc/readline.3
doc/rltech.texi
doc/rluser.texi
readline.c
readline.h
readline.pc.in
text.c

index 9d43a4b6717112a107b27fb6f33afb6c638fbe1d..f006fd1ff37181095411e08a1462fa30b2252da6 100644 (file)
--- 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
+         <thomas.petazzoni@bootlin.com>
index 488408eae8e06df49da2345cbbc35d06e0f2cbe3..6ea6f40f9fa7927b1e77a96d21338b924ab3b520 100644 (file)
@@ -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 30779966850cb9cb5e7ff0c896ff697450ef5ab3..2e05b4605cc3b99f9adc7eaf79abb1402ee39847 100644 (file)
--- 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;
 
index be87fafb59cf3d2c5cdf63dee5b2d0de724fed9b..e304679a6d1459407ae7f787616a4d662bfaad11 100755 (executable)
--- 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"
index fd0cec485f1571facf77afa53174d3bedcee3eb5..64ed9ccd1fb98971f5e1b9cbc3ff2d6450c4a67b 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 
-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],
 [
index 5b2663a85bb84fd9177e3bf48c85d2b5cfe60afc..75019efcfd34abc1a4686fd1d4cc80ad8fa32d83 100644 (file)
--- 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 (file)
index 0000000..2bbb1ac
Binary files /dev/null and b/doc/._rluserman.pdf differ
index 1c25f813218654703a89dc1fa9f4abd9f91bfdaf..d21f65d0f143ebf21a17101bb2e0573a11bb3ad9 100644 (file)
@@ -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
index 5b555dcfeac6487825f1d4c2ef142dc7243b2e60..be89c2dff870e1c30cd7f4ff1fc74fca813f0c39 100644 (file)
@@ -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.
index 5e57eaba1d8ef9e4086178887875dcca8e729e26..7d22b2cb6af6d0dc13085566349cac02f2c6d724 100644 (file)
@@ -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.
index 2d90366ae6451e46f1c3ba56307bad71959ec692..1c9acdcc1791bdc334f4db9b061b4a93aa73b3c1 100644 (file)
@@ -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,
index 64154c549c461a8c89abf40b74516d2b143c0c29..4842a02e0524a90cd32aaee65825d4de91739d5a 100644 (file)
@@ -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;
index c847e937f21f75674b4ff8e3cb08f3011bb91cd0..2081b197b68adfb33158291663dbeea4730bbbf2 100644 (file)
@@ -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));
index fbfca8acbe8fa9612b0bdf10383c781f1407c298..a7f2cf3877f615d7402f17d953e04cc28b292d44 100644 (file)
@@ -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 116a33b67fe098a6dc7c876af9b60e29c951f190..81de2a99c97b3f48f4150ab1949080599e193882 100644 (file)
--- 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) &&