To: [email protected]
Subject: Patch 7.2c.001
Fcc: outbox
From: Bram Moolenaar <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2c.001
Problem:    ":let x=[''] | let x += x" causes hang. (Matt Wozniski)
Solution:   Only insert elements up to the original length of the List.
Files:      runtime/doc/eval.txt, src/eval.c


*** ../vim-7.2c.000/runtime/doc/eval.txt        Wed Aug  6 18:28:51 2008
--- runtime/doc/eval.txt        Fri Aug  8 11:33:35 2008
***************
*** 2681,2687 ****
               Examples: >
                       :echo sort(extend(mylist, [7, 5]))
                       :call extend(mylist, [2, 3], 1)
! <             Use |add()| to concatenate one item to a list.  To concatenate
               two lists into a new list use the + operator: >
                       :let newlist = [1, 2, 3] + [4, 5]
 <
--- 2681,2691 ----
               Examples: >
                       :echo sort(extend(mylist, [7, 5]))
                       :call extend(mylist, [2, 3], 1)
! <             When {expr1} is the same List as {expr2} then the number of
!               items copied is equal to the original length of the List.
!               E.g., when {expr3} is 1 you get N new copies of the first item
!               (where N is the original length of the List).
!               Use |add()| to concatenate one item to a list.  To concatenate
               two lists into a new list use the + operator: >
                       :let newlist = [1, 2, 3] + [4, 5]
 <
*** ../vim-7.2c.000/src/eval.c  Sun Jul 27 15:57:29 2008
--- src/eval.c  Thu Aug  7 21:37:22 2008
***************
*** 6231,6238 ****
     listitem_T        *bef;
 {
     listitem_T        *item;

!     for (item = l2->lv_first; item != NULL; item = item->li_next)
       if (list_insert_tv(l1, &item->li_tv, bef) == FAIL)
           return FAIL;
     return OK;
--- 6231,6241 ----
     listitem_T        *bef;
 {
     listitem_T        *item;
+     int               todo = l2->lv_len;

!     /* We also quit the loop when we have inserted the original item count of
!      * the list, avoid a hang when we extend a list with itself. */
!     for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next)
       if (list_insert_tv(l1, &item->li_tv, bef) == FAIL)
           return FAIL;
     return OK;
*** ../vim-7.2c.000/src/version.c       Wed Aug  6 18:29:46 2008
--- src/version.c       Fri Aug  8 12:30:51 2008
***************
*** 678,679 ****
--- 678,681 ----
 {   /* Add new patch number below this line */
+ /**/
+     1,
 /**/

--
ARTHUR:  No, hang on!  Just answer the five questions ...
GALAHAD: Three questions ...
ARTHUR:  Three questions ...  And we shall watch ... and pray.
                "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
\\\            help me help AIDS victims -- http://ICCF-Holland.org    ///