- {
- assert (new_names[i] != NULL);
- assert (*new_names[i] != '\0');
- assert (strlen (new_names[i]) >= 1);
- assert (strlen (new_names[i]) <= LONG_NAME_LEN);
+ if (hsh_insert (d->name_tab, vars[i]) != NULL)
+ {
+ /* There is a name conflict.
+ Back out all the name changes that have already
+ taken place, and indicate failure. */
+ size_t fail_idx = i;
+ if (err_name != NULL)
+ *err_name = new_names[i];
+
+ for (i = 0; i < fail_idx; i++)
+ hsh_force_delete (d->name_tab, vars[i]);
+
+ for (i = 0; i < count; i++)
+ {
+ rename_var (d, vars[i], old_names[i]);
+ hsh_force_insert (d->name_tab, vars[i]);
+ }
+
+ pool_destroy (pool);
+ return false;
+ }
+
+ /* Clear short names. */
+ if (settings_get_algorithm () == ENHANCED)
+ for (i = 0; i < count; i++)
+ var_clear_short_names (vars[i]);
+
+ pool_destroy (pool);
+ 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])
+{
+ bool dropped = false;
+ char *cp;