From patchwork Sun Oct 1 04:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23271 Received: (qmail 103274 invoked by alias); 1 Oct 2017 04:07:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 102656 invoked by uid 89); 1 Oct 2017 04:07:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Oct 2017 04:07:23 +0000 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 8162B175A56 for ; Sat, 30 Sep 2017 22:07:22 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id G47K1w0172f2jeq0147Nsd; Sat, 30 Sep 2017 22:07:22 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=zDRtSZOmGiMteFvgy8wA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-0-208.hlrn.qwest.net ([75.166.0.208]:43148 helo=pokyo.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dyVWh-002l9R-SV; Sat, 30 Sep 2017 22:06:47 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 7/8] Use std::string in gdb_safe_append_history Date: Sat, 30 Sep 2017 22:06:42 -0600 Message-Id: <20171001040643.25162-8-tom@tromey.com> In-Reply-To: <20171001040643.25162-1-tom@tromey.com> References: <20171001040643.25162-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dyVWh-002l9R-SV X-Source-Sender: 75-166-0-208.hlrn.qwest.net (pokyo.Home) [75.166.0.208]:43148 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes a cleanup by using std::string in gdb_safe_append_history. 2017-09-30 Tom Tromey * top.c (gdb_safe_append_history): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/top.c | 24 ++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ad6da2d..293c796 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-09-30 Tom Tromey + * top.c (gdb_safe_append_history): Use std::string. + +2017-09-30 Tom Tromey + * event-top.c (stdin_event_handler): Update. * main.c (captured_main_1): Update. * top.h (make_delete_ui_cleanup): Remove. diff --git a/gdb/top.c b/gdb/top.c index 7efc3d5..af27fcb 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1094,19 +1094,16 @@ static void gdb_safe_append_history (void) { int ret, saved_errno; - char *local_history_filename; - struct cleanup *old_chain; - local_history_filename - = xstrprintf ("%s-gdb%ld~", history_filename, (long) getpid ()); - old_chain = make_cleanup (xfree, local_history_filename); + std::string local_history_filename + = string_printf ("%s-gdb%ld~", history_filename, (long) getpid ()); - ret = rename (history_filename, local_history_filename); + ret = rename (history_filename, local_history_filename.c_str ()); saved_errno = errno; if (ret < 0 && saved_errno != ENOENT) { warning (_("Could not rename %s to %s: %s"), - history_filename, local_history_filename, + history_filename, local_history_filename.c_str (), safe_strerror (saved_errno)); } else @@ -1122,24 +1119,23 @@ gdb_safe_append_history (void) to move it back anyway. Otherwise a global history file would never get created! */ gdb_assert (saved_errno == ENOENT); - write_history (local_history_filename); + write_history (local_history_filename.c_str ()); } else { - append_history (command_count, local_history_filename); + append_history (command_count, local_history_filename.c_str ()); if (history_is_stifled ()) - history_truncate_file (local_history_filename, history_max_entries); + history_truncate_file (local_history_filename.c_str (), + history_max_entries); } - ret = rename (local_history_filename, history_filename); + ret = rename (local_history_filename.c_str (), history_filename); saved_errno = errno; if (ret < 0 && saved_errno != EEXIST) warning (_("Could not rename %s to %s: %s"), - local_history_filename, history_filename, + local_history_filename.c_str (), history_filename, safe_strerror (saved_errno)); } - - do_cleanups (old_chain); } /* Read one line from the command input stream `instream' into a local