X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fcommand.c;h=1688a10eb6e3472dc5fa7e3ae0a21134827fc006;hb=68f08c4bb53fcde16035b622bdb6e9529f9cf3ae;hp=40b8505eba7753d0d247c982ec22f7d3648f99bb;hpb=cd4f5bfade86b443d1ec355c2dd8be205846b32f;p=pspp-builds.git diff --git a/src/language/command.c b/src/language/command.c index 40b8505e..1688a10e 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -39,6 +39,7 @@ #include #include #include +#include #if HAVE_SYS_WAIT_H #include @@ -169,7 +170,8 @@ cmd_parse (struct lexer *lexer, struct dataset *ds) /* Parses an entire command, from command name to terminating dot. */ static enum cmd_result -do_parse_command (struct lexer *lexer, struct dataset *ds, enum cmd_state state) +do_parse_command (struct lexer *lexer, + struct dataset *ds, enum cmd_state state) { const struct command *command; enum cmd_result result; @@ -179,38 +181,50 @@ do_parse_command (struct lexer *lexer, struct dataset *ds, enum cmd_state state) set_completion_state (state); lex_get (lexer); if (lex_token (lexer) == T_STOP) - return CMD_EOF; + { + result = CMD_EOF; + goto finish; + } else if (lex_token (lexer) == '.') { /* Null commands can result from extra empty lines. */ - return CMD_SUCCESS; + result = CMD_SUCCESS; + goto finish; } + prompt_set_style (PROMPT_LATER); /* Parse the command name. */ command = parse_command_name (lexer); if (command == NULL) - return CMD_FAILURE; + { + result = CMD_FAILURE; + goto finish; + } else if (command->function == NULL) { msg (SE, _("%s is unimplemented."), command->name); - return CMD_NOT_IMPLEMENTED; + result = CMD_NOT_IMPLEMENTED; + goto finish; } else if ((command->flags & F_TESTING) && !get_testing_mode ()) { msg (SE, _("%s may be used only in testing mode."), command->name); - return CMD_FAILURE; + result = CMD_FAILURE; + goto finish; } else if ((command->flags & F_ENHANCED) && get_syntax () != ENHANCED) { msg (SE, _("%s may be used only in enhanced syntax mode."), command->name); - return CMD_FAILURE; + result = CMD_FAILURE; + goto finish; } else if (!in_correct_state (command, state)) { report_state_mismatch (command, state); - return CMD_FAILURE; + result = CMD_FAILURE; + goto finish; } /* Execute command. */ @@ -221,6 +235,19 @@ do_parse_command (struct lexer *lexer, struct dataset *ds, enum cmd_state state) msg_set_command_name (NULL); assert (cmd_result_is_valid (result)); + + finish: + if ( cmd_result_is_failure (result)) + { + const struct source_stream *cs = lex_get_source_stream (lexer); + + if ( source_stream_current_error_mode (cs) == ERRMODE_STOP ) + { + msg (MW, _("Error encountered while ERROR=STOP is effective.")); + result = CMD_CASCADING_FAILURE; + } + } + return result; }