-int mutt_match_spam_list (const char *s, rx_t * l, char *text, int x)
-{
- static regmatch_t *pmatch = NULL;
- static int nmatch = 0;
- int i, n, tlen;
- char *p;
-
- if (!s)
- return 0;
-
- tlen = 0;
-
- for (; l; l = l->next) {
- /* If this pattern needs more matches, expand pmatch. */
- if (l->nmatch > nmatch) {
- p_realloc(&pmatch, l->nmatch);
- nmatch = l->nmatch;
- }
-
- /* Does this pattern match? */
- if (regexec(l->rx, s, l->nmatch, (regmatch_t *)pmatch, (int) 0) == 0) {
- /* Copy template into text, with substitutions. */
- for (p = l->template; *p;) {
- if (*p == '%') {
- n = atoi (++p); /* find pmatch index */
- while (isdigit ((unsigned char) *p))
- ++p; /* skip subst token */
- for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
- text[tlen++] = s[i];
- }
- else {
- text[tlen++] = *p++;
- }
- }
- text[tlen] = '\0';
- return 1;
- }
- }
-
- return 0;
-}
-