]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Move compat macros and prototypes to dlua-compat.h
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Thu, 4 Mar 2021 21:51:46 +0000 (16:51 -0500)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Wed, 10 Mar 2021 19:12:41 +0000 (19:12 +0000)
Additionally, fix -Wstrict-bool issue in luaL_newmetatable() compatibility
wrapper.

src/lib-lua/dlua-compat.h
src/lib-lua/dlua-script-private.h

index f1e564d5d0c6823129fe7a669fb826a117c99d5a..f53b7009b7c3348013ecfb6aa960e5339437abb4 100644 (file)
@@ -5,6 +5,23 @@
  * In general, make whatever Lua version we have behave more like Lua 5.3.
  */
 
+/* functionality missing from <= 5.2 */
+#if LUA_VERSION_NUM <= 502
+#  define luaL_newmetatable(L, tn) \
+       ((luaL_newmetatable(L, tn) != 0) ? \
+        (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : \
+        0)
+#endif
+
+/* functionality missing from <= 5.1 */
+#if LUA_VERSION_NUM <= 501
+#  define lua_load(L, r, s, fn, m) lua_load(L, r, s, fn)
+#  define luaL_newlibtable(L, l) (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1))
+#  define luaL_newlib(L, l) (luaL_newlibtable(L, l), luaL_register(L, NULL, l))
+void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
+void luaL_setmetatable (lua_State *L, const char *tname);
+#endif
+
 #ifndef HAVE_LUA_ISINTEGER
 /*
  * Lua 5.3 can actually keep track of intergers vs. numbers.  As a
index f14d221e9730b90fa617e952f38cb27415123500..edbfb6b8cf2d807778e5e7b2cf65e6bafc5d0f0c 100644 (file)
@@ -6,16 +6,6 @@
 #include "lauxlib.h"
 #include "dlua-compat.h"
 
-#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
-#define luaL_newmetatable(L, tn) \
-       (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0)
-#define luaL_newlibtable(L, l) (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1))
-#define luaL_newlib(L, l) (luaL_newlibtable(L, l), luaL_register(L, NULL, l))
-#define lua_load(L, r, s, fn, m) lua_load(L, r, s, fn)
-void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
-void luaL_setmetatable (lua_State *L, const char *tname);
-#endif
-
 /* consistency helpers */
 #define lua_isstring(L, n) (lua_isstring(L, n) == 1)
 #define lua_isnumber(L, n) (lua_isnumber(L, n) == 1)