More uses of scoped_restore
There were a few more places in gdb that could easily use scoped_restore, replacing some cleanups. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * reverse.c (exec_direction_default): Remove. (exec_reverse_once): Use scoped_restore. * remote.c (restore_remote_timeout): Remove. (remote_flash_erase, remote_flash_write, remote_flash_done) (readchar, remote_serial_write): Use scoped_restore. * cli/cli-script.c (struct source_cleanup_lines_args) (source_cleanup_lines): Remove. (script_from_file): Use scoped_restore. * cli/cli-cmds.c (source_verbose_cleanup): Remove. (source_command): Use scoped_restore.
This commit is contained in:
parent
b3bc84537b
commit
2ec845e758
5 changed files with 56 additions and 115 deletions
|
@ -645,26 +645,14 @@ source_script (const char *file, int from_tty)
|
|||
source_script_with_search (file, from_tty, 0);
|
||||
}
|
||||
|
||||
/* Return the source_verbose global variable to its previous state
|
||||
on exit from the source command, by whatever means. */
|
||||
static void
|
||||
source_verbose_cleanup (void *old_value)
|
||||
{
|
||||
source_verbose = *(int *)old_value;
|
||||
xfree (old_value);
|
||||
}
|
||||
|
||||
static void
|
||||
source_command (char *args, int from_tty)
|
||||
{
|
||||
struct cleanup *old_cleanups;
|
||||
char *file = args;
|
||||
int *old_source_verbose = XNEW (int);
|
||||
int search_path = 0;
|
||||
|
||||
*old_source_verbose = source_verbose;
|
||||
old_cleanups = make_cleanup (source_verbose_cleanup,
|
||||
old_source_verbose);
|
||||
scoped_restore save_source_verbose = make_scoped_restore (&source_verbose);
|
||||
|
||||
/* -v causes the source command to run in verbose mode.
|
||||
-s causes the file to be searched in the source search path,
|
||||
|
@ -705,8 +693,6 @@ source_command (char *args, int from_tty)
|
|||
}
|
||||
|
||||
source_script_with_search (file, from_tty, search_path);
|
||||
|
||||
do_cleanups (old_cleanups);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue