lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thank you all,

This is what I came up with:

https://github.com/brimworks/lua-zip/commit/4b37e9855e3b8d03ce92ec128aa41e6bbe87d6ce

All the checks may completely be an overkill, but I think it's the
best I can do. It seems to work without troubles on Debian with all
available versions of Lua, and on Homebrew too. (Also this code was
upstreamed and tagged as new version, so please^3 don't tell me
there's an obvious bug with this).


diff --git a/lua_zip.c b/lua_zip.c
index e9300b2..6570595 100644
--- a/lua_zip.c
+++ b/lua_zip.c
@@ -1,6 +1,3 @@
-#define LUA_COMPAT_ALL          /* Lua 5.2 -> Lua 5.1 */
-#define LUA_COMPAT_5_1          /* Lua 5.3 -> Lua 5.1 */
-
 #include <lauxlib.h>
 #include <lua.h>
 #include <zip.h>
@@ -8,6 +5,19 @@
 #include <errno.h>
 #include <string.h>

+#if LUA_VERSION_NUM > 502 && !defined(LUA_COMPAT_APIINTCASTS)
+#define luaL_checkint(L,n)      ((int)luaL_checkinteger(L, (n)))
+#endif
+
+#if LUA_VERSION_NUM > 501
+#if !defined(LUA_COMPAT_MODULE)
+#define luaL_register(L,_,funcs) luaL_setfuncs((L),funcs,0)
+#endif
+#if !defined(LUA_COMPAT_ALL) || !defined(LUA_COMPAT_5_1)
+#define lua_objlen(L,i)         lua_rawlen(L, (i))
+#define lua_equal(L,idx1,idx2)          lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#endif
+#endif

Thank you very much for the help!

-- Antonin