aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-09-22 03:42:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-09-22 03:42:15 -0300
commit6384475ec4112361b0ab27de553e85863464b846 (patch)
treed2242751ca7ccb13e364a097388708932bdeeb52 /lbaselib.c
parent3a15c7ce4338de8414239a898f6c121294b4dde7 (diff)
downloadlua-6384475ec4112361b0ab27de553e85863464b846.tar.gz
lua-6384475ec4112361b0ab27de553e85863464b846.tar.bz2
lua-6384475ec4112361b0ab27de553e85863464b846.zip
'luaL_getmetafield' returns type of metafield (instead of a boolean)
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lbaselib.c b/lbaselib.c
index ba92fc90..0ceb135c 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -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
213static int pairsmeta (lua_State *L, const char *method, int iszero, 213static 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*/
280static int luaB_ipairs (lua_State *L) { 280static 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);