lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 13, 2012, at 12:15 PM, Roberto Ierusalimschy wrote:

>> We run Lua 5.2 in an embedded device and have changed lua_Number to
>> the C type int.
>> 
>> There are a few problems with this in the new Lua 5.2
>> 
>> In lstrlib.c line 883, please consider changing:
>> luaL_argcheck(L, 0 <= n && n < (MAX_UINTFRM + 1), arg,
>> to:
>> luaL_argcheck(L, 0 <= n && (unsigned LUA_INTFRM_T)n <= (MAX_UINTFRM), arg,
> 
> I think this change does not work with the regular setting:
> 
>> return string.format("%x", 2^64)
> 0
> 
> (It should give an error in this case.)

How about 

luaL_argcheck(L, 0 <= n && n <= (unsigned LUA_INTFRM_T)(MAX_UINTFRM), arg,

This will convert n to (unsigned LUA_INTFRM_T) only when it's not a float/double.

e