+ // I disable this code as it doesn't seem to be faster (in fact, it seems
+ // to be much slower) than the old, hand-written code below and using it
+ // here requires always linking with libregex even if the user code doesn't
+ // use it
+#if 0 // wxUSE_REGEX
+ // first translate the shell-like mask into a regex
+ wxString pattern;
+ pattern.reserve(wxStrlen(pszMask));
+
+ pattern += _T('^');
+ while ( *pszMask )
+ {
+ switch ( *pszMask )
+ {
+ case _T('?'):
+ pattern += _T('.');
+ break;
+
+ case _T('*'):
+ pattern += _T(".*");
+ break;
+
+ case _T('^'):
+ case _T('.'):
+ case _T('$'):
+ case _T('('):
+ case _T(')'):
+ case _T('|'):
+ case _T('+'):
+ case _T('\\'):
+ // these characters are special in a RE, quote them
+ // (however note that we don't quote '[' and ']' to allow
+ // using them for Unix shell like matching)
+ pattern += _T('\\');
+ // fall through
+
+ default:
+ pattern += *pszMask;
+ }
+
+ pszMask++;
+ }
+ pattern += _T('$');
+
+ // and now use it
+ return wxRegEx(pattern, wxRE_NOSUB | wxRE_EXTENDED).Matches(c_str());
+#else // !wxUSE_REGEX
+ // TODO: this is, of course, awfully inefficient...
+
+ // the char currently being checked
+ const wxChar *pszTxt = c_str();
+
+ // the last location where '*' matched
+ const wxChar *pszLastStarInText = NULL;
+ const wxChar *pszLastStarInMask = NULL;
+
+match:
+ for ( ; *pszMask != wxT('\0'); pszMask++, pszTxt++ ) {