Skip to content

Commit 5209334

Browse files
committed
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, closes #4051, closes #4084)
1 parent 96428dd commit 5209334

3 files changed

Lines changed: 59 additions & 22 deletions

File tree

src/tag.c

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,32 @@ find_tags(
19211921
}
19221922

19231923
parse_line:
1924+
if (vim_strchr(lbuf, NL) == NULL
1925+
#ifdef FEAT_CSCOPE
1926+
&& !use_cscope
1927+
#endif
1928+
)
1929+
{
1930+
// Truncated line, ignore it. Has been reported for
1931+
// Mozilla JS with extremely long names.
1932+
if (p_verbose >= 5)
1933+
{
1934+
verbose_enter();
1935+
msg(_("Ignoring long line in tags file"));
1936+
verbose_leave();
1937+
}
1938+
#ifdef FEAT_TAG_BINS
1939+
if (state != TS_LINEAR)
1940+
{
1941+
// Avoid getting stuck.
1942+
linear = TRUE;
1943+
state = TS_LINEAR;
1944+
vim_fseek(fp, search_info.low_offset, SEEK_SET);
1945+
}
1946+
#endif
1947+
continue;
1948+
}
1949+
19241950
/*
19251951
* Figure out where the different strings are in this line.
19261952
* For "normal" tags: Do a quick check if the tag matches.
@@ -1937,28 +1963,6 @@ find_tags(
19371963
tagp.tagname_end = vim_strchr(lbuf, TAB);
19381964
if (tagp.tagname_end == NULL)
19391965
{
1940-
if (vim_strchr(lbuf, NL) == NULL)
1941-
{
1942-
/* Truncated line, ignore it. Has been reported for
1943-
* Mozilla JS with extremely long names. */
1944-
if (p_verbose >= 5)
1945-
{
1946-
verbose_enter();
1947-
msg(_("Ignoring long line in tags file"));
1948-
verbose_leave();
1949-
}
1950-
#ifdef FEAT_TAG_BINS
1951-
if (state != TS_LINEAR)
1952-
{
1953-
/* Avoid getting stuck. */
1954-
linear = TRUE;
1955-
state = TS_LINEAR;
1956-
vim_fseek(fp, search_info.low_offset, SEEK_SET);
1957-
}
1958-
#endif
1959-
continue;
1960-
}
1961-
19621966
/* Corrupted tag line. */
19631967
line_error = TRUE;
19641968
break;

src/testdir/test_tagjump.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,35 @@ func Test_tagnr_recall()
439439
call delete('Xtest.c')
440440
endfunc
441441

442+
func Test_tag_line_toolong()
443+
call writefile([
444+
\ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML'
445+
\ ], 'Xtags')
446+
set tags=Xtags
447+
let old_vbs = &verbose
448+
set verbose=5
449+
" ":tjump" should give "tag not found" not "Format error in tags file"
450+
call assert_fails('tj /foo', 'E426')
451+
try
452+
tj /foo
453+
catch /^Vim\%((\a\+)\)\=:E431/
454+
call assert_report(v:exception)
455+
catch /.*/
456+
endtry
457+
call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1])
458+
call writefile([
459+
\ '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML'
460+
\ ], 'Xtags')
461+
call assert_fails('tj /foo', 'E426')
462+
try
463+
tj /foo
464+
catch /^Vim\%((\a\+)\)\=:E431/
465+
call assert_report(v:exception)
466+
catch /.*/
467+
endtry
468+
call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1])
469+
call delete('Xtags')
470+
let &verbose = old_vbs
471+
endfunc
472+
442473
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1094,
774776
/**/
775777
1093,
776778
/**/

0 commit comments

Comments
 (0)