/* Variables for which to calculate statistics. */
static size_t n_variables;
-static struct variable **v_variables;
+static const struct variable **v_variables;
/* Arenas used to store semi-permanent storage. */
static struct pool *int_pool; /* Integer mode. */
static void determine_charts (void);
-static void calc_stats (struct variable *v, double d[frq_n_stats]);
+static void calc_stats (const struct variable *v, double d[frq_n_stats]);
static void precalc (const struct ccase *, void *, const struct dataset *);
static bool calc (const struct ccase *, void *, const struct dataset *);
static bool postcalc (void *, const struct dataset *);
-static void postprocess_freq_tab (struct variable *);
-static void dump_full (struct variable *);
-static void dump_condensed (struct variable *);
-static void dump_statistics (struct variable *, int show_varname);
-static void cleanup_freq_tab (struct variable *);
+static void postprocess_freq_tab (const struct variable *);
+static void dump_full (const struct variable *);
+static void dump_condensed (const struct variable *);
+static void dump_statistics (const struct variable *, int show_varname);
+static void cleanup_freq_tab (const struct variable *);
static hsh_compare_func compare_value_numeric_a, compare_value_alpha_a;
static hsh_compare_func compare_value_numeric_d, compare_value_alpha_d;
for (i = 0; i < n_variables; i++)
{
- struct variable *v = v_variables[i];
+ const struct variable *v = v_variables[i];
struct freq_tab *ft = &get_var_freqs (v)->tab;
if (ft->mode == FRQM_GENERAL)
for (i = 0; i < n_variables; i++)
{
- struct variable *v = v_variables[i];
+ const struct variable *v = v_variables[i];
struct var_freqs *vf = get_var_freqs (v);
struct freq_tab *ft = &vf->tab;
int n_categories;
const struct freq *f = f_;
const struct variable *v = v_;
- return !var_is_value_missing (v, f->value);
+ return !var_is_value_missing (v, f->value, MV_ANY);
}
/* Summarizes the frequency table data for variable V. */
static void
-postprocess_freq_tab (struct variable *v)
+postprocess_freq_tab (const struct variable *v)
{
hsh_compare_func *compare;
struct freq_tab *ft;
/* Frees the frequency table for variable V. */
static void
-cleanup_freq_tab (struct variable *v)
+cleanup_freq_tab (const struct variable *v)
{
struct freq_tab *ft = &get_var_freqs (v)->tab;
assert (ft->mode == FRQM_GENERAL);
|| dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL))
return 2;
- if (!parse_variables (lexer, dataset_dict (ds), &v_variables, &n_variables,
+ if (!parse_variables_const (lexer, dataset_dict (ds), &v_variables, &n_variables,
PV_APPEND | PV_NO_SCRATCH))
return 0;
for (i = old_n_variables; i < n_variables; i++)
{
- struct variable *v = v_variables[i];
+ const struct variable *v = v_variables[i];
struct var_freqs *vf;
if (var_get_aux (v) != NULL)
/* Variable list. */
size_t n;
- struct variable **v;
+ const struct variable **v;
- if (!parse_variables (lexer, dataset_dict (ds), &v, &n,
+ if (!parse_variables_const (lexer, dataset_dict (ds), &v, &n,
PV_NO_DUPLICATE | PV_NUMERIC))
return 0;
if (lex_match (lexer, '('))
static void
full_dim (struct tab_table *t, struct outp_driver *d)
{
- int lab = cmd.labels == FRQ_LABELS;
- int i;
+ int i = 0;
+ int columns = 5;
- if (lab)
+ if (cmd.labels == FRQ_LABELS)
+ {
t->w[0] = MIN (tab_natural_width (t, d, 0), d->prop_em_width * 15);
- for (i = lab; i < lab + 5; i++)
+ i = 1;
+ columns ++;
+ }
+
+ for (;i < columns; i++)
t->w[i] = MAX (tab_natural_width (t, d, i), d->prop_em_width * 8);
+
for (i = 0; i < t->nr; i++)
t->h[i] = d->font_height;
}
/* Displays a full frequency table for variable V. */
static void
-dump_full (struct variable *v)
+dump_full (const struct variable *v)
{
int n_categories;
struct var_freqs *vf;
{-1, -1, NULL},
};
- int lab = cmd.labels == FRQ_LABELS;
+ const bool lab = (cmd.labels == FRQ_LABELS);
vf = get_var_freqs (v);
ft = &vf->tab;
if (lab)
tab_text (t, 0, 1, TAB_CENTER | TAT_TITLE, _("Value Label"));
+
for (p = vec; p->s; p++)
- tab_text (t, p->c - (p->r ? !lab : 0), p->r,
+ tab_text (t, lab ? p->c : p->c - 1, p->r,
TAB_CENTER | TAT_TITLE, gettext (p->s));
r = 2;
if (lab)
{
-#if 0
-<<<<<<< frequencies.q
- const char *label = val_labs_find (v->val_labs, f->value[0]);
-=======
-#endif
const char *label = var_lookup_value_label (v, &f->value[0]);
if (label != NULL)
tab_text (t, 0, r, TAB_LEFT, label);
/* Display condensed frequency table for variable V. */
static void
-dump_condensed (struct variable *v)
+dump_condensed (const struct variable *v)
{
int n_categories;
struct var_freqs *vf;
/* Calculates all the pertinent statistics for variable V, putting
them in array D[]. FIXME: This could be made much more optimal. */
static void
-calc_stats (struct variable *v, double d[frq_n_stats])
+calc_stats (const struct variable *v, double d[frq_n_stats])
{
struct freq_tab *ft = &get_var_freqs (v)->tab;
double W = ft->valid_cases;
/* Displays a table of all the statistics requested for variable V. */
static void
-dump_statistics (struct variable *v, int show_varname)
+dump_statistics (const struct variable *v, int show_varname)
{
struct freq_tab *ft;
double stat_value[frq_n_stats];
/* Find out the extremes of the x value */
for ( frq = hsh_first(fh, &hi); frq != 0; frq = hsh_next(fh, &hi) )
{
- if ( var_is_value_missing(var, frq->value))
+ if (var_is_value_missing(var, frq->value, MV_ANY))
continue;
if ( frq->value[0].f < x_min ) x_min = frq->value[0].f ;