projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
move smap/nospam into the mime module.
[apps/madmutt.git]
/
lib-lib
/
rx.c
diff --git
a/lib-lib/rx.c
b/lib-lib/rx.c
index
0edce59
..
79ec5b8
100644
(file)
--- a/
lib-lib/rx.c
+++ b/
lib-lib/rx.c
@@
-38,11
+38,26
@@
rx_t *rx_compile(const char *s, int flags)
return pp;
}
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;
void rx_set_template(rx_t *rx, const char *tpl)
{
const char *p = tpl;
- m_strreplace(&rx->t
emplate
, tpl);
+ m_strreplace(&rx->t
pl
, tpl);
rx->nmatch = 0;
while ((p = strchr(p, '%'))) {
rx->nmatch = 0;
while ((p = strchr(p, '%'))) {
@@
-58,13
+73,12
@@
void rx_set_template(rx_t *rx, const char *tpl)
rx->nmatch++; /* match 0 is always the whole expr */
}
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->tpl);
}
int rx_list_match(rx_t *l, const char *s)
}
int rx_list_match(rx_t *l, const char *s)
@@
-98,7
+112,7
@@
int rx_list_match2(rx_t *l, const char *s, char *dst, int dlen)
if (regexec(l->rx, s, l->nmatch, pmatch, 0) == 0) {
/* Copy template into dst, with substitutions. */
if (regexec(l->rx, s, l->nmatch, pmatch, 0) == 0) {
/* Copy template into dst, with substitutions. */
- const char *p = l->t
emplate
, *q;
+ const char *p = l->t
pl
, *q;
for (q = strchr(p, '%'); q; q = strchr(p + 1, '%')) {
int n;
for (q = strchr(p, '%'); q; q = strchr(p + 1, '%')) {
int n;