Ejemplo n.º 1
0
TOKEN ChkControl( void )
{
    int         lines_skipped;
    ppctl_t     old_ppctl;

    if( !CompFlags.doing_macro_expansion ) {
        if( CompFlags.cpp_output ) {
            PrintWhiteSpace = FALSE;
        }
    }
    while( CurrChar == '\n' ) {
        if( TBreak() ) {
            CErr1( ERR_BREAK_KEY_HIT );
            CSuicide();
        }
        lines_skipped = 0;
        old_ppctl = CompFlags.pre_processing;
        for( ; CurrChar != EOF_CHAR; ) {
            if( CompFlags.cpp_output ) {
                CppPrtChar( '\n' );
            }
            NextChar();
            if( CurrChar != PreProcChar ) {
                SkipAhead();
            }
            if( CurrChar == EOF_CHAR )
                break;
            if( CurrChar == PreProcChar ) { /* start of comp control line */
                PPCTL_ENABLE_EOL();
                PPCTL_DISABLE_MACROS();
                PreProcStmt();
                PPFlush2EOL();
                CompFlags.pre_processing = old_ppctl;
            } else if( NestLevel != SkipLevel ) {
                PPCTL_ENABLE_EOL();
                PPCTL_DISABLE_MACROS();
                PPNextToken();              /* get into token mode */
                PPFlush2EOL();
                CompFlags.pre_processing = old_ppctl;
            }
            if( NestLevel == SkipLevel )
                break;
            if( CurrChar == '\n' ) {
                lines_skipped = 1;
            }
        }
        if( CompFlags.cpp_output ) {
            if( lines_skipped ) {
                if( SrcFile != NULL ) {                 /* 14-may-92 */
                    EmitLine( SrcFile->src_loc.line, SrcFile->src_name );
                }
            }
        }
    }
    // we have already skipped past all white space at the start of the line
    CurToken = T_WHITE_SPACE;
//  CurToken = ScanToken();
    return( T_WHITE_SPACE );
}
Ejemplo n.º 2
0
static void chkIOErr( file_handle fp, int error, char *filename ) {
/******************************************************************/

    char        err_msg[ERR_BUFF_SIZE+1];

    if( SDError( fp, err_msg ) ) {
        Error( error, filename, err_msg );
        CSuicide();
    }
}
Ejemplo n.º 3
0
void mywrite( FILE *fp, void *data, size_t len ) {
/*************************************************/

    char        err_msg[ERR_BUFF_SIZE+1];

    SDWrite( fp, data, len );
    if( SDError( fp, err_msg ) ) {
        Error( SM_IO_WRITE_ERR, fName, err_msg );
        CSuicide();
    }
}
Ejemplo n.º 4
0
static void *CLIAlloc( size_t size ) {
/*************************************/

    void        *p;

    p = FMemAlloc( size );
    if( p == NULL && size ) {
        Error( MO_DYNAMIC_OUT );
        CSuicide();
    }
    return( p );
}
Ejemplo n.º 5
0
static void macroAllocSegment(   // ALLOCATE MACRO SEGMENT
    unsigned minimum )          // - minimum size req'd
{
    MACRO_SEG_LIST  *macroSegment;

    if( minimum > MAC_SEGMENT_LIMIT ) {
        CErr1( ERR_OUT_OF_MACRO_MEMORY );
        CSuicide();
    }
    macroSegment = RingAlloc( &macroSegmentList, sizeof( MACRO_SEG_LIST ) );
    MacroOffset =  macroSegment->segment;
    macroSegmentLimit = MAC_SEGMENT_LIMIT;
    ExtraRptIncrementCtr( macro_segments );
}
Ejemplo n.º 6
0
/* splits the dataquad pointed to by dql so that the current one
   will have size "size" and the new one "oldsize - size" */
local void SplitDataQuad( DATA_QUAD_LIST *dql, unsigned long size )
{
    DATA_QUAD_LIST  *ndql;
    DATA_QUAD       *ndq;
    DATA_QUAD       *dq;
    unsigned long   oldsize;

    ndql = NewDataQuad();
    ndql->next = dql->next;
    ndql->prev = dql;
    dql->next = ndql;
    if( ndql->next != NULL )
        ndql->next->prev = ndql;
    oldsize = dql->size;
    ndql->size = oldsize - size;
    dql->size = size;

    ndq = &ndql->dq;
    dq = &dql->dq;
    memcpy( ndq, dq, sizeof( *dq ) );

    if( dq->flags & Q_DATA ) {
        if( dq->flags & Q_2_INTS_IN_ONE ) {
            dq->flags = ndq->flags = Q_DATA;
            ndq->u.long_values[0] = dq->u.long_values[1];
            ndq->u.long_values[1] = dq->u.long_values[1] = 0;
            size = 0;
        } else if( dq->flags & Q_REPEATED_DATA ) {
            dq->u.long_values[1] = size / (oldsize / dq->u.long_values[1]);
            ndq->u.long_values[1] -= dq->u.long_values[1];
            size = 0;
        } else if( dq->type == QDT_CONSTANT ) {
            dq->u.long_values[0] = size;
            ndq->u.long_values[0] -= dq->u.long_values[0];
            size = 0;
        } else if( dq->type == QDT_CONST ) {
            dq->u.string_leaf->length = size;
            ndq->u.string_leaf->literal += size;
            ndq->u.string_leaf->length = oldsize - size;
            size = 0;
        }
    }
    if( size != 0 ) {
        /* can't happen ! */
        CErr2p( ERR_FATAL_ERROR, "Bad initializer quad" );
        CSuicide();
    }
}
Ejemplo n.º 7
0
static void CLIWrite( dw_sectnum sect, const void *block, dw_size_t size ) {
/*********************************************************************/

    char                        *temp;
    section_data                *cur_sec;

    cur_sec = &Sections[sect];
    if ( cur_sec->sec_type == DEFAULT_SECTION ) {
        if ( ( initial_section_type == DEFAULT_SECTION ) ||
           ( initial_section_type == FILE_SECTION ) ) {
                cur_sec->sec_type = FILE_SECTION;
                SDSetAttr( REC_FIXED | SEEK );
                temp = tmpnam( NULL );
                cur_sec->u2.filename = FMemAlloc( strlen( temp ) + 1 );
                strcpy( cur_sec->u2.filename, temp );
                cur_sec->u1.fp = SDOpen( temp, UPDATE_FILE );
                chkIOErr( cur_sec->u1.fp, SM_OPENING_FILE, temp );
        } else {
                cur_sec->sec_type = initial_section_type;
                cur_sec->u1.size = MEM_INCREMENT;
                cur_sec->u2.data = FMemAlloc( MEM_INCREMENT );
        }
    }

    switch( cur_sec->sec_type ) {
    case( MEM_SECTION ):
        if ( cur_sec->u1.size <= ( cur_sec->cur_offset + size ) ) {
            temp = FMemAlloc( cur_sec->u1.size + MEM_INCREMENT );
            memcpy( temp, cur_sec->u2.data, cur_sec->u1.size );
            FMemFree( cur_sec->u2.data );
            cur_sec->u2.data = temp;
            cur_sec->u1.size += MEM_INCREMENT;
        }
        memcpy( ( cur_sec->u2.data + cur_sec->cur_offset ), block, size );
        break;
    case( FILE_SECTION ):
        SDWrite( cur_sec->u1.fp, (byte *)block, size );
        chkIOErr( cur_sec->u1.fp, SM_IO_WRITE_ERR, "temporary file" );
        break;
    default:
        Error( CP_FATAL_ERROR, "Internal browse generator error" );
        CSuicide();
    };
    cur_sec->cur_offset += size;
    if( cur_sec->cur_offset > cur_sec->max_offset ) {
        cur_sec->max_offset = cur_sec->cur_offset;
    }
}
Ejemplo n.º 8
0
local DATA_QUAD_LIST *NewDataQuad( void )
{
    static DATA_QUAD_LIST   *DataQuadPtr;
    DATA_QUAD_LIST          *dql;

    if( DataQuadIndex >= (DATA_QUADS_PER_SEG - 1) ) {
        if( DataQuadSegIndex == MAX_DATA_QUAD_SEGS ) {
            CErr1( ERR_INTERNAL_LIMIT_EXCEEDED );
            CSuicide();
        }
        ++DataQuadSegIndex;
        DataQuadIndex = 0;
        DataQuadPtr = FEmalloc( DATA_QUAD_SEG_SIZE );
        DataQuadSegs[ DataQuadSegIndex ] = DataQuadPtr;
    }
    dql = DataQuadPtr;
    ++DataQuadIndex;
    ++DataQuadPtr;
    return dql;
}
Ejemplo n.º 9
0
static void ioSuppError(        // SIGNAL I/O ERROR AND ABORT
    int error_code )            // - error code
{
    CErr2( error_code, errno );
    CSuicide();
}