(dict_clone): Copy case indexes from cloned dictionary. Fixes bug
[pspp-builds.git] / src / data / dictionary.c
index 46abaa7316cea0250c9635571f2e429bf0a362e8..5d6633bd7ad61e98f4288a9f88e797486c2efd49 100644 (file)
@@ -116,7 +116,13 @@ dict_create (void)
 }
 
 /* Creates and returns a (deep) copy of an existing
-   dictionary. */
+   dictionary.
+
+   The new dictionary's case indexes are copied from the old
+   dictionary.  If the new dictionary won't be used to access
+   cases produced with the old dictionary, then the new
+   dictionary's case indexes should be compacted with
+   dict_compact_values to save space. */
 struct dictionary *
 dict_clone (const struct dictionary *s)
 {
@@ -135,6 +141,8 @@ dict_clone (const struct dictionary *s)
 
       for (i = 0; i < var_get_short_name_cnt (sv); i++)
         var_set_short_name (dv, i, var_get_short_name (sv, i));
+
+      var_set_vardict (dv, var_get_vardict (sv));
     }
 
   d->next_value_idx = s->next_value_idx;