From: Ben Pfaff Date: Sun, 2 Jan 2011 00:16:30 +0000 (-0800) Subject: FLIP: Eliminate false dependency on VAR_NAME_LEN. X-Git-Tag: v0.7.7~63 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=11210e8190261d1ab630b1a56f6c0a44a5e82419 FLIP: Eliminate false dependency on VAR_NAME_LEN. The size of this buffer really shouldn't have anything to do with VAR_NAME_LEN but with the string about to be put into it. 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/stats/flip.c b/src/language/stats/flip.c index d08f1b86..487417ba 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009, 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 @@ -209,7 +209,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) make_new_var (dict, flip->new_names.names[i]); else { - char s[VAR_NAME_LEN + 1]; + char s[3 + INT_STRLEN_BOUND (i) + 1]; sprintf (s, "VAR%03zu", i); dict_create_var_assert (dict, s, 0); }