diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.59 2002/02/14 21:42:22 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.60 2002/03/20 12:54:08 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 | */ |
@@ -120,11 +120,18 @@ static int luaB_error (lua_State *L) { | |||
120 | 120 | ||
121 | 121 | ||
122 | static int luaB_metatable (lua_State *L) { | 122 | static int luaB_metatable (lua_State *L) { |
123 | luaL_check_type(L, 1, LUA_TTABLE); | 123 | luaL_check_any(L, 1); |
124 | if (lua_isnone(L, 2)) | 124 | if (lua_isnone(L, 2)) { |
125 | lua_getmetatable(L, 1); | 125 | if (lua_getmetatable(L, 1)) { |
126 | lua_pushliteral(L, "__metatable"); | ||
127 | lua_rawget(L, -2); | ||
128 | if (lua_isnil(L, -1)) | ||
129 | lua_pop(L, 1); | ||
130 | } | ||
131 | } | ||
126 | else { | 132 | else { |
127 | int t = lua_type(L, 2); | 133 | int t = lua_type(L, 2); |
134 | luaL_check_type(L, 1, LUA_TTABLE); | ||
128 | luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); | 135 | luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); |
129 | lua_settop(L, 2); | 136 | lua_settop(L, 2); |
130 | lua_setmetatable(L, 1); | 137 | lua_setmetatable(L, 1); |