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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 23 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 22 additions & 23 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)