X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9aee09a34bdeea9a65ecd7258d9e87f44b3d5e25..0d1cb8cb298ae68754575cb65695ff9567a36899:/src/common/regex.cpp diff --git a/src/common/regex.cpp b/src/common/regex.cpp index 1d5a9f6323..943fc2c46b 100644 --- a/src/common/regex.cpp +++ b/src/common/regex.cpp @@ -38,8 +38,8 @@ #include "wx/intl.h" #endif //WX_PRECOMP -// FreeBSD requires this, it probably doesn't hurt for others -#ifdef __UNIX__ +// FreeBSD & Watcom require this, it probably doesn't hurt for others +#if defined(__UNIX__) || defined(__WATCOMC__) || defined(__DIGITALMARS__) #include #endif @@ -73,17 +73,33 @@ private: // return the string containing the error message for the given err code wxString GetErrorMsg(int errorcode) const; + // init the members + void Init() + { + m_isCompiled = FALSE; + m_Matches = NULL; + m_nMatches = 0; + } + // free the RE if compiled void Free() { if ( IsValid() ) { regfree(&m_RegEx); - - m_isCompiled = FALSE; } + + delete [] m_Matches; } + // free the RE if any and reinit the members + void Reinit() + { + Free(); + Init(); + } + + // compiled RE regex_t m_RegEx; @@ -105,16 +121,12 @@ private: wxRegExImpl::wxRegExImpl() { - m_isCompiled = FALSE; - m_Matches = NULL; - m_nMatches = 0; + Init(); } wxRegExImpl::~wxRegExImpl() { Free(); - - delete [] m_Matches; } wxString wxRegExImpl::GetErrorMsg(int errorcode) const @@ -132,7 +144,7 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode) const (void)regerror(errorcode, &m_RegEx, (char *)buf.data(), len); - msg = buf.data(); + msg = wxString(buf.data(), wxConvLibc); #else // !Unicode (void)regerror(errorcode, &m_RegEx, msg.GetWriteBuf(len), len); @@ -149,7 +161,7 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode) const bool wxRegExImpl::Compile(const wxString& expr, int flags) { - Free(); + Reinit(); // translate our flags to regcomp() ones wxASSERT_MSG( !(flags &