From e5e740fee49b8a52b5d42debf07488503ca5ec40 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 30 Apr 2015 20:47:41 +0200 Subject: support for Lua 5.2 --- src/lua-mq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lua-mq.c b/src/lua-mq.c index 07cd2ef..a556818 100644 --- a/src/lua-mq.c +++ b/src/lua-mq.c @@ -192,7 +192,7 @@ static int l_mq_unlink(lua_State *L) return 1; } -static const struct luaL_reg mq_funcs [] = { +static const struct luaL_Reg mq_funcs [] = { { "create", l_mq_create }, { "open", l_mq_open }, { "send", l_mq_send }, @@ -204,6 +204,14 @@ static const struct luaL_reg mq_funcs [] = { LUALIB_API int luaopen_mq(lua_State *L) { +#if LUA_VERSION_NUM > 501 + lua_newtable(L); + luaL_setfuncs(L, mq_funcs, 0); + /* since Lua 5.2 libs shouldn't do that anymore... */ + /* lua_pushvalue(L, -1); */ + /* lua_setglobal(L, "mq"); */ +#else luaL_register(L, "mq", mq_funcs); +#endif return 1; } -- cgit v1.2.3