Revision: 4825 http://geany.svn.sourceforge.net/geany/?rev=4825&view=rev Author: eht16 Date: 2010-04-17 14:34:31 +0000 (Sat, 17 Apr 2010)
Log Message: ----------- Remove duplicate code from Txt2Tags parser. Remove the title control characters ('=') when parsing titles.
Modified Paths: -------------- trunk/ChangeLog trunk/tagmanager/txt2tags.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-17 14:34:19 UTC (rev 4824) +++ trunk/ChangeLog 2010-04-17 14:34:31 UTC (rev 4825) @@ -1,3 +1,10 @@ +2010-04-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * tagmanager/txt2tags.c: + Remove duplicate code from Txt2Tags parser. + Remove the title control characters ('=') when parsing titles. + + 2010-04-11 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* geany.glade, doc/geany.txt, plugins/geanyfunctions.h,
Modified: trunk/tagmanager/txt2tags.c =================================================================== --- trunk/tagmanager/txt2tags.c 2010-04-17 14:34:19 UTC (rev 4824) +++ trunk/tagmanager/txt2tags.c 2010-04-17 14:34:31 UTC (rev 4825) @@ -25,8 +25,12 @@ * DATA DEFINITIONS */
+typedef enum { + K_SECTION = 0, K_HEADER +} Txt2tagsKind; + static kindOption Txt2tagsKinds[] = { - { TRUE, 'v', "members", "sections" }, + { TRUE, 'm', "member", "sections" }, { TRUE, 's', "struct", "header1"} };
@@ -34,28 +38,42 @@ * FUNCTION DEFINITIONS */
-static void makeTxt2tagsTag (const vString* const name, boolean name_before) +static void parse_title (vString* const name, const char control_char) { - tagEntryInfo e; - initTagEntry (&e, vStringValue(name)); + char *text = vStringValue(name); + char *p = text; + int offset_start = 0; + boolean in_or_after_title = FALSE;
- if (name_before) - e.lineNumber--; /* we want the line before the underline chars */ - e.kindName = "variable"; - e.kind = 'v'; - - makeTagEntry(&e); + while (p != NULL && *p != '\0') + { + if (*p == control_char) + { + if (in_or_after_title) + break; + else + offset_start++; + } + else + in_or_after_title = TRUE; + p++; + } + *p = '\0'; + vStringCopyS(name, text + offset_start); + vStringStripLeading(name); + vStringStripTrailing(name); }
-static void makeTxt2tagsTag2 (const vString* const name, boolean name_before) +static void makeTxt2tagsTag (const vString* const name, boolean name_before, Txt2tagsKind type) { tagEntryInfo e; + kindOption *kind = &Txt2tagsKinds[type]; initTagEntry (&e, vStringValue(name));
if (name_before) - e.lineNumber--; - e.kindName = "struct"; - e.kind = 's'; + e.lineNumber--; /* we want the line before the underline chars */ + e.kindName = kind->name; + e.kind = kind->letter;
makeTagEntry(&e); } @@ -78,19 +96,16 @@ /*vStringClear(name);*/ vStringCatS(name, (const char *) line); vStringTerminate(name); - makeTxt2tagsTag(name, FALSE); + parse_title(name, line[0]); + makeTxt2tagsTag(name, FALSE, K_SECTION); } - /*else if (line[0] == "=") { - vStringClear(name); - vStringCatS(name, (const char *) line); - vStringTerminate(name); - makeTxt2tagsTag(name, FALSE); - }*/ + /* TODO what exactly should this match? + * K_HEADER ('struct') isn't matched in src/symbols.c */ else if (strcmp((char*)line, "°") == 0) { /*vStringClear(name);*/ vStringCatS(name, (const char *) line); vStringTerminate(name); - makeTxt2tagsTag2(name, FALSE); + makeTxt2tagsTag(name, FALSE, K_HEADER); } else { vStringClear (name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.