return s;
}
+static bool
+all_hidden_vlabels (const struct ctables_table *t, enum pivot_axis_type a)
+{
+ for (size_t i = 0; i < t->stacks[a].n; i++)
+ {
+ struct ctables_nest *nest = &t->stacks[a].nests[i];
+ if (nest->n != 1 || nest->scale_idx != 0)
+ return false;
+
+ enum ctables_vlabel vlabel
+ = t->ctables->vlabels[var_get_dict_index (nest->vars[0])];
+ if (vlabel != CTVL_NONE)
+ return false;
+ }
+ return true;
+}
+
static void
ctables_table_output (struct ctables *ct, struct ctables_table *t)
{
for (size_t k = 0; k < nest->n; k++)
{
enum ctables_vlabel vlabel = ct->vlabels[var_get_dict_index (nest->vars[k])];
+ if (vlabel == CTVL_NONE && nest->scale_idx == k)
+ vlabel = CTVL_NAME;
if (vlabel != CTVL_NONE)
{
levels[n_levels++] = (struct ctables_level) {
free (groups);
free (levels);
free (sections);
+
}
+
+ d[a]->hide_all_labels = all_hidden_vlabels (t, a);
}
{
AT_CLEANUP
-AT_SETUP([CTABLES scale summary functions - assertion failure])
+AT_SETUP([CTABLES hidden scale VLABELS])
AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
AT_DATA([ctables.sps],
[[GET 'nhtsa.sav'.
+CTABLES
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
CTABLES
/VLABELS VARIABLE=qn19a DISPLAY=NONE
- /TABLE region BY qn19a
- /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+CTABLES
+ /VLABELS VARIABLE=qn35 DISPLAY=NONE
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+
+* This one in particular caused a crash because no categories were
+ created on the column axis, so passing in 0 for the index was still
+ too big for that number of categories. It was fixed by creating a
+ name-only category for each variable despite the "NONE" request,
+ then hiding the entire dimension's labels if all its labels were
+ set to "NONE".
+CTABLES
+ /VLABELS VARIABLE=qn19a qn35 DISPLAY=NONE
+ /TABLE region BY qn19a + qn35
/SLABELS POSITION=ROW.
]])
-AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭──────────────┬────────────────────────────┬─────────────────────────────────╮
+│ │ 19a. About how old were you│ 35. In the past thirty days, how│
+│ │ when you first starting │ many times have you driven a │
+│ │ drinking alcohol, not │ motor vehicle WITHIN TWO HOURS │
+│ │ counting small tastes or │ AFTER drinking alcoholic │
+│ │ sips of alcohol. │ beverages? │
+├──────────────┼────────────────────────────┼─────────────────────────────────┤
+│Region NE Mean│ 19.33│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ MW Mean│ 19.83│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ S Mean│ 20.29│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ W Mean│ 19.87│ 2│
+╰──────────────┴────────────────────────────┴─────────────────────────────────╯
+
+ Custom Tables
+╭──────────────┬─────┬────────────────────────────────────────────────────────╮
+│ │ │ 35. In the past thirty days, how many times have you │
+│ │ │ driven a motor vehicle WITHIN TWO HOURS AFTER drinking │
+│ │QN19A│ alcoholic beverages? │
+├──────────────┼─────┼────────────────────────────────────────────────────────┤
+│Region NE Mean│19.33│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ MW Mean│19.83│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ S Mean│20.29│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ W Mean│19.87│ 2│
+╰──────────────┴─────┴────────────────────────────────────────────────────────╯
+
+ Custom Tables
+╭──────────────┬─────────────────────────────────────────────────────────┬────╮
+│ │ 19a. About how old were you when you first starting │ │
+│ │ drinking alcohol, not counting small tastes or sips of │ │
+│ │ alcohol. │qn35│
+├──────────────┼─────────────────────────────────────────────────────────┼────┤
+│Region NE Mean│ 19.33│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ MW Mean│ 19.83│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ S Mean│ 20.29│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ W Mean│ 19.87│ 2│
+╰──────────────┴─────────────────────────────────────────────────────────┴────╯
+
+ Custom Tables
+╭──────────────┬───────╮
+│Region NE Mean│19.33 2│
+│ ╶───────┼───────┤
+│ MW Mean│19.83 2│
+│ ╶───────┼───────┤
+│ S Mean│20.29 2│
+│ ╶───────┼───────┤
+│ W Mean│19.87 2│
+╰──────────────┴───────╯
+])
AT_CLEANUP