From 36f13ceb0ab384f0cad9813ae02792a1cf13021a Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 27 Sep 2017 20:05:17 +0800 Subject: [PATCH 1/3] vim-patch:8.0.0131 Problem: Not enough test coverage for syntax commands. Solution: Add more tests. (Dominique Pelle) https://github.com/vim/vim/commit/73b484c4da00011317dc68ada4f5dfc6515ad263 --- src/nvim/testdir/test_syntax.vim | 78 +++++++++++++++++++++++++++++++- src/nvim/version.c | 2 +- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index af2cbbfe8e..584b6f024a 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -50,7 +50,7 @@ func Test_syn_iskeyword() setlocal isk-=_ call assert_equal('DLTD_BY', GetSyntaxItem('DLTD')) /\/:norm! ygn - let b2=@0 + let b2 = @0 call assert_equal('DLTD', @0) syn iskeyword clear @@ -76,3 +76,79 @@ func Test_syntax_after_reload() call assert_true(exists('g:gotit')) call delete('Xsomefile') endfunc + +func Test_syntime() + if !has('profile') + finish + endif + + syntax on + syntime on + let a = execute('syntime report') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + view ../memfile_test.c + setfiletype cpp + redraw + let a = execute('syntime report') + call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a) + call assert_match(' \d*\.\d* \+[^0]\d* .* cppRawString ', a) + call assert_match(' \d*\.\d* \+[^0]\d* .* cppNumber ', a) + + syntime off + syntime clear + let a = execute('syntime report') + call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a) + call assert_notmatch('.* cppRawString *', a) + call assert_notmatch('.* cppNumber*', a) + call assert_notmatch('[1-9]', a) + + call assert_fails('syntime abc', 'E475') + + syntax clear + let a = execute('syntime report') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + bd +endfunc + +func Test_syntax_list() + syntax on + let a = execute('syntax list') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + view ../memfile_test.c + setfiletype c + + let a = execute('syntax list') + call assert_match('cInclude*', a) + call assert_match('cDefine', a) + + let a = execute('syntax list cDefine') + call assert_notmatch('cInclude*', a) + call assert_match('cDefine', a) + call assert_match(' links to Macro$', a) + + call assert_fails('syntax list ABCD', 'E28:') + call assert_fails('syntax list @ABCD', 'E392:') + + syntax clear + let a = execute('syntax list') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + bd +endfunc + +func Test_syntax_completion() + call feedkeys(":syn \\\"\", 'tx') + call assert_equal('"syn case clear cluster conceal enable include iskeyword keyword list manual match off on region reset spell sync', @:) + + call feedkeys(":syn case \\\"\", 'tx') + call assert_equal('"syn case ignore match', @:) + + call feedkeys(":syn list \\\"\", 'tx') + call assert_match('^"syn list Boolean Character ', @:) + + call feedkeys(":syn match \\\"\", 'tx') + call assert_match('^"syn match Boolean Character ', @:) +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b0d4e194fa..bf53f16e8d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -972,7 +972,7 @@ static const int included_patches[] = { 134, 133, // 132, - // 131, + 131, // 130 NA // 129 NA 128, From 65c97961ecdcfa89bb0ce9ff88f1e84e4d926f21 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 27 Sep 2017 20:06:35 +0800 Subject: [PATCH 2/3] vim-patch:8.0.0132 Problem: Test fails because of using :finish. Solution: Change to return. https://github.com/vim/vim/commit/4c8980b717f73042f1d625ee255fa74eddb989ba --- src/nvim/testdir/test_syntax.vim | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 584b6f024a..73594f0f55 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -79,7 +79,7 @@ endfunc func Test_syntime() if !has('profile') - finish + return endif syntax on diff --git a/src/nvim/version.c b/src/nvim/version.c index bf53f16e8d..6b57185b50 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -971,7 +971,7 @@ static const int included_patches[] = { 135, 134, 133, - // 132, + 132, 131, // 130 NA // 129 NA From f97ca6b3339ca04477296c834a159d40d2201ccd Mon Sep 17 00:00:00 2001 From: ckelsel Date: Thu, 28 Sep 2017 11:47:26 +0800 Subject: [PATCH 3/3] vim-patch:8.0.0155 Problem: When sorting zero elements a NULL pointer is passed to qsort(), which ubsan warns for. Solution: Don't call qsort() if there are no elements. (Dominique Pelle) https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e --- src/nvim/syntax.c | 9 ++++++--- src/nvim/version.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 65c0e2464a..5781424d2b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5845,9 +5845,12 @@ static void syntime_report(void) } } - /* sort on total time */ - qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T), - syn_compare_syntime); + // Sort on total time. Skip if there are no items to avoid passing NULL + // pointer to qsort(). + if (ga.ga_len > 1) { + qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T), + syn_compare_syntime); + } MSG_PUTS_TITLE(_( " TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN")); diff --git a/src/nvim/version.c b/src/nvim/version.c index 6b57185b50..1432a92998 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -948,7 +948,7 @@ static const int included_patches[] = { 158, // 157, 156, - // 155, + 155, // 154, // 153, // 152 NA