Rename all structs and functions to uniformly use the prefix 'regex'.
return true;
}
- if (mutt_match_rx_list(addr->mailbox, Alternates))
+ if (mutt_match_regex_list(addr->mailbox, Alternates))
{
mutt_debug(5, "mutt_addr_is_user: yes, %s matched by alternates.\n", addr->mailbox);
- if (mutt_match_rx_list(addr->mailbox, UnAlternates))
+ if (mutt_match_regex_list(addr->mailbox, UnAlternates))
mutt_debug(5, "mutt_addr_is_user: but, %s matched by unalternates.\n", addr->mailbox);
else
return true;
continue;
if (prefix && *prefix && (strncmp(prefix, nntp_data->group, strlen(prefix)) != 0))
continue;
- if (!((regexec(Mask.rx, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not))
+ if (!((regexec(Mask.regex, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not))
continue;
add_folder(menu, state, nntp_data->group, NULL, NULL, NULL, nntp_data);
}
if (prefix && *prefix && (mutt_strncmp(prefix, de->d_name, mutt_strlen(prefix)) != 0))
continue;
- if (!((regexec(Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
+ if (!((regexec(Mask.regex, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
continue;
mutt_concat_path(buffer, d, de->d_name, sizeof(buffer));
else
{
mutt_str_replace(&Mask.pattern, buf);
- regfree(Mask.rx);
- FREE(&Mask.rx);
- Mask.rx = rx;
+ regfree(Mask.regex);
+ FREE(&Mask.regex);
+ Mask.regex = rx;
Mask.not = not;
destroy_state(&state);
* type for regular expressions.
*/
- regfree(&tmp->rx);
+ regfree(&tmp->regex);
mutt_pattern_free(&tmp->color_pattern);
FREE(&tmp->pattern);
FREE(l);
for (int i = 0; Context && i < Context->msgcount; i++)
Context->hdrs[i]->pair = 0;
}
- else if ((r = REGCOMP(&tmp->rx, s, (sensitive ? mutt_which_case(s) : REG_ICASE))) != 0)
+ else if ((r = REGCOMP(&tmp->regex, s, (sensitive ? mutt_which_case(s) : REG_ICASE))) != 0)
{
- regerror(r, &tmp->rx, err->data, err->dsize);
+ regerror(r, &tmp->regex, err->data, err->dsize);
free_color_line(&tmp, 1);
return -1;
}
{
regmatch_t pmatch[cl->match + 1];
- if (regexec(&cl->rx, buf + offset, cl->match + 1, pmatch, 0) != 0)
+ if (regexec(&cl->regex, buf + offset, cl->match + 1, pmatch, 0) != 0)
continue; /* regex doesn't match the status bar */
int first = pmatch[cl->match].rm_so + offset;
WHERE struct ListHead MimeLookupList INITVAL(STAILQ_HEAD_INITIALIZER(MimeLookupList));
WHERE struct ListHead UnIgnore INITVAL(STAILQ_HEAD_INITIALIZER(UnIgnore));
-WHERE struct RxList *Alternates;
-WHERE struct RxList *UnAlternates;
-WHERE struct RxList *MailLists;
-WHERE struct RxList *UnMailLists;
-WHERE struct RxList *SubscribedLists;
-WHERE struct RxList *UnSubscribedLists;
+WHERE struct RegexList *Alternates;
+WHERE struct RegexList *UnAlternates;
+WHERE struct RegexList *MailLists;
+WHERE struct RegexList *UnMailLists;
+WHERE struct RegexList *SubscribedLists;
+WHERE struct RegexList *UnSubscribedLists;
WHERE struct ReplaceList *SpamList;
-WHERE struct RxList *NoSpamList;
-WHERE struct ReplaceList *SubjectRxList;
+WHERE struct RegexList *NoSpamList;
+WHERE struct ReplaceList *SubjectRegexList;
/* bit vector for the yes/no/ask variable type */
#ifdef MAIN_C
return;
hash_delete(Groups, g->name, g, NULL);
rfc822_free_address(&g->as);
- mutt_free_rx_list(&g->rs);
+ mutt_free_regex_list(&g->rs);
FREE(&g->name);
FREE(&g);
}
return 0;
}
-static int group_add_rx(struct Group *g, const char *s, int flags, struct Buffer *err)
+static int group_add_regex(struct Group *g, const char *s, int flags, struct Buffer *err)
{
- return mutt_add_to_rx_list(&g->rs, s, flags, err);
+ return mutt_add_to_regex_list(&g->rs, s, flags, err);
}
-static int group_remove_rx(struct Group *g, const char *s)
+static int group_remove_regex(struct Group *g, const char *s)
{
- return mutt_remove_from_rx_list(&g->rs, s);
+ return mutt_remove_from_regex_list(&g->rs, s);
}
void mutt_group_context_add_adrlist(struct GroupContext *ctx, struct Address *a)
return rv;
}
-int mutt_group_context_add_rx(struct GroupContext *ctx, const char *s,
+int mutt_group_context_add_regex(struct GroupContext *ctx, const char *s,
int flags, struct Buffer *err)
{
int rv = 0;
for (; (!rv) && ctx; ctx = ctx->next)
- rv = group_add_rx(ctx->g, s, flags, err);
+ rv = group_add_regex(ctx->g, s, flags, err);
return rv;
}
-int mutt_group_context_remove_rx(struct GroupContext *ctx, const char *s)
+int mutt_group_context_remove_regex(struct GroupContext *ctx, const char *s)
{
int rv = 0;
for (; (!rv) && ctx; ctx = ctx->next)
{
- rv = group_remove_rx(ctx->g, s);
+ rv = group_remove_regex(ctx->g, s);
if (empty_group(ctx->g))
group_remove(ctx->g);
}
if (s && g)
{
- if (mutt_match_rx_list(s, g->rs))
+ if (mutt_match_regex_list(s, g->rs))
return true;
for (ap = g->as; ap; ap = ap->next)
if (ap->mailbox && (mutt_strcasecmp(s, ap->mailbox) == 0))
struct Group
{
struct Address *as;
- struct RxList *rs;
+ struct RegexList *rs;
char *name;
};
void mutt_group_context_add(struct GroupContext **ctx, struct Group *group);
void mutt_group_context_destroy(struct GroupContext **ctx);
void mutt_group_context_add_adrlist(struct GroupContext *ctx, struct Address *a);
-int mutt_group_context_add_rx(struct GroupContext *ctx, const char *s, int flags, struct Buffer *err);
+int mutt_group_context_add_regex(struct GroupContext *ctx, const char *s, int flags, struct Buffer *err);
bool mutt_group_match(struct Group *g, const char *s);
int mutt_group_context_clear(struct GroupContext **ctx);
-int mutt_group_context_remove_rx(struct GroupContext *ctx, const char *s);
+int mutt_group_context_remove_regex(struct GroupContext *ctx, const char *s);
int mutt_group_context_remove_adrlist(struct GroupContext *ctx, struct Address *a);
struct Group *mutt_pattern_group(const char *k);
} digest;
struct Md5Ctx ctx;
struct ReplaceList *spam = NULL;
- struct RxList *nospam = NULL;
+ struct RegexList *nospam = NULL;
hcachever = HCACHEVER;
/* Mix in user's spam list */
for (spam = SpamList; spam; spam = spam->next)
{
- md5_process_bytes(spam->rx->pattern, strlen(spam->rx->pattern), &ctx);
+ md5_process_bytes(spam->regex->pattern, strlen(spam->regex->pattern), &ctx);
md5_process_bytes(spam->template, strlen(spam->template), &ctx);
}
/* Mix in user's nospam list */
for (nospam = NoSpamList; nospam; nospam = nospam->next)
{
- md5_process_bytes(nospam->rx->pattern, strlen(nospam->rx->pattern), &ctx);
+ md5_process_bytes(nospam->regex->pattern, strlen(nospam->regex->pattern), &ctx);
}
/* Get a hash and take its bytes as an (unsigned int) hash version */
bool mutt_is_mail_list(struct Address *addr)
{
- if (!mutt_match_rx_list(addr->mailbox, UnMailLists))
- return mutt_match_rx_list(addr->mailbox, MailLists);
+ if (!mutt_match_regex_list(addr->mailbox, UnMailLists))
+ return mutt_match_regex_list(addr->mailbox, MailLists);
return false;
}
bool mutt_is_subscribed_list(struct Address *addr)
{
- if (!mutt_match_rx_list(addr->mailbox, UnMailLists) &&
- !mutt_match_rx_list(addr->mailbox, UnSubscribedLists))
- return mutt_match_rx_list(addr->mailbox, SubscribedLists);
+ if (!mutt_match_regex_list(addr->mailbox, UnMailLists) &&
+ !mutt_match_regex_list(addr->mailbox, UnSubscribedLists))
+ return mutt_match_regex_list(addr->mailbox, SubscribedLists);
return false;
}
if (!env)
return NULL;
- if (!SubjectRxList)
+ if (!SubjectRegexList)
return env->subject;
if (env->subject == NULL || *env->subject == '\0')
return env->disp_subj = NULL;
- env->disp_subj = mutt_apply_replace(NULL, 0, env->subject, SubjectRxList);
+ env->disp_subj = mutt_apply_replace(NULL, 0, env->subject, SubjectRegexList);
return env->disp_subj;
}
char *subj = NULL;
if (hdr->env->disp_subj)
subj = hdr->env->disp_subj;
- else if (SubjectRxList)
+ else if (SubjectRegexList)
subj = apply_subject_mods(hdr->env);
else
subj = hdr->env->subject;
struct Hook
{
int type; /**< hook type */
- struct Regex rx; /**< regular expression */
+ struct Regex regex; /**< regular expression */
char *command; /**< filename, command or pattern to execute */
struct Pattern *pattern; /**< used for fcc,save,send-hook */
TAILQ_ENTRY(Hook) entries;
}
}
else if (ptr->type == data &&
- ptr->rx.not == not&&(mutt_strcmp(pattern.data, ptr->rx.pattern) == 0))
+ ptr->regex.not == not&&(mutt_strcmp(pattern.data, ptr->regex.pattern) == 0))
{
if (data & (MUTT_FOLDERHOOK | MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_MESSAGEHOOK |
MUTT_ACCOUNTHOOK | MUTT_REPLYHOOK | MUTT_CRYPTHOOK |
ptr->type = data;
ptr->command = command.data;
ptr->pattern = pat;
- ptr->rx.pattern = pattern.data;
- ptr->rx.rx = rx;
- ptr->rx.not = not;
+ ptr->regex.pattern = pattern.data;
+ ptr->regex.regex = rx;
+ ptr->regex.not = not;
TAILQ_INSERT_TAIL(&Hooks, ptr, entries);
return 0;
static void delete_hook(struct Hook *h)
{
FREE(&h->command);
- FREE(&h->rx.pattern);
- if (h->rx.rx)
+ FREE(&h->regex.pattern);
+ if (h->regex.regex)
{
- regfree(h->rx.rx);
+ regfree(h->regex.regex);
}
mutt_pattern_free(&h->pattern);
FREE(&h);
if (tmp->type & MUTT_FOLDERHOOK)
{
- if ((regexec(tmp->rx.rx, path, 0, NULL, 0) == 0) ^ tmp->rx.not)
+ if ((regexec(tmp->regex.regex, path, 0, NULL, 0) == 0) ^ tmp->regex.not)
{
if (mutt_parse_rc_line(tmp->command, &token, &err) == -1)
{
{
if (tmp->type & type)
{
- if (regexec(tmp->rx.rx, pat, 0, NULL, 0) == 0)
+ if (regexec(tmp->regex.regex, pat, 0, NULL, 0) == 0)
return tmp->command;
}
}
continue;
if (hook->type & type)
- if ((mutt_pattern_exec(hook->pattern, 0, ctx, hdr, &cache) > 0) ^ hook->rx.not)
+ if ((mutt_pattern_exec(hook->pattern, 0, ctx, hdr, &cache) > 0) ^ hook->regex.not)
{
if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
{
continue;
if (hook->type & type)
- if ((mutt_pattern_exec(hook->pattern, 0, ctx, hdr, &cache) > 0) ^ hook->rx.not)
+ if ((mutt_pattern_exec(hook->pattern, 0, ctx, hdr, &cache) > 0) ^ hook->regex.not)
{
mutt_make_string(path, pathlen, hook->command, ctx, hdr);
return 0;
TAILQ_FOREACH(tmp, &Hooks, entries)
{
if ((tmp->type & hook) &&
- ((match && regexec(tmp->rx.rx, match, 0, NULL, 0) == 0) ^ tmp->rx.not))
+ ((match && regexec(tmp->regex.regex, match, 0, NULL, 0) == 0) ^ tmp->regex.not))
return tmp->command;
}
return NULL;
TAILQ_FOREACH(tmp, &Hooks, entries)
{
if ((tmp->type & hook) &&
- ((match && regexec(tmp->rx.rx, match, 0, NULL, 0) == 0) ^ tmp->rx.not))
+ ((match && regexec(tmp->regex.regex, match, 0, NULL, 0) == 0) ^ tmp->regex.not))
mutt_list_insert_tail(matches, safe_strdup(tmp->command));
}
}
if (!(hook->command && (hook->type & MUTT_ACCOUNTHOOK)))
continue;
- if ((regexec(hook->rx.rx, url, 0, NULL, 0) == 0) ^ hook->rx.not)
+ if ((regexec(hook->regex.regex, url, 0, NULL, 0) == 0) ^ hook->regex.not)
{
inhook = true;
/* apply filemask filter. This should really be done at menu setup rather
* than at scan, since it's so expensive to scan. But that's big changes
* to browser.c */
- if (!((regexec(Mask.rx, relpath, 0, NULL, 0) == 0) ^ Mask.not))
+ if (!((regexec(Mask.regex, relpath, 0, NULL, 0) == 0) ^ Mask.not))
{
FREE(&mx.mbox);
return;
if (ptr->pattern)
{
FREE(&ptr->pattern);
- regfree((regex_t *) ptr->rx);
- FREE(&ptr->rx);
+ regfree((regex_t *) ptr->regex);
+ FREE(&ptr->regex);
}
ptr->pattern = safe_strdup(tmp->data);
- ptr->rx = rx;
+ ptr->regex = rx;
ptr->not = not;
return 1;
if (CUR_ENV && CUR_ENV->subject)
{
CUR_ENV->real_subj =
- (regexec(ReplyRegexp.rx, CUR_ENV->subject, 1, pmatch, 0)) ?
+ (regexec(ReplyRegexp.regex, CUR_ENV->subject, 1, pmatch, 0)) ?
CUR_ENV->subject :
CUR_ENV->subject + pmatch[0].rm_eo;
}
case DT_REGEX:
pp = (struct Regex *) p->data;
FREE(&pp->pattern);
- if (pp->rx)
+ if (pp->regex)
{
- regfree(pp->rx);
- FREE(&pp->rx);
+ regfree(pp->regex);
+ FREE(&pp->regex);
}
break;
case DT_PATH:
for (int i = 0; MuttVars[i].option; i++)
free_opt(MuttVars + i);
- mutt_free_rx_list(&Alternates);
- mutt_free_rx_list(&UnAlternates);
- mutt_free_rx_list(&MailLists);
- mutt_free_rx_list(&UnMailLists);
- mutt_free_rx_list(&SubscribedLists);
- mutt_free_rx_list(&UnSubscribedLists);
- mutt_free_rx_list(&NoSpamList);
+ mutt_free_regex_list(&Alternates);
+ mutt_free_regex_list(&UnAlternates);
+ mutt_free_regex_list(&MailLists);
+ mutt_free_regex_list(&UnMailLists);
+ mutt_free_regex_list(&SubscribedLists);
+ mutt_free_regex_list(&UnSubscribedLists);
+ mutt_free_regex_list(&NoSpamList);
}
static void add_to_stailq(struct ListHead *head, const char *str)
mutt_list_insert_tail(head, safe_strdup(str));
}
-static struct RxList *new_rx_list(void)
+static struct RegexList *new_regex_list(void)
{
- return safe_calloc(1, sizeof(struct RxList));
+ return safe_calloc(1, sizeof(struct RegexList));
}
-int mutt_add_to_rx_list(struct RxList **list, const char *s, int flags, struct Buffer *err)
+int mutt_add_to_regex_list(struct RegexList **list, const char *s, int flags, struct Buffer *err)
{
- struct RxList *t = NULL, *last = NULL;
+ struct RegexList *t = NULL, *last = NULL;
struct Regex *rx = NULL;
if (!s || !*s)
/* check to make sure the item is not already on this list */
for (last = *list; last; last = last->next)
{
- if (mutt_strcasecmp(rx->pattern, last->rx->pattern) == 0)
+ if (mutt_strcasecmp(rx->pattern, last->regex->pattern) == 0)
{
/* already on the list, so just ignore it */
last = NULL;
if (!*list || last)
{
- t = new_rx_list();
- t->rx = rx;
+ t = new_regex_list();
+ t->regex = rx;
if (last)
{
last->next = t;
cur = *list;
if (!cur)
return 0;
- if (cur->rx && (mutt_strcmp(cur->rx->pattern, pat) == 0))
+ if (cur->regex && (mutt_strcmp(cur->regex->pattern, pat) == 0))
{
*list = cur->next;
- mutt_free_regexp(&cur->rx);
+ mutt_free_regexp(&cur->regex);
FREE(&cur->template);
FREE(&cur);
return 1;
prev = cur;
for (cur = prev->next; cur;)
{
- if (mutt_strcmp(cur->rx->pattern, pat) == 0)
+ if (mutt_strcmp(cur->regex->pattern, pat) == 0)
{
prev->next = cur->next;
- mutt_free_regexp(&cur->rx);
+ mutt_free_regexp(&cur->regex);
FREE(&cur->template);
FREE(&cur);
cur = prev->next;
/* check to make sure the item is not already on this list */
for (last = *list; last; last = last->next)
{
- if (mutt_strcasecmp(rx->pattern, last->rx->pattern) == 0)
+ if (mutt_strcasecmp(rx->pattern, last->regex->pattern) == 0)
{
/* Already on the list. Formerly we just skipped this case, but
* now we're supporting removals, which means we're supporting
if (!t)
{
t = new_replace_list();
- t->rx = rx;
+ t->regex = rx;
rx = NULL;
if (last)
last->next = t;
p++;
}
- if (t->nmatch > t->rx->rx->re_nsub)
+ if (t->nmatch > t->regex->regex->re_nsub)
{
snprintf(err->data, err->dsize, "%s", _("Not enough subexpressions for "
"template"));
if (parse_group_context(&gc, buf, s, data, err) == -1)
goto bail;
- mutt_remove_from_rx_list(&UnAlternates, buf->data);
+ mutt_remove_from_regex_list(&UnAlternates, buf->data);
- if (mutt_add_to_rx_list(&Alternates, buf->data, REG_ICASE, err) != 0)
+ if (mutt_add_to_regex_list(&Alternates, buf->data, REG_ICASE, err) != 0)
goto bail;
- if (mutt_group_context_add_rx(gc, buf->data, REG_ICASE, err) != 0)
+ if (mutt_group_context_add_regex(gc, buf->data, REG_ICASE, err) != 0)
goto bail;
} while (MoreArgs(s));
do
{
mutt_extract_token(buf, s, 0);
- mutt_remove_from_rx_list(&Alternates, buf->data);
+ mutt_remove_from_regex_list(&Alternates, buf->data);
if ((mutt_strcmp(buf->data, "*") != 0) &&
- mutt_add_to_rx_list(&UnAlternates, buf->data, REG_ICASE, err) != 0)
+ mutt_add_to_regex_list(&UnAlternates, buf->data, REG_ICASE, err) != 0)
return -1;
} while (MoreArgs(s));
/* If not, try to remove from the nospam list. */
else
{
- mutt_remove_from_rx_list(&NoSpamList, buf->data);
+ mutt_remove_from_regex_list(&NoSpamList, buf->data);
}
return 0;
if (mutt_strcmp(buf->data, "*") == 0)
{
mutt_free_replace_list(&SpamList);
- mutt_free_rx_list(&NoSpamList);
+ mutt_free_regex_list(&NoSpamList);
return 0;
}
return 0;
/* Otherwise, add it to the nospam list. */
- if (mutt_add_to_rx_list(&NoSpamList, buf->data, REG_ICASE, err) != 0)
+ if (mutt_add_to_regex_list(&NoSpamList, buf->data, REG_ICASE, err) != 0)
return -1;
return 0;
if (parse_group_context(&gc, buf, s, data, err) == -1)
goto bail;
- mutt_remove_from_rx_list(&UnMailLists, buf->data);
+ mutt_remove_from_regex_list(&UnMailLists, buf->data);
- if (mutt_add_to_rx_list(&MailLists, buf->data, REG_ICASE, err) != 0)
+ if (mutt_add_to_regex_list(&MailLists, buf->data, REG_ICASE, err) != 0)
goto bail;
- if (mutt_group_context_add_rx(gc, buf->data, REG_ICASE, err) != 0)
+ if (mutt_group_context_add_regex(gc, buf->data, REG_ICASE, err) != 0)
goto bail;
} while (MoreArgs(s));
case GS_RX:
if (data == MUTT_GROUP &&
- mutt_group_context_add_rx(gc, buf->data, REG_ICASE, err) != 0)
+ mutt_group_context_add_regex(gc, buf->data, REG_ICASE, err) != 0)
goto bail;
- else if (data == MUTT_UNGROUP && mutt_group_context_remove_rx(gc, buf->data) < 0)
+ else if (data == MUTT_UNGROUP && mutt_group_context_remove_regex(gc, buf->data) < 0)
goto bail;
break;
tmpminor[len + 2] = '\0';
a->major_int = mutt_check_mime_type(a->major);
- ret = REGCOMP(&a->minor_rx, tmpminor, REG_ICASE);
+ ret = REGCOMP(&a->minor_regex, tmpminor, REG_ICASE);
FREE(&tmpminor);
if (ret)
{
- regerror(ret, &a->minor_rx, err->data, err->dsize);
+ regerror(ret, &a->minor_regex, err->data, err->dsize);
FREE(&a->major);
FREE(&a);
return -1;
{
mutt_debug(5, "parse_unattach_list: removed %s/%s [%d]\n", a->major,
a->minor, a->major_int);
- regfree(&a->minor_rx);
+ regfree(&a->minor_regex);
FREE(&a->major);
STAILQ_REMOVE(head, np, ListNode, entries);
FREE(&np->data);
do
{
mutt_extract_token(buf, s, 0);
- mutt_remove_from_rx_list(&SubscribedLists, buf->data);
- mutt_remove_from_rx_list(&MailLists, buf->data);
+ mutt_remove_from_regex_list(&SubscribedLists, buf->data);
+ mutt_remove_from_regex_list(&MailLists, buf->data);
if ((mutt_strcmp(buf->data, "*") != 0) &&
- mutt_add_to_rx_list(&UnMailLists, buf->data, REG_ICASE, err) != 0)
+ mutt_add_to_regex_list(&UnMailLists, buf->data, REG_ICASE, err) != 0)
return -1;
} while (MoreArgs(s));
if (parse_group_context(&gc, buf, s, data, err) == -1)
goto bail;
- mutt_remove_from_rx_list(&UnMailLists, buf->data);
- mutt_remove_from_rx_list(&UnSubscribedLists, buf->data);
+ mutt_remove_from_regex_list(&UnMailLists, buf->data);
+ mutt_remove_from_regex_list(&UnSubscribedLists, buf->data);
- if (mutt_add_to_rx_list(&MailLists, buf->data, REG_ICASE, err) != 0)
+ if (mutt_add_to_regex_list(&MailLists, buf->data, REG_ICASE, err) != 0)
goto bail;
- if (mutt_add_to_rx_list(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
+ if (mutt_add_to_regex_list(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
goto bail;
- if (mutt_group_context_add_rx(gc, buf->data, REG_ICASE, err) != 0)
+ if (mutt_group_context_add_regex(gc, buf->data, REG_ICASE, err) != 0)
goto bail;
} while (MoreArgs(s));
do
{
mutt_extract_token(buf, s, 0);
- mutt_remove_from_rx_list(&SubscribedLists, buf->data);
+ mutt_remove_from_regex_list(&SubscribedLists, buf->data);
if ((mutt_strcmp(buf->data, "*") != 0) &&
- mutt_add_to_rx_list(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
+ mutt_add_to_regex_list(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
return -1;
} while (MoreArgs(s));
int flags = 0;
FREE(&pp->pattern);
- if (pp->rx)
+ if (pp->regex)
{
- regfree(pp->rx);
- FREE(&pp->rx);
+ regfree(pp->regex);
+ FREE(&pp->regex);
}
if (p->init)
int retval;
char *s = (char *) p->init;
- pp->rx = safe_calloc(1, sizeof(regex_t));
+ pp->regex = safe_calloc(1, sizeof(regex_t));
pp->pattern = safe_strdup((char *) p->init);
if (mutt_strcmp(p->option, "mask") != 0)
flags |= mutt_which_case((const char *) p->init);
s++;
pp->not = 1;
}
- retval = REGCOMP(pp->rx, s, flags);
+ retval = REGCOMP(pp->regex, s, flags);
if (retval != 0)
{
char msgbuf[STRING];
- regerror(retval, pp->rx, msgbuf, sizeof(msgbuf));
+ regerror(retval, pp->regex, msgbuf, sizeof(msgbuf));
fprintf(stderr, _("restore_default(%s): error in regexp: %s\n"),
p->option, pp->pattern);
fprintf(stderr, "%s\n", msgbuf);
mutt_sleep(0);
FREE(&pp->pattern);
- FREE(&pp->rx);
+ FREE(&pp->regex);
}
}
}
if (CUR_ENV && CUR_ENV->subject)
{
CUR_ENV->real_subj =
- (regexec(ReplyRegexp.rx, CUR_ENV->subject, 1, pmatch, 0)) ?
+ (regexec(ReplyRegexp.regex, CUR_ENV->subject, 1, pmatch, 0)) ?
CUR_ENV->subject :
CUR_ENV->subject + pmatch[0].rm_eo;
}
{ "source", parse_source, 0 },
{ "spam", parse_spam_list, MUTT_SPAM },
{ "startup-hook", mutt_parse_hook, MUTT_STARTUPHOOK | MUTT_GLOBALHOOK },
- { "subjectrx", parse_subjectrx_list, UL &SubjectRxList },
+ { "subjectrx", parse_subjectrx_list, UL &SubjectRegexList },
{ "subscribe", parse_subscribe, 0 },
#ifdef USE_NOTMUCH
{ "tag-formats", parse_tag_formats, 0 },
#ifdef USE_SIDEBAR
{ "unsidebar_whitelist", parse_path_unlist, UL &SidebarWhitelist },
#endif
- { "unsubjectrx", parse_unsubjectrx_list, UL &SubjectRxList },
+ { "unsubjectrx", parse_unsubjectrx_list, UL &SubjectRegexList },
{ "unsubscribe", parse_unsubscribe, 0 },
#ifdef USE_NOTMUCH
{ "unvirtual-mailboxes", mutt_parse_unmailboxes, MUTT_VIRTUAL },
* | mutt_quote_filename() | Quote a filename to survive the shell's quoting rules
* | mutt_read_line() | Read a line from a file
* | mutt_rmtree() | Recursively remove a directory
- * | mutt_rx_sanitize_string() | Escape any regex-magic characters in a string
+ * | mutt_regex_sanitize_string() | Escape any regex-magic characters in a string
* | mutt_sanitize_filename() | Replace unsafe characters in a filename
* | mutt_set_mtime() | Set the modification time of one file from another
* | mutt_touch_atime() | Set the access time to current time
}
/**
- * mutt_rx_sanitize_string - Escape any regex-magic characters in a string
+ * mutt_regex_sanitize_string - Escape any regex-magic characters in a string
* @param dest Buffer for result
* @param destlen Length of buffer
* @param src String to transform
* @retval 0 Success
* @retval -1 Error
*/
-int mutt_rx_sanitize_string(char *dest, size_t destlen, const char *src)
+int mutt_regex_sanitize_string(char *dest, size_t destlen, const char *src)
{
while (*src && (--destlen > 2))
{
size_t mutt_quote_filename(char *d, size_t l, const char *f);
char * mutt_read_line(char *s, size_t *size, FILE *fp, int *line, int flags);
int mutt_rmtree(const char *path);
-int mutt_rx_sanitize_string(char *dest, size_t destlen, const char *src);
+int mutt_regex_sanitize_string(char *dest, size_t destlen, const char *src);
void mutt_sanitize_filename(char *f, short slash);
void mutt_set_mtime(const char *from, const char *to);
void mutt_touch_atime(int f);
#include <stdio.h>
struct ReplaceList;
-struct RxList;
+struct RegexList;
struct State;
struct ListHead;
struct Mapping;
#define MUTT_X_MOZILLA_KEYS (1 << 2) /**< tbird */
#define MUTT_KEYWORDS (1 << 3) /**< rfc2822 */
-void mutt_free_rx_list(struct RxList **list);
+void mutt_free_regex_list(struct RegexList **list);
void mutt_free_replace_list(struct ReplaceList **list);
int mutt_matches_ignore(const char *s);
/* add an element to a list */
-int mutt_remove_from_rx_list(struct RxList **l, const char *str);
+int mutt_remove_from_regex_list(struct RegexList **l, const char *str);
void mutt_init(int skip_sys_rc, struct ListHead *commands);
char *major;
int major_int;
char *minor;
- regex_t minor_rx;
+ regex_t minor_regex;
};
#define MUTT_PARTS_TOPLEVEL (1 << 0) /* is the top-level part */
*/
struct ColorLine
{
- regex_t rx;
+ regex_t regex;
int match; /**< which substringmap 0 for old behaviour */
char *pattern;
struct Pattern *color_pattern; /**< compiled pattern to speed up index color
*/
struct Regex
{
- char *pattern; /**< printable version */
- regex_t *rx; /**< compiled expression */
- int not; /**< do not match */
+ char *pattern; /**< printable version */
+ regex_t *regex; /**< compiled expression */
+ int not; /**< do not match */
};
/**
- * struct RxList - List of regular expressions
+ * struct RegexList - List of regular expressions
*/
-struct RxList
+struct RegexList
{
- struct Regex *rx;
- struct RxList *next;
+ struct Regex *regex;
+ struct RegexList *next;
};
/**
*/
struct ReplaceList
{
- struct Regex *rx;
+ struct Regex *regex;
int nmatch;
char *template;
struct ReplaceList *next;
}
}
-int mutt_remove_from_rx_list(struct RxList **l, const char *str)
+int mutt_remove_from_regex_list(struct RegexList **l, const char *str)
{
- struct RxList *p = NULL, *last = NULL;
+ struct RegexList *p = NULL, *last = NULL;
int rv = -1;
if (mutt_strcmp("*", str) == 0)
{
- mutt_free_rx_list(l); /* ``unCMD *'' means delete all current entries */
+ mutt_free_regex_list(l); /* ``unCMD *'' means delete all current entries */
rv = 0;
}
else
last = NULL;
while (p)
{
- if (mutt_strcasecmp(str, p->rx->pattern) == 0)
+ if (mutt_strcasecmp(str, p->regex->pattern) == 0)
{
- mutt_free_regexp(&p->rx);
+ mutt_free_regexp(&p->regex);
if (last)
last->next = p->next;
else
return _mutt_expand_path(s, slen, 0);
}
-char *_mutt_expand_path(char *s, size_t slen, int rx)
+char *_mutt_expand_path(char *s, size_t slen, int regex)
{
char p[_POSIX_PATH_MAX] = "";
char q[_POSIX_PATH_MAX] = "";
}
}
- if (rx && *p && !recurse)
+ if (regex && *p && !recurse)
{
- mutt_rx_sanitize_string(q, sizeof(q), p);
+ mutt_regex_sanitize_string(q, sizeof(q), p);
snprintf(tmp, sizeof(tmp), "%s%s", q, tail);
}
else
memset(dest, 0, destlen);
- if (GecosMask.rx)
+ if (GecosMask.regex)
{
- if (regexec(GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0)
+ if (regexec(GecosMask.regex, pw->pw_gecos, 1, pat_match, 0) == 0)
strfcpy(dest, pw->pw_gecos + pat_match[0].rm_so,
MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen));
}
nmatch = l->nmatch;
}
- if (regexec(l->rx->rx, src, l->nmatch, pmatch, 0) == 0)
+ if (regexec(l->regex->regex, src, l->nmatch, pmatch, 0) == 0)
{
tlen = 0;
switcher ^= 1;
dst = twinbuf[switcher];
- mutt_debug(5, "mutt_apply_replace: %s matches %s\n", src, l->rx->pattern);
+ mutt_debug(5, "mutt_apply_replace: %s matches %s\n", src, l->regex->pattern);
/* Copy into other twinbuf with substitutions */
if (l->template)
{
struct Regex *pp = safe_calloc(1, sizeof(struct Regex));
pp->pattern = safe_strdup(s);
- pp->rx = safe_calloc(1, sizeof(regex_t));
- if (REGCOMP(pp->rx, NONULL(s), flags) != 0)
+ pp->regex = safe_calloc(1, sizeof(regex_t));
+ if (REGCOMP(pp->regex, NONULL(s), flags) != 0)
mutt_free_regexp(&pp);
return pp;
void mutt_free_regexp(struct Regex **pp)
{
FREE(&(*pp)->pattern);
- regfree((*pp)->rx);
- FREE(&(*pp)->rx);
+ regfree((*pp)->regex);
+ FREE(&(*pp)->regex);
FREE(pp);
}
-void mutt_free_rx_list(struct RxList **list)
+void mutt_free_regex_list(struct RegexList **list)
{
- struct RxList *p = NULL;
+ struct RegexList *p = NULL;
if (!list)
return;
{
p = *list;
*list = (*list)->next;
- mutt_free_regexp(&p->rx);
+ mutt_free_regexp(&p->regex);
FREE(&p);
}
}
{
p = *list;
*list = (*list)->next;
- mutt_free_regexp(&p->rx);
+ mutt_free_regexp(&p->regex);
FREE(&p->template);
FREE(&p);
}
}
-bool mutt_match_rx_list(const char *s, struct RxList *l)
+bool mutt_match_regex_list(const char *s, struct RegexList *l)
{
if (!s)
return false;
for (; l; l = l->next)
{
- if (regexec(l->rx->rx, s, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0)
+ if (regexec(l->regex->regex, s, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0)
{
- mutt_debug(5, "mutt_match_rx_list: %s matches %s\n", s, l->rx->pattern);
+ mutt_debug(5, "mutt_match_regex_list: %s matches %s\n", s, l->regex->pattern);
return true;
}
}
}
/* Does this pattern match? */
- if (regexec(l->rx->rx, s, (size_t) l->nmatch, (regmatch_t *) pmatch, (int) 0) == 0)
+ if (regexec(l->regex->regex, s, (size_t) l->nmatch, (regmatch_t *) pmatch, (int) 0) == 0)
{
- mutt_debug(5, "mutt_match_spam_list: %s matches %s\n", s, l->rx->pattern);
- mutt_debug(5, "mutt_match_spam_list: %d subs\n", (int) l->rx->rx->re_nsub);
+ mutt_debug(5, "mutt_match_spam_list: %s matches %s\n", s, l->regex->pattern);
+ mutt_debug(5, "mutt_match_spam_list: %d subs\n", (int) l->regex->regex->re_nsub);
/* Copy template into text, with substitutions. */
for (p = l->template; *p && tlen < textsize - 1;)
while ((line = mutt_read_line(line, &linelen, fpin, &lineno, 0)) != NULL)
{
- if (regexec(PgpGoodSign.rx, line, 0, NULL, 0) == 0)
+ if (regexec(PgpGoodSign.regex, line, 0, NULL, 0) == 0)
{
mutt_debug(2, "pgp_copy_checksig: \"%s\" matches regexp.\n", line);
rv = 0;
while ((line = mutt_read_line(line, &linelen, fpin, &lineno, 0)) != NULL)
{
- if (regexec(PgpDecryptionOkay.rx, line, 0, NULL, 0) == 0)
+ if (regexec(PgpDecryptionOkay.regex, line, 0, NULL, 0) == 0)
{
mutt_debug(2, "pgp_check_decryption_okay: \"%s\" matches regexp.\n", line);
rv = 0;
{
for (color_line = ColorHdrList; color_line; color_line = color_line->next)
{
- if (REGEXEC(color_line->rx, buf) == 0)
+ if (REGEXEC(color_line->regex, buf) == 0)
{
line_info[n].type = MT_COLOR_HEADER;
line_info[n].syntax[0].color = color_line->pair;
}
else if (check_sig(buf, line_info, n - 1) == 0)
line_info[n].type = MT_COLOR_SIGNATURE;
- else if (regexec((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
+ else if (regexec((regex_t *) QuoteRegexp.regex, buf, 1, pmatch, 0) == 0)
{
- if (regexec((regex_t *) Smileys.rx, buf, 1, smatch, 0) == 0)
+ if (regexec((regex_t *) Smileys.regex, buf, 1, smatch, 0) == 0)
{
if (smatch[0].rm_so > 0)
{
c = buf[smatch[0].rm_so];
buf[smatch[0].rm_so] = 0;
- if (regexec((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
+ if (regexec((regex_t *) QuoteRegexp.regex, buf, 1, pmatch, 0) == 0)
{
if (q_classify && line_info[n].quote == NULL)
line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so,
color_line = ColorBodyList;
while (color_line)
{
- if (regexec(&color_line->rx, buf + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0)
+ if (regexec(&color_line->regex, buf + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0)
{
if (pmatch[0].rm_eo != pmatch[0].rm_so)
{
null_rx = false;
for (color_line = ColorAttachList; color_line; color_line = color_line->next)
{
- if (regexec(&color_line->rx, buf + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0)
+ if (regexec(&color_line->regex, buf + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0)
{
if (pmatch[0].rm_eo != pmatch[0].rm_so)
{
(*last)--;
goto out;
}
- if (regexec((regex_t *) QuoteRegexp.rx, (char *) fmt, 1, pmatch, 0) != 0)
+ if (regexec((regex_t *) QuoteRegexp.regex, (char *) fmt, 1, pmatch, 0) != 0)
goto out;
(*line_info)[n].quote =
classify_quote(quote_list, (char *) fmt + pmatch[0].rm_so,
if (mutt_match_spam_list(line, SpamList, buf, sizeof(buf)))
{
- if (!mutt_match_rx_list(line, NoSpamList))
+ if (!mutt_match_regex_list(line, NoSpamList))
{
/* if spam tag already exists, figure out how to amend it */
if (e->spam && *buf)
rfc2047_decode(&e->subject);
- if (regexec(ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
+ if (regexec(ReplyRegexp.regex, e->subject, 1, pmatch, 0) == 0)
e->real_subj = e->subject + pmatch[0].rm_eo;
else
e->real_subj = e->subject;
dflt ? "[OK] " : "[EXCL] ", b->type,
b->subtype ? b->subtype : "*", a->major, a->minor, a->major_int);
if ((a->major_int == TYPEANY || a->major_int == b->type) &&
- (!b->subtype || !regexec(&a->minor_rx, b->subtype, 0, NULL, 0)))
+ (!b->subtype || !regexec(&a->minor_regex, b->subtype, 0, NULL, 0)))
{
mutt_debug(5, "yes\n");
return true;
}
else
{
- pat->p.rx = safe_malloc(sizeof(regex_t));
- r = REGCOMP(pat->p.rx, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case(buf.data));
+ pat->p.regex = safe_malloc(sizeof(regex_t));
+ r = REGCOMP(pat->p.regex, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case(buf.data));
if (r)
{
- regerror(r, pat->p.rx, errmsg, sizeof(errmsg));
+ regerror(r, pat->p.regex, errmsg, sizeof(errmsg));
mutt_buffer_printf(err, "'%s': %s", buf.data, errmsg);
FREE(&buf.data);
- FREE(&pat->p.rx);
+ FREE(&pat->p.regex);
return false;
}
FREE(&buf.data);
else if (pat->groupmatch)
return !mutt_group_match(pat->p.g, buf);
else
- return regexec(pat->p.rx, buf, 0, NULL, 0);
+ return regexec(pat->p.regex, buf, 0, NULL, 0);
}
static int msg_search(struct Context *ctx, struct Pattern *pat, int msgno)
FREE(&tmp->p.str);
else if (tmp->groupmatch)
tmp->p.g = NULL;
- else if (tmp->p.rx)
+ else if (tmp->p.regex)
{
- regfree(tmp->p.rx);
- FREE(&tmp->p.rx);
+ regfree(tmp->p.regex);
+ FREE(&tmp->p.regex);
}
if (tmp->child)
struct Pattern *next;
struct Pattern *child; /**< arguments to logical op */
union {
- regex_t *rx;
+ regex_t *regex;
struct Group *g;
char *str;
} p;
struct Parameter;
struct Regex;
struct ReplaceList;
-struct RxList;
+struct RegexList;
struct State;
struct ListHead;
char *mutt_charset_hook(const char *chs);
char *mutt_iconv_hook(const char *chs);
char *mutt_expand_path(char *s, size_t slen);
-char *_mutt_expand_path(char *s, size_t slen, int rx);
+char *_mutt_expand_path(char *s, size_t slen, int regex);
char *mutt_find_hook(int type, const char *pat);
char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw);
char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b);
void mutt_version(void);
void mutt_view_attachments(struct Header *hdr);
void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int display);
-int mutt_add_to_rx_list(struct RxList **list, const char *s, int flags, struct Buffer *err);
+int mutt_add_to_regex_list(struct RegexList **list, const char *s, int flags, struct Buffer *err);
bool mutt_addr_is_user(struct Address *addr);
int mutt_addwch(wchar_t wc);
int mutt_alias_complete(char *s, size_t buflen);
bool mutt_is_subscribed_list(struct Address *addr);
bool mutt_is_text_part(struct Body *b);
int mutt_lookup_mime_type(struct Body *att, const char *path);
-bool mutt_match_rx_list(const char *s, struct RxList *l);
+bool mutt_match_regex_list(const char *s, struct RegexList *l);
bool mutt_match_spam_list(const char *s, struct ReplaceList *l, char *text, int textsize);
int mutt_multi_choice(char *prompt, char *letters);
bool mutt_needs_mailcap(struct Body *m);
static int search_attach_keyword(char *filename)
{
/* Search for the regex in AttachKeyword within a file */
- if (!AttachKeyword.rx)
+ if (!AttachKeyword.regex)
return 0;
FILE *attf = safe_fopen(filename, "r");
while (!feof(attf))
{
fgets(inputline, LONG_STRING, attf);
- if (regexec(QuoteRegexp.rx, inputline, 0, NULL, 0) != 0 &&
- regexec(AttachKeyword.rx, inputline, 0, NULL, 0) == 0)
+ if (regexec(QuoteRegexp.regex, inputline, 0, NULL, 0) != 0 &&
+ regexec(AttachKeyword.regex, inputline, 0, NULL, 0) == 0)
{
found = 1;
break;