From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.143.51]) by sourceware.org (Postfix) with ESMTPS id 432BA3851C3C for ; Sun, 14 Jun 2020 20:16:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 432BA3851C3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway31.websitewelcome.com (Postfix) with ESMTP id BF69D20428 for ; Sun, 14 Jun 2020 15:16:26 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id kZ3Kj2e5MXGIkkZ3Kja8m4; Sun, 14 Jun 2020 15:16:26 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=JuxTuwSnG329cqz+xFblO4M20+Ki062bHPIkvC5CP6M=; b=e/qU2JGBQ1iYtRmZ8vn410t7p8 vwbRWHoRn4aRHu+kbd+E8g/tcbz1rAUlpWe2VzSnUcwlq5hBjXeLkHQGo+B2d0/yOMMt8AZch7FnU 14rT/1cwXi9E0vinUtBLKVJTR; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:47116 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jkZ3K-000aer-DH; Sun, 14 Jun 2020 14:16:26 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Chet Ramey Subject: [PATCH 3/4] reading history entries with timestamps can result in joined entries Date: Sun, 14 Jun 2020 14:16:22 -0600 Message-Id: <20200614201623.11743-4-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200614201623.11743-1-tom@tromey.com> References: <20200614201623.11743-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jkZ3K-000aer-DH X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:47116 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3036.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2020 20:16:28 -0000 From: Chet Ramey --- 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