aboutsummaryrefslogtreecommitdiff
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
parent5e8ab5643ca4752d53f4363d21bbc2b7b6518aef (diff)
support Oniguruma for regex.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1113 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.ja8
-rw-r--r--configure.in30
-rw-r--r--libsylph/filter.c21
-rw-r--r--src/about.c3
-rw-r--r--src/prefs_filter_edit.c2
6 files changed, 61 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 87a9a16e..bc3ff813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-03
+
+ * libsylph/filter.c
+ src/about.c
+ src/prefs_filter_edit.c
+ configure.in: Oniguruma can be used instead of system's regex API
+ (thanks to IWAMOTO Kouichi).
+
2006-08-02
* src/sumaryview.c:
diff --git a/ChangeLog.ja b/ChangeLog.ja
index c7c5b1a6..d95b7d0b 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,11 @@
+2006-08-03
+
+ * libsylph/filter.c
+ src/about.c
+ src/prefs_filter_edit.c
+ configure.in: システムの正規表現 API 以外に Oniguruma を使用できる
+ ようにした (岩本さん thanks).
+
2006-08-02
* src/sumaryview.c:
diff --git a/configure.in b/configure.in
index 83c565f6..b2318332 100644
--- a/configure.in
+++ b/configure.in
@@ -9,7 +9,7 @@ MINOR_VERSION=2
MICRO_VERSION=7
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=
+EXTRA_VERSION=+svn
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target
@@ -269,6 +269,33 @@ else
AC_MSG_RESULT(no)
fi
+dnl Check for Oniguruma support in message filtering
+AC_ARG_ENABLE(oniguruma,
+ [ --enable-oniguruma Use Oniguruma instead of system's regex [[default=no]]],
+ [ac_cv_enable_oniguruma=$enableval], [ac_cv_enable_oniguruma=no])
+AC_MSG_CHECKING([whether to use Oniguruma])
+if test "$ac_cv_enable_oniguruma" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_CHECK_HEADERS(oniguruma.h onigposix.h,
+ [ AC_DEFINE(USE_ONIGURUMA, 1, Define if you want to use Oniguruma.) ],
+ [ ac_cv_enable_oniguruma=no ])
+
+ if test "$ac_cv_enable_oniguruma" = yes; then
+ AC_CHECK_LIB(onig, onig_new,
+ [ ac_cv_enable_oniguruma=yes ],
+ [ ac_cv_enable_oniguruma=no ])
+ fi
+
+ AC_MSG_CHECKING([whether oniguruma is available])
+ AC_MSG_RESULT($ac_cv_enable_oniguruma)
+
+ if test "$ac_cv_enable_oniguruma" = yes; then
+ LIBS="$LIBS -lonig"
+ fi
+else
+ AC_MSG_RESULT(no)
+fi
+
AC_CHECK_LIB(xpg4, setlocale)
dnl for GThread support (currently disabled)
@@ -404,6 +431,7 @@ echo "iconv : $am_cv_func_iconv"
echo "compface : $ac_cv_enable_compface"
echo "IPv6 : $ac_cv_enable_ipv6"
echo "GtkSpell : $ac_cv_enable_gtkspell"
+echo "Oniguruma : $ac_cv_enable_oniguruma"
echo ""
echo "The binary will be installed in $prefix/bin"
echo ""
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
diff --git a/src/about.c b/src/about.c
index 2b780fa1..cecf5fbe 100644
--- a/src/about.c
+++ b/src/about.c
@@ -165,6 +165,9 @@ static void about_create(void)
#if USE_GTKSPELL
" GtkSpell"
#endif
+#if USE_ONIGURUMA
+ " Oniguruma"
+#endif
"");
label = gtk_label_new(buf);
diff --git a/src/prefs_filter_edit.c b/src/prefs_filter_edit.c
index dc80ddeb..5a057c12 100644
--- a/src/prefs_filter_edit.c
+++ b/src/prefs_filter_edit.c
@@ -521,7 +521,7 @@ CondHBox *prefs_filter_edit_cond_hbox_create(FilterCondEdit *cond_edit)
PF_MATCH_EQUAL);
MENUITEM_ADD(menu, menuitem, _("is not"),
PF_MATCH_NOT_EQUAL);
-#ifndef G_OS_WIN32
+#if defined(USE_ONIGURUMA) || defined(HAVE_REGCOMP)
MENUITEM_ADD(menu, menuitem, _("match to regex"),
PF_MATCH_REGEX);
MENUITEM_ADD(menu, menuitem, _("doesn't match to regex"),