+2008-03-06 Ben Pfaff <blp@gnu.org>
+
+ * dictionary.c (var_name_is_insertable): New function.
+ (make_hinted_name): Don't accept variable names that match PSPP
+ keywords. Thanks to Jason Stover for reporting the problem.
+
2008-03-06 Ben Pfaff <blp@gnu.org>
* format-guesser.c (syntax): Require month names to be spelled out
return true;
}
+/* Returns true if a variable named NAME may be inserted in DICT;
+ that is, if there is not already a variable with that name in
+ DICT and if NAME is not a reserved word. (The caller's checks
+ have already verified that NAME is otherwise acceptable as a
+ variable name.) */
+static bool
+var_name_is_insertable (const struct dictionary *dict, const char *name)
+{
+ return (dict_lookup_var (dict, name) == NULL
+ && lex_id_to_token (ss_cstr (name)) == T_ID);
+}
+
static bool
make_hinted_name (const struct dictionary *dict, const char *hint,
char name[VAR_NAME_LEN + 1])
size_t len = strlen (name);
unsigned long int i;
- if (dict_lookup_var (dict, name) == NULL)
+ if (var_name_is_insertable (dict, name))
return true;
for (i = 0; i < ULONG_MAX; i++)
ofs = MIN (VAR_NAME_LEN - strlen (suffix), len);
strcpy (&name[ofs], suffix);
- if (dict_lookup_var (dict, name) == NULL)
+ if (var_name_is_insertable (dict, name))
return true;
}
}