{
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;
{
assert (!var_has_vardict (v));
cat_stored_values_destroy (v->obs_vals);
+ var_clear_short_names (v);
var_clear_aux (v);
val_labs_destroy (v->val_labs);
var_clear_label (v);
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. */
{
size_t old_cnt = var->short_name_cnt;
size_t i;
-
var->short_name_cnt = MAX (idx * 2, 1);
var->short_names = xnrealloc (var->short_names, var->short_name_cnt,
sizeof *var->short_names);
var_clear_short_names (struct variable *v)
{
size_t i;
-
+
for (i = 0; i < v->short_name_cnt; i++)
free (v->short_names[i]);
+ free (v->short_names);
v->short_names = NULL;
v->short_name_cnt = 0;
}