static void delete_missing (struct pivot_table *);
static void build_matrix (struct pivot_table *);
-/* Output pivot table beginning at PB and continuing until PE,
- exclusive. For efficiency, *MATP is a pointer to a matrix that can
- hold *MAXROWS entries. */
+/* Output pivot table PT in the context of PROC. */
static void
output_pivot_table (struct crosstabs_proc *proc, struct pivot_table *pt)
{
enum_var_values (pt, COL_VAR, &pt->cols, &pt->n_cols, proc->descending);
+ if (pt->n_cols == 0)
+ {
+ struct string vars;
+ int i;
+
+ ds_init_cstr (&vars, var_get_name (pt->vars[0]));
+ for (i = 1; i < pt->n_vars; i++)
+ ds_put_format (&vars, " * %s", var_get_name (pt->vars[i]));
+
+ /* TRANSLATORS: The %s here describes a crosstabulation. It takes the
+ form "var1 * var2 * var3 * ...". */
+ msg (SW, _("Crosstabulation %s contained no non-missing cases."),
+ ds_cstr (&vars));
+
+ ds_destroy (&vars);
+ return;
+ }
+
if (proc->cells)
table = create_crosstab_table (proc, pt);
if (proc->statistics & (1u << CRS_ST_CHISQ))
Total,4.0,2.0,6.0
]])
AT_CLEANUP
+
+# Bug #31260.
+AT_SETUP([CROSSTABS crash when all cases missing])
+AT_DATA([crosstabs.sps], [dnl
+DATA LIST LIST NOTABLE /X1 X2.
+BEGIN DATA.
+1 1
+END DATA.
+
+MISSING VALUES x2 (1).
+
+CROSSTABS /TABLES= X1 by X2.
+])
+AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+X1 * X2,0,0.0%,1,100.0%,1,100.0%
+
+crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
+])
+AT_CLEANUP