X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Flexer%2Flexer.c;h=4cb3f593095f5c9f4c18d82a0e54a53ccbfbb0b0;hb=0e614c6c80612cdd413ffc3a8bdb2619ba5a8a7d;hp=3d2e29ac92aac6ca2bfd51aa9edfd1caccae7753;hpb=b990f5c31bc831e588a86f9f4826387c6843c989;p=pspp diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index 3d2e29ac92..4cb3f59309 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -451,7 +451,7 @@ lex_end_of_command (void) if (token != '.') { lex_error (_("expecting end of command")); - return CMD_TRAILING_GARBAGE; + return CMD_FAILURE; } else return CMD_SUCCESS; @@ -736,6 +736,25 @@ lex_set_prog (char *p) { prog = p; } + +/* Discards the rest of the current command. + When we're reading commands from a file, we skip tokens until + a terminal dot or EOF. + When we're reading commands interactively from the user, + that's just discarding the current line, because presumably + the user doesn't want to finish typing a command that will be + ignored anyway. */ +void +lex_discard_rest_of_command (void) +{ + if (!getl_is_interactive ()) + { + while (token != T_STOP && token != '.') + lex_get (); + } + else + lex_discard_line (); +} /* Weird line reading functions. */