]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/regex.cpp
Fixed undeclared identifier compile error.
[wxWidgets.git] / src / common / regex.cpp
index e39cde96bf6880332cf171fd57288fb5f327e387..7f23266dd5d9405eaebc9ec1e94d7e3f494fc909 100644 (file)
@@ -18,7 +18,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "regex.h"
 #endif
 
 
 #include "wx/regex.h"
 
+#ifdef wxUSE_NEW_REGEX
+    #define regerror wx_regerror
+    #define regfree wx_regfree
+#endif
+
 // ----------------------------------------------------------------------------
 // private classes
 // ----------------------------------------------------------------------------
@@ -148,7 +153,9 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode) const
 
         msg = wxString(buf.data(), wxConvLibc);
 #else // !Unicode
-        (void)regerror(errorcode, &m_RegEx, wxStringBuffer(msg, len), len);
+        (void)regerror(errorcode, &m_RegEx, msg.GetWriteBuf(len), len);
+
+        msg.UngetWriteBuf();
 #endif // Unicode/!Unicode
     }
     else // regerror() returned 0
@@ -178,9 +185,15 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags)
     if ( flags & wxRE_NEWLINE )
         flagsRE |= REG_NEWLINE;
 
+
     // compile it
+#if wxUSE_NEW_REGEX
+    int errorcode = wx_regcomp(&m_RegEx, expr, expr.Length(), flagsRE);
+#else
     int errorcode = regcomp(&m_RegEx, expr.mb_str(), flagsRE);
-    if ( errorcode )
+#endif
+
+     if ( errorcode )
     {
         wxLogError(_("Invalid regular expression '%s': %s"),
                    expr.c_str(), GetErrorMsg(errorcode).c_str());
@@ -253,7 +266,12 @@ bool wxRegExImpl::Matches(const wxChar *str, int flags) const
     }
 
     // do match it
+#ifdef wxUSE_NEW_REGEX
+       rm_detail_t rd;
+    int rc = wx_regexec(&self->m_RegEx, str, wxStrlen(str), &rd, m_nMatches, m_Matches, flagsRE);
+#else
     int rc = regexec(&self->m_RegEx, wxConvertWX2MB(str), m_nMatches, m_Matches, flagsRE);
+#endif
 
     switch ( rc )
     {