mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 7.4.1068
Problem: Wrong way to check for unletting internal variables. Solution: Use a better way. (Olaf Dabrunz)
This commit is contained in:
33
src/eval.c
33
src/eval.c
@@ -3738,25 +3738,30 @@ do_unlet(name, forceit)
|
|||||||
ht = find_var_ht(name, &varname);
|
ht = find_var_ht(name, &varname);
|
||||||
if (ht != NULL && *varname != NUL)
|
if (ht != NULL && *varname != NUL)
|
||||||
{
|
{
|
||||||
|
if (ht == &globvarht)
|
||||||
|
d = &globvardict;
|
||||||
|
else if (current_funccal != NULL
|
||||||
|
&& ht == ¤t_funccal->l_vars.dv_hashtab)
|
||||||
|
d = ¤t_funccal->l_vars;
|
||||||
|
else if (ht == &compat_hashtab)
|
||||||
|
d = &vimvardict;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
|
||||||
|
d = di == NULL ? NULL : di->di_tv.vval.v_dict;
|
||||||
|
}
|
||||||
|
if (d == NULL)
|
||||||
|
{
|
||||||
|
EMSG2(_(e_intern2), "do_unlet()");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
hi = hash_find(ht, varname);
|
hi = hash_find(ht, varname);
|
||||||
if (!HASHITEM_EMPTY(hi))
|
if (!HASHITEM_EMPTY(hi))
|
||||||
{
|
{
|
||||||
di = HI2DI(hi);
|
di = HI2DI(hi);
|
||||||
if (var_check_fixed(di->di_flags, name, FALSE)
|
if (var_check_fixed(di->di_flags, name, FALSE)
|
||||||
|| var_check_ro(di->di_flags, name, FALSE))
|
|| var_check_ro(di->di_flags, name, FALSE)
|
||||||
return FAIL;
|
|| tv_check_lock(d->dv_lock, name, FALSE))
|
||||||
|
|
||||||
if (ht == &globvarht)
|
|
||||||
d = &globvardict;
|
|
||||||
else if (current_funccal != NULL
|
|
||||||
&& ht == ¤t_funccal->l_vars.dv_hashtab)
|
|
||||||
d = ¤t_funccal->l_vars;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
|
|
||||||
d = di->di_tv.vval.v_dict;
|
|
||||||
}
|
|
||||||
if (d == NULL || tv_check_lock(d->dv_lock, name, FALSE))
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
delete_var(ht, hi);
|
delete_var(ht, hi);
|
||||||
|
@@ -741,6 +741,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1068,
|
||||||
/**/
|
/**/
|
||||||
1067,
|
1067,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user