From 9ca1606e2aeece48e6757312575f5f130cf56067 Mon Sep 17 00:00:00 2001 From: mniip Date: Thu, 14 Jul 2016 17:04:58 +0300 Subject: lua: Force 'return' when = is present --- plugins/lua/lua.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c index 6f3fc27f..06e0f6eb 100644 --- a/plugins/lua/lua.c +++ b/plugins/lua/lua.c @@ -1482,17 +1482,22 @@ static void inject_string(script_info *info, char const *line) lua_State *L = info->state; int base, top; char *ret_line; + gboolean force_ret = FALSE; if(line[0] == '=') + { line++; + force_ret = TRUE; + } ret_line = g_strconcat("return ", line, NULL); lua_rawgeti(L, LUA_REGISTRYINDEX, info->traceback); base = lua_gettop(L); if(luaL_loadbuffer(L, ret_line, strlen(ret_line), "@interpreter")) { - lua_pop(L, 1); - if(luaL_loadbuffer(L, line, strlen(line), "@interpreter")) + if(!force_ret) + lua_pop(L, 1); + if(force_ret || luaL_loadbuffer(L, line, strlen(line), "@interpreter")) { hexchat_printf(ph, "Lua syntax error: %s", luaL_optstring(L, -1, "")); lua_pop(L, 2); -- cgit 1.4.1