X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fxforms%2Frecode.c;h=c9787b11bdfeaf3094b1650a76daa50dabedb76e;hb=38993354cabb6fc37bb882be92f9a49e9aeb4c88;hp=f4a19a9c9e14bb16052fd9f39dbc3b34f8fe56fb;hpb=d775f576e4ffc0973c5f183b57b2baa089f555dc;p=pspp diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index f4a19a9c9e..c9787b11bd 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -20,24 +20,25 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xalloc.h" +#include "data/case.h" +#include "data/data-in.h" +#include "data/dictionary.h" +#include "data/format.h" +#include "data/procedure.h" +#include "data/transformations.h" +#include "data/variable.h" +#include "language/command.h" +#include "language/lexer/lexer.h" +#include "language/lexer/value-parser.h" +#include "language/lexer/variable-parser.h" +#include "libpspp/assertion.h" +#include "libpspp/cast.h" +#include "libpspp/compiler.h" +#include "libpspp/message.h" +#include "libpspp/pool.h" +#include "libpspp/str.h" + +#include "gl/xalloc.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -158,6 +159,7 @@ cmd_recode (struct lexer *lexer, struct dataset *ds) /* Create destination variables, if needed. This must be the final step; otherwise we'd have to delete destination variables on failure. */ + trns->dst_dict = dataset_dict (ds); if (trns->src_vars != trns->dst_vars) create_dst_vars (trns, dataset_dict (ds)); @@ -389,7 +391,7 @@ parse_map_out (struct lexer *lexer, struct pool *pool, struct map_out *out) } else if (lex_match_id (lexer, "SYSMIS")) set_map_out_num (out, SYSMIS); - else if (lex_token (lexer) == T_STRING) + else if (lex_is_string (lexer)) { set_map_out_str (out, pool, lex_tokstr (lexer)); lex_get (lexer); @@ -544,8 +546,6 @@ 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]; @@ -607,8 +607,9 @@ static const struct map_out * find_src_string (struct recode_trns *trns, const uint8_t *value, const struct variable *src_var) { - struct mapping *m; + const char *encoding = dict_get_encoding (trns->dst_dict); int width = var_get_width (src_var); + struct mapping *m; for (m = trns->mappings; m < trns->mappings + trns->map_cnt; m++) { @@ -631,8 +632,7 @@ find_src_string (struct recode_trns *trns, const uint8_t *value, msg_disable (); match = data_in (ss_buffer (CHAR_CAST_BUG (char *, value), width), - LEGACY_NATIVE, FMT_F, 0, 0, 0, trns->dst_dict, - &uv, 0); + LEGACY_NATIVE, FMT_F, 0, 0, &uv, 0, encoding); msg_enable (); out->value.f = uv.f; break; @@ -680,7 +680,7 @@ recode_trns_proc (void *trns_, struct ccase **c, casenumber case_idx UNUSED) } else { - char *dst = case_str_rw (*c, dst_var); + char *dst = CHAR_CAST_BUG (char *, case_str_rw (*c, dst_var)); if (out != NULL) { if (!out->copy_input)