3 @@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lu
5 return 0; /* Reject the number */
7 + } else if (v > LUA_INTEGER_MAX) {
10 } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) {
11 return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */
12 @@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Inte
16 +#ifdef LONG_OVERFLOW_LUA_INTEGER
17 +unsigned LUA_INTEGER lua_str2ul( const char *str, char **endptr, int base ) {
18 + unsigned long v= strtoul(str, endptr, base);
19 + if ( v > LUA_INTEGER_MAX ) {
23 + return (unsigned LUA_INTEGER)v;
26 --- a/src/lnum_config.h
27 +++ b/src/lnum_config.h
32 -# define lua_str2ul (unsigned LUA_INTEGER)strtoul
33 +# if LONG_MAX > LUA_INTEGER_MAX
34 +# define LONG_OVERFLOW_LUA_INTEGER
35 + unsigned LUA_INTEGER lua_str2ul( const char *str, char **endptr, int base );
37 +# define lua_str2ul (unsigned LUA_INTEGER)strtoul
40 #ifndef LUA_INTEGER_MIN
41 # define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */