On import of a global tags file, do not rewind the file if the first line is ```# format=ctags```. Otherwise the import would abort on the first line and 0 symbols would be imported. Fixes #1814. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1816
-- Commit Summary --
* tagmanager: do not rewind file on '# format=ctags'
-- File Changes --
M src/tagmanager/tm_source_file.c (9)
-- Patch Links --
https://github.com/geany/geany/pull/1816.patch https://github.com/geany/geany/pull/1816.diff
No, that won't work. Simply not rewinding will leave the file having read BUFSIZ which is guaranteed to be at least 256, so well past the end of the type spec that is to be skipped. So have to always rewind, then forward over the `# format=ctags` part (probably keep the length from having found it).
Or I'm not sure why it doesn't use getline() instead of reading BUFSIZ, but anyway.
Also noticed the "skip" code [here](https://github.com/geany/geany/blob/7c6b4794b1c0f9696465fb8920ccffc107f5b4d8...) would seem to actually be an infinite loop?
No, ```fgets``` also stops at a newline, see this cite from cplusplus.com:
Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first.
A problem would only occur if the line is longer than ``BUFSIZ```.
No, fgets also stops at a newline, see this cite from cplusplus.com:
Ok.
While this seems to be a fair enough fix for the problem you describe, there's actually more issues with this `rewind()` call, although they are a lot less important indeed. See #1817.
Closed #1816.
Ok, closing this.
github-comments@lists.geany.org