X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fautorecode.c;h=893880a61b5f8476ebe270bb25ca3476cd0e4c1a;hb=f5c108becd49d78f4898cab11352291f5689d24e;hp=4e5628a0cc5dd2ff0862bd5abab5e94e96ce823b;hpb=7eee0554f378481faf447e2d2e940f389d6b05ec;p=pspp-builds.git diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index 4e5628a0..893880a6 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -42,7 +42,7 @@ /* FIXME: Implement PRINT subcommand. */ /* An AUTORECODE variable's original value. */ -union arc_value +union arc_value { double f; /* Numeric. */ char *c; /* Short or long string. */ @@ -72,14 +72,14 @@ struct autorecode_trns }; /* Descending or ascending sort order. */ -enum direction +enum direction { ASCENDING, DESCENDING }; /* AUTORECODE data. */ -struct autorecode_pgm +struct autorecode_pgm { const struct variable **src_vars; /* Source variables. */ char **dst_names; /* Target variable names. */ @@ -122,7 +122,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) lex_match_id (lexer, "VARIABLES"); lex_match (lexer, '='); - if (!parse_variables_const (lexer, dataset_dict (ds), &arc.src_vars, + if (!parse_variables_const (lexer, dataset_dict (ds), &arc.src_vars, &arc.var_cnt, PV_NO_DUPLICATE)) goto lossage; @@ -230,19 +230,19 @@ lossage: } static void -arc_free (struct autorecode_pgm *arc) +arc_free (struct autorecode_pgm *arc) { free (arc->src_vars); - if (arc->dst_names != NULL) + if (arc->dst_names != NULL) { size_t i; - + for (i = 0; i < arc->var_cnt; i++) free (arc->dst_names[i]); free (arc->dst_names); } free (arc->dst_vars); - if (arc->src_values != NULL) + if (arc->src_values != NULL) { size_t i; @@ -286,7 +286,7 @@ recode (struct dataset *ds, const struct autorecode_pgm *arc) { struct arc_item *item = pool_alloc (trns->pool, sizeof *item); union arc_value *vp = *p; - + if (var_is_numeric (arc->src_vars[i])) item->from.f = vp->f; else @@ -296,7 +296,7 @@ recode (struct dataset *ds, const struct autorecode_pgm *arc) hsh_force_insert (spec->items, item); } } - add_transformation (ds, + add_transformation (ds, autorecode_trns_proc, autorecode_trns_free, trns); } @@ -354,7 +354,7 @@ hash_alpha_value (const void *a_, const void *v_) { const union arc_value *a = a_; const struct variable *v = v_; - + return hsh_hash_bytes (a->c, var_get_width (v)); }