# HG changeset patch # User Ryan C. Gordon # Date 1234420762 18000 # Node ID cdc8bb82f7d2847cd3e95e34a6fcd0335100c2ed # Parent f8f81d832fa0d4bc8d1ba6a3bf6e2107484d62dc Fixed parse_num(). diff -r f8f81d832fa0 -r cdc8bb82f7d2 mojoshader_assembler.c --- a/mojoshader_assembler.c Thu Feb 12 01:31:17 2009 -0500 +++ b/mojoshader_assembler.c Thu Feb 12 01:39:22 2009 -0500 @@ -982,13 +982,23 @@ static int parse_num(Context *ctx, const int floatok, uint32 *value) { union { float f; int32 si32; uint32 ui32; } cvt; + int negative = 0; + Token token = nexttoken(ctx); - const Token token = nexttoken(ctx); + if (token == ((Token) '-')) + { + negative = 1; + token = nexttoken(ctx); + } // if + if (token == TOKEN_INT_LITERAL) { int d = 0; sscanf(ctx->token, "%d", &d); - cvt.si32 = (int32) d; + if (floatok) + cvt.f = (float) ((negative) ? -d : d); + else + cvt.si32 = (int32) ((negative) ? -d : d); } // if else if (token == TOKEN_FLOAT_LITERAL) { @@ -999,6 +1009,8 @@ return 0; } // if sscanf(ctx->token, "%f", &cvt.f); + if (negative) + cvt.f = -cvt.f; } // if else {