[geany/geany] ef2265: Fix renaming of variables with anonymous type
Jiří Techet
git-noreply at geany.org
Fri May 6 22:32:28 UTC 2022
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Fri, 06 May 2022 22:32:28 UTC
Commit: ef2265c451b93e0990e151c6e7764841f16e2bc9
https://github.com/geany/geany/commit/ef2265c451b93e0990e151c6e7764841f16e2bc9
Log Message:
-----------
Fix renaming of variables with anonymous type
It is possible to define variables such as
struct {/* someting */} a, b;
In this case, we need to change the 'var_type' to correspond to the
renamed anonymous struct.
Modified Paths:
--------------
src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -354,6 +354,26 @@ static void rename_anon_tags(TMSourceFile *source_file)
}
}
+ /* We are out of the nesting - the next tags could be variables
+ * of an anonymous struct such as "struct {} a, b;" */
+ while (j < source_file->tags_array->len)
+ {
+ TMTag *var_tag = TM_TAG(source_file->tags_array->pdata[j]);
+ guint var_scope_len = var_tag->scope ? strlen(var_tag->scope) : 0;
+
+ /* Should be at the same scope level as the anon tag */
+ if (var_scope_len == scope_len &&
+ g_strcmp0(var_tag->var_type, orig_name) == 0)
+ {
+ g_free(var_tag->var_type);
+ var_tag->var_type = g_strdup(new_name);
+ }
+ else
+ break;
+
+ j++;
+ }
+
g_free(orig_name);
}
}
--------------
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