summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index 1f8d296f..abc85e91 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.179 2002/03/20 12:51:29 roberto Exp roberto $ 2** $Id: lapi.c,v 1.180 2002/03/26 20:46:10 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -400,9 +400,10 @@ LUA_API void lua_newtable (lua_State *L) {
400} 400}
401 401
402 402
403LUA_API void lua_getmetatable (lua_State *L, int objindex) { 403LUA_API int lua_getmetatable (lua_State *L, int objindex) {
404 StkId obj; 404 StkId obj;
405 Table *mt; 405 Table *mt;
406 int res;
406 lua_lock(L); 407 lua_lock(L);
407 obj = luaA_indexAcceptable(L, objindex); 408 obj = luaA_indexAcceptable(L, objindex);
408 switch (ttype(obj)) { 409 switch (ttype(obj)) {
@@ -415,12 +416,17 @@ LUA_API void lua_getmetatable (lua_State *L, int objindex) {
415 default: 416 default:
416 mt = hvalue(defaultmeta(L)); 417 mt = hvalue(defaultmeta(L));
417 } 418 }
418 if (mt == hvalue(defaultmeta(L))) 419 if (mt == hvalue(defaultmeta(L))) {
419 setnilvalue(L->top); 420 setnilvalue(L->top);
420 else 421 res = 0;
422 }
423 else {
421 sethvalue(L->top, mt); 424 sethvalue(L->top, mt);
425 res = 1;
426 }
422 api_incr_top(L); 427 api_incr_top(L);
423 lua_unlock(L); 428 lua_unlock(L);
429 return res;
424} 430}
425 431
426 432