From: Ben Pfaff Date: Wed, 10 Aug 2022 05:39:10 +0000 (-0700) Subject: work on crash X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=7cd70df07f7e183645853716642810afd4b87bcd work on crash --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index da511b6951..2833ce6b51 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -4362,6 +4362,8 @@ ctables_format (double d, const struct fmt_spec *format, static void ctables_table_output (struct ctables *ct, struct ctables_table *t) { + printf ("\n"); + struct pivot_table *pt = pivot_table_create__ ( (t->title ? pivot_value_new_user_text (t->title, SIZE_MAX) @@ -4379,6 +4381,7 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) && t->summary_specs.n > 1)); if (summary_dimension) { + printf ("summary_dimension\n"); struct pivot_dimension *d = pivot_dimension_create ( pt, t->slabels_axis, N_("Statistics")); const struct ctables_summary_spec_set *specs = &t->summary_specs; @@ -4392,6 +4395,7 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) bool categories_dimension = t->clabels_example != NULL; if (categories_dimension) { + printf ("categories_dimension\n"); struct pivot_dimension *d = pivot_dimension_create ( pt, t->label_axis[t->clabels_from_axis], t->clabels_from_axis == PIVOT_AXIS_ROW @@ -4414,17 +4418,9 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) struct pivot_dimension *d[PIVOT_N_AXES]; for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++) { - static const char *names[] = { - [PIVOT_AXIS_ROW] = N_("Rows"), - [PIVOT_AXIS_COLUMN] = N_("Columns"), - [PIVOT_AXIS_LAYER] = N_("Layers"), - }; - d[a] = (t->axes[a] || a == t->summary_axis - ? pivot_dimension_create (pt, a, names[a]) - : NULL); - if (!d[a]) + d[a] = NULL; + if (!t->axes[a] && a != t->summary_axis) continue; - assert (t->axes[a]); for (size_t i = 0; i < t->stacks[a].n; i++) @@ -4536,6 +4532,17 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) }; } + if (!n_levels) + goto next_free; + + static const char *names[] = { + [PIVOT_AXIS_ROW] = N_("Rows"), + [PIVOT_AXIS_COLUMN] = N_("Columns"), + [PIVOT_AXIS_LAYER] = N_("Layers"), + }; + d[a] = pivot_dimension_create (pt, a, names[a]); + printf ("%s dimension\n", names[a]); + /* Pivot categories: - variable label for nest->vars[0], if vlabel != CTVL_NONE @@ -4633,8 +4640,9 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) cell->axes[a].leaf = prev_leaf; } - free (sorted); free (groups); + next_free: + free (sorted); free (levels); free (sections); } diff --git a/tests/language/stats/ctables.at b/tests/language/stats/ctables.at index 726da3d723..a60ec46b22 100644 --- a/tests/language/stats/ctables.at +++ b/tests/language/stats/ctables.at @@ -2964,6 +2964,15 @@ AT_SETUP([CTABLES scale summary functions - assertion failure]) AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) AT_DATA([ctables.sps], [[GET 'nhtsa.sav'. +CTABLES + /VLABELS VARIABLE=qn19a DISPLAY=BOTH + /TABLE region BY qn19a + /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE + /SLABELS POSITION=ROW. +CTABLES + /VLABELS VARIABLE=qn19a DISPLAY=NONE + /TABLE region BY qn19a + /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE. CTABLES /VLABELS VARIABLE=qn19a DISPLAY=NONE /TABLE region BY qn19a