tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Format"));
tab_box (t, TAL_1, TAL_1, TAL_0, TAL_1, 0, 0, 3, parser->field_cnt);
tab_hline (t, TAL_2, 0, 3, 1);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
for (i = 0; i < parser->field_cnt; i++)
{
tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Format"));
tab_box (t, TAL_1, TAL_1, TAL_0, TAL_1, 0, 0, 1, parser->field_cnt);
tab_hline (t, TAL_2, 0, 1, 1);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
for (i = 0; i < parser->field_cnt; i++)
{
tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Record"));
tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Columns"));
tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Format"));
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
row = 1;
ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
{
return;
t = tab_create (3, split_cnt + 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_vline (t, TAL_GAP, 1, 0, split_cnt);
tab_vline (t, TAL_GAP, 2, 0, split_cnt);
tab_text (t, 0, 0, TAB_NONE, _("Variable"));
dict_get_encoding(d) ? dict_get_encoding(d) : _("Unknown"));
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_submit (t);
t = tab_create (4, 1 + 2 * dict_get_var_cnt (d), 1);
- tab_dim (t, sysfile_info_dim, NULL);
+ tab_dim (t, sysfile_info_dim, NULL, NULL);
tab_headers (t, 0, 0, 1, 0);
tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
tab_joint_text (t, 1, 0, 2, 0, TAB_LEFT | TAT_TITLE, _("Description"));
}
}
-static int _flags;
+struct variables_dim_aux
+ {
+ int flags;
+ };
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
static void
-variables_dim (struct tab_rendering *r, void *aux UNUSED)
+variables_dim (struct tab_rendering *r, void *aux_)
{
const struct outp_driver *d = r->driver;
+ struct variables_dim_aux *aux = aux_;
tab_natural_dimensions (r, NULL);
- if (_flags & (DF_VALUE_LABELS | DF_VARIABLE_LABELS | DF_MISSING_VALUES
- | DF_AT_ATTRIBUTES | DF_ATTRIBUTES))
+ if (aux->flags & (DF_VALUE_LABELS | DF_VARIABLE_LABELS | DF_MISSING_VALUES
+ | DF_AT_ATTRIBUTES | DF_ATTRIBUTES))
{
r->w[1] = MAX (r->w[1], d->prop_em_width * 5);
r->w[2] = MAX (r->w[2], d->prop_em_width * 35);
}
}
+static void
+variables_dim_free (void *aux_)
+{
+ struct variables_dim_aux *aux = aux_;
+ free (aux);
+}
+
static void
display_variables (const struct variable **vl, size_t n, int flags)
{
struct tab_table *t;
+ struct variables_dim_aux *aux;
int nc; /* Number of columns. */
int pc; /* `Position column' */
int r; /* Current row. */
size_t i;
- _flags = flags;
-
/* One column for the name,
two columns for general description,
one column for dictionary index. */
? _("Description") : _("Label")));
if (flags & DF_DICT_INDEX)
tab_text (t, pc, 0, TAB_LEFT | TAT_TITLE, _("Position"));
- tab_dim (t, variables_dim, NULL);
+
+ aux = xmalloc (sizeof *aux);
+ aux->flags = flags;
+ tab_dim (t, variables_dim, variables_dim_free, aux);
r = 1;
for (i = 0; i < n; i++)
tab_text (t, 1, 0, TAB_LEFT | TAT_TITLE, _("Value"));
display_attributes (t, set, flags, 0, 1);
tab_columns (t, TAB_COL_DOWN, 1);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_title (t, "Custom data file attributes.");
tab_submit (t);
}
t = tab_create (4, nrow + 1, 0);
tab_headers (t, 0, 0, 1, 0);
tab_columns (t, TAB_COL_DOWN, 1);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_1, TAL_1, -1, -1, 0, 0, 3, nrow);
tab_box (t, -1, -1, -1, TAL_1, 0, 0, 3, nrow);
tab_hline (t, TAL_2, 0, 3, 1);
struct tab_table *table = tab_create (7, ost->n_vars * 3 + 1, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Binomial Test"));
}
table = tab_create(4, n_cells + 2, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, var_to_string(var));
tab_text (table, 1, 0, TAB_LEFT, _("Observed N"));
int n_cells = test->hi - test->lo + 1;
table = tab_create(1 + ost->n_vars * 4, n_cells + 3, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Frequencies"));
for ( i = 0 ; i < ost->n_vars ; ++i )
struct tab_table *table;
table = tab_create (1 + ost->n_vars, 4, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Test Statistics"));
tab_headers (table, 1, 0, 1, 0);
unsigned int statistics; /* Bit k is 1 if statistic k is requested. */
};
+/* Auxiliary data structure for tab_dim. */
+struct crosstabs_dim_aux
+ {
+ enum mv_class exclude;
+ };
+
static void
init_proc (struct crosstabs_proc *proc, struct dataset *ds)
{
static void display_risk (struct pivot_table *, struct tab_table *);
static void display_directional (struct crosstabs_proc *, struct pivot_table *,
struct tab_table *);
-static void crosstabs_dim (struct tab_rendering *, void *proc);
+static void crosstabs_dim (struct tab_rendering *, void *aux);
+static void crosstabs_dim_free (void *aux);
static void table_value_missing (struct crosstabs_proc *proc,
struct tab_table *table, int c, int r,
unsigned char opt, const union value *v,
submit (struct crosstabs_proc *proc, struct pivot_table *pt,
struct tab_table *t)
{
+ struct crosstabs_dim_aux *aux;
int i;
if (t == NULL)
tab_box (t, -1, -1, -1, TAL_GAP, 0, tab_t (t), tab_l (t) - 1,
tab_nr (t) - 1);
tab_vline (t, TAL_2, tab_l (t), 0, tab_nr (t) - 1);
- tab_dim (t, crosstabs_dim, proc);
+
+ aux = xmalloc (sizeof *aux);
+ aux->exclude = proc->exclude;
+ tab_dim (t, crosstabs_dim, crosstabs_dim_free, aux);
+
tab_submit (t);
}
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
static void
-crosstabs_dim (struct tab_rendering *r, void *proc_)
+crosstabs_dim (struct tab_rendering *r, void *aux_)
{
const struct tab_table *t = r->table;
struct outp_driver *d = r->driver;
- struct crosstabs_proc *proc = proc_;
+ struct crosstabs_dim_aux *aux = aux_;
int i;
/* Width of a numerical column. */
int c = outp_string_width (d, "0.000000", OUTP_PROPORTIONAL);
- if (proc->exclude == MV_NEVER)
+ if (aux->exclude == MV_NEVER)
c += outp_string_width (d, "M", OUTP_PROPORTIONAL);
/* Set width for header columns. */
r->h[i] = tab_natural_height (r, i);
}
+static void
+crosstabs_dim_free (void *aux_)
+{
+ struct crosstabs_dim_aux *aux = aux_;
+ free (aux);
+}
+
static bool
find_crosstab (struct pivot_table *pt, size_t *row0p, size_t *row1p)
{
tab_hline (t, TAL_2, 0, 1, 1);
tab_text (t, 0, 0, TAB_CENTER | TAT_TITLE, _("Source"));
tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Target"));
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
{
size_t i, y;
tab_box (t, -1, -1, -1, TAL_1, 1, 0, nc - 1, dsc->var_cnt);
tab_hline (t, TAL_2, 0, nc - 1, 1);
tab_vline (t, TAL_2, 1, 0, dsc->var_cnt);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
nc = 0;
tab_text (t, nc++, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
/* Outline the box */
tab_box (tbl,
tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
/* Outline the box */
tab_box (tbl,
tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
/* Outline the box */
tab_box (tbl,
tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
/* Outline the box */
tab_box (tbl,
\f
/* Frequency table display. */
+struct full_dim_aux
+ {
+ bool show_labels;
+ };
+
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
static void
-full_dim (struct tab_rendering *r, void *aux UNUSED)
+full_dim (struct tab_rendering *r, void *aux_)
{
const struct outp_driver *d = r->driver;
const struct tab_table *t = r->table;
+ const struct full_dim_aux *aux = aux_;
int i;
for (i = 0; i < t->nc; i++)
{
r->w[i] = tab_natural_width (r, i);
- if (cmd.labels == FRQ_LABELS && i == 0)
+ if (aux->show_labels && i == 0)
r->w[i] = MIN (r->w[i], d->prop_em_width * 15);
else
r->w[i] = MAX (r->w[i], d->prop_em_width * 8);
r->h[i] = d->font_height;
}
+static void
+full_dim_free (void *aux_)
+{
+ struct full_dim_aux *aux = aux_;
+ free (aux);
+}
+
/* Displays a full frequency table for variable V. */
static void
dump_full (const struct variable *v, const struct variable *wv)
const bool lab = (cmd.labels == FRQ_LABELS);
+ struct full_dim_aux *aux;
+
vf = get_var_freqs (v);
ft = &vf->tab;
n_categories = ft->n_valid + ft->n_missing;
t = tab_create (5 + lab, n_categories + 3, 0);
tab_headers (t, 0, 0, 2, 0);
- tab_dim (t, full_dim, NULL);
+
+ aux = xmalloc (sizeof *aux);
+ aux->show_labels = lab;
+ tab_dim (t, full_dim, full_dim_free, aux);
if (lab)
tab_text (t, 0, 1, TAB_CENTER | TAT_TITLE, _("Value Label"));
tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("Pct"));
tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Cum"));
tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Pct"));
- tab_dim (t, condensed_dim, NULL);
+ tab_dim (t, condensed_dim, NULL, NULL);
r = 2;
for (f = ft->valid; f < ft->missing; f++)
calc_stats (v, stat_value);
t = tab_create (3, n_stats + n_percentiles + 2, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_1, TAL_1, -1, -1 , 0 , 0 , 2, tab_nr(t) - 1) ;
table = tab_create (columns, 2 + n_vars, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Descriptive Statistics"));
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t,
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 2, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
/* Put a frame around the entire box, and vertical lines inside */
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 1, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
/* Put a frame around the entire box, and vertical lines inside */
tab_box (t,
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 2, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
/* Put a frame around the entire box, and vertical lines inside */
tab_box (t,
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 3, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
/* Put a frame around the entire box, and vertical lines inside */
tab_box (t,
adjrsq = 1.0 - (1.0 - rsq) * (c->n_obs - 1.0) / (c->n_obs - c->n_indeps);
std_error = sqrt (pspp_linreg_mse (c));
t = tab_create (n_cols, n_rows, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
tab_hline (t, TAL_2, 0, n_cols - 1, 1);
tab_vline (t, TAL_2, 2, 0, n_rows - 1);
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
tab_hline (t, TAL_2, 0, n_cols - 1, 1);
tab_vline (t, TAL_2, 2, 0, n_rows - 1);
assert (c != NULL);
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
n_rows = 2 * (c->n_indeps + 1);
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
- tab_dim (t, tab_natural_dimensions, NULL);
+ tab_dim (t, tab_natural_dimensions, NULL, NULL);
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
tab_hline (t, TAL_2, 0, n_cols - 1, 1);
tab_vline (t, TAL_2, 2, 0, n_rows - 1);
{
struct tab_table *tab = tab_create(1, 1, 0);
- tab_dim (tab, tab_natural_dimensions, NULL);
+ tab_dim (tab, tab_natural_dimensions, NULL, NULL);
tab_flags (tab, SOMF_NO_TITLE );
tab_text(tab, 0, 0, TAT_PRINTF, "Scale: %s", ds_cstr (&rel->scale_name));
struct tab_table *tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
tab_title (tbl, _("Reliability Statistics"));
struct tab_table *tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
tab_title (tbl, _("Item-Total Statistics"));
tbl = tab_create (n_cols, n_rows, 0);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
- tab_dim (tbl, tab_natural_dimensions, NULL);
+ tab_dim (tbl, tab_natural_dimensions, NULL, NULL);
tab_title (tbl, _("Case Processing Summary"));
const struct variable *wv = dict_get_weight (dict);
const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0;
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Frequencies"));
int i;
struct tab_table *table = tab_create (1 + t2s->n_pairs, 4, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Test Statistics"));
tab_headers (this->t, 0, 0, 1, 0);
tab_box (this->t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols - 1, rows - 1);
tab_hline (this->t, TAL_2, 0, cols- 1, 1);
- tab_dim (this->t, tab_natural_dimensions, NULL);
+ tab_dim (this->t, tab_natural_dimensions, NULL, NULL);
}
\f
/* ssbox implementations. */
tab_headers (self->t, 0, 0, 3, 0);
tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols - 1, rows - 1);
tab_hline (self->t, TAL_2, 0, cols- 1, 3);
- tab_dim (self->t, tab_natural_dimensions, NULL);
+ tab_dim (self->t, tab_natural_dimensions, NULL, NULL);
}
/* Base finalizer for the trbox */
tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols - 1, rows - 1);
tab_hline (table, TAL_2, 0, cols - 1, 1);
tab_vline (table, TAL_2, 2, 0, rows - 1);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Paired Samples Correlations"));
/* column headings */
struct tab_table *table = tab_create (5, 1 + 4 * t2s->n_pairs, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Ranks"));
size_t i;
struct tab_table *table = tab_create (1 + t2s->n_pairs, exact ? 5 : 3, 0);
- tab_dim (table, tab_natural_dimensions, NULL);
+ tab_dim (table, tab_natural_dimensions, NULL, NULL);
tab_title (table, _("Test Statistics"));
tab = tab_create(1, 1, 0);
- tab_dim (tab, tab_natural_dimensions, NULL);
+ tab_dim (tab, tab_natural_dimensions, NULL, NULL);
tab_flags (tab, SOMF_NO_TITLE );
tab_text(tab, 0, 0, 0, ds_cstr (lex_tokstr (lexer)));
tab_destroy (struct tab_table *t)
{
assert (t != NULL);
+ if (t->dim_free != NULL)
+ t->dim_free (t->dim_aux);
free (t->title);
pool_destroy (t->container);
}
va_end (args);
}
-/* Set DIM_FUNC as the dimension function for table T. */
+/* Set DIM_FUNC, which will be passed auxiliary data AUX, as the
+ dimension function for table T.
+
+ DIM_FUNC must not assume that it is called from the same
+ context as tab_dim; for example, table T might be kept in
+ memory and, thus, DIM_FUNC might be called after the currently
+ running command completes. If it is non-null, FREE_FUNC is
+ called when the table is destroyed, to allow any data
+ allocated for use by DIM_FUNC to be freed. */
void
-tab_dim (struct tab_table *t, tab_dim_func *dim_func, void *aux)
+tab_dim (struct tab_table *t,
+ tab_dim_func *dim_func, tab_dim_free_func *free_func, void *aux)
{
- assert (t != NULL && t->dim == NULL);
+ assert (t->dim == NULL);
t->dim = dim_func;
+ t->dim_free = free_func;
t->dim_aux = aux;
}
tab_text (t, 0, 0, options & ~TAT_PRINTF, buf);
tab_flags (t, SOMF_NO_TITLE | SOMF_NO_SPACING);
- tab_dim (t, options & TAT_NOWRAP ? nowrap_dim : wrap_dim, NULL);
+ tab_dim (t, options & TAT_NOWRAP ? nowrap_dim : wrap_dim, NULL, NULL);
tab_submit (t);
free (tmp_buf);
struct tab_rendering;
typedef void tab_dim_func (struct tab_rendering *, void *aux);
+typedef void tab_dim_free_func (void *aux);
/* A table. */
struct tab_table
unsigned char *ct; /* Cell types; unsigned char[nr][nc]. */
unsigned char *rh; /* Horiz rules; unsigned char[nr+1][nc]. */
unsigned char *rv; /* Vert rules; unsigned char[nr][nc+1]. */
+
+ /* Calculating row and column dimensions. */
tab_dim_func *dim; /* Calculates cell widths and heights. */
+ tab_dim_free_func *dim_free; /* Frees space allocated for dim function. */
void *dim_aux; /* Auxiliary data for dim function. */
/* Editing info. */
tab_dim_func tab_natural_dimensions;
int tab_natural_width (const struct tab_rendering *, int c);
int tab_natural_height (const struct tab_rendering *, int r);
-void tab_dim (struct tab_table *, tab_dim_func *, void *aux);
+void tab_dim (struct tab_table *,
+ tab_dim_func *, tab_dim_free_func *, void *aux);
/* Rules. */
void tab_hline (struct tab_table *, int style, int x1, int x2, int y);