From 899b397f3f5d04c5f34ef8b964f9395e34cbff14 Mon Sep 17 00:00:00 2001 From: tomoe-mami Date: Tue, 1 Nov 2016 14:18:47 +0100 Subject: [PATCH] lua: use lua_pushinteger for int values in lua 5.3 --- src/plugins/lua/weechat-lua-api.c | 9 +++++++++ src/plugins/lua/weechat-lua.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index ba75aad74..ab3dcc163 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -82,12 +82,21 @@ if (__string) \ free (__string); \ return 1 +#if LUA_VERSION_NUM >= 503 +#define API_RETURN_INT(__int) \ + lua_pushinteger (L, __int); \ + return 1 +#define API_RETURN_LONG(__long) \ + lua_pushinteger (L, __long); \ + return 1 +#else #define API_RETURN_INT(__int) \ lua_pushnumber (L, __int); \ return 1 #define API_RETURN_LONG(__long) \ lua_pushnumber (L, __long); \ return 1 +#endif /* LUA_VERSION_NUM >= 503 */ /* diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c index fbb08cad1..90f3e4fc9 100644 --- a/src/plugins/lua/weechat-lua.c +++ b/src/plugins/lua/weechat-lua.c @@ -188,7 +188,11 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type, lua_pushstring (lua_current_interpreter, (char *)argv[i]); break; case 'i': /* integer */ +#if LUA_VERSION_NUM >= 503 + lua_pushinteger (lua_current_interpreter, *((int *)argv[i])); +#else lua_pushnumber (lua_current_interpreter, *((int *)argv[i])); +#endif /* LUA_VERSION_NUM >= 503 */ break; case 'h': /* hash */ weechat_lua_pushhashtable (lua_current_interpreter, @@ -267,7 +271,11 @@ weechat_lua_add_constant (lua_State *L, struct t_lua_const *ptr_const) if (ptr_const->str_value) lua_pushstring (L, ptr_const->str_value); else +#if LUA_VERSION_NUM >= 503 + lua_pushinteger (L, ptr_const->int_value); +#else lua_pushnumber (L, ptr_const->int_value); +#endif /* LUA_VERSION_NUM >= 503 */ lua_settable(L, -3); }