diff options
author | Alexander Færøy <ahf@0x90.dk> | 2014-07-02 21:15:45 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@0x90.dk> | 2014-07-02 21:15:45 +0200 |
commit | f779e04a9d4357ce4bcfb31079053d8262fbfc2a (patch) | |
tree | a3f9d5619a13e26ca6eac958754b66e29dc16b53 /src | |
parent | b9ba58d25f1acdf0843b04a7c37f2e34de502854 (diff) | |
parent | 0086211236ae5541ec3ddc55282eebab81f93680 (diff) | |
download | irssi-f779e04a9d4357ce4bcfb31079053d8262fbfc2a.zip |
Merge pull request #72 from dgl/regexp-error
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 } |