aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2014-11-21 21:11:42 -0800
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2014-11-21 21:11:42 -0800
commitfafaf9dc531119fe359b95ea0c790491b7a900ce (patch)
tree557880e29815267427c58cb70b0ec175c5158119
parent721f3948b4cb31832354182a972630fc5cf426cb (diff)
Uses ICU regex on win32 platform
-rw-r--r--src/core/provider/MCMailProvider.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/provider/MCMailProvider.cpp b/src/core/provider/MCMailProvider.cpp
index 8ebc44db..fd1b9ffb 100644
--- a/src/core/provider/MCMailProvider.cpp
+++ b/src/core/provider/MCMailProvider.cpp
@@ -11,7 +11,14 @@
#include "MCIterator.h"
#include "MCJSON.h"
+#ifdef _MSC_VER
+#include <unicode/utext.h>
+#include <unicode/utypes.h>
+#include <unicode/localpointer.h>
+#include <unicode/parseerr.h>
+#else
#include <regex.h>
+#endif
using namespace mailcore;
@@ -181,6 +188,30 @@ bool MailProvider::matchMX(String * hostname)
bool MailProvider::matchDomain(String * match, String * domain)
{
+#ifdef _MSC_VER
+ UParseError error;
+ UErrorCode code = U_ZERO_ERROR;
+ URegularExpression * r = uregex_open(match->unicodeCharacters(), match->length(), UREGEX_CASE_INSENSITIVE, &error, &code);
+ if (code != U_ZERO_ERROR) {
+ uregex_close(r);
+ return false;
+ }
+ uregex_setText(r, domain->unicodeChararacters(), domain->length(), &code);
+ if (code != U_ZERO_ERROR) {
+ uregex_close(r);
+ return false;
+ }
+
+ bool matched = uregex_matches(r, 0, &code)
+ if (code != U_ZERO_ERROR) {
+ uregex_close(r);
+ return false;
+ }
+
+ uregex_close(r);
+
+ return matched;
+#else
const char * cDomain;
regex_t r;
bool matched;
@@ -200,6 +231,7 @@ bool MailProvider::matchDomain(String * match, String * domain)
regfree(&r);
return matched;
+#endif
}
String * MailProvider::sentMailFolderPath()