comparison src/evalvars.c @ 23982:9fcd71d0db89 v8.2.2533

patch 8.2.2533: Vim9: cannot use a range with :unlet Commit: https://github.com/vim/vim/commit/5b5ae29bd3d7b832b6f15320430f7f191e0abd1f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 20 17:04:02 2021 +0100 patch 8.2.2533: Vim9: cannot use a range with :unlet Problem: Vim9: cannot use a range with :unlet. Solution: Implement ISN_UNLETRANGE.
author Bram Moolenaar <Bram@vim.org>
date Sat, 20 Feb 2021 17:15:03 +0100
parents da1c89e61b04
children fc4c2beea99a
comparison
equal deleted inserted replaced
23981:05c1a8485fb9 23982:9fcd71d0db89
1654 || (lp->ll_dict != NULL 1654 || (lp->ll_dict != NULL
1655 && value_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE))) 1655 && value_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE)))
1656 return FAIL; 1656 return FAIL;
1657 else if (lp->ll_range) 1657 else if (lp->ll_range)
1658 { 1658 {
1659 listitem_T *li; 1659 if (list_unlet_range(lp->ll_list, lp->ll_li, lp->ll_name, lp->ll_n1,
1660 listitem_T *ll_li = lp->ll_li; 1660 !lp->ll_empty2, lp->ll_n2) == FAIL)
1661 int ll_n1 = lp->ll_n1; 1661 return FAIL;
1662
1663 while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1))
1664 {
1665 li = ll_li->li_next;
1666 if (value_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE))
1667 return FAIL;
1668 ll_li = li;
1669 ++ll_n1;
1670 }
1671
1672 // Delete a range of List items.
1673 while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1))
1674 {
1675 li = lp->ll_li->li_next;
1676 listitem_remove(lp->ll_list, lp->ll_li);
1677 lp->ll_li = li;
1678 ++lp->ll_n1;
1679 }
1680 } 1662 }
1681 else 1663 else
1682 { 1664 {
1683 if (lp->ll_list != NULL) 1665 if (lp->ll_list != NULL)
1684 // unlet a List item. 1666 // unlet a List item.
1689 } 1671 }
1690 1672
1691 return ret; 1673 return ret;
1692 } 1674 }
1693 1675
1676 /*
1677 * Unlet one item or a range of items from a list.
1678 * Return OK or FAIL.
1679 */
1680 int
1681 list_unlet_range(
1682 list_T *l,
1683 listitem_T *li_first,
1684 char_u *name,
1685 long n1_arg,
1686 int has_n2,
1687 long n2)
1688 {
1689 listitem_T *li = li_first;
1690 int n1 = n1_arg;
1691
1692 while (li != NULL && (!has_n2 || n2 >= n1))
1693 {
1694 if (value_check_lock(li->li_tv.v_lock, name, FALSE))
1695 return FAIL;
1696 li = li->li_next;
1697 ++n1;
1698 }
1699
1700 // Delete a range of List items.
1701 li = li_first;
1702 n1 = n1_arg;
1703 while (li != NULL && (!has_n2 || n2 >= n1))
1704 {
1705 listitem_T *next = li->li_next;
1706
1707 listitem_remove(l, li);
1708 li = next;
1709 ++n1;
1710 }
1711 return OK;
1712 }
1694 /* 1713 /*
1695 * "unlet" a variable. Return OK if it existed, FAIL if not. 1714 * "unlet" a variable. Return OK if it existed, FAIL if not.
1696 * When "forceit" is TRUE don't complain if the variable doesn't exist. 1715 * When "forceit" is TRUE don't complain if the variable doesn't exist.
1697 */ 1716 */
1698 int 1717 int