From 50e00137bfcc4eb3d4ae753a5e57e7a444194c96 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 27 Aug 2022 13:04:30 -0700 Subject: [PATCH] Fix XXX makrings. --- src/language/stats/ctables.c | 58 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index e38c64d30e..12f9958c3c 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -2638,7 +2638,7 @@ ctables_summary_uninit (union ctables_summary *s, static void ctables_summary_add (union ctables_summary *s, const struct ctables_summary_spec *ss, - const struct variable *var, const union value *value, + const union value *value, bool is_scale, bool is_scale_missing, bool is_missing, bool is_included, double weight) @@ -2710,7 +2710,6 @@ ctables_summary_add (union ctables_summary *s, case CTSF_RANGE: if (!is_scale_missing) { - assert (!var_is_alpha (var)); /* XXX? */ if (s->min == SYSMIS || value->f < s->min) s->min = value->f; if (s->max == SYSMIS || value->f > s->max) @@ -2983,24 +2982,6 @@ ctables_cell_compare_leaf_3way (const void *a_, const void *b_, return 0; } -/* Algorithm: - - For each row: - For each ctables_table: - For each combination of row vars: - For each combination of column vars: - For each combination of layer vars: - Add entry - Make a table of row values: - Sort entries by row values - Assign a 0-based index to each actual value - Construct a dimension - Make a table of column values - Make a table of layer values - For each entry: - Fill the table entry using the indexes from before. - */ - static struct ctables_area * ctables_area_insert (struct ctables_section *s, struct ctables_cell *cell, enum ctables_area_type area) @@ -3153,7 +3134,7 @@ ctables_categories_total (const struct ctables_categories *c) static struct ctables_cell * ctables_cell_insert__ (struct ctables_section *s, const struct ccase *c, - const struct ctables_category *cats[PIVOT_N_AXES][10]) + const struct ctables_category **cats[PIVOT_N_AXES]) { size_t hash = 0; enum ctables_summary_variant sv = CSV_CELL; @@ -3309,7 +3290,7 @@ add_weight (double dst[N_CTWS], const double src[N_CTWS]) static void ctables_cell_add__ (struct ctables_section *s, const struct ccase *c, - const struct ctables_category *cats[PIVOT_N_AXES][10], + const struct ctables_category **cats[PIVOT_N_AXES], bool is_included, double weight[N_CTWS]) { struct ctables_cell *cell = ctables_cell_insert__ (s, c, cats); @@ -3321,10 +3302,9 @@ ctables_cell_add__ (struct ctables_section *s, const struct ccase *c, bool scale_missing = specs->is_scale && (is_missing || is_listwise_missing (specs, c)); for (size_t i = 0; i < specs->n; i++) - ctables_summary_add (&cell->summaries[i], &specs->specs[i], - specs->var, value, specs->is_scale, - scale_missing, is_missing, is_included, - weight[specs->specs[i].weighting]); + ctables_summary_add (&cell->summaries[i], &specs->specs[i], value, + specs->is_scale, scale_missing, is_missing, + is_included, weight[specs->specs[i].weighting]); for (enum ctables_area_type at = 0; at < N_CTATS; at++) if (!(cell->omit_areas && (1u << at))) { @@ -3352,7 +3332,7 @@ ctables_cell_add__ (struct ctables_section *s, const struct ccase *c, static void recurse_totals (struct ctables_section *s, const struct ccase *c, - const struct ctables_category *cats[PIVOT_N_AXES][10], + const struct ctables_category **cats[PIVOT_N_AXES], bool is_included, double weight[N_CTWS], enum pivot_axis_type start_axis, size_t start_nest) { @@ -3383,7 +3363,7 @@ recurse_totals (struct ctables_section *s, const struct ccase *c, static void recurse_subtotals (struct ctables_section *s, const struct ccase *c, - const struct ctables_category *cats[PIVOT_N_AXES][10], + const struct ctables_category **cats[PIVOT_N_AXES], bool is_included, double weight[N_CTWS], enum pivot_axis_type start_axis, size_t start_nest) { @@ -3431,7 +3411,15 @@ static void ctables_cell_insert (struct ctables_section *s, const struct ccase *c, double weight[N_CTWS]) { - const struct ctables_category *cats[PIVOT_N_AXES][10]; /* XXX */ + const struct ctables_category *layer_cats[s->nests[PIVOT_AXIS_LAYER]->n]; + const struct ctables_category *row_cats[s->nests[PIVOT_AXIS_ROW]->n]; + const struct ctables_category *column_cats[s->nests[PIVOT_AXIS_COLUMN]->n]; + const struct ctables_category **cats[PIVOT_N_AXES] = + { + [PIVOT_AXIS_LAYER] = layer_cats, + [PIVOT_AXIS_ROW] = row_cats, + [PIVOT_AXIS_COLUMN] = column_cats, + }; bool is_included = true; @@ -5033,7 +5021,7 @@ ctables_add_category_occurrences (const struct variable *var, static void ctables_section_recurse_add_empty_categories ( struct ctables_section *s, - const struct ctables_category *cats[PIVOT_N_AXES][10], struct ccase *c, + const struct ctables_category **cats[PIVOT_N_AXES], struct ccase *c, enum pivot_axis_type a, size_t a_idx) { if (a >= PIVOT_N_AXES) @@ -5091,7 +5079,15 @@ ctables_section_add_empty_categories (struct ctables_section *s) if (!show_empty) return; - const struct ctables_category *cats[PIVOT_N_AXES][10]; /* XXX */ + const struct ctables_category *layer_cats[s->nests[PIVOT_AXIS_LAYER]->n]; + const struct ctables_category *row_cats[s->nests[PIVOT_AXIS_ROW]->n]; + const struct ctables_category *column_cats[s->nests[PIVOT_AXIS_COLUMN]->n]; + const struct ctables_category **cats[PIVOT_N_AXES] = + { + [PIVOT_AXIS_LAYER] = layer_cats, + [PIVOT_AXIS_ROW] = row_cats, + [PIVOT_AXIS_COLUMN] = column_cats, + }; struct ccase *c = case_create (dict_get_proto (s->table->ctables->dict)); ctables_section_recurse_add_empty_categories (s, cats, c, 0, 0); case_unref (c); -- 2.30.2