OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) | 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 return reverseFindInner(characters8(), matchString->characters8(), i
ndex, ourLength, matchLength); | 1418 return reverseFindInner(characters8(), matchString->characters8(), i
ndex, ourLength, matchLength); |
1419 return reverseFindInner(characters8(), matchString->characters16(), inde
x, ourLength, matchLength); | 1419 return reverseFindInner(characters8(), matchString->characters16(), inde
x, ourLength, matchLength); |
1420 } | 1420 } |
1421 | 1421 |
1422 if (matchString->is8Bit()) | 1422 if (matchString->is8Bit()) |
1423 return reverseFindInner(characters16(), matchString->characters8(), inde
x, ourLength, matchLength); | 1423 return reverseFindInner(characters16(), matchString->characters8(), inde
x, ourLength, matchLength); |
1424 | 1424 |
1425 return reverseFindInner(characters16(), matchString->characters16(), index,
ourLength, matchLength); | 1425 return reverseFindInner(characters16(), matchString->characters16(), index,
ourLength, matchLength); |
1426 } | 1426 } |
1427 | 1427 |
1428 template <typename SearchCharacterType, typename MatchCharacterType> | |
1429 ALWAYS_INLINE static size_t reverseFindIgnoringCaseInner(const SearchCharacterTy
pe* searchCharacters, const MatchCharacterType* matchCharacters, unsigned index,
unsigned length, unsigned matchLength) | |
1430 { | |
1431 // delta is the number of additional times to test; delta == 0 means test on
ly once. | |
1432 unsigned delta = min(index, length - matchLength); | |
1433 | |
1434 // keep looping until we match | |
1435 while (!equalIgnoringCase(searchCharacters + delta, matchCharacters, matchLe
ngth)) { | |
1436 if (!delta) | |
1437 return kNotFound; | |
1438 --delta; | |
1439 } | |
1440 return delta; | |
1441 } | |
1442 | |
1443 size_t StringImpl::reverseFindIgnoringCase(StringImpl* matchString, unsigned ind
ex) | |
1444 { | |
1445 // Check for null or empty string to match against | |
1446 if (!matchString) | |
1447 return kNotFound; | |
1448 unsigned matchLength = matchString->length(); | |
1449 unsigned ourLength = length(); | |
1450 if (!matchLength) | |
1451 return min(index, ourLength); | |
1452 | |
1453 // Check index & matchLength are in range. | |
1454 if (matchLength > ourLength) | |
1455 return kNotFound; | |
1456 | |
1457 if (is8Bit()) { | |
1458 if (matchString->is8Bit()) | |
1459 return reverseFindIgnoringCaseInner(characters8(), matchString->char
acters8(), index, ourLength, matchLength); | |
1460 return reverseFindIgnoringCaseInner(characters8(), matchString->characte
rs16(), index, ourLength, matchLength); | |
1461 } | |
1462 | |
1463 if (matchString->is8Bit()) | |
1464 return reverseFindIgnoringCaseInner(characters16(), matchString->charact
ers8(), index, ourLength, matchLength); | |
1465 | |
1466 return reverseFindIgnoringCaseInner(characters16(), matchString->characters1
6(), index, ourLength, matchLength); | |
1467 } | |
1468 | |
1469 ALWAYS_INLINE static bool equalInner(const StringImpl* stringImpl, unsigned star
tOffset, const LChar* matchString, unsigned matchLength) | 1428 ALWAYS_INLINE static bool equalInner(const StringImpl* stringImpl, unsigned star
tOffset, const LChar* matchString, unsigned matchLength) |
1470 { | 1429 { |
1471 ASSERT(stringImpl); | 1430 ASSERT(stringImpl); |
1472 ASSERT(matchLength <= stringImpl->length()); | 1431 ASSERT(matchLength <= stringImpl->length()); |
1473 ASSERT(startOffset + matchLength <= stringImpl->length()); | 1432 ASSERT(startOffset + matchLength <= stringImpl->length()); |
1474 | 1433 |
1475 if (stringImpl->is8Bit()) | 1434 if (stringImpl->is8Bit()) |
1476 return equal(stringImpl->characters8() + startOffset, matchString, match
Length); | 1435 return equal(stringImpl->characters8() + startOffset, matchString, match
Length); |
1477 return equal(stringImpl->characters16() + startOffset, matchString, matchLen
gth); | 1436 return equal(stringImpl->characters16() + startOffset, matchString, matchLen
gth); |
1478 } | 1437 } |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2127 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
2169 // TODO(rob.buis) implement upper-casing rules for lt | 2128 // TODO(rob.buis) implement upper-casing rules for lt |
2170 // like in StringImpl::upper(locale). | 2129 // like in StringImpl::upper(locale). |
2171 } | 2130 } |
2172 } | 2131 } |
2173 | 2132 |
2174 return toUpper(c); | 2133 return toUpper(c); |
2175 } | 2134 } |
2176 | 2135 |
2177 } // namespace WTF | 2136 } // namespace WTF |
OLD | NEW |