X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fctables.c;fp=src%2Flanguage%2Fstats%2Fctables.c;h=8acf76a5c9b2cfae476da0d22f64ea39b1b24299;hb=06ac0c2d623e9ae54c3e22a2d6740219ab357b21;hp=0ff1a4d41dfcfd948284013f208be84c485a1639;hpb=79438d764f7c0490daac9e234c47cf049d8284df;p=pspp diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 0ff1a4d41d..8acf76a5c9 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -1285,7 +1285,7 @@ ctables_table_parse_categories (struct lexer *lexer, struct dictionary *dict, return false; struct ctables_categories *c = xmalloc (sizeof *c); - *c = (struct ctables_categories) { .n_refs = n_vars }; + *c = (struct ctables_categories) { .n_refs = n_vars, .show_empty = true }; for (size_t i = 0; i < n_vars; i++) { struct ctables_categories **cp @@ -3459,19 +3459,25 @@ ctables_section_recurse_add_empty_categories ( enum pivot_axis_type a, size_t a_idx) { if (a >= PIVOT_N_AXES) - { - - } - else if (!s->nests[a] || idx >= s->nests[a]->n) - { - - - } + ctables_cell_insert__ (s, c, cats); + else if (!s->nests[a] || a_idx >= s->nests[a]->n) + ctables_section_recurse_add_empty_categories (s, cats, c, a + 1, 0); else { - - for (size_t i = 0; i < s->nests[a]->n; i++) - + const struct variable *var = s->nests[a]->vars[a_idx]; + int width = var_get_width (var); + const struct hmap *occurrences = &s->occurrences[a][a_idx]; + const struct ctables_section_value *sv; + HMAP_FOR_EACH (sv, struct ctables_section_value, node, occurrences) + { + union value *value = case_data_rw (c, var); + value_destroy (value, width); + value_clone (value, &sv->value, width); + cats[a][a_idx] = ctables_categories_match ( + s->table->categories[var_get_dict_index (var)], value, var); + assert (cats[a][a_idx] != NULL); + ctables_section_recurse_add_empty_categories (s, cats, c, a, a_idx + 1); + } } } @@ -3498,7 +3504,8 @@ ctables_section_add_empty_categories (struct ctables_section *s) const struct ctables_category *cats[PIVOT_N_AXES][10]; /* XXX */ struct ccase *c = case_create (dict_get_proto (s->table->ctables->dict)); - ctables_section_recurse_add_empty_categories (s, c, cats, a, 0); + ctables_section_recurse_add_empty_categories (s, cats, c, 0, 0); + case_unref (c); } static bool @@ -3783,6 +3790,7 @@ cmd_ctables (struct lexer *lexer, struct dataset *ds) .n_refs = n_vars, .cats = cat, .n_cats = 1, + .show_empty = true, }; struct ctables_categories **categories = xnmalloc (n_vars,