From a74ac710e3cd2b6a52fd763ab31ce68e83f21dfe Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 2 Jan 2016 20:19:32 -0800 Subject: [PATCH] LIST: Allow a subset of the CASES settings to be specified. 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 | 4 ---- src/language/data-io/list.c | 17 ++++++----------- tests/language/data-io/list.at | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/doc/data-io.texi b/doc/data-io.texi index 1316f603a6..e1eeff09a3 100644 --- a/doc/data-io.texi +++ b/doc/data-io.texi @@ -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 diff --git a/src/language/data-io/list.c b/src/language/data-io/list.c index 153c204f21..e3c38c7a6d 100644 --- a/src/language/data-io/list.c +++ b/src/language/data-io/list.c @@ -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); diff --git a/tests/language/data-io/list.at b/tests/language/data-io/list.at index 6716354ccf..40e12477bc 100644 --- a/tests/language/data-io/list.at +++ b/tests/language/data-io/list.at @@ -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 -- 2.30.2