X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=720def8e6c6708d655db98ced2e51b995daf4bfc;hb=refs%2Fbuilds%2F20130924032641%2Fpspp;hp=e981ba661f66b8eb7a1f8d57e1ac9fcff8c22adb;hpb=c7037d42254bb3c0e1dac2e1bd6ef95c6db8ba27;p=pspp diff --git a/src/data/variable.c b/src/data/variable.c index e981ba661f..720def8e6c 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -77,6 +77,8 @@ struct variable }; +static void var_set_print_format_quiet (struct variable *v, const struct fmt_spec *print); +static void var_set_write_format_quiet (struct variable *v, const struct fmt_spec *write); static bool var_set_label_quiet (struct variable *v, const char *label, bool issue_warning); static void var_set_name_quiet (struct variable *v, const char *name); @@ -242,18 +244,13 @@ var_get_width (const struct variable *v) return v->width; } -/* Changes the width of V to NEW_WIDTH. - This function should be used cautiously. */ void -var_set_width (struct variable *v, int new_width) +var_set_width_and_formats (struct variable *v, int new_width, + const struct fmt_spec *print, const struct fmt_spec *write) { struct variable *ov; - const int old_width = v->width; unsigned int traits = 0; - if (old_width == new_width) - return; - ov = var_clone (v); if (var_has_missing_values (v)) @@ -288,9 +285,38 @@ var_set_width (struct variable *v, int new_width) v->width = new_width; traits |= VAR_TRAIT_WIDTH; + + if (print) + { + var_set_print_format_quiet (v, print); + traits |= VAR_TRAIT_PRINT_FORMAT; + } + + if (write) + { + var_set_write_format_quiet (v, write); + traits |= VAR_TRAIT_WRITE_FORMAT; + } + dict_var_changed (v, traits, ov); } +/* Changes the width of V to NEW_WIDTH. + This function should be used cautiously. */ +void +var_set_width (struct variable *v, int new_width) +{ + const int old_width = v->width; + + if (old_width == new_width) + return; + + var_set_width_and_formats (v, new_width, NULL, NULL); +} + + + + /* Returns true if variable V is numeric, false otherwise. */ bool var_is_numeric (const struct variable *v)