X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fctables.c;h=b2bf14b39992e4f24a02aa55dd29d4af1002218a;hb=4480f216f5be2ba8795bf7fc1594c87da14a69ff;hp=aa204b4ea5f0070bd1aa1a582ac09a4d63e7bdeb;hpb=433baa13e773d56e6dacbdc8df8f266b4f46e7ef;p=pspp diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index aa204b4ea5..b2bf14b399 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -5317,7 +5317,8 @@ ctables_table_clear (struct ctables_table *t) } static bool -ctables_execute (struct dataset *ds, struct ctables *ct) +ctables_execute (struct dataset *ds, struct casereader *input, + struct ctables *ct) { for (size_t i = 0; i < ct->n_tables; i++) { @@ -5331,7 +5332,6 @@ ctables_execute (struct dataset *ds, struct ctables *ct) } struct dictionary *dict = dataset_dict (ds); - struct casereader *input = proc_open (ds); struct casegrouper *grouper = (dict_get_split_type (dict) == SPLIT_SEPARATE ? casegrouper_create_splits (input, dict) @@ -5386,8 +5386,7 @@ ctables_execute (struct dataset *ds, struct ctables *ct) ctables_table_clear (t); } } - bool ok = casegrouper_destroy (grouper); - return proc_commit (ds) && ok; + return casegrouper_destroy (grouper); } /* Postcomputes. */ @@ -6022,6 +6021,15 @@ put_title_text (struct string *out, struct substring in, time_t now, int cmd_ctables (struct lexer *lexer, struct dataset *ds) { + struct casereader *input; + if (measure_guesser_is_needed (ds)) + { + input = proc_open (ds); + measure_guesser_run (ds, input); + } + else + input = NULL; + size_t n_vars = dict_get_n_vars (dataset_dict (ds)); enum ctables_vlabel *vlabels = xnmalloc (n_vars, sizeof *vlabels); enum settings_value_show tvars = settings_get_show_variables (); @@ -6750,11 +6758,17 @@ cmd_ctables (struct lexer *lexer, struct dataset *ds) } while (lex_token (lexer) != T_ENDCMD); - bool ok = ctables_execute (ds, ct); + if (!input) + input = proc_open (ds); + bool ok = ctables_execute (ds, input, ct); + ok = proc_commit (ds) && ok; + ctables_destroy (ct); return ok ? CMD_SUCCESS : CMD_FAILURE; error: + if (input) + proc_commit (ds); ctables_destroy (ct); return CMD_FAILURE; }