X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fcrosstabs.q;h=3c689ebc494c581d1906d5e0ee6d0c92be18f6b3;hb=729b96a6bd9342c45e6f65a113fd87c70da85b0a;hp=70bbe5cc95b31857214fa50f21e3070466b9a80f;hpb=75a44b28768f03ff9774fd9252d1e0f5051f13ea;p=pspp-builds.git diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 70bbe5cc..3c689ebc 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -177,6 +177,7 @@ get_var_range (const struct variable *v) struct crosstabs_proc { + const struct dictionary *dict; enum { INTEGER, GENERAL } mode; enum mv_class exclude; bool pivot; @@ -204,6 +205,7 @@ static void init_proc (struct crosstabs_proc *proc, struct dataset *ds) { const struct variable *wv = dict_get_weight (dataset_dict (ds)); + proc->dict = dataset_dict (ds); proc->bad_warn = true; proc->variables = NULL; proc->n_variables = 0; @@ -1184,14 +1186,16 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt) { const struct variable *var = pt->const_vars[i]; size_t ofs; + char *s = NULL; ds_put_format (&title, ", %s=", var_get_name (var)); /* Insert the formatted value of the variable, then trim leading spaces in what was just inserted. */ ofs = ds_length (&title); - data_out (&pt->const_values[i], var_get_print_format (var), - ds_put_uninit (&title, var_get_width (var))); + s = data_out (&pt->const_values[i], dict_get_encoding (proc->dict), var_get_print_format (var)); + ds_put_cstr (&title, s); + free (s); ds_remove (&title, ofs, ss_cspan (ds_substr (&title, ofs, SIZE_MAX), ss_cstr (" "))); } @@ -1510,6 +1514,7 @@ table_value_missing (struct crosstabs_proc *proc, const union value *v, const struct variable *var) { struct substring s; + char *ss; const struct fmt_spec *print = var_get_print_format (var); const char *label = var_lookup_value_label (var, v); @@ -1520,7 +1525,9 @@ table_value_missing (struct crosstabs_proc *proc, } s.string = tab_alloc (table, print->w); - data_out (v, print, s.string); + ss = data_out (v, dict_get_encoding (proc->dict), print); + strcpy (s.string, ss); + free (ss); s.length = print->w; if (proc->exclude == MV_NEVER && var_is_num_missing (var, v->f, MV_USER)) s.string[s.length++] = 'M'; @@ -1554,16 +1561,19 @@ display_dimensions (struct crosstabs_proc *proc, struct pivot_table *pt, additionally suffixed with a letter `M'. */ static void format_cell_entry (struct tab_table *table, int c, int r, double value, - char suffix, bool mark_missing) + char suffix, bool mark_missing, const struct dictionary *dict) { const struct fmt_spec f = {FMT_F, 10, 1}; union value v; struct substring s; + char *ss; s.length = 10; s.string = tab_alloc (table, 16); v.f = value; - data_out (&v, &f, s.string); + ss = data_out (&v, dict_get_encoding (dict), &f); + strcpy (s.string, ss); + free (ss); while (*s.string == ' ') { s.length--; @@ -1649,7 +1659,7 @@ display_crosstabulation (struct crosstabs_proc *proc, struct pivot_table *pt, default: NOT_REACHED (); } - format_cell_entry (table, c, i, v, suffix, mark_missing); + format_cell_entry (table, c, i, v, suffix, mark_missing, proc->dict); } mp++; @@ -1700,7 +1710,7 @@ display_crosstabulation (struct crosstabs_proc *proc, struct pivot_table *pt, NOT_REACHED (); } - format_cell_entry (table, pt->n_cols, 0, v, suffix, mark_missing); + format_cell_entry (table, pt->n_cols, 0, v, suffix, mark_missing, proc->dict); tab_next_row (table); } } @@ -1750,7 +1760,7 @@ display_crosstabulation (struct crosstabs_proc *proc, struct pivot_table *pt, NOT_REACHED (); } - format_cell_entry (table, c, i, v, suffix, mark_missing); + format_cell_entry (table, c, i, v, suffix, mark_missing, proc->dict); } last_row = i; }