str: Add function xstrdup_if_nonnull() and introduce many users.
[pspp] / src / language / stats / autorecode.c
index c093b1e6ab7af66245f47183f5e2d6c75ce03505..3b51928fc64e4633008d0cc24b5e484d3312d618 100644 (file)
@@ -245,7 +245,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds)
       spec->format = *var_get_print_format (src_vars[i]);
 
       const char *label = var_get_label (src_vars[i]);
-      spec->label = label ? xstrdup (label) : NULL;
+      spec->label = xstrdup_if_nonnull (label);
 
       if (group && i > 0)
         spec->items = arc->specs[0].items;
@@ -491,9 +491,10 @@ arc_free (struct autorecode_pgm *arc)
         }
 
       size_t n_rec_items =
-        (arc->n_specs == 1 || arc->specs[0].items == arc->specs[1].items
+        (arc->n_specs >= 2 && arc->specs[0].items == arc->specs[1].items
          ? 1
          : arc->n_specs);
+
       for (size_t i = 0; i < n_rec_items; i++)
         {
           struct arc_spec *spec = &arc->specs[i];