Revision: 1412 http://svn.sourceforge.net/geany/?rev=1412&view=rev Author: ntrel Date: 2007-03-21 09:27:25 -0700 (Wed, 21 Mar 2007)
Log Message: ----------- Separate alternative PHP/LaTeX global tags parser into tm_tag_init_from_file_alt() (for easier diff with Anjuta).
Modified Paths: -------------- trunk/ChangeLog trunk/tagmanager/include/tm_tag.h trunk/tagmanager/tm_tag.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-03-21 13:26:16 UTC (rev 1411) +++ trunk/ChangeLog 2007-03-21 16:27:25 UTC (rev 1412) @@ -5,9 +5,12 @@ * src/main.c, src/symbols.c, src/symbols.h, tagmanager/tm_workspace.c: Add option --generate-tags (-g) to generate a global tags file from a list of source files. Currently this is only likely to work - correctly for C-like source files. Run 'geany -g' for syntax info. + correctly for C source files. Run 'geany -g' for syntax info. Remove short option for hidden option --generate-data-files. Update tm_workspace_create_global_tags() from Anjuta 1.2.4a. + * tagmanager/tm_tag.c, tagmanager/include/tm_tag.h + Separate alternative PHP/LaTeX global tags parser into + tm_tag_init_from_file_alt() (for easier diff with Anjuta).
2007-03-20 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/tagmanager/include/tm_tag.h =================================================================== --- trunk/tagmanager/include/tm_tag.h 2007-03-21 13:26:16 UTC (rev 1411) +++ trunk/tagmanager/include/tm_tag.h 2007-03-21 16:27:25 UTC (rev 1412) @@ -176,13 +176,17 @@ \param tag The TMTag structure to populate \param file The TMSourceFile struct (assigned to the file member) \param fp FILE pointer from where the tag line is read - \param mode langType - if set to greater than 0, the alternative parser is used and mode represents - the langType to use for the tags \return TRUE on success, FALSE on FAILURE */ -gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp, gint mode); +gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp);
/*! + Same as tm_tag_init_from_file(), but using an alternative parser for PHP and + LaTeX global tags files. +*/ +gboolean tm_tag_init_from_file_alt(TMTag *tag, TMSourceFile *file, FILE *fp); + +/*! Creates a new tag structure from a tagEntryInfo pointer and a TMSOurceFile pointer and returns a pointer to it. \param file - Pointer to the TMSourceFile structure containing the tag @@ -192,7 +196,8 @@ TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry);
/*! - Same as tm_tag_new() except that the tag attributes are read from file + Same as tm_tag_new() except that the tag attributes are read from file. + \param mode langType to use for the tag. */ TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode);
Modified: trunk/tagmanager/tm_tag.c =================================================================== --- trunk/tagmanager/tm_tag.c 2007-03-21 13:26:16 UTC (rev 1411) +++ trunk/tagmanager/tm_tag.c 2007-03-21 16:27:25 UTC (rev 1412) @@ -202,7 +202,7 @@ return tag; }
-gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp, gint mode) +gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp) { guchar buf[BUFSIZ]; guchar *start, *end; @@ -211,99 +211,110 @@
if ((NULL == fgets((gchar*)buf, BUFSIZ, fp)) || ('\0' == *buf)) return FALSE; - if (mode == 0 || mode == 1) + for (start = end = buf, status = TRUE; (TRUE == status); start = end, ++ end) { - for (start = end = buf, status = TRUE; (TRUE == status); start = end, ++ end) + while ((*end < TA_NAME) && (*end != '\0') && (*end != '\n')) + ++ end; + if (('\0' == *end) || ('\n' == *end)) + status = FALSE; + changed_char = *end; + *end = '\0'; + if (NULL == tag->name) { - while ((*end < TA_NAME) && (*end != '\0') && (*end != '\n')) - ++ end; - if (('\0' == *end) || ('\n' == *end)) - status = FALSE; - changed_char = *end; - *end = '\0'; - if (NULL == tag->name) - { - if (!isprint(*start)) - return FALSE; - else - tag->name = g_strdup((gchar*)start); - } + if (!isprint(*start)) + return FALSE; else + tag->name = g_strdup((gchar*)start); + } + else + { + switch (*start) { - switch (*start) - { - case TA_LINE: - tag->atts.entry.line = atol((gchar*)start + 1); - break; - case TA_LOCAL: - tag->atts.entry.local = atoi((gchar*)start + 1); - break; - case TA_TYPE: - tag->type = (TMTagType) atoi((gchar*)start + 1); - break; - case TA_ARGLIST: - tag->atts.entry.arglist = g_strdup((gchar*)start + 1); - break; - case TA_SCOPE: - tag->atts.entry.scope = g_strdup((gchar*)start + 1); - break; - case TA_POINTER: - tag->atts.entry.pointerOrder = atoi((gchar*)start + 1); - break; - case TA_VARTYPE: - tag->atts.entry.var_type = g_strdup((gchar*)start + 1); - break; - case TA_INHERITS: - tag->atts.entry.inheritance = g_strdup((gchar*)start + 1); - break; - case TA_TIME: - if (tm_tag_file_t != tag->type) - { - g_warning("Got time attribute for non-file tag %s", tag->name); - return FALSE; - } - else - tag->atts.file.timestamp = atol((gchar*)start + 1); - break; - case TA_LANG: - if (tm_tag_file_t != tag->type) - { - g_warning("Got lang attribute for non-file tag %s", tag->name); - return FALSE; - } - else - tag->atts.file.lang = atoi((gchar*)start + 1); - break; - case TA_INACTIVE: - if (tm_tag_file_t != tag->type) - { - g_warning("Got inactive attribute for non-file tag %s", tag->name); - return FALSE; - } - else - tag->atts.file.inactive = (gboolean) atoi((gchar*)start + 1); - break; - case TA_ACCESS: - tag->atts.entry.access = *(start + 1); - break; - case TA_IMPL: - tag->atts.entry.impl = *(start + 1); - break; - default: - #ifdef TM_DEBUG - g_warning("Unknown attribute %s", start + 1); - #endif - break; - } - tag->atts.file.lang = mode; + case TA_LINE: + tag->atts.entry.line = atol((gchar*)start + 1); + break; + case TA_LOCAL: + tag->atts.entry.local = atoi((gchar*)start + 1); + break; + case TA_TYPE: + tag->type = (TMTagType) atoi((gchar*)start + 1); + break; + case TA_ARGLIST: + tag->atts.entry.arglist = g_strdup((gchar*)start + 1); + break; + case TA_SCOPE: + tag->atts.entry.scope = g_strdup((gchar*)start + 1); + break; + case TA_POINTER: + tag->atts.entry.pointerOrder = atoi((gchar*)start + 1); + break; + case TA_VARTYPE: + tag->atts.entry.var_type = g_strdup((gchar*)start + 1); + break; + case TA_INHERITS: + tag->atts.entry.inheritance = g_strdup((gchar*)start + 1); + break; + case TA_TIME: + if (tm_tag_file_t != tag->type) + { + g_warning("Got time attribute for non-file tag %s", tag->name); + return FALSE; + } + else + tag->atts.file.timestamp = atol((gchar*)start + 1); + break; + case TA_LANG: + if (tm_tag_file_t != tag->type) + { + g_warning("Got lang attribute for non-file tag %s", tag->name); + return FALSE; + } + else + tag->atts.file.lang = atoi((gchar*)start + 1); + break; + case TA_INACTIVE: + if (tm_tag_file_t != tag->type) + { + g_warning("Got inactive attribute for non-file tag %s", tag->name); + return FALSE; + } + else + tag->atts.file.inactive = (gboolean) atoi((gchar*)start + 1); + break; + case TA_ACCESS: + tag->atts.entry.access = *(start + 1); + break; + case TA_IMPL: + tag->atts.entry.impl = *(start + 1); + break; + default: +#ifdef TM_DEBUG + g_warning("Unknown attribute %s", start + 1); +#endif + break; } - *end = changed_char; } + *end = changed_char; } - else + if (NULL == tag->name) + return FALSE; + if (tm_tag_file_t != tag->type) + tag->atts.entry.file = file; + return TRUE; +} + +// alternative parser for PHP and LaTeX global tags files with the following format +// tagname|return value|arglist|description\n +gboolean tm_tag_init_from_file_alt(TMTag *tag, TMSourceFile *file, FILE *fp) +{ + guchar buf[BUFSIZ]; + guchar *start, *end; + gboolean status; + //guchar changed_char = TA_NAME; + + if ((NULL == fgets((gchar*)buf, BUFSIZ, fp)) || ('\0' == *buf)) + return FALSE; { - // alternative parser for PHP and LaTeX global tags files with the following format - // tagname|return value|arglist|description\n gchar **fields; guint field_len; for (start = end = buf, status = TRUE; (TRUE == status); start = end, ++ end) @@ -324,7 +335,6 @@ else tag->name = NULL; if (field_len >= 2 && fields[1] != NULL) tag->atts.entry.var_type = g_strdup(fields[1]); if (field_len >= 3 && fields[2] != NULL) tag->atts.entry.arglist = g_strdup(fields[2]); - tag->atts.file.lang = mode; tag->type = tm_tag_prototype_t; g_strfreev(fields); } @@ -340,13 +350,21 @@ TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode) { TMTag *tag; + gboolean result;
TAG_NEW(tag); - if (FALSE == tm_tag_init_from_file(tag, file, fp, mode)) + + if (mode == 0 || mode == 1) + result = tm_tag_init_from_file(tag, file, fp); + else + result = tm_tag_init_from_file_alt(tag, file, fp); + + if (! result) { TAG_FREE(tag); return NULL; } + tag->atts.file.lang = mode; return tag; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.