*/
struct Regex *mutt_regex_compile(const char *str, int flags)
{
+ if (!str || !*str)
+ return NULL;
struct Regex *rx = mutt_mem_calloc(1, sizeof(struct Regex));
rx->pattern = mutt_str_strdup(str);
rx->regex = mutt_mem_calloc(1, sizeof(regex_t));
*/
struct Regex *mutt_regex_new(const char *str, int flags, struct Buffer *err)
{
- if (!str)
+ if (!str || !*str)
return NULL;
int rflags = 0;
*/
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
{
- if (!str || !*str)
+ if (!rl || !str || !*str)
return 0;
struct Regex *rx = mutt_regex_compile(str, flags);
*/
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
{
- struct RegexListNode *np = NULL;
- if (!str)
+ if (!rl || !str)
return false;
+ struct RegexListNode *np = NULL;
STAILQ_FOREACH(np, rl, entries)
{
if (!np->regex || !np->regex->regex)
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat,
const char *templ, struct Buffer *err)
{
- if (!pat || !*pat || !templ)
+ if (!rl || !pat || !*pat || !templ)
return 0;
struct Regex *rx = mutt_regex_compile(pat, REG_ICASE);
if (!rx)
{
- mutt_buffer_printf(err, _("Bad regex: %s"), pat);
+ if (err)
+ mutt_buffer_printf(err, _("Bad regex: %s"), pat);
return -1;
}
if (np->nmatch > np->regex->regex->re_nsub)
{
- mutt_buffer_printf(err, "%s", _("Not enough subexpressions for template"));
+ if (err)
+ mutt_buffer_printf(err, "%s", _("Not enough subexpressions for template"));
mutt_replacelist_remove(rl, pat);
return -1;
}
if (buf && buflen)
buf[0] = '\0';
- if (!str || (*str == '\0') || (buf && !buflen))
+ if (!rl || !str || (*str == '\0') || (buf && !buflen))
return buf;
twinbuf[0][0] = '\0';