]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - lib/readline/history.c
bash-4.4 rc1 release
[thirdparty/bash.git] / lib / readline / history.c
index 216b2a56c98d13f38b8c09a597e4ffdacb45a861..3b8dbc58651756f353ff10d34c54005146d6afe2 100644 (file)
@@ -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