stylish updates.
authorPierre Habouzit <madcoder@debian.org>
Sun, 11 Mar 2007 23:23:29 +0000 (00:23 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 11 Mar 2007 23:23:29 +0000 (00:23 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
init.c
lib-lua/lib-lua.h
lib-lua/lib-lua_priv.h
lib-lua/lua-token.sh
lib-lua/madmutt.c
lib-lua/runtime.c

diff --git a/init.c b/init.c
index f99452a..e153736 100644 (file)
--- a/init.c
+++ b/init.c
@@ -496,7 +496,7 @@ int quadoption (int opt)
 
 int query_quadoption2(int opt, const char *prompt)
 {
 
 int query_quadoption2(int opt, const char *prompt)
 {
-  int v = mlua_reggetq(opt);
+  int v = mlua_reggeti(opt);
 
   switch (v) {
   case M_YES:
 
   switch (v) {
   case M_YES:
index efad96c..4ce8906 100644 (file)
@@ -41,9 +41,9 @@ int mlua_dofile(const char *filename);
 int mlua_wrap(void (*errfun)(const char *fmt, ...), int status);
 
 const char *mlua_reggets(enum lua_token tk);
 int mlua_wrap(void (*errfun)(const char *fmt, ...), int status);
 
 const char *mlua_reggets(enum lua_token tk);
-quadopt_t mlua_reggetq(enum lua_token tk);
+int mlua_reggeti(enum lua_token tk);
 
 void mlua_regsets(enum lua_token tk, const char *s);
 
 void mlua_regsets(enum lua_token tk, const char *s);
-void mlua_regsetq(enum lua_token tk, quadopt_t q);
+void mlua_regseti(enum lua_token tk, int i);
 
 #endif
 
 #endif
index 5f69d81..84fd121 100644 (file)
@@ -29,8 +29,6 @@
 typedef enum reg_type {
     REG_NIL,
     REG_INT,
 typedef enum reg_type {
     REG_NIL,
     REG_INT,
-    REG_BOOL,
-    REG_QUAD,
     REG_STR,
 } reg_type;
 
     REG_STR,
 } reg_type;
 
index 8dc5a83..b715c37 100644 (file)
@@ -109,4 +109,3 @@ exit 0
 ## quit
 ## sendmail
 ## shell
 ## quit
 ## sendmail
 ## shell
-## tmpdir
index 29907f3..6fe2b4d 100644 (file)
@@ -81,9 +81,6 @@ static int madmutt_assign(lua_State *L)
         char buf[STRING];
         int i;
 
         char buf[STRING];
         int i;
 
-      default:
-        return luaL_error(L, "read-only or inexistant property '%s'", idx, tk);
-
       case LTK_DOTLOCK:
       case LTK_SENDMAIL:
       case LTK_SHELL:
       case LTK_DOTLOCK:
       case LTK_SENDMAIL:
       case LTK_SHELL:
@@ -99,30 +96,56 @@ static int madmutt_assign(lua_State *L)
         i = quadopt_parse(val);
         if (i < 0)
             return luaL_error(L, "invalid quad option value: '%s'", val);
         i = quadopt_parse(val);
         if (i < 0)
             return luaL_error(L, "invalid quad option value: '%s'", val);
-        mlua_regsetq(tk, i);
+        mlua_regseti(tk, i);
         return 0;
         return 0;
+
+      case LTK_UNKNOWN:
+      case LTK_count:
+        break;
     }
     }
+
+    return luaL_error(L, "read-only or inexistant property '%s'", idx, tk);
 }
 
 static int madmutt_get(lua_State *L)
 {
     const char *idx = luaL_checkstring(L, 2);
 }
 
 static int madmutt_get(lua_State *L)
 {
     const char *idx = luaL_checkstring(L, 2);
-    int tk;
-
-    switch ((tk = lua_which_token(idx, -1))) {
-      default:
-        lua_getmetatable(L, 1);
-        lua_replace(L, 1);
-        lua_rawget(L, 1);
-        return 1;
+    enum lua_token tk = lua_which_token(idx, -1);
 
 
+    switch (tk) {
       case LTK_DOTLOCK:
       case LTK_SENDMAIL:
       case LTK_SHELL:
       case LTK_DOTLOCK:
       case LTK_SENDMAIL:
       case LTK_SHELL:
+      case LTK_EDITOR:
         lua_pushstring(L, mlua_reggets(tk));
         lua_pushstring(L, mlua_reggets(tk));
+        return 1;
+
+      case LTK_QUIT:
+        switch (mlua_reggeti(tk)) {
+          case M_YES:
+            lua_pushstring(L, "yes");
+            return 1;
+          case M_NO:
+            lua_pushstring(L, "no");
+            return 1;
+          case M_ASKNO:
+            lua_pushstring(L, "ask-no");
+            return 1;
+          case M_ASKYES:
+            lua_pushstring(L, "ask-yes");
+            return 1;
+          default:
+            return 0;
+        }
+
+      case LTK_UNKNOWN:
+      case LTK_count:
         break;
     }
 
         break;
     }
 
+    lua_getmetatable(L, 1);
+    lua_replace(L, 1);
+    lua_rawget(L, 1);
     return 1;
 }
 
     return 1;
 }
 
@@ -248,7 +271,7 @@ static const struct {
      ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
      ** Madmutt.
      */
      ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
      ** Madmutt.
      */
-    {"editor",       madmutt_init_editor, NULL },
+    { "editor",       madmutt_init_editor, NULL },
     /*
      ** .pp
      ** This variable specifies which editor is used by Madmutt.
     /*
      ** .pp
      ** This variable specifies which editor is used by Madmutt.
@@ -268,7 +291,7 @@ static const struct {
      ** Command to use when spawning a subshell.  By default, the user's login
      ** shell from \fT/etc/passwd\fP is used.
      */
      ** Command to use when spawning a subshell.  By default, the user's login
      ** shell from \fT/etc/passwd\fP is used.
      */
-    {"quit",         NULL, "yes" }
+    { "quit",         NULL, "yes" },
     /*
      ** .pp
      ** This variable controls whether ``quit'' and ``exit'' actually quit
     /*
      ** .pp
      ** This variable controls whether ``quit'' and ``exit'' actually quit
index 7a351ee..0fb777c 100644 (file)
@@ -74,9 +74,9 @@ const char *mlua_reggets(int tk)
     return registry[tk].s;
 }
 
     return registry[tk].s;
 }
 
-quadopt_t mlua_reggetq(int tk)
+int mlua_reggeti(int tk)
 {
 {
-    if (registry[tk].type != REG_QUAD)
+    if (registry[tk].type != REG_INT)
         return -1;
     return registry[tk].i;
 }
         return -1;
     return registry[tk].i;
 }
@@ -88,9 +88,9 @@ void mlua_regsets(int tk, const char *s)
     registry[tk].s    = m_strdup(s);
 }
 
     registry[tk].s    = m_strdup(s);
 }
 
-void mlua_regsetq(int tk, quadopt_t q)
+void mlua_regseti(int tk, int i)
 {
     reg_entry_wipe(registry + tk);
 {
     reg_entry_wipe(registry + tk);
-    registry[tk].type = REG_QUAD;
-    registry[tk].i    = q;
+    registry[tk].type = REG_INT;
+    registry[tk].i    = i;
 }
 }