const char * errormsg = NULL;
int erroroffset = 0;
- char regexString[200] = {0};
- int regexLen = 0;
+
+ char *regexString = UCS2UTF8_ConvertToUtf8(str.c_str());
int pcre_opts = 0;
-#ifdef UNICODE
- // For unicode builds, use UTF-8.
- // Convert pattern to UTF-8 and set option for PCRE to specify UTF-8.
- regexLen = TransformUcs2ToUtf8(str.c_str(), str.length(),
- regexString, (int)sizeof(regexString));
- pcre_opts |= PCRE_UTF8;
-#else
- strcpy(regexString, str.c_str());
- regexLen = strlen(regexString);
-#endif
+
pcre_opts |= PCRE_CASELESS;
-
pcre *regexp = pcre_compile(regexString, pcre_opts, &errormsg,
&erroroffset, NULL);
if (regexp)
filterList->push_back(elem);
}
+ UCS2UTF8_Dealloc(regexString);
}
/**
*/
BOOL TestAgainstRegList(const vector<FileFilterElement*> *filterList, LPCTSTR szTest)
{
- int ovector[30];
- const String sTest = szTest;
- const int ilen = sTest.length() * sizeof(TCHAR) + 1;
- char *compString = new char[ilen];
- size_t stringlen;
-
-#ifdef UNICODE
- stringlen = TransformUcs2ToUtf8(sTest.c_str(), sTest.length(),
- compString, ilen);
-#else
- strncpy(compString, sTest.c_str(), sTest.length());
- stringlen = ilen - 1;//linelen(compString);
-#endif
-
- compString[stringlen] = 0;
-
+ int ovector[30];
+ size_t stringlen =_tcslen(szTest);
+ char *compString = UCS2UTF8_ConvertToUtf8(szTest);
int result = 0;
vector<FileFilterElement*>::const_iterator iter = filterList->begin();
while (iter != filterList->end())
break;
++iter;
}
- delete [] compString;
+ UCS2UTF8_Dealloc(compString);
if (result >= 0)
return TRUE;
return FALSE;
FileFilterElement element;
const char * errormsg = NULL;
int erroroffset = 0;
- const int ilen = _tcslen(sPiece) * sizeof(TCHAR) + 1;
- char *regexString = new char[ilen];
-
-#ifdef UNICODE
- size_t regexLen = TransformUcs2ToUtf8((LPCTSTR)sPiece, _tcslen(sPiece),
- regexString, ilen);
-#else
- strcpy(regexString, (LPCTSTR)sPiece);
- size_t regexLen = ilen;
-#endif
- regexString[regexLen] = 0;
+ char *regexString = UCS2UTF8_ConvertToUtf8(sPiece);
pcre *regexp = pcre_compile(regexString, 0, &errormsg, &erroroffset, NULL);
if (regexp)
{
elem->pRegExp = regexp;
m_filters->push_back(elem);
}
- delete [] regexString;
+ UCS2UTF8_Dealloc(regexString);
};
}
int pos;
const char * errormsg = NULL;
int erroroffset = 0;
- const int ilen = _tcslen(pszFindWhat) * sizeof(TCHAR) + 1;
- char *regexString = new char[ilen];
+ char *regexString = UCS2UTF8_ConvertToUtf8(pszFindWhat);
int pcre_opts = 0;
-#ifdef UNICODE
- // For unicode builds, use UTF-8.
- // Convert pattern to UTF-8 and set option for PCRE to specify UTF-8.
- size_t regexLen = TransformUcs2ToUtf8(pszFindWhat, _tcslen(pszFindWhat),
- regexString, ilen);
- pcre_opts |= PCRE_UTF8;
-#else
- strcpy(regexString, pszFindWhat);
- size_t regexLen = ilen;
-#endif
- regexString[regexLen] = 0;
pcre_opts |= PCRE_BSR_ANYCRLF;
if ((dwFlags & FIND_MATCH_CASE) == 0)
pcre_opts |= PCRE_CASELESS;
errormsg = NULL;
pe = pcre_study(regexp, 0, &errormsg);
}
- delete [] regexString;
+ UCS2UTF8_Dealloc(regexString);
int ovector[30];
- int compStringBufLen = _tcslen(pszFindWhere) * sizeof(TCHAR) + 1;
- char *compString = new char[compStringBufLen];
- int stringLen = 0;
-
-#ifdef UNICODE
- stringLen = TransformUcs2ToUtf8(pszFindWhere, _tcslen(pszFindWhere),
- compString, compStringBufLen);
-#else
- strncpy(compString, pszFindWhere, compStringBufLen);
- stringLen = compStringBufLen;
-#endif
- compString[stringLen] = 0;
+ char *compString = UCS2UTF8_ConvertToUtf8(pszFindWhere);
+ int stringLen = _tcslen(pszFindWhere);
int result = pcre_exec(regexp, pe, compString, stringLen,
0, 0, ovector, 30);
else
pos = -1;
- delete [] compString;
+ UCS2UTF8_Dealloc(compString);
pcre_free(regexp);
pcre_free(pe);
return pos;