From: Ben Pfaff Date: Thu, 16 Feb 2023 23:24:05 +0000 (-0800) Subject: CROSSTABS: Always cite all the dimensions if there are too many. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aef47e8bd7e9ec09defcbe7bf3949ce148dd8510;p=pspp CROSSTABS: Always cite all the dimensions if there are too many. 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. --- diff --git a/src/language/commands/crosstabs.c b/src/language/commands/crosstabs.c index 0762d0efb6..72579b0b97 100644 --- a/src/language/commands/crosstabs.c +++ b/src/language/commands/crosstabs.c @@ -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); diff --git a/tests/language/commands/crosstabs.at b/tests/language/commands/crosstabs.at index b5f037ca80..392c48c738 100644 --- a/tests/language/commands/crosstabs.at +++ b/tests/language/commands/crosstabs.at @@ -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).