lua: Force 'return' when = is present
This commit is contained in:
parent
9c049271e7
commit
9ca1606e2a
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user