]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20200508 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 8 May 2020 18:26:22 +0000 (14:26 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 8 May 2020 18:26:22 +0000 (14:26 -0400)
29 files changed:
bind.c
display.c
doc/history.3
doc/history.texi
doc/hsuser.texi
doc/readline.3
doc/rlman.texi
doc/rltech.texi
doc/rluser.texi
doc/rluserman.texi
doc/version.texi
emacs_keymap.c
funmap.c
histfile.c
input.c
isearch.c
kill.c
mbutil.c
misc.c
patchlevel
readline.c
readline.h
rlprivate.h
search.c
support/config.guess
support/config.sub
terminal.c
text.c
util.c

diff --git a/bind.c b/bind.c
index 9eb484d9899abfc5d2ad602c396d776699218c44..3cbed2cc420fca1f46e84ab999f1e29e1083e16d 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -262,6 +262,13 @@ rl_unbind_function_in_map (rl_command_func_t *func, Keymap map)
          map[i].function = (rl_command_func_t *)NULL;
          rval = 1;
        }
+      else if (map[i].type == ISKMAP)          /* TAG:readline-8.1 */
+       {
+         int r;
+         r = rl_unbind_function_in_map (func, FUNCTION_TO_KEYMAP (map, i));
+         if (r == 1)
+           rval = 1;
+       }
     }
   return rval;
 }
index 67ef84a9c8cc935e6da23eb92fc7c0c98742f401..491b7d417983f2b8bdc6ddcf3377faceb19e5610 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1,6 +1,6 @@
 /* display.c -- readline redisplay facility. */
 
-/* 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.
 extern char *strchr (), *strrchr ();
 #endif /* !strchr && !__STDC__ */
 
-static void update_line PARAMS((char *, char *, int, int, int, int));
+static void putc_face PARAMS((int, int, char *));
+static void puts_face PARAMS((const char *, const char *, int));
+static void norm_face PARAMS((char *, int));
+
+static void update_line PARAMS((char *, char *, char *, char *, int, int, int, int));
 static void space_to_eol PARAMS((int));
 static void delete_chars PARAMS((int));
 static void insert_some_chars PARAMS((char *, int, int));
 static void open_some_spaces PARAMS((int));
 static void cr PARAMS((void));
 static void redraw_prompt PARAMS((char *));
+static void _rl_move_cursor_relative PARAMS((int, const char *, const char *));
 
 /* Values for FLAGS */
 #define PMT_MULTILINE  0x01
@@ -82,6 +87,7 @@ static char *expand_prompt PARAMS((char *, int, int *, int *, int *, int *));
 struct line_state
   {
     char *line;
+    char *lface;
     int *lbreaks;
     int lbsize;
 #if defined (HANDLE_MULTIBYTE)
@@ -104,7 +110,9 @@ static int line_structures_initialized = 0;
 #define vis_lbsize     (line_state_visible->lbsize)
 
 #define visible_line   (line_state_visible->line)
+#define vis_face       (line_state_visible->lface)
 #define invisible_line (line_state_invisible->line)
+#define inv_face       (line_state_invisible->lface)
 
 #if defined (HANDLE_MULTIBYTE)
 static int _rl_col_width PARAMS((const char *, int, int, int));
@@ -125,6 +133,10 @@ static int _rl_col_width PARAMS((const char *, int, int, int));
    to use prompt_last_invisible directly. */
 #define PROMPT_ENDING_INDEX \
   ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
+
+#define FACE_NORMAL    '0'
+#define FACE_STANDOUT  '1'
+#define FACE_INVALID   ((char)1)
   
 /* **************************************************************** */
 /*                                                                 */
@@ -223,7 +235,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  = 0;
 
 /* Set to a non-zero value if horizontal scrolling has been enabled
    automatically because the terminal was resized to height 1. */
@@ -602,6 +614,42 @@ rl_expand_prompt (char *prompt)
     }
 }
 
+/* Allocate the various line structures, making sure they can hold MINSIZE
+   bytes. If the existing line size can accommodate MINSIZE bytes, don't do
+   anything. */
+static void
+realloc_line (int minsize)
+{
+  int minimum_size;
+  int newsize, delta;
+
+  minimum_size = DEFAULT_LINE_BUFFER_SIZE;
+  if (minsize < minimum_size)
+    minsize = minimum_size;
+  if (minsize <= _rl_screenwidth)      /* XXX - for gdb */
+    minsize = _rl_screenwidth + 1;
+  if (line_size >= minsize)
+    return;
+
+  newsize = minimum_size;
+  while (newsize < minsize)
+    newsize *= 2;
+
+  visible_line = (char *)xrealloc (visible_line, newsize);
+  vis_face = (char *)xrealloc (vis_face, newsize);
+
+  invisible_line = (char *)xrealloc (invisible_line, newsize);
+  inv_face = (char *)xrealloc (inv_face, newsize);
+
+  delta = newsize - line_size;  
+  memset (visible_line + line_size, 0, delta);
+  memset (vis_face + line_size, FACE_NORMAL, delta);
+  memset (invisible_line + line_size, 1, delta);
+  memset (inv_face + line_size, FACE_INVALID, delta);
+
+  line_size = newsize;
+}
+
 /* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
    arrays of line break markers.  MINSIZE is the minimum size of VISIBLE_LINE
    and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
@@ -610,34 +658,12 @@ rl_expand_prompt (char *prompt)
 static void
 init_line_structures (int minsize)
 {
-  register int n;
-  int osize;
-
-  osize = minsize;
-  if (minsize <= _rl_screenwidth)      /* XXX - for gdb */
-    minsize = _rl_screenwidth + 1;
-
   if (invisible_line == 0)     /* initialize it */
     {
-      if (line_size < minsize)
-       line_size = minsize;
-      visible_line = (char *)xmalloc (line_size);
-      invisible_line = (char *)xmalloc (line_size);
-    }
-  else if (line_size < minsize)        /* ensure it can hold MINSIZE chars */
-    {
-      line_size *= 2;
-      if (line_size < minsize)
-       line_size = minsize;
-      visible_line = (char *)xrealloc (visible_line, line_size);
-      invisible_line = (char *)xrealloc (invisible_line, line_size);
-    }
-
-  for (n = osize; n < line_size; n++)
-    {
-      visible_line[n] = 0;
-      invisible_line[n] = 1;
+      if (line_size > minsize)
+       minsize = line_size;
     }
+   realloc_line (minsize); 
 
   if (vis_lbreaks == 0)
     {
@@ -660,6 +686,43 @@ init_line_structures (int minsize)
   line_structures_initialized = 1;
 }
 
+/* Convenience functions to add chars to the invisible line that update the
+   face information at the same time. */
+static void            /* XXX - change this */
+invis_addc (int *outp, char c, char face)
+{
+  realloc_line (*outp + 1);
+  invisible_line[*outp] = c;
+  inv_face[*outp] = face;
+  *outp += 1;
+}
+
+static void
+invis_adds (int *outp, const char *str, int n, char face)
+{
+  int i;
+
+  for (i = 0; i < n; i++)
+    invis_addc (outp, str[i], face);
+}
+
+static void
+invis_nul (int *outp)
+{
+  invis_addc (outp, '\0', 0);
+  *outp -= 1;
+}
+
+static void
+set_active_region (int *beg, int *end)
+{
+  if (rl_point >= 0 && rl_point <= rl_end && rl_mark >= 0 && rl_mark <= rl_end)
+    {
+      *beg = (rl_mark < rl_point) ? rl_mark : rl_point;
+      *end = (rl_mark < rl_point) ? rl_point : rl_mark;
+    }
+}
+
 /* Do whatever tests are necessary and tell update_line that it can do a
    quick, dumb redisplay on the assumption that there are so many
    differences between the old and new lines that it would be a waste to
@@ -678,11 +741,12 @@ _rl_optimize_redisplay (void)
 void
 rl_redisplay (void)
 {
-  register int in, out, c, linenum, cursor_linenum;
-  register char *line;
+  int in, out, c, linenum, cursor_linenum;
   int inv_botlin, lb_botlin, lb_linenum, o_cpos;
   int newlines, lpos, temp, n0, num, prompt_lines_estimate;
   char *prompt_this_line;
+  char cur_face;
+  int hl_begin, hl_end;
   int mb_cur_max = MB_CUR_MAX;
 #if defined (HANDLE_MULTIBYTE)
   wchar_t wc;
@@ -700,6 +764,14 @@ rl_redisplay (void)
   _rl_block_sigint ();  
   RL_SETSTATE (RL_STATE_REDISPLAYING);
 
+  cur_face = FACE_NORMAL;
+  /* Can turn this into an array for multiple highlighted objects in addition
+     to the region */
+  hl_begin = hl_end = -1;
+
+  if (rl_mark_active_p ())
+    set_active_region (&hl_begin, &hl_end);
+
   if (!rl_display_prompt)
     rl_display_prompt = "";
 
@@ -728,7 +800,6 @@ rl_redisplay (void)
 
   prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;
 
-  line = invisible_line;
   out = inv_botlin = 0;
 
   /* Mark the line as modified or not.  We only do this for history
@@ -736,8 +807,8 @@ rl_redisplay (void)
   modmark = 0;
   if (_rl_mark_modified_lines && current_history () && rl_undo_list)
     {
-      line[out++] = '*';
-      line[out] = '\0';
+      invis_addc (&out, '*', cur_face);
+      invis_nul (&out);
       modmark = 1;
     }
 
@@ -761,18 +832,8 @@ rl_redisplay (void)
        _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
 
       if (local_prompt_len > 0)
-       {
-         temp = local_prompt_len + out + 2;
-         if (temp >= line_size)
-           {
-             line_size = (temp + 1024) - (temp % 1024);
-             visible_line = (char *)xrealloc (visible_line, line_size);
-             line = invisible_line = (char *)xrealloc (invisible_line, line_size);
-           }
-         strncpy (line + out, local_prompt, local_prompt_len);
-         out += local_prompt_len;
-       }
-      line[out] = '\0';
+       invis_adds (&out, local_prompt, local_prompt_len, cur_face);
+      invis_nul (&out);
       wrap_offset = local_prompt_len - prompt_visible_length;
     }
   else
@@ -796,16 +857,8 @@ rl_redisplay (void)
        }
 
       prompt_physical_chars = pmtlen = strlen (prompt_this_line);      /* XXX */
-      temp = pmtlen + out + 2;
-      if (temp >= line_size)
-       {
-         line_size = (temp + 1024) - (temp % 1024);
-         visible_line = (char *)xrealloc (visible_line, line_size);
-         line = invisible_line = (char *)xrealloc (invisible_line, line_size);
-       }
-      strncpy (line + out,  prompt_this_line, pmtlen);
-      out += pmtlen;
-      line[out] = '\0';
+      invis_adds (&out, prompt_this_line, pmtlen, cur_face);
+      invis_nul (&out);
       wrap_offset = prompt_invis_chars_first_line = 0;
     }
 
@@ -943,6 +996,11 @@ rl_redisplay (void)
   for (in = 0; in < rl_end; in++)
 #endif
     {
+      if (in == hl_begin)
+       cur_face = FACE_STANDOUT;
+      else if (in == hl_end)
+       cur_face = FACE_NORMAL;
+
       c = (unsigned char)rl_line_buffer[in];
 
 #if defined (HANDLE_MULTIBYTE)
@@ -967,14 +1025,6 @@ rl_redisplay (void)
        }
 #endif
 
-      if (out + 8 >= line_size)                /* XXX - 8 for \t */
-       {
-         line_size *= 2;
-         visible_line = (char *)xrealloc (visible_line, line_size);
-         invisible_line = (char *)xrealloc (invisible_line, line_size);
-         line = invisible_line;
-       }
-
       if (in == rl_point)
        {
          cpos_buffer_position = out;
@@ -989,9 +1039,12 @@ rl_redisplay (void)
        {
          if (_rl_output_meta_chars == 0)
            {
-             sprintf (line + out, "\\%o", c);
+             char obuf[5];
+             int olen;
 
-             if (lpos + 4 >= _rl_screenwidth)
+             olen = sprintf (obuf, "\\%o", c);
+         
+             if (lpos + olen >= _rl_screenwidth)
                {
                  temp = _rl_screenwidth - lpos;
                  CHECK_INV_LBREAKS ();
@@ -999,16 +1052,20 @@ rl_redisplay (void)
 #if defined (HANDLE_MULTIBYTE)
                  line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;
 #endif
-                 lpos = 4 - temp;
+                 lpos = olen - temp;
                }
              else
-               lpos += 4;
+               lpos += olen;
 
-             out += 4;
+             for (temp = 0; temp < olen; temp++)
+               {
+                 invis_addc (&out, obuf[temp], cur_face);
+                 CHECK_LPOS ();
+               }
            }
          else
            {
-             line[out++] = c;
+             invis_addc (&out, c, cur_face);
              CHECK_LPOS();
            }
        }
@@ -1030,19 +1087,19 @@ rl_redisplay (void)
 #endif
              lpos = temp - temp2;
              while (out < newout)
-               line[out++] = ' ';
+               invis_addc (&out, ' ', cur_face);
            }
          else
            {
              while (out < newout)
-               line[out++] = ' ';
+               invis_addc (&out, ' ', cur_face);
              lpos += temp;
            }
        }
 #endif
       else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
        {
-         line[out++] = '\0';   /* XXX - sentinel */
+         invis_addc (&out, '\0', cur_face);
          CHECK_INV_LBREAKS ();
          inv_lbreaks[++newlines] = out;
 #if defined (HANDLE_MULTIBYTE)
@@ -1052,9 +1109,9 @@ rl_redisplay (void)
        }
       else if (CTRL_CHAR (c) || c == RUBOUT)
        {
-         line[out++] = '^';
+         invis_addc (&out, '^', cur_face);
          CHECK_LPOS();
-         line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
+         invis_addc (&out, CTRL_CHAR (c) ? UNCTRL (c) : '?', cur_face);
          CHECK_LPOS();
        }
       else
@@ -1070,7 +1127,7 @@ rl_redisplay (void)
                for (i = lpos; i < _rl_screenwidth; i++)
                  {
                    /* The space will be removed in update_line() */
-                   line[out++] = ' ';
+                   invis_addc (&out, ' ', cur_face);
                    _rl_wrapped_multicolumn++;
                    CHECK_LPOS();
                  }
@@ -1080,17 +1137,17 @@ rl_redisplay (void)
                  lb_linenum = newlines;
                }
              for (i = in; i < in+wc_bytes; i++)
-               line[out++] = rl_line_buffer[i];
+               invis_addc (&out, rl_line_buffer[i], cur_face);
              for (i = 0; i < wc_width; i++)
                CHECK_LPOS();
            }
          else
            {
-             line[out++] = c;
+             invis_addc (&out, c, cur_face);
              CHECK_LPOS();
            }
 #else
-         line[out++] = c;
+         invis_addc (&out, c, cur_face);
          CHECK_LPOS();
 #endif
        }
@@ -1112,7 +1169,7 @@ rl_redisplay (void)
         in++;
 #endif
     }
-  line[out] = '\0';
+  invis_nul (&out);
   line_totbytes = out;
   if (cpos_buffer_position < 0)
     {
@@ -1161,7 +1218,7 @@ rl_redisplay (void)
            {
 #if defined (HANDLE_MULTIBYTE)
              if (mb_cur_max > 1 && rl_byte_oriented == 0)
-               out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
+               out = _rl_find_prev_mbchar (invisible_line, _rl_screenchars, MB_FIND_ANY);
              else
 #endif
                out = _rl_screenchars - 1;
@@ -1179,14 +1236,32 @@ rl_redisplay (void)
 #define VIS_LLEN(l)    ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
 #define INV_LLEN(l)    (inv_lbreaks[l+1] - inv_lbreaks[l])
 #define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
+#define VIS_FACE(line) (vis_face + vis_lbreaks[line])
 #define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+#define VIS_LINE_FACE(line) ((line) > _rl_vis_botlin) ? "" : VIS_FACE(line)
 #define INV_LINE(line) (invisible_line + inv_lbreaks[line])
+#define INV_LINE_FACE(line) (inv_face + inv_lbreaks[line])
 
 #define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
                        _rl_last_c_pos != o_cpos && \
                        _rl_last_c_pos > wrap_offset && \
                        o_cpos < prompt_last_invisible)
 
+
+         /* We don't want to highlight anything that's going to be off the top
+            of the display; if the current line takes up more than an entire
+           screen, just mark the lines that won't be displayed as having a
+           `normal' face.
+           It's imperfect, but better than display corruption. */
+         if (rl_mark_active_p () && inv_botlin > _rl_screenheight)
+           {
+             int extra;
+
+             extra = inv_botlin - _rl_screenheight;
+             for (linenum = 0; linenum <= extra; linenum++)
+               norm_face (INV_LINE_FACE(linenum), INV_LLEN (linenum));
+           }
+
          /* For each line in the buffer, do the updating display. */
          for (linenum = 0; linenum <= inv_botlin; linenum++)
            {
@@ -1194,7 +1269,9 @@ rl_redisplay (void)
                 the locale from a non-multibyte to a multibyte one. */
              o_cpos = _rl_last_c_pos;
              cpos_adjusted = 0;
-             update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,
+             update_line (VIS_LINE(linenum), VIS_LINE_FACE(linenum),
+                          INV_LINE(linenum), INV_LINE_FACE(linenum),
+                          linenum,
                           VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin);
 
              /* update_line potentially changes _rl_last_c_pos, but doesn't
@@ -1285,7 +1362,7 @@ rl_redisplay (void)
                {
                  tt = VIS_CHARS (linenum);
                  _rl_move_vert (linenum);
-                 _rl_move_cursor_relative (0, tt);
+                 _rl_move_cursor_relative (0, tt, VIS_FACE(linenum));
                  _rl_clear_to_eol
                    ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
                }
@@ -1317,18 +1394,9 @@ rl_redisplay (void)
          /* XXX - why not use local_prompt_len? */
          nleft = prompt_visible_length + wrap_offset;
          if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
-#if 0
-             _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)
-#else
              _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt)
-#endif
            {
-#if defined (__MSDOS__)
-             putc ('\r', rl_outstream);
-#else
-             if (_rl_term_cr)
-               tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
+             _rl_cr ();
              if (modmark)
                _rl_output_some_chars ("*", 1);
 
@@ -1374,9 +1442,9 @@ rl_redisplay (void)
             point specified by a buffer position (NLEFT) that doesn't take
             invisible characters into account. */
          if (mb_cur_max > 1 && rl_byte_oriented == 0)
-           _rl_move_cursor_relative (nleft, &invisible_line[pos]);
+           _rl_move_cursor_relative (nleft, &invisible_line[pos], &inv_face[pos]);
          else if (nleft != _rl_last_c_pos)
-           _rl_move_cursor_relative (nleft, &invisible_line[pos]);
+           _rl_move_cursor_relative (nleft, &invisible_line[pos], &inv_face[pos]);
        }
     }
   else                         /* Do horizontal scrolling. Much simpler */
@@ -1432,7 +1500,7 @@ rl_redisplay (void)
       /* If the first character on the screen isn't the first character
         in the display line, indicate this with a special character. */
       if (lmargin > 0)
-       line[lmargin] = '<';
+       invisible_line[lmargin] = '<';
 
       /* If SCREENWIDTH characters starting at LMARGIN do not encompass
         the whole line, indicate that with a special character at the
@@ -1440,15 +1508,15 @@ rl_redisplay (void)
         wrap offset into account. */
       t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
       if (t > 0 && t < out)
-       line[t - 1] = '>';
+       invisible_line[t - 1] = '>';
 
       if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
        {
          forced_display = 0;
          o_cpos = _rl_last_c_pos;
          cpos_adjusted = 0;
-         update_line (&visible_line[last_lmargin],
-                      &invisible_line[lmargin],
+         update_line (&visible_line[last_lmargin], &vis_face[last_lmargin],
+                      &invisible_line[lmargin], &inv_face[lmargin],
                       0,
                       _rl_screenwidth + visible_wrap_offset,
                       _rl_screenwidth + (lmargin ? 0 : wrap_offset),
@@ -1473,7 +1541,7 @@ rl_redisplay (void)
          if (visible_first_line_len > _rl_screenwidth)
            visible_first_line_len = _rl_screenwidth;
 
-         _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]);
+         _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin], &inv_face[lmargin]);
          last_lmargin = lmargin;
        }
     }
@@ -1502,18 +1570,56 @@ rl_redisplay (void)
   _rl_release_sigint ();
 }
 
+static void
+putc_face (int c, int face, char *cur_face)
+{
+  char cf;
+  cf = *cur_face;
+  if (cf != face)
+    {
+      if (cf != FACE_NORMAL && cf != FACE_STANDOUT)
+       return;
+      if (face != FACE_NORMAL && face != FACE_STANDOUT)
+       return;
+      if (face == FACE_STANDOUT && cf == FACE_NORMAL)
+        _rl_standout_on ();
+      if (face == FACE_NORMAL && cf == FACE_STANDOUT)
+        _rl_standout_off ();
+      *cur_face = face;
+    }
+  if (c != EOF)
+    putc (c, rl_outstream);
+}
+
+static void
+puts_face (const char *str, const char *face, int n)
+{
+  int i;
+  char cur_face;
+
+  for (cur_face = FACE_NORMAL, i = 0; i < n; i++)
+    putc_face (str[i], face[i], &cur_face);
+  putc_face (EOF, FACE_NORMAL, &cur_face);
+}
+
+static void
+norm_face (char *face, int n)
+{
+  memset (face, FACE_NORMAL, n);
+}
+
 #define ADJUST_CPOS(x) do { _rl_last_c_pos -= (x) ; cpos_adjusted = 1; } while (0)
 
 /* PWP: update_line() is based on finding the middle difference of each
    line on the screen; vis:
 
                             /old first difference
-       /beginning of line   |        /old last same       /old EOL
-       v                    v        v             v
+       /beginning of line   |              /old last same       /old EOL
+       v                    v              v                    v
 old:   eddie> Oh, my little gruntle-buggy is to me, as lurgid as
 new:   eddie> Oh, my little buggy says to me, as lurgid as
-       ^                    ^  ^                          ^
-       \beginning of line   |  \new last same     \new end of line
+       ^                    ^        ^                    ^
+       \beginning of line   |        \new last same       \new end of line
                             \new first difference
 
    All are character pointers for the sake of speed.  Special cases for
@@ -1521,9 +1627,10 @@ new:     eddie> Oh, my little buggy says to me, as lurgid as
 
    Could be made even smarter, but this works well enough */
 static void
-update_line (char *old, char *new, int current_line, int omax, int nmax, int inv_botlin)
+update_line (char *old, char *old_face, char *new, char *new_face, int current_line, int omax, int nmax, int inv_botlin)
 {
-  register char *ofd, *ols, *oe, *nfd, *nls, *ne;
+  char *ofd, *ols, *oe, *nfd, *nls, *ne;
+  char *ofdf, *nfdf, *olsf, *nlsf;
   int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
   int current_invis_chars;
   int col_lendiff, col_temp;
@@ -1658,7 +1765,7 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
              int count, i, j;
              char *optr;
 
-             _rl_output_some_chars (new, newbytes);
+             puts_face (new, new_face, newbytes);
              _rl_last_c_pos = newwidth;
              _rl_last_v_pos++;
 
@@ -1673,6 +1780,9 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
                  ne = new + nmax;
                  nd = newbytes;
                  nfd = new + nd;
+                 ofdf = old_face + oldbytes;
+                 nfdf = new_face + newbytes;
+
                  goto dumb_update;
                }
              if (oldbytes != 0 && newbytes != 0)
@@ -1686,8 +1796,12 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
                  /* 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);
+                   {
+                     memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);
+                     memmove (old_face+newbytes, old_face+oldbytes, strlen (old+oldbytes) + 1);
+                   }
                  memcpy (old, new, newbytes);
+                 memcpy (old_face, new_face, newbytes);
                  j = newbytes - oldbytes;
                  omax += j;
                  /* Fix up indices if we copy data from one line to another */
@@ -1701,20 +1815,26 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
              _rl_last_c_pos = 1;
              _rl_last_v_pos++;
              if (old[0] && new[0])
-               old[0] = new[0];
+               {
+                 old[0] = new[0];
+                 old_face[0] = new_face[0];
+               }
            }
        }
       else
 #endif
        {
          if (new[0])
-           putc (new[0], rl_outstream);
+           puts_face (new, new_face, 1);
          else
            putc (' ', rl_outstream);
          _rl_last_c_pos = 1;
          _rl_last_v_pos++;
          if (old[0] && new[0])
-           old[0] = new[0];
+           {
+             old[0] = new[0];
+             old_face[0] = new_face[0];
+           }
        }
     }
 
@@ -1722,11 +1842,13 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
   if (_rl_quick_redisplay)
     {
       nfd = new;
+      nfdf = new_face;
       ofd = old;
+      ofdf = old_face;
       for (od = 0, oe = ofd; od < omax && *oe; oe++, od++);
       for (nd = 0, ne = nfd; nd < nmax && *ne; ne++, nd++);
       od = nd = 0;
-      _rl_move_cursor_relative (0, old);
+      _rl_move_cursor_relative (0, old, old_face);
 
       bytes_to_insert = ne - nfd;
       if (bytes_to_insert < local_prompt_len)  /* ??? */
@@ -1742,7 +1864,7 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
       bytes_to_insert -= local_prompt_len;
       if (bytes_to_insert > 0)
        {
-         _rl_output_some_chars (new+local_prompt_len, bytes_to_insert);
+         puts_face (new+local_prompt_len, nfdf+local_prompt_len, bytes_to_insert);
          if (mb_cur_max > 1 && rl_byte_oriented)
            _rl_last_c_pos += _rl_col_width (new, local_prompt_len, ne-new, 1);
          else
@@ -1765,11 +1887,13 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
       /* See if the old line is a subset of the new line, so that the
         only change is adding characters. */
       temp = (omax < nmax) ? omax : nmax;
-      if (memcmp (old, new, temp) == 0)                /* adding at the end */
+      if (memcmp (old, new, temp) == 0 && memcmp (old_face, new_face, temp) == 0)
        {
-         new_offset = old_offset = temp;
+         new_offset = old_offset = temp;       /* adding at the end */
          ofd = old + temp;
+         ofdf = old_face + temp;
          nfd = new + temp;
+         nfdf = new_face + temp;
        }
       else
        {      
@@ -1777,36 +1901,42 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
          memset (&ps_old, 0, sizeof(mbstate_t));
 
          /* Are the old and new lines the same? */
-         if (omax == nmax && memcmp (new, old, omax) == 0)
+         if (omax == nmax && memcmp (new, old, omax) == 0 && memcmp (new_face, old_face, omax) == 0)
            {
              old_offset = omax;
              new_offset = nmax;
              ofd = old + omax;
+             ofdf = old_face + omax;
              nfd = new + nmax;
+             nfdf = new_face + nmax;
            }
          else
            {
              /* Go through the line from the beginning and find the first
-                difference. */
+                difference. We assume that faces change at (possibly multi-
+                byte) character boundaries. */
              new_offset = old_offset = 0;
-             for (ofd = old, nfd = new;
+             for (ofd = old, ofdf = old_face, nfd = new, nfdf = new_face;
                    (ofd - old < omax) && *ofd &&
-                   _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); )
+                   _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new) &&
+                   *ofdf == *nfdf; )
                {
                  old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY);
                  new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY);
 
                  ofd = old + old_offset;
+                 ofdf = old_face + old_offset;
                  nfd = new + new_offset;
+                 nfdf = new_face + new_offset;
                }
            }
        }
     }
   else
 #endif
-  for (ofd = old, nfd = new;
-       (ofd - old < omax) && *ofd && (*ofd == *nfd);
-       ofd++, nfd++)
+  for (ofd = old, ofdf = old_face, nfd = new, nfdf = new_face;
+       (ofd - old < omax) && *ofd && (*ofd == *nfd) && (*ofdf == *nfdf);
+       ofd++, nfd++, ofdf++, nfdf++)
     ;
 
   /* Move to the end of the screen line.  ND and OD are used to keep track
@@ -1835,7 +1965,9 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
          old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY);
          new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY);
          ofd = old + old_offset;       /* equal by definition */
+         ofdf = old_face + old_offset;
          nfd = new + new_offset;
+         nfdf = new_face + new_offset;
        }
     }
 #endif
@@ -1848,34 +1980,41 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
   if (mb_cur_max > 1 && rl_byte_oriented == 0)
     {
       ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY);
+      olsf = old_face + (ols - old);
       nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY);
+      nlsf = new_face + (nls - new);
 
       while ((ols > ofd) && (nls > nfd))
        {
          memset (&ps_old, 0, sizeof (mbstate_t));
          memset (&ps_new, 0, sizeof (mbstate_t));
 
-         if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0)
+         if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0 ||
+               *olsf != *nlsf)
            break;
 
          if (*ols == ' ')
            wsatend = 0;
 
          ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY);
+         olsf = old_face + (ols - old);
          nls = new + _rl_find_prev_mbchar (new, nls - new, MB_FIND_ANY);
+         nlsf = new_face + (nls - new);
        }
     }
   else
     {
 #endif /* HANDLE_MULTIBYTE */
   ols = oe - 1;                        /* find last same */
+  olsf = old_face + (ols - old);
   nls = ne - 1;
-  while ((ols > ofd) && (nls > nfd) && (*ols == *nls))
+  nlsf = new_face + (nls - new);
+  while ((ols > ofd) && (nls > nfd) && (*ols == *nls) && (*olsf == *nlsf))
     {
       if (*ols != ' ')
        wsatend = 0;
-      ols--;
-      nls--;
+      ols--; olsf--;
+      nls--; nlsf--;
     }
 #if defined (HANDLE_MULTIBYTE)
     }
@@ -1884,15 +2023,17 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
   if (wsatend)
     {
       ols = oe;
+      olsf = old_face + (ols - old);
       nls = ne;
+      nlsf = new_face + (nls - new);
     }
 #if defined (HANDLE_MULTIBYTE)
   /* This may not work for stateful encoding, but who cares?  To handle
      stateful encoding properly, we have to scan each string from the
      beginning and compare. */
-  else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0)
+  else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0 || *olsf != *nlsf)
 #else
-  else if (*ols != *nls)
+  else if (*ols != *nls || *olsf != *nlsf)
 #endif
     {
       if (*ols)                        /* don't step past the NUL */
@@ -1909,6 +2050,8 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
          else
            nls++;
        }
+      olsf = old_face + (ols - old);
+      nlsf = new_face + (nls - new);
     }
 
   /* count of invisible characters in the current invisible line. */
@@ -1962,11 +2105,7 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
       (((od > 0 || nd > 0) && (od <= prompt_last_invisible || nd <= prompt_last_invisible)) ||
                ((od >= lendiff) && _rl_last_c_pos < PROMPT_ENDING_INDEX)))
     {
-#if defined (__MSDOS__)
-      putc ('\r', rl_outstream);
-#else
-      tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
+      _rl_cr ();
       if (modmark)
        _rl_output_some_chars ("*", 1);
       _rl_output_some_chars (local_prompt, lendiff);
@@ -2005,6 +2144,7 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
       if ((od <= prompt_last_invisible || nd <= prompt_last_invisible))
        {
          nfd = new + lendiff;  /* number of characters we output above */
+         nfdf = new_face + lendiff;
          nd = lendiff;
 
          /* Do a dumb update and return */
@@ -2012,7 +2152,7 @@ dumb_update:
          temp = ne - nfd;
          if (temp > 0)
            {
-             _rl_output_some_chars (nfd, temp);
+             puts_face (nfd, nfdf, temp);
              if (mb_cur_max > 1 && rl_byte_oriented == 0)
                {
                  _rl_last_c_pos += _rl_col_width (new, nd, ne - new, 1);
@@ -2063,7 +2203,7 @@ dumb_update:
   /* When this function returns, _rl_last_c_pos is correct, and an absolute
      cursor position in multibyte mode, but a buffer index when not in a
      multibyte locale. */
-  _rl_move_cursor_relative (od, old);
+  _rl_move_cursor_relative (od, old, old_face);
 
 #if defined (HANDLE_MULTIBYTE)
   /* We need to indicate that the cursor position is correct in the presence of
@@ -2122,6 +2262,9 @@ dumb_update:
                                                    : _rl_col_width (new, 0, nls - new, 1);
          /* if we changed nls and ols, we need to recompute lendiff */
          lendiff = (nls - nfd) - (ols - ofd);
+
+         nlsf = new_face + (nls - new);
+         olsf = old_face + (ols - old);
        }
       else
        newwidth = _rl_col_width (new, nfd - new, nls - new, 1);
@@ -2189,7 +2332,7 @@ dumb_update:
         only happen in a multibyte environment. */
       if (lendiff < 0)
        {
-         _rl_output_some_chars (nfd, temp);
+         puts_face (nfd, nfdf, temp);
          _rl_last_c_pos += col_temp;
          /* If nfd begins before any invisible characters in the prompt,
             adjust _rl_last_c_pos to account for wrap_offset and set
@@ -2223,7 +2366,7 @@ dumb_update:
                      (visible_wrap_offset >= current_invis_chars))
            {
              open_some_spaces (col_lendiff);
-             _rl_output_some_chars (nfd, bytes_to_insert);
+             puts_face (nfd, nfdf, bytes_to_insert);
              if (mb_cur_max > 1 && rl_byte_oriented == 0)
                _rl_last_c_pos += _rl_col_width (nfd, 0, bytes_to_insert, 1);
              else
@@ -2233,13 +2376,13 @@ dumb_update:
            {
              /* At the end of a line the characters do not have to
                 be "inserted".  They can just be placed on the screen. */
-             _rl_output_some_chars (nfd, temp);
+             puts_face (nfd, nfdf, temp);
              _rl_last_c_pos += col_temp;
              return;
            }
          else  /* just write from first difference to end of new line */
            {
-             _rl_output_some_chars (nfd, temp);
+             puts_face (nfd, nfdf, temp);
              _rl_last_c_pos += col_temp;
              /* If nfd begins before the last invisible character in the
                 prompt, adjust _rl_last_c_pos to account for wrap_offset
@@ -2261,7 +2404,7 @@ dumb_update:
       else
        {
          /* cannot insert chars, write to EOL */
-         _rl_output_some_chars (nfd, temp);
+         puts_face (nfd, nfdf, temp);
          _rl_last_c_pos += col_temp;
          /* If we're in a multibyte locale and were before the last invisible
             char in the current line (which implies we just output some invisible
@@ -2315,7 +2458,7 @@ dumb_update:
                 characters in the prompt, we need to adjust _rl_last_c_pos
                 in a multibyte locale to account for the wrap offset and
                 set cpos_adjusted accordingly. */
-             _rl_output_some_chars (nfd, bytes_to_insert);
+             puts_face (nfd, nfdf, bytes_to_insert);
              if (mb_cur_max > 1 && rl_byte_oriented == 0)
                {
                  /* This still doesn't take into account whether or not the
@@ -2349,7 +2492,7 @@ dumb_update:
                 so we move there with _rl_move_cursor_relative */
              if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
                {
-                 _rl_move_cursor_relative (ne-new, new);
+                 _rl_move_cursor_relative (ne-new, new, new_face);
                  goto clear_rest_of_line;
                }
            }
@@ -2363,7 +2506,7 @@ dumb_update:
                 characters in the prompt, we need to adjust _rl_last_c_pos
                 in a multibyte locale to account for the wrap offset and
                 set cpos_adjusted accordingly. */
-             _rl_output_some_chars (nfd, temp);
+             puts_face (nfd, nfdf, temp);
              _rl_last_c_pos += col_temp;               /* XXX */
              if (mb_cur_max > 1 && rl_byte_oriented == 0)
                {
@@ -2420,11 +2563,7 @@ rl_clear_visible_line (void)
   int curr_line;
 
   /* Make sure we move to column 0 so we clear the entire line */
-#if defined (__MSDOS__)
-  putc ('\r', rl_outstream);
-#else
-  tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
+  _rl_cr ();
   _rl_last_c_pos = 0;
 
   /* Move to the last screen line of the current visible line */
@@ -2537,8 +2676,8 @@ rl_redraw_prompt_last_line (void)
    DATA is the contents of the screen line of interest; i.e., where
    the movement is being done.
    DATA is always the visible line or the invisible line */
-void
-_rl_move_cursor_relative (int new, const char *data)
+static void
+_rl_move_cursor_relative (int new, const char *data, const char *dataf)
 {
   register int i;
   int woff;                    /* number of invisible chars on current line */
@@ -2635,11 +2774,7 @@ _rl_move_cursor_relative (int new, const char *data)
   if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) ||
       (_rl_term_autowrap && i == _rl_screenwidth))
     {
-#if defined (__MSDOS__)
-      putc ('\r', rl_outstream);
-#else
-      tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif /* !__MSDOS__ */
+      _rl_cr ();
       cpos = _rl_last_c_pos = 0;
     }
 
@@ -2671,14 +2806,12 @@ _rl_move_cursor_relative (int new, const char *data)
            }
          else
            {
-             tputs (_rl_term_cr, 1, _rl_output_character_function);
-             for (i = 0; i < new; i++)
-               putc (data[i], rl_outstream);
+             _rl_cr ();
+             puts_face (data, dataf, new);
            }
        }
       else
-       for (i = cpos; i < new; i++)
-         putc (data[i], rl_outstream);
+       puts_face (data + cpos, dataf + cpos, new - cpos);
     }
 
 #if defined (HANDLE_MULTIBYTE)
@@ -2706,11 +2839,7 @@ _rl_move_vert (int to)
     {
       for (i = 0; i < delta; i++)
        putc ('\n', rl_outstream);
-#if defined (__MSDOS__)
-      putc ('\r', rl_outstream);
-#else
-      tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
+      _rl_cr ();
       _rl_last_c_pos = 0;
     }
   else
@@ -3051,14 +3180,18 @@ space_to_eol (int count)
 }
 
 void
-_rl_clear_screen (void)
+_rl_clear_screen (int clrscr)
 {
 #if defined (__DJGPP__)
   ScreenClear ();
   ScreenSetCursor (0, 0);
 #else
   if (_rl_term_clrpag)
-    tputs (_rl_term_clrpag, 1, _rl_output_character_function);
+    {
+      tputs (_rl_term_clrpag, 1, _rl_output_character_function);
+      if (clrscr && _rl_term_clrscroll)
+       tputs (_rl_term_clrscroll, 1, _rl_output_character_function);
+    }
   else
     rl_crlf ();
 #endif /* __DJGPP__ */
@@ -3153,7 +3286,7 @@ _rl_update_final (void)
   /* If we've wrapped lines, remove the final xterm line-wrap flag. */
   if (full_lines && _rl_term_autowrap && botline_length == _rl_screenwidth)
     {
-      char *last_line;
+      char *last_line, *last_face;
 
       /* LAST_LINE includes invisible characters, so if you want to get the
         last character of the first line, you have to take WOFF into account.
@@ -3161,10 +3294,12 @@ _rl_update_final (void)
         which takes a buffer position as the first argument, and any direct
         subscripts of LAST_LINE. */
       last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; /* = VIS_CHARS(_rl_vis_botlin); */
+      last_face = &vis_face[vis_lbreaks[_rl_vis_botlin]]; /* = VIS_CHARS(_rl_vis_botlin); */
       cpos_buffer_position = -1;       /* don't know where we are in buffer */
-      _rl_move_cursor_relative (_rl_screenwidth - 1 + woff, last_line);        /* XXX */
+      _rl_move_cursor_relative (_rl_screenwidth - 1 + woff, last_line, last_face);     /* XXX */
       _rl_clear_to_eol (0);
-      putc (last_line[_rl_screenwidth - 1 + woff], rl_outstream);
+      puts_face (&last_line[_rl_screenwidth - 1 + woff],
+                &last_face[_rl_screenwidth - 1 + woff], 1);
     }
   _rl_vis_botlin = 0;
   if (botline_length > 0 || _rl_last_c_pos > 0)
@@ -3177,15 +3312,8 @@ _rl_update_final (void)
 static void
 cr (void)
 {
-  if (_rl_term_cr)
-    {
-#if defined (__MSDOS__)
-      putc ('\r', rl_outstream);
-#else
-      tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
-      _rl_last_c_pos = 0;
-    }
+  _rl_cr ();
+  _rl_last_c_pos = 0;
 }
 
 /* Redraw the last line of a multi-line prompt that may possibly contain
@@ -3228,24 +3356,19 @@ _rl_redisplay_after_sigwinch (void)
     {
       _rl_move_vert (_rl_vis_botlin);
 
-#if defined (__MSDOS__)
-      putc ('\r', rl_outstream);
-#else
-      tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif
+      _rl_cr ();
       _rl_last_c_pos = 0;
-#if defined (__MSDOS__)
-      space_to_eol (_rl_screenwidth);
-      putc ('\r', rl_outstream);
-#else
+
+#if !defined (__MSDOS__)
       if (_rl_term_clreol)
        tputs (_rl_term_clreol, 1, _rl_output_character_function);
       else
+#endif
        {
          space_to_eol (_rl_screenwidth);
-         tputs (_rl_term_cr, 1, _rl_output_character_function);
+         _rl_cr ();
        }
-#endif
+
       if (_rl_last_v_pos > 0)
        _rl_move_vert (0);
     }
@@ -3310,6 +3433,14 @@ _rl_current_display_line (void)
   return ret;
 }
 
+void
+_rl_refresh_line (void)
+{
+  rl_clear_visible_line ();
+  rl_redraw_prompt_last_line ();
+  rl_keep_mark_active ();
+}
+
 #if defined (HANDLE_MULTIBYTE)
 /* Calculate the number of screen columns occupied by STR from START to END.
    In the case of multibyte characters with stateful encoding, we have to
index 346b6614cad1243ace1526921cc97dca4aaee698..35b45e636a9dd2122f585ddd284b7493cf76ac81 100644 (file)
@@ -40,8 +40,8 @@
 .SH NAME
 history \- GNU History Library
 .SH COPYRIGHT
-.if t The GNU History Library is Copyright \(co 1989-2017 by the Free Software Foundation, Inc.
-.if n The GNU History Library is Copyright (C) 1989-2017 by the Free Software Foundation, Inc.
+.if t The GNU History Library is Copyright \(co 1989-2020 by the Free Software Foundation, Inc.
+.if n The GNU History Library is Copyright (C) 1989-2020 by the Free Software Foundation, Inc.
 .SH DESCRIPTION
 Many programs read input from the user a line at a time.  The GNU
 History library is able to keep track of those lines, associate arbitrary
@@ -49,7 +49,6 @@ data with each line, and utilize information from previous lines in
 composing new ones. 
 .PP
 .SH "HISTORY EXPANSION"
-.PP
 The history library supports a history expansion feature that
 is identical to the history expansion in
 .BR bash.
@@ -80,7 +79,6 @@ history expansion character, which is \^\fB!\fP\^ by default.
 Only backslash (\^\fB\e\fP\^) and single quotes can quote
 the history expansion character.
 .SS Event Designators
-.PP
 An event designator is a reference to a command line entry in the
 history list.
 Unless the reference is absolute, events are relative to the current
@@ -134,7 +132,6 @@ Equivalent to
 The entire command line typed so far.
 .PD
 .SS Word Designators
-.PP
 Word designators are used to select desired words from the event.
 A
 .B :
@@ -191,7 +188,6 @@ If \fBx\fP is missing, it defaults to 0.
 If a word designator is supplied without an event specification, the
 previous command is used as the event.
 .SS Modifiers
-.PP
 After the optional word designator, there may appear a sequence of
 one or more of the following modifiers, each preceded by a `:'.
 These modify, or edit, the word or words selected from the history event.
@@ -280,7 +276,6 @@ in the event line.
 .SH "PROGRAMMING WITH HISTORY FUNCTIONS"
 This section describes how to use the History library in other programs.
 .SS Introduction to History
-.PP
 The programmer using the History library has available functions
 for remembering lines on a history list, associating arbitrary data
 with a line, removing lines from the list, searching through the list
@@ -308,9 +303,7 @@ in any file that uses the
 History library's features.  It supplies extern declarations for all
 of the library's public functions and variables, and declares all of
 the public data structures.
-
 .SS History Storage
-.PP
 The history list is an array of history entries.  A history entry is
 declared as follows:
 .PP
@@ -346,7 +339,6 @@ typedef struct _hist_state {
 If the flags member includes \fBHS_STIFLED\fP, the history has been
 stifled.
 .SH "History Functions"
-.PP
 This section describes the calling sequence for the various functions
 exported by the GNU History library.
 .SS Initializing History and State Management
@@ -365,7 +357,6 @@ Return a structure describing the current state of the input history.
 Set the state of the history list according to \fIstate\fP.
 
 .SS History List Management
-
 These functions manage individual entries on the history list, or set
 parameters managing the list itself.
 
@@ -599,7 +590,7 @@ The number of entries currently stored in the history list.
 The maximum number of history entries.  This must be changed using
 \fBstifle_history()\fP.
 
-.Vb int history_wite_timestamps
+.Vb int history_write_timestamps
 If non-zero, timestamps are written to the history file, so they can be
 preserved between sessions.  The default value is 0, meaning that
 timestamps are not saved.
index 98e22332770c17f3bf8c3598fbe8165869f293ed..7a3a4767e7a591ded5f14e0b4879cd4a28358e37 100644 (file)
@@ -12,7 +12,7 @@ This document describes the GNU History library
 a programming tool that provides a consistent user interface for
 recalling lines of previously typed input.
 
-Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 998eb652db981e0083a66ec65c9d31877d7e916c..b8fedf331f10a9577cf195a95c69ce7c6b089fbb 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988--2018 Free Software Foundation, Inc.
+Copyright (C) 1988--2020 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
@@ -149,7 +149,14 @@ 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
+current command number).
+
+When listing, a @var{first} or @var{last} of 0 is equivalent to -1
+and -0 is equivalent to the current command (usually the @code{fc}
+command);
+otherwise 0 is equivalent to -1 and -0 is invalid.
+
+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
index beea0e34d884aa38ae959543935d502591758985..d7ddf6d3a39aeb187193c95e9b96e399c7dc9e77 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Mon Nov 25 10:53:27 EST 2019
+.\"    Last Change: Tue Mar 24 09:27:30 EDT 2020
 .\"
-.TH READLINE 3 "2019 November 25" "GNU Readline 8.0"
+.TH READLINE 3 "2020 March 24" "GNU Readline 8.0"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -34,8 +34,8 @@ readline \- get a line from a user with editing
 \fBreadline\fP (\fIconst char *prompt\fP);
 .fi
 .SH COPYRIGHT
-.if n Readline is Copyright (C) 1989\-2014 Free Software Foundation,  Inc.
-.if t Readline is Copyright \(co 1989\-2014 Free Software Foundation, Inc.
+.if n Readline is Copyright (C) 1989\-2020 Free Software Foundation,  Inc.
+.if t Readline is Copyright \(co 1989\-2020 Free Software Foundation, Inc.
 .SH DESCRIPTION
 .LP
 .B readline
@@ -163,7 +163,6 @@ In addition to command names, readline allows keys to be bound
 to a string that is inserted when the key is pressed (a \fImacro\fP).
 .PP
 .SS Key Bindings
-.PP
 The syntax for controlling key bindings in the
 .I inputrc
 file is simple.  All that is required is the name of the
@@ -318,7 +317,6 @@ similar mechanisms.  The
 file may be edited and re-read if a program does not provide
 any other means to incorporate new bindings.
 .SS Variables
-.PP
 Readline has variables that can be used to further customize its
 behavior.  A variable may be set in the
 .I inputrc
@@ -634,7 +632,6 @@ by \fIstat\fP(2) is appended to the filename when listing possible
 completions.
 .PD
 .SS Conditional Constructs
-.PP
 Readline implements a facility similar in spirit to the conditional
 compilation features of the C preprocessor which allows key
 bindings and variable settings to be performed as the result
@@ -732,7 +729,6 @@ would read \fI/etc/inputrc\fP:
 .fi 
 .RE
 .SH SEARCHING
-.PP
 Readline provides commands for searching through the command history
 for lines containing a specified string.
 There are two search modes:
@@ -772,7 +768,6 @@ Non-incremental searches read the entire search string before starting
 to search for matching history lines.  The search string may be
 typed by the user or be part of the contents of the current line.
 .SH EDITING COMMANDS
-.PP
 The following is a list of the names of the commands and the default
 key sequences to which they are bound.
 Command names without an accompanying key sequence are unbound by default.
@@ -782,7 +777,6 @@ position, and \fImark\fP refers to a cursor position saved by the
 \fBset\-mark\fP command.
 The text between the point and mark is referred to as the \fIregion\fP.
 .SS Commands for Moving
-.PP
 .PD 0
 .TP
 .B beginning\-of\-line (C\-a)
@@ -818,8 +812,15 @@ Readline line does not take up more than one physical line or if the length
 of the current Readline line is not greater than the length of the prompt
 plus the screen width.
 .TP
+.B clear\-display (M\-C\-l)
+Clear the screen and, if possible, the terminal's scrollback buffer,
+then redraw the current line,
+leaving the current line at the top of the screen.
+.TP
 .B clear\-screen (C\-l)
-Clear the screen leaving the current line at the top of the screen.
+Clear the screen,
+then redraw the current line,
+leaving the current line at the top of the screen.
 With an argument, refresh the current line without clearing the
 screen.
 .TP
@@ -827,7 +828,6 @@ screen.
 Refresh the current line.
 .PD
 .SS Commands for Manipulating the History
-.PP
 .PD 0
 .TP
 .B accept\-line (Newline, Return)
@@ -918,9 +918,17 @@ the direction to move through the history.  A negative argument switches
 the direction through the history (back or forward).
 The history expansion facilities are used to extract the last argument,
 as if the "!$" history expansion had been specified.
+.TP
+.B
+operate\-and\-get\-next (C\-o)
+Accept the current line for return to the calling application as if a
+newline had been entered,
+and fetch the next line relative to the current line from the history
+for editing.
+A numeric argument, if supplied, specifies the history entry to use instead
+of the current line.
 .PD
 .SS Commands for Changing Text
-.PP
 .PD 0
 .TP
 .B \fIend\-of\-file\fP (usually C\-d)
@@ -995,7 +1003,6 @@ Characters bound to \fBbackward\-delete\-char\fP replace the character
 before point with a space.  By default, this command is unbound.
 .PD
 .SS Killing and Yanking
-.PP
 .PD 0
 .TP
 .B kill\-line (C\-k)
@@ -1058,7 +1065,6 @@ or
 .BR yank\-pop .
 .PD
 .SS Numeric Arguments
-.PP
 .PD 0
 .TP
 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
@@ -1080,7 +1086,6 @@ first time makes the argument count four, a second time makes the
 argument count sixteen, and so on.
 .PD
 .SS Completing
-.PP
 .PD 0
 .TP
 .B complete (TAB)
@@ -1137,7 +1142,6 @@ If at the end of the line, behaves identically to
 \fBpossible-completions\fP.
 .PD
 .SS Keyboard Macros
-.PP
 .PD 0
 .TP
 .B start\-kbd\-macro (C\-x (\^)
@@ -1156,7 +1160,6 @@ Print the last keyboard macro defined in a format suitable for the
 \fIinputrc\fP file.
 .PD
 .SS Miscellaneous
-.PP
 .PD 0
 .TP
 .B re\-read\-init\-file (C\-x C\-r)
@@ -1332,6 +1335,7 @@ Emacs Meta bindings
 "M-C-H"  backward-kill-word
 "M-C-I"  tab-insert
 "M-C-J"  vi-editing-mode
+"M-C-L"  clear-display
 "M-C-M"  vi-editing-mode
 "M-C-R"  revert-line
 "M-C-Y"  yank-nth-arg
@@ -1536,5 +1540,4 @@ Comments and bug reports concerning
 this manual page should be directed to
 .IR chet.ramey@case.edu .
 .SH BUGS
-.PP
 It's too big and too slow.
index 737f971ddd1d545e341102961ca55b533cf43ba1..ec7487b7a78812f10d236078f88fd1b431aa03c5 100644 (file)
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 92125d763c405467fafd90338f648fcd2d67e6f3..4547469e3f350abe8484b3636e76278dbd70e08d 100644 (file)
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
 in the consistency of user interface across discrete programs that need
 to provide a command line interface.
 
-Copyright (C) 1988--2019 Free Software Foundation, Inc.
+Copyright (C) 1988--2020 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
index 1291712198b87f117d7936e5434c2d3ed8f6d7f5..d71aa4de1667493510ef2166faccd8ea24b59051 100644 (file)
@@ -9,7 +9,7 @@ use these features.  There is a document entitled "readline.texinfo"
 which contains both end-user and programmer documentation for the
 GNU Readline Library.
 
-Copyright (C) 1988--2016 Free Software Foundation, Inc.
+Copyright (C) 1988--2020 Free Software Foundation, Inc.
 
 Authored by Brian Fox and Chet Ramey.
 
@@ -1201,8 +1201,14 @@ Readline line does not take up more than one physical line or if the length
 of the current Readline line is not greater than the length of the prompt
 plus the screen width.
 
+@item clear-display (M-C-l)
+Clear the screen and, if possible, the terminal's scrollback buffer,
+then redraw the current line,
+leaving the current line at the top of the screen.
+
 @item clear-screen (C-l)
-Clear the screen and redraw the current line,
+Clear the screen,
+then redraw the current line,
 leaving the current line at the top of the screen.
 
 @item redraw-current-line ()
@@ -1316,6 +1322,14 @@ the direction through the history (back or forward).
 The history expansion facilities are used to extract the last argument,
 as if the @samp{!$} history expansion had been specified.
 
+@item operate-and-get-next (C-o)
+Accept the current line for return to the calling application as if a
+newline had been entered,
+and fetch the next line relative to the current line from the history
+for editing.
+A numeric argument, if supplied, specifies the history entry to use instead
+of the current line.
+
 @end ftable
 
 @node Commands For Text
@@ -1788,12 +1802,6 @@ Perform history and alias expansion on the current line.
 @item insert-last-argument (M-. or M-_)
 A synonym for @code{yank-last-arg}.
 
-@item operate-and-get-next (C-o)
-Accept the current line for execution and fetch the next line
-relative to the current line from the history for editing.
-A numeric argument, if supplied, specifies the history entry to use instead
-of the current line.
-
 @item edit-and-execute-command (C-x C-e)
 Invoke an editor on the current command line, and execute the result as shell
 commands.
index b5754389eb2a6e439ae0cb8ec5a3e3abef276849..6e8e848b6e5ae993259eb3a964e8573fe3a73fc5 100644 (file)
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 9cb7069e412c28a386917f11d13553bae42aea11..ba51a075ad2da7742532aaf241917189fce93679 100644 (file)
@@ -1,10 +1,10 @@
 @ignore
-Copyright (C) 1988-2019 Free Software Foundation, Inc. 
+Copyright (C) 1988-2020 Free Software Foundation, Inc. 
 @end ignore
 
 @set EDITION 8.0
 @set VERSION 8.0
-@set UPDATED 25 November 2019
-@set UPDATED-MONTH November 2019
+@set UPDATED 4 May 2020
+@set UPDATED-MONTH May 2020
 
-@set LASTCHANGE Mon Nov 25 10:53:13 EST 2019
+@set LASTCHANGE Mon May  4 14:55:02 EDT 2020
index b5e53f494a1a1b6115bb9dbe552d720fff1d9c50..02597dad31a4811bb55d44a30914b7b955eb2871 100644 (file)
@@ -47,7 +47,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
   { ISFUNC, rl_clear_screen },                 /* Control-l */
   { ISFUNC, rl_newline },                      /* Control-m */
   { ISFUNC, rl_get_next_history },             /* Control-n */
-  { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-o */
+  { ISFUNC, rl_operate_and_get_next },         /* Control-o */
   { ISFUNC, rl_get_previous_history },         /* Control-p */
   { ISFUNC, rl_quoted_insert },                        /* Control-q */
   { ISFUNC, rl_reverse_search_history },       /* Control-r */
@@ -327,7 +327,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
   { ISFUNC, rl_tab_insert },           /* Meta-Control-i */
   { ISFUNC, rl_vi_editing_mode },      /* Meta-Control-j */
   { ISFUNC, (rl_command_func_t *)0x0 },        /* Meta-Control-k */
-  { ISFUNC, (rl_command_func_t *)0x0 },        /* Meta-Control-l */
+  { ISFUNC, rl_clear_display },                /* Meta-Control-l */
   { ISFUNC, rl_vi_editing_mode },      /* Meta-Control-m */
   { ISFUNC, (rl_command_func_t *)0x0 },        /* Meta-Control-n */
   { ISFUNC, (rl_command_func_t *)0x0 },        /* Meta-Control-o */
index 0dab3897c00b162c4d93260efc9e7b4e5769eebf..eca49a3e4f61c0e57289d10352219830c59214ba 100644 (file)
--- a/funmap.c
+++ b/funmap.c
@@ -73,6 +73,7 @@ static const FUNMAP default_funmap[] = {
   { "capitalize-word", rl_capitalize_word },
   { "character-search", rl_char_search },
   { "character-search-backward", rl_backward_char_search },
+  { "clear-display", rl_clear_display },
   { "clear-screen", rl_clear_screen },
   { "complete", rl_complete },
   { "copy-backward-word", rl_copy_backward_word },
@@ -116,6 +117,7 @@ static const FUNMAP default_funmap[] = {
   { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
   { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
   { "old-menu-complete", rl_old_menu_complete },
+  { "operate-and-get-next", rl_operate_and_get_next },
   { "overwrite-mode", rl_overwrite_mode },
 #if defined (_WIN32)
   { "paste-from-clipboard", rl_paste_from_clipboard },
index a38d3952dce352839f0ad4f8a2fb8eed911f0b53..f0fa5ce15fe1a90d2e6c28e9f0729893e5589fee 100644 (file)
@@ -507,6 +507,12 @@ histfile_restore (const char *backup, const char *orig)
   return (history_rename (backup, orig));
 }
 
+/* Should we call chown, based on whether finfo and nfinfo describe different
+   files with different owners? */
+
+#define SHOULD_CHOWN(finfo, nfinfo) \
+  (finfo.st_uid != nfinfo.st_uid || finfo.st_gid != nfinfo.st_gid)
+  
 /* Truncate the history file FNAME, leaving only LINES trailing lines.
    If FNAME is NULL, then use ~/.history.  Writes a new file and renames
    it to the original name.  Returns 0 on success, errno on failure. */
@@ -515,7 +521,7 @@ history_truncate_file (const char *fname, int lines)
 {
   char *buffer, *filename, *tempname, *bp, *bp1;               /* bp1 == bp+1 */
   int file, chars_read, rv, orig_lines, exists, r;
-  struct stat finfo;
+  struct stat finfo, nfinfo;
   size_t file_size;
 
   history_lines_written_to_file = 0;
@@ -536,6 +542,9 @@ history_truncate_file (const char *fname, int lines)
     }
   exists = 1;
 
+  nfinfo.st_uid = finfo.st_uid;
+  nfinfo.st_gid = finfo.st_gid;
+
   if (S_ISREG (finfo.st_mode) == 0)
     {
       close (file);
@@ -624,6 +633,9 @@ history_truncate_file (const char *fname, int lines)
       if (write (file, bp, chars_read - (bp - buffer)) < 0)
        rv = errno;
 
+      if (fstat (file, &nfinfo) < 0 && rv == 0)
+       rv = errno;
+
       if (close (file) < 0 && rv == 0)
        rv = errno;
     }
@@ -651,7 +663,7 @@ history_truncate_file (const char *fname, int lines)
      user is running this, it's a no-op.  If the shell is running after sudo
      with a shared history file, we don't want to leave the history file
      owned by root. */
-  if (rv == 0 && exists)
+  if (rv == 0 && exists && SHOULD_CHOWN (finfo, nfinfo))
     r = chown (filename, finfo.st_uid, finfo.st_gid);
 #endif
 
@@ -670,7 +682,7 @@ history_do_write (const char *filename, int nelements, int overwrite)
   register int i;
   char *output, *tempname, *histname;
   int file, mode, rv, exists;
-  struct stat finfo;
+  struct stat finfo, nfinfo;
 #ifdef HISTORY_USE_MMAP
   size_t cursize;
 
@@ -715,15 +727,11 @@ history_do_write (const char *filename, int nelements, int overwrite)
     the_history = history_list ();
     /* Calculate the total number of bytes to write. */
     for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
-#if 0
-      buffer_size += 2 + HISTENT_BYTES (the_history[i]);
-#else
       {
        if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
          buffer_size += strlen (the_history[i]->timestamp) + 1;
        buffer_size += strlen (the_history[i]->line) + 1;
       }
-#endif
 
     /* Allocate the buffer, and fill it. */
 #ifdef HISTORY_USE_MMAP
diff --git a/input.c b/input.c
index c34dabf0a567afa20030ca28e50561a19fa59a77..9a69e13cc6d7461c01b2d60e56be5c86eb23349b 100644 (file)
--- a/input.c
+++ b/input.c
@@ -349,8 +349,7 @@ _rl_input_available (void)
   FD_ZERO (&exceptfds);
   FD_SET (tty, &readfds);
   FD_SET (tty, &exceptfds);
-  timeout.tv_sec = 0;
-  timeout.tv_usec = _keyboard_input_timeout;
+  USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
   return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
 #else
 
@@ -369,6 +368,24 @@ _rl_input_available (void)
   return 0;
 }
 
+int
+_rl_nchars_available ()
+{
+  int chars_avail, fd, result;
+  
+  chars_avail = 0;
+     
+#if defined (FIONREAD)
+  fd = fileno (rl_instream);
+  errno = 0;    
+  result = ioctl (fd, FIONREAD, &chars_avail);    
+  if (result == -1 && errno == EIO)    
+    return -1;    
+#endif
+
+  return chars_avail;
+}
+
 int
 _rl_input_queued (int t)
 {
index c8f60a01dcda3622c0e46740e621781029103701..201a37bbcff0d4c84fa2e92a8792a70e2f73c078 100644 (file)
--- a/isearch.c
+++ b/isearch.c
@@ -6,7 +6,7 @@
 /*                                                                 */
 /* **************************************************************** */
 
-/* Copyright (C) 1987-2017 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.      
@@ -257,6 +257,9 @@ _rl_isearch_init (int direction)
 
   _rl_iscxt = cxt;             /* save globally */
 
+  /* experimental right now */
+  _rl_init_executing_keyseq ();
+
   return cxt;
 }
 
@@ -289,12 +292,16 @@ _rl_isearch_fini (_rl_search_cxt *cxt)
       else
        cxt->sline_index = strlen (rl_line_buffer);
       rl_mark = cxt->save_mark;
+      rl_deactivate_mark ();
     }
 
   rl_point = cxt->sline_index;
   /* Don't worry about where to put the mark here; rl_get_previous_history
-     and rl_get_next_history take care of it. */
+     and rl_get_next_history take care of it.
+     If we want to highlight the search string, this is where to set the
+     point and mark to do it. */
   _rl_fix_point (0);
+  rl_deactivate_mark ();
 
 /*  _rl_optimize_redisplay (); */
   rl_clear_message ();
@@ -346,6 +353,24 @@ _rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
       return -1;
     }
 
+  _rl_add_executing_keyseq (c);
+
+  /* XXX - experimental code to allow users to bracketed-paste into the search
+     string even when ESC is one of the isearch-terminators. Not perfect yet. */
+  if (_rl_enable_bracketed_paste && c == ESC && strchr (cxt->search_terminators, c) && (n = _rl_nchars_available ()) > (2*BRACK_PASTE_SLEN-1))
+    {
+      j = _rl_read_bracketed_paste_prefix (c);
+      if (j == 1)
+       {
+         cxt->lastc = -7;              /* bracketed paste, see below */
+         goto opcode_dispatch; 
+        }
+      else if (_rl_pushed_input_available ())  /* eat extra char we pushed back */
+       c = cxt->lastc = rl_read_key ();
+      else
+       c = cxt->lastc;                 /* last ditch */
+    }
+
   /* If we are moving into a new keymap, modify cxt->keymap and go on.
      This can be a problem if c == ESC and we want to terminate the
      incremental search, so we check */
@@ -396,7 +421,11 @@ add_character:
       if (cxt->mb[1])
        f = rl_function_of_keyseq (cxt->mb, cxt->keymap, (int *)NULL);
       else
-       f = cxt->keymap[c].function;
+       {
+         f = cxt->keymap[c].function;
+         if (f == rl_do_lowercase_version)
+           f = cxt->keymap[_rl_to_lower (c)].function;
+       }
 
       if (f == rl_reverse_search_history)
        cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
@@ -463,9 +492,14 @@ add_character:
        }
       else if (cxt->lastc > 0 && cxt->prevc > 0 && f && f != rl_insert)
        {
-         rl_stuff_char (cxt->lastc);
-         rl_execute_next (cxt->prevc);
-         /* XXX - do we insert everything in cxt->pmb? */
+         _rl_term_executing_keyseq ();         /* should this go in the caller? */
+
+         _rl_pending_command.map = cxt->keymap;
+         _rl_pending_command.count = 1;        /* XXX */
+         _rl_pending_command.key = cxt->lastc;
+         _rl_pending_command.func = f;
+         _rl_command_to_execute = &_rl_pending_command;
+
          return (0);
        }
     }
@@ -511,6 +545,9 @@ add_character:
        return (0);
       }
 
+  _rl_init_executing_keyseq ();
+
+opcode_dispatch:
   /* Now dispatch on the character.  `Opcodes' affect the search string or
      state.  Other characters are added to the string.  */
   switch (cxt->lastc)
@@ -528,6 +565,7 @@ add_character:
              rl_display_search (cxt->search_string, cxt->sflags, -1);
              break;
            }
+         /* XXX - restore keymap here? */
          return (1);
        }
       else if ((cxt->sflags & SF_REVERSE) && cxt->sline_index >= 0)
@@ -575,6 +613,7 @@ add_character:
       rl_replace_line (cxt->lines[cxt->save_line], 0);
       rl_point = cxt->save_point;
       rl_mark = cxt->save_mark;
+      rl_deactivate_mark ();
       rl_restore_prompt();
       rl_clear_message ();
 
@@ -641,6 +680,7 @@ add_character:
          free (paste);
          break;
        }
+      rl_activate_mark ();
       if (cxt->search_string_index + pastelen + 1 >= cxt->search_string_size)
        {
          cxt->search_string_size += pastelen + 2;
@@ -745,11 +785,15 @@ add_character:
       cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
     }
 
+  /* reset the keymaps for the next time through the loop */
+  cxt->keymap = cxt->okeymap = _rl_keymap;
+
   if (cxt->sflags & SF_FAILED)
     {
       /* We cannot find the search string.  Ding the bell. */
       rl_ding ();
       cxt->history_pos = cxt->last_found_line;
+      rl_deactivate_mark ();
       rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
       return 1;
     }
@@ -761,7 +805,10 @@ add_character:
     {
       cxt->prev_line_found = cxt->lines[cxt->history_pos];
       rl_replace_line (cxt->lines[cxt->history_pos], 0);
+      rl_activate_mark ();     
       rl_point = cxt->sline_index;
+      if (rl_mark_active_p () && cxt->search_string_index > 0)
+       rl_mark = rl_point + cxt->search_string_index;
       cxt->last_found_line = cxt->history_pos;
       rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
     }
diff --git a/kill.c b/kill.c
index 2bea7d05b25dc6dba301c5cc9e8fa30db1d98f8e..5366445e23d85d39f816985a0774be6bdcb1154d 100644 (file)
--- a/kill.c
+++ b/kill.c
@@ -1,6 +1,6 @@
 /* kill.c -- kill ring management. */
 
-/* Copyright (C) 1994-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1994-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.      
@@ -718,7 +718,7 @@ _rl_bracketed_text (size_t *lenp)
 /* Having read the special escape sequence denoting the beginning of a
    `bracketed paste' sequence, read the rest of the pasted input until the
    closing sequence and insert the pasted text as a single unit without
-   interpretation. */
+   interpretation. Temporarily highlight the inserted text. */
 int
 rl_bracketed_paste_begin (int count, int key)
 {
@@ -727,7 +727,9 @@ rl_bracketed_paste_begin (int count, int key)
   char *buf;
 
   buf = _rl_bracketed_text (&len);
+  rl_mark = rl_point;
   retval = rl_insert_text (buf) == len ? 0 : 1;
+  rl_activate_mark ();
 
   xfree (buf);
   return (retval);
index 17716357feb0c31b686636ccece7a1567426db35..dc62b4cc24dd55df745c1e623a24f3ca94f21059 100644 (file)
--- a/mbutil.c
+++ b/mbutil.c
@@ -1,6 +1,6 @@
 /* mbutil.c -- readline multibyte character utility functions */
 
-/* Copyright (C) 2001-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2001-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.      
@@ -86,7 +86,7 @@ int _rl_utf8locale = 0;
 static int
 _rl_utf8_mblen (const char *s, size_t n)
 {
-  unsigned char c, c1;
+  unsigned char c, c1, c2, c3;
 
   if (s == 0)
     return (0);        /* no shift states */
@@ -101,25 +101,46 @@ _rl_utf8_mblen (const char *s, size_t n)
       c1 = (unsigned char)s[1];
       if (c < 0xe0)
        {
-         if (n >= 2 && (s[1] ^ 0x80) < 0x40)
+         if (n == 1)
+           return -2;
+         if (n >= 2 && (c1 ^ 0x80) < 0x40)
            return 2;
        }
       else if (c < 0xf0)
        {
-         if (n >= 3
-               && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+         if (n == 1)
+           return -2;
+         if ((c1 ^ 0x80) < 0x40
                && (c >= 0xe1 || c1 >= 0xa0)
                && (c != 0xed || c1 < 0xa0))
-           return 3;
+           {
+             if (n == 2)
+               return -2;
+             c2 = (unsigned char)s[2];
+             if ((c2 ^ 0x80) < 0x40)
+               return 3;
+           }
        }
-      else if (c < 0xf8)
+      else if (c < 0xf4)
        {
-         if (n >= 4
-               && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-               && (s[3] ^ 0x80) < 0x40
+         if (n == 1)
+           return -2;
+         if (((c1 ^ 0x80) < 0x40)
                && (c >= 0xf1 || c1 >= 0x90)
                && (c < 0xf4 || (c == 0xf4 && c1 < 0x90)))
-           return 4;
+           {
+             if (n == 2)
+               return -2;
+             c2 = (unsigned char)s[2];
+             if ((c2 ^ 0x80) < 0x40)
+               {
+                 if (n == 3)
+                   return -2;
+                 c3 = (unsigned char)s[3];
+                 if ((c3 ^ 0x80) < 0x40)
+                   return 4;
+               }
+           }
        }
     }
   /* invalid or incomplete multibyte character */
@@ -206,6 +227,66 @@ _rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_z
   return point;
 }
 
+static inline int
+_rl_test_nonzero (char *string, int ind, int len)
+{
+  size_t tmp;
+  wchar_t wc;
+  mbstate_t ps;
+
+  memset (&ps, 0, sizeof (mbstate_t));
+  tmp = mbrtowc (&wc, string + ind, len - ind, &ps);
+  /* treat invalid multibyte sequences as non-zero-width */
+  return (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp) || WCWIDTH (wc) > 0);
+}
+
+/* experimental -- needs to handle zero-width characters better */
+static int
+_rl_find_prev_utf8char (char *string, int seed, int find_non_zero)
+{
+  char *s;
+  unsigned char b;
+  int save, prev;
+  size_t len;
+
+  if (find_non_zero)
+    len = RL_STRLEN (string);
+
+  prev = seed - 1;
+  while (prev >= 0)
+   {
+      b = (unsigned char)string[prev];
+      if (UTF8_SINGLEBYTE (b))
+       return (prev);
+
+      save = prev;
+
+      /* Move back until we're not in the middle of a multibyte char */
+      if (UTF8_MBCHAR (b))
+       {
+         while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBCHAR (b))
+           ;
+       }
+
+      if (UTF8_MBFIRSTCHAR (b))
+       {
+         if (find_non_zero)
+           {
+             if (_rl_test_nonzero (string, prev, len))
+               return (prev);
+             else              /* valid but WCWIDTH (wc) == 0 */
+               prev = prev - 1;
+           }
+         else
+           return (prev);
+       }
+      else
+       return (save);                  /* invalid utf-8 multibyte sequence */
+    }
+
+  return ((prev < 0) ? 0 : prev);
+}  
+
 /*static*/ int
 _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
 {
@@ -214,6 +295,9 @@ _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
   size_t tmp;
   wchar_t wc;
 
+  if (_rl_utf8locale)
+    return (_rl_find_prev_utf8char (string, seed, find_non_zero));
+
   memset(&ps, 0, sizeof(mbstate_t));
   length = strlen(string);
   
diff --git a/misc.c b/misc.c
index e6b42ebf2bc9deb5959c4d2bc6a750bcf63501dd..3d9a674ca59d9a4de961ac846cd66fe221c4f2c6 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -637,6 +637,48 @@ rl_get_previous_history (int count, int key)
   return 0;
 }
 
+/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
+   editing command. */
+
+/* This could stand to be global to the readline library */
+static rl_hook_func_t *_rl_saved_internal_startup_hook = 0;
+static int saved_history_logical_offset = -1;
+
+#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries)
+
+static int
+set_saved_history ()
+{
+  int absolute_offset, count;
+
+  if (saved_history_logical_offset >= 0)
+    {
+      absolute_offset = saved_history_logical_offset - history_base;
+      count = where_history () - absolute_offset;
+      rl_get_previous_history (count, 0);
+    }
+  saved_history_logical_offset = -1;
+  _rl_internal_startup_hook = _rl_saved_internal_startup_hook;
+
+  return (0);
+}
+
+int
+rl_operate_and_get_next (count, c)
+     int count, c;
+{
+  /* Accept the current line. */
+  rl_newline (1, c);
+
+  saved_history_logical_offset = rl_explicit_arg ? count : where_history () + history_base + 1;
+
+
+  _rl_saved_internal_startup_hook = _rl_internal_startup_hook;
+  _rl_internal_startup_hook = set_saved_history;
+
+  return 0;
+}
+
 /* **************************************************************** */
 /*                                                                 */
 /*                         Editing Modes                           */
index d8c9df7e6bb19b63a7c7f1c4f192a91529e40699..626a945e08fbd8926846afabedb8740ebf1720c7 100644 (file)
@@ -1,3 +1,3 @@
 # Do not edit -- exists only for use by patch
 
-0
+4
index 1adc383bab0f3ccde55a54735777ac7e9802f9ec..ed5c4283aceef338c567e1fca201a0c6e5cc0b34 100644 (file)
@@ -73,11 +73,11 @@ extern int errno;
 #include "xmalloc.h"
 
 #ifndef RL_LIBRARY_VERSION
-#  define RL_LIBRARY_VERSION "5.1"
+#  define RL_LIBRARY_VERSION "8.0"
 #endif
 
 #ifndef RL_READLINE_VERSION
-#  define RL_READLINE_VERSION  0x0501
+#  define RL_READLINE_VERSION  0x0800
 #endif
 
 extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
@@ -199,6 +199,10 @@ int rl_key_sequence_length = 0;
    before readline_internal_setup () prints the first prompt. */
 rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
 
+/* Any readline function can set this and have it run just before the user's
+   rl_startup_hook. */
+rl_hook_func_t *_rl_internal_startup_hook = (rl_hook_func_t *)NULL;
+
 /* If non-zero, this is the address of a function to call just before
    readline_internal_setup () returns and readline_internal starts
    reading input characters. */
@@ -258,6 +262,9 @@ int rl_executing_key;
 char *rl_executing_keyseq = 0;
 int _rl_executing_keyseq_size = 0;
 
+struct _rl_cmd _rl_pending_command;
+struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
+
 /* Timeout (specified in milliseconds) when reading characters making up an
    ambiguous multiple-key sequence */
 int _rl_keyseq_timeout = 500;
@@ -314,7 +321,7 @@ int _rl_show_mode_in_prompt = 0;
 /* Non-zero means to attempt to put the terminal in `bracketed paste mode',
    where it will prefix pasted text with an escape sequence and send
    another to mark the end of the paste. */
-int _rl_enable_bracketed_paste = 0;
+int _rl_enable_bracketed_paste = 1;    /* XXX - for now */
 
 /* **************************************************************** */
 /*                                                                 */
@@ -417,6 +424,11 @@ readline_internal_setup (void)
   if (rl_startup_hook)
     (*rl_startup_hook) ();
 
+  if (_rl_internal_startup_hook)
+    (*_rl_internal_startup_hook) ();
+
+  rl_deactivate_mark ();
+
 #if defined (VI_MODE)
   if (rl_editing_mode == vi_mode)
     rl_vi_insertion_mode (1, 'i');     /* don't want to reset last */
@@ -632,12 +644,34 @@ readline_internal_charloop (void)
       r = _rl_dispatch ((unsigned char)c, _rl_keymap);
       RL_CHECK_SIGNALS ();
 
+      if (_rl_command_to_execute)
+       {
+         (*rl_redisplay_function) ();
+
+         rl_executing_keymap = _rl_command_to_execute->map;
+         rl_executing_key = _rl_command_to_execute->key;
+
+         rl_dispatching = 1;
+         RL_SETSTATE(RL_STATE_DISPATCHING);
+         r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
+         _rl_command_to_execute = 0;
+         RL_UNSETSTATE(RL_STATE_DISPATCHING);
+         rl_dispatching = 0;
+
+         RL_CHECK_SIGNALS ();
+       }
+
       /* If there was no change in _rl_last_command_was_kill, then no kill
         has taken place.  Note that if input is pending we are reading
         a prefix command, so nothing has changed yet. */
       if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
        _rl_last_command_was_kill = 0;
 
+      if (_rl_keep_mark_active)
+        _rl_keep_mark_active = 0;
+      else if (rl_mark_active_p ())
+        rl_deactivate_mark ();
+
       _rl_internal_char_cleanup ();
 
 #if defined (READLINE_CALLBACKS)
@@ -1253,7 +1287,7 @@ readline_initialize_everything (void)
 
   rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
   if (rl_executing_keyseq)
-    rl_executing_keyseq[0] = '\0';
+    rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
 }
 
 /* If this system allows us to look at the values of the regular
@@ -1368,9 +1402,12 @@ bind_bracketed_paste_prefix (void)
 
   _rl_keymap = emacs_standard_keymap;
   rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
-  
+
+#if defined (VI_MODE)
   _rl_keymap = vi_insertion_keymap;
   rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
+  /* XXX - is there a reason to do this in the vi command keymap? */
+#endif
 
   _rl_keymap = xkeymap;
 }
@@ -1458,5 +1495,35 @@ rl_restore_state (struct readline_state *sp)
   rl_attempted_completion_function = sp->attemptfunc;
   rl_completer_word_break_characters = sp->wordbreakchars;
 
+  rl_deactivate_mark ();
+
   return (0);
 }
+
+/* Functions to manage the string that is the current key sequence. */
+
+void
+_rl_init_executing_keyseq (void)
+{
+  rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
+}
+
+void
+_rl_term_executing_keyseq (void)
+{
+  rl_executing_keyseq[rl_key_sequence_length] = '\0';
+}
+
+void
+_rl_end_executing_keyseq (void)
+{
+  if (rl_key_sequence_length > 0)
+    rl_executing_keyseq[--rl_key_sequence_length] = '\0';
+}
+
+void
+_rl_add_executing_keyseq (int key)
+{
+  RESIZE_KEYSEQ_BUFFER ();
+ rl_executing_keyseq[rl_key_sequence_length++] = key;
+}
index da782716af2a52edf38c2e6252bddc54d2f7eb6e..8e6ec53791d83dedfedf61d816bd79e922a6e70d 100644 (file)
@@ -1,6 +1,6 @@
 /* Readline.h -- the names of functions callable from within readline. */
 
-/* Copyright (C) 1987-2016 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.      
@@ -95,6 +95,7 @@ extern int rl_forward_word PARAMS((int, int));
 extern int rl_backward_word PARAMS((int, int));
 extern int rl_refresh_line PARAMS((int, int));
 extern int rl_clear_screen PARAMS((int, int));
+extern int rl_clear_display PARAMS((int, int));
 extern int rl_skip_csi_sequence PARAMS((int, int));
 extern int rl_arrow_keys PARAMS((int, int));
 
@@ -132,6 +133,7 @@ extern int rl_beginning_of_history PARAMS((int, int));
 extern int rl_end_of_history PARAMS((int, int));
 extern int rl_get_next_history PARAMS((int, int));
 extern int rl_get_previous_history PARAMS((int, int));
+extern int rl_operate_and_get_next PARAMS((int, int));
 
 /* Bindable commands for managing the mark and region. */
 extern int rl_set_mark PARAMS((int, int));
@@ -392,6 +394,14 @@ extern int rl_clear_message PARAMS((void));
 extern int rl_reset_line_state PARAMS((void));
 extern int rl_crlf PARAMS((void));
 
+/* Functions to manage the mark and region, especially the notion of an
+   active mark and an active region. */
+extern void rl_keep_mark_active PARAMS((void));
+
+extern void rl_activate_mark PARAMS((void));
+extern void rl_deactivate_mark PARAMS((void));
+extern int rl_mark_active_p PARAMS((void));
+
 #if defined (USE_VARARGS) && defined (PREFER_STDARG)
 extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
 #else
index f1c6147484bc1d093c5d627df12acc13c3d47b69..954031d814a2b56729afd605a27d0065d2725efb 100644 (file)
@@ -1,7 +1,7 @@
 /* rlprivate.h -- functions and variables global to the readline library,
                  but not intended for use by applications. */
 
-/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1999-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.      
@@ -109,6 +109,15 @@ typedef struct  __rl_search_context
   char  *search_terminators;
 } _rl_search_cxt;
 
+struct _rl_cmd {
+  Keymap map;
+  int count;
+  int key;
+  rl_command_func_t *func;
+};
+extern struct _rl_cmd _rl_pending_command;
+extern struct _rl_cmd *_rl_command_to_execute;
+
 /* Callback data for reading numeric arguments */
 #define NUM_SAWMINUS   0x01
 #define NUM_SAWDIGITS  0x02
@@ -267,24 +276,25 @@ extern void _rl_free_match_list PARAMS((char **));
 /* display.c */
 extern char *_rl_strip_prompt PARAMS((char *));
 extern void _rl_reset_prompt PARAMS((void));
-extern void _rl_move_cursor_relative PARAMS((int, const char *));
 extern void _rl_move_vert PARAMS((int));
 extern void _rl_save_prompt PARAMS((void));
 extern void _rl_restore_prompt PARAMS((void));
 extern char *_rl_make_prompt_for_search PARAMS((int));
 extern void _rl_erase_at_end_of_line PARAMS((int));
 extern void _rl_clear_to_eol PARAMS((int));
-extern void _rl_clear_screen PARAMS((void));
+extern void _rl_clear_screen PARAMS((int));
 extern void _rl_update_final PARAMS((void));
 extern void _rl_optimize_redisplay PARAMS((void));
 extern void _rl_redisplay_after_sigwinch PARAMS((void));
 extern void _rl_clean_up_for_exit PARAMS((void));
 extern void _rl_erase_entire_line PARAMS((void));
 extern int _rl_current_display_line PARAMS((void));
+extern void _rl_refresh_line PARAMS((void));
 
 /* input.c */
 extern int _rl_any_typein PARAMS((void));
 extern int _rl_input_available PARAMS((void));
+extern int _rl_nchars_available PARAMS((void));
 extern int _rl_input_queued PARAMS((int));
 extern void _rl_insert_typein PARAMS((int));
 extern int _rl_unget_char PARAMS((int));
@@ -353,6 +363,11 @@ extern int _rl_dispatch PARAMS((int, Keymap));
 extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
 extern void _rl_internal_char_cleanup PARAMS((void));
 
+extern void _rl_init_executing_keyseq PARAMS((void));
+extern void _rl_term_executing_keyseq PARAMS((void));
+extern void _rl_end_executing_keyseq PARAMS((void));
+extern void _rl_add_executing_keyseq PARAMS((int)); 
+
 /* rltty.c */
 extern int _rl_disable_tty_signals PARAMS((void));
 extern int _rl_restore_tty_signals PARAMS((void));
@@ -378,12 +393,15 @@ extern void _rl_output_character_function PARAMS((int));
 #else
 extern int _rl_output_character_function PARAMS((int));
 #endif
+extern void _rl_cr PARAMS((void));
 extern void _rl_output_some_chars PARAMS((const char *, int));
 extern int _rl_backspace PARAMS((int));
 extern void _rl_enable_meta_key PARAMS((void));
 extern void _rl_disable_meta_key PARAMS((void));
 extern void _rl_control_keypad PARAMS((int));
 extern void _rl_set_cursor PARAMS((int, int));
+extern void _rl_standout_on PARAMS((void));
+extern void _rl_standout_off PARAMS((void));
 
 /* text.c */
 extern void _rl_fix_point PARAMS((int));
@@ -527,6 +545,8 @@ extern int _rl_keyseq_timeout;
 
 extern int _rl_executing_keyseq_size;
 
+extern rl_hook_func_t *_rl_internal_startup_hook;
+
 /* search.c */
 extern _rl_search_cxt *_rl_nscxt;
 
@@ -565,6 +585,7 @@ extern int _rl_term_autowrap;
 
 /* text.c */
 extern int _rl_optimize_typeahead;
+extern int _rl_keep_mark_active;
 
 /* undo.c */
 extern int _rl_doing_an_undo;
index d3920d4b6f18faf020b63a00fdbac76bf74bb892..ab65a3752395cd589f8fd16be18804147ca3db18 100644 (file)
--- a/search.c
+++ b/search.c
@@ -1,6 +1,6 @@
 /* search.c - code for non-incremental searching in emacs and vi modes. */
 
-/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1992-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.      
@@ -159,7 +159,7 @@ noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp)
 static int
 noninc_dosearch (char *string, int dir, int flags)
 {
-  int oldpos, pos;
+  int oldpos, pos, ind;
   HIST_ENTRY *entry;
 
   if (string == 0 || *string == '\0' || noninc_history_pos < 0)
@@ -168,7 +168,7 @@ noninc_dosearch (char *string, int dir, int flags)
       return 0;
     }
 
-  pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir, flags, (int *)0);
+  pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir, flags, &ind);
   if (pos == -1)
     {
       /* Search failed, current history position unchanged. */
@@ -192,8 +192,19 @@ noninc_dosearch (char *string, int dir, int flags)
 
   make_history_line_current (entry);
 
-  rl_point = 0;
-  rl_mark = rl_end;
+  if (_rl_enable_bracketed_paste && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end)
+    {
+      rl_point = ind;
+      rl_mark = ind + strlen (string);
+      if (rl_mark > rl_end)
+       rl_mark = rl_end;       /* can't happen? */
+      rl_activate_mark ();
+    }
+  else
+    {  
+      rl_point = 0;
+      rl_mark = rl_end;
+    }
 
   rl_clear_message ();
   return 1;
@@ -268,6 +279,8 @@ _rl_nsearch_abort (_rl_search_cxt *cxt)
 static int
 _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
 {
+  int n;
+
   if (c < 0)
     c = CTRL ('C');  
 
@@ -301,6 +314,28 @@ _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
       _rl_nsearch_abort (cxt);
       return -1;
 
+    case ESC:
+      /* XXX - experimental code to allow users to bracketed-paste into the
+        search string. Similar code is in isearch.c:_rl_isearch_dispatch().
+        The difference here is that the bracketed paste sometimes doesn't
+        paste everything, so checking for the prefix and the suffix in the
+        input queue doesn't work well. We just have to check to see if the
+        number of chars in the input queue is enough for the bracketed paste
+        prefix and hope for the best. */
+      if (_rl_enable_bracketed_paste && ((n = _rl_nchars_available ()) >= (BRACK_PASTE_SLEN-1)))
+       {
+         if (_rl_read_bracketed_paste_prefix (c) == 1)
+           rl_bracketed_paste_begin (1, c);
+         else
+           {
+             c = rl_read_key ();       /* get the ESC that got pushed back */
+             _rl_insert_char (1, c);
+           }
+        }
+      else
+        _rl_insert_char (1, c);
+      break;
+
     default:
 #if defined (HANDLE_MULTIBYTE)
       if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@@ -312,6 +347,7 @@ _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
     }
 
   (*rl_redisplay_function) ();
+  rl_deactivate_mark ();
   return 1;
 }
 
index 18f8edc0ff54405d81247b07a34a647675a29b2e..11fda528bc7b15f6a8a963a20c06cd9a6dbe5d6b 100755 (executable)
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2018 Free Software Foundation, Inc.
+#   Copyright 1992-2020 Free Software Foundation, Inc.
 
-timestamp='2018-08-29'
+timestamp='2020-04-26'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2020 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -96,10 +96,11 @@ fi
 
 tmp=
 # shellcheck disable=SC2172
-trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
-trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
 
 set_cc_for_build() {
+    # prevent multiple calls if $tmp is already set
+    test "$tmp" && return 0
     : "${TMPDIR=/tmp}"
     # shellcheck disable=SC2039
     { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
@@ -263,6 +264,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     *:SolidBSD:*:*)
        echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
        exit ;;
+    *:OS108:*:*)
+       echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
+       exit ;;
     macppc:MirBSD:*:*)
        echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
        exit ;;
@@ -272,12 +276,15 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     *:Sortix:*:*)
        echo "$UNAME_MACHINE"-unknown-sortix
        exit ;;
+    *:Twizzler:*:*)
+       echo "$UNAME_MACHINE"-unknown-twizzler
+       exit ;;
     *:Redox:*:*)
        echo "$UNAME_MACHINE"-unknown-redox
        exit ;;
     mips:OSF1:*.*)
-        echo mips-dec-osf1
-        exit ;;
+       echo mips-dec-osf1
+       exit ;;
     alpha:OSF1:*:*)
        case $UNAME_RELEASE in
        *4.0)
@@ -392,15 +399,20 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
        echo i386-pc-auroraux"$UNAME_RELEASE"
        exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
-       case `isainfo -b` in
-           32)
-               echo i386-pc-solaris2"$UNAME_REL"
-               ;;
-           64)
-               echo x86_64-pc-solaris2"$UNAME_REL"
-               ;;
-       esac
+       set_cc_for_build
+       SUN_ARCH=i386
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH=x86_64
+           fi
+       fi
+       echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
@@ -914,7 +926,7 @@ EOF
        echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     alpha:Linux:*:*)
-       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
          EV5)   UNAME_MACHINE=alphaev5 ;;
          EV56)  UNAME_MACHINE=alphaev56 ;;
          PCA56) UNAME_MACHINE=alphapca56 ;;
@@ -981,22 +993,50 @@ EOF
        exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
        set_cc_for_build
+       IS_GLIBC=0
+       test x"${LIBC}" = xgnu && IS_GLIBC=1
        sed 's/^        //' << EOF > "$dummy.c"
        #undef CPU
-       #undef ${UNAME_MACHINE}
-       #undef ${UNAME_MACHINE}el
+       #undef mips
+       #undef mipsel
+       #undef mips64
+       #undef mips64el
+       #if ${IS_GLIBC} && defined(_ABI64)
+       LIBCABI=gnuabi64
+       #else
+       #if ${IS_GLIBC} && defined(_ABIN32)
+       LIBCABI=gnuabin32
+       #else
+       LIBCABI=${LIBC}
+       #endif
+       #endif
+
+       #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+       CPU=mipsisa64r6
+       #else
+       #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+       CPU=mipsisa32r6
+       #else
+       #if defined(__mips64)
+       CPU=mips64
+       #else
+       CPU=mips
+       #endif
+       #endif
+       #endif
+
        #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-       CPU=${UNAME_MACHINE}el
+       MIPS_ENDIAN=el
        #else
        #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-       CPU=${UNAME_MACHINE}
+       MIPS_ENDIAN=
        #else
-       CPU=
+       MIPS_ENDIAN=
        #endif
        #endif
 EOF
-       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
-       test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
+       test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
        ;;
     mips64el:Linux:*:*)
        echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@@ -1109,7 +1149,7 @@ EOF
            *Pentium)        UNAME_MACHINE=i586 ;;
            *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
        esac
-       echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
+       echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
        exit ;;
     i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
@@ -1293,38 +1333,39 @@ EOF
        echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
        exit ;;
     *:Darwin:*:*)
-       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-       set_cc_for_build
-       if test "$UNAME_PROCESSOR" = unknown ; then
-           UNAME_PROCESSOR=powerpc
+       UNAME_PROCESSOR=`uname -p`
+       case $UNAME_PROCESSOR in
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       if command -v xcode-select > /dev/null 2> /dev/null && \
+               ! xcode-select --print-path > /dev/null 2> /dev/null ; then
+           # Avoid executing cc if there is no toolchain installed as
+           # cc will be a stub that puts up a graphical alert
+           # prompting the user to install developer tools.
+           CC_FOR_BUILD=no_compiler_found
+       else
+           set_cc_for_build
        fi
-       if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
-           if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
-               if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-                      grep IS_64BIT_ARCH >/dev/null
-               then
-                   case $UNAME_PROCESSOR in
-                       i386) UNAME_PROCESSOR=x86_64 ;;
-                       powerpc) UNAME_PROCESSOR=powerpc64 ;;
-                   esac
-               fi
-               # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
-               if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
-                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-                      grep IS_PPC >/dev/null
-               then
-                   UNAME_PROCESSOR=powerpc
-               fi
+       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+           if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+                  (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                  grep IS_64BIT_ARCH >/dev/null
+           then
+               case $UNAME_PROCESSOR in
+                   i386) UNAME_PROCESSOR=x86_64 ;;
+                   powerpc) UNAME_PROCESSOR=powerpc64 ;;
+               esac
+           fi
+           # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+           if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+                  (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                  grep IS_PPC >/dev/null
+           then
+               UNAME_PROCESSOR=powerpc
            fi
        elif test "$UNAME_PROCESSOR" = i386 ; then
-           # Avoid executing cc on OS X 10.9, as it ships with a stub
-           # that puts up a graphical alert prompting to install
-           # developer tools.  Any system running Mac OS X 10.7 or
-           # later (Darwin 11 and later) is required to have a 64-bit
-           # processor. This is not true of the ARM version of Darwin
-           # that Apple uses in portable devices.
-           UNAME_PROCESSOR=x86_64
+           # uname -m returns i386 or x86_64
+           UNAME_PROCESSOR=$UNAME_MACHINE
        fi
        echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
        exit ;;
@@ -1424,8 +1465,148 @@ EOF
     amd64:Isilon\ OneFS:*:*)
        echo x86_64-unknown-onefs
        exit ;;
+    *:Unleashed:*:*)
+       echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
+       exit ;;
 esac
 
+# No uname command or uname output not recognized.
+set_cc_for_build
+cat > "$dummy.c" <<EOF
+#ifdef _SEQUENT_
+#include <sys/types.h>
+#include <sys/utsname.h>
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#include <signal.h>
+#if defined(_SIZE_T_) || defined(SIGLOST)
+#include <sys/utsname.h>
+#endif
+#endif
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+  "4"
+#else
+  ""
+#endif
+  ); exit (0);
+#endif
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+  struct utsname un;
+
+  uname(&un);
+  if (strncmp(un.version, "V2", 2) == 0) {
+    printf ("i386-sequent-ptx2\n"); exit (0);
+  }
+  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+    printf ("i386-sequent-ptx1\n"); exit (0);
+  }
+  printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+#include <sys/param.h>
+#if defined (BSD)
+#if BSD == 43
+  printf ("vax-dec-bsd4.3\n"); exit (0);
+#else
+#if BSD == 199006
+  printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#endif
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#else
+#if defined(_SIZE_T_) || defined(SIGLOST)
+  struct utsname un;
+  uname (&un);
+  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#if defined(_SIZE_T_) || defined(SIGLOST)
+  struct utsname *un;
+  uname (&un);
+  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
+#else
+  printf ("mips-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
 echo "$0: unable to guess system type" >&2
 
 case "$UNAME_MACHINE:$UNAME_SYSTEM" in
@@ -1448,6 +1629,12 @@ copies of config.guess and config.sub with the latest versions from:
   https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
   https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+EOF
+
+year=`echo $timestamp | sed 's,-.*,,'`
+# shellcheck disable=SC2003
+if test "`expr "\`date +%Y\`" - "$year"`" -lt 3 ; then
+   cat >&2 <<EOF
 
 If $0 has already been updated, send the following data and any
 information you think might be pertinent to config-patches@gnu.org to
@@ -1475,6 +1662,7 @@ UNAME_RELEASE = "$UNAME_RELEASE"
 UNAME_SYSTEM  = "$UNAME_SYSTEM"
 UNAME_VERSION = "$UNAME_VERSION"
 EOF
+fi
 
 exit 1
 
index f208558ec21f53223066d8d576dfb6c97c9465dd..973a2980ac3ad53d126199f5b7446e86344347a9 100755 (executable)
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2018 Free Software Foundation, Inc.
+#   Copyright 1992-2020 Free Software Foundation, Inc.
 
-timestamp='2018-08-29'
+timestamp='2020-05-04'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2020 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -111,7 +111,8 @@ case $# in
 esac
 
 # Split fields of configuration type
-IFS="-" read -r field1 field2 field3 field4 <<EOF
+# shellcheck disable=SC2162
+IFS="-" read field1 field2 field3 field4 <<EOF
 $1
 EOF
 
@@ -336,17 +337,14 @@ case $1 in
                                basic_machine=m88k-harris
                                os=sysv3
                                ;;
-                       hp300)
+                       hp300 | hp300hpux)
                                basic_machine=m68k-hp
+                               os=hpux
                                ;;
                        hp300bsd)
                                basic_machine=m68k-hp
                                os=bsd
                                ;;
-                       hp300hpux)
-                               basic_machine=m68k-hp
-                               os=hpux
-                               ;;
                        hppaosf)
                                basic_machine=hppa1.1-hp
                                os=osf
@@ -359,10 +357,6 @@ case $1 in
                                basic_machine=i386-mach
                                os=mach
                                ;;
-                       vsta)
-                               basic_machine=i386-pc
-                               os=vsta
-                               ;;
                        isi68 | isi)
                                basic_machine=m68k-isi
                                os=sysv
@@ -611,6 +605,10 @@ case $1 in
                                basic_machine=vax-dec
                                os=vms
                                ;;
+                       vsta)
+                               basic_machine=i386-pc
+                               os=vsta
+                               ;;
                        vxworks960)
                                basic_machine=i960-wrs
                                os=vxworks
@@ -821,7 +819,9 @@ case $basic_machine in
                cpu=m68k
                vendor=next
                case $os in
-                   nextstep* )
+                   openstep*)
+                       ;;
+                   nextstep*)
                        ;;
                    ns2*)
                      os=nextstep2
@@ -918,7 +918,8 @@ case $basic_machine in
                ;;
 
        *-*)
-               IFS="-" read -r cpu vendor <<EOF
+               # shellcheck disable=SC2162
+               IFS="-" read cpu vendor <<EOF
 $basic_machine
 EOF
                ;;
@@ -1161,13 +1162,14 @@ case $cpu-$vendor in
                        | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
                        | alphapca5[67] | alpha64pca5[67] \
                        | am33_2.0 \
+                       | amdgcn \
                        | arc | arceb \
                        | arm  | arm[lb]e | arme[lb] | armv* \
                        | avr | avr32 \
                        | asmjs \
                        | ba \
                        | be32 | be64 \
-                       | bfin | bs2000 \
+                       | bfin | bpf | bs2000 \
                        | c[123]* | c30 | [cjt]90 | c4x \
                        | c8051 | clipper | craynv | csky | cydra \
                        | d10v | d30v | dlx | dsp16xx \
@@ -1182,13 +1184,13 @@ case $cpu-$vendor in
                        | le32 | le64 \
                        | lm32 \
                        | m32c | m32r | m32rle \
-                       | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k | v70 | w65 \
-                       | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip \
+                       | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
+                       | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
                        | m88110 | m88k | maxq | mb | mcore | mep | metag \
                        | microblaze | microblazeel \
                        | mips | mipsbe | mipseb | mipsel | mipsle \
                        | mips16 \
-                       | mips64 | mips64el \
+                       | mips64 | mips64eb | mips64el \
                        | mips64octeon | mips64octeonel \
                        | mips64orion | mips64orionel \
                        | mips64r5900 | mips64r5900el \
@@ -1215,11 +1217,12 @@ case $cpu-$vendor in
                        | nds32 | nds32le | nds32be \
                        | nfp \
                        | nios | nios2 | nios2eb | nios2el \
-                       | none | np1 | ns16k | ns32k \
+                       | none | np1 | ns16k | ns32k | nvptx \
                        | open8 \
                        | or1k* \
                        | or32 \
                        | orion \
+                       | picochip \
                        | pdp10 | pdp11 | pj | pjl | pn | power \
                        | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
                        | pru \
@@ -1227,7 +1230,8 @@ case $cpu-$vendor in
                        | riscv | riscv32 | riscv64 \
                        | rl78 | romp | rs6000 | rx \
                        | score \
-                       | sh | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
+                       | sh | shl \
+                       | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
                        | sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
                        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
                        | sparclite \
@@ -1237,10 +1241,11 @@ case $cpu-$vendor in
                        | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
                        | tron \
                        | ubicom32 \
-                       | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+                       | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
                        | vax \
                        | visium \
-                       | wasm32 \
+                       | w65 \
+                       | wasm32 | wasm64 \
                        | we32k \
                        | x86 | x86_64 | xc16x | xgate | xps100 \
                        | xstormy16 | xtensa* \
@@ -1338,11 +1343,11 @@ case $os in
             | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
             | sym* | kopensolaris* | plan9* \
             | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
-            | aos* | aros* | cloudabi* | sortix* \
+            | aos* | aros* | cloudabi* | sortix* | twizzler* \
             | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
             | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
             | knetbsd* | mirbsd* | netbsd* \
-            | bitrig* | openbsd* | solidbsd* | libertybsd* \
+            | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
             | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
             | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
             | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
@@ -1360,7 +1365,8 @@ case $os in
             | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
             | skyos* | haiku* | rdos* | toppers* | drops* | es* \
             | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
-            | midnightbsd*)
+            | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
+            | nsk* | powerunix* | genode*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        qnx*)
@@ -1444,9 +1450,6 @@ case $os in
        ns2)
                os=nextstep2
                ;;
-       nsk*)
-               os=nsk
-               ;;
        # Preserve the version number of sinix5.
        sinix5.*)
                os=`echo $os | sed -e 's|sinix|sysv|'`
index 86299f54ff3e3543399bc3f658fd7283730e4af8..41b6f1948014c1ef28fedcf7d19e4f539a4f1f82 100644 (file)
@@ -152,6 +152,10 @@ static int term_has_meta;
 static char *_rl_term_mm;
 static char *_rl_term_mo;
 
+/* The sequences to enter and exit standout mode. */
+static char *_rl_term_so;
+static char *_rl_term_se;
+
 /* The key sequences output by the arrow keys, if this terminal has any. */
 static char *_rl_term_ku;
 static char *_rl_term_kd;
@@ -423,6 +427,8 @@ static const struct _tc_string tc_strings[] =
   { "mo", &_rl_term_mo },
   { "nd", &_rl_term_forward_char },
   { "pc", &_rl_term_pc },
+  { "se", &_rl_term_se },
+  { "so", &_rl_term_so },
   { "up", &_rl_term_up },
   { "vb", &_rl_visible_bell },
   { "vs", &_rl_term_vs },
@@ -470,6 +476,7 @@ _rl_init_terminal_io (const char *terminal_name)
   _rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
   _rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
   _rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
+  _rl_term_so = _rl_term_se = (char *)NULL;
 #if defined(HACK_TERMCAP_MOTION)
   _rl_term_forward_char = (char *)NULL;
 #endif
@@ -534,6 +541,7 @@ _rl_init_terminal_io (const char *terminal_name)
       _rl_term_mm = _rl_term_mo = (char *)NULL;
       _rl_term_ve = _rl_term_vs = (char *)NULL;
       _rl_term_forward_char = (char *)NULL;
+      _rl_term_so = _rl_term_se = (char *)NULL;
       _rl_terminal_can_insert = term_has_meta = 0;
 
       /* Reasonable defaults for tgoto().  Readline currently only uses
@@ -554,7 +562,7 @@ _rl_init_terminal_io (const char *terminal_name)
   BC = _rl_term_backspace;
   UP = _rl_term_up;
 
-  if (!_rl_term_cr)
+  if (_rl_term_cr == 0)
     _rl_term_cr = "\r";
 
   _rl_term_autowrap = TGETFLAG ("am") && TGETFLAG ("xn");
@@ -689,6 +697,16 @@ rl_crlf (void)
   return 0;
 }
 
+void
+_rl_cr (void)
+{
+#if defined (__MSDOS__)
+  putc ('\r', rl_outstream);
+#else
+  tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
+}
+
 /* Ring the terminal bell. */
 int
 rl_ding (void)
@@ -721,6 +739,30 @@ rl_ding (void)
   return (-1);
 }
 
+/* **************************************************************** */
+/*                                                                 */
+/*             Entering and leaving terminal standout mode         */
+/*                                                                 */
+/* **************************************************************** */
+
+void
+_rl_standout_on (void)
+{
+#ifndef __MSDOS__
+  if (_rl_term_so && _rl_term_se)
+    tputs (_rl_term_so, 1, _rl_output_character_function);
+#endif
+}
+
+void
+_rl_standout_off (void)
+{
+#ifndef __MSDOS__
+  if (_rl_term_so && _rl_term_se)
+    tputs (_rl_term_se, 1, _rl_output_character_function);
+#endif
+}
+
 /* **************************************************************** */
 /*                                                                 */
 /*             Controlling the Meta Key and Keypad                 */
diff --git a/text.c b/text.c
index 7bd35d1e352a8f93b5bef67fac00bcff6e5fb828..2567dea268ae2412dda65d9c9fbd898e1ac11e86 100644 (file)
--- a/text.c
+++ b/text.c
@@ -1,6 +1,6 @@
 /* text.c -- text handling commands for readline. */
 
-/* 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.      
@@ -580,18 +580,8 @@ rl_backward_word (int count, int key)
 int
 rl_refresh_line (int ignore1, int ignore2)
 {
-  int curr_line;
-
-  curr_line = _rl_current_display_line ();
-
-  _rl_move_vert (curr_line);
-  _rl_move_cursor_relative (0, rl_line_buffer);   /* XXX is this right */
-
-  _rl_clear_to_eol (0);                /* arg of 0 means to not use spaces */
-
-  rl_redraw_prompt_last_line ();
+  _rl_refresh_line ();
   rl_display_fixed = 1;
-
   return 0;
 }
 
@@ -607,7 +597,18 @@ rl_clear_screen (int count, int key)
       return 0;
     }
 
-  _rl_clear_screen ();         /* calls termcap function to clear screen */
+  _rl_clear_screen (0);                /* calls termcap function to clear screen */
+  rl_keep_mark_active ();
+  rl_forced_update_display ();
+  rl_display_fixed = 1;
+
+  return 0;
+}
+
+int
+rl_clear_display (int count, int key)
+{
+  _rl_clear_screen (1);                /* calls termcap function to clear screen and scrollback buffer */
   rl_forced_update_display ();
   rl_display_fixed = 1;
 
@@ -1091,6 +1092,13 @@ rl_tab_insert (int count, int key)
 int
 rl_newline (int count, int key)
 {
+  if (rl_mark_active_p ())
+    {
+      rl_deactivate_mark ();
+      (*rl_redisplay_function) ();
+      _rl_want_redisplay = 0;
+    }
+
   rl_done = 1;
 
   if (_rl_history_preserve_point)
@@ -1830,7 +1838,43 @@ rl_exchange_point_and_mark (int count, int key)
       return 1;
     }
   else
-    SWAP (rl_point, rl_mark);
+    {
+      SWAP (rl_point, rl_mark);
+      rl_activate_mark ();
+    }
 
   return 0;
 }
+
+/* Active mark support */
+
+/* Is the region active? */
+static int mark_active = 0;
+
+/* Does the current command want the mark to remain active when it completes? */
+int _rl_keep_mark_active;
+
+void
+rl_keep_mark_active (void)
+{
+  _rl_keep_mark_active++;
+}
+
+void
+rl_activate_mark (void)
+{
+  mark_active = 1;
+  rl_keep_mark_active ();
+}
+
+void
+rl_deactivate_mark (void)
+{
+  mark_active = 0;
+}
+
+int
+rl_mark_active_p (void)
+{
+  return (mark_active);
+}
diff --git a/util.c b/util.c
index 577174953081bdef6f754d07f91a1717ac6577b7..1576b55d50d53cf2a61b32a879697b9a338f5647 100644 (file)
--- a/util.c
+++ b/util.c
@@ -102,6 +102,7 @@ _rl_abort_internal (void)
   rl_clear_message ();
   _rl_reset_argument ();
   rl_clear_pending_input ();
+  rl_deactivate_mark ();
 
   while (rl_executing_macro)
     _rl_pop_executing_macro ();