for (index = strStart;
index <= (strStart + strLength - strToFindLength);
index++) {
- Bool match = FALSE;
UnicodeIndex i;
+ Bool match = FALSE;
UnicodeIndex indexSrc = index;
UnicodeIndex indexSrch = strToFindStart;
UnicodeIndex strToFindLength) // IN:
{
UnicodeIndex index;
- UnicodeIndex strToFindEnd;
uint32 *utf32Source = NULL;
uint32 *utf32Search = NULL;
* to be searched.
*/
- strToFindEnd = strToFindStart + strToFindLength - 1;
-
- for (index = strStart + strLength - 1; index >= strStart; index--) {
- if (utf32Source[index] == utf32Search[strToFindEnd]) {
- UnicodeIndex strSubOffset = index;
- UnicodeIndex strToFindSubOffset = strToFindEnd;
-
- while (TRUE) {
- if (strToFindSubOffset == strToFindStart) {
- index = strSubOffset; // Found the substring.
- goto bail;
- }
+ for (index = strStart + strLength - strToFindLength;
+ index >= strStart;
+ index--) {
+ UnicodeIndex i;
+ Bool match = FALSE;
+ UnicodeIndex indexSrc = index;
+ UnicodeIndex indexSrch = strToFindStart;
- strToFindSubOffset--;
- strSubOffset--;
+ for (i = 0; i < strToFindLength; i++) {
+ match = (utf32Source[indexSrc++] == utf32Search[indexSrch++]);
- if (utf32Source[strSubOffset] != utf32Search[strToFindSubOffset]) {
- break;
- }
+ if (!match) {
+ break;
}
}
+
+ if (match) {
+ goto bail;
+ }
}
index = UNICODE_INDEX_NOT_FOUND;