X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Frx.c;h=02a01d0acdac5b4dfd457a3eb1b0062ba8c8cd1f;hp=0edce593907000c360bea7f048adc1350d3fea7f;hb=6b771604433435b4280a5fbae2612134fe4129dd;hpb=1410cfc03a04ccce7aac48a62f9d465ab341cef1 diff --git a/lib-lib/rx.c b/lib-lib/rx.c index 0edce59..02a01d0 100644 --- a/lib-lib/rx.c +++ b/lib-lib/rx.c @@ -38,6 +38,21 @@ rx_t *rx_compile(const char *s, int flags) return pp; } +int rx_validate(const char *s, char *errbuf, ssize_t errlen) +{ + regex_t re; + int res; + + p_clear(&re, 1); + res = REGCOMP(&re, NONULL(s), 0); + if (res) { + regerror(res, &re, errbuf, errlen); + } + regfree(&re); + + return res; +} + void rx_set_template(rx_t *rx, const char *tpl) { const char *p = tpl; @@ -58,13 +73,12 @@ void rx_set_template(rx_t *rx, const char *tpl) rx->nmatch++; /* match 0 is always the whole expr */ } -void rx_delete(rx_t **p) +void rx_wipe(rx_t *rx) { - p_delete(&(*p)->pattern); - regfree((*p)->rx); - p_delete(&(*p)->rx); - p_delete(&(*p)->template); - p_delete(p); + p_delete(&rx->pattern); + regfree(rx->rx); + p_delete(&rx->rx); + p_delete(&rx->template); } int rx_list_match(rx_t *l, const char *s)