From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 7/8] Use std::string in gdb_safe_append_history
Date: Sun, 01 Oct 2017 04:07:00 -0000 [thread overview]
Message-ID: <20171001040643.25162-8-tom@tromey.com> (raw)
In-Reply-To: <20171001040643.25162-1-tom@tromey.com>
This removes a cleanup by using std::string in
gdb_safe_append_history.
2017-09-30 Tom Tromey <tom@tromey.com>
* 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 <tom@tromey.com>
+ * top.c (gdb_safe_append_history): Use std::string.
+
+2017-09-30 Tom Tromey <tom@tromey.com>
+
* 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
--
2.9.5
next prev parent reply other threads:[~2017-10-01 4:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-01 4:06 [RFA 0/8] more cleanup removal Tom Tromey
2017-10-01 4:06 ` [RFA 8/8] Use std::string in info_symbol_command Tom Tromey
2017-10-01 4:06 ` [RFA 4/8] Remove unused declarations Tom Tromey
2017-10-01 4:06 ` [RFA 6/8] Remove make_delete_ui_cleanup Tom Tromey
2017-10-01 4:07 ` [RFA 3/8] Use std::string in utils.c Tom Tromey
2017-10-03 10:50 ` Pedro Alves
2017-10-03 11:26 ` Tom Tromey
2017-10-01 4:07 ` [RFA 5/8] Use gdb::byte_vector in load_progress Tom Tromey
2017-10-01 4:07 ` [RFA 1/8] Change record_full_gdb_operation_disable_set not to return a cleanup Tom Tromey
2017-10-01 4:07 ` Tom Tromey [this message]
2017-10-01 4:07 ` [RFA 2/8] Remove set_batch_flag_and_make_cleanup_restore_page_info Tom Tromey
2017-10-03 10:55 ` [RFA 0/8] more cleanup removal Pedro Alves
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=20171001040643.25162-8-tom@tromey.com \
--to=tom@tromey.com \
--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