From: John Darrington Date: Sat, 18 Jul 2009 09:32:46 +0000 (+0200) Subject: Before recoding a variable's name, check that it X-Git-Tag: build37~53^2~4 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=573b7c2cdd49d29bcc35e407bb52cb28199973c1;p=pspp-builds.git Before recoding a variable's name, check that it doesn't clash with an existing one. Thanks to Ben Pfaff for pointing out this potential problem. --- diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 5850887f..0f583a12 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -202,8 +202,17 @@ recode_strings (struct dictionary *dict) { /* Convert the long variable name */ struct variable *var = dict_get_var (dict, i); - char *utf8_name = recode_string (UTF8, enc, var_get_name (var), -1); - dict_rename_var (dict, var, utf8_name); + const char *native_name = var_get_name (var); + char *utf8_name = recode_string (UTF8, enc, native_name, -1); + if ( 0 != strcmp (utf8_name, native_name)) + { + if ( NULL == dict_lookup_var (dict, utf8_name)) + dict_rename_var (dict, var, utf8_name); + else + msg (MW, + _("Recoded variable name duplicates an existing `%s' within system file."), utf8_name); + } + free (utf8_name); /* Convert the variable label */