Chromium Code Reviews| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 return true; | 682 return true; |
| 683 } | 683 } |
| 684 return false; | 684 return false; |
| 685 } | 685 } |
| 686 | 686 |
| 687 typedef int32_t (*icuCaseConverter)(UChar*, int32_t, const UChar*, int32_t, cons t char*, UErrorCode*); | 687 typedef int32_t (*icuCaseConverter)(UChar*, int32_t, const UChar*, int32_t, cons t char*, UErrorCode*); |
| 688 | 688 |
| 689 static PassRefPtr<StringImpl> caseConvert(const UChar* source16, size_t length, icuCaseConverter converter, const char* locale, StringImpl* originalString) | 689 static PassRefPtr<StringImpl> caseConvert(const UChar* source16, size_t length, icuCaseConverter converter, const char* locale, StringImpl* originalString) |
| 690 { | 690 { |
| 691 UChar* data16; | 691 UChar* data16; |
| 692 int32_t targetLength = length; | 692 size_t targetLength = length; |
| 693 RefPtr<StringImpl> output = StringImpl::createUninitialized(length, data16); | 693 RefPtr<StringImpl> output = StringImpl::createUninitialized(length, data16); |
| 694 do { | 694 do { |
| 695 UErrorCode status = U_ZERO_ERROR; | 695 UErrorCode status = U_ZERO_ERROR; |
| 696 targetLength = converter(data16, targetLength, source16, length, locale, &status); | 696 targetLength = converter(data16, targetLength, source16, length, locale, &status); |
| 697 if (U_SUCCESS(status)) { | 697 if (U_SUCCESS(status)) { |
| 698 output->truncateAssumingIsolated(targetLength); | 698 ASSERT(targetLength <= length); |
|
tkent
2014/11/25 00:41:22
This assertion is not correct.
input: ß (length=
| |
| 699 if (length > 0) | |
| 700 output->truncateAssumingIsolated(targetLength); | |
| 699 return output.release(); | 701 return output.release(); |
| 700 } | 702 } |
| 701 if (status != U_BUFFER_OVERFLOW_ERROR) | 703 if (status != U_BUFFER_OVERFLOW_ERROR) |
| 702 return originalString; | 704 return originalString; |
| 703 // Expand the buffer. | 705 // Expand the buffer. |
| 704 output = StringImpl::createUninitialized(targetLength, data16); | 706 output = StringImpl::createUninitialized(targetLength, data16); |
| 705 } while (true); | 707 } while (true); |
| 706 } | 708 } |
| 707 | 709 |
| 708 PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) | 710 PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2085 | 2087 |
| 2086 size_t StringImpl::sizeInBytes() const | 2088 size_t StringImpl::sizeInBytes() const |
| 2087 { | 2089 { |
| 2088 size_t size = length(); | 2090 size_t size = length(); |
| 2089 if (!is8Bit()) | 2091 if (!is8Bit()) |
| 2090 size *= 2; | 2092 size *= 2; |
| 2091 return size + sizeof(*this); | 2093 return size + sizeof(*this); |
| 2092 } | 2094 } |
| 2093 | 2095 |
| 2094 } // namespace WTF | 2096 } // namespace WTF |
| OLD | NEW |