X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcommand.c;h=b386317a2c1052f07617f51f48ef022328b73339;hb=3fb94e235e0333e200332a72dca42b3f300667ad;hp=4afe70be1130a96af955f2627cbe7724e516244e;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp diff --git a/src/command.c b/src/command.c index 4afe70be11..b386317a2c 100644 --- a/src/command.c +++ b/src/command.c @@ -17,24 +17,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* AIX requires this to be the first thing in the file. */ #include -#if __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX -#pragma alloca -#else -#ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -#endif -#endif -#endif -#endif - #include #include "command.h" #include @@ -266,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]; @@ -578,19 +561,28 @@ int cmd_execute (void) { lex_match_id ("EXECUTE"); - procedure (NULL, NULL, NULL); + procedure (NULL, NULL, NULL, NULL); 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")) @@ -606,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) @@ -717,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 () == '.')