]> granicus.if.org Git - vim/commitdiff
patch 8.1.1094: long line in tags file causes error v8.1.1094
authorBram Moolenaar <Bram@vim.org>
Sat, 30 Mar 2019 20:41:48 +0000 (21:41 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 30 Mar 2019 20:41:48 +0000 (21:41 +0100)
Problem:    Long line in tags file causes error.
Solution:   Check for overlong line earlier. (Andy Massimino, closes #4051,
            closes #4084)

src/tag.c
src/testdir/test_tagjump.vim
src/version.c

index 20473d111574835fb6c472899b7abb1fff820026..0f4a70d97574968ac95fa3909ab6cfc934d772b3 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -1921,6 +1921,32 @@ line_read_in:
            }
 
 parse_line:
+           if (vim_strchr(lbuf, NL) == NULL
+#ifdef FEAT_CSCOPE
+                                            && !use_cscope
+#endif
+                                            )
+           {
+               // 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();
+               }
+#ifdef FEAT_TAG_BINS
+               if (state != TS_LINEAR)
+               {
+                   // Avoid getting stuck.
+                   linear = TRUE;
+                   state = TS_LINEAR;
+                   vim_fseek(fp, search_info.low_offset, SEEK_SET);
+               }
+#endif
+               continue;
+           }
+
            /*
             * Figure out where the different strings are in this line.
             * For "normal" tags: Do a quick check if the tag matches.
@@ -1937,28 +1963,6 @@ parse_line:
                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();
-                       }
-#ifdef FEAT_TAG_BINS
-                       if (state != TS_LINEAR)
-                       {
-                           /* Avoid getting stuck. */
-                           linear = TRUE;
-                           state = TS_LINEAR;
-                           vim_fseek(fp, search_info.low_offset, SEEK_SET);
-                       }
-#endif
-                       continue;
-                   }
-
                    /* Corrupted tag line. */
                    line_error = TRUE;
                    break;
index 4ce9ece879639421e84b4c61675f01a043343cf0..7e64ac43589b445d538119597ec622670b4b013c 100644 (file)
@@ -439,4 +439,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
index 6287c79d7a97a2f6571fd61cdd38aec81c2e0014..9ba9e92d0cd85fc6e199425c4ffa1e40fd5bf760 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1094,
 /**/
     1093,
 /**/