aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-30 21:17:58 -0600
committerTom Tromey <tom@tromey.com>2017-08-03 07:59:06 -0600
commit3c9ebddd93ffb8b44b8cc69f3be9db08c861368e (patch)
tree3f182a582c64e9464dbda668189714e76252d2c4 /gdb/top.c
parentb51b225eb9b03b627967108ee3de38ada5de219d (diff)
downloadgdb-3c9ebddd93ffb8b44b8cc69f3be9db08c861368e.zip
gdb-3c9ebddd93ffb8b44b8cc69f3be9db08c861368e.tar.gz
gdb-3c9ebddd93ffb8b44b8cc69f3be9db08c861368e.tar.bz2
Replace do_restore_instream_cleanup with scoped_restore
This changes the users of do_restore_instream_cleanup to use a scoped_restore instead. This patch is broken out because it warrants some additional attention: in particular it's unclear to me whether current_ui can change in the body of these functions -- but if it can, then the cleanup would have modified a different UI's instream member. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * top.h (do_restore_instream_cleanup): Remove. * top.c (do_restore_instream_cleanup): Remove. (read_command_file): Use scoped_restore. * cli/cli-script.c (execute_user_command): Use scoped_restore.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 43bf0d4..6b00c6e 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -444,27 +444,14 @@ quit_cover (void)
event-top.c into this file, top.c. */
/* static */ const char *source_file_name;
-/* Clean up on error during a "source" command (or execution of a
- user-defined command). */
-
-void
-do_restore_instream_cleanup (void *stream)
-{
- struct ui *ui = current_ui;
-
- /* Restore the previous input stream. */
- ui->instream = (FILE *) stream;
-}
-
/* Read commands from STREAM. */
void
read_command_file (FILE *stream)
{
struct ui *ui = current_ui;
- struct cleanup *cleanups;
- cleanups = make_cleanup (do_restore_instream_cleanup, ui->instream);
- ui->instream = stream;
+ scoped_restore save_instream
+ = make_scoped_restore (&ui->instream, stream);
/* Read commands from `instream' and execute them until end of file
or error reading instream. */
@@ -479,8 +466,6 @@ read_command_file (FILE *stream)
break;
command_handler (command);
}
-
- do_cleanups (cleanups);
}
void (*pre_init_ui_hook) (void);