}
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++)
{
}
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)
ctables_table_clear (t);
}
}
- bool ok = casegrouper_destroy (grouper);
- return proc_commit (ds) && ok;
+ return casegrouper_destroy (grouper);
}
\f
/* Postcomputes. */
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 ();
}
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;
}