Skip to content

Commit

Permalink
tools: update icu to 65.1
Browse files Browse the repository at this point in the history
Update the version of the bundled ICU (deps/icu-small) to ICU version
65.2.

Fixes: nodejs#30211
Fixes: nodejs#29540
  • Loading branch information
albertyw committed Nov 22, 2019
1 parent e4812d6 commit 15ffd05
Show file tree
Hide file tree
Showing 704 changed files with 17,705 additions and 11,605 deletions.
5 changes: 3 additions & 2 deletions deps/icu-small/README-FULL-ICU.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ICU sources - auto generated by shrink-icu-src.py

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


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

10 changes: 5 additions & 5 deletions deps/icu-small/source/common/brkeng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ UnhandledEngine::findBreaks( UText *text,
int32_t /* startPos */,
int32_t endPos,
UVector32 &/*foundBreaks*/ ) const {
UChar32 c = utext_current32(text);
UChar32 c = utext_current32(text);
while((int32_t)utext_getNativeIndex(text) < endPos && fHandled->contains(c)) {
utext_next32(text); // TODO: recast loop to work with post-increment operations.
c = utext_current32(text);
Expand Down Expand Up @@ -129,7 +129,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) {
const LanguageBreakEngine *lbe = NULL;
UErrorCode status = U_ZERO_ERROR;

static UMutex gBreakEngineMutex = U_MUTEX_INITIALIZER;
static UMutex gBreakEngineMutex;
Mutex m(&gBreakEngineMutex);

if (fEngines == NULL) {
Expand All @@ -149,7 +149,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) {
}
}
}

// We didn't find an engine. Create one.
lbe = loadEngineFor(c);
if (lbe != NULL) {
Expand Down Expand Up @@ -224,7 +224,7 @@ ICULanguageBreakFactory::loadEngineFor(UChar32 c) {
}

DictionaryMatcher *
ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
UErrorCode status = U_ZERO_ERROR;
// open root from brkitr tree.
UResourceBundle *b = ures_open(U_ICUDATA_BRKITR, "", &status);
Expand Down Expand Up @@ -265,7 +265,7 @@ ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
m = new UCharsDictionaryMatcher(characters, file);
}
if (m == NULL) {
// no matcher exists to take ownership - either we are an invalid
// no matcher exists to take ownership - either we are an invalid
// type or memory allocation failed
udata_close(file);
}
Expand Down
6 changes: 3 additions & 3 deletions deps/icu-small/source/common/brkiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
// If there is a result, set the valid locale and actual locale, and the kind
if (U_SUCCESS(status) && result != NULL) {
U_LOCALE_BASED(locBased, *(BreakIterator*)result);
locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
actualLocale.data());
}

Expand Down Expand Up @@ -277,7 +277,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {}
// defined in ucln_cmn.h
U_NAMESPACE_END

static icu::UInitOnce gInitOnceBrkiter;
static icu::UInitOnce gInitOnceBrkiter = U_INITONCE_INITIALIZER;
static icu::ICULocaleService* gService = NULL;


Expand All @@ -299,7 +299,7 @@ static UBool U_CALLCONV breakiterator_cleanup(void) {
U_CDECL_END
U_NAMESPACE_BEGIN

static void U_CALLCONV
static void U_CALLCONV
initService(void) {
gService = new ICUBreakIteratorService();
ucln_common_registerCleanup(UCLN_COMMON_BREAKITERATOR, breakiterator_cleanup);
Expand Down
2 changes: 1 addition & 1 deletion deps/icu-small/source/common/bytesinkutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class U_COMMON_API ByteSinkUtil {
ByteSink &sink, uint32_t options, Edits *edits);
};

class CharStringByteSink : public ByteSink {
class U_COMMON_API CharStringByteSink : public ByteSink {
public:
CharStringByteSink(CharString* dest);
~CharStringByteSink() override;
Expand Down
12 changes: 6 additions & 6 deletions deps/icu-small/source/common/caniter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
goto CleanPartialInitialization;
}

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

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

/**
* See if the decomposition of cp2 is at segment starting at segmentPos
* See if the decomposition of cp2 is at segment starting at segmentPos
* (with canonical rearrangment!)
* If so, take the remainder, and return the equivalents
* If so, take the remainder, and return the equivalents
*/
Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
//Hashtable *CanonicalIterator::extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
Expand Down
13 changes: 5 additions & 8 deletions deps/icu-small/source/common/characterproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,16 @@ UBool U_CALLCONV characterproperties_cleanup();
constexpr int32_t NUM_INCLUSIONS = UPROPS_SRC_COUNT + UCHAR_INT_LIMIT - UCHAR_INT_START;

struct Inclusion {
UnicodeSet *fSet;
UInitOnce fInitOnce;
UnicodeSet *fSet = nullptr;
UInitOnce fInitOnce = U_INITONCE_INITIALIZER;
};
Inclusion gInclusions[NUM_INCLUSIONS]; // cached getInclusions()

UnicodeSet *sets[UCHAR_BINARY_LIMIT] = {};

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

icu::UMutex *cpMutex() {
static icu::UMutex m = U_MUTEX_INITIALIZER;
return &m;
}
icu::UMutex cpMutex;

//----------------------------------------------------------------
// Inclusions list
Expand Down Expand Up @@ -361,7 +358,7 @@ u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return nullptr;
}
Mutex m(cpMutex());
Mutex m(&cpMutex);
UnicodeSet *set = sets[property];
if (set == nullptr) {
sets[property] = set = makeSet(property, *pErrorCode);
Expand All @@ -377,7 +374,7 @@ u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return nullptr;
}
Mutex m(cpMutex());
Mutex m(&cpMutex);
UCPMap *map = maps[property - UCHAR_INT_START];
if (map == nullptr) {
maps[property - UCHAR_INT_START] = map = makeMap(property, *pErrorCode);
Expand Down
23 changes: 23 additions & 0 deletions deps/icu-small/source/common/charstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ CharString& CharString::operator=(CharString&& src) U_NOEXCEPT {
return *this;
}

char *CharString::cloneData(UErrorCode &errorCode) const {
if (U_FAILURE(errorCode)) { return nullptr; }
char *p = static_cast<char *>(uprv_malloc(len + 1));
if (p == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
}
uprv_memcpy(p, buffer.getAlias(), len + 1);
return p;
}

CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) {
if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) {
len=s.len;
Expand All @@ -52,6 +63,18 @@ int32_t CharString::lastIndexOf(char c) const {
return -1;
}

bool CharString::contains(StringPiece s) const {
if (s.empty()) { return false; }
const char *p = buffer.getAlias();
int32_t lastStart = len - s.length();
for (int32_t i = 0; i <= lastStart; ++i) {
if (uprv_memcmp(p + i, s.data(), s.length()) == 0) {
return true;
}
}
return false;
}

CharString &CharString::truncate(int32_t newLength) {
if(newLength<0) {
newLength=0;
Expand Down
14 changes: 14 additions & 0 deletions deps/icu-small/source/common/charstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,24 @@ class U_COMMON_API CharString : public UMemory {

const char *data() const { return buffer.getAlias(); }
char *data() { return buffer.getAlias(); }
/**
* Allocates length()+1 chars and copies the NUL-terminated data().
* The caller must uprv_free() the result.
*/
char *cloneData(UErrorCode &errorCode) const;

bool operator==(StringPiece other) const {
return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0);
}
bool operator!=(StringPiece other) const {
return !operator==(other);
}

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

bool contains(StringPiece s) const;

CharString &clear() { len=0; buffer[0]=0; return *this; }
CharString &truncate(int32_t newLength);

Expand Down
2 changes: 1 addition & 1 deletion deps/icu-small/source/common/cmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static UMemFreeFn *pFree;
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
#include <stdio.h>
static int n=0;
static long b=0;
static long b=0;
#endif

U_CAPI void * U_EXPORT2
Expand Down
47 changes: 23 additions & 24 deletions deps/icu-small/source/common/cmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,45 +64,44 @@ uprv_free(void *mem);
U_CAPI void * U_EXPORT2
uprv_calloc(size_t num, size_t size) U_MALLOC_ATTR U_ALLOC_SIZE_ATTR2(1,2);

/**
* This should align the memory properly on any machine.
* This is very useful for the safeClone functions.
*/
typedef union {
long t1;
double t2;
void *t3;
} UAlignedMemory;

/**
* Get the least significant bits of a pointer (a memory address).
* For example, with a mask of 3, the macro gets the 2 least significant bits,
* which will be 0 if the pointer is 32-bit (4-byte) aligned.
*
* ptrdiff_t is the most appropriate integer type to cast to.
* size_t should work too, since on most (or all?) platforms it has the same
* width as ptrdiff_t.
* uintptr_t is the most appropriate integer type to cast to.
*/
#define U_POINTER_MASK_LSB(ptr, mask) (((ptrdiff_t)(char *)(ptr)) & (mask))
#define U_POINTER_MASK_LSB(ptr, mask) ((uintptr_t)(ptr) & (mask))

/**
* Get the amount of bytes that a pointer is off by from
* the previous UAlignedMemory-aligned pointer.
*/
#define U_ALIGNMENT_OFFSET(ptr) U_POINTER_MASK_LSB(ptr, sizeof(UAlignedMemory) - 1)

/**
* Get the amount of bytes to add to a pointer
* in order to get the next UAlignedMemory-aligned address.
* Create & return an instance of "type" in statically allocated storage.
* e.g.
* static std::mutex *myMutex = STATIC_NEW(std::mutex);
* To destroy an object created in this way, invoke the destructor explicitly, e.g.
* myMutex->~mutex();
* DO NOT use delete.
* DO NOT use with class UMutex, which has specific support for static instances.
*
* STATIC_NEW is intended for use when
* - We want a static (or global) object.
* - We don't want it to ever be destructed, or to explicitly control destruction,
* to avoid use-after-destruction problems.
* - We want to avoid an ordinary heap allocated object,
* to avoid the possibility of memory allocation failures, and
* to avoid memory leak reports, from valgrind, for example.
* This is defined as a macro rather than a template function because each invocation
* must define distinct static storage for the object being returned.
*/
#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr))
#define STATIC_NEW(type) [] () { \
alignas(type) static char storage[sizeof(type)]; \
return new(storage) type();} ()

/**
* Heap clean up function, called from u_cleanup()
* Clears any user heap functions from u_setMemoryFunctions()
* Does NOT deallocate any remaining allocated memory.
*/
U_CFUNC UBool
U_CFUNC UBool
cmemory_cleanup(void);

/**
Expand Down
9 changes: 5 additions & 4 deletions deps/icu-small/source/common/common.rc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
//
//

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
Expand All @@ -29,17 +29,17 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// TEXTINCLUDE
//

1 TEXTINCLUDE
1 TEXTINCLUDE
BEGIN
"msvcres.h\0"
END

2 TEXTINCLUDE
2 TEXTINCLUDE
BEGIN
"#include <winresrc.h>\0"
END

3 TEXTINCLUDE
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
Expand Down Expand Up @@ -107,3 +107,4 @@ END

/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

2 changes: 1 addition & 1 deletion deps/icu-small/source/common/cstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CStr::CStr(const UnicodeString &in) {
}
#else
// No conversion available. Convert any invariant characters; substitute '?' for the rest.
// Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
// Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
// whole string because they require that the entire input be invariant.
char buf[2];
for (int i=0; i<in.length(); i = in.moveIndex32(i, 1)) {
Expand Down
2 changes: 1 addition & 1 deletion deps/icu-small/source/common/cstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* ICU-internal class CStr, a small helper class to facilitate passing UnicodeStrings
* to functions needing (const char *) strings, such as printf().
*
* It is intended primarily for use in debugging or in tests. Uses platform
* It is intended primarily for use in debugging or in tests. Uses platform
* default code page conversion, which will do the best job possible,
* but may be lossy, depending on the platform.
*
Expand Down
Loading

0 comments on commit 15ffd05

Please sign in to comment.