static bool enlarge_dst_widths (struct recode_trns *);
static void create_dst_vars (struct recode_trns *, struct dictionary *);
-static trns_proc_func recode_trns_proc;
-static trns_free_func recode_trns_free;
+static bool recode_trns_free (void *trns_);
+
+static const struct trns_class recode_trns_class;
\f
/* Parser. */
create_dst_vars (trns, dict);
/* Done. */
- add_transformation (ds,
- recode_trns_proc, recode_trns_free, trns);
+ add_transformation (ds, &recode_trns_class, trns);
}
while (lex_match (lexer, T_SLASH));
if (trns->src_type != VAL_STRING
|| (have_dst_type && trns->dst_type != VAL_NUMERIC))
{
- msg (SE, _("CONVERT requires string input values and "
- "numeric output values."));
+ lex_next_error (lexer, -1, -1,
+ _("CONVERT requires string input values and "
+ "numeric output values."));
return false;
}
}
if (lex_token (lexer) == T_ID
&& lex_id_match (ss_cstr ("THRU"), lex_tokss (lexer)))
{
- msg (SE, _("%s is not allowed with string variables."), "THRU");
+ lex_error (lexer, _("%s is not allowed with string variables."),
+ "THRU");
return false;
}
}
}
else
{
- lex_error (lexer, _("expecting output value"));
+ lex_error (lexer, _("Syntax error expecting output value."));
return false;
}
return true;
const struct variable *v = trns->dst_vars[i];
if (v != NULL && var_get_type (v) != trns->dst_type)
{
- msg (SE, _("Type mismatch. Cannot store %s data in "
- "%s variable %s."),
- trns->dst_type == VAL_STRING ? _("string") : _("numeric"),
- var_is_alpha (v) ? _("string") : _("numeric"),
- var_get_name (v));
+ if (trns->dst_type == VAL_STRING)
+ msg (SE, _("Type mismatch. Cannot store string data in "
+ "numeric variable %s."), var_get_name (v));
+ else
+ msg (SE, _("Type mismatch. Cannot store numeric data in "
+ "string variable %s."), var_get_name (v));
return false;
}
}
match = value == in->x.f;
break;
case MAP_MISSING:
- match = var_is_num_missing (v, value, MV_ANY);
+ match = var_is_num_missing (v, value) != 0;
break;
case MAP_RANGE:
match = value >= in->x.f && value <= in->y.f;
break;
}
case MAP_MISSING:
- match = var_is_str_missing (src_var, value, MV_ANY);
+ match = var_is_str_missing (src_var, value) != 0;
break;
default:
NOT_REACHED ();
}
/* Performs RECODE transformation. */
-static int
+static enum trns_result
recode_trns_proc (void *trns_, struct ccase **c, casenumber case_idx UNUSED)
{
struct recode_trns *trns = trns_;
pool_destroy (trns->pool);
return true;
}
+
+static const struct trns_class recode_trns_class = {
+ .name = "RECODE",
+ .execute = recode_trns_proc,
+ .destroy = recode_trns_free,
+};