#include "libpspp/pool.h"
#include "libpspp/str.h"
#include "output/pivot-table.h"
-#include "output/chart-item.h"
#include "output/charts/barchart.h"
#include "gl/minmax.h"
for (xt = &proc.pivots[0]; xt < &proc.pivots[proc.n_pivots]; xt++)
{
free (xt->vars);
- /* We must not call value_destroy on const_values because
- it is a wild pointer; it never pointed to anything owned
- by the crosstabulation.
-
- The rest of the data was allocated and destroyed at a
- lower level already. */
+ free (xt->const_vars);
+ free (xt->const_indexes);
}
free (proc.pivots);
xt->vars = xcalloc (n_by, sizeof *xt->vars);
xt->n_consts = 0;
xt->const_vars = NULL;
+ xt->const_indexes = NULL;
for (j = 0; j < n_by; j++)
xt->vars[j].var = by[j][by_iter[j]];
struct crosstabulation subset;
make_crosstabulation_subset (xt, row0, row1, &subset);
output_crosstabulation (proc, &subset);
+ free (subset.const_indexes);
}
}
if (proc->barchart)
{
- const struct variable **vars = xcalloc (xt->n_vars, sizeof *vars);
- for (size_t i = 0; i < xt->n_vars; i++)
+ int n_vars = (xt->n_vars > 2 ? 2 : xt->n_vars);
+ const struct variable **vars = xcalloc (n_vars, sizeof *vars);
+ for (size_t i = 0; i < n_vars; i++)
vars[i] = xt->vars[i].var;
- chart_item_submit (barchart_create (vars, xt->n_vars, _("Count"),
- false,
- xt->entries, xt->n_entries));
+ chart_submit (barchart_create (vars, n_vars, _("Count"),
+ false,
+ xt->entries, xt->n_entries));
free (vars);
}
}
ds_cstr (&vars));
ds_destroy (&vars);
- free_var_values (xt, COL_VAR);
+ for (size_t i = 0; i < xt->n_vars; i++)
+ free_var_values (xt, i);
return;
}
free (x.mat);
free (x.row_tot);
free (x.col_tot);
+ free (x.const_indexes);
}
if (table)
if (!pivot_table_is_empty (risk))
pivot_table_submit (risk);
else
- pivot_table_destroy (risk);
+ pivot_table_unref (risk);
}
if (direct)
ds_put_format (&title, ", %s=", var_to_string (var));
/* Insert the formatted value of VAR without any leading spaces. */
- s = data_out (value, var_get_encoding (var), var_get_print_format (var));
+ s = data_out (value, var_get_encoding (var), var_get_print_format (var),
+ settings_get_fmt_settings ());
ds_put_cstr (&title, s + strspn (s, " "));
free (s);
}
struct pivot_table *table = pivot_table_create__ (
- pivot_value_new_user_text_nocopy (ds_steal_cstr (&title)));
+ pivot_value_new_user_text_nocopy (ds_steal_cstr (&title)),
+ "Crosstabulation");
pivot_table_set_weight_format (table, &proc->weight_format);
- table->omit_empty = true;
struct pivot_dimension *statistics = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Statistics"));
{
struct pivot_table *chisq = pivot_table_create (N_("Chi-Square Tests"));
pivot_table_set_weight_format (chisq, &xt->weight_format);
- chisq->omit_empty = true;
pivot_dimension_create (
chisq, PIVOT_AXIS_ROW, N_("Statistics"),
{
struct pivot_table *sym = pivot_table_create (N_("Symmetric Measures"));
pivot_table_set_weight_format (sym, &xt->weight_format);
- sym->omit_empty = true;
pivot_dimension_create (
sym, PIVOT_AXIS_COLUMN, N_("Values"),
{
struct pivot_table *risk = pivot_table_create (N_("Risk Estimate"));
pivot_table_set_weight_format (risk, &xt->weight_format);
- risk->omit_empty = true;
struct pivot_dimension *values = pivot_dimension_create (
risk, PIVOT_AXIS_COLUMN, N_("Values"),
N_("Value"), PIVOT_RC_OTHER);
pivot_category_create_group (
+ /* xgettext:no-c-format */
values->root, N_("95% Confidence Interval"),
N_("Lower"), PIVOT_RC_OTHER,
N_("Upper"), PIVOT_RC_OTHER);
{
struct pivot_table *direct = pivot_table_create (N_("Directional Measures"));
pivot_table_set_weight_format (direct, &xt->weight_format);
- direct->omit_empty = true;
pivot_dimension_create (
direct, PIVOT_AXIS_COLUMN, N_("Values"),
N_("Value"), PIVOT_RC_OTHER,
N_("Asymp. Std. Error"), PIVOT_RC_OTHER,
N_("Approx. T"), PIVOT_RC_OTHER,
- N_("Approx Sig."), PIVOT_RC_SIGNIFICANCE);
+ N_("Approx. Sig."), PIVOT_RC_SIGNIFICANCE);
struct pivot_dimension *statistics = pivot_dimension_create (
direct, PIVOT_AXIS_ROW, N_("Statistics"));
/* Given an array of ENTRY_CNT table_entry structures starting at
ENTRIES, creates a sorted list of the values that the variable
- with index VAR_IDX takes on. The values are returned as a
- malloc()'d array stored in *VALUES, with the number of values
- stored in *VALUE_CNT.
-
- The caller must eventually free *VALUES, but each pointer in *VALUES points
- to existing data not owned by *VALUES itself. */
+ with index VAR_IDX takes on. Stores the array of the values in
+ XT->values and the number of values in XT->n_values. */
static void
enum_var_values (const struct crosstabulation *xt, int var_idx,
bool descending)
free_var_values (const struct crosstabulation *xt, int var_idx)
{
struct xtab_var *xv = &xt->vars[var_idx];
- //free (xv->values);
+ free (xv->values);
xv->values = NULL;
xv->n_values = 0;
}
}
}
}
+
+ free (indexes);
}
static void calc_r (struct crosstabulation *,
struct pivot_value *total = pivot_value_new_number (xt->total);
pivot_value_set_rc (sym, total, PIVOT_RC_COUNT);
pivot_table_put (sym, indexes, sym->n_dimensions, total);
+
+ free (indexes);
}
static bool calc_risk (struct crosstabulation *,
pivot_value_new_number (entries[j]));
}
}
+
+ free (indexes);
}
\f
/* Statistical calculations. */