eval: Rename tv_list_remove_items() to tv_list_drop_items()

tv_list_remove_items() may cause confusion with tv_list_item_remove()
This commit is contained in:
ZyX
2017-12-24 16:38:30 +03:00
parent ac55558c97
commit 67fa9e5237
3 changed files with 14 additions and 14 deletions

View File

@@ -1534,8 +1534,8 @@ ex_let_vars (
EMSG(_("E688: More targets than List items")); EMSG(_("E688: More targets than List items"));
return FAIL; return FAIL;
} }
// l may actually be NULL, but it should fail with E688 or even earlier if you // lt may actually be NULL, but it should fail with E688 or even earlier if
// try to do ":let [] = v:_null_list". // you try to do ":let [] = v:_null_list".
assert(l != NULL); assert(l != NULL);
listitem_T *item = tv_list_first(l); listitem_T *item = tv_list_first(l);
@@ -1543,11 +1543,11 @@ ex_let_vars (
arg = skipwhite(arg + 1); arg = skipwhite(arg + 1);
arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, (const char_u *)",;]", arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, (const char_u *)",;]",
nextchars); nextchars);
item = TV_LIST_ITEM_NEXT(l, item);
if (arg == NULL) { if (arg == NULL) {
return FAIL; return FAIL;
} }
item = TV_LIST_ITEM_NEXT(l, item);
arg = skipwhite(arg); arg = skipwhite(arg);
if (*arg == ';') { if (*arg == ';') {
/* Put the rest of the list (may be empty) in the var after ';'. /* Put the rest of the list (may be empty) in the var after ';'.
@@ -1559,7 +1559,7 @@ ex_let_vars (
} }
ltv.v_type = VAR_LIST; ltv.v_type = VAR_LIST;
ltv.v_lock = 0; ltv.v_lock = VAR_UNLOCKED;
ltv.vval.v_list = rest_list; ltv.vval.v_list = rest_list;
tv_list_ref(rest_list); tv_list_ref(rest_list);
@@ -13283,7 +13283,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} else { } else {
if (argvars[2].v_type == VAR_UNKNOWN) { if (argvars[2].v_type == VAR_UNKNOWN) {
// Remove one item, return its value. // Remove one item, return its value.
tv_list_remove_items(l, item, item); tv_list_drop_items(l, item, item);
*rettv = *TV_LIST_ITEM_TV(item); *rettv = *TV_LIST_ITEM_TV(item);
xfree(item); xfree(item);
} else { } else {

View File

@@ -71,7 +71,7 @@ listitem_T *tv_list_item_remove(list_T *const l, listitem_T *const item)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
listitem_T *const next_item = TV_LIST_ITEM_NEXT(l, item); listitem_T *const next_item = TV_LIST_ITEM_NEXT(l, item);
tv_list_remove_items(l, item, item); tv_list_drop_items(l, item, item);
tv_clear(TV_LIST_ITEM_TV(item)); tv_clear(TV_LIST_ITEM_TV(item));
xfree(item); xfree(item);
return next_item; return next_item;
@@ -261,8 +261,8 @@ void tv_list_unref(list_T *const l)
/// @param[out] l List to remove from. /// @param[out] l List to remove from.
/// @param[in] item First item to remove. /// @param[in] item First item to remove.
/// @param[in] item2 Last item to remove. /// @param[in] item2 Last item to remove.
void tv_list_remove_items(list_T *const l, listitem_T *const item, void tv_list_drop_items(list_T *const l, listitem_T *const item,
listitem_T *const item2) listitem_T *const item2)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
// Notify watchers. // Notify watchers.
@@ -296,7 +296,7 @@ void tv_list_move_items(list_T *const l, listitem_T *const item,
const int cnt) const int cnt)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
tv_list_remove_items(l, item, item2); tv_list_drop_items(l, item, item2);
item->li_prev = tgt_l->lv_last; item->li_prev = tgt_l->lv_last;
item2->li_next = NULL; item2->li_next = NULL;
if (tgt_l->lv_last == NULL) { if (tgt_l->lv_last == NULL) {

View File

@@ -408,7 +408,7 @@ describe('typval.c', function()
}) })
end) end)
end) end)
describe('remove_items()', function() describe('drop_items()', function()
itp('works', function() itp('works', function()
local l_tv = lua2typvalt({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}) local l_tv = lua2typvalt({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13})
local l = l_tv.vval.v_list local l = l_tv.vval.v_list
@@ -421,19 +421,19 @@ describe('typval.c', function()
} }
alloc_log:clear() alloc_log:clear()
lib.tv_list_remove_items(l, lis[1], lis[3]) lib.tv_list_drop_items(l, lis[1], lis[3])
eq({4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, typvalt2lua(l_tv)) eq({4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, typvalt2lua(l_tv))
eq({lis[4], lis[7], lis[13]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item}) eq({lis[4], lis[7], lis[13]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item})
lib.tv_list_remove_items(l, lis[11], lis[13]) lib.tv_list_drop_items(l, lis[11], lis[13])
eq({4, 5, 6, 7, 8, 9, 10}, typvalt2lua(l_tv)) eq({4, 5, 6, 7, 8, 9, 10}, typvalt2lua(l_tv))
eq({lis[4], lis[7], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil}) eq({lis[4], lis[7], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
lib.tv_list_remove_items(l, lis[6], lis[8]) lib.tv_list_drop_items(l, lis[6], lis[8])
eq({4, 5, 9, 10}, typvalt2lua(l_tv)) eq({4, 5, 9, 10}, typvalt2lua(l_tv))
eq({lis[4], lis[9], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil}) eq({lis[4], lis[9], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
lib.tv_list_remove_items(l, lis[4], lis[10]) lib.tv_list_drop_items(l, lis[4], lis[10])
eq(empty_list, typvalt2lua(l_tv)) eq(empty_list, typvalt2lua(l_tv))
eq({true, true, true}, {lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil}) eq({true, true, true}, {lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil})