# HG changeset patch # User vimboss # Date 1218191791 0 # Node ID 9d74e2f433c0370cb458c83d12b05f72226df489 # Parent f4f8014d516e9b9620311aa2bb7a5a2d5749f451 updated for version 7.2c-001 diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2681,7 +2681,11 @@ extend({expr1}, {expr2} [, {expr3}]) * Examples: > :echo sort(extend(mylist, [7, 5])) :call extend(mylist, [2, 3], 1) -< Use |add()| to concatenate one item to a list. To concatenate +< 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] < diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -6231,8 +6231,11 @@ list_extend(l1, l2, bef) listitem_T *bef; { listitem_T *item; - - for (item = l2->lv_first; item != NULL; item = item->li_next) + 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; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -677,6 +677,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1, +/**/ 0 };