geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

entry.c File Reference
#include "general.h"
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include "debug.h"
#include "entry_p.h"
#include "field.h"
#include "fmt_p.h"
#include "kind.h"
#include "nestlevel.h"
#include "options_p.h"
#include "ptag_p.h"
#include "rbtree.h"
#include "read.h"
#include "read_p.h"
#include "routines.h"
#include "routines_p.h"
#include "parse_p.h"
#include "ptrarray.h"
#include "sort_p.h"
#include "strlist.h"
#include "subparser_p.h"
#include "trashbox.h"
#include "writer_p.h"
#include "xtag_p.h"
Include dependency graph for entry.c:

Go to the source code of this file.

Classes

struct  eTagFile
 
struct  eTagFile::sNumTags
 
struct  eTagFile::sMax
 
struct  sTagEntryInfoX
 
struct  anyKindsEntryInScopeData
 

Macros

#define USE_REPLACEMENT_TRUNCATE
 
#define field(x)   (fields + ((size_t) (x) * fieldLength))
 
#define WHOLE_FILE   -1L
 

Typedefs

typedef struct eTagFile tagFile
 
typedef struct sTagEntryInfoX tagEntryInfoX
 

Functions

void freeTagFileResources (void)
 
const char * tagFileName (void)
 
void abort_if_ferror (MIO *const mio)
 
static void rememberMaxLengths (const size_t nameLength, const size_t lineLength)
 
static void addCommonPseudoTags (void)
 
void makeFileTag (const char *const fileName)
 
static void updateSortedFlag (const char *const line, MIO *const mio, MIOPos startOfLine)
 
static long unsigned int updatePseudoTags (MIO *const mio)
 
static bool isValidTagAddress (const char *const excmd)
 
static bool isCtagsLine (const char *const line)
 
static bool isEtagsLine (const char *const line)
 
static bool isTagFile (const char *const filename)
 
void openTagFile (void)
 
static void copyBytes (MIO *const fromMio, MIO *const toMio, const long size)
 
static void copyFile (const char *const from, const char *const to, const long size)
 
static int replacementTruncate (const char *const name, const long size)
 
static void internalSortTagFile (void)
 
static void sortTagFile (void)
 
static void resizeTagFile (const long newSize)
 
static void writeEtagsIncludes (MIO *const mio)
 
void closeTagFile (const bool resize)
 
static size_t appendInputLine (int putc_func(char, void *), const char *const line, unsigned int patternLengthLimit, void *data, bool *omitted)
 
static int vstring_putc (char c, void *data)
 
static int vstring_puts (const char *s, void *data)
 
char * readLineFromBypassForTag (vString *const vLine, const tagEntryInfo *const tag, long *const pSeekValue)
 
size_t truncateTagLineAfterTag (char *const line, const char *const token, const bool discardNewline)
 
static char * getFullQualifiedScopeNameFromCorkQueue (const tagEntryInfo *inner_scope)
 
void getTagScopeInformation (tagEntryInfo *const tag, const char **kind, const char **name)
 
static int makePatternStringCommon (const tagEntryInfo *const tag, int(*putc_func)(char, void *), int(*puts_func)(const char *, void *), void *output)
 
char * makePatternString (const tagEntryInfo *const tag)
 
static tagFieldtagFieldNew (fieldType ftype, const char *value, bool valueOwner)
 
static void tagFieldDelete (tagField *f)
 
static void attachParserFieldGeneric (tagEntryInfo *const tag, fieldType ftype, const char *value, bool valueOwner)
 
void attachParserField (tagEntryInfo *const tag, bool inCorkQueue, fieldType ftype, const char *value)
 
void attachParserFieldToCorkEntry (int index, fieldType ftype, const char *value)
 
const tagFieldgetParserFieldForIndex (const tagEntryInfo *tag, int index)
 
const char * getParserFieldValueForType (tagEntryInfo *const tag, fieldType ftype)
 
static void copyParserFields (const tagEntryInfo *const tag, tagEntryInfo *slot)
 
static tagEntryInfonewNilTagEntry (unsigned int corkFlags)
 
static tagEntryInfoXcopyTagEntry (const tagEntryInfo *const tag, unsigned int corkFlags)
 
static void clearParserFields (tagEntryInfo *const tag)
 
static void deleteTagEnry (void *data)
 
static void corkSymtabPut (tagEntryInfoX *scope, const char *name, tagEntryInfoX *item)
 
bool foreachEntriesInScope (int corkIndex, const char *name, entryForeachFunc func, void *data)
 
static bool findName (int corkIndex, tagEntryInfo *entry, void *data)
 
int anyEntryInScope (int corkIndex, const char *name)
 
static bool findNameOfKinds (int corkIndex, tagEntryInfo *entry, void *data)
 
int anyKindEntryInScope (int corkIndex, const char *name, int kind)
 
int anyKindsEntryInScope (int corkIndex, const char *name, const int *kinds, int count)
 
int anyKindsEntryInScopeRecursive (int corkIndex, const char *name, const int *kinds, int count)
 
void registerEntry (int corkIndex)
 
static int queueTagEntry (const tagEntryInfo *const tag)
 
void setupWriter (void *writerClientData)
 
bool teardownWriter (const char *filename)
 
static bool isTagWritable (const tagEntryInfo *const tag)
 
static void buildFqTagCache (tagEntryInfo *const tag)
 
static void writeTagEntry (const tagEntryInfo *const tag)
 
bool writePseudoTag (const ptagDesc *desc, const char *const fileName, const char *const pattern, const char *const parserName)
 
void corkTagFile (unsigned int corkFlags)
 
void uncorkTagFile (void)
 
tagEntryInfogetEntryInCorkQueue (int n)
 
tagEntryInfogetEntryOfNestingLevel (const NestingLevel *nl)
 
size_t countEntryInCorkQueue (void)
 
int makePlaceholder (const char *const name)
 
int makeTagEntry (const tagEntryInfo *const tag)
 
int makeQualifiedTagEntry (const tagEntryInfo *const e)
 
static void initTagEntryFull (tagEntryInfo *const e, const char *const name, unsigned long lineNumber, langType langType_, MIOPos filePosition, const char *inputFileName, int kindIndex, roleBitsType roleBits, const char *sourceFileName, langType sourceLangType, long sourceLineNumberDifference)
 
void initTagEntry (tagEntryInfo *const e, const char *const name, int kindIndex)
 
void initRefTagEntry (tagEntryInfo *const e, const char *const name, int kindIndex, int roleIndex)
 
void initForeignRefTagEntry (tagEntryInfo *const e, const char *const name, langType langType, int kindIndex, int roleIndex)
 
static void markTagExtraBitFull (tagEntryInfo *const tag, xtagType extra, bool mark)
 
void markTagExtraBit (tagEntryInfo *const tag, xtagType extra)
 
bool isTagExtraBitMarked (const tagEntryInfo *const tag, xtagType extra)
 
bool isTagExtra (const tagEntryInfo *const tag)
 
static void assignRoleFull (tagEntryInfo *const e, int roleIndex, bool assign)
 
void assignRole (tagEntryInfo *const e, int roleIndex)
 
bool isRoleAssigned (const tagEntryInfo *const e, int roleIndex)
 
unsigned long numTagsAdded (void)
 
void setNumTagsAdded (unsigned long nadded)
 
unsigned long numTagsTotal (void)
 
unsigned long maxTagsLine (void)
 
void invalidatePatternCache (void)
 
void tagFilePosition (MIOPos *p)
 
void setTagFilePosition (MIOPos *p)
 
const char * getTagFileDirectory (void)
 
static bool markAsPlaceholder (int index, tagEntryInfo *e, void *data)
 
void markAllEntriesInScopeAsPlaceholder (int index)
 

Variables

static tagFile TagFile
 
static bool TagsToStdout = false
 

Macro Definition Documentation

◆ field

#define field (   x)    (fields + ((size_t) (x) * fieldLength))

◆ USE_REPLACEMENT_TRUNCATE

#define USE_REPLACEMENT_TRUNCATE

Definition at line 72 of file entry.c.

◆ WHOLE_FILE

#define WHOLE_FILE   -1L

Typedef Documentation

◆ tagEntryInfoX

typedef struct sTagEntryInfoX tagEntryInfoX

◆ tagFile

typedef struct eTagFile tagFile

Function Documentation

◆ abort_if_ferror()

void abort_if_ferror ( MIO *const  mio)

Definition at line 158 of file entry.c.

References error(), FATAL, mio_error(), NULL, and PERROR.

Referenced by closeTagFile(), endEtagsFile(), writePseudoTag(), and writeTagEntry().

◆ addCommonPseudoTags()

static void addCommonPseudoTags ( void  )
static

Definition at line 173 of file entry.c.

References isPtagCommonInParsers(), LANG_IGNORE, makePtagIfEnabled(), Option, and PTAG_COUNT.

Referenced by openTagFile().

◆ anyEntryInScope()

int anyEntryInScope ( int  corkIndex,
const char *  name 
)

Definition at line 1334 of file entry.c.

References CORK_NIL, findName(), foreachEntriesInScope(), index, and name.

◆ anyKindEntryInScope()

int anyKindEntryInScope ( int  corkIndex,
const char *  name,
int  kind 
)

Definition at line 1366 of file entry.c.

References anyKindsEntryInScope(), and name.

◆ anyKindsEntryInScope()

int anyKindsEntryInScope ( int  corkIndex,
const char *  name,
const int *  kinds,
int  count 
)

◆ anyKindsEntryInScopeRecursive()

int anyKindsEntryInScopeRecursive ( int  corkIndex,
const char *  name,
const int *  kinds,
int  count 
)

◆ appendInputLine()

static size_t appendInputLine ( int   putc_funcchar, void *,
const char *const  line,
unsigned int  patternLengthLimit,
void *  data,
bool *  omitted 
)
static

Definition at line 653 of file entry.c.

References BACKSLASH, sOptionValues::backward, CRETURN, line, NEWLINE, and Option.

Referenced by makePatternStringCommon().

◆ assignRole()

void assignRole ( tagEntryInfo *const  e,
int  roleIndex 
)

Definition at line 1964 of file entry.c.

References assignRoleFull().

Referenced by createCTSTTags(), and matchTagPattern().

◆ assignRoleFull()

static void assignRoleFull ( tagEntryInfo *const  e,
int  roleIndex,
bool  assign 
)
static

◆ attachParserField()

void attachParserField ( tagEntryInfo *const  tag,
bool  inCorkQueue,
fieldType  ftype,
const char *  value 
)

◆ attachParserFieldGeneric()

◆ attachParserFieldToCorkEntry()

void attachParserFieldToCorkEntry ( int  index,
fieldType  ftype,
const char *  value 
)

Definition at line 987 of file entry.c.

References attachParserField(), getEntryInCorkQueue(), and index.

◆ buildFqTagCache()

static void buildFqTagCache ( tagEntryInfo *const  tag)
static

Definition at line 1519 of file entry.c.

References getTagScopeInformation(), and NULL.

Referenced by writeTagEntry().

◆ clearParserFields()

◆ closeTagFile()

◆ copyBytes()

static void copyBytes ( MIO *const  fromMio,
MIO *const  toMio,
const long  size 
)
static

Definition at line 453 of file entry.c.

References eFree(), error(), FATAL, mio_read(), mio_write(), PERROR, and xMalloc.

Referenced by copyFile().

◆ copyFile()

static void copyFile ( const char *const  from,
const char *const  to,
const long  size 
)
static

Definition at line 472 of file entry.c.

References copyBytes(), error(), FATAL, mio_new_file(), mio_unref(), NULL, and PERROR.

Referenced by replacementTruncate().

◆ copyParserFields()

static void copyParserFields ( const tagEntryInfo *const  tag,
tagEntryInfo slot 
)
static

◆ copyTagEntry()

◆ corkSymtabPut()

static void corkSymtabPut ( tagEntryInfoX scope,
const char *  name,
tagEntryInfoX item 
)
static

◆ corkTagFile()

void corkTagFile ( unsigned int  corkFlags)

◆ countEntryInCorkQueue()

size_t countEntryInCorkQueue ( void  )

Definition at line 1650 of file entry.c.

References eTagFile::corkQueue, ptrArrayCount(), and TagFile.

◆ deleteTagEnry()

◆ findName()

static bool findName ( int  corkIndex,
tagEntryInfo entry,
void *  data 
)
static

Definition at line 1326 of file entry.c.

References index.

Referenced by anyEntryInScope().

◆ findNameOfKinds()

static bool findNameOfKinds ( int  corkIndex,
tagEntryInfo entry,
void *  data 
)
static

◆ foreachEntriesInScope()

◆ freeTagFileResources()

void freeTagFileResources ( void  )

Definition at line 142 of file entry.c.

References eTagFile::directory, eFree(), NULL, TagFile, eTagFile::vLine, and vStringDelete().

Referenced by ctags_cli_main().

◆ getEntryInCorkQueue()

◆ getEntryOfNestingLevel()

◆ getFullQualifiedScopeNameFromCorkQueue()

◆ getParserFieldForIndex()

◆ getParserFieldValueForType()

const char * getParserFieldValueForType ( tagEntryInfo *const  tag,
fieldType  ftype 
)

◆ getTagFileDirectory()

const char * getTagFileDirectory ( void  )

Definition at line 2024 of file entry.c.

References eTagFile::directory, and TagFile.

Referenced by setInputFileParametersCommon().

◆ getTagScopeInformation()

◆ initForeignRefTagEntry()

void initForeignRefTagEntry ( tagEntryInfo *const  e,
const char *const  name,
langType  langType,
int  kindIndex,
int  roleIndex 
)

◆ initRefTagEntry()

void initRefTagEntry ( tagEntryInfo *const  e,
const char *const  name,
int  kindIndex,
int  roleIndex 
)

◆ initTagEntry()

◆ initTagEntryFull()

◆ internalSortTagFile()

static void internalSortTagFile ( void  )
static

◆ invalidatePatternCache()

void invalidatePatternCache ( void  )

Definition at line 1997 of file entry.c.

References eTagFile::patternCacheValid, and TagFile.

Referenced by openInputFile(), and pushNarrowedInputStream().

◆ isCtagsLine()

static bool isCtagsLine ( const char *const  line)
static

Definition at line 311 of file entry.c.

References eFree(), error(), FATAL, field, isValidTagAddress(), line, NULL, and xMalloc.

Referenced by isTagFile().

◆ isEtagsLine()

static bool isEtagsLine ( const char *const  line)
static

Definition at line 351 of file entry.c.

References line.

Referenced by isTagFile().

◆ isRoleAssigned()

bool isRoleAssigned ( const tagEntryInfo *const  e,
int  roleIndex 
)

◆ isTagExtra()

bool isTagExtra ( const tagEntryInfo *const  tag)

Definition at line 1932 of file entry.c.

References isTagExtraBitMarked(), and XTAG_COUNT.

◆ isTagExtraBitMarked()

bool isTagExtraBitMarked ( const tagEntryInfo *const  tag,
xtagType  extra 
)

◆ isTagFile()

static bool isTagFile ( const char *const  filename)
static

◆ isTagWritable()

◆ isValidTagAddress()

static bool isValidTagAddress ( const char *const  excmd)
static

Definition at line 294 of file entry.c.

References eFree(), NULL, and xMalloc.

Referenced by isCtagsLine().

◆ makeFileTag()

◆ makePatternString()

char * makePatternString ( const tagEntryInfo *const  tag)

◆ makePatternStringCommon()

◆ makePlaceholder()

int makePlaceholder ( const char *const  name)

◆ makeQualifiedTagEntry()

◆ makeTagEntry()

◆ markAllEntriesInScopeAsPlaceholder()

void markAllEntriesInScopeAsPlaceholder ( int  index)

Definition at line 2036 of file entry.c.

References foreachEntriesInScope(), index, markAsPlaceholder(), and NULL.

Referenced by markAsPlaceholder().

◆ markAsPlaceholder()

static bool markAsPlaceholder ( int  index,
tagEntryInfo e,
void *  data 
)
static

◆ markTagExtraBit()

void markTagExtraBit ( tagEntryInfo *const  tag,
xtagType  extra 
)

◆ markTagExtraBitFull()

static void markTagExtraBitFull ( tagEntryInfo *const  tag,
xtagType  extra,
bool  mark 
)
static

◆ maxTagsLine()

unsigned long maxTagsLine ( void  )

Definition at line 1992 of file entry.c.

References eTagFile::sMax::line, eTagFile::max, and TagFile.

Referenced by printTotals().

◆ newNilTagEntry()

static tagEntryInfo * newNilTagEntry ( unsigned int  corkFlags)
static

◆ numTagsAdded()

unsigned long numTagsAdded ( void  )

Definition at line 1977 of file entry.c.

References eTagFile::sNumTags::added, eTagFile::numTags, and TagFile.

Referenced by createTagsWithFallback1(), endEtagsFile(), and printTotals().

◆ numTagsTotal()

unsigned long numTagsTotal ( void  )

Definition at line 1987 of file entry.c.

References eTagFile::sNumTags::added, eTagFile::numTags, eTagFile::sNumTags::prev, and TagFile.

Referenced by printTotals().

◆ openTagFile()

◆ queueTagEntry()

static int queueTagEntry ( const tagEntryInfo *const  tag)
static

◆ readLineFromBypassForTag()

char * readLineFromBypassForTag ( vString *const  vLine,
const tagEntryInfo *const  tag,
long *const  pSeekValue 
)

◆ registerEntry()

◆ rememberMaxLengths()

static void rememberMaxLengths ( const size_t  nameLength,
const size_t  lineLength 
)
static

Definition at line 164 of file entry.c.

References eTagFile::sMax::line, eTagFile::max, eTagFile::sMax::tag, and TagFile.

Referenced by writePseudoTag(), and writeTagEntry().

◆ replacementTruncate()

static int replacementTruncate ( const char *const  name,
const long  size 
)
static

Definition at line 493 of file entry.c.

References copyFile(), eFree(), mio_unref(), name, NULL, tempFile(), tempName, and WHOLE_FILE.

Referenced by resizeTagFile().

◆ resizeTagFile()

static void resizeTagFile ( const long  newSize)
static

Definition at line 555 of file entry.c.

References close, errno, eTagFile::mio, mio_try_resize(), eTagFile::name, open, replacementTruncate(), and TagFile.

Referenced by closeTagFile().

◆ setNumTagsAdded()

void setNumTagsAdded ( unsigned long  nadded)

Definition at line 1982 of file entry.c.

References eTagFile::sNumTags::added, eTagFile::numTags, and TagFile.

Referenced by createTagsWithFallback1(), and endEtagsFile().

◆ setTagFilePosition()

void setTagFilePosition ( MIOPos p)

Definition at line 2013 of file entry.c.

References error(), FATAL, eTagFile::mio, mio_setpos(), NULL, PERROR, and TagFile.

Referenced by createTagsWithFallback1().

◆ setupWriter()

void setupWriter ( void *  writerClientData)

Definition at line 1457 of file entry.c.

References eTagFile::mio, TagFile, and writerSetup().

Referenced by parseMio().

◆ sortTagFile()

static void sortTagFile ( void  )
static

◆ tagFieldDelete()

static void tagFieldDelete ( tagField f)
static

Definition at line 938 of file entry.c.

References eFree(), sTagField::value, and sTagField::valueOwner.

Referenced by attachParserFieldGeneric().

◆ tagFieldNew()

static tagField * tagFieldNew ( fieldType  ftype,
const char *  value,
bool  valueOwner 
)
static

Definition at line 928 of file entry.c.

References sTagField::ftype, sTagField::value, sTagField::valueOwner, and xMalloc.

Referenced by attachParserFieldGeneric().

◆ tagFileName()

const char * tagFileName ( void  )

Definition at line 149 of file entry.c.

References eTagFile::name, and TagFile.

Referenced by internalSortTagFile(), and writeSortedTags().

◆ tagFilePosition()

void tagFilePosition ( MIOPos p)

Definition at line 2002 of file entry.c.

References error(), FATAL, eTagFile::mio, mio_getpos(), NULL, PERROR, and TagFile.

Referenced by createTagsWithFallback1().

◆ teardownWriter()

bool teardownWriter ( const char *  filename)

Definition at line 1462 of file entry.c.

References filename, eTagFile::mio, TagFile, and writerTeardown().

Referenced by parseMio().

◆ truncateTagLineAfterTag()

size_t truncateTagLineAfterTag ( char *const  line,
const char *const  token,
const bool  discardNewline 
)

Definition at line 735 of file entry.c.

References line, NULL, and strstr().

Referenced by makePatternStringCommon(), and writeEtagsEntry().

◆ uncorkTagFile()

◆ updatePseudoTags()

static long unsigned int updatePseudoTags ( MIO *const  mio)
static

◆ updateSortedFlag()

static void updateSortedFlag ( const char *const  line,
MIO *const  mio,
MIOPos  startOfLine 
)
static

◆ vstring_putc()

static int vstring_putc ( char  c,
void *  data 
)
static

Definition at line 696 of file entry.c.

References vStringPut().

Referenced by makePatternString(), and makePatternStringCommon().

◆ vstring_puts()

static int vstring_puts ( const char *  s,
void *  data 
)
static

Definition at line 703 of file entry.c.

References vStringCatS(), and vStringLength.

Referenced by makePatternString(), and makePatternStringCommon().

◆ writeEtagsIncludes()

static void writeEtagsIncludes ( MIO *const  mio)
static

◆ writePseudoTag()

◆ writeTagEntry()

Variable Documentation

◆ TagFile

◆ TagsToStdout

bool TagsToStdout = false
static

Definition at line 125 of file entry.c.

Referenced by closeTagFile(), internalSortTagFile(), openTagFile(), and sortTagFile().