Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sat, 30 Jul 2016 09:53:26 UTC Commit: 1e36d2367e2b1180a84d7830b0f0e79be2dc44c8 https://github.com/geany/geany/commit/1e36d2367e2b1180a84d7830b0f0e79be2dc44...
Log Message: ----------- Add separate "input" entry to sInputFile and use it
This patch basically just replaces
sInputFile.name -> sInputFile.input.name sInputFile.lineNumber -> sInputFile.input.lineNumber
plus some minor related stuff.
Modified Paths: -------------- ctags/main/entry.c ctags/main/read.c ctags/main/read.h ctags/main/vstring.c ctags/main/vstring.h ctags/parsers/sh.c
Modified: ctags/main/entry.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -387,7 +387,7 @@ extern void makeTagEntry (const tagEntryInfo *const tag) { Assert (tag->name != NULL); if (tag->name [0] == '\0') - error (WARNING, "ignoring null tag in %s", vStringValue (File.name)); + error (WARNING, "ignoring null tag in %s", getInputFileName ()); else { int length = 0;
Modified: ctags/main/read.c 25 lines changed, 13 insertions(+), 12 deletions(-) =================================================================== @@ -37,7 +37,7 @@ static MIOPos StartOfLine; /* holds deferred position of start of line */
extern void freeSourceFileResources (void) { - vStringDelete (File.name); + vStringDelete (File.input.name); vStringDelete (File.path); vStringDelete (File.source.name); vStringDelete (File.line); @@ -52,9 +52,9 @@ static void setInputFileName (const char *const fileName) const char *const head = fileName; const char *const tail = baseFilename (head);
- if (File.name != NULL) - vStringDelete (File.name); - File.name = vStringNewInit (fileName); + if (File.input.name != NULL) + vStringDelete (File.input.name); + File.input.name = vStringNewInit (fileName);
if (File.path != NULL) vStringDelete (File.path); @@ -76,10 +76,11 @@ static void setSourceFileParameters (vString *const fileName, const langType lan if (File.source.tagPath != NULL) eFree (File.source.tagPath); if (! Option.tagRelative || isAbsolutePath (vStringValue (fileName))) - File.source.tagPath = eStrdup (vStringValue (fileName)); + File.source.tagPath = vStringNewCopy (fileName); else File.source.tagPath = - relativeFilename (vStringValue (fileName), TagFile.directory); + vStringNewOwn (relativeFilename (vStringValue (fileName), + TagFile.directory));
if (vStringLength (fileName) > TagFile.max.file) TagFile.max.file = vStringLength (fileName); @@ -266,7 +267,7 @@ extern boolean fileOpen (const char *const fileName, const langType language) mio_getpos (File.fp, &StartOfLine); mio_getpos (File.fp, &File.filePosition); File.currentLine = NULL; - File.lineNumber = 0L; + File.input.lineNumber = 0L; File.eof = FALSE; File.newLine = TRUE;
@@ -312,7 +313,7 @@ extern boolean bufferOpen (unsigned char *buffer, size_t buffer_size, mio_getpos (File.fp, &StartOfLine); mio_getpos (File.fp, &File.filePosition); File.currentLine = NULL; - File.lineNumber = 0L; + File.input.lineNumber = 0L; File.eof = FALSE; File.newLine = TRUE;
@@ -337,8 +338,8 @@ extern void fileClose (void) * and is incremented upon each newline. */ if (Option.printTotals) - addTotals (0, File.lineNumber - 1L, - getFileSize (vStringValue (File.name))); + addTotals (0, File.input.lineNumber - 1L, + getFileSize (vStringValue (File.input.name)));
mio_free (File.fp); File.fp = NULL; @@ -356,7 +357,7 @@ static void fileNewline (void) { File.filePosition = StartOfLine; File.newLine = FALSE; - File.lineNumber++; + File.input.lineNumber++; File.source.lineNumber++; DebugStatement ( if (Option.breakLine == File.lineNumber) lineBreak (); ) DebugStatement ( debugPrintf (DEBUG_RAW, "%6ld: ", File.lineNumber); ) @@ -610,7 +611,7 @@ extern char *readSourceLine (vString *const vLine, MIOPos location, *pSeekValue = mio_tell (File.fp); result = readLine (vLine, File.fp); if (result == NULL) - error (FATAL, "Unexpected end of file: %s", vStringValue (File.name)); + error (FATAL, "Unexpected end of file: %s", getInputFileName ()); mio_setpos (File.fp, &orignalPosition);
return result;
Modified: ctags/main/read.h 29 lines changed, 17 insertions(+), 12 deletions(-) =================================================================== @@ -25,11 +25,11 @@ /* * MACROS */ -#define getInputLineNumber() File.lineNumber +#define getInputLineNumber() File.input.lineNumber #define getInputFileName() vStringValue (File.source.name) #define getInputFilePosition() File.filePosition #define getSourceFileName() vStringValue (File.source.name) -#define getSourceFileTagPath() File.source.tagPath +#define getSourceFileTagPath() vStringValue (File.source.tagPath) #define getSourceLanguage() File.source.language #define getSourceLanguageName() getLanguageName (File.source.language) #define getSourceLineNumber() File.source.lineNumber @@ -60,15 +60,25 @@ enum eCharacters { CHAR_SYMBOL = ('C' + 0x80) };
-/* Maintains the state of the current source file. +/* Maintains the state of the current input file. */ +typedef struct sInputFileInfo { + vString *name; /* name to report for input file */ + vString *tagPath; /* path of input file relative to tag file */ + unsigned long lineNumber;/* line number in the input file */ + unsigned long lineNumberOrigin; /* The value set to `lineNumber' + when `resetInputFile' is called + on the input stream. + This is needed for nested stream. */ + boolean isHeader; /* is input file a header file? */ + langType language; /* language of input file */ +} inputFileInfo; + typedef struct sInputFile { - vString *name; /* name of input file */ vString *path; /* path of input file (if any) */ vString *line; /* last line read from file */ const unsigned char* currentLine; /* current line being worked on */ MIO *fp; /* stream used for reading the file */ - unsigned long lineNumber; /* line number in the input file */ MIOPos filePosition; /* file position of current line */ unsigned int ungetchIdx; int ungetchBuf[3]; /* characters that were ungotten */ @@ -79,13 +89,8 @@ typedef struct sInputFile { * was defined. This may be different from the input file when #line * directives are processed (i.e. the input file is preprocessor output). */ - struct sSource { - vString *name; /* name to report for source file */ - char *tagPath; /* path of source file relative to tag file */ - unsigned long lineNumber;/* line number in the source file */ - boolean isHeader; /* is source file a header file? */ - langType language; /* language of source file */ - } source; + inputFileInfo input; /* name, lineNumber */ + inputFileInfo source; } inputFile;
/*
Modified: ctags/main/vstring.c 10 lines changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -234,4 +234,14 @@ extern void vStringSetLength (vString *const string) string->length = strlen (string->buffer); }
+extern vString *vStringNewOwn (char *s) +{ + vString *r; + + r = vStringNewInit (s); + eFree (s); + + return r; +} + /* vi:set tabstop=4 shiftwidth=4: */
Modified: ctags/main/vstring.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -79,6 +79,8 @@ extern void vStringCopyToLower (vString *const dest, const vString *const src); extern void vStringSetLength (vString *const string); extern void vStringTruncate (vString *const string, const size_t length);
+extern vString *vStringNewOwn (char *s); + #endif /* _VSTRING_H */
/* vi:set tabstop=4 shiftwidth=4: */
Modified: ctags/parsers/sh.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -43,7 +43,7 @@ static kindOption ShKinds [] = { */ static boolean hackReject (const vString* const tagName) { - const char *const scriptName = baseFilename (vStringValue (File.name)); + const char *const scriptName = baseFilename (getInputFileName ()); boolean result = (boolean) (strcmp (scriptName, "configure") == 0 && strcmp (vStringValue (tagName), "main") == 0); return result;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).