Miscellaneous cleanup to categorical values, linreg and design matrix code.
[pspp] / src / language / xforms / recode.c
index 18f724432fcae680450d0c3ebee465b569a9904d..83d48553479b9e0f0f91dc1c5b201d15602a6064 100644 (file)
@@ -260,6 +260,7 @@ parse_mappings (struct lexer *lexer, struct recode_trns *trns)
           struct map_in in;
           set_map_in_generic (&in, MAP_CONVERT);
           add_mapping (trns, &map_allocated, &in);
+          set_map_out_num (&trns->mappings[trns->map_cnt - 1].out, 0.0);
               
           dst_type = VAR_NUMERIC;
           if (trns->src_type != VAR_STRING
@@ -312,6 +313,12 @@ parse_map_in (struct lexer *lexer, struct map_in *in, struct pool *pool,
         return false;
       set_map_in_str (in, pool, lex_tokstr (lexer), max_src_width);
       lex_get (lexer);
+      if (lex_token (lexer) == T_ID
+          && lex_id_match (ss_cstr ("THRU"), ss_cstr (lex_tokid (lexer)))) 
+        {
+          msg (SE, _("THRU is not allowed with string variables."));
+          return false; 
+        }
     }
 
   return true;
@@ -509,7 +516,7 @@ enlarge_dst_widths (struct recode_trns *trns)
       if (!out->copy_input && out->width < max_dst_width) 
         {
           char *s = pool_alloc_unaligned (trns->pool, max_dst_width + 1);
-          str_copy_rpad (s, max_dst_width + 1, out->value.c);
+          buf_copy_rpad (s, max_dst_width + 1, out->value.c, out->width);
           out->value.c = s;
         }
     }
@@ -554,7 +561,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_USER);
+          match = var_is_num_missing (v, value, MV_ANY);
           break;
         case MAP_RANGE:
           match = value >= in->x.f && value <= in->y.f;
@@ -636,9 +643,9 @@ recode_trns_proc (void *trns_, struct ccase *c, casenumber case_idx UNUSED)
       const struct map_out *out;
 
       if (trns->src_type == VAR_NUMERIC) 
-          out = find_src_numeric (trns, src_data->f, src_var);
+        out = find_src_numeric (trns, src_data->f, src_var);
       else
-          out = find_src_string (trns, src_data->s, var_get_width (src_var));
+        out = find_src_string (trns, src_data->s, var_get_width (src_var));
 
       if (trns->dst_type == VAR_NUMERIC) 
         {