Fix botlib parser for negative int/float values, thanks to Makro for reporting (#4227).

This commit is contained in:
Thilo Schulz 2009-10-19 23:29:44 +00:00
parent 5663ff1362
commit ba31be1736
3 changed files with 48 additions and 17 deletions

View file

@ -2561,12 +2561,16 @@ int PC_DollarDirective_evalint(source_t *source)
sprintf(token.string, "%d", abs(value));
token.type = TT_NUMBER;
token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;
#ifdef NUMBERVALUE
token.intvalue = value;
token.floatvalue = value;
token.intvalue = abs(value);
token.floatvalue = token.intvalue;
#endif //NUMBERVALUE
PC_UnreadSourceToken(source, &token);
if (value < 0) UnreadSignToken(source);
if (value < 0)
UnreadSignToken(source);
return qtrue;
} //end of the function PC_DollarDirective_evalint
//============================================================================
@ -2588,12 +2592,16 @@ int PC_DollarDirective_evalfloat(source_t *source)
sprintf(token.string, "%1.2f", fabs(value));
token.type = TT_NUMBER;
token.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL;
#ifdef NUMBERVALUE
token.intvalue = (unsigned long) value;
token.floatvalue = value;
token.floatvalue = fabs(value);
token.intvalue = (unsigned long) token.floatvalue;
#endif //NUMBERVALUE
PC_UnreadSourceToken(source, &token);
if (value < 0) UnreadSignToken(source);
if (value < 0)
UnreadSignToken(source);
return qtrue;
} //end of the function PC_DollarDirective_evalfloat
//============================================================================