1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Warn with error if regexp ignore fails to parse

This commit is contained in:
David Leadbeater 2014-06-29 21:57:38 +01:00
parent 2b6bba3fd2
commit 0086211236

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
}