[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VAR_NAME_LEN 14/17] FLIP: Eliminate false dependency on VAR_NAME_LEN.

From: Ben Pfaff
Subject: [VAR_NAME_LEN 14/17] FLIP: Eliminate false dependency on VAR_NAME_LEN.
Date: Sat, 5 Feb 2011 13:25:56 -0800

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.
 src/language/stats/flip.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c
index d08f1b8..487417b 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]);
-        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);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]