diff options
author | David Leadbeater <dgl@dgl.cx> | 2014-06-29 21:57:38 +0100 |
---|---|---|
committer | David Leadbeater <dgl@dgl.cx> | 2014-06-30 00:23:42 +0100 |
commit | 0086211236ae5541ec3ddc55282eebab81f93680 (patch) | |
tree | 1b23bc91ff178285093d856400f9836c3fab15fe /src | |
parent | 2b6bba3fd2019158990f13d9e8913fd3bbb20b61 (diff) | |
download | irssi-0086211236ae5541ec3ddc55282eebab81f93680.zip |
Warn with error if regexp ignore fails to parse
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ignore.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c index a7aa106f..eda232c7 100644 --- a/src/core/ignore.c +++ b/src/core/ignore.c @@ -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 } |