#endif
unsigned newlen;
int comma;
- int new_value_alloced; // new string option
- // was allocated
// When using ":set opt=val" for a global option
// with a local value the local value will be
s = newval;
newval = vim_strsave(s);
}
- new_value_alloced = TRUE;
}
else if (nextchar == '<') // set to global val
{
newval = vim_strsave(*(char_u **)get_varp_scope(
&(options[opt_idx]), OPT_GLOBAL));
- new_value_alloced = TRUE;
}
else
{
if (save_arg != NULL) // number for 'whichwrap'
arg = save_arg;
- new_value_alloced = TRUE;
}
/*
// 'syntax' or 'filetype' autocommands may be
// triggered that can cause havoc.
errmsg = did_set_string_option(
- opt_idx, (char_u **)varp,
- new_value_alloced, oldval, errbuf,
+ opt_idx, (char_u **)varp, oldval, errbuf,
opt_flags, &value_checked);
secure = secure_saved;
saved_newval = vim_strsave(s);
}
#endif
- if ((errmsg = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
+ if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
opt_flags, &value_checked)) == NULL)
did_set_option(opt_idx, opt_flags, TRUE, value_checked);
/*
* Handle string options that need some action to perform when changed.
+ * The new value must be allocated.
* Returns NULL for success, or an unstranslated error message for an error.
*/
char *
did_set_string_option(
int opt_idx, // index in options[] table
char_u **varp, // pointer to the option variable
- int new_value_alloced, // new value was allocated
char_u *oldval, // previous value of the option
char *errbuf, // buffer for errors, or NULL
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
// When setting the global value to empty, make it "zip".
if (*p_cm == NUL)
{
- if (new_value_alloced)
- free_string_option(p_cm);
+ free_string_option(p_cm);
p_cm = vim_strsave((char_u *)"zip");
- new_value_alloced = TRUE;
}
// When using ":set cm=name" the local value is going to be empty.
// Do that here, otherwise the crypt functions will still use the
t_colors = colors;
if (t_colors <= 1)
{
- if (new_value_alloced)
- vim_free(T_CCO);
+ vim_free(T_CCO);
T_CCO = empty_option;
}
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
if (STRCMP(p, "*") == 0)
{
p = gui_mch_font_dialog(oldval);
-
- if (new_value_alloced)
- free_string_option(p_guifont);
-
+ free_string_option(p_guifont);
p_guifont = (p != NULL) ? p : vim_strsave(oldval);
- new_value_alloced = TRUE;
}
# endif
if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
{
// Dialog was cancelled: Keep the old value without giving
// an error message.
- if (new_value_alloced)
- free_string_option(p_guifont);
+ free_string_option(p_guifont);
p_guifont = vim_strsave(oldval);
- new_value_alloced = TRUE;
}
else
# endif
REPTERM_FROM_PART | REPTERM_DO_LT, NULL);
if (p != NULL)
{
- if (new_value_alloced)
- free_string_option(p_pt);
+ free_string_option(p_pt);
p_pt = p;
- new_value_alloced = TRUE;
}
}
}
name = get_scriptlocal_funcname(*p_opt);
if (name != NULL)
{
- if (new_value_alloced)
- free_string_option(*p_opt);
+ free_string_option(*p_opt);
*p_opt = name;
- new_value_alloced = TRUE;
}
}
// If error detected, restore the previous value.
if (errmsg != NULL)
{
- if (new_value_alloced)
- free_string_option(*varp);
+ free_string_option(*varp);
*varp = oldval;
// When resetting some values, need to act on it.
if (did_chartab)
// our fingers (esp. init_highlight()).
if (free_oldval)
free_string_option(oldval);
- if (new_value_alloced)
- set_option_flag(opt_idx, P_ALLOCED);
- else
- clear_option_flag(opt_idx, P_ALLOCED);
+ set_option_flag(opt_idx, P_ALLOCED);
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& is_global_local_option(opt_idx))
void set_string_option_direct_in_win(win_T *wp, char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
void set_string_option_direct_in_buf(buf_T *buf, char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
char *set_string_option(int opt_idx, char_u *value, int opt_flags);
-char *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char *errbuf, int opt_flags, int *value_checked);
+char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, char *errbuf, int opt_flags, int *value_checked);
int check_ff_value(char_u *p);
/* vim: set ft=c : */