+Sat May 6 15:58:36 2006 Ben Pfaff <blp@gnu.org>
+
+ Get rid of `char *c' member in union value, for cleanliness.
+
+ * value.h: (union value) Remove `c' member.
+
Sat May 6 15:36:59 2006 Ben Pfaff <blp@gnu.org>
Make dictionary compacting functions a little more general.
#define LOWEST second_lowest_value
#define HIGHEST DBL_MAX
-/* Describes one value, which is either a floating-point number or a
- short string. */
+/* A numeric or short string value.
+ Multiple consecutive values represent a long string. */
union value
{
- /* A numeric value. */
double f;
-
- /* A short-string value. */
char s[MAX_SHORT_STRING];
-
- /* Used by evaluate_expression() to return a string result.
- As currently implemented, it's a pointer to a dynamic
- buffer in the appropriate expression.
-
- Also used by the AGGREGATE procedure in handling string
- values. */
- char *c;
};
/* Maximum number of `union value's in a single number or string
+Sat May 6 16:00:13 2006 Ben Pfaff <blp@gnu.org>
+
+ Get rid of `char *c' member in union value, for cleanliness.
+
+ * aggregate.c: (union agr_argument) New union.
+ (struct agr_var) Change element type of arg[] from union value to
+ union agr_argument.
+ (parse_aggregate_functions) Change local variable types likewise.
+
+ * autorecode.c: (union arc_value) New union.
+ (struct arc_item) Change "from" from union value to union
+ arc_value.
+ (recode) Change local variable from union value to union
+ arc_value.
+ (autorecode_trns_proc) Ditto.
+ (compare_alpha_value) Ditto.
+ (hash_alpha_value) Ditto.
+ (compare_numeric_value) Ditto.
+ (hash_numeric_value) Ditto.
+ (autorecode_proc_func) Ditto.
+
Sat May 6 10:43:33 2006 Ben Pfaff <blp@gnu.org>
Continue reforming procedure execution. In this phase, get rid of
#include "gettext.h"
#define _(msgid) gettext (msgid)
+/* Argument for AGGREGATE function. */
+union agr_argument
+ {
+ double f; /* Numeric. */
+ char *c; /* Short or long string. */
+ };
+
/* Specifies how to make an aggregate variable. */
struct agr_var
{
struct variable *dest; /* Target variable. */
int function; /* Function. */
int include_missing; /* 1=Include user-missing values. */
- union value arg[2]; /* Arguments. */
+ union agr_argument arg[2]; /* Arguments. */
/* Accumulated during AGGREGATE execution. */
double dbl[3];
const struct agr_func *function;
int func_index;
- union value arg[2];
+ union agr_argument arg[2];
struct variable **src;
size_t n_src;
|| (src[0]->type == ALPHA
&& str_compare_rpad (arg[0].c, arg[1].c) > 0)))
{
- union value t = arg[0];
+ union agr_argument t = arg[0];
arg[0] = arg[1];
arg[1] = t;
/* FIXME: Implement PRINT subcommand. */
+/* An AUTORECODE variable's original value. */
+union arc_value
+ {
+ double f; /* Numeric. */
+ char *c; /* Short or long string. */
+ };
+
/* Explains how to recode one value. `from' must be first element. */
struct arc_item
{
- union value from; /* Original value. */
+ union arc_value from; /* Original value. */
double to; /* Recoded value. */
};
struct variable **src_vars; /* Source variables. */
char **dst_names; /* Target variable names. */
struct variable **dst_vars; /* Target variables. */
- struct hsh_table **src_values; /* `union value's of source vars. */
+ struct hsh_table **src_values; /* `union arc_value's of source vars. */
size_t var_cnt; /* Number of variables. */
struct pool *src_values_pool; /* Pool used by src_values. */
enum direction direction; /* Sort order. */
for (j = 0; *p; p++, j++)
{
struct arc_item *item = pool_alloc (trns->pool, sizeof *item);
- union value *vp = *p;
+ union arc_value *vp = *p;
if (arc->src_vars[i]->type == NUMERIC)
item->from.f = vp->f;
{
struct arc_spec *spec = &trns->specs[i];
struct arc_item *item;
- union value v;
+ union arc_value v;
if (spec->src->type == NUMERIC)
v.f = case_num (c, spec->src->fv);
static int
compare_alpha_value (const void *a_, const void *b_, void *v_)
{
- const union value *a = a_;
- const union value *b = b_;
+ const union arc_value *a = a_;
+ const union arc_value *b = b_;
const struct variable *v = v_;
return memcmp (a->c, b->c, v->width);
static unsigned
hash_alpha_value (const void *a_, void *v_)
{
- const union value *a = a_;
+ const union arc_value *a = a_;
const struct variable *v = v_;
return hsh_hash_bytes (a->c, v->width);
static int
compare_numeric_value (const void *a_, const void *b_, void *foo UNUSED)
{
- const union value *a = a_;
- const union value *b = b_;
+ const union arc_value *a = a_;
+ const union arc_value *b = b_;
return a->f < b->f ? -1 : a->f > b->f;
}
static unsigned
hash_numeric_value (const void *a_, void *foo UNUSED)
{
- const union value *a = a_;
+ const union arc_value *a = a_;
return hsh_hash_double (a->f);
}
for (i = 0; i < arc->var_cnt; i++)
{
- union value v, *vp, **vpp;
+ union arc_value v, *vp, **vpp;
if (arc->src_vars[i]->type == NUMERIC)
v.f = case_num (c, arc->src_vars[i]->fv);
else
v.c = (char *) case_str (c, arc->src_vars[i]->fv);
- vpp = (union value **) hsh_probe (arc->src_values[i], &v);
+ vpp = (union arc_value **) hsh_probe (arc->src_values[i], &v);
if (*vpp == NULL)
{
vp = pool_alloc (arc->src_values_pool, sizeof *vp);
+Sat May 6 16:02:55 2006 Ben Pfaff <blp@gnu.org>
+
+ Get rid of `char *c' member in union value, for cleanliness.
+
+ * recode.c: (union recode_value) New union.
+ (struct map_in) Change x, y types to union recode_value.
+ (struct map_out) Change value type to union recode_value.
+ (find_src_string) Wrap data_in() call so it uses a real `union
+ value'.
+
Sat May 6 14:08:42 2006 Ben Pfaff <blp@gnu.org>
* select-if.c (cmd_filter): Make FILTER without any further
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. */
};
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: