This prevents loading a spurious tag for the format specifier line, as well as fixing loading of CTags format with a format specifier line.
Before this change, the file pointer was rewound after reading a format specifier line; but this had various unwanted side effects depending on the recognized format:
* For TagManager and Pipe formats, it led to loading a tag named after the format specifier (e.g. a literal `# format=tagmanager`). This was fairly harmless and only introduced a spurious tag seldom even used because `#` isn't usually considered for looking up completions. * For CTags format, having an explicit specifier led to failure to load the file in most cases because the specifier line would be parsed but doesn't usually follow the format's requirements, leading to early abortion loading that file. On some very specific specifier lines actually following CTags format, it could have led to loading a spurious tag instead.
Fixes #1814 and closes #1816. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1817
-- Commit Summary --
* Skip the format specifier when loading a global tag file
-- File Changes --
M src/tagmanager/tm_source_file.c (5)
-- Patch Links --
https://github.com/geany/geany/pull/1817.patch https://github.com/geany/geany/pull/1817.diff
LGBI.
Looks like a better solution indeed.
@b4n also check [this](https://github.com/geany/geany/blob/7c6b4794b1c0f9696465fb8920ccffc107f5b4d8...) isn't an infinite loop?
LGBI (will possibly do a test with a ctags file in the evening).
@elextr why would this be an infinite loop? The body calls `fgets(buf, …)` so the content of the buffer changes each time, so I don't see the issue?
I did a quick test of a ctags file using the following content at start of the file: ``` # format=ctags !_TAG_PROGRAM_AUTHOR LarsGit223 !_TAG_FILE_FORMAT 1.0 CSS3 ctags file alignment-adjust CSS3 //;"kind:c alignment-baseline CSS3 //;"kind:c ...more tags... ```
``` # format=ctags alignment-adjust CSS3 //;"kind:c alignment-baseline CSS3 //;"kind:c ...more tags... ```
``` alignment-adjust CSS3 //;"kind:c alignment-baseline CSS3 //;"kind:c ...more tags... ``` In all cases the number of imported tags was the same. As a simple test I typed in the first and last tag to see if auto-completion recognizes them. That worked fine in all three cases. So I can confirm that it's working for me for ctags files.
Merged #1817.
@b4n, hah, I read the line as a standalone `while`, not noticing the `do` in front, see so few `do ... while()` loops. :grin:
github-comments@lists.geany.org