+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.
+
2017-08-03 Tom Tromey <tom@tromey.com>
* cli/cli-script.c (execute_user_command)
{
struct ui *ui = current_ui;
struct command_line *cmdlines;
- struct cleanup *old_chain;
enum command_control_type ret;
extern unsigned int max_user_call_depth;
/* Set the instream to 0, indicating execution of a
user-defined function. */
- old_chain = make_cleanup (do_restore_instream_cleanup, ui->instream);
- ui->instream = NULL;
+ scoped_restore restore_instream
+ = make_scoped_restore (&ui->instream, nullptr);
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
}
cmdlines = cmdlines->next;
}
- do_cleanups (old_chain);
}
/* This function is called every time GDB prints a prompt. It ensures
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. */
break;
command_handler (command);
}
-
- do_cleanups (cleanups);
}
\f
void (*pre_init_ui_hook) (void);
extern void set_verbose (char *, int, struct cmd_list_element *);
-extern void do_restore_instream_cleanup (void *stream);
-
extern char *handle_line_of_input (struct buffer *cmd_line_buffer,
char *rl, int repeat,
const char *annotation_suffix);