aboutsummaryrefslogtreecommitdiff
path: root/libsylph/filter.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-08-03 06:52:37 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-08-03 06:52:37 +0000
commit34165083a911ffb9bf2c6938e3466285d553cfd8 (patch)
tree84794a347e85611b44fab93d07adb95735303d58 /libsylph/filter.c
parent5e8ab5643ca4752d53f4363d21bbc2b7b6518aef (diff)
support Oniguruma for regex.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1113 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/filter.c')
-rw-r--r--libsylph/filter.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libsylph/filter.c b/libsylph/filter.c
index c0bc2aff..e33c3554 100644
--- a/libsylph/filter.c
+++ b/libsylph/filter.c
@@ -29,7 +29,9 @@
#include <strings.h>
#include <stdlib.h>
#include <sys/types.h>
-#if HAVE_REGEX_H
+#if USE_ONIGURUMA
+# include <onigposix.h>
+#elif HAVE_REGEX_H
# include <regex.h>
#endif
#include <time.h>
@@ -276,20 +278,21 @@ gint filter_action_exec(FilterRule *rule, MsgInfo *msginfo, const gchar *file,
static gboolean strmatch_regex(const gchar *haystack, const gchar *needle)
{
-#if HAVE_REGEX_H && HAVE_REGCOMP
+#if defined(USE_ONIGURUMA) || defined(HAVE_REGCOMP)
gint ret = 0;
regex_t preg;
- regmatch_t pmatch[1];
- ret = regcomp(&preg, needle, REG_EXTENDED|REG_ICASE);
- if (ret != 0) return FALSE;
+#if USE_ONIGURUMA
+ reg_set_encoding(REG_POSIX_ENCODING_UTF8);
+#endif
+ ret = regcomp(&preg, needle, REG_ICASE|REG_EXTENDED);
+ if (ret != 0)
+ return FALSE;
- ret = regexec(&preg, haystack, 1, pmatch, 0);
+ ret = regexec(&preg, haystack, 0, NULL, 0);
regfree(&preg);
- if (ret == REG_NOMATCH) return FALSE;
-
- if (pmatch[0].rm_so != -1)
+ if (ret == 0)
return TRUE;
else
#endif