From: Ben Pfaff Date: Sat, 1 Jan 2011 19:09:01 +0000 (-0800) Subject: MODIFY VARIABLES: Eliminate VAR_NAME_LEN limit on variable names. X-Git-Tag: v0.7.7~69 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23e4750c9a2fbc89126fe7be83ee7a3c1914cc07;p=pspp-builds.git MODIFY VARIABLES: Eliminate VAR_NAME_LEN limit on variable names. This is actually a general code improvement, since it eliminates memory allocation and copying that was not actually necessary. Most uses of VAR_NAME_LEN within PSPP are wrong due to encoding issues: the limit applies to variable names in the encoding used by the data set, but most uses of VAR_NAME_LEN actually limit the length of a name in UTF-8. The UTF-8 representation of a name can be longer or shorter than its representation in the data set encoding, so it seems best to eliminate references to VAR_NAME_LEN entirely. --- diff --git a/src/language/dictionary/modify-variables.c b/src/language/dictionary/modify-variables.c index cc847372..aae81222 100644 --- a/src/language/dictionary/modify-variables.c +++ b/src/language/dictionary/modify-variables.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -368,7 +368,7 @@ compare_variables_given_ordering (const void *a_, const void *b_, struct var_renaming { struct variable *var; - char new_name[VAR_NAME_LEN + 1]; + const char *new_name; }; /* A algo_compare_func that compares new_name members in struct @@ -431,7 +431,7 @@ validate_var_modification (const struct dictionary *d, for (i = 0; i < keep_cnt; i++) { var_renaming[i].var = keep_vars[i]; - strcpy (var_renaming[i].new_name, var_get_name (keep_vars[i])); + var_renaming[i].new_name = var_get_name (keep_vars[i]); } /* Rename variables in var_renaming array. */ @@ -449,7 +449,7 @@ validate_var_modification (const struct dictionary *d, continue; vr = var_renaming + (kv - keep_vars); - strcpy (vr->new_name, vm->new_names[i]); + vr->new_name = vm->new_names[i]; } /* Sort var_renaming array by new names and check for