From: Ben Pfaff Date: Sun, 16 Jan 2022 03:48:11 +0000 (-0800) Subject: labeling, with clabels and slabels, all seems to work right X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=82bb2efcfd8fe17cb2d5caeb8edf26612fe0ca4c labeling, with clabels and slabels, all seems to work right --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 51a4a102a6..8dcd682f10 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -2831,32 +2831,10 @@ ctables_table_output_different_axis (struct ctables *ct, struct ctables_table *t for (size_t j = 0; j < n_sorted; j++) { struct ctables_cell *cell = sorted[j]; + struct ctables_cell *prev = j > 0 ? sorted[j - 1] : NULL; const struct ctables_nest *nest = &t->stacks[a].nests[cell->axes[a].stack_idx]; - size_t n_common = 0; - bool new_subtable = false; - if (j > 0) - { - struct ctables_cell *prev = sorted[j - 1]; - if (prev->axes[a].stack_idx == cell->axes[a].stack_idx) - { - for (; n_common < nest->n; n_common++) - if (n_common != nest->scale_idx - && (prev->axes[a].cvs[n_common].category - != cell->axes[a].cvs[n_common].category - || !value_equal (&prev->axes[a].cvs[n_common].value, - &cell->axes[a].cvs[n_common].value, - var_get_type (nest->vars[n_common])))) - break; - if (a == PIVOT_AXIS_ROW) - printf ("n_common=%zu\n", n_common); - } - else - new_subtable = true; - } - else - new_subtable = true; - + bool new_subtable = !prev || prev->axes[a].stack_idx != cell->axes[a].stack_idx; if (new_subtable) { n_levels = 0; @@ -2894,20 +2872,29 @@ ctables_table_output_different_axis (struct ctables *ct, struct ctables_table *t } printf ("\n"); } - if (a == PIVOT_AXIS_ROW) - printf ("n_common=%zu\n", n_common); - if (n_common == nest->n) + + size_t n_common = 0; + if (!new_subtable) { - cell->axes[a].leaf = prev_leaf; - continue; + for (; n_common < nest->n; n_common++) + { + const struct ctables_level *level = &levels[n_common]; + if (level->type == CTL_CATEGORY) + { + size_t var_idx = level->var_idx; + if (prev->axes[a].cvs[var_idx].category + != cell->axes[a].cvs[var_idx].category + || !value_equal (&prev->axes[a].cvs[var_idx].value, + &cell->axes[a].cvs[var_idx].value, + var_get_type (nest->vars[var_idx]))) + break; + } + } } - for (size_t k = 0; k < n_levels; k++) + for (size_t k = n_common; k < n_levels; k++) { const struct ctables_level *level = &levels[k]; - if (n_common > level->var_idx) - continue; - struct pivot_category *parent = k ? groups[k - 1] : d[a]->root; if (level->type == CTL_SUMMARY) {