]> granicus.if.org Git - neomutt/commitdiff
lua: fix variable getting/setting
authorRichard Russon <rich@flatcap.org>
Tue, 27 Mar 2018 02:40:07 +0000 (03:40 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 28 Mar 2018 02:18:07 +0000 (03:18 +0100)
contrib/lua/test_lua-api_spec.lua
main.c
mutt_lua.c

index 70619f5a76a46d2bd2c1ef81bc0ed6d76526dea5..dc8df5d68cb4d2701447a60e84dfce85ea6ce3c7 100644 (file)
@@ -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 c58df013500a334e83533aeade1e89f795d886d8..58e8fc51465d9f2feb61fb30fee3919bb9b38c50 100644 (file)
--- 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
index a54139b4380b4b6a04ac0967f1fa6217ac5a0395..7dd7027348e5b22d182009547f3e6f952cb2c413 100644 (file)
@@ -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);