To: vim_dev@googlegroups.com Subject: Patch 7.4.2160 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2160 Problem: setmatches() mixes up values. (Nikolai Pavlov) Solution: Save the string instead of reusing a shared buffer. Files: src/dict.c, src/evalfunc.c, src/testdir/test_expr.vim *** ../vim-7.4.2159/src/dict.c 2016-07-17 15:46:08.464046515 +0200 --- src/dict.c 2016-08-05 21:36:31.453078198 +0200 *************** *** 418,423 **** --- 418,424 ---- /* * 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 * *** ../vim-7.4.2159/src/evalfunc.c 2016-08-05 20:35:09.786315271 +0200 --- src/evalfunc.c 2016-08-05 21:39:04.755860033 +0200 *************** *** 9659,9669 **** } } ! group = get_dict_string(d, (char_u *)"group", FALSE); 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) : NULL; if (i == 0) { --- 9659,9669 ---- } } ! 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", TRUE) : NULL; if (i == 0) { *************** *** 9677,9682 **** --- 9677,9684 ---- list_unref(s); s = NULL; } + vim_free(group); + vim_free(conceal); li = li->li_next; } *** ../vim-7.4.2159/src/testdir/test_expr.vim 2016-08-01 15:40:24.187878367 +0200 --- src/testdir/test_expr.vim 2016-08-05 21:43:13.637884751 +0200 *************** *** 194,196 **** --- 194,205 ---- 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 *** ../vim-7.4.2159/src/version.c 2016-08-05 21:25:26.054376197 +0200 --- src/version.c 2016-08-05 21:37:39.760535161 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2160, /**/ -- Hanson's Treatment of Time: There are never enough hours in a day, but always too many days before Saturday. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///