X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flanguage%2Fxforms%2Frecode.c;h=42fa9ff2157a531671b5aa2f173b56a1c203a10f;hb=d4f19dd9241b87b0b330daf674ed90d767b44822;hp=a2d963188ac949d64fa5e1ea9829d8f59375411a;hpb=339f1956cc727eda788638644ef93ab7852b31cd;p=pspp diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index a2d963188a..42fa9ff215 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -128,8 +128,9 @@ static void set_map_out_str (struct map_out *, struct pool *, 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; /* Parser. */ @@ -173,8 +174,7 @@ cmd_recode (struct lexer *lexer, struct dataset *ds) 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)); @@ -279,8 +279,9 @@ parse_mappings (struct lexer *lexer, struct recode_trns *trns, 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; } } @@ -336,7 +337,8 @@ parse_map_in (struct lexer *lexer, struct map_in *in, struct pool *pool, 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; } } @@ -419,7 +421,7 @@ parse_map_out (struct lexer *lexer, struct pool *pool, struct map_out *out) } else { - lex_error (lexer, _("expecting output value")); + lex_error (lexer, _("Syntax error expecting output value.")); return false; } return true; @@ -520,11 +522,12 @@ parse_dst_vars (struct lexer *lexer, struct recode_trns *trns, 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; } } @@ -615,7 +618,7 @@ find_src_numeric (struct recode_trns *trns, double value, const struct variable 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; @@ -676,7 +679,7 @@ find_src_string (struct recode_trns *trns, const uint8_t *value, 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 (); @@ -690,7 +693,7 @@ find_src_string (struct recode_trns *trns, const uint8_t *value, } /* 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_; @@ -747,3 +750,9 @@ recode_trns_free (void *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, +};