]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Add lua_pushboolean helper to push real booleans
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 14 Mar 2018 16:49:50 +0000 (18:49 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 14 Nov 2018 12:01:53 +0000 (14:01 +0200)
Makes boolean handling in dovecot code slightly easier

src/auth/db-lua.c
src/lib-lua/dlua-script-private.h
src/lib-lua/dlua-script.c

index 0a5ad64000bca2f1ff8f22269f6d61f7b569276b..7776bca64bc520832bcf7badf24124ebe457d2ab 100644 (file)
@@ -317,7 +317,7 @@ static void auth_lua_push_auth_request(struct dlua_script *script, struct auth_r
 
 #undef LUA_TABLE_SETBOOL
 #define LUA_TABLE_SETBOOL(field) \
-       lua_pushboolean(script->L, req->field ? 1 : 0); \
+       lua_pushboolean(script->L, req->field); \
        lua_setfield(script->L, -2, #field);
 
        LUA_TABLE_SETBOOL(skip_password_check);
index 4914c91923f38080b2920333a1c74e3e60ef5767..ddd7ac8a4a1dd2e4d5d07860faa0788a6206069e 100644 (file)
@@ -25,6 +25,7 @@ void luaL_setmetatable (lua_State *L, const char *tname);
 #define lua_isstring(L, n) (lua_isstring(L, n) == 1)
 #define lua_isnumber(L, n) (lua_isnumber(L, n) == 1)
 #define lua_toboolean(L, n) (lua_toboolean(L, n) == 1)
+#define lua_pushboolean(L, b) lua_pushboolean((L), (b) ? 1 : 0)
 
 #define DLUA_TABLE_STRING(n, s) { .name = n, .type = DLUA_TABLE_VALUE_STRING, .v.s = s }
 #define DLUA_TABLE_INTEGER(n, i) { .name = n, .type = DLUA_TABLE_VALUE_INTEGER, .v.i = i }
index 9e93450b6f689dc1a8ba2f722c44e9a57dca92f1..2a9b5c3e11a9d95ec60166b627f51bcd059383c2 100644 (file)
@@ -333,7 +333,7 @@ void dlua_setmembers(struct dlua_script *script,
                        lua_pushnumber(script->L, values->v.d);
                        break;
                case DLUA_TABLE_VALUE_BOOLEAN:
-                       lua_pushboolean(script->L, values->v.b ? 1 : 0);
+                       lua_pushboolean(script->L, values->v.b);
                        break;
                case DLUA_TABLE_VALUE_NULL:
                        lua_pushnil(script->L);