Esempio n. 1
0
int PP_Sharp( char *ptr )
{
    char        *token;
    char        c;

    while( *ptr == ' '  ||  *ptr == '\t' ) ++ptr;
    token = ptr;
    while( *ptr >= 'a'  &&  *ptr <= 'z' ) ++ptr;
    c = *ptr;
    *ptr = '\0';
    if( strcmp( token, "include" ) == 0 ) {
        *ptr = c;
        if( NestLevel == SkipLevel ) {
            PP_Include( ptr );
            return( 0 );
        }
    } else if( strcmp( token, "define" ) == 0 ) {
        *ptr = c;
        if( NestLevel == SkipLevel )  PP_Define( ptr );
    } else if( strcmp( token, "undef" ) == 0 ) {
        *ptr = c;
        if( NestLevel == SkipLevel )  PP_Undef( ptr );
    } else if( strcmp( token, "ifdef" ) == 0 ) {
        *ptr = c;
        PP_Ifdef( ptr );
    } else if( strcmp( token, "ifndef" ) == 0 ) {
        *ptr = c;
        PP_Ifndef( ptr );
    } else if( strcmp( token, "if" ) == 0 ) {
        *ptr = c;
        PP_If( ptr );
    } else if( strcmp( token, "elif" ) == 0 ) {
        *ptr = c;
        PP_Elif( ptr );
    } else if( strcmp( token, "else" ) == 0 ) {
        *ptr = c;
        PP_Else();
    } else if( strcmp( token, "endif" ) == 0 ) {
        *ptr = c;
        PP_Endif();
    } else {
        *ptr = c;
        if( PPFlags & PPFLAG_ASM_COMMENT ) {
            // # is also a line-comment char in MS's stupid assembler
            // so we just return 1 to say we recognized it and the rest
            // of this delightful preprocessor will take care of eating
            // the remainder of the line
            return( 1 );
        }
        return( 0 );            // indicate unrecognized
    }
    return( 1 );                // indicate recognized
}
Esempio n. 2
0
static int PP_Sharp( const char *ptr )
{
    const char  *token;
    size_t      len;

    while( *ptr == ' ' || *ptr == '\t' )
        ++ptr;
    token = ptr;
    while( *ptr >= 'a' && *ptr <= 'z' )
        ++ptr;
    len = ptr - token;
    if( len == 7 && memcmp( token, "include", 7 ) == 0 ) {
        if( NestLevel == SkipLevel ) {
            PP_Include( ptr );
            return( 0 );
        }
    } else if( len == 6 && memcmp( token, "define", 6 ) == 0 ) {
        if( NestLevel == SkipLevel ) {
            PP_Define( ptr );
        }
    } else if( len == 5 && memcmp( token, "undef", 5 ) == 0 ) {
        if( NestLevel == SkipLevel ) {
            PP_Undef( ptr );
        }
    } else if( len == 5 && memcmp( token, "ifdef", 5 ) == 0 ) {
        PP_Ifdef( ptr );
    } else if( len == 6 && memcmp( token, "ifndef", 6 ) == 0 ) {
        PP_Ifndef( ptr );
    } else if( len == 2 && memcmp( token, "if", 2 ) == 0 ) {
        PP_If( ptr );
    } else if( len == 4 && memcmp( token, "elif", 4 ) == 0 ) {
        PP_Elif( ptr );
    } else if( len == 4 && memcmp( token, "else", 4 ) == 0 ) {
        PP_Else();
    } else if( len == 5 && memcmp( token, "endif", 5 ) == 0 ) {
        PP_Endif();
    } else {
        if( PPFlags & PPFLAG_ASM_COMMENT ) {
            // # is also a line-comment char in MS's stupid assembler
            // so we just return 1 to say we recognized it and the rest
            // of this delightful preprocessor will take care of eating
            // the remainder of the line
            return( 1 );
        }
        return( 0 );            // indicate unrecognized
    }
    return( 1 );                // indicate recognized
}