Skip to content

Commit 9585a16

Browse files
committed
patch 8.0.0550: cannot parse some etags format tags file
Problem: Some etags format tags file use 0x01, breaking the parsing. Solution: Use 0x02 for TAG_SEP. (James McCoy, closes #1614)
1 parent 395b6ba commit 9585a16

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

src/tag.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,18 +2355,19 @@ find_tags(
23552355
}
23562356
else
23572357
{
2358-
#define TAG_SEP 0x01
2358+
#define TAG_SEP 0x02
23592359
size_t tag_fname_len = STRLEN(tag_fname);
23602360
#ifdef FEAT_EMACS_TAGS
23612361
size_t ebuf_len = 0;
23622362
#endif
23632363

23642364
/* Save the tag in a buffer.
2365-
* Use 0x01 to separate fields (Can't use NUL, because the
2366-
* hash key is terminated by NUL).
2367-
* Emacs tag: <mtt><tag_fname><0x01><ebuf><0x01><lbuf><NUL>
2368-
* other tag: <mtt><tag_fname><0x01><0x01><lbuf><NUL>
2369-
* without Emacs tags: <mtt><tag_fname><0x01><lbuf><NUL>
2365+
* Use 0x02 to separate fields (Can't use NUL because the
2366+
* hash key is terminated by NUL, or Ctrl_A because that is
2367+
* part of some Emacs tag files -- see parse_tag_line).
2368+
* Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL>
2369+
* other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL>
2370+
* without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL>
23702371
* Here <mtt> is the "mtt" value plus 1 to avoid NUL.
23712372
*/
23722373
len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3;

src/testdir/test_taglist.vim

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,40 @@ func Test_taglist()
1919
bwipe
2020
endfunc
2121

22+
func Test_taglist_native_etags()
23+
if !has('emacs_tags')
24+
return
25+
endif
26+
call writefile([
27+
\ "\x0c",
28+
\ "src/os_unix.c,13491",
29+
\ "set_signals(\x7f1335,32699",
30+
\ "reset_signals(\x7f1407,34136",
31+
\ ], 'Xtags')
32+
33+
set tags=Xtags
34+
35+
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
36+
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
37+
38+
call delete('Xtags')
39+
endfunc
40+
41+
func Test_taglist_ctags_etags()
42+
if !has('emacs_tags')
43+
return
44+
endif
45+
call writefile([
46+
\ "\x0c",
47+
\ "src/os_unix.c,13491",
48+
\ "set_signals(void)\x7fset_signals\x011335,32699",
49+
\ "reset_signals(void)\x7freset_signals\x011407,34136",
50+
\ ], 'Xtags')
51+
52+
set tags=Xtags
53+
54+
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
55+
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
56+
57+
call delete('Xtags')
58+
endfunc

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
550,
767769
/**/
768770
549,
769771
/**/

0 commit comments

Comments
 (0)