variable: Introduce and use new function var_get_encoding().
[pspp] / src / language / stats / crosstabs.q
index 5dc7069af569d597e65fac0eb9daf1ee6d58ba49..d0fd6dd51fcc88bf3631c4e01768b1281ece9a6e 100644 (file)
@@ -654,9 +654,7 @@ tabulate_general_case (struct pivot_table *pt, const struct ccase *c,
   for (j = 0; j < pt->n_vars; j++)
     {
       const struct variable *var = pt->vars[j];
-      int width = var_get_width (var);
-      value_init (&te->values[j], width);
-      value_copy (&te->values[j], case_data (c, var), width);
+      value_clone (&te->values[j], case_data (c, var), var_get_width (var));
     }
   hmap_insert (&pt->data, &te->node, hash);
 }
@@ -1193,7 +1191,8 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt)
       /* Insert the formatted value of the variable, then trim
          leading spaces in what was just inserted. */
       ofs = ds_length (&title);
-      s = data_out (&pt->const_values[i], dict_get_encoding (proc->dict), var_get_print_format (var));
+      s = data_out (&pt->const_values[i], var_get_encoding (var),
+                    var_get_print_format (var));
       ds_put_cstr (&title, s);
       free (s);
       ds_remove (&title, ofs, ss_cspan (ds_substr (&title, ofs, SIZE_MAX),