+
+/* Creates and returns a clone of OLD_VAR. Most properties of
+ the new variable are copied from OLD_VAR, except:
+
+ - The variable's short name is not copied, because there is
+ no reason to give a new variable with potentially a new
+ name the same short name.
+
+ - The new variable is not added to OLD_VAR's dictionary by
+ default. Use dict_clone_var, instead, to do that.
+*/
+struct variable *
+var_clone (const struct variable *old_var)
+{
+ struct variable *new_var = var_create (var_get_name (old_var),
+ var_get_width (old_var));
+
+ var_set_missing_values_quiet (new_var, var_get_missing_values (old_var));
+ var_set_print_format_quiet (new_var, var_get_print_format (old_var));
+ var_set_write_format_quiet (new_var, var_get_write_format (old_var));
+ var_set_value_labels_quiet (new_var, var_get_value_labels (old_var));
+ var_set_label_quiet (new_var, var_get_label (old_var), false);
+ var_set_measure_quiet (new_var, var_get_measure (old_var));
+ var_set_role_quiet (new_var, var_get_role (old_var));
+ var_set_display_width_quiet (new_var, var_get_display_width (old_var));
+ var_set_alignment_quiet (new_var, var_get_alignment (old_var));
+ var_set_leave_quiet (new_var, var_get_leave (old_var));
+ var_set_attributes_quiet (new_var, var_get_attributes (old_var));
+
+ return new_var;
+}
+
+
+