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] 0a0ed5: Create geany.c/h and put isIgnoreToken()
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: 0a0ed51792b9af2693b9ec632c1456e62ace0af3
https://github.com/geany/geany/commit/0a0ed51792b9af2693b9ec632c1456e62ace0…
Log Message: ----------- Create geany.c/h and put isIgnoreToken() This is a (hopefully) temporary file where we put geany-specific code that for some reason has to be still in ctags. Put isIgnoreToken() in this file. Modified Paths: -------------- ctags/Makefile.am ctags/main/geany.c ctags/main/geany.h ctags/main/options.c ctags/main/options.h ctags/parsers/c.c src/symbols.c Modified: ctags/Makefile.am 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -64,6 +64,8 @@ libctags_la_SOURCES = \ main/error.c \ main/error.h \ main/gcc-attr.h \ + main/geany.c \ + main/geany.h \ main/general.h \ main/keyword.c \ main/keyword.h \ Modified: ctags/main/geany.c 80 lines changed, 80 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2016, Jiri Techet +* +* 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. +* +* Defines external interface to option processing. +*/ + +#include "general.h" /* must always come first */ + +#include "geany.h" +#include "vstring.h" + +#include <string.h> +#include <glib.h> + +/* tags_ignore is a NULL-terminated array of strings, read from ~/.config/geany/ignore.tags. + * This file contains a space or newline separated list of symbols which should be ignored + * by the C/C++ parser, see -I command line option of ctags for details. */ +gchar **c_tags_ignore = NULL; + +/* Determines whether or not "name" should be ignored, per the ignore list. + */ +extern bool isIgnoreToken (const char *const name, + bool *const pIgnoreParens, + const char **const replacement) +{ + bool result = false; + + if (c_tags_ignore != NULL) + { + const size_t nameLen = strlen (name); + unsigned int i; + guint len = g_strv_length (c_tags_ignore); + vString *token = vStringNew(); + + if (pIgnoreParens != NULL) + *pIgnoreParens = false; + + for (i = 0 ; i < len ; ++i) + { + size_t tokenLen; + + vStringCopyS (token, c_tags_ignore[i]); + tokenLen = vStringLength (token); + + if (tokenLen >= 2 && vStringChar (token, tokenLen - 1) == '*' && + strncmp (vStringValue (token), name, tokenLen - 1) == 0) + { + result = true; + break; + } + if (strncmp (vStringValue (token), name, nameLen) == 0) + { + if (nameLen == tokenLen) + { + result = true; + break; + } + else if (tokenLen == nameLen + 1 && + vStringChar (token, tokenLen - 1) == '+') + { + result = true; + if (pIgnoreParens != NULL) + *pIgnoreParens = true; + break; + } + else if (vStringChar (token, nameLen) == '=') + { + if (replacement != NULL) + *replacement = vStringValue (token) + nameLen + 1; + break; + } + } + } + vStringDelete (token); + } + return result; +} Modified: ctags/main/geany.h 14 lines changed, 14 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,14 @@ +/* +* Copyright (c) 2016, Jiri Techet +* +* 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. +* +* Defines external interface to option processing. +*/ +#ifndef CTAGS_GEANY_H +#define CTAGS_GEANY_H + +extern bool isIgnoreToken (const char *const name, bool *const pIgnoreParens, const char **const replacement); + +#endif /* CTAGS_GEANY_H */ Modified: ctags/main/options.c 66 lines changed, 0 insertions(+), 66 deletions(-) =================================================================== @@ -23,8 +23,6 @@ #include "options.h" #include "parse.h" -#include <glib.h> - #define CTAGS_ENVIRONMENT "CTAGS" #define CTAGS_FILE "tags" @@ -133,67 +131,3 @@ extern bool isIncludeFile (const char *const fileName) { return false; } - -/* tags_ignore is a NULL-terminated array of strings, read from ~/.config/geany/ignore.tags. - * This file contains a space or newline separated list of symbols which should be ignored - * by the C/C++ parser, see -I command line option of ctags for details. */ -gchar **c_tags_ignore = NULL; - -/* Determines whether or not "name" should be ignored, per the ignore list. - */ -extern bool isIgnoreToken (const char *const name, - bool *const pIgnoreParens, - const char **const replacement) -{ - bool result = false; - - if (c_tags_ignore != NULL) - { - const size_t nameLen = strlen (name); - unsigned int i; - guint len = g_strv_length (c_tags_ignore); - vString *token = vStringNew(); - - if (pIgnoreParens != NULL) - *pIgnoreParens = false; - - for (i = 0 ; i < len ; ++i) - { - size_t tokenLen; - - vStringCopyS (token, c_tags_ignore[i]); - tokenLen = vStringLength (token); - - if (tokenLen >= 2 && vStringChar (token, tokenLen - 1) == '*' && - strncmp (vStringValue (token), name, tokenLen - 1) == 0) - { - result = true; - break; - } - if (strncmp (vStringValue (token), name, nameLen) == 0) - { - if (nameLen == tokenLen) - { - result = true; - break; - } - else if (tokenLen == nameLen + 1 && - vStringChar (token, tokenLen - 1) == '+') - { - result = true; - if (pIgnoreParens != NULL) - *pIgnoreParens = true; - break; - } - else if (vStringChar (token, nameLen) == '=') - { - if (replacement != NULL) - *replacement = vStringValue (token) + nameLen + 1; - break; - } - } - } - vStringDelete (token); - } - return result; -} Modified: ctags/main/options.h 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -103,6 +103,5 @@ extern void freeList (stringList** const pString); extern void setDefaultTagFileName (void); extern bool isIncludeFile (const char *const fileName); -extern bool isIgnoreToken (const char *const name, bool *const pIgnoreParens, const char **const replacement); #endif /* CTAGS_MAIN_OPTIONS_H */ Modified: ctags/parsers/c.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -26,6 +26,7 @@ #include "read.h" #include "routines.h" #include "xtag.h" +#include "geany.h" /* * MACROS Modified: src/symbols.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -118,7 +118,7 @@ symbol_menu; static void load_user_tags(GeanyFiletypeID ft_id); -/* get the tags_ignore list, exported by tagmanager's options.c */ +/* get the tags_ignore list, exported by tagmanager's geany.c */ extern gchar **c_tags_ignore; /* ignore certain tokens when parsing C-like syntax. -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 37f015: Implement iFileGetLine() using gets()
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: 37f015d993ad1bc1e052503582a745e5b3c94ca7
https://github.com/geany/geany/commit/37f015d993ad1bc1e052503582a745e5b3c94…
Log Message: ----------- Implement iFileGetLine() using gets() Modified Paths: -------------- ctags/main/read.c ctags/main/read.h Modified: ctags/main/read.c 197 lines changed, 81 insertions(+), 116 deletions(-) =================================================================== @@ -127,27 +127,27 @@ static bool setSourceFileName (vString *const fileName) * Line directive parsing */ -static int skipWhite (void) +static void skipWhite (char **str) { - int c; - do - c = mio_getc (File.mio); - while (c == ' ' || c == '\t'); - return c; + while (**str == ' ' || **str == '\t') + (*str)++; } -static unsigned long readLineNumber (void) +static unsigned long readLineNumber (char **str) { + char *s; unsigned long lNum = 0; - int c = skipWhite (); - while (c != EOF && isdigit (c)) + + skipWhite (str); + s = *str; + while (*s != '\0' && isdigit (*s)) { - lNum = (lNum * 10) + (c - '0'); - c = mio_getc (File.mio); + lNum = (lNum * 10) + (*s - '0'); + s++; } - mio_ungetc (File.mio, c); - if (c != ' ' && c != '\t') + if (*s != ' ' && *s != '\t') lNum = 0; + *str = s; return lNum; } @@ -160,59 +160,54 @@ static unsigned long readLineNumber (void) * # n "filename" * So we need to be fairly flexible in what we accept. */ -static vString *readFileName (void) +static vString *readFileName (char *s) { vString *const fileName = vStringNew (); bool quoteDelimited = false; - int c = skipWhite (); - if (c == '"') + skipWhite (&s); + if (*s == '"') { - c = mio_getc (File.mio); /* skip double-quote */ + s++; /* skip double-quote */ quoteDelimited = true; } - while (c != EOF && c != '\n' && - (quoteDelimited ? (c != '"') : (c != ' ' && c != '\t'))) + while (*s != '\0' && *s != '\n' && + (quoteDelimited ? (*s != '"') : (*s != ' ' && *s != '\t'))) { - vStringPut (fileName, c); - c = mio_getc (File.mio); + vStringPut (fileName, *s); + s++; } - if (c == '\n') - mio_ungetc (File.mio, c); vStringPut (fileName, '\0'); return fileName; } -static bool parseLineDirective (void) +static bool parseLineDirective (char *s) { bool result = false; - int c = skipWhite (); + + skipWhite (&s); DebugStatement ( const char* lineStr = ""; ) - if (isdigit (c)) - { - mio_ungetc (File.mio, c); + if (isdigit (*s)) result = true; - } - else if (c == 'l' && mio_getc (File.mio) == 'i' && - mio_getc (File.mio) == 'n' && mio_getc (File.mio) == 'e') + else if (strncmp (s, "line", 4) == 0) { - c = mio_getc (File.mio); - if (c == ' ' || c == '\t') + s += 4; + if (*s == ' ' || *s == '\t') { DebugStatement ( lineStr = "line"; ) result = true; } } if (result) { - const unsigned long lNum = readLineNumber (); + const unsigned long lNum = readLineNumber (&s); if (lNum == 0) result = false; else { - vString *const fileName = readFileName (); + vString *const fileName = readFileName (s); if (vStringLength (fileName) == 0) { File.source.lineNumber = lNum - 1; /* applies to NEXT line */ @@ -225,7 +220,7 @@ static bool parseLineDirective (void) lineStr, lNum, vStringValue (fileName)); ) } - if (Option.include.fileNames && vStringLength (fileName) > 0 && + if (vStringLength (fileName) > 0 && lNum == 1) { tagEntryInfo tag; @@ -276,8 +271,6 @@ extern bool fileOpen (const char *const fileName, const langType language) mio_getpos (File.mio, &File.filePosition); File.currentLine = NULL; File.input.lineNumber = 0L; - File.eof = false; - File.newLine = true; if (File.line != NULL) vStringClear (File.line); @@ -322,8 +315,6 @@ extern bool bufferOpen (unsigned char *buffer, size_t buffer_size, mio_getpos (File.mio, &File.filePosition); File.currentLine = NULL; File.input.lineNumber = 0L; - File.eof = false; - File.newLine = true; if (File.line != NULL) vStringClear (File.line); @@ -356,74 +347,17 @@ extern void fileClose (void) } } -extern bool fileEOF (void) -{ - return File.eof; -} - /* Action to take for each encountered input newline. */ static void fileNewline (void) { File.filePosition = StartOfLine; - File.newLine = false; File.input.lineNumber++; File.source.lineNumber++; DebugStatement ( if (Option.breakLine == File.input.lineNumber) lineBreak (); ) DebugStatement ( debugPrintf (DEBUG_RAW, "%6ld: ", File.input.lineNumber); ) } -/* This function reads a single character from the stream, performing newline - * canonicalization. - */ -static int iFileGetc (void) -{ - int c; -readnext: - c = mio_getc (File.mio); - - /* If previous character was a newline, then we're starting a line. - */ - if (File.newLine && c != EOF) - { - fileNewline (); - if (c == '#' && Option.lineDirectives) - { - if (parseLineDirective ()) - goto readnext; - else - { - mio_setpos (File.mio, &StartOfLine); - c = mio_getc (File.mio); - } - } - } - - if (c == EOF) - File.eof = true; - else if (c == NEWLINE) - { - File.newLine = true; - mio_getpos (File.mio, &StartOfLine); - } - else if (c == CRETURN) - { - /* Turn line breaks into a canonical form. The three commonly - * used forms if line breaks: LF (UNIX/Mac OS X), CR (Mac OS 9), - * and CR-LF (MS-DOS) are converted into a generic newline. - */ - const int next = mio_getc (File.mio); /* is CR followed by LF? */ - if (next != NEWLINE) - mio_ungetc (File.mio, next); - - c = NEWLINE; /* convert CR into newline */ - File.newLine = true; - mio_getpos (File.mio, &StartOfLine); - } - DebugStatement ( debugPutc (DEBUG_RAW, c); ) - return c; -} - extern void ungetcToInputFile (int c) { const size_t len = ARRAY_SIZE (File.ungetchBuf); @@ -436,28 +370,59 @@ extern void ungetcToInputFile (int c) static vString *iFileGetLine (void) { - vString *result = NULL; - int c; - if (File.line == NULL) - File.line = vStringNew (); - vStringClear (File.line); - do + char *str; + size_t size; + bool haveLine; + + File.line = vStringNewOrClear (File.line); + str = vStringValue (File.line); + size = vStringSize (File.line); + + for (;;) { - c = iFileGetc (); - if (c != EOF) - vStringPut (File.line, c); - if (c == '\n' || (c == EOF && vStringLength (File.line) > 0)) + bool newLine; + bool eof; + + mio_gets (File.mio, str, size); + vStringSetLength (File.line); + haveLine = vStringLength (File.line) > 0; + newLine = haveLine && vStringLast (File.line) == '\n'; + eof = mio_eof (File.mio); + + /* Turn line breaks into a canonical form. The three commonly + * used forms of line breaks are: LF (UNIX/Mac OS X), CR-LF (MS-DOS) and + * CR (Mac OS 9). As CR-only EOL isn't haneled by gets() and Mac OS 9 + * is dead, we only handle CR-LF EOLs and convert them into LF. */ + if (newLine && vStringLength (File.line) > 1 && + vStringItem (File.line, vStringLength (File.line) - 2) == '\r') { -#ifdef HAVE_REGEX - if (vStringLength (File.line) > 0) - matchRegex (File.line, File.source.language); -#endif - result = File.line; - break; + vStringItem (File.line, vStringLength (File.line) - 2) = '\n'; + vStringChop (File.line); } - } while (c != EOF); - Assert (result != NULL || File.eof); - return result; + + if (newLine || eof) + break; + + vStringResize (File.line, vStringLength (File.line) * 2); + str = vStringValue (File.line) + vStringLength (File.line); + size = vStringSize (File.line) - vStringLength (File.line); + } + + if (haveLine) + { + /* Use StartOfLine from previous iFileGetLine() call */ + fileNewline (); + /* Store StartOfLine for the next iFileGetLine() call */ + mio_getpos (File.mio, &StartOfLine); + + if (Option.lineDirectives && vStringChar (File.line, 0) == '#') + parseLineDirective (vStringValue (File.line) + 1); + matchRegex (File.line, File.source.language); + + return File.line; + } + + return NULL; } /* Do not mix use of readLineFromInputFile () and getcFromInputFile () for the same file. Modified: ctags/main/read.h 3 lines changed, 0 insertions(+), 3 deletions(-) =================================================================== @@ -78,8 +78,6 @@ typedef struct sInputFile { MIOPos filePosition; /* file position of current line */ unsigned int ungetchIdx; int ungetchBuf[3]; /* characters that were ungotten */ - bool eof; /* have we reached the end of file? */ - bool newLine; /* will the next character begin a new line? */ /* Contains data pertaining to the original source file in which the tag * was defined. This may be different from the input file when #line @@ -104,7 +102,6 @@ extern kindOption *getInputLanguageFileKind (void); extern void freeSourceFileResources (void); extern bool fileOpen (const char *const fileName, const langType language); -extern bool fileEOF (void); extern void fileClose (void); extern int getcFromInputFile (void); extern int getNthPrevCFromInputFile (unsigned int nth, int def); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] a5dea8: Grab all MIO changes from uctags
by Jiří Techet
17 Dec '18
17 Dec '18
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Sat, 08 Oct 2016 12:13:41 UTC Commit: a5dea8091bdd84de1f70c7989ff2a3c79d31a9ee
https://github.com/geany/geany/commit/a5dea8091bdd84de1f70c7989ff2a3c79d31a…
Log Message: ----------- Grab all MIO changes from uctags Modified Paths: -------------- ctags/main/mio.c ctags/main/mio.h Modified: ctags/main/mio.c 382 lines changed, 351 insertions(+), 31 deletions(-) =================================================================== @@ -18,6 +18,22 @@ * */ +#ifndef QUALIFIER +#include "general.h" /* must always come first */ + +#include "routines.h" +#include "debug.h" +#else + +#if defined (HAVE_CONFIG_H) +#include <config.h> +#endif + +#ifdef USE_STDBOOL_H +#include <stdbool.h> +#endif +#endif + #include "mio.h" #include <stdarg.h> @@ -27,6 +43,63 @@ #include <stdlib.h> #include <limits.h> +#ifdef QUALIFIER +#define xMalloc(n,Type) (Type *)eMalloc((size_t)(n) * sizeof (Type)) +#define xCalloc(n,Type) (Type *)eCalloc((size_t)(n), sizeof (Type)) +#define xRealloc(p,n,Type) (Type *)eRealloc((p), (n) * sizeof (Type)) + +extern void *eMalloc (const size_t size) +{ + void *buffer = malloc (size); + + if (buffer == NULL) + { + fprintf(stderr, "out of memory"); + abort (); + } + + return buffer; +} + +extern void *eCalloc (const size_t count, const size_t size) +{ + void *buffer = calloc (count, size); + + if (buffer == NULL) + { + fprintf(stderr, "out of memory"); + abort (); + } + + return buffer; +} + +extern void *eRealloc (void *const ptr, const size_t size) +{ + void *buffer; + if (ptr == NULL) + buffer = eMalloc (size); + else + { + buffer = realloc (ptr, size); + if (buffer == NULL) + { + fprintf(stderr, "out of memory"); + abort (); + } + } + return buffer; +} + +extern void eFree (void *const ptr) +{ + free (ptr); +} + +# define Assert(c) +# define AssertNotReached() +#endif + /* minimal reallocation chunk size */ #define MIO_CHUNK_SIZE 4096 @@ -42,9 +115,12 @@ * file based operations and in-memory operations. Its goal is to ease the port * of an application that uses C file I/O API to perform in-memory operations. * - * A #MIO object is created using mio_new_file() or mio_new_memory(), depending - * on whether you want file or in-memory operations, and destroyed using - * mio_free(). There is also some other convenient API to create file-based + * A #MIO object is created using mio_new_file(), mio_new_memory() or mio_new_mio(), + * depending on whether you want file or in-memory operations. + * Its life is managed by reference counting. Just after calling one of functions + * for creating, the count is 1. mio_ref() increments the counter. mio_free() + * decrements it. When the counter becomes 0, the #MIO object will be destroyed + * in mio_free(). There is also some other convenient API to create file-based * #MIO objects for more complex cases, such as mio_new_file_full() and * mio_new_fp(). * @@ -58,6 +134,43 @@ */ +typedef struct _MIOUserData MIOUserData; +struct _MIOUserData { + void *d; + MIODestroyNotify f; +}; + +/** + * MIO: + * + * An object representing a #MIO stream. No assumptions should be made about + * what compose this object, and none of its fields should be accessed directly. + */ +struct _MIO { + /*< private >*/ + MIOType type; + unsigned int refcount; + union { + struct { + FILE *fp; + MIOFCloseFunc close_func; + } file; + struct { + unsigned char *buf; + int ungetch; + size_t pos; + size_t size; + size_t allocated_size; + MIOReallocFunc realloc_func; + MIODestroyNotify free_func; + bool error; + bool eof; + } mem; + } impl; + MIOUserData udata; +}; + + /** * mio_new_file_full: * @filename: Filename to open, passed as-is to @open_func as the first argument @@ -93,21 +206,24 @@ MIO *mio_new_file_full (const char *filename, /* we need to create the MIO object first, because we may not be able to close * the opened file if the user passed NULL as the close function, which means * that everything must succeed if we've opened the file successfully */ - mio = malloc (sizeof *mio); + mio = xMalloc (1, MIO); if (mio) { FILE *fp = open_func (filename, mode); if (! fp) { - free (mio); + eFree (mio); mio = NULL; } else { mio->type = MIO_TYPE_FILE; mio->impl.file.fp = fp; mio->impl.file.close_func = close_func; + mio->refcount = 1; + mio->udata.d = NULL; + mio->udata.f = NULL; } } @@ -160,12 +276,15 @@ MIO *mio_new_fp (FILE *fp, MIOFCloseFunc close_func) if (!fp) return NULL; - mio = malloc (sizeof *mio); + mio = xMalloc (1, MIO); if (mio) { mio->type = MIO_TYPE_FILE; mio->impl.file.fp = fp; mio->impl.file.close_func = close_func; + mio->refcount = 1; + mio->udata.d = NULL; + mio->udata.f = NULL; } return mio; @@ -214,7 +333,7 @@ MIO *mio_new_memory (unsigned char *data, { MIO *mio; - mio = malloc (sizeof *mio); + mio = xMalloc (1, MIO); if (mio) { mio->type = MIO_TYPE_MEMORY; @@ -227,11 +346,89 @@ MIO *mio_new_memory (unsigned char *data, mio->impl.mem.free_func = free_func; mio->impl.mem.eof = false; mio->impl.mem.error = false; + mio->refcount = 1; + mio->udata.d = NULL; + mio->udata.f = NULL; } return mio; } +/** + * mio_new_mio: + * @base: The original mio + * @start: stream offset of the @base where new mio starts + * @size: the length of the data copied from @base to new mio + * + * Creates a new #MIO object by copying data from existing #MIO (@base). + * The range for copying are given with @start and @size. + * Copying data at the range from @start to the end of @base is + * done if 0 is given as @size. + * + * If @size(!= 0) is larger than the length from @start to the end of + * @base, %NULL is return. + * + * The function doesn't move the file position of @base. + * + * Free-function: mio_free() + * + */ + +MIO *mio_new_mio (MIO *base, long start, size_t size) +{ + unsigned char *data; + long original_pos; + MIO *submio; + size_t r; + + original_pos = mio_tell (base); + + if (size == 0) + { + long end; + + if (mio_seek (base, 0, SEEK_END) != 0) + return NULL; + end = mio_tell (base); + size = end - start; + Assert (size >= 0); + } + + if (mio_seek (base, start, SEEK_SET) != 0) + return NULL; + + data = xMalloc (size, unsigned char); + r= mio_read (base, data, 1, size); + mio_seek (base, original_pos, SEEK_SET); + + if (r != size) + goto cleanup; + + submio = mio_new_memory (data, size, eRealloc, eFree); + if (! submio) + goto cleanup; + + return submio; + +cleanup: + eFree (data); + return NULL; +} + +/** + * mio_ref: + * @mio: A #MIO object + * + * Increments the reference counter of a #MIO. + * + * Returns: passed @mio. + */ +MIO *mio_ref (MIO *mio) +{ + mio->refcount++; + return mio; +} + /** * mio_file_get_fp: * @mio: A #MIO object @@ -288,7 +485,8 @@ unsigned char *mio_memory_get_data (MIO *mio, size_t *size) * mio_free: * @mio: A #MIO object * - * Destroys a #MIO object. + * Decrements the reference counter of a #MIO and destroys the #MIO + * object if its counter becomes 0. * * Returns: Error code obtained from the registered MIOFCloseFunc or 0 on success. */ @@ -298,14 +496,20 @@ int mio_free (MIO *mio) if (mio) { + if (--mio->refcount) + return 0; + + if (mio->udata.d && mio->udata.f) + mio->udata.f (mio->udata.d); + if (mio->type == MIO_TYPE_FILE) { if (mio->impl.file.close_func) rv = mio->impl.file.close_func (mio->impl.file.fp); mio->impl.file.close_func = NULL; mio->impl.file.fp = NULL; } - else + else if (mio->type == MIO_TYPE_MEMORY) { if (mio->impl.mem.free_func) mio->impl.mem.free_func (mio->impl.mem.buf); @@ -318,8 +522,10 @@ int mio_free (MIO *mio) mio->impl.mem.eof = false; mio->impl.mem.error = false; } + else + AssertNotReached (); - free (mio); + eFree (mio); } return rv; @@ -347,7 +553,7 @@ size_t mio_read (MIO *mio, { if (mio->type == MIO_TYPE_FILE) return fread (ptr_, size, nmemb, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { size_t n_read = 0; @@ -382,6 +588,11 @@ size_t mio_read (MIO *mio, return n_read; } + else + { + AssertNotReached (); + return 0; + } } /* @@ -490,7 +701,7 @@ size_t mio_write (MIO *mio, { if (mio->type == MIO_TYPE_FILE) return fwrite (ptr, size, nmemb, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { size_t n_written = 0; @@ -506,6 +717,11 @@ size_t mio_write (MIO *mio, return n_written; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -522,7 +738,7 @@ int mio_putc (MIO *mio, int c) { if (mio->type == MIO_TYPE_FILE) return fputc (c, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { int rv = EOF; @@ -535,6 +751,11 @@ int mio_putc (MIO *mio, int c) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -550,7 +771,7 @@ int mio_puts (MIO *mio, const char *s) { if (mio->type == MIO_TYPE_FILE) return fputs (s, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { int rv = EOF; size_t len; @@ -565,6 +786,11 @@ int mio_puts (MIO *mio, const char *s) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -583,7 +809,7 @@ int mio_vprintf (MIO *mio, const char *format, va_list ap) { if (mio->type == MIO_TYPE_FILE) return vfprintf (mio->impl.file.fp, format, ap); - else + else if (mio->type == MIO_TYPE_MEMORY) { int rv = -1; size_t n; @@ -623,6 +849,11 @@ int mio_vprintf (MIO *mio, const char *format, va_list ap) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -662,7 +893,7 @@ int mio_getc (MIO *mio) { if (mio->type == MIO_TYPE_FILE) return fgetc (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { int rv = EOF; @@ -682,6 +913,11 @@ int mio_getc (MIO *mio) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -704,7 +940,7 @@ int mio_ungetc (MIO *mio, int ch) { if (mio->type == MIO_TYPE_FILE) return ungetc (ch, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { int rv = EOF; @@ -717,6 +953,11 @@ int mio_ungetc (MIO *mio, int ch) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -735,28 +976,35 @@ char *mio_gets (MIO *mio, char *s, size_t size) { if (mio->type == MIO_TYPE_FILE) return fgets (s, (int)size, mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { char *rv = NULL; if (size > 0) { size_t i = 0; + bool newline = false; + /* Avoiding dereference inside the for loop below improves + * performance so we do it here. */ + size_t pos = mio->impl.mem.pos; + size_t buf_size = mio->impl.mem.size; + unsigned char *buf = mio->impl.mem.buf; if (mio->impl.mem.ungetch != EOF) { s[i] = (char)mio->impl.mem.ungetch; mio->impl.mem.ungetch = EOF; - mio->impl.mem.pos++; + pos++; i++; } - for (; mio->impl.mem.pos < mio->impl.mem.size && i < (size - 1); i++) + for (; pos < buf_size && i < (size - 1); i++) { - s[i] = (char)mio->impl.mem.buf[mio->impl.mem.pos]; - mio->impl.mem.pos++; + s[i] = (char)buf[pos]; + pos++; if (s[i] == '\n') { i++; + newline = true; break; } } @@ -765,12 +1013,19 @@ char *mio_gets (MIO *mio, char *s, size_t size) s[i] = 0; rv = s; } - if (mio->impl.mem.pos >= mio->impl.mem.size) + if (!newline && pos >= buf_size) mio->impl.mem.eof = true; + mio->impl.mem.pos = pos; + mio->impl.mem.size = buf_size; } return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -784,11 +1039,13 @@ void mio_clearerr (MIO *mio) { if (mio->type == MIO_TYPE_FILE) clearerr (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { mio->impl.mem.error = false; mio->impl.mem.eof = false; } + else + AssertNotReached (); } /** @@ -804,8 +1061,13 @@ int mio_eof (MIO *mio) { if (mio->type == MIO_TYPE_FILE) return feof (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) return mio->impl.mem.eof != false; + else + { + AssertNotReached (); + return 0; + } } /** @@ -821,8 +1083,13 @@ int mio_error (MIO *mio) { if (mio->type == MIO_TYPE_FILE) return ferror (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) return mio->impl.mem.error != false; + else + { + AssertNotReached (); + return 0; + } } /** @@ -843,7 +1110,7 @@ int mio_seek (MIO *mio, long offset, int whence) { if (mio->type == MIO_TYPE_FILE) return fseek (mio->impl.file.fp, offset, whence); - else + else if (mio->type == MIO_TYPE_MEMORY) { /* FIXME: should we support seeking out of bounds like lseek() seems to do? */ int rv = -1; @@ -894,6 +1161,12 @@ int mio_seek (MIO *mio, long offset, int whence) return rv; } + else + { + AssertNotReached (); + return 0; + } + } /** @@ -910,7 +1183,7 @@ long mio_tell (MIO *mio) { if (mio->type == MIO_TYPE_FILE) return ftell (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { long rv = -1; @@ -925,6 +1198,11 @@ long mio_tell (MIO *mio) return rv; } + else + { + AssertNotReached (); + return 0; + } } /** @@ -939,13 +1217,15 @@ void mio_rewind (MIO *mio) { if (mio->type == MIO_TYPE_FILE) rewind (mio->impl.file.fp); - else + else if (mio->type == MIO_TYPE_MEMORY) { mio->impl.mem.pos = 0; mio->impl.mem.ungetch = EOF; mio->impl.mem.eof = false; mio->impl.mem.error = false; } + else + AssertNotReached (); } /** @@ -967,7 +1247,7 @@ int mio_getpos (MIO *mio, MIOPos *pos) pos->type = mio->type; if (mio->type == MIO_TYPE_FILE) rv = fgetpos (mio->impl.file.fp, &pos->impl.file); - else + else if (mio->type == MIO_TYPE_MEMORY) { rv = -1; @@ -984,6 +1264,9 @@ int mio_getpos (MIO *mio, MIOPos *pos) rv = 0; } } + else + AssertNotReached(); + #ifdef MIO_DEBUG if (rv != -1) { @@ -1028,7 +1311,7 @@ int mio_setpos (MIO *mio, MIOPos *pos) if (mio->type == MIO_TYPE_FILE) rv = fsetpos (mio->impl.file.fp, &pos->impl.file); - else + else if (mio->type == MIO_TYPE_MEMORY) { rv = -1; @@ -1041,6 +1324,8 @@ int mio_setpos (MIO *mio, MIOPos *pos) rv = 0; } } + else + AssertNotReached (); return rv; } @@ -1061,3 +1346,38 @@ int mio_flush (MIO *mio) return fflush (mio->impl.file.fp); return 0; } + + +/** + * mio_attach_user_data: + * @mio: A #MIO object + * @user_data: a pointer to any data object + * @user_data_free_func: a call back function to destroy the data object passed as @user_data + * + * Attach any data object to a #MIO object. Attached data can be got with + * mio_get_user_data(). The attached data is destroyed when new data is attached to + * the #MIO object, or #the MIO object itself is destroyed. For destroying the data + * @user_data_free_func is used. + * + */ + +void mio_attach_user_data (MIO *mio, void *user_data, MIODestroyNotify user_data_free_func) +{ + if (mio->udata.d && mio->udata.f) + mio->udata.f (mio->udata.d); + + mio->udata.d = user_data; + mio->udata.f = user_data_free_func; +} + +/** + * mio_get_user_data: + * @mio: A #MIO object + * + * Returns: user data attached with mio_attach_user_data() to a #MIO object. + * + */ +void *mio_get_user_data (MIO *mio) +{ + return mio->udata.d; +} Modified: ctags/main/mio.h 40 lines changed, 12 insertions(+), 28 deletions(-) =================================================================== @@ -21,7 +21,11 @@ #ifndef MIO_H #define MIO_H +#ifndef QUALIFIER #include "general.h" /* must always come first */ +#else +#include "gcc-attr.h" +#endif #include <stdio.h> #include <stdarg.h> @@ -96,7 +100,7 @@ typedef void (*MIODestroyNotify) (void *data); */ struct _MIOPos { /*< private >*/ - unsigned int type; + MIOType type; #ifdef MIO_DEBUG void *tag; #endif @@ -106,33 +110,6 @@ struct _MIOPos { } impl; }; -/** - * MIO: - * - * An object representing a #MIO stream. No assumptions should be made about - * what compose this object, and none of its fields should be accessed directly. - */ -struct _MIO { - /*< private >*/ - unsigned int type; - union { - struct { - FILE *fp; - MIOFCloseFunc close_func; - } file; - struct { - unsigned char *buf; - int ungetch; - size_t pos; - size_t size; - size_t allocated_size; - MIOReallocFunc realloc_func; - MIODestroyNotify free_func; - bool error; - bool eof; - } mem; - } impl; -}; MIO *mio_new_file (const char *filename, const char *mode); @@ -145,6 +122,10 @@ MIO *mio_new_memory (unsigned char *data, size_t size, MIOReallocFunc realloc_func, MIODestroyNotify free_func); + +MIO *mio_new_mio (MIO *base, long start, size_t size); +MIO *mio_ref (MIO *mio); + int mio_free (MIO *mio); FILE *mio_file_get_fp (MIO *mio); unsigned char *mio_memory_get_data (MIO *mio, size_t *size); @@ -175,4 +156,7 @@ int mio_getpos (MIO *mio, MIOPos *pos); int mio_setpos (MIO *mio, MIOPos *pos); int mio_flush (MIO *mio); +void mio_attach_user_data (MIO *mio, void *user_data, MIODestroyNotify user_data_free_func); +void *mio_get_user_data (MIO *mio); + #endif /* MIO_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] 7ebcfb: Define gcc attributes inside gcc-attr.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:36 UTC Commit: 7ebcfb77dca3accd06effb8f4698f8ab04ab5e8f
https://github.com/geany/geany/commit/7ebcfb77dca3accd06effb8f4698f8ab04ab5…
Log Message: ----------- Define gcc attributes inside gcc-attr.h Modified Paths: -------------- ctags/Makefile.am ctags/main/gcc-attr.h ctags/main/general.h Modified: ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -61,6 +61,7 @@ libctags_la_SOURCES = \ main/entry.h \ main/error.c \ main/error.h \ + main/gcc-attr.h \ main/general.h \ main/keyword.c \ main/keyword.h \ Modified: ctags/main/gcc-attr.h 30 lines changed, 30 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,30 @@ +/* +* 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. +*/ + +/* This is derived from general.h. + Only readtags related source file should include this. + ctags related source file should include genera.h instead. */ + +#ifndef CTAGS_MAIN_GCC_ATTR_H +#define CTAGS_MAIN_GCC_ATTR_H + +/* Prevent warnings about unused variables in GCC. */ +#if defined (__GNUC__) && !defined (__GNUG__) +# ifdef __MINGW32__ +# define CTAGS_ATTR_UNUSED +# else +# define CTAGS_ATTR_UNUSED __attribute__((unused)) +# endif +# define CTAGS_ATTR_PRINTF(s,f) __attribute__((format (printf, s, f))) +# define attr__noreturn __attribute__((__noreturn__)) +#else +# define CTAGS_ATTR_UNUSED +# define CTAGS_ATTR_PRINTF(s,f) +# define attr__noreturn +#endif + +#endif /* CTAGS_MAIN_GCC_ATTR_H */ Modified: ctags/main/general.h 13 lines changed, 1 insertions(+), 12 deletions(-) =================================================================== @@ -27,18 +27,7 @@ /* * MACROS */ - -/* This is a helpful internal feature of later versions (> 2.7) of GCC - * to prevent warnings about unused variables. - */ -#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__APPLE_CC__) || defined (__GNUG__)) -# define CTAGS_ATTR_UNUSED __attribute__((unused)) -# define CTAGS_ATTR_PRINTF(s,f) __attribute__((format (printf, s, f))) -#else -# define CTAGS_ATTR_UNUSED -# define CTAGS_ATTR_PRINTF(s,f) -#endif - +#include "gcc-attr.h" /* MS-DOS doesn't allow manipulation of standard error, so we send it to * stdout instead. -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] ded5ea: Move debug related code to debug.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: ded5ea3eeaefa0c7ac25f685015668b34dbf4fcb
https://github.com/geany/geany/commit/ded5ea3eeaefa0c7ac25f685015668b34dbf4…
Log Message: ----------- Move debug related code to debug.c/h Modified Paths: -------------- ctags/Makefile.am ctags/main/debug.c ctags/main/debug.h ctags/main/entry.c ctags/main/general.h ctags/main/lregex.c ctags/main/main.c ctags/main/parse.c ctags/main/sort.c ctags/parsers/powershell.c Modified: ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -57,6 +57,7 @@ libctags_la_SOURCES = \ main/args.h \ main/ctags.h \ main/debug.h \ + main/debug.c \ main/entry.c \ main/entry.h \ main/error.c \ Modified: ctags/main/debug.c 23 lines changed, 23 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,23 @@ +/* +* Copyright (c) 1996-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. +* +* This module contains debugging functions. +*/ + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include <glib.h> + +#include "debug.h" + +/* wrap g_warning so we don't include glib.h for all parsers, to keep compat with CTags */ +void utils_warn(const char *msg) +{ + g_warning("%s", msg); +} Modified: ctags/main/debug.h 15 lines changed, 12 insertions(+), 3 deletions(-) =================================================================== @@ -14,9 +14,18 @@ */ #include "general.h" /* must always come first */ -#ifdef DEBUG -# include <assert.h> -#endif #include "entry.h" +/* +* Macros +*/ + +/* fake debug statement macro */ +#define DebugStatement(x) ; +#define PrintStatus(x) ; +/* wrap g_warning so we don't include glib.h for all parsers, to keep compat with CTags */ +extern void utils_warn(const char *msg); +#define Assert(x) if (!(x)) utils_warn("Assert(" #x ") failed!") +#define AssertNotReached() Assert(!"The control reaches unexpected place") + #endif /* CTAGS_MAIN_DEBUG_H */ Modified: ctags/main/entry.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -35,6 +35,7 @@ #endif #include "ctags.h" +#include "debug.h" #include "entry.h" #include "main.h" #include "options.h" Modified: ctags/main/general.h 6 lines changed, 0 insertions(+), 6 deletions(-) =================================================================== @@ -96,12 +96,6 @@ int fnmatch(const char *pattern, const char *string, int flags); #endif -/* fake debug statement macro */ -#define DebugStatement(x) ; -#define PrintStatus(x) ; -/* wrap g_warning so we don't include glib.h for all parsers, to keep compat with CTags */ -void utils_warn(const char *msg); -#define Assert(x) if (!(x)) utils_warn("Assert(" #x ") failed!") /* * DATA DECLARATIONS */ Modified: ctags/main/lregex.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -27,6 +27,7 @@ # endif #endif +#include "debug.h" #include "mio.h" #include "entry.h" #include "parse.h" Modified: ctags/main/main.c 8 lines changed, 0 insertions(+), 8 deletions(-) =================================================================== @@ -22,8 +22,6 @@ */ #include "general.h" /* must always come first */ -#include <glib.h> - /* To provide timings features if available. */ #ifdef HAVE_CLOCK @@ -168,9 +166,3 @@ static void printTotals (const clock_t *const timeStamps) } #endif /* Unused in Geany */ - -/* wrap g_warning so we don't include glib.h for all parsers, to keep compat with CTags */ -void utils_warn(const char *msg) -{ - g_warning("%s", msg); -} Modified: ctags/main/parse.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -15,7 +15,7 @@ #include <string.h> - +#include "debug.h" #include "mio.h" #include "entry.h" #include "keyword.h" Modified: ctags/main/sort.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -18,6 +18,7 @@ #include <string.h> #include <stdio.h> +#include "debug.h" #include "entry.h" #include "routines.h" #include "options.h" Modified: ctags/parsers/powershell.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -14,6 +14,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ +#include "debug.h" #include "main.h" #include "parse.h" #include "read.h" -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 580beb: Remove all unused code from main.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:13:41 UTC Commit: 580beba0c7fe8361afa52976901bb67d8d45b084
https://github.com/geany/geany/commit/580beba0c7fe8361afa52976901bb67d8d45b…
Log Message: ----------- Remove all unused code from main.c Modified Paths: -------------- ctags/main/main.c Modified: ctags/main/main.c 122 lines changed, 0 insertions(+), 122 deletions(-) =================================================================== @@ -22,70 +22,15 @@ */ #include "general.h" /* must always come first */ -/* To provide timings features if available. - */ -#ifdef HAVE_CLOCK -# ifdef HAVE_TIME_H -# include <time.h> -# endif -#else -# ifdef HAVE_TIMES -# ifdef HAVE_SYS_TIMES_H -# include <sys/times.h> -# endif -# endif -#endif - -/* To provide directory searching for recursion feature. - */ - -#ifdef HAVE_DIRENT_H -# ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> /* required by dirent.h */ -# endif -# include <dirent.h> /* to declare opendir() */ -#endif -#ifdef HAVE_DIRECT_H -# include <direct.h> /* to _getcwd() */ -#endif -#ifdef HAVE_DIR_H -# include <dir.h> /* to declare findfirst() and findnext */ -#endif -#ifdef HAVE_IO_H -# include <io.h> /* to declare _findfirst() */ -#endif - #include <string.h> -#include "debug.h" -#include "entry.h" -#include "keyword.h" -#include "main.h" #include "options.h" -#include "read.h" -#include "routines.h" -/* -* MACROS -*/ -#define plural(value) (((unsigned long)(value) == 1L) ? "" : "s") - -/* -* DATA DEFINITIONS -*/ -static struct { long files, lines, bytes; } Totals = { 0, 0, 0 }; - -/* -* FUNCTION DEFINITIONS -*/ extern void addTotals ( const unsigned int files, const long unsigned int lines, const long unsigned int bytes) { - Totals.files += files; - Totals.lines += lines; - Totals.bytes += bytes; } extern bool isDestinationStdout (void) @@ -99,70 +44,3 @@ extern bool isDestinationStdout (void) toStdout = true; return toStdout; } - -#if 0 /* Unused in Geany */ - -#if defined (HAVE_CLOCK) -# define CLOCK_AVAILABLE -# ifndef CLOCKS_PER_SEC -# define CLOCKS_PER_SEC 1000000 -# endif -#elif defined (HAVE_TIMES) -# define CLOCK_AVAILABLE -# define CLOCKS_PER_SEC 60 -static clock_t clock (void) -{ - struct tms buf; - - times (&buf); - return (buf.tms_utime + buf.tms_stime); -} -#else -# define clock() (clock_t)0 -#endif - -static void printTotals (const clock_t *const timeStamps) -{ - const unsigned long totalTags = TagFile.numTags.added + - TagFile.numTags.prev; - - fprintf (errout, "%ld file%s, %ld line%s (%ld kB) scanned", - Totals.files, plural (Totals.files), - Totals.lines, plural (Totals.lines), - Totals.bytes/1024L); -#ifdef CLOCK_AVAILABLE - { - const double interval = ((double) (timeStamps [1] - timeStamps [0])) / - CLOCKS_PER_SEC; - - fprintf (errout, " in %.01f seconds", interval); - if (interval != (double) 0.0) - fprintf (errout, " (%lu kB/s)", - (unsigned long) (Totals.bytes / interval) / 1024L); - } -#endif - fputc ('\n', errout); - - fprintf (errout, "%lu tag%s added to tag file", - TagFile.numTags.added, plural (TagFile.numTags.added)); - if (Option.append) - fprintf (errout, " (now %lu tags)", totalTags); - fputc ('\n', errout); - - if (totalTags > 0 && Option.sorted) - { - fprintf (errout, "%lu tag%s sorted", totalTags, plural (totalTags)); -#ifdef CLOCK_AVAILABLE - fprintf (errout, " in %.02f seconds", - ((double) (timeStamps [2] - timeStamps [1])) / CLOCKS_PER_SEC); -#endif - fputc ('\n', errout); - } - -#ifdef DEBUG - fprintf (errout, "longest tag line = %lu\n", - (unsigned long) TagFile.max.line); -#endif -} - -#endif /* Unused in Geany */ -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] c6294e: Grab uctags ctags.h and add repoinfo.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: c6294e37c9e511228bd31819548f809537980156
https://github.com/geany/geany/commit/c6294e37c9e511228bd31819548f809537980…
Log Message: ----------- Grab uctags ctags.h and add repoinfo.c/h Modified Paths: -------------- ctags/Makefile.am ctags/main/ctags.h ctags/main/entry.c ctags/main/repoinfo.c ctags/main/repoinfo.h Modified: ctags/Makefile.am 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -83,6 +83,8 @@ libctags_la_SOURCES = \ main/ptrarray.h \ main/read.c \ main/read.h \ + main/repoinfo.c \ + main/repoinfo.h \ main/routines.c \ main/routines.h \ main/sort.c \ Modified: ctags/main/ctags.h 21 lines changed, 15 insertions(+), 6 deletions(-) =================================================================== @@ -14,12 +14,21 @@ /* * MACROS */ -#ifndef PROGRAM_VERSION -# define PROGRAM_VERSION "5.0.1" +#if defined (HAVE_CONFIG_H) +# define PROGRAM_VERSION PACKAGE_VERSION +#else +# define PROGRAM_VERSION "0.0.0" #endif -#define PROGRAM_NAME "Exuberant Ctags" -#define PROGRAM_URL "
http://ctags.sourceforge.net
" -#define AUTHOR_NAME "Darren Hiebert" -#define AUTHOR_EMAIL "darren(a)hiebert.com" +#define PROGRAM_NAME "Universal Ctags" +#define PROGRAM_URL "
https://ctags.io/
" +#define PROGRAM_COPYRIGHT "Copyright (C) 2015" +#define AUTHOR_NAME "Universal Ctags Team" + +/* + * Constant + */ +extern const char* ctags_repoinfo; +#define CTAGS_FIELD_PREFIX "UCTAGS" + #endif /* CTAGS_MAIN_CTAGS_H */ Modified: ctags/main/entry.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -149,7 +149,7 @@ static void addPseudoTags (void) writePseudoTag ("TAG_FILE_FORMAT", format, formatComment); writePseudoTag ("TAG_FILE_SORTED", Option.sorted ? "1":"0", "0=unsorted, 1=sorted"); - writePseudoTag ("TAG_PROGRAM_AUTHOR", AUTHOR_NAME, AUTHOR_EMAIL); + 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, ""); Modified: ctags/main/repoinfo.c 12 lines changed, 12 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,12 @@ +#include "general.h" +#include "ctags.h" + +#ifdef HAVE_REPOINFO_H +#include "main/repoinfo.h" +#endif + +#ifndef CTAGS_REPOINFO +#define CTAGS_REPOINFO ((char*)0) +#endif + +const char* ctags_repoinfo = CTAGS_REPOINFO; Modified: ctags/main/repoinfo.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1 @@ +#define CTAGS_REPOINFO "ff6491f" -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 85a894: Grab args.c/h uctags implementation
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: 85a894b09789f2ed7201ba6f92be3d0092e33da4
https://github.com/geany/geany/commit/85a894b09789f2ed7201ba6f92be3d0092e33…
Log Message: ----------- Grab args.c/h uctags implementation Basically dead code for us. Modified Paths: -------------- ctags/main/args.c ctags/main/args.h Modified: ctags/main/args.c 50 lines changed, 43 insertions(+), 7 deletions(-) =================================================================== @@ -69,6 +69,12 @@ static char* nextStringLine (const char** const next) } if (*end == '\n') ++end; + else if (*end == '\r') + { + ++end; + if (*end == '\n') + ++end; + } *next = end; return result; } @@ -121,26 +127,59 @@ static char* nextFileLine (FILE* const fp) int c; c = fgetc (fp); - while (c != EOF && c != '\n') + while (c != EOF) { - vStringPut (vs, c); + if (c != '\n' && c != '\r') + vStringPut (vs, c); + else if (vStringLength (vs) > 0) + break; c = fgetc (fp); } - if (vStringLength (vs) > 0) + if (c != EOF || vStringLength (vs) > 0) { + if (c == '\r') + { + c = fgetc (fp); + if (c != '\n') + c = ungetc (c, fp); + } + vStringStripTrailing (vs); result = xMalloc (vStringLength (vs) + 1, char); + vStringStripLeading (vs); strcpy (result, vStringValue (vs)); } vStringDelete (vs); } return result; } +static bool isCommentLine (char* line) +{ + while (isspace(*line)) + ++line; + return (*line == '#'); +} + +static char* nextFileLineSkippingComments (FILE* const fp) +{ + char* result; + bool comment; + + do + { + result = nextFileLine (fp); + comment = (result && isCommentLine (result)); + if (comment) + eFree (result); + } while (comment); + return result; +} + static char* nextFileString (const Arguments* const current, FILE* const fp) { char* result; if (current->lineMode) - result = nextFileLine (fp); + result = nextFileLineSkippingComments (fp); else result = nextFileArg (fp); return result; @@ -151,8 +190,6 @@ extern Arguments* argNewFromString (const char* const string) Arguments* result = xMalloc (1, Arguments); memset (result, 0, sizeof (Arguments)); result->type = ARG_STRING; - result->u.stringArgs.string = string; - result->u.stringArgs.item = string; result->u.stringArgs.next = string; result->item = nextString (result, &result->u.stringArgs.next); return result; @@ -224,7 +261,6 @@ extern void argForth (Arguments* const current) case ARG_STRING: if (current->item != NULL) eFree (current->item); - current->u.stringArgs.item = current->u.stringArgs.next; current->item = nextString (current, ¤t->u.stringArgs.next); break; case ARG_ARGV: Modified: ctags/main/args.h 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -20,13 +20,13 @@ * DATA DECLARATIONS */ +typedef enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } argType; + typedef struct sArgs { - enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } type; + argType type; union { struct sStringArgs { - const char* string; const char* next; - const char* item; } stringArgs; struct sArgvArgs { char* const* argv; -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 65f782: Don't initialize ExecutableProgram and ExecutableName
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: 65f782b6d2acb7e967be717a1a4dafa76b3ae38c
https://github.com/geany/geany/commit/65f782b6d2acb7e967be717a1a4dafa76b3ae…
Log Message: ----------- Don't initialize ExecutableProgram and ExecutableName We shouldn't need it. Modified Paths: -------------- ctags/main/routines.c Modified: ctags/main/routines.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -162,8 +162,8 @@ const char *const PathDelimiters = ":/\\"; char *CurrentDirectory; -static const char *ExecutableProgram = NULL; -static const char *ExecutableName = "geany"; +static const char *ExecutableProgram; +static const char *ExecutableName; /* * 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] d5b60d: Use uctags implementation of strstr()
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: d5b60d2f21560d0dd0479ff32090cd6865c49a3f
https://github.com/geany/geany/commit/d5b60d2f21560d0dd0479ff32090cd6865c49…
Log Message: ----------- Use uctags implementation of strstr() Modified Paths: -------------- ctags/main/routines.c Modified: ctags/main/routines.c 7 lines changed, 3 insertions(+), 4 deletions(-) =================================================================== @@ -239,13 +239,12 @@ extern void eFree (void *const ptr) extern char* strstr (const char *str, const char *substr) { const size_t length = strlen (substr); - const char *match = NULL; const char *p; - for (p = str ; *p != '\0' && match == NULL ; ++p) + for (p = str ; *p != '\0' ; ++p) if (strncmp (p, substr, length) == 0) - match = p; - return (char*) match; + return (char*) p; + return NULL; } #endif -------------- 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
...
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