- table = tab_create (nvar + n_cols,
- (pe - pb) / n_cols * 3 / 2 * num_cells + 10, 1);
- tab_headers (table, nvar - 1, 0, 2, 0);
-
- /* First header line. */
- tab_joint_text (table, nvar - 1, 0, (nvar - 1) + (n_cols - 1), 0,
- TAB_CENTER | TAT_TITLE, var_get_name (x->vars[COL_VAR]));
-
- tab_hline (table, TAL_1, nvar - 1, nvar + n_cols - 2, 1);
-
- /* Second header line. */
- {
- int i;
-
- for (i = 2; i < nvar; i++)
- tab_joint_text (table, nvar - i - 1, 0, nvar - i - 1, 1,
- TAB_RIGHT | TAT_TITLE, var_to_string (x->vars[i]));
- tab_text (table, nvar - 2, 1, TAB_RIGHT | TAT_TITLE,
- var_get_name (x->vars[ROW_VAR]));
- for (i = 0; i < n_cols; i++)
- table_value_missing (table, nvar + i - 1, 1, TAB_RIGHT, &cols[i],
- x->vars[COL_VAR]);
- tab_text (table, nvar + n_cols - 1, 1, TAB_CENTER, _("Total"));
- }
-
- tab_hline (table, TAL_1, 0, nvar + n_cols - 1, 2);
- tab_vline (table, TAL_1, nvar + n_cols - 1, 0, 1);
-
- /* Title. */
- {
- char *title = local_alloc (x->nvar * 64 + 128);
- char *cp = title;
- int i;
-
- if (cmd.pivot == CRS_PIVOT)
- for (i = 0; i < nvar; i++)
- {
- if (i)
- cp = stpcpy (cp, " by ");
- cp = stpcpy (cp, var_get_name (x->vars[i]));
- }
- else
- {
- cp = spprintf (cp, "%s by %s for",
- var_get_name (x->vars[0]),
- var_get_name (x->vars[1]));
- for (i = 2; i < nvar; i++)
- {
- char buf[64], *bufp;
-
- if (i > 2)
- *cp++ = ',';
- *cp++ = ' ';
- cp = stpcpy (cp, var_get_name (x->vars[i]));
- *cp++ = '=';
- format_short (buf, var_get_print_format (x->vars[i]),
- &(*pb)->values[i]);
- for (bufp = buf; isspace ((unsigned char) *bufp); bufp++)
- ;
- cp = stpcpy (cp, bufp);
- }
- }
-
- cp = stpcpy (cp, " [");
- for (i = 0; i < num_cells; i++)
- {
- struct tuple
- {
- int value;
- const char *name;
- };
-
- static const struct tuple cell_names[] =
- {
- {CRS_CL_COUNT, N_("count")},
- {CRS_CL_ROW, N_("row %")},
- {CRS_CL_COLUMN, N_("column %")},
- {CRS_CL_TOTAL, N_("total %")},
- {CRS_CL_EXPECTED, N_("expected")},
- {CRS_CL_RESIDUAL, N_("residual")},
- {CRS_CL_SRESIDUAL, N_("std. resid.")},
- {CRS_CL_ASRESIDUAL, N_("adj. resid.")},
- {-1, NULL},
- };
-
- const struct tuple *t;
-
- for (t = cell_names; t->value != cells[i]; t++)
- assert (t->value != -1);
- if (i)
- cp = stpcpy (cp, ", ");
- cp = stpcpy (cp, gettext (t->name));
- }
- strcpy (cp, "].");
-
- tab_title (table, "%s", title);
- local_free (title);
- }