return true;
const struct ctables_nest *n0 = &stack->nests[0];
- assert (n0->n > 0);
+ if (n0->n == 0)
+ {
+ assert (stack->n == 1);
+ return true;
+ }
+
const struct variable *v0 = n0->vars[n0->n - 1];
struct ctables_categories *c0 = t->categories[var_get_dict_index (v0)];
t->clabels_example = v0;
struct ctables_nest *nest = xmalloc (sizeof *nest);
*nest = (struct ctables_nest) { .n = 0 };
t->stacks[a] = (struct ctables_stack) { .nests = nest, .n = 1 };
+
+ /* There's no point in moving labels away from an axis that has no
+ labels, so avoid dealing with the special cases around that. */
+ t->label_axis[a] = a;
}
struct ctables_stack *stack = &t->stacks[t->summary_axis];
if (!ct->e_weight)
goto error;
}
- else if (lex_match_id (lexer, " HIDESMALLCOUNTS"))
+ else if (lex_match_id (lexer, "HIDESMALLCOUNTS"))
{
if (lex_match_id (lexer, "COUNT"))
{
}
else if (lex_match_id (lexer, "CLABELS"))
{
- while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
+ if (lex_match_id (lexer, "AUTO"))
{
- if (lex_match_id (lexer, "AUTO"))
- {
- t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_ROW;
- t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_COLUMN;
- }
- else if (lex_match_id (lexer, "ROWLABELS"))
- {
- lex_match (lexer, T_EQUALS);
- if (lex_match_id (lexer, "OPPOSITE"))
- t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_COLUMN;
- else if (lex_match_id (lexer, "LAYER"))
- t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_LAYER;
- else
- {
- lex_error_expecting (lexer, "OPPOSITE", "LAYER");
- goto error;
- }
- }
- else if (lex_match_id (lexer, "COLLABELS"))
+ t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_ROW;
+ t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_COLUMN;
+ }
+ else if (lex_match_id (lexer, "ROWLABELS"))
+ {
+ lex_match (lexer, T_EQUALS);
+ t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_COLUMN;
+ if (lex_match_id (lexer, "OPPOSITE"))
+ t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_COLUMN;
+ else if (lex_match_id (lexer, "LAYER"))
+ t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_LAYER;
+ else
{
- lex_match (lexer, T_EQUALS);
- if (lex_match_id (lexer, "OPPOSITE"))
- t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_ROW;
- else if (lex_match_id (lexer, "LAYER"))
- t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_LAYER;
- else
- {
- lex_error_expecting (lexer, "OPPOSITE", "LAYER");
- goto error;
- }
+ lex_error_expecting (lexer, "OPPOSITE", "LAYER");
+ goto error;
}
+ }
+ else if (lex_match_id (lexer, "COLLABELS"))
+ {
+ lex_match (lexer, T_EQUALS);
+ t->label_axis[PIVOT_AXIS_ROW] = PIVOT_AXIS_ROW;
+ if (lex_match_id (lexer, "OPPOSITE"))
+ t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_ROW;
+ else if (lex_match_id (lexer, "LAYER"))
+ t->label_axis[PIVOT_AXIS_COLUMN] = PIVOT_AXIS_LAYER;
else
{
- lex_error_expecting (lexer, "AUTO", "ROWLABELS",
- "COLLABELS");
+ lex_error_expecting (lexer, "OPPOSITE", "LAYER");
goto error;
}
}
+ else
+ {
+ lex_error_expecting (lexer, "AUTO", "ROWLABELS",
+ "COLLABELS");
+ goto error;
+ }
}
else if (lex_match_id (lexer, "CRITERIA"))
{
-# AT_SETUP([CTABLES parsing])
-# AT_DATA([ctables.sps],
-# [[DATA LIST LIST NOTABLE /x y z.
-# CTABLES /TABLE=(x + y) > z.
-# CTABLES /TABLE=(x[c] + y[c]) > z.
-# CTABLES /TABLE=(x + y) > z[c].
-# CTABLES /TABLE=x BY y BY z.
-# CTABLES /TABLE=x[c] [ROWPCT.COUNT] > y[c].
-# CTABLES /TABLE=x[c] > y[c] [ROWPCT.COUNT].
-# ]])
-# AT_CHECK([pspp ctables.sps])
-# AT_CLEANUP
+AT_SETUP([CTABLES parsing])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
+ /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
+ /FORMAT UNITS=CM EMPTY="(-)"
+ /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
+ /VLABELS VARIABLES=qn17 DISPLAY=NAME
+ /VLABELS VARIABLES=qns3a DISPLAY=LABEL
+ /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
+ /VLABELS VARIABLES=qn20 DISPLAY=NONE
+ /MRSETS COUNTDUPLICATES=NO
+ /MRSETS COUNTDUPLICATES=YES
+ /SMISSING VARIABLE
+ /SMISSING LISTWISE
+ /WEIGHT VARIABLE=qns3a
+ /HIDESMALLCOUNTS
+ /HIDESMALLCOUNTS COUNT=10
+ /TABLE qnd1
+ /SLABELS POSITION=COLUMN VISIBLE=YES
+ /SLABELS VISIBLE=NO POSITION=ROW
+ /SLABELS POSITION=LAYER
+ /CLABELS AUTO
+ /CLABELS ROWLABELS=OPPOSITE
+ /CLABELS ROWLABELS=LAYER
+ /CLABELS COLLABELS=OPPOSITE
+ /CLABELS COLLABELS=LAYER
+ /CRITERIA CILEVEL=50
+ /CATEGORIES VARIABLES=qn1 qn17
+ ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
+ POSITION=BEFORE EMPTY=INCLUDE.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+Mean
+╭───────────────────────────────┬──╮
+│qnd1 D1. AGE: What is your age?│49│
+╰───────────────────────────────┴──╯
+])
+AT_CLEANUP
AT_SETUP([CTABLES one categorical variable])
AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])