Skip to content

Commit 15ffd05

Browse files
committed
tools: update icu to 65.1
Update the version of the bundled ICU (deps/icu-small) to ICU version 65.2. Fixes: nodejs#30211 Fixes: nodejs#29540
1 parent e4812d6 commit 15ffd05

File tree

704 files changed

+17705
-11605
lines changed

Some content is hidden

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

704 files changed

+17705
-11605
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
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
9+

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ UnhandledEngine::findBreaks( UText *text,
7878
int32_t /* startPos */,
7979
int32_t endPos,
8080
UVector32 &/*foundBreaks*/ ) const {
81-
UChar32 c = utext_current32(text);
81+
UChar32 c = utext_current32(text);
8282
while((int32_t)utext_getNativeIndex(text) < endPos && fHandled->contains(c)) {
8383
utext_next32(text); // TODO: recast loop to work with post-increment operations.
8484
c = utext_current32(text);
@@ -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) {
@@ -149,7 +149,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) {
149149
}
150150
}
151151
}
152-
152+
153153
// We didn't find an engine. Create one.
154154
lbe = loadEngineFor(c);
155155
if (lbe != NULL) {
@@ -224,7 +224,7 @@ ICULanguageBreakFactory::loadEngineFor(UChar32 c) {
224224
}
225225

226226
DictionaryMatcher *
227-
ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
227+
ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
228228
UErrorCode status = U_ZERO_ERROR;
229229
// open root from brkitr tree.
230230
UResourceBundle *b = ures_open(U_ICUDATA_BRKITR, "", &status);
@@ -265,7 +265,7 @@ ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
265265
m = new UCharsDictionaryMatcher(characters, file);
266266
}
267267
if (m == NULL) {
268-
// no matcher exists to take ownership - either we are an invalid
268+
// no matcher exists to take ownership - either we are an invalid
269269
// type or memory allocation failed
270270
udata_close(file);
271271
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
119119
// If there is a result, set the valid locale and actual locale, and the kind
120120
if (U_SUCCESS(status) && result != NULL) {
121121
U_LOCALE_BASED(locBased, *(BreakIterator*)result);
122-
locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
122+
locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
123123
actualLocale.data());
124124
}
125125

@@ -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

@@ -299,7 +299,7 @@ static UBool U_CALLCONV breakiterator_cleanup(void) {
299299
U_CDECL_END
300300
U_NAMESPACE_BEGIN
301301

302-
static void U_CALLCONV
302+
static void U_CALLCONV
303303
initService(void) {
304304
gService = new ICUBreakIteratorService();
305305
ucln_common_registerCleanup(UCLN_COMMON_BREAKITERATOR, breakiterator_cleanup);

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/caniter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
208208
goto CleanPartialInitialization;
209209
}
210210

211-
// i should initialy be the number of code units at the
211+
// i should initialy be the number of code units at the
212212
// start of the string
213213
i = U16_LENGTH(source.char32At(0));
214214
//int32_t i = 1;
215215
// find the segments
216-
// This code iterates through the source string and
216+
// This code iterates through the source string and
217217
// extracts segments that end up on a codepoint that
218218
// doesn't start any decompositions. (Analysis is done
219219
// on the NFD form - see above).
@@ -241,7 +241,7 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
241241
for (i = 0; i < current_length; i++) {
242242
current[i] = 0;
243243
}
244-
// for each segment, get all the combinations that can produce
244+
// for each segment, get all the combinations that can produce
245245
// it after NFD normalization
246246
for (i = 0; i < pieces_length; ++i) {
247247
//if (PROGRESS) printf("SEGMENT\n");
@@ -316,7 +316,7 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
316316
if(U_FAILURE(status)) {
317317
return;
318318
}
319-
// The upper remove is destructive. The question is do we have to make a copy, or we don't care about the contents
319+
// The upper remove is destructive. The question is do we have to make a copy, or we don't care about the contents
320320
// of source at this point.
321321

322322
// prefix this character to all of them
@@ -493,9 +493,9 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
493493
}
494494

495495
/**
496-
* See if the decomposition of cp2 is at segment starting at segmentPos
496+
* See if the decomposition of cp2 is at segment starting at segmentPos
497497
* (with canonical rearrangment!)
498-
* If so, take the remainder, and return the equivalents
498+
* If so, take the remainder, and return the equivalents
499499
*/
500500
Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
501501
//Hashtable *CanonicalIterator::extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {

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.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static UMemFreeFn *pFree;
3838
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
3939
#include <stdio.h>
4040
static int n=0;
41-
static long b=0;
41+
static long b=0;
4242
#endif
4343

4444
U_CAPI void * U_EXPORT2

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

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,44 @@ 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()
102101
* Clears any user heap functions from u_setMemoryFunctions()
103102
* Does NOT deallocate any remaining allocated memory.
104103
*/
105-
U_CFUNC UBool
104+
U_CFUNC UBool
106105
cmemory_cleanup(void);
107106

108107
/**

deps/icu-small/source/common/common.rc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#undef APSTUDIO_READONLY_SYMBOLS
1919

2020
/////////////////////////////////////////////////////////////////////////////
21-
//
21+
//
2222

2323
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
2424
#pragma code_page(1252)
@@ -29,17 +29,17 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
2929
// TEXTINCLUDE
3030
//
3131

32-
1 TEXTINCLUDE
32+
1 TEXTINCLUDE
3333
BEGIN
3434
"msvcres.h\0"
3535
END
3636

37-
2 TEXTINCLUDE
37+
2 TEXTINCLUDE
3838
BEGIN
3939
"#include <winresrc.h>\0"
4040
END
4141

42-
3 TEXTINCLUDE
42+
3 TEXTINCLUDE
4343
BEGIN
4444
"\r\n"
4545
"\0"
@@ -107,3 +107,4 @@ END
107107

108108
/////////////////////////////////////////////////////////////////////////////
109109
#endif // not APSTUDIO_INVOKED
110+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CStr::CStr(const UnicodeString &in) {
3030
}
3131
#else
3232
// No conversion available. Convert any invariant characters; substitute '?' for the rest.
33-
// Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
33+
// Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
3434
// whole string because they require that the entire input be invariant.
3535
char buf[2];
3636
for (int i=0; i<in.length(); i = in.moveIndex32(i, 1)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* ICU-internal class CStr, a small helper class to facilitate passing UnicodeStrings
2525
* to functions needing (const char *) strings, such as printf().
2626
*
27-
* It is intended primarily for use in debugging or in tests. Uses platform
27+
* It is intended primarily for use in debugging or in tests. Uses platform
2828
* default code page conversion, which will do the best job possible,
2929
* but may be lossy, depending on the platform.
3030
*

0 commit comments

Comments
 (0)