| 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 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 { | 2296 { |
| 2297 if (!a || !b) | 2297 if (!a || !b) |
| 2298 return !a == !b; | 2298 return !a == !b; |
| 2299 size_t length = strlen(reinterpret_cast<const char*>(b)); | 2299 size_t length = strlen(reinterpret_cast<const char*>(b)); |
| 2300 RELEASE_ASSERT(length <= numeric_limits<unsigned>::max()); | 2300 RELEASE_ASSERT(length <= numeric_limits<unsigned>::max()); |
| 2301 if (length != a->length()) | 2301 if (length != a->length()) |
| 2302 return false; | 2302 return false; |
| 2303 return equalSubstringIgnoringASCIICase(a, 0, b, length); | 2303 return equalSubstringIgnoringASCIICase(a, 0, b, length); |
| 2304 } | 2304 } |
| 2305 | 2305 |
| 2306 template<typename CharacterType1, typename CharacterType2> |
| 2307 int codePointCompareIgnoringASCIICase(unsigned l1, unsigned l2, const CharacterT
ype1* c1, const CharacterType2* c2) |
| 2308 { |
| 2309 const unsigned lmin = l1 < l2 ? l1 : l2; |
| 2310 unsigned pos = 0; |
| 2311 while (pos < lmin && toASCIILower(*c1) == toASCIILower(*c2)) { |
| 2312 ++c1; |
| 2313 ++c2; |
| 2314 ++pos; |
| 2315 } |
| 2316 |
| 2317 if (pos < lmin) |
| 2318 return (toASCIILower(c1[0]) > toASCIILower(c2[0])) ? 1 : -1; |
| 2319 |
| 2320 if (l1 == l2) |
| 2321 return 0; |
| 2322 |
| 2323 return (l1 > l2) ? 1 : -1; |
| 2324 } |
| 2325 |
| 2326 int codePointCompareIgnoringASCIICase(const StringImpl* string1, const LChar* st
ring2) |
| 2327 { |
| 2328 unsigned length1 = string1 ? string1->length() : 0; |
| 2329 size_t length2 = string2 ? strlen(reinterpret_cast<const char*>(string2)) :
0; |
| 2330 |
| 2331 if (!string1) |
| 2332 return length2 > 0 ? -1 : 0; |
| 2333 |
| 2334 if (!string2) |
| 2335 return length1 > 0 ? 1 : 0; |
| 2336 |
| 2337 if (string1->is8Bit()) |
| 2338 return codePointCompareIgnoringASCIICase(length1, length2, string1->char
acters8(), string2); |
| 2339 return codePointCompareIgnoringASCIICase(length1, length2, string1->characte
rs16(), string2); |
| 2340 } |
| 2341 |
| 2306 size_t StringImpl::sizeInBytes() const | 2342 size_t StringImpl::sizeInBytes() const |
| 2307 { | 2343 { |
| 2308 size_t size = length(); | 2344 size_t size = length(); |
| 2309 if (!is8Bit()) | 2345 if (!is8Bit()) |
| 2310 size *= 2; | 2346 size *= 2; |
| 2311 return size + sizeof(*this); | 2347 return size + sizeof(*this); |
| 2312 } | 2348 } |
| 2313 | 2349 |
| 2314 UChar32 toUpper(UChar32 c, const AtomicString& localeIdentifier) | 2350 UChar32 toUpper(UChar32 c, const AtomicString& localeIdentifier) |
| 2315 { | 2351 { |
| 2316 if (!localeIdentifier.isNull()) { | 2352 if (!localeIdentifier.isNull()) { |
| 2317 if (localeIdMatchesLang(localeIdentifier, "tr") || localeIdMatchesLang(l
ocaleIdentifier, "az")) { | 2353 if (localeIdMatchesLang(localeIdentifier, "tr") || localeIdMatchesLang(l
ocaleIdentifier, "az")) { |
| 2318 if (c == 'i') | 2354 if (c == 'i') |
| 2319 return latinCapitalLetterIWithDotAbove; | 2355 return latinCapitalLetterIWithDotAbove; |
| 2320 if (c == latinSmallLetterDotlessI) | 2356 if (c == latinSmallLetterDotlessI) |
| 2321 return 'I'; | 2357 return 'I'; |
| 2322 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2358 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
| 2323 // TODO(rob.buis) implement upper-casing rules for lt | 2359 // TODO(rob.buis) implement upper-casing rules for lt |
| 2324 // like in StringImpl::upper(locale). | 2360 // like in StringImpl::upper(locale). |
| 2325 } | 2361 } |
| 2326 } | 2362 } |
| 2327 | 2363 |
| 2328 return toUpper(c); | 2364 return toUpper(c); |
| 2329 } | 2365 } |
| 2330 | 2366 |
| 2331 } // namespace WTF | 2367 } // namespace WTF |
| OLD | NEW |