r5123 | ntrel | 2010-08-10 17:12:24 +0100 (Tue, 10 Aug 2010) | 4 lines
[geany-mirror.git] / tagmanager / abc.c
blobb854f9bd02dca14c06db51f12cfed0f1b62aea32
1 /*
2 * Copyright (c) 2009, Eric Forgeot
4 * Based on work by Jon Strait
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * This module contains functions for generating tags for Abc files.
13 * INCLUDE FILES
15 #include "general.h" /* must always come first */
17 #include <ctype.h>
18 #include <string.h>
20 #include "parse.h"
21 #include "read.h"
22 #include "vstring.h"
25 * DATA DEFINITIONS
28 static kindOption AbcKinds[] = {
29 { TRUE, 'm', "member", "sections" },
30 { TRUE, 's', "struct", "header1"}
34 * FUNCTION DEFINITIONS
37 /* checks if str is all the same character */
38 /*static boolean issame(const char *str)
40 char first = *str;
42 while (*(++str))
44 if (*str && *str != first)
45 return FALSE;
47 return TRUE;
48 }*/
51 static void makeAbcTag (const vString* const name, boolean name_before)
53 tagEntryInfo e;
54 initTagEntry (&e, vStringValue(name));
56 if (name_before)
57 e.lineNumber--; /* we want the line before the underline chars */
58 e.kindName = AbcKinds[0].name;
59 e.kind = AbcKinds[0].letter;
61 makeTagEntry(&e);
64 /*static void makeAbcTag2 (const vString* const name, boolean name_before)
66 tagEntryInfo e;
67 initTagEntry (&e, vStringValue(name));
69 if (name_before)
70 e.lineNumber--;
71 e.kindName = "struct";
72 e.kind = 's';
74 makeTagEntry(&e);
75 }*/
77 static void findAbcTags (void)
79 vString *name = vStringNew();
80 const unsigned char *line;
82 while ((line = fileReadLine()) != NULL)
84 /*int name_len = vStringLength(name);*/
86 /* underlines must be the same length or more */
87 /*if (name_len > 0 && (line[0] == '=' || line[0] == '-') && issame((const char*) line))
89 makeAbcTag(name, TRUE);
90 }*/
91 /* if (line[1] == '%') {
92 vStringClear(name);
93 vStringCatS(name, (const char *) line);
94 vStringTerminate(name);
95 makeAbcTag(name, FALSE);
96 }*/
97 if (line[0] == 'T') {
98 /*vStringClear(name);*/
99 vStringCatS(name, " / ");
100 vStringCatS(name, (const char *) line);
101 vStringTerminate(name);
102 makeAbcTag(name, FALSE);
104 else {
105 vStringClear (name);
106 if (! isspace(*line))
107 vStringCatS(name, (const char*) line);
108 vStringTerminate(name);
111 vStringDelete (name);
114 extern parserDefinition* AbcParser (void)
116 static const char *const patterns [] = { "*.abc", NULL };
117 static const char *const extensions [] = { "abc", NULL };
118 parserDefinition* const def = parserNew ("Abc");
120 def->kinds = AbcKinds;
121 def->kindCount = KIND_COUNT (AbcKinds);
122 def->patterns = patterns;
123 def->extensions = extensions;
124 def->parser = findAbcTags;
125 return def;