From: Ben Pfaff Date: Thu, 2 Mar 2023 22:16:25 +0000 (-0800) Subject: DO REPEAT: Order PRINT output correctly. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df1d194af32e35739355981252785e768f21ebb0;p=pspp DO REPEAT: Order PRINT output correctly. This was printed in reverse order, although the commands were executed in the correct order. --- diff --git a/src/language/commands/repeat.c b/src/language/commands/repeat.c index f71409147c..2efce93e2b 100644 --- a/src/language/commands/repeat.c +++ b/src/language/commands/repeat.c @@ -275,17 +275,22 @@ parse_commands (struct lexer *lexer, struct hmap *dummies) bool print = ok && lex_match_id (lexer, "PRINT"); lex_discard_rest_of_command (lexer); - for (size_t i = 0; i < n_values; i++) + if (print) { - struct string *output = &outputs[n_values - i - 1]; - if (print) + for (size_t i = 0; i < n_values; i++) { + struct string *output = &outputs[i]; struct substring s = output->ss; ss_chomp_byte (&s, '\n'); char *label = xasprintf (_("Expansion %zu of %zu"), i + 1, n_values); output_item_submit ( text_item_create_nocopy (TEXT_ITEM_LOG, ss_xstrdup (s), label)); } + } + + for (size_t i = 0; i < n_values; i++) + { + struct string *output = &outputs[n_values - i - 1]; const char *encoding = lex_get_encoding (lexer); struct lex_reader *reader = lex_reader_for_substring_nocopy (ds_ss (output), encoding); lex_reader_set_file_name (reader, file_name); diff --git a/tests/language/commands/do-repeat.at b/tests/language/commands/do-repeat.at index ad2fa978b5..81bc952bc8 100644 --- a/tests/language/commands/do-repeat.at +++ b/tests/language/commands/do-repeat.at @@ -32,9 +32,9 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv do-repeat.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -COMPUTE x=3. -COMPUTE y='c'. -COMPUTE c=3. +COMPUTE x=1. +COMPUTE y='a'. +COMPUTE a=1. END CASE. COMPUTE x=2. @@ -42,9 +42,9 @@ COMPUTE y='b'. COMPUTE b=2. END CASE. -COMPUTE x=1. -COMPUTE y='a'. -COMPUTE a=1. +COMPUTE x=3. +COMPUTE y='c'. +COMPUTE c=3. END CASE. Table: Data List