From de1f714a96756fe10ba57b2b35d6b175c176db2c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 17 Jun 2011 22:18:27 -0700 Subject: [PATCH] variable: Do not trim trailing whitespace from variable labels. Until now, PSPP has trimmed trailing whitespace from variable labels. SPSS does not do this, which led to gratuitous changes in variable labels when reading and then writing back a .sav file, so this commit stops stripping trailing whitespace from variable labels. Thanks to Curt Reinhold for providing the .sav file that led to this discovery. --- src/data/variable.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/data/variable.c b/src/data/variable.c index 121a57517c..35fdab29eb 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -583,7 +583,7 @@ var_set_label (struct variable *v, const char *label, bool issue_warning) free (v->label); v->label = NULL; - if (label != NULL) + if (label != NULL && label[strspn (label, CC_SPACES)]) { const char *dict_encoding = var_get_encoding (v); struct substring s = ss_cstr (label); @@ -605,8 +605,6 @@ var_set_label (struct variable *v, const char *label, bool issue_warning) } } - ss_trim (&s, ss_cstr (CC_SPACES)); - if (!ss_is_empty (s)) v->label = ss_xstrdup (s); } -- 2.30.2