command: Fix delayed execution of FINISH.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 8 Dec 2014 06:34:21 +0000 (22:34 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 8 Dec 2014 06:34:21 +0000 (22:34 -0800)
PSPP delayed the execution of FINISH until it read the first token
of the next command.  This commit changes it to execute immediately,
as one would expect..

Reported by Daniel Schlieper.
Bug #43766.

src/language/command.c
tests/language/command.at

index 76377035886b26e97dae5ad0222e660e91c411ef..788759113136e6e7570b4ebcfeb00eb9e8427526 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013, 2014 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
@@ -242,8 +242,9 @@ finish:
     result = lex_end_of_command (lexer);
 
   lex_discard_rest_of_command (lexer);
-  while (lex_token (lexer) == T_ENDCMD)
-    lex_get (lexer);
+  if (result != CMD_EOF && result != CMD_FINISH)
+    while (lex_token (lexer) == T_ENDCMD)
+      lex_get (lexer);
 
   if (opened)
     text_item_submit (text_item_create (TEXT_ITEM_COMMAND_CLOSE,
index 8d65b6fb8c2998bd14a27ee8d5f4d9f9b2174587..ae91558ce14965b19950150da347153a390d8b90 100644 (file)
@@ -13,6 +13,14 @@ command.sps:2: error: EXECUTE: EXECUTE is allowed only after the active dataset
 ])
 AT_CLEANUP
 
+dnl Tests for a bug where FINISH or EXIT wasn't executed until the lexer
+dnl read the first token of the next command.
+dnl
+dnl (If this reecurs, the the test will run forever.)
+AT_SETUP([FINISH executes immediately])
+AT_CHECK([(echo "FINISH."; while :; do echo; done) | pspp])
+AT_CLEANUP
+
 AT_BANNER([ERASE])
 
 AT_SETUP([ERASE -- safer mode])