combine-files: Fix crash when no files are given.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 30 Apr 2023 00:44:51 +0000 (17:44 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 30 Apr 2023 00:44:51 +0000 (17:44 -0700)
ADD FILES, MATCH FILES, and UPDATE would crash if no files were given.
This fixes the problem.

src/language/commands/combine-files.c
tests/language/commands/match-files.at
tests/language/commands/update.at

index 6743c5e7a9cfd88483b234069780ef565c377160..dd54f90a93f91f1139bc657600a8fa6b88af0c49 100644 (file)
@@ -185,6 +185,11 @@ combine_files (enum comb_command_type command,
           type = COMB_TABLE;
           table_idx = MIN (table_idx, proc.n_files);
         }
+      else if (!proc.n_files)
+        {
+          lex_error_expecting (lexer, "FILE", "TABLE");
+          goto error;
+        }
       else
         break;
       lex_match (lexer, T_EQUALS);
index f59c7a01a58b41b03c6665419604be42cf5f7be9..74a1f3c3be5a132c0d69138b03fb7e0a89b2263c 100644 (file)
@@ -297,6 +297,7 @@ MATCH FILES/FILE='x.sav'/SORT/FILE=*/RENAME(name=name2)/SORT.
 MATCH FILES/FILE='x.sav'/FILE=*/RENAME(name=name2)/FIRST=x.
 MATCH FILES/FILE='x.sav'/FILE=*/RENAME(name=name2)/LAST=x.
 MATCH FILES/FILE='x.sav'/FILE=*/RENAME(name=name2)/IN=x.
+MATCH FILES/KEEP=**.
 ])
 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
 "match-files.sps:1.18: error: MATCH FILES: Cannot specify the active dataset since none has been defined.
@@ -392,5 +393,9 @@ match-files.sps:20: error: MATCH FILES: Variable name has different type or widt
 "match-files.sps:39.55: error: MATCH FILES: Variable name x specified on IN subcommand duplicates an existing variable name.
    39 | MATCH FILES/FILE='x.sav'/FILE=*/RENAME(name=name2)/IN=x.
       |                                                       ^"
+
+"match-files.sps:40.13-40.16: error: MATCH FILES: Syntax error expecting FILE or TABLE.
+   40 | MATCH FILES/KEEP=**.
+      |             ^~~~"
 ])
 AT_CLEANUP
index e3590d2e71a1534497a25e6d879871074400d822..66789c411d9d5b5e56680eaea091a92e26416d42 100644 (file)
@@ -118,7 +118,7 @@ AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
    15 | UPDATE/FILE='x.sav'/FILE=*/RENAME(name=name2).
       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 
-"update.sps:16.8-16.12: error: UPDATE: Syntax error expecting BY, MAP, DROP, or KEEP.
+"update.sps:16.8-16.12: error: UPDATE: Syntax error expecting FILE or TABLE.
    16 | UPDATE/xyzzy.
       |        ^~~~~"
 ])