X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Frx.c;h=58e943c22f75b7b13bc4885f0c1c533e5a37fa26;hp=d89d23468f5ed697e779ba30ee6edda329b5bfab;hb=2b9f5916b3aebd8d34903d420ce8160121171534;hpb=717c9f150ded0fed572d27f68db07f94a9fe70e8 diff --git a/lib-lib/rx.c b/lib-lib/rx.c index d89d234..58e943c 100644 --- a/lib-lib/rx.c +++ b/lib-lib/rx.c @@ -29,7 +29,8 @@ rx_t *rx_compile(const char *s, int flags) rx_t *pp = p_new(rx_t, 1); pp->pattern = m_strdup(s); - pp->rx = p_new(regex_t, 1); + pp->rx = p_new(regex_t, 1); + pp->flags = flags; if (REGCOMP(pp->rx, NONULL(s), flags) != 0) { rx_delete(&pp); @@ -38,6 +39,14 @@ rx_t *rx_compile(const char *s, int flags) return pp; } +rx_t *rx_dup(rx_t *r) +{ + rx_t *res = rx_compile(r->pattern, r->flags); + res->neg = r->neg; + rx_set_template(res, r->tpl); + return res; +} + int rx_validate(const char *s, char *errbuf, ssize_t errlen) { regex_t re; @@ -59,6 +68,8 @@ void rx_set_template(rx_t *rx, const char *tpl) m_strreplace(&rx->tpl, tpl); rx->nmatch = 0; + if (m_strisempty(rx->tpl)) + return; while ((p = strchr(p, '%'))) { if (isdigit(*++p)) {