Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Thu, 01 Sep 2022 21:05:29 UTC Commit: b8754a7a32e2972761e07ebb191db44ab01ec6bb https://github.com/geany/geany/commit/b8754a7a32e2972761e07ebb191db44ab01ec6...
Log Message: ----------- Fix renaming tag type containing anonymous type
The current code assumes that the whole var_type string consists of the anonymous type name. This works for simple cases like
struct {} X;
where X is of the type __anonXXXX but not for cases like
struct {} X[2];
where X is of type __anonXXXX[].
For these cases checking for equality of var_tag->var_type, orig_name isn't sufficient and we have to check whether orig_name is a substring of var_tag->var_type and replace this substring with the new anon name.
This problem can be seen for instance in the symbol tree tooltip of the symbols_icons variable inside symbols.c
Modified Paths: -------------- src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c 12 lines changed, 9 insertions(+), 3 deletions(-) =================================================================== @@ -380,18 +380,24 @@ 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;" */ + * of an anonymous struct such as "struct {} a[2], *b, c;" */ 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; + gchar *pos;
/* 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) + var_tag->var_type && (pos = strstr(var_tag->var_type, orig_name))) { + GString *str = g_string_new(var_tag->var_type); + gssize p = pos - var_tag->var_type; + g_string_erase(str, p, strlen(orig_name)); + g_string_insert(str, p, new_name); g_free(var_tag->var_type); - var_tag->var_type = g_strdup(new_name); + var_tag->var_type = str->str; + g_string_free(str, FALSE); } else break;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).