Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sat, 18 Oct 2014 19:40:10 UTC Commit: 48725e4188764b71b97f4e68291f89a222d91a5d https://github.com/geany/geany/commit/48725e4188764b71b97f4e68291f89a222d91a...
Log Message: ----------- Get rid of the file struct in TMTag, preparation for the union removal
The union on TMTag is very confusing and rather dangerous. The fields file/timestamp and line/lang overlap. Some implicit assumptions are made in the code - timestamp is never set so when file is NULL, the file struct should be used to get the lang member. Rather avoid using unions and move the lang member to the entry struct together with the other attributes.
Modified Paths: -------------- src/symbols.c tagmanager/src/tm_tag.c tagmanager/src/tm_tag.h tagmanager/src/tm_workspace.c
Modified: src/symbols.c 9 lines changed, 5 insertions(+), 4 deletions(-) =================================================================== @@ -266,9 +266,10 @@ GString *symbols_find_tags_as_string(GPtrArray *tags_array, guint tag_types, gin for (j = 0; j < typedefs->len; ++j) { tag = TM_TAG(typedefs->pdata[j]); - /* tag->atts.file.lang contains (for some reason) the line of the tag if - * tag->atts.entry.file is not NULL */ - tag_lang = (tag->atts.entry.file) ? tag->atts.entry.file->lang : tag->atts.file.lang; + /* tag->atts.file.lang contains the line of the tag if tag->atts.entry.file + * is not NULL (geany document); otherwise it's a global tag with lang + * information in tag->atts.entry.lang */ + tag_lang = (tag->atts.entry.file) ? tag->atts.entry.file->lang : tag->atts.entry.lang;
/* the check for tag_lang == lang is necessary to avoid wrong type colouring of * e.g. PHP classes in C++ files @@ -351,7 +352,7 @@ GString *symbols_get_macro_list(gint lang) { tag = TM_TAG(tags->pdata[i]); tag_lang = (tag->atts.entry.file) ? - tag->atts.entry.file->lang : tag->atts.file.lang; + tag->atts.entry.file->lang : tag->atts.entry.lang;
if (tag_lang == lang) g_ptr_array_add(ftags, (gpointer) tags->pdata[i]);
Modified: tagmanager/src/tm_tag.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -583,7 +583,7 @@ TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileForma TAG_FREE(tag); return NULL; } - tag->atts.file.lang = mode; + tag->atts.entry.lang = mode; return tag; }
Modified: tagmanager/src/tm_tag.h 11 lines changed, 4 insertions(+), 7 deletions(-) =================================================================== @@ -129,7 +129,7 @@ typedef struct _TMTag /** These are *real* tag attributes */ struct { - TMSourceFile *file; /**< File in which the tag occurs */ + TMSourceFile *file; /**< File in which the tag occurs; NULL for global tags */ gulong line; /**< Line number of the tag */ gboolean local; /**< Is the tag of local scope */ guint pointerOrder; @@ -139,13 +139,10 @@ typedef struct _TMTag char *var_type; /**< Variable type (maps to struct for typedefs) */ char access; /**< Access type (public/protected/private/etc.) */ char impl; /**< Implementation (e.g. virtual) */ + + langType lang; /**< Programming language of the file - set only for + global tags when the file member is NULL */ } entry; - /** These are pseudo tag attributes representing a file */ - struct - { - time_t timestamp; /**< Time of parsing of the file */ - langType lang; /**< Programming language of the file */ - } file; } atts; gint refcount; /**< the reference count of the tag */ } TMTag;
Modified: tagmanager/src/tm_workspace.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -639,7 +639,7 @@ const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *at int tags_lang_alt = 0; /* tag->atts.file.lang contains the language and * tags->atts.entry.file is NULL */ - tags_lang = (*matches[1])->atts.file.lang; + tags_lang = (*matches[1])->atts.entry.lang; /* tags_lang_alt is used to load C global tags only once for C and C++ * lang = 1 is C++, lang = 0 is C * if we have lang 0, than accept also lang 1 for C++ */ @@ -682,7 +682,7 @@ static gboolean match_langs(gint lang, const TMTag *tag) } else { /* global tag */ - if (lang == tag->atts.file.lang) + if (lang == tag->atts.entry.lang) return TRUE; } return FALSE;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).