Updated patch with second approach: # HG changeset patch # User ZyX <[email protected]> # Date 1409287235 -14400 # Fri Aug 29 08:40:35 2014 +0400 # Node ID 93db73f6960f25b2ffb10b12010d524252b0ac4a # Parent 0ccbf92e36c043ec944614b02f4c83f0f41929d6 Fix slice operations on partially locked list
Patch from https://groups.google.com/forum/#!topic/vim_dev/-IYtF6S4EjM diff -r 0ccbf92e36c0 -r 93db73f6960f src/eval.c --- a/src/eval.c Sun Aug 10 13:46:36 2014 +0200 +++ b/src/eval.c Fri Aug 29 08:40:35 2014 +0400 @@ -2945,6 +2945,23 @@ ; else if (lp->ll_range) { + listitem_T *ll_li = lp->ll_li; + int ll_n1 = lp->ll_n1; + + /* + * Check whether any of the list items is locked + */ + for (ri = rettv->vval.v_list->lv_first; ri != NULL; ) + { + if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name)) + return; + ri = ri->li_next; + if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == ll_n1)) + break; + ll_li = ll_li->li_next; + ++ll_n1; + } + /* * Assign the List values to the list items. */ @@ -3646,6 +3663,17 @@ else if (lp->ll_range) { listitem_T *li; + listitem_T *ll_li = lp->ll_li; + int ll_n1 = lp->ll_n1; + + while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1)) + { + li = ll_li->li_next; + if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name)) + return FAIL; + ll_li = li; + ++ll_n1; + } /* Delete a range of List items. */ while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1)) diff -r 0ccbf92e36c0 -r 93db73f6960f src/testdir/test55.in --- a/src/testdir/test55.in Sun Aug 10 13:46:36 2014 +0200 +++ b/src/testdir/test55.in Fri Aug 29 08:40:35 2014 +0400 @@ -282,6 +282,21 @@ : $put =ps : endfor :endfor +:unlet l +:let l = [1, 2, 3, 4] +:lockvar! l +:$put =string(l) +:unlockvar l[1] +:unlet l[0:1] +:$put =string(l) +:unlet l[1:2] +:$put =string(l) +:unlockvar l[1] +:let l[0:1] = [0, 1] +:$put =string(l) +:let l[1:2] = [0, 1] +:$put =string(l) +:unlet l :" :lockvar/islocked() triggering script autoloading :set rtp+=./sautest :lockvar g:footest#x diff -r 0ccbf92e36c0 -r 93db73f6960f src/testdir/test55.ok --- a/src/testdir/test55.ok Sun Aug 10 13:46:36 2014 +0200 +++ b/src/testdir/test55.ok Fri Aug 29 08:40:35 2014 +0400 @@ -86,6 +86,11 @@ FFpFFpp 0000-000 ppppppp +[1, 2, 3, 4] +[1, 2, 3, 4] +[1, 2, 3, 4] +[1, 2, 3, 4] +[1, 2, 3, 4] locked g:footest#x:-1 exists g:footest#x:0 g:footest#x: 1 -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
