diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.295 2014/08/01 17:33:08 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.296 2014/08/21 20:07:56 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -129,7 +129,7 @@ static int luaB_setmetatable (lua_State *L) { | |||
129 | luaL_checktype(L, 1, LUA_TTABLE); | 129 | luaL_checktype(L, 1, LUA_TTABLE); |
130 | luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, | 130 | luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, |
131 | "nil or table expected"); | 131 | "nil or table expected"); |
132 | if (luaL_getmetafield(L, 1, "__metatable")) | 132 | if (luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL) |
133 | return luaL_error(L, "cannot change a protected metatable"); | 133 | return luaL_error(L, "cannot change a protected metatable"); |
134 | lua_settop(L, 2); | 134 | lua_settop(L, 2); |
135 | lua_setmetatable(L, 1); | 135 | lua_setmetatable(L, 1); |
@@ -212,7 +212,7 @@ static int luaB_type (lua_State *L) { | |||
212 | 212 | ||
213 | static int pairsmeta (lua_State *L, const char *method, int iszero, | 213 | static int pairsmeta (lua_State *L, const char *method, int iszero, |
214 | lua_CFunction iter) { | 214 | lua_CFunction iter) { |
215 | if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */ | 215 | if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ |
216 | luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ | 216 | luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ |
217 | lua_pushcfunction(L, iter); /* will return generator, */ | 217 | lua_pushcfunction(L, iter); /* will return generator, */ |
218 | lua_pushvalue(L, 1); /* state, */ | 218 | lua_pushvalue(L, 1); /* state, */ |
@@ -279,8 +279,8 @@ static int ipairsaux (lua_State *L) { | |||
279 | */ | 279 | */ |
280 | static int luaB_ipairs (lua_State *L) { | 280 | static int luaB_ipairs (lua_State *L) { |
281 | lua_CFunction iter = | 281 | lua_CFunction iter = |
282 | (luaL_getmetafield(L, 1, "__len") || | 282 | (luaL_getmetafield(L, 1, "__len") != LUA_TNIL || |
283 | luaL_getmetafield(L, 1, "__index")) | 283 | luaL_getmetafield(L, 1, "__index") != LUA_TNIL) |
284 | ? ipairsaux : ipairsaux_raw; | 284 | ? ipairsaux : ipairsaux_raw; |
285 | #if defined(LUA_COMPAT_IPAIRS) | 285 | #if defined(LUA_COMPAT_IPAIRS) |
286 | return pairsmeta(L, "__ipairs", 1, iter); | 286 | return pairsmeta(L, "__ipairs", 1, iter); |