From 0590895ea78cb3e7be25ca833bfeca5f56dc7e21 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 8 Jun 2004 15:20:23 +0000 Subject: fix parse error in sign of exponents (bug 968323) --- src/mesa/shader/arbprogparse.c | 43 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index ae06444372..de449fe098 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -621,23 +621,23 @@ parse_string_without_adding (GLubyte ** inst, struct arb_program *Program) } /** - * \return 0 if sign is plus, 1 if sign is minus + * \return -1 if we parse '-', return 1 otherwise */ -static GLuint +static GLint parse_sign (GLubyte ** inst) { /*return *(*inst)++ != '+'; */ if (**inst == '-') { (*inst)++; - return 1; + return -1; } else if (**inst == '+') { (*inst)++; - return 0; + return 1; } - return 0; + return 1; } /** @@ -670,10 +670,7 @@ parse_integer (GLubyte ** inst, struct arb_program *Program) */ Program->Position = parse_position (inst); - if (sign) - value *= -1; - - return value; + return value * sign; } /** @@ -685,9 +682,6 @@ parse_float (GLubyte ** inst, struct arb_program *Program) GLuint leading_zeros =0; GLfloat value = 0; -#if 0 - tmp[0] = parse_sign (inst); /* This is the sign of the number + - >0, - -> 1 */ -#endif tmp[1] = parse_integer (inst, Program); /* This is the integer portion of the number */ /* Now we grab the fractional portion of the number (the digits after @@ -709,10 +703,7 @@ parse_float (GLubyte ** inst, struct arb_program *Program) denom *= 10; denom *= (GLint) _mesa_pow( 10, leading_zeros ); value += (GLfloat) tmp[2] / (GLfloat) denom; -#if 0 - if (tmp[0]) - value *= -1; -#endif + value *= (GLfloat) _mesa_pow (10, (GLfloat) tmp[3] * (GLfloat) tmp[4]); return value; @@ -724,17 +715,9 @@ parse_float (GLubyte ** inst, struct arb_program *Program) static GLfloat parse_signed_float (GLubyte ** inst, struct arb_program *Program) { - GLint negate; - GLfloat value; - - negate = parse_sign (inst); - - value = parse_float (inst, Program); - - if (negate) - value *= -1; - - return value; + GLint sign = parse_sign (inst); + GLfloat value = parse_float (inst, Program); + return value * sign; } /** @@ -2405,7 +2388,7 @@ parse_extended_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLboolean * Negate *Negate = GL_FALSE; for (a = 0; a < 4; a++) { - if (parse_sign (inst)) + if (parse_sign (inst) == -1) *Negate = GL_TRUE; swz = *(*inst)++; @@ -2614,7 +2597,7 @@ parse_vector_src_reg (GLcontext * ctx, GLubyte ** inst, GLubyte * Swizzle, GLboolean *IsRelOffset) { /* Grab the sign */ - *Negate = parse_sign (inst); + *Negate = (parse_sign (inst) == -1); /* And the src reg */ if (parse_src_reg (ctx, inst, vc_head, Program, File, Index, IsRelOffset)) @@ -2635,7 +2618,7 @@ parse_scalar_src_reg (GLcontext * ctx, GLubyte ** inst, GLubyte * Swizzle, GLboolean *IsRelOffset) { /* Grab the sign */ - *Negate = parse_sign (inst); + *Negate = (parse_sign (inst) == -1); /* And the src reg */ if (parse_src_reg (ctx, inst, vc_head, Program, File, Index, IsRelOffset)) -- cgit v1.2.3