return a->type == b->type && a->w == b->w && a->d == b->d;
}
-/* Adjusts FMT to be valid for a value of the given WIDTH. */
-void
+/* Adjusts FMT to be valid for a value of the given WIDTH if necessary.
+ If nothing needed to be changed the return value is false
+ */
+bool
fmt_resize (struct fmt_spec *fmt, int width)
{
if ((width > 0) != fmt_is_string (fmt->type))
else
{
/* Still numeric. */
+ return false;
}
+ return true;
}
/* Adjusts FMT's width and decimal places to be valid for USE. */
int fmt_var_width (const struct fmt_spec *);
char *fmt_to_string (const struct fmt_spec *, char s[FMT_STRING_LEN_MAX + 1]);
bool fmt_equal (const struct fmt_spec *, const struct fmt_spec *);
-void fmt_resize (struct fmt_spec *, int new_width);
+bool fmt_resize (struct fmt_spec *, int new_width);
void fmt_fix (struct fmt_spec *, enum fmt_use);
void fmt_fix_input (struct fmt_spec *);
{
struct variable *ov;
const int old_width = v->width;
+ unsigned int traits = 0;
if (old_width == new_width)
return;
ov = var_clone (v);
- if (mv_is_resizable (&v->miss, new_width))
- mv_resize (&v->miss, new_width);
- else
+ if (var_has_missing_values (v))
{
- mv_destroy (&v->miss);
- mv_init (&v->miss, new_width);
+ if (mv_is_resizable (&v->miss, new_width))
+ mv_resize (&v->miss, new_width);
+ else
+ {
+ mv_destroy (&v->miss);
+ mv_init (&v->miss, new_width);
+ }
+ traits |= VAR_TRAIT_MISSING_VALUES;
}
if (v->val_labs != NULL)
val_labs_destroy (v->val_labs);
v->val_labs = NULL;
}
+ traits |= VAR_TRAIT_VALUE_LABELS;
}
- fmt_resize (&v->print, new_width);
- fmt_resize (&v->write, new_width);
+ if (fmt_resize (&v->print, new_width))
+ traits |= VAR_TRAIT_PRINT_FORMAT;
+
+ if (fmt_resize (&v->write, new_width))
+ traits |= VAR_TRAIT_WRITE_FORMAT;
v->width = new_width;
- dict_var_changed (v, VAR_TRAIT_WIDTH, ov);
+ traits |= VAR_TRAIT_WIDTH;
+ dict_var_changed (v, traits, ov);
}
/* Returns true if variable V is numeric, false otherwise. */