From 53b5d4de6c8732da113f56efdd1e0e9b797d8591 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 1 Sep 2017 13:28:40 +0800 Subject: fixes compile for Lua 5.1 --- lua/lua-ext-console.c | 4 +--- lua/lua-plugin-init.c | 5 +++++ lua/lua-plugin.c | 8 ++++---- lua/test-lua-plugin.c | 2 -- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/lua-ext-console.c b/lua/lua-ext-console.c index dbbadfb..2c9c37c 100644 --- a/lua/lua-ext-console.c +++ b/lua/lua-ext-console.c @@ -101,8 +101,6 @@ int main(int argc, char * argv[]){ exit(1); } - g_type_init(); - IBusEnginePlugin * plugin = ibus_engine_plugin_new(); for ( i = 1; i < argc; ++i){ @@ -128,7 +126,7 @@ int main(int argc, char * argv[]){ print_interactive_help(); if ( 0 == strcmp("i", strs[0]) ) list_all_commands(plugin); - break; + break; case 2: if ( 0 == strcmp("i", strs[0])) do_lua_call(plugin, strs[1], NULL); diff --git a/lua/lua-plugin-init.c b/lua/lua-plugin-init.c index acc750a..e42cc17 100644 --- a/lua/lua-plugin-init.c +++ b/lua/lua-plugin-init.c @@ -26,10 +26,15 @@ #include "lua-plugin.h" +#if LUA_VERSION_NUM >= 502 +/* ugly hack for lua 5.2 */ + #ifndef lua_objlen #define lua_objlen lua_rawlen #endif +#endif + static const luaL_Reg lualibs[] = { {"", luaopen_base}, diff --git a/lua/lua-plugin.c b/lua/lua-plugin.c index 39b32f3..89941e7 100644 --- a/lua/lua-plugin.c +++ b/lua/lua-plugin.c @@ -25,15 +25,15 @@ #include "lua-plugin.h" -#ifndef lua_objlen -#define lua_objlen lua_rawlen -#endif - #if LUA_VERSION_NUM >= 502 /* ugly hack for lua 5.2 */ #define lua_open luaL_newstate +#ifndef lua_objlen +#define lua_objlen lua_rawlen +#endif + #endif #define IBUS_ENGINE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginPrivate)) diff --git a/lua/test-lua-plugin.c b/lua/test-lua-plugin.c index 432903a..d334ea8 100644 --- a/lua/test-lua-plugin.c +++ b/lua/test-lua-plugin.c @@ -28,8 +28,6 @@ int main(int argc, char * argv[]){ printf("starting test...\n"); - g_type_init(); - IBusEnginePlugin * plugin; plugin = ibus_engine_plugin_new(); -- cgit