diff options
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r-- | gdb/cli/cli-script.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index ab69ca49980..ca0c14f043b 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -36,9 +36,6 @@ /* Prototypes for local functions */ -static struct cleanup * - make_cleanup_free_command_lines (struct command_line **arg); - static enum command_control_type recurse_read_control_structure (struct command_line *current_cmd); @@ -255,7 +252,7 @@ do_restore_user_call_depth (void * call_depth) void execute_user_command (struct cmd_list_element *c, char *args) { - register struct command_line *cmdlines; + struct command_line *cmdlines; struct cleanup *old_chain; enum command_control_type ret; static int user_call_depth = 0; @@ -297,21 +294,25 @@ execute_control_command (struct command_line *cmd) { struct expression *expr; struct command_line *current; - struct cleanup *old_chain = 0; + struct cleanup *old_chain = make_cleanup (null_cleanup, 0); struct value *val; struct value *val_mark; int loop; enum command_control_type ret; char *new_line; + /* Start by assuming failure, if a problem is detected, the code + below will simply "break" out of the switch. */ + ret = invalid_control; + switch (cmd->control_type) { case simple_control: /* A simple command, execute it and return. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); execute_command (new_line, 0); ret = cmd->control_type; break; @@ -328,8 +329,8 @@ execute_control_command (struct command_line *cmd) /* Parse the loop control expression for the while statement. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -388,8 +389,8 @@ execute_control_command (struct command_line *cmd) { new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); /* Parse the conditional for the if statement. */ expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -427,11 +428,10 @@ execute_control_command (struct command_line *cmd) default: warning ("Invalid control type in command structure."); - return invalid_control; + break; } - if (old_chain) - do_cleanups (old_chain); + do_cleanups (old_chain); return ret; } @@ -974,8 +974,8 @@ read_command_lines (char *prompt_arg, int from_tty) void free_command_lines (struct command_line **lptr) { - register struct command_line *l = *lptr; - register struct command_line *next; + struct command_line *l = *lptr; + struct command_line *next; struct command_line **blist; int i; @@ -1001,7 +1001,7 @@ do_free_command_lines_cleanup (void *arg) free_command_lines (arg); } -static struct cleanup * +struct cleanup * make_cleanup_free_command_lines (struct command_line **arg) { return make_cleanup (do_free_command_lines_cleanup, arg); @@ -1040,7 +1040,7 @@ copy_command_lines (struct command_line *cmds) static void validate_comname (char *comname) { - register char *p; + char *p; if (comname == 0) error_no_arg ("name of command to define"); @@ -1070,8 +1070,8 @@ define_command (char *comname, int from_tty) CMD_PRE_HOOK, CMD_POST_HOOK }; - register struct command_line *cmds; - register struct cmd_list_element *c, *newc, *oldc, *hookc = 0; + struct command_line *cmds; + struct cmd_list_element *c, *newc, *oldc, *hookc = 0; char *tem = comname; char *tem2; char tmpbuf[MAX_TMPBUF]; @@ -1176,7 +1176,7 @@ void document_command (char *comname, int from_tty) { struct command_line *doclines; - register struct cmd_list_element *c; + struct cmd_list_element *c; char *tem = comname; char tmpbuf[128]; @@ -1194,8 +1194,8 @@ document_command (char *comname, int from_tty) xfree (c->doc); { - register struct command_line *cl1; - register int len = 0; + struct command_line *cl1; + int len = 0; for (cl1 = doclines; cl1; cl1 = cl1->next) len += strlen (cl1->line) + 1; @@ -1233,7 +1233,6 @@ source_cleanup_lines (void *args) error_pre_print = p->old_error_pre_print; } -/* ARGSUSED */ static void do_fclose_cleanup (void *stream) { @@ -1290,7 +1289,7 @@ script_from_file (FILE *stream, char *file) void show_user_1 (struct cmd_list_element *c, struct ui_file *stream) { - register struct command_line *cmdlines; + struct command_line *cmdlines; cmdlines = c->user_commands; if (!cmdlines) |