X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=dcd91800022cd26a55ea10b719ee2cdb620a1898;hb=255de8df66dde4395a62d7cfc84adf317f435744;hp=59f452217c1178ea95ac79264f4749e6256f1f51;hpb=6999c6d125665923b52ae15cbad83d06c92a8875;p=pspp-builds.git 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. */