Issue #1971 - Part 2: Update ICU source to 63.2.

This commit is contained in:
Job Bautista 2022-07-24 21:03:27 +08:00 committed by roytam1
commit 1e69214382
3160 changed files with 275815 additions and 234203 deletions

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -15,8 +15,10 @@
#if !UCONFIG_NO_FORMATTING
#include "unicode/strenum.h"
#include "unicode/ustring.h"
#include "unicode/timezone.h"
#include "unicode/utf16.h"
#include "tznames_impl.h"
#include "cmemory.h"
@ -68,7 +70,7 @@ enum UTimeZoneNameTypeIndex {
UTZNM_INDEX_SHORT_DAYLIGHT,
UTZNM_INDEX_COUNT
};
static const UChar* EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
static const UChar* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
U_CDECL_BEGIN
static UBool U_CALLCONV tzdbTimeZoneNames_cleanup(void) {
@ -410,25 +412,29 @@ TextTrieMap::search(CharacterNode *node, const UnicodeString &text, int32_t star
return;
}
}
UChar32 c = text.char32At(index);
if (fIgnoreCase) {
// size of character may grow after fold operation
UnicodeString tmp(c);
// for folding we need to get a complete code point.
// size of character may grow after fold operation;
// then we need to get result as UTF16 code units.
UChar32 c32 = text.char32At(index);
index += U16_LENGTH(c32);
UnicodeString tmp(c32);
tmp.foldCase();
int32_t tmpidx = 0;
while (tmpidx < tmp.length()) {
c = tmp.char32At(tmpidx);
UChar c = tmp.charAt(tmpidx++);
node = getChildNode(node, c);
if (node == NULL) {
break;
}
tmpidx = tmp.moveIndex32(tmpidx, 1);
}
} else {
// here we just get the next UTF16 code unit
UChar c = text.charAt(index++);
node = getChildNode(node, c);
}
if (node != NULL) {
search(node, text, start, index+1, handler, status);
search(node, text, start, index, handler, status);
}
}
@ -1069,7 +1075,7 @@ TimeZoneNamesImpl::loadStrings(const UnicodeString& tzCanonicalID, UErrorCode& s
U_ASSERT(!mzIDs.isNull());
const UnicodeString *mzID;
while ((mzID = mzIDs->snext(status)) && U_SUCCESS(status)) {
while (((mzID = mzIDs->snext(status)) != NULL) && U_SUCCESS(status)) {
loadMetaZoneNames(*mzID, status);
}
}
@ -1279,7 +1285,7 @@ static void mergeTimeZoneKey(const UnicodeString& mzID, char* result) {
char mzIdChar[ZID_KEY_MAX + 1];
int32_t keyLen;
int32_t prefixLen = uprv_strlen(gMZPrefix);
int32_t prefixLen = static_cast<int32_t>(uprv_strlen(gMZPrefix));
keyLen = mzID.extract(0, mzID.length(), mzIdChar, ZID_KEY_MAX + 1, US_INV);
uprv_memcpy((void *)result, (void *)gMZPrefix, prefixLen);
uprv_memcpy((void *)(result + prefixLen), (void *)mzIdChar, keyLen);
@ -1447,7 +1453,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
virtual ~ZoneStringsLoader();
void* createKey(const char* key, UErrorCode& status) {
int32_t len = sizeof(char) * (uprv_strlen(key) + 1);
int32_t len = sizeof(char) * (static_cast<int32_t>(uprv_strlen(key)) + 1);
char* newKey = (char*) uprv_malloc(len);
if (newKey == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
@ -1463,7 +1469,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
}
UnicodeString mzIDFromKey(const char* key) {
return UnicodeString(key + MZ_PREFIX_LEN, uprv_strlen(key) - MZ_PREFIX_LEN, US_INV);
return UnicodeString(key + MZ_PREFIX_LEN, static_cast<int32_t>(uprv_strlen(key)) - MZ_PREFIX_LEN, US_INV);
}
UnicodeString tzIDFromKey(const char* key) {
@ -1650,7 +1656,7 @@ void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) {
StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(
UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
if (U_SUCCESS(status)) {
while ((id = tzIDs->snext(status))) {
while ((id = tzIDs->snext(status)) != NULL) {
if (U_FAILURE(status)) {
break;
}
@ -1938,8 +1944,8 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod
// metazone mapping for "CST" is America_Central,
// but if region is one of CN/MO/TW, "CST" is parsed
// as metazone China (China Standard Time).
for (int32_t i = 0; i < ninfo->nRegions; i++) {
const char *region = ninfo->parseRegions[i];
for (int32_t j = 0; j < ninfo->nRegions; j++) {
const char *region = ninfo->parseRegions[j];
if (uprv_strcmp(fRegion, region) == 0) {
match = ninfo;
matchRegion = TRUE;
@ -2053,8 +2059,11 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
const UnicodeString *mzID;
StringEnumeration *mzIDs = TimeZoneNamesImpl::_getAvailableMetaZoneIDs(status);
if (U_SUCCESS(status)) {
while ((mzID = mzIDs->snext(status)) && U_SUCCESS(status)) {
while ((mzID = mzIDs->snext(status)) != 0 && U_SUCCESS(status)) {
const TZDBNames *names = TZDBTimeZoneNames::getMetaZoneNames(*mzID, status);
if (U_FAILURE(status)) {
break;
}
if (names == NULL) {
continue;
}
@ -2119,7 +2128,7 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale)
: fLocale(locale) {
UBool useWorld = TRUE;
const char* region = fLocale.getCountry();
int32_t regionLen = uprv_strlen(region);
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
UErrorCode status = U_ZERO_ERROR;
char loc[ULOC_FULLNAME_CAPACITY];
@ -2186,9 +2195,11 @@ TZDBTimeZoneNames::getMetaZoneDisplayName(const UnicodeString& mzID,
UErrorCode status = U_ZERO_ERROR;
const TZDBNames *tzdbNames = TZDBTimeZoneNames::getMetaZoneNames(mzID, status);
if (U_SUCCESS(status)) {
const UChar *s = tzdbNames->getName(type);
if (s != NULL) {
name.setTo(TRUE, s, -1);
if (tzdbNames != NULL) {
const UChar *s = tzdbNames->getName(type);
if (s != NULL) {
name.setTo(TRUE, s, -1);
}
}
}