| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 77f32ee commit 3e8ceed
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -725,9 +725,14 @@ class MemoryPool : public UMemory { | |||
| 725 | 725 | } | |
| 726 | 726 | ||
| 727 | 727 | MemoryPool& operator=(MemoryPool&& other) U_NOEXCEPT { | |
| 728 | - fCount = other.fCount; | ||
| 729 | - fPool = std::move(other.fPool); | ||
| 730 | - other.fCount = 0; | ||
| 728 | + // Since `this` may contain instances that need to be deleted, we can't | ||
| 729 | + // just throw them away and replace them with `other`. The normal way of | ||
| 730 | + // dealing with this in C++ is to swap `this` and `other`, rather than | ||
| 731 | + // simply overwrite: the destruction of `other` can then take care of | ||
| 732 | + // running MemoryPool::~MemoryPool() over the still-to-be-deallocated | ||
| 733 | + // instances. | ||
| 734 | + std::swap(fCount, other.fCount); | ||
| 735 | + std::swap(fPool, other.fPool); | ||
| 731 | 736 | return *this; | |
| 732 | 737 | } | |
| 733 | 738 | ||
@@ -796,9 +801,6 @@ class MemoryPool : public UMemory { | |||
| 796 | 801 | template<typename T, int32_t stackCapacity = 8> | |
| 797 | 802 | class MaybeStackVector : protected MemoryPool<T, stackCapacity> { | |
| 798 | 803 | public: | |
| 799 | - using MemoryPool<T, stackCapacity>::MemoryPool; | ||
| 800 | - using MemoryPool<T, stackCapacity>::operator=; | ||
| 801 | - | ||
| 802 | 804 | template<typename... Args> | |
| 803 | 805 | T* emplaceBack(Args&&... args) { | |
| 804 | 806 | return this->create(args...); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | 36 | #include "unicode/bytestream.h" | |
| 37 | 37 | #include "unicode/locid.h" | |
| 38 | + #include "unicode/localebuilder.h" | ||
| 38 | 39 | #include "unicode/strenum.h" | |
| 39 | 40 | #include "unicode/stringpiece.h" | |
| 40 | 41 | #include "unicode/uloc.h" | |
@@ -1028,7 +1029,7 @@ class AliasReplacer { | |||
| 1028 | 1029 | // place the the replaced locale ID in out and return true. | |
| 1029 | 1030 | // Otherwise return false for no replacement or error. | |
| 1030 | 1031 | bool replace( | |
| 1031 | - const Locale& locale, CharString& out, UErrorCode status); | ||
| 1032 | + const Locale& locale, CharString& out, UErrorCode& status); | ||
| 1032 | 1033 | ||
| 1033 | 1034 | private: | |
| 1034 | 1035 | const char* language; | |
@@ -1336,10 +1337,13 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status) | |||
| 1336 | 1337 | // Cannot use nullptr for language because that will construct | |
| 1337 | 1338 | // the default locale, in that case, use "und" to get the correct | |
| 1338 | 1339 | // locale. | |
| 1339 | - Locale l(language == nullptr ? "und" : language, nullptr, script); | ||
| 1340 | + Locale l = LocaleBuilder() | ||
| 1341 | + .setLanguage(language == nullptr ? "und" : language) | ||
| 1342 | + .setScript(script) | ||
| 1343 | + .build(status); | ||
| 1340 | 1344 | l.addLikelySubtags(status); | |
| 1341 | 1345 | const char* likelyRegion = l.getCountry(); | |
| 1342 | - CharString* item = nullptr; | ||
| 1346 | + LocalPointer<CharString> item; | ||
| 1343 | 1347 | if (likelyRegion != nullptr && uprv_strlen(likelyRegion) > 0) { | |
| 1344 | 1348 | size_t len = uprv_strlen(likelyRegion); | |
| 1345 | 1349 | const char* foundInReplacement = uprv_strstr(replacement, | |
@@ -1351,20 +1355,22 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status) | |||
| 1351 | 1355 | *(foundInReplacement-1) == ' '); | |
| 1352 | 1356 | U_ASSERT(foundInReplacement[len] == ' ' || | |
| 1353 | 1357 | foundInReplacement[len] == '\0'); | |
| 1354 | - item = new CharString(foundInReplacement, (int32_t)len, status); | ||
| 1358 | + item.adoptInsteadAndCheckErrorCode( | ||
| 1359 | + new CharString(foundInReplacement, (int32_t)len, status), status); | ||
| 1355 | 1360 | } | |
| 1356 | 1361 | } | |
| 1357 | - if (item == nullptr) { | ||
| 1358 | - item = new CharString(replacement, | ||
| 1359 | - (int32_t)(firstSpace - replacement), status); | ||
| 1362 | + if (item.isNull() && U_SUCCESS(status)) { | ||
| 1363 | + item.adoptInsteadAndCheckErrorCode( | ||
| 1364 | + new CharString(replacement, | ||
| 1365 | + (int32_t)(firstSpace - replacement), status), status); | ||
| 1360 | 1366 | } | |
| 1361 | 1367 | if (U_FAILURE(status)) { return false; } | |
| 1362 | - if (item == nullptr) { | ||
| 1368 | + if (item.isNull()) { | ||
| 1363 | 1369 | status = U_MEMORY_ALLOCATION_ERROR; | |
| 1364 | 1370 | return false; | |
| 1365 | 1371 | } | |
| 1366 | 1372 | replacedRegion = item->data(); | |
| 1367 | - toBeFreed.addElement(item, status); | ||
| 1373 | + toBeFreed.addElement(item.orphan(), status); | ||
| 1368 | 1374 | } | |
| 1369 | 1375 | U_ASSERT(!same(region, replacedRegion)); | |
| 1370 | 1376 | region = replacedRegion; | |
@@ -1453,7 +1459,7 @@ AliasReplacer::outputToString( | |||
| 1453 | 1459 | int32_t variantsStart = out.length(); | |
| 1454 | 1460 | for (int32_t i = 0; i < variants.size(); i++) { | |
| 1455 | 1461 | out.append(SEP_CHAR, status) | |
| 1456 | - .append((const char*)((UVector*)variants.elementAt(i)), | ||
| 1462 | + .append((const char*)(variants.elementAt(i)), | ||
| 1457 | 1463 | status); | |
| 1458 | 1464 | } | |
| 1459 | 1465 | T_CString_toUpperCase(out.data() + variantsStart); | |
@@ -1470,7 +1476,7 @@ AliasReplacer::outputToString( | |||
| 1470 | 1476 | } | |
| 1471 | 1477 | ||
| 1472 | 1478 | bool | |
| 1473 | - AliasReplacer::replace(const Locale& locale, CharString& out, UErrorCode status) | ||
| 1479 | + AliasReplacer::replace(const Locale& locale, CharString& out, UErrorCode& status) | ||
| 1474 | 1480 | { | |
| 1475 | 1481 | data = AliasData::singleton(status); | |
| 1476 | 1482 | if (U_FAILURE(status)) { | |
@@ -2453,9 +2459,13 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro | |||
| 2453 | 2459 | if (U_FAILURE(status)) { | |
| 2454 | 2460 | return; | |
| 2455 | 2461 | } | |
| 2462 | + if (status == U_STRING_NOT_TERMINATED_WARNING) { | ||
| 2463 | + status = U_ZERO_ERROR; | ||
| 2464 | + } | ||
| 2456 | 2465 | int32_t bufferLength = uprv_max((int32_t)(uprv_strlen(fullName) + 1), ULOC_FULLNAME_CAPACITY); | |
| 2457 | 2466 | int32_t newLength = uloc_setKeywordValue(keywordName, keywordValue, fullName, | |
| 2458 | 2467 | bufferLength, &status) + 1; | |
| 2468 | + U_ASSERT(status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 2459 | 2469 | /* Handle the case the current buffer is not enough to hold the new id */ | |
| 2460 | 2470 | if (status == U_BUFFER_OVERFLOW_ERROR) { | |
| 2461 | 2471 | U_ASSERT(newLength > bufferLength); | |
@@ -2472,6 +2482,7 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro | |||
| 2472 | 2482 | fullName = newFullName; | |
| 2473 | 2483 | status = U_ZERO_ERROR; | |
| 2474 | 2484 | uloc_setKeywordValue(keywordName, keywordValue, fullName, newLength, &status); | |
| 2485 | + U_ASSERT(status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 2475 | 2486 | } else { | |
| 2476 | 2487 | U_ASSERT(newLength <= bufferLength); | |
| 2477 | 2488 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1402,12 +1402,13 @@ void RBBITableBuilder::exportTable(void *where) { | |||
| 1402 | 1402 | U_ASSERT (sd->fAccepting <= 255); | |
| 1403 | 1403 | U_ASSERT (sd->fLookAhead <= 255); | |
| 1404 | 1404 | U_ASSERT (0 <= sd->fTagsIdx && sd->fTagsIdx <= 255); | |
| 1405 | - row->r8.fAccepting = sd->fAccepting; | ||
| 1406 | - row->r8.fLookAhead = sd->fLookAhead; | ||
| 1407 | - row->r8.fTagsIdx = sd->fTagsIdx; | ||
| 1405 | + RBBIStateTableRow8 *r8 = (RBBIStateTableRow8*)row; | ||
| 1406 | + r8->fAccepting = sd->fAccepting; | ||
| 1407 | + r8->fLookAhead = sd->fLookAhead; | ||
| 1408 | + r8->fTagsIdx = sd->fTagsIdx; | ||
| 1408 | 1409 | for (col=0; col<catCount; col++) { | |
| 1409 | 1410 | U_ASSERT (sd->fDtran->elementAti(col) <= kMaxStateFor8BitsTable); | |
| 1410 | - row->r8.fNextState[col] = sd->fDtran->elementAti(col); | ||
| 1411 | + r8->fNextState[col] = sd->fDtran->elementAti(col); | ||
| 1411 | 1412 | } | |
| 1412 | 1413 | } else { | |
| 1413 | 1414 | U_ASSERT (sd->fAccepting <= 0xffff); | |
@@ -1603,12 +1604,13 @@ void RBBITableBuilder::exportSafeTable(void *where) { | |||
| 1603 | 1604 | UnicodeString *rowString = (UnicodeString *)fSafeTable->elementAt(state); | |
| 1604 | 1605 | RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + state*table->fRowLen); | |
| 1605 | 1606 | if (use8BitsForSafeTable()) { | |
| 1606 | - row->r8.fAccepting = 0; | ||
| 1607 | - row->r8.fLookAhead = 0; | ||
| 1608 | - row->r8.fTagsIdx = 0; | ||
| 1607 | + RBBIStateTableRow8 *r8 = (RBBIStateTableRow8*)row; | ||
| 1608 | + r8->fAccepting = 0; | ||
| 1609 | + r8->fLookAhead = 0; | ||
| 1610 | + r8->fTagsIdx = 0; | ||
| 1609 | 1611 | for (col=0; col<catCount; col++) { | |
| 1610 | 1612 | U_ASSERT(rowString->charAt(col) <= kMaxStateFor8BitsTable); | |
| 1611 | - row->r8.fNextState[col] = static_cast<uint8_t>(rowString->charAt(col)); | ||
| 1613 | + r8->fNextState[col] = static_cast<uint8_t>(rowString->charAt(col)); | ||
| 1612 | 1614 | } | |
| 1613 | 1615 | } else { | |
| 1614 | 1616 | row->r16.fAccepting = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -877,6 +877,9 @@ uloc_setKeywordValue(const char* keywordName, | |||
| 877 | 877 | if(U_FAILURE(*status)) { | |
| 878 | 878 | return -1; | |
| 879 | 879 | } | |
| 880 | + if (*status == U_STRING_NOT_TERMINATED_WARNING) { | ||
| 881 | + *status = U_ZERO_ERROR; | ||
| 882 | + } | ||
| 880 | 883 | if (keywordName == NULL || keywordName[0] == 0 || bufferCapacity <= 1) { | |
| 881 | 884 | *status = U_ILLEGAL_ARGUMENT_ERROR; | |
| 882 | 885 | return 0; | |
@@ -914,6 +917,7 @@ uloc_setKeywordValue(const char* keywordName, | |||
| 914 | 917 | startSearchHere = (char*)locale_getKeywordsStart(buffer); | |
| 915 | 918 | if(startSearchHere == NULL || (startSearchHere[1]==0)) { | |
| 916 | 919 | if(keywordValueLen == 0) { /* no keywords = nothing to remove */ | |
| 920 | + U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 917 | 921 | return bufLen; | |
| 918 | 922 | } | |
| 919 | 923 | ||
@@ -933,6 +937,7 @@ uloc_setKeywordValue(const char* keywordName, | |||
| 933 | 937 | startSearchHere += keywordNameLen; | |
| 934 | 938 | *startSearchHere++ = '='; | |
| 935 | 939 | uprv_strcpy(startSearchHere, keywordValueBuffer); | |
| 940 | + U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 936 | 941 | return needLen; | |
| 937 | 942 | } /* end shortcut - no @ */ | |
| 938 | 943 | ||
@@ -1047,13 +1052,27 @@ uloc_setKeywordValue(const char* keywordName, | |||
| 1047 | 1052 | if (!handledInputKeyAndValue || U_FAILURE(*status)) { | |
| 1048 | 1053 | /* if input key/value specified removal of a keyword not present in locale, or | |
| 1049 | 1054 | * there was an error in CharString.append, leave original locale alone. */ | |
| 1055 | + U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 1050 | 1056 | return bufLen; | |
| 1051 | 1057 | } | |
| 1052 | 1058 | ||
| 1053 | 1059 | // needLen = length of the part before '@' | |
| 1054 | 1060 | needLen = (int32_t)(startSearchHere - buffer); | |
| 1055 | - return needLen + updatedKeysAndValues.extract( | ||
| 1061 | + // Check to see can we fit the startSearchHere, if not, return | ||
| 1062 | + // U_BUFFER_OVERFLOW_ERROR without copy updatedKeysAndValues into it. | ||
| 1063 | + // We do this because this API function does not behave like most others: | ||
| 1064 | + // It promises never to set a U_STRING_NOT_TERMINATED_WARNING. | ||
| 1065 | + // When the contents fits but without the terminating NUL, in this case we need to not change | ||
| 1066 | + // the buffer contents and return with a buffer overflow error. | ||
| 1067 | + int32_t appendLength = updatedKeysAndValues.length(); | ||
| 1068 | + if (appendLength >= bufferCapacity - needLen) { | ||
| 1069 | + *status = U_BUFFER_OVERFLOW_ERROR; | ||
| 1070 | + return needLen + appendLength; | ||
| 1071 | + } | ||
| 1072 | + needLen += updatedKeysAndValues.extract( | ||
| 1056 | 1073 | startSearchHere, bufferCapacity - needLen, *status); | |
| 1074 | + U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING); | ||
| 1075 | + return needLen; | ||
| 1057 | 1076 | } | |
| 1058 | 1077 | ||
| 1059 | 1078 | /* ### ID parsing implementation **************************************************/ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,6 +143,11 @@ | |||
| 143 | 143 | * <td>icu::MessageFormat</td> | |
| 144 | 144 | * </tr> | |
| 145 | 145 | * <tr> | |
| 146 | + * <td>List Formatting</td> | ||
| 147 | + * <td>ulistformatter.h</td> | ||
| 148 | + * <td>icu::ListFormatter</td> | ||
| 149 | + * </tr> | ||
| 150 | + * <tr> | ||
| 146 | 151 | * <td>Number Formatting<br/>(includes currency and unit formatting)</td> | |
| 147 | 152 | * <td>unumberformatter.h, unum.h</td> | |
| 148 | 153 | * <td>icu::number::NumberFormatter (ICU 60+) or icu::NumberFormat (older versions)</td> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1137,6 +1137,7 @@ | |||
| 1137 | 1137 | #define ulocimp_toLanguageTag U_ICU_ENTRY_POINT_RENAME(ulocimp_toLanguageTag) | |
| 1138 | 1138 | #define ulocimp_toLegacyKey U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyKey) | |
| 1139 | 1139 | #define ulocimp_toLegacyType U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyType) | |
| 1140 | + #define ultag_getTKeyStart U_ICU_ENTRY_POINT_RENAME(ultag_getTKeyStart) | ||
| 1140 | 1141 | #define ultag_isExtensionSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isExtensionSubtags) | |
| 1141 | 1142 | #define ultag_isLanguageSubtag U_ICU_ENTRY_POINT_RENAME(ultag_isLanguageSubtag) | |
| 1142 | 1143 | #define ultag_isPrivateuseValueSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isPrivateuseValueSubtags) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,7 @@ | |||
| 66 | 66 | * This value will change in the subsequent releases of ICU | |
| 67 | 67 | * @stable ICU 2.6 | |
| 68 | 68 | */ | |
| 69 | - #define U_ICU_VERSION_MINOR_NUM 1 | ||
| 69 | + #define U_ICU_VERSION_MINOR_NUM 2 | ||
| 70 | 70 | ||
| 71 | 71 | /** The current ICU patchlevel version as an integer. | |
| 72 | 72 | * This value will change in the subsequent releases of ICU | |
@@ -139,7 +139,7 @@ | |||
| 139 | 139 | * This value will change in the subsequent releases of ICU | |
| 140 | 140 | * @stable ICU 2.4 | |
| 141 | 141 | */ | |
| 142 | - #define U_ICU_VERSION "68.1" | ||
| 142 | + #define U_ICU_VERSION "68.2" | ||
| 143 | 143 | ||
| 144 | 144 | /** | |
| 145 | 145 | * The current ICU library major version number as a string, for library name suffixes. | |
@@ -158,7 +158,7 @@ | |||
| 158 | 158 | /** Data version in ICU4C. | |
| 159 | 159 | * @internal ICU 4.4 Internal Use Only | |
| 160 | 160 | **/ | |
| 161 | - #define U_ICU_DATA_VERSION "68.1" | ||
| 161 | + #define U_ICU_DATA_VERSION "68.2" | ||
| 162 | 162 | #endif /* U_HIDE_INTERNAL_API */ | |
| 163 | 163 | ||
| 164 | 164 | /*=========================================================================== | |
| Back | FazBrowse Home | New Git URL |
0 commit comments