X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffrequencies.q;h=e46bb1dc3839415d9d03bde87de3367b47e4321c;hb=c87013b64d1731dac5da8f738ae8d1b4c1030a90;hp=d1a75f72e347046c4c272f3aba410a61c3e4aff2;hpb=7b98b3a4f58f6dc5a8e9cbc188b627966d5e652d;p=pspp-builds.git diff --git a/src/frequencies.q b/src/frequencies.q index d1a75f72..e46bb1dc 100644 --- a/src/frequencies.q +++ b/src/frequencies.q @@ -160,9 +160,9 @@ static struct pool *gen_pool; /* General mode. */ 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 *); @@ -246,7 +246,7 @@ internal_cmd_frequencies (void) cmd.sort = FRQ_AVALUE; /* Do it! */ - procedure (precalc, calc, postcalc); + procedure_with_splits (precalc, calc, postcalc, NULL); return CMD_SUCCESS; } @@ -355,7 +355,7 @@ determine_charts (void) /* 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; @@ -408,7 +408,7 @@ calc (struct ccase *c) /* 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; @@ -451,7 +451,7 @@ precalc (void) /* Finishes up with the variables after frequencies have been calculated. Displays statistics, percentiles, ... */ static void -postcalc (void) +postcalc (void *aux UNUSED) { int i; @@ -518,6 +518,8 @@ get_freq_comparator (int frq_sort, int var_type) 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_) { @@ -527,8 +529,9 @@ 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; @@ -575,11 +578,13 @@ postprocess_freq_tab (struct variable * v) } } +/* 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 @@ -588,7 +593,7 @@ static int 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; @@ -715,8 +720,11 @@ frq_custom_grouped (struct cmd_frequencies *cmd UNUSED) return 0; } } - else - nl = 0; + else + { + nl = 0; + dl = NULL; + } for (i = 0; i < n; i++) { @@ -889,9 +897,9 @@ 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) @@ -911,9 +919,9 @@ compare_freq_alpha_a (const void *a_, const void *b_, void *v_) 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); @@ -927,9 +935,9 @@ 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) @@ -949,9 +957,9 @@ compare_freq_alpha_d (const void *a_, const void *b_, void *v_) 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);