X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fcrosstabs.q;h=99fa41d9c056a039ef9d92fdc9090758539c9d15;hb=8f04b0ced35a66cfdebefbcb53c81979add36ca3;hp=a83a86472f33c74189ed81421f66953197af1711;hpb=f15c854d8500105766b2f5666bb62b983ff24f88;p=pspp-builds.git diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index a83a8647..99fa41d9 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; @@ -881,8 +883,8 @@ make_summary_table (struct crosstabs_proc *proc) { tab_double (summary, i * 2 + 1, 0, TAB_RIGHT, n[i], &proc->weight_format); - tab_text (summary, i * 2 + 2, 0, TAB_RIGHT | TAT_PRINTF, "%.1f%%", - n[i] / n[2] * 100.); + tab_text_format (summary, i * 2 + 2, 0, TAB_RIGHT, "%.1f%%", + n[i] / n[2] * 100.); } tab_next_row (summary); @@ -1191,7 +1193,7 @@ 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], var_get_print_format (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), @@ -1235,9 +1237,9 @@ create_chisq_table (struct pivot_table *pt) tab_text (chisq, 3, 0, TAB_RIGHT | TAT_TITLE, _("Asymp. Sig. (2-sided)")); tab_text (chisq, 4, 0, TAB_RIGHT | TAT_TITLE, - _("Exact. Sig. (2-sided)")); + _("Exact Sig. (2-sided)")); tab_text (chisq, 5, 0, TAB_RIGHT | TAT_TITLE, - _("Exact. Sig. (1-sided)")); + _("Exact Sig. (1-sided)")); tab_offset (chisq, 0, 1); return chisq; @@ -1278,8 +1280,8 @@ create_risk_table (struct pivot_table *pt) tab_title (risk, _("Risk estimate.")); tab_offset (risk, pt->n_vars - 2, 0); - tab_joint_text (risk, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, - _("95%% Confidence Interval")); + tab_joint_text_format (risk, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE, + _("95%% Confidence Interval")); tab_text (risk, 0, 1, TAB_LEFT | TAT_TITLE, _("Statistic")); tab_text (risk, 1, 1, TAB_RIGHT | TAT_TITLE, _("Value")); tab_text (risk, 2, 1, TAB_RIGHT | TAT_TITLE, _("Lower")); @@ -1512,7 +1514,6 @@ 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); @@ -1522,11 +1523,8 @@ table_value_missing (struct crosstabs_proc *proc, return; } - s.string = tab_alloc (table, print->w); - ss = data_out (v, print); - strcpy (s.string, ss); - free (ss); - s.length = print->w; + s = ss_cstr (data_out_pool (v, dict_get_encoding (proc->dict), print, + table->container)); if (proc->exclude == MV_NEVER && var_is_num_missing (var, v->f, MV_USER)) s.string[s.length++] = 'M'; while (s.length && *s.string == ' ') @@ -1559,19 +1557,15 @@ 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; - ss = data_out (&v, &f); - strcpy (s.string, ss); - free (ss); + s = ss_cstr (data_out_pool (&v, dict_get_encoding (dict), &f, table->container)); + while (*s.string == ' ') { s.length--; @@ -1657,7 +1651,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++; @@ -1708,7 +1702,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); } } @@ -1758,7 +1752,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; } @@ -2068,8 +2062,8 @@ display_directional (struct crosstabs_proc *proc, struct pivot_table *pt, else string = var_get_name (pt->vars[1]); - tab_text (direct, j, 0, TAB_LEFT | TAT_PRINTF, - gettext (stats_names[j][k]), string); + tab_text_format (direct, j, 0, TAB_LEFT, + gettext (stats_names[j][k]), string); } } }