static trns_proc_func autorecode_trns_proc;
static trns_free_func autorecode_trns_free;
-static bool autorecode_proc_func (const struct ccase *, void *);
+static bool autorecode_proc_func (const struct ccase *, void *, const struct dataset *);
static hsh_compare_func compare_alpha_value, compare_numeric_value;
static hsh_hash_func hash_alpha_value, hash_numeric_value;
-static void recode (const struct autorecode_pgm *);
+static void recode (struct dataset *, const struct autorecode_pgm *);
static void arc_free (struct autorecode_pgm *);
/* Performs the AUTORECODE procedure. */
int
-cmd_autorecode (void)
+cmd_autorecode (struct lexer *lexer, struct dataset *ds)
{
struct autorecode_pgm arc;
size_t dst_cnt;
arc.print = 0;
dst_cnt = 0;
- lex_match_id ("VARIABLES");
- lex_match ('=');
- if (!parse_variables (default_dict, &arc.src_vars, &arc.var_cnt,
+ lex_match_id (lexer, "VARIABLES");
+ lex_match (lexer, '=');
+ if (!parse_variables (lexer, dataset_dict (ds), &arc.src_vars, &arc.var_cnt,
PV_NO_DUPLICATE))
goto lossage;
- if (!lex_force_match_id ("INTO"))
+ if (!lex_force_match_id (lexer, "INTO"))
goto lossage;
- lex_match ('=');
- if (!parse_DATA_LIST_vars (&arc.dst_names, &dst_cnt, PV_NONE))
+ lex_match (lexer, '=');
+ if (!parse_DATA_LIST_vars (lexer, &arc.dst_names, &dst_cnt, PV_NONE))
goto lossage;
if (dst_cnt != arc.var_cnt)
{
goto lossage;
}
- while (lex_match ('/'))
- if (lex_match_id ("DESCENDING"))
+ while (lex_match (lexer, '/'))
+ if (lex_match_id (lexer, "DESCENDING"))
arc.direction = DESCENDING;
- else if (lex_match_id ("PRINT"))
+ else if (lex_match_id (lexer, "PRINT"))
arc.print = 1;
- if (token != '.')
+ if (lex_token (lexer) != '.')
{
- lex_error (_("expecting end of command"));
+ lex_error (lexer, _("expecting end of command"));
goto lossage;
}
{
int j;
- if (dict_lookup_var (default_dict, arc.dst_names[i]) != NULL)
+ if (dict_lookup_var (dataset_dict (ds), arc.dst_names[i]) != NULL)
{
msg (SE, _("Target variable %s duplicates existing variable %s."),
arc.dst_names[i], arc.dst_names[i]);
arc.src_values[i] = hsh_create (10, compare_numeric_value,
hash_numeric_value, NULL, NULL);
- ok = procedure (autorecode_proc_func, &arc);
+ ok = procedure (ds, autorecode_proc_func, &arc);
for (i = 0; i < arc.var_cnt; i++)
- arc.dst_vars[i] = dict_create_var_assert (default_dict,
+ arc.dst_vars[i] = dict_create_var_assert (dataset_dict (ds),
arc.dst_names[i], 0);
- recode (&arc);
+ recode (ds, &arc);
arc_free (&arc);
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
/* AUTORECODE transformation. */
static void
-recode (const struct autorecode_pgm *arc)
+recode (struct dataset *ds, const struct autorecode_pgm *arc)
{
struct autorecode_trns *trns;
size_t i;
hsh_force_insert (spec->items, item);
}
}
- add_transformation (autorecode_trns_proc, autorecode_trns_free, trns);
+ add_transformation (ds,
+ autorecode_trns_proc, autorecode_trns_free, trns);
}
/* Executes an AUTORECODE transformation. */
static int
-autorecode_trns_proc (void *trns_, struct ccase *c, casenum_t case_idx UNUSED)
+autorecode_trns_proc (void *trns_, struct ccase *c, casenumber case_idx UNUSED)
{
struct autorecode_trns *trns = trns_;
size_t i;
/* AUTORECODE procedure. */
static int
-compare_alpha_value (const void *a_, const void *b_, void *v_)
+compare_alpha_value (const void *a_, const void *b_, const void *v_)
{
const union arc_value *a = a_;
const union arc_value *b = b_;
}
static unsigned
-hash_alpha_value (const void *a_, void *v_)
+hash_alpha_value (const void *a_, const void *v_)
{
const union arc_value *a = a_;
const struct variable *v = v_;
}
static int
-compare_numeric_value (const void *a_, const void *b_, void *foo UNUSED)
+compare_numeric_value (const void *a_, const void *b_, const void *aux UNUSED)
{
const union arc_value *a = a_;
const union arc_value *b = b_;
}
static unsigned
-hash_numeric_value (const void *a_, void *foo UNUSED)
+hash_numeric_value (const void *a_, const void *aux UNUSED)
{
const union arc_value *a = a_;
}
static bool
-autorecode_proc_func (const struct ccase *c, void *arc_)
+autorecode_proc_func (const struct ccase *c, void *arc_, const struct dataset *ds UNUSED)
{
struct autorecode_pgm *arc = arc_;
size_t i;