From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Chet Ramey <chet.ramey@case.edu>
Subject: [PATCH 3/4] reading history entries with timestamps can result in joined entries
Date: Sun, 14 Jun 2020 14:16:22 -0600 [thread overview]
Message-ID: <20200614201623.11743-4-tom@tromey.com> (raw)
In-Reply-To: <20200614201623.11743-1-tom@tromey.com>
From: Chet Ramey <chet.ramey@case.edu>
---
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
--
2.17.2
next prev parent reply other threads:[~2020-06-14 20:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 20:16 [PATCH 0/4] Import readline 8.0 patches Tom Tromey
2020-06-14 20:16 ` [PATCH 1/4] Readline-8.0 patch 1: fix file descriptor leak with zero-length history file Tom Tromey
2020-06-14 20:16 ` [PATCH 2/4] fix problems moving back beyond start of history Tom Tromey
2020-06-14 20:16 ` Tom Tromey [this message]
2020-06-14 20:16 ` [PATCH 4/4] problems restoring the history file are not signaled correctly to the calling application Tom Tromey
2020-06-15 18:21 ` [PATCH 0/4] Import readline 8.0 patches Christian Biesinger
2020-06-30 21:19 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200614201623.11743-4-tom@tromey.com \
--to=tom@tromey.com \
--cc=chet.ramey@case.edu \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).