X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcommand.c;h=f4c76c33b32bde5d8cb9ed67f1cafad17c8ed5a3;hb=7b98b3a4f58f6dc5a8e9cbc188b627966d5e652d;hp=7e9bb7742b7fba2f76dc4769d0c14e57594ad1f1;hpb=6bc566408707e018674d1776d835c78368b6b5a3;p=pspp diff --git a/src/command.c b/src/command.c index 7e9bb7742b..f4c76c33b3 100644 --- a/src/command.c +++ b/src/command.c @@ -249,7 +249,7 @@ cmd_parse (void) /* Perform the state transition if the command completed successfully (at least in part). */ - if (result != 0) + if (result != CMD_FAILURE) { pgm_state = cp->transition[pgm_state]; @@ -565,15 +565,24 @@ cmd_execute (void) return lex_end_of_command (); } + +#define assert_not_safer() \ + do { \ + if (set_safer) \ + { \ + msg (SE, _("This command not allowed when the SAFER option is set.")); \ + return CMD_FAILURE; \ + } \ +} while(0) + + + /* Parses, performs the ERASE command. */ int cmd_erase (void) { - if (set_safer) - { - msg (SE, _("This command not allowed when the SAFER option is set.")); - return CMD_FAILURE; - } + + assert_not_safer(); lex_match_id ("ERASE"); if (!lex_force_match_id ("FILE")) @@ -589,10 +598,10 @@ cmd_erase (void) return CMD_FAILURE; } - return lex_end_of_command (); + return CMD_SUCCESS; } -#if unix +#ifdef unix /* Spawn a shell process. */ static int shell (void) @@ -700,15 +709,11 @@ cmd_host (void) { int code; - if (set_safer) - { - msg (SE, _("This command not allowed when the SAFER option is set.")); - return CMD_FAILURE; - } + assert_not_safer(); lex_match_id ("HOST"); -#if unix +#ifdef unix /* Figure out whether to invoke an interactive shell or to execute a single shell command. */ if (lex_look_ahead () == '.')