From 00920360da8d93fa9145da1e07ce916b258c0096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Sun, 9 Oct 2016 16:49:13 +0200 Subject: [PATCH] entry: Sync initTagEntry() code For now use "source" instead of "input" for various functions inside read.c which we need as we don't initialize "input" yet. --- ctags/main/entry.c | 76 ++++++++++++++++++++++++++++++++++++++++------ ctags/main/entry.h | 15 ++++++++- ctags/main/read.c | 15 +++++++++ ctags/main/read.h | 3 ++ 4 files changed, 99 insertions(+), 10 deletions(-) diff --git a/ctags/main/entry.c b/ctags/main/entry.c index 1c38a3e4..a4fcc9e9 100644 --- a/ctags/main/entry.c +++ b/ctags/main/entry.c @@ -504,17 +504,75 @@ out: return r; } -extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind) +extern void initTagEntry (tagEntryInfo *const e, const char *const name, + const kindOption *kind) { - Assert (File.source.name != NULL); + initTagEntryFull(e, name, + getInputLineNumber (), + getInputLanguageName (), + getInputFilePosition (), + getInputFileTagPath (), + kind, + ROLE_INDEX_DEFINITION, + getSourceFileTagPath(), + getSourceLanguageName(), + getSourceLineNumber() - getInputLineNumber ()); +} + +extern void initRefTagEntry (tagEntryInfo *const e, const char *const name, + const kindOption *kind, int roleIndex) +{ + initTagEntryFull(e, name, + getInputLineNumber (), + getInputLanguageName (), + getInputFilePosition (), + getInputFileTagPath (), + kind, + roleIndex, + getSourceFileTagPath(), + getSourceLanguageName(), + getSourceLineNumber() - getInputLineNumber ()); +} + +extern void initTagEntryFull (tagEntryInfo *const e, const char *const name, + unsigned long lineNumber, + const char* language, + MIOPos filePosition, + const char *inputFileName, + const kindOption *kind, + int roleIndex, + const char *sourceFileName, + const char* sourceLanguage, + long sourceLineNumberDifference) +{ + int i; + Assert (getInputFileName() != NULL); + memset (e, 0, sizeof (tagEntryInfo)); - e->lineNumberEntry = (bool) (Option.locate == EX_LINENUM); - e->lineNumber = getSourceLineNumber (); - e->language = getSourceLanguageName (); - e->filePosition = getInputFilePosition (); - e->sourceFileName = getSourceFileTagPath (); - e->name = name; - e->kind = kind; + e->lineNumberEntry = (bool) (Option.locate == EX_LINENUM); + e->lineNumber = lineNumber; +/* e->boundaryInfo = getNestedInputBoundaryInfo (lineNumber); */ + e->language = language; + e->filePosition = filePosition; + e->inputFileName = inputFileName; + e->name = name; + e->extensionFields.scopeIndex = CORK_NIL; + e->kind = kind; + + Assert (roleIndex >= ROLE_INDEX_DEFINITION); + Assert (kind == NULL || roleIndex < kind->nRoles); + e->extensionFields.roleIndex = roleIndex; + if (roleIndex > ROLE_INDEX_DEFINITION) + markTagExtraBit (e, XTAG_REFERENCE_TAGS); + + e->sourceLanguage = sourceLanguage; + e->sourceFileName = sourceFileName; + e->sourceLineNumberDifference = sourceLineNumberDifference; + + e->usedParserFields = 0; + + for ( i = 0; i < PRE_ALLOCATED_PARSER_FIELDS; i++ ) + e->parserFields[i].ftype = FIELD_UNKNOWN; } extern void setTagWriter (tagWriter *t) diff --git a/ctags/main/entry.h b/ctags/main/entry.h index d6c72862..8dba34f0 100644 --- a/ctags/main/entry.h +++ b/ctags/main/entry.h @@ -114,7 +114,20 @@ extern const char *tagFileName (void); extern void openTagFile (void); extern void closeTagFile (const bool resize); extern int makeTagEntry (const tagEntryInfo *const tag); -extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind); +extern void initTagEntry (tagEntryInfo *const e, const char *const name, + const kindOption *kind); +extern void initRefTagEntry (tagEntryInfo *const e, const char *const name, + const kindOption *kind, int roleIndex); +extern void initTagEntryFull (tagEntryInfo *const e, const char *const name, + unsigned long lineNumber, + const char* language, + MIOPos filePosition, + const char *inputFileName, + const kindOption *kind, + int roleIndex, + const char *sourceFileName, + const char* sourceLanguage, + long sourceLineNumberDifference); extern unsigned long numTagsAdded(void); extern void setNumTagsAdded (unsigned long nadded); diff --git a/ctags/main/read.c b/ctags/main/read.c index f6275f40..024b0c0c 100644 --- a/ctags/main/read.c +++ b/ctags/main/read.c @@ -35,6 +35,21 @@ static MIOPos StartOfLine; /* holds deferred position of start of line */ * FUNCTION DEFINITIONS */ +extern langType getInputLanguage (void) +{ + return File.source.language; +} + +extern const char *getInputLanguageName (void) +{ + return getLanguageName (getInputLanguage()); +} + +extern const char *getInputFileTagPath (void) +{ + return vStringValue (File.source.tagPath); +} + extern kindOption *getInputLanguageFileKind (void) { return getLanguageFileKind (File.input.language); diff --git a/ctags/main/read.h b/ctags/main/read.h index 8bc44f26..261517b9 100644 --- a/ctags/main/read.h +++ b/ctags/main/read.h @@ -98,6 +98,9 @@ extern inputFile File; */ /* InputFile: reading from fp in inputFile with updating fields in input fields */ +extern langType getInputLanguage (void); +extern const char *getInputLanguageName (void); +extern const char *getInputFileTagPath (void); extern kindOption *getInputLanguageFileKind (void); extern void freeSourceFileResources (void);