From: Ben Pfaff Date: Sat, 16 Dec 2006 22:11:08 +0000 (+0000) Subject: Don't assume that MEASURE_* and ALIGN_* have the same values found in X-Git-Tag: v0.6.0~633 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f2f805c653f0dc901924944ea4c55309ff14d32;p=pspp-builds.git Don't assume that MEASURE_* and ALIGN_* have the same values found in system files. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index aae7ca95..470e8969 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,15 @@ +Sat Dec 16 14:09:25 2006 Ben Pfaff + + * sys-file-reader.c (read_display_parameters): Don't assume that + MEASURE_* and ALIGN_* have the same values found in system files. + + * sys-file-writer.c (write_variable_display_parameters): Ditto. + + * variable.h: Change MEASURE_NOMINAL, MEASURE_ORDINAL, + MEASURE_SCALE to be 0-based instead of 1-based. This also fixes + the value of n_MEASURES, which was off by 1 (at least from my + point of view). + Sat Dec 16 12:17:34 WST 2006 John Darrington * dictionary.c dictionary.h vardict.h variable.c: Added optional diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 8c440849..9a4b33a9 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -813,7 +813,7 @@ read_display_parameters (struct sfm_reader *r, size_t size, size_t count, int align = read_int32 (r); struct variable *v; - if (!measure_is_valid (measure) || !alignment_is_valid (align)) + if (measure < 1 || measure > 3 || align < 0 || align > 2) { if (!warned) sys_warn (r, _("Invalid variable display parameters. " @@ -823,9 +823,13 @@ read_display_parameters (struct sfm_reader *r, size_t size, size_t count, } v = dict_get_var (dict, i); - var_set_measure (v, measure); + var_set_measure (v, (measure == 1 ? MEASURE_NOMINAL + : measure == 2 ? MEASURE_ORDINAL + : MEASURE_SCALE)); var_set_display_width (v, width); - var_set_alignment (v, align); + var_set_alignment (v, (align == 0 ? ALIGN_LEFT + : align == 1 ? ALIGN_RIGHT + : ALIGN_CENTRE)); } } diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index a7cc830f..f82cafad 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -709,9 +709,13 @@ write_variable_display_parameters (struct sfm_writer *w, v = dict_get_var(dict, i); - params.measure = var_get_measure (v); + params.measure = (var_get_measure (v) == MEASURE_NOMINAL ? 1 + : var_get_measure (v) == MEASURE_ORDINAL ? 2 + : 3); params.width = var_get_display_width (v); - params.align = var_get_alignment (v); + params.align = (var_get_alignment (v) == ALIGN_LEFT ? 0 + : var_get_alignment (v) == ALIGN_RIGHT ? 1 + : 2); buf_write (w, ¶ms, sizeof(params)); diff --git a/src/data/variable.h b/src/data/variable.h index b97f8582..0ab2821d 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -115,9 +115,9 @@ bool var_has_label (const struct variable *); /* How data is measured. */ enum measure { - MEASURE_NOMINAL = 1, - MEASURE_ORDINAL = 2, - MEASURE_SCALE = 3, + MEASURE_NOMINAL = 0, + MEASURE_ORDINAL = 1, + MEASURE_SCALE = 2, n_MEASURES }; diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index c8ea53ce..c20e3be2 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,10 @@ +Sat Dec 16 14:10:43 2006 Ben Pfaff + + * psppire-var-store.c (text_for_column): Adjust to account for new + values of the MEASURE_* enums. + + * var-sheet.c (change_measure): Ditto. + Sat Dec 16 12:24:35 WST 2006 John Darrington * psppire-variable.c psppire-variable.h: Deleted. diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index cb78ad62..64fbfa7d 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -680,8 +680,8 @@ text_for_column(const struct variable *pv, gint c, GError **err) { const gint measure = var_get_measure (pv); - g_assert (measure - 1 < n_MEASURES); - return g_locale_to_utf8 (gettext (measures[measure - 1]), + g_assert (measure < n_MEASURES); + return g_locale_to_utf8 (gettext (measures[measure]), -1, 0, 0, err); } break; diff --git a/src/ui/gui/var-sheet.c b/src/ui/gui/var-sheet.c index f7797fad..b65c6e89 100644 --- a/src/ui/gui/var-sheet.c +++ b/src/ui/gui/var-sheet.c @@ -160,7 +160,7 @@ change_measure(GtkComboBox *cb, if ( active_item < 0 ) return ; - var_set_measure (pv, active_item + 1); + var_set_measure (pv, active_item); }