| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 } else if (dataEnd - data < utf8SequenceLength) { | 379 } else if (dataEnd - data < utf8SequenceLength) { |
| 380 return 0; | 380 return 0; |
| 381 } | 381 } |
| 382 | 382 |
| 383 if (!isLegalUTF8(reinterpret_cast<const unsigned char*>(data), | 383 if (!isLegalUTF8(reinterpret_cast<const unsigned char*>(data), |
| 384 utf8SequenceLength)) | 384 utf8SequenceLength)) |
| 385 return 0; | 385 return 0; |
| 386 | 386 |
| 387 UChar32 character = readUTF8Sequence(data, utf8SequenceLength); | 387 UChar32 character = readUTF8Sequence(data, utf8SequenceLength); |
| 388 ASSERT(!isASCII(character)); | 388 DCHECK(!isASCII(character)); |
| 389 | 389 |
| 390 if (U_IS_BMP(character)) { | 390 if (U_IS_BMP(character)) { |
| 391 // UTF-16 surrogate values are illegal in UTF-32 | 391 // UTF-16 surrogate values are illegal in UTF-32 |
| 392 if (U_IS_SURROGATE(character)) | 392 if (U_IS_SURROGATE(character)) |
| 393 return 0; | 393 return 0; |
| 394 stringHasher.addCharacter(static_cast<UChar>(character)); // normal case | 394 stringHasher.addCharacter(static_cast<UChar>(character)); // normal case |
| 395 utf16Length++; | 395 utf16Length++; |
| 396 } else if (U_IS_SUPPLEMENTARY(character)) { | 396 } else if (U_IS_SUPPLEMENTARY(character)) { |
| 397 stringHasher.addCharacters(static_cast<UChar>(U16_LEAD(character)), | 397 stringHasher.addCharacters(static_cast<UChar>(U16_LEAD(character)), |
| 398 static_cast<UChar>(U16_TRAIL(character))); | 398 static_cast<UChar>(U16_TRAIL(character))); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 420 int utf8SequenceLength = inlineUTF8SequenceLengthNonASCII(*b); | 420 int utf8SequenceLength = inlineUTF8SequenceLengthNonASCII(*b); |
| 421 | 421 |
| 422 if (bEnd - b < utf8SequenceLength) | 422 if (bEnd - b < utf8SequenceLength) |
| 423 return false; | 423 return false; |
| 424 | 424 |
| 425 if (!isLegalUTF8(reinterpret_cast<const unsigned char*>(b), | 425 if (!isLegalUTF8(reinterpret_cast<const unsigned char*>(b), |
| 426 utf8SequenceLength)) | 426 utf8SequenceLength)) |
| 427 return 0; | 427 return 0; |
| 428 | 428 |
| 429 UChar32 character = readUTF8Sequence(b, utf8SequenceLength); | 429 UChar32 character = readUTF8Sequence(b, utf8SequenceLength); |
| 430 ASSERT(!isASCII(character)); | 430 DCHECK(!isASCII(character)); |
| 431 | 431 |
| 432 if (U_IS_BMP(character)) { | 432 if (U_IS_BMP(character)) { |
| 433 // UTF-16 surrogate values are illegal in UTF-32 | 433 // UTF-16 surrogate values are illegal in UTF-32 |
| 434 if (U_IS_SURROGATE(character)) | 434 if (U_IS_SURROGATE(character)) |
| 435 return false; | 435 return false; |
| 436 if (*a++ != character) | 436 if (*a++ != character) |
| 437 return false; | 437 return false; |
| 438 } else if (U_IS_SUPPLEMENTARY(character)) { | 438 } else if (U_IS_SUPPLEMENTARY(character)) { |
| 439 if (*a++ != U16_LEAD(character)) | 439 if (*a++ != U16_LEAD(character)) |
| 440 return false; | 440 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 457 | 457 |
| 458 bool equalLatin1WithUTF8(const LChar* a, | 458 bool equalLatin1WithUTF8(const LChar* a, |
| 459 const LChar* aEnd, | 459 const LChar* aEnd, |
| 460 const char* b, | 460 const char* b, |
| 461 const char* bEnd) { | 461 const char* bEnd) { |
| 462 return equalWithUTF8Internal(a, aEnd, b, bEnd); | 462 return equalWithUTF8Internal(a, aEnd, b, bEnd); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace Unicode | 465 } // namespace Unicode |
| 466 } // namespace WTF | 466 } // namespace WTF |
| OLD | NEW |