LIST: Allow a subset of the CASES settings to be specified.
[pspp] / src / language / data-io / list.c
index c7f85f3917d780f564a1060ce1f8d639aee77b37..e3c38c7a6d1a52d0eeba7d52837f1cf49b9475d8 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009-2011, 2013 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
@@ -56,10 +56,10 @@ enum numbering
 
 struct lst_cmd
 {
-  int first;
-  int last;
-  int step;
-  struct variable **v_variables;
+  long first;
+  long last;
+  long step;
+  const struct variable **v_variables;
   size_t n_variables;
   enum numbering numbering;
 };
@@ -128,7 +128,7 @@ list_execute (const struct lst_cmd *lcmd, struct dataset *ds)
 
       casereader_destroy (group);
 
-      table_item_submit (table_item_create (t, "Data List"));
+      table_item_submit (table_item_create (t, "Data List", NULL));
     }
   ok = casegrouper_destroy (grouper);
   ok = proc_commit (ds) && ok;
@@ -162,7 +162,7 @@ cmd_list (struct lexer *lexer, struct dataset *ds)
       if (lex_match_id (lexer, "VARIABLES") )
         {
           lex_match (lexer, T_EQUALS);
-          if (! parse_variables (lexer, dict, &cmd.v_variables, &cmd.n_variables, 0 ))
+          if (! parse_variables_const (lexer, dict, &cmd.v_variables, &cmd.n_variables, 0 ))
             {
               msg (SE, _("No variables specified."));
               return CMD_FAILURE;
@@ -189,31 +189,26 @@ 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))
             {
-              lex_match_int (lexer, &cmd.first);
+              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);
             }
         }
-      else if (! parse_variables (lexer, dict, &cmd.v_variables, &cmd.n_variables, 0 ))
+      else if (! parse_variables_const (lexer, dict, &cmd.v_variables, &cmd.n_variables, 0 ))
         {
           return CMD_FAILURE;
         }