Use std::string in gdb_safe_append_history
This removes a cleanup by using std::string in gdb_safe_append_history. 2017-10-03 Tom Tromey <tom@tromey.com> * top.c (gdb_safe_append_history): Use std::string.
This commit is contained in:
parent
895b8f306b
commit
8cff8730f4
|
@ -1,3 +1,7 @@
|
||||||
|
2017-10-03 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* top.c (gdb_safe_append_history): Use std::string.
|
||||||
|
|
||||||
2017-10-03 Tom Tromey <tom@tromey.com>
|
2017-10-03 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* event-top.c (stdin_event_handler): Update.
|
* event-top.c (stdin_event_handler): Update.
|
||||||
|
|
24
gdb/top.c
24
gdb/top.c
|
@ -1094,19 +1094,16 @@ static void
|
||||||
gdb_safe_append_history (void)
|
gdb_safe_append_history (void)
|
||||||
{
|
{
|
||||||
int ret, saved_errno;
|
int ret, saved_errno;
|
||||||
char *local_history_filename;
|
|
||||||
struct cleanup *old_chain;
|
|
||||||
|
|
||||||
local_history_filename
|
std::string local_history_filename
|
||||||
= xstrprintf ("%s-gdb%ld~", history_filename, (long) getpid ());
|
= string_printf ("%s-gdb%ld~", history_filename, (long) getpid ());
|
||||||
old_chain = make_cleanup (xfree, local_history_filename);
|
|
||||||
|
|
||||||
ret = rename (history_filename, local_history_filename);
|
ret = rename (history_filename, local_history_filename.c_str ());
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
if (ret < 0 && saved_errno != ENOENT)
|
if (ret < 0 && saved_errno != ENOENT)
|
||||||
{
|
{
|
||||||
warning (_("Could not rename %s to %s: %s"),
|
warning (_("Could not rename %s to %s: %s"),
|
||||||
history_filename, local_history_filename,
|
history_filename, local_history_filename.c_str (),
|
||||||
safe_strerror (saved_errno));
|
safe_strerror (saved_errno));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1122,24 +1119,23 @@ gdb_safe_append_history (void)
|
||||||
to move it back anyway. Otherwise a global history file would
|
to move it back anyway. Otherwise a global history file would
|
||||||
never get created! */
|
never get created! */
|
||||||
gdb_assert (saved_errno == ENOENT);
|
gdb_assert (saved_errno == ENOENT);
|
||||||
write_history (local_history_filename);
|
write_history (local_history_filename.c_str ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
append_history (command_count, local_history_filename);
|
append_history (command_count, local_history_filename.c_str ());
|
||||||
if (history_is_stifled ())
|
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;
|
saved_errno = errno;
|
||||||
if (ret < 0 && saved_errno != EEXIST)
|
if (ret < 0 && saved_errno != EEXIST)
|
||||||
warning (_("Could not rename %s to %s: %s"),
|
warning (_("Could not rename %s to %s: %s"),
|
||||||
local_history_filename, history_filename,
|
local_history_filename.c_str (), history_filename,
|
||||||
safe_strerror (saved_errno));
|
safe_strerror (saved_errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanups (old_chain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one line from the command input stream `instream' into a local
|
/* Read one line from the command input stream `instream' into a local
|
||||||
|
|
Loading…
Reference in New Issue