Remove duplicate code from Txt2Tags parser.

Remove the title control characters ('=') when parsing titles.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4825 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-04-17 14:34:31 +00:00
parent 85cded2a87
commit ccc57dbf7e
2 changed files with 47 additions and 25 deletions

View File

@ -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,

View File

@ -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 @@ static kindOption Txt2tagsKinds[] = {
* FUNCTION DEFINITIONS
*/
static void makeTxt2tagsTag (const vString* const name, boolean name_before)
static void parse_title (vString* const name, const char control_char)
{
char *text = vStringValue(name);
char *p = text;
int offset_start = 0;
boolean in_or_after_title = FALSE;
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 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--; /* we want the line before the underline chars */
e.kindName = "variable";
e.kind = 'v';
makeTagEntry(&e);
}
static void makeTxt2tagsTag2 (const vString* const name, boolean name_before)
{
tagEntryInfo e;
initTagEntry (&e, vStringValue(name));
if (name_before)
e.lineNumber--;
e.kindName = "struct";
e.kind = 's';
e.kindName = kind->name;
e.kind = kind->letter;
makeTagEntry(&e);
}
@ -78,19 +96,16 @@ static void findTxt2tagsTags (void)
/*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);