From: Pierre Habouzit Date: Mon, 26 Mar 2007 23:05:51 +0000 (+0200) Subject: make quadopts be consistently dealt with as strings. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=1681dff7a1b69b0dad31d515c466439548b71f94;p=apps%2Fmadmutt.git make quadopts be consistently dealt with as strings. Signed-off-by: Pierre Habouzit --- diff --git a/lib-lua/base.cpkg b/lib-lua/base.cpkg index f9b7304..221e2a0 100644 --- a/lib-lua/base.cpkg +++ b/lib-lua/base.cpkg @@ -7,7 +7,7 @@ @type quadopt_t { .ctype = unsigned : 2; .check = luaM_checkquadopt($L, $$); - .push = lua_pushinteger($L, $$); + .push = luaM_pushquadopt($L, $$); }; @type string_t { diff --git a/lib-lua/lib-lua.h b/lib-lua/lib-lua.h index 862b6b5..569e77e 100644 --- a/lib-lua/lib-lua.h +++ b/lib-lua/lib-lua.h @@ -47,6 +47,8 @@ int luaM_wrap(void (*errfun)(const char *fmt, ...) int status); quadopt_t luaM_checkquadopt(lua_State *L, int narg); +void luaM_pushquadopt(lua_State *Ls, int val); + const char *luaM_checkrx(lua_State *Ls, int narg); char *luaM_pathnew(const char *val); rx_t *luaM_rxnew(const char* val); diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index f7401e2..923222b 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -97,6 +97,17 @@ quadopt_t luaM_checkquadopt(lua_State *Ls, int narg) return i; } +void luaM_pushquadopt(lua_State *Ls, int val) +{ + switch (val) { + case M_YES: return lua_pushstring(Ls, "yes"); + case M_NO: return lua_pushstring(Ls, "no"); + case M_ASKYES: return lua_pushstring(Ls, "ask-yes"); + case M_ASKNO: return lua_pushstring(Ls, "ask-no"); + default: return lua_pushnil(Ls); + } +} + const char *luaM_checkrx(lua_State *Ls, int narg) { const char *s = luaL_checkstring(Ls, narg);