Use a scoped_restore for command_nest_depth
authorTom Tromey <tom@tromey.com>
Mon, 1 May 2017 03:15:58 +0000 (21:15 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 3 Aug 2017 13:59:05 +0000 (07:59 -0600)
This changes a couple of places to use a scoped_restore when
manipulating command_nest_depth.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (execute_user_command)
(execute_control_command): Use scoped_restore.

gdb/ChangeLog
gdb/cli/cli-script.c

index be5fd55e4ce74b6f29604305e6a46b501c7ba8c6..9337365973522fab7b9a8649f28d921ae4a745d1 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-03  Tom Tromey  <tom@tromey.com>
+
+       * cli/cli-script.c (execute_user_command)
+       (execute_control_command): Use scoped_restore.
+
 2017-08-03  Tom Tromey  <tom@tromey.com>
 
        * cli/cli-script.c (do_restore_user_call_depth): Remove.
index 36aa371d55dfc62979886a480ffd32c054c1db85..d8dfbfc097148792ab0733185816bc66720b9c3c 100644 (file)
@@ -398,7 +398,8 @@ execute_user_command (struct cmd_list_element *c, char *args)
 
   scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
 
-  command_nest_depth++;
+  scoped_restore save_nesting
+    = make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
   while (cmdlines)
     {
       ret = execute_control_command (cmdlines);
@@ -409,7 +410,6 @@ execute_user_command (struct cmd_list_element *c, char *args)
        }
       cmdlines = cmdlines->next;
     }
-  command_nest_depth--;
   do_cleanups (old_chain);
 }
 
@@ -529,9 +529,9 @@ execute_control_command (struct command_line *cmd)
            current = *cmd->body_list;
            while (current)
              {
-               command_nest_depth++;
+               scoped_restore save_nesting
+                 = make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
                ret = execute_control_command (current);
-               command_nest_depth--;
 
                /* If we got an error, or a "break" command, then stop
                   looping.  */
@@ -588,9 +588,9 @@ execute_control_command (struct command_line *cmd)
        /* Execute commands in the given arm.  */
        while (current)
          {
-           command_nest_depth++;
+           scoped_restore save_nesting
+             = make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
            ret = execute_control_command (current);
-           command_nest_depth--;
 
            /* If we got an error, get out.  */
            if (ret != simple_control)
This page took 0.031407 seconds and 4 git commands to generate.