Skip to content
Permalink
Browse files
Fine-grained compatibility definitions
Turns out that you were on a good track with commit 5ec8969, and what
I did with ec6f461 was nonsense.

`LUA_COMPAT_ALL` and `LUA_COMPAT_5_1` are used when compiling Lua, to
add compatility functions to liblua, and don't have the desired effect
here. If compat functions are not available on the system (apparently
neither Debian nor Homebrew enable them), then we need to define the
compatibility functions ourselves.

With this commit, lua-zip can now be used on Lua 5.1, 5.2, and 5.3,
even if compatibility functions are not present in the Lua library.
  • Loading branch information
MisterDA committed Apr 7, 2019
1 parent 9607231 commit 4b37e98
Showing 1 changed file with 13 additions and 3 deletions.
@@ -1,13 +1,23 @@
#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>
#include <assert.h>
#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

#define ARCHIVE_MT "zip{archive}"
#define ARCHIVE_FILE_MT "zip{archive.file}"

0 comments on commit 4b37e98

Please sign in to comment.