Skip to content

Commit 0cb7720

Browse files
albertywtargos
authored andcommitted
tools: update icu to 65.1
Update the version of the bundled ICU (deps/icu-small) to ICU version 65.2. Fixes: #30211 Fixes: #29540 PR-URL: #30232 Reviewed-By: Steven R Loomis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
1 parent c440f3f commit 0cb7720

File tree

453 files changed

+11832
-5897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

453 files changed

+11832
-5897
lines changed

deps/icu-small/README-FULL-ICU.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ICU sources - auto generated by shrink-icu-src.py
22

33
This directory contains the ICU subset used by --with-intl=full-icu
4-
It is a strict subset of ICU 64 source files with the following exception(s):
5-
* deps/icu-small/source/data/in/icudt64l.dat.bz2 : compressed data file
4+
It is a strict subset of ICU 65 source files with the following exception(s):
5+
* deps/icu-small/source/data/in/icudt65l.dat.bz2 : compressed data file
66

77

88
To rebuild this directory, see ../../tools/icu/README.md

deps/icu-small/source/common/brkeng.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) {
129129
const LanguageBreakEngine *lbe = NULL;
130130
UErrorCode status = U_ZERO_ERROR;
131131

132-
static UMutex gBreakEngineMutex = U_MUTEX_INITIALIZER;
132+
static UMutex gBreakEngineMutex;
133133
Mutex m(&gBreakEngineMutex);
134134

135135
if (fEngines == NULL) {

deps/icu-small/source/common/brkiter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {}
277277
// defined in ucln_cmn.h
278278
U_NAMESPACE_END
279279

280-
static icu::UInitOnce gInitOnceBrkiter;
280+
static icu::UInitOnce gInitOnceBrkiter = U_INITONCE_INITIALIZER;
281281
static icu::ICULocaleService* gService = NULL;
282282

283283

deps/icu-small/source/common/bytesinkutil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class U_COMMON_API ByteSinkUtil {
5959
ByteSink &sink, uint32_t options, Edits *edits);
6060
};
6161

62-
class CharStringByteSink : public ByteSink {
62+
class U_COMMON_API CharStringByteSink : public ByteSink {
6363
public:
6464
CharStringByteSink(CharString* dest);
6565
~CharStringByteSink() override;

deps/icu-small/source/common/characterproperties.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,16 @@ UBool U_CALLCONV characterproperties_cleanup();
3838
constexpr int32_t NUM_INCLUSIONS = UPROPS_SRC_COUNT + UCHAR_INT_LIMIT - UCHAR_INT_START;
3939

4040
struct Inclusion {
41-
UnicodeSet *fSet;
42-
UInitOnce fInitOnce;
41+
UnicodeSet *fSet = nullptr;
42+
UInitOnce fInitOnce = U_INITONCE_INITIALIZER;
4343
};
4444
Inclusion gInclusions[NUM_INCLUSIONS]; // cached getInclusions()
4545

4646
UnicodeSet *sets[UCHAR_BINARY_LIMIT] = {};
4747

4848
UCPMap *maps[UCHAR_INT_LIMIT - UCHAR_INT_START] = {};
4949

50-
icu::UMutex *cpMutex() {
51-
static icu::UMutex m = U_MUTEX_INITIALIZER;
52-
return &m;
53-
}
50+
icu::UMutex cpMutex;
5451

5552
//----------------------------------------------------------------
5653
// Inclusions list
@@ -361,7 +358,7 @@ u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) {
361358
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
362359
return nullptr;
363360
}
364-
Mutex m(cpMutex());
361+
Mutex m(&cpMutex);
365362
UnicodeSet *set = sets[property];
366363
if (set == nullptr) {
367364
sets[property] = set = makeSet(property, *pErrorCode);
@@ -377,7 +374,7 @@ u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode) {
377374
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
378375
return nullptr;
379376
}
380-
Mutex m(cpMutex());
377+
Mutex m(&cpMutex);
381378
UCPMap *map = maps[property - UCHAR_INT_START];
382379
if (map == nullptr) {
383380
maps[property - UCHAR_INT_START] = map = makeMap(property, *pErrorCode);

deps/icu-small/source/common/charstr.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ CharString& CharString::operator=(CharString&& src) U_NOEXCEPT {
3535
return *this;
3636
}
3737

38+
char *CharString::cloneData(UErrorCode &errorCode) const {
39+
if (U_FAILURE(errorCode)) { return nullptr; }
40+
char *p = static_cast<char *>(uprv_malloc(len + 1));
41+
if (p == nullptr) {
42+
errorCode = U_MEMORY_ALLOCATION_ERROR;
43+
return nullptr;
44+
}
45+
uprv_memcpy(p, buffer.getAlias(), len + 1);
46+
return p;
47+
}
48+
3849
CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) {
3950
if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) {
4051
len=s.len;
@@ -52,6 +63,18 @@ int32_t CharString::lastIndexOf(char c) const {
5263
return -1;
5364
}
5465

66+
bool CharString::contains(StringPiece s) const {
67+
if (s.empty()) { return false; }
68+
const char *p = buffer.getAlias();
69+
int32_t lastStart = len - s.length();
70+
for (int32_t i = 0; i <= lastStart; ++i) {
71+
if (uprv_memcmp(p + i, s.data(), s.length()) == 0) {
72+
return true;
73+
}
74+
}
75+
return false;
76+
}
77+
5578
CharString &CharString::truncate(int32_t newLength) {
5679
if(newLength<0) {
5780
newLength=0;

deps/icu-small/source/common/charstr.h

+14
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,24 @@ class U_COMMON_API CharString : public UMemory {
8282

8383
const char *data() const { return buffer.getAlias(); }
8484
char *data() { return buffer.getAlias(); }
85+
/**
86+
* Allocates length()+1 chars and copies the NUL-terminated data().
87+
* The caller must uprv_free() the result.
88+
*/
89+
char *cloneData(UErrorCode &errorCode) const;
90+
91+
bool operator==(StringPiece other) const {
92+
return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0);
93+
}
94+
bool operator!=(StringPiece other) const {
95+
return !operator==(other);
96+
}
8597

8698
/** @return last index of c, or -1 if c is not in this string */
8799
int32_t lastIndexOf(char c) const;
88100

101+
bool contains(StringPiece s) const;
102+
89103
CharString &clear() { len=0; buffer[0]=0; return *this; }
90104
CharString &truncate(int32_t newLength);
91105

deps/icu-small/source/common/cmemory.h

+22-23
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,37 @@ uprv_free(void *mem);
6464
U_CAPI void * U_EXPORT2
6565
uprv_calloc(size_t num, size_t size) U_MALLOC_ATTR U_ALLOC_SIZE_ATTR2(1,2);
6666

67-
/**
68-
* This should align the memory properly on any machine.
69-
* This is very useful for the safeClone functions.
70-
*/
71-
typedef union {
72-
long t1;
73-
double t2;
74-
void *t3;
75-
} UAlignedMemory;
76-
7767
/**
7868
* Get the least significant bits of a pointer (a memory address).
7969
* For example, with a mask of 3, the macro gets the 2 least significant bits,
8070
* which will be 0 if the pointer is 32-bit (4-byte) aligned.
8171
*
82-
* ptrdiff_t is the most appropriate integer type to cast to.
83-
* size_t should work too, since on most (or all?) platforms it has the same
84-
* width as ptrdiff_t.
72+
* uintptr_t is the most appropriate integer type to cast to.
8573
*/
86-
#define U_POINTER_MASK_LSB(ptr, mask) (((ptrdiff_t)(char *)(ptr)) & (mask))
74+
#define U_POINTER_MASK_LSB(ptr, mask) ((uintptr_t)(ptr) & (mask))
8775

8876
/**
89-
* Get the amount of bytes that a pointer is off by from
90-
* the previous UAlignedMemory-aligned pointer.
91-
*/
92-
#define U_ALIGNMENT_OFFSET(ptr) U_POINTER_MASK_LSB(ptr, sizeof(UAlignedMemory) - 1)
93-
94-
/**
95-
* Get the amount of bytes to add to a pointer
96-
* in order to get the next UAlignedMemory-aligned address.
77+
* Create & return an instance of "type" in statically allocated storage.
78+
* e.g.
79+
* static std::mutex *myMutex = STATIC_NEW(std::mutex);
80+
* To destroy an object created in this way, invoke the destructor explicitly, e.g.
81+
* myMutex->~mutex();
82+
* DO NOT use delete.
83+
* DO NOT use with class UMutex, which has specific support for static instances.
84+
*
85+
* STATIC_NEW is intended for use when
86+
* - We want a static (or global) object.
87+
* - We don't want it to ever be destructed, or to explicitly control destruction,
88+
* to avoid use-after-destruction problems.
89+
* - We want to avoid an ordinary heap allocated object,
90+
* to avoid the possibility of memory allocation failures, and
91+
* to avoid memory leak reports, from valgrind, for example.
92+
* This is defined as a macro rather than a template function because each invocation
93+
* must define distinct static storage for the object being returned.
9794
*/
98-
#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr))
95+
#define STATIC_NEW(type) [] () { \
96+
alignas(type) static char storage[sizeof(type)]; \
97+
return new(storage) type();} ()
9998

10099
/**
101100
* Heap clean up function, called from u_cleanup()

deps/icu-small/source/common/edits.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ UBool Edits::growArray() {
243243
return TRUE;
244244
}
245245

246-
UBool Edits::copyErrorTo(UErrorCode &outErrorCode) {
246+
UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const {
247247
if (U_FAILURE(outErrorCode)) { return TRUE; }
248248
if (U_SUCCESS(errorCode_)) { return FALSE; }
249249
outErrorCode = errorCode_;

deps/icu-small/source/common/filteredbrk.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class SimpleFilteredSentenceBreakIterator : public BreakIterator {
173173
status = U_SAFECLONE_ALLOCATED_WARNING;
174174
return clone();
175175
}
176-
virtual BreakIterator* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); }
176+
virtual SimpleFilteredSentenceBreakIterator* clone() const { return new SimpleFilteredSentenceBreakIterator(*this); }
177177
virtual UClassID getDynamicClassID(void) const { return NULL; }
178178
virtual UBool operator==(const BreakIterator& o) const { if(this==&o) return true; return false; }
179179

deps/icu-small/source/common/localebuilder.cpp

+46-14
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,18 @@ _isKeywordValue(const char* key, const char* value, int32_t value_len)
157157
}
158158

159159
static void
160-
_copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& errorCode)
160+
_copyExtensions(const Locale& from, icu::StringEnumeration *keywords,
161+
Locale& to, bool validate, UErrorCode& errorCode)
161162
{
162163
if (U_FAILURE(errorCode)) { return; }
163-
LocalPointer<icu::StringEnumeration> iter(from.createKeywords(errorCode));
164-
if (U_FAILURE(errorCode) || iter.isNull()) { return; }
164+
LocalPointer<icu::StringEnumeration> ownedKeywords;
165+
if (keywords == nullptr) {
166+
ownedKeywords.adoptInstead(from.createKeywords(errorCode));
167+
if (U_FAILURE(errorCode) || ownedKeywords.isNull()) { return; }
168+
keywords = ownedKeywords.getAlias();
169+
}
165170
const char* key;
166-
while ((key = iter->next(nullptr, errorCode)) != nullptr) {
171+
while ((key = keywords->next(nullptr, errorCode)) != nullptr) {
167172
CharString value;
168173
CharStringByteSink sink(&value);
169174
from.getKeywordValue(key, sink, errorCode);
@@ -176,34 +181,34 @@ _copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& error
176181
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
177182
return;
178183
}
179-
to->setKeywordValue(key, value.data(), errorCode);
184+
to.setKeywordValue(key, value.data(), errorCode);
180185
if (U_FAILURE(errorCode)) { return; }
181186
}
182187
}
183188

184189
void static
185-
_clearUAttributesAndKeyType(Locale* locale, UErrorCode& errorCode)
190+
_clearUAttributesAndKeyType(Locale& locale, UErrorCode& errorCode)
186191
{
187192
// Clear Unicode attributes
188-
locale->setKeywordValue(kAttributeKey, "", errorCode);
193+
locale.setKeywordValue(kAttributeKey, "", errorCode);
189194

190195
// Clear all Unicode keyword values
191-
LocalPointer<icu::StringEnumeration> iter(locale->createUnicodeKeywords(errorCode));
196+
LocalPointer<icu::StringEnumeration> iter(locale.createUnicodeKeywords(errorCode));
192197
if (U_FAILURE(errorCode) || iter.isNull()) { return; }
193198
const char* key;
194199
while ((key = iter->next(nullptr, errorCode)) != nullptr) {
195-
locale->setUnicodeKeywordValue(key, nullptr, errorCode);
200+
locale.setUnicodeKeywordValue(key, nullptr, errorCode);
196201
}
197202
}
198203

199204
static void
200-
_setUnicodeExtensions(Locale* locale, const CharString& value, UErrorCode& errorCode)
205+
_setUnicodeExtensions(Locale& locale, const CharString& value, UErrorCode& errorCode)
201206
{
202207
// Add the unicode extensions to extensions_
203208
CharString locale_str("und-u-", errorCode);
204209
locale_str.append(value, errorCode);
205210
_copyExtensions(
206-
Locale::forLanguageTag(locale_str.data(), errorCode),
211+
Locale::forLanguageTag(locale_str.data(), errorCode), nullptr,
207212
locale, false, errorCode);
208213
}
209214

@@ -235,10 +240,10 @@ LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value)
235240
status_);
236241
return *this;
237242
}
238-
_clearUAttributesAndKeyType(extensions_, status_);
243+
_clearUAttributesAndKeyType(*extensions_, status_);
239244
if (U_FAILURE(status_)) { return *this; }
240245
if (!value.empty()) {
241-
_setUnicodeExtensions(extensions_, value_str, status_);
246+
_setUnicodeExtensions(*extensions_, value_str, status_);
242247
}
243248
return *this;
244249
}
@@ -401,6 +406,24 @@ Locale makeBogusLocale() {
401406
return bogus;
402407
}
403408

409+
void LocaleBuilder::copyExtensionsFrom(const Locale& src, UErrorCode& errorCode)
410+
{
411+
if (U_FAILURE(errorCode)) { return; }
412+
LocalPointer<icu::StringEnumeration> keywords(src.createKeywords(errorCode));
413+
if (U_FAILURE(errorCode) || keywords.isNull() || keywords->count(errorCode) == 0) {
414+
// Error, or no extensions to copy.
415+
return;
416+
}
417+
if (extensions_ == nullptr) {
418+
extensions_ = new Locale();
419+
if (extensions_ == nullptr) {
420+
status_ = U_MEMORY_ALLOCATION_ERROR;
421+
return;
422+
}
423+
}
424+
_copyExtensions(src, keywords.getAlias(), *extensions_, false, errorCode);
425+
}
426+
404427
Locale LocaleBuilder::build(UErrorCode& errorCode)
405428
{
406429
if (U_FAILURE(errorCode)) {
@@ -425,12 +448,21 @@ Locale LocaleBuilder::build(UErrorCode& errorCode)
425448
}
426449
Locale product(locale_str.data());
427450
if (extensions_ != nullptr) {
428-
_copyExtensions(*extensions_, &product, true, errorCode);
451+
_copyExtensions(*extensions_, nullptr, product, true, errorCode);
429452
}
430453
if (U_FAILURE(errorCode)) {
431454
return makeBogusLocale();
432455
}
433456
return product;
434457
}
435458

459+
UBool LocaleBuilder::copyErrorTo(UErrorCode &outErrorCode) const {
460+
if (U_FAILURE(outErrorCode)) {
461+
// Do not overwrite the older error code
462+
return TRUE;
463+
}
464+
outErrorCode = status_;
465+
return U_FAILURE(outErrorCode);
466+
}
467+
436468
U_NAMESPACE_END

0 commit comments

Comments
 (0)