From 0086211236ae5541ec3ddc55282eebab81f93680 Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Sun, 29 Jun 2014 21:57:38 +0100 Subject: Warn with error if regexp ignore fails to parse --- src/core/ignore.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src') 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 } -- cgit v1.2.3