lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
List overview
Commits
December 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
commits@lists.geany.org
1 participants
130 discussions
Start a n
N
ew thread
[geany/geany] 380a66: lregex: some simple syncs
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Wed, 12 Oct 2016 11:26:45 UTC Commit: 380a662a25011b53d3746d31c975208eb91b16b4
https://github.com/geany/geany/commit/380a662a25011b53d3746d31c975208eb91b1…
Log Message: ----------- lregex: some simple syncs Modified Paths: -------------- ctags/main/lregex.c Modified: ctags/main/lregex.c 57 lines changed, 34 insertions(+), 23 deletions(-) =================================================================== @@ -199,18 +199,16 @@ static bool parseTagRegex ( *name = scanSeparators (regexp); if (*regexp == '\0') - printf ("regex: empty regexp\n"); + error (WARNING, "empty regexp"); else if (**name != separator) - printf ("regex: %s: incomplete regexp\n", regexp); + error (WARNING, "%s: incomplete regexp", regexp); else { char* const third = scanSeparators (*name); - if (**name == '\0') - printf ("regex: %s: regexp missing name pattern\n", regexp); - if ((*name) [strlen (*name) - 1] == '\\') - printf ("regex: error in name pattern: \"%s\"\n", *name); + if (**name != '\0' && (*name) [strlen (*name) - 1] == '\\') + error (WARNING, "error in name pattern: \"%s\"", *name); if (*third != separator) - printf ("regex: %s: regexp missing final separator\n", regexp); + error (WARNING, "%s: regexp missing final separator", regexp); else { char* const fourth = scanSeparators (third); @@ -326,20 +324,20 @@ static void parseKinds ( *description = NULL; if (kinds == NULL || kinds [0] == '\0') { - *kind = 'r'; - *kindName = eStrdup ("regex"); + *kind = KIND_REGEX_DEFAULT; + *kindName = eStrdup (KIND_REGEX_DEFAULT_LONG); } else if (kinds [0] != '\0') { const char* k = kinds; if (k [0] != ',' && (k [1] == ',' || k [1] == '\0')) *kind = *k++; else - *kind = 'r'; + *kind = KIND_REGEX_DEFAULT; if (*k == ',') ++k; if (k [0] == '\0') - *kindName = eStrdup ("regex"); + *kindName = eStrdup (KIND_REGEX_DEFAULT_LONG); else { const char *const comma = strchr (k, ','); @@ -377,13 +375,13 @@ static void processLanguageRegex (const langType language, else if (parameter [0] != '@') addLanguageRegex (language, parameter); else if (! doesFileExist (parameter + 1)) - printf ("regex: cannot open regex file\n"); + error (WARNING, "cannot open regex file"); else { const char* regexfile = parameter + 1; MIO* const mio = mio_new_file (regexfile, "r"); if (mio == NULL) - printf ("regex: %s\n", regexfile); + error (WARNING | PERROR, "%s", regexfile); else { vString* const regex = vStringNew (); @@ -468,7 +466,7 @@ static void matchCallbackPattern ( } static bool matchRegexPattern (const vString* const line, - const regexPattern* const patbuf) + const regexPattern* const patbuf) { bool result = false; GMatchInfo *minfo; @@ -541,11 +539,10 @@ extern void addTagRegex ( } } -extern void addCallbackRegex ( - const langType language CTAGS_ATTR_UNUSED, - const char* const regex CTAGS_ATTR_UNUSED, - const char* const flags CTAGS_ATTR_UNUSED, - const regexCallback callback CTAGS_ATTR_UNUSED) +extern void addCallbackRegex (const langType language CTAGS_ATTR_UNUSED, + const char* const regex CTAGS_ATTR_UNUSED, + const char* const flags CTAGS_ATTR_UNUSED, + const regexCallback callback CTAGS_ATTR_UNUSED) { Assert (regex != NULL); if (regexAvailable) @@ -576,7 +573,7 @@ extern void addLanguageRegex ( */ extern bool processRegexOption (const char *const option, - const char *const parameter CTAGS_ATTR_UNUSED) + const char *const parameter CTAGS_ATTR_UNUSED) { bool handled = false; const char* const dash = strchr (option, '-'); @@ -648,9 +645,23 @@ extern void freeRegexResources (void) SetUpper = -1; } -/* Check for broken regcomp() on Cygwin */ +/* Return true if available. */ extern bool checkRegex (void) { - /* not needed now we have GRegex */ - return true; +/* not needed with GRegex */ +#if 0 /*defined (CHECK_REGCOMP)*/ + { + /* Check for broken regcomp() on Cygwin */ + regex_t patbuf; + int errcode; + if (regcomp (&patbuf, "/hello/", 0) != 0) + error (WARNING, "Disabling broken regex"); + else + regexAvailable = true; + } +#else + /* We are using bundled regex engine. */ + regexAvailable = true; +#endif + return regexAvailable; } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 8c4c57: lregex: remove unused functions
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Wed, 12 Oct 2016 11:26:45 UTC Commit: 8c4c570eb6ec4e8017386162e87f2b7e3ef3e5a0
https://github.com/geany/geany/commit/8c4c570eb6ec4e8017386162e87f2b7e3ef3e…
Log Message: ----------- lregex: remove unused functions So it's easier to sync them by simply getting the uctags versions. Modified Paths: -------------- ctags/main/lregex.c ctags/main/parse.h Modified: ctags/main/lregex.c 69 lines changed, 1 insertions(+), 68 deletions(-) =================================================================== @@ -356,17 +356,6 @@ static void parseKinds ( } } -static void printRegexKind (const regexPattern *pat, unsigned int i, bool indent) -{ - const kindOption *const kind = &pat [i].u.tag.kind; - const char *const indentation = indent ? " " : ""; - Assert (pat [i].type == PTRN_TAG); - printf ("%s%c %s %s\n", indentation, - kind->letter != '\0' ? kind->letter : '?', - kind->description != NULL ? kind->description : kind->name, - kind->enabled ? "" : " [off]"); -} - static void processLanguageRegex (const langType language, const char* const parameter) { @@ -575,63 +564,7 @@ extern void addLanguageRegex ( extern bool processRegexOption (const char *const option, const char *const parameter CTAGS_ATTR_UNUSED) { - bool handled = false; - const char* const dash = strchr (option, '-'); - if (dash != NULL && strncmp (option, "regex", dash - option) == 0) - { - langType language; - language = getNamedLanguage (dash + 1, 0); - if (language == LANG_IGNORE) - printf ("regex: unknown language \"%s\" in --%s option\n", (dash + 1), option); - else - processLanguageRegex (language, parameter); - handled = true; - } - return handled; -} - -extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED) -{ - if (language <= SetUpper && Sets [language].count > 0) - { - patternSet* const set = Sets + language; - unsigned int i; - for (i = 0 ; i < set->count ; ++i) - if (set->patterns [i].type == PTRN_TAG) - set->patterns [i].u.tag.kind.enabled = false; - } -} - -extern bool enableRegexKind ( - const langType language CTAGS_ATTR_UNUSED, - const int kind CTAGS_ATTR_UNUSED, const bool mode CTAGS_ATTR_UNUSED) -{ - bool result = false; - if (language <= SetUpper && Sets [language].count > 0) - { - patternSet* const set = Sets + language; - unsigned int i; - for (i = 0 ; i < set->count ; ++i) - if (set->patterns [i].type == PTRN_TAG && - set->patterns [i].u.tag.kind.letter == kind) - { - set->patterns [i].u.tag.kind.enabled = mode; - result = true; - } - } - return result; -} - -extern void printRegexKinds (const langType language CTAGS_ATTR_UNUSED, bool indent CTAGS_ATTR_UNUSED) -{ - if (language <= SetUpper && Sets [language].count > 0) - { - patternSet* const set = Sets + language; - unsigned int i; - for (i = 0 ; i < set->count ; ++i) - if (set->patterns [i].type == PTRN_TAG) - printRegexKind (set->patterns, i, indent); - } + return false; } extern void freeRegexResources (void) Modified: ctags/main/parse.h 3 lines changed, 0 insertions(+), 3 deletions(-) =================================================================== @@ -145,9 +145,6 @@ extern bool processRegexOption (const char *const option, const char *const para extern void addLanguageRegex (const langType language, const char* const regex); 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); -extern bool enableRegexKind (const langType language, const int kind, const bool mode); -extern void printRegexKinds (const langType language, bool indent); extern void freeRegexResources (void); extern bool checkRegex (void); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] b6ca38: parse: other small syncs
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 21:40:20 UTC Commit: b6ca38712f944c87ecdcafbbf3dba55a6279405b
https://github.com/geany/geany/commit/b6ca38712f944c87ecdcafbbf3dba55a62794…
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
).
1
0
0
0
[geany/geany] 59d637: lregex: sync includes
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Wed, 12 Oct 2016 09:48:57 UTC Commit: 59d6375b0924e188a6b4afcbc667252a5d162acd
https://github.com/geany/geany/commit/59d6375b0924e188a6b4afcbc667252a5d162…
Log Message: ----------- lregex: sync includes Modified Paths: -------------- ctags/main/lregex.c Modified: ctags/main/lregex.c 27 lines changed, 9 insertions(+), 18 deletions(-) =================================================================== @@ -17,22 +17,22 @@ #include "general.h" /* must always come first */ #include <string.h> -#include <glib.h> -#ifdef HAVE_REGCOMP -# include <ctype.h> -# include <stddef.h> -# ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> /* declare off_t (not known to regex.h on FreeBSD) */ -# endif +#include <ctype.h> +#include <stddef.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> /* declare off_t (not known to regex.h on FreeBSD) */ #endif +#include <glib.h> #include "debug.h" -#include "mio.h" #include "entry.h" +#include "flags.h" +#include "htable.h" +#include "kind.h" +#include "options.h" #include "parse.h" #include "read.h" -#include "kind.h" #include "routines.h" /* @@ -42,16 +42,12 @@ /* Back-references \0 through \9 */ #define BACK_REFERENCE_COUNT 10 -#if defined (HAVE_REGCOMP) && !defined (REGCOMP_BROKEN) -# define POSIX_REGEX -#endif #define REGEX_NAME "Regex" /* * DATA DECLARATIONS */ -#if defined (POSIX_REGEX) enum pType { PTRN_TAG, PTRN_CALLBACK }; @@ -69,7 +65,6 @@ typedef struct { } u; } regexPattern; -#endif typedef struct { regexPattern *patterns; @@ -295,7 +290,6 @@ static void addCompiledCallbackPattern ( ptrn->u.callback.function = callback; } -#if defined (POSIX_REGEX) static GRegex* compileRegex (const char* const regexp, const char* const flags) { @@ -322,7 +316,6 @@ static GRegex* compileRegex (const char* const regexp, const char* const flags) return result; } -#endif static void parseKinds ( const char* const kinds, char* const kind, char** const kindName, @@ -406,7 +399,6 @@ static void processLanguageRegex (const langType language, * Regex pattern matching */ -#if defined (POSIX_REGEX) static vString* substitute ( const char* const in, const char* out, @@ -497,7 +489,6 @@ static bool matchRegexPattern (const vString* const line, return result; } -#endif /* PUBLIC INTERFACE */ -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 051b78: parse: some simple syncs and include syncs
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 21:04:13 UTC Commit: 051b780745db947e5e63cf25b0b02f6ecba96eb2
https://github.com/geany/geany/commit/051b780745db947e5e63cf25b0b02f6ecba96…
Log Message: ----------- parse: some simple syncs and include syncs Addition of dependency.c/h and promise.c/h. Also moved tagEntryFunction definitions to geany.c/h. Modified Paths: -------------- ctags/Makefile.am ctags/main/dependency.c ctags/main/dependency.h ctags/main/entry.c ctags/main/geany.c ctags/main/geany.h ctags/main/parse.c ctags/main/parse.h ctags/main/promise.c ctags/main/promise.h ctags/parsers/abc.c ctags/parsers/asciidoc.c ctags/parsers/conf.c ctags/parsers/markdown.c ctags/parsers/rest.c ctags/parsers/txt2tags.c src/tagmanager/tm_ctags_wrappers.c Modified: ctags/Makefile.am 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -58,6 +58,8 @@ libctags_la_SOURCES = \ main/ctags.h \ main/debug.h \ main/debug.c \ + main/dependency.h \ + main/dependency.c \ main/e_msoft.h \ main/entry.c \ main/entry.h \ @@ -101,6 +103,8 @@ libctags_la_SOURCES = \ main/parsers.h \ main/pcoproc.c \ main/pcoproc.h \ + main/promise.c \ + main/promise.h \ main/ptag.c \ main/ptag.h \ main/ptrarray.c \ Modified: ctags/main/dependency.c 102 lines changed, 102 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2016, Red Hat, Inc. + * Copyright (c) 2016, Masatake YAMATO + * + * Author: Masatake YAMATO <yamato(a)redhat.com> + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + */ + +#include "general.h" /* must always come first */ + +#include "dependency.h" +#include "parse.h" + +#include <string.h> + + +static void linkKinds (kindOption *masterKind, kindOption *slaveKind) +{ + kindOption *tail; + + slaveKind->master = masterKind; + + tail = slaveKind; + while (tail->slave) + { + tail->enabled = masterKind->enabled; + tail = tail->slave; + } + + tail->slave = masterKind->slave; + masterKind->slave = slaveKind; +} + +static void linkKindDependency (parserDefinition *const masterParser, + parserDefinition *const slaveParser) +{ + unsigned int k_slave, k_master; + kindOption *kind_slave, *kind_master; + + for (k_slave = 0; k_slave < slaveParser->kindCount; k_slave++) + { + if (slaveParser->kinds [k_slave].syncWith == LANG_AUTO) + { + kind_slave = slaveParser->kinds + k_slave; + for (k_master = 0; k_master < masterParser->kindCount; k_master++) + { + kind_master = masterParser->kinds + k_master; + if ((kind_slave->letter == kind_master->letter) + && (strcmp (kind_slave->name, kind_master->name) == 0)) + { + linkKinds (kind_master, kind_slave); + kind_slave->syncWith = masterParser->id; + kind_master->syncWith = masterParser->id; + break; + } + } + } + } +} + +extern void linkDependencyAtInitializeParsing (depType dtype, + parserDefinition *const masterParser, + parserDefinition *const slaveParser) +{ + if (dtype == DEPTYPE_KIND_OWNER) + linkKindDependency (masterParser, slaveParser); + else if (dtype == DEPTYPE_SUBPARSER) + { + subparser *s = xMalloc (1, subparser); + + s->id = slaveParser->id; + s->next = masterParser->subparsers; + masterParser->subparsers = s; + } +} + +extern void initializeSubparsers (const parserDefinition *parser) +{ + subparser *sp; + + for (sp = parser->subparsers; sp; sp = sp->next) + initializeParser (sp->id); +} + +extern void finalizeSubparsers (parserDefinition *parser) +{ + subparser *sp; + subparser *tmp; + + for (sp = parser->subparsers; sp;) + { + tmp = sp; + sp = sp->next; + tmp->next = NULL; + eFree (tmp); + } + parser->subparsers = NULL; +} Modified: ctags/main/dependency.h 45 lines changed, 45 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2016, Red Hat, Inc. + * Copyright (c) 2016, Masatake YAMATO + * + * Author: Masatake YAMATO <yamato(a)redhat.com> + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + */ +#ifndef CTAGS_MAIN_DEPENDENCY_H +#define CTAGS_MAIN_DEPENDENCY_H + +#include "general.h" + +#include "types.h" + + +typedef enum eDepType { + DEPTYPE_KIND_OWNER, + DEPTYPE_SUBPARSER, + COUNT_DEPTYPES, +} depType; + +typedef struct sParserDependency { + depType type; + const char *upperParser; + void *data; +} parserDependency; + +extern void linkDependencyAtInitializeParsing (depType dtype, + parserDefinition *const masterParser, + parserDefinition *const slaveParser); + +typedef struct sSubparser subparser; +struct sSubparser { + langType id; + subparser *next; +}; + +extern void initializeSubparsers (const parserDefinition *parser); +extern void finalizeSubparsers (parserDefinition *parser); + +#endif /* CTAGS_MAIN_DEPENDENCY_H */ Modified: ctags/main/entry.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -11,6 +11,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ +#include "geany.h" #include <string.h> #include <ctype.h> /* to define isspace () */ @@ -1092,8 +1093,7 @@ static void writeTagEntry (const tagEntryInfo *const tag) buildFqTagCache (tag); */ /* length = writer->writeEntry (TagFile.mio, tag, writerData); */ - if (TagEntryFunction != NULL) - length = TagEntryFunction(tag, TagEntryUserData); + length = callTagEntryFunction (tag); ++TagFile.numTags.added; rememberMaxLengths (strlen (tag->name), (size_t) length); Modified: ctags/main/geany.c 17 lines changed, 17 insertions(+), 0 deletions(-) =================================================================== @@ -15,6 +15,9 @@ #include <string.h> #include <glib.h> +static tagEntryFunction TagEntryFunction = NULL; +static void *TagEntryUserData = NULL; + /* tags_ignore is a NULL-terminated array of strings, read from ~/.config/geany/ignore.tags. * This file contains a space or newline separated list of symbols which should be ignored * by the C/C++ parser, see -I command line option of ctags for details. */ @@ -78,3 +81,17 @@ extern bool isIgnoreToken (const char *const name, } return result; } + +extern void setTagEntryFunction(tagEntryFunction entry_function, void *user_data) +{ + TagEntryFunction = entry_function; + TagEntryUserData = user_data; +} + +extern int callTagEntryFunction(const tagEntryInfo *const tag) +{ + int length = 0; + if (TagEntryFunction != NULL) + length = TagEntryFunction(tag, TagEntryUserData); + return length; +} Modified: ctags/main/geany.h 8 lines changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -9,6 +9,14 @@ #ifndef CTAGS_GEANY_H #define CTAGS_GEANY_H +#include "types.h" + +typedef int (*tagEntryFunction) (const tagEntryInfo *const tag, void *user_data); + + extern bool isIgnoreToken (const char *const name, bool *const pIgnoreParens, const char **const replacement); +extern void setTagEntryFunction(tagEntryFunction entry_function, void *user_data); +extern int callTagEntryFunction(const tagEntryInfo *const tag); + #endif /* CTAGS_GEANY_H */ Modified: ctags/main/parse.c 63 lines changed, 21 insertions(+), 42 deletions(-) =================================================================== @@ -16,16 +16,21 @@ #include <string.h> #include "debug.h" -#include "mio.h" #include "entry.h" +#include "flags.h" #include "keyword.h" #include "main.h" #define OPTION_WRITE #include "options.h" #include "parsers.h" +#include "promise.h" +#include "ptag.h" #include "read.h" -#include "vstring.h" #include "routines.h" +#include "vstring.h" +#ifdef HAVE_ICONV +# include "mbcs.h" +#endif #include "xtag.h" /* @@ -41,20 +46,10 @@ static kindOption defaultFileKind = { .description = KIND_FILE_DEFAULT_LONG, }; -tagEntryFunction TagEntryFunction = NULL; -void *TagEntryUserData = NULL; - /* * FUNCTION DEFINITIONS */ -extern void setTagEntryFunction(tagEntryFunction entry_function, void *user_data) -{ - TagEntryFunction = entry_function; - TagEntryUserData = user_data; -} - - extern void makeSimpleTag (const vString* const name, kindOption* const kinds, const int kind) { @@ -287,19 +282,19 @@ extern void addLanguageExtensionMap (const langType language, stringListAdd (LanguageTable [language]->currentExtensions, str); } +extern void enableLanguage (const langType language, const bool state) +{ + Assert (0 <= language && language < (int) LanguageCount); + LanguageTable [language]->enabled = state; +} + extern void enableLanguages (const bool state) { unsigned int i; for (i = 0 ; i < LanguageCount ; ++i) LanguageTable [i]->enabled = state; } -extern void enableLanguage (const langType language, const bool state) -{ - Assert (0 <= language && language < (int) LanguageCount); - LanguageTable [language]->enabled = state; -} - static void initializeParserOne (langType lang) { parserDefinition *const parser = LanguageTable [lang]; @@ -371,22 +366,6 @@ extern void initializeParsing (void) initializeParsers (); } -extern void freeParserResources (void) -{ - unsigned int i; - for (i = 0 ; i < LanguageCount ; ++i) - { - freeList (&LanguageTable [i]->currentPatterns); - freeList (&LanguageTable [i]->currentExtensions); - eFree (LanguageTable [i]->name); - LanguageTable [i]->name = NULL; - eFree (LanguageTable [i]); - } - eFree (LanguageTable); - LanguageTable = NULL; - LanguageCount = 0; -} - /* * Option parsing */ @@ -396,8 +375,14 @@ extern void processLanguageDefineOption (const char *const option, { } -extern bool processKindOption (const char *const option, - const char *const parameter) +extern bool processKindOption ( + const char *const option, const char *const parameter) +{ + return false; +} + +extern bool processAliasOption ( + const char *const option, const char *const parameter) { return false; } @@ -440,9 +425,3 @@ extern void installKeywordTable (const langType language) lang->keywordInstalled = true; } } - -extern bool processAliasOption ( - const char *const option, const char *const parameter) -{ - return false; -} Modified: ctags/main/parse.h 28 lines changed, 13 insertions(+), 15 deletions(-) =================================================================== @@ -13,10 +13,13 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ +#include "types.h" +#include "dependency.h" +#include "field.h" +#include "kind.h" #include "parsers.h" /* contains list of parsers */ #include "strlist.h" -#include "entry.h" /* * MACROS @@ -32,7 +35,6 @@ typedef void (*createRegexTag) (const vString* const name); typedef void (*simpleParser) (void); typedef bool (*rescanParser) (const unsigned int passCount); typedef void (*parserInitialize) (langType language); -typedef int (*tagEntryFunction) (const tagEntryInfo *const tag, void *user_data); typedef enum { METHOD_NOT_CRAFTED = 1 << 0, @@ -44,10 +46,10 @@ typedef enum { typedef struct { const char *const regex; - const char *const name; - const char *const kinds; + const char* const name; + const char* const kinds; const char *const flags; - bool *disabled; + bool *disabled; } tagRegexTable; typedef struct { @@ -66,7 +68,7 @@ struct sParserDefinition { parserInitialize initialize; /* initialization routine, if needed */ simpleParser parser; /* simple parser (common case) */ rescanParser parser2; /* rescanning parser (unusual case) */ - unsigned int method; /* See PARSE__... definitions above */ + unsigned int method; /* See METHOD_ definitions above */ /* used internally */ unsigned int id; /* id assigned to language */ @@ -79,14 +81,17 @@ struct sParserDefinition { unsigned int keywordCount; 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); typedef struct { - int start; /* character index in line where match starts */ + size_t start; /* character index in line where match starts */ size_t length; /* length of match */ } regexMatch; @@ -98,6 +103,7 @@ typedef enum { LMAP_ALL = LMAP_PATTERN | LMAP_EXTENSION, } langmapType; + /* * FUNCTION PROTOTYPES */ @@ -131,7 +137,6 @@ 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 void freeParserResources (void); extern void processLanguageDefineOption (const char *const option, const char *const parameter); extern bool processKindOption (const char *const option, const char *const parameter); @@ -147,15 +152,8 @@ extern void addTagRegex (const langType language, const char* const regex, const 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); extern bool enableRegexKind (const langType language, const int kind, const bool mode); -extern void printRegexKindOptions (const langType language); extern void printRegexKinds (const langType language, bool indent); extern void freeRegexResources (void); extern bool checkRegex (void); - -/* Extra stuff for Tag Manager */ -extern tagEntryFunction TagEntryFunction; -extern void *TagEntryUserData; -extern void setTagEntryFunction(tagEntryFunction entry_function, void *user_data); - #endif /* CTAGS_MAIN_PARSE_H */ Modified: ctags/main/promise.c 102 lines changed, 102 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2016, Red Hat, Inc. + * Copyright (c) 2016, Masatake YAMATO + * + * Author: Masatake YAMATO <yamato(a)redhat.com> + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + */ + +#include "general.h" +#include "promise.h" +#include "debug.h" +#include "xtag.h" + + +struct promise { + langType lang; + unsigned long startLine; + int startCharOffset; + unsigned long endLine; + int endCharOffset; + unsigned long sourceLineOffset; +}; + +static struct promise *promises; +static int promise_count; +static int promise_allocated; + +int makePromise (const char *parser, + unsigned long startLine, int startCharOffset, + unsigned long endLine, int endCharOffset, + unsigned long sourceLineOffset) +{ + struct promise *p; + int r; + langType lang; + + if (!isXtagEnabled (XTAG_TAGS_GENERATED_BY_SUB_PARSERS)) + return -1; + + lang = getNamedLanguage (parser, 0); + if (lang == LANG_IGNORE) + return -1; + + if ( promise_count == promise_allocated) + { + size_t c = promise_allocated? (promise_allocated * 2): 8; + promises = xRealloc (promises, c, struct promise); + promise_allocated = c; + } + + p = promises + promise_count; + + p->lang = lang; + p->startLine = startLine; + p->startCharOffset = startCharOffset; + p->endLine = endLine; + p->endCharOffset = endCharOffset; + p->sourceLineOffset = sourceLineOffset; + + r = promise_count; + promise_count++; + return r; +} + +void breakPromisesAfter (int promise) +{ + Assert (promise_count >= promise); + + promise_count = promise; +} + +bool forcePromises (void) +{ + int i; + bool tagFileResized = false; + + for (i = 0; i < promise_count; ++i) + { + struct promise *p = promises + i; +/* tagFileResized = runParserInNarrowedInputStream (p->lang, + p->startLine, + p->startCharOffset, + p->endLine, + p->endCharOffset, + p->sourceLineOffset) + ? true + : tagFileResized;*/ + } + + promise_count = 0; + return tagFileResized; +} + + +int getLastPromise (void) +{ + return promise_count - 1; +} Modified: ctags/main/promise.h 27 lines changed, 27 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2016, Red Hat, Inc. + * Copyright (c) 2016, Masatake YAMATO + * + * Author: Masatake YAMATO <yamato(a)redhat.com> + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + */ +#ifndef CTAGS_MAIN_PROMISE_H +#define CTAGS_MAIN_PROMISE_H + +#include "general.h" +#include "mio.h" +#include "parse.h" + +int makePromise (const char *parser, + unsigned long startLine, int startCharOffset, + unsigned long endLine, int endCharOffset, + unsigned long sourceLineOffset); +bool forcePromises (void); +void breakPromisesAfter (int promise); +int getLastPromise (void); + +#endif /* CTAGS_MAIN_PROMISE_H */ Modified: ctags/parsers/abc.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -21,6 +21,7 @@ #include "read.h" #include "vstring.h" #include "routines.h" +#include "entry.h" /* * DATA DEFINITIONS Modified: ctags/parsers/asciidoc.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -22,6 +22,7 @@ #include "vstring.h" #include "nestlevel.h" #include "routines.h" +#include "entry.h" /* * DATA DEFINITIONS Modified: ctags/parsers/conf.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -19,6 +19,7 @@ #include "read.h" #include "vstring.h" #include "routines.h" +#include "entry.h" /* * DATA DEFINITIONS Modified: ctags/parsers/markdown.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -20,6 +20,7 @@ #include "read.h" #include "vstring.h" #include "routines.h" +#include "entry.h" /* * DATA DEFINITIONS Modified: ctags/parsers/rest.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -21,6 +21,7 @@ #include "vstring.h" #include "nestlevel.h" #include "routines.h" +#include "entry.h" /* * DATA DEFINITIONS Modified: ctags/parsers/txt2tags.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -23,6 +23,7 @@ #include "nestlevel.h" #include "vstring.h" #include "routines.h" +#include "entry.h" /* as any character may happen in an input, use something highly unlikely */ Modified: src/tagmanager/tm_ctags_wrappers.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -24,7 +24,7 @@ #include "entry.h" #include "parse.h" #include "read.h" - +#include "geany.h" typedef struct { TMCtagsNewTagCallback tag_callback; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 8436b9: read: add the remaining stuff from uctags
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 15:15:34 UTC Commit: 8436b975ed941ebb9757080066c3af9645313bd8
https://github.com/geany/geany/commit/8436b975ed941ebb9757080066c3af9645313…
Log Message: ----------- read: add the remaining stuff from uctags Modified Paths: -------------- ctags/main/read.c ctags/main/read.h Modified: ctags/main/read.c 279 lines changed, 278 insertions(+), 1 deletions(-) =================================================================== @@ -121,6 +121,7 @@ static void langStackClear(langStack *langStack); * DATA DEFINITIONS */ static inputFile File; /* static read through functions */ +static inputFile BackupFile; /* File is copied here when a nested parser is pushed */ static MIOPos StartOfLine; /* holds deferred position of start of line */ /* @@ -242,6 +243,11 @@ extern void freeInputFileResources (void) freeInputFileInfo (&File.source); } +extern const unsigned char *getInputFileData (size_t *size) +{ + return mio_memory_get_data (File.mio, size); +} + /* * inputLineFposMap related functions */ @@ -542,6 +548,7 @@ extern bool openInputFile (const char *const fileName, const langType language, { const char *const openMode = "rb"; bool opened = false; + bool memStreamRequired; /* If another file was already open, then close it. */ @@ -551,7 +558,27 @@ extern bool openInputFile (const char *const fileName, const langType language, File.mio = NULL; } - File.mio = mio? mio_ref (mio): getMio (fileName, openMode, true); + /* File position is used as key for checking the availability of + pattern cache in entry.h. If an input file is changed, the + key is meaningless. So notifying the changing here. */ + invalidatePatternCache(); + + if (File.sourceTagPathHolder == NULL) + File.sourceTagPathHolder = stringListNew (); + stringListClear (File.sourceTagPathHolder); + + memStreamRequired = false; /*doesParserRequireMemoryStream (language);*/ + + if (mio) + { + size_t tmp; + if (memStreamRequired && (!mio_memory_get_data (mio, &tmp))) + mio = NULL; + else + mio_rewind (mio); + } + + File.mio = mio? mio_ref (mio): getMio (fileName, openMode, memStreamRequired); if (File.mio == NULL) error (WARNING | PERROR, "cannot open \"%s\"", fileName); @@ -598,6 +625,24 @@ extern bool bufferOpen (const char *const fileName, const langType language, return opened; } +extern void resetInputFile (const langType language) +{ + Assert (File.mio); + + mio_rewind (File.mio); + mio_getpos (File.mio, &StartOfLine); + mio_getpos (File.mio, &File.filePosition); + File.currentLine = NULL; + + if (File.line != NULL) + vStringClear (File.line); + + resetLangOnStack (& (File.input.langInfo), language); + File.input.lineNumber = File.input.lineNumberOrigin; + setLangToType (& (File.source.langInfo), language); + File.source.lineNumber = File.source.lineNumberOrigin; +} + extern void closeInputFile (void) { if (File.mio != NULL) @@ -618,11 +663,20 @@ extern void closeInputFile (void) } } +extern void *getInputFileUserData(void) +{ + return mio_get_user_data (File.mio); +} + /* Action to take for each encountered input newline. */ static void fileNewline (void) { File.filePosition = StartOfLine; + + if (BackupFile.mio == NULL) + appendLineFposMap (&File.lineFposMap, File.filePosition); + File.input.lineNumber++; File.source.lineNumber++; DebugStatement ( if (Option.breakLine == File.input.lineNumber) lineBreak (); ) @@ -832,6 +886,11 @@ extern char *readLineRaw (vString *const vLine, MIO *const mio) } } } while (reReadLine); + +#ifdef HAVE_ICONV + if (isConverting ()) + convertString (vLine); +#endif } return result; } @@ -857,6 +916,224 @@ extern char *readLineFromBypass ( return result; } +/* If a xcmd parser is used, ctags cannot know the location for a tag. + * In the other hand, etags output and cross reference output require the + * line after the location. + * + * readLineFromBypassSlow retrieves the line for (lineNumber and pattern of a tag). + */ + +extern char *readLineFromBypassSlow (vString *const vLine, + unsigned long lineNumber, + const char *pattern, + long *const pSeekValue) +{ + char *result = NULL; + + + MIOPos originalPosition; + char *line; + size_t len; + long pos; + + regex_t patbuf; + char lastc; + + + /* + * Compile the pattern + */ + { + char *pat; + int errcode; + char errmsg[256]; + + pat = eStrdup (pattern); + pat[strlen(pat) - 1] = '\0'; + errcode = regcomp (&patbuf, pat + 1, 0); + eFree (pat); + + if (errcode != 0) + { + regerror (errcode, &patbuf, errmsg, 256); + error (WARNING, "regcomp %s in readLineFromBypassSlow: %s", pattern, errmsg); + regfree (&patbuf); + return NULL; + } + } + + /* + * Get the line for lineNumber + */ + { + unsigned long n; + + mio_getpos (File.mio, &originalPosition); + mio_rewind (File.mio); + line = NULL; + pos = 0; + for (n = 0; n < lineNumber; n++) + { + pos = mio_tell (File.mio); + line = readLineRaw (vLine, File.mio); + if (line == NULL) + break; + } + if (line == NULL) + goto out; + else + len = strlen(line); + + if (len == 0) + goto out; + + lastc = line[len - 1]; + if (lastc == '\n') + line[len - 1] = '\0'; + } + + /* + * Match + */ + { + regmatch_t pmatch; + int after_newline = 0; + if (regexec (&patbuf, line, 1, &pmatch, 0) == 0) + { + line[len - 1] = lastc; + result = line + pmatch.rm_so; + if (pSeekValue) + { + after_newline = ((lineNumber == 1)? 0: 1); + *pSeekValue = pos + after_newline + pmatch.rm_so; + } + } + } + +out: + regfree (&patbuf); + mio_setpos (File.mio, &originalPosition); + return result; +} + +/* + * Similar to readLineRaw but this doesn't use fgetpos/fsetpos. + * Useful for reading from pipe. + */ +char* readLineRawWithNoSeek (vString* const vline, FILE *const pp) +{ + int c; + bool nlcr; + char *result = NULL; + + vStringClear (vline); + nlcr = false; + + while (1) + { + c = fgetc (pp); + + if (c == EOF) + { + if (! feof (pp)) + error (FATAL | PERROR, "Failure on attempt to read file"); + else + break; + } + + result = vStringValue (vline); + + if (c == '\n' || c == '\r') + nlcr = true; + else if (nlcr) + { + ungetc (c, pp); + break; + } + else + vStringPut (vline, c); + } + + return result; +} + +extern void pushNarrowedInputStream (const langType language, + unsigned long startLine, int startCharOffset, + unsigned long endLine, int endCharOffset, + unsigned long sourceLineOffset) +{ + long p, q; + MIOPos original; + MIOPos tmp; + MIO *subio; + + original = getInputFilePosition (); + + tmp = getInputFilePositionForLine (startLine); + mio_setpos (File.mio, &tmp); + mio_seek (File.mio, startCharOffset, SEEK_CUR); + p = mio_tell (File.mio); + + tmp = getInputFilePositionForLine (endLine); + mio_setpos (File.mio, &tmp); + mio_seek (File.mio, endCharOffset, SEEK_CUR); + q = mio_tell (File.mio); + + mio_setpos (File.mio, &original); + + subio = mio_new_mio (File.mio, p, q - p); + + + BackupFile = File; + + File.mio = subio; + File.nestedInputStreamInfo.startLine = startLine; + File.nestedInputStreamInfo.startCharOffset = startCharOffset; + File.nestedInputStreamInfo.endLine = endLine; + File.nestedInputStreamInfo.endCharOffset = endCharOffset; + + File.input.lineNumberOrigin = ((startLine == 0)? 0: startLine - 1); + File.source.lineNumberOrigin = ((sourceLineOffset == 0)? 0: sourceLineOffset - 1); +} + +extern unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber) +{ + unsigned int info; + + if (File.nestedInputStreamInfo.startLine == 0 + && File.nestedInputStreamInfo.startCharOffset == 0 + && File.nestedInputStreamInfo.endLine == 0 + && File.nestedInputStreamInfo.endCharOffset == 0) + /* Not in a nested input stream */ + return 0; + + info = 0; + if (File.nestedInputStreamInfo.startLine == lineNumber + && File.nestedInputStreamInfo.startCharOffset != 0) + info |= BOUNDARY_START; + if (File.nestedInputStreamInfo.endLine == lineNumber + && File.nestedInputStreamInfo.endCharOffset != 0) + info |= BOUNDARY_END; + + return info; +} +extern void popNarrowedInputStream (void) +{ + mio_free (File.mio); + File = BackupFile; + memset (&BackupFile, 0, sizeof (BackupFile)); +} + +extern void pushLanguage (const langType language) +{ + pushLangOnStack (&File.input.langInfo, language); +} + +extern langType popLanguage (void) +{ + return popLangOnStack (&File.input.langInfo); +} + static void langStackInit (langStack *langStack) { langStack->count = 0; Modified: ctags/main/read.h 23 lines changed, 23 insertions(+), 0 deletions(-) =================================================================== @@ -70,6 +70,8 @@ extern kindOption *getInputLanguageFileKind (void); extern bool doesInputLanguageRequestAutomaticFQTag (void); extern void freeInputFileResources (void); +extern const unsigned char *getInputFileData (size_t *size); + /* Stream opend by getMio can be passed to openInputFile as the 3rd argument. If the 3rd argument is NULL, openInputFile calls getMio internally. The 3rd argument is introduced for reusing mio object @@ -79,21 +81,42 @@ extern bool bufferOpen (const char *const fileName, const langType language, unsigned char *buffer, size_t buffer_size); extern MIO *getMio (const char *const fileName, const char *const openMode, bool memStreamRequired); +extern void resetInputFile (const langType language); + extern void closeInputFile (void); +extern void *getInputFileUserData(void); extern int getcFromInputFile (void); extern int getNthPrevCFromInputFile (unsigned int nth, int def); extern int skipToCharacterInInputFile (int c); extern void ungetcToInputFile (int c); extern const unsigned char *readLineFromInputFile (void); +enum nestedInputBoundaryFlag { + BOUNDARY_START = 1UL << 0, + BOUNDARY_END = 1UL << 1, +}; +extern unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber); + extern const char *getSourceFileTagPath (void); extern const char *getSourceLanguageName (void); extern unsigned long getSourceLineNumber (void); /* Raw: reading from given a parameter, fp */ extern char *readLineRaw (vString *const vLine, MIO *const mio); +extern char* readLineRawWithNoSeek (vString *const vline, FILE *const pp); /* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */ extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue); +extern char *readLineFromBypassSlow (vString *const vLine, unsigned long lineNumber, + const char *pattern, long *const pSeekValue); + +extern void pushNarrowedInputStream (const langType language, + unsigned long startLine, int startCharOffset, + unsigned long endLine, int endCharOffset, + unsigned long sourceLineOffset); +extern void popNarrowedInputStream (void); + +extern void pushLanguage(const langType language); +extern langType popLanguage (void); #endif /* CTAGS_MAIN_READ_H */ -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 2f83d0: parse: remove things unused by Geany for simpler merge
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 15:30:06 UTC Commit: 2f83d0d164a94ab5073eb6e804fca05c17b7bb4d
https://github.com/geany/geany/commit/2f83d0d164a94ab5073eb6e804fca05c17b7b…
Log Message: ----------- parse: remove things unused by Geany for simpler merge Modified Paths: -------------- ctags/main/parse.c ctags/main/parse.h Modified: ctags/main/parse.c 237 lines changed, 2 insertions(+), 235 deletions(-) =================================================================== @@ -228,23 +228,6 @@ extern langType getFileLanguage (const char *const fileName) extern void printLanguageMap (const langType language) { - bool first = true; - unsigned int i; - stringList* map = LanguageTable [language]->currentPatterns; - Assert (0 <= language && language < (int) LanguageCount); - for (i = 0 ; map != NULL && i < stringListCount (map) ; ++i) - { - printf ("%s(%s)", (first ? "" : " "), - vStringValue (stringListItem (map, i))); - first = false; - } - map = LanguageTable [language]->currentExtensions; - for (i = 0 ; map != NULL && i < stringListCount (map) ; ++i) - { - printf ("%s.%s", (first ? "" : " "), - vStringValue (stringListItem (map, i))); - first = false; - } } extern void installLanguageMapDefault (const langType language) @@ -411,221 +394,12 @@ extern void freeParserResources (void) extern void processLanguageDefineOption (const char *const option, const char *const parameter CTAGS_ATTR_UNUSED) { - if (parameter [0] == '\0') - error (WARNING, "No language specified for \"%s\" option", option); - else if (getNamedLanguage (parameter, 0) != LANG_IGNORE) - error (WARNING, "Language \"%s\" already defined", parameter); - else - { - unsigned int i = LanguageCount++; - parserDefinition* const def = parserNew (parameter); - def->parser = findRegexTags; - def->currentPatterns = stringListNew (); - def->currentExtensions = stringListNew (); - def->method = METHOD_NOT_CRAFTED; - def->enabled = true; - def->id = i; - LanguageTable = xRealloc (LanguageTable, i + 1, parserDefinition*); - LanguageTable [i] = def; - } -} - -static kindOption *langKindOption (const langType language, const int flag) -{ - unsigned int i; - kindOption* result = NULL; - const parserDefinition* lang; - Assert (0 <= language && language < (int) LanguageCount); - lang = LanguageTable [language]; - for (i=0 ; i < lang->kindCount && result == NULL ; ++i) - if (lang->kinds [i].letter == flag) - result = &lang->kinds [i]; - return result; -} - -static void disableLanguageKinds (const langType language) -{ - if (LanguageTable [language]->method & METHOD_REGEX) - disableRegexKinds (language); - else - { - unsigned int i; - for (i = 0 ; i < LanguageTable [language]->kindCount ; ++i) - LanguageTable [language]->kinds [i].enabled = false; - } -} - -static bool enableLanguageKind (const langType language, - const int kind, const bool mode) -{ - bool result = false; - if (LanguageTable [language]->method & METHOD_REGEX) - result = enableRegexKind (language, kind, mode); - else - { - kindOption* const opt = langKindOption (language, kind); - if (opt != NULL) - { - opt->enabled = mode; - result = true; - } - } - return result; -} - -static void processLangKindOption (const langType language, - const char *const option, - const char *const parameter) -{ - const char *p = parameter; - bool mode = true; - int c; - - Assert (0 <= language && language < (int) LanguageCount); - if (*p != '+' && *p != '-') - disableLanguageKinds (language); - while ((c = *p++) != '\0') switch (c) - { - case '+': mode = true; break; - case '-': mode = false; break; - - default: - { - if (! enableLanguageKind (language, c, mode)) - error (WARNING, "Unsupported parameter '%c' for --%s option", - c, option); - } break; - } } extern bool processKindOption (const char *const option, const char *const parameter) { - bool handled = false; - const char* const dash = strchr (option, '-'); - if (dash != NULL && - (strcmp (dash + 1, "types") == 0 || strcmp (dash + 1, "kinds") == 0)) - { - langType language; - vString* langName = vStringNew (); - vStringNCopyS (langName, option, dash - option); - language = getNamedLanguage (vStringValue (langName), 0); - if (language == LANG_IGNORE) - error (WARNING, "Unknown language specified in \"%s\" option", option); - else - processLangKindOption (language, option, parameter); - vStringDelete (langName); - handled = true; - } - return handled; -} - -static void printLangugageKindOption (const kindOption* const kind) -{ - printf (" %c %s%s\n", kind->letter, - kind->description != NULL ? kind->description : - (kind->name != NULL ? kind->name : ""), - kind->enabled ? "" : " [off]"); -} - -static void printLangugageKindOptions (const langType language) -{ - const parserDefinition* lang; - Assert (0 <= language && language < (int) LanguageCount); - lang = LanguageTable [language]; - if (lang->kinds != NULL || lang->method & METHOD_NOT_CRAFTED) - { - unsigned int i; - char* const name = newLowerString (lang->name); - printf (" --%s-types=[+|-]kinds\n", name); - eFree (name); - if (lang->kinds != NULL) - for (i = 0 ; i < lang->kindCount ; ++i) - printLangugageKindOption (lang->kinds + i); - /*printRegexKindOptions (language);*/ /* unused */ - } -} - -extern void printKindOptions (void) -{ - unsigned int i; - - printf ( - "\n The following options are used to specify which language-specific tag\n\ - types (or kinds) should be included in the tag file. \"Kinds\" is a group of\n\ - one-letter flags designating kinds of tags to either include or exclude from\n\ - the output. Each letter or group of letters may be preceded by either '+' to\n\ - add it to those already included, or '-' to exclude it from the output. In\n\ - the absence of any preceding '+' or '-' sign, only those kinds listed in\n\ - \"kinds\" will be included in the output. Below each option is a list of the\n\ - flags accepted. All kinds are enabled by default unless otherwise noted.\n\n"); - - for (i = 0 ; i < LanguageCount ; ++i) - printLangugageKindOptions (i); -} - -/* -* File parsing -*/ - -static bool createTagsForFile (const char *const fileName, - const langType language, - const unsigned int passCount) -{ - bool retried = false; - - if (openInputFile (fileName, language, NULL)) - { - - makeFileTag (fileName); - - if (LanguageTable [language]->parser != NULL) - LanguageTable [language]->parser (); - else if (LanguageTable [language]->parser2 != NULL) - retried = LanguageTable [language]->parser2 (passCount); - - - closeInputFile (); - } - - return retried; -} - -static bool createTagsWithFallback (const char *const fileName, - const langType language) -{ - const unsigned long numTags = numTagsAdded (); - MIOPos filePosition; - unsigned int passCount = 0; - bool tagFileResized = false; - - tagFilePosition (&filePosition); - while (createTagsForFile (fileName, language, ++passCount)) - { - /* Restore prior state of tag file. - */ - setTagFilePosition (&filePosition); - setNumTagsAdded (numTags); - tagFileResized = true; - } - return tagFileResized; -} - -extern bool parseFile (const char *const fileName) -{ - bool tagFileResized = false; - langType language = Option.language; - if (Option.language == LANG_AUTO) - language = getFileLanguage (fileName); - Assert (language != LANG_AUTO); - if (Option.filter) - openTagFile (); - - tagFileResized = createTagsWithFallback (fileName, language); - - addTotals (1, 0L, 0L); - - return tagFileResized; + return false; } extern void installTagRegexTable (const langType language) @@ -670,12 +444,5 @@ extern void installKeywordTable (const langType language) extern bool processAliasOption ( const char *const option, const char *const parameter) { - langType language; - - language = getLanguageComponentInOption (option, "alias-"); - if (language == LANG_IGNORE) - return false; - -/* processLangAliasOption (language, parameter); */ - return true; + return false; } Modified: ctags/main/parse.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -134,8 +134,6 @@ extern void initializeParser (langType language); extern void freeParserResources (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 printKindOptions (void); -extern bool parseFile (const char *const fileName); extern void installKeywordTable (const langType language); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] ed03c2: read: introduce langStack for source files
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 15:05:56 UTC Commit: ed03c2042de388f34301838552cd092a65632958
https://github.com/geany/geany/commit/ed03c2042de388f34301838552cd092a65632…
Log Message: ----------- read: introduce langStack for source files Modified Paths: -------------- ctags/main/read.c Modified: ctags/main/read.c 92 lines changed, 83 insertions(+), 9 deletions(-) =================================================================== @@ -60,7 +60,9 @@ typedef struct sInputFileInfo { on the input stream. This is needed for nested stream. */ bool isHeader; /* is input file a header file? */ - langType language; /* language of input file */ + + /* language of input file */ + inputLangInfo langInfo; } inputFileInfo; typedef struct sInputLineFposMap { @@ -104,6 +106,17 @@ typedef struct sInputFile { inputLineFposMap lineFposMap; } inputFile; + +/* +* FUNCTION DECLARATIONS +*/ +static void langStackInit (langStack *langStack); +static langType langStackTop (langStack *langStack); +static void langStackPush (langStack *langStack, langType type); +static langType langStackPop (langStack *langStack); +static void langStackClear(langStack *langStack); + + /* * DATA DEFINITIONS */ @@ -146,7 +159,7 @@ extern MIOPos getInputFilePositionForLine (int line) extern langType getInputLanguage (void) { - return File.input.language; + return langStackTop (&File.input.langInfo.stack); } extern const char *getInputLanguageName (void) @@ -199,7 +212,7 @@ extern const char *getSourceFileTagPath (void) extern const char *getSourceLanguageName (void) { - return getLanguageName (File.source.language); + return getLanguageName (File.source.langInfo.type); } extern unsigned long getSourceLineNumber (void) @@ -254,6 +267,7 @@ static void setOwnerDirectoryOfInputFile (const char *const fileName) static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName, const langType language, + void (* setLang) (inputLangInfo *, langType), stringList *holder) { if (finfo->name != NULL) @@ -276,23 +290,47 @@ static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const f finfo->isHeader = isIncludeFile (vStringValue (fileName)); - if (language != -1) - finfo->language = language; - else - finfo->language = getFileLanguage (vStringValue (fileName)); + setLang (& (finfo->langInfo), language); +} + +static void resetLangOnStack (inputLangInfo *langInfo, langType lang) +{ + Assert (langInfo->stack.count > 0); + langStackClear (& (langInfo->stack)); + langStackPush (& (langInfo->stack), lang); +} + +static void pushLangOnStack (inputLangInfo *langInfo, langType lang) +{ + langStackPush (& langInfo->stack, lang); +} + +static langType popLangOnStack (inputLangInfo *langInfo) +{ + return langStackPop (& langInfo->stack); +} + +static void clearLangOnStack (inputLangInfo *langInfo) +{ + return langStackClear (& langInfo->stack); +} + +static void setLangToType (inputLangInfo *langInfo, langType lang) +{ + langInfo->type = lang; } static void setInputFileParameters (vString *const fileName, const langType language) { setInputFileParametersCommon (&File.input, fileName, - language, + language, pushLangOnStack, NULL); } static void setSourceFileParameters (vString *const fileName, const langType language) { setInputFileParametersCommon (&File.source, fileName, - language, + language, setLangToType, File.sourceTagPathHolder); } @@ -530,6 +568,8 @@ extern void closeInputFile (void) { if (File.mio != NULL) { + clearLangOnStack (& (File.input.langInfo)); + /* The line count of the file is 1 too big, since it is one-based * and is incremented upon each newline. */ @@ -781,3 +821,37 @@ extern char *readLineFromBypass ( what itself should do; just report it to the caller. */ return result; } + +static void langStackInit (langStack *langStack) +{ + langStack->count = 0; + langStack->size = 1; + langStack->languages = xCalloc (langStack->size, langType); +} + +static langType langStackTop (langStack *langStack) +{ + Assert (langStack->count > 0); + return langStack->languages [langStack->count - 1]; +} + +static void langStackClear (langStack *langStack) +{ + while (langStack->count > 0) + langStackPop (langStack); +} + +static void langStackPush (langStack *langStack, langType type) +{ + if (langStack->size == 0) + langStackInit (langStack); + else if (langStack->count == langStack->size) + langStack->languages = xRealloc (langStack->languages, + ++ langStack->size, langType); + langStack->languages [ langStack->count ++ ] = type; +} + +static langType langStackPop (langStack *langStack) +{ + return langStack->languages [ -- langStack->count ]; +} -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] f89e9f: read: Add function to initialize common parts of input/source files and use it
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 14:59:10 UTC Commit: f89e9f8014674a330c44a2b88512d0c56bc93f8f
https://github.com/geany/geany/commit/f89e9f8014674a330c44a2b88512d0c56bc93…
Log Message: ----------- read: Add function to initialize common parts of input/source files and use it Also correct input/source file usage in the file and initialize everything like in universal-ctags. Modified Paths: -------------- ctags/main/read.c Modified: ctags/main/read.c 105 lines changed, 67 insertions(+), 38 deletions(-) =================================================================== @@ -146,7 +146,7 @@ extern MIOPos getInputFilePositionForLine (int line) extern langType getInputLanguage (void) { - return File.source.language; + return File.input.language; } extern const char *getInputLanguageName (void) @@ -156,7 +156,7 @@ extern const char *getInputLanguageName (void) extern const char *getInputFileTagPath (void) { - return vStringValue (File.source.tagPath); + return vStringValue (File.input.tagPath); } extern bool isInputLanguage (langType lang) @@ -183,7 +183,7 @@ extern bool doesInputLanguageAllowNullTag (void) extern kindOption *getInputLanguageFileKind (void) { - return getLanguageFileKind (File.input.language); + return getLanguageFileKind (getInputLanguage ()); } extern bool doesInputLanguageRequestAutomaticFQTag (void) @@ -207,27 +207,39 @@ extern unsigned long getSourceLineNumber (void) return File.source.lineNumber; } +static void freeInputFileInfo (inputFileInfo *finfo) +{ + if (finfo->name) + { + vStringDelete (finfo->name); + finfo->name = NULL; + } + if (finfo->tagPath) + { + vStringDelete (finfo->tagPath); + finfo->tagPath = NULL; + } +} + extern void freeInputFileResources (void) { - vStringDelete (File.input.name); - vStringDelete (File.path); - vStringDelete (File.source.name); - vStringDelete (File.line); + if (File.path != NULL) + vStringDelete (File.path); + if (File.line != NULL) + vStringDelete (File.line); + freeInputFileInfo (&File.input); + freeInputFileInfo (&File.source); } /* * Input file access functions */ -static void setInputFileName (const char *const fileName) +static void setOwnerDirectoryOfInputFile (const char *const fileName) { const char *const head = fileName; const char *const tail = baseFilename (head); - if (File.input.name != NULL) - vStringDelete (File.input.name); - File.input.name = vStringNewInit (fileName); - if (File.path != NULL) vStringDelete (File.path); if (tail == head) @@ -239,34 +251,49 @@ static void setInputFileName (const char *const fileName) vStringNCopyS (File.path, fileName, length); } } -static void setSourceFileParameters (vString *const fileName, const langType language) + +static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName, + const langType language, + stringList *holder) { - if (File.source.name != NULL) - vStringDelete (File.source.name); - if (File.input.name != NULL) - vStringDelete (File.input.name); - File.source.name = fileName; - File.input.name = vStringNewCopy(fileName); + if (finfo->name != NULL) + vStringDelete (finfo->name); + finfo->name = fileName; - if (File.source.tagPath != NULL) - eFree (File.source.tagPath); + if (finfo->tagPath != NULL) + { + if (holder) + stringListAdd (holder, finfo->tagPath); + else + vStringDelete (finfo->tagPath); + } if (! Option.tagRelative || isAbsolutePath (vStringValue (fileName))) - File.source.tagPath = vStringNewCopy (fileName); + finfo->tagPath = vStringNewCopy (fileName); else - File.source.tagPath = + finfo->tagPath = vStringNewOwn (relativeFilename (vStringValue (fileName), - getTagFileDirectory ())); + getTagFileDirectory ())); - if (vStringLength (fileName) > maxTagsLine ()) - setMaxTagsLine (vStringLength (fileName)); + finfo->isHeader = isIncludeFile (vStringValue (fileName)); - File.source.isHeader = isIncludeFile (vStringValue (fileName)); - File.input.isHeader = File.source.isHeader; if (language != -1) - File.source.language = language; + finfo->language = language; else - File.source.language = getFileLanguage (vStringValue (fileName)); - File.input.language = File.source.language; + finfo->language = getFileLanguage (vStringValue (fileName)); +} + +static void setInputFileParameters (vString *const fileName, const langType language) +{ + setInputFileParametersCommon (&File.input, fileName, + language, + NULL); +} + +static void setSourceFileParameters (vString *const fileName, const langType language) +{ + setInputFileParametersCommon (&File.source, fileName, + language, + File.sourceTagPathHolder); } static bool setSourceFileName (vString *const fileName) @@ -284,7 +311,7 @@ static bool setSourceFileName (vString *const fileName) vStringValue (File.path), vStringValue (fileName)); pathName = vStringNewOwn (tmp); } - setSourceFileParameters (pathName, -1); + setSourceFileParameters (pathName, language); result = true; } return result; @@ -461,21 +488,24 @@ extern bool openInputFile (const char *const fileName, const langType language, { opened = true; - setInputFileName (fileName); + setOwnerDirectoryOfInputFile (fileName); mio_getpos (File.mio, &StartOfLine); mio_getpos (File.mio, &File.filePosition); File.currentLine = NULL; - File.input.lineNumber = 0L; if (File.line != NULL) vStringClear (File.line); + setInputFileParameters (vStringNewInit (fileName), language); + File.input.lineNumberOrigin = 0L; + File.input.lineNumber = File.input.lineNumberOrigin; setSourceFileParameters (vStringNewInit (fileName), language); - File.source.lineNumber = 0L; + File.source.lineNumberOrigin = 0L; + File.source.lineNumber = File.source.lineNumberOrigin; verbose ("OPENING %s as %s language %sfile\n", fileName, getLanguageName (language), - File.source.isHeader ? "include " : ""); + File.input.isHeader ? "include " : ""); } return opened; } @@ -508,7 +538,6 @@ extern void closeInputFile (void) fileStatus *status = eStat (vStringValue (File.input.name)); addTotals (0, File.input.lineNumber - 1L, status->size); } - mio_free (File.mio); File.mio = NULL; } @@ -584,7 +613,7 @@ static vString *iFileGetLine (void) if (Option.lineDirectives && vStringChar (File.line, 0) == '#') parseLineDirective (vStringValue (File.line) + 1); - matchRegex (File.line, File.source.language); + matchRegex (File.line, getInputLanguage ()); return File.line; } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 53f83e: read: add lineFposMap
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Tue, 11 Oct 2016 15:09:54 UTC Commit: 53f83e7ceef29ba75472094b12a92df334c52874
https://github.com/geany/geany/commit/53f83e7ceef29ba75472094b12a92df334c52…
Log Message: ----------- read: add lineFposMap Modified Paths: -------------- ctags/main/read.c Modified: ctags/main/read.c 43 lines changed, 39 insertions(+), 4 deletions(-) =================================================================== @@ -151,10 +151,8 @@ extern MIOPos getInputFilePosition (void) extern MIOPos getInputFilePositionForLine (int line) { - MIOPos pos; - return pos; -/* return File.lineFposMap.pos[(((File.lineFposMap.count > (line - 1)) \ - && (line > 0))? (line - 1): 0)];*/ + return File.lineFposMap.pos[(((File.lineFposMap.count > (line - 1)) \ + && (line > 0))? (line - 1): 0)]; } extern langType getInputLanguage (void) @@ -244,6 +242,41 @@ extern void freeInputFileResources (void) freeInputFileInfo (&File.source); } +/* + * inputLineFposMap related functions + */ +static void freeLineFposMap (inputLineFposMap *lineFposMap) +{ + if (lineFposMap->pos) + { + free (lineFposMap->pos); + lineFposMap->pos = NULL; + lineFposMap->count = 0; + lineFposMap->size = 0; + } +} + +static void allocLineFposMap (inputLineFposMap *lineFposMap) +{ +#define INITIAL_lineFposMap_LEN 256 + lineFposMap->pos = xCalloc (INITIAL_lineFposMap_LEN, MIOPos); + lineFposMap->size = INITIAL_lineFposMap_LEN; + lineFposMap->count = 0; +} + +static void appendLineFposMap (inputLineFposMap *lineFposMap, MIOPos pos) +{ + if (lineFposMap->size == lineFposMap->count) + { + lineFposMap->size *= 2; + lineFposMap->pos = xRealloc (lineFposMap->pos, + lineFposMap->size, + MIOPos); + } + lineFposMap->pos [lineFposMap->count] = pos; + lineFposMap->count++; +} + /* * Input file access functions */ @@ -540,6 +573,7 @@ extern bool openInputFile (const char *const fileName, const langType language, setSourceFileParameters (vStringNewInit (fileName), language); File.source.lineNumberOrigin = 0L; File.source.lineNumber = File.source.lineNumberOrigin; + allocLineFposMap (&File.lineFposMap); verbose ("OPENING %s as %s language %sfile\n", fileName, getLanguageName (language), @@ -580,6 +614,7 @@ extern void closeInputFile (void) } mio_free (File.mio); File.mio = NULL; + freeLineFposMap (&File.lineFposMap); } } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
4
5
...
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200