[binutils-gdb] reading history entries with timestamps can result in joined entries

Tom Tromey tromey@sourceware.org
Tue Jun 30 21:34:54 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c74251adf3de3f0b248802a0aeb832f4e2471f1a

commit c74251adf3de3f0b248802a0aeb832f4e2471f1a
Author: Chet Ramey <chet.ramey@case.edu>
Date:   Fri Feb 7 14:57:47 2020 -0500

    reading history entries with timestamps can result in joined entries

Diff:
---
 readline/readline/histfile.c | 15 ++++++++++++++-
 readline/readline/patchlevel |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/readline/readline/histfile.c b/readline/readline/histfile.c
index a8a92aa3604..6c3adc9bd8d 100644
--- a/readline/readline/histfile.c
+++ b/readline/readline/histfile.c
@@ -369,9 +369,11 @@ read_history_range (const char *filename, int from, int to)
     }
 
   has_timestamps = HIST_TIMESTAMP_START (buffer);
-  history_multiline_entries += has_timestamps && history_write_timestamps;  
+  history_multiline_entries += has_timestamps && history_write_timestamps;
 
   /* Skip lines until we are at FROM. */
+  if (has_timestamps)
+    last_ts = buffer;
   for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
     if (*line_end == '\n')
       {
@@ -380,7 +382,18 @@ read_history_range (const char *filename, int from, int to)
 	   line.  We should check more extensively here... */
 	if (HIST_TIMESTAMP_START(p) == 0)
 	  current_line++;
+	else
+	  last_ts = p;
 	line_start = p;
+	/* If we are at the last line (current_line == from) but we have
+	   timestamps (has_timestamps), then line_start points to the
+	   text of the last command, and we need to skip to its end. */
+	if (current_line >= from && has_timestamps)
+	  {
+	    for (line_end = p; line_end < bufend && *line_end != '\n'; line_end++)
+	      ;
+	    line_start = (*line_end == '\n') ? line_end + 1 : line_end;
+	  }
       }
 
   /* If there are lines left to gobble, then gobble them now. */
diff --git a/readline/readline/patchlevel b/readline/readline/patchlevel
index 7cbda82ded8..ce3e3556533 100644
--- a/readline/readline/patchlevel
+++ b/readline/readline/patchlevel
@@ -1,3 +1,3 @@
 # Do not edit -- exists only for use by patch
 
-2
+3


More information about the Gdb-cvs mailing list