From 83ef740e150c5f29bd8ed92681d892160474fd7f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 20 Jun 2019 22:05:29 -0400 Subject: vim-patch:8.0.1239: cannot use a lambda for the skip argument to searchpair() Problem: Cannot use a lambda for the skip argument to searchpair(). Solution: Evaluate a partial, funcref and lambda. (LemonBoy, closes vim/vim#1454, closes vim/vim#2265) https://github.com/vim/vim/commit/48570488f17e397183ea7d5c7ca67d6e4ffb013d --- src/nvim/testdir/test_search.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir/test_search.vim') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 87cad241e2..24ea8cd75a 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -298,6 +298,25 @@ func Test_searchpair() q! endfunc +func Test_searchpair_skip() + func Zero() + return 0 + endfunc + func Partial(x) + return a:x + endfunc + new + call setline(1, ['{', 'foo', 'foo', 'foo', '}']) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', '')) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', '0')) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', {-> 0})) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Zero'))) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Partial', [0]))) + " invalid argument + 3 | call assert_equal(0, searchpair('{', '', '}', 'bWn', 0)) + bw! +endfunc + func Test_searchc() " These commands used to cause memory overflow in searchc(). new -- cgit From efdc0f6a6949ec9bfb0d9ef454871458489773f0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 07:38:43 -0400 Subject: vim-patch:8.1.0112: no error when using bad arguments with searchpair() Problem: No error when using bad arguments with searchpair(). Solution: Add error messages. https://github.com/vim/vim/commit/3dddb09c98825acefa6f2d94bb369b8e00d7b3e5 --- src/nvim/testdir/test_search.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir/test_search.vim') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 24ea8cd75a..c455279a59 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -288,16 +288,26 @@ func Test_searchpair() new call setline(1, ['other code here', '', '[', '" cursor here', ']']) 4 - let a=searchpair('\[','',']','bW') + let a = searchpair('\[','',']','bW') call assert_equal(3, a) set nomagic 4 - let a=searchpair('\[','',']','bW') + let a = searchpair('\[','',']','bW') call assert_equal(3, a) set magic q! endfunc +func Test_searchpair_errors() + call assert_fails("call searchpair([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: using List as a String') + call assert_fails("call searchpair('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: using Funcref as a String') + call assert_fails("call searchpair('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: using Dictionary as a String') + call assert_fails("call searchpair('start', 'middle', 'end', 'flags', 'skip', 99, 100)", 'E475: Invalid argument: flags') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 0, 99, 100)", 'E475: Invalid argument: 0') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100') +endfunc + func Test_searchpair_skip() func Zero() return 0 @@ -312,8 +322,6 @@ func Test_searchpair_skip() 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', {-> 0})) 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Zero'))) 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Partial', [0]))) - " invalid argument - 3 | call assert_equal(0, searchpair('{', '', '}', 'bWn', 0)) bw! endfunc -- cgit From f0d6695e7cc13cd5f1ee006575a369faf2546893 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 20:46:43 -0400 Subject: vim-patch:8.1.0181: memory leak with trailing characters in skip expression Problem: Memory leak with trailing characters in skip expression. Solution: Free the return value. https://github.com/vim/vim/commit/a43ebe9454386427ca38c75810e2d36991f17812 --- src/nvim/testdir/test_search.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir/test_search.vim') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index c455279a59..5e5ec96fd1 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -325,6 +325,16 @@ func Test_searchpair_skip() bw! endfunc +func Test_searchpair_leak() + new + call setline(1, 'if one else another endif') + + " The error in the skip expression caused memory to leak. + call assert_fails("call searchpair('\\', '\\', '\\', '', '\"foo\" 2')", 'E15:') + + bwipe! +endfunc + func Test_searchc() " These commands used to cause memory overflow in searchc(). new -- cgit