enum ctables_vlabel
{
- CTVL_DEFAULT = SETTINGS_VALUE_SHOW_DEFAULT,
+ CTVL_NONE = SETTINGS_VALUE_SHOW_DEFAULT,
CTVL_NAME = SETTINGS_VALUE_SHOW_VALUE,
CTVL_LABEL = SETTINGS_VALUE_SHOW_LABEL,
CTVL_BOTH = SETTINGS_VALUE_SHOW_BOTH,
- CTVL_NONE,
};
-static void UNUSED
-ctables_vlabel_unique (enum ctables_vlabel vlabel)
-{
- /* This ensures that all of the values are unique. */
- switch (vlabel)
- {
- case CTVL_DEFAULT:
- case CTVL_NAME:
- case CTVL_LABEL:
- case CTVL_BOTH:
- case CTVL_NONE:
- abort ();
- }
-}
/* XXX:
- unweighted summaries (U*)
var_get_type (ft->vars.vars[n_common])))
break;
- for (size_t m = n_common; m + 1 < ft->vars.n; m++)
+ for (size_t m = n_common; m < ft->vars.n; m++)
{
struct pivot_category *parent = m > 0 ? groups[m - 1] : d->root;
- if (true)
+ const struct variable *var = ft->vars.vars[m];
+ enum ctables_vlabel vlabel = ct->vlabels[var_get_dict_index (var)];
+
+ if (vlabel != CTVL_NONE)
parent = pivot_category_create_group__ (
parent, pivot_value_new_variable (ft->vars.vars[m]));
- groups[m] = pivot_category_create_group__ (
- parent,
- pivot_value_new_var_value (ft->vars.vars[m], &f->values[m]));
- }
- int leaf = pivot_category_create_leaf (
- ft->vars.n > 1 ? groups[ft->vars.n - 2] : d->root,
- pivot_value_new_var_value (ft->vars.vars[ft->vars.n - 1],
- &f->values[ft->vars.n - 1]));
+ if (m + 1 < ft->vars.n)
+ parent = pivot_category_create_group__ (
+ parent,
+ pivot_value_new_var_value (ft->vars.vars[m], &f->values[m]));
+ groups[m] = parent;
- pivot_table_put1 (pt, leaf, pivot_value_new_number (f->count));
+ if (m == ft->vars.n - 1)
+ {
+ int leaf = pivot_category_create_leaf (
+ parent,
+ pivot_value_new_var_value (ft->vars.vars[ft->vars.n - 1],
+ &f->values[ft->vars.n - 1]));
+ pivot_table_put1 (pt, leaf, pivot_value_new_number (f->count));
+ }
+ }
}
free (groups);
}
{
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 ();
for (size_t i = 0; i < n_vars; i++)
- vlabels[i] = CTVL_DEFAULT;
+ vlabels[i] = (enum ctables_vlabel) tvars;
struct ctables *ct = xmalloc (sizeof *ct);
*ct = (struct ctables) {
enum ctables_vlabel vlabel;
if (lex_match_id (lexer, "DEFAULT"))
- vlabel = CTVL_DEFAULT;
+ vlabel = (enum ctables_vlabel) settings_get_show_variables ();
else if (lex_match_id (lexer, "NAME"))
vlabel = CTVL_NAME;
else if (lex_match_id (lexer, "LABEL"))