LIST: Allow a subset of the CASES settings to be specified.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Jan 2016 04:19:32 +0000 (20:19 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Jan 2016 04:19:32 +0000 (20:19 -0800)
The LIST documentation said that any subset of the FROM, TO, and BY
settings could be used on the CASES subcommand, but until now the command
as implemented required all of them to be present.  This commit fixes
the implementation.

Also updates the documentation to reflect the current implementation.

doc/data-io.texi
src/language/data-io/list.c
tests/language/data-io/list.at

index 1316f603a6aa9d8c0ee832d460817ba645531570..e1eeff09a37d1876eacc2fb4c269f84a0f21d617 100644 (file)
@@ -942,10 +942,6 @@ currently not used.
 Case numbers start from 1.  They are counted after all transformations
 have been considered.
 
-@cmd{LIST} attempts to fit all the values on a single line.  If needed
-to make them fit, variable names are displayed vertically.  If values
-cannot fit on a single line, then a multi-line format will be used.
-
 @cmd{LIST} is a procedure.  It causes the data to be read.
 
 @node NEW FILE
index 153c204f219c780ec3b94ef92dbb18146aee20d8..e3c38c7a6d1a52d0eeba7d52837f1cf49b9475d8 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009-2011, 2013, 2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009-2011, 2013, 2014, 2016 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
@@ -189,25 +189,20 @@ cmd_list (struct lexer *lexer, struct dataset *ds)
       else if (lex_match_id (lexer, "CASES"))
         {
           lex_match (lexer, T_EQUALS);
-          lex_force_match_id (lexer, "FROM");
-
-          if (lex_force_int (lexer))
+          if (lex_match_id (lexer, "FROM") && lex_force_int (lexer))
             {
-             cmd.first = lex_integer (lexer);
+              cmd.first = lex_integer (lexer);
               lex_get (lexer);
             }
 
-          lex_force_match (lexer, T_TO);
-
-          if (lex_force_int (lexer))
+          if ((lex_match (lexer, T_TO) && lex_force_int (lexer))
+              || lex_is_integer (lexer))
             {
               cmd.last = lex_integer (lexer);
               lex_get (lexer);
             }
 
-          lex_force_match (lexer, T_BY);
-
-          if (lex_force_int (lexer))
+          if (lex_match (lexer, T_BY) && lex_force_int (lexer))
             {
               cmd.step = lex_integer (lexer);
               lex_get (lexer);
index 6716354ccfd0782c725196e153ef0805dc2818dc..40e12477bc1633310978834608325c64e1cf9632 100644 (file)
@@ -185,6 +185,10 @@ AT_DATA([data.txt], [dnl
 AT_DATA([list.sps], [dnl
 DATA LIST FILE='data.txt' NOTABLE/x0 to x9 1-10.
 LIST /CASES=FROM 6 TO 20 BY 5.
+LIST /CASES=4.
+LIST /CASES=BY 10.
+LIST /CASES=FROM 25.
+LIST /CASES=FROM 26.
 ])
 AT_CHECK([pspp -o pspp.csv list.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
@@ -193,6 +197,26 @@ x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
 2,3,9,9,6,1,9,6,7,0
 2,2,8,4,5,3,4,0,8,3
 6,8,2,1,5,6,7,7,4,6
+
+Table: Data List
+x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
+7,6,7,5,3,2,4,6,6,3
+8,8,8,6,9,3,0,8,9,4
+4,9,2,6,1,1,5,0,7,9
+8,1,9,8,4,8,8,9,2,0
+
+Table: Data List
+x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
+7,6,7,5,3,2,4,6,6,3
+2,2,8,4,5,3,4,0,8,3
+7,9,7,0,6,2,0,0,9,1
+
+Table: Data List
+x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
+0,7,0,0,4,8,9,5,2,4
+
+Table: Data List
+x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
 ])
 AT_CLEANUP