CROSSTABS: Always cite all the dimensions if there are too many.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Feb 2023 23:24:05 +0000 (15:24 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Feb 2023 23:26:29 +0000 (15:26 -0800)
Otherwise, 32-bit and 64-bit systems cite different sets of dimensions,
which makes the test output change between i386 and x86-64.

Thanks to Friedrich Beckmann for reporting this bug.
Bug #63797.

src/language/commands/crosstabs.c
tests/language/commands/crosstabs.at

index 0762d0efb68316187d95d931967246cb5fc50723..72579b0b972a17b7be971b8e92e943dd1daccfdc 100644 (file)
@@ -601,6 +601,7 @@ parse_crosstabs_tables (struct lexer *lexer, struct dataset *ds,
   size_t nx = 1;
   size_t n_by = 0;
   int vars_start = lex_ofs (lexer);
+  bool overflow = false;
   do
     {
       by = xnrealloc (by, n_by + 1, sizeof *by);
@@ -610,15 +611,16 @@ parse_crosstabs_tables (struct lexer *lexer, struct dataset *ds,
        goto done;
       size_t n = by_nvar[n_by++];
       if (xalloc_oversized (nx, n))
-        {
-          lex_ofs_error (
-            lexer, vars_start, lex_ofs (lexer) - 1,
-            _("Too many cross-tabulation variables or dimensions."));
-          goto done;
-        }
+        overflow = true;
       nx *= n;
     }
   while (lex_match (lexer, T_BY));
+  if (overflow)
+    {
+      lex_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1,
+                     _("Too many cross-tabulation variables or dimensions."));
+      goto done;
+    }
   if (n_by < 2)
     {
       bool unused UNUSED = lex_force_match (lexer, T_BY);
index b5f037ca801371b0473d9629e2596bcc4638dac4..392c48c738a1823ee26641d54b22f2600cf7a90a 100644 (file)
@@ -2014,11 +2014,14 @@ AT_CHECK([pspp -O format=csv crosstabs.sps], [1], [dnl
    13 | CROSSTABS **.
       |           ^~"
 
-"crosstabs.sps:15.8-16.59: error: CROSSTABS: Too many cross-tabulation variables or dimensions.
+"crosstabs.sps:15.8-20.87: error: CROSSTABS: Too many cross-tabulation variables or dimensions.
    15 |        v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
       |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    16 |     BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
-      | -----------------------------------------------------------"
+      | ---------------------------------------------------------------------------------------
+  ... |
+   20 |     BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100.
+      | ---------------------------------------------------------------------------------------"
 
 crosstabs.sps:21: error: CROSSTABS: At least one crosstabulation must be requested (using the TABLES subcommand).