From: Ben Pfaff Date: Mon, 8 Dec 2014 06:34:21 +0000 (-0800) Subject: command: Fix delayed execution of FINISH. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=bde476f0e660baabf9a409b600edf864750f10b4 command: Fix delayed execution of FINISH. 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. --- diff --git a/src/language/command.c b/src/language/command.c index 7637703588..7887591131 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -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, diff --git a/tests/language/command.at b/tests/language/command.at index 8d65b6fb8c..ae91558ce1 100644 --- a/tests/language/command.at +++ b/tests/language/command.at @@ -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])