lexer: Rename LEX_ERROR_INTERACTIVE to LEX_ERROR_TERMINAL, change default 20130816030502/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 16 Aug 2013 05:35:19 +0000 (22:35 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 16 Aug 2013 05:39:34 +0000 (22:39 -0700)
The LEX_ERROR_INTERACTIVE error handling mode really only makes sense for
reading from a terminal, where we know we're getting one line at a time
and not partial lines.  Unfortunately LEX_ERROR_INTERACTIVE was the default
and it was getting used as such in the GUI for reading from syntax files.
This meant that if there was an error in the GUI then the current buffer
(which might be any arbitrary chunk of syntax) was being discarded, which
caused terrible confusion.

This commit changes the default to LEX_ERROR_CONTINUE, which works
in a reasonable fashion regardless of the input source.  It also renames
LEX_ERROR_INTERACTIVE to LEX_ERROR_TERMINAL to make it clear that that's
the only reasonable use.

Reported by Thambu David <thambu@cmcvellore.ac.in>, archived at:
http://lists.gnu.org/archive/html/pspp-users/2013-08/msg00019.html

NEWS
src/language/data-io/inpt-pgm.c
src/language/lexer/lexer.c
src/language/lexer/lexer.h
src/ui/terminal/main.c
src/ui/terminal/terminal-reader.c

diff --git a/NEWS b/NEWS
index 92226aa72358b218d8e01debbdcafe13ecb8f4b1..c522d1871dafaf927a7bd66f90b593be9b981556 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,16 +6,19 @@ Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
 
 Changes after 0.8.0:
 
- * Notable bug fixes:
-
-   - System files written by IBM SPSS 21 are now read without warnings.
-
  * PSPPIRE graphical user interface improvements:
 
    - Syntax windows now parse syntax in "auto" mode, which in practice
      should mean that both "batch" and "interactive" syntax now works,
      instead of just "interactive" syntax.
 
+ * Notable bug fixes:
+
+   - System files written by IBM SPSS 21 are now read without warnings.
+
+   - PSPPIRE should now more gracefully handle syntax files that contain
+     errors.
+
 Changes from 0.6.2 to 0.8.0:
 
  * New commands:
index a500df4117130f4ae0ce808b3a1ccd6a209f8b28..0301d7d057aa77ca000a36abc51937ab638d982e 100644 (file)
@@ -127,7 +127,7 @@ cmd_input_program (struct lexer *lexer, struct dataset *ds)
 
         default:
           if (cmd_result_is_failure (result)
-              && lex_get_error_mode (lexer) != LEX_ERROR_INTERACTIVE)
+              && lex_get_error_mode (lexer) != LEX_ERROR_TERMINAL)
             {
               if (result == CMD_EOF)
                 msg (SE, _("Unexpected end-of-file within INPUT PROGRAM."));
index 61676bb717e21f542c3c8a981e7eb7106cc324d3..bbe16cbe17a2c02305f631e8a04cfed5355a805b 100644 (file)
@@ -129,7 +129,7 @@ lex_reader_init (struct lex_reader *reader,
 {
   reader->class = class;
   reader->syntax = LEX_SYNTAX_AUTO;
-  reader->error = LEX_ERROR_INTERACTIVE;
+  reader->error = LEX_ERROR_CONTINUE;
   reader->file_name = NULL;
   reader->line_number = 0;
 }
@@ -1053,7 +1053,7 @@ lex_get_syntax_mode (const struct lexer *lexer)
 }
 
 /* Returns the error mode for the syntax file from which the current drawn is
-   drawn.  Returns LEX_ERROR_INTERACTIVE for a T_STOP token or if the command's
+   drawn.  Returns LEX_ERROR_TERMINAL for a T_STOP token or if the command's
    source does not have line numbers.
 
    There is no version of this function that takes an N argument because
@@ -1063,13 +1063,12 @@ enum lex_error_mode
 lex_get_error_mode (const struct lexer *lexer)
 {
   struct lex_source *src = lex_source__ (lexer);
-  return src == NULL ? LEX_ERROR_INTERACTIVE : src->reader->error;
+  return src == NULL ? LEX_ERROR_TERMINAL : src->reader->error;
 }
 
 /* If the source that LEXER is currently reading has error mode
-   LEX_ERROR_INTERACTIVE, discards all buffered input and tokens, so that the
-   next token to be read comes directly from whatever is next read from the
-   stream.
+   LEX_ERROR_TERMINAL, discards all buffered input and tokens, so that the next
+   token to be read comes directly from whatever is next read from the stream.
 
    It makes sense to call this function after encountering an error in a
    command entered on the console, because usually the user would prefer not to
@@ -1078,7 +1077,7 @@ void
 lex_interactive_reset (struct lexer *lexer)
 {
   struct lex_source *src = lex_source__ (lexer);
-  if (src != NULL && src->reader->error == LEX_ERROR_INTERACTIVE)
+  if (src != NULL && src->reader->error == LEX_ERROR_TERMINAL)
     {
       src->head = src->tail = 0;
       src->journal_pos = src->seg_pos = src->line_pos = 0;
@@ -1100,7 +1099,7 @@ lex_discard_rest_of_command (struct lexer *lexer)
 }
 
 /* Discards all lookahead tokens in LEXER, then discards all input sources
-   until it encounters one with error mode LEX_ERROR_INTERACTIVE or until it
+   until it encounters one with error mode LEX_ERROR_TERMINAL or until it
    runs out of input sources. */
 void
 lex_discard_noninteractive (struct lexer *lexer)
@@ -1112,7 +1111,7 @@ lex_discard_noninteractive (struct lexer *lexer)
       while (!deque_is_empty (&src->deque))
         lex_source_pop__ (src);
 
-      for (; src != NULL && src->reader->error != LEX_ERROR_INTERACTIVE;
+      for (; src != NULL && src->reader->error != LEX_ERROR_TERMINAL;
            src = lex_source__ (lexer))
         lex_source_destroy (src);
     }
index a6be161fe100ceb5919871b05601f1efd2e03e2f..87b1e2e7233e624487a8f3d97111990d68c2919b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2010, 2011, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ enum lex_syntax_mode
 /* Handling of errors. */
 enum lex_error_mode
   {
-    LEX_ERROR_INTERACTIVE,     /* Always continue to next command. */
+    LEX_ERROR_TERMINAL,        /* Discard input line and continue reading. */
     LEX_ERROR_CONTINUE,        /* Continue to next command, except for
                                   cascading failures. */
     LEX_ERROR_STOP             /* Stop processing. */
index 6e573d5cca90bd770e0eac4e33a24ccc1a7cf530..c30b5f85bc02bd82259ce8aeadb6e7910ea6af02 100644 (file)
@@ -147,7 +147,7 @@ main (int argc, char **argv)
               lex_discard_noninteractive (lexer);
             }
           else if (result == CMD_CASCADING_FAILURE
-                   && lex_get_error_mode (lexer) != LEX_ERROR_INTERACTIVE)
+                   && lex_get_error_mode (lexer) != LEX_ERROR_TERMINAL)
             {
               msg (SE, _("Stopping syntax file processing here to avoid "
                          "a cascade of dependent command failures."));
index a3f33e725589a005f4b4d92a115d119e327614b4..43f3b92f673dd281bc5746c688bbb759f2a2e2e1 100644 (file)
@@ -177,7 +177,7 @@ terminal_reader_create (void)
   r = xzalloc (sizeof *r);
   r->reader.class = &terminal_reader_class;
   r->reader.syntax = LEX_SYNTAX_INTERACTIVE;
-  r->reader.error = LEX_ERROR_INTERACTIVE;
+  r->reader.error = LEX_ERROR_TERMINAL;
   r->reader.file_name = NULL;
   r->s = ss_empty ();
   r->offset = 0;