Exemplo n.º 1
0
extern bool RcIoTextInputShutdown( void )
/***************************************/
{
    if( InStack.Buffer != NULL ) {
        RESFREE( InStack.Buffer );
        InStack.Buffer = NULL;
        InStack.BufferSize = 0;
        if( IsEmptyFileStack( InStack ) ) {
            return( false );
        } else {
            while( !IsEmptyFileStack( InStack ) ) {
                RcIoPopTextInputFile();
            }
            // return( true );
        }
    }
    return( true );
} /* RcIoTextInputShutdown */
Exemplo n.º 2
0
extern const LogicalFileInfo * RcIoGetLogicalFileInfo( void )
/***********************************************************/
{
    if( IsEmptyFileStack( InStack ) ) {
        return( NULL );
    } else {
        return( &(InStack.Current->Logical) );
    }
} /* RcIoGetLogicalFileInfo */
Exemplo n.º 3
0
extern int RcIoTextInputShutdown( void )
/**************************************/
{
    if( InStack.Buffer != NULL ) {
        RcMemFree( InStack.Buffer );
        InStack.Buffer = NULL;
        InStack.BufferSize = 0;
        if( IsEmptyFileStack( InStack ) ) {
            return( FALSE );
        } else {
            while( !IsEmptyFileStack( InStack ) ) {
                RcIoPopInputFile();
            }
            // return( TRUE );
        }
    }
    return( TRUE );
} /* RcIoTextInputShutdown */
Exemplo n.º 4
0
extern int RcIoIsCOrHFile( void )
/*******************************/
/* returns true if the current file is a .c or .h file, false otherwise */
{
    if( IsEmptyFileStack( InStack ) ) {
        return( FALSE );
    } else {
        return( InStack.Current->Logical.IsCOrHFile );
    }
} /* RcIoIsCOrHFile */
Exemplo n.º 5
0
extern void RcIoOverrideIsCOrHFlag( void )
/****************************************/
{
    LogicalFileInfo *   log;

    if( !IsEmptyFileStack( InStack ) ) {
        log = &(InStack.Current->Logical);
        log->IsCOrHFile = FALSE;
    }
} /* RcIoOverrideIsCOrHFlag */
Exemplo n.º 6
0
static void SetPhysFileOffset( FileStack * stack )
/************************************************/
{
    PhysFileInfo    *phys;
    size_t          charsinbuff;

    if( !IsEmptyFileStack( *stack ) ) {
        phys = &(stack->Current->Physical);
        charsinbuff = stack->BufferSize - ( stack->NextChar - stack->Buffer );
        phys->Offset = ftell( phys->fp ) - charsinbuff;
    }
} /* SetPhysFileOffset */
Exemplo n.º 7
0
extern void RcIoSetLogicalFileInfo( int linenum, char * filename )
/****************************************************************/
{
    LogicalFileInfo *   log;

    if( !IsEmptyFileStack( InStack ) ) {
        log = &(InStack.Current->Logical);
        log->LineNum = linenum;
        if( filename != NULL ) {
            strncpy( log->Filename, filename, _MAX_PATH );
            RcIoSetIsCOrHFlag();
        }
    }
} /* RcIoSetLogicalFileInfo */
Exemplo n.º 8
0
extern int RcIoPopInputFile( void )
/*********************************/
{
    PhysFileInfo *  phys;

    phys = &(InStack.Current->Physical);
    ClosePhysicalFile( phys );
    InStack.Current--;
    if( IsEmptyFileStack( InStack ) ) {
        return( TRUE );
    } else {
        ReadBuffer( &(InStack) );
        return( FALSE );
    }
} /* RcIoPopInputFile */
Exemplo n.º 9
0
bool RcIoPopTextInputFile( void )
/*******************************/
{
    PhysFileInfo *  phys;

    phys = &(InStack.Current->Physical);
    ClosePhysicalFile( phys );
    FreeLogicalFilename();
    FreePhysicalFilename();
    InStack.Current--;
    if( IsEmptyFileStack( InStack ) ) {
        return( true );
    } else {
        ReadBuffer( &(InStack) );
        return( false );
    }
} /* RcIoPopTextInputFile */
Exemplo n.º 10
0
extern void RcIoSetIsCOrHFlag( void )
/***********************************/
{
    LogicalFileInfo *   log;
    char                ext[_MAX_EXT];

    if( !IsEmptyFileStack( InStack ) ) {
        log = &(InStack.Current->Logical);
        _splitpath( log->Filename, NULL, NULL, NULL, ext );
        /* if this is a c or h file ext will be '.', '[ch]', '\0' */
        if( ( ext[1] == 'c' || ext[1] == 'h' || ext[1] == 'C' || ext[1] == 'H' ) && ext[2] == '\0' ) {
            /* if the logical file is a c or h file */
            log->IsCOrHFile = true;
        } else {
            log->IsCOrHFile = false;
        }
    }
} /* RcIoSetIsCOrHFlag */
Exemplo n.º 11
0
int RcIoGetChar( void )
/*********************/
{
    bool    isempty;
    bool    error;

    if( IsEmptyFileStack( InStack ) ) {
        return( EOF );
    }

    if( InStack.NextChar >= InStack.EofChar ) {
        /* we have reached the end of the buffer */
        if( InStack.NextChar >= InStack.Buffer + InStack.BufferSize ) {
            /* try to read next buffer */
            error = ReadBuffer( &(InStack) );
            if( error ) {
                /* this error is reported in ReadBuffer so just terminate */
                RcFatalError( ERR_NO_MSG );
            }
        }
        if( InStack.NextChar >= InStack.EofChar ) {
            /* this is a real EOF */
            /* unstack one file */
            isempty = RcIoPopTextInputFile();
            if( isempty ) {
                return( EOF );
            } else {
                /* if we are still at the EOF char, there has been an error */
                if( InStack.NextChar >= InStack.EofChar ) {
                    /* this error is reported in ReadBuffer so just terminate */
                    RcFatalError( ERR_NO_MSG );
                } else {
                    /* return \n which will end the current token properly */
                    /* if it it is not a string and end it with a runaway */
                    /* string error for strings */
                    return( '\n' );
                }
            }
        }
    }
    return( GetLogChar( &InStack ) );
} /* RcIoGetChar */
Exemplo n.º 12
0
extern void RcIoSetLogicalFileInfo( int linenum, const char * filename )
/**********************************************************************/
{
    LogicalFileInfo *   log;

    if( !IsEmptyFileStack( InStack ) ) {
        log = &(InStack.Current->Logical);
        log->LineNum = linenum;
        if( filename != NULL ) {
            if( log->Filename == NULL ) {
                log->Filename = RESALLOC( strlen( filename ) + 1 );
                strcpy( log->Filename, filename );
            } else if( strcmp( log->Filename, filename ) != 0 ) {
                RESFREE( log->Filename );
                log->Filename = RESALLOC( strlen( filename ) + 1 );
                strcpy( log->Filename, filename );
            }
            RcIoSetIsCOrHFlag();
        }
    }
} /* RcIoSetLogicalFileInfo */