mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 11:56:30 +00:00
vim-patch:8.0.0352: not easy to see when a typval needs to be cleared
Problem: The condition for when a typval needs to be cleared is too
complicated.
Solution: Init the type to VAR_UNKNOWN and clear it always.
f06e5a549f
This commit is contained in:
@@ -2084,6 +2084,8 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
* Loop until no more [idx] or .key is following.
|
* Loop until no more [idx] or .key is following.
|
||||||
*/
|
*/
|
||||||
lp->ll_tv = &v->di_tv;
|
lp->ll_tv = &v->di_tv;
|
||||||
|
var1.v_type = VAR_UNKNOWN;
|
||||||
|
var2.v_type = VAR_UNKNOWN;
|
||||||
while (*p == '[' || (*p == '.' && lp->ll_tv->v_type == VAR_DICT)) {
|
while (*p == '[' || (*p == '.' && lp->ll_tv->v_type == VAR_DICT)) {
|
||||||
if (!(lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list != NULL)
|
if (!(lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list != NULL)
|
||||||
&& !(lp->ll_tv->v_type == VAR_DICT
|
&& !(lp->ll_tv->v_type == VAR_DICT
|
||||||
@@ -2134,9 +2136,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
EMSG(_(e_dictrange));
|
EMSG(_(e_dictrange));
|
||||||
}
|
}
|
||||||
if (!empty1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (rettv != NULL && (rettv->v_type != VAR_LIST
|
if (rettv != NULL && (rettv->v_type != VAR_LIST
|
||||||
@@ -2144,9 +2144,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
emsgf(_("E709: [:] requires a List value"));
|
emsgf(_("E709: [:] requires a List value"));
|
||||||
}
|
}
|
||||||
if (!empty1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = skipwhite(p + 1);
|
p = skipwhite(p + 1);
|
||||||
@@ -2155,16 +2153,12 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
} else {
|
} else {
|
||||||
lp->ll_empty2 = false;
|
lp->ll_empty2 = false;
|
||||||
if (eval1(&p, &var2, true) == FAIL) { // Recursive!
|
if (eval1(&p, &var2, true) == FAIL) { // Recursive!
|
||||||
if (!empty1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!tv_check_str(&var2)) {
|
if (!tv_check_str(&var2)) {
|
||||||
// Not a number or string.
|
// Not a number or string.
|
||||||
if (!empty1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
tv_clear(&var2);
|
tv_clear(&var2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -2177,12 +2171,8 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
emsgf(_(e_missbrac));
|
emsgf(_(e_missbrac));
|
||||||
}
|
}
|
||||||
if (!empty1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
if (lp->ll_range && !lp->ll_empty2) {
|
|
||||||
tv_clear(&var2);
|
tv_clear(&var2);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2236,9 +2226,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
emsgf(_(e_dictkey), key);
|
emsgf(_(e_dictkey), key);
|
||||||
}
|
}
|
||||||
if (len == -1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
@@ -2246,32 +2234,28 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
} else {
|
} else {
|
||||||
lp->ll_newkey = vim_strnsave(key, len);
|
lp->ll_newkey = vim_strnsave(key, len);
|
||||||
}
|
}
|
||||||
if (len == -1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
// existing variable, need to check if it can be changed
|
// existing variable, need to check if it can be changed
|
||||||
} else if (!(flags & GLV_READ_ONLY) && var_check_ro(lp->ll_di->di_flags,
|
} else if (!(flags & GLV_READ_ONLY) && var_check_ro(lp->ll_di->di_flags,
|
||||||
(const char *)name,
|
(const char *)name,
|
||||||
(size_t)(p - name))) {
|
(size_t)(p - name))) {
|
||||||
if (len == -1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == -1) {
|
|
||||||
tv_clear(&var1);
|
tv_clear(&var1);
|
||||||
}
|
|
||||||
lp->ll_tv = &lp->ll_di->di_tv;
|
lp->ll_tv = &lp->ll_di->di_tv;
|
||||||
} else {
|
} else {
|
||||||
// Get the number and item for the only or first index of the List.
|
// Get the number and item for the only or first index of the List.
|
||||||
if (empty1) {
|
if (empty1) {
|
||||||
lp->ll_n1 = 0;
|
lp->ll_n1 = 0;
|
||||||
} else {
|
} else {
|
||||||
lp->ll_n1 = (long)tv_get_number(&var1); // Is number or string.
|
// Is number or string.
|
||||||
tv_clear(&var1);
|
lp->ll_n1 = (long)tv_get_number(&var1);
|
||||||
}
|
}
|
||||||
|
tv_clear(&var1);
|
||||||
|
|
||||||
lp->ll_dict = NULL;
|
lp->ll_dict = NULL;
|
||||||
lp->ll_list = lp->ll_tv->vval.v_list;
|
lp->ll_list = lp->ll_tv->vval.v_list;
|
||||||
lp->ll_li = tv_list_find(lp->ll_list, lp->ll_n1);
|
lp->ll_li = tv_list_find(lp->ll_list, lp->ll_n1);
|
||||||
@@ -2282,9 +2266,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lp->ll_li == NULL) {
|
if (lp->ll_li == NULL) {
|
||||||
if (lp->ll_range && !lp->ll_empty2) {
|
|
||||||
tv_clear(&var2);
|
tv_clear(&var2);
|
||||||
}
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
EMSGN(_(e_listidx), lp->ll_n1);
|
EMSGN(_(e_listidx), lp->ll_n1);
|
||||||
}
|
}
|
||||||
@@ -2326,6 +2308,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tv_clear(&var1);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user