<p></p>
<p><b>@kugel-</b> requested changes on this pull request.</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772278102">src/tagmanager/tm_parser.c</a>:</p>
<pre style='color:#555'>> @@ -818,6 +818,28 @@ void tm_parser_verify_type_mappings(void)
}
+/* determine anonymous tags from tag names only when corresponding
+ * ctags information is not available */
+gboolean tm_parser_is_anon_name(TMParserType lang, gchar *name)
+{
+ guint i;
+ char dummy;
+
+ if (lang == TM_PARSER_C || lang == TM_PARSER_CPP)
+ {
+ return sscanf(name, "anon_%*[a-z]_%u%c", &i, &dummy) == 1 ||
</pre>
<p dir="auto">Does sscanf really understand regexes? This is also new over the old code in <code>tm_tag_is_anon()</code></p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772278152">src/tagmanager/tm_workspace.c</a>:</p>
<pre style='color:#555'>> @@ -695,7 +695,7 @@ static void fill_find_tags_array_prefix(GPtrArray *dst, const GPtrArray *src,
for (i = 0; i < count && num < max_num; ++i)
{
if (tm_parser_langs_compatible(lang, (*tag)->lang) &&
- !tm_tag_is_anon(*tag) &&
+ !((*tag)->flags & tm_tag_flag_anon_t) &&
</pre>
<p dir="auto">IMO the this is not an improvement. Might keep <code>tm_tag_is_anon()</code> and reduce its implementation to just test the flag</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772279678">scripts/update-ctags.py</a>:</p>
<pre style='color:#555'>> @@ -51,6 +51,3 @@
main_diff = set(main_src_files) - set(main_dst_files)
if main_diff:
print('Files added to main: ' + str(main_diff))
-
-os.chdir(dstdir)
-os.system('patch -p1 <ctags_changes.patch')
</pre>
<p dir="auto">yay</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772280531">src/tagmanager/tm_ctags.c</a>:</p>
<pre style='color:#555'>> @@ -120,7 +120,15 @@ static gboolean init_tag(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag
tag->name = g_strdup(tag_entry->name);
tag->type = type;
tag->local = tag_entry->isFileScope;
- tag->pointerOrder = 0; /* backward compatibility (use var_type instead) */
+ tag->flags = tm_tag_flag_none_t;
+ if (isTagExtraBitMarked(tag_entry, XTAG_ANONYMOUS))
+ {
+ tag->flags |= tm_tag_flag_anon_t;
+ /* Temporarily store kind letter for anon name generation to flags
+ * as we don't have any other place where to store it. This will
+ * be cleared later in rename_anon_tags() */
+ tag->flags |= (guint)kind_letter << 16;
</pre>
<p dir="auto">Can't you just add a member to <code>TMTag</code> instead of this workaround?</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772284487">src/tagmanager/tm_ctags.c</a>:</p>
<pre style='color:#555'>> + /* set the name of the original anon tag and pretend
+ * it wasn't a anon tag */
+ tag->name = g_strdup(typedef_tag->name);
+ tag->flags &= ~tm_tag_flag_anon_t;
+ new_name = tag->name;
+ /* the typedef tag will be removed */
+ g_ptr_array_add(removed_typedefs, GUINT_TO_POINTER(j));
+ }
+ }
+ }
+
+ /* there's no typedef name for the anon tag so let's generate one */
+ if (!new_name)
+ {
+ gchar buf[50];
+ guint anon_counter = GPOINTER_TO_UINT(g_hash_table_lookup(anon_counter_table, kind_name));
</pre>
<p dir="auto">I think a hash_table is a overweight here. Since <code>kind</code> is in the range 0...255 a simple array would sufficie</p>
<p dir="auto">guint anon_counter = anon_counter_table[kind]++;</p>
<p dir="auto">Alternatively, you could use a hash table that uses <code>kind</code> as the key and not a more expensive hash of <code>kind_name</code></p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772285943">src/tagmanager/tm_ctags.c</a>:</p>
<pre style='color:#555'>> + if (nested_scope_len <= scope_len)
+ break;
+
+ pos = strstr(nested_tag->scope, orig_name);
+ /* We found the parent name in the nested tag scope - replace it
+ * with the new name. Note: anonymous tag names generated by
+ * ctags are unique enough that we don't have to check for
+ * scope separators here. */
+ if (pos)
+ {
+ gchar *str = g_malloc(nested_scope_len + 50);
+ guint prefix_len = pos - nested_tag->scope;
+
+ strncpy(str, nested_tag->scope, prefix_len);
+ strcpy(str + prefix_len, new_name);
+ strcpy(str + prefix_len + new_name_len, pos + orig_name_len);
</pre>
<p dir="auto">Such string building could use <code>asprintf()</code> (not requesting a change here; also I see that GLIB only provides <code>g_vasprintf()</code> but not <code>g_asprintf()</code>, very strange)</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772286732">tests/ctags/enum.f90.tags</a>:</p>
<pre style='color:#555'>> @@ -11,6 +9,8 @@ Named5
Named6�2�Constants�0
Named7�2�Constants�0
a�4�Enum#1�0
+anon_enum_1�2�Constants�1
+anon_enum_2�2�Constants�1
</pre>
<p dir="auto">I wonder if the new naming is really appreciated by Fortran users? I guess we'll see ;-)</p>
<hr>
<p>In <a href="https://github.com/geany/geany/pull/3059#discussion_r772288460">src/tagmanager/tm_parser.c</a>:</p>
<pre style='color:#555'>> +{
+ guint i;
+ char dummy;
+
+ if (lang == TM_PARSER_C || lang == TM_PARSER_CPP)
+ {
+ return sscanf(name, "anon_%*[a-z]_%u%c", &i, &dummy) == 1 ||
+ sscanf(name, "__anon%u%c", &i, &dummy) == 1;
+ }
+ else if (lang == TM_PARSER_FORTRAN || lang == TM_PARSER_F77)
+ {
+ return sscanf(name, "Structure#%u%c", &i, &dummy) == 1 ||
+ sscanf(name, "Interface#%u%c", &i, &dummy) == 1 ||
+ sscanf(name, "Enum#%u%c", &i, &dummy) == 1;
+ }
+ return FALSE;
</pre>
<p dir="auto">The unit test files for java script indicate that the naming is changed. Why is that not handled here (I know it also wasn't in the old <code>tm_tag_is_anon()</code> but I would like to understand why)?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/3059#pullrequestreview-836269780">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJZFHIX4LSAVU5GM6PDUR4HQZANCNFSM5KMJEVBQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAIOWJ7YELQFTCZVVSJF3IDUR4HQZA5CNFSM5KMJEVB2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOGHMHNVA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><geany/geany/pull/3059/review/836269780</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/pull/3059#pullrequestreview-836269780",
"url": "https://github.com/geany/geany/pull/3059#pullrequestreview-836269780",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>