X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fxforms%2Frecode.c;h=f4a19a9c9e14bb16052fd9f39dbc3b34f8fe56fb;hb=d775f576e4ffc0973c5f183b57b2baa089f555dc;hp=57a742c96c16b6534dd23c205d39b2140441902a;hpb=5c3291dc396b795696e94f47780308fd7ace6fc4;p=pspp diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 57a742c96c..f4a19a9c9e 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009, 2010 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 @@ -29,8 +29,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -83,6 +83,8 @@ struct recode_trns { struct pool *pool; + + /* Variable types, for convenience. */ enum val_type src_type; /* src_vars[*] type. */ enum val_type dst_type; /* dst_vars[*] type. */ @@ -90,6 +92,7 @@ struct recode_trns /* Variables. */ const struct variable **src_vars; /* Source variables. */ const struct variable **dst_vars; /* Destination variables. */ + const struct dictionary *dst_dict; /* Dictionary of dst_vars */ char **dst_names; /* Name of dest variables, if they're new. */ size_t var_cnt; /* Number of variables. */ @@ -370,7 +373,8 @@ set_map_in_str (struct map_in *in, struct pool *pool, in->type = MAP_SINGLE; value_init_pool (pool, &in->x, width); value_copy_buf_rpad (&in->x, width, - ds_data (string), ds_length (string), ' '); + CHAR_CAST_BUG (uint8_t *, ds_data (string)), + ds_length (string), ' '); } /* Parses a mapping output value into OUT, allocating memory from @@ -540,6 +544,8 @@ create_dst_vars (struct recode_trns *trns, struct dictionary *dict) { size_t i; + trns->dst_dict = dict; + for (i = 0; i < trns->var_cnt; i++) { const struct variable **var = &trns->dst_vars[i]; @@ -598,7 +604,7 @@ find_src_numeric (struct recode_trns *trns, double value, const struct variable /* Returns the output mapping in TRNS for an input of VALUE with the given WIDTH, or a null pointer if there is no mapping. */ static const struct map_out * -find_src_string (struct recode_trns *trns, const char *value, +find_src_string (struct recode_trns *trns, const uint8_t *value, const struct variable *src_var) { struct mapping *m; @@ -624,8 +630,9 @@ find_src_string (struct recode_trns *trns, const char *value, union value uv; msg_disable (); - match = data_in (ss_buffer (value, width), LEGACY_NATIVE, - FMT_F, 0, 0, 0, &uv, 0); + match = data_in (ss_buffer (CHAR_CAST_BUG (char *, value), width), + LEGACY_NATIVE, FMT_F, 0, 0, 0, trns->dst_dict, + &uv, 0); msg_enable (); out->value.f = uv.f; break;