diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-29 10:52:21 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-29 10:52:21 -0200 |
commit | 9be89a1864a4a8c6505e3f1c3457831893b66d27 (patch) | |
tree | b984a302511a7c7502bc3c0c952cab66e3fd8b20 | |
parent | b9f371a3c2e6da297d7d6de581519c92d4e38e2f (diff) | |
download | lua-9be89a1864a4a8c6505e3f1c3457831893b66d27.tar.gz lua-9be89a1864a4a8c6505e3f1c3457831893b66d27.tar.bz2 lua-9be89a1864a4a8c6505e3f1c3457831893b66d27.zip |
'luaL_checkversion' also checks convertions (number to integer types)
-rw-r--r-- | lauxlib.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.222 2010/10/25 19:01:37 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.223 2010/10/25 20:31:11 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -876,5 +876,12 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { | |||
876 | else if (*v != ver) | 876 | else if (*v != ver) |
877 | luaL_error(L, "version mismatch: app. needs %d, Lua core provides %f", | 877 | luaL_error(L, "version mismatch: app. needs %d, Lua core provides %f", |
878 | ver, *v); | 878 | ver, *v); |
879 | /* check conversions number -> integer types */ | ||
880 | lua_pushnumber(L, -(lua_Number)0x1234); | ||
881 | if (lua_tointeger(L, -1) != -0x1234 || | ||
882 | lua_tounsigned(L, -1) != (lua_Unsigned)-0x1234) | ||
883 | luaL_error(L, "bad conversion number->int;" | ||
884 | " must recompile Lua with proper settings"); | ||
885 | lua_pop(L, 1); | ||
879 | } | 886 | } |
880 | 887 | ||