From: Ben Pfaff Date: Tue, 12 Apr 2011 13:43:04 +0000 (-0700) Subject: tab: Make tab_value() take a variable instead of a dictionary. X-Git-Tag: v0.7.8~72 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22d2bdfb26bf8df59a27191aa669090d57df56bd;p=pspp-builds.git tab: Make tab_value() take a variable instead of a dictionary. It seems far more likely that callers will have the variable handy than the dictionary. Also, when the variable is used the format can be optional since tab_value() can get it from the variable's print format. --- diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 91015f57..b230702e 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -1492,7 +1492,7 @@ table_value_missing (struct crosstabs_proc *proc, free (s); } else - tab_value (table, c, r, opt, v, proc->dict, print); + tab_value (table, c, r, opt, v, var, print); } } diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 9bc2f73e..01247f51 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -188,7 +188,6 @@ struct var_freqs /* Variable attributes. */ int width; - struct fmt_spec print; }; struct frq_proc @@ -646,7 +645,6 @@ frq_custom_variables (struct lexer *lexer, struct dataset *ds, vf->n_groups = 0; vf->groups = NULL; vf->width = var_get_width (var); - vf->print = *var_get_print_format (var); } frq->n_vars = n_vars; @@ -850,7 +848,7 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) if (label != NULL) tab_text (t, 0, r, TAB_LEFT, label); - tab_value (t, 1, r, TAB_NONE, &f->value, ft->dict, &vf->print); + tab_value (t, 1, r, TAB_NONE, &f->value, vf->var, NULL); tab_double (t, 2, r, TAB_NONE, f->count, wfmt); tab_double (t, 3, r, TAB_NONE, percent, NULL); tab_double (t, 4, r, TAB_NONE, valid_percent, NULL); @@ -867,7 +865,7 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) if (label != NULL) tab_text (t, 0, r, TAB_LEFT, label); - tab_value (t, 1, r, TAB_NONE, &f->value, ft->dict, &vf->print); + tab_value (t, 1, r, TAB_NONE, &f->value, vf->var, NULL); tab_double (t, 2, r, TAB_NONE, f->count, wfmt); tab_double (t, 3, r, TAB_NONE, f->count / ft->total_cases * 100.0, NULL); diff --git a/src/output/tab.c b/src/output/tab.c index 7ce860f1..f5f1f1f8 100644 --- a/src/output/tab.c +++ b/src/output/tab.c @@ -24,10 +24,10 @@ #include #include "data/data-out.h" -#include "data/dictionary.h" #include "data/format.h" #include "data/settings.h" #include "data/value.h" +#include "data/variable.h" #include "libpspp/assertion.h" #include "libpspp/compiler.h" #include "libpspp/i18n.h" @@ -360,7 +360,7 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, 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 dictionary *dict, + const union value *v, const struct variable *var, const struct fmt_spec *f) { char *contents; @@ -379,7 +379,9 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt, } #endif - contents = data_out_pool (v, dict_get_encoding (dict), f, table->container); + contents = data_out_pool (v, var_get_encoding (var), + f != NULL ? f : var_get_print_format (var), + table->container); table->cc[c + r * table->cf] = contents; table->ct[c + r * table->cf] = opt; diff --git a/src/output/tab.h b/src/output/tab.h index 7ac85187..dd6840c6 100644 --- a/src/output/tab.h +++ b/src/output/tab.h @@ -111,7 +111,7 @@ 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 dictionary *dict, + const union value *, const struct variable *, const struct fmt_spec *); void tab_fixed (struct tab_table *, int c, int r, unsigned char opt,