From a3addae03634794b841b6c8c4dd8ff83542d8896 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 12 Mar 2014 17:57:40 -0300 Subject: lua_gettable and similars return type of gotten value --- loslib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'loslib.c') diff --git a/loslib.c b/loslib.c index 3e9a1bf8..b301681f 100644 --- a/loslib.c +++ b/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.42 2014/02/26 15:27:56 roberto Exp roberto $ +** $Id: loslib.c,v 1.43 2014/02/26 15:55:58 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -158,8 +158,7 @@ static void setboolfield (lua_State *L, const char *key, int value) { static int getboolfield (lua_State *L, const char *key) { int res; - lua_getfield(L, -1, key); - res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + res = (lua_getfield(L, -1, key) == LUA_TNIL) ? -1 : lua_toboolean(L, -1); lua_pop(L, 1); return res; } -- cgit v1.2.3-55-g6feb