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] f0e7af: Make combinePathAndFile() return char * instead of vString
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: f0e7af2c3279cd8ced9806050f38629c930502f3
https://github.com/geany/geany/commit/f0e7af2c3279cd8ced9806050f38629c93050…
Log Message: ----------- Make combinePathAndFile() return char * instead of vString Also move eStrdup() to the correct position in the header. In addition add the same includes into debug.h as those in uctags (the removal of vstring inclusion inside routines.h causes compilation errors - it would be best to explicitly include all needed files in every source to avoid problems like this but let's do just syncing the two implementations for now). Modified Paths: -------------- ctags/main/debug.h ctags/main/read.c ctags/main/routines.c ctags/main/routines.h Modified: ctags/main/debug.h 22 lines changed, 22 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,22 @@ +/* +* Copyright (c) 1998-2002, 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. +* +* External interface to debug.c +*/ +#ifndef CTAGS_MAIN_DEBUG_H +#define CTAGS_MAIN_DEBUG_H + +/* +* Include files +*/ +#include "general.h" /* must always come first */ + +#ifdef DEBUG +# include <assert.h> +#endif +#include "entry.h" + +#endif /* CTAGS_MAIN_DEBUG_H */ Modified: ctags/main/read.c 7 lines changed, 5 insertions(+), 2 deletions(-) =================================================================== @@ -112,8 +112,11 @@ static bool setSourceFileName (vString *const fileName) if (isAbsolutePath (vStringValue (fileName)) || File.path == NULL) pathName = vStringNewCopy (fileName); else - pathName = combinePathAndFile (vStringValue (File.path), - vStringValue (fileName)); + { + char *tmp = combinePathAndFile ( + vStringValue (File.path), vStringValue (fileName)); + pathName = vStringNewOwn (tmp); + } setSourceFileParameters (pathName, -1); result = true; } Modified: ctags/main/routines.c 12 lines changed, 4 insertions(+), 8 deletions(-) =================================================================== @@ -490,23 +490,19 @@ extern bool isAbsolutePath (const char *const path) return result; } -extern vString *combinePathAndFile (const char *const path, - const char *const file) +extern char *combinePathAndFile ( + const char *const path, const char *const file) { vString *const filePath = vStringNew (); const int lastChar = path [strlen (path) - 1]; -# ifdef MSDOS_STYLE_PATH - bool terminated = (bool) (strchr (PathDelimiters, lastChar) != NULL); -# else - bool terminated = (bool) (lastChar == PATH_SEPARATOR); -# endif + bool terminated = isPathSeparator (lastChar); vStringCopyS (filePath, path); if (! terminated) vStringPut (filePath, OUTPUT_PATH_SEPARATOR); vStringCatS (filePath, file); - return filePath; + return vStringDeleteUnwrap (filePath); } /* Return a newly-allocated string whose contents concatenate those of Modified: ctags/main/routines.h 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -16,7 +16,6 @@ #include <stdio.h> -#include "vstring.h" #include "mio.h" /* @@ -106,6 +105,7 @@ extern void eFree (void *const ptr); #ifndef HAVE_STRSTR extern char* strstr (const char *str, const char *substr); #endif +extern char* eStrdup (const char* str); extern void toLowerString (char* str); extern void toUpperString (char* str); extern char* newLowerString (const char* str); @@ -120,11 +120,10 @@ extern bool isSameFile (const char *const name1, const char *const name2); extern const char *baseFilename (const char *const filePath); extern const char *fileExtension (const char *const fileName); extern bool isAbsolutePath (const char *const path); -extern vString *combinePathAndFile (const char *const path, const char *const file); +extern char *combinePathAndFile (const char *const path, const char *const file); extern char* absoluteFilename (const char *file); 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* eStrdup (const char* str); #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] 9e7ead: Use parse separator utilities in routines.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: Sat, 08 Oct 2016 12:12:45 UTC Commit: 9e7eade7c068d62dd37046cff3e168d317b3e554
https://github.com/geany/geany/commit/9e7eade7c068d62dd37046cff3e168d317b3e…
Log Message: ----------- Use parse separator utilities in routines.c Modified Paths: -------------- ctags/main/routines.c Modified: ctags/main/routines.c 35 lines changed, 15 insertions(+), 20 deletions(-) =================================================================== @@ -461,7 +461,7 @@ extern const char *fileExtension (const char *const fileName) if (pDelimiter == NULL) extension = ""; else - extension = pDelimiter + 1; /* skip to first char of extension */ + extension = pDelimiter + 1; /* skip to first char of extension */ return extension; } @@ -470,11 +470,11 @@ extern bool isAbsolutePath (const char *const path) { bool result = false; #if defined (MSDOS_STYLE_PATH) - if (strchr (PathDelimiters, path [0]) != NULL) + if (isPathSeparator (path [0])) result = true; else if (isalpha (path [0]) && path [1] == ':') { - if (strchr (PathDelimiters, path [2]) != NULL) + if (isPathSeparator (path [2])) result = true; else /* We don't support non-absolute file names with a drive @@ -485,7 +485,7 @@ extern bool isAbsolutePath (const char *const path) path); } #else - result = (bool) (path [0] == PATH_SEPARATOR); + result = isPathSeparator (path [0]); #endif return result; } @@ -536,12 +536,13 @@ extern char* absoluteFilename (const char *file) res = concat (CurrentDirectory, file, ""); /* Delete the "/dirname/.." and "/." substrings. */ - slashp = strchr (res, '/'); + slashp = strchr (res, PATH_SEPARATOR); while (slashp != NULL && slashp [0] != '\0') { if (slashp[1] == '.') { - if (slashp [2] == '.' && (slashp [3] == '/' || slashp [3] == '\0')) + if (slashp [2] == '.' && + (slashp [3] == PATH_SEPARATOR || slashp [3] == '\0')) { cp = slashp; do @@ -554,20 +555,20 @@ extern char* absoluteFilename (const char *file) * so the luser could say `d:/../NAME'. We silently treat this * as `d:/NAME'. */ - else if (cp [0] != '/') + else if (cp [0] != PATH_SEPARATOR) cp = slashp; #endif memmove (cp, slashp + 3, strlen (slashp + 3) + 1); slashp = cp; continue; } - else if (slashp [2] == '/' || slashp [2] == '\0') + else if (slashp [2] == PATH_SEPARATOR || slashp [2] == '\0') { memmove (slashp, slashp + 2, strlen (slashp + 2) + 1); continue; } } - slashp = strchr (slashp + 1, '/'); + slashp = strchr (slashp + 1, PATH_SEPARATOR); } if (res [0] == '\0') @@ -585,20 +586,14 @@ extern char* absoluteFilename (const char *file) } /* Return a newly allocated string containing the absolute file name of dir - * where FILE resides given CWD (which should end with a slash). + * where `file' resides given `CurrentDirectory'. * Routine adapted from Gnu etags. */ extern char* absoluteDirname (char *file) { char *slashp, *res; char save; -#ifdef MSDOS_STYLE_PATH - char *p; - for (p = file ; *p != '\0' ; p++) - if (*p == '\\') - *p = '/'; -#endif - slashp = strrchr (file, '/'); + slashp = strrchr (file, PATH_SEPARATOR); if (slashp == NULL) res = eStrdup (CurrentDirectory); else @@ -630,17 +625,17 @@ extern char* relativeFilename (const char *file, const char *dir) fp--; dp--; /* back to the first differing char */ do - { /* look at the equal chars until '/' */ + { /* look at the equal chars until path sep */ if (fp == absdir) return absdir; /* first char differs, give up */ fp--; dp--; - } while (*fp != '/'); + } while (*fp != PATH_SEPARATOR); /* Build a sequence of "../" strings for the resulting relative file name. */ i = 0; - while ((dp = strchr (dp + 1, '/')) != NULL) + while ((dp = strchr (dp + 1, PATH_SEPARATOR)) != NULL) i += 1; res = xMalloc (3 * i + strlen (fp + 1) + 1, char); res [0] = '\0'; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 3219d9: Make sure that file extension is taken from file (not preceding directory)
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: 3219d9783c770d4ee6dd598bf1f932c3fe53e694
https://github.com/geany/geany/commit/3219d9783c770d4ee6dd598bf1f932c3fe53e…
Log Message: ----------- Make sure that file extension is taken from file (not preceding directory) Modified Paths: -------------- ctags/main/routines.c Modified: ctags/main/routines.c 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -455,8 +455,9 @@ extern const char *fileExtension (const char *const fileName) { const char *extension; const char *pDelimiter = NULL; + const char *const base = baseFilename (fileName); - pDelimiter = strrchr (fileName, '.'); + pDelimiter = strrchr (base, '.'); if (pDelimiter == NULL) extension = ""; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] ed01b7: Grab uctags keyword.c/h and add types.h with type declarations
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:44 UTC Commit: ed01b7edb4dd8f24857fdefe9a226fc6e5c7473d
https://github.com/geany/geany/commit/ed01b7edb4dd8f24857fdefe9a226fc6e5c74…
Log Message: ----------- Grab uctags keyword.c/h and add types.h with type declarations keyword.c/h contains only changes made by me. To make the sync complete, add type.h with type declarations (and remove the added declarations from their original locations). Modified Paths: -------------- ctags/Makefile.am ctags/main/entry.h ctags/main/keyword.c ctags/main/keyword.h ctags/main/kind.h ctags/main/lcpp.h ctags/main/parse.h ctags/main/types.h Modified: ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -89,6 +89,7 @@ libctags_la_SOURCES = \ main/sort.h \ main/strlist.c \ main/strlist.h \ + main/types.h \ main/vstring.c \ main/vstring.h \ main/xtag.h \ Modified: ctags/main/entry.h 5 lines changed, 3 insertions(+), 2 deletions(-) =================================================================== @@ -13,6 +13,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ +#include "types.h" #include "mio.h" #include "vstring.h" @@ -51,7 +52,7 @@ typedef struct sTagFields { /* Information about the current tag candidate. */ -typedef struct sTagEntryInfo { +struct sTagEntryInfo { bool lineNumberEntry; /* pattern or line number entry */ unsigned long lineNumber; /* line number of tag */ MIOPos filePosition; /* file position of line containing tag */ @@ -74,7 +75,7 @@ typedef struct sTagEntryInfo { const char *signature; /* Argument list for functions and macros with arguments */ const char *varType; } extensionFields; /* list of extension fields*/ -} tagEntryInfo; +}; /* * GLOBAL VARIABLES Modified: ctags/main/keyword.c 22 lines changed, 17 insertions(+), 5 deletions(-) =================================================================== @@ -13,12 +13,12 @@ #include "general.h" /* must always come first */ #include <string.h> +#include <ctype.h> #include "debug.h" #include "keyword.h" #include "options.h" #include "routines.h" -#include "main.h" /* * DATA DECLARATIONS @@ -78,7 +78,7 @@ static unsigned int hashValue (const char *const string, langType language) /* "djb" hash as used in g_str_hash() in glib */ for (p = (const signed char *)string; *p != '\0'; p++) - h = (h << 5) + h + *p; + h = (h << 5) + h + tolower (*p); /* consider language as an extra "character" and add it to the hash */ h = (h << 5) + h + language; @@ -136,15 +136,17 @@ extern void addKeyword (const char *const string, langType language, int value) } } -extern int lookupKeyword (const char *const string, langType language) +static int lookupKeywordFull (const char *const string, bool caseSensitive, langType language) { const unsigned int index = hashValue (string, language) % TableSize; hashEntry *entry = getHashTableEntry (index); - int result = -1; + int result = KEYWORD_NONE; while (entry != NULL) { - if (language == entry->language && strcmp (string, entry->string) == 0) + if (language == entry->language && + ((caseSensitive && strcmp (string, entry->string) == 0) || + (!caseSensitive && strcasecmp (string, entry->string) == 0))) { result = entry->value; break; @@ -154,6 +156,16 @@ extern int lookupKeyword (const char *const string, langType language) return result; } +extern int lookupKeyword (const char *const string, langType language) +{ + return lookupKeywordFull (string, true, language); +} + +extern int lookupCaseKeyword (const char *const string, langType language) +{ + return lookupKeywordFull (string, false, language); +} + extern void freeKeywordTable (void) { if (HashTable != NULL) Modified: ctags/main/keyword.h 4 lines changed, 3 insertions(+), 1 deletions(-) =================================================================== @@ -14,7 +14,8 @@ */ #include "general.h" /* must always come first */ -#include "parse.h" +#include "types.h" +#include "vstring.h" #define KEYWORD_NONE -1 @@ -23,6 +24,7 @@ */ extern void addKeyword (const char *const string, langType language, int value); extern int lookupKeyword (const char *const string, langType language); +extern int lookupCaseKeyword (const char *const string, langType language); extern void freeKeywordTable (void); #ifdef DEBUG extern void printKeywordTable (void); Modified: ctags/main/kind.h 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -17,11 +17,11 @@ #define KIND_FILE_DEFAULT 'F' #define KIND_FILE_DEFAULT_LONG "file" -typedef struct sKindOption { +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 */ -} kindOption; +}; #endif /* CTAGS_MAIN_KIND_H */ Modified: ctags/main/lcpp.h 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -13,8 +13,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ - -#include "ctags.h" /* to define langType */ +#include "types.h" /* * MACROS Modified: ctags/main/parse.h 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -27,7 +27,6 @@ /* * DATA DECLARATIONS */ -typedef int langType; typedef void (*createRegexTag) (const vString* const name); typedef void (*simpleParser) (void); Modified: ctags/main/types.h 21 lines changed, 21 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,21 @@ +/* +* Copyright (c) 1998-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. +* +* Private definitions for parsing support. +*/ + +#ifndef CTAGS_MAIN_TYPES_H +#define CTAGS_MAIN_TYPES_H + +typedef int langType; + +struct sTagEntryInfo; +typedef struct sTagEntryInfo tagEntryInfo; + +struct sKindOption; +typedef struct sKindOption kindOption; + +#endif /* CTAGS_MAIN_TYPES_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] fb4fc0: Make tempFile() return MIO
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: fb4fc07b6a2197d5fdf9ea304c8d51d507ad5f2c
https://github.com/geany/geany/commit/fb4fc07b6a2197d5fdf9ea304c8d51d507ad5…
Log Message: ----------- Make tempFile() return MIO Modified Paths: -------------- ctags/main/entry.c ctags/main/routines.c ctags/main/routines.h Modified: ctags/main/entry.c 11 lines changed, 5 insertions(+), 6 deletions(-) =================================================================== @@ -272,10 +272,9 @@ extern void openTagFile (void) */ if (TagsToStdout) { - FILE *fp; - - fp = tempFile ("w", &TagFile.name); - TagFile.mio = mio_new_fp (fp, fclose); + /* Open a tempfile with read and write mode. Read mode is used when + * write the result to stdout. */ + TagFile.mio = tempFile ("w+", &TagFile.name); } else { @@ -363,8 +362,8 @@ extern void copyFile (const char *const from, const char *const to, const long s static int replacementTruncate (const char *const name, const long size) { char *tempName = NULL; - FILE *fp = tempFile ("w", &tempName); - fclose (fp); + MIO *mio = tempFile ("w", &tempName); + mio_free (mio); copyFile (name, tempName, size); copyFile (tempName, name, WHOLE_FILE); remove (tempName); Modified: ctags/main/routines.c 6 lines changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -658,10 +658,11 @@ extern char* relativeFilename (const char *file, const char *dir) return res; } -extern FILE *tempFile (const char *const mode, char **const pName) +extern MIO *tempFile (const char *const mode, char **const pName) { char *name; FILE *fp; + MIO *mio; int fd; #if defined(HAVE_MKSTEMP) const char *const pattern = "tags.XXXXXX"; @@ -701,9 +702,10 @@ extern FILE *tempFile (const char *const mode, char **const pName) fp = fdopen (fd, mode); if (fp == NULL) error (FATAL | PERROR, "cannot open temporary file"); + mio = mio_new_fp (fp, fclose); DebugStatement ( debugPrintf (DEBUG_STATUS, "opened temporary file %s\n", name); ) Assert (*pName == NULL); *pName = name; - return fp; + return mio; } Modified: ctags/main/routines.h 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -17,6 +17,7 @@ #include <stdio.h> #include "vstring.h" +#include "mio.h" /* * MACROS @@ -123,7 +124,7 @@ extern vString *combinePathAndFile (const char *const path, const char *const fi extern char* absoluteFilename (const char *file); extern char* absoluteDirname (char *file); extern char* relativeFilename (const char *file, const char *dir); -extern FILE *tempFile (const char *const mode, char **const pName); +extern MIO *tempFile (const char *const mode, char **const pName); extern char* eStrdup (const char* str); #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] 2f1ad0: Remove most uses of glib calls
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:44 UTC Commit: 2f1ad0232b4410f874ea7f7521e1f50302c88ffe
https://github.com/geany/geany/commit/2f1ad0232b4410f874ea7f7521e1f50302c88…
Log Message: ----------- Remove most uses of glib calls Some special cases which require more work still remain, plus there's still GRegex. Modified Paths: -------------- ctags/main/entry.c ctags/main/lcpp.c ctags/main/parse.c ctags/main/read.c ctags/main/routines.c ctags/main/sort.c ctags/main/strlist.c Modified: ctags/main/entry.c 14 lines changed, 6 insertions(+), 8 deletions(-) =================================================================== @@ -15,8 +15,6 @@ #include <string.h> #include <ctype.h> /* to define isspace () */ #include <errno.h> -#include <glib.h> -#include <glib/gstdio.h> #if defined (HAVE_SYS_TYPES_H) # include <sys/types.h> /* to declare off_t on some hosts */ @@ -247,7 +245,7 @@ static long unsigned int updatePseudoTags (MIO *const mio) static bool isTagFile (const char *const filename) { bool ok = false; /* we assume not unless confirmed */ - MIO *const mio = mio_new_file_full (filename, "rb", g_fopen, fclose); + MIO *const mio = mio_new_file (filename, "rb"); if (mio == NULL && errno == ENOENT) ok = true; @@ -293,17 +291,17 @@ extern void openTagFile (void) if (Option.append && fileExists) { - TagFile.mio = mio_new_file_full (TagFile.name, "r+", g_fopen, fclose); + 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_full (TagFile.name, "a+", g_fopen, fclose); + TagFile.mio = mio_new_file (TagFile.name, "a+"); } } else { - TagFile.mio = mio_new_file_full (TagFile.name, "w", g_fopen, fclose); + TagFile.mio = mio_new_file (TagFile.name, "w"); if (TagFile.mio != NULL) addPseudoTags (); } @@ -343,12 +341,12 @@ 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) { - MIO* const fromMio = mio_new_file_full (from, "rb", g_fopen, fclose); + MIO* const fromMio = mio_new_file (from, "rb"); if (fromMio == NULL) error (FATAL | PERROR, "cannot open file to copy"); else { - MIO* const toMio = mio_new_file_full (to, "wb", g_fopen, fclose); + MIO* const toMio = mio_new_file (to, "wb"); if (toMio == NULL) error (FATAL | PERROR, "cannot open copy destination"); else Modified: ctags/main/lcpp.c 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -14,7 +14,6 @@ #include "general.h" /* must always come first */ #include <string.h> -#include <glib.h> #include "debug.h" #include "entry.h" @@ -23,6 +22,7 @@ #include "options.h" #include "read.h" #include "vstring.h" +#include "routines.h" /* * MACROS @@ -325,7 +325,7 @@ static void makeDefineTag (const char *const name, bool parameterized) } makeTagEntry (&e); if (parameterized) - free((char *) e.extensionFields.signature); + eFree((char *) e.extensionFields.signature); } } @@ -968,13 +968,13 @@ extern char *cppGetArglistFromFilePos(MIOPos startPosition, const char *tokenNam { size_t len = pos2 - pos1; - result = (char *) g_malloc(len + 1); + result = (char *) eMalloc(len + 1); if (result != NULL && (len = mio_read(File.mio, result, 1, len)) > 0) { result[len] = '\0'; arglist = getArglistFromStr(result, tokenName); } - g_free(result); + eFree(result); } mio_setpos(File.mio, &originalPosition); return arglist; Modified: ctags/main/parse.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -172,7 +172,7 @@ static vString* determineInterpreter (const char* const cmd) static langType getInterpreterLanguage (const char *const fileName) { langType result = LANG_IGNORE; - FILE* const fp = g_fopen (fileName, "r"); + FILE* const fp = fopen (fileName, "r"); if (fp != NULL) { vString* const vLine = vStringNew (); Modified: ctags/main/read.c 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -15,7 +15,6 @@ #include <string.h> #include <ctype.h> -#include <glib/gstdio.h> #define FILE_WRITE #include "read.h" @@ -262,7 +261,7 @@ extern bool fileOpen (const char *const fileName, const langType language) File.mio = NULL; } - File.mio = mio_new_file_full (fileName, openMode, g_fopen, fclose); + File.mio = mio_new_file (fileName, openMode); if (File.mio == NULL) error (WARNING | PERROR, "cannot open \"%s\"", fileName); else Modified: ctags/main/routines.c 7 lines changed, 2 insertions(+), 5 deletions(-) =================================================================== @@ -12,9 +12,6 @@ */ #include "general.h" /* must always come first */ -#include <glib.h> -#include <glib/gstdio.h> - #include <errno.h> #ifdef HAVE_STDLIB_H @@ -200,7 +197,7 @@ extern const char *getExecutableName (void) extern void *eMalloc (const size_t size) { - void *buffer = g_malloc (size); + void *buffer = malloc (size); if (buffer == NULL) error (FATAL, "out of memory"); @@ -225,7 +222,7 @@ extern void *eRealloc (void *const ptr, const size_t size) buffer = eMalloc (size); else { - buffer = g_realloc (ptr, size); + buffer = realloc (ptr, size); if (buffer == NULL) error (FATAL, "out of memory"); } Modified: ctags/main/sort.c 20 lines changed, 9 insertions(+), 11 deletions(-) =================================================================== @@ -17,8 +17,6 @@ #endif #include <string.h> #include <stdio.h> -#include <glib.h> -#include <glib/gstdio.h> #include "entry.h" #include "routines.h" @@ -36,7 +34,7 @@ extern void catFile (const char *const name) { - FILE *const fp = g_fopen (name, "r"); + FILE *const fp = fopen (name, "r"); if (fp != NULL) { @@ -64,7 +62,7 @@ extern void externalSortTags (const bool toStdout) PE_CONST char *const sortOrder2 = "LC_ALL=C"; const size_t length = 4 + strlen (sortOrder1) + strlen (sortOrder2) + strlen (sortCommand) + (2 * strlen (tagFileName ())); - char *const cmd = (char *) g_try_malloc (length + 1); + char *const cmd = (char *) malloc (length + 1); int ret = -1; if (cmd != NULL) @@ -87,7 +85,7 @@ extern void externalSortTags (const bool toStdout) #endif verbose ("system (\"%s\")\n", cmd); ret = system (cmd); - g_free (cmd); + free (cmd); } if (ret != 0) @@ -135,7 +133,7 @@ static void writeSortedTags ( mio = mio_new_fp (stdout, NULL); else { - mio = mio_new_file_full (tagFileName (), "w", g_fopen, fclose); + mio = mio_new_file (tagFileName (), "w"); if (mio == NULL) failedSort (mio, NULL); } @@ -164,15 +162,15 @@ extern void internalSortTags (const bool toStdout) */ size_t numTags = TagFile.numTags.added + TagFile.numTags.prev; const size_t tableSize = numTags * sizeof (char *); - char **const table = (char **) g_try_malloc (tableSize); /* line pointers */ + char **const table = (char **) malloc (tableSize); /* line pointers */ DebugStatement ( size_t mallocSize = tableSize; ) /* cumulative total */ if (table == NULL) failedSort (mio, "out of memory"); /* Open the tag file and place its lines into allocated buffers. */ - mio = mio_new_file_full (tagFileName (), "r", g_fopen, fclose); + mio = mio_new_file (tagFileName (), "r"); if (mio == NULL) failedSort (mio, NULL); for (i = 0 ; i < numTags && ! mio_eof (mio) ; ) @@ -190,7 +188,7 @@ extern void internalSortTags (const bool toStdout) { const size_t stringSize = strlen (line) + 1; - table [i] = (char *) g_try_malloc (stringSize); + table [i] = (char *) malloc (stringSize); if (table [i] == NULL) failedSort (mio, "out of memory"); DebugStatement ( mallocSize += stringSize; ) @@ -210,8 +208,8 @@ extern void internalSortTags (const bool toStdout) PrintStatus (("sort memory: %ld bytes\n", (long) mallocSize)); for (i = 0 ; i < numTags ; ++i) - g_free (table [i]); - g_free (table); + free (table [i]); + free (table); } #endif Modified: ctags/main/strlist.c 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -16,7 +16,6 @@ #ifdef HAVE_FNMATCH_H # include <fnmatch.h> #endif -#include <glib/gstdio.h> #include "routines.h" #include "read.h" @@ -90,7 +89,7 @@ extern stringList* stringListNewFromArgv (const char* const* const argv) extern stringList* stringListNewFromFile (const char* const fileName) { stringList* result = NULL; - MIO* const mio = mio_new_file_full (fileName, "r", g_fopen, fclose); + MIO* const mio = mio_new_file (fileName, "r"); if (mio != NULL) { result = stringListNew (); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] a52137: Grab uctags implementation of strlist
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:44 UTC Commit: a52137f414aaa3d3d9a160c8c061a51ce142ad33
https://github.com/geany/geany/commit/a52137f414aaa3d3d9a160c8c061a51ce142a…
Log Message: ----------- Grab uctags implementation of strlist Except missing mio_free() in stringListNewFromFile() which has been ported to uctags. Except the use of ptrarray for strlist implementation, there's nothing interesting in the Geany version which would be worth preserving. Modified Paths: -------------- ctags/main/strlist.c ctags/main/strlist.h Modified: ctags/main/strlist.c 164 lines changed, 70 insertions(+), 94 deletions(-) =================================================================== @@ -13,12 +13,11 @@ #include "general.h" /* must always come first */ #include <string.h> -#ifdef HAVE_FNMATCH_H -# include <fnmatch.h> -#endif +#include <fnmatch.h> -#include "routines.h" +#include "debug.h" #include "read.h" +#include "routines.h" #include "strlist.h" /* @@ -27,53 +26,24 @@ extern stringList *stringListNew (void) { - stringList* const result = xMalloc (1, stringList); - result->max = 0; - result->count = 0; - result->list = NULL; - return result; + return ptrArrayNew ((ptrArrayDeleteFunc)vStringDelete); } extern void stringListAdd (stringList *const current, vString *string) { - enum { incrementalIncrease = 10 }; - Assert (current != NULL); - if (current->list == NULL) - { - Assert (current->max == 0); - current->count = 0; - current->max = incrementalIncrease; - current->list = xMalloc (current->max, vString*); - } - else if (current->count == current->max) - { - current->max += incrementalIncrease; - current->list = xRealloc (current->list, current->max, vString*); - } - current->list [current->count++] = string; + ptrArrayAdd (current, string); } extern void stringListRemoveLast (stringList *const current) { - Assert (current != NULL); - Assert (current->count > 0); - --current->count; - current->list [current->count] = NULL; + ptrArrayRemoveLast (current); } /* Combine list `from' into `current', deleting `from' */ extern void stringListCombine ( stringList *const current, stringList *const from) { - unsigned int i; - Assert (current != NULL); - Assert (from != NULL); - for (i = 0 ; i < from->count ; ++i) - { - stringListAdd (current, from->list [i]); - from->list [i] = NULL; - } - stringListDelete (from); + ptrArrayCombine (current, from); } extern stringList* stringListNewFromArgv (const char* const* const argv) @@ -110,50 +80,28 @@ extern stringList* stringListNewFromFile (const char* const fileName) extern unsigned int stringListCount (const stringList *const current) { - Assert (current != NULL); - return current->count; + return ptrArrayCount (current); } extern vString* stringListItem ( const stringList *const current, const unsigned int indx) { - Assert (current != NULL); - return current->list [indx]; + return ptrArrayItem (current, indx); } extern vString* stringListLast (const stringList *const current) { - Assert (current != NULL); - Assert (current->count > 0); - return current->list [current->count - 1]; + return ptrArrayLast (current); } extern void stringListClear (stringList *const current) { - unsigned int i; - Assert (current != NULL); - for (i = 0 ; i < current->count ; ++i) - { - vStringDelete (current->list [i]); - current->list [i] = NULL; - } - current->count = 0; + ptrArrayClear (current); } extern void stringListDelete (stringList *const current) { - if (current != NULL) - { - if (current->list != NULL) - { - stringListClear (current); - eFree (current->list); - current->list = NULL; - } - current->max = 0; - current->count = 0; - eFree (current); - } + ptrArrayDelete (current); } static bool compareString ( @@ -178,8 +126,8 @@ static int stringListIndex ( Assert (current != NULL); Assert (string != NULL); Assert (test != NULL); - for (i = 0 ; result == -1 && i < current->count ; ++i) - if ((*test)(string, current->list [i])) + for (i = 0 ; result == -1 && i < ptrArrayCount (current) ; ++i) + if ((*test)(string, ptrArrayItem (current, i))) result = i; return result; } @@ -193,6 +141,22 @@ extern bool stringListHas ( return result; } +static vString* stringListFinds ( + const stringList *const current, const char *const string, + bool (*test)(const char *s, vString *const vs)) +{ + int i; + + Assert (current != NULL); + Assert (string != NULL); + + i = stringListIndex (current, string, test); + if (i == -1) + return NULL; + else + return stringListItem(current, i); +} + extern bool stringListHasInsensitive ( const stringList *const current, const char *const string) { @@ -203,36 +167,29 @@ extern bool stringListHasInsensitive ( return result; } -extern bool stringListHasTest ( - const stringList *const current, bool (*test)(const char *s)) +extern bool stringListHasTest (const stringList *const current, + bool (*test)(const char *s, void *userData), + void *userData) { bool result = false; unsigned int i; Assert (current != NULL); - for (i = 0 ; ! result && i < current->count ; ++i) - result = (*test)(vStringValue (current->list [i])); + for (i = 0 ; ! result && i < ptrArrayCount (current) ; ++i) + result = (*test)(vStringValue ((vString *)ptrArrayItem (current, i)), userData); return result; } -extern bool stringListRemoveExtension ( - stringList* const current, const char* const extension) +extern bool stringListDeleteItemExtension (stringList* const current, const char* const extension) { - bool result = false; int where; #ifdef CASE_INSENSITIVE_FILENAMES where = stringListIndex (current, extension, compareStringInsensitive); #else where = stringListIndex (current, extension, compareString); #endif if (where != -1) - { - memmove (current->list + where, current->list + where + 1, - (current->count - where) * sizeof (*current->list)); - current->list [current->count - 1] = NULL; - --current->count; - result = true; - } - return result; + ptrArrayDeleteItem (current, where); + return where != -1; } extern bool stringListExtensionMatched ( @@ -245,33 +202,52 @@ extern bool stringListExtensionMatched ( #endif } +extern vString* stringListExtensionFinds ( + const stringList* const current, const char* const extension) +{ +#ifdef CASE_INSENSITIVE_FILENAMES + return stringListFinds (current, extension, compareStringInsensitive); +#else + return stringListFinds (current, extension, compareString); +#endif +} + static bool fileNameMatched ( const vString* const vpattern, const char* const fileName) { const char* const pattern = vStringValue (vpattern); -#if defined (HAVE_FNMATCH) return (bool) (fnmatch (pattern, fileName, 0) == 0); -#elif defined (CASE_INSENSITIVE_FILENAMES) - return (bool) (strcasecmp (pattern, fileName) == 0); -#else - return (bool) (strcmp (pattern, fileName) == 0); -#endif } extern bool stringListFileMatched ( + const stringList* const current, const char* const fileName) +{ + return stringListFileFinds (current, fileName)? true: false; +} + +extern vString* stringListFileFinds ( const stringList* const current, const char* const fileName) { - bool result = false; + vString* vstr = NULL; + bool matched = false; unsigned int i; - for (i = 0 ; ! result && i < stringListCount (current) ; ++i) - result = fileNameMatched (stringListItem (current, i), fileName); - return result; + for (i = 0 ; ! matched && i < stringListCount (current) ; ++i) + { + vstr = stringListItem (current, i); + matched = fileNameMatched (vstr, fileName); + } + return matched? vstr: NULL; } -extern void stringListPrint (const stringList *const current) +extern void stringListPrint (const stringList *const current, FILE *fp) { unsigned int i; Assert (current != NULL); - for (i = 0 ; i < current->count ; ++i) - printf ("%s%s", (i > 0) ? ", " : "", vStringValue (current->list [i])); + for (i = 0 ; i < ptrArrayCount (current) ; ++i) + fprintf (fp, "%s%s", (i > 0) ? ", " : "", vStringValue ((vString *)ptrArrayItem (current, i))); +} + +extern void stringListReverse (const stringList *const current) +{ + ptrArrayReverse (current); } Modified: ctags/main/strlist.h 20 lines changed, 12 insertions(+), 8 deletions(-) =================================================================== @@ -15,15 +15,14 @@ #include "general.h" /* must always come first */ #include "vstring.h" +#include "ptrarray.h" + +#include <stdio.h> /* * DATA DECLARATIONS */ -typedef struct sStringList { - unsigned int max; - unsigned int count; - vString **list; -} stringList; +typedef ptrArray stringList; /* * FUNCTION PROTOTYPES @@ -41,10 +40,15 @@ extern vString* stringListLast (const stringList *const current); extern void stringListDelete (stringList *const current); extern bool stringListHasInsensitive (const stringList *const current, const char *const string); extern bool stringListHas (const stringList *const current, const char *const string); -extern bool stringListHasTest (const stringList *const current, bool (*test)(const char *s)); -extern bool stringListRemoveExtension (stringList* const current, const char* const extension); +extern bool stringListHasTest (const stringList *const current, + bool (*test)(const char *s, void *userData), + void *userData); +extern bool stringListDeleteItemExtension (stringList* const current, const char* const extension); extern bool stringListExtensionMatched (const stringList* const list, const char* const extension); +extern vString* stringListExtensionFinds (const stringList* const list, const char* const extension); extern bool stringListFileMatched (const stringList* const list, const char* const str); -extern void stringListPrint (const stringList *const current); +extern vString* stringListFileFinds (const stringList* const list, const char* const str); +extern void stringListPrint (const stringList *const current, FILE *fp); +extern void stringListReverse (const stringList *const current); #endif /* CTAGS_MAIN_STRLIST_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] 560107: Drop some more unused functions from 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:35 UTC Commit: 560107804ce5c081326624d3d6de433e0d5eb75d
https://github.com/geany/geany/commit/560107804ce5c081326624d3d6de433e0d5eb…
Log Message: ----------- Drop some more unused functions from routines.c/h Also get the error() implementation from error.c/h (modified slightly to make sure exit() isn't called and which doesn't call errorPrinter() as this one should be set somewhere else in the code and it doesn't happen now). Modified Paths: -------------- ctags/Makefile.am ctags/main/error.c ctags/main/error.h ctags/main/parse.c ctags/main/routines.c ctags/main/routines.h Modified: ctags/Makefile.am 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -59,6 +59,8 @@ libctags_la_SOURCES = \ main/debug.h \ main/entry.c \ main/entry.h \ + main/error.c \ + main/error.h \ main/general.h \ main/keyword.c \ main/keyword.h \ Modified: ctags/main/error.c 59 lines changed, 59 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,59 @@ +/* +* 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. +* +* This module contains a lose assortment of shared functions. +*/ + +#include "general.h" /* must always come first */ +#include <string.h> +#include <errno.h> + +#include "error.h" +#include "options.h" + +#define selected(var,feature) (((int)(var) & (int)(feature)) == (int)feature) + +static errorPrintFunc errorPrinter; +static void *errorPrinterData; + +extern void setErrorPrinter (errorPrintFunc printer, void *data) +{ + errorPrinter = printer; + errorPrinterData = data; +} + +extern bool stderrDefaultErrorPrinter (const errorSelection selection, + const char *const format, + va_list ap, void *data CTAGS_ATTR_UNUSED) +{ + fprintf (stderr, "%s: %s", getExecutableName (), + selected (selection, WARNING) ? "Warning: " : ""); + vfprintf (stderr, format, ap); + if (selected (selection, PERROR)) +#ifdef HAVE_STRERROR + fprintf (stderr, " : %s", strerror (errno)); +#else + perror (" "); +#endif + fputs ("\n", stderr); + + return false; +} + +extern void error (const errorSelection selection, + const char *const format, ...) +{ + va_list ap; + bool shouldExit; + + va_start (ap, format); + shouldExit = false; + va_end (ap); + + if (shouldExit) + exit (1); +} + Modified: ctags/main/error.h 26 lines changed, 26 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,26 @@ +/* +* 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. +* +* This module contains a lose assortment of shared functions. +*/ + +#ifndef CTAGS_MAIN_ERORR_H +#define CTAGS_MAIN_ERORR_H + +#include "general.h" /* must always come first */ + +#include <stdarg.h> +#include "routines.h" + +typedef bool (* errorPrintFunc) (const errorSelection selection, const char *const format, + va_list ap, void *data); + +extern void setErrorPrinter (errorPrintFunc printer, void *data); + +extern bool stderrDefaultErrorPrinter (const errorSelection selection, const char *const format, va_list ap, + void *data); + +#endif Modified: ctags/main/parse.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -116,7 +116,7 @@ extern langType getNamedLanguage (const char *const name) for (i = 0 ; i < LanguageCount && result == LANG_IGNORE ; ++i) { if (LanguageTable [i]->name != NULL) - if (stricmp (name, LanguageTable [i]->name) == 0) + if (strcasecmp (name, LanguageTable [i]->name) == 0) result = i; } return result; Modified: ctags/main/routines.c 146 lines changed, 0 insertions(+), 146 deletions(-) =================================================================== @@ -661,111 +661,6 @@ extern char* relativeFilename (const char *file, const char *dir) return res; } -extern long unsigned int getFileSize (const char *const name) -{ - GStatBuf fileStatus; - unsigned long size = 0; - - if (stat (name, &fileStatus) == 0) - size = fileStatus.st_size; - - return size; -} - -#if 0 -static bool isSymbolicLink (const char *const name) -{ -#if defined (WIN32) - return false; -#else - GStatBuf fileStatus; - bool result = false; - - if (lstat (name, &fileStatus) == 0) - result = (bool) (S_ISLNK (fileStatus.st_mode)); - - return result; -#endif -} - -static bool isNormalFile (const char *const name) -{ - GStatBuf fileStatus; - bool result = false; - - if (stat (name, &fileStatus) == 0) - result = (bool) (S_ISREG (fileStatus.st_mode)); - - return result; -} -#endif - -extern bool isExecutable (const char *const name) -{ - GStatBuf fileStatus; - bool result = false; - - if (stat (name, &fileStatus) == 0) - result = (bool) ((fileStatus.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) != 0); - - return result; -} - -#ifdef HAVE_MKSTEMP - -static bool isSetUID (const char *const name) -{ -#if defined (WIN32) - return false; -#else - GStatBuf fileStatus; - bool result = false; - - if (stat (name, &fileStatus) == 0) - result = (bool) ((fileStatus.st_mode & S_ISUID) != 0); - - return result; -#endif -} - -#endif - -#if 0 -static bool isDirectory (const char *const name) -{ - bool result = false; - GStatBuf fileStatus; - - if (stat (name, &fileStatus) == 0) - result = (bool) S_ISDIR (fileStatus.st_mode); - return result; -} -#endif - -/*#ifndef HAVE_FGETPOS*/ -/* -extern int fgetpos ( stream, pos ) - FILE *const stream; - fpos_t *const pos; -{ - int result = 0; - - *pos = ftell (stream); - if (*pos == -1L) - result = -1; - - return result; -} - -extern int fsetpos ( stream, pos ) - FILE *const stream; - fpos_t *const pos; -{ - return fseek (stream, *pos, SEEK_SET); -} -*/ -/*#endif*/ - extern FILE *tempFile (const char *const mode, char **const pName) { char *name; @@ -815,44 +710,3 @@ extern FILE *tempFile (const char *const mode, char **const pName) *pName = name; return fp; } - -extern void error (const errorSelection selection, - const char *const format, ...) -{ - va_list ap; - - va_start (ap, format); - fprintf (errout, "%s: %s", getExecutableName (), - selected (selection, WARNING) ? "Warning: " : ""); - vfprintf (errout, format, ap); - if (selected (selection, PERROR)) - fprintf (errout, " : %s", g_strerror (errno)); - fputs ("\n", errout); - va_end (ap); - if (selected (selection, FATAL)) - exit (1); -} - -#ifndef HAVE_STRICMP -extern int stricmp (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; -} -#endif - -#ifndef HAVE_STRNICMP -extern int strnicmp (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; -} -#endif Modified: ctags/main/routines.h 16 lines changed, 4 insertions(+), 12 deletions(-) =================================================================== @@ -102,6 +102,9 @@ 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); +#ifndef HAVE_STRSTR +extern char* strstr (const char *str, const char *substr); +#endif extern void toLowerString (char* str); extern void toUpperString (char* str); extern char* newLowerString (const char* str); @@ -114,24 +117,13 @@ extern bool doesFileExist (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); +extern const char *fileExtension (const char *const fileName); extern bool isAbsolutePath (const char *const path); extern vString *combinePathAndFile (const char *const path, const char *const file); extern char* absoluteFilename (const char *file); extern char* absoluteDirname (char *file); extern char* relativeFilename (const char *file, const char *dir); extern FILE *tempFile (const char *const mode, char **const pName); -extern void processExcludeOption (const char *const option, const char *const parameter); -extern const char *fileExtension (const char *const fileName); extern char* eStrdup (const char* str); -#ifndef HAVE_STRICMP -extern int stricmp (const char *s1, const char *s2); -#endif -#ifndef HAVE_STRNICMP -extern int strnicmp (const char *s1, const char *s2, size_t n); -#endif -#ifndef HAVE_STRSTR -extern char* strstr (const char *str, const char *substr); -#endif - #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] d88a9d: Eliminate uses of g_stat()
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: Thu, 06 Oct 2016 15:20:36 UTC Commit: d88a9dd3fc32fe0877eefac3d0211a421dea9a99
https://github.com/geany/geany/commit/d88a9dd3fc32fe0877eefac3d0211a421dea9…
Log Message: ----------- Eliminate uses of g_stat() Convert g_stat() to stat() and introduce eStat() to routines.c/h and use it instead of getFileSize() and isExecutable(). On the way grab implementations of isSameFile() and tempFile() from universal-ctags (I haven't checked in detail if all the ifdef cases do the right thing but these functions aren't probably called in Geany so we don't have to worry much). Also drop unused setCurrentDirectory(). Modified Paths: -------------- ctags/main/read.c ctags/main/routines.c ctags/main/routines.h Modified: ctags/main/read.c 6 lines changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -344,8 +344,10 @@ extern void fileClose (void) * and is incremented upon each newline. */ if (Option.printTotals) - addTotals (0, File.input.lineNumber - 1L, - getFileSize (vStringValue (File.input.name))); + { + fileStatus *status = eStat (vStringValue (File.input.name)); + addTotals (0, File.input.lineNumber - 1L, status->size); + } mio_free (File.mio); File.mio = NULL; Modified: ctags/main/routines.c 184 lines changed, 134 insertions(+), 50 deletions(-) =================================================================== @@ -177,7 +177,9 @@ extern int stat (const char *, struct stat *); #ifdef NEED_PROTO_LSTAT extern int lstat (const char *, struct stat *); #endif - +#if defined (WIN32) +# define lstat(fn,buf) stat(fn,buf) +#endif /* * FUNCTION DEFINITIONS @@ -299,65 +301,133 @@ extern char* newUpperString (const char* str) return result; } - -#if 0 -static void setCurrentDirectory (void) +/* For caching of stat() calls */ +extern fileStatus *eStat (const char *const fileName) { - char* const cwd = getcwd (NULL, PATH_MAX); - CurrentDirectory = xMalloc (strlen (cwd) + 2, char); - if (cwd [strlen (cwd) - (size_t) 1] == PATH_SEPARATOR) - strcpy (CurrentDirectory, cwd); - else - sprintf (CurrentDirectory, "%s%c", cwd, OUTPUT_PATH_SEPARATOR); - free (cwd); + struct stat status; + static fileStatus file; + if (file.name == NULL || strcmp (fileName, file.name) != 0) + { + eStatFree (&file); + file.name = eStrdup (fileName); + if (lstat (file.name, &status) != 0) + file.exists = false; + else + { + file.isSymbolicLink = (bool) S_ISLNK (status.st_mode); + if (file.isSymbolicLink && stat (file.name, &status) != 0) + file.exists = false; + else + { + file.exists = true; + file.isDirectory = (bool) S_ISDIR (status.st_mode); + file.isNormalFile = (bool) (S_ISREG (status.st_mode)); + file.isExecutable = (bool) ((status.st_mode & + (S_IXUSR | S_IXGRP | S_IXOTH)) != 0); + file.isSetuid = (bool) ((status.st_mode & S_ISUID) != 0); + file.isSetgid = (bool) ((status.st_mode & S_ISGID) != 0); + file.size = status.st_size; + } + } + } + return &file; } -#endif +extern void eStatFree (fileStatus *status) +{ + if (status->name != NULL) + { + eFree (status->name); + status->name = NULL; + } +} extern bool doesFileExist (const char *const fileName) { - GStatBuf fileStatus; - - return (bool) (g_stat (fileName, &fileStatus) == 0); + fileStatus *status = eStat (fileName); + return status->exists; } extern bool isRecursiveLink (const char* const dirName) { bool result = false; - char* const path = absoluteFilename (dirName); - while (path [strlen (path) - 1] == PATH_SEPARATOR) - path [strlen (path) - 1] = '\0'; - while (! result && strlen (path) > (size_t) 1) + fileStatus *status = eStat (dirName); + if (status->isSymbolicLink) { - char *const separator = strrchr (path, PATH_SEPARATOR); - if (separator == NULL) - break; - else if (separator == path) /* backed up to root directory */ - *(separator + 1) = '\0'; - else - *separator = '\0'; - result = isSameFile (path, dirName); + char* const path = absoluteFilename (dirName); + while (path [strlen (path) - 1] == PATH_SEPARATOR) + path [strlen (path) - 1] = '\0'; + while (! result && strlen (path) > (size_t) 1) + { + char *const separator = strrchr (path, PATH_SEPARATOR); + if (separator == NULL) + break; + else if (separator == path) /* backed up to root directory */ + *(separator + 1) = '\0'; + else + *separator = '\0'; + result = isSameFile (path, dirName); + } + eFree (path); } - eFree (path); return result; } +/* + * Pathname manipulation (O/S dependent!!!) + */ + +static bool isPathSeparator (const int c) +{ + bool result; +#if defined (MSDOS_STYLE_PATH) + result = (bool) (strchr (PathDelimiters, c) != NULL); +#else + result = (bool) (c == PATH_SEPARATOR); +#endif + return result; +} + +#if ! defined (HAVE_STAT_ST_INO) + +static void canonicalizePath (char *const path CTAGS_ATTR_UNUSED) +{ +# if defined (MSDOS_STYLE_PATH) + char *p; + for (p = path ; *p != '\0' ; ++p) + if (isPathSeparator (*p) && *p != ':') + *p = PATH_SEPARATOR; +# endif +} + +#endif + extern bool isSameFile (const char *const name1, const char *const name2) { bool result = false; -#ifdef HAVE_STAT_ST_INO - GStatBuf stat1, stat2; +#if defined (HAVE_STAT_ST_INO) + struct stat stat1, stat2; - if (g_stat (name1, &stat1) == 0 && g_stat (name2, &stat2) == 0) + if (stat (name1, &stat1) == 0 && stat (name2, &stat2) == 0) result = (bool) (stat1.st_ino == stat2.st_ino); +#else + { + char *const n1 = absoluteFilename (name1); + char *const n2 = absoluteFilename (name2); + canonicalizePath (n1); + canonicalizePath (n2); +# if defined (CASE_INSENSITIVE_FILENAMES) + result = (bool) (strcasecmp (n1, n2) == 0); +# else + result = (bool) (strcmp (n1, n2) == 0); +# endif + free (n1); + free (n2); + } #endif return result; } -/* - * Pathname manipulation (O/S dependent!!!) - */ - extern const char *baseFilename (const char *const filePath) { #if defined (MSDOS_STYLE_PATH) @@ -384,9 +454,6 @@ extern const char *baseFilename (const char *const filePath) return tail; } -/* - * File extension and language mapping - */ extern const char *fileExtension (const char *const fileName) { const char *extension; @@ -599,7 +666,7 @@ extern long unsigned int getFileSize (const char *const name) GStatBuf fileStatus; unsigned long size = 0; - if (g_stat (name, &fileStatus) == 0) + if (stat (name, &fileStatus) == 0) size = fileStatus.st_size; return size; @@ -614,7 +681,7 @@ static bool isSymbolicLink (const char *const name) GStatBuf fileStatus; bool result = false; - if (g_lstat (name, &fileStatus) == 0) + if (lstat (name, &fileStatus) == 0) result = (bool) (S_ISLNK (fileStatus.st_mode)); return result; @@ -626,7 +693,7 @@ static bool isNormalFile (const char *const name) GStatBuf fileStatus; bool result = false; - if (g_stat (name, &fileStatus) == 0) + if (stat (name, &fileStatus) == 0) result = (bool) (S_ISREG (fileStatus.st_mode)); return result; @@ -638,7 +705,7 @@ extern bool isExecutable (const char *const name) GStatBuf fileStatus; bool result = false; - if (g_stat (name, &fileStatus) == 0) + if (stat (name, &fileStatus) == 0) result = (bool) ((fileStatus.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) != 0); return result; @@ -654,7 +721,7 @@ static bool isSetUID (const char *const name) GStatBuf fileStatus; bool result = false; - if (g_stat (name, &fileStatus) == 0) + if (stat (name, &fileStatus) == 0) result = (bool) ((fileStatus.st_mode & S_ISUID) != 0); return result; @@ -669,7 +736,7 @@ static bool isDirectory (const char *const name) bool result = false; GStatBuf fileStatus; - if (g_stat (name, &fileStatus) == 0) + if (stat (name, &fileStatus) == 0) result = (bool) S_ISDIR (fileStatus.st_mode); return result; } @@ -704,16 +771,33 @@ extern FILE *tempFile (const char *const mode, char **const pName) char *name; FILE *fp; int fd; -#ifdef HAVE_MKSTEMP - const char *const template = "tags.XXXXXX"; +#if defined(HAVE_MKSTEMP) + const char *const pattern = "tags.XXXXXX"; const char *tmpdir = NULL; - if (! isSetUID (ExecutableProgram)) + fileStatus *file = eStat (ExecutableProgram); +# ifdef WIN32 + tmpdir = getenv ("TMP"); +# else + if (! file->isSetuid) tmpdir = getenv ("TMPDIR"); +# endif if (tmpdir == NULL) tmpdir = TMPDIR; - name = xMalloc (strlen (tmpdir) + 1 + strlen (template) + 1, char); - sprintf (name, "%s%c%s", tmpdir, OUTPUT_PATH_SEPARATOR, template); - fd = mkstemp(name); + name = xMalloc (strlen (tmpdir) + 1 + strlen (pattern) + 1, char); + sprintf (name, "%s%c%s", tmpdir, OUTPUT_PATH_SEPARATOR, pattern); + fd = mkstemp (name); + eStatFree (file); +#elif defined(HAVE_TEMPNAM) + const char *tmpdir = NULL; +# ifdef WIN32 + tmpdir = getenv ("TMP"); +# endif + if (tmpdir == NULL) + tmpdir = TMPDIR; + name = tempnam (tmpdir, "tags"); + if (name == NULL) + error (FATAL | PERROR, "cannot allocate temporary file name"); + fd = open (name, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); #else name = xMalloc (L_tmpnam, char); if (tmpnam (name) != name) Modified: ctags/main/routines.h 32 lines changed, 30 insertions(+), 2 deletions(-) =================================================================== @@ -57,6 +57,34 @@ extern char *CurrentDirectory; typedef int errorSelection; enum eErrorTypes { FATAL = 1, WARNING = 2, PERROR = 4 }; +typedef struct { + /* Name of file for which status is valid */ + char* name; + + /* Does file exist? If not, members below do not contain valid data. */ + bool exists; + + /* is file path a symbolic link to another file? */ + bool isSymbolicLink; + + /* Is file (pointed to) a directory? */ + bool isDirectory; + + /* Is file (pointed to) a normal file? */ + bool isNormalFile; + + /* Is file (pointed to) executable? */ + bool isExecutable; + + /* Is file (pointed to) setuid? */ + bool isSetuid; + + /* Is file (pointed to) setgid? */ + bool isSetgid; + + /* Size of file (pointed to) */ + unsigned long size; +} fileStatus; /* * FUNCTION PROTOTYPES @@ -80,6 +108,8 @@ extern char* newLowerString (const char* str); extern char* newUpperString (const char* str); /* File system functions */ +extern fileStatus *eStat (const char *const fileName); +extern void eStatFree (fileStatus *status); extern bool doesFileExist (const char *const fileName); extern bool isRecursiveLink (const char* const dirName); extern bool isSameFile (const char *const name1, const char *const name2); @@ -93,8 +123,6 @@ extern FILE *tempFile (const char *const mode, char **const pName); extern void processExcludeOption (const char *const option, const char *const parameter); extern const char *fileExtension (const char *const fileName); extern char* eStrdup (const char* str); -extern long unsigned int getFileSize (const char *const name); -extern bool isExecutable (const char *const name); #ifndef HAVE_STRICMP extern int stricmp (const char *s1, const char *s2); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] ed6d24: Remove unused functions from options.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:44 UTC Commit: ed6d24bb9a3ce9f8393e97eb753bdb3f57feed84
https://github.com/geany/geany/commit/ed6d24bb9a3ce9f8393e97eb753bdb3f57fee…
Log Message: ----------- Remove unused functions from options.c/h Modified Paths: -------------- ctags/main/options.c ctags/main/options.h Modified: ctags/main/options.c 53 lines changed, 0 insertions(+), 53 deletions(-) =================================================================== @@ -197,56 +197,3 @@ extern bool isIgnoreToken (const char *const name, } return result; } - -void addIgnoreListFromFile (const char *const fileName) -{ - stringList* tokens = stringListNewFromFile (fileName); - if (Option.ignore == NULL) - Option.ignore = tokens; - else - stringListCombine (Option.ignore, tokens); -} - -extern void processExcludeOption (const char *const option CTAGS_ATTR_UNUSED, - const char *const parameter) -{ - if (parameter [0] == '\0') - freeList (&Excluded); - else if (parameter [0] == '@') - { - stringList* const new = stringListNewFromFile (parameter + 1); - if (Excluded == NULL) - Excluded = new; - else - stringListCombine (Excluded, new); - } - else - { - vString *const item = vStringNewInit (parameter); - if (Excluded == NULL) - Excluded = stringListNew (); - stringListAdd (Excluded, item); - } -} - -extern bool isExcludedFile (const char* const name) -{ - const char* base = baseFilename (name); - bool result = false; - if (Excluded != NULL) - { - result = stringListFileMatched (Excluded, base); - if (! result && name != base) - result = stringListFileMatched (Excluded, name); - } - return result; -} - - - -/* - * Generic option parsing - */ -#define readOptionConfiguration -#define initOptions -#define freeOptionResources Modified: ctags/main/options.h 6 lines changed, 0 insertions(+), 6 deletions(-) =================================================================== @@ -98,12 +98,6 @@ extern void freeList (stringList** const pString); extern void setDefaultTagFileName (void); extern bool isIncludeFile (const char *const fileName); -extern bool isExcludedFile (const char* const name); extern bool isIgnoreToken (const char *const name, bool *const pIgnoreParens, const char **const replacement); -extern void readOptionConfiguration (void); -extern void initOptions (void); -extern void freeOptionResources (void); - -void addIgnoreListFromFile (const char *const fileName); #endif /* CTAGS_MAIN_OPTIONS_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
8
9
...
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