From 033725a375c3ffe41c3e6025e8c65962bf726062 Mon Sep 17 00:00:00 2001 From: John Darrington <john@darrington.wattle.id.au> Date: Sat, 4 Jul 2020 08:38:33 +0200 Subject: [PATCH] Follow-up to bugfix #58664 If the width of a variable changes, then implicitly so does its missing values --- even if the number of missing values is zero. This is because the variable's width is cached in the missing_value struct itself. --- src/data/variable.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/data/variable.c b/src/data/variable.c index 2b0dd2579d..593e23ca72 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -307,17 +307,15 @@ var_set_width_and_formats (struct variable *v, int new_width, ov = var_clone (v); - if (var_has_missing_values (v)) + if (mv_is_resizable (&v->miss, new_width)) + mv_resize (&v->miss, new_width); + else { - 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; + mv_destroy (&v->miss); + mv_init (&v->miss, new_width); } + if (new_width != var_get_width (v)) + traits |= VAR_TRAIT_MISSING_VALUES; if (v->val_labs != NULL) { -- 2.30.2