summaryrefslogtreecommitdiff
path: root/src/core/ignore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ignore.c')
-rw-r--r--src/core/ignore.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c
index d4a92e3c..cec91e6b 100644
--- a/src/core/ignore.c
+++ b/src/core/ignore.c
@@ -24,6 +24,7 @@
#include "levels.h"
#include "lib-config/iconfig.h"
#include "settings.h"
+#include "iregex.h"
#include "masks.h"
#include "servers.h"
@@ -67,13 +68,8 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
return FALSE;
if (rec->regexp) {
-#ifdef USE_GREGEX
return rec->preg != NULL &&
- g_regex_match(rec->preg, text, 0, NULL);
-#else
- return rec->regexp_compiled &&
- regexec(&rec->preg, text, 0, NULL, 0) == 0;
-#endif
+ i_regex_match(rec->preg, text, 0, NULL);
}
return rec->fullword ?
@@ -327,41 +323,19 @@ static void ignore_remove_config(IGNORE_REC *rec)
static void ignore_init_rec(IGNORE_REC *rec)
{
-#ifdef USE_GREGEX
if (rec->preg != NULL)
- g_regex_unref(rec->preg);
+ i_regex_unref(rec->preg);
if (rec->regexp && rec->pattern != NULL) {
GError *re_error = NULL;
- rec->preg = g_regex_new(rec->pattern, G_REGEX_OPTIMIZE | G_REGEX_RAW | G_REGEX_CASELESS, 0, &re_error);
+ rec->preg = i_regex_new(rec->pattern, G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, &re_error);
if (rec->preg == NULL) {
g_warning("Failed to compile regexp '%s': %s", rec->pattern, re_error->message);
g_error_free(re_error);
}
}
-#else
- char *errbuf;
- int errcode, errbuf_len;
-
- if (rec->regexp_compiled) regfree(&rec->preg);
- 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
}
void ignore_add_rec(IGNORE_REC *rec)
@@ -381,11 +355,7 @@ static void ignore_destroy(IGNORE_REC *rec, int send_signal)
if (send_signal)
signal_emit("ignore destroyed", 1, rec);
-#ifdef USE_GREGEX
- if (rec->preg != NULL) g_regex_unref(rec->preg);
-#else
- if (rec->regexp_compiled) regfree(&rec->preg);
-#endif
+ if (rec->preg != NULL) i_regex_unref(rec->preg);
if (rec->channels != NULL) g_strfreev(rec->channels);
g_free_not_null(rec->mask);
g_free_not_null(rec->servertag);