Fixed a bug causing pspp to crash when computed variables had no format
[pspp-builds.git] / src / autorecode.c
index bec21badbfc84e35f428cc03ce5a442ec2de66bc..8d15ce63ba3b55fe858cf10e593cd47c9c9f1486 100644 (file)
@@ -76,7 +76,7 @@ static int print;
 
 static int autorecode_trns_proc (struct trns_header *, struct ccase *);
 static void autorecode_trns_free (struct trns_header *);
-static int autorecode_proc_func (struct ccase *);
+static int autorecode_proc_func (struct ccase *, void *);
 static hsh_compare_func compare_alpha_value, compare_numeric_value;
 static hsh_hash_func hash_alpha_value, hash_numeric_value;
 static void recode (void);
@@ -98,7 +98,7 @@ cmd_autorecode (void)
   lex_match_id ("AUTORECODE");
   lex_match_id ("VARIABLES");
   lex_match ('=');
-  if (!parse_variables (&default_dict, &v_src, &nv_src, PV_NO_DUPLICATE))
+  if (!parse_variables (default_dict, &v_src, &nv_src, PV_NO_DUPLICATE))
     return CMD_FAILURE;
   if (!lex_force_match_id ("INTO"))
     return CMD_FAILURE;
@@ -126,7 +126,7 @@ cmd_autorecode (void)
     {
       int j;
 
-      if (is_varname (n_dest[i]))
+      if (dict_lookup_var (default_dict, n_dest[i]) != NULL)
        {
          msg (SE, _("Target variable %s duplicates existing variable %s."),
               n_dest[i], n_dest[i]);
@@ -153,11 +153,12 @@ cmd_autorecode (void)
       h_trans[i] = hsh_create (10, compare_numeric_value,
                               hash_numeric_value, NULL, NULL);
 
-  procedure (NULL, autorecode_proc_func, NULL);
+  procedure (NULL, autorecode_proc_func, NULL, NULL);
 
   for (i = 0; i < nv_dest; i++)
     {
-      v_dest[i] = force_create_variable (&default_dict, n_dest[i], NUMERIC, 0);
+      v_dest[i] = dict_create_var_assert (default_dict, n_dest[i], 0);
+      v_dest[i]->init = 0;
       free (n_dest[i]);
     }
   free (n_dest);
@@ -291,7 +292,7 @@ hash_alpha_value (const void *a_, void *v_)
 }
 
 static int
-compare_numeric_value (const void *a_, const void *b_, void *foo unused)
+compare_numeric_value (const void *a_, const void *b_, void *foo UNUSED)
 {
   const union value *a = a_;
   const union value *b = b_;
@@ -300,7 +301,7 @@ compare_numeric_value (const void *a_, const void *b_, void *foo unused)
 }
 
 static unsigned
-hash_numeric_value (const void *a_, void *foo unused)
+hash_numeric_value (const void *a_, void *foo UNUSED)
 {
   const union value *a = a_;
 
@@ -308,7 +309,7 @@ hash_numeric_value (const void *a_, void *foo unused)
 }
 
 static int
-autorecode_proc_func (struct ccase * c)
+autorecode_proc_func (struct ccase *c, void *aux UNUSED)
 {
   int i;