X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flexer.c;h=df48d4eca5499c5fbaf82cfd8b2ba6ea70a4c586;hb=2cc5c881d3bf3effeb07bc9e3aef958975a17b27;hp=91712bf2650552f61ababddfde500d89f0cac435;hpb=74a57f26f1458b28a0fddbb9f46004ac8f4d9c30;p=pspp-builds.git diff --git a/src/lexer.c b/src/lexer.c index 91712bf2..df48d4ec 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -19,7 +19,7 @@ #include #include "lexer.h" -#include +#include "error.h" #include #include #include @@ -71,7 +71,7 @@ static char *prog; /* Nonzero only if this line ends with a terminal dot. */ static int dot; -/* Nonzero only if the last token returned was T_EOF. */ +/* Nonzero only if the last token returned was T_STOP. */ static int eof; /* If nonzero, next token returned by lex_get(). @@ -696,32 +696,23 @@ lex_put_back_id (const char *id) /* Weird line processing functions. */ -/* Discards the rest of the current input line for tokenization - purposes, but returns the entire contents of the line for use by - the caller. */ -char * +/* Returns the entire contents of the current line. */ +const char * lex_entire_line (void) { - prog = ds_end (&getl_buf); - dot = 0; return ds_value (&getl_buf); } /* As lex_entire_line(), but only returns the part of the current line that hasn't already been tokenized. - If HAD_DOT is non-null, stores nonzero into *HAD_DOT if the line + If END_DOT is non-null, stores nonzero into *END_DOT if the line ends with a terminal dot, or zero if it doesn't. */ -char * -lex_rest_of_line (int *had_dot) +const char * +lex_rest_of_line (int *end_dot) { - char *s = prog; - prog = ds_end (&getl_buf); - - if (had_dot) - *had_dot = dot; - dot = 0; - - return s; + if (end_dot) + *end_dot = dot; + return prog; } /* Causes the rest of the current input line to be ignored for @@ -729,10 +720,7 @@ lex_rest_of_line (int *had_dot) void lex_discard_line (void) { - msg (SW, _("The rest of this command has been discarded.")); - - ds_clear (&getl_buf); - prog = ds_value (&getl_buf); + prog = ds_end (&getl_buf); dot = put_token = 0; } @@ -980,7 +968,13 @@ lex_skip_comment (void) { for (;;) { - lex_get_line (); + if (!lex_get_line ()) + { + put_token = T_STOP; + eof = 1; + return; + } + if (put_token == '.') break;