Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Tue, 11 Oct 2016 21:40:20 UTC Commit: b6ca38712f944c87ecdcafbbf3dba55a6279405b https://github.com/geany/geany/commit/b6ca38712f944c87ecdcafbbf3dba55a627940...
Log Message: ----------- parse: other small syncs
Modified Paths: -------------- ctags/main/parse.c ctags/main/parse.h src/tagmanager/tm_ctags_wrappers.c
Modified: ctags/main/parse.c 102 lines changed, 67 insertions(+), 35 deletions(-) =================================================================== @@ -33,12 +33,19 @@ #endif #include "xtag.h"
+/* + * FUNCTION PROTOTYPES + */ + +static void installKeywordTable (const langType language); +static void installTagRegexTable (const langType language); + /* * DATA DEFINITIONS */ static parserDefinitionFunc* BuiltInParsers[] = { PARSER_LIST }; parserDefinition** LanguageTable = NULL; -unsigned int LanguageCount = 0; +static unsigned int LanguageCount = 0; static kindOption defaultFileKind = { .enabled = false, .letter = KIND_FILE_DEFAULT, @@ -50,16 +57,24 @@ static kindOption defaultFileKind = { * FUNCTION DEFINITIONS */
-extern void makeSimpleTag (const vString* const name, - kindOption* const kinds, const int kind) +extern unsigned int countParsers (void) +{ + return LanguageCount; +} + +extern int makeSimpleTag ( + const vString* const name, kindOption* const kinds, const int kind) { + int r = CORK_NIL; + if (name != NULL && vStringLength (name) > 0) { tagEntryInfo e; - initTagEntry (&e, vStringValue (name), &(kinds [kind])); + initTagEntry (&e, vStringValue (name), & kinds [kind]);
- makeTagEntry (&e); + r = makeTagEntry (&e); } + return r; }
@@ -86,9 +101,15 @@ extern parserDefinition* parserNewFull (const char* name, char fileKind)
extern const char *getLanguageName (const langType language) { - /*Assert (0 <= language && language < (int) LanguageCount);*/ - if (language < 0) return NULL; - return LanguageTable [language]->name; + const char* result; + if (language == LANG_IGNORE) + result = "unknown"; + else + { + Assert (0 <= language && language < (int) LanguageCount); + result = LanguageTable [language]->name; + } + return result; }
extern kindOption* getLanguageFileKind (const langType language) @@ -173,9 +194,9 @@ static vString* determineInterpreter (const char* const cmd) do { vStringClear (interpreter); - for ( ; isspace (*p) ; ++p) + for ( ; isspace ((int) *p) ; ++p) ; /* no-op */ - for ( ; *p != '\0' && ! isspace (*p) ; ++p) + for ( ; *p != '\0' && ! isspace ((int) *p) ; ++p) vStringPut (interpreter, (int) *p); } while (strcmp (vStringValue (interpreter), "env") == 0); return interpreter; @@ -227,33 +248,42 @@ extern void printLanguageMap (const langType language)
extern void installLanguageMapDefault (const langType language) { - Assert (language >= 0); - if (LanguageTable [language]->currentPatterns != NULL) - stringListDelete (LanguageTable [language]->currentPatterns); - if (LanguageTable [language]->currentExtensions != NULL) - stringListDelete (LanguageTable [language]->currentExtensions); - - if (LanguageTable [language]->patterns == NULL) - LanguageTable [language]->currentPatterns = stringListNew (); + parserDefinition* lang; + Assert (0 <= language && language < (int) LanguageCount); + lang = LanguageTable [language]; + if (lang->currentPatterns != NULL) + stringListDelete (lang->currentPatterns); + if (lang->currentExtensions != NULL) + stringListDelete (lang->currentExtensions); + + if (lang->patterns == NULL) + lang->currentPatterns = stringListNew (); else { - LanguageTable [language]->currentPatterns = - stringListNewFromArgv (LanguageTable [language]->patterns); + lang->currentPatterns = + stringListNewFromArgv (lang->patterns); } - if (LanguageTable [language]->extensions == NULL) - LanguageTable [language]->currentExtensions = stringListNew (); + if (lang->extensions == NULL) + lang->currentExtensions = stringListNew (); else { - LanguageTable [language]->currentExtensions = - stringListNewFromArgv (LanguageTable [language]->extensions); + lang->currentExtensions = + stringListNewFromArgv (lang->extensions); + } + BEGIN_VERBOSE(vfp); + { + printLanguageMap (language); + putc ('\n', vfp); } + END_VERBOSE(); }
extern void installLanguageMapDefaults (void) { unsigned int i; for (i = 0 ; i < LanguageCount ; ++i) { + verbose (" %s: ", getLanguageName (i)); installLanguageMapDefault (i); } } @@ -268,10 +298,12 @@ extern void clearLanguageMap (const langType language) extern void addLanguagePatternMap (const langType language, const char* ptrn) { vString* const str = vStringNewInit (ptrn); + parserDefinition* lang; Assert (0 <= language && language < (int) LanguageCount); - if (LanguageTable [language]->currentPatterns == NULL) - LanguageTable [language]->currentPatterns = stringListNew (); - stringListAdd (LanguageTable [language]->currentPatterns, str); + lang = LanguageTable [language]; + if (lang->currentPatterns == NULL) + lang->currentPatterns = stringListNew (); + stringListAdd (lang->currentPatterns, str); }
extern void addLanguageExtensionMap (const langType language, @@ -314,7 +346,7 @@ extern void initializeParser (langType lang) if (lang == LANG_AUTO) { int i; - for (i = 0; i < LanguageCount; i++) + for (i = 0; i < countParsers(); i++) initializeParserOne (i); } else @@ -333,9 +365,10 @@ extern void initializeParsing (void) unsigned int builtInCount; unsigned int i;
- builtInCount = sizeof (BuiltInParsers) / sizeof (BuiltInParsers [0]); + builtInCount = ARRAY_SIZE (BuiltInParsers); LanguageTable = xMalloc (builtInCount, parserDefinition*);
+ verbose ("Installing parsers: "); for (i = 0 ; i < builtInCount ; ++i) { parserDefinition* const def = (*BuiltInParsers [i]) (); @@ -357,6 +390,7 @@ extern void initializeParsing (void) accepted = true; if (accepted) { + verbose ("%s%s", i > 0 ? ", " : "", def->name); def->id = LanguageCount++; LanguageTable [def->id] = def; } @@ -387,7 +421,7 @@ extern bool processAliasOption ( return false; }
-extern void installTagRegexTable (const langType language) +static void installTagRegexTable (const langType language) { parserDefinition* lang; unsigned int i; @@ -396,32 +430,30 @@ extern void installTagRegexTable (const langType language) lang = LanguageTable [language];
- if ((lang->tagRegexTable != NULL) && (lang->tagRegexInstalled == false)) + if (lang->tagRegexTable != NULL) { for (i = 0; i < lang->tagRegexCount; ++i) addTagRegex (language, lang->tagRegexTable [i].regex, lang->tagRegexTable [i].name, lang->tagRegexTable [i].kinds, lang->tagRegexTable [i].flags); - lang->tagRegexInstalled = true; } }
-extern void installKeywordTable (const langType language) +static void installKeywordTable (const langType language) { parserDefinition* lang; unsigned int i;
Assert (0 <= language && language < (int) LanguageCount); lang = LanguageTable [language];
- if ((lang->keywordTable != NULL) && (lang->keywordInstalled == false)) + if (lang->keywordTable != NULL) { for (i = 0; i < lang->keywordCount; ++i) addKeyword (lang->keywordTable [i].name, language, lang->keywordTable [i].id); - lang->keywordInstalled = true; } }
Modified: ctags/main/parse.h 13 lines changed, 4 insertions(+), 9 deletions(-) =================================================================== @@ -83,9 +83,6 @@ struct sParserDefinition { unsigned int initialized:1; /* initialize() is called or not */ subparser *subparsers; /* The parsers on this list must be initialized when this parser is initialized. */ - - unsigned int tagRegexInstalled:1; /* tagRegexTable is installed or not. */ - unsigned int keywordInstalled:1; /* keywordTable is installed or not. */ };
typedef parserDefinition* (parserDefinitionFunc) (void); @@ -112,14 +109,14 @@ typedef enum { * return a structure allocated using parserNew(). This structure must, * at minimum, set the `parser' field. */ -extern parserDefinitionFunc PARSER_LIST; extern parserDefinition** LanguageTable; -extern unsigned int LanguageCount; +extern parserDefinitionFunc PARSER_LIST; /* Legacy interface */ extern bool includingDefineTags (void);
+ /* Language processing and parsing */ -extern void makeSimpleTag (const vString* const name, kindOption* const kinds, const int kind); +extern int makeSimpleTag (const vString* const name, kindOption* const kinds, const int kind);
extern parserDefinition* parserNew (const char* name); extern parserDefinition* parserNewFull (const char* name, char fileKind); @@ -137,17 +134,15 @@ extern void enableLanguages (const bool state); extern void enableLanguage (const langType language, const bool state); extern void initializeParsing (void); extern void initializeParser (langType language); +extern unsigned int countParsers (void); extern void processLanguageDefineOption (const char *const option, const char *const parameter); extern bool processKindOption (const char *const option, const char *const parameter);
-extern void installKeywordTable (const langType language); - /* Regex interface */ extern void findRegexTags (void); extern bool matchRegex (const vString* const line, const langType language); extern bool processRegexOption (const char *const option, const char *const parameter); extern void addLanguageRegex (const langType language, const char* const regex); -extern void installTagRegexTable (const langType language); extern void addTagRegex (const langType language, const char* const regex, const char* const name, const char* const kinds, const char* const flags); extern void addCallbackRegex (const langType language, const char* const regex, const char* flags, const regexCallback callback); extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED);
Modified: src/tagmanager/tm_ctags_wrappers.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -153,5 +153,5 @@ gboolean tm_ctags_is_using_regex_parser(TMParserType lang)
guint tm_ctags_get_lang_count(void) { - return LanguageCount; + return countParsers(); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).