From 26d6f3cb1b99090e2a8dca1b7f43aaee2ecf06a7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 14 Apr 2024 10:07:16 -0700 Subject: [PATCH] LIST: Fix bug listing duplicate variables. Thanks to Zhou Geng for reporting this bug as poc28 in the report here: https://lists.gnu.org/archive/html/bug-gnu-pspp/2024-03/msg00015.html --- src/language/commands/list.c | 2 +- tests/language/commands/list.at | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/language/commands/list.c b/src/language/commands/list.c index 604f896e98..950bf645cc 100644 --- a/src/language/commands/list.c +++ b/src/language/commands/list.c @@ -65,7 +65,7 @@ list_execute (const struct lst_cmd *lcmd, struct dataset *ds) struct subcase sc; subcase_init_empty (&sc); for (size_t i = 0; i < lcmd->n_vars; i++) - subcase_add_var (&sc, lcmd->vars[i], SC_ASCEND); + subcase_add_var_always (&sc, lcmd->vars[i], SC_ASCEND); struct casegrouper *grouper; struct casereader *group; diff --git a/tests/language/commands/list.at b/tests/language/commands/list.at index c10c95a809..9d805a0595 100644 --- a/tests/language/commands/list.at +++ b/tests/language/commands/list.at @@ -361,4 +361,22 @@ AT_CHECK([pspp -O format=csv list.sps], [1], [dnl 7 | LIST **. | ^~" ]) +AT_CLEANUP + +dnl Checks for regression against a crash +AT_SETUP([LIST duplicate variables]) +AT_DATA([list.sps], [dnl +DATA LIST LIST NOTABLE /v r1 Se oRe o. +BEGIN DATA. +2 +END DATA. +LIST o o. +]) +AT_CHECK([pspp -O format=csv list.sps], [0], [dnl +"list.sps:3: warning: Missing value(s) for all variables from r1 onward. These will be filled with the system-missing value or blanks, as appropriate." + +Table: Data List +o,o +. ,. @&t@ +]) AT_CLEANUP \ No newline at end of file -- 2.30.2