PRINT SPACE: When an output file is specified, don't ignore expression.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 12 Feb 2011 16:02:48 +0000 (08:02 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 12 Feb 2011 16:02:48 +0000 (08:02 -0800)
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
tests/automake.mk
tests/language/data-io/print-space.at [new file with mode: 0644]

index 2fc932de4ea46f9576ee81dca277610afcd9675f..73712c0d322db368ca5d7dc0f831bc4b122b437f 100644 (file)
@@ -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;
index 3bb36e5152dbc7962aa2b081696a71916cd2458d..639af7e14a0dc2a4ba5dc727089a0f282f266375 100644 (file)
@@ -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 (file)
index 0000000..e2bd2ee
--- /dev/null
@@ -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