1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Merge pull request #72 from dgl/regexp-error

Warn with error if regexp ignore fails to parse
This commit is contained in:
Alexander Færøy 2014-07-02 21:15:45 +02:00
commit f779e04a9d

View File

@ -293,10 +293,24 @@ static void ignore_remove_config(IGNORE_REC *rec)
static void ignore_init_rec(IGNORE_REC *rec)
{
#ifdef HAVE_REGEX_H
char *errbuf;
int errcode, errbuf_len;
if (rec->regexp_compiled) regfree(&rec->preg);
rec->regexp_compiled = !rec->regexp || rec->pattern == NULL ? FALSE :
regcomp(&rec->preg, rec->pattern,
REG_EXTENDED|REG_ICASE|REG_NOSUB) == 0;
rec->regexp_compiled = FALSE;
if (rec->regexp && rec->pattern != NULL) {
errcode = regcomp(&rec->preg, rec->pattern,
REG_EXTENDED|REG_ICASE|REG_NOSUB);
if (errcode != 0) {
errbuf_len = regerror(errcode, &rec->preg, 0, 0);
errbuf = g_malloc(errbuf_len);
regerror(errcode, &rec->preg, errbuf, errbuf_len);
g_warning("Failed to compile regexp '%s': %s", rec->pattern, errbuf);
g_free(errbuf);
} else {
rec->regexp_compiled = TRUE;
}
}
#endif
}