Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 27 Aug 2022 22:22:29 UTC
Commit: fe4c0738ebbed148117fed85ad44528dec089e90
https://github.com/geany/geany/commit/fe4c0738ebbed148117fed85ad44528dec089…
Log Message:
-----------
Fix anonymous tag renaming when interleaved by scopeless macros
This problem can be seen on
scintilla/src/Document.cxx
where not all anonymous tags are renamed because of macros. Fix that
by not breaking the rename loop for macros for C-like languages.
Modified Paths:
--------------
src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c
11 lines changed, 10 insertions(+), 1 deletions(-)
===================================================================
@@ -245,6 +245,7 @@ void tm_ctags_clear_ignore_symbols(void)
* with the counter (which gets complicated when also subparsers are involved) */
static void rename_anon_tags(TMSourceFile *source_file)
{
+ gboolean is_c = source_file->lang == TM_PARSER_C || source_file->lang == TM_PARSER_CPP;
gint *anon_counter_table = NULL;
GPtrArray *removed_typedefs = NULL;
guint i;
@@ -264,7 +265,7 @@ static void rename_anon_tags(TMSourceFile *source_file)
orig_name = tag->name;
orig_name_len = strlen(orig_name);
- if (source_file->lang == TM_PARSER_C || source_file->lang == TM_PARSER_CPP)
+ if (is_c)
{
/* First check if there's a typedef behind the scope nesting
* such as typedef struct {} Foo; - in this case we can replace
@@ -274,6 +275,10 @@ static void rename_anon_tags(TMSourceFile *source_file)
TMTag *nested_tag = TM_TAG(source_file->tags_array->pdata[j]);
guint nested_scope_len = nested_tag->scope ? strlen(nested_tag->scope) : 0;
+ /* Tags can be interleaved with scopeless macros - skip those */
+ if (nested_tag->type & (tm_tag_macro_t | tm_tag_macro_with_arg_t))
+ continue;
+
/* Nested tags have longer scope than the parent - once the scope
* is equal or lower than the parent scope, we are outside the tag's
* scope. */
@@ -333,6 +338,10 @@ static void rename_anon_tags(TMSourceFile *source_file)
guint nested_scope_len = nested_tag->scope ? strlen(nested_tag->scope) : 0;
gchar *pos;
+ /* Tags can be interleaved with scopeless macros - skip those */
+ if (is_c && nested_tag->type & (tm_tag_macro_t | tm_tag_macro_with_arg_t))
+ continue;
+
/* In Fortran, we can create variables of anonymous structures:
* structure var1, var2
* integer a
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).