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)  

read.c File Reference
#include "general.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "read.h"
#include "read_p.h"
#include "debug.h"
#include "entry_p.h"
#include "routines.h"
#include "routines_p.h"
#include "options_p.h"
#include "parse_p.h"
#include "promise_p.h"
#include "stats_p.h"
#include "trace.h"
#include "trashbox.h"
Include dependency graph for read.c:

Go to the source code of this file.

Classes

struct  sLangStack
 
union  sInputLangInfo
 
struct  sInputFileInfo
 
struct  sComputPos
 
struct  sInputLineFposMap
 
struct  sNestedInputStreamInfo
 
struct  sInputFile
 

Macros

#define FILE_WRITE
 
#define INITIAL_lineFposMap_LEN   256
 
#define MAX_IN_MEMORY_FILE_SIZE   (1024*1024)
 

Typedefs

typedef struct sLangStack langStack
 
typedef union sInputLangInfo inputLangInfo
 
typedef struct sInputFileInfo inputFileInfo
 
typedef struct sComputPos compoundPos
 
typedef struct sInputLineFposMap inputLineFposMap
 
typedef struct sNestedInputStreamInfo nestedInputStreamInfo
 
typedef struct sInputFile inputFile
 
typedef enum eEolType eolType
 

Enumerations

enum  eEolType { eol_eof = 0 , eol_nl , eol_cr_nl }
 

Functions

static void langStackInit (langStack *langStack)
 
static langType langStackTop (langStack *langStack)
 
static langType langStackBotom (langStack *langStack)
 
static void langStackPush (langStack *langStack, langType type)
 
static langType langStackPop (langStack *langStack)
 
static void langStackClear (langStack *langStack)
 
unsigned long getInputLineNumber (void)
 
int getInputLineOffset (void)
 
const char * getInputFileName (void)
 
MIOPos getInputFilePosition (void)
 
static compoundPosgetInputFileCompoundPosForLine (unsigned int line)
 
MIOPos getInputFilePositionForLine (unsigned int line)
 
long getInputFileOffsetForLine (unsigned int line)
 
langType getInputLanguage (void)
 
const char * getInputLanguageName (void)
 
const char * getInputFileTagPath (void)
 
bool isInputLanguage (langType lang)
 
bool isInputHeaderFile (void)
 
bool isInputLanguageKindEnabled (int kindIndex)
 
bool isInputLanguageRoleEnabled (int kindIndex, int roleIndex)
 
unsigned int countInputLanguageKinds (void)
 
unsigned int countInputLanguageRoles (int kindIndex)
 
bool doesInputLanguageAllowNullTag (void)
 
bool doesInputLanguageRequestAutomaticFQTag (void)
 
const char * getSourceFileTagPath (void)
 
langType getSourceLanguage (void)
 
unsigned long getSourceLineNumber (void)
 
static void freeInputFileInfo (inputFileInfo *finfo)
 
void freeInputFileResources (void)
 
const unsigned char * getInputFileData (size_t *size)
 
static void freeLineFposMap (inputLineFposMap *lineFposMap)
 
static void allocLineFposMap (inputLineFposMap *lineFposMap)
 
static void appendLineFposMap (inputLineFposMap *lineFposMap, compoundPos *pos, bool crAdjustment)
 
static int compoundPosForOffset (const void *oft, const void *p)
 
unsigned long getInputLineNumberForFileOffset (long offset)
 
static void setOwnerDirectoryOfInputFile (const char *const fileName)
 
static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName, const langType language, stringList *holder)
 
static void resetLangOnStack (inputLangInfo *langInfo, langType lang)
 
langType baseLangOnStack (inputLangInfo *langInfo)
 
static void pushLangOnStack (inputLangInfo *langInfo, langType lang)
 
static langType popLangOnStack (inputLangInfo *langInfo)
 
static void clearLangOnStack (inputLangInfo *langInfo)
 
static void setInputFileParameters (vString *const fileName, const langType language)
 
static void setSourceFileParameters (vString *const fileName, const langType language)
 
static bool setSourceFileName (vString *const fileName)
 
static void skipWhite (char **str)
 
static unsigned long readLineNumber (char **str)
 
static vStringreadFileName (char *s)
 
static bool parseLineDirective (char *s)
 
MIOgetMio (const char *const fileName, const char *const openMode, bool memStreamRequired)
 
static bool checkUTF8BOM (MIO *mio, bool skipIfFound)
 
static void rewindInputFile (inputFile *f)
 
bool openInputFile (const char *const fileName, const langType language, MIO *mio)
 
void resetInputFile (const langType language)
 
void closeInputFile (void)
 
void * getInputFileUserData (void)
 
static void fileNewline (bool crAdjustment)
 
void ungetcToInputFile (int c)
 
static eolType readLine (vString *const vLine, MIO *const mio)
 
static vStringiFileGetLine (void)
 
int getcFromInputFile (void)
 
int getNthPrevCFromInputFile (unsigned int nth, int def)
 
int skipToCharacterInInputFile (int c)
 
int skipToCharacterInInputFile2 (int c0, int c1)
 
const unsigned char * readLineFromInputFile (void)
 
char * readLineRaw (vString *const vLine, MIO *const mio)
 
char * readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue)
 
void pushNarrowedInputStream (unsigned long startLine, long startCharOffset, unsigned long endLine, long endCharOffset, unsigned long sourceLineOffset, int promise)
 
bool doesParserRunAsGuest (void)
 
unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber)
 
void popNarrowedInputStream (void)
 
void pushLanguage (const langType language)
 
langType popLanguage (void)
 
langType getLanguageForBaseParser (void)
 
bool isThinStreamSpec (unsigned long startLine, long startCharOffset, unsigned long endLine, long endCharOffset, unsigned long sourceLineOffset)
 

Variables

static inputLangInfo inputLang
 
static langType sourceLang
 
static inputFile File
 
static inputFile BackupFile
 
static compoundPos StartOfLine
 

Macro Definition Documentation

◆ FILE_WRITE

#define FILE_WRITE

Definition at line 20 of file read.c.

◆ INITIAL_lineFposMap_LEN

#define INITIAL_lineFposMap_LEN   256

◆ MAX_IN_MEMORY_FILE_SIZE

#define MAX_IN_MEMORY_FILE_SIZE   (1024*1024)

Definition at line 604 of file read.c.

Typedef Documentation

◆ compoundPos

typedef struct sComputPos compoundPos

◆ eolType

typedef enum eEolType eolType

◆ inputFile

typedef struct sInputFile inputFile

◆ inputFileInfo

typedef struct sInputFileInfo inputFileInfo

◆ inputLangInfo

◆ inputLineFposMap

◆ langStack

typedef struct sLangStack langStack

◆ nestedInputStreamInfo

Enumeration Type Documentation

◆ eEolType

enum eEolType
Enumerator
eol_eof 
eol_nl 
eol_cr_nl 

Definition at line 823 of file read.c.

Function Documentation

◆ allocLineFposMap()

static void allocLineFposMap ( inputLineFposMap lineFposMap)
static

◆ appendLineFposMap()

static void appendLineFposMap ( inputLineFposMap lineFposMap,
compoundPos pos,
bool  crAdjustment 
)
static

◆ baseLangOnStack()

langType baseLangOnStack ( inputLangInfo langInfo)

Definition at line 435 of file read.c.

References Assert, sLangStack::count, langStackBotom(), and sInputLangInfo::stack.

Referenced by getLanguageForBaseParser().

◆ checkUTF8BOM()

static bool checkUTF8BOM ( MIO mio,
bool  skipIfFound 
)
static

Definition at line 641 of file read.c.

References mio_getc(), and mio_rewind().

Referenced by openInputFile().

◆ clearLangOnStack()

static void clearLangOnStack ( inputLangInfo langInfo)
static

Definition at line 451 of file read.c.

References langStackClear(), and sInputLangInfo::stack.

Referenced by closeInputFile().

◆ closeInputFile()

◆ compoundPosForOffset()

static int compoundPosForOffset ( const void *  oft,
const void *  p 
)
static

Definition at line 344 of file read.c.

References sComputPos::crAdjustment, sComputPos::offset, and pos.

Referenced by getInputLineNumberForFileOffset().

◆ countInputLanguageKinds()

unsigned int countInputLanguageKinds ( void  )

Definition at line 232 of file read.c.

References countLanguageKinds(), and getInputLanguage().

◆ countInputLanguageRoles()

unsigned int countInputLanguageRoles ( int  kindIndex)

Definition at line 237 of file read.c.

References countLanguageRoles(), and getInputLanguage().

Referenced by makeSimpleRefTag().

◆ doesInputLanguageAllowNullTag()

bool doesInputLanguageAllowNullTag ( void  )

Definition at line 242 of file read.c.

References doesLanguageAllowNullTag(), and getInputLanguage().

Referenced by makeTagEntry().

◆ doesInputLanguageRequestAutomaticFQTag()

bool doesInputLanguageRequestAutomaticFQTag ( void  )

Definition at line 247 of file read.c.

References doesLanguageRequestAutomaticFQTag(), and getInputLanguage().

Referenced by uncorkTagFile(), and writeTagEntry().

◆ doesParserRunAsGuest()

◆ fileNewline()

◆ freeInputFileInfo()

static void freeInputFileInfo ( inputFileInfo finfo)
static

Definition at line 267 of file read.c.

References sInputFileInfo::name, NULL, sInputFileInfo::tagPath, and vStringDelete().

Referenced by freeInputFileResources().

◆ freeInputFileResources()

void freeInputFileResources ( void  )

◆ freeLineFposMap()

static void freeLineFposMap ( inputLineFposMap lineFposMap)
static

Definition at line 299 of file read.c.

References sInputLineFposMap::count, eFree(), NULL, sInputLineFposMap::pos, and sInputLineFposMap::size.

Referenced by closeInputFile().

◆ getcFromInputFile()

◆ getInputFileCompoundPosForLine()

static compoundPos * getInputFileCompoundPosForLine ( unsigned int  line)
static

◆ getInputFileData()

const unsigned char * getInputFileData ( size_t *  size)

Definition at line 291 of file read.c.

References File, sInputFile::mio, and mio_memory_get_data().

◆ getInputFileName()

◆ getInputFileOffsetForLine()

long getInputFileOffsetForLine ( unsigned int  line)

◆ getInputFilePosition()

◆ getInputFilePositionForLine()

MIOPos getInputFilePositionForLine ( unsigned int  line)

◆ getInputFileTagPath()

const char * getInputFileTagPath ( void  )

Definition at line 206 of file read.c.

References File, sInputFile::input, sInputFileInfo::tagPath, and vStringValue.

Referenced by initForeignRefTagEntry(), and initTagEntry().

◆ getInputFileUserData()

void * getInputFileUserData ( void  )

Definition at line 792 of file read.c.

References File, sInputFile::mio, and mio_get_user_data().

◆ getInputLanguage()

◆ getInputLanguageName()

const char * getInputLanguageName ( void  )

Definition at line 201 of file read.c.

References getInputLanguage(), and getLanguageName().

◆ getInputLineNumber()

◆ getInputLineNumberForFileOffset()

◆ getInputLineOffset()

int getInputLineOffset ( void  )

◆ getLanguageForBaseParser()

langType getLanguageForBaseParser ( void  )

Definition at line 1164 of file read.c.

References baseLangOnStack(), and inputLang.

Referenced by doesSubparserRun().

◆ getMio()

MIO * getMio ( const char *const  fileName,
const char *const  openMode,
bool  memStreamRequired 
)

◆ getNestedInputBoundaryInfo()

◆ getNthPrevCFromInputFile()

int getNthPrevCFromInputFile ( unsigned int  nth,
int  def 
)

Definition at line 961 of file read.c.

References sInputFile::currentLine, File, sInputFile::line, NULL, sInputFile::ungetchIdx, and vStringValue.

Referenced by cppGetc().

◆ getSourceFileTagPath()

const char * getSourceFileTagPath ( void  )

Definition at line 252 of file read.c.

References File, sInputFile::source, sInputFileInfo::tagPath, and vStringValue.

Referenced by initForeignRefTagEntry(), initTagEntry(), and parseMio().

◆ getSourceLanguage()

langType getSourceLanguage ( void  )

Definition at line 257 of file read.c.

References sourceLang.

Referenced by initForeignRefTagEntry(), and initTagEntry().

◆ getSourceLineNumber()

unsigned long getSourceLineNumber ( void  )

Definition at line 262 of file read.c.

References File, sInputFileInfo::lineNumber, and sInputFile::source.

Referenced by initForeignRefTagEntry(), initTagEntry(), and readTag().

◆ iFileGetLine()

◆ isInputHeaderFile()

bool isInputHeaderFile ( void  )

Definition at line 216 of file read.c.

References File, sInputFile::input, and sInputFileInfo::isHeader.

Referenced by makeDefineTag(), and makeTag().

◆ isInputLanguage()

◆ isInputLanguageKindEnabled()

bool isInputLanguageKindEnabled ( int  kindIndex)

Definition at line 221 of file read.c.

References getInputLanguage(), and isLanguageKindEnabled().

◆ isInputLanguageRoleEnabled()

bool isInputLanguageRoleEnabled ( int  kindIndex,
int  roleIndex 
)

Definition at line 226 of file read.c.

References getInputLanguage(), and isLanguageRoleEnabled().

◆ isThinStreamSpec()

bool isThinStreamSpec ( unsigned long  startLine,
long  startCharOffset,
unsigned long  endLine,
long  endCharOffset,
unsigned long  sourceLineOffset 
)

Definition at line 1210 of file read.c.

Referenced by makePromise(), and pushNarrowedInputStream().

◆ langStackBotom()

static langType langStackBotom ( langStack langStack)
static

Definition at line 1183 of file read.c.

References Assert, sLangStack::count, and sLangStack::languages.

Referenced by baseLangOnStack().

◆ langStackClear()

static void langStackClear ( langStack langStack)
static

Definition at line 1189 of file read.c.

References sLangStack::count, and langStackPop().

Referenced by clearLangOnStack(), and resetLangOnStack().

◆ langStackInit()

static void langStackInit ( langStack langStack)
static

◆ langStackPop()

static langType langStackPop ( langStack langStack)
static

Definition at line 1205 of file read.c.

References sLangStack::count, and sLangStack::languages.

Referenced by langStackClear(), and popLangOnStack().

◆ langStackPush()

static void langStackPush ( langStack langStack,
langType  type 
)
static

◆ langStackTop()

static langType langStackTop ( langStack langStack)
static

Definition at line 1177 of file read.c.

References Assert, sLangStack::count, and sLangStack::languages.

Referenced by getInputLanguage().

◆ openInputFile()

◆ parseLineDirective()

◆ popLangOnStack()

static langType popLangOnStack ( inputLangInfo langInfo)
static

Definition at line 446 of file read.c.

References langStackPop(), and sInputLangInfo::stack.

Referenced by popLanguage().

◆ popLanguage()

◆ popNarrowedInputStream()

void popNarrowedInputStream ( void  )

◆ pushLangOnStack()

static void pushLangOnStack ( inputLangInfo langInfo,
langType  lang 
)
static

Definition at line 441 of file read.c.

References langStackPush(), and sInputLangInfo::stack.

Referenced by pushLanguage(), and setInputFileParameters().

◆ pushLanguage()

◆ pushNarrowedInputStream()

◆ readFileName()

static vString * readFileName ( char *  s)
static

Definition at line 528 of file read.c.

References skipWhite(), vStringNew(), and vStringPut().

Referenced by parseLineDirective().

◆ readLine()

static eolType readLine ( vString *const  vLine,
MIO *const  mio 
)
static

◆ readLineFromBypass()

char * readLineFromBypass ( vString *const  vLine,
MIOPos  location,
long *const  pSeekValue 
)

◆ readLineFromInputFile()

◆ readLineNumber()

static unsigned long readLineNumber ( char **  str)
static

Definition at line 501 of file read.c.

References skipWhite().

Referenced by parseLineDirective().

◆ readLineRaw()

◆ resetInputFile()

◆ resetLangOnStack()

static void resetLangOnStack ( inputLangInfo langInfo,
langType  lang 
)
static

Definition at line 428 of file read.c.

References Assert, sLangStack::count, langStackClear(), langStackPush(), and sInputLangInfo::stack.

Referenced by resetInputFile().

◆ rewindInputFile()

static void rewindInputFile ( inputFile f)
static

Definition at line 654 of file read.c.

References Assert, sInputFile::bomFound, CTAGS_ATTR_UNUSED, sInputFile::mio, mio_getc(), and mio_rewind().

Referenced by resetInputFile().

◆ setInputFileParameters()

static void setInputFileParameters ( vString *const  fileName,
const langType  language 
)
static

Definition at line 456 of file read.c.

References File, sInputFile::input, inputLang, NULL, pushLangOnStack(), and setInputFileParametersCommon().

Referenced by openInputFile().

◆ setInputFileParametersCommon()

◆ setOwnerDirectoryOfInputFile()

static void setOwnerDirectoryOfInputFile ( const char *const  fileName)
static

Definition at line 376 of file read.c.

References baseFilename(), File, NULL, sInputFile::path, tail(), vStringDelete(), vStringNCopyS(), and vStringNew().

Referenced by openInputFile().

◆ setSourceFileName()

static bool setSourceFileName ( vString *const  fileName)
static

◆ setSourceFileParameters()

static void setSourceFileParameters ( vString *const  fileName,
const langType  language 
)
static

◆ skipToCharacterInInputFile()

int skipToCharacterInInputFile ( int  c)

Definition at line 972 of file read.c.

References getcFromInputFile().

Referenced by readToken(), readTokenFull(), and skipToCharacterInInputFile2().

◆ skipToCharacterInInputFile2()

int skipToCharacterInInputFile2 ( int  c0,
int  c1 
)

Definition at line 982 of file read.c.

References getcFromInputFile(), and skipToCharacterInInputFile().

◆ skipWhite()

static void skipWhite ( char **  str)
static

Definition at line 495 of file read.c.

Referenced by parseLineDirective(), readFileName(), and readLineNumber().

◆ ungetcToInputFile()

Variable Documentation

◆ BackupFile

inputFile BackupFile
static

Definition at line 135 of file read.c.

Referenced by fileNewline(), popNarrowedInputStream(), and pushNarrowedInputStream().

◆ File

◆ inputLang

◆ sourceLang

langType sourceLang
static

Definition at line 118 of file read.c.

Referenced by getSourceLanguage(), resetInputFile(), and setSourceFileParameters().

◆ StartOfLine

compoundPos StartOfLine
static

Definition at line 136 of file read.c.

Referenced by fileNewline(), iFileGetLine(), openInputFile(), and resetInputFile().