projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Patch #5244.
[pspp]
/
src
/
language
/
xforms
/
recode.c
diff --git
a/src/language/xforms/recode.c
b/src/language/xforms/recode.c
index c9cb203961071d556cbb2a279838fe42f36e8bb0..03fd0bc3dd0fc6132e781b452f16473d5069a910 100644
(file)
--- a/
src/language/xforms/recode.c
+++ b/
src/language/xforms/recode.c
@@
-26,13
+26,15
@@
#include <data/case.h>
#include <data/data-in.h>
#include <data/dictionary.h>
#include <data/case.h>
#include <data/data-in.h>
#include <data/dictionary.h>
-#include <procedure.h>
+#include <
data/
procedure.h>
#include <data/transformations.h>
#include <data/variable.h>
#include <language/command.h>
#include <language/lexer/lexer.h>
#include <data/transformations.h>
#include <data/variable.h>
#include <language/command.h>
#include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
#include <language/lexer/range-parser.h>
#include <libpspp/alloc.h>
#include <language/lexer/range-parser.h>
#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
#include <libpspp/magic.h>
#include <libpspp/message.h>
#include <libpspp/compiler.h>
#include <libpspp/magic.h>
#include <libpspp/message.h>
@@
-56,18
+58,25
@@
enum map_in_type
MAP_CONVERT /* "123" => 123. */
};
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_*. */
/* 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. */
};
/* 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. */
};
int width; /* If copy_input false, output value width. */
};
@@
-552,7
+561,7
@@
find_src_numeric (struct recode_trns *trns, double value, struct variable *v)
match = true;
break;
default:
match = true;
break;
default:
-
abort
();
+
NOT_REACHED
();
}
if (match)
}
if (match)
@@
-585,21
+594,23
@@
find_src_string (struct recode_trns *trns, const char *value, int width)
break;
case MAP_CONVERT:
{
break;
case MAP_CONVERT:
{
+ union value uv;
struct data_in di;
di.s = value;
di.e = value + width;
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);
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:
break;
}
default:
-
abort
();
+
NOT_REACHED
();
}
if (match)
}
if (match)