From: John Darrington Date: Tue, 7 Jul 2009 04:19:17 +0000 (+0800) Subject: Add dictionary argument to tab_value. X-Git-Tag: build37~53^2~19 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44c2b035a7526fdf366271de915fc774df302f96;p=pspp-builds.git Add dictionary argument to tab_value. In order to properly display values, tab_value needs to know the dictionary from whence the value comes. This is necessary so that string values can be properly decoded. This change adds this argument to tab_value and updates all callers. --- diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 8295f51a..83b864c9 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -207,6 +207,8 @@ struct freq_tab struct hsh_table *data; /* Undifferentiated data. */ struct freq_mutable *valid; /* Valid freqs. */ int n_valid; /* Number of total freqs. */ + const struct dictionary *dict; /* The dict from whence entries in the table + come */ struct freq_mutable *missing; /* Missing freqs. */ int n_missing; /* Number of missing freqs. */ @@ -755,6 +757,7 @@ frq_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_freque } vf = var_attach_aux (v, xmalloc (sizeof *vf), var_dtor_free); vf->tab.valid = vf->tab.missing = NULL; + vf->tab.dict = dataset_dict (ds); vf->n_groups = 0; vf->groups = NULL; vf->width = var_get_width (v); @@ -1091,7 +1094,7 @@ dump_full (const struct variable *v, const struct variable *wv) tab_text (t, 0, r, TAB_LEFT, label); } - tab_value (t, 0 + lab, r, TAB_NONE, &f->value, &vf->print); + tab_value (t, 0 + lab, r, TAB_NONE, &f->value, ft->dict, &vf->print); tab_double (t, 1 + lab, r, TAB_NONE, f->count, wfmt); tab_double (t, 2 + lab, r, TAB_NONE, percent, NULL); tab_double (t, 3 + lab, r, TAB_NONE, valid_percent, NULL); @@ -1109,7 +1112,7 @@ dump_full (const struct variable *v, const struct variable *wv) tab_text (t, 0, r, TAB_LEFT, label); } - tab_value (t, 0 + lab, r, TAB_NONE, &f->value, &vf->print); + tab_value (t, 0 + lab, r, TAB_NONE, &f->value, ft->dict, &vf->print); tab_double (t, 1 + lab, r, TAB_NONE, f->count, wfmt); tab_double (t, 2 + lab, r, TAB_NONE, f->count / ft->total_cases * 100.0, NULL); @@ -1185,7 +1188,7 @@ dump_condensed (const struct variable *v, const struct variable *wv) percent = f->count / ft->total_cases * 100.0; cum_total += f->count / ft->valid_cases * 100.0; - tab_value (t, 0, r, TAB_NONE, &f->value, &vf->print); + tab_value (t, 0, r, TAB_NONE, &f->value, ft->dict, &vf->print); tab_double (t, 1, r, TAB_NONE, f->count, wfmt); tab_double (t, 2, r, TAB_NONE, percent, NULL); tab_double (t, 3, r, TAB_NONE, cum_total, NULL); @@ -1193,7 +1196,7 @@ dump_condensed (const struct variable *v, const struct variable *wv) } for (; f < &ft->valid[n_categories]; f++) { - tab_value (t, 0, r, TAB_NONE, &f->value, &vf->print); + tab_value (t, 0, r, TAB_NONE, &f->value, ft->dict, &vf->print); tab_double (t, 1, r, TAB_NONE, f->count, wfmt); tab_double (t, 2, r, TAB_NONE, f->count / ft->total_cases * 100.0, NULL); diff --git a/src/output/table.c b/src/output/table.c index 97d16117..2de17901 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -518,7 +519,8 @@ tab_natural_dimensions (struct tab_table *t, struct outp_driver *d, from V, displayed with format spec F. */ void tab_value (struct tab_table *table, int c, int r, unsigned char opt, - const union value *v, const struct fmt_spec *f) + const union value *v, const struct dictionary *dict, + const struct fmt_spec *f) { char *contents; @@ -537,7 +539,7 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt, } #endif - contents = data_out_pool (v, "FIXME", f, table->container); + contents = data_out_pool (v, dict_get_encoding (dict), f, table->container); table->cc[c + r * table->cf] = ss_cstr (contents); table->ct[c + r * table->cf] = opt; @@ -578,7 +580,7 @@ tab_fixed (struct tab_table *table, int c, int r, unsigned char opt, #endif double_value.f = val; - s = data_out_pool (&double_value, "FIXME", &f, table->container); + s = data_out_pool (&double_value, "FIXME-tab_fixed", &f, table->container); cp = s; while (isspace ((unsigned char) *cp) && cp < &s[w]) @@ -629,7 +631,7 @@ tab_double (struct tab_table *table, int c, int r, unsigned char opt, #endif double_value.f = val; - s = data_out_pool (&double_value, "FIXME", fmt, table->container); + s = data_out_pool (&double_value, "FIXME-tab_double", fmt, table->container); cp = s; while (isspace ((unsigned char) *cp) && cp < s + fmt->w) diff --git a/src/output/table.h b/src/output/table.h index 2777c59d..e1383613 100644 --- a/src/output/table.h +++ b/src/output/table.h @@ -154,9 +154,11 @@ enum /* Cells. */ struct fmt_spec; +struct dictionary; union value; void tab_value (struct tab_table *, int c, int r, unsigned char opt, - const union value *, const struct fmt_spec *); + const union value *, const struct dictionary *dict, + const struct fmt_spec *); void tab_fixed (struct tab_table *, int c, int r, unsigned char opt, double v, int w, int d);