X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fxforms%2Frecode.c;h=86bd8b88292a6a46163bf0d07f1b464eb6aa0bda;hb=762876f19fa870401ae882515de1b58703b73ac4;hp=38bb5508e1260149e54b02a1d4b71d4eb80c75f2;hpb=2322678e8fddbbf158b01b2720db2636404bba3b;p=pspp-builds.git diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 38bb5508..86bd8b88 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -18,23 +18,27 @@ 02110-1301, USA. */ #include -#include "message.h" + #include #include #include -#include "alloc.h" -#include "case.h" -#include "command.h" -#include "compiler.h" -#include "data-in.h" -#include "dictionary.h" -#include "message.h" -#include "lexer.h" -#include "magic.h" -#include "pool.h" -#include "range-parser.h" -#include "str.h" -#include "variable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -52,18 +56,25 @@ enum map_in_type MAP_CONVERT /* "123" => 123. */ }; +/* A value involved in a RECODE mapping. */ +union recode_value + { + double f; /* Numeric. */ + char *c; /* Short or long string. */ + }; + /* Describes input values to be mapped. */ struct map_in { enum map_in_type type; /* One of MAP_*. */ - union value x, y; /* Source values. */ + union recode_value x, y; /* Source values. */ }; /* Describes the value used as output from a mapping. */ struct map_out { bool copy_input; /* If true, copy input to output. */ - union value value; /* If copy_input false, recoded value. */ + union recode_value value; /* If copy_input false, recoded value. */ int width; /* If copy_input false, output value width. */ }; @@ -139,7 +150,7 @@ cmd_recode (void) || !parse_dst_vars (trns)) { recode_trns_free (trns); - return CMD_PART_SUCCESS; + return CMD_FAILURE; } /* Ensure that all the output strings are at least as wide @@ -581,17 +592,19 @@ find_src_string (struct recode_trns *trns, const char *value, int width) break; case MAP_CONVERT: { + union value uv; struct data_in di; di.s = value; di.e = value + width; - di.v = &out->value; + di.v = &uv; di.flags = DI_IGNORE_ERROR; di.f1 = di.f2 = 0; di.format.type = FMT_F; di.format.w = width; di.format.d = 0; match = data_in (&di); + out->value.f = uv.f; break; } default: