Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update ICU to 68.2 #36980

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions deps/icu-small/source/common/cmemory.h
Expand Up @@ -725,9 +725,14 @@ class MemoryPool : public UMemory {
}

MemoryPool& operator=(MemoryPool&& other) U_NOEXCEPT {
fCount = other.fCount;
fPool = std::move(other.fPool);
other.fCount = 0;
// Since `this` may contain instances that need to be deleted, we can't
// just throw them away and replace them with `other`. The normal way of
// dealing with this in C++ is to swap `this` and `other`, rather than
// simply overwrite: the destruction of `other` can then take care of
// running MemoryPool::~MemoryPool() over the still-to-be-deallocated
// instances.
std::swap(fCount, other.fCount);
std::swap(fPool, other.fPool);
return *this;
}

Expand Down Expand Up @@ -796,9 +801,6 @@ class MemoryPool : public UMemory {
template<typename T, int32_t stackCapacity = 8>
class MaybeStackVector : protected MemoryPool<T, stackCapacity> {
public:
using MemoryPool<T, stackCapacity>::MemoryPool;
using MemoryPool<T, stackCapacity>::operator=;

template<typename... Args>
T* emplaceBack(Args&&... args) {
return this->create(args...);
Expand Down
33 changes: 22 additions & 11 deletions deps/icu-small/source/common/locid.cpp
Expand Up @@ -35,6 +35,7 @@

#include "unicode/bytestream.h"
#include "unicode/locid.h"
#include "unicode/localebuilder.h"
#include "unicode/strenum.h"
#include "unicode/stringpiece.h"
#include "unicode/uloc.h"
Expand Down Expand Up @@ -1028,7 +1029,7 @@ class AliasReplacer {
// place the the replaced locale ID in out and return true.
// Otherwise return false for no replacement or error.
bool replace(
const Locale& locale, CharString& out, UErrorCode status);
const Locale& locale, CharString& out, UErrorCode& status);

private:
const char* language;
Expand Down Expand Up @@ -1336,10 +1337,13 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
// Cannot use nullptr for language because that will construct
// the default locale, in that case, use "und" to get the correct
// locale.
Locale l(language == nullptr ? "und" : language, nullptr, script);
Locale l = LocaleBuilder()
.setLanguage(language == nullptr ? "und" : language)
.setScript(script)
.build(status);
l.addLikelySubtags(status);
const char* likelyRegion = l.getCountry();
CharString* item = nullptr;
LocalPointer<CharString> item;
if (likelyRegion != nullptr && uprv_strlen(likelyRegion) > 0) {
size_t len = uprv_strlen(likelyRegion);
const char* foundInReplacement = uprv_strstr(replacement,
Expand All @@ -1351,20 +1355,22 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
*(foundInReplacement-1) == ' ');
U_ASSERT(foundInReplacement[len] == ' ' ||
foundInReplacement[len] == '\0');
item = new CharString(foundInReplacement, (int32_t)len, status);
item.adoptInsteadAndCheckErrorCode(
new CharString(foundInReplacement, (int32_t)len, status), status);
}
}
if (item == nullptr) {
item = new CharString(replacement,
(int32_t)(firstSpace - replacement), status);
if (item.isNull() && U_SUCCESS(status)) {
item.adoptInsteadAndCheckErrorCode(
new CharString(replacement,
(int32_t)(firstSpace - replacement), status), status);
}
if (U_FAILURE(status)) { return false; }
if (item == nullptr) {
if (item.isNull()) {
status = U_MEMORY_ALLOCATION_ERROR;
return false;
}
replacedRegion = item->data();
toBeFreed.addElement(item, status);
toBeFreed.addElement(item.orphan(), status);
}
U_ASSERT(!same(region, replacedRegion));
region = replacedRegion;
Expand Down Expand Up @@ -1453,7 +1459,7 @@ AliasReplacer::outputToString(
int32_t variantsStart = out.length();
for (int32_t i = 0; i < variants.size(); i++) {
out.append(SEP_CHAR, status)
.append((const char*)((UVector*)variants.elementAt(i)),
.append((const char*)(variants.elementAt(i)),
status);
}
T_CString_toUpperCase(out.data() + variantsStart);
Expand All @@ -1470,7 +1476,7 @@ AliasReplacer::outputToString(
}

bool
AliasReplacer::replace(const Locale& locale, CharString& out, UErrorCode status)
AliasReplacer::replace(const Locale& locale, CharString& out, UErrorCode& status)
{
data = AliasData::singleton(status);
if (U_FAILURE(status)) {
Expand Down Expand Up @@ -2453,9 +2459,13 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro
if (U_FAILURE(status)) {
return;
}
if (status == U_STRING_NOT_TERMINATED_WARNING) {
status = U_ZERO_ERROR;
}
int32_t bufferLength = uprv_max((int32_t)(uprv_strlen(fullName) + 1), ULOC_FULLNAME_CAPACITY);
int32_t newLength = uloc_setKeywordValue(keywordName, keywordValue, fullName,
bufferLength, &status) + 1;
U_ASSERT(status != U_STRING_NOT_TERMINATED_WARNING);
/* Handle the case the current buffer is not enough to hold the new id */
if (status == U_BUFFER_OVERFLOW_ERROR) {
U_ASSERT(newLength > bufferLength);
Expand All @@ -2472,6 +2482,7 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro
fullName = newFullName;
status = U_ZERO_ERROR;
uloc_setKeywordValue(keywordName, keywordValue, fullName, newLength, &status);
U_ASSERT(status != U_STRING_NOT_TERMINATED_WARNING);
} else {
U_ASSERT(newLength <= bufferLength);
}
Expand Down
18 changes: 10 additions & 8 deletions deps/icu-small/source/common/rbbitblb.cpp
Expand Up @@ -1402,12 +1402,13 @@ void RBBITableBuilder::exportTable(void *where) {
U_ASSERT (sd->fAccepting <= 255);
U_ASSERT (sd->fLookAhead <= 255);
U_ASSERT (0 <= sd->fTagsIdx && sd->fTagsIdx <= 255);
row->r8.fAccepting = sd->fAccepting;
row->r8.fLookAhead = sd->fLookAhead;
row->r8.fTagsIdx = sd->fTagsIdx;
RBBIStateTableRow8 *r8 = (RBBIStateTableRow8*)row;
r8->fAccepting = sd->fAccepting;
r8->fLookAhead = sd->fLookAhead;
r8->fTagsIdx = sd->fTagsIdx;
for (col=0; col<catCount; col++) {
U_ASSERT (sd->fDtran->elementAti(col) <= kMaxStateFor8BitsTable);
row->r8.fNextState[col] = sd->fDtran->elementAti(col);
r8->fNextState[col] = sd->fDtran->elementAti(col);
}
} else {
U_ASSERT (sd->fAccepting <= 0xffff);
Expand Down Expand Up @@ -1603,12 +1604,13 @@ void RBBITableBuilder::exportSafeTable(void *where) {
UnicodeString *rowString = (UnicodeString *)fSafeTable->elementAt(state);
RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + state*table->fRowLen);
if (use8BitsForSafeTable()) {
row->r8.fAccepting = 0;
row->r8.fLookAhead = 0;
row->r8.fTagsIdx = 0;
RBBIStateTableRow8 *r8 = (RBBIStateTableRow8*)row;
r8->fAccepting = 0;
r8->fLookAhead = 0;
r8->fTagsIdx = 0;
for (col=0; col<catCount; col++) {
U_ASSERT(rowString->charAt(col) <= kMaxStateFor8BitsTable);
row->r8.fNextState[col] = static_cast<uint8_t>(rowString->charAt(col));
r8->fNextState[col] = static_cast<uint8_t>(rowString->charAt(col));
}
} else {
row->r16.fAccepting = 0;
Expand Down
21 changes: 20 additions & 1 deletion deps/icu-small/source/common/uloc.cpp
Expand Up @@ -877,6 +877,9 @@ uloc_setKeywordValue(const char* keywordName,
if(U_FAILURE(*status)) {
return -1;
}
if (*status == U_STRING_NOT_TERMINATED_WARNING) {
*status = U_ZERO_ERROR;
}
if (keywordName == NULL || keywordName[0] == 0 || bufferCapacity <= 1) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
Expand Down Expand Up @@ -914,6 +917,7 @@ uloc_setKeywordValue(const char* keywordName,
startSearchHere = (char*)locale_getKeywordsStart(buffer);
if(startSearchHere == NULL || (startSearchHere[1]==0)) {
if(keywordValueLen == 0) { /* no keywords = nothing to remove */
U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING);
return bufLen;
}

Expand All @@ -933,6 +937,7 @@ uloc_setKeywordValue(const char* keywordName,
startSearchHere += keywordNameLen;
*startSearchHere++ = '=';
uprv_strcpy(startSearchHere, keywordValueBuffer);
U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING);
return needLen;
} /* end shortcut - no @ */

Expand Down Expand Up @@ -1047,13 +1052,27 @@ uloc_setKeywordValue(const char* keywordName,
if (!handledInputKeyAndValue || U_FAILURE(*status)) {
/* if input key/value specified removal of a keyword not present in locale, or
* there was an error in CharString.append, leave original locale alone. */
U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING);
return bufLen;
}

// needLen = length of the part before '@'
needLen = (int32_t)(startSearchHere - buffer);
return needLen + updatedKeysAndValues.extract(
// Check to see can we fit the startSearchHere, if not, return
// U_BUFFER_OVERFLOW_ERROR without copy updatedKeysAndValues into it.
// We do this because this API function does not behave like most others:
// It promises never to set a U_STRING_NOT_TERMINATED_WARNING.
// When the contents fits but without the terminating NUL, in this case we need to not change
// the buffer contents and return with a buffer overflow error.
int32_t appendLength = updatedKeysAndValues.length();
if (appendLength >= bufferCapacity - needLen) {
*status = U_BUFFER_OVERFLOW_ERROR;
return needLen + appendLength;
}
needLen += updatedKeysAndValues.extract(
startSearchHere, bufferCapacity - needLen, *status);
U_ASSERT(*status != U_STRING_NOT_TERMINATED_WARNING);
return needLen;
}

/* ### ID parsing implementation **************************************************/
Expand Down
5 changes: 5 additions & 0 deletions deps/icu-small/source/common/unicode/docmain.h
Expand Up @@ -143,6 +143,11 @@
* <td>icu::MessageFormat</td>
* </tr>
* <tr>
* <td>List Formatting</td>
* <td>ulistformatter.h</td>
* <td>icu::ListFormatter</td>
* </tr>
* <tr>
* <td>Number Formatting<br/>(includes currency and unit formatting)</td>
* <td>unumberformatter.h, unum.h</td>
* <td>icu::number::NumberFormatter (ICU 60+) or icu::NumberFormat (older versions)</td>
Expand Down
1 change: 1 addition & 0 deletions deps/icu-small/source/common/unicode/urename.h
Expand Up @@ -1137,6 +1137,7 @@
#define ulocimp_toLanguageTag U_ICU_ENTRY_POINT_RENAME(ulocimp_toLanguageTag)
#define ulocimp_toLegacyKey U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyKey)
#define ulocimp_toLegacyType U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyType)
#define ultag_getTKeyStart U_ICU_ENTRY_POINT_RENAME(ultag_getTKeyStart)
#define ultag_isExtensionSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isExtensionSubtags)
#define ultag_isLanguageSubtag U_ICU_ENTRY_POINT_RENAME(ultag_isLanguageSubtag)
#define ultag_isPrivateuseValueSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isPrivateuseValueSubtags)
Expand Down
6 changes: 3 additions & 3 deletions deps/icu-small/source/common/unicode/uvernum.h
Expand Up @@ -66,7 +66,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.6
*/
#define U_ICU_VERSION_MINOR_NUM 1
#define U_ICU_VERSION_MINOR_NUM 2

/** The current ICU patchlevel version as an integer.
* This value will change in the subsequent releases of ICU
Expand Down Expand Up @@ -139,7 +139,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.4
*/
#define U_ICU_VERSION "68.1"
#define U_ICU_VERSION "68.2"

/**
* The current ICU library major version number as a string, for library name suffixes.
Expand All @@ -158,7 +158,7 @@
/** Data version in ICU4C.
* @internal ICU 4.4 Internal Use Only
**/
#define U_ICU_DATA_VERSION "68.1"
#define U_ICU_DATA_VERSION "68.2"
#endif /* U_HIDE_INTERNAL_API */

/*===========================================================================
Expand Down