The exact error message that this function reported varied between 32-
and 64-bit platforms for invalid integers that require more than 32 bits
but no more than 64 bits, since "long int" has a different range between
those platforms. This commit fixes the problem.
This issue caused the test "testing lexer crash due to overflow" to fail
on 32-bit platforms.
Thanks to Friedrich Beckmann for reporting the problem.
bool
lex_force_int_range (struct lexer *lexer, const char *name, long min, long max)
{
+ bool is_number = lex_is_number (lexer);
bool is_integer = lex_is_integer (lexer);
- bool too_small = is_integer && lex_integer (lexer) < min;
- bool too_big = is_integer && lex_integer (lexer) > max;
+ bool too_small = (is_integer ? lex_integer (lexer) < min
+ : is_number ? lex_number (lexer) < min
+ : false);
+ bool too_big = (is_integer ? lex_integer (lexer) > max
+ : is_number ? lex_number (lexer) > max
+ : false);
if (is_integer && !too_small && !too_big)
return true;