diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-05 22:22:06 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-05 22:22:06 +0200 |
commit | 7dc5e2e486fe0287601968e535902a41a39f65bb (patch) | |
tree | 7dae219602d36900e7c309d44a17f4e800bf90aa /src | |
parent | 5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9 (diff) |
patch 7.4.2160v7.4.2160
Problem: setmatches() mixes up values. (Nikolai Pavlov)
Solution: Save the string instead of reusing a shared buffer.
Diffstat (limited to 'src')
-rw-r--r-- | src/dict.c | 1 | ||||
-rw-r--r-- | src/evalfunc.c | 6 | ||||
-rw-r--r-- | src/testdir/test_expr.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/dict.c b/src/dict.c index 9c590064cc..30a15a6f07 100644 --- a/src/dict.c +++ b/src/dict.c @@ -418,6 +418,7 @@ dict_find(dict_T *d, char_u *key, int len) /* * Get a string item from a dictionary. * When "save" is TRUE allocate memory for it. + * When FALSE a shared buffer is used, can only be used once! * Returns NULL if the entry doesn't exist or out of memory. */ char_u * diff --git a/src/evalfunc.c b/src/evalfunc.c index 00956612f8..dc0e630af8 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -9659,11 +9659,11 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) } } - group = get_dict_string(d, (char_u *)"group", FALSE); + group = get_dict_string(d, (char_u *)"group", TRUE); priority = (int)get_dict_number(d, (char_u *)"priority"); id = (int)get_dict_number(d, (char_u *)"id"); conceal = dict_find(d, (char_u *)"conceal", -1) != NULL - ? get_dict_string(d, (char_u *)"conceal", FALSE) + ? get_dict_string(d, (char_u *)"conceal", TRUE) : NULL; if (i == 0) { @@ -9677,6 +9677,8 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) list_unref(s); s = NULL; } + vim_free(group); + vim_free(conceal); li = li->li_next; } diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 0800039aee..557d74960f 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -194,3 +194,12 @@ func Test_funcref() let OneByRef = funcref('One') call assert_equal(2, OneByRef()) endfunc + +func Test_setmatches() + hi def link 1 Comment + hi def link 2 PreProc + let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4, "conceal": 5}] + let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4, "conceal": '5'}] + call setmatches(set) + call assert_equal(exp, getmatches()) +endfunc diff --git a/src/version.c b/src/version.c index 1c83d6e7b8..94e14bff86 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2160, +/**/ 2159, /**/ 2158, |