From: Ben Pfaff Date: Wed, 25 Jul 2007 04:31:34 +0000 (+0000) Subject: Fix bug #6113. X-Git-Tag: v0.6.0~351 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=679e253a4777564db48ccec70b8ce2f6e5b7e46b;p=pspp-builds.git Fix bug #6113. * sys-file-writer.c (write_variable_display_parameters): Use new var_default_display_width function to choose display width of segments after the first one in a given variable. * variable.c (var_create): Use var_default_display_width to pick new variable's display width. (var_default_display_width): New function. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index cb0116e8..61cf23b9 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,13 @@ +2007-07-24 Ben Pfaff + + Fix bug #6113. + * sys-file-writer.c (write_variable_display_parameters): Use new + var_default_display_width function to choose display width of + segments after the first one in a given variable. + * variable.c (var_create): Use var_default_display_width to pick + new variable's display width. + (var_default_display_width): New function. + 2007-07-24 Ben Pfaff Fix bug #20427. diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 12b276a5..6b4344a7 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -547,8 +547,7 @@ write_variable_display_parameters (struct sfm_writer *w, int width_left = width - sfm_segment_effective_offset (width, i); write_int (w, measure); write_int (w, (i == 0 ? var_get_display_width (v) - : sfm_width_to_segments (width_left) > 1 ? 32 - : width_left)); + : var_default_display_width (width_left))); write_int (w, alignment); } } diff --git a/src/data/variable.c b/src/data/variable.c index 59f45221..dcd91800 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -112,16 +112,15 @@ var_create (const char *name, int width) { v->print = fmt_for_output (FMT_F, 8, 2); v->alignment = ALIGN_RIGHT; - v->display_width = 8; v->measure = MEASURE_SCALE; } else { v->print = fmt_for_output (FMT_A, var_get_width (v), 0); v->alignment = ALIGN_LEFT; - v->display_width = 8; v->measure = MEASURE_NOMINAL; } + v->display_width = var_default_display_width (width); v->write = v->print; v->val_labs = NULL; v->label = NULL; @@ -722,9 +721,6 @@ var_get_display_width (const struct variable *v) return v->display_width; } - - - /* Sets V's display width to DISPLAY_WIDTH. */ void var_set_display_width (struct variable *v, int display_width) @@ -732,6 +728,15 @@ var_set_display_width (struct variable *v, int display_width) v->display_width = display_width; dict_var_changed (v); } + +/* Returns the default display width for a variable of the given + WIDTH, as set by var_create. The return value can be used to + reset a variable's display width to the default. */ +int +var_default_display_width (int width) +{ + return width == 0 ? 8 : MIN (width, 32); +} /* Returns true if A is a valid alignment, false otherwise. */ diff --git a/src/data/variable.h b/src/data/variable.h index 31b046bc..44cfba70 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -123,6 +123,8 @@ void var_set_measure (struct variable *, enum measure); int var_get_display_width (const struct variable *); void var_set_display_width (struct variable *, int display_width); +int var_default_display_width (int width); + /* Alignment of data for display. */ enum alignment {