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
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 -----
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] f23b56: entry: make makeTakEntry() implementation closer to 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: Sun, 09 Oct 2016 13:22:42 UTC Commit: f23b56b0272c4fd12f2607cce6c692be21951e8b
https://github.com/geany/geany/commit/f23b56b0272c4fd12f2607cce6c692be21951…
Log Message: ----------- entry: make makeTakEntry() implementation closer to uctags For now, comment-out code that we don't use and that doesn't work. Modified Paths: -------------- ctags/main/entry.c ctags/main/entry.h Modified: ctags/main/entry.c 67 lines changed, 56 insertions(+), 11 deletions(-) =================================================================== @@ -436,27 +436,72 @@ static int replacementTruncate (const char *const name, const long size) #endif - /* * Tag entry management */ +static void writeTagEntry (const tagEntryInfo *const tag) +{ + int length = 0; + +/* if (tag->placeholder) + return; + if (! tag->kind->enabled) + return; + if (tag->extensionFields.roleIndex != ROLE_INDEX_DEFINITION + && ! isXtagEnabled (XTAG_REFERENCE_TAGS)) + return; +*/ + DebugStatement ( debugEntry (tag); ) +/* Assert (writer); */ +/* + if (includeExtensionFlags () + && isXtagEnabled (XTAG_QUALIFIED_TAGS) + && doesInputLanguageRequestAutomaticFQTag ()) + buildFqTagCache (tag); +*/ + /* length = writer->writeEntry (TagFile.mio, tag, writerData); */ + if (TagEntryFunction != NULL) + length = TagEntryFunction(tag, TagEntryUserData); + + ++TagFile.numTags.added; + rememberMaxLengths (strlen (tag->name), (size_t) length); + DebugStatement ( mio_flush (TagFile.mio); ) + + /*abort_if_ferror (TagFile.mio);*/ +} -extern void makeTagEntry (const tagEntryInfo *const tag) +extern int makeTagEntry (const tagEntryInfo *const tag) { + int r = CORK_NIL; Assert (tag->name != NULL); - if (tag->name [0] == '\0') - error (WARNING, "ignoring null tag in %s", getInputFileName ()); - else - { - int length = 0; - if (NULL != TagEntryFunction) - length = TagEntryFunction(tag, TagEntryUserData); +/* + if (getInputLanguageFileKind() != tag->kind) + { + if (! isInputLanguageKindEnabled (tag->kind->letter) && + (tag->extensionFields.roleIndex == ROLE_INDEX_DEFINITION)) + return CORK_NIL; + if ((tag->extensionFields.roleIndex != ROLE_INDEX_DEFINITION) + && (! tag->kind->roles[tag->extensionFields.roleIndex].enabled)) + return CORK_NIL; + } +*/ - ++TagFile.numTags.added; - rememberMaxLengths (strlen (tag->name), (size_t) length); + if (tag->name [0] == '\0' && (!tag->placeholder)) + { +/* if (!doesInputLanguageAllowNullTag()) */ + error (WARNING, "ignoring null tag in %s(line: %lu)", + getInputFileName (), tag->lineNumber); + goto out; } + +/* if (TagFile.cork) + r = queueTagEntry (tag); + else*/ + writeTagEntry (tag); +out: + return r; } extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind) Modified: ctags/main/entry.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -113,7 +113,7 @@ extern void freeTagFileResources (void); extern const char *tagFileName (void); extern void openTagFile (void); extern void closeTagFile (const bool resize); -extern void makeTagEntry (const tagEntryInfo *const tag); +extern int makeTagEntry (const tagEntryInfo *const tag); extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind); extern unsigned long numTagsAdded(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] 88cbe3: Grab ctags version of general.h and make related changes
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: Sat, 08 Oct 2016 12:13:41 UTC Commit: 88cbe3871c75fa47be0995d52c3e1afe75e51a92
https://github.com/geany/geany/commit/88cbe3871c75fa47be0995d52c3e1afe75e51…
Log Message: ----------- Grab ctags version of general.h and make related changes Added e_msoft.h, changed configure.ac to make more checks for header files so we have corresponding macros defined, drop HAVE_REGEX macro check which isn't defined any more, drop debugging function from lua parser (complains about missing definition of errout). Tested only on Linux (TODO: Windows, OS X) Modified Paths: -------------- configure.ac ctags/Makefile.am ctags/main/e_msoft.h ctags/main/general.h ctags/main/lregex.c ctags/main/parse.c ctags/main/parse.h ctags/parsers/lua.c Modified: configure.ac 7 lines changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -38,7 +38,12 @@ AC_PROG_LN_S # autoscan start # Checks for header files. -AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h stdlib.h sys/time.h errno.h limits.h]) +AC_CHECK_HEADERS([fcntl.h glob.h stdlib.h sys/time.h errno.h limits.h]) + +# Checks for dependencies needed by ctags +AC_CHECK_HEADERS([fnmatch.h direct.h io.h sys/dir.h]) +AH_TEMPLATE([USE_STDBOOL_H], [whether or not to use <stdbool.h>.]) +AC_DEFINE([USE_STDBOOL_H]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_OFF_T Modified: ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -58,6 +58,7 @@ libctags_la_SOURCES = \ main/ctags.h \ main/debug.h \ main/debug.c \ + main/e_msoft.h \ main/entry.c \ main/entry.h \ main/error.c \ Modified: ctags/main/e_msoft.h 71 lines changed, 71 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2002-2003, Darren Hiebert +* +* 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. +* +* Configures ctags for Microsoft environment. +*/ +#ifndef E_MSOFT_H +#define E_MSOFT_H + +#define CASE_INSENSITIVE_FILENAMES 1 +#define MANUAL_GLOBBING 1 +#define MSDOS_STYLE_PATH 1 +#define HAVE_FCNTL_H 1 +#define HAVE_IO_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_TIME_H 1 +#define HAVE_CLOCK 1 +#define HAVE_CHSIZE 1 +#define HAVE_FGETPOS 1 +#define HAVE_STRICMP 1 +#define HAVE_STRNICMP 1 +#define HAVE_STRSTR 1 +#define HAVE_STRERROR 1 +#define HAVE_FINDNEXT 1 +#define HAVE_TEMPNAM 1 +#define HAVE_FNMATCH 1 +#define HAVE_FNMATCH_H 1 +#define HAVE_PUTENV 1 +#define tempnam(dir,pfx) _tempnam(dir,pfx) +#define TMPDIR "\\" + +#ifdef _MSC_VER + +# define HAVE__FINDFIRST 1 +# define HAVE_DIRECT_H 1 +# if _MSC_VER < 1900 +# define snprintf _snprintf +# endif +# define findfirst_t intptr_t + +#if (_MSC_VER >= 1800) // Visual Studio 2013 or newer +#define HAVE_STDBOOL_H 1 +#else +typedef enum { false, true } bool; +#endif + +# ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE 1 +# endif +# pragma warning(disable : 4996) + +#elif defined (__MINGW32__) + +# include <_mingw.h> +# define HAVE_STDBOOL_H 1 +# define HAVE_DIR_H 1 +# define HAVE_DIRENT_H 1 +# define HAVE__FINDFIRST 1 +# define findfirst_t long +# define ffblk _finddata_t +# define FA_DIREC _A_SUBDIR +# define ff_name name + +#endif + +#endif Modified: ctags/main/general.h 93 lines changed, 19 insertions(+), 74 deletions(-) =================================================================== @@ -14,99 +14,44 @@ */ #if defined (HAVE_CONFIG_H) # include <config.h> +#if (defined (HAVE_FORK) && defined (HAVE_WAITPID) && defined (HAVE_EXECV) && defined (HAVE_PIPE)) +#define HAVE_COPROC #endif -#ifdef macintosh -# include "mac.h" +#elif defined (WIN32) +# include "e_msoft.h" #endif -/* include unistd.h preventively because at least under MacOSX it is needed for off_t */ -#include <unistd.h> - -#include <stdbool.h> /* * MACROS */ #include "gcc-attr.h" -/* MS-DOS doesn't allow manipulation of standard error, so we send it to - * stdout instead. +/* + * Portability macros */ -#if defined (WIN32) -# define errout stdout -#else -# define errout stderr -#endif - -#if defined (__CYGWIN__) -# define UNIX_PATH_SEPARATOR 1 -# define MSDOS_STYLE_PATH -#endif - -#if defined (WIN32) -# define CASE_INSENSITIVE_FILENAMES -# define MSDOS_STYLE_PATH -# define HAVE_DOS_H 1 -# define HAVE_FCNTL_H 1 -# define HAVE_IO_H 1 -# define HAVE_STDLIB_H 1 -# define HAVE_SYS_STAT_H 1 -# define HAVE_SYS_TYPES_H 1 -# define HAVE_TIME_H 1 -# define HAVE_CLOCK 1 -# define HAVE_CHSIZE 1 -# define HAVE_FGETPOS 1 -# define HAVE_STRICMP 1 -# define HAVE_STRNICMP 1 -# define HAVE_STRSTR 1 -# define HAVE_STRERROR 1 -# define HAVE_FINDNEXT 1 -# ifdef _MSC_VER -# define HAVE__FINDFIRST 1 -# define HAVE_DIRECT_H 1 -# elif defined (__MINGW32__) -# define HAVE_DIR_H 1 -# define HAVE_DIRENT_H 1 -# define HAVE__FINDFIRST 1 -# define ffblk _finddata_t -# define FA_DIREC _A_SUBDIR -# define ff_name name +#if !defined(HAVE_STRCASECMP) && !defined(strcasecmp) +# ifdef HAVE_STRICMP +# define strcasecmp(s1,s2) stricmp(s1,s2) +# else +# define strcasecmp(s1,s2) struppercmp(s1,s2) # endif -/* provide the prototype for cross-compiling/Windows */ -char *lrealpath(const char *filename); -#endif - -#ifndef HAVE_FNMATCH_H -/* provide the prototype for cross-compiling/Windows */ -int fnmatch(const char *pattern, const char *string, int flags); #endif -#if defined (__MWERKS__) && defined (__MACINTOSH__) -# define HAVE_STAT_H 1 -#endif - - -#ifdef __FreeBSD__ -#include <sys/types.h> -#endif /* __FreeBSD__ */ - -/* Define regex if supported */ -#if (defined (HAVE_REGCOMP) && !defined (REGCOMP_BROKEN)) || defined (HAVE_RE_COMPILE_PATTERN) -# define HAVE_REGEX 1 +#if !defined(HAVE_STRNCASECMP) && !defined(strncasecmp) +# ifdef HAVE_STRNICMP +# define strncasecmp(s1,s2,n) strnicmp(s1,s2,n) +# else +# define strncasecmp(s1,s2,n) strnuppercmp(s1,s2,n) +# endif #endif - /* * DATA DECLARATIONS */ -#if ! defined (HAVE_FGETPOS) && ! defined (fpos_t) -# define fpos_t long -#endif - -/* Work-around for broken implementation of fgetpos()/fsetpos() on Mingw32 */ -#if defined (__MINGW32__) && defined (__MSVCRT__) -# undef HAVE_FGETPOS +#ifdef USE_STDBOOL_H +# include <stdbool.h> #endif /* Modified: ctags/main/lregex.c 23 lines changed, 0 insertions(+), 23 deletions(-) =================================================================== @@ -35,8 +35,6 @@ #include "kind.h" #include "routines.h" -#ifdef HAVE_REGEX - /* * MACROS */ @@ -528,16 +526,13 @@ extern void findRegexTags (void) ; } -#endif /* HAVE_REGEX */ - extern void addTagRegex ( const langType language CTAGS_ATTR_UNUSED, const char* const regex CTAGS_ATTR_UNUSED, const char* const name CTAGS_ATTR_UNUSED, const char* const kinds CTAGS_ATTR_UNUSED, const char* const flags CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX Assert (regex != NULL); Assert (name != NULL); if (! regexBroken) @@ -553,7 +548,6 @@ extern void addTagRegex ( kind, kindName, description); } } -#endif } extern void addCallbackRegex ( @@ -562,21 +556,18 @@ extern void addCallbackRegex ( const char* const flags CTAGS_ATTR_UNUSED, const regexCallback callback CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX Assert (regex != NULL); if (! regexBroken) { GRegex* const cp = compileRegex (regex, flags); if (cp != NULL) addCompiledCallbackPattern (language, cp, callback); } -#endif } extern void addLanguageRegex ( const langType language CTAGS_ATTR_UNUSED, const char* const regex CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX if (! regexBroken) { char *const regex_pat = eStrdup (regex); @@ -587,7 +578,6 @@ extern void addLanguageRegex ( eFree (regex_pat); } } -#endif } /* @@ -601,25 +591,19 @@ extern bool processRegexOption (const char *const option, const char* const dash = strchr (option, '-'); if (dash != NULL && strncmp (option, "regex", dash - option) == 0) { -#ifdef HAVE_REGEX langType language; language = getNamedLanguage (dash + 1); if (language == LANG_IGNORE) printf ("regex: unknown language \"%s\" in --%s option\n", (dash + 1), option); else processLanguageRegex (language, parameter); -#else - printf ("regex: regex support not available; required for --%s option\n", - option); -#endif handled = true; } return handled; } extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX if (language <= SetUpper && Sets [language].count > 0) { patternSet* const set = Sets + language; @@ -628,15 +612,13 @@ extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED) if (set->patterns [i].type == PTRN_TAG) set->patterns [i].u.tag.kind.enabled = false; } -#endif } extern bool enableRegexKind ( const langType language CTAGS_ATTR_UNUSED, const int kind CTAGS_ATTR_UNUSED, const bool mode CTAGS_ATTR_UNUSED) { bool result = false; -#ifdef HAVE_REGEX if (language <= SetUpper && Sets [language].count > 0) { patternSet* const set = Sets + language; @@ -649,13 +631,11 @@ extern bool enableRegexKind ( result = true; } } -#endif return result; } extern void printRegexKinds (const langType language CTAGS_ATTR_UNUSED, bool indent CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX if (language <= SetUpper && Sets [language].count > 0) { patternSet* const set = Sets + language; @@ -664,20 +644,17 @@ extern void printRegexKinds (const langType language CTAGS_ATTR_UNUSED, bool ind if (set->patterns [i].type == PTRN_TAG) printRegexKind (set->patterns, i, indent); } -#endif } extern void freeRegexResources (void) { -#ifdef HAVE_REGEX int i; for (i = 0 ; i <= SetUpper ; ++i) clearPatternSet (i); if (Sets != NULL) eFree (Sets); Sets = NULL; SetUpper = -1; -#endif } /* Check for broken regcomp() on Cygwin */ Modified: ctags/main/parse.c 17 lines changed, 0 insertions(+), 17 deletions(-) =================================================================== @@ -339,10 +339,8 @@ extern void initializeParsing (void) error (FATAL, "parser definition must contain name\n"); else if (def->method & METHOD_REGEX) { -#ifdef HAVE_REGEX def->parser = findRegexTags; accepted = true; -#endif } else if ((def->parser == NULL) == (def->parser2 == NULL)) error (FATAL, @@ -384,7 +382,6 @@ extern void freeParserResources (void) extern void processLanguageDefineOption (const char *const option, const char *const parameter CTAGS_ATTR_UNUSED) { -#ifdef HAVE_REGEX if (parameter [0] == '\0') error (WARNING, "No language specified for \"%s\" option", option); else if (getNamedLanguage (parameter) != LANG_IGNORE) @@ -402,10 +399,6 @@ extern void processLanguageDefineOption (const char *const option, LanguageTable = xRealloc (LanguageTable, i + 1, parserDefinition*); LanguageTable [i] = def; } -#else - error (WARNING, "regex support not available; required for --%s option", - option); -#endif } static kindOption *langKindOption (const langType language, const int flag) @@ -465,11 +458,7 @@ extern void processLegacyKindOption (const char *const parameter) static void disableLanguageKinds (const langType language) { if (LanguageTable [language]->method & METHOD_REGEX) -#ifdef HAVE_REGEX disableRegexKinds (language); -#else - ; -#endif else { unsigned int i; @@ -483,11 +472,7 @@ static bool enableLanguageKind (const langType language, { bool result = false; if (LanguageTable [language]->method & METHOD_REGEX) -#ifdef HAVE_REGEX result = enableRegexKind (language, kind, mode); -#else - ; -#endif else { kindOption* const opt = langKindOption (language, kind); @@ -569,9 +554,7 @@ static void printLangugageKindOptions (const langType language) if (lang->kinds != NULL) for (i = 0 ; i < lang->kindCount ; ++i) printLangugageKindOption (lang->kinds + i); -#ifdef HAVE_REGEX /*printRegexKindOptions (language);*/ /* unused */ -#endif } } Modified: ctags/main/parse.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -134,10 +134,8 @@ extern bool parseFile (const char *const fileName); extern void installKeywordTable (const langType language); /* Regex interface */ -#ifdef HAVE_REGEX extern void findRegexTags (void); extern bool matchRegex (const vString* const line, const langType language); -#endif 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); Modified: ctags/parsers/lua.c 8 lines changed, 0 insertions(+), 8 deletions(-) =================================================================== @@ -34,14 +34,6 @@ static kindOption LuaKinds [] = { * FUNCTION DEFINITIONS */ -/* for debugging purposes */ -static void CTAGS_ATTR_UNUSED print_string (char *p, char *q) -{ - for ( ; p != q; p++) - fprintf (errout, "%c", *p); - fprintf (errout, "\n"); -} - /* * Helper function. * Returns 1 if line looks like a line of Lua code. -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 4cde63: Sync the beginning of entry.c/h
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: Sun, 09 Oct 2016 10:40:08 UTC Commit: 4cde630dd78282cead151a9afb14bd7056c7f407
https://github.com/geany/geany/commit/4cde630dd78282cead151a9afb14bd7056c7f…
Log Message: ----------- Sync the beginning of entry.c/h Mostly sTagEntryInfo and eTagFile taken from uctags and sync of includes. Modified Paths: -------------- ctags/main/entry.c ctags/main/entry.h Modified: ctags/main/entry.c 57 lines changed, 36 insertions(+), 21 deletions(-) =================================================================== @@ -22,7 +22,9 @@ #if defined (HAVE_TYPES_H) # include <types.h> /* to declare off_t on some hosts */ #endif - +#if defined (HAVE_UNISTD_H) +# include <unistd.h> /* to declare close (), ftruncate (), truncate () */ +#endif /* These header files provide for the functions necessary to do file * truncation. @@ -34,23 +36,25 @@ # include <io.h> #endif -#include "ctags.h" #include "debug.h" #include "entry.h" +#include "field.h" +#include "fmt.h" +#include "kind.h" #include "main.h" #include "options.h" +#include "output.h" +#include "ptag.h" #include "read.h" +#include "routines.h" #include "sort.h" #include "strlist.h" -#include "routines.h" -#include "output.h" +#include "xtag.h" +#include "ctags.h" /* * MACROS */ -#define PSEUDO_TAG_PREFIX "!_" - -#define includeExtensionFlags() (Option.tagFileFormat > 1) /* * Portability defines @@ -76,27 +80,37 @@ typedef struct eTagFile { char *directory; MIO *mio; struct sNumTags { unsigned long added, prev; } numTags; - struct sMax { size_t line, tag, file; } max; -/* struct sEtags { - char *name; - MIO *mio; - size_t byteCount; - } etags;*/ + struct sMax { size_t line, tag; } max; vString *vLine; + + unsigned int cork; + struct sCorkQueue { + struct sTagEntryInfo* queue; + unsigned int length; + unsigned int count; + } corkQueue; + + bool patternCacheValid; } tagFile; /* * DATA DEFINITIONS */ tagFile TagFile = { - NULL, /* tag file name */ - NULL, /* tag file directory (absolute) */ - NULL, /* file pointer */ - { 0, 0 }, /* numTags */ - { 0, 0, 0 }, /* max */ -/* { NULL, NULL, 0 },*/ /* etags */ - NULL /* vLine */ + NULL, /* tag file name */ + NULL, /* tag file directory (absolute) */ + NULL, /* file pointer */ + { 0, 0 }, /* numTags */ + { 0, 0 }, /* max */ + NULL, /* vLine */ + .cork = false, + .corkQueue = { + .queue = NULL, + .length = 0, + .count = 0 + }, + .patternCacheValid = false, }; static bool TagsToStdout = false; @@ -118,7 +132,8 @@ extern int ftruncate (int fd, off_t length); extern void freeTagFileResources (void) { - eFree (TagFile.directory); + if (TagFile.directory != NULL) + eFree (TagFile.directory); vStringDelete (TagFile.vLine); } Modified: ctags/main/entry.h 69 lines changed, 54 insertions(+), 15 deletions(-) =================================================================== @@ -15,17 +15,21 @@ #include "general.h" /* must always come first */ #include "types.h" +#include <stdio.h> + #include "field.h" -#include "mio.h" -#include "vstring.h" #include "kind.h" +#include "vstring.h" +#include "xtag.h" +#include "mio.h" +#include "nestlevel.h" /* * MACROS */ #define WHOLE_FILE -1L +#define includeExtensionFlags() (Option.tagFileFormat > 1) -#define NO_PARSER_FIELD -1 #define CORK_NIL 0 /* @@ -39,16 +43,25 @@ typedef struct sTagField { /* Information about the current tag candidate. */ struct sTagEntryInfo { - bool lineNumberEntry; /* pattern or line number entry */ - unsigned long lineNumber; /* line number of tag */ - MIOPos filePosition; /* file position of line containing tag */ - const char* language; /* language of source file */ - bool isFileScope; /* is tag visible only within source file? */ - bool isFileEntry; /* is this just an entry for a file name? */ - bool truncateLine; /* truncate tag line at end of tag name? */ - const char *sourceFileName; /* name of source file */ - const char *name; /* name of the tag */ - const kindOption *kind; /* kind descriptor */ + unsigned int lineNumberEntry:1; /* pattern or line number entry */ + unsigned int isFileScope :1; /* is tag visible only within input file? */ + unsigned int isFileEntry :1; /* is this just an entry for a file name? */ + unsigned int truncateLine :1; /* truncate tag line at end of tag name? */ + unsigned int placeholder :1; /* This is just a part of scope context. + Put this entry to cork queue but + don't print it to tags file. */ + + unsigned long lineNumber; /* line number of tag */ + const char* pattern; /* pattern for locating input line + * (may be NULL if not present) *//* */ + unsigned int boundaryInfo; /* info about nested input stream */ + MIOPos filePosition; /* file position of line containing tag */ + const char* language; /* language of input file */ + const char *inputFileName; /* name of input file */ + const char *name; /* name of the tag */ + const kindOption *kind; /* kind descriptor */ + unsigned char extra[ ((XTAG_COUNT) / 8) + 1 ]; + struct { const char* access; const char* fileScope; @@ -57,16 +70,42 @@ struct sTagEntryInfo { const kindOption* scopeKind; const char* scopeName; + int scopeIndex; /* cork queue entry for upper scope tag. + This field is meaningful if the value + is not CORK_NIL and scope[0] and scope[1] are + NULL. */ + + const char* signature; - const char *signature; /* Argument list for functions and macros with arguments */ const char *varType; - } extensionFields; /* list of extension fields*/ + +#define ROLE_INDEX_DEFINITION -1 + int roleIndex; /* for role of reference tag */ + +#ifdef HAVE_LIBXML + const char* xpath; +#endif + unsigned long endLine; + } extensionFields; /* list of extension fields*/ + +#define PRE_ALLOCATED_PARSER_FIELDS 5 +#define NO_PARSER_FIELD -1 + unsigned int usedParserFields; + tagField parserFields [PRE_ALLOCATED_PARSER_FIELDS]; + + /* Following source* fields are used only when #line is found + in input and --line-directive is given in ctags command line. */ + const char* sourceLanguage; + const char *sourceFileName; + unsigned long sourceLineNumberDifference; }; + /* * GLOBAL VARIABLES */ + /* * FUNCTION PROTOTYPES */ -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 3f52bf: entry: Take over uctags tag writing code
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: Sun, 09 Oct 2016 10:48:49 UTC Commit: 3f52bfb4ab95598f125673049bac76226772b77b
https://github.com/geany/geany/commit/3f52bfb4ab95598f125673049bac76226772b…
Log Message: ----------- entry: Take over uctags tag writing code We don't use it so we can grab whatever is there. Modified Paths: -------------- ctags/main/entry.c ctags/main/entry.h Modified: ctags/main/entry.c 122 lines changed, 78 insertions(+), 44 deletions(-) =================================================================== @@ -50,7 +50,6 @@ #include "sort.h" #include "strlist.h" #include "xtag.h" -#include "ctags.h" /* * MACROS @@ -161,38 +160,53 @@ static void rememberMaxLengths (const size_t nameLength, const size_t lineLength TagFile.max.line = lineLength; } -static void writePseudoTag (const char *const tagName, - const char *const fileName, - const char *const pattern) +static void addCommonPseudoTags (void) { - const int length = mio_printf (TagFile.mio, "%s%s\t%s\t/%s/\n", - PSEUDO_TAG_PREFIX, tagName, fileName, pattern); - ++TagFile.numTags.added; - rememberMaxLengths (strlen (tagName), (size_t) length); + int i; + + for (i = 0; i < PTAG_COUNT; i++) + { + if (isPtagCommonInParsers (i)) + makePtagIfEnabled (i, NULL); + } } -static void addPseudoTags (void) +extern void makeFileTag (const char *const fileName) { - if (! Option.xref) + xtagType xtag = XTAG_UNKNOWN; + + if (isXtagEnabled(XTAG_FILE_NAMES)) + xtag = XTAG_FILE_NAMES; + + if (xtag != XTAG_UNKNOWN) { - char format [11]; - const char *formatComment = "unknown format"; - - sprintf (format, "%u", Option.tagFileFormat); - - if (Option.tagFileFormat == 1) - formatComment = "original ctags format"; - else if (Option.tagFileFormat == 2) - formatComment = - "extended format; --format=1 will not append ;\" to lines"; - - writePseudoTag ("TAG_FILE_FORMAT", format, formatComment); - writePseudoTag ("TAG_FILE_SORTED", Option.sorted ? "1":"0", - "0=unsorted, 1=sorted"); - writePseudoTag ("TAG_PROGRAM_AUTHOR", AUTHOR_NAME, ""); - writePseudoTag ("TAG_PROGRAM_NAME", PROGRAM_NAME, ""); - writePseudoTag ("TAG_PROGRAM_URL", PROGRAM_URL, "official site"); - writePseudoTag ("TAG_PROGRAM_VERSION", PROGRAM_VERSION, ""); + tagEntryInfo tag; + kindOption *kind; + + kind = getInputLanguageFileKind(); + Assert (kind); + kind->enabled = isXtagEnabled(XTAG_FILE_NAMES); + + /* TODO: you can return here if enabled == false. */ + + initTagEntry (&tag, baseFilename (fileName), kind); + + tag.isFileEntry = true; + tag.lineNumberEntry = true; + markTagExtraBit (&tag, xtag); + + tag.lineNumber = 1; + if (isFieldEnabled (FIELD_END)) + { + /* isFieldEnabled is called again in the rendering + stage. However, it is called here for avoiding + unnecessary read line loop. */ + while (readLineFromInputFile () != NULL) + ; /* Do nothing */ + tag.extensionFields.endLine = getInputLineNumber (); + } + + makeTagEntry (&tag); } } @@ -315,41 +329,48 @@ extern void openTagFile (void) /* Open a tempfile with read and write mode. Read mode is used when * write the result to stdout. */ TagFile.mio = tempFile ("w+", &TagFile.name); + if (isXtagEnabled (XTAG_PSEUDO_TAGS)) + addCommonPseudoTags (); } else { bool fileExists; - setDefaultTagFileName (); TagFile.name = eStrdup (Option.tagFileName); fileExists = doesFileExist (TagFile.name); if (fileExists && ! isTagFile (TagFile.name)) error (FATAL, "\"%s\" doesn't look like a tag file; I refuse to overwrite it.", TagFile.name); - if (Option.append && fileExists) + if (Option.etags) { - TagFile.mio = mio_new_file (TagFile.name, "r+"); - if (TagFile.mio != NULL) - { - TagFile.numTags.prev = updatePseudoTags (TagFile.mio); - mio_free (TagFile.mio); - TagFile.mio = mio_new_file (TagFile.name, "a+"); - } + if (Option.append && fileExists) + TagFile.mio = mio_new_file (TagFile.name, "a+b"); + else + TagFile.mio = mio_new_file (TagFile.name, "w+b"); } else { - TagFile.mio = mio_new_file (TagFile.name, "w"); - if (TagFile.mio != NULL) - addPseudoTags (); + if (Option.append && fileExists) + { + TagFile.mio = mio_new_file (TagFile.name, "r+"); + if (TagFile.mio != NULL) + { + TagFile.numTags.prev = updatePseudoTags (TagFile.mio); + mio_free (TagFile.mio); + TagFile.mio = mio_new_file (TagFile.name, "a+"); + } + } + else + { + TagFile.mio = mio_new_file (TagFile.name, "w"); + if (TagFile.mio != NULL && isXtagEnabled (XTAG_PSEUDO_TAGS)) + addCommonPseudoTags (); + } } - if (TagFile.mio == NULL) - { error (FATAL | PERROR, "cannot open tag file"); - exit (1); - } } if (TagsToStdout) TagFile.directory = eStrdup (CurrentDirectory); @@ -455,6 +476,19 @@ extern void setTagWriter (tagWriter *t) /* writer = t; */ } +extern void markTagExtraBit (tagEntryInfo *const tag, xtagType extra) +{ + unsigned int index; + unsigned int offset; + + Assert (extra < XTAG_COUNT); + Assert (extra != XTAG_UNKNOWN); + + index = (extra / 8); + offset = (extra % 8); + tag->extra [ index ] |= (1 << offset); +} + extern unsigned long numTagsAdded(void) { return TagFile.numTags.added; Modified: ctags/main/entry.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -129,5 +129,6 @@ extern void setTagFilePosition (MIOPos *p); extern const char* getTagFileDirectory (void); extern void getTagScopeInformation (tagEntryInfo *const tag, const char **kind, const char **name); +extern void markTagExtraBit (tagEntryInfo *const tag, xtagType extra); #endif /* CTAGS_MAIN_ENTRY_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] 6ce628: entry: Some more or less formal changes
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: Sun, 09 Oct 2016 12:47:54 UTC Commit: 6ce628da2cd73d736d1f53f1197efc8fcb19ae01
https://github.com/geany/geany/commit/6ce628da2cd73d736d1f53f1197efc8fcb19a…
Log Message: ----------- entry: Some more or less formal changes Modified Paths: -------------- ctags/main/entry.c ctags/main/entry.h Modified: ctags/main/entry.c 31 lines changed, 16 insertions(+), 15 deletions(-) =================================================================== @@ -239,7 +239,8 @@ static void updateSortedFlag ( d != (int) Option.sorted) { mio_setpos (mio, &flagLocation); - mio_putc (mio, Option.sorted ? '1' : '0'); + mio_putc (mio, Option.sorted == SO_FOLDSORTED ? '2' : + (Option.sorted == SO_SORTED ? '1' : '0')); } mio_setpos (mio, &nextLine); } @@ -252,27 +253,27 @@ static void updateSortedFlag ( */ static long unsigned int updatePseudoTags (MIO *const mio) { - enum { maxClassLength = 20 }; - char class [maxClassLength + 1]; + enum { maxEntryLength = 20 }; + char entry [maxEntryLength + 1]; unsigned long linesRead = 0; MIOPos startOfLine; - size_t classLength; + size_t entryLength; const char *line; - sprintf (class, "%sTAG_FILE", PSEUDO_TAG_PREFIX); - classLength = strlen (class); - Assert (classLength < maxClassLength); + sprintf (entry, "%sTAG_FILE", PSEUDO_TAG_PREFIX); + entryLength = strlen (entry); + Assert (entryLength < maxEntryLength); mio_getpos (mio, &startOfLine); line = readLineRaw (TagFile.vLine, mio); - while (line != NULL && line [0] == class [0]) + while (line != NULL && line [0] == entry [0]) { ++linesRead; - if (strncmp (line, class, classLength) == 0) + if (strncmp (line, entry, entryLength) == 0) { char tab, classType [16]; - if (sscanf (line + classLength, "%15s%c", classType, &tab) == 2 && + if (sscanf (line + entryLength, "%15s%c", classType, &tab) == 2 && tab == '\t') { if (strcmp (classType, "_SORTED") == 0) @@ -298,7 +299,7 @@ static long unsigned int updatePseudoTags (MIO *const mio) static bool isTagFile (const char *const filename) { - bool ok = false; /* we assume not unless confirmed */ + bool ok = false; /* we assume not unless confirmed */ MIO *const mio = mio_new_file (filename, "rb"); if (mio == NULL && errno == ENOENT) @@ -380,7 +381,7 @@ extern void openTagFile (void) #ifdef USE_REPLACEMENT_TRUNCATE -extern void copyBytes (MIO* const fromMio, MIO* const toMio, const long size) +static void copyBytes (MIO* const fromMio, MIO* const toMio, const long size) { enum { BufferSize = 1000 }; long toRead, numRead; @@ -389,7 +390,7 @@ extern void copyBytes (MIO* const fromMio, MIO* const toMio, const long size) do { toRead = (0 < remaining && remaining < BufferSize) ? - remaining : BufferSize; + remaining : (long) BufferSize; numRead = mio_read (fromMio, buffer, (size_t) 1, (size_t) toRead); if (mio_write (toMio, buffer, (size_t)1, (size_t)numRead) < (size_t)numRead) error (FATAL | PERROR, "cannot complete write"); @@ -399,7 +400,7 @@ extern void copyBytes (MIO* const fromMio, MIO* const toMio, const long size) eFree (buffer); } -extern void copyFile (const char *const from, const char *const to, const long size) +static void copyFile (const char *const from, const char *const to, const long size) { MIO* const fromMio = mio_new_file (from, "rb"); if (fromMio == NULL) @@ -516,7 +517,7 @@ extern void setMaxTagsLine (unsigned long max) extern void invalidatePatternCache(void) { -/* TagFile.patternCacheValid = false; */ + TagFile.patternCacheValid = false; } extern void tagFilePosition (MIOPos *p) Modified: ctags/main/entry.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -111,8 +111,6 @@ struct sTagEntryInfo { */ extern void freeTagFileResources (void); extern const char *tagFileName (void); -extern void copyBytes (MIO* const fromMio, MIO* const toMio, const long size); -extern void copyFile (const char *const from, const char *const to, const long size); extern void openTagFile (void); extern void closeTagFile (const bool resize); extern void makeTagEntry (const tagEntryInfo *const tag); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] e685d9: Some sync of lcpp.c/h
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: Sun, 09 Oct 2016 09:04:51 UTC Commit: e685d956d66651139d6deaf779bcec3b7f4aa0d2
https://github.com/geany/geany/commit/e685d956d66651139d6deaf779bcec3b7f4aa…
Log Message: ----------- Some sync of lcpp.c/h Sync things which are possible to sync from lcpp.c/h. This file is heavily dependent on c.c and since our c.c differs quite significantly, it's not possible to use the universal-ctags implementation right now. Modified Paths: -------------- ctags/main/entry.h ctags/main/lcpp.c ctags/main/lcpp.h ctags/parsers/c.c Modified: ctags/main/entry.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -26,6 +26,7 @@ #define WHOLE_FILE -1L #define NO_PARSER_FIELD -1 +#define CORK_NIL 0 /* * DATA DECLARATIONS Modified: ctags/main/lcpp.c 74 lines changed, 45 insertions(+), 29 deletions(-) =================================================================== @@ -22,7 +22,7 @@ #include "options.h" #include "read.h" #include "vstring.h" -#include "routines.h" +#include "parse.h" #include "xtag.h" /* @@ -135,10 +135,7 @@ extern void cppInit (const bool state, const bool hasAtLiteralStrings, Cpp.directive.ifdef [0].branchChosen = false; Cpp.directive.ifdef [0].ignoring = false; - if (Cpp.directive.name == NULL) - Cpp.directive.name = vStringNew (); - else - vStringClear (Cpp.directive.name); + Cpp.directive.name = vStringNewOrClear (Cpp.directive.name); } extern void cppTerminate (void) @@ -305,35 +302,40 @@ static bool popConditional (void) return isIgnore (); } -static void makeDefineTag (const char *const name, bool parameterized) +static int makeDefineTag (const char *const name, bool parameterized, bool undef) { const bool isFileScope = (bool) (! isInputHeaderFile ()); - if (includingDefineTags () && - (! isFileScope || isXtagEnabled(XTAG_FILE_SCOPE))) + if (!Cpp.defineMacroKind) + return CORK_NIL; + if (isFileScope && !isXtagEnabled(XTAG_FILE_SCOPE)) + return CORK_NIL; + + if ( /* condition for definition tag */ + ((!undef) && Cpp.defineMacroKind->enabled) + || /* condition for reference tag */ + (undef && isXtagEnabled(XTAG_REFERENCE_TAGS))) { tagEntryInfo e; initTagEntry (&e, name, Cpp.defineMacroKind); - - e.lineNumberEntry = (bool) (Option.locate != EX_PATTERN); + e.lineNumberEntry = (bool) (Option.locate == EX_LINENUM); e.isFileScope = isFileScope; e.truncateLine = true; if (parameterized) - { - e.extensionFields.signature = cppGetArglistFromFilePos(getInputFilePosition() - , e.name); - } + e.extensionFields.signature = cppGetArglistFromFilePos(getInputFilePosition(), e.name); makeTagEntry (&e); if (parameterized) eFree((char *) e.extensionFields.signature); } + return CORK_NIL; } -static void directiveDefine (const int c) +static int directiveDefine (const int c, bool undef) { bool parameterized; int nc; + int r = CORK_NIL; if (cppIsident1 (c)) { @@ -342,9 +344,22 @@ static void directiveDefine (const int c) ungetcToInputFile (nc); parameterized = (bool) (nc == '('); if (! isIgnore ()) - makeDefineTag (vStringValue (Cpp.directive.name), parameterized); + makeDefineTag (vStringValue (Cpp.directive.name), parameterized, undef); } Cpp.directive.state = DRCTV_NONE; + return r; +} + +static void directiveUndef (const int c) +{ + if (isXtagEnabled (XTAG_REFERENCE_TAGS)) + { + directiveDefine (c, true); + } + else + { + Cpp.directive.state = DRCTV_NONE; + } } static void directivePragma (int c) @@ -362,7 +377,7 @@ static void directivePragma (int c) if (cppIsident1 (c)) { readIdentifier (c, Cpp.directive.name); - makeDefineTag (vStringValue (Cpp.directive.name), false); + makeDefineTag (vStringValue (Cpp.directive.name), NULL, false); } } } @@ -417,18 +432,20 @@ static bool directiveHash (const int c) /* Handles a pre-processor directive whose first character is given by "c". */ -static bool handleDirective (const int c) +static bool handleDirective (const int c, int *macroCorkIndex) { bool ignore = isIgnore (); switch (Cpp.directive.state) { case DRCTV_NONE: ignore = isIgnore (); break; - case DRCTV_DEFINE: directiveDefine (c); break; + case DRCTV_DEFINE: + *macroCorkIndex = directiveDefine (c, false); + break; case DRCTV_HASH: ignore = directiveHash (c); break; case DRCTV_IF: ignore = directiveIf (c); break; case DRCTV_PRAGMA: directivePragma (c); break; - case DRCTV_UNDEF: directiveDefine (c); break; + case DRCTV_UNDEF: directiveUndef (c); break; } return ignore; } @@ -612,13 +629,6 @@ static int skipToEndOfChar (void) ungetcToInputFile (c); break; } - else if (count == 1 && strchr ("DHOB", toupper (c)) != NULL) - veraBase = c; - else if (veraBase != '\0' && ! isalnum (c)) - { - ungetcToInputFile (c); - break; - } } return CHAR_SYMBOL; /* symbolic representation of character */ } @@ -633,6 +643,7 @@ extern int cppGetc (void) bool directive = false; bool ignore = false; int c; + int macroCorkIndex = CORK_NIL; if (Cpp.ungetch != '\0') { @@ -643,13 +654,15 @@ extern int cppGetc (void) } else do { +start_loop: c = getcFromInputFile (); process: switch (c) { case EOF: ignore = false; directive = false; + macroCorkIndex = CORK_NIL; break; case TAB: @@ -658,7 +671,10 @@ extern int cppGetc (void) case NEWLINE: if (directive && ! ignore) + { + macroCorkIndex = CORK_NIL; directive = false; + } Cpp.directive.accept = true; break; @@ -705,7 +721,7 @@ extern int cppGetc (void) int next = getcFromInputFile (); if (next == NEWLINE) - continue; + goto start_loop; else ungetcToInputFile (next); break; @@ -828,7 +844,7 @@ extern int cppGetc (void) enter: Cpp.directive.accept = false; if (directive) - ignore = handleDirective (c); + ignore = handleDirective (c, ¯oCorkIndex); break; } } while (directive || ignore); Modified: ctags/main/lcpp.h 34 lines changed, 30 insertions(+), 4 deletions(-) =================================================================== @@ -28,17 +28,43 @@ * VMS allows '$' in identifiers. * Vala allows '@' in identifiers. */ -#define cppIsident1(c) (isalpha(c) || (c) == '_' || (c) == '~' || (c) == '$' || (c) == '@') +#define cppIsident1(c) ( ((c >= 0) && (c < 0x80) && isalpha(c)) \ + || (c) == '_' || (c) == '~' || (c) == '$' || (c) == '@') +/* NOTE about isident1 profitability + + Doing the same as isascii before passing value to isalpha + ---------------------------------------------------------- + cppGetc() can return the value out of range of char. + cppGetc calls skipToEndOfString and skipToEndOfString can + return STRING_SYMBOL(== 338). + + Depending on the platform, isalpha(338) returns different value . + As far as Fedora22, it returns 0. On Windows 2010, it returns 1. + + man page on Fedora 22 says: + + These functions check whether c, which must have the value of an + unsigned char or EOF, falls into a certain character class + according to the specified locale. + + isascii is for suitable to verify the range of input. However, it + is not portable enough. */ + +#define RoleTemplateUndef { true, "undef", "undefined" } + +#define RoleTemplateSystem { true, "system", "system header" } +#define RoleTemplateLocal { true, "local", "local header" } /* * FUNCTION PROTOTYPES */ extern bool cppIsBraceFormat (void); extern unsigned int cppGetDirectiveNestLevel (void); -extern void cppInit (const bool state, const bool hasAtLiteralStrings, - const bool hasCxxRawLiteralStrings, - const kindOption *defineMacroKind); +extern void cppInit (const bool state, + const bool hasAtLiteralStrings, + const bool hasCxxRawLiteralStrings, + const kindOption *defineMacroKind); extern void cppTerminate (void); extern void cppBeginStatement (void); extern void cppEndStatement (void); Modified: ctags/parsers/c.c 7 lines changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -3138,11 +3138,16 @@ static bool findCTags (const unsigned int passCount) { exception_t exception; bool retry; + kindOption *kind_for_define = NULL; contextual_fake_count = 0; Assert (passCount < 3); - cppInit ((bool) (passCount > 1), isInputLanguage (Lang_csharp), isInputLanguage (Lang_cpp), &(CKinds [CK_DEFINE])); + + kind_for_define = CKinds+CK_DEFINE; + + cppInit ((bool) (passCount > 1), isInputLanguage (Lang_csharp), isInputLanguage(Lang_cpp), + kind_for_define); exception = (exception_t) setjmp (Exception); retry = false; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 2b8c7a: Sync the rest of routines.c/h
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: Sat, 08 Oct 2016 12:12:45 UTC Commit: 2b8c7ae5ad0f8875b45472c2bdad5e022e270601
https://github.com/geany/geany/commit/2b8c7ae5ad0f8875b45472c2bdad5e022e270…
Log Message: ----------- Sync the rest of routines.c/h Requires checking for errno.h limits.h in autoconf as there are ifdefs around those in routines.c. Modified Paths: -------------- configure.ac ctags/main/routines.c ctags/main/routines.h Modified: configure.ac 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -38,7 +38,7 @@ AC_PROG_LN_S # autoscan start # Checks for header files. -AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h stdlib.h sys/time.h]) +AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h stdlib.h sys/time.h errno.h limits.h]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_OFF_T Modified: ctags/main/routines.c 193 lines changed, 189 insertions(+), 4 deletions(-) =================================================================== @@ -12,8 +12,6 @@ */ #include "general.h" /* must always come first */ -#include <errno.h> - #ifdef HAVE_STDLIB_H # include <stdlib.h> /* to declare malloc (), realloc () */ #endif @@ -138,7 +136,10 @@ # if defined (_MSC_VER) # define stat _stat # define getcwd _getcwd +# define currentdrive() (_getdrive() + 'A' - 1) # define PATH_MAX _MAX_PATH +# else +# define currentdrive() 'C' # endif #endif @@ -150,8 +151,6 @@ * Miscellaneous macros */ -#define selected(var,feature) (((int)(var) & (int)(feature)) == (int)feature) - /* * DATA DEFINITIONS @@ -182,6 +181,11 @@ extern int lstat (const char *, struct stat *); * FUNCTION DEFINITIONS */ +extern void freeRoutineResources (void) +{ + if (CurrentDirectory != NULL) + eFree (CurrentDirectory); +} extern void setExecutableName (const char *const path) { @@ -194,6 +198,14 @@ extern const char *getExecutableName (void) return ExecutableName; } +extern const char *getExecutablePath (void) +{ + return ExecutableProgram; +} + +/* + * Memory allocation functions + */ extern void *eMalloc (const size_t size) { @@ -235,6 +247,37 @@ extern void eFree (void *const ptr) free (ptr); } +/* + * String manipulation functions + */ + +/* + * Compare two strings, ignoring case. + * Return 0 for match, < 0 for smaller, > 0 for bigger + * Make sure case is folded to uppercase in comparison (like for 'sort -f') + * This makes a difference when one of the chars lies between upper and lower + * ie. one of the chars [ \ ] ^ _ ` for ascii. (The '_' in particular !) + */ +extern int struppercmp (const char *s1, const char *s2) +{ + int result; + do + { + result = toupper ((int) *s1) - toupper ((int) *s2); + } while (result == 0 && *s1++ != '\0' && *s2++ != '\0'); + return result; +} + +extern int strnuppercmp (const char *s1, const char *s2, size_t n) +{ + int result; + do + { + result = toupper ((int) *s1) - toupper ((int) *s2); + } while (result == 0 && --n > 0 && *s1++ != '\0' && *s2++ != '\0'); + return result; +} + #ifndef HAVE_STRSTR extern char* strstr (const char *str, const char *substr) { @@ -248,13 +291,32 @@ extern char* strstr (const char *str, const char *substr) } #endif +extern char* strrstr (const char *str, const char *substr) +{ + const size_t length = strlen (substr); + const char *p; + + for (p = str + strlen(str) - length ; p >= str ; --p) + if (strncmp (p, substr, length) == 0) + return (char*) p; + return NULL; +} + extern char* eStrdup (const char* str) { char* result = xMalloc (strlen (str) + 1, char); strcpy (result, str); return result; } +extern char* eStrndup (const char* str, size_t len) +{ + char* result = xMalloc (len + 1, char); + memset(result, 0, len + 1); + strncpy (result, str, len); + return result; +} + extern void toLowerString (char* str) { while (*str != '\0') @@ -297,6 +359,76 @@ extern char* newUpperString (const char* str) return result; } +/* Safe wrapper for strtoul + * + * The conversion result is placed in value and must only be used if the + * function returned true. + */ +extern bool strToULong(const char *const str, int base, unsigned long *value) +{ + char *endptr; + + errno = 0; + *value = strtoul (str, &endptr, base); + return *endptr == '\0' && str != endptr && errno == 0; +} + +/* Safe wrapper for strtol/atol + * + * The conversion result is placed in value and must only be used if the + * function returned true. + */ +extern bool strToLong(const char *const str, int base, long *value) +{ + char *endptr; + + errno = 0; + *value = strtol (str, &endptr, base); + return *endptr == '\0' && str != endptr && errno == 0; +} + +extern bool strToUInt(const char *const str, int base, unsigned int *value) +{ + unsigned long ulong_value; + + if(!strToULong(str, base, &ulong_value) || ulong_value > UINT_MAX) + return false; + + *value = (unsigned int) ulong_value; + return true; +} + +extern bool strToInt(const char *const str, int base, int *value) +{ + long long_value; + + if(!strToLong(str, base, &long_value) || long_value > INT_MAX || long_value < INT_MIN) + return false; + + *value = (int) long_value; + return true; +} + +/* + * File system functions + */ + +extern void setCurrentDirectory (void) +{ + char* buf; + if (CurrentDirectory == NULL) + CurrentDirectory = xMalloc ((size_t) (PATH_MAX + 1), char); + buf = getcwd (CurrentDirectory, PATH_MAX); + if (buf == NULL) + perror (""); + if (CurrentDirectory [strlen (CurrentDirectory) - (size_t) 1] != + PATH_SEPARATOR) + { + sprintf (CurrentDirectory + strlen (CurrentDirectory), "%c", + OUTPUT_PATH_SEPARATOR); + } +} + /* For caching of stat() calls */ extern fileStatus *eStat (const char *const fileName) { @@ -344,6 +476,12 @@ extern bool doesFileExist (const char *const fileName) return status->exists; } +extern bool doesExecutableExist (const char *const fileName) +{ + fileStatus *status = eStat (fileName); + return status->exists && status->isExecutable; +} + extern bool isRecursiveLink (const char* const dirName) { bool result = false; @@ -434,10 +572,26 @@ extern const char *baseFilename (const char *const filePath) */ for (i = 0 ; i < strlen (PathDelimiters) ; ++i) { +# ifdef HAVE_MBLEN + const char *p; + int ml; + + /* Some DBCS has letter contains 0x5C in trailing byte. + * So skip to the trailing byte. */ + for (p = filePath ; *p != '\0' ; ++p) + { + ml = mblen(p, MB_LEN_MAX); + if (ml > 1) + p += ml - 1; + else if (*p == PathDelimiters [i] && p > tail) + tail = p; + } +# else const char *sep = strrchr (filePath, PathDelimiters [i]); if (sep > tail) tail = sep; +# endif } #else const char *tail = strrchr (filePath, PATH_SEPARATOR); @@ -466,6 +620,24 @@ extern const char *fileExtension (const char *const fileName) return extension; } +extern char* baseFilenameSansExtensionNew (const char *const fileName, + const char *const templateExt) +{ + const char *pDelimiter = NULL; + const char *const base = baseFilename (fileName); + char* shorten_base; + + pDelimiter = strrchr (base, templateExt[0]); + + if (pDelimiter && (strcmp (pDelimiter, templateExt) == 0)) + { + shorten_base = eStrndup (base, pDelimiter - base); + return shorten_base; + } + else + return NULL; +} + extern bool isAbsolutePath (const char *const path) { bool result = false; @@ -531,7 +703,20 @@ extern char* absoluteFilename (const char *file) char *slashp, *cp; char *res = NULL; if (isAbsolutePath (file)) + { +#ifdef MSDOS_STYLE_PATH + if (file [1] == ':') + res = eStrdup (file); + else + { + char drive [3]; + sprintf (drive, "%c:", currentdrive ()); + res = concat (drive, file, ""); + } +#else res = eStrdup (file); +#endif + } else res = concat (CurrentDirectory, file, ""); Modified: ctags/main/routines.h 17 lines changed, 17 insertions(+), 0 deletions(-) =================================================================== @@ -26,6 +26,7 @@ #define xRealloc(p,n,Type) (Type *)eRealloc((p), (n) * sizeof (Type)) #define ARRAY_SIZE(X) (sizeof (X) / sizeof (X[0])) +#define ARRAY_AND_SIZE(X) (X), ARRAY_SIZE(X) #define STRINGIFY(X) STRINGIFY_(X) #define STRINGIFY_(X) #X @@ -89,8 +90,10 @@ typedef struct { /* * FUNCTION PROTOTYPES */ +extern void freeRoutineResources (void); extern void setExecutableName (const char *const path); extern const char *getExecutableName (void); +extern const char *getExecutablePath (void); extern void error (const errorSelection selection, const char *const format, ...) CTAGS_ATTR_PRINTF (2, 3); /* Memory allocation functions */ @@ -102,19 +105,31 @@ extern void *eMalloc (const size_t size); extern void *eCalloc (const size_t count, const size_t size); extern void *eRealloc (void *const ptr, const size_t size); extern void eFree (void *const ptr); + +/* String manipulation functions */ +extern int struppercmp (const char *s1, const char *s2); +extern int strnuppercmp (const char *s1, const char *s2, size_t n); #ifndef HAVE_STRSTR extern char* strstr (const char *str, const char *substr); #endif +extern char* strrstr (const char *str, const char *substr); extern char* eStrdup (const char* str); +extern char* eStrndup (const char* str, size_t len); extern void toLowerString (char* str); extern void toUpperString (char* str); extern char* newLowerString (const char* str); extern char* newUpperString (const char* str); +extern bool strToUInt(const char *const str, int base, unsigned int *value); +extern bool strToULong(const char *string, int base, unsigned long *value); +extern bool strToInt(const char *const str, int base, int *value); +extern bool strToLong(const char *string, int base, long *value); /* File system functions */ +extern void setCurrentDirectory (void); extern fileStatus *eStat (const char *const fileName); extern void eStatFree (fileStatus *status); extern bool doesFileExist (const char *const fileName); +extern bool doesExecutableExist (const char *const fileName); extern bool isRecursiveLink (const char* const dirName); extern bool isSameFile (const char *const name1, const char *const name2); extern const char *baseFilename (const char *const filePath); @@ -126,4 +141,6 @@ extern char* absoluteDirname (char *file); extern char* relativeFilename (const char *file, const char *dir); extern MIO *tempFile (const char *const mode, char **const pName); +extern char* baseFilenameSansExtensionNew (const char *const fileName, const char *const templateExt); + #endif /* CTAGS_MAIN_ROUTINES_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] 848fa0: Move eTagFile from entry.h to entry.c
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: Sun, 09 Oct 2016 09:56:49 UTC Commit: 848fa0dce3c95d8cdd767875e08d13e16d4121e6
https://github.com/geany/geany/commit/848fa0dce3c95d8cdd767875e08d13e16d412…
Log Message: ----------- Move eTagFile from entry.h to entry.c Add access functions and use them outside entry.c. In addition to functions defined in uctags setMaxTagsLine() had to be added because it is needed in parser.c (at the moment, will be probably gone in some of the next commits). Modified Paths: -------------- ctags/main/entry.c ctags/main/entry.h ctags/main/parse.c ctags/main/read.c Modified: ctags/main/entry.c 62 lines changed, 62 insertions(+), 0 deletions(-) =================================================================== @@ -68,6 +68,23 @@ # define O_RDWR _O_RDWR #endif + +/* Maintains the state of the tag file. + */ +typedef struct eTagFile { + char *name; + char *directory; + MIO *mio; + struct sNumTags { unsigned long added, prev; } numTags; + struct sMax { size_t line, tag, file; } max; +/* struct sEtags { + char *name; + MIO *mio; + size_t byteCount; + } etags;*/ + vString *vLine; +} tagFile; + /* * DATA DEFINITIONS */ @@ -422,3 +439,48 @@ extern void setTagWriter (tagWriter *t) { /* writer = t; */ } + +extern unsigned long numTagsAdded(void) +{ + return TagFile.numTags.added; +} + +extern void setNumTagsAdded (unsigned long nadded) +{ + TagFile.numTags.added = nadded; +} + +extern unsigned long numTagsTotal(void) +{ + return TagFile.numTags.added + TagFile.numTags.prev; +} + +extern unsigned long maxTagsLine (void) +{ + return (unsigned long)TagFile.max.line; +} + +extern void setMaxTagsLine (unsigned long max) +{ + TagFile.max.line = max; +} + +extern void invalidatePatternCache(void) +{ +/* TagFile.patternCacheValid = false; */ +} + +extern void tagFilePosition (MIOPos *p) +{ + mio_getpos (TagFile.mio, p); +} + +extern void setTagFilePosition (MIOPos *p) +{ + mio_setpos (TagFile.mio, p); +} + +extern const char* getTagFileDirectory (void) +{ + return TagFile.directory; +} Modified: ctags/main/entry.h 35 lines changed, 12 insertions(+), 23 deletions(-) =================================================================== @@ -36,28 +36,6 @@ typedef struct sTagField { const char* value; } tagField; -/* Maintains the state of the tag file. - */ -typedef struct eTagFile { - char *name; - char *directory; - MIO *mio; - struct sNumTags { unsigned long added, prev; } numTags; - struct sMax { size_t line, tag, file; } max; -/* struct sEtags { - char *name; - MIO *mio; - size_t byteCount; - } etags;*/ - vString *vLine; -} tagFile; - -typedef struct sTagFields { - unsigned int count; /* number of additional extension flags */ - const char *const *label; /* list of labels for extension flags */ - const char *const *value; /* list of values for extension flags */ -} tagFields; - /* Information about the current tag candidate. */ struct sTagEntryInfo { @@ -88,7 +66,6 @@ struct sTagEntryInfo { /* * GLOBAL VARIABLES */ -extern tagFile TagFile; /* * FUNCTION PROTOTYPES @@ -102,4 +79,16 @@ extern void closeTagFile (const bool resize); extern void makeTagEntry (const tagEntryInfo *const tag); extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind); +extern unsigned long numTagsAdded(void); +extern void setNumTagsAdded (unsigned long nadded); +extern unsigned long numTagsTotal(void); +extern unsigned long maxTagsLine(void); +extern void setMaxTagsLine (unsigned long max); +extern void invalidatePatternCache(void); +extern void tagFilePosition (MIOPos *p); +extern void setTagFilePosition (MIOPos *p); +extern const char* getTagFileDirectory (void); +extern void getTagScopeInformation (tagEntryInfo *const tag, + const char **kind, const char **name); + #endif /* CTAGS_MAIN_ENTRY_H */ Modified: ctags/main/parse.c 10 lines changed, 5 insertions(+), 5 deletions(-) =================================================================== @@ -609,18 +609,18 @@ static bool createTagsForFile (const char *const fileName, static bool createTagsWithFallback (const char *const fileName, const langType language) { - const unsigned long numTags = TagFile.numTags.added; - MIOPos tagFilePosition; + const unsigned long numTags = numTagsAdded (); + MIOPos filePosition; unsigned int passCount = 0; bool tagFileResized = false; - mio_getpos (TagFile.mio, &tagFilePosition); + tagFilePosition (&filePosition); while (createTagsForFile (fileName, language, ++passCount)) { /* Restore prior state of tag file. */ - mio_setpos (TagFile.mio, &tagFilePosition); - TagFile.numTags.added = numTags; + setTagFilePosition (&filePosition); + setNumTagsAdded (numTags); tagFileResized = true; } return tagFileResized; Modified: ctags/main/read.c 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -88,10 +88,10 @@ static void setSourceFileParameters (vString *const fileName, const langType lan else File.source.tagPath = vStringNewOwn (relativeFilename (vStringValue (fileName), - TagFile.directory)); + getTagFileDirectory ())); - if (vStringLength (fileName) > TagFile.max.file) - TagFile.max.file = vStringLength (fileName); + if (vStringLength (fileName) > maxTagsLine ()) + setMaxTagsLine (vStringLength (fileName)); File.source.isHeader = isIncludeFile (vStringValue (fileName)); File.input.isHeader = File.source.isHeader; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 1a43ee: Grab uctags kind.c/h
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: Sat, 08 Oct 2016 15:38:31 UTC Commit: 1a43ee2afa2cbecd497554aa3c07163ea5dabd01
https://github.com/geany/geany/commit/1a43ee2afa2cbecd497554aa3c07163ea5dab…
Log Message: ----------- Grab uctags kind.c/h Modified Paths: -------------- ctags/main/kind.c ctags/main/kind.h Modified: ctags/main/kind.c 158 lines changed, 158 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,158 @@ +/* + * + * Copyright (c) 2015, Red Hat, Inc. + * Copyright (c) 2015, 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 <stdio.h> +#include "debug.h" +#include "kind.h" +#include "parse.h" + +extern void printRole (const roleDesc* const role) +{ + if (role) + printf ("%s\t%s\t%s\n", role->name, role->description, role->enabled? "on": "off"); +} + +extern const char *renderRole (const roleDesc* const role, vString* b) +{ + vStringCatS (b, role->name); + return vStringValue (b); +} + +#define PR_KIND_WIDTH_LETTER 7 +#define PR_KIND_WIDTH_NAME 15 +#define PR_KIND_WIDTH_DESCRIPTION 30 +#define PR_KIND_WIDTH_ENABLED 8 +#define PR_KIND_WIDTH_REFONLY 7 +#define PR_KIND_WIDTH_NROLE 6 +#define PR_KIND_WIDTH_MASTER 10 +#define MAKE_KIND_FMT(PREFIX,LETTER_SPEC,NROLL_SPEC) \ + PREFIX \ + PR_KIND_FMT (LETTER,LETTER_SPEC) \ + " " \ + PR_KIND_FMT (NAME,s) \ + " " \ + PR_KIND_FMT (ENABLED,s) \ + " " \ + PR_KIND_FMT (REFONLY,s) \ + " " \ + PR_KIND_FMT (NROLE,NROLL_SPEC) \ + " " \ + PR_KIND_FMT (MASTER,s) \ + " " \ + PR_KIND_FMT (DESCRIPTION,s) \ + "\n" + +extern void printKindListHeader (bool indent, bool tabSeparated) +{ +#define KIND_HEADER_COMMON_FMT MAKE_KIND_FMT("%s", s, s) + + const char *fmt = tabSeparated + ? "%s%s%s\t%s\t%s\t%s\t%s\t%s\t%s\n" + : (indent + ? PR_KIND_FMT (LANG,s) KIND_HEADER_COMMON_FMT + : "%s" KIND_HEADER_COMMON_FMT) + ; + + printf (fmt, + (indent? "#PARSER": ""), + (indent? (tabSeparated? "\t": " "): ""), + (indent? "LETTER": "#LETTER"), + "NAME", + "ENABLED", + "REFONLY", + "NROLES", + "MASTER", + "DESCRIPTION"); + +#undef KIND_HEADER_COMMON_FMT +} + +extern void printKind (const kindOption* const kind, bool allKindFields, bool indent, + bool tabSeparated) +{ +#define KIND_FMT MAKE_KIND_FMT("", c, d) + + if (allKindFields) + { + printf ((tabSeparated + ?"%s%c\t%s\t%s\t%s\t%d\t%s\t%s\n" + :"%s" KIND_FMT), + (indent? (tabSeparated? "\t": " "): ""), + kind->letter, + kind->name != NULL ? kind->name : "", + kind->enabled ? "on" : "off", + kind->referenceOnly ? "TRUE" : "FALSE", + kind->nRoles, + (kind->master + || kind->slave ) ? getLanguageName (kind->syncWith): "", + kind->description != NULL ? kind->description : ""); + } + else if (!kind->referenceOnly) + { + printf ("%s%c %s%s\n", indent ? " " : "", kind->letter, + kind->description != NULL ? kind->description : + (kind->name != NULL ? kind->name : ""), + kind->enabled ? "" : " [off]"); + } + +#undef KIND_FMT +} + +const char *scopeSeparatorFor (const kindOption *kind, char parentLetter) +{ + scopeSeparator *table; + Assert (kind); + table = kind->separators; + + /* If no table is given, use the default generic separator ".". + The exception is if a root separator is looked up. In this case, + return NULL to notify there is no root separator to the caller. */ + + if (table == NULL) + { + if (parentLetter == KIND_NULL) + return NULL; + else + return "."; + } + + while (table - kind->separators < kind->separatorCount) + { + /* KIND_WILDCARD cannot be used as a key for finding + a root separator.*/ + if ( (table->parentLetter == KIND_WILDCARD + && parentLetter != KIND_NULL) + || table->parentLetter == parentLetter) + return table->separator; + table++; + } + if (parentLetter == KIND_NULL) + return NULL; + else + return "."; +} + +extern void enableKind (kindOption *kind, bool enable) +{ + kindOption *slave; + + if (kind->master) + enableKind (kind->master, enable); + else + { + kind->enabled = enable; + for (slave = kind->slave; slave; slave = slave->slave) + slave->enabled = enable; + } +} Modified: ctags/main/kind.h 69 lines changed, 68 insertions(+), 1 deletions(-) =================================================================== @@ -9,19 +9,86 @@ #define CTAGS_MAIN_KIND_H #include "general.h" +#include "types.h" +#include "routines.h" /* for STRINGIFY */ +#include "vstring.h" + +typedef struct sRoleDesc { + bool enabled; + const char* name; /* role name */ + const char* description; /* displayed in --help output */ +} roleDesc; + +extern void printRole (const roleDesc* const role); /* for --help */ +extern const char *renderRole (const roleDesc* const role, vString* b); + +/* + * Predefined kinds + */ +#define KIND_REGEX_DEFAULT 'r' +#define KIND_REGEX_DEFAULT_LONG "regex" +/* We treat ' ' as a ghost kind. + It will never be listed up in --list-kinds. */ #define KIND_NULL '\0' -#define KIND_FILE_ALT '!' +#define KIND_GHOST ' ' +#define KIND_GHOST_LONG "ghost" #define KIND_FILE_DEFAULT 'F' #define KIND_FILE_DEFAULT_LONG "file" +#define KIND_FILE_ALT '!' + +#define KIND_GENERIC_REFERENCE '@' +#define KIND_GENERIC_REFERENCE_DEFAULT_LONG "reference" + +#define KIND_WILDCARD '*' + +typedef struct sScopeSeparator { + char parentLetter; + const char *separator; +} scopeSeparator; + struct sKindOption { bool enabled; /* are tags for kind enabled? */ char letter; /* kind letter */ const char* name; /* kind name */ const char* description; /* displayed in --help output */ + bool referenceOnly; + int nRoles; /* The number of role elements. */ + roleDesc *roles; + scopeSeparator *separators; + unsigned int separatorCount; + + /* Usage of `syncWith' field is a bit tricky. + + If `LANG_AUTO' is specified to `syncWith' field of a kind + (target kind), the main part of ctags updtes the field with + the id of a parser (master parser) when initializing + parsers. It also updates `slave' and `master' fields. + + If the value other than `LANG_AUTO' is specified, + the main part does nothing. */ + langType syncWith; + kindOption *slave; + kindOption *master; }; +#define ATTACH_ROLES(RS) .nRoles = ARRAY_SIZE(RS), .roles = RS +#define ATTACH_SEPARATORS(S) .separators = S, .separatorCount = ARRAY_SIZE(S) + +/* The value of `tabSeparated' is meaningfull only when `allKindFields' is true. */ +extern void printKind (const kindOption* const kind, bool allKindFields, bool indent, + bool tabSeparated); +extern void printKindListHeader (bool indent, bool tabSeparated); +extern const char *scopeSeparatorFor (const kindOption *kind, char parentLetter); + +extern void enableKind (kindOption *kind, bool enable); + +#define PR_KIND_STR(X) PR_KIND_WIDTH_##X +#define PR_KIND_FMT(X,T) "%-" STRINGIFY(PR_KIND_STR(X)) STRINGIFY(T) + +#define PR_KIND_WIDTH_LANG 15 + #endif /* CTAGS_MAIN_KIND_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] f1dbf2: Grab ctags implementation of sort.c/h
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: Sat, 08 Oct 2016 12:13:41 UTC Commit: f1dbf2cb7b4b5695a3f735c4819b35c3254f3493
https://github.com/geany/geany/commit/f1dbf2cb7b4b5695a3f735c4819b35c3254f3…
Log Message: ----------- Grab ctags implementation of sort.c/h I haven't studies the changes much but this file is responsible for sorting tag files which isn't interesing for us. Modified Paths: -------------- ctags/main/options.h ctags/main/sort.c ctags/main/sort.h Modified: ctags/main/options.h 5 lines changed, 5 insertions(+), 0 deletions(-) =================================================================== @@ -31,6 +31,11 @@ * DATA DECLARATIONS */ +typedef enum sortType { + SO_UNSORTED, + SO_SORTED, + SO_FOLDSORTED +} sortType; /* This stores the command line options. */ Modified: ctags/main/sort.c 105 lines changed, 66 insertions(+), 39 deletions(-) =================================================================== @@ -12,39 +12,38 @@ */ #include "general.h" /* must always come first */ +#if defined (HAVE_IO_H) +# include <io.h> +#endif #if defined (HAVE_STDLIB_H) # include <stdlib.h> /* to declare malloc () */ #endif +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif #include <string.h> #include <stdio.h> #include "debug.h" #include "entry.h" -#include "routines.h" #include "options.h" #include "read.h" +#include "routines.h" #include "sort.h" -#ifdef TRAP_MEMORY_CALLS -# include "safe_malloc.h" -#endif - /* * FUNCTION DEFINITIONS */ -extern void catFile (const char *const name) +extern void catFile (MIO *mio) { - FILE *const fp = fopen (name, "r"); - - if (fp != NULL) + if (mio != NULL) { int c; - - while ((c = getc (fp)) != EOF) + mio_seek (mio, 0, SEEK_SET); + while ((c = mio_getc (mio)) != EOF) putchar (c); fflush (stdout); - fclose (fp); } } @@ -56,9 +55,12 @@ extern void catFile (const char *const name) # define PE_CONST const #endif -extern void externalSortTags (const bool toStdout) +extern void externalSortTags (const bool toStdout, MIO *tagFile) { - const char *const sortCommand = "sort -u -o"; + const char *const sortNormalCommand = "sort -u"; + const char *const sortFoldedCommand = "sort -u -f"; + const char *sortCommand = + Option.sorted == SO_FOLDSORTED ? sortFoldedCommand : sortNormalCommand; PE_CONST char *const sortOrder1 = "LC_COLLATE=C"; PE_CONST char *const sortOrder2 = "LC_ALL=C"; const size_t length = 4 + strlen (sortOrder1) + strlen (sortOrder2) + @@ -70,29 +72,51 @@ extern void externalSortTags (const bool toStdout) { /* Ensure ASCII value sort order. */ -#ifdef HAVE_SETENV +#if defined (HAVE_SETENV) || defined (HAVE_PUTENV) +# ifdef HAVE_SETENV setenv ("LC_COLLATE", "C", 1); setenv ("LC_ALL", "C", 1); - sprintf (cmd, "%s %s %s", sortCommand, tagFileName (), tagFileName ()); -#else -# ifdef HAVE_PUTENV +# else putenv (sortOrder1); putenv (sortOrder2); - sprintf (cmd, "%s %s %s", sortCommand, tagFileName (), tagFileName ()); -# else - sprintf (cmd, "%s %s %s %s %s", sortOrder1, sortOrder2, sortCommand, - tagFileName (), tagFileName ()); # endif + if (toStdout) + sprintf (cmd, "%s", sortCommand); + else + sprintf (cmd, "%s -o %s %s", sortCommand, + tagFileName (), tagFileName ()); +#else + if (toStdout) + sprintf (cmd, "%s %s %s", sortOrder1, sortOrder2, sortCommand); + else + sprintf (cmd, "%s %s %s -o %s %s", sortOrder1, sortOrder2, + sortCommand, tagFileName (), tagFileName ()); #endif verbose ("system (\"%s\")\n", cmd); - ret = system (cmd); + if (toStdout) + { + const int fdstdin = 0; + int fdsave; + + fdsave = dup (fdstdin); + if (fdsave < 0) + error (FATAL | PERROR, "cannot save stdin fd"); + if (dup2 (fileno (mio_file_get_fp (tagFile)), fdstdin) < 0) + error (FATAL | PERROR, "cannot redirect stdin"); + if (lseek (fdstdin, 0, SEEK_SET) != 0) + error (FATAL | PERROR, "cannot rewind tag file"); + ret = system (cmd); + if (dup2 (fdsave, fdstdin) < 0) + error (FATAL | PERROR, "cannot restore stdin fd"); + close (fdsave); + } + else + ret = system (cmd); free (cmd); } if (ret != 0) error (FATAL | PERROR, "cannot sort tag file"); - else if (toStdout) - catFile (tagFileName ()); } #else @@ -103,7 +127,7 @@ extern void externalSortTags (const bool toStdout) * so have lots of memory if you have large tag files. */ -static void failedSort (MIO *const mio, const char* msg) +extern void failedSort (MIO *const mio, const char* msg) { const char* const cannotSort = "cannot sort tag file"; if (mio != NULL) @@ -114,6 +138,14 @@ static void failedSort (MIO *const mio, const char* msg) error (FATAL, "%s: %s", msg, cannotSort); } +static int compareTagsFolded(const void *const one, const void *const two) +{ + const char *const line1 = *(const char* const*) one; + const char *const line2 = *(const char* const*) two; + + return struppercmp (line1, line2); +} + static int compareTags (const void *const one, const void *const two) { const char *const line1 = *(const char* const*) one; @@ -148,32 +180,28 @@ static void writeSortedTags ( failedSort (mio, NULL); } if (toStdout) - fflush (mio_file_get_fp (mio)); + mio_flush (mio); mio_free (mio); } -extern void internalSortTags (const bool toStdout) +extern void internalSortTags (const bool toStdout, MIO* mio, size_t numTags) { vString *vLine = vStringNew (); - MIO *mio = NULL; const char *line; size_t i; + int (*cmpFunc)(const void *, const void *); /* Allocate a table of line pointers to be sorted. */ - size_t numTags = TagFile.numTags.added + TagFile.numTags.prev; const size_t tableSize = numTags * sizeof (char *); - char **const table = (char **) malloc (tableSize); /* line pointers */ - DebugStatement ( size_t mallocSize = tableSize; ) /* cumulative total */ + char **const table = (char **) malloc (tableSize); /* line pointers */ + DebugStatement ( size_t mallocSize = tableSize; ) /* cumulative total */ + + cmpFunc = Option.sorted == SO_FOLDSORTED ? compareTagsFolded : compareTags; if (table == NULL) failedSort (mio, "out of memory"); - /* Open the tag file and place its lines into allocated buffers. - */ - mio = mio_new_file (tagFileName (), "r"); - if (mio == NULL) - failedSort (mio, NULL); for (i = 0 ; i < numTags && ! mio_eof (mio) ; ) { line = readLineRaw (vLine, mio); @@ -198,12 +226,11 @@ extern void internalSortTags (const bool toStdout) } } numTags = i; - mio_free (mio); vStringDelete (vLine); /* Sort the lines. */ - qsort (table, numTags, sizeof (*table), compareTags); + qsort (table, numTags, sizeof (*table), cmpFunc); writeSortedTags (table, numTags, toStdout); Modified: ctags/main/sort.h 15 lines changed, 12 insertions(+), 3 deletions(-) =================================================================== @@ -14,15 +14,24 @@ */ #include "general.h" /* must always come first */ +#include <stdio.h> + +#include "mio.h" + /* * FUNCTION PROTOTYPES */ -extern void catFile (const char *const name); +extern void catFile (MIO *mio); #ifdef EXTERNAL_SORT -extern void externalSortTags (const bool toStdout); +extern void externalSortTags (const bool toStdout, MIO *tagFile); #else -extern void internalSortTags (const bool toStdout); +extern void internalSortTags (const bool toStdout, + MIO *mio, + size_t numTags); #endif +/* mio is closed in this function. */ +extern void failedSort (MIO *const mio, const char* msg); + #endif /* CTAGS_MAIN_SORT_H */ -------------- 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
6
7
...
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