[geany/geany] 11da55: Skip the format specifier when loading a global tag file

Colomban Wendling git-noreply at xxxxx
Fri Mar 23 04:48:18 UTC 2018


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Fri, 23 Mar 2018 04:48:18 UTC
Commit:      11da5557a0addb47ede0273d3975486daf9c82c0
             https://github.com/geany/geany/commit/11da5557a0addb47ede0273d3975486daf9c82c0

Log Message:
-----------
Skip the format specifier when loading a global tag file

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.


Modified Paths:
--------------
    src/tagmanager/tm_source_file.c

Modified: src/tagmanager/tm_source_file.c
5 lines changed, 3 insertions(+), 2 deletions(-)
===================================================================
@@ -537,7 +537,7 @@ GPtrArray *tm_source_file_read_tags_file(const gchar *tags_file, TMParserType mo
 		return NULL; /* early out on error */
 	}
 	else
-	{	/* We read the first line for the format specification. */
+	{	/* We read (and discard) the first line for the format specification. */
 		if (buf[0] == '#' && strstr((gchar*) buf, "format=pipe") != NULL)
 			format = TM_FILE_FORMAT_PIPE;
 		else if (buf[0] == '#' && strstr((gchar*) buf, "format=tagmanager") != NULL)
@@ -562,8 +562,9 @@ GPtrArray *tm_source_file_read_tags_file(const gchar *tags_file, TMParserType mo
 				format = TM_FILE_FORMAT_PIPE;
 			else if (tab_cnt > 1)
 				format = TM_FILE_FORMAT_CTAGS;
+			/* reset the file pointer, to start reading again from the beginning */
+			rewind(fp);
 		}
-		rewind(fp); /* reset the file pointer, to start reading again from the beginning */
 	}
 
 	file_tags = g_ptr_array_new();



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list