- wxChar *fnd;
- while ((fnd = wxStrchr(haystack, *needle))) {
- if (!wxStrcmp(fnd, needle)) return fnd;
- haystack = fnd + 1;
- }
- return (wxChar *)NULL;
+ wxCHECK_RET( needle, NULL, _T("NULL argument in wxStrstr") );
+
+ // VZ: this is not exactly the most efficient string search algorithm...
+
+ const size_t len = wxStrlen(needle);
+
+ while ( const wxChar *fnd = wxStrchr(haystack, *needle) )
+ {
+ if ( !wxStrncmp(fnd, needle, len) )
+ return fnd;
+
+ haystack = fnd + 1;
+ }
+
+ return NULL;