aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lauxlib.c b/lauxlib.c
index e08da9bc..822f7955 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.237 2011/11/29 15:55:08 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.238 2011/11/30 12:58:57 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*/
@@ -269,7 +269,7 @@ LUALIB_API int luaL_execresult (lua_State *L, int stat) {
269*/ 269*/
270 270
271LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { 271LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
272 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ 272 luaL_getmetatable(L, tname); /* try to get metatable */
273 if (!lua_isnil(L, -1)) /* name already in use? */ 273 if (!lua_isnil(L, -1)) /* name already in use? */
274 return 0; /* leave previous value on top, but return 0 */ 274 return 0; /* leave previous value on top, but return 0 */
275 lua_pop(L, 1); 275 lua_pop(L, 1);
@@ -290,7 +290,7 @@ LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
290 void *p = lua_touserdata(L, ud); 290 void *p = lua_touserdata(L, ud);
291 if (p != NULL) { /* value is a userdata? */ 291 if (p != NULL) { /* value is a userdata? */
292 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ 292 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
293 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ 293 luaL_getmetatable(L, tname); /* get correct metatable */
294 if (!lua_rawequal(L, -1, -2)) /* not the same? */ 294 if (!lua_rawequal(L, -1, -2)) /* not the same? */
295 p = NULL; /* value is a userdata with wrong metatable */ 295 p = NULL; /* value is a userdata with wrong metatable */
296 lua_pop(L, 2); /* remove both metatables */ 296 lua_pop(L, 2); /* remove both metatables */