From: Richard Russon Date: Tue, 27 Mar 2018 02:40:07 +0000 (+0100) Subject: lua: fix variable getting/setting X-Git-Tag: neomutt-20180512~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=477ec3b4de2855d4c3f076a9de0cf90089992bd4;p=neomutt lua: fix variable getting/setting --- diff --git a/contrib/lua/test_lua-api_spec.lua b/contrib/lua/test_lua-api_spec.lua index 70619f5a7..dc8df5d68 100644 --- a/contrib/lua/test_lua-api_spec.lua +++ b/contrib/lua/test_lua-api_spec.lua @@ -61,7 +61,7 @@ describe('lua API', function() end) it('works with DT_PATH', function() - test_config_type("alias_file", "contrib/lua/test_lua-api_runner.muttrc", "/dev/null") + test_config_type("alias_file", "contrib/lua/test_lua-api_runner.neomuttrc", "/dev/null") end) it('works with DT_MAGIC', function() diff --git a/main.c b/main.c index c58df0135..58e8fc514 100644 --- a/main.c +++ b/main.c @@ -508,6 +508,8 @@ int main(int argc, char **argv, char **env) { OPT_NO_CURSES = true; sendflags = SENDBATCH; + MuttLogger = log_disp_terminal; + log_queue_flush(log_disp_terminal); } /* Always create the mutt_windows because batch mode has some shared code diff --git a/mutt_lua.c b/mutt_lua.c index a54139b43..7dd702734 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -149,6 +149,7 @@ static int lua_mutt_set(lua_State *l) FREE(&opt.var); break; case DT_QUAD: + { opt.var = (long) lua_tointeger(l, -1); if ((opt.var != MUTT_YES) && (opt.var != MUTT_NO) && (opt.var != MUTT_ASKYES) && (opt.var != MUTT_ASKNO)) @@ -161,8 +162,11 @@ static int lua_mutt_set(lua_State *l) rc = -1; } else + { rc = mutt_option_set(&opt, &err); + } break; + } case DT_MAGIC: if (mx_set_magic(lua_tostring(l, -1))) { @@ -186,8 +190,7 @@ static int lua_mutt_set(lua_State *l) break; } case DT_BOOL: - opt.var = (long) lua_toboolean(l, -1); - rc = mutt_option_set(&opt, &err); + *(bool *) opt.var = lua_toboolean(l, -1); break; default: luaL_error(l, "Unsupported NeoMutt parameter type %d for %s", opt.type, param); @@ -235,7 +238,7 @@ static int lua_mutt_get(lua_State *l) } return 1; case DT_QUAD: - lua_pushinteger(l, opt.var); + lua_pushinteger(l, *(unsigned char *) opt.var); return 1; case DT_REGEX: case DT_MAGIC: @@ -254,7 +257,7 @@ static int lua_mutt_get(lua_State *l) lua_pushinteger(l, (signed short) *((unsigned long *) opt.var)); return 1; case DT_BOOL: - lua_pushboolean(l, opt.var); + lua_pushboolean(l, *((bool *) opt.var)); return 1; default: luaL_error(l, "NeoMutt parameter type %d unknown for %s", opt.type, param);