diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6447038..0959886 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,10 @@ test: stage: test image: archlinux script: - - pacman -Syu --noconfirm luarocks lua51 gcc opencc - - luarocks install --lua-version 5.1 busted - - luarocks make --lua-version 5.1 - - busted busted_unittest.lua \ No newline at end of file + - pacman -Syu --noconfirm luarocks gcc opencc lua51 lua52 lua53 lua + - for i in 5.1 5.2 5.3 5.4; do + - luarocks install --lua-version $i busted + - luarocks make --lua-version $i + - busted busted_unittest.lua + - luarocks remove --lua-version $i busted + - done \ No newline at end of file diff --git a/luaocc-0.1-2.rockspec b/luaocc-0.1-2.rockspec index 714508c..f2f5fbb 100644 --- a/luaocc-0.1-2.rockspec +++ b/luaocc-0.1-2.rockspec @@ -10,7 +10,7 @@ description = { license = "Apache" } dependencies = { - "lua ~> 5.1" + "lua >= 5.1 <= 5.4" } external_dependencies = { OPENCC = { diff --git a/main.c b/main.c index 951386a..06593e4 100644 --- a/main.c +++ b/main.c @@ -35,21 +35,26 @@ static int L_close(lua_State *L) { return 0; } -static const struct luaL_reg occlib[] = { +static const struct luaL_Reg occlib[] = { {"open", L_open}, {"convert", L_convert}, {NULL, NULL} }; -static const struct luaL_reg occmt[] = { +static const struct luaL_Reg occmt[] = { {"__call", L_convert}, {"__gc", L_close}, {NULL, NULL} }; +#if (LUA_VERSION_NUM >= 502) + #define luaL_register(L, _, l) luaL_setfuncs(L, l, 0) +#endif + int luaopen_luaocc(lua_State *L) { luaL_newmetatable(L, "luaocc"); luaL_register(L, NULL, occmt); - luaL_register(L, "luaocc", occlib); + lua_newtable(L); + luaL_register(L, NULL, occlib); return 1; -} \ No newline at end of file +}