]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20200124 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 24 Jan 2020 19:46:19 +0000 (14:46 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 24 Jan 2020 19:46:19 +0000 (14:46 -0500)
configure
configure.ac
display.c
kill.c
rlprivate.h
text.c
vi_mode.c

index 16b30bc7599a9c7b00d42e3f5e67594675fd4283..8da2fd247b699803d7523fcc67a4eed9628fc51f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac for Readline 8.0, version 2.86.
+# From configure.ac for Readline 8.0, version 2.87.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69 for readline 8.0.
 #
@@ -3909,8 +3909,8 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
 
 
 
-# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
-test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
+# If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
+test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
 
 if test $ac_cv_c_compiler_gnu = yes; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
@@ -5351,6 +5351,7 @@ int s;
   nsigint++;
 }
 
+int
 main()
 {
        nsigint = 0;
@@ -5403,6 +5404,7 @@ else
 #include <setjmp.h>
 #include <stdlib.h>
 
+int
 main()
 {
 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
@@ -5505,7 +5507,10 @@ else
 #if defined (HAVE_LOCALE_H)
 #include <locale.h>
 #endif
+#include <string.h>
+#include <stdlib.h>
 
+int
 main(c, v)
 int     c;
 char    *v[];
@@ -5575,7 +5580,9 @@ else
 #endif
 #include <stdio.h>
 #include <ctype.h>
+#include <stdlib.h>
 
+int
 main(c, v)
 int    c;
 char   *v[];
@@ -6719,6 +6726,7 @@ else
 #include <locale.h>
 #include <wchar.h>
 
+int
 main(c, v)
 int     c;
 char    **v;
index cf74a32a5767bdd1b7193724c61c880b8ae0a6bd..0cae7b69a3341736ef8a934e7c6dc9d0f518d4b8 100644 (file)
@@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
 dnl
 dnl Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 1987-2019 Free Software Foundation, Inc.
+# Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -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 8.0, version 2.86])
+AC_REVISION([for Readline 8.0, version 2.87])
 
 AC_INIT(readline, 8.0, bug-readline@gnu.org)
 
@@ -104,8 +104,8 @@ AC_PROG_CC
 dnl AC_AIX
 AC_MINIX
 
-# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
-test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
+# If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
+test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
 
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_INSTALL
index 4631047bb501efe2b44abbe70369cf4cb9100eb3..67ef84a9c8cc935e6da23eb92fc7c0c98742f401 100644 (file)
--- a/display.c
+++ b/display.c
@@ -223,7 +223,7 @@ static int msg_bufsiz = 0;
 static int forced_display;
 
 /* Default and initial buffer size.  Can grow. */
-static int line_size = DEFAULT_LINE_BUFFER_SIZE;
+static int line_size  = DEFAULT_LINE_BUFFER_SIZE;
 
 /* Set to a non-zero value if horizontal scrolling has been enabled
    automatically because the terminal was resized to height 1. */
@@ -1663,8 +1663,11 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
              _rl_last_v_pos++;
 
              /* 5a. If the number of screen positions doesn't match, punt
-                and do a dumb update. */
-             if (newwidth != oldwidth)
+                and do a dumb update.
+                5b. If the number of bytes is greater in the new line than
+                the old, do a dumb update, because there is no guarantee we
+                can extend the old line enough to fit the new bytes. */
+             if (newwidth != oldwidth || newbytes > oldbytes)
                {
                  oe = old + omax;
                  ne = new + nmax;
@@ -1678,13 +1681,17 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
                     consume the first character of old. Fix up `old' so it
                     reflects the new screen contents.  We use +1 in the
                     memmove call to copy the trailing NUL. */
-                 memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);
+                 /* (strlen(old+oldbytes) == (omax - oldbytes - 1)) */
+
+                 /* Don't bother trying to fit the bytes if the number of bytes
+                    doesn't change. */
+                 if (oldbytes != newbytes)
+                   memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);
                  memcpy (old, new, newbytes);
                  j = newbytes - oldbytes;
-                     
                  omax += j;
                  /* Fix up indices if we copy data from one line to another */
-                 for (i = current_line+1; i <= inv_botlin+1; i++)
+                 for (i = current_line+1; j != 0 && i <= inv_botlin+1 && i <=_rl_vis_botlin+1; i++)
                    vis_lbreaks[i] += j;
                }
            }
diff --git a/kill.c b/kill.c
index 6a2e0c6a59500eaf8a9203cd5abff004497f2e29..2bea7d05b25dc6dba301c5cc9e8fa30db1d98f8e 100644 (file)
--- a/kill.c
+++ b/kill.c
@@ -408,6 +408,7 @@ region_kill_internal (int delete)
       _rl_copy_to_kill_ring (text, rl_point < rl_mark);
     }
 
+  _rl_fix_point (1);
   _rl_last_command_was_kill++;
   return 0;
 }
@@ -427,8 +428,8 @@ rl_kill_region (int count, int key)
 
   npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
   r = region_kill_internal (1);
-  _rl_fix_point (1);
   rl_point = npoint;
+  _rl_fix_point (1);
   return r;
 }
 
index 1a99a5ae33700d158ff6411ce936b8f775c65862..f1c6147484bc1d093c5d627df12acc13c3d47b69 100644 (file)
@@ -387,6 +387,7 @@ extern void _rl_set_cursor PARAMS((int, int));
 
 /* text.c */
 extern void _rl_fix_point PARAMS((int));
+extern void _rl_fix_mark PARAMS((void));
 extern int _rl_replace_text PARAMS((const char *, int, int));
 extern int _rl_forward_char_internal PARAMS((int));
 extern int _rl_backward_char_internal PARAMS((int));
diff --git a/text.c b/text.c
index ff6ab6884a922724c9e68838f30a91abc8232276..7bd35d1e352a8f93b5bef67fac00bcff6e5fb828 100644 (file)
--- a/text.c
+++ b/text.c
@@ -154,6 +154,7 @@ rl_delete_text (int from, int to)
 
   rl_end -= diff;
   rl_line_buffer[rl_end] = '\0';
+  _rl_fix_mark ();
   return (diff);
 }
 
@@ -176,6 +177,12 @@ _rl_fix_point (int fix_mark_too)
   if (fix_mark_too)
     _RL_FIX_POINT (rl_mark);
 }
+
+void
+_rl_fix_mark (void)
+{
+  _RL_FIX_POINT (rl_mark);
+}
 #undef _RL_FIX_POINT
 
 /* Replace the contents of the line buffer between START and END with
@@ -479,6 +486,8 @@ rl_forward_word (int count, int key)
 
   while (count)
     {
+      if (rl_point > rl_end)
+       rl_point = rl_end;
       if (rl_point == rl_end)
        return 0;
 
@@ -498,6 +507,8 @@ rl_forward_word (int count, int key)
            }
        }
 
+      if (rl_point > rl_end)
+       rl_point = rl_end;
       if (rl_point == rl_end)
        return 0;
 
@@ -1483,7 +1494,9 @@ rl_change_case (int count, int op)
                }
              else if (m < mlen)
                {
-                 rl_extend_line_buffer (mlen - m + 1);
+                 rl_extend_line_buffer (rl_end + mlen + (e - s) - m + 2);
+                 s = rl_line_buffer + start;   /* have to redo this */
+                 e = rl_line_buffer + rl_end;
                  memmove (s + mlen, s + m, (e - s) - m);
                  memcpy (s, mb, mlen);
                  next += mlen - m;     /* next char changes */
index dd4c3e8c4848f36d0fbd7808da373cec0cdd88cd..035fb644ee17e27281f391f6155f363957b33dcc 100644 (file)
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -1,7 +1,7 @@
 /* vi_mode.c -- A vi emulation mode for Bash.
    Derived from code written by Jeff Sparkes (jsparkes@bnr.ca).  */
 
-/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
@@ -837,6 +837,12 @@ _rl_vi_save_replace (void)
   start = end - vi_replace_count + 1;
   len = vi_replace_count + 1;
 
+  if (start < 0)
+    {
+      len = end + 1;
+      start = 0;
+    }
+
   vi_save_insert_buffer (start, len);  
 }
 
@@ -1162,6 +1168,7 @@ rl_domove_motion_callback (_rl_vimotion_cxt *m)
   /* Append a blank character temporarily so that the motion routines
      work right at the end of the line.  Original value of rl_end is saved
      as m->end. */
+  rl_extend_line_buffer (rl_end + 1);
   rl_line_buffer[rl_end++] = ' ';
   rl_line_buffer[rl_end] = '\0';
 
@@ -1193,8 +1200,7 @@ _rl_vi_domove_motion_cleanup (int c, _rl_vimotion_cxt *m)
   /* Remove the blank that we added in rl_domove_motion_callback. */
   rl_end = m->end;
   rl_line_buffer[rl_end] = '\0';
-  if (rl_point > rl_end)
-    rl_point = rl_end;
+  _rl_fix_point (0);
 
   /* No change in position means the command failed. */
   if (rl_mark == rl_point)
@@ -1518,6 +1524,8 @@ vi_yank_dispatch (_rl_vimotion_cxt *m)
   rl_do_undo ();
   rl_point = m->start;
 
+  _rl_fix_point (1);
+
   return (0);
 }
 
@@ -2102,7 +2110,7 @@ rl_vi_overstrike_delete (int count, int key)
       s = rl_point;
 
       if (rl_do_undo ())
-       vi_replace_count--;
+       vi_replace_count--;             /* XXX */
 
       if (rl_point == s)
        rl_backward_char (1, key);
@@ -2117,6 +2125,39 @@ rl_vi_overstrike_delete (int count, int key)
   return (0);
 }
 
+static int
+rl_vi_overstrike_kill_line (int count, int key)
+{
+  int r, end;
+
+  end = rl_end;
+  r = rl_unix_line_discard (count, key);
+  vi_replace_count -= end - rl_end;
+  return r;
+}
+
+static int
+rl_vi_overstrike_kill_word (int count, int key)
+{
+  int r, end;
+
+  end = rl_end;
+  r = rl_vi_unix_word_rubout (count, key);
+  vi_replace_count -= end - rl_end;
+  return r;
+}
+
+static int
+rl_vi_overstrike_yank (int count, int key)
+{
+  int r, end;
+
+  end = rl_end;
+  r = rl_yank (count, key);
+  vi_replace_count += rl_end - end;
+  return r;
+}
+
 /* Read bracketed paste mode pasted text and insert it in overwrite mode */
 static int
 rl_vi_overstrike_bracketed_paste (int count, int key)
@@ -2177,6 +2218,21 @@ rl_vi_replace (int count, int key)
          vi_insertion_keymap[CTRL ('H')].function == rl_rubout)
        vi_replace_map[CTRL ('H')].function = rl_vi_overstrike_delete;
 
+      /* Same for ^U and unix-line-discard. */
+      if (vi_insertion_keymap[CTRL ('U')].type == ISFUNC &&
+         vi_insertion_keymap[CTRL ('U')].function == rl_unix_line_discard)
+       vi_replace_map[CTRL ('U')].function = rl_vi_overstrike_kill_line;
+
+      /* And for ^W and unix-word-rubout. */
+      if (vi_insertion_keymap[CTRL ('W')].type == ISFUNC &&
+         vi_insertion_keymap[CTRL ('W')].function == rl_vi_unix_word_rubout)
+       vi_replace_map[CTRL ('W')].function = rl_vi_overstrike_kill_word;
+
+      /* And finally for ^Y and yank. */
+      if (vi_insertion_keymap[CTRL ('Y')].type == ISFUNC &&
+         vi_insertion_keymap[CTRL ('Y')].function == rl_yank)
+       vi_replace_map[CTRL ('Y')].function = rl_vi_overstrike_yank;
+
       /* Make sure this is the value we need. */
       vi_replace_map[ANYOTHERKEY].type = ISFUNC;
       vi_replace_map[ANYOTHERKEY].function = (rl_command_func_t *)NULL;
@@ -2279,6 +2335,7 @@ _rl_vi_goto_mark (void)
   if (ch == '`')
     {
       rl_point = rl_mark;
+      _rl_fix_point (1);
       return 0;
     }
   else if (ch < 0 || ch < 'a' || ch > 'z')     /* make test against 0 explicit */
@@ -2294,6 +2351,7 @@ _rl_vi_goto_mark (void)
       return 1;
     }
   rl_point = vi_mark_chars[ch];
+  _rl_fix_point (1);
   return 0;
 }