static void determine_charts (void);
-static void precalc (void);
-static int calc (struct ccase *);
-static void postcalc (void);
+static void precalc (void *);
+static int calc (struct ccase *, void *);
+static void postcalc (void *);
static void postprocess_freq_tab (struct variable *);
static void dump_full (struct variable *);
cmd.sort = FRQ_AVALUE;
/* Do it! */
- procedure (precalc, calc, postcalc);
+ procedure (precalc, calc, postcalc, NULL);
return CMD_SUCCESS;
}
/* Add data from case C to the frequency table. */
static int
-calc (struct ccase *c)
+calc (struct ccase *c, void *aux UNUSED)
{
double weight;
int i;
/* Prepares each variable that is the target of FREQUENCIES by setting
up its hash table. */
static void
-precalc (void)
+precalc (void *aux UNUSED)
{
int i;
/* Finishes up with the variables after frequencies have been
calculated. Displays statistics, percentiles, ... */
static void
-postcalc (void)
+postcalc (void *aux UNUSED)
{
int i;
case FRQ_DFREQ | (ALPHA << 16): return compare_freq_alpha_d;
default: assert (0);
}
+
+ return 0;
}
+/* Returns nonzero iff the value in struct freq F is non-missing
+ for variable V. */
static int
not_missing (const void *f_, void *v_)
{
return !is_missing (&f->v, v);
}
+/* Summarizes the frequency table data for variable V. */
static void
-postprocess_freq_tab (struct variable * v)
+postprocess_freq_tab (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)
{
assert (v->p.frq.tab.mode == FRQM_GENERAL);
free (v->p.frq.tab.valid);
+ hsh_destroy (v->p.frq.tab.data);
}
/* Parses the VARIABLES subcommand, adding to
{n_variables,v_variables}. */
static int
-frq_custom_variables (struct cmd_frequencies *cmd unused)
+frq_custom_variables (struct cmd_frequencies *cmd UNUSED)
{
int mode;
- int min, max;
+ int min = 0, max = 0;
int old_n_variables = n_variables;
int i;
/* Parses the GROUPED subcommand, setting the frq.{n_grouped,grouped}
fields of specified variables. */
static int
-frq_custom_grouped (struct cmd_frequencies *cmd unused)
+frq_custom_grouped (struct cmd_frequencies *cmd UNUSED)
{
lex_match ('=');
if ((token == T_ID && dict_lookup_var (default_dict, tokid) != NULL)
return 0;
}
}
- else
- nl = 0;
+ else
+ {
+ nl = 0;
+ dl = NULL;
+ }
for (i = 0; i < n; i++)
{
/* Parses the PERCENTILES subcommand, adding user-specified
percentiles to the list. */
static int
-frq_custom_percentiles (struct cmd_frequencies *cmd unused)
+frq_custom_percentiles (struct cmd_frequencies *cmd UNUSED)
{
lex_match ('=');
if (token != T_NUM)
/* Parses the NTILES subcommand, adding the percentiles that
correspond to the specified evenly-distributed ntiles. */
static int
-frq_custom_ntiles (struct cmd_frequencies *cmd unused)
+frq_custom_ntiles (struct cmd_frequencies *cmd UNUSED)
{
int i;
/* Hash of numeric values. */
static unsigned
-hash_value_numeric (const void *value_, void *foo unused)
+hash_value_numeric (const void *value_, void *foo UNUSED)
{
const struct freq *value = value_;
return hsh_hash_double (value->v.f);
/* Hash of string values. */
static unsigned
-hash_value_alpha (const void *value_, void *len_)
+hash_value_alpha (const void *value_, void *v_)
{
const struct freq *value = value_;
- int *len = len_;
+ struct variable *v = v_;
- return hsh_hash_bytes (value->v.s, *len);
+ return hsh_hash_bytes (value->v.s, v->width);
}
/* Ascending numeric compare of values. */
static int
-compare_value_numeric_a (const void *a_, const void *b_, void *foo unused)
+compare_value_numeric_a (const void *a_, const void *b_, void *foo UNUSED)
{
const struct freq *a = a_;
const struct freq *b = b_;
/* Descending numeric compare of values. */
static int
-compare_value_numeric_d (const void *a, const void *b, void *foo unused)
+compare_value_numeric_d (const void *a, const void *b, void *foo UNUSED)
{
return -compare_value_numeric_a (a, b, foo);
}
/* Ascending numeric compare of frequency;
secondary key on ascending numeric value. */
static int
-compare_freq_numeric_a (const void *a_, const void *b_, void *foo unused)
+compare_freq_numeric_a (const void *a_, const void *b_, void *foo UNUSED)
{
const struct freq *a = a_;
const struct freq *b = b_;
- if (a->v.c > b->v.c)
+ if (a->c > b->c)
return 1;
- else if (a->v.c < b->v.c)
+ else if (a->c < b->c)
return -1;
if (a->v.f > b->v.f)
const struct freq *b = b_;
const struct variable *v = v_;
- if (a->v.c > b->v.c)
+ if (a->c > b->c)
return 1;
- else if (a->v.c < b->v.c)
+ else if (a->c < b->c)
return -1;
else
return memcmp (a->v.s, b->v.s, v->width);
/* Descending numeric compare of frequency;
secondary key on ascending numeric value. */
static int
-compare_freq_numeric_d (const void *a_, const void *b_, void *foo unused)
+compare_freq_numeric_d (const void *a_, const void *b_, void *foo UNUSED)
{
const struct freq *a = a_;
const struct freq *b = b_;
- if (a->v.c > b->v.c)
+ if (a->c > b->c)
return -1;
- else if (a->v.c < b->v.c)
+ else if (a->c < b->c)
return 1;
if (a->v.f > b->v.f)
const struct freq *b = b_;
const struct variable *v = v_;
- if (a->v.c > b->v.c)
+ if (a->c > b->c)
return -1;
- else if (a->v.c < b->v.c)
+ else if (a->c < b->c)
return 1;
else
return memcmp (a->v.s, b->v.s, v->width);