From: Ben Pfaff Date: Sat, 18 Jun 2011 05:18:27 +0000 (-0700) Subject: variable: Do not trim trailing whitespace from variable labels. X-Git-Tag: v0.7.9~275 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de1f714a96756fe10ba57b2b35d6b175c176db2c;p=pspp-builds.git 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. --- diff --git a/src/data/variable.c b/src/data/variable.c index 121a5751..35fdab29 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); }