+2007-07-24 Ben Pfaff <blp@gnu.org>
+
+ 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 <blp@gnu.org>
Fix bug #20427.
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);
}
}
{
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;
return v->display_width;
}
-
-
-
/* Sets V's display width to DISPLAY_WIDTH. */
void
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);
+}
\f
/* Returns true if A is a valid alignment,
false otherwise. */
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
{