From 2a73549ee8633afa817cc49fd691dc0ed3e67cf4 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Mon, 1 Apr 2019 01:38:55 +0200 Subject: vim-patch:8.1.1093: support for outdated tags format slows down tag parsing Problem: Support for outdated tags format slows down tag parsing. Solution: Remove FEAT_TAG_OLDSTATIC. https://github.com/vim/vim/commit/96428dd4e961332e97d86013a321cedf5fafbed6 --- src/nvim/tag.c | 62 +++++++++------------------------------------------------- 1 file changed, 9 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c609af4751..bc425ab6d4 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1560,24 +1560,6 @@ parse_line: break; } - /* - * Check for old style static tag: "file:tag file .." - */ - tagp.fname = NULL; - for (p = lbuf; p < tagp.tagname_end; ++p) { - if (*p == ':') { - if (tagp.fname == NULL) - tagp.fname = tagp.tagname_end + 1; - if ( fnamencmp(lbuf, tagp.fname, p - lbuf) == 0 - && tagp.fname[p - lbuf] == TAB - ) { - /* found one */ - tagp.tagname = p + 1; - break; - } - } - } - /* * Skip this line if the length of the tag is different and * there is no regexp, or the tag is too short. @@ -1677,11 +1659,8 @@ parse_line: if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) continue; - /* - * Can be a matching tag, isolate the file name and command. - */ - if (tagp.fname == NULL) - tagp.fname = tagp.tagname_end + 1; + // Can be a matching tag, isolate the file name and command. + tagp.fname = tagp.tagname_end + 1; tagp.fname_end = vim_strchr(tagp.fname, TAB); tagp.command = tagp.fname_end + 1; if (tagp.fname_end == NULL) @@ -1748,19 +1727,12 @@ parse_line: /* Don't change the ordering, always use the same table. */ mtt = MT_GL_OTH; } else { - /* Decide in which array to store this match. */ - is_current = test_for_current( - tagp.fname, tagp.fname_end, tag_fname, - buf_ffname); - { - if (tagp.tagname != lbuf) - is_static = TRUE; /* detected static tag before */ - else - is_static = test_for_static(&tagp); - } + // Decide in which array to store this match. + is_current = test_for_current(tagp.fname, tagp.fname_end, tag_fname, + buf_ffname); + is_static = test_for_static(&tagp); - /* decide in which of the sixteen tables to store this - * match */ + // Decide in which of the sixteen tables to store this match. if (is_static) { if (is_current) mtt = MT_ST_CUR; @@ -2192,25 +2164,9 @@ parse_tag_line ( */ static bool test_for_static(tagptrs_T *tagp) { - char_u *p; - - int len; + char_u *p; - /* - * Check for old style static tag: "file:tag file .." - */ - len = (int)(tagp->fname_end - tagp->fname); - p = tagp->tagname + len; - if ( p < tagp->tagname_end - && *p == ':' - && fnamencmp(tagp->tagname, tagp->fname, len) == 0) { - tagp->tagname = p + 1; - return TRUE; - } - - /* - * Check for new style static tag ":...file:[...]" - */ + // Check for new style static tag ":...file:[...]" p = tagp->command; while ((p = vim_strchr(p, '\t')) != NULL) { ++p; -- cgit From e05a47f68b84fb4318959d9563f865f63ef5fa4d Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Mon, 1 Apr 2019 01:50:01 +0200 Subject: vim-patch:8.1.1094: long line in tags file causes error Problem: Long line in tags file causes error. Solution: Check for overlong line earlier. (Andy Massimino) https://github.com/vim/vim/commit/5209334c551778fe6f76945f373ee14fcac96f52 --- src/nvim/tag.c | 52 ++++++++++++++++++--------------------- src/nvim/testdir/test_tagjump.vim | 31 +++++++++++++++++++++++ 2 files changed, 55 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index bc425ab6d4..c2254e2416 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1527,36 +1527,32 @@ line_read_in: } parse_line: - /* - * Figure out where the different strings are in this line. - * For "normal" tags: Do a quick check if the tag matches. - * This speeds up tag searching a lot! - */ - if (orgpat.headlen - ) { + if (vim_strchr(lbuf, NL) == NULL && !use_cscope) { + // Truncated line, ignore it. Has been reported for Mozilla JS with + // extremely long names. + if (p_verbose >= 5) { + verbose_enter(); + MSG(_("Ignoring long line in tags file")); + verbose_leave(); + } + if (state != TS_LINEAR) { + // Avoid getting stuck. + linear = true; + state = TS_LINEAR; + vim_fseek(fp, search_info.low_offset, SEEK_SET); + } + continue; + } + + // Figure out where the different strings are in this line. + // For "normal" tags: Do a quick check if the tag matches. + // This speeds up tag searching a lot! + if (orgpat.headlen) { tagp.tagname = lbuf; tagp.tagname_end = vim_strchr(lbuf, TAB); - if (tagp.tagname_end == NULL) - { - if (vim_strchr(lbuf, NL) == NULL) { - /* Truncated line, ignore it. Has been reported for - * Mozilla JS with extremely long names. */ - if (p_verbose >= 5) { - verbose_enter(); - MSG(_("Ignoring long line in tags file")); - verbose_leave(); - } - if (state != TS_LINEAR) { - /* Avoid getting stuck. */ - linear = TRUE; - state = TS_LINEAR; - vim_fseek(fp, search_info.low_offset, SEEK_SET); - } - continue; - } - - /* Corrupted tag line. */ - line_error = TRUE; + if (tagp.tagname_end == NULL) { + // Corrupted tag line. + line_error = true; break; } diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index 180738a7c9..ad1f5fab73 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -331,4 +331,35 @@ func Test_tagnr_recall() call delete('Xtest.c') endfunc +func Test_tag_line_toolong() + call writefile([ + \ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' + \ ], 'Xtags') + set tags=Xtags + let old_vbs = &verbose + set verbose=5 + " ":tjump" should give "tag not found" not "Format error in tags file" + call assert_fails('tj /foo', 'E426') + try + tj /foo + catch /^Vim\%((\a\+)\)\=:E431/ + call assert_report(v:exception) + catch /.*/ + endtry + call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1]) + call writefile([ + \ '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' + \ ], 'Xtags') + call assert_fails('tj /foo', 'E426') + try + tj /foo + catch /^Vim\%((\a\+)\)\=:E431/ + call assert_report(v:exception) + catch /.*/ + endtry + call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1]) + call delete('Xtags') + let &verbose = old_vbs +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From a79c0c8f7a8bb09a5d3eda9799851e271e986579 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 2 Apr 2019 22:15:54 +0200 Subject: vim-patch:8.1.1100: tag file without trailing newline no longer works Problem: Tag file without trailing newline no longer works. (Marco Hinz) Solution: Don't expect a newline at the end of the file. https://github.com/vim/vim/commit/fd700393becfc35b6fad305221265b87a8564ddb --- src/nvim/tag.c | 8 +++++--- src/nvim/testdir/test_taglist.vim | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c2254e2416..861063ff62 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1527,9 +1527,11 @@ line_read_in: } parse_line: - if (vim_strchr(lbuf, NL) == NULL && !use_cscope) { - // Truncated line, ignore it. Has been reported for Mozilla JS with - // extremely long names. + // When the line is too long the NUL will not be in the + // last-but-one byte (see vim_fgets()). + // Has been reported for Mozilla JS with extremely long names. + // In that case we can't parse it and we ignore the line. + if (lbuf[LSIZE - 2] != NUL && !use_cscope) { if (p_verbose >= 5) { verbose_enter(); MSG(_("Ignoring long line in tags file")); diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim index 3ad2025915..f4e939254a 100644 --- a/src/nvim/testdir/test_taglist.vim +++ b/src/nvim/testdir/test_taglist.vim @@ -61,3 +61,16 @@ func Test_tags_too_long() call assert_fails('tag ' . repeat('x', 1020), 'E426') tags endfunc + +" For historical reasons we support a tags file where the last line is missing +" the newline. +func Test_tagsfile_without_trailing_newline() + call writefile(["Foo\tfoo\t1"], 'Xtags', 'b') + set tags=Xtags + + let tl = taglist('.*') + call assert_equal(1, len(tl)) + call assert_equal('Foo', tl[0].name) + + call delete('Xtags') +endfunc -- cgit