1
0
forked from aniani/vim

patch 8.1.1583: set_ref_in_list() only sets ref in items

Problem:    Set_ref_in_list() only sets ref in items.
Solution:   Rename to set_ref_in_list_items() to avoid confusion.
This commit is contained in:
Bram Moolenaar
2019-06-23 01:46:15 +02:00
parent 0fcf26ba4f
commit 7be3ab2589
7 changed files with 50 additions and 48 deletions

View File

@@ -5840,6 +5840,36 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack)
return abort; return abort;
} }
/*
* Mark a dict and its items with "copyID".
* Returns TRUE if setting references failed somehow.
*/
int
set_ref_in_dict(dict_T *d, int copyID)
{
if (d != NULL && d->dv_copyID != copyID)
{
d->dv_copyID = copyID;
return set_ref_in_ht(&d->dv_hashtab, copyID, NULL);
}
return FALSE;
}
/*
* Mark a list and its items with "copyID".
* Returns TRUE if setting references failed somehow.
*/
int
set_ref_in_list(list_T *ll, int copyID)
{
if (ll != NULL && ll->lv_copyID != copyID)
{
ll->lv_copyID = copyID;
return set_ref_in_list_items(ll, copyID, NULL);
}
return FALSE;
}
/* /*
* Mark all lists and dicts referenced through list "l" with "copyID". * Mark all lists and dicts referenced through list "l" with "copyID".
* "ht_stack" is used to add hashtabs to be marked. Can be NULL. * "ht_stack" is used to add hashtabs to be marked. Can be NULL.
@@ -5847,7 +5877,7 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack)
* Returns TRUE if setting references failed somehow. * Returns TRUE if setting references failed somehow.
*/ */
int int
set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack) set_ref_in_list_items(list_T *l, int copyID, ht_stack_T **ht_stack)
{ {
listitem_T *li; listitem_T *li;
int abort = FALSE; int abort = FALSE;
@@ -5930,7 +5960,7 @@ set_ref_in_item(
ll->lv_copyID = copyID; ll->lv_copyID = copyID;
if (list_stack == NULL) if (list_stack == NULL)
{ {
abort = set_ref_in_list(ll, copyID, ht_stack); abort = set_ref_in_list_items(ll, copyID, ht_stack);
} }
else else
{ {

View File

@@ -1980,31 +1980,19 @@ luaV_setref(lua_State *L)
{ {
list_T *l = (list_T *)lua_touserdata(L, 5); // key list_T *l = (list_T *)lua_touserdata(L, 5); // key
if (l->lv_copyID != copyID) abort = set_ref_in_list(l, copyID);
{
l->lv_copyID = copyID;
abort = set_ref_in_list(l, copyID, NULL);
}
} }
else if (lua_rawequal(L, -1, 3)) // dict? else if (lua_rawequal(L, -1, 3)) // dict?
{ {
dict_T *d = (dict_T *)lua_touserdata(L, 5); // key dict_T *d = (dict_T *)lua_touserdata(L, 5); // key
if (d->dv_copyID != copyID) abort = set_ref_in_dict(d, copyID);
{
d->dv_copyID = copyID;
abort = set_ref_in_ht(&d->dv_hashtab, copyID, NULL);
}
} }
else if (lua_rawequal(L, -1, 4)) // funcref? else if (lua_rawequal(L, -1, 4)) // funcref?
{ {
luaV_Funcref *f = (luaV_Funcref *)lua_touserdata(L, 5); // key luaV_Funcref *f = (luaV_Funcref *)lua_touserdata(L, 5); // key
if (f->self != NULL && f->self->dv_copyID != copyID) abort = set_ref_in_dict(f->self, copyID);
{
f->self->dv_copyID = copyID;
abort = set_ref_in_ht(&f->self->dv_hashtab, copyID, NULL);
}
} }
lua_pop(L, 2); // metatable and value lua_pop(L, 2); // metatable and value
} }

View File

@@ -5832,23 +5832,16 @@ run_eval(const char *cmd, typval_T *rettv
set_ref_in_py(const int copyID) set_ref_in_py(const int copyID)
{ {
pylinkedlist_T *cur; pylinkedlist_T *cur;
dict_T *dd; list_T *ll;
list_T *ll; int i;
int i; int abort = FALSE;
int abort = FALSE;
FunctionObject *func; FunctionObject *func;
if (lastdict != NULL) if (lastdict != NULL)
{ {
for (cur = lastdict ; !abort && cur != NULL ; cur = cur->pll_prev) for (cur = lastdict ; !abort && cur != NULL ; cur = cur->pll_prev)
{ abort = set_ref_in_dict(((DictionaryObject *)(cur->pll_obj))->dict,
dd = ((DictionaryObject *) (cur->pll_obj))->dict; copyID);
if (dd->dv_copyID != copyID)
{
dd->dv_copyID = copyID;
abort = abort || set_ref_in_ht(&dd->dv_hashtab, copyID, NULL);
}
}
} }
if (lastlist != NULL) if (lastlist != NULL)
@@ -5856,11 +5849,7 @@ set_ref_in_py(const int copyID)
for (cur = lastlist ; !abort && cur != NULL ; cur = cur->pll_prev) for (cur = lastlist ; !abort && cur != NULL ; cur = cur->pll_prev)
{ {
ll = ((ListObject *) (cur->pll_obj))->list; ll = ((ListObject *) (cur->pll_obj))->list;
if (ll->lv_copyID != copyID) abort = set_ref_in_list(ll, copyID);
{
ll->lv_copyID = copyID;
abort = abort || set_ref_in_list(ll, copyID, NULL);
}
} }
} }
@@ -5869,12 +5858,7 @@ set_ref_in_py(const int copyID)
for (cur = lastfunc ; !abort && cur != NULL ; cur = cur->pll_prev) for (cur = lastfunc ; !abort && cur != NULL ; cur = cur->pll_prev)
{ {
func = (FunctionObject *) cur->pll_obj; func = (FunctionObject *) cur->pll_obj;
if (func->self != NULL && func->self->dv_copyID != copyID) abort = set_ref_in_dict(func->self, copyID);
{
func->self->dv_copyID = copyID;
abort = abort || set_ref_in_ht(
&func->self->dv_hashtab, copyID, NULL);
}
if (func->argc) if (func->argc)
for (i = 0; !abort && i < func->argc; ++i) for (i = 0; !abort && i < func->argc; ++i)
abort = abort abort = abort

View File

@@ -2297,11 +2297,7 @@ set_ref_in_one_popup(win_T *wp, int copyID)
tv.vval.v_partial = wp->w_filter_cb.cb_partial; tv.vval.v_partial = wp->w_filter_cb.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
} }
if (wp->w_popup_mask != NULL && wp->w_popup_mask->lv_copyID != copyID) abort = abort || set_ref_in_list(wp->w_popup_mask, copyID);
{
wp->w_popup_mask->lv_copyID = copyID;
abort = abort || set_ref_in_list(wp->w_popup_mask, copyID, NULL);
}
return abort; return abort;
} }

View File

@@ -50,7 +50,9 @@ int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
int get_copyID(void); int get_copyID(void);
int garbage_collect(int testing); int garbage_collect(int testing);
int set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack); int set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack);
int set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack); int set_ref_in_dict(dict_T *d, int copyID);
int set_ref_in_list(list_T *ll, int copyID);
int set_ref_in_list_items(list_T *l, int copyID, ht_stack_T **ht_stack);
int set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack); int set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack);
char_u *echo_string_core(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID, int echo_style, int restore_copyID, int composite_val); char_u *echo_string_core(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID, int echo_style, int restore_copyID, int composite_val);
char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID); char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);

View File

@@ -4000,7 +4000,7 @@ set_ref_in_previous_funccal(int copyID)
abort = abort abort = abort
|| set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID + 1, NULL) || set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID + 1, NULL)
|| set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID + 1, NULL) || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID + 1, NULL)
|| set_ref_in_list(&fc->l_varlist, copyID + 1, NULL); || set_ref_in_list_items(&fc->l_varlist, copyID + 1, NULL);
} }
return abort; return abort;
} }
@@ -4016,7 +4016,7 @@ set_ref_in_funccal(funccall_T *fc, int copyID)
abort = abort abort = abort
|| set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID, NULL) || set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID, NULL)
|| set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID, NULL) || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID, NULL)
|| set_ref_in_list(&fc->l_varlist, copyID, NULL) || set_ref_in_list_items(&fc->l_varlist, copyID, NULL)
|| set_ref_in_func(NULL, fc->func, copyID); || set_ref_in_func(NULL, fc->func, copyID);
} }
return abort; return abort;

View File

@@ -777,6 +777,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 */
/**/
1583,
/**/ /**/
1582, 1582,
/**/ /**/