0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

updated for version 7.2-295

This commit is contained in:
Bram Moolenaar
2009-11-17 11:20:35 +00:00
parent eaf0339211
commit 627b1d3862
3 changed files with 11 additions and 4 deletions

View File

@@ -3802,7 +3802,8 @@ map({expr}, {string}) *map()*
Replace each item in {expr} with the result of evaluating Replace each item in {expr} with the result of evaluating
{string}. {string}.
Inside {string} |v:val| has the value of the current item. Inside {string} |v:val| has the value of the current item.
For a |Dictionary| |v:key| has the key of the current item. For a |Dictionary| |v:key| has the key of the current item
and for a |List| |v:key| has the index of the current item.
Example: > Example: >
:call map(mylist, '"> " . v:val . " <"') :call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist". < This puts "> " before and " <" after each item in "mylist".

View File

@@ -9928,6 +9928,7 @@ filter_map(argvars, rettv, map)
int todo; int todo;
char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()"; char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
int save_did_emsg; int save_did_emsg;
int index = 0;
if (argvars[0].v_type == VAR_LIST) if (argvars[0].v_type == VAR_LIST)
{ {
@@ -9961,9 +9962,9 @@ filter_map(argvars, rettv, map)
save_did_emsg = did_emsg; save_did_emsg = did_emsg;
did_emsg = FALSE; did_emsg = FALSE;
prepare_vimvar(VV_KEY, &save_key);
if (argvars[0].v_type == VAR_DICT) if (argvars[0].v_type == VAR_DICT)
{ {
prepare_vimvar(VV_KEY, &save_key);
vimvars[VV_KEY].vv_type = VAR_STRING; vimvars[VV_KEY].vv_type = VAR_STRING;
ht = &d->dv_hashtab; ht = &d->dv_hashtab;
@@ -9987,24 +9988,27 @@ filter_map(argvars, rettv, map)
} }
} }
hash_unlock(ht); hash_unlock(ht);
restore_vimvar(VV_KEY, &save_key);
} }
else else
{ {
vimvars[VV_KEY].vv_type = VAR_NUMBER;
for (li = l->lv_first; li != NULL; li = nli) for (li = l->lv_first; li != NULL; li = nli)
{ {
if (tv_check_lock(li->li_tv.v_lock, ermsg)) if (tv_check_lock(li->li_tv.v_lock, ermsg))
break; break;
nli = li->li_next; nli = li->li_next;
vimvars[VV_KEY].vv_nr = index;
if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL
|| did_emsg) || did_emsg)
break; break;
if (!map && rem) if (!map && rem)
listitem_remove(l, li); listitem_remove(l, li);
++index;
} }
} }
restore_vimvar(VV_KEY, &save_key);
restore_vimvar(VV_VAL, &save_val); restore_vimvar(VV_VAL, &save_val);
did_emsg |= save_did_emsg; did_emsg |= save_did_emsg;

View File

@@ -681,6 +681,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
295,
/**/ /**/
294, 294,
/**/ /**/