]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: unified Lua version checks
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 14:22:44 +0000 (16:22 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 14:22:44 +0000 (16:22 +0200)
daemon/bindings.c
daemon/engine.c

index 5ed40a3c43f09e0acf8660235d993856398cc89b..cbb181837053f11d9240d3caa644fb626ae9a158 100644 (file)
 #include "daemon/bindings.h"
 
 /** @internal Compatibility wrapper for Lua 5.0 - 5.2 */
-#if LUA_VERSION_NUM < 502
+#if LUA_VERSION_NUM >= 502
+#define register_lib(L, name, lib) \
+       luaL_newlib((L), (lib))
+#else
 #define lua_rawlen(L, obj) \
        lua_objlen((L), (obj))
 #define register_lib(L, name, lib) \
        luaL_openlib((L), (name), (lib), 0)
-#else
-#define register_lib(L, name, lib) \
-       luaL_newlib((L), (lib))
 #endif
 
 /** List loaded modules */
index 791936d32783eb26d99f763d57358d7d678aa8e4..4011407908784c4aec85d90a4d620f558591f6d9 100644 (file)
@@ -321,11 +321,11 @@ int engine_unregister(struct engine *engine, const char *name)
 void engine_lualib(struct engine *engine, const char *name, lua_CFunction lib_cb)
 {
        if (engine != NULL) {
-#if LUA_VERSION_NUM < 502
-               lib_cb(engine->L);
-#else
+#if LUA_VERSION_NUM >= 502
                luaL_requiref(engine->L, name, lib_cb, 1);
                lua_pop(engine->L, 1);
+#else
+               lib_cb(engine->L);
 #endif
        }
 }