X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=ac724aff44e698b745f4a216e80fa6760e0a1992;hp=f570b559e646d7fd289645be27c6132727a0dcd3;hb=05e61a9707a6da5c0bca77aa7c3c019a918494de;hpb=6b771604433435b4280a5fbae2612134fe4129dd;ds=inline diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index f570b55..ac724af 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -20,7 +20,8 @@ #include #include -#include +#include "../alias.h" +#include "../mutt.h" static lua_State *L; @@ -83,3 +84,32 @@ quadopt_t luaM_checkquadopt(lua_State *Ls, int narg) return i; } +const char *luaM_checkrx(lua_State *Ls, int narg) +{ + const char *s = luaL_checkstring(Ls, narg); + char buf[STRING]; + + if (rx_validate(s, buf, ssizeof(buf))) { + s = lua_pushfstring(Ls, "invalid regexp: `%s'", buf); + luaL_argerror(Ls, narg, s); + return NULL; + } + + return s; +} + +char *luaM_pathnew(const char *val) +{ + char path[PATH_MAX]; + _mutt_expand_path(path, sizeof(path), val, 0); + return m_strdup(path); +} + +rx_t *luaM_rxnew(const char *val) +{ + if (m_strisempty(val)) + val = "."; + + return rx_compile(val, mutt_which_case(val)); +} +