Ejemplo n.º 1
0
char *ResRead32String( WResFileID handle, int *strlen )
/*****************************************************/
{
    VarString *         newstring;
    bool                error;
    uint_16             nextchar;
    char *              retstring;

    newstring = VarStringStart();
    error = ResReadUint16( &nextchar, handle );
    while( !error && nextchar != 0x0000 ) {
        VarStringAddChar( newstring, (uint_8)(nextchar & 0x00ff) );
        error = ResReadUint16( &nextchar, handle );
    }

    retstring = VarStringEnd( newstring, strlen );

    if( error && retstring != NULL ) {
        WRESFREE(retstring);
        retstring = NULL;
    }

    return( retstring );
} /* ResRead32String */
Ejemplo n.º 2
0
char *ResReadString( WResFileID handle, int *strlen )
/***************************************************/
{
    VarString *         newstring;
    bool                error;
    uint_8              nextchar;
    char *              retstring;

    newstring = VarStringStart();
    error = ResReadUint8( &nextchar, handle );
    while( !error && nextchar != '\0' ) {
        VarStringAddChar( newstring, nextchar );
        error = ResReadUint8( &nextchar, handle );
    }

    retstring = VarStringEnd( newstring, strlen );

    if( error && retstring != NULL ) {
        WRESFREE(retstring);
        retstring = NULL;
    }

    return( retstring );
} /* ResReadString */
Ejemplo n.º 3
0
static YYTOKENTYPE scanDFA( ScanValue *value )
/********************************************/
{
    long                newint;     /* these are used to accumulate parts of */
    VarString           *newstring; /* a new value */
    YYTOKENTYPE         token;
#ifdef SCANDEBUG
    char                debugstring[10];
#endif
    char                *stringFromFile;
    int                 i;

    value->intinfo.type  = SCAN_INT_TYPE_DEFAULT;
    value->string.string = NULL;
    longString = false;

    state( S_START ):
        if( isspace( LookAhead ) ) {
            do_transition( S_START );
        } else if( isdigit( LookAhead ) ) {
            newint = LookAhead - '0';
            newstring = VarStringStart();
            VarStringAddChar( newstring, LookAhead );
            if( LookAhead == '0' ) {
                do_transition( S_HEXSTART );
            } else {
                do_transition( S_DECIMAL );
            }
        } else if( isalpha( LookAhead ) || LookAhead == '_' ) {
            newstring = VarStringStart();
            VarStringAddChar( newstring, LookAhead );
            if( LookAhead == 'l' || LookAhead == 'L' ) {
                do_transition( S_L_STRING );
            }
            do_transition( S_NAME );
        } else switch( LookAhead ) {
            case '"':
                newstring = VarStringStart();  /* don't include the " */
                newLineInString = 0; /* reset newline in string status */
                do_transition( S_STRING );
            case '.':
                newstring = VarStringStart();
                VarStringAddChar( newstring, LookAhead );
                do_transition( S_DOS_FILENAME );
            case EOF:
                DEBUGPUTS( "EOF" )
                return( 0 );                /* yacc wants 0 on EOF */
            case '#':           do_transition( S_POUND_SIGN );
            case '(':           do_transition( S_LPAREN );
            case ')':           do_transition( S_RPAREN );
            case '[':           do_transition( S_LSQ_BRACKET );
            case ']':           do_transition( S_RSQ_BRACKET );
            case '{':           do_transition( S_LBRACE );
            case '}':           do_transition( S_RBRACE );
            case '+':           do_transition( S_PLUS );
            case '-':           do_transition( S_MINUS );
            case '~':           do_transition( S_BITNOT );
            case '!':           do_transition( S_NOT );
            case '*':           do_transition( S_TIMES );
            case '/':           do_transition( S_DIVIDE );
            case '%':           do_transition( S_MOD );
            case '>':           do_transition( S_GT );
            case '<':           do_transition( S_LT );
            case '=':           do_transition( S_EQ );
            case '&':           do_transition( S_BITAND );
            case '^':           do_transition( S_BITXOR );
            case '|':           do_transition( S_BITOR );
            case '?':           do_transition( S_QUESTION );
            case ':':           do_transition( S_COLON );
            case ',':           do_transition( S_COMMA );
            case ';':           do_transition( S_COMMENT );
            case '\\':
                newstring = VarStringStart();
                VarStringAddChar( newstring, LookAhead );
                do_transition( S_DOS_FILENAME );
            default:
                value->UnknownChar = LookAhead;
                do_transition( S_ERROR );
        }
    state( S_L_STRING ):
        if( LookAhead =='"' ) {
            longString = true;
            RESFREE( VarStringEnd( newstring, NULL ) );
            change_state( S_START );
        } else {
            change_state( S_NAME );
        }
    state( S_ERROR ):
        ErrorHasOccured = true;
        return( Y_SCAN_ERROR );

    state( S_COMMENT ):
        if( LookAhead == '\n' || LookAhead == EOF ) {
            do_transition( S_START );
        } else {
            do_transition( S_COMMENT );
        }

    state( S_POUND_SIGN ):
        DEBUGPUTS( "#" )
        return( Y_POUND_SIGN );

    state( S_LPAREN ):
        DEBUGPUTS( "(" )
        return( Y_LPAREN );

    state( S_RPAREN ):
        DEBUGPUTS( ")" )
        return( Y_RPAREN );

    state( S_LSQ_BRACKET ):
        DEBUGPUTS( "[" )
        return( Y_LSQ_BRACKET );

    state( S_RSQ_BRACKET ):
        DEBUGPUTS( "]" )
        return( Y_RSQ_BRACKET );

    state( S_LBRACE ):
        DEBUGPUTS( "{" )
        return( Y_LBRACE );

    state( S_RBRACE ):
        DEBUGPUTS( "}" )
        return( Y_RBRACE );

    state( S_PLUS ):
        DEBUGPUTS( "+" )
        return( Y_PLUS );

    state( S_MINUS ):
        DEBUGPUTS( "-" )
        return( Y_MINUS );

    state( S_BITNOT ):
        DEBUGPUTS( "~" )
        return( Y_BITNOT );

    state( S_NOT ):
        if( LookAhead == '=' ) {
            do_transition( S_NE );
        } else {
            DEBUGPUTS( "!" )
            return( Y_NOT );
        }

    state( S_TIMES ):
        DEBUGPUTS( "*" )
        return( Y_TIMES );

    state( S_DIVIDE ):
        DEBUGPUTS( "/" )
        return( Y_DIVIDE );

    state( S_MOD ):
        DEBUGPUTS( "%" )
        return( Y_MOD );

    state( S_GT ):
        switch( LookAhead ) {
        case '>':       do_transition( S_SHIFTR );
        case '=':       do_transition( S_GE );
        default:
            DEBUGPUTS( ">" )
            return( Y_GT );
        }

    state( S_LT ):
        switch( LookAhead ) {
        case '<':       do_transition( S_SHIFTL );
        case '=':       do_transition( S_LE );
        default:
            DEBUGPUTS( "<" )
            return( Y_LT );
        }

    state( S_EQ ):
        if( LookAhead == '=' ) {
            do_transition( S_ENDEQ );
        } else {
            DEBUGPUTS( "=" )
            return( Y_SINGLE_EQ );
        }

    state( S_BITAND ):
        if( LookAhead == '&' ) {
            do_transition( S_AND );
        } else {
            DEBUGPUTS( "&" )
            return( Y_BITAND );
        }

    state( S_BITXOR ):
        DEBUGPUTS( "^" )
        return( Y_BITXOR );

    state( S_BITOR ):
        if( LookAhead == '|' ) {
            do_transition( S_OR );
        } else {
            DEBUGPUTS( "|" )
            return( Y_BITOR );
        }

    state( S_QUESTION ):
        DEBUGPUTS( "?" )
        return( Y_QUESTION );

    state( S_COLON ):
        DEBUGPUTS( ":" )
        return( Y_COLON );

    state( S_COMMA ):
        DEBUGPUTS( "," )
        return( Y_COMMA );

    state( S_NE ):
        DEBUGPUTS( "!=" )
        return( Y_NE );

    state( S_SHIFTR ):
        DEBUGPUTS( ">>" )
        return( Y_SHIFTR );

    state( S_GE ):
        DEBUGPUTS( ">=" )
        return( Y_GE );

    state( S_SHIFTL ):
        DEBUGPUTS( "<<" )
        return( Y_SHIFTL );

    state( S_LE ):
        DEBUGPUTS( "<=" )
        return( Y_LE );

    state( S_ENDEQ ):
        DEBUGPUTS( "==" )
        return( Y_EQ );

    state( S_AND ):
        DEBUGPUTS( "&&" )
        return( Y_AND );

    state( S_OR ):
        DEBUGPUTS( "||" )
        return( Y_OR );

    state( S_STRING ):
        /* handle double-byte characters */
        i = CharSetLen[LookAhead];
        if( i ) {
            VarStringAddChar( newstring, LookAhead );
            for( ; i > 0; --i ) {
                GetNextChar();
                VarStringAddChar( newstring, LookAhead );
            }
            do_transition( S_STRING );
        }

        // if newline in string was detected, remove all whitespace from
        // begining of the next line
        if( newLineInString ) {
            if( isspace( LookAhead ) ) {
                do_transition( S_STRING );
            } else {
                // non whitespace was detected, reset newline flag, so whitespaces are treated normally
                newLineInString = 0;
            }
        }

        switch( LookAhead ) {
        case '"':           do_transition( S_STRINGEND );
        case '\\':          do_transition( S_ESCAPE_CHAR );
        case '\n':
            if( RcIoIsCOrHFile() ) {
                value->string.string = VarStringEnd( newstring, &(value->string.length) );
                DEBUGPUTS( "STRING" )
                return( Y_STRING );
            } else {
                // MSVC's RC uses this obscure way of handling newline in strings and we follow.
                // First store <space> and then <newline character>. Then on next line, all white
                // spaces from begining of line is removed
                VarStringAddChar( newstring, ' ' );
                VarStringAddChar( newstring, LookAhead );
                newLineInString = 1;
                do_transition( S_STRING );
            }
        default:
            VarStringAddChar( newstring, LookAhead );
            do_transition( S_STRING );
        }