From 94ab41f950adbdbd353c376851f3198abc9736fa Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 12 Feb 2011 08:02:48 -0800 Subject: [PATCH] PRINT SPACE: When an output file is specified, don't ignore expression. When both OUTFILE= and an expression were specified on PRINT SPACE, the expression was ignored (if it was only a single token) or an error would occur (if it was was more than one token). --- src/language/data-io/print-space.c | 3 +- tests/automake.mk | 1 + tests/language/data-io/print-space.at | 93 +++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tests/language/data-io/print-space.at diff --git a/src/language/data-io/print-space.c b/src/language/data-io/print-space.c index 2fc932de..73712c0d 100644 --- a/src/language/data-io/print-space.c +++ b/src/language/data-io/print-space.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 2010, 2011 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 @@ -59,7 +59,6 @@ cmd_print_space (struct lexer *lexer, struct dataset *ds) handle = fh_parse (lexer, FH_REF_FILE); if (handle == NULL) return CMD_FAILURE; - lex_get (lexer); } else handle = NULL; diff --git a/tests/automake.mk b/tests/automake.mk index 3bb36e51..639af7e1 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -262,6 +262,7 @@ TESTSUITE_AT = \ tests/language/data-io/inpt-pgm.at \ tests/language/data-io/list.at \ tests/language/data-io/match-files.at \ + tests/language/data-io/print-space.at \ tests/language/data-io/print.at \ tests/language/data-io/save.at \ tests/language/data-io/save-translate.at \ diff --git a/tests/language/data-io/print-space.at b/tests/language/data-io/print-space.at new file mode 100644 index 00000000..e2bd2ee0 --- /dev/null +++ b/tests/language/data-io/print-space.at @@ -0,0 +1,93 @@ +AT_BANNER([PRINT SPACE]) + +AT_SETUP([PRINT SPACE without arguments]) +AT_DATA([print-space.sps], [dnl +DATA LIST NOTABLE/x 1. +BEGIN DATA. +1 +2 +END DATA. +PRINT/x. +PRINT SPACE. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print-space.sps], [0], [dnl +1 @&t@ + + + +2 @&t@ + + +]) +AT_CLEANUP + +AT_SETUP([PRINT SPACE with number]) +AT_DATA([print-space.sps], [dnl +DATA LIST NOTABLE/x 1. +BEGIN DATA. +1 +2 +END DATA. +PRINT/x. +PRINT SPACE 2. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print-space.sps], [0], [dnl +1 @&t@ + + + + + +2 @&t@ + + + + +]) +AT_CLEANUP + +AT_SETUP([PRINT SPACE to file]) +AT_CAPTURE_FILE([output.txt]) +AT_DATA([print-space.sps], [dnl +DATA LIST NOTABLE/x 1. +BEGIN DATA. +1 +2 +END DATA. +PRINT OUTFILE='output.txt'/x. +PRINT SPACE OUTFILE='output.txt'. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print-space.sps]) +AT_CHECK([cat output.txt], [0], [dnl + 1 @&t@ + @&t@ + 2 @&t@ + @&t@ +]) +AT_CLEANUP + +AT_SETUP([PRINT SPACE to file with number]) +AT_CAPTURE_FILE([output.txt]) +AT_DATA([print-space.sps], [dnl +DATA LIST NOTABLE/x 1. +BEGIN DATA. +1 +2 +END DATA. +PRINT OUTFILE='output.txt'/x. +PRINT SPACE OUTFILE='output.txt' 2. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print-space.sps]) +AT_CHECK([cat output.txt], [0], [dnl + 1 @&t@ + @&t@ + @&t@ + 2 @&t@ + @&t@ + @&t@ +]) +AT_CLEANUP -- 2.30.2