+2018-05-25 Tom Tromey <tom@tromey.com>
+
+ * cli/cli-interp.c (safe_execute_command): Use scoped_restore.
+ * interps.c (interp_exec): Use scoped_restore.
+
2018-05-25 Tom Tromey <tom@tromey.com>
* remote.c (remote_target::remote_file_get): Use
int from_tty)
{
struct gdb_exception e = exception_none;
- struct ui_out *saved_uiout;
/* Save and override the global ``struct ui_out'' builder. */
- saved_uiout = current_uiout;
- current_uiout = command_uiout;
+ scoped_restore saved_uiout = make_scoped_restore (¤t_uiout,
+ command_uiout);
TRY
{
}
END_CATCH
- /* Restore the global builder. */
- current_uiout = saved_uiout;
-
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
caller should print the exception. */
exception_print (gdb_stderr, e);
{
struct ui_interp_info *ui_interp = get_current_interp_info ();
- struct gdb_exception ex;
- struct interp *save_command_interp;
-
/* See `command_interp' for why we do this. */
- save_command_interp = ui_interp->command_interpreter;
- ui_interp->command_interpreter = interp;
-
- ex = interp->exec (command_str);
-
- ui_interp->command_interpreter = save_command_interp;
+ scoped_restore save_command_interp
+ = make_scoped_restore (&ui_interp->command_interpreter, interp);
- return ex;
+ return interp->exec (command_str);
}
/* A convenience routine that nulls out all the common command hooks.