| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1d21a8d commit ee669a0
215 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | ICU sources - auto generated by shrink-icu-src.py | |
| 2 | 2 | ||
| 3 | 3 | This directory contains the ICU subset used by --with-intl=full-icu | |
| 4 | - It is a strict subset of ICU 68 source files with the following exception(s): | ||
| 5 | - * deps/icu-small/source/data/in/icudt68l.dat.bz2 : compressed data file | ||
| 4 | + It is a strict subset of ICU 69 source files with the following exception(s): | ||
| 5 | + * deps/icu-small/source/data/in/icudt69l.dat.bz2 : compressed data file | ||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | 8 | To rebuild this directory, see ../../tools/icu/README.md | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -474,31 +474,39 @@ BytesTrieBuilder::writeDeltaTo(int32_t jumpTarget) { | |||
| 474 | 474 | U_ASSERT(i>=0); | |
| 475 | 475 | if(i<=BytesTrie::kMaxOneByteDelta) { | |
| 476 | 476 | return write(i); | |
| 477 | + } else { | ||
| 478 | + char intBytes[5]; | ||
| 479 | + return write(intBytes, internalEncodeDelta(i, intBytes)); | ||
| 477 | 480 | } | |
| 478 | - char intBytes[5]; | ||
| 479 | - int32_t length; | ||
| 481 | + } | ||
| 482 | + | ||
| 483 | + int32_t | ||
| 484 | + BytesTrieBuilder::internalEncodeDelta(int32_t i, char intBytes[]) { | ||
| 485 | + U_ASSERT(i>=0); | ||
| 486 | + if(i<=BytesTrie::kMaxOneByteDelta) { | ||
| 487 | + intBytes[0]=(char)i; | ||
| 488 | + return 1; | ||
| 489 | + } | ||
| 490 | + int32_t length=1; | ||
| 480 | 491 | if(i<=BytesTrie::kMaxTwoByteDelta) { | |
| 481 | 492 | intBytes[0]=(char)(BytesTrie::kMinTwoByteDeltaLead+(i>>8)); | |
| 482 | - length=1; | ||
| 483 | 493 | } else { | |
| 484 | 494 | if(i<=BytesTrie::kMaxThreeByteDelta) { | |
| 485 | 495 | intBytes[0]=(char)(BytesTrie::kMinThreeByteDeltaLead+(i>>16)); | |
| 486 | - length=2; | ||
| 487 | 496 | } else { | |
| 488 | 497 | if(i<=0xffffff) { | |
| 489 | 498 | intBytes[0]=(char)BytesTrie::kFourByteDeltaLead; | |
| 490 | - length=3; | ||
| 491 | 499 | } else { | |
| 492 | 500 | intBytes[0]=(char)BytesTrie::kFiveByteDeltaLead; | |
| 493 | 501 | intBytes[1]=(char)(i>>24); | |
| 494 | - length=4; | ||
| 502 | + length=2; | ||
| 495 | 503 | } | |
| 496 | - intBytes[1]=(char)(i>>16); | ||
| 504 | + intBytes[length++]=(char)(i>>16); | ||
| 497 | 505 | } | |
| 498 | - intBytes[1]=(char)(i>>8); | ||
| 506 | + intBytes[length++]=(char)(i>>8); | ||
| 499 | 507 | } | |
| 500 | 508 | intBytes[length++]=(char)i; | |
| 501 | - return write(intBytes, length); | ||
| 509 | + return length; | ||
| 502 | 510 | } | |
| 503 | 511 | ||
| 504 | 512 | U_NAMESPACE_END | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,8 @@ | |||
| 14 | 14 | * created by: Markus W. Scherer | |
| 15 | 15 | */ | |
| 16 | 16 | ||
| 17 | + #include <cstdlib> | ||
| 18 | + | ||
| 17 | 19 | #include "unicode/utypes.h" | |
| 18 | 20 | #include "unicode/putil.h" | |
| 19 | 21 | #include "charstr.h" | |
@@ -141,6 +143,38 @@ CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &error | |||
| 141 | 143 | return *this; | |
| 142 | 144 | } | |
| 143 | 145 | ||
| 146 | + CharString &CharString::appendNumber(int32_t number, UErrorCode &status) { | ||
| 147 | + if (number < 0) { | ||
| 148 | + this->append('-', status); | ||
| 149 | + if (U_FAILURE(status)) { | ||
| 150 | + return *this; | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + if (number == 0) { | ||
| 155 | + this->append('0', status); | ||
| 156 | + return *this; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + int32_t numLen = 0; | ||
| 160 | + while (number != 0) { | ||
| 161 | + int32_t residue = number % 10; | ||
| 162 | + number /= 10; | ||
| 163 | + this->append(std::abs(residue) + '0', status); | ||
| 164 | + numLen++; | ||
| 165 | + if (U_FAILURE(status)) { | ||
| 166 | + return *this; | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + int32_t start = this->length() - numLen, end = this->length() - 1; | ||
| 171 | + while(start < end) { | ||
| 172 | + std::swap(this->data()[start++], this->data()[end--]); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + return *this; | ||
| 176 | + } | ||
| 177 | + | ||
| 144 | 178 | char *CharString::getAppendBuffer(int32_t minCapacity, | |
| 145 | 179 | int32_t desiredCapacityHint, | |
| 146 | 180 | int32_t &resultCapacity, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,9 @@ class U_COMMON_API CharString : public UMemory { | |||
| 127 | 127 | return append(s.data(), s.length(), errorCode); | |
| 128 | 128 | } | |
| 129 | 129 | CharString &append(const char *s, int32_t sLength, UErrorCode &status); | |
| 130 | + | ||
| 131 | + CharString &appendNumber(int32_t number, UErrorCode &status); | ||
| 132 | + | ||
| 130 | 133 | /** | |
| 131 | 134 | * Returns a writable buffer for appending and writes the buffer's capacity to | |
| 132 | 135 | * resultCapacity. Guarantees resultCapacity>=minCapacity if U_SUCCESS(). | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,14 +31,63 @@ | |||
| 31 | 31 | #include <stddef.h> | |
| 32 | 32 | #include <string.h> | |
| 33 | 33 | #include "unicode/localpointer.h" | |
| 34 | + #include "uassert.h" | ||
| 34 | 35 | ||
| 35 | 36 | #if U_DEBUG && defined(UPRV_MALLOC_COUNT) | |
| 36 | 37 | #include <stdio.h> | |
| 37 | 38 | #endif | |
| 38 | 39 | ||
| 39 | - | ||
| 40 | - #define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size) | ||
| 41 | - #define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size) | ||
| 40 | + // uprv_memcpy and uprv_memmove | ||
| 41 | + #if defined(__clang__) | ||
| 42 | + #define uprv_memcpy(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 43 | + /* Suppress warnings about addresses that will never be NULL */ \ | ||
| 44 | + _Pragma("clang diagnostic push") \ | ||
| 45 | + _Pragma("clang diagnostic ignored \"-Waddress\"") \ | ||
| 46 | + U_ASSERT(dst != NULL); \ | ||
| 47 | + U_ASSERT(src != NULL); \ | ||
| 48 | + _Pragma("clang diagnostic pop") \ | ||
| 49 | + U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size); \ | ||
| 50 | + } UPRV_BLOCK_MACRO_END | ||
| 51 | + #define uprv_memmove(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 52 | + /* Suppress warnings about addresses that will never be NULL */ \ | ||
| 53 | + _Pragma("clang diagnostic push") \ | ||
| 54 | + _Pragma("clang diagnostic ignored \"-Waddress\"") \ | ||
| 55 | + U_ASSERT(dst != NULL); \ | ||
| 56 | + U_ASSERT(src != NULL); \ | ||
| 57 | + _Pragma("clang diagnostic pop") \ | ||
| 58 | + U_STANDARD_CPP_NAMESPACE memmove(dst, src, size); \ | ||
| 59 | + } UPRV_BLOCK_MACRO_END | ||
| 60 | + #elif defined(__GNUC__) | ||
| 61 | + #define uprv_memcpy(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 62 | + /* Suppress warnings about addresses that will never be NULL */ \ | ||
| 63 | + _Pragma("GCC diagnostic push") \ | ||
| 64 | + _Pragma("GCC diagnostic ignored \"-Waddress\"") \ | ||
| 65 | + U_ASSERT(dst != NULL); \ | ||
| 66 | + U_ASSERT(src != NULL); \ | ||
| 67 | + _Pragma("GCC diagnostic pop") \ | ||
| 68 | + U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size); \ | ||
| 69 | + } UPRV_BLOCK_MACRO_END | ||
| 70 | + #define uprv_memmove(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 71 | + /* Suppress warnings about addresses that will never be NULL */ \ | ||
| 72 | + _Pragma("GCC diagnostic push") \ | ||
| 73 | + _Pragma("GCC diagnostic ignored \"-Waddress\"") \ | ||
| 74 | + U_ASSERT(dst != NULL); \ | ||
| 75 | + U_ASSERT(src != NULL); \ | ||
| 76 | + _Pragma("GCC diagnostic pop") \ | ||
| 77 | + U_STANDARD_CPP_NAMESPACE memmove(dst, src, size); \ | ||
| 78 | + } UPRV_BLOCK_MACRO_END | ||
| 79 | + #else | ||
| 80 | + #define uprv_memcpy(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 81 | + U_ASSERT(dst != NULL); \ | ||
| 82 | + U_ASSERT(src != NULL); \ | ||
| 83 | + U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size); \ | ||
| 84 | + } UPRV_BLOCK_MACRO_END | ||
| 85 | + #define uprv_memmove(dst, src, size) UPRV_BLOCK_MACRO_BEGIN { \ | ||
| 86 | + U_ASSERT(dst != NULL); \ | ||
| 87 | + U_ASSERT(src != NULL); \ | ||
| 88 | + U_STANDARD_CPP_NAMESPACE memmove(dst, src, size); \ | ||
| 89 | + } UPRV_BLOCK_MACRO_END | ||
| 90 | + #endif | ||
| 42 | 91 | ||
| 43 | 92 | /** | |
| 44 | 93 | * \def UPRV_LENGTHOF | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -265,13 +265,9 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, | |||
| 265 | 265 | goto foundBest; | |
| 266 | 266 | } | |
| 267 | 267 | do { | |
| 268 | - int32_t wordsMatched = 1; | ||
| 269 | 268 | if (words[(wordsFound + 1) % THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd) > 0) { | |
| 270 | - if (wordsMatched < 2) { | ||
| 271 | - // Followed by another dictionary word; mark first word as a good candidate | ||
| 272 | - words[wordsFound%THAI_LOOKAHEAD].markCurrent(); | ||
| 273 | - wordsMatched = 2; | ||
| 274 | - } | ||
| 269 | + // Followed by another dictionary word; mark first word as a good candidate | ||
| 270 | + words[wordsFound%THAI_LOOKAHEAD].markCurrent(); | ||
| 275 | 271 | ||
| 276 | 272 | // If we're already at the end of the range, we're done | |
| 277 | 273 | if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { | |
@@ -503,13 +499,9 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, | |||
| 503 | 499 | goto foundBest; | |
| 504 | 500 | } | |
| 505 | 501 | do { | |
| 506 | - int32_t wordsMatched = 1; | ||
| 507 | 502 | if (words[(wordsFound + 1) % LAO_LOOKAHEAD].candidates(text, fDictionary, rangeEnd) > 0) { | |
| 508 | - if (wordsMatched < 2) { | ||
| 509 | - // Followed by another dictionary word; mark first word as a good candidate | ||
| 510 | - words[wordsFound%LAO_LOOKAHEAD].markCurrent(); | ||
| 511 | - wordsMatched = 2; | ||
| 512 | - } | ||
| 503 | + // Followed by another dictionary word; mark first word as a good candidate | ||
| 504 | + words[wordsFound%LAO_LOOKAHEAD].markCurrent(); | ||
| 513 | 505 | ||
| 514 | 506 | // If we're already at the end of the range, we're done | |
| 515 | 507 | if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { | |
@@ -699,13 +691,9 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, | |||
| 699 | 691 | goto foundBest; | |
| 700 | 692 | } | |
| 701 | 693 | do { | |
| 702 | - int32_t wordsMatched = 1; | ||
| 703 | 694 | if (words[(wordsFound + 1) % BURMESE_LOOKAHEAD].candidates(text, fDictionary, rangeEnd) > 0) { | |
| 704 | - if (wordsMatched < 2) { | ||
| 705 | - // Followed by another dictionary word; mark first word as a good candidate | ||
| 706 | - words[wordsFound%BURMESE_LOOKAHEAD].markCurrent(); | ||
| 707 | - wordsMatched = 2; | ||
| 708 | - } | ||
| 695 | + // Followed by another dictionary word; mark first word as a good candidate | ||
| 696 | + words[wordsFound%BURMESE_LOOKAHEAD].markCurrent(); | ||
| 709 | 697 | ||
| 710 | 698 | // If we're already at the end of the range, we're done | |
| 711 | 699 | if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { | |
@@ -908,13 +896,9 @@ KhmerBreakEngine::divideUpDictionaryRange( UText *text, | |||
| 908 | 896 | goto foundBest; | |
| 909 | 897 | } | |
| 910 | 898 | do { | |
| 911 | - int32_t wordsMatched = 1; | ||
| 912 | 899 | if (words[(wordsFound + 1) % KHMER_LOOKAHEAD].candidates(text, fDictionary, rangeEnd) > 0) { | |
| 913 | - if (wordsMatched < 2) { | ||
| 914 | - // Followed by another dictionary word; mark first word as a good candidate | ||
| 915 | - words[wordsFound % KHMER_LOOKAHEAD].markCurrent(); | ||
| 916 | - wordsMatched = 2; | ||
| 917 | - } | ||
| 900 | + // Followed by another dictionary word; mark first word as a good candidate | ||
| 901 | + words[wordsFound % KHMER_LOOKAHEAD].markCurrent(); | ||
| 918 | 902 | ||
| 919 | 903 | // If we're already at the end of the range, we're done | |
| 920 | 904 | if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,7 @@ Edits &Edits::moveArray(Edits &src) U_NOEXCEPT { | |||
| 86 | 86 | } | |
| 87 | 87 | ||
| 88 | 88 | Edits &Edits::operator=(const Edits &other) { | |
| 89 | + if (this == &other) { return *this; } // self-assignment: no-op | ||
| 89 | 90 | length = other.length; | |
| 90 | 91 | delta = other.delta; | |
| 91 | 92 | numChanges = other.numChanges; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments