X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fautorecode.c;h=887b12230d48222f805a97c37de6298aa15f7971;hb=77ce797fbee4ea815123f46f2dbdad589fd608a2;hp=893880a61b5f8476ebe270bb25ca3476cd0e4c1a;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp-builds.git diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index 893880a6..887b1223 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -1,20 +1,18 @@ -/* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. +/* PSPP - a program for statistical analysis. + Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ #include #include @@ -28,14 +26,14 @@ #include #include #include -#include #include #include #include -#include #include #include +#include "xalloc.h" + #include "gettext.h" #define _(msgid) gettext (msgid) @@ -105,7 +103,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) { struct autorecode_pgm arc; struct casereader *input; - struct ccase c; + struct ccase *c; size_t dst_cnt; size_t i; bool ok; @@ -135,9 +133,9 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) { size_t i; - msg (SE, _("Source variable count (%u) does not match " - "target variable count (%u)."), - (unsigned) arc.var_cnt, (unsigned) dst_cnt); + msg (SE, _("Source variable count (%zu) does not match " + "target variable count (%zu)."), + arc.var_cnt, dst_cnt); for (i = 0; i < dst_cnt; i++) free (arc.dst_names[i]); @@ -191,15 +189,15 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) } input = proc_open (ds); - for (; casereader_read (input, &c); case_destroy (&c)) + for (; (c = casereader_read (input)) != NULL; case_unref (c)) for (i = 0; i < arc.var_cnt; i++) { union arc_value v, *vp, **vpp; if (var_is_numeric (arc.src_vars[i])) - v.f = case_num (&c, arc.src_vars[i]); + v.f = case_num (c, arc.src_vars[i]); else - v.c = (char *) case_str (&c, arc.src_vars[i]); + v.c = (char *) case_str (c, arc.src_vars[i]); vpp = (union arc_value **) hsh_probe (arc.src_values[i], &v); if (*vpp == NULL) @@ -302,11 +300,13 @@ recode (struct dataset *ds, const struct autorecode_pgm *arc) /* Executes an AUTORECODE transformation. */ static int -autorecode_trns_proc (void *trns_, struct ccase *c, casenumber case_idx UNUSED) +autorecode_trns_proc (void *trns_, struct ccase **c, + casenumber case_idx UNUSED) { struct autorecode_trns *trns = trns_; size_t i; + *c = case_unshare (*c); for (i = 0; i < trns->spec_cnt; i++) { struct arc_spec *spec = &trns->specs[i]; @@ -314,12 +314,12 @@ autorecode_trns_proc (void *trns_, struct ccase *c, casenumber case_idx UNUSED) union arc_value v; if (var_is_numeric (spec->src)) - v.f = case_num (c, spec->src); + v.f = case_num (*c, spec->src); else - v.c = (char *) case_str (c, spec->src); + v.c = (char *) case_str (*c, spec->src); item = hsh_force_find (spec->items, &v); - case_data_rw (c, spec->dest)->f = item->to; + case_data_rw (*c, spec->dest)->f = item->to; } return TRNS_CONTINUE; } @@ -355,7 +355,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)); + return hash_bytes (a->c, var_get_width (v), 0); } static int @@ -372,5 +372,5 @@ hash_numeric_value (const void *a_, const void *aux UNUSED) { const union arc_value *a = a_; - return hsh_hash_double (a->f); + return hash_double (a->f, 0); }