]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20160108 snapshot
authorChet Ramey <chet.ramey@case.edu>
Wed, 13 Jan 2016 20:22:04 +0000 (15:22 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 13 Jan 2016 20:22:04 +0000 (15:22 -0500)
bind.c
display.c
doc/hsuser.texi
doc/rluser.texi
histexpand.c
histfile.c
history.c
history.h
isearch.c
util.c

diff --git a/bind.c b/bind.c
index f88e5aad55c10cecceacd94d5b6f5589760bff0a..77c594aa948d1d889899ee1b7f46def2db35f8aa 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -74,8 +74,13 @@ Keymap rl_binding_keymap;
 
 static int _rl_skip_to_delim PARAMS((char *, int, int));
 
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
+static void _rl_init_file_error (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+#else
+static void _rl_init_file_error ();
+#endif
+
 static char *_rl_read_file PARAMS((char *, size_t *));
-static void _rl_init_file_error PARAMS((const char *));
 static int _rl_read_init_file PARAMS((const char *, int));
 static int glean_key_from_name PARAMS((char *));
 
@@ -989,14 +994,35 @@ _rl_read_init_file (filename, include_level)
 }
 
 static void
-_rl_init_file_error (msg)
-     const char *msg;
+#if defined (PREFER_STDARG)
+_rl_init_file_error (const char *format, ...)
+#else
+_rl_init_file_error (va_alist)
+     va_dcl
+#endif
 {
+  va_list args;
+#if defined (PREFER_VARARGS)
+  char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+  va_start (args, format);
+#else
+  va_start (args);
+  format = va_arg (args, char *);
+#endif
+
+  fprintf (stderr, "readline: ");
   if (currently_reading_init_file)
-    _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
-                    current_readline_init_lineno, msg);
-  else
-    _rl_errmsg ("%s", msg);
+    fprintf (stderr, "%s: line %d: ", current_readline_init_file,
+                    current_readline_init_lineno);
+
+  vfprintf (stderr, format, args);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+
+  va_end (args);
 }
 
 /* **************************************************************** */
@@ -1216,7 +1242,7 @@ handle_parser_directive (statement)
       }
 
   /* display an error message about the unknown parser directive */
-  _rl_init_file_error ("unknown parser directive");
+  _rl_init_file_error ("%s: unknown parser directive", directive);
   return (1);
 }
 
@@ -1262,7 +1288,7 @@ rl_parse_and_bind (string)
 {
   char *funname, *kname;
   register int c, i;
-  int key, equivalency;
+  int key, equivalency, foundmod;
 
   while (string && whitespace (*string))
     string++;
@@ -1292,7 +1318,7 @@ rl_parse_and_bind (string)
       /* If we didn't find a closing quote, abort the line. */
       if (string[i] == '\0')
         {
-          _rl_init_file_error ("no closing `\"' in key binding");
+          _rl_init_file_error ("%s: no closing `\"' in key binding", string);
           return 1;
         }
       else
@@ -1449,11 +1475,24 @@ remove_trailing:
   key = glean_key_from_name (kname);
 
   /* Add in control and meta bits. */
+  foundmod = 0;
   if (substring_member_of_array (string, _rl_possible_control_prefixes))
-    key = CTRL (_rl_to_upper (key));
+    {
+      key = CTRL (_rl_to_upper (key));
+      foundmod = 1;
+    }
 
   if (substring_member_of_array (string, _rl_possible_meta_prefixes))
-    key = META (key);
+    {
+      key = META (key);
+      foundmod = 1;
+    }
+
+  if (foundmod == 0 && kname != string)
+    {
+      _rl_init_file_error ("%s: unknown key modifier", string);
+      return 1;
+    }
 
   /* Temporary.  Handle old-style keyname with macro-binding. */
   if (*funname == '\'' || *funname == '"')
@@ -1480,6 +1519,7 @@ remove_trailing:
 #endif /* PREFIX_META_HACK */
   else
     rl_bind_key (key, rl_named_function (funname));
+
   return 0;
 }
 
@@ -1681,10 +1721,14 @@ rl_variable_bind (name, value)
 
   i = find_string_var (name);
 
-  /* For the time being, unknown variable names or string names without a
-     handler function are simply ignored. */
+  /* For the time being, string names without a handler function are simply
+     ignored. */
   if (i < 0 || string_varlist[i].set_func == 0)
-    return 0;
+    {
+      if (i < 0)
+       _rl_init_file_error ("%s: unknown variable name", name);
+      return 0;
+    }
 
   v = (*string_varlist[i].set_func) (value);
   return v;
index 2ad30fce3e65aa9555604856a886c17d9638ff9e..f261933d1c23bf782496677d4e18f0b13f3a7532 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1,6 +1,6 @@
 /* display.c -- readline redisplay facility. */
 
-/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 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.
index dcd8daed9cbe103ca37c7f164ffec6f7b332db2b..c45001bfcc28ce4d77eeae45a689db5c609190ac 100644 (file)
@@ -102,7 +102,7 @@ associated with each history entry is written to the history file,
 marked with the history comment character.
 When the history file is read, lines beginning with the history
 comment character followed immediately by a digit are interpreted
-as timestamps for the previous history line.
+as timestamps for the following history entry.
 
 The builtin command @code{fc} may be used to list or edit and re-execute
 a portion of the history list.
index 6465895abf2680d28541f193a58fac48915e83f0..a8f7d45089b0e49bdf2dac1a6c4b0ff246cd1fad 100644 (file)
@@ -608,8 +608,9 @@ Acceptable @code{keymap} names are
 @code{vi-move},
 @code{vi-command}, and
 @code{vi-insert}.
-@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
-equivalent to @code{emacs-standard}.  The default value is @code{emacs}.
+@code{vi} is equivalent to @code{vi-command} (@code{vi-move} is also a
+synonym); @code{emacs} is equivalent to @code{emacs-standard}.
+The default value is @code{emacs}.
 The value of the @code{editing-mode} variable also affects the
 default keymap.
 
index fc133036493d826d436c732b06ced22551202b29..fdecebcb0e2317d5c1e04aa1b017784e340d37aa 100644 (file)
@@ -1,6 +1,6 @@
 /* histexpand.c -- history expansion. */
 
-/* Copyright (C) 1989-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
 
    This file contains the GNU History Library (History), a set of
    routines for managing the text of previously typed lines.
index 860653fbf2e0c371e000d2130882e3cae3ef336c..30d44a8a4071318d833405795f252a00e5e095fa 100644 (file)
@@ -107,9 +107,19 @@ extern int errno;
 #  define PATH_MAX     1024    /* default */
 #endif
 
+extern void _hs_append_history_line PARAMS((int, const char *));
+
+/* history file version; currently unused */
+int history_file_version = 1;
+
 /* If non-zero, we write timestamps to the history file in history_do_write() */
 int history_write_timestamps = 0;
 
+/* If non-zero, we assume that a history file that starts with a timestamp
+   uses timestamp-delimited entries and can include multi-line history
+   entries. Used by read_history_range */
+int history_multiline_entries = 0;
+
 /* Immediately after a call to read_history() or read_history_range(), this
    will return the number of lines just read from the history file in that
    call. */
@@ -259,7 +269,7 @@ read_history_range (filename, from, to)
 {
   register char *line_start, *line_end, *p;
   char *input, *buffer, *bufend, *last_ts;
-  int file, current_line, chars_read;
+  int file, current_line, chars_read, has_timestamps, reset_comment_char;
   struct stat finfo;
   size_t file_size;
 #if defined (EFBIG)
@@ -336,6 +346,19 @@ read_history_range (filename, from, to)
   bufend = buffer + chars_read;
   current_line = 0;
 
+  /* Heuristic: the history comment character rarely changes, so assume we
+     have timestamps if the buffer starts with `#[:digit:]' and temporarily
+     set history_comment_char so timestamp parsing works right */
+  reset_comment_char = 0;
+  if (history_comment_char == '\0' && buffer[0] == '#' && isdigit ((unsigned char)buffer[1]))
+    {
+      history_comment_char = '#';
+      reset_comment_char = 1;
+    }
+
+  has_timestamps = HIST_TIMESTAMP_START (buffer);
+  history_multiline_entries += has_timestamps && history_write_timestamps;  
+
   /* Skip lines until we are at FROM. */
   for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
     if (*line_end == '\n')
@@ -362,7 +385,10 @@ read_history_range (filename, from, to)
          {
            if (HIST_TIMESTAMP_START(line_start) == 0)
              {
-               add_history (line_start);
+               if (last_ts == NULL && history_multiline_entries)
+                 _hs_append_history_line (history_length - 1, line_start);
+               else
+                 add_history (line_start);
                if (last_ts)
                  {
                    add_history_time (last_ts);
@@ -385,6 +411,8 @@ read_history_range (filename, from, to)
       }
 
   history_lines_read_from_file = current_line;
+  if (reset_comment_char)
+    history_comment_char = '\0';
 
   FREE (input);
 #ifndef HISTORY_USE_MMAP
index 216b2a56c98d13f38b8c09a597e4ffdacb45a861..3b8dbc58651756f353ff10d34c54005146d6afe2 100644 (file)
--- a/history.c
+++ b/history.c
@@ -1,6 +1,6 @@
 /* history.c -- standalone history library */
 
-/* Copyright (C) 1989-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
 
    This file contains the GNU History Library (History), a set of
    routines for managing the text of previously typed lines.
@@ -407,6 +407,30 @@ replace_history_entry (which, line, data)
   return (old_value);
 }
 
+/* Append LINE to the history line at offset WHICH, adding a newline to the
+   end of the current line first.  This can be used to construct multi-line
+   history entries while reading lines from the history file. */
+void
+_hs_append_history_line (which, line)
+     int which;
+     const char *line;
+{
+  HIST_ENTRY *hent;
+  size_t newlen, curlen;
+  char *newline;
+
+  hent = the_history[which];
+  curlen = strlen (hent->line);
+  newlen = curlen + strlen (line) + 2;
+  newline = realloc (hent->line, newlen);
+  if (newline)
+    {
+      hent->line = newline;
+      hent->line[curlen++] = '\n';
+      strcpy (hent->line + curlen, line);
+    }
+}
+
 /* Replace the DATA in the specified history entries, replacing OLD with
    NEW.  WHICH says which one(s) to replace:  WHICH == -1 means to replace
    all of the history entries where entry->data == OLD; WHICH == -2 means
index b79e51f4c20f8bdae45dc0a4b7cd0dee0a93fdd6..8ce7c805d168f88e77e6d7be14aaea6ada69e981 100644 (file)
--- a/history.h
+++ b/history.h
@@ -1,6 +1,6 @@
 /* history.h -- the names of functions that you can call in history. */
 
-/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
 
    This file contains the GNU History Library (History), a set of
    routines for managing the text of previously typed lines.
@@ -263,6 +263,10 @@ extern int history_quotes_inhibit_expansion;
 
 extern int history_write_timestamps;
 
+/* These two are undocumented; the second is reserved for future use */
+extern int history_multiline_entries;
+extern int history_file_version;
+
 /* Backwards compatibility */
 extern int max_input_history;
 
index 0eb5259cbeba103a60332cbbd4d4778a12d338d4..819fcbce45fc22bb37495604e762317cf133c2c3 100644 (file)
--- a/isearch.c
+++ b/isearch.c
@@ -6,7 +6,7 @@
 /*                                                                 */
 /* **************************************************************** */
 
-/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 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.      
diff --git a/util.c b/util.c
index aec4af5f7356ea4f06c76663a91f8cc9c8d29938..4589c61f94e490f60440a18ffa7fd1fccf9839fb 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,6 +1,6 @@
 /* util.c -- readline utility functions */
 
-/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 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.