SF.net SVN: geany: [1462] trunk/tagmanager/tm_workspace.c
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Apr 18 15:20:56 UTC 2007
Revision: 1462
http://svn.sourceforge.net/geany/?rev=1462&view=rev
Author: ntrel
Date: 2007-04-18 08:20:56 -0700 (Wed, 18 Apr 2007)
Log Message:
-----------
Keep tag names with different argument lists when loading global
tags.
Prevent segfault if using tm_workspace_find_scoped() with global
tags.
Modified Paths:
--------------
trunk/tagmanager/tm_workspace.c
Modified: trunk/tagmanager/tm_workspace.c
===================================================================
--- trunk/tagmanager/tm_workspace.c 2007-04-18 15:20:11 UTC (rev 1461)
+++ trunk/tagmanager/tm_workspace.c 2007-04-18 15:20:56 UTC (rev 1462)
@@ -134,11 +134,16 @@
return FALSE;
}
+static TMTagAttrType global_tags_sort_attrs[] =
+{
+ tm_tag_attr_name_t, tm_tag_attr_scope_t,
+ tm_tag_attr_type_t, tm_tag_attr_arglist_t, 0
+};
+
gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode)
{
FILE *fp;
TMTag *tag;
- TMTagAttrType attr[] = { tm_tag_attr_name_t, 0 };
if (NULL == (fp = fopen(tags_file, "r")))
return FALSE;
@@ -152,7 +157,7 @@
// resort the whole array, because tm_tags_find expects a sorted array and it is not sorted
// when global.tags, php.tags and latex.tags are loaded at the same time
- tm_tags_sort(theWorkspace->global_tags, attr, TRUE);
+ tm_tags_sort(theWorkspace->global_tags, global_tags_sort_attrs, TRUE);
return TRUE;
}
@@ -205,10 +210,6 @@
char *temp_file = g_strdup_printf("%s/%d_%ld_1.cpp", P_tmpdir, getpid(), time(NULL));
char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", P_tmpdir, getpid(), time(NULL));
#endif
- TMTagAttrType sort_attrs[] = {
- tm_tag_attr_name_t, tm_tag_attr_scope_t,
- tm_tag_attr_type_t, tm_tag_attr_arglist_t, 0
- };
if (NULL == (fp = fopen(temp_file, "w")))
return FALSE;
@@ -336,7 +337,7 @@
tm_source_file_free(source_file);
return FALSE;
}
- if (FALSE == tm_tags_sort(tags_array, sort_attrs, TRUE))
+ if (FALSE == tm_tags_sort(tags_array, global_tags_sort_attrs, TRUE))
{
tm_source_file_free(source_file);
return FALSE;
@@ -557,6 +558,20 @@
return tags;
}
+static gboolean match_langs(gint lang, const TMTag *tag)
+{
+ if (tag->atts.entry.file)
+ { // workspace tag
+ if (lang == tag->atts.entry.file->lang)
+ return TRUE;
+ }
+ else
+ { // global tag
+ if (lang == tag->atts.file.lang)
+ return TRUE;
+ }
+ return FALSE;
+}
/* scope can be NULL.
* lang can be -1 */
@@ -579,8 +594,8 @@
if (! scope || (match[tagIter]->atts.entry.scope &&
0 == strcmp(match[tagIter]->atts.entry.scope, scope)))
{
- if ((lang == -1 || lang == match[tagIter]->atts.entry.file->lang) &&
- type & match[tagIter]->type)
+ if (type & match[tagIter]->type)
+ if (lang == -1 || match_langs(lang, match[tagIter]))
{
g_ptr_array_add (dst, match[tagIter]);
if (first)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list