diff --git a/deps/icu-small/README-FULL-ICU.txt b/deps/icu-small/README-FULL-ICU.txt index d954e58a5fa0e3..7a351738a584f8 100644 --- a/deps/icu-small/README-FULL-ICU.txt +++ b/deps/icu-small/README-FULL-ICU.txt @@ -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 + diff --git a/deps/icu-small/source/common/brkeng.cpp b/deps/icu-small/source/common/brkeng.cpp index 42771b3617747d..78492db66201f1 100644 --- a/deps/icu-small/source/common/brkeng.cpp +++ b/deps/icu-small/source/common/brkeng.cpp @@ -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); @@ -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) { @@ -149,7 +149,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) { } } } - + // We didn't find an engine. Create one. lbe = loadEngineFor(c); if (lbe != NULL) { @@ -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); @@ -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); } diff --git a/deps/icu-small/source/common/brkiter.cpp b/deps/icu-small/source/common/brkiter.cpp index 23e0cc3c153392..3d1366a6688009 100644 --- a/deps/icu-small/source/common/brkiter.cpp +++ b/deps/icu-small/source/common/brkiter.cpp @@ -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()); } @@ -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; @@ -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); diff --git a/deps/icu-small/source/common/bytesinkutil.h b/deps/icu-small/source/common/bytesinkutil.h index 69e4cbcd263932..6808fbe6777837 100644 --- a/deps/icu-small/source/common/bytesinkutil.h +++ b/deps/icu-small/source/common/bytesinkutil.h @@ -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; diff --git a/deps/icu-small/source/common/caniter.cpp b/deps/icu-small/source/common/caniter.cpp index d57c64247fc591..b28acfc84ee3b0 100644 --- a/deps/icu-small/source/common/caniter.cpp +++ b/deps/icu-small/source/common/caniter.cpp @@ -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). @@ -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"); @@ -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 @@ -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) { diff --git a/deps/icu-small/source/common/characterproperties.cpp b/deps/icu-small/source/common/characterproperties.cpp index 5a57364375b372..7b50a4e2051b97 100644 --- a/deps/icu-small/source/common/characterproperties.cpp +++ b/deps/icu-small/source/common/characterproperties.cpp @@ -38,8 +38,8 @@ 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() @@ -47,10 +47,7 @@ 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 @@ -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); @@ -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); diff --git a/deps/icu-small/source/common/charstr.cpp b/deps/icu-small/source/common/charstr.cpp index 852cc539457760..dda29dac63273c 100644 --- a/deps/icu-small/source/common/charstr.cpp +++ b/deps/icu-small/source/common/charstr.cpp @@ -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(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; @@ -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; diff --git a/deps/icu-small/source/common/charstr.h b/deps/icu-small/source/common/charstr.h index 1a97e01988f991..23b950ed6ecc76 100644 --- a/deps/icu-small/source/common/charstr.h +++ b/deps/icu-small/source/common/charstr.h @@ -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); diff --git a/deps/icu-small/source/common/cmemory.cpp b/deps/icu-small/source/common/cmemory.cpp index 0b7e432c4dee46..663c1411e4cb3b 100644 --- a/deps/icu-small/source/common/cmemory.cpp +++ b/deps/icu-small/source/common/cmemory.cpp @@ -38,7 +38,7 @@ static UMemFreeFn *pFree; #if U_DEBUG && defined(UPRV_MALLOC_COUNT) #include static int n=0; -static long b=0; +static long b=0; #endif U_CAPI void * U_EXPORT2 diff --git a/deps/icu-small/source/common/cmemory.h b/deps/icu-small/source/common/cmemory.h index f501b20a14ca13..7f7fd8d08642d5 100644 --- a/deps/icu-small/source/common/cmemory.h +++ b/deps/icu-small/source/common/cmemory.h @@ -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); /** diff --git a/deps/icu-small/source/common/common.rc b/deps/icu-small/source/common/common.rc index 5c723a27c52820..020abacc0d81fe 100644 --- a/deps/icu-small/source/common/common.rc +++ b/deps/icu-small/source/common/common.rc @@ -18,7 +18,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// +// LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252) @@ -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 \0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -107,3 +107,4 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + diff --git a/deps/icu-small/source/common/cstr.cpp b/deps/icu-small/source/common/cstr.cpp index 0114434329ad7e..24654f8fc22897 100644 --- a/deps/icu-small/source/common/cstr.cpp +++ b/deps/icu-small/source/common/cstr.cpp @@ -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=2 && radix<=16); uval = (uint32_t) v; if(v<0 && radix == 10) { /* Only in base 10 do we conside numbers to be signed. */ - uval = (uint32_t)(-v); + uval = (uint32_t)(-v); buffer[length++] = '-'; } - + tbx = sizeof(tbuf)-1; tbuf[tbx] = 0; /* We are generating the digits backwards. Null term the end. */ do { @@ -177,7 +177,7 @@ T_CString_integerToString(char* buffer, int32_t v, int32_t radix) tbuf[--tbx] = (char)(T_CString_itosOffset(digit)); uval = uval / radix; } while (uval != 0); - + /* copy converted number into user buffer */ uprv_strcpy(buffer+length, tbuf+tbx); length += sizeof(tbuf) - tbx -1; @@ -199,15 +199,15 @@ T_CString_int64ToString(char* buffer, int64_t v, uint32_t radix) uint8_t digit; int32_t length = 0; uint64_t uval; - + U_ASSERT(radix>=2 && radix<=16); uval = (uint64_t) v; if(v<0 && radix == 10) { /* Only in base 10 do we conside numbers to be signed. */ - uval = (uint64_t)(-v); + uval = (uint64_t)(-v); buffer[length++] = '-'; } - + tbx = sizeof(tbuf)-1; tbuf[tbx] = 0; /* We are generating the digits backwards. Null term the end. */ do { @@ -215,7 +215,7 @@ T_CString_int64ToString(char* buffer, int64_t v, uint32_t radix) tbuf[--tbx] = (char)(T_CString_itosOffset(digit)); uval = uval / radix; } while (uval != 0); - + /* copy converted number into user buffer */ uprv_strcpy(buffer+length, tbuf+tbx); length += sizeof(tbuf) - tbx -1; @@ -331,7 +331,7 @@ uprv_strndup(const char *src, int32_t n) { dup = uprv_strdup(src); } else { dup = (char*)uprv_malloc(n+1); - if (dup) { + if (dup) { uprv_memcpy(dup, src, n); dup[n] = 0; } diff --git a/deps/icu-small/source/common/cwchar.cpp b/deps/icu-small/source/common/cwchar.cpp index 4fd531114e8df8..20c7d71e0f0769 100644 --- a/deps/icu-small/source/common/cwchar.cpp +++ b/deps/icu-small/source/common/cwchar.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ****************************************************************************** * * Copyright (C) 2001, International Business Machines @@ -52,3 +52,4 @@ U_CAPI size_t uprv_wcslen(const wchar_t *src) { } #endif + diff --git a/deps/icu-small/source/common/cwchar.h b/deps/icu-small/source/common/cwchar.h index 939eb599d69f8f..8fd041a1b9c568 100644 --- a/deps/icu-small/source/common/cwchar.h +++ b/deps/icu-small/source/common/cwchar.h @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ****************************************************************************** * * Copyright (C) 2001, International Business Machines @@ -42,11 +42,11 @@ # define uprv_wcscat wcscat # define uprv_wcslen wcslen #else -U_CAPI wchar_t* U_EXPORT2 +U_CAPI wchar_t* U_EXPORT2 uprv_wcscpy(wchar_t *dst, const wchar_t *src); -U_CAPI wchar_t* U_EXPORT2 +U_CAPI wchar_t* U_EXPORT2 uprv_wcscat(wchar_t *dst, const wchar_t *src); -U_CAPI size_t U_EXPORT2 +U_CAPI size_t U_EXPORT2 uprv_wcslen(const wchar_t *src); #endif diff --git a/deps/icu-small/source/common/dictbe.cpp b/deps/icu-small/source/common/dictbe.cpp index 6ceba21a244047..c769138ae4b391 100644 --- a/deps/icu-small/source/common/dictbe.cpp +++ b/deps/icu-small/source/common/dictbe.cpp @@ -67,7 +67,7 @@ DictionaryBreakEngine::findBreaks( UText *text, rangeEnd = current; result = divideUpDictionaryRange(text, rangeStart, rangeEnd, foundBreaks); utext_setNativeIndex(text, current); - + return result; } @@ -105,24 +105,24 @@ class PossibleWord { public: PossibleWord() : count(0), prefix(0), offset(-1), mark(0), current(0) {} ~PossibleWord() {} - + // Fill the list of candidates if needed, select the longest, and return the number found int32_t candidates( UText *text, DictionaryMatcher *dict, int32_t rangeEnd ); - + // Select the currently marked candidate, point after it in the text, and invalidate self int32_t acceptMarked( UText *text ); - + // Back up from the current candidate to the next shorter one; return TRUE if that exists // and point the text after it UBool backUp( UText *text ); - + // Return the longest prefix this candidate location shares with a dictionary word // Return value is in code points. int32_t longestPrefix() { return prefix; } - + // Mark the current candidate as the one we like void markCurrent() { mark = current; } - + // Get length in code points of the marked word. int32_t markedCPLength() { return cpLengths[mark]; } }; @@ -238,16 +238,16 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, int32_t current; UErrorCode status = U_ZERO_ERROR; PossibleWord words[THAI_LOOKAHEAD]; - + utext_setNativeIndex(text, rangeStart); - + while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) { cpWordLength = 0; cuWordLength = 0; // Look for candidate words at the current position int32_t candidates = words[wordsFound%THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); - + // If we found exactly one, use that if (candidates == 1) { cuWordLength = words[wordsFound % THAI_LOOKAHEAD].acceptMarked(text); @@ -268,12 +268,12 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, words[wordsFound%THAI_LOOKAHEAD].markCurrent(); wordsMatched = 2; } - + // If we're already at the end of the range, we're done if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { goto foundBest; } - + // See if any of the possible second words is followed by a third word do { // If we find a third word, stop right away @@ -292,13 +292,13 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, cpWordLength = words[wordsFound % THAI_LOOKAHEAD].markedCPLength(); wordsFound += 1; } - + // We come here after having either found a word or not. We look ahead to the // next word. If it's not a dictionary word, we will combine it with the word we // just found (if there is one), but only if the preceding word does not exceed // the threshold. // The text iterator should now be positioned at the end of the word we found. - + UChar32 uc = 0; if ((int32_t)utext_getNativeIndex(text) < rangeEnd && cpWordLength < THAI_ROOT_COMBINE_THRESHOLD) { // if it is a dictionary word, do nothing. If it isn't, then if there is @@ -334,12 +334,12 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, } } } - + // Bump the word count if there wasn't already one if (cuWordLength <= 0) { wordsFound += 1; } - + // Update the length with the passed-over characters cuWordLength += chars; } @@ -348,14 +348,14 @@ ThaiBreakEngine::divideUpDictionaryRange( UText *text, utext_setNativeIndex(text, current+cuWordLength); } } - + // Never stop before a combining mark. int32_t currPos; while ((currPos = (int32_t)utext_getNativeIndex(text)) < rangeEnd && fMarkSet.contains(utext_current32(text))) { utext_next32(text); cuWordLength += (int32_t)utext_getNativeIndex(text) - currPos; } - + // Look ahead for possible suffixes if a dictionary word does not follow. // We do this in code rather than using a rule so that the heuristic // resynch continues to function. For example, one of the suffix characters @@ -473,16 +473,16 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, int32_t current; UErrorCode status = U_ZERO_ERROR; PossibleWord words[LAO_LOOKAHEAD]; - + utext_setNativeIndex(text, rangeStart); - + while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) { cuWordLength = 0; cpWordLength = 0; // Look for candidate words at the current position int32_t candidates = words[wordsFound%LAO_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); - + // If we found exactly one, use that if (candidates == 1) { cuWordLength = words[wordsFound % LAO_LOOKAHEAD].acceptMarked(text); @@ -503,12 +503,12 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, words[wordsFound%LAO_LOOKAHEAD].markCurrent(); wordsMatched = 2; } - + // If we're already at the end of the range, we're done if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { goto foundBest; } - + // See if any of the possible second words is followed by a third word do { // If we find a third word, stop right away @@ -526,7 +526,7 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, cpWordLength = words[wordsFound % LAO_LOOKAHEAD].markedCPLength(); wordsFound += 1; } - + // We come here after having either found a word or not. We look ahead to the // next word. If it's not a dictionary word, we will combine it withe the word we // just found (if there is one), but only if the preceding word does not exceed @@ -564,12 +564,12 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, } } } - + // Bump the word count if there wasn't already one if (cuWordLength <= 0) { wordsFound += 1; } - + // Update the length with the passed-over characters cuWordLength += chars; } @@ -578,14 +578,14 @@ LaoBreakEngine::divideUpDictionaryRange( UText *text, utext_setNativeIndex(text, current + cuWordLength); } } - + // Never stop before a combining mark. int32_t currPos; while ((currPos = (int32_t)utext_getNativeIndex(text)) < rangeEnd && fMarkSet.contains(utext_current32(text))) { utext_next32(text); cuWordLength += (int32_t)utext_getNativeIndex(text) - currPos; } - + // Look ahead for possible suffixes if a dictionary word does not follow. // We do this in code rather than using a rule so that the heuristic // resynch continues to function. For example, one of the suffix characters @@ -666,16 +666,16 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, int32_t current; UErrorCode status = U_ZERO_ERROR; PossibleWord words[BURMESE_LOOKAHEAD]; - + utext_setNativeIndex(text, rangeStart); - + while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) { cuWordLength = 0; cpWordLength = 0; // Look for candidate words at the current position int32_t candidates = words[wordsFound%BURMESE_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); - + // If we found exactly one, use that if (candidates == 1) { cuWordLength = words[wordsFound % BURMESE_LOOKAHEAD].acceptMarked(text); @@ -696,12 +696,12 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, words[wordsFound%BURMESE_LOOKAHEAD].markCurrent(); wordsMatched = 2; } - + // If we're already at the end of the range, we're done if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) { goto foundBest; } - + // See if any of the possible second words is followed by a third word do { // If we find a third word, stop right away @@ -719,7 +719,7 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, cpWordLength = words[wordsFound % BURMESE_LOOKAHEAD].markedCPLength(); wordsFound += 1; } - + // We come here after having either found a word or not. We look ahead to the // next word. If it's not a dictionary word, we will combine it withe the word we // just found (if there is one), but only if the preceding word does not exceed @@ -757,12 +757,12 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, } } } - + // Bump the word count if there wasn't already one if (cuWordLength <= 0) { wordsFound += 1; } - + // Update the length with the passed-over characters cuWordLength += chars; } @@ -771,14 +771,14 @@ BurmeseBreakEngine::divideUpDictionaryRange( UText *text, utext_setNativeIndex(text, current + cuWordLength); } } - + // Never stop before a combining mark. int32_t currPos; while ((currPos = (int32_t)utext_getNativeIndex(text)) < rangeEnd && fMarkSet.contains(utext_current32(text))) { utext_next32(text); cuWordLength += (int32_t)utext_getNativeIndex(text) - currPos; } - + // Look ahead for possible suffixes if a dictionary word does not follow. // We do this in code rather than using a rule so that the heuristic // resynch continues to function. For example, one of the suffix characters @@ -1027,7 +1027,7 @@ KhmerBreakEngine::divideUpDictionaryRange( UText *text, foundBreaks.push((current+cuWordLength), status); } } - + // Don't return a break for the end of the dictionary range if there is one there. if (foundBreaks.peeki() >= rangeEnd) { (void) foundBreaks.popi(); @@ -1098,7 +1098,7 @@ static inline int32_t utext_i32_flag(int32_t bitIndex) { return (int32_t)1 << bitIndex; } - + /* * @param text A UText representing the text * @param rangeStart The start of the range of dictionary characters @@ -1106,7 +1106,7 @@ static inline int32_t utext_i32_flag(int32_t bitIndex) { * @param foundBreaks vector to receive the break positions * @return The number of breaks found */ -int32_t +int32_t CjkBreakEngine::divideUpDictionaryRange( UText *inText, int32_t rangeStart, int32_t rangeEnd, @@ -1169,7 +1169,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, if (U_FAILURE(status)) { return 0; } - + UnicodeString fragment; UnicodeString normalizedFragment; for (int32_t srcI = 0; srcI < inString.length();) { // Once per normalization chunk @@ -1238,7 +1238,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, } } } - + // bestSnlp[i] is the snlp of the best segmentation of the first i // code points in the range to be matched. UVector32 bestSnlp(numCodePts + 1, status); @@ -1248,7 +1248,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, } - // prev[i] is the index of the last CJK code point in the previous word in + // prev[i] is the index of the last CJK code point in the previous word in // the best segmentation of the first i characters. UVector32 prev(numCodePts + 1, status); for(int32_t i = 0; i <= numCodePts; i++){ @@ -1283,8 +1283,8 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, // Note: lengths is filled with code point lengths // The NULL parameter is the ignored code unit lengths. - // if there are no single character matches found in the dictionary - // starting with this character, treat character as a 1-character word + // if there are no single character matches found in the dictionary + // starting with this character, treat character as a 1-character word // with the highest value possible, i.e. the least likely to occur. // Exclude Korean characters from this treatment, as they should be left // together by default. @@ -1357,7 +1357,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, numBreaks++; } - // Now that we're done, convert positions in t_boundary[] (indices in + // Now that we're done, convert positions in t_boundary[] (indices in // the normalized input string) back to indices in the original input UText // while reversing t_boundary and pushing values to foundBreaks. int32_t prevCPPos = -1; @@ -1391,3 +1391,4 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText, U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ + diff --git a/deps/icu-small/source/common/dictbe.h b/deps/icu-small/source/common/dictbe.h index 99d176cc2e7bcf..731bfdff9f225e 100644 --- a/deps/icu-small/source/common/dictbe.h +++ b/deps/icu-small/source/common/dictbe.h @@ -68,7 +68,7 @@ class DictionaryBreakEngine : public LanguageBreakEngine { *

Find any breaks within a run in the supplied text.

* * @param text A UText representing the text. The iterator is left at - * the end of the run of characters which the engine is capable of handling + * the end of the run of characters which the engine is capable of handling * that starts from the first character in the range. * @param startPos The start of the run within the supplied text. * @param endPos The end of the run within the supplied text. @@ -218,118 +218,118 @@ class LaoBreakEngine : public DictionaryBreakEngine { }; -/******************************************************************* - * BurmeseBreakEngine - */ - -/** - *

BurmeseBreakEngine is a kind of DictionaryBreakEngine that uses a - * DictionaryMatcher and heuristics to determine Burmese-specific breaks.

- * - *

After it is constructed a BurmeseBreakEngine may be shared between - * threads without synchronization.

- */ -class BurmeseBreakEngine : public DictionaryBreakEngine { - private: - /** - * The set of characters handled by this engine - * @internal - */ - - UnicodeSet fBurmeseWordSet; - UnicodeSet fEndWordSet; - UnicodeSet fBeginWordSet; - UnicodeSet fMarkSet; - DictionaryMatcher *fDictionary; - - public: - - /** - *

Default constructor.

- * - * @param adoptDictionary A DictionaryMatcher to adopt. Deleted when the - * engine is deleted. - */ - BurmeseBreakEngine(DictionaryMatcher *adoptDictionary, UErrorCode &status); - - /** - *

Virtual destructor.

- */ - virtual ~BurmeseBreakEngine(); - - protected: - /** - *

Divide up a range of known dictionary characters.

- * - * @param text A UText representing the text - * @param rangeStart The start of the range of dictionary characters - * @param rangeEnd The end of the range of dictionary characters - * @param foundBreaks Output of C array of int32_t break positions, or 0 - * @return The number of breaks found - */ - virtual int32_t divideUpDictionaryRange( UText *text, - int32_t rangeStart, - int32_t rangeEnd, - UVector32 &foundBreaks ) const; - -}; - -/******************************************************************* - * KhmerBreakEngine - */ - -/** - *

KhmerBreakEngine is a kind of DictionaryBreakEngine that uses a - * DictionaryMatcher and heuristics to determine Khmer-specific breaks.

- * - *

After it is constructed a KhmerBreakEngine may be shared between - * threads without synchronization.

- */ -class KhmerBreakEngine : public DictionaryBreakEngine { - private: - /** - * The set of characters handled by this engine - * @internal - */ - - UnicodeSet fKhmerWordSet; - UnicodeSet fEndWordSet; - UnicodeSet fBeginWordSet; - UnicodeSet fMarkSet; - DictionaryMatcher *fDictionary; - - public: - - /** - *

Default constructor.

- * - * @param adoptDictionary A DictionaryMatcher to adopt. Deleted when the - * engine is deleted. - */ - KhmerBreakEngine(DictionaryMatcher *adoptDictionary, UErrorCode &status); - - /** - *

Virtual destructor.

- */ - virtual ~KhmerBreakEngine(); - - protected: - /** - *

Divide up a range of known dictionary characters.

- * - * @param text A UText representing the text - * @param rangeStart The start of the range of dictionary characters - * @param rangeEnd The end of the range of dictionary characters - * @param foundBreaks Output of C array of int32_t break positions, or 0 - * @return The number of breaks found - */ - virtual int32_t divideUpDictionaryRange( UText *text, - int32_t rangeStart, - int32_t rangeEnd, - UVector32 &foundBreaks ) const; - -}; - +/******************************************************************* + * BurmeseBreakEngine + */ + +/** + *

BurmeseBreakEngine is a kind of DictionaryBreakEngine that uses a + * DictionaryMatcher and heuristics to determine Burmese-specific breaks.

+ * + *

After it is constructed a BurmeseBreakEngine may be shared between + * threads without synchronization.

+ */ +class BurmeseBreakEngine : public DictionaryBreakEngine { + private: + /** + * The set of characters handled by this engine + * @internal + */ + + UnicodeSet fBurmeseWordSet; + UnicodeSet fEndWordSet; + UnicodeSet fBeginWordSet; + UnicodeSet fMarkSet; + DictionaryMatcher *fDictionary; + + public: + + /** + *

Default constructor.

+ * + * @param adoptDictionary A DictionaryMatcher to adopt. Deleted when the + * engine is deleted. + */ + BurmeseBreakEngine(DictionaryMatcher *adoptDictionary, UErrorCode &status); + + /** + *

Virtual destructor.

+ */ + virtual ~BurmeseBreakEngine(); + + protected: + /** + *

Divide up a range of known dictionary characters.

+ * + * @param text A UText representing the text + * @param rangeStart The start of the range of dictionary characters + * @param rangeEnd The end of the range of dictionary characters + * @param foundBreaks Output of C array of int32_t break positions, or 0 + * @return The number of breaks found + */ + virtual int32_t divideUpDictionaryRange( UText *text, + int32_t rangeStart, + int32_t rangeEnd, + UVector32 &foundBreaks ) const; + +}; + +/******************************************************************* + * KhmerBreakEngine + */ + +/** + *

KhmerBreakEngine is a kind of DictionaryBreakEngine that uses a + * DictionaryMatcher and heuristics to determine Khmer-specific breaks.

+ * + *

After it is constructed a KhmerBreakEngine may be shared between + * threads without synchronization.

+ */ +class KhmerBreakEngine : public DictionaryBreakEngine { + private: + /** + * The set of characters handled by this engine + * @internal + */ + + UnicodeSet fKhmerWordSet; + UnicodeSet fEndWordSet; + UnicodeSet fBeginWordSet; + UnicodeSet fMarkSet; + DictionaryMatcher *fDictionary; + + public: + + /** + *

Default constructor.

+ * + * @param adoptDictionary A DictionaryMatcher to adopt. Deleted when the + * engine is deleted. + */ + KhmerBreakEngine(DictionaryMatcher *adoptDictionary, UErrorCode &status); + + /** + *

Virtual destructor.

+ */ + virtual ~KhmerBreakEngine(); + + protected: + /** + *

Divide up a range of known dictionary characters.

+ * + * @param text A UText representing the text + * @param rangeStart The start of the range of dictionary characters + * @param rangeEnd The end of the range of dictionary characters + * @param foundBreaks Output of C array of int32_t break positions, or 0 + * @return The number of breaks found + */ + virtual int32_t divideUpDictionaryRange( UText *text, + int32_t rangeStart, + int32_t rangeEnd, + UVector32 &foundBreaks ) const; + +}; + #if !UCONFIG_NO_NORMALIZATION /******************************************************************* diff --git a/deps/icu-small/source/common/dictionarydata.cpp b/deps/icu-small/source/common/dictionarydata.cpp index 0efa5874931a07..6e2dbee5b618be 100644 --- a/deps/icu-small/source/common/dictionarydata.cpp +++ b/deps/icu-small/source/common/dictionarydata.cpp @@ -30,7 +30,7 @@ const int32_t DictionaryData::TRANSFORM_NONE = 0; const int32_t DictionaryData::TRANSFORM_TYPE_OFFSET = 0x1000000; const int32_t DictionaryData::TRANSFORM_TYPE_MASK = 0x7f000000; const int32_t DictionaryData::TRANSFORM_OFFSET_MASK = 0x1fffff; - + DictionaryMatcher::~DictionaryMatcher() { } @@ -172,10 +172,10 @@ udict_swap(const UDataSwapper *ds, const void *inData, int32_t length, headerSize = udata_swapDataHeader(ds, inData, length, outData, pErrorCode); if (pErrorCode == NULL || U_FAILURE(*pErrorCode)) return 0; pInfo = (const UDataInfo *)((const char *)inData + 4); - if (!(pInfo->dataFormat[0] == 0x44 && - pInfo->dataFormat[1] == 0x69 && - pInfo->dataFormat[2] == 0x63 && - pInfo->dataFormat[3] == 0x74 && + if (!(pInfo->dataFormat[0] == 0x44 && + pInfo->dataFormat[1] == 0x69 && + pInfo->dataFormat[2] == 0x63 && + pInfo->dataFormat[3] == 0x74 && pInfo->formatVersion[0] == 1)) { udata_printError(ds, "udict_swap(): data format %02x.%02x.%02x.%02x (format version %02x) is not recognized as dictionary data\n", pInfo->dataFormat[0], pInfo->dataFormat[1], pInfo->dataFormat[2], pInfo->dataFormat[3], pInfo->formatVersion[0]); diff --git a/deps/icu-small/source/common/dictionarydata.h b/deps/icu-small/source/common/dictionarydata.h index d86c6dfdbbc71b..0d303d9a8dcfdb 100644 --- a/deps/icu-small/source/common/dictionarydata.h +++ b/deps/icu-small/source/common/dictionarydata.h @@ -62,7 +62,7 @@ class U_COMMON_API DictionaryData : public UMemory { /** * Wrapper class around generic dictionaries, implementing matches(). * getType() should return a TRIE_TYPE_??? constant from DictionaryData. - * + * * All implementations of this interface must be thread-safe if they are to be used inside of the * dictionary-based break iteration code. */ diff --git a/deps/icu-small/source/common/dtintrv.cpp b/deps/icu-small/source/common/dtintrv.cpp index dee637e62c07d4..80bb5d6dbd13f8 100644 --- a/deps/icu-small/source/common/dtintrv.cpp +++ b/deps/icu-small/source/common/dtintrv.cpp @@ -5,7 +5,7 @@ * others. All Rights Reserved. ******************************************************************************* * -* File DTINTRV.CPP +* File DTINTRV.CPP * ******************************************************************************* */ @@ -34,7 +34,7 @@ DateInterval::~DateInterval(){} DateInterval::DateInterval(const DateInterval& other) : UObject(other) { *this = other; -} +} DateInterval& @@ -47,16 +47,17 @@ DateInterval::operator=(const DateInterval& other) { } -DateInterval* +DateInterval* DateInterval::clone() const { return new DateInterval(*this); } -UBool -DateInterval::operator==(const DateInterval& other) const { +UBool +DateInterval::operator==(const DateInterval& other) const { return ( fromDate == other.fromDate && toDate == other.toDate ); } U_NAMESPACE_END + diff --git a/deps/icu-small/source/common/edits.cpp b/deps/icu-small/source/common/edits.cpp index 00a8d601a1cc80..95f0c19a728cf4 100644 --- a/deps/icu-small/source/common/edits.cpp +++ b/deps/icu-small/source/common/edits.cpp @@ -243,7 +243,7 @@ UBool Edits::growArray() { return TRUE; } -UBool Edits::copyErrorTo(UErrorCode &outErrorCode) { +UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { return TRUE; } if (U_SUCCESS(errorCode_)) { return FALSE; } outErrorCode = errorCode_; diff --git a/deps/icu-small/source/common/filteredbrk.cpp b/deps/icu-small/source/common/filteredbrk.cpp index 162b38de5d6fa2..c07128cbce10e1 100644 --- a/deps/icu-small/source/common/filteredbrk.cpp +++ b/deps/icu-small/source/common/filteredbrk.cpp @@ -137,7 +137,7 @@ static const UChar kFULLSTOP = 0x002E; // '.' */ class SimpleFilteredSentenceBreakData : public UMemory { public: - SimpleFilteredSentenceBreakData(UCharsTrie *forwards, UCharsTrie *backwards ) + SimpleFilteredSentenceBreakData(UCharsTrie *forwards, UCharsTrie *backwards ) : fForwardsPartialTrie(forwards), fBackwardsTrie(backwards), refcount(1) { } SimpleFilteredSentenceBreakData *incr() { refcount++; return this; } SimpleFilteredSentenceBreakData *decr() { if((--refcount) <= 0) delete this; return 0; } @@ -173,7 +173,7 @@ class SimpleFilteredSentenceBreakIterator : public BreakIterator { status = U_SAFECLONE_ALLOCATED_WARNING; return clone(); } - virtual BreakIterator* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); } + virtual SimpleFilteredSentenceBreakIterator* clone() const { return new SimpleFilteredSentenceBreakIterator(*this); } virtual UClassID getDynamicClassID(void) const { return NULL; } virtual UBool operator==(const BreakIterator& o) const { if(this==&o) return true; return false; } @@ -217,7 +217,7 @@ class SimpleFilteredSentenceBreakIterator : public BreakIterator { int32_t internalPrev(int32_t n); /** * set up the UText with the value of the fDelegate. - * Call this before calling breakExceptionAt. + * Call this before calling breakExceptionAt. * May be able to avoid excess calls */ void resetState(UErrorCode &status); @@ -361,7 +361,7 @@ SimpleFilteredSentenceBreakIterator::internalNext(int32_t n) { default: case kNoExceptionHere: return n; - } + } } return n; } @@ -390,7 +390,7 @@ SimpleFilteredSentenceBreakIterator::internalPrev(int32_t n) { default: case kNoExceptionHere: return n; - } + } } return n; } @@ -433,9 +433,9 @@ UBool SimpleFilteredSentenceBreakIterator::isBoundary(int32_t offset) { default: case kNoExceptionHere: return true; - } + } } - + int32_t SimpleFilteredSentenceBreakIterator::next(int32_t offset) { return internalNext(fDelegate->next(offset)); @@ -472,7 +472,7 @@ SimpleFilteredBreakIteratorBuilder::~SimpleFilteredBreakIteratorBuilder() { } -SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(UErrorCode &status) +SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(UErrorCode &status) : fSet(status) { } @@ -483,16 +483,16 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc if(U_SUCCESS(status)) { UErrorCode subStatus = U_ZERO_ERROR; LocalUResourceBundlePointer b(ures_open(U_ICUDATA_BRKITR, fromLocale.getBaseName(), &subStatus)); - if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { - status = subStatus; // copy the failing status + if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { + status = subStatus; // copy the failing status #if FB_DEBUG fprintf(stderr, "open BUNDLE %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status)); #endif return; // leaves the builder empty, if you try to use it. } LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &subStatus)); - if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { - status = subStatus; // copy the failing status + if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { + status = subStatus; // copy the failing status #if FB_DEBUG fprintf(stderr, "open EXCEPTIONS %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status)); #endif @@ -506,9 +506,9 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc fprintf(stderr, "open SentenceBreak %s => %s, %s\n", fromLocale.getBaseName(), ures_getLocale(breaks.getAlias(), &subsub), u_errorName(subStatus)); } #endif - - if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { - status = subStatus; // copy the failing status + + if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { + status = subStatus; // copy the failing status #if FB_DEBUG fprintf(stderr, "open %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status)); #endif @@ -516,7 +516,7 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc } LocalUResourceBundlePointer strs; - subStatus = status; // Pick up inherited warning status now + subStatus = status; // Pick up inherited warning status now do { strs.adoptInstead(ures_getNextResource(breaks.getAlias(), strs.orphan(), &subStatus)); if(strs.isValid() && U_SUCCESS(subStatus)) { @@ -573,7 +573,7 @@ SimpleFilteredBreakIteratorBuilder::build(BreakIterator* adoptBreakIterator, UEr int32_t subCount = fSet.size(); UnicodeString *ustrs_ptr = newUnicodeStringArray(subCount); - + LocalArray ustrs(ustrs_ptr); LocalMemory partials; diff --git a/deps/icu-small/source/common/hash.h b/deps/icu-small/source/common/hash.h index fa1e4ee9affc7b..f02cb7087a508b 100644 --- a/deps/icu-small/source/common/hash.h +++ b/deps/icu-small/source/common/hash.h @@ -245,3 +245,4 @@ inline UBool Hashtable::equals(const Hashtable& that)const{ U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/common/icudataver.cpp b/deps/icu-small/source/common/icudataver.cpp index 6dd3ea1baee607..d31441137416be 100644 --- a/deps/icu-small/source/common/icudataver.cpp +++ b/deps/icu-small/source/common/icudataver.cpp @@ -16,11 +16,11 @@ U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status) { UResourceBundle *icudatares = NULL; - + if (U_FAILURE(*status)) { return; } - + if (dataVersionFillin != NULL) { icudatares = ures_openDirect(NULL, U_ICU_VERSION_BUNDLE , status); if (U_SUCCESS(*status)) { diff --git a/deps/icu-small/source/common/icuplug.cpp b/deps/icu-small/source/common/icuplug.cpp index c3c8231b77d572..c6439cc819a322 100644 --- a/deps/icu-small/source/common/icuplug.cpp +++ b/deps/icu-small/source/common/icuplug.cpp @@ -45,7 +45,7 @@ using namespace icu; #endif /** - * Internal structure of an ICU plugin. + * Internal structure of an ICU plugin. */ struct UPlugData { @@ -75,21 +75,21 @@ struct UPlugData { * @param listSize the number of entries in the list * @param memberSize the size of one member * @param itemToRemove the item number of the member - * @return the new listsize + * @return the new listsize */ static int32_t uplug_removeEntryAt(void *list, int32_t listSize, int32_t memberSize, int32_t itemToRemove) { uint8_t *bytePtr = (uint8_t *)list; - + /* get rid of some bad cases first */ if(listSize<1) { return listSize; } - + /* is there anything to move? */ if(listSize > itemToRemove+1) { memmove(bytePtr+(itemToRemove*memberSize), bytePtr+((itemToRemove+1)*memberSize), memberSize); } - + return listSize-1; } @@ -98,13 +98,13 @@ static int32_t uplug_removeEntryAt(void *list, int32_t listSize, int32_t memberS #if U_ENABLE_DYLOAD /** - * Library management. Internal. + * Library management. Internal. * @internal */ struct UPlugLibrary; /** - * Library management. Internal. + * Library management. Internal. * @internal */ typedef struct UPlugLibrary { @@ -125,7 +125,7 @@ static int32_t libraryMax = UPLUG_LIBRARY_INITIAL_COUNT; */ static int32_t searchForLibraryName(const char *libName) { int32_t i; - + for(i=0;i=pastPlug) { return NULL; } else { @@ -286,7 +286,7 @@ static void uplug_callPlug(UPlugData *plug, UPlugReason reason, UErrorCode *stat static void uplug_unloadPlug(UPlugData *plug, UErrorCode *status) { if(plug->awaitingLoad) { /* shouldn't happen. Plugin hasn'tbeen loaded yet.*/ *status = U_INTERNAL_PROGRAM_ERROR; - return; + return; } if(U_SUCCESS(plug->pluginStatus)) { /* Don't unload a plug which has a failing load status - means it didn't actually load. */ @@ -297,11 +297,11 @@ static void uplug_unloadPlug(UPlugData *plug, UErrorCode *status) { static void uplug_queryPlug(UPlugData *plug, UErrorCode *status) { if(!plug->awaitingLoad || !(plug->level == UPLUG_LEVEL_UNKNOWN) ) { /* shouldn't happen. Plugin hasn'tbeen loaded yet.*/ *status = U_INTERNAL_PROGRAM_ERROR; - return; + return; } plug->level = UPLUG_LEVEL_INVALID; uplug_callPlug(plug, UPLUG_REASON_QUERY, status); - if(U_SUCCESS(*status)) { + if(U_SUCCESS(*status)) { if(plug->level == UPLUG_LEVEL_INVALID) { plug->pluginStatus = U_PLUGIN_DIDNT_SET_LEVEL; plug->awaitingLoad = FALSE; @@ -372,17 +372,17 @@ static UPlugData *uplug_allocatePlug(UPlugEntrypoint *entrypoint, const char *co } else { plug->config[0] = 0; } - + if(symName!=NULL) { uprv_strncpy(plug->sym, symName, UPLUG_NAME_MAX); } else { plug->sym[0] = 0; } - + plug->entrypoint = entrypoint; plug->lib = lib; uplug_queryPlug(plug, status); - + return plug; } @@ -421,7 +421,7 @@ uplug_removePlug(UPlugData *plug, UErrorCode *status) { UPlugData *cursor = NULL; UPlugData *plugToRemove = NULL; if(U_FAILURE(*status)) return; - + for(cursor=pluginList;cursor!=NULL;) { if(cursor==plug) { plugToRemove = plug; @@ -430,14 +430,14 @@ uplug_removePlug(UPlugData *plug, UErrorCode *status) { cursor = uplug_nextPlug(cursor); } } - + uplug_doUnloadPlug(plugToRemove, status); } -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 uplug_setPlugNoUnload(UPlugData *data, UBool dontUnload) { data->dontUnload = dontUnload; @@ -508,10 +508,10 @@ uplug_getConfiguration(UPlugData *data) { } U_INTERNAL UPlugData* U_EXPORT2 -uplug_getPlugInternal(int32_t n) { +uplug_getPlugInternal(int32_t n) { if(n <0 || n >= pluginCount) { return NULL; - } else { + } else { return &(pluginList[n]); } } @@ -551,7 +551,7 @@ uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UE #if U_ENABLE_DYLOAD -static UPlugData* +static UPlugData* uplug_initErrorPlug(const char *libName, const char *sym, const char *config, const char *nameOrError, UErrorCode loadStatus, UErrorCode *status) { UPlugData *plug = uplug_allocateEmptyPlug(status); @@ -583,7 +583,7 @@ uplug_initErrorPlug(const char *libName, const char *sym, const char *config, co /** * Fetch a plugin from DLL, and then initialize it from a library- but don't load it. */ -static UPlugData* +static UPlugData* uplug_initPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status) { void *lib = NULL; UPlugData *plug = NULL; @@ -615,7 +615,7 @@ uplug_initPlugFromLibrary(const char *libName, const char *sym, const char *conf } U_CAPI UPlugData* U_EXPORT2 -uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status) { +uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status) { UPlugData *plug = NULL; if(U_FAILURE(*status)) { return NULL; } plug = uplug_initPlugFromLibrary(libName, sym, config, status); @@ -635,7 +635,7 @@ U_CAPI UPlugLevel U_EXPORT2 uplug_getCurrentLevel() { static UBool U_CALLCONV uplug_cleanup(void) { int32_t i; - + UPlugData *pluginToRemove; /* cleanup plugs */ for(i=0;iawaitingLoad = FALSE; - } + } } - } + } for(i=0;iawaitingLoad) { - if(pluginToLoad->level == UPLUG_LEVEL_INVALID) { + if(pluginToLoad->level == UPLUG_LEVEL_INVALID) { pluginToLoad->pluginStatus = U_PLUGIN_DIDNT_SET_LEVEL; } else if(pluginToLoad->level == UPLUG_LEVEL_UNKNOWN) { pluginToLoad->pluginStatus = U_INTERNAL_PROGRAM_ERROR; @@ -697,7 +697,7 @@ static void uplug_loadWaitingPlugs(UErrorCode *status) { pluginToLoad->awaitingLoad = FALSE; } } - + #if UPLUG_TRACE DBG((stderr, " Done Loading Plugs. Level: %d\n", (int32_t)uplug_getCurrentLevel())); #endif @@ -733,7 +733,7 @@ uplug_init(UErrorCode *status) { } if(U_FAILURE(*status)) return; -#if defined(DEFAULT_ICU_PLUGINS) +#if defined(DEFAULT_ICU_PLUGINS) if(plugin_dir.isEmpty()) { plugin_dir.append(DEFAULT_ICU_PLUGINS, -1, *status); } @@ -745,7 +745,7 @@ uplug_init(UErrorCode *status) { if(!plugin_dir.isEmpty()) { FILE *f; - + CharString pluginFile; #ifdef OS390BATCH /* There are potentially a lot of ways to implement a plugin directory on OS390/zOS */ @@ -778,16 +778,16 @@ uplug_init(UErrorCode *status) { #endif return; } - - /* plugin_file is not used for processing - it is only used + + /* plugin_file is not used for processing - it is only used so that uplug_getPluginFile() works (i.e. icuinfo) */ uprv_strncpy(plugin_file, pluginFile.data(), sizeof(plugin_file)); - + #if UPLUG_TRACE DBG((stderr, "pluginfile= %s len %d/%d\n", plugin_file, (int)strlen(plugin_file), (int)sizeof(plugin_file))); #endif - + #ifdef __MVS__ if (iscics()) /* 12 Nov 2011 JAM */ { @@ -803,8 +803,8 @@ uplug_init(UErrorCode *status) { char linebuf[1024]; char *p, *libName=NULL, *symName=NULL, *config=NULL; int32_t line = 0; - - + + while(fgets(linebuf,1023,f)) { line++; @@ -830,7 +830,7 @@ uplug_init(UErrorCode *status) { while(*p&&!isspace((int)*p)) { p++; } - + if(*p) { /* has config */ *p=0; ++p; @@ -841,7 +841,7 @@ uplug_init(UErrorCode *status) { config = p; } } - + /* chop whitespace at the end of the config */ if(config!=NULL&&*config!=0) { p = config+strlen(config); @@ -849,9 +849,9 @@ uplug_init(UErrorCode *status) { *p=0; } } - + /* OK, we're good. */ - { + { UErrorCode subStatus = U_ZERO_ERROR; UPlugData *plug = uplug_initPlugFromLibrary(libName, symName, config, &subStatus); if(U_FAILURE(subStatus) && U_SUCCESS(*status)) { @@ -880,3 +880,5 @@ uplug_init(UErrorCode *status) { } #endif + + diff --git a/deps/icu-small/source/common/icuplugimp.h b/deps/icu-small/source/common/icuplugimp.h index 282c639b40e271..3cad8f87f18ca2 100644 --- a/deps/icu-small/source/common/icuplugimp.h +++ b/deps/icu-small/source/common/icuplugimp.h @@ -9,7 +9,7 @@ ****************************************************************************** * * FILE NAME : icuplugimp.h -* +* * Internal functions for the ICU plugin system * * Date Name Description @@ -26,7 +26,7 @@ #if UCONFIG_ENABLE_PLUGINS /*========================*/ -/** @{ Library Manipulation +/** @{ Library Manipulation */ /** @@ -65,7 +65,7 @@ uplug_findLibrary(void *lib, UErrorCode *status); */ /** - * Initialize the plugins + * Initialize the plugins * @param status error result * @internal - Internal use only. */ @@ -75,12 +75,12 @@ uplug_init(UErrorCode *status); /** * Get raw plug N * @internal - Internal use only - */ + */ U_INTERNAL UPlugData* U_EXPORT2 uplug_getPlugInternal(int32_t n); /** - * Get the name of the plugin file. + * Get the name of the plugin file. * @internal - Internal use only. */ U_INTERNAL const char* U_EXPORT2 diff --git a/deps/icu-small/source/common/localebuilder.cpp b/deps/icu-small/source/common/localebuilder.cpp index fe931fcf759dfd..1dd8131e5895a5 100644 --- a/deps/icu-small/source/common/localebuilder.cpp +++ b/deps/icu-small/source/common/localebuilder.cpp @@ -157,13 +157,18 @@ _isKeywordValue(const char* key, const char* value, int32_t value_len) } static void -_copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& errorCode) +_copyExtensions(const Locale& from, icu::StringEnumeration *keywords, + Locale& to, bool validate, UErrorCode& errorCode) { if (U_FAILURE(errorCode)) { return; } - LocalPointer iter(from.createKeywords(errorCode)); - if (U_FAILURE(errorCode) || iter.isNull()) { return; } + LocalPointer ownedKeywords; + if (keywords == nullptr) { + ownedKeywords.adoptInstead(from.createKeywords(errorCode)); + if (U_FAILURE(errorCode) || ownedKeywords.isNull()) { return; } + keywords = ownedKeywords.getAlias(); + } const char* key; - while ((key = iter->next(nullptr, errorCode)) != nullptr) { + while ((key = keywords->next(nullptr, errorCode)) != nullptr) { CharString value; CharStringByteSink sink(&value); from.getKeywordValue(key, sink, errorCode); @@ -176,34 +181,34 @@ _copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& error errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; } - to->setKeywordValue(key, value.data(), errorCode); + to.setKeywordValue(key, value.data(), errorCode); if (U_FAILURE(errorCode)) { return; } } } void static -_clearUAttributesAndKeyType(Locale* locale, UErrorCode& errorCode) +_clearUAttributesAndKeyType(Locale& locale, UErrorCode& errorCode) { // Clear Unicode attributes - locale->setKeywordValue(kAttributeKey, "", errorCode); + locale.setKeywordValue(kAttributeKey, "", errorCode); // Clear all Unicode keyword values - LocalPointer iter(locale->createUnicodeKeywords(errorCode)); + LocalPointer iter(locale.createUnicodeKeywords(errorCode)); if (U_FAILURE(errorCode) || iter.isNull()) { return; } const char* key; while ((key = iter->next(nullptr, errorCode)) != nullptr) { - locale->setUnicodeKeywordValue(key, nullptr, errorCode); + locale.setUnicodeKeywordValue(key, nullptr, errorCode); } } static void -_setUnicodeExtensions(Locale* locale, const CharString& value, UErrorCode& errorCode) +_setUnicodeExtensions(Locale& locale, const CharString& value, UErrorCode& errorCode) { // Add the unicode extensions to extensions_ CharString locale_str("und-u-", errorCode); locale_str.append(value, errorCode); _copyExtensions( - Locale::forLanguageTag(locale_str.data(), errorCode), + Locale::forLanguageTag(locale_str.data(), errorCode), nullptr, locale, false, errorCode); } @@ -235,10 +240,10 @@ LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value) status_); return *this; } - _clearUAttributesAndKeyType(extensions_, status_); + _clearUAttributesAndKeyType(*extensions_, status_); if (U_FAILURE(status_)) { return *this; } if (!value.empty()) { - _setUnicodeExtensions(extensions_, value_str, status_); + _setUnicodeExtensions(*extensions_, value_str, status_); } return *this; } @@ -401,6 +406,24 @@ Locale makeBogusLocale() { return bogus; } +void LocaleBuilder::copyExtensionsFrom(const Locale& src, UErrorCode& errorCode) +{ + if (U_FAILURE(errorCode)) { return; } + LocalPointer keywords(src.createKeywords(errorCode)); + if (U_FAILURE(errorCode) || keywords.isNull() || keywords->count(errorCode) == 0) { + // Error, or no extensions to copy. + return; + } + if (extensions_ == nullptr) { + extensions_ = new Locale(); + if (extensions_ == nullptr) { + status_ = U_MEMORY_ALLOCATION_ERROR; + return; + } + } + _copyExtensions(src, keywords.getAlias(), *extensions_, false, errorCode); +} + Locale LocaleBuilder::build(UErrorCode& errorCode) { if (U_FAILURE(errorCode)) { @@ -425,7 +448,7 @@ Locale LocaleBuilder::build(UErrorCode& errorCode) } Locale product(locale_str.data()); if (extensions_ != nullptr) { - _copyExtensions(*extensions_, &product, true, errorCode); + _copyExtensions(*extensions_, nullptr, product, true, errorCode); } if (U_FAILURE(errorCode)) { return makeBogusLocale(); @@ -433,4 +456,13 @@ Locale LocaleBuilder::build(UErrorCode& errorCode) return product; } +UBool LocaleBuilder::copyErrorTo(UErrorCode &outErrorCode) const { + if (U_FAILURE(outErrorCode)) { + // Do not overwrite the older error code + return TRUE; + } + outErrorCode = status_; + return U_FAILURE(outErrorCode); +} + U_NAMESPACE_END diff --git a/deps/icu-small/source/common/localematcher.cpp b/deps/icu-small/source/common/localematcher.cpp new file mode 100644 index 00000000000000..d975fe759b4ce1 --- /dev/null +++ b/deps/icu-small/source/common/localematcher.cpp @@ -0,0 +1,720 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localematcher.cpp +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCMATCHER_H__ +#define __LOCMATCHER_H__ + +#include "unicode/utypes.h" +#include "unicode/localebuilder.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" +#include "cstring.h" +#include "localeprioritylist.h" +#include "loclikelysubtags.h" +#include "locdistance.h" +#include "lsr.h" +#include "uassert.h" +#include "uhash.h" +#include "uvector.h" + +#define UND_LSR LSR("und", "", "") + +/** + * Indicator for the lifetime of desired-locale objects passed into the LocaleMatcher. + * + * @draft ICU 65 + */ +enum ULocMatchLifetime { + /** + * Locale objects are temporary. + * The matcher will make a copy of a locale that will be used beyond one function call. + * + * @draft ICU 65 + */ + ULOCMATCH_TEMPORARY_LOCALES, + /** + * Locale objects are stored at least as long as the matcher is used. + * The matcher will keep only a pointer to a locale that will be used beyond one function call, + * avoiding a copy. + * + * @draft ICU 65 + */ + ULOCMATCH_STORED_LOCALES // TODO: permanent? cached? clone? +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchLifetime ULocMatchLifetime; +#endif + +U_NAMESPACE_BEGIN + +LocaleMatcher::Result::Result(LocaleMatcher::Result &&src) U_NOEXCEPT : + desiredLocale(src.desiredLocale), + supportedLocale(src.supportedLocale), + desiredIndex(src.desiredIndex), + supportedIndex(src.supportedIndex), + desiredIsOwned(src.desiredIsOwned) { + if (desiredIsOwned) { + src.desiredLocale = nullptr; + src.desiredIndex = -1; + src.desiredIsOwned = FALSE; + } +} + +LocaleMatcher::Result::~Result() { + if (desiredIsOwned) { + delete desiredLocale; + } +} + +LocaleMatcher::Result &LocaleMatcher::Result::operator=(LocaleMatcher::Result &&src) U_NOEXCEPT { + this->~Result(); + + desiredLocale = src.desiredLocale; + supportedLocale = src.supportedLocale; + desiredIndex = src.desiredIndex; + supportedIndex = src.supportedIndex; + desiredIsOwned = src.desiredIsOwned; + + if (desiredIsOwned) { + src.desiredLocale = nullptr; + src.desiredIndex = -1; + src.desiredIsOwned = FALSE; + } + return *this; +} + +Locale LocaleMatcher::Result::makeResolvedLocale(UErrorCode &errorCode) const { + if (U_FAILURE(errorCode) || supportedLocale == nullptr) { + return Locale::getRoot(); + } + const Locale *bestDesired = getDesiredLocale(); + if (bestDesired == nullptr || *supportedLocale == *bestDesired) { + return *supportedLocale; + } + LocaleBuilder b; + b.setLocale(*supportedLocale); + + // Copy the region from bestDesired, if there is one. + const char *region = bestDesired->getCountry(); + if (*region != 0) { + b.setRegion(region); + } + + // Copy the variants from bestDesired, if there are any. + // Note that this will override any supportedLocale variants. + // For example, "sco-ulster-fonipa" + "...-fonupa" => "sco-fonupa" (replacing ulster). + const char *variants = bestDesired->getVariant(); + if (*variants != 0) { + b.setVariant(variants); + } + + // Copy the extensions from bestDesired, if there are any. + // C++ note: The following note, copied from Java, may not be true, + // as long as C++ copies by legacy ICU keyword, not by extension singleton. + // Note that this will override any supportedLocale extensions. + // For example, "th-u-nu-latn-ca-buddhist" + "...-u-nu-native" => "th-u-nu-native" + // (replacing calendar). + b.copyExtensionsFrom(*bestDesired, errorCode); + return b.build(errorCode); +} + +LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) U_NOEXCEPT : + errorCode_(src.errorCode_), + supportedLocales_(src.supportedLocales_), + thresholdDistance_(src.thresholdDistance_), + demotion_(src.demotion_), + defaultLocale_(src.defaultLocale_), + favor_(src.favor_) { + src.supportedLocales_ = nullptr; + src.defaultLocale_ = nullptr; +} + +LocaleMatcher::Builder::~Builder() { + delete supportedLocales_; + delete defaultLocale_; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) U_NOEXCEPT { + this->~Builder(); + + errorCode_ = src.errorCode_; + supportedLocales_ = src.supportedLocales_; + thresholdDistance_ = src.thresholdDistance_; + demotion_ = src.demotion_; + defaultLocale_ = src.defaultLocale_; + favor_ = src.favor_; + + src.supportedLocales_ = nullptr; + src.defaultLocale_ = nullptr; + return *this; +} + +void LocaleMatcher::Builder::clearSupportedLocales() { + if (supportedLocales_ != nullptr) { + supportedLocales_->removeAllElements(); + } +} + +bool LocaleMatcher::Builder::ensureSupportedLocaleVector() { + if (U_FAILURE(errorCode_)) { return false; } + if (supportedLocales_ != nullptr) { return true; } + supportedLocales_ = new UVector(uprv_deleteUObject, nullptr, errorCode_); + if (U_FAILURE(errorCode_)) { return false; } + if (supportedLocales_ == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return false; + } + return true; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocalesFromListString( + StringPiece locales) { + LocalePriorityList list(locales, errorCode_); + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + if (!ensureSupportedLocaleVector()) { return *this; } + int32_t length = list.getLengthIncludingRemoved(); + for (int32_t i = 0; i < length; ++i) { + Locale *locale = list.orphanLocaleAt(i); + if (locale == nullptr) { continue; } + supportedLocales_->addElement(locale, errorCode_); + if (U_FAILURE(errorCode_)) { + delete locale; + break; + } + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocales(Locale::Iterator &locales) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + if (!ensureSupportedLocaleVector()) { return *this; } + while (locales.hasNext()) { + const Locale &locale = locales.next(); + Locale *clone = locale.clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + break; + } + supportedLocales_->addElement(clone, errorCode_); + if (U_FAILURE(errorCode_)) { + delete clone; + break; + } + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::addSupportedLocale(const Locale &locale) { + if (!ensureSupportedLocaleVector()) { return *this; } + Locale *clone = locale.clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return *this; + } + supportedLocales_->addElement(clone, errorCode_); + if (U_FAILURE(errorCode_)) { + delete clone; + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *defaultLocale) { + if (U_FAILURE(errorCode_)) { return *this; } + Locale *clone = nullptr; + if (defaultLocale != nullptr) { + clone = defaultLocale->clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return *this; + } + } + delete defaultLocale_; + defaultLocale_ = clone; + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setFavorSubtag(ULocMatchFavorSubtag subtag) { + if (U_FAILURE(errorCode_)) { return *this; } + favor_ = subtag; + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setDemotionPerDesiredLocale(ULocMatchDemotion demotion) { + if (U_FAILURE(errorCode_)) { return *this; } + demotion_ = demotion; + return *this; +} + +#if 0 +/** + * Internal only! + * + * @param thresholdDistance the thresholdDistance to set, with -1 = default + * @return this Builder object + * @internal + * @deprecated This API is ICU internal only. + */ +@Deprecated +LocaleMatcher::Builder &LocaleMatcher::Builder::internalSetThresholdDistance(int32_t thresholdDistance) { + if (U_FAILURE(errorCode_)) { return *this; } + if (thresholdDistance > 100) { + thresholdDistance = 100; + } + thresholdDistance_ = thresholdDistance; + return *this; +} +#endif + +UBool LocaleMatcher::Builder::copyErrorTo(UErrorCode &outErrorCode) const { + if (U_FAILURE(outErrorCode)) { return TRUE; } + if (U_SUCCESS(errorCode_)) { return FALSE; } + outErrorCode = errorCode_; + return TRUE; +} + +LocaleMatcher LocaleMatcher::Builder::build(UErrorCode &errorCode) const { + if (U_SUCCESS(errorCode) && U_FAILURE(errorCode_)) { + errorCode = errorCode_; + } + return LocaleMatcher(*this, errorCode); +} + +namespace { + +LSR getMaximalLsrOrUnd(const XLikelySubtags &likelySubtags, const Locale &locale, + UErrorCode &errorCode) { + if (U_FAILURE(errorCode) || locale.isBogus() || *locale.getName() == 0 /* "und" */) { + return UND_LSR; + } else { + return likelySubtags.makeMaximizedLsrFrom(locale, errorCode); + } +} + +int32_t hashLSR(const UHashTok token) { + const LSR *lsr = static_cast(token.pointer); + return lsr->hashCode; +} + +UBool compareLSRs(const UHashTok t1, const UHashTok t2) { + const LSR *lsr1 = static_cast(t1.pointer); + const LSR *lsr2 = static_cast(t2.pointer); + return *lsr1 == *lsr2; +} + +bool putIfAbsent(UHashtable *lsrToIndex, const LSR &lsr, int32_t i, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return false; } + U_ASSERT(i > 0); + int32_t index = uhash_geti(lsrToIndex, &lsr); + if (index != 0) { + return false; + } else { + uhash_puti(lsrToIndex, const_cast(&lsr), i, &errorCode); + return U_SUCCESS(errorCode); + } +} + +} // namespace + +LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) : + likelySubtags(*XLikelySubtags::getSingleton(errorCode)), + localeDistance(*LocaleDistance::getSingleton(errorCode)), + thresholdDistance(builder.thresholdDistance_), + demotionPerDesiredLocale(0), + favorSubtag(builder.favor_), + supportedLocales(nullptr), lsrs(nullptr), supportedLocalesLength(0), + supportedLsrToIndex(nullptr), + supportedLSRs(nullptr), supportedIndexes(nullptr), supportedLSRsLength(0), + ownedDefaultLocale(nullptr), defaultLocale(nullptr), defaultLocaleIndex(-1) { + if (U_FAILURE(errorCode)) { return; } + if (thresholdDistance < 0) { + thresholdDistance = localeDistance.getDefaultScriptDistance(); + } + supportedLocalesLength = builder.supportedLocales_ != nullptr ? + builder.supportedLocales_->size() : 0; + const Locale *def = builder.defaultLocale_; + int32_t idef = -1; + if (supportedLocalesLength > 0) { + // Store the supported locales in input order, + // so that when different types are used (e.g., language tag strings) + // we can return those by parallel index. + supportedLocales = static_cast( + uprv_malloc(supportedLocalesLength * sizeof(const Locale *))); + // Supported LRSs in input order. + // In C++, we store these permanently to simplify ownership management + // in the hash tables. Duplicate LSRs (if any) are unused overhead. + lsrs = new LSR[supportedLocalesLength]; + if (supportedLocales == nullptr || lsrs == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + // If the constructor fails partway, we need null pointers for destructibility. + uprv_memset(supportedLocales, 0, supportedLocalesLength * sizeof(const Locale *)); + // Also find the first supported locale whose LSR is + // the same as that for the default locale. + LSR builderDefaultLSR; + const LSR *defLSR = nullptr; + if (def != nullptr) { + builderDefaultLSR = getMaximalLsrOrUnd(likelySubtags, *def, errorCode); + if (U_FAILURE(errorCode)) { return; } + defLSR = &builderDefaultLSR; + } + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + const Locale &locale = *static_cast(builder.supportedLocales_->elementAt(i)); + supportedLocales[i] = locale.clone(); + if (supportedLocales[i] == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + const Locale &supportedLocale = *supportedLocales[i]; + LSR &lsr = lsrs[i] = getMaximalLsrOrUnd(likelySubtags, supportedLocale, errorCode); + lsr.setHashCode(); + if (U_FAILURE(errorCode)) { return; } + if (idef < 0 && defLSR != nullptr && lsr == *defLSR) { + idef = i; + defLSR = &lsr; // owned pointer to put into supportedLsrToIndex + if (*def == supportedLocale) { + def = &supportedLocale; // owned pointer to keep + } + } + } + + // We need an unordered map from LSR to first supported locale with that LSR, + // and an ordered list of (LSR, supported index). + // We insert the supported locales in the following order: + // 1. Default locale, if it is supported. + // 2. Priority locales (aka "paradigm locales") in builder order. + // 3. Remaining locales in builder order. + // In Java, we use a LinkedHashMap for both map & ordered lists. + // In C++, we use separate structures. + // We over-allocate arrays of LSRs and indexes for simplicity. + // We reserve slots at the array starts for the default and paradigm locales, + // plus enough for all supported locales. + // If there are few paradigm locales and few duplicate supported LSRs, + // then the amount of wasted space is small. + supportedLsrToIndex = uhash_openSize(hashLSR, compareLSRs, uhash_compareLong, + supportedLocalesLength, &errorCode); + if (U_FAILURE(errorCode)) { return; } + int32_t paradigmLimit = 1 + localeDistance.getParadigmLSRsLength(); + int32_t suppLSRsCapacity = paradigmLimit + supportedLocalesLength; + supportedLSRs = static_cast( + uprv_malloc(suppLSRsCapacity * sizeof(const LSR *))); + supportedIndexes = static_cast( + uprv_malloc(suppLSRsCapacity * sizeof(int32_t))); + if (supportedLSRs == nullptr || supportedIndexes == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + int32_t paradigmIndex = 0; + int32_t otherIndex = paradigmLimit; + if (idef >= 0) { + uhash_puti(supportedLsrToIndex, const_cast(defLSR), idef + 1, &errorCode); + supportedLSRs[0] = defLSR; + supportedIndexes[0] = idef; + paradigmIndex = 1; + } + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + if (i == idef) { continue; } + const Locale &locale = *supportedLocales[i]; + const LSR &lsr = lsrs[i]; + if (defLSR == nullptr) { + U_ASSERT(i == 0); + def = &locale; + defLSR = &lsr; + idef = 0; + uhash_puti(supportedLsrToIndex, const_cast(&lsr), 0 + 1, &errorCode); + supportedLSRs[0] = &lsr; + supportedIndexes[0] = 0; + paradigmIndex = 1; + } else if (idef >= 0 && lsr == *defLSR) { + // lsr == *defLSR means that this supported locale is + // a duplicate of the default locale. + // Either an explicit default locale is supported, and we added it before the loop, + // or there is no explicit default locale, and this is + // a duplicate of the first supported locale. + // In both cases, idef >= 0 now, so otherwise we can skip the comparison. + // For a duplicate, putIfAbsent() is a no-op, so nothing to do. + } else { + if (putIfAbsent(supportedLsrToIndex, lsr, i + 1, errorCode)) { + if (localeDistance.isParadigmLSR(lsr)) { + supportedLSRs[paradigmIndex] = &lsr; + supportedIndexes[paradigmIndex++] = i; + } else { + supportedLSRs[otherIndex] = &lsr; + supportedIndexes[otherIndex++] = i; + } + } + } + if (U_FAILURE(errorCode)) { return; } + } + // Squeeze out unused array slots. + if (paradigmIndex < paradigmLimit && paradigmLimit < otherIndex) { + uprv_memmove(supportedLSRs + paradigmIndex, supportedLSRs + paradigmLimit, + (otherIndex - paradigmLimit) * sizeof(const LSR *)); + uprv_memmove(supportedIndexes + paradigmIndex, supportedIndexes + paradigmLimit, + (otherIndex - paradigmLimit) * sizeof(int32_t)); + } + supportedLSRsLength = otherIndex - (paradigmLimit - paradigmIndex); + } + + if (def != nullptr && (idef < 0 || def != supportedLocales[idef])) { + ownedDefaultLocale = def->clone(); + if (ownedDefaultLocale == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + def = ownedDefaultLocale; + } + defaultLocale = def; + defaultLocaleIndex = idef; + + if (builder.demotion_ == ULOCMATCH_DEMOTION_REGION) { + demotionPerDesiredLocale = localeDistance.getDefaultDemotionPerDesiredLocale(); + } +} + +LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT : + likelySubtags(src.likelySubtags), + localeDistance(src.localeDistance), + thresholdDistance(src.thresholdDistance), + demotionPerDesiredLocale(src.demotionPerDesiredLocale), + favorSubtag(src.favorSubtag), + supportedLocales(src.supportedLocales), lsrs(src.lsrs), + supportedLocalesLength(src.supportedLocalesLength), + supportedLsrToIndex(src.supportedLsrToIndex), + supportedLSRs(src.supportedLSRs), + supportedIndexes(src.supportedIndexes), + supportedLSRsLength(src.supportedLSRsLength), + ownedDefaultLocale(src.ownedDefaultLocale), defaultLocale(src.defaultLocale), + defaultLocaleIndex(src.defaultLocaleIndex) { + src.supportedLocales = nullptr; + src.lsrs = nullptr; + src.supportedLocalesLength = 0; + src.supportedLsrToIndex = nullptr; + src.supportedLSRs = nullptr; + src.supportedIndexes = nullptr; + src.supportedLSRsLength = 0; + src.ownedDefaultLocale = nullptr; + src.defaultLocale = nullptr; + src.defaultLocaleIndex = -1; +} + +LocaleMatcher::~LocaleMatcher() { + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + delete supportedLocales[i]; + } + uprv_free(supportedLocales); + delete[] lsrs; + uhash_close(supportedLsrToIndex); + uprv_free(supportedLSRs); + uprv_free(supportedIndexes); + delete ownedDefaultLocale; +} + +LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) U_NOEXCEPT { + this->~LocaleMatcher(); + + thresholdDistance = src.thresholdDistance; + demotionPerDesiredLocale = src.demotionPerDesiredLocale; + favorSubtag = src.favorSubtag; + supportedLocales = src.supportedLocales; + lsrs = src.lsrs; + supportedLocalesLength = src.supportedLocalesLength; + supportedLsrToIndex = src.supportedLsrToIndex; + supportedLSRs = src.supportedLSRs; + supportedIndexes = src.supportedIndexes; + supportedLSRsLength = src.supportedLSRsLength; + ownedDefaultLocale = src.ownedDefaultLocale; + defaultLocale = src.defaultLocale; + defaultLocaleIndex = src.defaultLocaleIndex; + + src.supportedLocales = nullptr; + src.lsrs = nullptr; + src.supportedLocalesLength = 0; + src.supportedLsrToIndex = nullptr; + src.supportedLSRs = nullptr; + src.supportedIndexes = nullptr; + src.supportedLSRsLength = 0; + src.ownedDefaultLocale = nullptr; + src.defaultLocale = nullptr; + src.defaultLocaleIndex = -1; + return *this; +} + +class LocaleLsrIterator { +public: + LocaleLsrIterator(const XLikelySubtags &likelySubtags, Locale::Iterator &locales, + ULocMatchLifetime lifetime) : + likelySubtags(likelySubtags), locales(locales), lifetime(lifetime) {} + + ~LocaleLsrIterator() { + if (lifetime == ULOCMATCH_TEMPORARY_LOCALES) { + delete remembered; + } + } + + bool hasNext() const { + return locales.hasNext(); + } + + LSR next(UErrorCode &errorCode) { + current = &locales.next(); + return getMaximalLsrOrUnd(likelySubtags, *current, errorCode); + } + + void rememberCurrent(int32_t desiredIndex, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + bestDesiredIndex = desiredIndex; + if (lifetime == ULOCMATCH_STORED_LOCALES) { + remembered = current; + } else { + // ULOCMATCH_TEMPORARY_LOCALES + delete remembered; + remembered = new Locale(*current); + if (remembered == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + } + } + } + + const Locale *orphanRemembered() { + const Locale *rem = remembered; + remembered = nullptr; + return rem; + } + + int32_t getBestDesiredIndex() const { + return bestDesiredIndex; + } + +private: + const XLikelySubtags &likelySubtags; + Locale::Iterator &locales; + ULocMatchLifetime lifetime; + const Locale *current = nullptr, *remembered = nullptr; + int32_t bestDesiredIndex = -1; +}; + +const Locale *LocaleMatcher::getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return nullptr; } + int32_t suppIndex = getBestSuppIndex( + getMaximalLsrOrUnd(likelySubtags, desiredLocale, errorCode), + nullptr, errorCode); + return U_SUCCESS(errorCode) && suppIndex >= 0 ? supportedLocales[suppIndex] : defaultLocale; +} + +const Locale *LocaleMatcher::getBestMatch(Locale::Iterator &desiredLocales, + UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return nullptr; } + if (!desiredLocales.hasNext()) { + return defaultLocale; + } + LocaleLsrIterator lsrIter(likelySubtags, desiredLocales, ULOCMATCH_TEMPORARY_LOCALES); + int32_t suppIndex = getBestSuppIndex(lsrIter.next(errorCode), &lsrIter, errorCode); + return U_SUCCESS(errorCode) && suppIndex >= 0 ? supportedLocales[suppIndex] : defaultLocale; +} + +const Locale *LocaleMatcher::getBestMatchForListString( + StringPiece desiredLocaleList, UErrorCode &errorCode) const { + LocalePriorityList list(desiredLocaleList, errorCode); + LocalePriorityList::Iterator iter = list.iterator(); + return getBestMatch(iter, errorCode); +} + +LocaleMatcher::Result LocaleMatcher::getBestMatchResult( + const Locale &desiredLocale, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } + int32_t suppIndex = getBestSuppIndex( + getMaximalLsrOrUnd(likelySubtags, desiredLocale, errorCode), + nullptr, errorCode); + if (U_FAILURE(errorCode) || suppIndex < 0) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } else { + return Result(&desiredLocale, supportedLocales[suppIndex], 0, suppIndex, FALSE); + } +} + +LocaleMatcher::Result LocaleMatcher::getBestMatchResult( + Locale::Iterator &desiredLocales, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode) || !desiredLocales.hasNext()) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } + LocaleLsrIterator lsrIter(likelySubtags, desiredLocales, ULOCMATCH_TEMPORARY_LOCALES); + int32_t suppIndex = getBestSuppIndex(lsrIter.next(errorCode), &lsrIter, errorCode); + if (U_FAILURE(errorCode) || suppIndex < 0) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } else { + return Result(lsrIter.orphanRemembered(), supportedLocales[suppIndex], + lsrIter.getBestDesiredIndex(), suppIndex, TRUE); + } +} + +int32_t LocaleMatcher::getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter, + UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return -1; } + int32_t desiredIndex = 0; + int32_t bestSupportedLsrIndex = -1; + for (int32_t bestDistance = thresholdDistance;;) { + // Quick check for exact maximized LSR. + // Returns suppIndex+1 where 0 means not found. + if (supportedLsrToIndex != nullptr) { + desiredLSR.setHashCode(); + int32_t index = uhash_geti(supportedLsrToIndex, &desiredLSR); + if (index != 0) { + int32_t suppIndex = index - 1; + if (remainingIter != nullptr) { + remainingIter->rememberCurrent(desiredIndex, errorCode); + } + return suppIndex; + } + } + int32_t bestIndexAndDistance = localeDistance.getBestIndexAndDistance( + desiredLSR, supportedLSRs, supportedLSRsLength, bestDistance, favorSubtag); + if (bestIndexAndDistance >= 0) { + bestDistance = bestIndexAndDistance & 0xff; + if (remainingIter != nullptr) { + remainingIter->rememberCurrent(desiredIndex, errorCode); + if (U_FAILURE(errorCode)) { return -1; } + } + bestSupportedLsrIndex = bestIndexAndDistance >= 0 ? bestIndexAndDistance >> 8 : -1; + } + if ((bestDistance -= demotionPerDesiredLocale) <= 0) { + break; + } + if (remainingIter == nullptr || !remainingIter->hasNext()) { + break; + } + desiredLSR = remainingIter->next(errorCode); + if (U_FAILURE(errorCode)) { return -1; } + ++desiredIndex; + } + if (bestSupportedLsrIndex < 0) { + // no good match + return -1; + } + return supportedIndexes[bestSupportedLsrIndex]; +} + +double LocaleMatcher::internalMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const { + // Returns the inverse of the distance: That is, 1-distance(desired, supported). + LSR suppLSR = getMaximalLsrOrUnd(likelySubtags, supported, errorCode); + if (U_FAILURE(errorCode)) { return 0; } + const LSR *pSuppLSR = &suppLSR; + int32_t distance = localeDistance.getBestIndexAndDistance( + getMaximalLsrOrUnd(likelySubtags, desired, errorCode), + &pSuppLSR, 1, + thresholdDistance, favorSubtag) & 0xff; + return (100 - distance) / 100.0; +} + +U_NAMESPACE_END + +#endif // __LOCMATCHER_H__ diff --git a/deps/icu-small/source/common/localeprioritylist.cpp b/deps/icu-small/source/common/localeprioritylist.cpp new file mode 100644 index 00000000000000..06442fb46a83ad --- /dev/null +++ b/deps/icu-small/source/common/localeprioritylist.cpp @@ -0,0 +1,239 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localeprioritylist.cpp +// created: 2019jul11 Markus W. Scherer + +#include "unicode/utypes.h" +#include "unicode/localpointer.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" +#include "charstr.h" +#include "cmemory.h" +#include "localeprioritylist.h" +#include "uarrsort.h" +#include "uassert.h" +#include "uhash.h" + +U_NAMESPACE_BEGIN + +namespace { + +int32_t hashLocale(const UHashTok token) { + auto *locale = static_cast(token.pointer); + return locale->hashCode(); +} + +UBool compareLocales(const UHashTok t1, const UHashTok t2) { + auto *l1 = static_cast(t1.pointer); + auto *l2 = static_cast(t2.pointer); + return *l1 == *l2; +} + +constexpr int32_t WEIGHT_ONE = 1000; + +struct LocaleAndWeight { + Locale *locale; + int32_t weight; // 0..1000 = 0.0..1.0 + int32_t index; // force stable sort + + int32_t compare(const LocaleAndWeight &other) const { + int32_t diff = other.weight - weight; // descending: other-this + if (diff != 0) { return diff; } + return index - other.index; + } +}; + +int32_t U_CALLCONV +compareLocaleAndWeight(const void * /*context*/, const void *left, const void *right) { + return static_cast(left)-> + compare(*static_cast(right)); +} + +const char *skipSpaces(const char *p, const char *limit) { + while (p < limit && *p == ' ') { ++p; } + return p; +} + +int32_t findTagLength(const char *p, const char *limit) { + // Look for accept-language delimiters. + // Leave other validation up to the Locale constructor. + const char *q; + for (q = p; q < limit; ++q) { + char c = *q; + if (c == ' ' || c == ',' || c == ';') { break; } + } + return static_cast(q - p); +} + +/** + * Parses and returns a qvalue weight in millis. + * Advances p to after the parsed substring. + * Returns a negative value if parsing fails. + */ +int32_t parseWeight(const char *&p, const char *limit) { + p = skipSpaces(p, limit); + char c; + if (p == limit || ((c = *p) != '0' && c != '1')) { return -1; } + int32_t weight = (c - '0') * 1000; + if (++p == limit || *p != '.') { return weight; } + int32_t multiplier = 100; + while (++p != limit && '0' <= (c = *p) && c <= '9') { + c -= '0'; + if (multiplier > 0) { + weight += c * multiplier; + multiplier /= 10; + } else if (multiplier == 0) { + // round up + if (c >= 5) { ++weight; } + multiplier = -1; + } // else ignore further fraction digits + } + return weight <= WEIGHT_ONE ? weight : -1; // bad if > 1.0 +} + +} // namespace + +/** + * Nothing but a wrapper over a MaybeStackArray of LocaleAndWeight. + * + * This wrapper exists (and is not in an anonymous namespace) + * so that we can forward-declare it in the header file and + * don't have to expose the MaybeStackArray specialization and + * the LocaleAndWeight to code (like the test) that #includes localeprioritylist.h. + * Also, otherwise we would have to do a platform-specific + * template export declaration of some kind for the MaybeStackArray specialization + * to be properly exported from the common DLL. + */ +struct LocaleAndWeightArray : public UMemory { + MaybeStackArray array; +}; + +LocalePriorityList::LocalePriorityList(StringPiece s, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + list = new LocaleAndWeightArray(); + if (list == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + const char *p = s.data(); + const char *limit = p + s.length(); + while ((p = skipSpaces(p, limit)) != limit) { + if (*p == ',') { // empty range field + ++p; + continue; + } + int32_t tagLength = findTagLength(p, limit); + if (tagLength == 0) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + CharString tag(p, tagLength, errorCode); + if (U_FAILURE(errorCode)) { return; } + Locale locale = Locale(tag.data()); + if (locale.isBogus()) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + int32_t weight = WEIGHT_ONE; + if ((p = skipSpaces(p + tagLength, limit)) != limit && *p == ';') { + if ((p = skipSpaces(p + 1, limit)) == limit || *p != 'q' || + (p = skipSpaces(p + 1, limit)) == limit || *p != '=' || + (++p, (weight = parseWeight(p, limit)) < 0)) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + p = skipSpaces(p, limit); + } + if (p != limit && *p != ',') { // trailing junk + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + add(locale, weight, errorCode); + if (p == limit) { break; } + ++p; + } + sort(errorCode); +} + +LocalePriorityList::~LocalePriorityList() { + if (list != nullptr) { + for (int32_t i = 0; i < listLength; ++i) { + delete list->array[i].locale; + } + delete list; + } + uhash_close(map); +} + +const Locale *LocalePriorityList::localeAt(int32_t i) const { + return list->array[i].locale; +} + +Locale *LocalePriorityList::orphanLocaleAt(int32_t i) { + if (list == nullptr) { return nullptr; } + LocaleAndWeight &lw = list->array[i]; + Locale *l = lw.locale; + lw.locale = nullptr; + return l; +} + +bool LocalePriorityList::add(const Locale &locale, int32_t weight, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return false; } + if (map == nullptr) { + if (weight <= 0) { return true; } // do not add q=0 + map = uhash_open(hashLocale, compareLocales, uhash_compareLong, &errorCode); + if (U_FAILURE(errorCode)) { return false; } + } + LocalPointer clone; + int32_t index = uhash_geti(map, &locale); + if (index != 0) { + // Duplicate: Remove the old item and append it anew. + LocaleAndWeight &lw = list->array[index - 1]; + clone.adoptInstead(lw.locale); + lw.locale = nullptr; + lw.weight = 0; + ++numRemoved; + } + if (weight <= 0) { // do not add q=0 + if (index != 0) { + // Not strictly necessary but cleaner. + uhash_removei(map, &locale); + } + return true; + } + if (clone.isNull()) { + clone.adoptInstead(locale.clone()); + if (clone.isNull() || (clone->isBogus() && !locale.isBogus())) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + } + if (listLength == list->array.getCapacity()) { + int32_t newCapacity = listLength < 50 ? 100 : 4 * listLength; + if (list->array.resize(newCapacity, listLength) == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + } + uhash_puti(map, clone.getAlias(), listLength + 1, &errorCode); + if (U_FAILURE(errorCode)) { return false; } + LocaleAndWeight &lw = list->array[listLength]; + lw.locale = clone.orphan(); + lw.weight = weight; + lw.index = listLength++; + if (weight < WEIGHT_ONE) { hasWeights = true; } + U_ASSERT(uhash_count(map) == getLength()); + return true; +} + +void LocalePriorityList::sort(UErrorCode &errorCode) { + // Sort by descending weights if there is a mix of weights. + // The comparator forces a stable sort via the item index. + if (U_FAILURE(errorCode) || getLength() <= 1 || !hasWeights) { return; } + uprv_sortArray(list->array.getAlias(), listLength, sizeof(LocaleAndWeight), + compareLocaleAndWeight, nullptr, FALSE, &errorCode); +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/localeprioritylist.h b/deps/icu-small/source/common/localeprioritylist.h new file mode 100644 index 00000000000000..80ca38a7b52892 --- /dev/null +++ b/deps/icu-small/source/common/localeprioritylist.h @@ -0,0 +1,115 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localeprioritylist.h +// created: 2019jul11 Markus W. Scherer + +#ifndef __LOCALEPRIORITYLIST_H__ +#define __LOCALEPRIORITYLIST_H__ + +#include "unicode/utypes.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" + +struct UHashtable; + +U_NAMESPACE_BEGIN + +struct LocaleAndWeightArray; + +/** + * Parses a list of locales from an accept-language string. + * We are a bit more lenient than the spec: + * We accept extra whitespace in more places, empty range fields, + * and any number of qvalue fraction digits. + * + * https://tools.ietf.org/html/rfc2616#section-14.4 + * 14.4 Accept-Language + * + * Accept-Language = "Accept-Language" ":" + * 1#( language-range [ ";" "q" "=" qvalue ] ) + * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) + * + * Each language-range MAY be given an associated quality value which + * represents an estimate of the user's preference for the languages + * specified by that range. The quality value defaults to "q=1". For + * example, + * + * Accept-Language: da, en-gb;q=0.8, en;q=0.7 + * + * https://tools.ietf.org/html/rfc2616#section-3.9 + * 3.9 Quality Values + * + * HTTP content negotiation (section 12) uses short "floating point" + * numbers to indicate the relative importance ("weight") of various + * negotiable parameters. A weight is normalized to a real number in + * the range 0 through 1, where 0 is the minimum and 1 the maximum + * value. If a parameter has a quality value of 0, then content with + * this parameter is `not acceptable' for the client. HTTP/1.1 + * applications MUST NOT generate more than three digits after the + * decimal point. User configuration of these values SHOULD also be + * limited in this fashion. + * + * qvalue = ( "0" [ "." 0*3DIGIT ] ) + * | ( "1" [ "." 0*3("0") ] ) + */ +class U_COMMON_API LocalePriorityList : public UMemory { +public: + class Iterator : public Locale::Iterator { + public: + UBool hasNext() const override { return count < length; } + + const Locale &next() override { + for(;;) { + const Locale *locale = list.localeAt(index++); + if (locale != nullptr) { + ++count; + return *locale; + } + } + } + + private: + friend class LocalePriorityList; + + Iterator(const LocalePriorityList &list) : list(list), length(list.getLength()) {} + + const LocalePriorityList &list; + int32_t index = 0; + int32_t count = 0; + const int32_t length; + }; + + LocalePriorityList(StringPiece s, UErrorCode &errorCode); + + ~LocalePriorityList(); + + int32_t getLength() const { return listLength - numRemoved; } + + int32_t getLengthIncludingRemoved() const { return listLength; } + + Iterator iterator() const { return Iterator(*this); } + + const Locale *localeAt(int32_t i) const; + + Locale *orphanLocaleAt(int32_t i); + +private: + LocalePriorityList(const LocalePriorityList &) = delete; + LocalePriorityList &operator=(const LocalePriorityList &) = delete; + + bool add(const Locale &locale, int32_t weight, UErrorCode &errorCode); + + void sort(UErrorCode &errorCode); + + LocaleAndWeightArray *list = nullptr; + int32_t listLength = 0; + int32_t numRemoved = 0; + bool hasWeights = false; // other than 1.0 + UHashtable *map = nullptr; +}; + +U_NAMESPACE_END + +#endif // __LOCALEPRIORITYLIST_H__ diff --git a/deps/icu-small/source/common/localsvc.h b/deps/icu-small/source/common/localsvc.h index 0339a44dcd95ec..33640195135bd8 100644 --- a/deps/icu-small/source/common/localsvc.h +++ b/deps/icu-small/source/common/localsvc.h @@ -16,7 +16,7 @@ /** * Prototype for user-supplied service hook. This function is expected to return * a type of factory object specific to the requested service. - * + * * @param what service-specific string identifying the specific user hook * @param status error status * @return a service-specific hook, or NULL on failure. diff --git a/deps/icu-small/source/common/locavailable.cpp b/deps/icu-small/source/common/locavailable.cpp index 1e608ffb9e1c84..e8ec512e370992 100644 --- a/deps/icu-small/source/common/locavailable.cpp +++ b/deps/icu-small/source/common/locavailable.cpp @@ -19,11 +19,13 @@ * that then do not depend on resource bundle code and res_index bundles. */ +#include "unicode/errorcode.h" #include "unicode/utypes.h" #include "unicode/locid.h" #include "unicode/uloc.h" #include "unicode/ures.h" #include "cmemory.h" +#include "cstring.h" #include "ucln_cmn.h" #include "uassert.h" #include "umutex.h" @@ -62,7 +64,7 @@ U_NAMESPACE_BEGIN void U_CALLCONV locale_available_init() { // This function is a friend of class Locale. // This function is only invoked via umtx_initOnce(). - + // for now, there is a hardcoded list, so just walk through that list and set it up. // Note: this function is a friend of class Locale. availableLocaleListCount = uloc_countAvailable(); @@ -95,84 +97,174 @@ U_NAMESPACE_USE /* ### Constants **************************************************/ -/* These strings describe the resources we attempt to load from - the locale ResourceBundle data file.*/ -static const char _kIndexLocaleName[] = "res_index"; -static const char _kIndexTag[] = "InstalledLocales"; +namespace { -static char** _installedLocales = NULL; -static int32_t _installedLocalesCount = 0; -static icu::UInitOnce _installedLocalesInitOnce; +// Enough capacity for the two lists in the res_index.res file +const char** gAvailableLocaleNames[2] = {}; +int32_t gAvailableLocaleCounts[2] = {}; +icu::UInitOnce ginstalledLocalesInitOnce = U_INITONCE_INITIALIZER; -/* ### Get available **************************************************/ +class AvailableLocalesSink : public ResourceSink { + public: + void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE { + ResourceTable resIndexTable = value.getTable(status); + if (U_FAILURE(status)) { + return; + } + for (int32_t i = 0; resIndexTable.getKeyAndValue(i, key, value); ++i) { + ULocAvailableType type; + if (uprv_strcmp(key, "InstalledLocales") == 0) { + type = ULOC_AVAILABLE_DEFAULT; + } else if (uprv_strcmp(key, "AliasLocales") == 0) { + type = ULOC_AVAILABLE_ONLY_LEGACY_ALIASES; + } else { + // CLDRVersion, etc. + continue; + } + ResourceTable availableLocalesTable = value.getTable(status); + if (U_FAILURE(status)) { + return; + } + gAvailableLocaleCounts[type] = availableLocalesTable.getSize(); + gAvailableLocaleNames[type] = static_cast( + uprv_malloc(gAvailableLocaleCounts[type] * sizeof(const char*))); + if (gAvailableLocaleNames[type] == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t j = 0; availableLocalesTable.getKeyAndValue(j, key, value); ++j) { + gAvailableLocaleNames[type][j] = key; + } + } + } +}; -static UBool U_CALLCONV uloc_cleanup(void) { - char ** temp; +class AvailableLocalesStringEnumeration : public StringEnumeration { + public: + AvailableLocalesStringEnumeration(ULocAvailableType type) : fType(type) { + } + + const char* next(int32_t *resultLength, UErrorCode&) override { + ULocAvailableType actualType = fType; + int32_t actualIndex = fIndex++; + + // If the "combined" list was requested, resolve that now + if (fType == ULOC_AVAILABLE_WITH_LEGACY_ALIASES) { + int32_t defaultLocalesCount = gAvailableLocaleCounts[ULOC_AVAILABLE_DEFAULT]; + if (actualIndex < defaultLocalesCount) { + actualType = ULOC_AVAILABLE_DEFAULT; + } else { + actualIndex -= defaultLocalesCount; + actualType = ULOC_AVAILABLE_ONLY_LEGACY_ALIASES; + } + } - if (_installedLocales) { - temp = _installedLocales; - _installedLocales = NULL; + // Return the requested string + int32_t count = gAvailableLocaleCounts[actualType]; + const char* result; + if (actualIndex < count) { + result = gAvailableLocaleNames[actualType][actualIndex]; + if (resultLength != nullptr) { + *resultLength = static_cast(uprv_strlen(result)); + } + } else { + result = nullptr; + if (resultLength != nullptr) { + *resultLength = 0; + } + } + return result; + } - _installedLocalesCount = 0; - _installedLocalesInitOnce.reset(); + void reset(UErrorCode&) override { + fIndex = 0; + } - uprv_free(temp); + int32_t count(UErrorCode&) const override { + if (fType == ULOC_AVAILABLE_WITH_LEGACY_ALIASES) { + return gAvailableLocaleCounts[ULOC_AVAILABLE_DEFAULT] + + gAvailableLocaleCounts[ULOC_AVAILABLE_ONLY_LEGACY_ALIASES]; + } else { + return gAvailableLocaleCounts[fType]; + } } + + private: + ULocAvailableType fType; + int32_t fIndex = 0; +}; + +/* ### Get available **************************************************/ + +static UBool U_CALLCONV uloc_cleanup(void) { + for (int32_t i = 0; i < UPRV_LENGTHOF(gAvailableLocaleNames); i++) { + uprv_free(gAvailableLocaleNames[i]); + gAvailableLocaleNames[i] = nullptr; + gAvailableLocaleCounts[i] = 0; + } + ginstalledLocalesInitOnce.reset(); return TRUE; } // Load Installed Locales. This function will be called exactly once // via the initOnce mechanism. -static void U_CALLCONV loadInstalledLocales() { - UErrorCode status = U_ZERO_ERROR; - int32_t i = 0; - int32_t localeCount; - - U_ASSERT(_installedLocales == NULL); - U_ASSERT(_installedLocalesCount == 0); +static void U_CALLCONV loadInstalledLocales(UErrorCode& status) { + ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup); - _installedLocalesCount = 0; + icu::LocalUResourceBundlePointer rb(ures_openDirect(NULL, "res_index", &status)); + AvailableLocalesSink sink; + ures_getAllItemsWithFallback(rb.getAlias(), "", sink, status); +} - icu::LocalUResourceBundlePointer indexLocale(ures_openDirect(NULL, _kIndexLocaleName, &status)); - icu::StackUResourceBundle installed; +void _load_installedLocales(UErrorCode& status) { + umtx_initOnce(ginstalledLocalesInitOnce, &loadInstalledLocales, status); +} - ures_getByKey(indexLocale.getAlias(), _kIndexTag, installed.getAlias(), &status); +} // namespace - if(U_SUCCESS(status)) { - localeCount = ures_getSize(installed.getAlias()); - _installedLocales = (char **) uprv_malloc(sizeof(char*) * (localeCount+1)); - if (_installedLocales != NULL) { - ures_resetIterator(installed.getAlias()); - while(ures_hasNext(installed.getAlias())) { - ures_getNextString(installed.getAlias(), NULL, (const char **)&_installedLocales[i++], &status); - } - _installedLocales[i] = NULL; - _installedLocalesCount = localeCount; - ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup); - } +U_CAPI const char* U_EXPORT2 +uloc_getAvailable(int32_t offset) { + icu::ErrorCode status; + _load_installedLocales(status); + if (status.isFailure()) { + return nullptr; + } + if (offset > gAvailableLocaleCounts[0]) { + // *status = U_ILLEGAL_ARGUMENT_ERROR; + return nullptr; } + return gAvailableLocaleNames[0][offset]; } -static void _load_installedLocales() -{ - umtx_initOnce(_installedLocalesInitOnce, &loadInstalledLocales); +U_CAPI int32_t U_EXPORT2 +uloc_countAvailable() { + icu::ErrorCode status; + _load_installedLocales(status); + if (status.isFailure()) { + return 0; + } + return gAvailableLocaleCounts[0]; } -U_CAPI const char* U_EXPORT2 -uloc_getAvailable(int32_t offset) -{ - - _load_installedLocales(); - - if (offset > _installedLocalesCount) - return NULL; - return _installedLocales[offset]; +U_CAPI UEnumeration* U_EXPORT2 +uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status) { + if (U_FAILURE(*status)) { + return nullptr; + } + if (type < 0 || type >= ULOC_AVAILABLE_COUNT) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return nullptr; + } + _load_installedLocales(*status); + if (U_FAILURE(*status)) { + return nullptr; + } + LocalPointer result( + new AvailableLocalesStringEnumeration(type), *status); + if (U_FAILURE(*status)) { + return nullptr; + } + return uenum_openFromStringEnumeration(result.orphan(), status); } -U_CAPI int32_t U_EXPORT2 -uloc_countAvailable() -{ - _load_installedLocales(); - return _installedLocalesCount; -} diff --git a/deps/icu-small/source/common/locbased.h b/deps/icu-small/source/common/locbased.h index 6db6a41dc416df..45738863b5ec96 100644 --- a/deps/icu-small/source/common/locbased.h +++ b/deps/icu-small/source/common/locbased.h @@ -22,7 +22,7 @@ * `actualLocale' of size ULOC_FULLNAME_CAPACITY */ #define U_LOCALE_BASED(varname, objname) \ - LocaleBased varname((objname).validLocale, (objname).actualLocale); + LocaleBased varname((objname).validLocale, (objname).actualLocale) U_NAMESPACE_BEGIN @@ -88,7 +88,7 @@ class U_COMMON_API LocaleBased : public UMemory { private: char* valid; - + char* actual; }; diff --git a/deps/icu-small/source/common/locdispnames.cpp b/deps/icu-small/source/common/locdispnames.cpp index 7216a3a3083e3d..d92348e31c8843 100644 --- a/deps/icu-small/source/common/locdispnames.cpp +++ b/deps/icu-small/source/common/locdispnames.cpp @@ -296,7 +296,7 @@ static const char _kSeparator[] = "separator"; static int32_t _getStringOrCopyKey(const char *path, const char *locale, - const char *tableKey, + const char *tableKey, const char* subTableKey, const char *itemKey, const char *substitute, @@ -320,7 +320,7 @@ _getStringOrCopyKey(const char *path, const char *locale, } else { /* second-level item, use special fallback */ s=uloc_getTableStringWithFallback(path, locale, - tableKey, + tableKey, subTableKey, itemKey, &length, @@ -409,7 +409,7 @@ uloc_getDisplayScript(const char* locale, UErrorCode err = U_ZERO_ERROR; int32_t res = _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity, uloc_getScript, _kScriptsStandAlone, &err); - + if ( err == U_USING_DEFAULT_WARNING ) { return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity, uloc_getScript, _kScripts, pErrorCode); @@ -488,7 +488,7 @@ uloc_getDisplayName(const char *locale, const UChar *pattern; int32_t patLen = 0; int32_t sub0Pos, sub1Pos; - + UChar formatOpenParen = 0x0028; // ( UChar formatReplaceOpenParen = 0x005B; // [ UChar formatCloseParen = 0x0029; // ) @@ -785,9 +785,9 @@ uloc_getDisplayKeyword(const char* keyword, /* pass itemKey=NULL to look for a top-level item */ return _getStringOrCopyKey(U_ICUDATA_LANG, displayLocale, - _kKeys, NULL, - keyword, - keyword, + _kKeys, NULL, + keyword, + keyword, dest, destCapacity, status); @@ -825,8 +825,8 @@ uloc_getDisplayKeywordValue( const char* locale, if (*status == U_STRING_NOT_TERMINATED_WARNING) *status = U_BUFFER_OVERFLOW_ERROR; - /* - * if the keyword is equal to currency .. then to get the display name + /* + * if the keyword is equal to currency .. then to get the display name * we need to do the fallback ourselves */ if(uprv_stricmp(keyword, _kCurrency)==0){ @@ -872,11 +872,11 @@ uloc_getDisplayKeywordValue( const char* locale, } } - + }else{ return _getStringOrCopyKey(U_ICUDATA_LANG, displayLocale, - _kTypes, keyword, + _kTypes, keyword, keywordValue, keywordValue, dest, destCapacity, diff --git a/deps/icu-small/source/common/locdistance.cpp b/deps/icu-small/source/common/locdistance.cpp new file mode 100644 index 00000000000000..800d0eacf2b605 --- /dev/null +++ b/deps/icu-small/source/common/locdistance.cpp @@ -0,0 +1,364 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// locdistance.cpp +// created: 2019may08 Markus W. Scherer + +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "cstring.h" +#include "locdistance.h" +#include "loclikelysubtags.h" +#include "uassert.h" +#include "ucln_cmn.h" +#include "uinvchar.h" +#include "umutex.h" + +U_NAMESPACE_BEGIN + +namespace { + +/** + * Bit flag used on the last character of a subtag in the trie. + * Must be set consistently by the builder and the lookup code. + */ +constexpr int32_t END_OF_SUBTAG = 0x80; +/** Distance value bit flag, set by the builder. */ +constexpr int32_t DISTANCE_SKIP_SCRIPT = 0x80; +/** Distance value bit flag, set by trieNext(). */ +constexpr int32_t DISTANCE_IS_FINAL = 0x100; +constexpr int32_t DISTANCE_IS_FINAL_OR_SKIP_SCRIPT = DISTANCE_IS_FINAL | DISTANCE_SKIP_SCRIPT; + +constexpr int32_t ABOVE_THRESHOLD = 100; + +// Indexes into array of distances. +enum { + IX_DEF_LANG_DISTANCE, + IX_DEF_SCRIPT_DISTANCE, + IX_DEF_REGION_DISTANCE, + IX_MIN_REGION_DISTANCE, + IX_LIMIT +}; + +LocaleDistance *gLocaleDistance = nullptr; +UInitOnce gInitOnce = U_INITONCE_INITIALIZER; + +UBool U_CALLCONV cleanup() { + delete gLocaleDistance; + gLocaleDistance = nullptr; + gInitOnce.reset(); + return TRUE; +} + +} // namespace + +void U_CALLCONV LocaleDistance::initLocaleDistance(UErrorCode &errorCode) { + // This function is invoked only via umtx_initOnce(). + U_ASSERT(gLocaleDistance == nullptr); + const XLikelySubtags &likely = *XLikelySubtags::getSingleton(errorCode); + if (U_FAILURE(errorCode)) { return; } + const LocaleDistanceData &data = likely.getDistanceData(); + if (data.distanceTrieBytes == nullptr || + data.regionToPartitions == nullptr || data.partitions == nullptr || + // ok if no paradigms + data.distances == nullptr) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + gLocaleDistance = new LocaleDistance(data); + if (gLocaleDistance == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + ucln_common_registerCleanup(UCLN_COMMON_LOCALE_DISTANCE, cleanup); +} + +const LocaleDistance *LocaleDistance::getSingleton(UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return nullptr; } + umtx_initOnce(gInitOnce, &LocaleDistance::initLocaleDistance, errorCode); + return gLocaleDistance; +} + +LocaleDistance::LocaleDistance(const LocaleDistanceData &data) : + trie(data.distanceTrieBytes), + regionToPartitionsIndex(data.regionToPartitions), partitionArrays(data.partitions), + paradigmLSRs(data.paradigms), paradigmLSRsLength(data.paradigmsLength), + defaultLanguageDistance(data.distances[IX_DEF_LANG_DISTANCE]), + defaultScriptDistance(data.distances[IX_DEF_SCRIPT_DISTANCE]), + defaultRegionDistance(data.distances[IX_DEF_REGION_DISTANCE]), + minRegionDistance(data.distances[IX_MIN_REGION_DISTANCE]) { + // For the default demotion value, use the + // default region distance between unrelated Englishes. + // Thus, unless demotion is turned off, + // a mere region difference for one desired locale + // is as good as a perfect match for the next following desired locale. + // As of CLDR 36, we have . + LSR en("en", "Latn", "US"); + LSR enGB("en", "Latn", "GB"); + const LSR *p_enGB = &enGB; + defaultDemotionPerDesiredLocale = getBestIndexAndDistance(en, &p_enGB, 1, + 50, ULOCMATCH_FAVOR_LANGUAGE) & 0xff; +} + +int32_t LocaleDistance::getBestIndexAndDistance( + const LSR &desired, + const LSR **supportedLSRs, int32_t supportedLSRsLength, + int32_t threshold, ULocMatchFavorSubtag favorSubtag) const { + BytesTrie iter(trie); + // Look up the desired language only once for all supported LSRs. + // Its "distance" is either a match point value of 0, or a non-match negative value. + // Note: The data builder verifies that there are no <*, supported> or rules. + int32_t desLangDistance = trieNext(iter, desired.language, false); + uint64_t desLangState = desLangDistance >= 0 && supportedLSRsLength > 1 ? iter.getState64() : 0; + // Index of the supported LSR with the lowest distance. + int32_t bestIndex = -1; + for (int32_t slIndex = 0; slIndex < supportedLSRsLength; ++slIndex) { + const LSR &supported = *supportedLSRs[slIndex]; + bool star = false; + int32_t distance = desLangDistance; + if (distance >= 0) { + U_ASSERT((distance & DISTANCE_IS_FINAL) == 0); + if (slIndex != 0) { + iter.resetToState64(desLangState); + } + distance = trieNext(iter, supported.language, true); + } + // Note: The data builder verifies that there are no rules with "any" (*) language and + // real (non *) script or region subtags. + // This means that if the lookup for either language fails we can use + // the default distances without further lookups. + int32_t flags; + if (distance >= 0) { + flags = distance & DISTANCE_IS_FINAL_OR_SKIP_SCRIPT; + distance &= ~DISTANCE_IS_FINAL_OR_SKIP_SCRIPT; + } else { // <*, *> + if (uprv_strcmp(desired.language, supported.language) == 0) { + distance = 0; + } else { + distance = defaultLanguageDistance; + } + flags = 0; + star = true; + } + U_ASSERT(0 <= distance && distance <= 100); + // We implement "favor subtag" by reducing the language subtag distance + // (unscientifically reducing it to a quarter of the normal value), + // so that the script distance is relatively more important. + // For example, given a default language distance of 80, we reduce it to 20, + // which is below the default threshold of 50, which is the default script distance. + if (favorSubtag == ULOCMATCH_FAVOR_SCRIPT) { + distance >>= 2; + } + if (distance >= threshold) { + continue; + } + + int32_t scriptDistance; + if (star || flags != 0) { + if (uprv_strcmp(desired.script, supported.script) == 0) { + scriptDistance = 0; + } else { + scriptDistance = defaultScriptDistance; + } + } else { + scriptDistance = getDesSuppScriptDistance(iter, iter.getState64(), + desired.script, supported.script); + flags = scriptDistance & DISTANCE_IS_FINAL; + scriptDistance &= ~DISTANCE_IS_FINAL; + } + distance += scriptDistance; + if (distance >= threshold) { + continue; + } + + if (uprv_strcmp(desired.region, supported.region) == 0) { + // regionDistance = 0 + } else if (star || (flags & DISTANCE_IS_FINAL) != 0) { + distance += defaultRegionDistance; + } else { + int32_t remainingThreshold = threshold - distance; + if (minRegionDistance >= remainingThreshold) { + continue; + } + + // From here on we know the regions are not equal. + // Map each region to zero or more partitions. (zero = one non-matching string) + // (Each array of single-character partition strings is encoded as one string.) + // If either side has more than one, then we find the maximum distance. + // This could be optimized by adding some more structure, but probably not worth it. + distance += getRegionPartitionsDistance( + iter, iter.getState64(), + partitionsForRegion(desired), + partitionsForRegion(supported), + remainingThreshold); + } + if (distance < threshold) { + if (distance == 0) { + return slIndex << 8; + } + bestIndex = slIndex; + threshold = distance; + } + } + return bestIndex >= 0 ? (bestIndex << 8) | threshold : 0xffffff00 | ABOVE_THRESHOLD; +} + +int32_t LocaleDistance::getDesSuppScriptDistance( + BytesTrie &iter, uint64_t startState, const char *desired, const char *supported) { + // Note: The data builder verifies that there are no <*, supported> or rules. + int32_t distance = trieNext(iter, desired, false); + if (distance >= 0) { + distance = trieNext(iter, supported, true); + } + if (distance < 0) { + UStringTrieResult result = iter.resetToState64(startState).next(u'*'); // <*, *> + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + if (uprv_strcmp(desired, supported) == 0) { + distance = 0; // same script + } else { + distance = iter.getValue(); + U_ASSERT(distance >= 0); + } + if (result == USTRINGTRIE_FINAL_VALUE) { + distance |= DISTANCE_IS_FINAL; + } + } + return distance; +} + +int32_t LocaleDistance::getRegionPartitionsDistance( + BytesTrie &iter, uint64_t startState, + const char *desiredPartitions, const char *supportedPartitions, int32_t threshold) { + char desired = *desiredPartitions++; + char supported = *supportedPartitions++; + U_ASSERT(desired != 0 && supported != 0); + // See if we have single desired/supported partitions, from NUL-terminated + // partition strings without explicit length. + bool suppLengthGt1 = *supportedPartitions != 0; // gt1: more than 1 character + // equivalent to: if (desLength == 1 && suppLength == 1) + if (*desiredPartitions == 0 && !suppLengthGt1) { + // Fastpath for single desired/supported partitions. + UStringTrieResult result = iter.next(uprv_invCharToAscii(desired) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_NEXT(result)) { + result = iter.next(uprv_invCharToAscii(supported) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_VALUE(result)) { + return iter.getValue(); + } + } + return getFallbackRegionDistance(iter, startState); + } + + const char *supportedStart = supportedPartitions - 1; // for restart of inner loop + int32_t regionDistance = 0; + // Fall back to * only once, not for each pair of partition strings. + bool star = false; + for (;;) { + // Look up each desired-partition string only once, + // not for each (desired, supported) pair. + UStringTrieResult result = iter.next(uprv_invCharToAscii(desired) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_NEXT(result)) { + uint64_t desState = suppLengthGt1 ? iter.getState64() : 0; + for (;;) { + result = iter.next(uprv_invCharToAscii(supported) | END_OF_SUBTAG); + int32_t d; + if (USTRINGTRIE_HAS_VALUE(result)) { + d = iter.getValue(); + } else if (star) { + d = 0; + } else { + d = getFallbackRegionDistance(iter, startState); + star = true; + } + if (d >= threshold) { + return d; + } else if (regionDistance < d) { + regionDistance = d; + } + if ((supported = *supportedPartitions++) != 0) { + iter.resetToState64(desState); + } else { + break; + } + } + } else if (!star) { + int32_t d = getFallbackRegionDistance(iter, startState); + if (d >= threshold) { + return d; + } else if (regionDistance < d) { + regionDistance = d; + } + star = true; + } + if ((desired = *desiredPartitions++) != 0) { + iter.resetToState64(startState); + supportedPartitions = supportedStart; + supported = *supportedPartitions++; + } else { + break; + } + } + return regionDistance; +} + +int32_t LocaleDistance::getFallbackRegionDistance(BytesTrie &iter, uint64_t startState) { +#if U_DEBUG + UStringTrieResult result = +#endif + iter.resetToState64(startState).next(u'*'); // <*, *> + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + int32_t distance = iter.getValue(); + U_ASSERT(distance >= 0); + return distance; +} + +int32_t LocaleDistance::trieNext(BytesTrie &iter, const char *s, bool wantValue) { + uint8_t c; + if ((c = *s) == 0) { + return -1; // no empty subtags in the distance data + } + for (;;) { + c = uprv_invCharToAscii(c); + // EBCDIC: If *s is not an invariant character, + // then c is now 0 and will simply not match anything, which is harmless. + uint8_t next = *++s; + if (next != 0) { + if (!USTRINGTRIE_HAS_NEXT(iter.next(c))) { + return -1; + } + } else { + // last character of this subtag + UStringTrieResult result = iter.next(c | END_OF_SUBTAG); + if (wantValue) { + if (USTRINGTRIE_HAS_VALUE(result)) { + int32_t value = iter.getValue(); + if (result == USTRINGTRIE_FINAL_VALUE) { + value |= DISTANCE_IS_FINAL; + } + return value; + } + } else { + if (USTRINGTRIE_HAS_NEXT(result)) { + return 0; + } + } + return -1; + } + c = next; + } +} + +UBool LocaleDistance::isParadigmLSR(const LSR &lsr) const { + // Linear search for a very short list (length 6 as of 2019). + // If there are many paradigm LSRs we should use a hash set. + U_ASSERT(paradigmLSRsLength <= 15); + for (int32_t i = 0; i < paradigmLSRsLength; ++i) { + if (lsr == paradigmLSRs[i]) { return true; } + } + return false; +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/locdistance.h b/deps/icu-small/source/common/locdistance.h new file mode 100644 index 00000000000000..7439f51c56bf8c --- /dev/null +++ b/deps/icu-small/source/common/locdistance.h @@ -0,0 +1,109 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// locdistance.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCDISTANCE_H__ +#define __LOCDISTANCE_H__ + +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "lsr.h" + +U_NAMESPACE_BEGIN + +struct LocaleDistanceData; + +/** + * Offline-built data for LocaleMatcher. + * Mostly but not only the data for mapping locales to their maximized forms. + */ +class LocaleDistance final : public UMemory { +public: + static const LocaleDistance *getSingleton(UErrorCode &errorCode); + + /** + * Finds the supported LSR with the smallest distance from the desired one. + * Equivalent LSR subtags must be normalized into a canonical form. + * + *

Returns the index of the lowest-distance supported LSR in bits 31..8 + * (negative if none has a distance below the threshold), + * and its distance (0..ABOVE_THRESHOLD) in bits 7..0. + */ + int32_t getBestIndexAndDistance(const LSR &desired, + const LSR **supportedLSRs, int32_t supportedLSRsLength, + int32_t threshold, ULocMatchFavorSubtag favorSubtag) const; + + int32_t getParadigmLSRsLength() const { return paradigmLSRsLength; } + + UBool isParadigmLSR(const LSR &lsr) const; + + int32_t getDefaultScriptDistance() const { + return defaultScriptDistance; + } + + int32_t getDefaultDemotionPerDesiredLocale() const { + return defaultDemotionPerDesiredLocale; + } + +private: + LocaleDistance(const LocaleDistanceData &data); + LocaleDistance(const LocaleDistance &other) = delete; + LocaleDistance &operator=(const LocaleDistance &other) = delete; + + static void initLocaleDistance(UErrorCode &errorCode); + + static int32_t getDesSuppScriptDistance(BytesTrie &iter, uint64_t startState, + const char *desired, const char *supported); + + static int32_t getRegionPartitionsDistance( + BytesTrie &iter, uint64_t startState, + const char *desiredPartitions, const char *supportedPartitions, + int32_t threshold); + + static int32_t getFallbackRegionDistance(BytesTrie &iter, uint64_t startState); + + static int32_t trieNext(BytesTrie &iter, const char *s, bool wantValue); + + const char *partitionsForRegion(const LSR &lsr) const { + // ill-formed region -> one non-matching string + int32_t pIndex = regionToPartitionsIndex[lsr.regionIndex]; + return partitionArrays[pIndex]; + } + + int32_t getDefaultRegionDistance() const { + return defaultRegionDistance; + } + + // The trie maps each dlang+slang+dscript+sscript+dregion+sregion + // (encoded in ASCII with bit 7 set on the last character of each subtag) to a distance. + // There is also a trie value for each subsequence of whole subtags. + // One '*' is used for a (desired, supported) pair of "und", "Zzzz"/"", or "ZZ"/"". + BytesTrie trie; + + /** + * Maps each region to zero or more single-character partitions. + */ + const uint8_t *regionToPartitionsIndex; + const char **partitionArrays; + + /** + * Used to get the paradigm region for a cluster, if there is one. + */ + const LSR *paradigmLSRs; + int32_t paradigmLSRsLength; + + int32_t defaultLanguageDistance; + int32_t defaultScriptDistance; + int32_t defaultRegionDistance; + int32_t minRegionDistance; + int32_t defaultDemotionPerDesiredLocale; +}; + +U_NAMESPACE_END + +#endif // __LOCDISTANCE_H__ diff --git a/deps/icu-small/source/common/locdspnm.cpp b/deps/icu-small/source/common/locdspnm.cpp index da35be9e766e50..43334f51964622 100644 --- a/deps/icu-small/source/common/locdspnm.cpp +++ b/deps/icu-small/source/common/locdspnm.cpp @@ -291,6 +291,7 @@ class LocaleDisplayNamesImpl : public LocaleDisplayNames { UnicodeString formatCloseParen; UnicodeString formatReplaceCloseParen; UDisplayContext nameLength; + UDisplayContext substitute; // Constants for capitalization context usage types. enum CapContextUsage { @@ -337,7 +338,7 @@ class LocaleDisplayNamesImpl : public LocaleDisplayNames { UnicodeString& result) const; private: UnicodeString& localeIdName(const char* localeId, - UnicodeString& result) const; + UnicodeString& result, bool substitute) const; UnicodeString& appendWithSep(UnicodeString& buffer, const UnicodeString& src) const; UnicodeString& adjustForUsageAndContext(CapContextUsage usage, UnicodeString& result) const; UnicodeString& scriptDisplayName(const char* script, UnicodeString& result, UBool skipAdjust) const; @@ -359,6 +360,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE) , capitalizationBrkIter(NULL) , nameLength(UDISPCTX_LENGTH_FULL) + , substitute(UDISPCTX_SUBSTITUTE) { initialize(); } @@ -371,6 +373,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE) , capitalizationBrkIter(NULL) , nameLength(UDISPCTX_LENGTH_FULL) + , substitute(UDISPCTX_SUBSTITUTE) { while (length-- > 0) { UDisplayContext value = *contexts++; @@ -385,6 +388,9 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, case UDISPCTX_TYPE_DISPLAY_LENGTH: nameLength = value; break; + case UDISPCTX_TYPE_SUBSTITUTE_HANDLING: + substitute = value; + break; default: break; } @@ -535,6 +541,8 @@ LocaleDisplayNamesImpl::getContext(UDisplayContextType type) const { return capitalizationContext; case UDISPCTX_TYPE_DISPLAY_LENGTH: return nameLength; + case UDISPCTX_TYPE_SUBSTITUTE_HANDLING: + return substitute; default: break; } @@ -549,7 +557,7 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage, if ( result.length() > 0 && u_islower(result.char32At(0)) && capitalizationBrkIter!= NULL && ( capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || fCapitalization[usage] ) ) { // note fCapitalization[usage] won't be set unless capitalizationContext is UI_LIST_OR_MENU or STANDALONE - static UMutex capitalizationBrkIterLock = U_MUTEX_INITIALIZER; + static UMutex capitalizationBrkIterLock; Mutex lock(&capitalizationBrkIterLock); result.toTitle(capitalizationBrkIter, locale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); } @@ -583,7 +591,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, do { // loop construct is so we can break early out of search if (hasScript && hasCountry) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, "_", country, (char *)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasScript = FALSE; hasCountry = FALSE; @@ -592,7 +600,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } if (hasScript) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, (char *)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasScript = FALSE; break; @@ -600,7 +608,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } if (hasCountry) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", country, (char*)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasCountry = FALSE; break; @@ -609,7 +617,11 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } while (FALSE); } if (resultName.isBogus() || resultName.isEmpty()) { - localeIdName(lang, resultName); + localeIdName(lang, resultName, substitute == UDISPCTX_SUBSTITUTE); + if (resultName.isBogus()) { + result.setToBogus(); + return result; + } } UnicodeString resultRemainder; @@ -617,13 +629,28 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, UErrorCode status = U_ZERO_ERROR; if (hasScript) { - resultRemainder.append(scriptDisplayName(script, temp, TRUE)); + UnicodeString script_str = scriptDisplayName(script, temp, TRUE); + if (script_str.isBogus()) { + result.setToBogus(); + return result; + } + resultRemainder.append(script_str); } if (hasCountry) { - appendWithSep(resultRemainder, regionDisplayName(country, temp, TRUE)); + UnicodeString region_str = regionDisplayName(country, temp, TRUE); + if (region_str.isBogus()) { + result.setToBogus(); + return result; + } + appendWithSep(resultRemainder, region_str); } if (hasVariant) { - appendWithSep(resultRemainder, variantDisplayName(variant, temp, TRUE)); + UnicodeString variant_str = variantDisplayName(variant, temp, TRUE); + if (variant_str.isBogus()) { + result.setToBogus(); + return result; + } + appendWithSep(resultRemainder, variant_str); } resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen); resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen); @@ -689,14 +716,18 @@ LocaleDisplayNamesImpl::localeDisplayName(const char* localeId, // private UnicodeString& LocaleDisplayNamesImpl::localeIdName(const char* localeId, - UnicodeString& result) const { + UnicodeString& result, bool substitute) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { langData.getNoFallback("Languages%short", localeId, result); if (!result.isBogus()) { return result; } } - return langData.getNoFallback("Languages", localeId, result); + if (substitute) { + return langData.get("Languages", localeId, result); + } else { + return langData.getNoFallback("Languages", localeId, result); + } } UnicodeString& @@ -706,12 +737,16 @@ LocaleDisplayNamesImpl::languageDisplayName(const char* lang, return result = UnicodeString(lang, -1, US_INV); } if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Languages%short", lang, result); + langData.getNoFallback("Languages%short", lang, result); if (!result.isBogus()) { return adjustForUsageAndContext(kCapContextUsageLanguage, result); } } - langData.get("Languages", lang, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Languages", lang, result); + } else { + langData.getNoFallback("Languages", lang, result); + } return adjustForUsageAndContext(kCapContextUsageLanguage, result); } @@ -720,12 +755,16 @@ LocaleDisplayNamesImpl::scriptDisplayName(const char* script, UnicodeString& result, UBool skipAdjust) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Scripts%short", script, result); + langData.getNoFallback("Scripts%short", script, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result); } } - langData.get("Scripts", script, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Scripts", script, result); + } else { + langData.getNoFallback("Scripts", script, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result); } @@ -746,12 +785,16 @@ LocaleDisplayNamesImpl::regionDisplayName(const char* region, UnicodeString& result, UBool skipAdjust) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { - regionData.get("Countries%short", region, result); + regionData.getNoFallback("Countries%short", region, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result); } } - regionData.get("Countries", region, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + regionData.get("Countries", region, result); + } else { + regionData.getNoFallback("Countries", region, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result); } @@ -767,7 +810,11 @@ LocaleDisplayNamesImpl::variantDisplayName(const char* variant, UnicodeString& result, UBool skipAdjust) const { // don't have a resource for short variant names - langData.get("Variants", variant, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Variants", variant, result); + } else { + langData.getNoFallback("Variants", variant, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageVariant, result); } @@ -782,7 +829,11 @@ LocaleDisplayNamesImpl::keyDisplayName(const char* key, UnicodeString& result, UBool skipAdjust) const { // don't have a resource for short key names - langData.get("Keys", key, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Keys", key, result); + } else { + langData.getNoFallback("Keys", key, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKey, result); } @@ -802,9 +853,8 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key, UErrorCode sts = U_ZERO_ERROR; UnicodeString ustrValue(value, -1, US_INV); int32_t len; - UBool isChoice = FALSE; const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(), - locale.getBaseName(), UCURR_LONG_NAME, &isChoice, &len, &sts); + locale.getBaseName(), UCURR_LONG_NAME, nullptr /* isChoiceFormat */, &len, &sts); if (U_FAILURE(sts)) { // Return the value as is on failure result = ustrValue; @@ -815,12 +865,16 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key, } if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Types%short", key, value, result); + langData.getNoFallback("Types%short", key, value, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } } - langData.get("Types", key, value, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Types", key, value, result); + } else { + langData.getNoFallback("Types", key, value, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } diff --git a/deps/icu-small/source/common/locid.cpp b/deps/icu-small/source/common/locid.cpp index 06986b636adc31..c6d3f88fc3be07 100644 --- a/deps/icu-small/source/common/locid.cpp +++ b/deps/icu-small/source/common/locid.cpp @@ -38,19 +38,19 @@ #include "unicode/strenum.h" #include "unicode/stringpiece.h" #include "unicode/uloc.h" -#include "putilimp.h" -#include "mutex.h" -#include "umutex.h" -#include "uassert.h" + +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" +#include "mutex.h" +#include "putilimp.h" #include "uassert.h" +#include "ucln_cmn.h" #include "uhash.h" #include "ulocimp.h" -#include "ucln_cmn.h" +#include "umutex.h" #include "ustr_imp.h" -#include "charstr.h" -#include "bytesinkutil.h" U_CDECL_BEGIN static UBool U_CALLCONV locale_cleanup(void); @@ -62,10 +62,7 @@ static Locale *gLocaleCache = NULL; static UInitOnce gLocaleCacheInitOnce = U_INITONCE_INITIALIZER; // gDefaultLocaleMutex protects all access to gDefaultLocalesHashT and gDefaultLocale. -static UMutex *gDefaultLocaleMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gDefaultLocaleMutex; static UHashtable *gDefaultLocalesHashT = NULL; static Locale *gDefaultLocale = NULL; @@ -174,7 +171,7 @@ U_NAMESPACE_BEGIN Locale *locale_set_default_internal(const char *id, UErrorCode& status) { // Synchronize this entire function. - Mutex lock(gDefaultLocaleMutex()); + Mutex lock(&gDefaultLocaleMutex); UBool canonicalize = FALSE; @@ -711,7 +708,7 @@ const Locale& U_EXPORT2 Locale::getDefault() { { - Mutex lock(gDefaultLocaleMutex()); + Mutex lock(&gDefaultLocaleMutex); if (gDefaultLocale != NULL) { return *gDefaultLocale; } @@ -1399,5 +1396,7 @@ Locale::getBaseName() const { return baseName; } +Locale::Iterator::~Iterator() = default; + //eof U_NAMESPACE_END diff --git a/deps/icu-small/source/common/loclikely.cpp b/deps/icu-small/source/common/loclikely.cpp index 50cc2a65de0b2d..a4a4181cb13b5c 100644 --- a/deps/icu-small/source/common/loclikely.cpp +++ b/deps/icu-small/source/common/loclikely.cpp @@ -148,7 +148,7 @@ appendTag( * to be used when constructing the new tag. If the alternateTags parameter is NULL, or * it contains no language tag, the default tag for the unknown language is used. * - * If the length of the new string exceeds the capacity of the output buffer, + * If the length of the new string exceeds the capacity of the output buffer, * the function copies as many bytes to the output buffer as it can, and returns * the error U_BUFFER_OVERFLOW_ERROR. * @@ -366,7 +366,7 @@ createTagStringWithAlternates( * must be less than or equal to 0. If the lang parameter is an empty string, the * default value for an unknown language is written to the output buffer. * - * If the length of the new string exceeds the capacity of the output buffer, + * If the length of the new string exceeds the capacity of the output buffer, * the function copies as many bytes to the output buffer as it can, and returns * the error U_BUFFER_OVERFLOW_ERROR. * @@ -508,7 +508,7 @@ parseTagString( */ if (_isIDSeparator(*position)) { ++position; - } + } } subtagLength = ulocimp_getCountry(position, region, *regionLength, &position); @@ -807,24 +807,24 @@ createLikelySubtagsString( return FALSE; } -#define CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength) \ - { int32_t count = 0; \ - int32_t i; \ - for (i = 0; i < trailingLength; i++) { \ - if (trailing[i] == '-' || trailing[i] == '_') { \ - count = 0; \ - if (count > 8) { \ - goto error; \ - } \ - } else if (trailing[i] == '@') { \ - break; \ - } else if (count > 8) { \ +#define CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength) UPRV_BLOCK_MACRO_BEGIN { \ + int32_t count = 0; \ + int32_t i; \ + for (i = 0; i < trailingLength; i++) { \ + if (trailing[i] == '-' || trailing[i] == '_') { \ + count = 0; \ + if (count > 8) { \ goto error; \ - } else { \ - count++; \ } \ + } else if (trailing[i] == '@') { \ + break; \ + } else if (count > 8) { \ + goto error; \ + } else { \ + count++; \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END static void _uloc_addLikelySubtags(const char* localeID, @@ -1355,3 +1355,4 @@ ulocimp_getRegionForSupplementalData(const char *localeID, UBool inferRegion, uprv_strncpy(region, rgBuf, regionCapacity); return u_terminateChars(region, regionCapacity, rgLen, status); } + diff --git a/deps/icu-small/source/common/loclikelysubtags.cpp b/deps/icu-small/source/common/loclikelysubtags.cpp new file mode 100644 index 00000000000000..d7f5e124c2c790 --- /dev/null +++ b/deps/icu-small/source/common/loclikelysubtags.cpp @@ -0,0 +1,638 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// loclikelysubtags.cpp +// created: 2019may08 Markus W. Scherer + +#include +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localpointer.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "charstr.h" +#include "cstring.h" +#include "loclikelysubtags.h" +#include "lsr.h" +#include "uassert.h" +#include "ucln_cmn.h" +#include "uhash.h" +#include "uinvchar.h" +#include "umutex.h" +#include "uresdata.h" +#include "uresimp.h" + +U_NAMESPACE_BEGIN + +namespace { + +constexpr char PSEUDO_ACCENTS_PREFIX = '\''; // -XA, -PSACCENT +constexpr char PSEUDO_BIDI_PREFIX = '+'; // -XB, -PSBIDI +constexpr char PSEUDO_CRACKED_PREFIX = ','; // -XC, -PSCRACK + +/** + * Stores NUL-terminated strings with duplicate elimination. + * Checks for unique UTF-16 string pointers and converts to invariant characters. + */ +class UniqueCharStrings { +public: + UniqueCharStrings(UErrorCode &errorCode) : strings(nullptr) { + uhash_init(&map, uhash_hashUChars, uhash_compareUChars, uhash_compareLong, &errorCode); + if (U_FAILURE(errorCode)) { return; } + strings = new CharString(); + if (strings == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + } + } + ~UniqueCharStrings() { + uhash_close(&map); + delete strings; + } + + /** Returns/orphans the CharString that contains all strings. */ + CharString *orphanCharStrings() { + CharString *result = strings; + strings = nullptr; + return result; + } + + /** Adds a string and returns a unique number for it. */ + int32_t add(const UnicodeString &s, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return 0; } + if (isFrozen) { + errorCode = U_NO_WRITE_PERMISSION; + return 0; + } + // The string points into the resource bundle. + const char16_t *p = s.getBuffer(); + int32_t oldIndex = uhash_geti(&map, p); + if (oldIndex != 0) { // found duplicate + return oldIndex; + } + // Explicit NUL terminator for the previous string. + // The strings object is also terminated with one implicit NUL. + strings->append(0, errorCode); + int32_t newIndex = strings->length(); + strings->appendInvariantChars(s, errorCode); + uhash_puti(&map, const_cast(p), newIndex, &errorCode); + return newIndex; + } + + void freeze() { isFrozen = true; } + + /** + * Returns a string pointer for its unique number, if this object is frozen. + * Otherwise nullptr. + */ + const char *get(int32_t i) const { + U_ASSERT(isFrozen); + return isFrozen && i > 0 ? strings->data() + i : nullptr; + } + +private: + UHashtable map; + CharString *strings; + bool isFrozen = false; +}; + +} // namespace + +LocaleDistanceData::LocaleDistanceData(LocaleDistanceData &&data) : + distanceTrieBytes(data.distanceTrieBytes), + regionToPartitions(data.regionToPartitions), + partitions(data.partitions), + paradigms(data.paradigms), paradigmsLength(data.paradigmsLength), + distances(data.distances) { + data.partitions = nullptr; + data.paradigms = nullptr; +} + +LocaleDistanceData::~LocaleDistanceData() { + uprv_free(partitions); + delete[] paradigms; +} + +// TODO(ICU-20777): Rename to just LikelySubtagsData. +struct XLikelySubtagsData { + UResourceBundle *langInfoBundle = nullptr; + UniqueCharStrings strings; + CharStringMap languageAliases; + CharStringMap regionAliases; + const uint8_t *trieBytes = nullptr; + LSR *lsrs = nullptr; + int32_t lsrsLength = 0; + + LocaleDistanceData distanceData; + + XLikelySubtagsData(UErrorCode &errorCode) : strings(errorCode) {} + + ~XLikelySubtagsData() { + ures_close(langInfoBundle); + delete[] lsrs; + } + + void load(UErrorCode &errorCode) { + langInfoBundle = ures_openDirect(nullptr, "langInfo", &errorCode); + if (U_FAILURE(errorCode)) { return; } + StackUResourceBundle stackTempBundle; + ResourceDataValue value; + ures_getValueWithFallback(langInfoBundle, "likely", stackTempBundle.getAlias(), + value, errorCode); + ResourceTable likelyTable = value.getTable(errorCode); + if (U_FAILURE(errorCode)) { return; } + + // Read all strings in the resource bundle and convert them to invariant char *. + LocalMemory languageIndexes, regionIndexes, lsrSubtagIndexes; + int32_t languagesLength = 0, regionsLength = 0, lsrSubtagsLength = 0; + if (!readStrings(likelyTable, "languageAliases", value, + languageIndexes, languagesLength, errorCode) || + !readStrings(likelyTable, "regionAliases", value, + regionIndexes, regionsLength, errorCode) || + !readStrings(likelyTable, "lsrs", value, + lsrSubtagIndexes,lsrSubtagsLength, errorCode)) { + return; + } + if ((languagesLength & 1) != 0 || + (regionsLength & 1) != 0 || + (lsrSubtagsLength % 3) != 0) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + if (lsrSubtagsLength == 0) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + + if (!likelyTable.findValue("trie", value)) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + int32_t length; + trieBytes = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + + // Also read distance/matcher data if available, + // to open & keep only one resource bundle pointer + // and to use one single UniqueCharStrings. + UErrorCode matchErrorCode = U_ZERO_ERROR; + ures_getValueWithFallback(langInfoBundle, "match", stackTempBundle.getAlias(), + value, matchErrorCode); + LocalMemory partitionIndexes, paradigmSubtagIndexes; + int32_t partitionsLength = 0, paradigmSubtagsLength = 0; + if (U_SUCCESS(matchErrorCode)) { + ResourceTable matchTable = value.getTable(errorCode); + if (U_FAILURE(errorCode)) { return; } + + if (matchTable.findValue("trie", value)) { + distanceData.distanceTrieBytes = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + } + + if (matchTable.findValue("regionToPartitions", value)) { + distanceData.regionToPartitions = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + if (length < LSR::REGION_INDEX_LIMIT) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + } + + if (!readStrings(matchTable, "partitions", value, + partitionIndexes, partitionsLength, errorCode) || + !readStrings(matchTable, "paradigms", value, + paradigmSubtagIndexes, paradigmSubtagsLength, errorCode)) { + return; + } + if ((paradigmSubtagsLength % 3) != 0) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + + if (matchTable.findValue("distances", value)) { + distanceData.distances = value.getIntVector(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + if (length < 4) { // LocaleDistance IX_LIMIT + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + } + } else if (matchErrorCode == U_MISSING_RESOURCE_ERROR) { + // ok for likely subtags + } else { // error other than missing resource + errorCode = matchErrorCode; + return; + } + + // Fetch & store invariant-character versions of strings + // only after we have collected and de-duplicated all of them. + strings.freeze(); + + languageAliases = CharStringMap(languagesLength / 2, errorCode); + for (int32_t i = 0; i < languagesLength; i += 2) { + languageAliases.put(strings.get(languageIndexes[i]), + strings.get(languageIndexes[i + 1]), errorCode); + } + + regionAliases = CharStringMap(regionsLength / 2, errorCode); + for (int32_t i = 0; i < regionsLength; i += 2) { + regionAliases.put(strings.get(regionIndexes[i]), + strings.get(regionIndexes[i + 1]), errorCode); + } + if (U_FAILURE(errorCode)) { return; } + + lsrsLength = lsrSubtagsLength / 3; + lsrs = new LSR[lsrsLength]; + if (lsrs == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0, j = 0; i < lsrSubtagsLength; i += 3, ++j) { + lsrs[j] = LSR(strings.get(lsrSubtagIndexes[i]), + strings.get(lsrSubtagIndexes[i + 1]), + strings.get(lsrSubtagIndexes[i + 2])); + } + + if (partitionsLength > 0) { + distanceData.partitions = static_cast( + uprv_malloc(partitionsLength * sizeof(const char *))); + if (distanceData.partitions == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0; i < partitionsLength; ++i) { + distanceData.partitions[i] = strings.get(partitionIndexes[i]); + } + } + + if (paradigmSubtagsLength > 0) { + distanceData.paradigmsLength = paradigmSubtagsLength / 3; + LSR *paradigms = new LSR[distanceData.paradigmsLength]; + if (paradigms == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0, j = 0; i < paradigmSubtagsLength; i += 3, ++j) { + paradigms[j] = LSR(strings.get(paradigmSubtagIndexes[i]), + strings.get(paradigmSubtagIndexes[i + 1]), + strings.get(paradigmSubtagIndexes[i + 2])); + } + distanceData.paradigms = paradigms; + } + } + +private: + bool readStrings(const ResourceTable &table, const char *key, ResourceValue &value, + LocalMemory &indexes, int32_t &length, UErrorCode &errorCode) { + if (table.findValue(key, value)) { + ResourceArray stringArray = value.getArray(errorCode); + if (U_FAILURE(errorCode)) { return false; } + length = stringArray.getSize(); + if (length == 0) { return true; } + int32_t *rawIndexes = indexes.allocateInsteadAndCopy(length); + if (rawIndexes == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + for (int i = 0; i < length; ++i) { + stringArray.getValue(i, value); // returns TRUE because i < length + rawIndexes[i] = strings.add(value.getUnicodeString(errorCode), errorCode); + if (U_FAILURE(errorCode)) { return false; } + } + } + return true; + } +}; + +namespace { + +XLikelySubtags *gLikelySubtags = nullptr; +UInitOnce gInitOnce = U_INITONCE_INITIALIZER; + +UBool U_CALLCONV cleanup() { + delete gLikelySubtags; + gLikelySubtags = nullptr; + gInitOnce.reset(); + return TRUE; +} + +} // namespace + +void U_CALLCONV XLikelySubtags::initLikelySubtags(UErrorCode &errorCode) { + // This function is invoked only via umtx_initOnce(). + U_ASSERT(gLikelySubtags == nullptr); + XLikelySubtagsData data(errorCode); + data.load(errorCode); + if (U_FAILURE(errorCode)) { return; } + gLikelySubtags = new XLikelySubtags(data); + if (gLikelySubtags == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + ucln_common_registerCleanup(UCLN_COMMON_LIKELY_SUBTAGS, cleanup); +} + +const XLikelySubtags *XLikelySubtags::getSingleton(UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return nullptr; } + umtx_initOnce(gInitOnce, &XLikelySubtags::initLikelySubtags, errorCode); + return gLikelySubtags; +} + +XLikelySubtags::XLikelySubtags(XLikelySubtagsData &data) : + langInfoBundle(data.langInfoBundle), + strings(data.strings.orphanCharStrings()), + languageAliases(std::move(data.languageAliases)), + regionAliases(std::move(data.regionAliases)), + trie(data.trieBytes), + lsrs(data.lsrs), +#if U_DEBUG + lsrsLength(data.lsrsLength), +#endif + distanceData(std::move(data.distanceData)) { + data.langInfoBundle = nullptr; + data.lsrs = nullptr; + + // Cache the result of looking up language="und" encoded as "*", and "und-Zzzz" ("**"). + UStringTrieResult result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_NEXT(result)); + trieUndState = trie.getState64(); + result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_NEXT(result)); + trieUndZzzzState = trie.getState64(); + result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + defaultLsrIndex = trie.getValue(); + trie.reset(); + + for (char16_t c = u'a'; c <= u'z'; ++c) { + result = trie.next(c); + if (result == USTRINGTRIE_NO_VALUE) { + trieFirstLetterStates[c - u'a'] = trie.getState64(); + } + trie.reset(); + } +} + +XLikelySubtags::~XLikelySubtags() { + ures_close(langInfoBundle); + delete strings; + delete[] lsrs; +} + +LSR XLikelySubtags::makeMaximizedLsrFrom(const Locale &locale, UErrorCode &errorCode) const { + const char *name = locale.getName(); + if (uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=") + // Private use language tag x-subtag-subtag... + return LSR(name, "", ""); + } + return makeMaximizedLsr(locale.getLanguage(), locale.getScript(), locale.getCountry(), + locale.getVariant(), errorCode); +} + +namespace { + +const char *getCanonical(const CharStringMap &aliases, const char *alias) { + const char *canonical = aliases.get(alias); + return canonical == nullptr ? alias : canonical; +} + +} // namespace + +LSR XLikelySubtags::makeMaximizedLsr(const char *language, const char *script, const char *region, + const char *variant, UErrorCode &errorCode) const { + // Handle pseudolocales like en-XA, ar-XB, fr-PSCRACK. + // They should match only themselves, + // not other locales with what looks like the same language and script subtags. + char c1; + if (region[0] == 'X' && (c1 = region[1]) != 0 && region[2] == 0) { + switch (c1) { + case 'A': + return LSR(PSEUDO_ACCENTS_PREFIX, language, script, region, errorCode); + case 'B': + return LSR(PSEUDO_BIDI_PREFIX, language, script, region, errorCode); + case 'C': + return LSR(PSEUDO_CRACKED_PREFIX, language, script, region, errorCode); + default: // normal locale + break; + } + } + + if (variant[0] == 'P' && variant[1] == 'S') { + if (uprv_strcmp(variant, "PSACCENT") == 0) { + return LSR(PSEUDO_ACCENTS_PREFIX, language, script, + *region == 0 ? "XA" : region, errorCode); + } else if (uprv_strcmp(variant, "PSBIDI") == 0) { + return LSR(PSEUDO_BIDI_PREFIX, language, script, + *region == 0 ? "XB" : region, errorCode); + } else if (uprv_strcmp(variant, "PSCRACK") == 0) { + return LSR(PSEUDO_CRACKED_PREFIX, language, script, + *region == 0 ? "XC" : region, errorCode); + } + // else normal locale + } + + language = getCanonical(languageAliases, language); + // (We have no script mappings.) + region = getCanonical(regionAliases, region); + return maximize(language, script, region); +} + +LSR XLikelySubtags::maximize(const char *language, const char *script, const char *region) const { + if (uprv_strcmp(language, "und") == 0) { + language = ""; + } + if (uprv_strcmp(script, "Zzzz") == 0) { + script = ""; + } + if (uprv_strcmp(region, "ZZ") == 0) { + region = ""; + } + if (*script != 0 && *region != 0 && *language != 0) { + return LSR(language, script, region); // already maximized + } + + uint32_t retainOldMask = 0; + BytesTrie iter(trie); + uint64_t state; + int32_t value; + // Small optimization: Array lookup for first language letter. + int32_t c0; + if (0 <= (c0 = uprv_lowerOrdinal(language[0])) && c0 <= 25 && + language[1] != 0 && // language.length() >= 2 + (state = trieFirstLetterStates[c0]) != 0) { + value = trieNext(iter.resetToState64(state), language, 1); + } else { + value = trieNext(iter, language, 0); + } + if (value >= 0) { + if (*language != 0) { + retainOldMask |= 4; + } + state = iter.getState64(); + } else { + retainOldMask |= 4; + iter.resetToState64(trieUndState); // "und" ("*") + state = 0; + } + + if (value > 0) { + // Intermediate or final value from just language. + if (value == SKIP_SCRIPT) { + value = 0; + } + if (*script != 0) { + retainOldMask |= 2; + } + } else { + value = trieNext(iter, script, 0); + if (value >= 0) { + if (*script != 0) { + retainOldMask |= 2; + } + state = iter.getState64(); + } else { + retainOldMask |= 2; + if (state == 0) { + iter.resetToState64(trieUndZzzzState); // "und-Zzzz" ("**") + } else { + iter.resetToState64(state); + value = trieNext(iter, "", 0); + U_ASSERT(value >= 0); + state = iter.getState64(); + } + } + } + + if (value > 0) { + // Final value from just language or language+script. + if (*region != 0) { + retainOldMask |= 1; + } + } else { + value = trieNext(iter, region, 0); + if (value >= 0) { + if (*region != 0) { + retainOldMask |= 1; + } + } else { + retainOldMask |= 1; + if (state == 0) { + value = defaultLsrIndex; + } else { + iter.resetToState64(state); + value = trieNext(iter, "", 0); + U_ASSERT(value > 0); + } + } + } + U_ASSERT(value < lsrsLength); + const LSR &result = lsrs[value]; + + if (*language == 0) { + language = "und"; + } + + if (retainOldMask == 0) { + // Quickly return a copy of the lookup-result LSR + // without new allocation of the subtags. + return LSR(result.language, result.script, result.region); + } + if ((retainOldMask & 4) == 0) { + language = result.language; + } + if ((retainOldMask & 2) == 0) { + script = result.script; + } + if ((retainOldMask & 1) == 0) { + region = result.region; + } + return LSR(language, script, region); +} + +int32_t XLikelySubtags::trieNext(BytesTrie &iter, const char *s, int32_t i) { + UStringTrieResult result; + uint8_t c; + if ((c = s[i]) == 0) { + result = iter.next(u'*'); + } else { + for (;;) { + c = uprv_invCharToAscii(c); + // EBCDIC: If s[i] is not an invariant character, + // then c is now 0 and will simply not match anything, which is harmless. + uint8_t next = s[++i]; + if (next != 0) { + if (!USTRINGTRIE_HAS_NEXT(iter.next(c))) { + return -1; + } + } else { + // last character of this subtag + result = iter.next(c | 0x80); + break; + } + c = next; + } + } + switch (result) { + case USTRINGTRIE_NO_MATCH: return -1; + case USTRINGTRIE_NO_VALUE: return 0; + case USTRINGTRIE_INTERMEDIATE_VALUE: + U_ASSERT(iter.getValue() == SKIP_SCRIPT); + return SKIP_SCRIPT; + case USTRINGTRIE_FINAL_VALUE: return iter.getValue(); + default: return -1; + } +} + +// TODO(ICU-20777): Switch Locale/uloc_ likely-subtags API from the old code +// in loclikely.cpp to this new code, including activating this +// minimizeSubtags() function. The LocaleMatcher does not minimize. +#if 0 +LSR XLikelySubtags::minimizeSubtags(const char *languageIn, const char *scriptIn, + const char *regionIn, ULocale.Minimize fieldToFavor, + UErrorCode &errorCode) const { + LSR result = maximize(languageIn, scriptIn, regionIn); + + // We could try just a series of checks, like: + // LSR result2 = addLikelySubtags(languageIn, "", ""); + // if result.equals(result2) return result2; + // However, we can optimize 2 of the cases: + // (languageIn, "", "") + // (languageIn, "", regionIn) + + // value00 = lookup(result.language, "", "") + BytesTrie iter = new BytesTrie(trie); + int value = trieNext(iter, result.language, 0); + U_ASSERT(value >= 0); + if (value == 0) { + value = trieNext(iter, "", 0); + U_ASSERT(value >= 0); + if (value == 0) { + value = trieNext(iter, "", 0); + } + } + U_ASSERT(value > 0); + LSR value00 = lsrs[value]; + boolean favorRegionOk = false; + if (result.script.equals(value00.script)) { //script is default + if (result.region.equals(value00.region)) { + return new LSR(result.language, "", ""); + } else if (fieldToFavor == ULocale.Minimize.FAVOR_REGION) { + return new LSR(result.language, "", result.region); + } else { + favorRegionOk = true; + } + } + + // The last case is not as easy to optimize. + // Maybe do later, but for now use the straightforward code. + LSR result2 = maximize(languageIn, scriptIn, ""); + if (result2.equals(result)) { + return new LSR(result.language, result.script, ""); + } else if (favorRegionOk) { + return new LSR(result.language, "", result.region); + } + return result; +} +#endif + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/loclikelysubtags.h b/deps/icu-small/source/common/loclikelysubtags.h new file mode 100644 index 00000000000000..8c8a08ac5e314e --- /dev/null +++ b/deps/icu-small/source/common/loclikelysubtags.h @@ -0,0 +1,143 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// loclikelysubtags.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCLIKELYSUBTAGS_H__ +#define __LOCLIKELYSUBTAGS_H__ + +#include +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "lsr.h" +#include "uhash.h" + +U_NAMESPACE_BEGIN + +struct XLikelySubtagsData; + +/** + * Map of const char * keys & values. + * Stores pointers as is: Does not own/copy/adopt/release strings. + */ +class CharStringMap final : public UMemory { +public: + /** Constructs an unusable non-map. */ + CharStringMap() : map(nullptr) {} + CharStringMap(int32_t size, UErrorCode &errorCode) { + map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars, + size, &errorCode); + } + CharStringMap(CharStringMap &&other) U_NOEXCEPT : map(other.map) { + other.map = nullptr; + } + CharStringMap(const CharStringMap &other) = delete; + ~CharStringMap() { + uhash_close(map); + } + + CharStringMap &operator=(CharStringMap &&other) U_NOEXCEPT { + map = other.map; + other.map = nullptr; + return *this; + } + CharStringMap &operator=(const CharStringMap &other) = delete; + + const char *get(const char *key) const { return static_cast(uhash_get(map, key)); } + void put(const char *key, const char *value, UErrorCode &errorCode) { + uhash_put(map, const_cast(key), const_cast(value), &errorCode); + } + +private: + UHashtable *map; +}; + +struct LocaleDistanceData { + LocaleDistanceData() = default; + LocaleDistanceData(LocaleDistanceData &&data); + ~LocaleDistanceData(); + + const uint8_t *distanceTrieBytes = nullptr; + const uint8_t *regionToPartitions = nullptr; + const char **partitions = nullptr; + const LSR *paradigms = nullptr; + int32_t paradigmsLength = 0; + const int32_t *distances = nullptr; + +private: + LocaleDistanceData &operator=(const LocaleDistanceData &) = delete; +}; + +// TODO(ICU-20777): Rename to just LikelySubtags. +class XLikelySubtags final : public UMemory { +public: + ~XLikelySubtags(); + + static constexpr int32_t SKIP_SCRIPT = 1; + + // VisibleForTesting + static const XLikelySubtags *getSingleton(UErrorCode &errorCode); + + // VisibleForTesting + LSR makeMaximizedLsrFrom(const Locale &locale, UErrorCode &errorCode) const; + + // TODO(ICU-20777): Switch Locale/uloc_ likely-subtags API from the old code + // in loclikely.cpp to this new code, including activating this + // minimizeSubtags() function. The LocaleMatcher does not minimize. +#if 0 + LSR minimizeSubtags(const char *languageIn, const char *scriptIn, const char *regionIn, + ULocale.Minimize fieldToFavor, UErrorCode &errorCode) const; +#endif + + // visible for LocaleDistance + const LocaleDistanceData &getDistanceData() const { return distanceData; } + +private: + XLikelySubtags(XLikelySubtagsData &data); + XLikelySubtags(const XLikelySubtags &other) = delete; + XLikelySubtags &operator=(const XLikelySubtags &other) = delete; + + static void initLikelySubtags(UErrorCode &errorCode); + + LSR makeMaximizedLsr(const char *language, const char *script, const char *region, + const char *variant, UErrorCode &errorCode) const; + + /** + * Raw access to addLikelySubtags. Input must be in canonical format, eg "en", not "eng" or "EN". + */ + LSR maximize(const char *language, const char *script, const char *region) const; + + static int32_t trieNext(BytesTrie &iter, const char *s, int32_t i); + + UResourceBundle *langInfoBundle; + // We could store the strings by value, except that if there were few enough strings, + // moving the contents could copy it to a different array, + // invalidating the pointers stored in the maps. + CharString *strings; + CharStringMap languageAliases; + CharStringMap regionAliases; + + // The trie maps each lang+script+region (encoded in ASCII) to an index into lsrs. + // There is also a trie value for each intermediate lang and lang+script. + // '*' is used instead of "und", "Zzzz"/"" and "ZZ"/"". + BytesTrie trie; + uint64_t trieUndState; + uint64_t trieUndZzzzState; + int32_t defaultLsrIndex; + uint64_t trieFirstLetterStates[26]; + const LSR *lsrs; +#if U_DEBUG + int32_t lsrsLength; +#endif + + // distance/matcher data: see comment in XLikelySubtagsData::load() + LocaleDistanceData distanceData; +}; + +U_NAMESPACE_END + +#endif // __LOCLIKELYSUBTAGS_H__ diff --git a/deps/icu-small/source/common/locmap.cpp b/deps/icu-small/source/common/locmap.cpp index 46986399b23e7a..a6311343551ed4 100644 --- a/deps/icu-small/source/common/locmap.cpp +++ b/deps/icu-small/source/common/locmap.cpp @@ -20,7 +20,7 @@ * * Date Name Description * 3/11/97 aliu Fixed off-by-one bug in assignment operator. Added - * setId() method and safety check against + * setId() method and safety check against * MAX_ID_LENGTH. * 04/23/99 stephen Added C wrapper for convertToPosix. * 09/18/00 george Removed the memory leaks. @@ -115,7 +115,7 @@ static const ILcidPosixElement locmap_ ## id [] = // Keep static locale variables inside the function so that // it can be created properly during static init. // -// Note: This table should be updated periodically. Check the [MS-LCID] Windows Language Code Identifier +// Note: This table should be updated periodically. Check the [MS-LCID] Windows Language Code Identifier // (LCID) Reference defined at https://msdn.microsoft.com/en-us/library/cc233965.aspx // // Microsoft is moving away from LCID in favor of locale name as of Vista. This table needs to be @@ -129,7 +129,7 @@ static const ILcidPosixElement locmap_ ## id [] = //////////////////////////////////////////// */ -// TODO: For Windows ideally this table would be a list of exceptions rather than a complete list as +// TODO: For Windows ideally this table would be a list of exceptions rather than a complete list as // LocaleNameToLCID and LCIDToLocaleName provide 90% of these. ILCID_POSIX_ELEMENT_ARRAY(0x0436, af, af_ZA) @@ -521,7 +521,7 @@ ILCID_POSIX_SUBTABLE(nl) { /* The "no" locale split into nb and nn. By default in ICU, "no" is nb.*/ // TODO: Not all of these are needed on Windows, but I don't know how ICU treats preferred ones here. ILCID_POSIX_SUBTABLE(no) { - {0x14, "no"}, /* really nb_NO - actually Windows differentiates between neutral (no region) and specific (with region) */ + {0x14, "no"}, /* really nb_NO - actually Windows differentiates between neutral (no region) and specific (with region) */ {0x7c14, "nb"}, /* really nb */ {0x0414, "nb_NO"}, /* really nb_NO. Keep first in the 414 list. */ {0x0414, "no_NO"}, /* really nb_NO */ @@ -1267,7 +1267,7 @@ uprv_convertToLCID(const char *langID, const char* posixID, UErrorCode* status) mid = (high+low) >> 1; /*Finds median*/ - if (mid == oldmid) + if (mid == oldmid) break; compVal = uprv_strcmp(langID, gPosixIDmap[mid].regionMaps->posixID); diff --git a/deps/icu-small/source/common/locmap.h b/deps/icu-small/source/common/locmap.h index 492a9413628ffb..e669873a143bfd 100644 --- a/deps/icu-small/source/common/locmap.h +++ b/deps/icu-small/source/common/locmap.h @@ -9,7 +9,7 @@ ****************************************************************************** * * File locmap.h : Locale Mapping Classes -* +* * * Created by: Helena Shih * @@ -37,3 +37,4 @@ U_CAPI uint32_t uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* sta U_CAPI uint32_t uprv_convertToLCID(const char* langID, const char* posixID, UErrorCode* status); #endif /* LOCMAP_H */ + diff --git a/deps/icu-small/source/common/locresdata.cpp b/deps/icu-small/source/common/locresdata.cpp index 69d744306417d5..d1d9a4729f107b 100644 --- a/deps/icu-small/source/common/locresdata.cpp +++ b/deps/icu-small/source/common/locresdata.cpp @@ -83,9 +83,9 @@ uloc_getTableStringWithFallback(const char *path, const char *locale, if(U_FAILURE(errorCode)){ *pErrorCode = errorCode; } - + break;*/ - + ures_getByKeyWithFallback(table.getAlias(), subTableKey, table.getAlias(), &errorCode); } if(U_SUCCESS(errorCode)){ @@ -112,8 +112,8 @@ uloc_getTableStringWithFallback(const char *path, const char *locale, break; } } - - if(U_FAILURE(errorCode)){ + + if(U_FAILURE(errorCode)){ /* still can't figure out ?.. try the fallback mechanism */ int32_t len = 0; @@ -126,9 +126,9 @@ uloc_getTableStringWithFallback(const char *path, const char *locale, *pErrorCode = errorCode; break; } - + u_UCharsToChars(fallbackLocale, explicitFallbackName, len); - + /* guard against recursive fallback */ if(uprv_strcmp(explicitFallbackName, locale)==0){ *pErrorCode = U_INTERNAL_PROGRAM_ERROR; @@ -207,7 +207,7 @@ uloc_getCharacterOrientation(const char* localeId, /** * Get the layout line orientation for the specified locale. - * + * * @param localeID locale name * @param status Error status * @return an enum indicating the layout orientation for lines. diff --git a/deps/icu-small/source/common/locutil.cpp b/deps/icu-small/source/common/locutil.cpp index 74745a37d6d47c..3d9d69ff7ed0e2 100644 --- a/deps/icu-small/source/common/locutil.cpp +++ b/deps/icu-small/source/common/locutil.cpp @@ -33,7 +33,7 @@ static icu::Hashtable * LocaleUtility_cache = NULL; */ /** - * Release all static memory held by Locale Utility. + * Release all static memory held by Locale Utility. */ U_CDECL_BEGIN static UBool U_CALLCONV service_cleanup(void) { @@ -271,3 +271,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/lsr.cpp b/deps/icu-small/source/common/lsr.cpp new file mode 100644 index 00000000000000..0c28eeda1bc7b6 --- /dev/null +++ b/deps/icu-small/source/common/lsr.cpp @@ -0,0 +1,101 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// lsr.cpp +// created: 2019may08 Markus W. Scherer + +#include "unicode/utypes.h" +#include "charstr.h" +#include "cmemory.h" +#include "cstring.h" +#include "lsr.h" +#include "uinvchar.h" +#include "ustr_imp.h" + +U_NAMESPACE_BEGIN + +LSR::LSR(char prefix, const char *lang, const char *scr, const char *r, UErrorCode &errorCode) : + language(nullptr), script(nullptr), region(r), + regionIndex(indexForRegion(region)) { + if (U_SUCCESS(errorCode)) { + CharString langScript; + langScript.append(prefix, errorCode).append(lang, errorCode).append('\0', errorCode); + int32_t scriptOffset = langScript.length(); + langScript.append(prefix, errorCode).append(scr, errorCode); + owned = langScript.cloneData(errorCode); + if (U_SUCCESS(errorCode)) { + language = owned; + script = owned + scriptOffset; + } + } +} + +LSR::LSR(LSR &&other) U_NOEXCEPT : + language(other.language), script(other.script), region(other.region), owned(other.owned), + regionIndex(other.regionIndex), hashCode(other.hashCode) { + if (owned != nullptr) { + other.language = other.script = ""; + other.owned = nullptr; + other.hashCode = 0; + } +} + +void LSR::deleteOwned() { + uprv_free(owned); +} + +LSR &LSR::operator=(LSR &&other) U_NOEXCEPT { + this->~LSR(); + language = other.language; + script = other.script; + region = other.region; + regionIndex = other.regionIndex; + owned = other.owned; + hashCode = other.hashCode; + if (owned != nullptr) { + other.language = other.script = ""; + other.owned = nullptr; + other.hashCode = 0; + } + return *this; +} + +UBool LSR::operator==(const LSR &other) const { + return + uprv_strcmp(language, other.language) == 0 && + uprv_strcmp(script, other.script) == 0 && + regionIndex == other.regionIndex && + // Compare regions if both are ill-formed (and their indexes are 0). + (regionIndex > 0 || uprv_strcmp(region, other.region) == 0); +} + +int32_t LSR::indexForRegion(const char *region) { + int32_t c = region[0]; + int32_t a = c - '0'; + if (0 <= a && a <= 9) { // digits: "419" + int32_t b = region[1] - '0'; + if (b < 0 || 9 < b) { return 0; } + c = region[2] - '0'; + if (c < 0 || 9 < c || region[3] != 0) { return 0; } + return (10 * a + b) * 10 + c + 1; + } else { // letters: "DE" + a = uprv_upperOrdinal(c); + if (a < 0 || 25 < a) { return 0; } + int32_t b = uprv_upperOrdinal(region[1]); + if (b < 0 || 25 < b || region[2] != 0) { return 0; } + return 26 * a + b + 1001; + } + return 0; +} + +LSR &LSR::setHashCode() { + if (hashCode == 0) { + hashCode = + (ustr_hashCharsN(language, static_cast(uprv_strlen(language))) * 37 + + ustr_hashCharsN(script, static_cast(uprv_strlen(script)))) * 37 + + regionIndex; + } + return *this; +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/lsr.h b/deps/icu-small/source/common/lsr.h new file mode 100644 index 00000000000000..db6cf938f47d02 --- /dev/null +++ b/deps/icu-small/source/common/lsr.h @@ -0,0 +1,72 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// lsr.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LSR_H__ +#define __LSR_H__ + +#include "unicode/utypes.h" +#include "unicode/uobject.h" +#include "cstring.h" + +U_NAMESPACE_BEGIN + +struct LSR final : public UMemory { + static constexpr int32_t REGION_INDEX_LIMIT = 1001 + 26 * 26; + + const char *language; + const char *script; + const char *region; + char *owned = nullptr; + /** Index for region, 0 if ill-formed. @see indexForRegion */ + int32_t regionIndex = 0; + /** Only set for LSRs that will be used in a hash table. */ + int32_t hashCode = 0; + + LSR() : language("und"), script(""), region("") {} + + /** Constructor which aliases all subtag pointers. */ + LSR(const char *lang, const char *scr, const char *r) : + language(lang), script(scr), region(r), + regionIndex(indexForRegion(region)) {} + /** + * Constructor which prepends the prefix to the language and script, + * copies those into owned memory, and aliases the region. + */ + LSR(char prefix, const char *lang, const char *scr, const char *r, UErrorCode &errorCode); + LSR(LSR &&other) U_NOEXCEPT; + LSR(const LSR &other) = delete; + inline ~LSR() { + // Pure inline code for almost all instances. + if (owned != nullptr) { + deleteOwned(); + } + } + + LSR &operator=(LSR &&other) U_NOEXCEPT; + LSR &operator=(const LSR &other) = delete; + + /** + * Returns a positive index (>0) for a well-formed region code. + * Do not rely on a particular region->index mapping; it may change. + * Returns 0 for ill-formed strings. + */ + static int32_t indexForRegion(const char *region); + + UBool operator==(const LSR &other) const; + + inline UBool operator!=(const LSR &other) const { + return !operator==(other); + } + + LSR &setHashCode(); + +private: + void deleteOwned(); +}; + +U_NAMESPACE_END + +#endif // __LSR_H__ diff --git a/deps/icu-small/source/common/messagepattern.cpp b/deps/icu-small/source/common/messagepattern.cpp index 2f79780bd2c233..f223d0671164fb 100644 --- a/deps/icu-small/source/common/messagepattern.cpp +++ b/deps/icu-small/source/common/messagepattern.cpp @@ -454,7 +454,7 @@ MessagePattern::parseMessage(int32_t index, int32_t msgStartLength, UChar c=msg.charAt(index++); if(c==u_apos) { if(index==msg.length()) { - // The apostrophe is the last character in the pattern. + // The apostrophe is the last character in the pattern. // Add a Part for auto-quoting. addPart(UMSGPAT_PART_TYPE_INSERT_CHAR, index, 0, u_apos, errorCode); // value=char to be inserted diff --git a/deps/icu-small/source/common/msvcres.h b/deps/icu-small/source/common/msvcres.h index d6581b27ebce51..0cace85e7472d0 100644 --- a/deps/icu-small/source/common/msvcres.h +++ b/deps/icu-small/source/common/msvcres.h @@ -11,8 +11,8 @@ // /* -These are defined before unicode/uversion.h in order to prevent -STLPort's broken stddef.h from being used when rc.exe parses this file. +These are defined before unicode/uversion.h in order to prevent +STLPort's broken stddef.h from being used when rc.exe parses this file. */ #define _STLP_OUTERMOST_HEADER_ID 0 #define _STLP_WINCE 1 diff --git a/deps/icu-small/source/common/mutex.h b/deps/icu-small/source/common/mutex.h index 5223397bbcc10a..44b1f90ba04dd2 100644 --- a/deps/icu-small/source/common/mutex.h +++ b/deps/icu-small/source/common/mutex.h @@ -28,50 +28,48 @@ U_NAMESPACE_BEGIN -//---------------------------------------------------------------------------- -// Code within that accesses shared static or global data should -// should instantiate a Mutex object while doing so. You should make your own -// private mutex where possible. - -// For example: -// -// UMutex myMutex = U_MUTEX_INITIALIZER; -// -// void Function(int arg1, int arg2) -// { -// static Object* foo; // Shared read-write object -// Mutex mutex(&myMutex); // or no args for the global lock -// foo->Method(); -// // When 'mutex' goes out of scope and gets destroyed here, the lock is released -// } -// -// Note: Do NOT use the form 'Mutex mutex();' as that merely forward-declares a function -// returning a Mutex. This is a common mistake which silently slips through the -// compiler!! -// +/** + * Mutex is a helper class for convenient locking and unlocking of a UMutex. + * + * Creating a local scope Mutex will lock a UMutex, holding the lock until the Mutex + * goes out of scope. + * + * If no UMutex is specified, the ICU global mutex is implied. + * + * For example: + * + * static UMutex myMutex; + * + * void Function(int arg1, int arg2) + * { + * static Object* foo; // Shared read-write object + * Mutex mutex(&myMutex); // or no args for the global lock + * foo->Method(); + * // When 'mutex' goes out of scope and gets destroyed here, the lock is released + * } + * + * Note: Do NOT use the form 'Mutex mutex();' as that merely forward-declares a function + * returning a Mutex. This is a common mistake which silently slips through the + * compiler!! + */ class U_COMMON_API Mutex : public UMemory { public: - inline Mutex(UMutex *mutex = NULL); - inline ~Mutex(); + Mutex(UMutex *mutex = nullptr) : fMutex(mutex) { + umtx_lock(fMutex); + } + ~Mutex() { + umtx_unlock(fMutex); + } -private: - UMutex *fMutex; + Mutex(const Mutex &other) = delete; // forbid assigning of this class + Mutex &operator=(const Mutex &other) = delete; // forbid copying of this class + void *operator new(size_t s) = delete; // forbid heap allocation. Locals only. - Mutex(const Mutex &other); // forbid copying of this class - Mutex &operator=(const Mutex &other); // forbid copying of this class +private: + UMutex *fMutex; }; -inline Mutex::Mutex(UMutex *mutex) - : fMutex(mutex) -{ - umtx_lock(fMutex); -} - -inline Mutex::~Mutex() -{ - umtx_unlock(fMutex); -} U_NAMESPACE_END diff --git a/deps/icu-small/source/common/normalizer2.cpp b/deps/icu-small/source/common/normalizer2.cpp index ca5d3aba1a1874..6be7e0b21a2bf9 100644 --- a/deps/icu-small/source/common/normalizer2.cpp +++ b/deps/icu-small/source/common/normalizer2.cpp @@ -293,11 +293,11 @@ U_CDECL_BEGIN static UBool U_CALLCONV uprv_normalizer2_cleanup() { delete noopSingleton; noopSingleton = NULL; - noopInitOnce.reset(); + noopInitOnce.reset(); #if NORM2_HARDCODE_NFC_DATA delete nfcSingleton; nfcSingleton = NULL; - nfcInitOnce.reset(); + nfcInitOnce.reset(); #endif return TRUE; } diff --git a/deps/icu-small/source/common/normalizer2impl.h b/deps/icu-small/source/common/normalizer2impl.h index 7ecdef6d9c8032..cf3015ea881bfc 100644 --- a/deps/icu-small/source/common/normalizer2impl.h +++ b/deps/icu-small/source/common/normalizer2impl.h @@ -245,9 +245,7 @@ class U_COMMON_API ReorderingBuffer : public UMemory { */ class U_COMMON_API Normalizer2Impl : public UObject { public: - Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { - fCanonIterDataInitOnce.reset(); - } + Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { } virtual ~Normalizer2Impl(); void init(const int32_t *inIndexes, const UCPTrie *inTrie, @@ -723,7 +721,7 @@ class U_COMMON_API Normalizer2Impl : public UObject { const uint16_t *extraData; // mappings and/or compositions for yesYes, yesNo & noNo characters const uint8_t *smallFCD; // [0x100] one bit per 32 BMP code points, set if any FCD!=0 - UInitOnce fCanonIterDataInitOnce; + UInitOnce fCanonIterDataInitOnce = U_INITONCE_INITIALIZER; CanonIterData *fCanonIterData; }; diff --git a/deps/icu-small/source/common/normlzr.cpp b/deps/icu-small/source/common/normlzr.cpp index 20b9f3df2ffccc..2dea0ffc33c91d 100644 --- a/deps/icu-small/source/common/normlzr.cpp +++ b/deps/icu-small/source/common/normlzr.cpp @@ -2,7 +2,7 @@ // License & terms of use: http://www.unicode.org/copyright.html /* ************************************************************************* - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1996-2012, International Business Machines Corporation and * others. All Rights Reserved. ************************************************************************* @@ -94,7 +94,7 @@ Normalizer::~Normalizer() delete text; } -Normalizer* +Normalizer* Normalizer::clone() const { return new Normalizer(*this); @@ -107,7 +107,7 @@ int32_t Normalizer::hashCode() const { return text->hashCode() + fUMode + fOptions + buffer.hashCode() + bufferPos + currentIndex + nextIndex; } - + UBool Normalizer::operator==(const Normalizer& that) const { return @@ -125,9 +125,9 @@ UBool Normalizer::operator==(const Normalizer& that) const //------------------------------------------------------------------------- void U_EXPORT2 -Normalizer::normalize(const UnicodeString& source, +Normalizer::normalize(const UnicodeString& source, UNormalizationMode mode, int32_t options, - UnicodeString& result, + UnicodeString& result, UErrorCode &status) { if(source.isBogus() || U_FAILURE(status)) { result.setToBogus(); @@ -160,17 +160,17 @@ Normalizer::normalize(const UnicodeString& source, } void U_EXPORT2 -Normalizer::compose(const UnicodeString& source, +Normalizer::compose(const UnicodeString& source, UBool compat, int32_t options, - UnicodeString& result, + UnicodeString& result, UErrorCode &status) { normalize(source, compat ? UNORM_NFKC : UNORM_NFC, options, result, status); } void U_EXPORT2 -Normalizer::decompose(const UnicodeString& source, +Normalizer::decompose(const UnicodeString& source, UBool compat, int32_t options, - UnicodeString& result, + UnicodeString& result, UErrorCode &status) { normalize(source, compat ? UNORM_NFKD : UNORM_NFD, options, result, status); } @@ -368,7 +368,7 @@ int32_t Normalizer::endIndex() const { //------------------------------------------------------------------------- void -Normalizer::setMode(UNormalizationMode newMode) +Normalizer::setMode(UNormalizationMode newMode) { fUMode = newMode; init(); @@ -381,8 +381,8 @@ Normalizer::getUMode() const } void -Normalizer::setOption(int32_t option, - UBool value) +Normalizer::setOption(int32_t option, + UBool value) { if (value) { fOptions |= option; @@ -403,7 +403,7 @@ Normalizer::getOption(int32_t option) const * The iteration position is set to the beginning of the input text. */ void -Normalizer::setText(const UnicodeString& newText, +Normalizer::setText(const UnicodeString& newText, UErrorCode &status) { if (U_FAILURE(status)) { @@ -424,8 +424,8 @@ Normalizer::setText(const UnicodeString& newText, * The iteration position is set to the beginning of the string. */ void -Normalizer::setText(const CharacterIterator& newText, - UErrorCode &status) +Normalizer::setText(const CharacterIterator& newText, + UErrorCode &status) { if (U_FAILURE(status)) { return; @@ -463,7 +463,7 @@ Normalizer::setText(ConstChar16Ptr newText, * @param result Receives a copy of the text under iteration. */ void -Normalizer::getText(UnicodeString& result) +Normalizer::getText(UnicodeString& result) { text->getText(result); } diff --git a/deps/icu-small/source/common/pluralmap.cpp b/deps/icu-small/source/common/pluralmap.cpp index a85dd1c979ffef..ec87f0198e19eb 100644 --- a/deps/icu-small/source/common/pluralmap.cpp +++ b/deps/icu-small/source/common/pluralmap.cpp @@ -29,7 +29,7 @@ PluralMapBase::Category PluralMapBase::toCategory(const UnicodeString &pluralForm) { CharString cCategory; UErrorCode status = U_ZERO_ERROR; - cCategory.appendInvariantChars(pluralForm, status); + cCategory.appendInvariantChars(pluralForm, status); return U_FAILURE(status) ? NONE : toCategory(cCategory.data()); } @@ -41,3 +41,4 @@ const char *PluralMapBase::getCategoryName(Category c) { U_NAMESPACE_END + diff --git a/deps/icu-small/source/common/punycode.cpp b/deps/icu-small/source/common/punycode.cpp index 4f0b9ea9cd385f..90fe1ec3c8026f 100644 --- a/deps/icu-small/source/common/punycode.cpp +++ b/deps/icu-small/source/common/punycode.cpp @@ -467,7 +467,7 @@ u_strFromPunycode(const UChar *src, int32_t srcLength, } i+=digit*w; - /** RAM: comment out the old code for conformance with draft-ietf-idn-punycode-03.txt + /** RAM: comment out the old code for conformance with draft-ietf-idn-punycode-03.txt t=k-bias; if(t(uprv_malloc(uprv_strlen(posixID) + 1 + 1)); + // Over-allocate in case we replace "C" with "en_US_POSIX" (+10), + null termination + char *correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID) + 10 + 1)); if (correctedPOSIXLocale == nullptr) { return nullptr; } @@ -1641,11 +1648,18 @@ The leftmost codepage (.xxx) wins. char *limit; if ((limit = uprv_strchr(correctedPOSIXLocale, '.')) != nullptr) { *limit = 0; - if ((limit = uprv_strchr(correctedPOSIXLocale, '@')) != nullptr) { - *limit = 0; - } + } + if ((limit = uprv_strchr(correctedPOSIXLocale, '@')) != nullptr) { + *limit = 0; } + if ((uprv_strcmp("C", correctedPOSIXLocale) == 0) // no @ variant + || (uprv_strcmp("POSIX", correctedPOSIXLocale) == 0)) { + // Raw input was C.* or POSIX.*, Give it a nice POSIX default value. + // (The "C"/"POSIX" case is handled in uprv_getPOSIXIDForCategory()) + uprv_strcpy(correctedPOSIXLocale, "en_US_POSIX"); + } + /* Note that we scan the *uncorrected* ID. */ const char *p; if ((p = uprv_strrchr(posixID, '@')) != nullptr) { @@ -1668,7 +1682,7 @@ The leftmost codepage (.xxx) wins. if ((q = uprv_strchr(p, '.')) != nullptr) { /* How big will the resulting string be? */ int32_t len = (int32_t)(uprv_strlen(correctedPOSIXLocale) + (q-p)); - uprv_strncat(correctedPOSIXLocale, p, q-p); + uprv_strncat(correctedPOSIXLocale, p, q-p); // do not include charset correctedPOSIXLocale[len] = 0; } else { @@ -2053,7 +2067,7 @@ int_getDefaultCodepage() static char codepage[64]; DWORD codepageNumber = 0; -#if U_PLATFORM_HAS_WINUWP_API > 0 +#if U_PLATFORM_HAS_WINUWP_API == 1 // UWP doesn't have a direct API to get the default ACP as Microsoft would rather // have folks use Unicode than a "system" code page, however this is the same // codepage as the system default locale codepage. (FWIW, the system locale is @@ -2066,7 +2080,7 @@ int_getDefaultCodepage() #endif // Special case for UTF-8 if (codepageNumber == 65001) - { + { return "UTF-8"; } // Windows codepages can look like windows-1252, so format the found number @@ -2259,7 +2273,7 @@ u_getVersion(UVersionInfo versionArray) { } /** - * icucfg.h dependent code + * icucfg.h dependent code */ #if U_ENABLE_DYLOAD && HAVE_DLOPEN && !U_PLATFORM_USES_ONLY_WIN32_API @@ -2319,15 +2333,15 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) { U_INTERNAL void * U_EXPORT2 uprv_dl_open(const char *libName, UErrorCode *status) { HMODULE lib = NULL; - + if(U_FAILURE(*status)) return NULL; - + lib = LoadLibraryA(libName); - + if(lib==NULL) { *status = U_MISSING_RESOURCE_ERROR; } - + return (void*)lib; } @@ -2335,9 +2349,9 @@ U_INTERNAL void U_EXPORT2 uprv_dl_close(void *lib, UErrorCode *status) { HMODULE handle = (HMODULE)lib; if(U_FAILURE(*status)) return; - + FreeLibrary(handle); - + return; } @@ -2345,11 +2359,11 @@ U_INTERNAL UVoidFunction* U_EXPORT2 uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) { HMODULE handle = (HMODULE)lib; UVoidFunction* addr = NULL; - + if(U_FAILURE(*status) || lib==NULL) return NULL; - + addr = (UVoidFunction*)GetProcAddress(handle, sym); - + if(addr==NULL) { DWORD lastError = GetLastError(); if(lastError == ERROR_PROC_NOT_FOUND) { @@ -2358,7 +2372,7 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) { *status = U_UNSUPPORTED_ERROR; /* other unknown error. */ } } - + return addr; } diff --git a/deps/icu-small/source/common/putilimp.h b/deps/icu-small/source/common/putilimp.h index f9c13d8e1b27bf..d9c90cf4e75638 100644 --- a/deps/icu-small/source/common/putilimp.h +++ b/deps/icu-small/source/common/putilimp.h @@ -178,76 +178,6 @@ typedef size_t uintptr_t; /** @} */ -/*===========================================================================*/ -/** @{ GCC built in functions for atomic memory operations */ -/*===========================================================================*/ - -/** - * \def U_HAVE_GCC_ATOMICS - * @internal - */ -#ifdef U_HAVE_GCC_ATOMICS - /* Use the predefined value. */ -#elif U_PLATFORM == U_PF_MINGW - #define U_HAVE_GCC_ATOMICS 0 -#elif U_GCC_MAJOR_MINOR >= 404 || defined(__clang__) - /* TODO: Intel icc and IBM xlc on AIX also support gcc atomics. (Intel originated them.) - * Add them for these compilers. - * Note: Clang sets __GNUC__ defines for version 4.2, so misses the 4.4 test here. - */ -# define U_HAVE_GCC_ATOMICS 1 -#else -# define U_HAVE_GCC_ATOMICS 0 -#endif - -/** @} */ - -/** - * \def U_HAVE_STD_ATOMICS - * Defines whether to use the C++11 std::atomic functions. - * If false, ICU will fall back to compiler or platform specific alternatives. - * Note: support for these fall back options for atomics will be removed in a future version - * of ICU, and the use of C++ 11 atomics will be required. - * @internal - */ -#ifdef U_HAVE_STD_ATOMICS - /* Use the predefined value. */ -#else -# define U_HAVE_STD_ATOMICS 1 -#endif - -/** - * \def U_HAVE_CLANG_ATOMICS - * Defines whether Clang c11 style built-in atomics are available. - * These are used in preference to gcc atomics when both are available. - */ -#ifdef U_HAVE_CLANG_ATOMICS - /* Use the predefined value. */ -#elif __has_builtin(__c11_atomic_load) && \ - __has_builtin(__c11_atomic_store) && \ - __has_builtin(__c11_atomic_fetch_add) && \ - __has_builtin(__c11_atomic_fetch_sub) -# define U_HAVE_CLANG_ATOMICS 1 -#else -# define U_HAVE_CLANG_ATOMICS 0 -#endif - - -/** - * \def U_HAVE_STD_MUTEX - * Defines whether to use the C++11 std::mutex functions. - * If false, ICU will fall back to compiler or platform specific alternatives. - * std::mutex is preferred, and used by default unless this setting is overridden. - * Note: support for other options for mutexes will be removed in a future version - * of ICU, and the use of std::mutex will be required. - * @internal - */ -#ifdef U_HAVE_STD_MUTEX - /* Use the predefined value. */ -#else -# define U_HAVE_STD_MUTEX 1 -#endif - /*===========================================================================*/ /** @{ Programs used by ICU code */ /*===========================================================================*/ @@ -438,7 +368,7 @@ U_INTERNAL UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* re * Return the default codepage for this platform and locale. * This function can call setlocale() on Unix platforms. Please read the * platform documentation on setlocale() before calling this function. - * @return the default codepage for this platform + * @return the default codepage for this platform * @internal */ U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void); @@ -447,7 +377,7 @@ U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void); /** * Please use uloc_getDefault() instead. * Return the default locale ID string by querying the system, or - * zero if one cannot be found. + * zero if one cannot be found. * This function can call setlocale() on Unix platforms. Please read the * platform documentation on setlocale() before calling this function. * @return the default locale ID string diff --git a/deps/icu-small/source/common/rbbi.cpp b/deps/icu-small/source/common/rbbi.cpp index 3b116ffaf6cba7..01dae48de44c1d 100644 --- a/deps/icu-small/source/common/rbbi.cpp +++ b/deps/icu-small/source/common/rbbi.cpp @@ -323,8 +323,8 @@ void RuleBasedBreakIterator::init(UErrorCode &status) { // Virtual function: does the right thing with subclasses. // //----------------------------------------------------------------------------- -BreakIterator* -RuleBasedBreakIterator::clone(void) const { +RuleBasedBreakIterator* +RuleBasedBreakIterator::clone() const { return new RuleBasedBreakIterator(*this); } @@ -352,7 +352,7 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const { // or have a different iteration position. // Note that fText's position is always the same as the break iterator's position. return FALSE; - }; + } if (!(fPosition == that2.fPosition && fRuleStatusIndex == that2.fRuleStatusIndex && @@ -1079,10 +1079,8 @@ const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) { } -BreakIterator * RuleBasedBreakIterator::createBufferClone(void * /*stackBuffer*/, - int32_t &bufferSize, - UErrorCode &status) -{ +RuleBasedBreakIterator *RuleBasedBreakIterator::createBufferClone( + void * /*stackBuffer*/, int32_t &bufferSize, UErrorCode &status) { if (U_FAILURE(status)){ return NULL; } diff --git a/deps/icu-small/source/common/rbbi_cache.cpp b/deps/icu-small/source/common/rbbi_cache.cpp index 17ee2320802f60..4f9e83360a2a32 100644 --- a/deps/icu-small/source/common/rbbi_cache.cpp +++ b/deps/icu-small/source/common/rbbi_cache.cpp @@ -519,7 +519,7 @@ UBool RuleBasedBreakIterator::BreakCache::populatePreceding(UErrorCode &status) // The initial handleNext() only advanced by a single code point. Go again. position = fBI->handleNext(); // Safe rules identify safe pairs. } - }; + } positionStatusIdx = fBI->fRuleStatusIndex; } } while (position >= fromPosition); diff --git a/deps/icu-small/source/common/rbbi_cache.h b/deps/icu-small/source/common/rbbi_cache.h index 864ff811aaaff3..7991d6c0c7bf4c 100644 --- a/deps/icu-small/source/common/rbbi_cache.h +++ b/deps/icu-small/source/common/rbbi_cache.h @@ -30,7 +30,7 @@ U_NAMESPACE_BEGIN * * The boundaries are stored in a simple ArrayList (vector), with the * assumption that they will be accessed sequentially. - */ + */ class RuleBasedBreakIterator::DictionaryCache: public UMemory { public: DictionaryCache(RuleBasedBreakIterator *bi, UErrorCode &status); @@ -55,7 +55,7 @@ class RuleBasedBreakIterator::DictionaryCache: public UMemory { RuleBasedBreakIterator *fBI; - + UVector32 fBreaks; // A vector containing the boundaries. int32_t fPositionInCache; // Index in fBreaks of last boundary returned by following() // or preceding(). Optimizes sequential access. diff --git a/deps/icu-small/source/common/rbbicst.pl b/deps/icu-small/source/common/rbbicst.pl index 839b9501dda953..32dd2ffff10742 100755 --- a/deps/icu-small/source/common/rbbicst.pl +++ b/deps/icu-small/source/common/rbbicst.pl @@ -264,7 +264,7 @@ $n++; } print " \n"; - + # # Emit constants for char class names # @@ -272,8 +272,8 @@ print " static final short kRuleSet_$setName = $charClasses{$setName};\n"; } print "\n\n"; - - + + print " static class RBBIRuleTableElement { \n"; print " short fAction; \n"; print " short fCharClass; \n"; @@ -291,20 +291,20 @@ print " } \n"; print " }; \n"; print " \n"; - - + + print " static RBBIRuleTableElement[] gRuleParseStateTable = { \n "; - print " new RBBIRuleTableElement(doNOP, 0, 0,0, true, null ) // 0 \n"; #output the unused state 0. + print " new RBBIRuleTableElement(doNOP, 0, 0,0, true, null ) // 0 \n"; #output the unused state 0. for ($state=1; $state < $num_states; $state++) { print " , new RBBIRuleTableElement($state_func_name[$state],"; if ($state_literal_chars[$state] ne "") { $c = $state_literal_chars[$state]; - print("'$c', "); + print("'$c', "); }else { print " $charClasses{$state_char_class[$state]},"; } print " $states{$state_dest_state[$state]},"; - + # The push-state field is optional. If omitted, fill field with a zero, which flags # the state machine that there is no push state. if ($state_push_state[$state] eq "") { @@ -313,14 +313,14 @@ print " $states{$state_push_state[$state]},"; } print " $state_flag[$state], "; - + # if this is the first row of the table for this state, put out the state name. if ($stateNames[$state] ne "") { print " \"$stateNames[$state]\") "; } else { print " null ) "; } - + # Put out a comment showing the number (index) of this state row, print " // $state "; print "\n"; @@ -328,7 +328,7 @@ print " };\n"; print "}; \n"; - + } else { @@ -454,3 +454,6 @@ print "U_NAMESPACE_END\n"; print "#endif\n"; } + + + diff --git a/deps/icu-small/source/common/rbbidata.cpp b/deps/icu-small/source/common/rbbidata.cpp index fdcb564961362e..1d4c9e5895f376 100644 --- a/deps/icu-small/source/common/rbbidata.cpp +++ b/deps/icu-small/source/common/rbbidata.cpp @@ -323,7 +323,7 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD // const uint8_t *inBytes =(const uint8_t *)inData+headerSize; RBBIDataHeader *rbbiDH = (RBBIDataHeader *)inBytes; - if (ds->readUInt32(rbbiDH->fMagic) != 0xb1a0 || + if (ds->readUInt32(rbbiDH->fMagic) != 0xb1a0 || !RBBIDataWrapper::isDataVersionAcceptable(rbbiDH->fFormatVersion) || ds->readUInt32(rbbiDH->fLength) < sizeof(RBBIDataHeader)) { udata_printError(ds, "ubrk_swap(): RBBI Data header is invalid.\n"); @@ -377,23 +377,23 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD // int32_t topSize = offsetof(RBBIStateTable, fTableData); - // Forward state table. + // Forward state table. tableStartOffset = ds->readUInt32(rbbiDH->fFTable); tableLength = ds->readUInt32(rbbiDH->fFTableLen); if (tableLength > 0) { - ds->swapArray32(ds, inBytes+tableStartOffset, topSize, + ds->swapArray32(ds, inBytes+tableStartOffset, topSize, outBytes+tableStartOffset, status); ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize, outBytes+tableStartOffset+topSize, status); } - + // Reverse state table. Same layout as forward table, above. tableStartOffset = ds->readUInt32(rbbiDH->fRTable); tableLength = ds->readUInt32(rbbiDH->fRTableLen); if (tableLength > 0) { - ds->swapArray32(ds, inBytes+tableStartOffset, topSize, + ds->swapArray32(ds, inBytes+tableStartOffset, topSize, outBytes+tableStartOffset, status); ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize, outBytes+tableStartOffset+topSize, status); diff --git a/deps/icu-small/source/common/rbbidata.h b/deps/icu-small/source/common/rbbidata.h index 3e573039d0f491..b7de6ce073cbc5 100644 --- a/deps/icu-small/source/common/rbbidata.h +++ b/deps/icu-small/source/common/rbbidata.h @@ -60,8 +60,8 @@ U_NAMESPACE_BEGIN // The current RBBI data format version. static const uint8_t RBBI_DATA_FORMAT_VERSION[] = {5, 0, 0, 0}; -/* - * The following structs map exactly onto the raw data from ICU common data file. +/* + * The following structs map exactly onto the raw data from ICU common data file. */ struct RBBIDataHeader { uint32_t fMagic; /* == 0xbla0 */ @@ -171,7 +171,7 @@ class RBBIDataWrapper : public UMemory { const RBBIStateTable *fForwardTable; const RBBIStateTable *fReverseTable; const UChar *fRuleSource; - const int32_t *fRuleStatusTable; + const int32_t *fRuleStatusTable; /* number of int32_t values in the rule status table. Used to sanity check indexing */ int32_t fStatusMaxIdx; diff --git a/deps/icu-small/source/common/rbbinode.cpp b/deps/icu-small/source/common/rbbinode.cpp index 2181d81acad2f2..69d84151fe818a 100644 --- a/deps/icu-small/source/common/rbbinode.cpp +++ b/deps/icu-small/source/common/rbbinode.cpp @@ -343,7 +343,7 @@ U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth) void RBBINode::printNodeHeader() { RBBIDebugPrintf(" Address serial type LeftChild RightChild Parent position value\n"); } - + void RBBINode::printTree(const RBBINode *node, UBool printHeading) { if (printHeading) { printNodeHeader(); @@ -356,7 +356,7 @@ void RBBINode::printTree(const RBBINode *node, UBool printHeading) { if (node->fLeftChild != NULL) { printTree(node->fLeftChild, FALSE); } - + if (node->fRightChild != NULL) { printTree(node->fRightChild, FALSE); } diff --git a/deps/icu-small/source/common/rbbinode.h b/deps/icu-small/source/common/rbbinode.h index e33662167fe3fd..f3525960225500 100644 --- a/deps/icu-small/source/common/rbbinode.h +++ b/deps/icu-small/source/common/rbbinode.h @@ -46,21 +46,21 @@ class RBBINode : public UMemory { opLParen }; - enum OpPrecedence { + enum OpPrecedence { precZero, precStart, precLParen, precOpOr, precOpCat }; - + NodeType fType; RBBINode *fParent; RBBINode *fLeftChild; RBBINode *fRightChild; UnicodeSet *fInputSet; // For uset nodes only. OpPrecedence fPrecedence; // For binary ops only. - + UnicodeString fText; // Text corresponding to this node. // May be lazily evaluated when (if) needed // for some node types. @@ -94,7 +94,7 @@ class RBBINode : public UMemory { RBBINode(NodeType t); RBBINode(const RBBINode &other); ~RBBINode(); - + RBBINode *cloneTree(); RBBINode *flattenVariables(); void flattenSets(); @@ -117,10 +117,11 @@ class RBBINode : public UMemory { }; #ifdef RBBI_DEBUG -U_CFUNC void +U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth=0); #endif U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/common/rbbirb.cpp b/deps/icu-small/source/common/rbbirb.cpp index 5f5661af94776d..08c577696c2254 100644 --- a/deps/icu-small/source/common/rbbirb.cpp +++ b/deps/icu-small/source/common/rbbirb.cpp @@ -242,7 +242,7 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules, if (U_FAILURE(status)) { delete This; This = NULL; - } + } else if(This == NULL) { // test for NULL status = U_MEMORY_ALLOCATION_ERROR; } diff --git a/deps/icu-small/source/common/rbbirb.h b/deps/icu-small/source/common/rbbirb.h index 37992daabb0b14..037c1dc2ce8ff7 100644 --- a/deps/icu-small/source/common/rbbirb.h +++ b/deps/icu-small/source/common/rbbirb.h @@ -91,7 +91,7 @@ class RBBISymbolTable : public UMemory, public SymbolTable { // A do-nothing inline function for non-debug builds. Member funcs can't be empty // or the call sites won't compile. int32_t fFakeField; - #define rbbiSymtablePrint() fFakeField=0; + #define rbbiSymtablePrint() fFakeField=0; #endif private: @@ -223,7 +223,7 @@ typedef std::pair IntPair; #define RBBIDebugPrintf printf #define RBBIDebugPuts puts #else -#undef RBBIDebugPrintf +#undef RBBIDebugPrintf #define RBBIDebugPuts(arg) #endif @@ -232,3 +232,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ #endif + + + diff --git a/deps/icu-small/source/common/rbbirpt.h b/deps/icu-small/source/common/rbbirpt.h index b94c4c25cbfb8c..586953c90c6fa4 100644 --- a/deps/icu-small/source/common/rbbirpt.h +++ b/deps/icu-small/source/common/rbbirpt.h @@ -8,8 +8,8 @@ // It is generated by the Perl script "rbbicst.pl" from // the rule parser state definitions file "rbbirpt.txt". // -// Copyright (C) 2002-2016 International Business Machines Corporation -// and others. All rights reserved. +// Copyright (C) 2002-2016 International Business Machines Corporation +// and others. All rights reserved. // //--------------------------------------------------------------------------------- #ifndef RBBIRPT_H @@ -81,107 +81,107 @@ struct RBBIRuleTableEl { static const struct RBBIRuleTableEl gRuleParseStateTable[] = { {doNOP, 0, 0, 0, TRUE} , {doExprStart, 254, 29, 9, FALSE} // 1 start - , {doNOP, 132, 1,0, TRUE} // 2 - , {doNoChain, 94 /* ^ */, 12, 9, TRUE} // 3 - , {doExprStart, 36 /* $ */, 88, 98, FALSE} // 4 - , {doNOP, 33 /* ! */, 19,0, TRUE} // 5 - , {doNOP, 59 /* ; */, 1,0, TRUE} // 6 - , {doNOP, 252, 0,0, FALSE} // 7 - , {doExprStart, 255, 29, 9, FALSE} // 8 + , {doNOP, 132, 1,0, TRUE} // 2 + , {doNoChain, 94 /* ^ */, 12, 9, TRUE} // 3 + , {doExprStart, 36 /* $ */, 88, 98, FALSE} // 4 + , {doNOP, 33 /* ! */, 19,0, TRUE} // 5 + , {doNOP, 59 /* ; */, 1,0, TRUE} // 6 + , {doNOP, 252, 0,0, FALSE} // 7 + , {doExprStart, 255, 29, 9, FALSE} // 8 , {doEndOfRule, 59 /* ; */, 1,0, TRUE} // 9 break-rule-end - , {doNOP, 132, 9,0, TRUE} // 10 - , {doRuleError, 255, 103,0, FALSE} // 11 + , {doNOP, 132, 9,0, TRUE} // 10 + , {doRuleError, 255, 103,0, FALSE} // 11 , {doExprStart, 254, 29,0, FALSE} // 12 start-after-caret - , {doNOP, 132, 12,0, TRUE} // 13 - , {doRuleError, 94 /* ^ */, 103,0, FALSE} // 14 - , {doExprStart, 36 /* $ */, 88, 37, FALSE} // 15 - , {doRuleError, 59 /* ; */, 103,0, FALSE} // 16 - , {doRuleError, 252, 103,0, FALSE} // 17 - , {doExprStart, 255, 29,0, FALSE} // 18 + , {doNOP, 132, 12,0, TRUE} // 13 + , {doRuleError, 94 /* ^ */, 103,0, FALSE} // 14 + , {doExprStart, 36 /* $ */, 88, 37, FALSE} // 15 + , {doRuleError, 59 /* ; */, 103,0, FALSE} // 16 + , {doRuleError, 252, 103,0, FALSE} // 17 + , {doExprStart, 255, 29,0, FALSE} // 18 , {doNOP, 33 /* ! */, 21,0, TRUE} // 19 rev-option - , {doReverseDir, 255, 28, 9, FALSE} // 20 + , {doReverseDir, 255, 28, 9, FALSE} // 20 , {doOptionStart, 130, 23,0, TRUE} // 21 option-scan1 - , {doRuleError, 255, 103,0, FALSE} // 22 + , {doRuleError, 255, 103,0, FALSE} // 22 , {doNOP, 129, 23,0, TRUE} // 23 option-scan2 - , {doOptionEnd, 255, 25,0, FALSE} // 24 + , {doOptionEnd, 255, 25,0, FALSE} // 24 , {doNOP, 59 /* ; */, 1,0, TRUE} // 25 option-scan3 - , {doNOP, 132, 25,0, TRUE} // 26 - , {doRuleError, 255, 103,0, FALSE} // 27 + , {doNOP, 132, 25,0, TRUE} // 26 + , {doRuleError, 255, 103,0, FALSE} // 27 , {doExprStart, 255, 29, 9, FALSE} // 28 reverse-rule , {doRuleChar, 254, 38,0, TRUE} // 29 term - , {doNOP, 132, 29,0, TRUE} // 30 - , {doRuleChar, 131, 38,0, TRUE} // 31 - , {doNOP, 91 /* [ */, 94, 38, FALSE} // 32 - , {doLParen, 40 /* ( */, 29, 38, TRUE} // 33 - , {doNOP, 36 /* $ */, 88, 37, FALSE} // 34 - , {doDotAny, 46 /* . */, 38,0, TRUE} // 35 - , {doRuleError, 255, 103,0, FALSE} // 36 + , {doNOP, 132, 29,0, TRUE} // 30 + , {doRuleChar, 131, 38,0, TRUE} // 31 + , {doNOP, 91 /* [ */, 94, 38, FALSE} // 32 + , {doLParen, 40 /* ( */, 29, 38, TRUE} // 33 + , {doNOP, 36 /* $ */, 88, 37, FALSE} // 34 + , {doDotAny, 46 /* . */, 38,0, TRUE} // 35 + , {doRuleError, 255, 103,0, FALSE} // 36 , {doCheckVarDef, 255, 38,0, FALSE} // 37 term-var-ref , {doNOP, 132, 38,0, TRUE} // 38 expr-mod - , {doUnaryOpStar, 42 /* * */, 43,0, TRUE} // 39 - , {doUnaryOpPlus, 43 /* + */, 43,0, TRUE} // 40 - , {doUnaryOpQuestion, 63 /* ? */, 43,0, TRUE} // 41 - , {doNOP, 255, 43,0, FALSE} // 42 + , {doUnaryOpStar, 42 /* * */, 43,0, TRUE} // 39 + , {doUnaryOpPlus, 43 /* + */, 43,0, TRUE} // 40 + , {doUnaryOpQuestion, 63 /* ? */, 43,0, TRUE} // 41 + , {doNOP, 255, 43,0, FALSE} // 42 , {doExprCatOperator, 254, 29,0, FALSE} // 43 expr-cont - , {doNOP, 132, 43,0, TRUE} // 44 - , {doExprCatOperator, 131, 29,0, FALSE} // 45 - , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 46 - , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 47 - , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 48 - , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 49 - , {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 50 - , {doExprCatOperator, 123 /* { */, 67,0, TRUE} // 51 - , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 52 - , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 53 - , {doExprFinished, 255, 255,0, FALSE} // 54 + , {doNOP, 132, 43,0, TRUE} // 44 + , {doExprCatOperator, 131, 29,0, FALSE} // 45 + , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 46 + , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 47 + , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 48 + , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 49 + , {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 50 + , {doExprCatOperator, 123 /* { */, 67,0, TRUE} // 51 + , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 52 + , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 53 + , {doExprFinished, 255, 255,0, FALSE} // 54 , {doSlash, 47 /* / */, 57,0, TRUE} // 55 look-ahead - , {doNOP, 255, 103,0, FALSE} // 56 + , {doNOP, 255, 103,0, FALSE} // 56 , {doExprCatOperator, 254, 29,0, FALSE} // 57 expr-cont-no-slash - , {doNOP, 132, 43,0, TRUE} // 58 - , {doExprCatOperator, 131, 29,0, FALSE} // 59 - , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 60 - , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 61 - , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 62 - , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 63 - , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 64 - , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 65 - , {doExprFinished, 255, 255,0, FALSE} // 66 + , {doNOP, 132, 43,0, TRUE} // 58 + , {doExprCatOperator, 131, 29,0, FALSE} // 59 + , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 60 + , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 61 + , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 62 + , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 63 + , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 64 + , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 65 + , {doExprFinished, 255, 255,0, FALSE} // 66 , {doNOP, 132, 67,0, TRUE} // 67 tag-open - , {doStartTagValue, 128, 70,0, FALSE} // 68 - , {doTagExpectedError, 255, 103,0, FALSE} // 69 + , {doStartTagValue, 128, 70,0, FALSE} // 68 + , {doTagExpectedError, 255, 103,0, FALSE} // 69 , {doNOP, 132, 74,0, TRUE} // 70 tag-value - , {doNOP, 125 /* } */, 74,0, FALSE} // 71 - , {doTagDigit, 128, 70,0, TRUE} // 72 - , {doTagExpectedError, 255, 103,0, FALSE} // 73 + , {doNOP, 125 /* } */, 74,0, FALSE} // 71 + , {doTagDigit, 128, 70,0, TRUE} // 72 + , {doTagExpectedError, 255, 103,0, FALSE} // 73 , {doNOP, 132, 74,0, TRUE} // 74 tag-close - , {doTagValue, 125 /* } */, 77,0, TRUE} // 75 - , {doTagExpectedError, 255, 103,0, FALSE} // 76 + , {doTagValue, 125 /* } */, 77,0, TRUE} // 75 + , {doTagExpectedError, 255, 103,0, FALSE} // 76 , {doExprCatOperator, 254, 29,0, FALSE} // 77 expr-cont-no-tag - , {doNOP, 132, 77,0, TRUE} // 78 - , {doExprCatOperator, 131, 29,0, FALSE} // 79 - , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 80 - , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 81 - , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 82 - , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 83 - , {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 84 - , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 85 - , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 86 - , {doExprFinished, 255, 255,0, FALSE} // 87 + , {doNOP, 132, 77,0, TRUE} // 78 + , {doExprCatOperator, 131, 29,0, FALSE} // 79 + , {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 80 + , {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 81 + , {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 82 + , {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 83 + , {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 84 + , {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 85 + , {doExprRParen, 41 /* ) */, 255,0, TRUE} // 86 + , {doExprFinished, 255, 255,0, FALSE} // 87 , {doStartVariableName, 36 /* $ */, 90,0, TRUE} // 88 scan-var-name - , {doNOP, 255, 103,0, FALSE} // 89 + , {doNOP, 255, 103,0, FALSE} // 89 , {doNOP, 130, 92,0, TRUE} // 90 scan-var-start - , {doVariableNameExpectedErr, 255, 103,0, FALSE} // 91 + , {doVariableNameExpectedErr, 255, 103,0, FALSE} // 91 , {doNOP, 129, 92,0, TRUE} // 92 scan-var-body - , {doEndVariableName, 255, 255,0, FALSE} // 93 + , {doEndVariableName, 255, 255,0, FALSE} // 93 , {doScanUnicodeSet, 91 /* [ */, 255,0, TRUE} // 94 scan-unicode-set - , {doScanUnicodeSet, 112 /* p */, 255,0, TRUE} // 95 - , {doScanUnicodeSet, 80 /* P */, 255,0, TRUE} // 96 - , {doNOP, 255, 103,0, FALSE} // 97 + , {doScanUnicodeSet, 112 /* p */, 255,0, TRUE} // 95 + , {doScanUnicodeSet, 80 /* P */, 255,0, TRUE} // 96 + , {doNOP, 255, 103,0, FALSE} // 97 , {doNOP, 132, 98,0, TRUE} // 98 assign-or-rule - , {doStartAssign, 61 /* = */, 29, 101, TRUE} // 99 - , {doNOP, 255, 37, 9, FALSE} // 100 + , {doStartAssign, 61 /* = */, 29, 101, TRUE} // 99 + , {doNOP, 255, 37, 9, FALSE} // 100 , {doEndAssign, 59 /* ; */, 1,0, TRUE} // 101 assign-end - , {doRuleErrorAssignExpr, 255, 103,0, FALSE} // 102 + , {doRuleErrorAssignExpr, 255, 103,0, FALSE} // 102 , {doExit, 255, 103,0, TRUE} // 103 errorDeath }; #ifdef RBBI_DEBUG diff --git a/deps/icu-small/source/common/rbbiscan.cpp b/deps/icu-small/source/common/rbbiscan.cpp index 170c212e13fd1f..f536ab5d39863c 100644 --- a/deps/icu-small/source/common/rbbiscan.cpp +++ b/deps/icu-small/source/common/rbbiscan.cpp @@ -96,7 +96,7 @@ RBBIRuleScanner::RBBIRuleScanner(RBBIRuleBuilder *rb) fLineNum = 1; fCharNum = 0; fLastChar = 0; - + fStateTable = NULL; fStack[0] = 0; fStackPtr = 0; @@ -357,7 +357,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action) thisRule->fRuleRoot = TRUE; // Flag if chaining into this rule is wanted. - // + // if (fRB->fChainRules && // If rule chaining is enabled globally via !!chain !fNoChainInRule) { // and no '^' chain-in inhibit was on this rule thisRule->fChainIn = TRUE; @@ -1114,7 +1114,7 @@ void RBBIRuleScanner::parse() { if (U_FAILURE(*fRB->fStatus)) { return; } - + // If there are no forward rules set an error. // if (fRB->fForwardTree == NULL) { diff --git a/deps/icu-small/source/common/rbbiscan.h b/deps/icu-small/source/common/rbbiscan.h index cac60fb18a11b8..c51b4cf2a68aa1 100644 --- a/deps/icu-small/source/common/rbbiscan.h +++ b/deps/icu-small/source/common/rbbiscan.h @@ -34,7 +34,7 @@ class RBBISymbolTable; //-------------------------------------------------------------------------------- // // class RBBIRuleScanner does the lowest level, character-at-a-time -// scanning of break iterator rules. +// scanning of break iterator rules. // // The output of the scanner is parse trees for // the rule expressions and a list of all Unicode Sets diff --git a/deps/icu-small/source/common/rbbisetb.cpp b/deps/icu-small/source/common/rbbisetb.cpp index e6b98cf3e22b98..36e2e07e9c65a0 100644 --- a/deps/icu-small/source/common/rbbisetb.cpp +++ b/deps/icu-small/source/common/rbbisetb.cpp @@ -207,7 +207,7 @@ void RBBISetBuilder::buildRanges() { } if (rlRange->fNum == 0) { fGroupCount ++; - rlRange->fNum = fGroupCount+2; + rlRange->fNum = fGroupCount+2; rlRange->setDictionaryFlag(); addValToSets(rlRange->fIncludesSets, fGroupCount+2); } @@ -397,7 +397,7 @@ UBool RBBISetBuilder::sawBOF() const { //------------------------------------------------------------------------ // // getFirstChar Given a runtime RBBI character category, find -// the first UChar32 that is in the set of chars +// the first UChar32 that is in the set of chars // in the category. //------------------------------------------------------------------------ UChar32 RBBISetBuilder::getFirstChar(int32_t category) const { diff --git a/deps/icu-small/source/common/rbbistbl.cpp b/deps/icu-small/source/common/rbbistbl.cpp index d90992290c3e63..5303f7609698ec 100644 --- a/deps/icu-small/source/common/rbbistbl.cpp +++ b/deps/icu-small/source/common/rbbistbl.cpp @@ -45,7 +45,7 @@ RBBISymbolTable::RBBISymbolTable(RBBIRuleScanner *rs, const UnicodeString &rules { fHashTable = NULL; fCachedSetLookup = NULL; - + fHashTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status); // uhash_open checks status if (U_FAILURE(status)) { diff --git a/deps/icu-small/source/common/rbbitblb.cpp b/deps/icu-small/source/common/rbbitblb.cpp index e6ae2dc654a88c..a20b51777cda7a 100644 --- a/deps/icu-small/source/common/rbbitblb.cpp +++ b/deps/icu-small/source/common/rbbitblb.cpp @@ -86,11 +86,11 @@ void RBBITableBuilder::buildForwardTable() { #endif // - // If the rules contained any references to {bof} + // If the rules contained any references to {bof} // add a {bof} to the - // tree. Means that all matches must start out with the + // tree. Means that all matches must start out with the // {bof} fake character. - // + // if (fRB->fSetBuilder->sawBOF()) { RBBINode *bofTop = new RBBINode(RBBINode::opCat); RBBINode *bofLeaf = new RBBINode(RBBINode::leafChar); @@ -421,9 +421,9 @@ void RBBITableBuilder::calcChainedFollowPos(RBBINode *tree) { } // Collect all leaf nodes that can start matches for rules - // with inbound chaining enabled, which is the union of the + // with inbound chaining enabled, which is the union of the // firstPosition sets from each of the rule root nodes. - + UVector ruleRootNodes(*fStatus); addRuleRootNodes(&ruleRootNodes, tree); @@ -534,7 +534,7 @@ void RBBITableBuilder::bofFixup() { // (excluding the fake bofNode) // We want the nodes that can start a match in the // part labeled "rest of tree" - // + // UVector *matchStartNodes = fTree->fLeftChild->fRightChild->fFirstPosSet; RBBINode *startNode; @@ -550,7 +550,7 @@ void RBBITableBuilder::bofFixup() { // explicitly written into a rule. // Add everything from the followPos set of this node to the // followPos set of the fake bofNode at the start of the tree. - // + // setAdd(bofNode->fFollowPos, startNode->fFollowPos); } } @@ -571,7 +571,7 @@ void RBBITableBuilder::buildStateTable() { } RBBIStateDescriptor *failState; // Set it to NULL to avoid uninitialized warning - RBBIStateDescriptor *initialState = NULL; + RBBIStateDescriptor *initialState = NULL; // // Add a dummy state 0 - the stop state. Not from Aho. int lastInputSymbol = fRB->fSetBuilder->getNumCharCategories() - 1; @@ -648,8 +648,8 @@ void RBBITableBuilder::buildStateTable() { if (U == NULL) { U = new UVector(*fStatus); if (U == NULL) { - *fStatus = U_MEMORY_ALLOCATION_ERROR; - goto ExitBuildSTdeleteall; + *fStatus = U_MEMORY_ALLOCATION_ERROR; + goto ExitBuildSTdeleteall; } } setAdd(U, p->fFollowPos); @@ -679,7 +679,7 @@ void RBBITableBuilder::buildStateTable() { { RBBIStateDescriptor *newState = new RBBIStateDescriptor(lastInputSymbol, fStatus); if (newState == NULL) { - *fStatus = U_MEMORY_ALLOCATION_ERROR; + *fStatus = U_MEMORY_ALLOCATION_ERROR; } if (U_FAILURE(*fStatus)) { goto ExitBuildSTdeleteall; diff --git a/deps/icu-small/source/common/resbund.cpp b/deps/icu-small/source/common/resbund.cpp index 00dbf6f8fe2e9c..7c5063b21143c4 100644 --- a/deps/icu-small/source/common/resbund.cpp +++ b/deps/icu-small/source/common/resbund.cpp @@ -51,6 +51,7 @@ #include "unicode/utypes.h" #include "unicode/resbund.h" +#include "cmemory.h" #include "mutex.h" #include "uassert.h" #include "umutex.h" @@ -205,7 +206,7 @@ ResourceBundle::ResourceBundle(UResourceBundle *res, UErrorCode& err) } } -ResourceBundle::ResourceBundle(const char* path, const Locale& locale, UErrorCode& err) +ResourceBundle::ResourceBundle(const char* path, const Locale& locale, UErrorCode& err) :UObject(), fLocale(NULL) { fResource = ures_open(path, locale.getName(), &err); @@ -377,7 +378,7 @@ void ResourceBundle::getVersion(UVersionInfo versionInfo) const { } const Locale &ResourceBundle::getLocale(void) const { - static UMutex gLocaleLock = U_MUTEX_INITIALIZER; + static UMutex gLocaleLock; Mutex lock(&gLocaleLock); if (fLocale != NULL) { return *fLocale; diff --git a/deps/icu-small/source/common/resbund_cnv.cpp b/deps/icu-small/source/common/resbund_cnv.cpp index ae854fe739cd32..45c0b399bfff45 100644 --- a/deps/icu-small/source/common/resbund_cnv.cpp +++ b/deps/icu-small/source/common/resbund_cnv.cpp @@ -39,7 +39,7 @@ ResourceBundle::ResourceBundle( const UnicodeString& path, constructForLocale(path, Locale::getDefault(), error); } -void +void ResourceBundle::constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error) diff --git a/deps/icu-small/source/common/resource.h b/deps/icu-small/source/common/resource.h index 3dbff785ef12a8..5199b858880770 100644 --- a/deps/icu-small/source/common/resource.h +++ b/deps/icu-small/source/common/resource.h @@ -28,6 +28,7 @@ #include "unicode/utypes.h" #include "unicode/unistr.h" #include "unicode/ures.h" +#include "restrace.h" struct ResourceData; @@ -47,8 +48,10 @@ class U_COMMON_API ResourceArray { ResourceArray() : items16(NULL), items32(NULL), length(0) {} /** Only for implementation use. @internal */ - ResourceArray(const uint16_t *i16, const uint32_t *i32, int32_t len) : - items16(i16), items32(i32), length(len) {} + ResourceArray(const uint16_t *i16, const uint32_t *i32, int32_t len, + const ResourceTracer& traceInfo) : + items16(i16), items32(i32), length(len), + fTraceInfo(traceInfo) {} /** * @return The number of items in the array resource. @@ -68,6 +71,7 @@ class U_COMMON_API ResourceArray { const uint16_t *items16; const uint32_t *items32; int32_t length; + ResourceTracer fTraceInfo; }; /** @@ -80,27 +84,37 @@ class U_COMMON_API ResourceTable { /** Only for implementation use. @internal */ ResourceTable(const uint16_t *k16, const int32_t *k32, - const uint16_t *i16, const uint32_t *i32, int32_t len) : - keys16(k16), keys32(k32), items16(i16), items32(i32), length(len) {} + const uint16_t *i16, const uint32_t *i32, int32_t len, + const ResourceTracer& traceInfo) : + keys16(k16), keys32(k32), items16(i16), items32(i32), length(len), + fTraceInfo(traceInfo) {} /** * @return The number of items in the array resource. */ int32_t getSize() const { return length; } /** - * @param i Array item index. + * @param i Table item index. * @param key Output-only, receives the key of the i'th item. * @param value Output-only, receives the value of the i'th item. * @return TRUE if i is non-negative and less than getSize(). */ UBool getKeyAndValue(int32_t i, const char *&key, ResourceValue &value) const; + /** + * @param key Key string to find in the table. + * @param value Output-only, receives the value of the item with that key. + * @return TRUE if the table contains the key. + */ + UBool findValue(const char *key, ResourceValue &value) const; + private: const uint16_t *keys16; const int32_t *keys32; const uint16_t *items16; const uint32_t *items32; int32_t length; + ResourceTracer fTraceInfo; }; /** diff --git a/deps/icu-small/source/common/restrace.cpp b/deps/icu-small/source/common/restrace.cpp new file mode 100644 index 00000000000000..5c6498850e2f8f --- /dev/null +++ b/deps/icu-small/source/common/restrace.cpp @@ -0,0 +1,130 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if U_ENABLE_TRACING + +#include "restrace.h" +#include "charstr.h" +#include "cstring.h" +#include "utracimp.h" +#include "uresimp.h" +#include "uassert.h" +#include "util.h" + +U_NAMESPACE_BEGIN + +ResourceTracer::~ResourceTracer() = default; + +void ResourceTracer::trace(const char* resType) const { + U_ASSERT(fResB || fParent); + UTRACE_ENTRY(UTRACE_UDATA_RESOURCE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + getFilePath(filePath, status); + + CharString resPath; + getResPath(resPath, status); + + // The longest type ("intvector") is 9 chars + const char kSpaces[] = " "; + CharString format; + format.append(kSpaces, sizeof(kSpaces) - 1 - uprv_strlen(resType), status); + format.append("(%s) %s @ %s", status); + + UTRACE_DATA3(UTRACE_VERBOSE, + format.data(), + resType, + filePath.data(), + resPath.data()); + UTRACE_EXIT_STATUS(status); +} + +void ResourceTracer::traceOpen() const { + U_ASSERT(fResB); + UTRACE_ENTRY(UTRACE_UDATA_BUNDLE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + UTRACE_DATA1(UTRACE_VERBOSE, "%s", getFilePath(filePath, status).data()); + UTRACE_EXIT_STATUS(status); +} + +CharString& ResourceTracer::getFilePath(CharString& output, UErrorCode& status) const { + if (fResB) { + output.append(fResB->fData->fPath, status); + output.append('/', status); + output.append(fResB->fData->fName, status); + output.append(".res", status); + } else { + fParent->getFilePath(output, status); + } + return output; +} + +CharString& ResourceTracer::getResPath(CharString& output, UErrorCode& status) const { + if (fResB) { + output.append('/', status); + output.append(fResB->fResPath, status); + // removing the trailing / + U_ASSERT(output[output.length()-1] == '/'); + output.truncate(output.length()-1); + } else { + fParent->getResPath(output, status); + } + if (fKey) { + output.append('/', status); + output.append(fKey, status); + } + if (fIndex != -1) { + output.append('[', status); + UnicodeString indexString; + ICU_Utility::appendNumber(indexString, fIndex); + output.appendInvariantChars(indexString, status); + output.append(']', status); + } + return output; +} + +void FileTracer::traceOpen(const char* path, const char* type, const char* name) { + if (uprv_strcmp(type, "res") == 0) { + traceOpenResFile(path, name); + } else { + traceOpenDataFile(path, type, name); + } +} + +void FileTracer::traceOpenDataFile(const char* path, const char* type, const char* name) { + UTRACE_ENTRY(UTRACE_UDATA_DATA_FILE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + filePath.append(path, status); + filePath.append('/', status); + filePath.append(name, status); + filePath.append('.', status); + filePath.append(type, status); + + UTRACE_DATA1(UTRACE_VERBOSE, "%s", filePath.data()); + UTRACE_EXIT_STATUS(status); +} + +void FileTracer::traceOpenResFile(const char* path, const char* name) { + UTRACE_ENTRY(UTRACE_UDATA_RES_FILE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + filePath.append(path, status); + filePath.append('/', status); + filePath.append(name, status); + filePath.append(".res", status); + + UTRACE_DATA1(UTRACE_VERBOSE, "%s", filePath.data()); + UTRACE_EXIT_STATUS(status); +} + +U_NAMESPACE_END + +#endif // U_ENABLE_TRACING diff --git a/deps/icu-small/source/common/restrace.h b/deps/icu-small/source/common/restrace.h new file mode 100644 index 00000000000000..ef29eaed578107 --- /dev/null +++ b/deps/icu-small/source/common/restrace.h @@ -0,0 +1,147 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#ifndef __RESTRACE_H__ +#define __RESTRACE_H__ + +#include "unicode/utypes.h" + +#if U_ENABLE_TRACING + +struct UResourceBundle; + +U_NAMESPACE_BEGIN + +class CharString; + +/** + * Instances of this class store information used to trace reads from resource + * bundles when ICU is built with --enable-tracing. + * + * All arguments of type const UResourceBundle*, const char*, and + * const ResourceTracer& are stored as pointers. The caller must retain + * ownership for the lifetime of this ResourceTracer. + * + * Exported as U_COMMON_API for Windows because it is a value field + * in other exported types. + */ +class U_COMMON_API ResourceTracer { +public: + ResourceTracer() : + fResB(nullptr), + fParent(nullptr), + fKey(nullptr), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB) : + fResB(resB), + fParent(nullptr), + fKey(nullptr), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB, const char* key) : + fResB(resB), + fParent(nullptr), + fKey(key), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB, int32_t index) : + fResB(resB), + fParent(nullptr), + fKey(nullptr), + fIndex(index) {} + + ResourceTracer(const ResourceTracer& parent, const char* key) : + fResB(nullptr), + fParent(&parent), + fKey(key), + fIndex(-1) {} + + ResourceTracer(const ResourceTracer& parent, int32_t index) : + fResB(nullptr), + fParent(&parent), + fKey(nullptr), + fIndex(index) {} + + ~ResourceTracer(); + + void trace(const char* type) const; + void traceOpen() const; + + /** + * Calls trace() if the resB or parent provided to the constructor was + * non-null; otherwise, does nothing. + */ + void maybeTrace(const char* type) const { + if (fResB || fParent) { + trace(type); + } + } + +private: + const UResourceBundle* fResB; + const ResourceTracer* fParent; + const char* fKey; + int32_t fIndex; + + CharString& getFilePath(CharString& output, UErrorCode& status) const; + + CharString& getResPath(CharString& output, UErrorCode& status) const; +}; + +/** + * This class provides methods to trace data file reads when ICU is built + * with --enable-tracing. + */ +class FileTracer { +public: + static void traceOpen(const char* path, const char* type, const char* name); + +private: + static void traceOpenDataFile(const char* path, const char* type, const char* name); + static void traceOpenResFile(const char* path, const char* name); +}; + +U_NAMESPACE_END + +#else // U_ENABLE_TRACING + +U_NAMESPACE_BEGIN + +/** + * Default trivial implementation when --enable-tracing is not used. + */ +class U_COMMON_API ResourceTracer { +public: + ResourceTracer() {} + + ResourceTracer(const void*) {} + + ResourceTracer(const void*, const char*) {} + + ResourceTracer(const void*, int32_t) {} + + ResourceTracer(const ResourceTracer&, const char*) {} + + ResourceTracer(const ResourceTracer&, int32_t) {} + + void trace(const char*) const {} + + void traceOpen() const {} + + void maybeTrace(const char*) const {} +}; + +/** + * Default trivial implementation when --enable-tracing is not used. + */ +class FileTracer { +public: + static void traceOpen(const char*, const char*, const char*) {} +}; + +U_NAMESPACE_END + +#endif // U_ENABLE_TRACING + +#endif //__RESTRACE_H__ diff --git a/deps/icu-small/source/common/ruleiter.h b/deps/icu-small/source/common/ruleiter.h index b6edc657aff261..4e1be53823d78a 100644 --- a/deps/icu-small/source/common/ruleiter.h +++ b/deps/icu-small/source/common/ruleiter.h @@ -39,7 +39,7 @@ class RuleCharacterIterator : public UMemory { private: /** * Text being iterated. - */ + */ const UnicodeString& text; /** @@ -51,7 +51,7 @@ class RuleCharacterIterator : public UMemory { * Symbol table used to parse and dereference variables. May be 0. */ const SymbolTable* sym; - + /** * Current variable expansion, or 0 if none. */ @@ -102,7 +102,7 @@ class RuleCharacterIterator : public UMemory { */ RuleCharacterIterator(const UnicodeString& text, const SymbolTable* sym, ParsePosition& pos); - + /** * Returns true if this iterator has no more characters to return. */ @@ -207,7 +207,7 @@ class RuleCharacterIterator : public UMemory { * representation of this object */ // UnicodeString& toString(UnicodeString& result) const; - + private: /** * Returns the current 32-bit code point without parsing escapes, parsing @@ -215,7 +215,7 @@ class RuleCharacterIterator : public UMemory { * @return the current 32-bit code point */ UChar32 _current() const; - + /** * Advances the position by the given amount. * @param count the number of 16-bit code units to advance past diff --git a/deps/icu-small/source/common/schriter.cpp b/deps/icu-small/source/common/schriter.cpp index f852800aaae6bd..17b68aee9d923a 100644 --- a/deps/icu-small/source/common/schriter.cpp +++ b/deps/icu-small/source/common/schriter.cpp @@ -101,7 +101,7 @@ StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const && end == realThat.end; } -CharacterIterator* +StringCharacterIterator* StringCharacterIterator::clone() const { return new StringCharacterIterator(*this); } diff --git a/deps/icu-small/source/common/serv.cpp b/deps/icu-small/source/common/serv.cpp index 40940740d02b45..ce545b9dbd5ecb 100644 --- a/deps/icu-small/source/common/serv.cpp +++ b/deps/icu-small/source/common/serv.cpp @@ -26,60 +26,60 @@ U_NAMESPACE_BEGIN const UChar ICUServiceKey::PREFIX_DELIMITER = 0x002F; /* '/' */ -ICUServiceKey::ICUServiceKey(const UnicodeString& id) +ICUServiceKey::ICUServiceKey(const UnicodeString& id) : _id(id) { } -ICUServiceKey::~ICUServiceKey() +ICUServiceKey::~ICUServiceKey() { } -const UnicodeString& -ICUServiceKey::getID() const +const UnicodeString& +ICUServiceKey::getID() const { return _id; } -UnicodeString& -ICUServiceKey::canonicalID(UnicodeString& result) const +UnicodeString& +ICUServiceKey::canonicalID(UnicodeString& result) const { return result.append(_id); } -UnicodeString& -ICUServiceKey::currentID(UnicodeString& result) const +UnicodeString& +ICUServiceKey::currentID(UnicodeString& result) const { return canonicalID(result); } -UnicodeString& -ICUServiceKey::currentDescriptor(UnicodeString& result) const +UnicodeString& +ICUServiceKey::currentDescriptor(UnicodeString& result) const { prefix(result); result.append(PREFIX_DELIMITER); return currentID(result); } -UBool -ICUServiceKey::fallback() +UBool +ICUServiceKey::fallback() { return FALSE; } -UBool -ICUServiceKey::isFallbackOf(const UnicodeString& id) const +UBool +ICUServiceKey::isFallbackOf(const UnicodeString& id) const { return id == _id; } -UnicodeString& -ICUServiceKey::prefix(UnicodeString& result) const +UnicodeString& +ICUServiceKey::prefix(UnicodeString& result) const { return result; } -UnicodeString& -ICUServiceKey::parsePrefix(UnicodeString& result) +UnicodeString& +ICUServiceKey::parsePrefix(UnicodeString& result) { int32_t n = result.indexOf(PREFIX_DELIMITER); if (n < 0) { @@ -89,8 +89,8 @@ ICUServiceKey::parsePrefix(UnicodeString& result) return result; } -UnicodeString& -ICUServiceKey::parseSuffix(UnicodeString& result) +UnicodeString& +ICUServiceKey::parseSuffix(UnicodeString& result) { int32_t n = result.indexOf(PREFIX_DELIMITER); if (n >= 0) { @@ -100,8 +100,8 @@ ICUServiceKey::parseSuffix(UnicodeString& result) } #ifdef SERVICE_DEBUG -UnicodeString& -ICUServiceKey::debug(UnicodeString& result) const +UnicodeString& +ICUServiceKey::debug(UnicodeString& result) const { debugClass(result); result.append((UnicodeString)" id: "); @@ -109,8 +109,8 @@ ICUServiceKey::debug(UnicodeString& result) const return result; } -UnicodeString& -ICUServiceKey::debugClass(UnicodeString& result) const +UnicodeString& +ICUServiceKey::debugClass(UnicodeString& result) const { return result.append((UnicodeString)"ICUServiceKey"); } @@ -124,30 +124,30 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUServiceKey) ICUServiceFactory::~ICUServiceFactory() {} -SimpleFactory::SimpleFactory(UObject* instanceToAdopt, const UnicodeString& id, UBool visible) +SimpleFactory::SimpleFactory(UObject* instanceToAdopt, const UnicodeString& id, UBool visible) : _instance(instanceToAdopt), _id(id), _visible(visible) { } -SimpleFactory::~SimpleFactory() +SimpleFactory::~SimpleFactory() { delete _instance; } -UObject* -SimpleFactory::create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const +UObject* +SimpleFactory::create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const { if (U_SUCCESS(status)) { UnicodeString temp; if (_id == key.currentID(temp)) { - return service->cloneInstance(_instance); + return service->cloneInstance(_instance); } } return NULL; } -void -SimpleFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const +void +SimpleFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const { if (_visible) { result.put(_id, (void*)this, status); // cast away const @@ -156,8 +156,8 @@ SimpleFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const } } -UnicodeString& -SimpleFactory::getDisplayName(const UnicodeString& id, const Locale& /* locale */, UnicodeString& result) const +UnicodeString& +SimpleFactory::getDisplayName(const UnicodeString& id, const Locale& /* locale */, UnicodeString& result) const { if (_visible && _id == id) { result = _id; @@ -168,8 +168,8 @@ SimpleFactory::getDisplayName(const UnicodeString& id, const Locale& /* locale * } #ifdef SERVICE_DEBUG -UnicodeString& -SimpleFactory::debug(UnicodeString& toAppendTo) const +UnicodeString& +SimpleFactory::debug(UnicodeString& toAppendTo) const { debugClass(toAppendTo); toAppendTo.append((UnicodeString)" id: "); @@ -179,8 +179,8 @@ SimpleFactory::debug(UnicodeString& toAppendTo) const return toAppendTo; } -UnicodeString& -SimpleFactory::debugClass(UnicodeString& toAppendTo) const +UnicodeString& +SimpleFactory::debugClass(UnicodeString& toAppendTo) const { return toAppendTo.append((UnicodeString)"SimpleFactory"); } @@ -217,14 +217,14 @@ class CacheEntry : public UMemory { delete service; } - CacheEntry(const UnicodeString& _actualDescriptor, UObject* _service) + CacheEntry(const UnicodeString& _actualDescriptor, UObject* _service) : refcount(1), actualDescriptor(_actualDescriptor), service(_service) { } /** * Instantiation creates an initial reference, so don't call this * unless you're creating a new pointer to this. Management of - * that pointer will have to know how to deal with refcounts. + * that pointer will have to know how to deal with refcounts. * Return true if the resource has not already been released. */ CacheEntry* ref() { @@ -281,8 +281,8 @@ class DNCache : public UMemory { Hashtable cache; const Locale locale; - DNCache(const Locale& _locale) - : cache(), locale(_locale) + DNCache(const Locale& _locale) + : cache(), locale(_locale) { // cache.setKeyDeleter(uprv_deleteUObject); } @@ -293,8 +293,8 @@ class DNCache : public UMemory { ****************************************************************** */ -StringPair* -StringPair::create(const UnicodeString& displayName, +StringPair* +StringPair::create(const UnicodeString& displayName, const UnicodeString& id, UErrorCode& status) { @@ -310,12 +310,12 @@ StringPair::create(const UnicodeString& displayName, return NULL; } -UBool +UBool StringPair::isBogus() const { return displayName.isBogus() || id.isBogus(); } -StringPair::StringPair(const UnicodeString& _displayName, +StringPair::StringPair(const UnicodeString& _displayName, const UnicodeString& _id) : displayName(_displayName) , id(_id) @@ -333,10 +333,7 @@ U_CDECL_END ****************************************************************** */ -static UMutex *lock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex lock; ICUService::ICUService() : name() @@ -348,7 +345,7 @@ ICUService::ICUService() { } -ICUService::ICUService(const UnicodeString& newName) +ICUService::ICUService(const UnicodeString& newName) : name(newName) , timestamp(0) , factories(NULL) @@ -361,21 +358,21 @@ ICUService::ICUService(const UnicodeString& newName) ICUService::~ICUService() { { - Mutex mutex(lock()); + Mutex mutex(&lock); clearCaches(); delete factories; factories = NULL; } } -UObject* -ICUService::get(const UnicodeString& descriptor, UErrorCode& status) const +UObject* +ICUService::get(const UnicodeString& descriptor, UErrorCode& status) const { return get(descriptor, NULL, status); } -UObject* -ICUService::get(const UnicodeString& descriptor, UnicodeString* actualReturn, UErrorCode& status) const +UObject* +ICUService::get(const UnicodeString& descriptor, UnicodeString* actualReturn, UErrorCode& status) const { UObject* result = NULL; ICUServiceKey* key = createKey(&descriptor, status); @@ -386,8 +383,8 @@ ICUService::get(const UnicodeString& descriptor, UnicodeString* actualReturn, UE return result; } -UObject* -ICUService::getKey(ICUServiceKey& key, UErrorCode& status) const +UObject* +ICUService::getKey(ICUServiceKey& key, UErrorCode& status) const { return getKey(key, NULL, status); } @@ -395,8 +392,8 @@ ICUService::getKey(ICUServiceKey& key, UErrorCode& status) const // this is a vector that subclasses of ICUService can override to further customize the result object // before returning it. All other public get functions should call this one. -UObject* -ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const +UObject* +ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const { return getKey(key, actualReturn, NULL, status); } @@ -406,9 +403,9 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& // reentrantly even without knowing the thread. class XMutex : public UMemory { public: - inline XMutex(UMutex *mutex, UBool reentering) + inline XMutex(UMutex *mutex, UBool reentering) : fMutex(mutex) - , fActive(!reentering) + , fActive(!reentering) { if (fActive) umtx_lock(fMutex); } @@ -428,8 +425,8 @@ struct UVectorDeleter { }; // called only by factories, treat as private -UObject* -ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUServiceFactory* factory, UErrorCode& status) const +UObject* +ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUServiceFactory* factory, UErrorCode& status) const { if (U_FAILURE(status)) { return NULL; @@ -443,16 +440,16 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer CacheEntry* result = NULL; { - // The factory list can't be modified until we're done, + // The factory list can't be modified until we're done, // otherwise we might update the cache with an invalid result. // The cache has to stay in synch with the factory list. - // ICU doesn't have monitors so we can't use rw locks, so + // ICU doesn't have monitors so we can't use rw locks, so // we single-thread everything using this service, for now. // if factory is not null, we're calling from within the mutex, // and since some unix machines don't have reentrant mutexes we // need to make sure not to try to lock it again. - XMutex mutex(lock(), factory != NULL); + XMutex mutex(&lock, factory != NULL); if (serviceCache == NULL) { ncthis->serviceCache = new Hashtable(status); @@ -498,7 +495,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer } // first test of cache failed, so we'll have to update - // the cache if we eventually succeed-- that is, if we're + // the cache if we eventually succeed-- that is, if we're // going to update the cache at all. putInCache = TRUE; @@ -522,7 +519,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer } } - // prepare to load the cache with all additional ids that + // prepare to load the cache with all additional ids that // will resolve to result, assuming we'll succeed. We // don't want to keep querying on an id that's going to // fallback to the one that succeeded, we want to hit the @@ -572,8 +569,8 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer // strip null prefix if (result->actualDescriptor.indexOf((UChar)0x2f) == 0) { // U+002f=slash (/) actualReturn->remove(); - actualReturn->append(result->actualDescriptor, - 1, + actualReturn->append(result->actualDescriptor, + 1, result->actualDescriptor.length() - 1); } else { *actualReturn = result->actualDescriptor; @@ -597,19 +594,19 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer return handleDefault(key, actualReturn, status); } -UObject* -ICUService::handleDefault(const ICUServiceKey& /* key */, UnicodeString* /* actualIDReturn */, UErrorCode& /* status */) const +UObject* +ICUService::handleDefault(const ICUServiceKey& /* key */, UnicodeString* /* actualIDReturn */, UErrorCode& /* status */) const { return NULL; } -UVector& +UVector& ICUService::getVisibleIDs(UVector& result, UErrorCode& status) const { return getVisibleIDs(result, NULL, status); } -UVector& -ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorCode& status) const +UVector& +ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorCode& status) const { result.removeAllElements(); @@ -618,7 +615,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC } { - Mutex mutex(lock()); + Mutex mutex(&lock); const Hashtable* map = getVisibleIDMap(status); if (map != NULL) { ICUServiceKey* fallbackKey = createKey(matchID, status); @@ -657,7 +654,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC return result; } -const Hashtable* +const Hashtable* ICUService::getVisibleIDMap(UErrorCode& status) const { if (U_FAILURE(status)) return NULL; @@ -684,18 +681,18 @@ ICUService::getVisibleIDMap(UErrorCode& status) const { } -UnicodeString& -ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result) const +UnicodeString& +ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result) const { return getDisplayName(id, result, Locale::getDefault()); } -UnicodeString& -ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const Locale& locale) const +UnicodeString& +ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const Locale& locale) const { { UErrorCode status = U_ZERO_ERROR; - Mutex mutex(lock()); + Mutex mutex(&lock); const Hashtable* map = getVisibleIDMap(status); if (map != NULL) { ICUServiceFactory* f = (ICUServiceFactory*)map->get(id); @@ -724,30 +721,30 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const return result; } -UVector& -ICUService::getDisplayNames(UVector& result, UErrorCode& status) const +UVector& +ICUService::getDisplayNames(UVector& result, UErrorCode& status) const { return getDisplayNames(result, Locale::getDefault(), NULL, status); } -UVector& -ICUService::getDisplayNames(UVector& result, const Locale& locale, UErrorCode& status) const +UVector& +ICUService::getDisplayNames(UVector& result, const Locale& locale, UErrorCode& status) const { return getDisplayNames(result, locale, NULL, status); } -UVector& -ICUService::getDisplayNames(UVector& result, - const Locale& locale, - const UnicodeString* matchID, - UErrorCode& status) const +UVector& +ICUService::getDisplayNames(UVector& result, + const Locale& locale, + const UnicodeString* matchID, + UErrorCode& status) const { result.removeAllElements(); result.setDeleter(userv_deleteStringPair); if (U_SUCCESS(status)) { ICUService* ncthis = (ICUService*)this; // cast away semantic const - Mutex mutex(lock()); + Mutex mutex(&lock); if (dnCache != NULL && dnCache->locale != locale) { delete dnCache; @@ -759,7 +756,7 @@ ICUService::getDisplayNames(UVector& result, if (U_FAILURE(status)) { return result; } - ncthis->dnCache = new DNCache(locale); + ncthis->dnCache = new DNCache(locale); if (dnCache == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return result; @@ -792,7 +789,7 @@ ICUService::getDisplayNames(UVector& result, * nextElement(pos) will skip the position at pos and begin the iteration * at the next position, which in this case will be 0. */ - int32_t pos = UHASH_FIRST; + int32_t pos = UHASH_FIRST; const UHashElement *entry = NULL; while ((entry = dnCache->cache.nextElement(pos)) != NULL) { const UnicodeString* id = (const UnicodeString*)entry->value.pointer; @@ -813,13 +810,13 @@ ICUService::getDisplayNames(UVector& result, } URegistryKey -ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UErrorCode& status) +ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UErrorCode& status) { return registerInstance(objToAdopt, id, TRUE, status); } URegistryKey -ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UBool visible, UErrorCode& status) +ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UBool visible, UErrorCode& status) { ICUServiceKey* key = createKey(&id, status); if (key != NULL) { @@ -836,7 +833,7 @@ ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UBool return NULL; } -ICUServiceFactory* +ICUServiceFactory* ICUService::createSimpleFactory(UObject* objToAdopt, const UnicodeString& id, UBool visible, UErrorCode& status) { if (U_SUCCESS(status)) { @@ -849,10 +846,10 @@ ICUService::createSimpleFactory(UObject* objToAdopt, const UnicodeString& id, UB } URegistryKey -ICUService::registerFactory(ICUServiceFactory* factoryToAdopt, UErrorCode& status) +ICUService::registerFactory(ICUServiceFactory* factoryToAdopt, UErrorCode& status) { if (U_SUCCESS(status) && factoryToAdopt != NULL) { - Mutex mutex(lock()); + Mutex mutex(&lock); if (factories == NULL) { factories = new UVector(deleteUObject, NULL, status); @@ -877,13 +874,13 @@ ICUService::registerFactory(ICUServiceFactory* factoryToAdopt, UErrorCode& statu return (URegistryKey)factoryToAdopt; } -UBool -ICUService::unregister(URegistryKey rkey, UErrorCode& status) +UBool +ICUService::unregister(URegistryKey rkey, UErrorCode& status) { ICUServiceFactory *factory = (ICUServiceFactory*)rkey; UBool result = FALSE; if (factory != NULL && factories != NULL) { - Mutex mutex(lock()); + Mutex mutex(&lock); if (factories->removeElement(factory)) { clearCaches(); @@ -899,39 +896,39 @@ ICUService::unregister(URegistryKey rkey, UErrorCode& status) return result; } -void -ICUService::reset() +void +ICUService::reset() { { - Mutex mutex(lock()); + Mutex mutex(&lock); reInitializeFactories(); clearCaches(); } notifyChanged(); } -void -ICUService::reInitializeFactories() +void +ICUService::reInitializeFactories() { if (factories != NULL) { factories->removeAllElements(); } } -UBool -ICUService::isDefault() const +UBool +ICUService::isDefault() const { return countFactories() == 0; } -ICUServiceKey* -ICUService::createKey(const UnicodeString* id, UErrorCode& status) const +ICUServiceKey* +ICUService::createKey(const UnicodeString* id, UErrorCode& status) const { return (U_FAILURE(status) || id == NULL) ? NULL : new ICUServiceKey(*id); } -void -ICUService::clearCaches() +void +ICUService::clearCaches() { // callers synchronize before use ++timestamp; @@ -942,33 +939,33 @@ ICUService::clearCaches() delete serviceCache; serviceCache = NULL; } -void -ICUService::clearServiceCache() +void +ICUService::clearServiceCache() { // callers synchronize before use delete serviceCache; serviceCache = NULL; } -UBool -ICUService::acceptsListener(const EventListener& l) const +UBool +ICUService::acceptsListener(const EventListener& l) const { return dynamic_cast(&l) != NULL; } -void -ICUService::notifyListener(EventListener& l) const +void +ICUService::notifyListener(EventListener& l) const { ((ServiceListener&)l).serviceChanged(*this); } UnicodeString& -ICUService::getName(UnicodeString& result) const +ICUService::getName(UnicodeString& result) const { return result.append(name); } -int32_t -ICUService::countFactories() const +int32_t +ICUService::countFactories() const { return factories == NULL ? 0 : factories->size(); } diff --git a/deps/icu-small/source/common/serv.h b/deps/icu-small/source/common/serv.h index 70695839a8f3ce..e1f69cd4119e5d 100644 --- a/deps/icu-small/source/common/serv.h +++ b/deps/icu-small/source/common/serv.h @@ -61,16 +61,16 @@ class DNCache; * The descriptor contains an optional prefix, followed by '/' * and the currentID. Factories that handle complex keys, * for example number format factories that generate multiple - * kinds of formatters for the same locale, use the descriptor - * to provide a fully unique identifier for the service object, + * kinds of formatters for the same locale, use the descriptor + * to provide a fully unique identifier for the service object, * while using the currentID (in this case, the locale string), * as the visible IDs that can be localized.

* *

The default implementation of ICUServiceKey has no fallbacks and - * has no custom descriptors.

+ * has no custom descriptors.

*/ class U_COMMON_API ICUServiceKey : public UObject { - private: + private: const UnicodeString _id; protected: @@ -111,7 +111,7 @@ class U_COMMON_API ICUServiceKey : public UObject { * the canonical ID to result. Result is returned as a convenience.

* * @param result the output parameter to which the current id will be appended. - * @return the modified result. + * @return the modified result. */ virtual UnicodeString& currentID(UnicodeString& result) const; @@ -127,7 +127,7 @@ class U_COMMON_API ICUServiceKey : public UObject { * instantiate the service.

* * @param result the output parameter to which the current id will be appended. - * @return the modified result. + * @return the modified result. */ virtual UnicodeString& currentDescriptor(UnicodeString& result) const; @@ -162,10 +162,10 @@ class U_COMMON_API ICUServiceKey : public UObject { /** *

A utility to parse the prefix out of a descriptor string. Only - * the (undelimited) prefix, if any, remains in result. Result is returned as a + * the (undelimited) prefix, if any, remains in result. Result is returned as a * convenience.

* - * @param result an input/output parameter that on entry is a descriptor, and + * @param result an input/output parameter that on entry is a descriptor, and * on exit is the prefix of that descriptor. * @return the modified result. */ @@ -173,10 +173,10 @@ class U_COMMON_API ICUServiceKey : public UObject { /** *

A utility to parse the suffix out of a descriptor string. Only - * the (undelimited) suffix, if any, remains in result. Result is returned as a + * the (undelimited) suffix, if any, remains in result. Result is returned as a * convenience.

* - * @param result an input/output parameter that on entry is a descriptor, and + * @param result an input/output parameter that on entry is a descriptor, and * on exit is the suffix of that descriptor. * @return the modified result. */ @@ -254,7 +254,7 @@ class U_COMMON_API ICUServiceFactory : public UObject { /** *

Return, in result, the display name of the id in the provided locale. - * This is an id, not a descriptor. If the id is + * This is an id, not a descriptor. If the id is * not visible, sets result to bogus. If the * incoming result is bogus, it remains bogus. Result is returned as a * convenience. Results are not defined if id is not one supported by this @@ -290,7 +290,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory { public: /** - *

Construct a SimpleFactory that maps a single ID to a single + *

Construct a SimpleFactory that maps a single ID to a single * service instance. If visible is TRUE, the ID will be visible. * The instance must not be NULL. The SimpleFactory will adopt * the instance, which must not be changed subsequent to this call.

@@ -318,7 +318,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory { virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const; /** - *

This implementation adds a mapping from ID -> this to result if visible is TRUE, + *

This implementation adds a mapping from ID -> this to result if visible is TRUE, * otherwise it removes ID from result.

* * @param result the mapping table to update. @@ -376,22 +376,22 @@ class U_COMMON_API ServiceListener : public EventListener { *

This method is called when the service changes. At the time of the * call this listener is registered with the service. It must * not modify the notifier in the context of this call.

- * + * * @param service the service that changed. */ virtual void serviceChanged(const ICUService& service) const = 0; - + public: /** * UObject RTTI boilerplate. */ static UClassID U_EXPORT2 getStaticClassID(); - + /** * UObject RTTI boilerplate. */ virtual UClassID getDynamicClassID() const; - + }; /* @@ -422,7 +422,7 @@ class U_COMMON_API StringPair : public UMemory { * @param status the error code status. * @return a StringPair if the creation was successful, otherwise NULL. */ - static StringPair* create(const UnicodeString& displayName, + static StringPair* create(const UnicodeString& displayName, const UnicodeString& id, UErrorCode& status); @@ -521,10 +521,10 @@ class U_COMMON_API StringPair : public UMemory { * subclass of ICUService that uses Locale names as IDs and uses * ICUServiceKeys that implement the standard resource bundle fallback * strategy. Most clients will wish to subclass it instead of - * ICUService.

+ * ICUService.

*/ class U_COMMON_API ICUService : public ICUNotifier { - protected: + protected: /** * Name useful for debugging. */ @@ -631,7 +631,7 @@ class U_COMMON_API ICUService : public ICUNotifier { * has no fallback. If no object is found, the result of handleDefault * is returned.

* - *

Subclasses can override this method to further customize the + *

Subclasses can override this method to further customize the * result before returning it. * * @param key the key. @@ -646,7 +646,7 @@ class U_COMMON_API ICUService : public ICUNotifier { * of a previous getKey call, to determine what previously-registered factories would * have returned. For details, see getKey(ICUServiceKey&, UErrorCode&). Subclasses * should not call it directly, but call through one of the other get functions.

- * + * * @param key the key. * @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or NULL. * @param factory the factory making the recursive call. @@ -710,7 +710,7 @@ class U_COMMON_API ICUService : public ICUNotifier { UnicodeString& getDisplayName(const UnicodeString& id, UnicodeString& result, const Locale& locale) const; /** - *

Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that + *

Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that * uses the current default Locale as the locale and NULL for * the matchID.

* @@ -721,7 +721,7 @@ class U_COMMON_API ICUService : public ICUNotifier { UVector& getDisplayNames(UVector& result, UErrorCode& status) const; /** - *

Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that + *

Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that * uses NULL for the matchID.

* * @param result a vector to hold the returned displayName/id StringPairs. @@ -755,8 +755,8 @@ class U_COMMON_API ICUService : public ICUNotifier { * @param status the error code status. * @return the result vector. */ UVector& getDisplayNames(UVector& result, - const Locale& locale, - const UnicodeString* matchID, + const Locale& locale, + const UnicodeString* matchID, UErrorCode& status) const; /** @@ -772,7 +772,7 @@ class U_COMMON_API ICUService : public ICUNotifier { URegistryKey registerInstance(UObject* objToAdopt, const UnicodeString& id, UErrorCode& status); /** - *

Register a service instance with the provided ID. The ID will be + *

Register a service instance with the provided ID. The ID will be * canonicalized. The canonicalized ID will be returned by * getVisibleIDs if visible is TRUE. The service instance will be adopted and * must not be modified subsequent to this call.

@@ -819,7 +819,7 @@ class U_COMMON_API ICUService : public ICUNotifier { * listeners.

* * @param rkey the registry key. - * @param status the error code status. + * @param status the error code status. * @return TRUE if the call successfully unregistered the factory. */ virtual UBool unregister(URegistryKey rkey, UErrorCode& status); @@ -835,7 +835,7 @@ class U_COMMON_API ICUService : public ICUNotifier { /** *

Return TRUE if the service is in its default state.

* - *

The default implementation returns TRUE if there are no + *

The default implementation returns TRUE if there are no * factories registered.

*/ virtual UBool isDefault(void) const; @@ -993,3 +993,4 @@ U_NAMESPACE_END /* ICUSERV_H */ #endif + diff --git a/deps/icu-small/source/common/servlk.cpp b/deps/icu-small/source/common/servlk.cpp index 27b046f1e504f5..538982ca36285c 100644 --- a/deps/icu-small/source/common/servlk.cpp +++ b/deps/icu-small/source/common/servlk.cpp @@ -184,3 +184,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/servlkf.cpp b/deps/icu-small/source/common/servlkf.cpp index 6e46bd2079722a..84f2347cddef0d 100644 --- a/deps/icu-small/source/common/servlkf.cpp +++ b/deps/icu-small/source/common/servlkf.cpp @@ -105,9 +105,9 @@ LocaleKeyFactory::getDisplayName(const UnicodeString& id, const Locale& locale, } UObject* -LocaleKeyFactory::handleCreate(const Locale& /* loc */, - int32_t /* kind */, - const ICUService* /* service */, +LocaleKeyFactory::handleCreate(const Locale& /* loc */, + int32_t /* kind */, + const ICUService* /* service */, UErrorCode& /* status */) const { return NULL; } @@ -148,3 +148,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/servloc.h b/deps/icu-small/source/common/servloc.h index 501989424423ea..ccf6433379ddb3 100644 --- a/deps/icu-small/source/common/servloc.h +++ b/deps/icu-small/source/common/servloc.h @@ -60,11 +60,11 @@ class ServiceListener; * *

Canonicalization adjusts the locale string so that the * section before the first understore is in lower case, and the rest - * is in upper case, with no trailing underscores.

+ * is in upper case, with no trailing underscores.

*/ class U_COMMON_API LocaleKey : public ICUServiceKey { - private: + private: int32_t _kind; UnicodeString _primaryID; UnicodeString _fallbackID; @@ -78,15 +78,15 @@ class U_COMMON_API LocaleKey : public ICUServiceKey { /** * Create a LocaleKey with canonical primary and fallback IDs. */ - static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, + static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, const UnicodeString* canonicalFallbackID, UErrorCode& status); /** * Create a LocaleKey with canonical primary and fallback IDs. */ - static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, - const UnicodeString* canonicalFallbackID, + static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, + const UnicodeString* canonicalFallbackID, int32_t kind, UErrorCode& status); @@ -97,9 +97,9 @@ class U_COMMON_API LocaleKey : public ICUServiceKey { * fallbackID is the current default locale's string in * canonical form. */ - LocaleKey(const UnicodeString& primaryID, - const UnicodeString& canonicalPrimaryID, - const UnicodeString* canonicalFallbackID, + LocaleKey(const UnicodeString& primaryID, + const UnicodeString& canonicalPrimaryID, + const UnicodeString* canonicalFallbackID, int32_t kind); public: @@ -145,16 +145,16 @@ class U_COMMON_API LocaleKey : public ICUServiceKey { *

First falls back through the primary ID, then through * the fallbackID. The final fallback is the empty string, * unless the primary id was the empty string, in which case - * there is no fallback. + * there is no fallback. */ virtual UBool fallback(); /** * Return true if a key created from id matches, or would eventually - * fallback to match, the canonical ID of this key. + * fallback to match, the canonical ID of this key. */ virtual UBool isFallbackOf(const UnicodeString& id) const; - + public: /** * UObject boilerplate. @@ -183,7 +183,7 @@ class U_COMMON_API LocaleKey : public ICUServiceKey { /** * A subclass of ICUServiceFactory that uses LocaleKeys, and is able to * 'cover' more specific locales with more general locales that it - * supports. + * supports. * *

Coverage may be either of the values VISIBLE or INVISIBLE. * @@ -203,7 +203,7 @@ class U_COMMON_API LocaleKeyFactory : public ICUServiceFactory { enum { /** * Coverage value indicating that the factory makes - * its locales visible, and does not cover more specific + * its locales visible, and does not cover more specific * locales. */ VISIBLE = 0, @@ -263,13 +263,13 @@ class U_COMMON_API LocaleKeyFactory : public ICUServiceFactory { virtual UObject* handleCreate(const Locale& loc, int32_t kind, const ICUService* service, UErrorCode& status) const; /** - * Return true if this id is one the factory supports (visible or + * Return true if this id is one the factory supports (visible or * otherwise). */ // virtual UBool isSupportedID(const UnicodeString& id, UErrorCode& status) const; /** - * Return the set of ids that this factory supports (visible or + * Return the set of ids that this factory supports (visible or * otherwise). This can be called often and might need to be * cached if it is expensive to create. */ @@ -306,14 +306,14 @@ class U_COMMON_API SimpleLocaleKeyFactory : public LocaleKeyFactory { const int32_t _kind; public: - SimpleLocaleKeyFactory(UObject* objToAdopt, - const UnicodeString& locale, - int32_t kind, + SimpleLocaleKeyFactory(UObject* objToAdopt, + const UnicodeString& locale, + int32_t kind, int32_t coverage); - SimpleLocaleKeyFactory(UObject* objToAdopt, - const Locale& locale, - int32_t kind, + SimpleLocaleKeyFactory(UObject* objToAdopt, + const Locale& locale, + int32_t kind, int32_t coverage); /** @@ -366,7 +366,7 @@ class U_COMMON_API SimpleLocaleKeyFactory : public LocaleKeyFactory { * IDs. Subclasses then override handleCreate to create the actual service * object. The default implementation returns a resource bundle. */ -class U_COMMON_API ICUResourceBundleFactory : public LocaleKeyFactory +class U_COMMON_API ICUResourceBundleFactory : public LocaleKeyFactory { protected: UnicodeString _bundleName; @@ -422,7 +422,7 @@ class U_COMMON_API ICUResourceBundleFactory : public LocaleKeyFactory ****************************************************************** */ -class U_COMMON_API ICULocaleService : public ICUService +class U_COMMON_API ICULocaleService : public ICUService { private: Locale fallbackLocale; @@ -447,7 +447,7 @@ class U_COMMON_API ICULocaleService : public ICUService #if 0 // redeclare because of overload resolution rules? // no, causes ambiguities since both UnicodeString and Locale have constructors that take a const char* - // need some compiler flag to remove warnings + // need some compiler flag to remove warnings UObject* get(const UnicodeString& descriptor, UErrorCode& status) const { return ICUService::get(descriptor, status); } @@ -475,12 +475,12 @@ class U_COMMON_API ICULocaleService : public ICUService * get(Locale, String, Locale[]) with a null kind. */ UObject* get(const Locale& locale, Locale* actualReturn, UErrorCode& status) const; - + /** * Convenience override for callers using locales. This uses * createKey(Locale.toString(), kind) to create a key, calls getKey, and then * if actualReturn is not null, returns the actualResult from - * getKey (stripping any prefix) into a Locale. + * getKey (stripping any prefix) into a Locale. */ UObject* get(const Locale& locale, int32_t kind, Locale* actualReturn, UErrorCode& status) const; @@ -548,3 +548,4 @@ U_NAMESPACE_END /* ICULSERV_H */ #endif + diff --git a/deps/icu-small/source/common/servls.cpp b/deps/icu-small/source/common/servls.cpp index 0b1b1b947d514e..81dc4f750ea93e 100644 --- a/deps/icu-small/source/common/servls.cpp +++ b/deps/icu-small/source/common/servls.cpp @@ -92,12 +92,12 @@ ICULocaleService::get(const Locale& locale, int32_t kind, Locale* actualReturn, URegistryKey -ICULocaleService::registerInstance(UObject* objToAdopt, const UnicodeString& locale, +ICULocaleService::registerInstance(UObject* objToAdopt, const UnicodeString& locale, UBool visible, UErrorCode& status) { Locale loc; LocaleUtility::initLocaleFromName(locale, loc); - return registerInstance(objToAdopt, loc, LocaleKey::KIND_ANY, + return registerInstance(objToAdopt, loc, LocaleKey::KIND_ANY, visible ? LocaleKeyFactory::VISIBLE : LocaleKeyFactory::INVISIBLE, status); } @@ -263,7 +263,7 @@ ICULocaleService::validateFallbackLocale() const { const Locale& loc = Locale::getDefault(); ICULocaleService* ncThis = (ICULocaleService*)this; - static UMutex llock = U_MUTEX_INITIALIZER; + static UMutex llock; { Mutex mutex(&llock); if (loc != fallbackLocale) { @@ -291,3 +291,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/servnotf.cpp b/deps/icu-small/source/common/servnotf.cpp index 9b5997bd17f509..f577795cae9d47 100644 --- a/deps/icu-small/source/common/servnotf.cpp +++ b/deps/icu-small/source/common/servnotf.cpp @@ -21,27 +21,24 @@ U_NAMESPACE_BEGIN EventListener::~EventListener() {} UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EventListener) -static UMutex *notifyLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex notifyLock; -ICUNotifier::ICUNotifier(void) -: listeners(NULL) +ICUNotifier::ICUNotifier(void) +: listeners(NULL) { } ICUNotifier::~ICUNotifier(void) { { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); delete listeners; listeners = NULL; } } -void -ICUNotifier::addListener(const EventListener* l, UErrorCode& status) +void +ICUNotifier::addListener(const EventListener* l, UErrorCode& status) { if (U_SUCCESS(status)) { if (l == NULL) { @@ -50,7 +47,7 @@ ICUNotifier::addListener(const EventListener* l, UErrorCode& status) } if (acceptsListener(*l)) { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners == NULL) { listeners = new UVector(5, status); } else { @@ -73,8 +70,8 @@ ICUNotifier::addListener(const EventListener* l, UErrorCode& status) } } -void -ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) +void +ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) { if (U_SUCCESS(status)) { if (l == NULL) { @@ -83,7 +80,7 @@ ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) } { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners != NULL) { // identity equality check for (int i = 0, e = listeners->size(); i < e; ++i) { @@ -102,11 +99,11 @@ ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) } } -void -ICUNotifier::notifyChanged(void) +void +ICUNotifier::notifyChanged(void) { if (listeners != NULL) { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners != NULL) { for (int i = 0, e = listeners->size(); i < e; ++i) { EventListener* el = (EventListener*)listeners->elementAt(i); @@ -120,3 +117,4 @@ U_NAMESPACE_END /* UCONFIG_NO_SERVICE */ #endif + diff --git a/deps/icu-small/source/common/servnotf.h b/deps/icu-small/source/common/servnotf.h index cf92fc169e927f..dba7a0fea3b2bc 100644 --- a/deps/icu-small/source/common/servnotf.h +++ b/deps/icu-small/source/common/servnotf.h @@ -34,7 +34,7 @@ U_NAMESPACE_END U_NAMESPACE_BEGIN class U_COMMON_API EventListener : public UObject { -public: +public: virtual ~EventListener(); public: @@ -62,54 +62,54 @@ class U_COMMON_API EventListener : public UObject { * eventually dequeues the list and calls notifyListener on each * listener in the list.

* - *

Subclasses override acceptsListener and notifyListener + *

Subclasses override acceptsListener and notifyListener * to add type-safe notification. AcceptsListener should return * true if the listener is of the appropriate type; ICUNotifier * itself will ensure the listener is non-null and that the * identical listener is not already registered with the Notifier. - * NotifyListener should cast the listener to the appropriate + * NotifyListener should cast the listener to the appropriate * type and call the appropriate method on the listener. */ class U_COMMON_API ICUNotifier : public UMemory { private: UVector* listeners; - -public: + +public: ICUNotifier(void); - + virtual ~ICUNotifier(void); - + /** * Add a listener to be notified when notifyChanged is called. * The listener must not be null. AcceptsListener must return * true for the listener. Attempts to concurrently * register the identical listener more than once will be - * silently ignored. + * silently ignored. */ virtual void addListener(const EventListener* l, UErrorCode& status); - + /** * Stop notifying this listener. The listener must * not be null. Attemps to remove a listener that is * not registered will be silently ignored. */ virtual void removeListener(const EventListener* l, UErrorCode& status); - + /** * ICU doesn't spawn its own threads. All listeners are notified in * the thread of the caller. Misbehaved listeners can therefore * indefinitely block the calling thread. Callers should beware of - * deadlock situations. + * deadlock situations. */ virtual void notifyChanged(void); - -protected: + +protected: /** * Subclasses implement this to return TRUE if the listener is * of the appropriate type. */ virtual UBool acceptsListener(const EventListener& l) const = 0; - + /** * Subclasses implement this to notify the listener. */ diff --git a/deps/icu-small/source/common/servrbf.cpp b/deps/icu-small/source/common/servrbf.cpp index 3f143afadf62bb..94279ab3a1513b 100644 --- a/deps/icu-small/source/common/servrbf.cpp +++ b/deps/icu-small/source/common/servrbf.cpp @@ -92,3 +92,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/servslkf.cpp b/deps/icu-small/source/common/servslkf.cpp index 4aa10414a038d3..09154d1b9198e7 100644 --- a/deps/icu-small/source/common/servslkf.cpp +++ b/deps/icu-small/source/common/servslkf.cpp @@ -119,3 +119,5 @@ U_NAMESPACE_END /* !UCONFIG_NO_SERVICE */ #endif + + diff --git a/deps/icu-small/source/common/sharedobject.h b/deps/icu-small/source/common/sharedobject.h index 878594c7ffa772..c0a5aba4782821 100644 --- a/deps/icu-small/source/common/sharedobject.h +++ b/deps/icu-small/source/common/sharedobject.h @@ -78,7 +78,7 @@ class U_COMMON_API SharedObject : public UObject { * Decrements the number of hard references to this object, and * arrange for possible cache-eviction and/or deletion if ref * count goes to zero. Thread-safe. - * + * * Not for use from within the UnifiedCache implementation. */ void removeRef() const; @@ -108,12 +108,12 @@ class U_COMMON_API SharedObject : public UObject { */ void deleteIfZeroRefCount() const; - + /** * Returns a writable version of ptr. * If there is exactly one owner, then ptr itself is returned as a * non-const pointer. - * If there are multiple owners, then ptr is replaced with a + * If there are multiple owners, then ptr is replaced with a * copy-constructed clone, * and that is returned. * Returns NULL if cloning failed. @@ -136,7 +136,7 @@ class U_COMMON_API SharedObject : public UObject { * Makes dest an owner of the object pointed to by src while adjusting * reference counts and deleting the previous object dest pointed to * if necessary. Before this call is made, dest must either be NULL or - * be included in the reference count of the object it points to. + * be included in the reference count of the object it points to. * * T must be a subclass of SharedObject. */ @@ -174,7 +174,7 @@ class U_COMMON_API SharedObject : public UObject { * Reference count, excluding references from within the UnifiedCache implementation. */ mutable u_atomic_int32_t hardRefCount; - + mutable const UnifiedCacheBase *cachePtr; }; diff --git a/deps/icu-small/source/common/sprpimpl.h b/deps/icu-small/source/common/sprpimpl.h index 26de904b1fde5a..ca0bcdb51695cc 100644 --- a/deps/icu-small/source/common/sprpimpl.h +++ b/deps/icu-small/source/common/sprpimpl.h @@ -36,20 +36,20 @@ enum UStringPrepType{ USPREP_UNASSIGNED = 0x0000 , USPREP_MAP = 0x0001 , - USPREP_PROHIBITED = 0x0002 , + USPREP_PROHIBITED = 0x0002 , USPREP_DELETE = 0x0003 , - USPREP_TYPE_LIMIT = 0x0004 + USPREP_TYPE_LIMIT = 0x0004 }; typedef enum UStringPrepType UStringPrepType; #ifdef USPREP_TYPE_NAMES_ARRAY static const char* usprepTypeNames[] ={ - "UNASSIGNED" , - "MAP" , - "PROHIBITED" , + "UNASSIGNED" , + "MAP" , + "PROHIBITED" , "DELETE", - "TYPE_LIMIT" + "TYPE_LIMIT" }; #endif @@ -60,7 +60,7 @@ enum{ enum{ _SPREP_TYPE_THRESHOLD = 0xFFF0, - _SPREP_MAX_INDEX_VALUE = 0x3FBF, /*16139*/ + _SPREP_MAX_INDEX_VALUE = 0x3FBF, /*16139*/ _SPREP_MAX_INDEX_TOP_LENGTH = 0x0003 }; @@ -68,7 +68,7 @@ enum{ enum { _SPREP_INDEX_TRIE_SIZE = 0, /* number of bytes in StringPrep trie */ _SPREP_INDEX_MAPPING_DATA_SIZE = 1, /* The array that contains the mapping */ - _SPREP_NORM_CORRECTNS_LAST_UNI_VERSION = 2, /* The index of Unicode version of last entry in NormalizationCorrections.txt */ + _SPREP_NORM_CORRECTNS_LAST_UNI_VERSION = 2, /* The index of Unicode version of last entry in NormalizationCorrections.txt */ _SPREP_ONE_UCHAR_MAPPING_INDEX_START = 3, /* The starting index of 1 UChar mapping index in the mapping data array */ _SPREP_TWO_UCHARS_MAPPING_INDEX_START = 4, /* The starting index of 2 UChars mapping index in the mapping data array */ _SPREP_THREE_UCHARS_MAPPING_INDEX_START = 5, /* The starting index of 3 UChars mapping index in the mapping data array */ @@ -101,7 +101,7 @@ struct UStringPrepProfile{ * @internal */ U_CAPI void U_EXPORT2 -uprv_syntaxError(const UChar* rules, +uprv_syntaxError(const UChar* rules, int32_t pos, int32_t rulesLen, UParseError* parseError); diff --git a/deps/icu-small/source/common/static_unicode_sets.h b/deps/icu-small/source/common/static_unicode_sets.h index 9d8a5fcddc9953..5d90ce5908de98 100644 --- a/deps/icu-small/source/common/static_unicode_sets.h +++ b/deps/icu-small/source/common/static_unicode_sets.h @@ -83,9 +83,9 @@ enum Key { * * This method is always safe and OK to chain: in the case of a memory or other * error, it returns an empty set from static memory. - * + * * Example: - * + * * UBool hasIgnorables = unisets::get(unisets::DEFAULT_IGNORABLES)->contains(...); * * @param key The desired UnicodeSet according to the enum in this file. diff --git a/deps/icu-small/source/common/uarrsort.cpp b/deps/icu-small/source/common/uarrsort.cpp index 03c4d4e7fc44aa..60905821649db9 100644 --- a/deps/icu-small/source/common/uarrsort.cpp +++ b/deps/icu-small/source/common/uarrsort.cpp @@ -34,6 +34,10 @@ enum { STACK_ITEM_SIZE=200 }; +static constexpr int32_t sizeInMaxAlignTs(int32_t sizeInBytes) { + return (sizeInBytes + sizeof(max_align_t) - 1) / sizeof(max_align_t); +} + /* UComparator convenience implementations ---------------------------------- */ U_CAPI int32_t U_EXPORT2 @@ -134,25 +138,15 @@ doInsertionSort(char *array, int32_t length, int32_t itemSize, static void insertionSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { - UAlignedMemory v[STACK_ITEM_SIZE/sizeof(UAlignedMemory)+1]; - void *pv; - /* allocate an intermediate item variable (v) */ - if(itemSize<=STACK_ITEM_SIZE) { - pv=v; - } else { - pv=uprv_malloc(itemSize); - if(pv==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; - return; - } + icu::MaybeStackArray v; + if (sizeInMaxAlignTs(itemSize) > v.getCapacity() && + v.resize(sizeInMaxAlignTs(itemSize)) == nullptr) { + *pErrorCode = U_MEMORY_ALLOCATION_ERROR; + return; } - doInsertionSort(array, length, itemSize, cmp, context, pv); - - if(pv!=v) { - uprv_free(pv); - } + doInsertionSort(array, length, itemSize, cmp, context, v.getAlias()); } /* QuickSort ---------------------------------------------------------------- */ @@ -238,26 +232,16 @@ subQuickSort(char *array, int32_t start, int32_t limit, int32_t itemSize, static void quickSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { - UAlignedMemory xw[(2*STACK_ITEM_SIZE)/sizeof(UAlignedMemory)+1]; - void *p; - /* allocate two intermediate item variables (x and w) */ - if(itemSize<=STACK_ITEM_SIZE) { - p=xw; - } else { - p=uprv_malloc(2*itemSize); - if(p==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; - return; - } + icu::MaybeStackArray xw; + if(sizeInMaxAlignTs(itemSize)*2 > xw.getCapacity() && + xw.resize(sizeInMaxAlignTs(itemSize) * 2) == nullptr) { + *pErrorCode=U_MEMORY_ALLOCATION_ERROR; + return; } - subQuickSort(array, 0, length, itemSize, - cmp, context, p, (char *)p+itemSize); - - if(p!=xw) { - uprv_free(p); - } + subQuickSort(array, 0, length, itemSize, cmp, context, + xw.getAlias(), xw.getAlias() + sizeInMaxAlignTs(itemSize)); } /* uprv_sortArray() API ----------------------------------------------------- */ diff --git a/deps/icu-small/source/common/ubidiimp.h b/deps/icu-small/source/common/ubidiimp.h index a5d0727495d767..9746b2bc103102 100644 --- a/deps/icu-small/source/common/ubidiimp.h +++ b/deps/icu-small/source/common/ubidiimp.h @@ -198,8 +198,8 @@ typedef struct Run { /* in a Run, logicalStart will get this bit set if the run level is odd */ #define INDEX_ODD_BIT (1UL<<31) -#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)(level)<<31)) -#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)(level)<<31)) +#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)((level)&1)<<31)) +#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)((level)&1)<<31)) #define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT) #define GET_INDEX(x) ((x)&~INDEX_ODD_BIT) @@ -387,41 +387,49 @@ typedef union { } BidiMemoryForAllocation; /* Macros for initial checks at function entry */ -#define RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrcode, retvalue) \ - if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return retvalue -#define RETURN_IF_NOT_VALID_PARA(bidi, errcode, retvalue) \ - if(!IS_VALID_PARA(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return retvalue; \ - } -#define RETURN_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode, retvalue) \ - if(!IS_VALID_PARA_OR_LINE(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return retvalue; \ - } -#define RETURN_IF_BAD_RANGE(arg, start, limit, errcode, retvalue) \ - if((arg)<(start) || (arg)>=(limit)) { \ - (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ - return retvalue; \ - } - -#define RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrcode) \ - if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return -#define RETURN_VOID_IF_NOT_VALID_PARA(bidi, errcode) \ - if(!IS_VALID_PARA(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return; \ - } -#define RETURN_VOID_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode) \ - if(!IS_VALID_PARA_OR_LINE(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return; \ - } -#define RETURN_VOID_IF_BAD_RANGE(arg, start, limit, errcode) \ - if((arg)<(start) || (arg)>=(limit)) { \ - (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ - return; \ - } +#define RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return retvalue; \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_NOT_VALID_PARA(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA_OR_LINE(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_BAD_RANGE(arg, start, limit, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if((arg)<(start) || (arg)>=(limit)) { \ + (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END + +#define RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrcode) UPRV_BLOCK_MACRO_BEGIN { \ + if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return; \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_NOT_VALID_PARA(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA_OR_LINE(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_BAD_RANGE(arg, start, limit, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if((arg)<(start) || (arg)>=(limit)) { \ + (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END /* helper function to (re)allocate memory if allowed */ U_CFUNC UBool diff --git a/deps/icu-small/source/common/ubiditransform.cpp b/deps/icu-small/source/common/ubiditransform.cpp index 394df6092d21b1..5b0d5cf96a4e03 100644 --- a/deps/icu-small/source/common/ubiditransform.cpp +++ b/deps/icu-small/source/common/ubiditransform.cpp @@ -31,11 +31,11 @@ #define SHAPE_LOGICAL U_SHAPE_TEXT_DIRECTION_LOGICAL #define SHAPE_VISUAL U_SHAPE_TEXT_DIRECTION_VISUAL_LTR -#define CHECK_LEN(STR, LEN, ERROR) { \ - if (LEN == 0) return 0; \ - if (LEN < -1) { *(ERROR) = U_ILLEGAL_ARGUMENT_ERROR; return 0; } \ - if (LEN == -1) LEN = u_strlen(STR); \ - } +#define CHECK_LEN(STR, LEN, ERROR) UPRV_BLOCK_MACRO_BEGIN { \ + if (LEN == 0) return 0; \ + if (LEN < -1) { *(ERROR) = U_ILLEGAL_ARGUMENT_ERROR; return 0; } \ + if (LEN == -1) LEN = u_strlen(STR); \ +} UPRV_BLOCK_MACRO_END #define MAX_ACTIONS 7 @@ -118,7 +118,7 @@ ubiditransform_close(UBiDiTransform *pBiDiTransform) /** * Performs Bidi resolution of text. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -135,7 +135,7 @@ action_resolve(UBiDiTransform *pTransform, UErrorCode *pErrorCode) /** * Performs basic reordering of text (Logical -> Visual LTR). - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -155,7 +155,7 @@ action_reorder(UBiDiTransform *pTransform, UErrorCode *pErrorCode) /** * Sets "inverse" mode on the UBiDi object. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -174,7 +174,7 @@ action_setInverse(UBiDiTransform *pTransform, UErrorCode *pErrorCode) /** * Sets "runs only" reordering mode indicating a Logical LTR <-> Logical RTL * transformation. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -191,7 +191,7 @@ action_setRunsOnly(UBiDiTransform *pTransform, UErrorCode *pErrorCode) /** * Performs string reverse. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -212,7 +212,7 @@ action_reverse(UBiDiTransform *pTransform, UErrorCode *pErrorCode) * Applies a new value to the text that serves as input at the current * processing step. This value is identical to the original one when we begin * the processing, but usually changes as the transformation progresses. - * + * * @param pTransform A pointer to the UBiDiTransform structure. * @param newSrc A pointer whose value is to be used as input text. * @param newLength A length of the new text in UChars. @@ -243,12 +243,12 @@ updateSrc(UBiDiTransform *pTransform, const UChar *newSrc, uint32_t newLength, } u_strncpy(pTransform->src, newSrc, newLength); pTransform->srcLength = u_terminateUChars(pTransform->src, - pTransform->srcSize, newLength, pErrorCode); + pTransform->srcSize, newLength, pErrorCode); } /** * Calls a lower level shaping function. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param options Shaping options. * @param pErrorCode Pointer to the error code value. @@ -263,7 +263,7 @@ doShape(UBiDiTransform *pTransform, uint32_t options, UErrorCode *pErrorCode) /** * Performs digit and letter shaping. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -293,7 +293,7 @@ action_shapeArabic(UBiDiTransform *pTransform, UErrorCode *pErrorCode) /** * Performs character mirroring. - * + * * @param pTransform Pointer to the UBiDiTransform structure. * @param pErrorCode Pointer to the error code value. * @@ -314,10 +314,10 @@ action_mirror(UBiDiTransform *pTransform, UErrorCode *pErrorCode) } do { UBool isOdd = ubidi_getLevelAt(pTransform->pBidi, i) & 1; - U16_NEXT(pTransform->src, i, pTransform->srcLength, c); + U16_NEXT(pTransform->src, i, pTransform->srcLength, c); U16_APPEND_UNSAFE(pTransform->dest, j, isOdd ? u_charMirror(c) : c); } while (i < pTransform->srcLength); - + *pTransform->pDestLength = pTransform->srcLength; pTransform->reorderingOptions = UBIDI_REORDER_DEFAULT; return TRUE; @@ -416,7 +416,7 @@ resolveBaseDirection(const UChar *text, uint32_t length, /** * Finds a valid ReorderingScheme matching the * caller-defined scheme. - * + * * @return A valid ReorderingScheme object or NULL */ static const ReorderingScheme* diff --git a/deps/icu-small/source/common/ucase.cpp b/deps/icu-small/source/common/ucase.cpp index 50c8d20c1fce73..4ec25a27a503bb 100644 --- a/deps/icu-small/source/common/ucase.cpp +++ b/deps/icu-small/source/common/ucase.cpp @@ -116,7 +116,7 @@ static const uint8_t flagsOffset[256]={ * moved to the last uint16_t of the value, use +1 for beginning of next slot * @param value (out) int32_t or uint32_t output if hasSlot, otherwise not modified */ -#define GET_SLOT_VALUE(excWord, idx, pExc16, value) \ +#define GET_SLOT_VALUE(excWord, idx, pExc16, value) UPRV_BLOCK_MACRO_BEGIN { \ if(((excWord)&UCASE_EXC_DOUBLE_SLOTS)==0) { \ (pExc16)+=SLOT_OFFSET(excWord, idx); \ (value)=*pExc16; \ @@ -124,7 +124,8 @@ static const uint8_t flagsOffset[256]={ (pExc16)+=2*SLOT_OFFSET(excWord, idx); \ (value)=*pExc16++; \ (value)=((value)<<16)|*pExc16; \ - } + } \ +} UPRV_BLOCK_MACRO_END /* simple case mappings ----------------------------------------------------- */ @@ -689,7 +690,7 @@ ucase_isCaseSensitive(UChar32 c) { * - The general category of C is * Nonspacing Mark (Mn), or Enclosing Mark (Me), or Format Control (Cf), or * Letter Modifier (Lm), or Symbol Modifier (Sk) - * - C is one of the following characters + * - C is one of the following characters * U+0027 APOSTROPHE * U+00AD SOFT HYPHEN (SHY) * U+2019 RIGHT SINGLE QUOTATION MARK @@ -1505,7 +1506,7 @@ U_CAPI UChar32 U_EXPORT2 u_tolower(UChar32 c) { return ucase_tolower(c); } - + /* Transforms the Unicode character to its upper case equivalent.*/ U_CAPI UChar32 U_EXPORT2 u_toupper(UChar32 c) { diff --git a/deps/icu-small/source/common/uchar.cpp b/deps/icu-small/source/common/uchar.cpp index 60fe75c78dec03..b54cd626d10fb3 100644 --- a/deps/icu-small/source/common/uchar.cpp +++ b/deps/icu-small/source/common/uchar.cpp @@ -14,7 +14,7 @@ * 04/02/97 aliu Creation. * 4/15/99 Madhu Updated all the function definitions for C Implementation * 5/20/99 Madhu Added the function u_getVersion() -* 8/19/1999 srl Upgraded scripts to Unicode3.0 +* 8/19/1999 srl Upgraded scripts to Unicode3.0 * 11/11/1999 weiv added u_isalnum(), cleaned comments * 01/11/2000 helena Renamed u_getVersion to u_getUnicodeVersion. * 06/20/2000 helena OS/400 port changes; mostly typecast. @@ -40,7 +40,7 @@ /* constants and macros for access to the data ------------------------------ */ /* getting a uint32_t properties word from the data */ -#define GET_PROPS(c, result) ((result)=UTRIE2_GET16(&propsTrie, c)); +#define GET_PROPS(c, result) ((result)=UTRIE2_GET16(&propsTrie, c)) /* API functions ------------------------------------------------------------ */ diff --git a/deps/icu-small/source/common/uchriter.cpp b/deps/icu-small/source/common/uchriter.cpp index 822168f5c8e600..bedbabc74c2351 100644 --- a/deps/icu-small/source/common/uchriter.cpp +++ b/deps/icu-small/source/common/uchriter.cpp @@ -89,7 +89,7 @@ UCharCharacterIterator::hashCode() const { return ustr_hashUCharsN(text, textLength) ^ pos ^ begin ^ end; } -CharacterIterator* +UCharCharacterIterator* UCharCharacterIterator::clone() const { return new UCharCharacterIterator(*this); } diff --git a/deps/icu-small/source/common/ucln_cmn.cpp b/deps/icu-small/source/common/ucln_cmn.cpp index d78491df419fb0..f3e07c6b89183f 100644 --- a/deps/icu-small/source/common/ucln_cmn.cpp +++ b/deps/icu-small/source/common/ucln_cmn.cpp @@ -52,7 +52,7 @@ u_cleanup(void) /*#endif*/ } -U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType libType) +U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType libType) { if (gLibCleanupFunctions[libType]) { @@ -65,9 +65,20 @@ U_CFUNC void ucln_common_registerCleanup(ECleanupCommonType type, cleanupFunc *func) { + // Thread safety messiness: From ticket 10295, calls to registerCleanup() may occur + // concurrently. Although such cases should be storing the same value, they raise errors + // from the thread sanity checker. Doing the store within a mutex avoids those. + // BUT that can trigger a recursive entry into std::call_once() in umutex.cpp when this code, + // running from the call_once function, tries to grab the ICU global mutex, which + // re-enters the mutex init path. So, work-around by special casing UCLN_COMMON_MUTEX, not + // using the ICU global mutex for it. + // + // No other point in ICU uses std::call_once(). + U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT); - if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) - { + if (type == UCLN_COMMON_MUTEX) { + gCommonCleanupFunctions[type] = func; + } else if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) { icu::Mutex m; // See ticket 10295 for discussion. gCommonCleanupFunctions[type] = func; } diff --git a/deps/icu-small/source/common/ucln_cmn.h b/deps/icu-small/source/common/ucln_cmn.h index 0ca911b47d9875..b837fb946296a1 100644 --- a/deps/icu-small/source/common/ucln_cmn.h +++ b/deps/icu-small/source/common/ucln_cmn.h @@ -22,8 +22,6 @@ /* These are the cleanup functions for various APIs. */ /* @return true if cleanup complete successfully.*/ -U_CFUNC UBool umtx_cleanup(void); - U_CFUNC UBool utrace_cleanup(void); U_CFUNC UBool ucln_lib_cleanup(void); @@ -41,6 +39,8 @@ typedef enum ECleanupCommonType { UCLN_COMMON_LOCALE_KEY_TYPE, UCLN_COMMON_LOCALE, UCLN_COMMON_LOCALE_AVAILABLE, + UCLN_COMMON_LIKELY_SUBTAGS, + UCLN_COMMON_LOCALE_DISTANCE, UCLN_COMMON_ULOC, UCLN_COMMON_CURRENCY, UCLN_COMMON_LOADED_NORMALIZER2, @@ -62,6 +62,7 @@ typedef enum ECleanupCommonType { */ UCLN_COMMON_UNIFIED_CACHE, UCLN_COMMON_URES, + UCLN_COMMON_MUTEX, // Mutexes should be the last to be cleaned up. UCLN_COMMON_COUNT /* This must be last */ } ECleanupCommonType; diff --git a/deps/icu-small/source/common/ucln_imp.h b/deps/icu-small/source/common/ucln_imp.h index 2e985669793b82..1bfcde0fb8eae2 100644 --- a/deps/icu-small/source/common/ucln_imp.h +++ b/deps/icu-small/source/common/ucln_imp.h @@ -113,13 +113,13 @@ U_CAPI void U_EXPORT2 UCLN_FINI () /* Windows: DllMain */ #elif U_PLATFORM_HAS_WIN32_API -/* +/* * ICU's own DllMain. */ /* these are from putil.c */ /* READ READ READ READ! Are you getting compilation errors from windows.h? - Any source file which includes this (ucln_imp.h) header MUST + Any source file which includes this (ucln_imp.h) header MUST be defined with language extensions ON. */ #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN @@ -168,7 +168,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) /* GCC - use __attribute((destructor)) */ static void ucln_destructor() __attribute__((destructor)) ; -static void ucln_destructor() +static void ucln_destructor() { UCLN_CLEAN_ME_UP; } diff --git a/deps/icu-small/source/common/ucmndata.h b/deps/icu-small/source/common/ucmndata.h index 16844414327259..c3eba9f4d02102 100644 --- a/deps/icu-small/source/common/ucmndata.h +++ b/deps/icu-small/source/common/ucmndata.h @@ -98,12 +98,12 @@ U_CDECL_END typedef struct { LookupFn Lookup; - NumEntriesFn NumEntries; + NumEntriesFn NumEntries; } commonDataFuncs; /* - * Functions to check whether a UDataMemory refers to memory containing + * Functions to check whether a UDataMemory refers to memory containing * a recognizable header and table of contents a Common Data Format * * If a valid header and TOC are found, diff --git a/deps/icu-small/source/common/ucnv.cpp b/deps/icu-small/source/common/ucnv.cpp index abf302eaddb7a8..856be708785796 100644 --- a/deps/icu-small/source/common/ucnv.cpp +++ b/deps/icu-small/source/common/ucnv.cpp @@ -25,6 +25,8 @@ #if !UCONFIG_NO_CONVERSION +#include + #include "unicode/ustring.h" #include "unicode/ucnv.h" #include "unicode/ucnv_err.h" @@ -81,7 +83,7 @@ ucnv_open (const char *name, return r; } -U_CAPI UConverter* U_EXPORT2 +U_CAPI UConverter* U_EXPORT2 ucnv_openPackage (const char *packageName, const char *converterName, UErrorCode * err) { return ucnv_createConverterFromPackage(packageName, converterName, err); @@ -148,7 +150,7 @@ ucnv_openCCSID (int32_t codepage, return ucnv_createConverter(NULL, myName, err); } -/* Creating a temporary stack-based object that can be used in one thread, +/* Creating a temporary stack-based object that can be used in one thread, and created from a converter that is shared across threads. */ @@ -158,7 +160,6 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U UConverter *localConverter, *allocatedConverter; int32_t stackBufferSize; int32_t bufferSizeNeeded; - char *stackBufferChars = (char *)stackBuffer; UErrorCode cbErr; UConverterToUnicodeArgs toUArgs = { sizeof(UConverterToUnicodeArgs), @@ -224,23 +225,22 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U } } - - /* Pointers on 64-bit platforms need to be aligned - * on a 64-bit boundary in memory. + /* Adjust (if necessary) the stackBuffer pointer to be aligned correctly for a UConverter. + * TODO(Jira ICU-20736) Redo this using std::align() once g++4.9 compatibility is no longer needed. */ - if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { - int32_t offsetUp = (int32_t)U_ALIGNMENT_OFFSET_UP(stackBufferChars); - if(stackBufferSize > offsetUp) { - stackBufferSize -= offsetUp; - stackBufferChars += offsetUp; + if (stackBuffer) { + uintptr_t p = reinterpret_cast(stackBuffer); + uintptr_t aligned_p = (p + alignof(UConverter) - 1) & ~(alignof(UConverter) - 1); + ptrdiff_t pointerAdjustment = aligned_p - p; + if (bufferSizeNeeded + pointerAdjustment <= stackBufferSize) { + stackBuffer = reinterpret_cast(aligned_p); + stackBufferSize -= pointerAdjustment; } else { /* prevent using the stack buffer but keep the size > 0 so that we do not just preflight */ stackBufferSize = 1; } } - stackBuffer = (void *)stackBufferChars; - /* Now, see if we must allocate any memory */ if (stackBufferSize < bufferSizeNeeded || stackBuffer == NULL) { @@ -448,7 +448,7 @@ ucnv_setSubstChars (UConverter * converter, { if (U_FAILURE (*err)) return; - + /*Makes sure that the subChar is within the codepages char length boundaries */ if ((len > converter->sharedData->staticData->maxBytesPerChar) || (len < converter->sharedData->staticData->minBytesPerChar)) @@ -456,7 +456,7 @@ ucnv_setSubstChars (UConverter * converter, *err = U_ILLEGAL_ARGUMENT_ERROR; return; } - + uprv_memcpy (converter->subChars, mySubChar, len); /*copies the subchars */ converter->subCharLen = len; /*sets the new len */ @@ -466,7 +466,7 @@ ucnv_setSubstChars (UConverter * converter, * we set subChar1 to 0. */ converter->subChar1 = 0; - + return; } @@ -475,7 +475,7 @@ ucnv_setSubstString(UConverter *cnv, const UChar *s, int32_t length, UErrorCode *err) { - UAlignedMemory cloneBuffer[U_CNV_SAFECLONE_BUFFERSIZE / sizeof(UAlignedMemory) + 1]; + alignas(UConverter) char cloneBuffer[U_CNV_SAFECLONE_BUFFERSIZE]; char chars[UCNV_ERROR_BUFFER_LENGTH]; UConverter *clone; @@ -657,7 +657,7 @@ ucnv_getMinCharSize (const UConverter * converter) U_CAPI const char* U_EXPORT2 ucnv_getName (const UConverter * converter, UErrorCode * err) - + { if (U_FAILURE (*err)) return NULL; @@ -1226,7 +1226,7 @@ ucnv_fromUnicode(UConverter *cnv, *err=U_ILLEGAL_ARGUMENT_ERROR; return; } - + /* output the target overflow buffer */ if( cnv->charErrorBufferLength>0 && ucnv_outputOverflowFromUnicode(cnv, target, targetLimit, &offsets, err) @@ -1672,7 +1672,7 @@ ucnv_toUnicode(UConverter *cnv, *err=U_ILLEGAL_ARGUMENT_ERROR; return; } - + /* output the target overflow buffer */ if( cnv->UCharErrorBufferLength>0 && ucnv_outputOverflowToUnicode(cnv, target, targetLimit, &offsets, err) @@ -2083,7 +2083,7 @@ ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return; } - + if(pivotStart==NULL) { if(!flush) { /* streaming conversion requires an explicit pivot buffer */ @@ -2332,7 +2332,7 @@ ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv, break; } } - + /* * toUnicode(source -> pivot); * @@ -2609,7 +2609,7 @@ ucnv_getType(const UConverter* converter) } U_CAPI void U_EXPORT2 -ucnv_getStarters(const UConverter* converter, +ucnv_getStarters(const UConverter* converter, UBool starters[256], UErrorCode* err) { @@ -2652,8 +2652,8 @@ static const UAmbiguousConverter *ucnv_getAmbiguous(const UConverter *cnv) } U_CAPI void U_EXPORT2 -ucnv_fixFileSeparator(const UConverter *cnv, - UChar* source, +ucnv_fixFileSeparator(const UConverter *cnv, + UChar* source, int32_t sourceLength) { const UAmbiguousConverter *a; int32_t i; @@ -2751,7 +2751,7 @@ ucnv_detectUnicodeSignature( const char* source, int32_t dummy; /* initial 0xa5 bytes: make sure that if we read fromUChar32 > 0){ return 1; } - return 0; + return 0; } diff --git a/deps/icu-small/source/common/ucnv2022.cpp b/deps/icu-small/source/common/ucnv2022.cpp index 4a35ff85e10fa0..dbc5bb7e07b2d6 100644 --- a/deps/icu-small/source/common/ucnv2022.cpp +++ b/deps/icu-small/source/common/ucnv2022.cpp @@ -1232,7 +1232,7 @@ _2022FromGR94DBCS(uint32_t value) { /* * This method does the reverse of _2022FromGR94DBCS(). Given the 2022 code point, it returns the * 2 byte value that is in the range A1..FE for each byte. Otherwise it returns the 2022 code point - * unchanged. + * unchanged. */ static inline uint32_t _2022ToGR94DBCS(uint32_t value) { @@ -3571,20 +3571,11 @@ _ISO_2022_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorC /* * Structure for cloning an ISO 2022 converter into a single memory block. - * ucnv_safeClone() of the converter will align the entire cloneStruct, - * and then ucnv_safeClone() of the sub-converter may additionally align - * currentConverter inside the cloneStruct, for which we need the deadSpace - * after currentConverter. - * This is because UAlignedMemory may be larger than the actually - * necessary alignment size for the platform. - * The other cloneStruct fields will not be moved around, - * and are aligned properly with cloneStruct's alignment. */ struct cloneStruct { UConverter cnv; UConverter currentConverter; - UAlignedMemory deadSpace; UConverterDataISO2022 mydata; }; @@ -3602,6 +3593,10 @@ _ISO_2022_SafeClone( UConverterDataISO2022 *cnvData; int32_t i, size; + if (U_FAILURE(*status)){ + return nullptr; + } + if (*pBufferSize == 0) { /* 'preflighting' request - set needed size into *pBufferSize */ *pBufferSize = (int32_t)sizeof(struct cloneStruct); return NULL; @@ -3619,7 +3614,7 @@ _ISO_2022_SafeClone( /* share the subconverters */ if(cnvData->currentConverter != NULL) { - size = (int32_t)(sizeof(UConverter) + sizeof(UAlignedMemory)); /* include size of padding */ + size = (int32_t)sizeof(UConverter); localClone->mydata.currentConverter = ucnv_safeClone(cnvData->currentConverter, &localClone->currentConverter, diff --git a/deps/icu-small/source/common/ucnv_bld.cpp b/deps/icu-small/source/common/ucnv_bld.cpp index e6ef833f4e4317..56fc3d6822f74f 100644 --- a/deps/icu-small/source/common/ucnv_bld.cpp +++ b/deps/icu-small/source/common/ucnv_bld.cpp @@ -194,10 +194,7 @@ static struct { /*initializes some global variables */ static UHashtable *SHARED_DATA_HASHTABLE = NULL; -static icu::UMutex *cnvCacheMutex() { /* Mutex for synchronizing cnv cache access. */ - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex cnvCacheMutex; /* Note: the global mutex is used for */ /* reference count updates. */ @@ -227,7 +224,7 @@ static UBool gDefaultConverterContainsOption; static const char DATA_TYPE[] = "cnv"; /* ucnv_flushAvailableConverterCache. This is only called from ucnv_cleanup(). - * If it is ever to be called from elsewhere, synchronization + * If it is ever to be called from elsewhere, synchronization * will need to be considered. */ static void @@ -602,9 +599,9 @@ U_CFUNC void ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData) { if(sharedData != NULL && sharedData->isReferenceCounted) { - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); ucnv_unload(sharedData); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } } @@ -612,9 +609,9 @@ U_CFUNC void ucnv_incrementRefCount(UConverterSharedData *sharedData) { if(sharedData != NULL && sharedData->isReferenceCounted) { - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); sharedData->referenceCounter++; - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } } @@ -815,9 +812,9 @@ ucnv_loadSharedData(const char *converterName, pArgs->nestedLoads=1; pArgs->pkg=NULL; - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); mySharedConverterData = ucnv_load(pArgs, err); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); if (U_FAILURE (*err) || (mySharedConverterData == NULL)) { return NULL; @@ -1064,7 +1061,7 @@ ucnv_flushCache () * because the sequence of looking up in the cache + incrementing * is protected by cnvCacheMutex. */ - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); /* * double loop: A delta/extension-only converter has a pointer to its base table's * shared data; the first iteration of the outer loop may see the delta converter @@ -1093,7 +1090,7 @@ ucnv_flushCache () } } } while(++i == 1 && remaining > 0); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); UTRACE_DATA1(UTRACE_INFO, "ucnv_flushCache() exits with %d converters remaining", remaining); @@ -1199,7 +1196,7 @@ internalSetName(const char *name, UErrorCode *status) { } algorithmicSharedData = getAlgorithmicTypeFromName(stackArgs.name); - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); gDefaultAlgorithmicSharedData = algorithmicSharedData; gDefaultConverterContainsOption = containsOption; @@ -1215,7 +1212,7 @@ internalSetName(const char *name, UErrorCode *status) { ucnv_enableCleanup(); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } #endif @@ -1240,7 +1237,7 @@ ucnv_getDefaultName() { but ucnv_setDefaultName is not thread safe. */ { - icu::Mutex lock(cnvCacheMutex()); + icu::Mutex lock(&cnvCacheMutex); name = gDefaultConverterName; } if(name==NULL) { @@ -1312,7 +1309,7 @@ ucnv_setDefaultName(const char *converterName) { /* The close may make the current name go away. */ ucnv_close(cnv); - + /* reset the converter cache */ u_flushDefaultConverter(); } diff --git a/deps/icu-small/source/common/ucnv_bld.h b/deps/icu-small/source/common/ucnv_bld.h index caa263f56d938b..18b3795e4d8b13 100644 --- a/deps/icu-small/source/common/ucnv_bld.h +++ b/deps/icu-small/source/common/ucnv_bld.h @@ -66,8 +66,8 @@ typedef struct UConverterImpl UConverterImpl; typedef struct UConverterStaticData { /* +offset: size */ uint32_t structSize; /* +0: 4 Size of this structure */ - - char name + + char name [UCNV_MAX_CONVERTER_NAME_LENGTH]; /* +4: 60 internal name of the converter- invariant chars */ int32_t codepage; /* +64: 4 codepage # (now IBM-$codepage) */ @@ -80,7 +80,7 @@ typedef struct UConverterStaticData { /* +offset: size */ uint8_t subChar[UCNV_MAX_SUBCHAR_LEN]; /* +72: 4 [note: 4 and 8 byte boundary] */ int8_t subCharLen; /* +76: 1 */ - + uint8_t hasToUnicodeFallback; /* +77: 1 UBool needs to be changed to UBool to be consistent across platform */ uint8_t hasFromUnicodeFallback; /* +78: 1 */ uint8_t unicodeMask; /* +79: 1 bit 0: has supplementary bit 1: has single surrogates */ diff --git a/deps/icu-small/source/common/ucnv_cnv.h b/deps/icu-small/source/common/ucnv_cnv.h index a996e2959784cf..2eed2c60df60c3 100644 --- a/deps/icu-small/source/common/ucnv_cnv.h +++ b/deps/icu-small/source/common/ucnv_cnv.h @@ -154,7 +154,7 @@ typedef void (*UConverterGetStarters)(const UConverter* converter, UErrorCode *pErrorCode); /* If this function pointer is null or if the function returns null - * the name field in static data struct should be returned by + * the name field in static data struct should be returned by * ucnv_getName() API function */ typedef const char * (*UConverterGetName) (const UConverter *cnv); @@ -177,9 +177,9 @@ typedef void (*UConverterWriteSub) (UConverterFromUnicodeArgs *pArgs, int32_t of * the initial state of the converter. It is not expected to increment the * reference counts of the standard data types such as the shared data. */ -typedef UConverter * (*UConverterSafeClone) (const UConverter *cnv, +typedef UConverter * (*UConverterSafeClone) (const UConverter *cnv, void *stackBuffer, - int32_t *pBufferSize, + int32_t *pBufferSize, UErrorCode *status); /** @@ -258,7 +258,7 @@ struct UConverterImpl { extern const UConverterSharedData _MBCSData, _Latin1Data, _UTF8Data, _UTF16BEData, _UTF16LEData, _UTF32BEData, _UTF32LEData, - _ISO2022Data, + _ISO2022Data, _LMBCSData1,_LMBCSData2, _LMBCSData3, _LMBCSData4, _LMBCSData5, _LMBCSData6, _LMBCSData8,_LMBCSData11,_LMBCSData16,_LMBCSData17,_LMBCSData18,_LMBCSData19, _HZData,_ISCIIData, _SCSUData, _ASCIIData, diff --git a/deps/icu-small/source/common/ucnv_err.cpp b/deps/icu-small/source/common/ucnv_err.cpp index 63794d2334f62b..6b738face5e7fb 100644 --- a/deps/icu-small/source/common/ucnv_err.cpp +++ b/deps/icu-small/source/common/ucnv_err.cpp @@ -129,7 +129,7 @@ UCNV_TO_U_CALLBACK_STOP ( } U_CAPI void U_EXPORT2 -UCNV_FROM_U_CALLBACK_SKIP ( +UCNV_FROM_U_CALLBACK_SKIP ( const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, @@ -217,7 +217,7 @@ UCNV_FROM_U_CALLBACK_ESCAPE ( UConverterFromUCallback ignoredCallback = NULL; const void *ignoredContext; - + if (reason > UCNV_IRREGULAR) { return; @@ -237,14 +237,14 @@ UCNV_FROM_U_CALLBACK_ESCAPE ( &original, &originalContext, &err2); - + if (U_FAILURE (err2)) { *err = err2; return; - } + } if(context==NULL) - { + { while (i < length) { valueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */ @@ -334,7 +334,7 @@ UCNV_FROM_U_CALLBACK_ESCAPE ( valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[i++], 16, 4); } } - } + } myValueSource = valueString; /* reset the error */ @@ -427,7 +427,7 @@ UCNV_TO_U_CALLBACK_ESCAPE ( } if(context==NULL) - { + { while (i < length) { uniValueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */ diff --git a/deps/icu-small/source/common/ucnv_ext.h b/deps/icu-small/source/common/ucnv_ext.h index 7b753ac217d8d5..dceea7ef12617a 100644 --- a/deps/icu-small/source/common/ucnv_ext.h +++ b/deps/icu-small/source/common/ucnv_ext.h @@ -248,7 +248,7 @@ * the result bytes in fromUBytes[]; (0 indexes fromUBytes[0]) * } * } - * + * * The first pair in a section contains the number of following pairs in the * UChar position (16 bits, number=1..0xffff). * The value of the initial pair is used when the current UChar is not found diff --git a/deps/icu-small/source/common/ucnv_io.cpp b/deps/icu-small/source/common/ucnv_io.cpp index d9e91314ed5347..7a95a3f1e61dd7 100644 --- a/deps/icu-small/source/common/ucnv_io.cpp +++ b/deps/icu-small/source/common/ucnv_io.cpp @@ -10,7 +10,7 @@ * * * ucnv_io.cpp: -* initializes global variables and defines functions pertaining to converter +* initializes global variables and defines functions pertaining to converter * name resolution aspect of the conversion code. * * new implementation: diff --git a/deps/icu-small/source/common/ucnv_lmb.cpp b/deps/icu-small/source/common/ucnv_lmb.cpp index 6dd8e83428a0af..168392837b5459 100644 --- a/deps/icu-small/source/common/ucnv_lmb.cpp +++ b/deps/icu-small/source/common/ucnv_lmb.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. @@ -15,9 +15,9 @@ * extensively hacked up by: Jim Snyder-Grant * * Modification History: -* +* * Date Name Description -* +* * 06/20/2000 helena OS/400 port changes; mostly typecast. * 06/27/2000 Jim Snyder-Grant Deal with partial characters and small buffers. * Add comments to document LMBCS format and implementation @@ -48,16 +48,16 @@ (Lotus Multi-Byte Character Set) - LMBCS was invented in the late 1980's and is primarily used in Lotus Notes - databases and in Lotus 1-2-3 files. Programmers who work with the APIs + LMBCS was invented in the late 1980's and is primarily used in Lotus Notes + databases and in Lotus 1-2-3 files. Programmers who work with the APIs into these products will sometimes need to deal with strings in this format. - The code in this file provides an implementation for an ICU converter of - LMBCS to and from Unicode. + The code in this file provides an implementation for an ICU converter of + LMBCS to and from Unicode. - Since the LMBCS character set is only sparsely documented in existing - printed or online material, we have added extensive annotation to this - file to serve as a guide to understanding LMBCS. + Since the LMBCS character set is only sparsely documented in existing + printed or online material, we have added extensive annotation to this + file to serve as a guide to understanding LMBCS. LMBCS was originally designed with these four sometimes-competing design goals: @@ -69,11 +69,11 @@ All of the national character sets LMBCS was trying to encode are 'ANSI' - based, in that the bytes from 0x20 - 0x7F are almost exactly the - same common Latin unaccented characters and symbols in all character sets. + based, in that the bytes from 0x20 - 0x7F are almost exactly the + same common Latin unaccented characters and symbols in all character sets. - So, in order to help meet the speed & memory design goals, the common ANSI - bytes from 0x20-0x7F are represented by the same single-byte values in LMBCS. + So, in order to help meet the speed & memory design goals, the common ANSI + bytes from 0x20-0x7F are represented by the same single-byte values in LMBCS. The general LMBCS code unit is from 1-3 bytes. We can describe the 3 bytes as follows: @@ -86,21 +86,21 @@ #define ULMBCS_CHARSIZE_MAX 3 /* The single-byte values from 0x20 to 0x7F are examples of single D1 bytes. - We often have to figure out if byte values are below or above this, so we - use the ANSI nomenclature 'C0' and 'C1' to refer to the range of control + We often have to figure out if byte values are below or above this, so we + use the ANSI nomenclature 'C0' and 'C1' to refer to the range of control characters just above & below the common lower-ANSI range */ -#define ULMBCS_C0END 0x1F -#define ULMBCS_C1START 0x80 +#define ULMBCS_C0END 0x1F +#define ULMBCS_C1START 0x80 /* - Since LMBCS is always dealing in byte units. we create a local type here for + Since LMBCS is always dealing in byte units. we create a local type here for dealing with these units of LMBCS code units: -*/ +*/ typedef uint8_t ulmbcs_byte_t; -/* - Most of the values less than 0x20 are reserved in LMBCS to announce - which national character standard is being used for the 'D' bytes. +/* + Most of the values less than 0x20 are reserved in LMBCS to announce + which national character standard is being used for the 'D' bytes. In the comments we show the common name and the IBM character-set ID for these character-set announcers: */ @@ -119,105 +119,105 @@ typedef uint8_t ulmbcs_byte_t; #define ULMBCS_GRP_CN 0x13 /* Chinese TC :ibm-1386 */ /* - So, the beginning of understanding LMBCS is that IF the first byte of a LMBCS - character is one of those 12 values, you can interpret the remaining bytes of - that character as coming from one of those character sets. Since the lower - ANSI bytes already are represented in single bytes, using one of the character - set announcers is used to announce a character that starts with a byte of + So, the beginning of understanding LMBCS is that IF the first byte of a LMBCS + character is one of those 12 values, you can interpret the remaining bytes of + that character as coming from one of those character sets. Since the lower + ANSI bytes already are represented in single bytes, using one of the character + set announcers is used to announce a character that starts with a byte of 0x80 or greater. - The character sets are arranged so that the single byte sets all appear - before the multi-byte character sets. When we need to tell whether a + The character sets are arranged so that the single byte sets all appear + before the multi-byte character sets. When we need to tell whether a group byte is for a single byte char set or not we use this define: */ -#define ULMBCS_DOUBLEOPTGROUP_START 0x10 +#define ULMBCS_DOUBLEOPTGROUP_START 0x10 -/* -However, to fully understand LMBCS, you must also understand a series of -exceptions & optimizations made in service of the design goals. +/* +However, to fully understand LMBCS, you must also understand a series of +exceptions & optimizations made in service of the design goals. First, those of you who are character set mavens may have noticed that -the 'double-byte' character sets are actually multi-byte character sets +the 'double-byte' character sets are actually multi-byte character sets that can have 1 or two bytes, even in the upper-ascii range. To force -each group byte to introduce a fixed-width encoding (to make it faster to -count characters), we use a convention of doubling up on the group byte +each group byte to introduce a fixed-width encoding (to make it faster to +count characters), we use a convention of doubling up on the group byte to introduce any single-byte character > 0x80 in an otherwise double-byte -character set. So, for example, the LMBCS sequence x10 x10 xAE is the +character set. So, for example, the LMBCS sequence x10 x10 xAE is the same as '0xAE' in the Japanese code page 943. -Next, you will notice that the list of group bytes has some gaps. +Next, you will notice that the list of group bytes has some gaps. These are used in various ways. -We reserve a few special single byte values for common control +We reserve a few special single byte values for common control characters. These are in the same place as their ANSI eqivalents for speed. */ - + #define ULMBCS_HT 0x09 /* Fixed control char - Horizontal Tab */ #define ULMBCS_LF 0x0A /* Fixed control char - Line Feed */ #define ULMBCS_CR 0x0D /* Fixed control char - Carriage Return */ -/* Then, 1-2-3 reserved a special single-byte character to put at the +/* Then, 1-2-3 reserved a special single-byte character to put at the beginning of internal 'system' range names: */ -#define ULMBCS_123SYSTEMRANGE 0x19 +#define ULMBCS_123SYSTEMRANGE 0x19 -/* Then we needed a place to put all the other ansi control characters -that must be moved to different values because LMBCS reserves those -values for other purposes. To represent the control characters, we start -with a first byte of 0xF & add the control chaarcter value as the +/* Then we needed a place to put all the other ansi control characters +that must be moved to different values because LMBCS reserves those +values for other purposes. To represent the control characters, we start +with a first byte of 0xF & add the control chaarcter value as the second byte */ -#define ULMBCS_GRP_CTRL 0x0F +#define ULMBCS_GRP_CTRL 0x0F -/* For the C0 controls (less than 0x20), we add 0x20 to preserve the -useful doctrine that any byte less than 0x20 in a LMBCS char must be +/* For the C0 controls (less than 0x20), we add 0x20 to preserve the +useful doctrine that any byte less than 0x20 in a LMBCS char must be the first byte of a character:*/ -#define ULMBCS_CTRLOFFSET 0x20 +#define ULMBCS_CTRLOFFSET 0x20 -/* -Where to put the characters that aren't part of any of the 12 national -character sets? The first thing that was done, in the earlier years of +/* +Where to put the characters that aren't part of any of the 12 national +character sets? The first thing that was done, in the earlier years of LMBCS, was to use up the spaces of the form - [G] D1, - + [G] D1, + where 'G' was one of the single-byte character groups, and - D1 was less than 0x80. These sequences are gathered together - into a Lotus-invented doublebyte character set to represent a - lot of stray values. Internally, in this implementation, we track this + D1 was less than 0x80. These sequences are gathered together + into a Lotus-invented doublebyte character set to represent a + lot of stray values. Internally, in this implementation, we track this as group '0', as a place to tuck this exceptions list.*/ -#define ULMBCS_GRP_EXCEPT 0x00 +#define ULMBCS_GRP_EXCEPT 0x00 /* - Finally, as the durability and usefulness of UNICODE became clear, - LOTUS added a new group 0x14 to hold Unicode values not otherwise + Finally, as the durability and usefulness of UNICODE became clear, + LOTUS added a new group 0x14 to hold Unicode values not otherwise represented in LMBCS: */ -#define ULMBCS_GRP_UNICODE 0x14 +#define ULMBCS_GRP_UNICODE 0x14 /* The two bytes appearing after a 0x14 are intrepreted as UFT-16 BE -(Big-Endian) characters. The exception comes when the UTF16 +(Big-Endian) characters. The exception comes when the UTF16 representation would have a zero as the second byte. In that case, -'F6' is used in its place, and the bytes are swapped. (This prevents +'F6' is used in its place, and the bytes are swapped. (This prevents LMBCS from encoding any Unicode values of the form U+F6xx, but that's OK: 0xF6xx is in the middle of the Private Use Area.)*/ -#define ULMBCS_UNICOMPATZERO 0xF6 +#define ULMBCS_UNICOMPATZERO 0xF6 -/* It is also useful in our code to have a constant for the size of +/* It is also useful in our code to have a constant for the size of a LMBCS char that holds a literal Unicode value */ -#define ULMBCS_UNICODE_SIZE 3 +#define ULMBCS_UNICODE_SIZE 3 -/* -To squish the LMBCS representations down even further, and to make -translations even faster,sometimes the optimization group byte can be dropped -from a LMBCS character. This is decided on a process-by-process basis. The +/* +To squish the LMBCS representations down even further, and to make +translations even faster,sometimes the optimization group byte can be dropped +from a LMBCS character. This is decided on a process-by-process basis. The group byte that is dropped is called the 'optimization group'. For Notes, the optimzation group is always 0x1.*/ -#define ULMBCS_DEFAULTOPTGROUP 0x1 -/* For 1-2-3 files, the optimzation group is stored in the header of the 1-2-3 -file. +#define ULMBCS_DEFAULTOPTGROUP 0x1 +/* For 1-2-3 files, the optimzation group is stored in the header of the 1-2-3 +file. - In any case, when using ICU, you either pass in the -optimization group as part of the name of the converter (LMBCS-1, LMBCS-2, -etc.). Using plain 'LMBCS' as the name of the converter will give you + In any case, when using ICU, you either pass in the +optimization group as part of the name of the converter (LMBCS-1, LMBCS-2, +etc.). Using plain 'LMBCS' as the name of the converter will give you LMBCS-1. @@ -228,7 +228,7 @@ Because of the extensive use of other character sets, the LMBCS converter keeps a mapping between optimization groups and IBM character sets, so that ICU converters can be created and used as needed. */ -/* As you can see, even though any byte below 0x20 could be an optimization +/* As you can see, even though any byte below 0x20 could be an optimization byte, only those at 0x13 or below can map to an actual converter. To limit some loops and searches, we define a value for that last group converter:*/ @@ -257,12 +257,12 @@ static const char * const OptGroupByteToCPName[ULMBCS_GRP_LAST + 1] = { /* 0x0013 */ "windows-936" /* The rest are null, including the 0x0014 Unicode compatibility region - and 0x0019, the 1-2-3 system range control char */ + and 0x0019, the 1-2-3 system range control char */ }; -/* That's approximately all the data that's needed for translating - LMBCS to Unicode. +/* That's approximately all the data that's needed for translating + LMBCS to Unicode. However, to translate Unicode to LMBCS, we need some more support. @@ -270,18 +270,18 @@ However, to translate Unicode to LMBCS, we need some more support. That's because there are often more than one possible mappings from a Unicode code point back into LMBCS. The first thing we do is look up into a table to figure out if there are more than one possible mappings. This table, -arranged by Unicode values (including ranges) either lists which group +arranged by Unicode values (including ranges) either lists which group to use, or says that it could go into one or more of the SBCS sets, or -into one or more of the DBCS sets. (If the character exists in both DBCS & -SBCS, the table will place it in the SBCS sets, to make the LMBCS code point +into one or more of the DBCS sets. (If the character exists in both DBCS & +SBCS, the table will place it in the SBCS sets, to make the LMBCS code point length as small as possible. Here's the two special markers we use to indicate ambiguous mappings: */ -#define ULMBCS_AMBIGUOUS_SBCS 0x80 /* could fit in more than one - LMBCS sbcs native encoding +#define ULMBCS_AMBIGUOUS_SBCS 0x80 /* could fit in more than one + LMBCS sbcs native encoding (example: most accented latin) */ -#define ULMBCS_AMBIGUOUS_MBCS 0x81 /* could fit in more than one - LMBCS mbcs native encoding +#define ULMBCS_AMBIGUOUS_MBCS 0x81 /* could fit in more than one + LMBCS mbcs native encoding (example: Unihan) */ #define ULMBCS_AMBIGUOUS_ALL 0x82 /* And here's a simple way to see if a group falls in an appropriate range */ @@ -296,7 +296,7 @@ ambiguous mappings: */ /* The table & some code to use it: */ -static const struct _UniLMBCSGrpMap +static const struct _UniLMBCSGrpMap { const UChar uniStartRange; const UChar uniEndRange; @@ -443,29 +443,29 @@ static const struct _UniLMBCSGrpMap {0xFF01, 0xFFEE, ULMBCS_AMBIGUOUS_MBCS}, {0xFFFF, 0xFFFF, ULMBCS_GRP_UNICODE} }; - -static ulmbcs_byte_t + +static ulmbcs_byte_t FindLMBCSUniRange(UChar uniChar) { const struct _UniLMBCSGrpMap * pTable = UniLMBCSGrpMap; - while (uniChar > pTable->uniEndRange) + while (uniChar > pTable->uniEndRange) { pTable++; } - if (uniChar >= pTable->uniStartRange) + if (uniChar >= pTable->uniStartRange) { return pTable->GrpType; } return ULMBCS_GRP_UNICODE; } -/* -We also ask the creator of a converter to send in a preferred locale +/* +We also ask the creator of a converter to send in a preferred locale that we can use in resolving ambiguous mappings. They send the locale -in as a string, and we map it, if possible, to one of the -LMBCS groups. We use this table, and the associated code, to +in as a string, and we map it, if possible, to one of the +LMBCS groups. We use this table, and the associated code, to do the lookup: */ /************************************************** @@ -534,12 +534,12 @@ static const struct _LocaleLMBCSGrpMap }; -static ulmbcs_byte_t +static ulmbcs_byte_t FindLMBCSLocale(const char *LocaleID) { const struct _LocaleLMBCSGrpMap *pTable = LocaleLMBCSGrpMap; - if ((!LocaleID) || (!*LocaleID)) + if ((!LocaleID) || (!*LocaleID)) { return 0; } @@ -561,16 +561,16 @@ FindLMBCSLocale(const char *LocaleID) } -/* - Before we get to the main body of code, here's how we hook up to the rest - of ICU. ICU converters are required to define a structure that includes +/* + Before we get to the main body of code, here's how we hook up to the rest + of ICU. ICU converters are required to define a structure that includes some function pointers, and some common data, in the style of a C++ vtable. There is also room in there for converter-specific data. LMBCS uses that converter-specific data to keep track of the 12 subconverters - we use, the optimization group, and the group (if any) that matches the + we use, the optimization group, and the group (if any) that matches the locale. We have one structure instantiated for each of the 12 possible - optimization groups. To avoid typos & to avoid boring the reader, we - put the declarations of these structures and functions into macros. To see + optimization groups. To avoid typos & to avoid boring the reader, we + put the declarations of these structures and functions into macros. To see the definitions of these structures, see unicode\ucnv_bld.h */ @@ -617,7 +617,7 @@ const UConverterSharedData _LMBCSData##n= \ /* The only function we needed to duplicate 12 times was the 'open' function, which will do basically the same thing except set a different -optimization group. So, we put the common stuff into a worker function, +optimization group. So, we put the common stuff into a worker function, and set up another macro to stamp out the 12 open functions:*/ #define DEFINE_LMBCS_OPEN(n) \ static void U_CALLCONV \ @@ -627,7 +627,7 @@ static void U_CALLCONV \ /* Here's the open worker & the common close function */ -static void +static void _LMBCSOpenWorker(UConverter* _this, UConverterLoadArgs *pArgs, UErrorCode* err, @@ -645,7 +645,7 @@ _LMBCSOpenWorker(UConverter* _this, stackArgs.onlyTestIsLoadable = pArgs->onlyTestIsLoadable; - for (i=0; i <= ULMBCS_GRP_LAST && U_SUCCESS(*err); i++) + for (i=0; i <= ULMBCS_GRP_LAST && U_SUCCESS(*err); i++) { if(OptGroupByteToCPName[i] != NULL) { extraInfo->OptGrpConverter[i] = ucnv_loadSharedData(OptGroupByteToCPName[i], &stackPieces, &stackArgs, err); @@ -667,7 +667,7 @@ _LMBCSOpenWorker(UConverter* _this, U_CDECL_BEGIN static void U_CALLCONV -_LMBCSClose(UConverter * _this) +_LMBCSClose(UConverter * _this) { if (_this->extraInfo != NULL) { @@ -692,9 +692,9 @@ typedef struct LMBCSClone { } LMBCSClone; static UConverter * U_CALLCONV -_LMBCSSafeClone(const UConverter *cnv, - void *stackBuffer, - int32_t *pBufferSize, +_LMBCSSafeClone(const UConverter *cnv, + void *stackBuffer, + int32_t *pBufferSize, UErrorCode *status) { (void)status; LMBCSClone *newLMBCS; @@ -736,10 +736,10 @@ _LMBCSSafeClone(const UConverter *cnv, * This may need to be looked at again as Lotus uses _LMBCSGetUnicodeSet(). (091216) */ -/* +/* Here's the basic helper function that we use when converting from - Unicode to LMBCS, and we suspect that a Unicode character will fit into - one of the 12 groups. The return value is the number of bytes written + Unicode to LMBCS, and we suspect that a Unicode character will fit into + one of the 12 groups. The return value is the number of bytes written starting at pStartLMBCS (if any). */ @@ -751,7 +751,7 @@ LMBCSConversionWorker ( UChar * pUniChar, /* The input unicode character */ ulmbcs_byte_t * lastConverterIndex, /* output: track last successful group used */ UBool * groups_tried /* output: track any unsuccessful groups */ -) +) { ulmbcs_byte_t * pLMBCS = pStartLMBCS; UConverterSharedData * xcnv = extraInfo->OptGrpConverter[group]; @@ -780,7 +780,7 @@ LMBCSConversionWorker ( except with the exception group. */ U_ASSERT((firstByte <= ULMBCS_C0END) || (firstByte >= ULMBCS_C1START) || (group == ULMBCS_GRP_EXCEPT)); - + /* use converted data: first write 0, 1 or two group bytes */ if (group != ULMBCS_GRP_EXCEPT && extraInfo->OptGroup != group) { @@ -820,11 +820,11 @@ LMBCSConversionWorker ( } -/* This is a much simpler version of above, when we +/* This is a much simpler version of above, when we know we are writing LMBCS using the Unicode group */ -static size_t -LMBCSConvertUni(ulmbcs_byte_t * pLMBCS, UChar uniChar) +static size_t +LMBCSConvertUni(ulmbcs_byte_t * pLMBCS, UChar uniChar) { /* encode into LMBCS Unicode range */ uint8_t LowCh = (uint8_t)(uniChar & 0x00FF); @@ -859,21 +859,21 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, int32_t bytes_written; UBool groups_tried[ULMBCS_GRP_LAST+1]; UConverterDataLMBCS * extraInfo = (UConverterDataLMBCS *) args->converter->extraInfo; - int sourceIndex = 0; + int sourceIndex = 0; /* Basic strategy: attempt to fill in local LMBCS 1-char buffer.(LMBCS) - If that succeeds, see if it will all fit into the target & copy it over + If that succeeds, see if it will all fit into the target & copy it over if it does. We try conversions in the following order: 1. Single-byte ascii & special fixed control chars (&null) - 2. Look up group in table & try that (could be + 2. Look up group in table & try that (could be A) Unicode group B) control group, - C) national encoding, + C) national encoding, or ambiguous SBCS or MBCS group (on to step 4...) - + 3. If its ambiguous, try this order: A) The optimization group B) The locale group @@ -912,8 +912,8 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, extraInfo->localeConverterIndex = ULMBCS_GRP_L1; } if (((uniChar > ULMBCS_C0END) && (uniChar < ULMBCS_C1START)) || - uniChar == 0 || uniChar == ULMBCS_HT || uniChar == ULMBCS_CR || - uniChar == ULMBCS_LF || uniChar == ULMBCS_123SYSTEMRANGE + uniChar == 0 || uniChar == ULMBCS_HT || uniChar == ULMBCS_CR || + uniChar == ULMBCS_LF || uniChar == ULMBCS_123SYSTEMRANGE ) { *pLMBCS++ = (ulmbcs_byte_t ) uniChar; @@ -921,15 +921,15 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, } - if (!bytes_written) + if (!bytes_written) { /* Check by UNICODE range (Strategy 2) */ ulmbcs_byte_t group = FindLMBCSUniRange(uniChar); - + if (group == ULMBCS_GRP_UNICODE) /* (Strategy 2A) */ { pLMBCS += LMBCSConvertUni(pLMBCS,uniChar); - + bytes_written = (int32_t)(pLMBCS - LMBCS); } else if (group == ULMBCS_GRP_CTRL) /* (Strategy 2B) */ @@ -951,7 +951,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, { /* a specific converter has been identified - use it */ bytes_written = (int32_t)LMBCSConversionWorker ( - extraInfo, group, pLMBCS, &uniChar, + extraInfo, group, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } if (!bytes_written) /* the ambiguous group cases (Strategy 3) */ @@ -1004,15 +1004,15 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, } if (!bytes_written) { - /* just check every possible matching converter (Strategy 3D) */ + /* just check every possible matching converter (Strategy 3D) */ ulmbcs_byte_t grp_start; - ulmbcs_byte_t grp_end; + ulmbcs_byte_t grp_end; ulmbcs_byte_t grp_ix; - grp_start = (ulmbcs_byte_t)((group == ULMBCS_AMBIGUOUS_MBCS) - ? ULMBCS_DOUBLEOPTGROUP_START + grp_start = (ulmbcs_byte_t)((group == ULMBCS_AMBIGUOUS_MBCS) + ? ULMBCS_DOUBLEOPTGROUP_START : ULMBCS_GRP_L1); - grp_end = (ulmbcs_byte_t)((group == ULMBCS_AMBIGUOUS_MBCS) - ? ULMBCS_GRP_LAST + grp_end = (ulmbcs_byte_t)((group == ULMBCS_AMBIGUOUS_MBCS) + ? ULMBCS_GRP_LAST : ULMBCS_GRP_TH); if(group == ULMBCS_AMBIGUOUS_ALL) { @@ -1020,22 +1020,22 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, grp_end = ULMBCS_GRP_LAST; } for (grp_ix = grp_start; - grp_ix <= grp_end && !bytes_written; + grp_ix <= grp_end && !bytes_written; grp_ix++) { if (extraInfo->OptGrpConverter [grp_ix] && !groups_tried [grp_ix]) { bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, - grp_ix, pLMBCS, &uniChar, + grp_ix, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } } - /* a final conversion fallback to the exceptions group if its likely + /* a final conversion fallback to the exceptions group if its likely to be single byte (Strategy 3E) */ if (!bytes_written && grp_start == ULMBCS_GRP_L1) { bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, - ULMBCS_GRP_EXCEPT, pLMBCS, &uniChar, + ULMBCS_GRP_EXCEPT, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } } @@ -1048,7 +1048,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, } } } - + /* we have a translation. increment source and write as much as posible to target */ args->source++; pLMBCS = LMBCS; @@ -1077,7 +1077,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, } /*Fix for SPR#DJOE66JFN3 (Lotus)*/ extraInfo->localeConverterIndex = OldConverterIndex; - } + } } @@ -1091,7 +1091,7 @@ GetUniFromLMBCSUni(char const ** ppLMBCSin) /* Called with LMBCS-style Unicode uint8_t HighCh = *(*ppLMBCSin)++; /* Big-endian Unicode in LMBCS compatibility group*/ uint8_t LowCh = *(*ppLMBCSin)++; - if (HighCh == ULMBCS_UNICOMPATZERO ) + if (HighCh == ULMBCS_UNICOMPATZERO ) { HighCh = LowCh; LowCh = 0; /* zero-byte in LSB special character */ @@ -1101,17 +1101,19 @@ GetUniFromLMBCSUni(char const ** ppLMBCSin) /* Called with LMBCS-style Unicode -/* CHECK_SOURCE_LIMIT: Helper macro to verify that there are at least'index' +/* CHECK_SOURCE_LIMIT: Helper macro to verify that there are at least'index' bytes left in source up to sourceLimit.Errors appropriately if not. If we reach the limit, then update the source pointer to there to consume all input as required by ICU converter semantics. */ -#define CHECK_SOURCE_LIMIT(index) \ - if (args->source+index > args->sourceLimit){\ - *err = U_TRUNCATED_CHAR_FOUND;\ - args->source = args->sourceLimit;\ - return 0xffff;} +#define CHECK_SOURCE_LIMIT(index) UPRV_BLOCK_MACRO_BEGIN { \ + if (args->source+index > args->sourceLimit) { \ + *err = U_TRUNCATED_CHAR_FOUND; \ + args->source = args->sourceLimit; \ + return 0xffff; \ + } \ +} UPRV_BLOCK_MACRO_END /* Return the Unicode representation for the current LMBCS character */ @@ -1130,32 +1132,32 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args, } /* Grab first byte & save address for error recovery */ CurByte = *((ulmbcs_byte_t *) (args->source++)); - + /* * at entry of each if clause: * 1. 'CurByte' points at the first byte of a LMBCS character - * 2. '*source'points to the next byte of the source stream after 'CurByte' + * 2. '*source'points to the next byte of the source stream after 'CurByte' * * the job of each if clause is: * 1. set '*source' to point at the beginning of next char (nop if LMBCS char is only 1 byte) * 2. set 'uniChar' up with the right Unicode value, or set 'err' appropriately */ - + /* First lets check the simple fixed values. */ if(((CurByte > ULMBCS_C0END) && (CurByte < ULMBCS_C1START)) /* ascii range */ - || (CurByte == 0) - || CurByte == ULMBCS_HT || CurByte == ULMBCS_CR + || (CurByte == 0) + || CurByte == ULMBCS_HT || CurByte == ULMBCS_CR || CurByte == ULMBCS_LF || CurByte == ULMBCS_123SYSTEMRANGE) { uniChar = CurByte; } - else + else { UConverterDataLMBCS * extraInfo; - ulmbcs_byte_t group; - UConverterSharedData *cnv; - + ulmbcs_byte_t group; + UConverterSharedData *cnv; + if (CurByte == ULMBCS_GRP_CTRL) /* Control character group - no opt group update */ { ulmbcs_byte_t C0C1byte; @@ -1163,15 +1165,15 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args, C0C1byte = *(args->source)++; uniChar = (C0C1byte < ULMBCS_C1START) ? C0C1byte - ULMBCS_CTRLOFFSET : C0C1byte; } - else + else if (CurByte == ULMBCS_GRP_UNICODE) /* Unicode compatibility group: BigEndian UTF16 */ { CHECK_SOURCE_LIMIT(2); - + /* don't check for error indicators fffe/ffff below */ return GetUniFromLMBCSUni(&(args->source)); } - else if (CurByte <= ULMBCS_CTRLOFFSET) + else if (CurByte <= ULMBCS_CTRLOFFSET) { group = CurByte; /* group byte is in the source */ extraInfo = (UConverterDataLMBCS *) args->converter->extraInfo; @@ -1179,7 +1181,7 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args, { /* this is not a valid group byte - no converter*/ *err = U_INVALID_CHAR_FOUND; - } + } else if (group >= ULMBCS_DOUBLEOPTGROUP_START) /* double byte conversion */ { @@ -1200,21 +1202,21 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args, else { /* single byte conversion */ CHECK_SOURCE_LIMIT(1); CurByte = *(args->source)++; - + if (CurByte >= ULMBCS_C1START) { uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP(cnv, CurByte); } else { - /* The non-optimizable oddballs where there is an explicit byte + /* The non-optimizable oddballs where there is an explicit byte * AND the second byte is not in the upper ascii range */ char bytes[2]; extraInfo = (UConverterDataLMBCS *) args->converter->extraInfo; - cnv = extraInfo->OptGrpConverter [ULMBCS_GRP_EXCEPT]; - + cnv = extraInfo->OptGrpConverter [ULMBCS_GRP_EXCEPT]; + /* Lookup value must include opt group */ bytes[0] = group; bytes[1] = CurByte; @@ -1275,15 +1277,15 @@ _LMBCSToUnicodeWithOffsets(UConverterToUnicodeArgs* args, if (args->converter->toULength) /* reassemble char from previous call */ { - const char *saveSourceLimit; + const char *saveSourceLimit; size_t size_old = args->converter->toULength; /* limit from source is either remainder of temp buffer, or user limit on source */ size_t size_new_maybe_1 = sizeof(LMBCS) - size_old; size_t size_new_maybe_2 = args->sourceLimit - args->source; size_t size_new = (size_new_maybe_1 < size_new_maybe_2) ? size_new_maybe_1 : size_new_maybe_2; - - + + uprv_memcpy(LMBCS, args->converter->toUBytes, size_old); uprv_memcpy(LMBCS + size_old, args->source, size_new); saveSourceLimit = args->sourceLimit; @@ -1340,7 +1342,7 @@ _LMBCSToUnicodeWithOffsets(UConverterToUnicodeArgs* args, { *err = U_BUFFER_OVERFLOW_ERROR; } - else if (U_FAILURE(*err)) + else if (U_FAILURE(*err)) { /* If character incomplete or unmappable/illegal, store it in toUBytes[] */ args->converter->toULength = savebytes; diff --git a/deps/icu-small/source/common/ucnv_u16.cpp b/deps/icu-small/source/common/ucnv_u16.cpp index 6c1b87d3c939c6..a5e8367400ae69 100644 --- a/deps/icu-small/source/common/ucnv_u16.cpp +++ b/deps/icu-small/source/common/ucnv_u16.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2002-2015, International Business Machines * Corporation and others. All Rights Reserved. @@ -199,7 +199,7 @@ _UTF16BEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, } else { length=0; /* from here on, length counts the bytes in overflow[] */ } - + if(c!=0) { /* * c is a surrogate, and @@ -567,7 +567,7 @@ _UTF16BEGetNextUChar(UConverterToUnicodeArgs *pArgs, UErrorCode *err) { pArgs->source=(const char *)s; return c; -} +} static void U_CALLCONV _UTF16BEReset(UConverter *cnv, UConverterResetChoice choice) { @@ -800,7 +800,7 @@ _UTF16LEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, } else { length=0; /* from here on, length counts the bytes in overflow[] */ } - + if(c!=0) { /* * c is a surrogate, and @@ -1168,7 +1168,7 @@ _UTF16LEGetNextUChar(UConverterToUnicodeArgs *pArgs, UErrorCode *err) { pArgs->source=(const char *)s; return c; -} +} static void U_CALLCONV _UTF16LEReset(UConverter *cnv, UConverterResetChoice choice) { diff --git a/deps/icu-small/source/common/ucnv_u32.cpp b/deps/icu-small/source/common/ucnv_u32.cpp index 13444a3afd97f1..9f98914b9d734d 100644 --- a/deps/icu-small/source/common/ucnv_u32.cpp +++ b/deps/icu-small/source/common/ucnv_u32.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2002-2015, International Business Machines * Corporation and others. All Rights Reserved. @@ -84,7 +84,7 @@ T_UConverter_toUnicode_UTF32_BE(UConverterToUnicodeArgs * args, if (ch <= MAXIMUM_UTF && !U_IS_SURROGATE(ch)) { /* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */ - if (ch <= MAXIMUM_UCS2) + if (ch <= MAXIMUM_UCS2) { /* fits in 16 bits */ *(myTarget++) = (UChar) ch; @@ -434,7 +434,7 @@ T_UConverter_getNextUChar_UTF32_BE(UConverterToUnicodeArgs* args, } length = (int32_t)((const uint8_t *)args->sourceLimit - mySource); - if (length < 4) + if (length < 4) { /* got a partial character */ uprv_memcpy(args->converter->toUBytes, mySource, length); @@ -640,7 +640,7 @@ T_UConverter_toUnicode_UTF32_LE_OFFSET_LOGIC(UConverterToUnicodeArgs * args, if (ch <= MAXIMUM_UTF && !U_IS_SURROGATE(ch)) { /* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */ - if (ch <= MAXIMUM_UCS2) + if (ch <= MAXIMUM_UCS2) { /* fits in 16 bits */ *(myTarget++) = (UChar) ch; @@ -929,7 +929,7 @@ T_UConverter_getNextUChar_UTF32_LE(UConverterToUnicodeArgs* args, } length = (int32_t)((const uint8_t *)args->sourceLimit - mySource); - if (length < 4) + if (length < 4) { /* got a partial character */ uprv_memcpy(args->converter->toUBytes, mySource, length); @@ -1247,7 +1247,7 @@ static const UConverterStaticData _UTF32StaticData = { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */ }; -const UConverterSharedData _UTF32Data = +const UConverterSharedData _UTF32Data = UCNV_IMMUTABLE_SHARED_DATA_INITIALIZER(&_UTF32StaticData, &_UTF32Impl); #endif diff --git a/deps/icu-small/source/common/ucnv_u7.cpp b/deps/icu-small/source/common/ucnv_u7.cpp index ec7befe9fc9a78..87ba8cf37ec191 100644 --- a/deps/icu-small/source/common/ucnv_u7.cpp +++ b/deps/icu-small/source/common/ucnv_u7.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. diff --git a/deps/icu-small/source/common/ucnv_u8.cpp b/deps/icu-small/source/common/ucnv_u8.cpp index 878d67304c7d89..9b518e08df6785 100644 --- a/deps/icu-small/source/common/ucnv_u8.cpp +++ b/deps/icu-small/source/common/ucnv_u8.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. @@ -134,7 +134,7 @@ static void U_CALLCONV ucnv_toUnicode_UTF8 (UConverterToUnicodeArgs * args, ch -= offsetsFromUTF8[inBytes]; /* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */ - if (ch <= MAXIMUM_UCS2) + if (ch <= MAXIMUM_UCS2) { /* fits in 16 bits */ *(myTarget++) = (UChar) ch; @@ -250,7 +250,7 @@ static void U_CALLCONV ucnv_toUnicode_UTF8_OFFSETS_LOGIC (UConverterToUnicodeAr ch -= offsetsFromUTF8[inBytes]; /* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */ - if (ch <= MAXIMUM_UCS2) + if (ch <= MAXIMUM_UCS2) { /* fits in 16 bits */ *(myTarget++) = (UChar) ch; @@ -640,7 +640,7 @@ static UChar32 U_CALLCONV ucnv_getNextUChar_UTF8(UConverterToUnicodeArgs *args, cnv->toULength = i; *err = U_ILLEGAL_CHAR_FOUND; return 0xffff; -} +} U_CDECL_END /* UTF-8-from-UTF-8 conversion functions ------------------------------------ */ diff --git a/deps/icu-small/source/common/ucnvbocu.cpp b/deps/icu-small/source/common/ucnvbocu.cpp index 5b66c5059a55ba..7c2aab56558c8c 100644 --- a/deps/icu-small/source/common/ucnvbocu.cpp +++ b/deps/icu-small/source/common/ucnvbocu.cpp @@ -202,14 +202,14 @@ bocu1TrailToByte[BOCU1_TRAIL_CONTROLS_COUNT]={ * @param d Divisor. * @param m Output variable for the rest (modulo result). */ -#define NEGDIVMOD(n, d, m) { \ +#define NEGDIVMOD(n, d, m) UPRV_BLOCK_MACRO_BEGIN { \ (m)=(n)%(d); \ (n)/=(d); \ if((m)<0) { \ --(n); \ (m)+=(d); \ } \ -} +} UPRV_BLOCK_MACRO_END /* Faster versions of packDiff() for single-byte-encoded diff values. */ diff --git a/deps/icu-small/source/common/ucnvhz.cpp b/deps/icu-small/source/common/ucnvhz.cpp index 31595374696d8c..6b2f5faaf0a59a 100644 --- a/deps/icu-small/source/common/ucnvhz.cpp +++ b/deps/icu-small/source/common/ucnvhz.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2000-2015, International Business Machines * Corporation and others. All Rights Reserved. @@ -13,7 +13,7 @@ * created on: 2000oct16 * created by: Ram Viswanadha * 10/31/2000 Ram Implemented offsets logic function -* +* */ #include "unicode/utypes.h" @@ -38,7 +38,7 @@ #define ESC_LEN 2 -#define CONCAT_ESCAPE_MACRO( args, targetIndex,targetLength,strToAppend, err, len,sourceIndex){ \ +#define CONCAT_ESCAPE_MACRO(args, targetIndex,targetLength,strToAppend, err, len,sourceIndex) UPRV_BLOCK_MACRO_BEGIN { \ while(len-->0){ \ if(targetIndex < targetLength){ \ args->target[targetIndex] = (unsigned char) *strToAppend; \ @@ -53,7 +53,7 @@ } \ strToAppend++; \ } \ -} +} UPRV_BLOCK_MACRO_END typedef struct{ @@ -117,7 +117,7 @@ _HZReset(UConverter *cnv, UConverterResetChoice choice){ } if(choice!=UCNV_RESET_TO_UNICODE) { cnv->fromUnicodeStatus= 0; - cnv->fromUChar32=0x0000; + cnv->fromUChar32=0x0000; if(cnv->extraInfo != NULL){ ((UConverterDataHZ*)cnv->extraInfo)->isEscapeAppended = FALSE; ((UConverterDataHZ*)cnv->extraInfo)->targetIndex = 0; @@ -129,7 +129,7 @@ _HZReset(UConverter *cnv, UConverterResetChoice choice){ /**************************************HZ Encoding************************************************* * Rules for HZ encoding -* +* * In ASCII mode, a byte is interpreted as an ASCII character, unless a * '~' is encountered. The character '~' is an escape character. By * convention, it must be immediately followed ONLY by '~', '{' or '\n' @@ -162,7 +162,7 @@ UConverter_toUnicode_HZ_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, UChar32 targetUniChar = 0x0000; int32_t mySourceChar = 0x0000; UConverterDataHZ* myData=(UConverterDataHZ*)(args->converter->extraInfo); - tempBuf[0]=0; + tempBuf[0]=0; tempBuf[1]=0; /* Calling code already handles this situation. */ @@ -170,11 +170,11 @@ UConverter_toUnicode_HZ_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, *err = U_ILLEGAL_ARGUMENT_ERROR; return; }*/ - + while(mySource< mySourceLimit){ - + if(myTarget < args->targetLimit){ - + mySourceChar= (unsigned char) *mySource++; if(args->converter->mode == UCNV_TILDE) { @@ -349,7 +349,7 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, UBool oldIsTargetUCharDBCS; int len =0; const char* escSeq=NULL; - + /* Calling code already handles this situation. */ /*if ((args->converter == NULL) || (args->targetLimit < myTarget) || (args->sourceLimit < args->source)){ *err = U_ILLEGAL_ARGUMENT_ERROR; @@ -362,9 +362,9 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, while (mySourceIndex < mySourceLength){ targetUniChar = missingCharMarker; if (myTargetIndex < targetLength){ - + mySourceChar = (UChar) mySource[mySourceIndex++]; - + oldIsTargetUCharDBCS = isTargetUCharDBCS; if(mySourceChar ==UCNV_TILDE){ @@ -389,7 +389,7 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, } } if (targetUniChar != missingCharMarker){ - myConverterData->isTargetUCharDBCS = isTargetUCharDBCS = (UBool)(targetUniChar>0x00FF); + myConverterData->isTargetUCharDBCS = isTargetUCharDBCS = (UBool)(targetUniChar>0x00FF); if(oldIsTargetUCharDBCS != isTargetUCharDBCS || !myConverterData->isEscapeAppended ){ /*Shifting from a double byte to single byte mode*/ if(!isTargetUCharDBCS){ @@ -403,10 +403,10 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, escSeq = DB_ESCAPE; CONCAT_ESCAPE_MACRO(args, myTargetIndex, targetLength, escSeq,err,len,mySourceIndex); myConverterData->isEscapeAppended = TRUE; - + } } - + if(isTargetUCharDBCS){ if( myTargetIndex > 8); @@ -421,7 +421,7 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, }else{ args->converter->charErrorBuffer[args->converter->charErrorBufferLength++] = (char) targetUniChar; *err = U_BUFFER_OVERFLOW_ERROR; - } + } }else{ args->converter->charErrorBuffer[args->converter->charErrorBufferLength++] =(char) (targetUniChar >> 8); args->converter->charErrorBuffer[args->converter->charErrorBufferLength++] = (char) targetUniChar; @@ -434,7 +434,7 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, if(offsets){ *(offsets++) = mySourceIndex-1; } - + }else{ args->converter->charErrorBuffer[args->converter->charErrorBufferLength++] = (char) targetUniChar; *err = U_BUFFER_OVERFLOW_ERROR; @@ -503,7 +503,7 @@ _HZ_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorCode *e char *p; char buffer[4]; p = buffer; - + if( convData->isTargetUCharDBCS){ *p++= UCNV_TILDE; *p++= UCNV_CLOSE_BRACE; @@ -518,39 +518,31 @@ _HZ_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorCode *e /* * Structure for cloning an HZ converter into a single memory block. - * ucnv_safeClone() of the HZ converter will align the entire cloneHZStruct, - * and then ucnv_safeClone() of the sub-converter may additionally align - * subCnv inside the cloneHZStruct, for which we need the deadSpace after - * subCnv. This is because UAlignedMemory may be larger than the actually - * necessary alignment size for the platform. - * The other cloneHZStruct fields will not be moved around, - * and are aligned properly with cloneHZStruct's alignment. */ struct cloneHZStruct { UConverter cnv; UConverter subCnv; - UAlignedMemory deadSpace; UConverterDataHZ mydata; }; static UConverter * U_CALLCONV -_HZ_SafeClone(const UConverter *cnv, - void *stackBuffer, - int32_t *pBufferSize, +_HZ_SafeClone(const UConverter *cnv, + void *stackBuffer, + int32_t *pBufferSize, UErrorCode *status) { struct cloneHZStruct * localClone; int32_t size, bufferSizeNeeded = sizeof(struct cloneHZStruct); if (U_FAILURE(*status)){ - return 0; + return nullptr; } if (*pBufferSize == 0){ /* 'preflighting' request - set needed size into *pBufferSize */ *pBufferSize = bufferSizeNeeded; - return 0; + return nullptr; } localClone = (struct cloneHZStruct *)stackBuffer; @@ -561,7 +553,7 @@ _HZ_SafeClone(const UConverter *cnv, localClone->cnv.isExtraLocal = TRUE; /* deep-clone the sub-converter */ - size = (int32_t)(sizeof(UConverter) + sizeof(UAlignedMemory)); /* include size of padding */ + size = (int32_t)sizeof(UConverter); ((UConverterDataHZ*)localClone->cnv.extraInfo)->gbConverter = ucnv_safeClone(((UConverterDataHZ*)cnv->extraInfo)->gbConverter, &localClone->subCnv, &size, status); @@ -586,20 +578,20 @@ U_CDECL_END static const UConverterImpl _HZImpl={ UCNV_HZ, - + NULL, NULL, - + _HZOpen, _HZClose, _HZReset, - + UConverter_toUnicode_HZ_OFFSETS_LOGIC, UConverter_toUnicode_HZ_OFFSETS_LOGIC, UConverter_fromUnicode_HZ_OFFSETS_LOGIC, UConverter_fromUnicode_HZ_OFFSETS_LOGIC, NULL, - + NULL, NULL, _HZ_WriteSub, @@ -612,14 +604,14 @@ static const UConverterImpl _HZImpl={ static const UConverterStaticData _HZStaticData={ sizeof(UConverterStaticData), "HZ", - 0, - UCNV_IBM, - UCNV_HZ, - 1, + 0, + UCNV_IBM, + UCNV_HZ, + 1, 4, { 0x1a, 0, 0, 0 }, 1, - FALSE, + FALSE, FALSE, 0, 0, diff --git a/deps/icu-small/source/common/ucnvisci.cpp b/deps/icu-small/source/common/ucnvisci.cpp index d0c07f2b27fae9..44a7c05a3c8113 100644 --- a/deps/icu-small/source/common/ucnvisci.cpp +++ b/deps/icu-small/source/common/ucnvisci.cpp @@ -213,13 +213,13 @@ _ISCIIOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode) { converterData->currentMaskFromUnicode = converterData->currentMaskToUnicode = converterData->defMaskToUnicode = lookupInitialData[pArgs->options & UCNV_OPTIONS_VERSION_MASK].maskEnum; - + converterData->isFirstBuffer=TRUE; (void)uprv_strcpy(converterData->name, ISCII_CNV_PREFIX); len = (int32_t)uprv_strlen(converterData->name); converterData->name[len]= (char)((pArgs->options & UCNV_OPTIONS_VERSION_MASK) + '0'); converterData->name[len+1]=0; - + converterData->prevToUnicodeStatus = 0x0000; } else { uprv_free(cnv->extraInfo); @@ -831,7 +831,7 @@ static const uint16_t nuktaSpecialCases[][2]={ }; -#define WRITE_TO_TARGET_FROM_U(args,offsets,source,target,targetLimit,targetByteUnit,err){ \ +#define WRITE_TO_TARGET_FROM_U(args,offsets,source,target,targetLimit,targetByteUnit,err) UPRV_BLOCK_MACRO_BEGIN { \ int32_t offset = (int32_t)(source - args->source-1); \ /* write the targetUniChar to target */ \ if(target < targetLimit){ \ @@ -884,7 +884,7 @@ static const uint16_t nuktaSpecialCases[][2]={ (uint8_t) (targetByteUnit); \ *err = U_BUFFER_OVERFLOW_ERROR; \ } \ -} +} UPRV_BLOCK_MACRO_END /* Rules: * Explicit Halant : @@ -934,12 +934,12 @@ UConverter_fromUnicode_ISCII_OFFSETS_LOGIC( break; } } - + sourceChar = *source++; tempContextFromUnicode = converterData->contextCharFromUnicode; - + targetByteUnit = missingCharMarker; - + /*check if input is in ASCII and C0 control codes range*/ if (sourceChar <= ASCII_END) { args->converter->fromUnicodeStatus = sourceChar; @@ -989,8 +989,8 @@ UConverter_fromUnicode_ISCII_OFFSETS_LOGIC( deltaChanged =TRUE; converterData->isFirstBuffer=FALSE; } - - if (converterData->currentDeltaFromUnicode == PNJ_DELTA) { + + if (converterData->currentDeltaFromUnicode == PNJ_DELTA) { if (sourceChar == PNJ_TIPPI) { /* Make sure Tippi is converterd to Bindi. */ sourceChar = PNJ_BINDI; @@ -998,7 +998,7 @@ UConverter_fromUnicode_ISCII_OFFSETS_LOGIC( /* This is for consonant cluster handling. */ converterData->contextCharFromUnicode = PNJ_ADHAK; } - + } /* Normalize all Indic codepoints to Devanagari and map them to ISCII */ /* now subtract the new delta from sourceChar*/ @@ -1031,7 +1031,7 @@ UConverter_fromUnicode_ISCII_OFFSETS_LOGIC( break; } } - + if (converterData->currentDeltaFromUnicode == PNJ_DELTA && (sourceChar + PNJ_DELTA) == PNJ_ADHAK) { continue; } @@ -1119,7 +1119,7 @@ static const uint16_t lookupTable[][2]={ { GURMUKHI, PNJ_MASK } }; -#define WRITE_TO_TARGET_TO_U(args,source,target,offsets,offset,targetUniChar,delta, err){\ +#define WRITE_TO_TARGET_TO_U(args,source,target,offsets,offset,targetUniChar,delta, err) UPRV_BLOCK_MACRO_BEGIN { \ /* add offset to current Indic Block */ \ if(targetUniChar>ASCII_END && \ targetUniChar != ZWJ && \ @@ -1140,9 +1140,9 @@ static const uint16_t lookupTable[][2]={ (UChar)targetUniChar; \ *err = U_BUFFER_OVERFLOW_ERROR; \ } \ -} +} UPRV_BLOCK_MACRO_END -#define GET_MAPPING(sourceChar,targetUniChar,data){ \ +#define GET_MAPPING(sourceChar,targetUniChar,data) UPRV_BLOCK_MACRO_BEGIN { \ targetUniChar = toUnicodeTable[(sourceChar)] ; \ /* is the code point valid in current script? */ \ if(sourceChar> ASCII_END && \ @@ -1153,7 +1153,7 @@ static const uint16_t lookupTable[][2]={ targetUniChar=missingCharMarker; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /*********** * Rules for ISCII to Unicode converter @@ -1189,7 +1189,7 @@ UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, UErrorCo UChar32 tempTargetUniChar = 0x0000; UChar* contextCharToUnicode= NULL; UBool found; - int i; + int i; int offset = 0; if ((args->converter == NULL) || (target < args->target) || (source < args->source)) { @@ -1245,7 +1245,7 @@ UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, UErrorCo /* We currently support only Anudatta and Devanagari abbreviation sign */ if (sourceChar==0xBF || sourceChar == 0xB8) { targetUniChar = (sourceChar==0xBF) ? DEV_ABBR_SIGN : DEV_ANUDATTA; - + /* find out if the mapping is valid in this state */ if (validityTable[(uint8_t)targetUniChar] & data->currentMaskToUnicode) { *contextCharToUnicode= NO_CHAR_MARKER; @@ -1452,7 +1452,7 @@ UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, UErrorCo WRITE_TO_TARGET_TO_U(args,source,target,args->offsets,(source-args->source -1),data->prevToUnicodeStatus,0,err); data->prevToUnicodeStatus = 0x0000; } - /* Check to make sure that Bindi and Tippi are handled correctly for Gurmukhi script. + /* Check to make sure that Bindi and Tippi are handled correctly for Gurmukhi script. * If 0xA2 is preceded by a codepoint in the PNJ_BINDI_TIPPI_SET then the target codepoint should be Tippi instead of Bindi. */ if (data->currentDeltaToUnicode == PNJ_DELTA && (targetUniChar + PNJ_DELTA) == PNJ_BINDI && isPNJBindiTippi((*toUnicodeStatus + PNJ_DELTA))) { diff --git a/deps/icu-small/source/common/ucnvlat1.cpp b/deps/icu-small/source/common/ucnvlat1.cpp index 15eeb5c51f5fb3..358bc0caa25a19 100644 --- a/deps/icu-small/source/common/ucnvlat1.cpp +++ b/deps/icu-small/source/common/ucnvlat1.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2000-2015, International Business Machines * Corporation and others. All Rights Reserved. diff --git a/deps/icu-small/source/common/ucnvmbcs.cpp b/deps/icu-small/source/common/ucnvmbcs.cpp index 2fec6b4b1510d6..ca9b0a335ad156 100644 --- a/deps/icu-small/source/common/ucnvmbcs.cpp +++ b/deps/icu-small/source/common/ucnvmbcs.cpp @@ -35,7 +35,7 @@ * limitations and adds m:n character mappings and other features. * See ucnv_ext.h for details. * -* Change history: +* Change history: * * 5/6/2001 Ram Moved MBCS_SINGLE_RESULT_FROM_U,MBCS_STAGE_2_FROM_U, * MBCS_VALUE_2_FROM_STAGE_2, MBCS_VALUE_4_FROM_STAGE_2 @@ -849,7 +849,7 @@ ucnv_MBCSEnumToUnicode(UConverterMBCSTable *mbcsTable, } } -U_CFUNC void +U_CFUNC void ucnv_MBCSGetFilteredUnicodeSetForUnicode(const UConverterSharedData *sharedData, const USetAdder *sa, UConverterUnicodeSet which, diff --git a/deps/icu-small/source/common/ucnvmbcs.h b/deps/icu-small/source/common/ucnvmbcs.h index a750b92e499c6e..209cdc532d4d23 100644 --- a/deps/icu-small/source/common/ucnvmbcs.h +++ b/deps/icu-small/source/common/ucnvmbcs.h @@ -180,15 +180,15 @@ * -- normal base table with optional extension * * int32_t stateTable[countStates][256]; - * + * * struct _MBCSToUFallback { (fallbacks are sorted by offset) * uint32_t offset; * UChar32 codePoint; * } toUFallbacks[countToUFallbacks]; - * + * * uint16_t unicodeCodeUnits[(offsetFromUTable-offsetToUCodeUnits)/2]; * (padded to an even number of units) - * + * * -- stage 1 tables * if(staticData.unicodeMask&UCNV_HAS_SUPPLEMENTARY) { * -- stage 1 table for all of Unicode @@ -566,10 +566,10 @@ ucnv_MBCSSingleFromUChar32(UConverterSharedData *sharedData, U_CFUNC UConverterType ucnv_MBCSGetType(const UConverter* converter); -U_CFUNC void +U_CFUNC void ucnv_MBCSFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, UErrorCode *pErrorCode); -U_CFUNC void +U_CFUNC void ucnv_MBCSToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs, UErrorCode *pErrorCode); diff --git a/deps/icu-small/source/common/ucnvscsu.cpp b/deps/icu-small/source/common/ucnvscsu.cpp index eb7b7ad5c8793e..74b5722b975bff 100644 --- a/deps/icu-small/source/common/ucnvscsu.cpp +++ b/deps/icu-small/source/common/ucnvscsu.cpp @@ -1969,9 +1969,9 @@ struct cloneSCSUStruct }; static UConverter * U_CALLCONV -_SCSUSafeClone(const UConverter *cnv, - void *stackBuffer, - int32_t *pBufferSize, +_SCSUSafeClone(const UConverter *cnv, + void *stackBuffer, + int32_t *pBufferSize, UErrorCode *status) { struct cloneSCSUStruct * localClone; diff --git a/deps/icu-small/source/common/ucnvsel.cpp b/deps/icu-small/source/common/ucnvsel.cpp index 6ccee1ae61fd70..2dff5ac1bc8388 100644 --- a/deps/icu-small/source/common/ucnvsel.cpp +++ b/deps/icu-small/source/common/ucnvsel.cpp @@ -658,7 +658,7 @@ static const UEnumeration defaultEncodings = { ucnvsel_close_selector_iterator, ucnvsel_count_encodings, uenum_unextDefault, - ucnvsel_next_encoding, + ucnvsel_next_encoding, ucnvsel_reset_iterator }; @@ -691,36 +691,36 @@ static int16_t countOnes(uint32_t* mask, int32_t len) { /* internal function! */ static UEnumeration *selectForMask(const UConverterSelector* sel, - uint32_t *mask, UErrorCode *status) { + uint32_t *theMask, UErrorCode *status) { + LocalMemory mask(theMask); // this is the context we will use. Store a table of indices to which // encodings are legit. - struct Enumerator* result = (Enumerator*)uprv_malloc(sizeof(Enumerator)); - if (result == NULL) { - uprv_free(mask); + LocalMemory result(static_cast(uprv_malloc(sizeof(Enumerator)))); + if (result.isNull()) { *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - result->index = NULL; // this will be allocated later! + result->index = nullptr; // this will be allocated later! result->length = result->cur = 0; result->sel = sel; - UEnumeration *en = (UEnumeration *)uprv_malloc(sizeof(UEnumeration)); - if (en == NULL) { + LocalMemory en(static_cast(uprv_malloc(sizeof(UEnumeration)))); + if (en.isNull()) { // TODO(markus): Combine Enumerator and UEnumeration into one struct. - uprv_free(mask); - uprv_free(result); *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - memcpy(en, &defaultEncodings, sizeof(UEnumeration)); - en->context = result; - + memcpy(en.getAlias(), &defaultEncodings, sizeof(UEnumeration)); + int32_t columns = (sel->encodingsCount+31)/32; - int16_t numOnes = countOnes(mask, columns); + int16_t numOnes = countOnes(mask.getAlias(), columns); // now, we know the exact space we need for index if (numOnes > 0) { - result->index = (int16_t*) uprv_malloc(numOnes * sizeof(int16_t)); - + result->index = static_cast(uprv_malloc(numOnes * sizeof(int16_t))); + if (result->index == nullptr) { + *status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } int32_t i, j; int16_t k = 0; for (j = 0 ; j < columns; j++) { @@ -734,8 +734,8 @@ static UEnumeration *selectForMask(const UConverterSelector* sel, } } //otherwise, index will remain NULL (and will never be touched by //the enumerator code anyway) - uprv_free(mask); - return en; + en->context = result.orphan(); + return en.orphan(); } /* check a string against the selector - UTF16 version */ @@ -767,7 +767,7 @@ ucnvsel_selectForString(const UConverterSelector* sel, } else { limit = NULL; } - + while (limit == NULL ? *s != 0 : s != limit) { UChar32 c; uint16_t pvIndex; @@ -808,7 +808,7 @@ ucnvsel_selectForUTF8(const UConverterSelector* sel, if(s!=NULL) { const char *limit = s + length; - + while (s != limit) { uint16_t pvIndex; UTRIE2_U8_NEXT16(sel->trie, s, limit, pvIndex); diff --git a/deps/icu-small/source/common/ucol_swp.cpp b/deps/icu-small/source/common/ucol_swp.cpp index 97b5c4aff50c88..1af19863fa84e7 100644 --- a/deps/icu-small/source/common/ucol_swp.cpp +++ b/deps/icu-small/source/common/ucol_swp.cpp @@ -173,7 +173,7 @@ swapFormatVersion3(const UDataSwapper *ds, header.contractionUCACombosSize=udata_readInt32(ds, inHeader->contractionUCACombosSize); header.scriptToLeadByte= ds->readUInt32(inHeader->scriptToLeadByte); header.leadByteToScript= ds->readUInt32(inHeader->leadByteToScript); - + /* swap the 32-bit integers in the header */ ds->swapArray32(ds, inHeader, (int32_t)((const char *)&inHeader->jamoSpecial-(const char *)inHeader), outHeader, pErrorCode); @@ -244,21 +244,21 @@ swapFormatVersion3(const UDataSwapper *ds, ds->swapArray16(ds, inBytes+header.contractionUCACombos, (int32_t)count, outBytes+header.contractionUCACombos, pErrorCode); } - + /* swap the script to lead bytes */ if(header.scriptToLeadByte!=0) { int indexCount = ds->readUInt16(*((uint16_t*)(inBytes+header.scriptToLeadByte))); // each entry = 2 * uint16 int dataCount = ds->readUInt16(*((uint16_t*)(inBytes+header.scriptToLeadByte + 2))); // each entry = uint16 - ds->swapArray16(ds, inBytes+header.scriptToLeadByte, + ds->swapArray16(ds, inBytes+header.scriptToLeadByte, 4 + (4 * indexCount) + (2 * dataCount), outBytes+header.scriptToLeadByte, pErrorCode); } - + /* swap the lead byte to scripts */ if(header.leadByteToScript!=0) { int indexCount = ds->readUInt16(*((uint16_t*)(inBytes+header.leadByteToScript))); // each entry = uint16 int dataCount = ds->readUInt16(*((uint16_t*)(inBytes+header.leadByteToScript + 2))); // each entry = uint16 - ds->swapArray16(ds, inBytes+header.leadByteToScript, + ds->swapArray16(ds, inBytes+header.leadByteToScript, 4 + (2 * indexCount) + (2 * dataCount), outBytes+header.leadByteToScript, pErrorCode); } diff --git a/deps/icu-small/source/common/ucptrie.cpp b/deps/icu-small/source/common/ucptrie.cpp index b72e318387a186..0004160a238b0e 100644 --- a/deps/icu-small/source/common/ucptrie.cpp +++ b/deps/icu-small/source/common/ucptrie.cpp @@ -280,7 +280,7 @@ UChar32 getRange(const void *t, UChar32 start, int32_t prevI3Block = -1; int32_t prevBlock = -1; UChar32 c = start; - uint32_t trieValue, value; + uint32_t trieValue, value = nullValue; bool haveValue = false; do { int32_t i3Block; diff --git a/deps/icu-small/source/common/ucurr.cpp b/deps/icu-small/source/common/ucurr.cpp index dba3247fef2c98..dfee3bd3000595 100644 --- a/deps/icu-small/source/common/ucurr.cpp +++ b/deps/icu-small/source/common/ucurr.cpp @@ -110,7 +110,7 @@ class EquivIterator : public icu::UMemory { // Constructor. hash stores the equivalence relationships; s is the string // for which we find equivalent strings. inline EquivIterator(const icu::Hashtable& hash, const icu::UnicodeString& s) - : _hash(hash) { + : _hash(hash) { _start = _current = &s; } inline ~EquivIterator() { } @@ -228,7 +228,7 @@ static const icu::Hashtable* getCurrSymbolsEquiv(); /** * Cleanup callback func */ -static UBool U_CALLCONV +static UBool U_CALLCONV isoCodes_cleanup(void) { if (gIsoCodes != NULL) { @@ -242,7 +242,7 @@ isoCodes_cleanup(void) /** * Cleanup callback func */ -static UBool U_CALLCONV +static UBool U_CALLCONV currSymbolsEquiv_cleanup(void) { delete const_cast(gCurrSymbolsEquiv); @@ -365,10 +365,7 @@ U_CDECL_END #if !UCONFIG_NO_SERVICE struct CReg; -static UMutex *gCRegLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gCRegLock; static CReg* gCRegHead = 0; struct CReg : public icu::UMemory { @@ -394,14 +391,14 @@ struct CReg : public icu::UMemory { if (status && U_SUCCESS(*status) && _iso && _id) { CReg* n = new CReg(_iso, _id); if (n) { - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); if (!gCRegHead) { /* register for the first time */ ucln_common_registerCleanup(UCLN_COMMON_CURRENCY, currency_cleanup); } n->next = gCRegHead; gCRegHead = n; - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return n; } *status = U_MEMORY_ALLOCATION_ERROR; @@ -411,7 +408,7 @@ struct CReg : public icu::UMemory { static UBool unreg(UCurrRegistryKey key) { UBool found = FALSE; - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); CReg** p = &gCRegHead; while (*p) { @@ -424,13 +421,13 @@ struct CReg : public icu::UMemory { p = &((*p)->next); } - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return found; } static const UChar* get(const char* id) { const UChar* result = NULL; - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); CReg* p = gCRegHead; /* register cleanup of the mutex */ @@ -442,7 +439,7 @@ struct CReg : public icu::UMemory { } p = p->next; } - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return result; } @@ -679,10 +676,10 @@ ucurr_getName(const UChar* currency, char buf[ISO_CURRENCY_CODE_LENGTH+1]; myUCharsToChars(buf, currency); - + /* Normalize the keyword value to uppercase */ T_CString_toUpperCase(buf); - + const UChar* s = NULL; ec2 = U_ZERO_ERROR; LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_CURR, loc, &ec2)); @@ -716,7 +713,9 @@ ucurr_getName(const UChar* currency, // We no longer support choice format data in names. Data should not contain // choice patterns. - *isChoiceFormat = FALSE; + if (isChoiceFormat != NULL) { + *isChoiceFormat = FALSE; + } if (U_SUCCESS(ec2)) { U_ASSERT(s != NULL); return s; @@ -777,11 +776,11 @@ ucurr_getPluralName(const UChar* currency, if (U_FAILURE(ec2)) { // fall back to "other" ec2 = U_ZERO_ERROR; - s = ures_getStringByKeyWithFallback(rb, "other", len, &ec2); + s = ures_getStringByKeyWithFallback(rb, "other", len, &ec2); if (U_FAILURE(ec2)) { ures_close(rb); // fall back to long name in Currencies - return ucurr_getName(currency, locale, UCURR_LONG_NAME, + return ucurr_getName(currency, locale, UCURR_LONG_NAME, isChoiceFormat, len, ec); } } @@ -834,7 +833,7 @@ typedef struct { static int U_CALLCONV currencyNameComparator(const void* a, const void* b) { const CurrencyNameStruct* currName_1 = (const CurrencyNameStruct*)a; const CurrencyNameStruct* currName_2 = (const CurrencyNameStruct*)b; - for (int32_t i = 0; + for (int32_t i = 0; i < MIN(currName_1->currencyNameLen, currName_2->currencyNameLen); ++i) { if (currName_1->currencyName[i] < currName_2->currencyName[i]) { @@ -856,7 +855,7 @@ static int U_CALLCONV currencyNameComparator(const void* a, const void* b) { // Give a locale, return the maximum number of currency names associated with // this locale. // It gets currency names from resource bundles using fallback. -// It is the maximum number because in the fallback chain, some of the +// It is the maximum number because in the fallback chain, some of the // currency names are duplicated. // For example, given locale as "en_US", the currency names get from resource // bundle in "en_US" and "en" are duplicated. The fallback mechanism will count @@ -908,7 +907,7 @@ getCurrencyNameCount(const char* loc, int32_t* total_currency_name_count, int32_ } } -static UChar* +static UChar* toUpperCase(const UChar* source, int32_t len, const char* locale) { UChar* dest = NULL; UErrorCode ec = U_ZERO_ERROR; @@ -919,7 +918,7 @@ toUpperCase(const UChar* source, int32_t len, const char* locale) { u_strToUpper(dest, destLen, source, len, locale, &ec); if (U_FAILURE(ec)) { u_memcpy(dest, source, len); - } + } return dest; } @@ -931,11 +930,11 @@ toUpperCase(const UChar* source, int32_t len, const char* locale) { // return the malloc-ed currency name arrays and the total number of currency // names in the array. static void -collectCurrencyNames(const char* locale, - CurrencyNameStruct** currencyNames, - int32_t* total_currency_name_count, - CurrencyNameStruct** currencySymbols, - int32_t* total_currency_symbol_count, +collectCurrencyNames(const char* locale, + CurrencyNameStruct** currencyNames, + int32_t* total_currency_name_count, + CurrencyNameStruct** currencySymbols, + int32_t* total_currency_symbol_count, UErrorCode& ec) { U_NAMESPACE_USE const icu::Hashtable *currencySymbolsEquiv = getCurrSymbolsEquiv(); @@ -987,13 +986,13 @@ collectCurrencyNames(const char* locale, // TODO: uhash_put wont change key/value? iso = (char*)ures_getKey(names); if (localeLevel == 0) { - uhash_put(currencyIsoCodes, iso, iso, &ec3); + uhash_put(currencyIsoCodes, iso, iso, &ec3); } else { if (uhash_get(currencyIsoCodes, iso) != NULL) { ures_close(names); continue; } else { - uhash_put(currencyIsoCodes, iso, iso, &ec3); + uhash_put(currencyIsoCodes, iso, iso, &ec3); } } // Add currency symbol. @@ -1044,19 +1043,19 @@ collectCurrencyNames(const char* locale, iso = (char*)ures_getKey(names); // Using hash to remove duplicated ISO codes in fallback chain. if (localeLevel == 0) { - uhash_put(currencyPluralIsoCodes, iso, iso, &ec4); + uhash_put(currencyPluralIsoCodes, iso, iso, &ec4); } else { if (uhash_get(currencyPluralIsoCodes, iso) != NULL) { ures_close(names); continue; } else { - uhash_put(currencyPluralIsoCodes, iso, iso, &ec4); + uhash_put(currencyPluralIsoCodes, iso, iso, &ec4); } } int32_t num = ures_getSize(names); int32_t len; for (int32_t j = 0; j < num; ++j) { - // TODO: remove duplicates between singular name and + // TODO: remove duplicates between singular name and // currency long name? s = ures_getStringByIndex(names, j, &len, &ec5); (*currencyNames)[*total_currency_name_count].IsoCode = iso; @@ -1080,9 +1079,9 @@ collectCurrencyNames(const char* locale, uhash_close(currencyPluralIsoCodes); // quick sort the struct - qsort(*currencyNames, *total_currency_name_count, + qsort(*currencyNames, *total_currency_name_count, sizeof(CurrencyNameStruct), currencyNameComparator); - qsort(*currencySymbols, *total_currency_symbol_count, + qsort(*currencySymbols, *total_currency_symbol_count, sizeof(CurrencyNameStruct), currencyNameComparator); #ifdef UCURR_DEBUG @@ -1119,13 +1118,13 @@ collectCurrencyNames(const char* locale, } // @param currencyNames: currency names array -// @param indexInCurrencyNames: the index of the character in currency names +// @param indexInCurrencyNames: the index of the character in currency names // array against which the comparison is done // @param key: input text char to compare against // @param begin(IN/OUT): the begin index of matching range in currency names array // @param end(IN/OUT): the end index of matching range in currency names array. static int32_t -binarySearch(const CurrencyNameStruct* currencyNames, +binarySearch(const CurrencyNameStruct* currencyNames, int32_t indexInCurrencyNames, const UChar key, int32_t* begin, int32_t* end) { @@ -1239,7 +1238,7 @@ binarySearch(const CurrencyNameStruct* currencyNames, // @param maxMatchIndex: the index in currencyName which has the longest // match with input text. static void -linearSearch(const CurrencyNameStruct* currencyNames, +linearSearch(const CurrencyNameStruct* currencyNames, int32_t begin, int32_t end, const UChar* text, int32_t textLen, int32_t *partialMatchLen, @@ -1278,7 +1277,7 @@ linearSearch(const CurrencyNameStruct* currencyNames, // @param maxMatchIndex: the index in currencyName which has the longest // match with input text. static void -searchCurrencyName(const CurrencyNameStruct* currencyNames, +searchCurrencyName(const CurrencyNameStruct* currencyNames, int32_t total_currency_count, const UChar* text, int32_t textLen, int32_t *partialMatchLen, @@ -1312,8 +1311,8 @@ searchCurrencyName(const CurrencyNameStruct* currencyNames, break; } *partialMatchLen = MAX(*partialMatchLen, index + 1); - if (matchIndex != -1) { - // find an exact match for text from text[0] to text[index] + if (matchIndex != -1) { + // find an exact match for text from text[0] to text[index] // in currencyNames array. *maxMatchLen = index + 1; *maxMatchIndex = matchIndex; @@ -1342,7 +1341,7 @@ typedef struct { // reference count. // reference count is set to 1 when an entry is put to cache. // it increases by 1 before accessing, and decreased by 1 after accessing. - // The entry is deleted when ref count is zero, which means + // The entry is deleted when ref count is zero, which means // the entry is replaced out of cache and no process is accessing it. int32_t refCount; } CurrencyNameCacheEntry; @@ -1356,10 +1355,7 @@ static CurrencyNameCacheEntry* currCache[CURRENCY_NAME_CACHE_NUM] = {NULL}; // It is a simple round-robin replacement strategy. static int8_t currentCacheEntryIndex = 0; -static UMutex *gCurrencyCacheMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gCurrencyCacheMutex; // Cache deletion static void @@ -1408,7 +1404,7 @@ getCacheEntry(const char* locale, UErrorCode& ec) { CurrencyNameStruct* currencySymbols = NULL; CurrencyNameCacheEntry* cacheEntry = NULL; - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); // in order to handle racing correctly, // not putting 'search' in a separate function. int8_t found = -1; @@ -1423,13 +1419,13 @@ getCacheEntry(const char* locale, UErrorCode& ec) { cacheEntry = currCache[found]; ++(cacheEntry->refCount); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); if (found == -1) { collectCurrencyNames(locale, ¤cyNames, &total_currency_name_count, ¤cySymbols, &total_currency_symbol_count, ec); if (U_FAILURE(ec)) { return NULL; } - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); // check again. for (int8_t i = 0; i < CURRENCY_NAME_CACHE_NUM; ++i) { if (currCache[i]!= NULL && @@ -1439,9 +1435,9 @@ getCacheEntry(const char* locale, UErrorCode& ec) { } } if (found == -1) { - // insert new entry to + // insert new entry to // currentCacheEntryIndex % CURRENCY_NAME_CACHE_NUM - // and remove the existing entry + // and remove the existing entry // currentCacheEntryIndex % CURRENCY_NAME_CACHE_NUM // from cache. cacheEntry = currCache[currentCacheEntryIndex]; @@ -1468,19 +1464,19 @@ getCacheEntry(const char* locale, UErrorCode& ec) { cacheEntry = currCache[found]; ++(cacheEntry->refCount); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); } return cacheEntry; } static void releaseCacheEntry(CurrencyNameCacheEntry* cacheEntry) { - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); --(cacheEntry->refCount); if (cacheEntry->refCount == 0) { // remove deleteCacheEntry(cacheEntry); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); } U_CAPI void @@ -1507,8 +1503,8 @@ uprv_parseCurrency(const char* locale, int32_t start = pos.getIndex(); - UChar inputText[MAX_CURRENCY_NAME_LEN]; - UChar upperText[MAX_CURRENCY_NAME_LEN]; + UChar inputText[MAX_CURRENCY_NAME_LEN]; + UChar upperText[MAX_CURRENCY_NAME_LEN]; int32_t textLen = MIN(MAX_CURRENCY_NAME_LEN, text.length() - start); text.extract(start, textLen, inputText); UErrorCode ec1 = U_ZERO_ERROR; @@ -1520,7 +1516,7 @@ uprv_parseCurrency(const char* locale, int32_t max = 0; int32_t matchIndex = -1; // case in-sensitive comparision against currency names - searchCurrencyName(currencyNames, total_currency_name_count, + searchCurrencyName(currencyNames, total_currency_name_count, upperText, textLen, partialMatchLen, &max, &matchIndex); #ifdef UCURR_DEBUG @@ -1531,7 +1527,7 @@ uprv_parseCurrency(const char* locale, int32_t matchIndexInSymbol = -1; if (type != UCURR_LONG_NAME) { // not name only // case sensitive comparison against currency symbols and ISO code. - searchCurrencyName(currencySymbols, total_currency_symbol_count, + searchCurrencyName(currencySymbols, total_currency_symbol_count, inputText, textLen, partialMatchLen, &maxInSymbol, &matchIndexInSymbol); @@ -1601,10 +1597,9 @@ uprv_getStaticCurrencyName(const UChar* iso, const char* loc, { U_NAMESPACE_USE - UBool isChoiceFormat; int32_t len; const UChar* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME, - &isChoiceFormat, &len, &ec); + nullptr /* isChoiceFormat */, &len, &ec); if (U_SUCCESS(ec)) { result.setTo(currname, len); } @@ -2062,11 +2057,11 @@ ucurr_createCurrencyList(UHashtable *isoCodes, UErrorCode* status){ UResourceBundle *currencyMapArray = ures_getByKey(rb, CURRENCY_MAP, rb, &localStatus); if (U_SUCCESS(localStatus)) { - // process each entry in currency map + // process each entry in currency map for (int32_t i=0; icontext = values; - + UResourceBundle *bundle = ures_openDirect(U_ICUDATA_CURR, "supplementalData", status); ures_getByKey(bundle, "CurrencyMap", bundle, status); UResourceBundle bundlekey, regbndl, curbndl, to; @@ -2554,7 +2549,7 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, ures_initStackObject(®bndl); ures_initStackObject(&curbndl); ures_initStackObject(&to); - + while (U_SUCCESS(*status) && ures_hasNext(bundle)) { ures_getNextResource(bundle, &bundlekey, status); if (U_FAILURE(*status)) { @@ -2595,11 +2590,11 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, if(curIDLength+1 > ULOC_KEYWORDS_CAPACITY) { *status = U_BUFFER_OVERFLOW_ERROR; } else { - u_UCharsToChars(defString, curID, curIDLength+1); + u_UCharsToChars(defString, curID, curIDLength+1); } } } -#endif +#endif if (U_FAILURE(*status)) { break; @@ -2621,7 +2616,7 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, uprv_free(curID); } } - + } if (U_SUCCESS(*status)) { if (commonlyUsed) { @@ -2646,7 +2641,7 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, } } } - + ulist_resetList((UList *)(en->context)); } else { ulist_deleteList(values); @@ -2659,9 +2654,9 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, ures_close(®bndl); ures_close(&bundlekey); ures_close(bundle); - + ulist_deleteList(otherValues); - + return en; } diff --git a/deps/icu-small/source/common/udata.cpp b/deps/icu-small/source/common/udata.cpp index 99efbc97eed737..ec9c999cea41a6 100644 --- a/deps/icu-small/source/common/udata.cpp +++ b/deps/icu-small/source/common/udata.cpp @@ -33,6 +33,7 @@ might have to #include some other header #include "cstring.h" #include "mutex.h" #include "putilimp.h" +#include "restrace.h" #include "uassert.h" #include "ucln_cmn.h" #include "ucmndata.h" @@ -110,11 +111,12 @@ static u_atomic_int32_t gHaveTriedToLoadCommonData = ATOMIC_INT32_T_INITIALIZER( static UHashtable *gCommonDataCache = NULL; /* Global hash table of opened ICU data files. */ static icu::UInitOnce gCommonDataCacheInitOnce = U_INITONCE_INITIALIZER; -#if U_PLATFORM_HAS_WINUWP_API == 0 +#if !defined(ICU_DATA_DIR_WINDOWS) static UDataFileAccess gDataFileAccess = UDATA_DEFAULT_ACCESS; // Access not synchronized. // Modifying is documented as thread-unsafe. #else -static UDataFileAccess gDataFileAccess = UDATA_NO_FILES; // Windows UWP looks in one spot explicitly +// If we are using the Windows data directory, then look in one spot only. +static UDataFileAccess gDataFileAccess = UDATA_NO_FILES; #endif static UBool U_CALLCONV @@ -206,7 +208,7 @@ setCommonICUData(UDataMemory *pData, /* The new common data. Belongs to ca return didUpdate; } -#if U_PLATFORM_HAS_WINUWP_API == 0 +#if !defined(ICU_DATA_DIR_WINDOWS) static UBool setCommonICUDataPointer(const void *pData, UBool /*warn*/, UErrorCode *pErrorCode) { @@ -320,7 +322,7 @@ static UDataMemory *udata_findCachedData(const char *path, UErrorCode &err) retVal = el->item; } #ifdef UDATA_DEBUG - fprintf(stderr, "Cache: [%s] -> %p\n", baseName, retVal); + fprintf(stderr, "Cache: [%s] -> %p\n", baseName, (void*) retVal); #endif return retVal; } @@ -382,8 +384,8 @@ static UDataMemory *udata_cacheDataItem(const char *path, UDataMemory *item, UEr umtx_unlock(NULL); #ifdef UDATA_DEBUG - fprintf(stderr, "Cache: [%s] <<< %p : %s. vFunc=%p\n", newElement->name, - newElement->item, u_errorName(subErr), newElement->item->vFuncs); + fprintf(stderr, "Cache: [%s] <<< %p : %s. vFunc=%p\n", newElement->name, + (void*) newElement->item, u_errorName(subErr), (void*) newElement->item->vFuncs); #endif if (subErr == U_USING_DEFAULT_WARNING || U_FAILURE(subErr)) { @@ -434,13 +436,13 @@ class UDataPathIterator /** * @param iter The iterator to be initialized. Its current state does not matter. - * @param inPath The full pathname to be iterated over. If NULL, defaults to U_ICUDATA_NAME - * @param pkg Package which is being searched for, ex "icudt28l". Will ignore leaf directories such as /icudt28l - * @param item Item to be searched for. Can include full path, such as /a/b/foo.dat + * @param inPath The full pathname to be iterated over. If NULL, defaults to U_ICUDATA_NAME + * @param pkg Package which is being searched for, ex "icudt28l". Will ignore leaf directories such as /icudt28l + * @param item Item to be searched for. Can include full path, such as /a/b/foo.dat * @param inSuffix Optional item suffix, if not-null (ex. ".dat") then 'path' can contain 'item' explicitly. - * Ex: 'stuff.dat' would be found in '/a/foo:/tmp/stuff.dat:/bar/baz' as item #2. + * Ex: 'stuff.dat' would be found in '/a/foo:/tmp/stuff.dat:/bar/baz' as item #2. * '/blarg/stuff.dat' would also be found. - * Note: inSuffix may also be the 'item' being searched for as well, (ex: "ibm-5348_P100-1997.cnv"), in which case + * Note: inSuffix may also be the 'item' being searched for as well, (ex: "ibm-5348_P100-1997.cnv"), in which case * the 'item' parameter is often the same as pkg. (Though sometimes might have a tree part as well, ex: "icudt62l-curr"). */ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, @@ -477,7 +479,7 @@ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, nextPath = itemPath.data(); } #ifdef UDATA_DEBUG - fprintf(stderr, "SUFFIX=%s [%p]\n", inSuffix, inSuffix); + fprintf(stderr, "SUFFIX=%s [%p]\n", inSuffix, (void*) inSuffix); #endif /** Suffix **/ @@ -492,12 +494,11 @@ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, /* pathBuffer will hold the output path strings returned by this iterator */ #ifdef UDATA_DEBUG - fprintf(stderr, "%p: init %s -> [path=%s], [base=%s], [suff=%s], [itempath=%s], [nextpath=%s], [checklast4=%s]\n", - iter, + fprintf(stderr, "0: init %s -> [path=%s], [base=%s], [suff=%s], [itempath=%s], [nextpath=%s], [checklast4=%s]\n", item, path, basename, - suffix, + suffix.data(), itemPath.data(), nextPath, checkLastFour?"TRUE":"false"); @@ -507,8 +508,8 @@ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, /** * Get the next path on the list. * - * @param iter The Iter to be used - * @param len If set, pointer to the length of the returned path, for convenience. + * @param iter The Iter to be used + * @param len If set, pointer to the length of the returned path, for convenience. * @return Pointer to the next path segment, or NULL if there are no more. */ const char *UDataPathIterator::next(UErrorCode *pErrorCode) @@ -536,7 +537,7 @@ const char *UDataPathIterator::next(UErrorCode *pErrorCode) nextPath = uprv_strchr(currentPath, U_PATH_SEP_CHAR); if(nextPath == NULL) { /* segment: entire path */ - pathLen = (int32_t)uprv_strlen(currentPath); + pathLen = (int32_t)uprv_strlen(currentPath); } else { /* segment: until next segment */ pathLen = (int32_t)(nextPath - currentPath); @@ -552,8 +553,8 @@ const char *UDataPathIterator::next(UErrorCode *pErrorCode) #ifdef UDATA_DEBUG fprintf(stderr, "rest of path (IDD) = %s\n", currentPath); fprintf(stderr, " "); - { - uint32_t qqq; + { + int32_t qqq; for(qqq=0;qqq=4) && uprv_strncmp(pathBuffer.data() +(pathLen-4), suffix.data(), 4)==0 && /* suffix matches */ uprv_strncmp(findBasename(pathBuffer.data()), basename, basenameLen)==0 && /* base matches */ uprv_strlen(pathBasename)==(basenameLen+4)) { /* base+suffix = full len */ #ifdef UDATA_DEBUG - fprintf(stderr, "Have %s file on the path: %s\n", suffix, pathBuffer.data()); + fprintf(stderr, "Have %s file on the path: %s\n", suffix.data(), pathBuffer.data()); #endif /* do nothing */ } - else + else { /* regular dir path */ if(pathBuffer[pathLen-1] != U_FILE_SEP_CHAR) { if((pathLen>=4) && @@ -640,7 +641,8 @@ U_NAMESPACE_END * our common data. * * * *----------------------------------------------------------------------*/ -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) +// When using the Windows system data, we expect only a single data file. extern "C" const DataHeader U_DATA_API U_ICUDATA_ENTRY_POINT; #endif @@ -679,7 +681,7 @@ openCommonData(const char *path, /* Path from OpenChoice? */ UDataMemory_init(&tData); - /* ??????? TODO revisit this */ + /* ??????? TODO revisit this */ if (commonDataIndex >= 0) { /* "mini-cache" for common ICU data */ if(commonDataIndex >= UPRV_LENGTHOF(gCommonICUDataArray)) { @@ -690,7 +692,8 @@ openCommonData(const char *path, /* Path from OpenChoice? */ if(gCommonICUDataArray[commonDataIndex] != NULL) { return gCommonICUDataArray[commonDataIndex]; } -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) +// When using the Windows system data, we expect only a single data file. int32_t i; for(i = 0; i < commonDataIndex; ++i) { if(gCommonICUDataArray[i]->pHeader == &U_ICUDATA_ENTRY_POINT) { @@ -714,7 +717,8 @@ openCommonData(const char *path, /* Path from OpenChoice? */ setCommonICUDataPointer(uprv_getICUData_conversion(), FALSE, pErrorCode); } */ -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) +// When using the Windows system data, we expect only a single data file. setCommonICUDataPointer(&U_ICUDATA_ENTRY_POINT, FALSE, pErrorCode); { Mutex lock; @@ -831,7 +835,7 @@ static UBool extendICUData(UErrorCode *pErr) * Use a specific mutex to avoid nested locks of the global mutex. */ #if MAP_IMPLEMENTATION==MAP_STDIO - static UMutex extendICUDataMutex = U_MUTEX_INITIALIZER; + static UMutex extendICUDataMutex; umtx_lock(&extendICUDataMutex); #endif if(!umtx_loadAcquire(gHaveTriedToLoadCommonData)) { @@ -979,9 +983,9 @@ checkDataItem } /** - * @return 0 if not loaded, 1 if loaded or err + * @return 0 if not loaded, 1 if loaded or err */ -static UDataMemory *doLoadFromIndividualFiles(const char *pkgName, +static UDataMemory *doLoadFromIndividualFiles(const char *pkgName, const char *dataPath, const char *tocEntryPathSuffix, /* following arguments are the same as doOpenChoice itself */ const char *path, const char *type, const char *name, @@ -1037,9 +1041,9 @@ static UDataMemory *doLoadFromIndividualFiles(const char *pkgName, } /** - * @return 0 if not loaded, 1 if loaded or err + * @return 0 if not loaded, 1 if loaded or err */ -static UDataMemory *doLoadFromCommonData(UBool isICUData, const char * /*pkgName*/, +static UDataMemory *doLoadFromCommonData(UBool isICUData, const char * /*pkgName*/, const char * /*dataPath*/, const char * /*tocEntryPathSuffix*/, const char *tocEntryName, /* following arguments are the same as doOpenChoice itself */ const char *path, const char *type, const char *name, @@ -1070,13 +1074,13 @@ static UDataMemory *doLoadFromCommonData(UBool isICUData, const char * /*pkgName /* look up the data piece in the common data */ pHeader=pCommonData->vFuncs->Lookup(pCommonData, tocEntryName, &length, subErrorCode); #ifdef UDATA_DEBUG - fprintf(stderr, "%s: pHeader=%p - %s\n", tocEntryName, pHeader, u_errorName(*subErrorCode)); + fprintf(stderr, "%s: pHeader=%p - %s\n", tocEntryName, (void*) pHeader, u_errorName(*subErrorCode)); #endif if(pHeader!=NULL) { pEntryData = checkDataItem(pHeader, isAcceptable, context, type, name, subErrorCode, pErrorCode); #ifdef UDATA_DEBUG - fprintf(stderr, "pEntryData=%p\n", pEntryData); + fprintf(stderr, "pEntryData=%p\n", (void*) pEntryData); #endif if (U_FAILURE(*pErrorCode)) { return NULL; @@ -1168,11 +1172,14 @@ doOpenChoice(const char *path, const char *type, const char *name, UBool isICUData = FALSE; + FileTracer::traceOpen(path, type, name); + + /* Is this path ICU data? */ if(path == NULL || !strcmp(path, U_ICUDATA_ALIAS) || /* "ICUDATA" */ !uprv_strncmp(path, U_ICUDATA_NAME U_TREE_SEPARATOR_STRING, /* "icudt26e-" */ - uprv_strlen(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING)) || + uprv_strlen(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING)) || !uprv_strncmp(path, U_ICUDATA_ALIAS U_TREE_SEPARATOR_STRING, /* "ICUDATA-" */ uprv_strlen(U_ICUDATA_ALIAS U_TREE_SEPARATOR_STRING))) { isICUData = TRUE; @@ -1219,7 +1226,7 @@ doOpenChoice(const char *path, const char *type, const char *name, } } else { treeChar = uprv_strchr(path, U_TREE_SEPARATOR); - if(treeChar) { + if(treeChar) { treeName.append(treeChar+1, *pErrorCode); /* following '-' */ if(isICUData) { pkgName.append(U_ICUDATA_NAME, *pErrorCode); @@ -1247,7 +1254,7 @@ doOpenChoice(const char *path, const char *type, const char *name, fprintf(stderr, " P=%s T=%s\n", pkgName.data(), treeName.data()); #endif - /* setting up the entry name and file name + /* setting up the entry name and file name * Make up a full name by appending the type to the supplied * name, assuming that a type was supplied. */ @@ -1276,12 +1283,12 @@ doOpenChoice(const char *path, const char *type, const char *name, fprintf(stderr, " tocEntryPath = %s\n", tocEntryName.data()); #endif -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) if(path == NULL) { path = COMMON_DATA_NAME; /* "icudt26e" */ } #else - // Windows UWP expects only a single data file. + // When using the Windows system data, we expects only a single data file. path = COMMON_DATA_NAME; /* "icudt26e" */ #endif @@ -1314,7 +1321,7 @@ doOpenChoice(const char *path, const char *type, const char *name, fprintf(stderr, "Trying packages (UDATA_PACKAGES_FIRST)\n"); #endif /* #2 */ - retVal = doLoadFromCommonData(isICUData, + retVal = doLoadFromCommonData(isICUData, pkgName.data(), dataPath, tocEntryPathSuffix, tocEntryName.data(), path, type, name, isAcceptable, context, &subErrorCode, pErrorCode); if((retVal != NULL) || U_FAILURE(*pErrorCode)) { @@ -1339,7 +1346,7 @@ doOpenChoice(const char *path, const char *type, const char *name, } /**** COMMON PACKAGE */ - if((gDataFileAccess==UDATA_ONLY_PACKAGES) || + if((gDataFileAccess==UDATA_ONLY_PACKAGES) || (gDataFileAccess==UDATA_FILES_FIRST)) { #ifdef UDATA_DEBUG fprintf(stderr, "Trying packages (UDATA_ONLY_PACKAGES || UDATA_FILES_FIRST)\n"); @@ -1351,10 +1358,10 @@ doOpenChoice(const char *path, const char *type, const char *name, return retVal; } } - + /* Load from DLL. If we haven't attempted package load, we also haven't had any chance to try a DLL (static or setCommonData/etc) load. - If we ever have a "UDATA_ONLY_FILES", add it to the or list here. */ + If we ever have a "UDATA_ONLY_FILES", add it to the or list here. */ if(gDataFileAccess==UDATA_NO_FILES) { #ifdef UDATA_DEBUG fprintf(stderr, "Trying common data (UDATA_NO_FILES)\n"); diff --git a/deps/icu-small/source/common/uelement.h b/deps/icu-small/source/common/uelement.h index 9d45f09fb87f65..05f36a098253dd 100644 --- a/deps/icu-small/source/common/uelement.h +++ b/deps/icu-small/source/common/uelement.h @@ -74,7 +74,7 @@ U_CDECL_END * @param key2 The string for comparison * @return true if key1 and key2 are equal, return false otherwise. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareUnicodeString(const UElement key1, const UElement key2); /** @@ -85,7 +85,7 @@ uhash_compareUnicodeString(const UElement key1, const UElement key2); * @param key2 The string for comparison * @return true if key1 and key2 are equal, return false otherwise. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2); #endif /* __UELEMENT_H__ */ diff --git a/deps/icu-small/source/common/uenum.cpp b/deps/icu-small/source/common/uenum.cpp index f75cfb7ac3ff6a..11d895ebcd7463 100644 --- a/deps/icu-small/source/common/uenum.cpp +++ b/deps/icu-small/source/common/uenum.cpp @@ -51,7 +51,7 @@ static void* _getBuffer(UEnumeration* en, int32_t capacity) { } ((_UEnumBuffer*) en->baseContext)->len = capacity; } - + return (void*) & ((_UEnumBuffer*) en->baseContext)->data; } diff --git a/deps/icu-small/source/common/uenumimp.h b/deps/icu-small/source/common/uenumimp.h index 93854406403b39..9c9df75ae0497a 100644 --- a/deps/icu-small/source/common/uenumimp.h +++ b/deps/icu-small/source/common/uenumimp.h @@ -23,14 +23,14 @@ U_CDECL_BEGIN -/** - * following are the type declarations for +/** + * following are the type declarations for * implementations of APIs. If any of these * functions are NULL, U_UNSUPPORTED_ERROR * is returned. If close is NULL, the enumeration * object is going to be released. * Initial error checking is done in the body - * of API function, so the implementations + * of API function, so the implementations * need not to check the initial error condition. */ @@ -63,13 +63,13 @@ UEnumCount(UEnumeration *en, UErrorCode *status); * This function returns the next element as a UChar *, * or NULL after all elements haven been enumerated. * - * @param en enumeration + * @param en enumeration * @param resultLength pointer to result length * @param status pointer to UErrorCode variable * @return next element as UChar *, * or NULL after all elements haven been enumerated */ -typedef const UChar* U_CALLCONV +typedef const UChar* U_CALLCONV UEnumUNext(UEnumeration* en, int32_t* resultLength, UErrorCode* status); @@ -80,13 +80,13 @@ UEnumUNext(UEnumeration* en, * This function returns the next element as a char *, * or NULL after all elements haven been enumerated. * - * @param en enumeration + * @param en enumeration * @param resultLength pointer to result length * @param status pointer to UErrorCode variable * @return next element as char *, * or NULL after all elements haven been enumerated */ -typedef const char* U_CALLCONV +typedef const char* U_CALLCONV UEnumNext(UEnumeration* en, int32_t* resultLength, UErrorCode* status); @@ -94,14 +94,14 @@ UEnumNext(UEnumeration* en, /** * Function type declaration for uenum_reset(). * - * This function should reset the enumeration + * This function should reset the enumeration * object * - * @param en enumeration + * @param en enumeration * @param status pointer to UErrorCode variable */ -typedef void U_CALLCONV -UEnumReset(UEnumeration* en, +typedef void U_CALLCONV +UEnumReset(UEnumeration* en, UErrorCode* status); @@ -112,8 +112,8 @@ struct UEnumeration { /* context. Use it for what you need */ void *context; - /** - * these are functions that will + /** + * these are functions that will * be used for APIs */ /* called from uenum_close */ diff --git a/deps/icu-small/source/common/uhash.cpp b/deps/icu-small/source/common/uhash.cpp index 79241a282913ed..86311ceb0b25d1 100644 --- a/deps/icu-small/source/common/uhash.cpp +++ b/deps/icu-small/source/common/uhash.cpp @@ -119,13 +119,14 @@ static const float RESIZE_POLICY_RATIO_TABLE[6] = { /* This macro expects a UHashTok.pointer as its keypointer and valuepointer parameters */ -#define HASH_DELETE_KEY_VALUE(hash, keypointer, valuepointer) \ - if (hash->keyDeleter != NULL && keypointer != NULL) { \ - (*hash->keyDeleter)(keypointer); \ - } \ - if (hash->valueDeleter != NULL && valuepointer != NULL) { \ - (*hash->valueDeleter)(valuepointer); \ - } +#define HASH_DELETE_KEY_VALUE(hash, keypointer, valuepointer) UPRV_BLOCK_MACRO_BEGIN { \ + if (hash->keyDeleter != NULL && keypointer != NULL) { \ + (*hash->keyDeleter)(keypointer); \ + } \ + if (hash->valueDeleter != NULL && valuepointer != NULL) { \ + (*hash->valueDeleter)(valuepointer); \ + } \ +} UPRV_BLOCK_MACRO_END /* * Constants for hinting whether a key or value is an integer diff --git a/deps/icu-small/source/common/uidna.cpp b/deps/icu-small/source/common/uidna.cpp index 6d56fcb8f517af..ac2f9c3c8cd963 100644 --- a/deps/icu-small/source/common/uidna.cpp +++ b/deps/icu-small/source/common/uidna.cpp @@ -47,7 +47,7 @@ static const UChar ACE_PREFIX[] ={ 0x0078,0x006E,0x002d,0x002d } ; #define CAPITAL_A 0x0041 #define CAPITAL_Z 0x005A -inline static UChar +inline static UChar toASCIILower(UChar ch){ if(CAPITAL_A <= ch && ch <= CAPITAL_Z){ return ch + LOWER_CASE_DELTA; @@ -55,27 +55,25 @@ toASCIILower(UChar ch){ return ch; } -inline static UBool +inline static UBool startsWithPrefix(const UChar* src , int32_t srcLength){ - UBool startsWithPrefix = TRUE; - if(srcLength < ACE_PREFIX_LENGTH){ return FALSE; } for(int8_t i=0; i< ACE_PREFIX_LENGTH; i++){ if(toASCIILower(src[i]) != ACE_PREFIX[i]){ - startsWithPrefix = FALSE; + return FALSE; } } - return startsWithPrefix; + return TRUE; } inline static int32_t -compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len, +compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len, const UChar* s2, int32_t s2Len){ - + int32_t minLength; int32_t lengthResult; @@ -103,10 +101,10 @@ compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len, if(i == minLength) { return lengthResult; } - + c1 = s1[i]; c2 = s2[i]; - + /* Case-insensitive comparison */ if(c1!=c2) { rc=(int32_t)toASCIILower(c1)-(int32_t)toASCIILower(c2); @@ -121,9 +119,9 @@ compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len, /** - * Ascertain if the given code point is a label separator as + * Ascertain if the given code point is a label separator as * defined by the IDNA RFC - * + * * @param ch The code point to be ascertained * @return true if the char is a label separator * @stable ICU 2.8 @@ -136,12 +134,12 @@ static inline UBool isLabelSeparator(UChar ch){ case 0xFF61: return TRUE; default: - return FALSE; + return FALSE; } } // returns the length of the label excluding the separator -// if *limit == separator then the length returned does not include +// if *limit == separator then the length returned does not include // the separtor. static inline int32_t getNextSeparator(UChar *src, int32_t srcLength, @@ -157,7 +155,7 @@ getNextSeparator(UChar *src, int32_t srcLength, if(isLabelSeparator(src[i])){ *limit = src + (i+1); // go past the delimiter return i; - + } } }else{ @@ -182,7 +180,7 @@ static inline UBool isLDHChar(UChar ch){ return FALSE; } //[\\u002D \\u0030-\\u0039 \\u0041-\\u005A \\u0061-\\u007A] - if( (ch==0x002D) || + if( (ch==0x002D) || (0x0030 <= ch && ch <= 0x0039) || (0x0041 <= ch && ch <= 0x005A) || (0x0061 <= ch && ch <= 0x007A) @@ -192,8 +190,8 @@ static inline UBool isLDHChar(UChar ch){ return FALSE; } -static int32_t -_internal_toASCII(const UChar* src, int32_t srcLength, +static int32_t +_internal_toASCII(const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UStringPrepProfile* nameprep, @@ -205,18 +203,18 @@ _internal_toASCII(const UChar* src, int32_t srcLength, UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE]; //initialize pointers to stack buffers UChar *b1 = b1Stack, *b2 = b2Stack; - int32_t b1Len=0, b2Len, - b1Capacity = MAX_LABEL_BUFFER_SIZE, + int32_t b1Len=0, b2Len, + b1Capacity = MAX_LABEL_BUFFER_SIZE, b2Capacity = MAX_LABEL_BUFFER_SIZE , reqLength=0; int32_t namePrepOptions = ((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0; UBool* caseFlags = NULL; - + // the source contains all ascii codepoints UBool srcIsASCII = TRUE; // assume the source contains all LDH codepoints - UBool srcIsLDH = TRUE; + UBool srcIsLDH = TRUE; int32_t j=0; @@ -224,11 +222,11 @@ _internal_toASCII(const UChar* src, int32_t srcLength, UBool useSTD3ASCIIRules = (UBool)((options & UIDNA_USE_STD3_RULES) != 0); int32_t failPos = -1; - + if(srcLength == -1){ srcLength = u_strlen(src); } - + if(srcLength > b1Capacity){ b1 = (UChar*) uprv_malloc(srcLength * U_SIZEOF_UCHAR); if(b1==NULL){ @@ -238,18 +236,18 @@ _internal_toASCII(const UChar* src, int32_t srcLength, b1Capacity = srcLength; } - // step 1 + // step 1 for( j=0;j 0x7F){ srcIsASCII = FALSE; } b1[b1Len++] = src[j]; } - + // step 2 is performed only if the source contains non ASCII if(srcIsASCII == FALSE){ - - // step 2 + + // step 2 b1Len = usprep_prepare(nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, status); if(*status == U_BUFFER_OVERFLOW_ERROR){ @@ -265,7 +263,7 @@ _internal_toASCII(const UChar* src, int32_t srcLength, } *status = U_ZERO_ERROR; // reset error - + b1Len = usprep_prepare(nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, status); } } @@ -281,7 +279,7 @@ _internal_toASCII(const UChar* src, int32_t srcLength, // for step 3 & 4 srcIsASCII = TRUE; for( j=0;j 0x7F){ srcIsASCII = FALSE; }else if(isLDHChar(b1[j])==FALSE){ // if the char is in ASCII range verify that it is an LDH character @@ -305,7 +303,7 @@ _internal_toASCII(const UChar* src, int32_t srcLength, // failPos is always set the index of failure uprv_syntaxError(b1,failPos, b1Len,parseError); }else if(b1[0] == HYPHEN){ - // fail position is 0 + // fail position is 0 uprv_syntaxError(b1,0,b1Len,parseError); }else{ // the last index in the source is always length-1 @@ -340,14 +338,14 @@ _internal_toASCII(const UChar* src, int32_t srcLength, if(*status == U_BUFFER_OVERFLOW_ERROR){ // redo processing of string /* we do not have enough room so grow the buffer*/ - b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR); + b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR); if(b2 == NULL){ *status = U_MEMORY_ALLOCATION_ERROR; goto CLEANUP; } *status = U_ZERO_ERROR; // reset error - + b2Len = u_strToPunycode(b1,b1Len,b2,b2Len,caseFlags, status); } //error bail out @@ -369,7 +367,7 @@ _internal_toASCII(const UChar* src, int32_t srcLength, u_memcpy(dest+ACE_PREFIX_LENGTH, b2, b2Len); }else{ - *status = U_IDNA_ACE_PREFIX_ERROR; + *status = U_IDNA_ACE_PREFIX_ERROR; //position of failure is 0 uprv_syntaxError(b1,0,b1Len,parseError); goto CLEANUP; @@ -388,7 +386,7 @@ _internal_toASCII(const UChar* src, int32_t srcLength, uprv_free(b2); } uprv_free(caseFlags); - + return u_terminateUChars(dest, destCapacity, reqLength, status); } @@ -403,7 +401,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, //get the options //UBool useSTD3ASCIIRules = (UBool)((options & UIDNA_USE_STD3_RULES) != 0); - int32_t namePrepOptions = ((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0; + int32_t namePrepOptions = ((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0; // TODO Revisit buffer handling. The label should not be over 63 ASCII characters. ICU4J may need to be updated too. UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE], b3Stack[MAX_LABEL_BUFFER_SIZE]; @@ -411,7 +409,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, //initialize pointers to stack buffers UChar *b1 = b1Stack, *b2 = b2Stack, *b1Prime=NULL, *b3=b3Stack; int32_t b1Len = 0, b2Len, b1PrimeLen, b3Len, - b1Capacity = MAX_LABEL_BUFFER_SIZE, + b1Capacity = MAX_LABEL_BUFFER_SIZE, b2Capacity = MAX_LABEL_BUFFER_SIZE, b3Capacity = MAX_LABEL_BUFFER_SIZE, reqLength=0; @@ -422,7 +420,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, /*UBool srcIsLDH = TRUE; int32_t failPos =0;*/ - // step 1: find out if all the codepoints in src are ASCII + // step 1: find out if all the codepoints in src are ASCII if(srcLength==-1){ srcLength = 0; for(;src[srcLength]!=0;){ @@ -441,6 +439,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, for(int32_t j=0; j 0x7f){ srcIsASCII = FALSE; + break; }/*else if(isLDHChar(src[j])==FALSE){ // here we do not assemble surrogates // since we know that LDH code points @@ -452,7 +451,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, }else{ return 0; } - + if(srcIsASCII == FALSE){ // step 2: process the string b1Len = usprep_prepare(nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, status); @@ -466,7 +465,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, } *status = U_ZERO_ERROR; // reset error - + b1Len = usprep_prepare(nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, status); } //bail out on error @@ -480,7 +479,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, b1Len = srcLength; } - // The RFC states that + // The RFC states that // // ToUnicode never fails. If any step fails, then the original input // is returned immediately in that step. @@ -559,7 +558,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, // failPos is always set the index of failure uprv_syntaxError(src,failPos, srcLength,parseError); }else if(src[0] == HYPHEN){ - // fail position is 0 + // fail position is 0 uprv_syntaxError(src,0,srcLength,parseError); }else{ // the last index in the source is always length-1 @@ -588,7 +587,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, } uprv_free(caseFlags); - // The RFC states that + // The RFC states that // // ToUnicode never fails. If any step fails, then the original input // is returned immediately in that step. @@ -609,12 +608,12 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, } U_CAPI int32_t U_EXPORT2 -uidna_toASCII(const UChar* src, int32_t srcLength, +uidna_toASCII(const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UParseError* parseError, UErrorCode* status){ - + if(status == NULL || U_FAILURE(*status)){ return 0; } @@ -624,16 +623,16 @@ uidna_toASCII(const UChar* src, int32_t srcLength, } UStringPrepProfile* nameprep = usprep_openByType(USPREP_RFC3491_NAMEPREP, status); - + if(U_FAILURE(*status)){ return -1; } - + int32_t retLen = _internal_toASCII(src, srcLength, dest, destCapacity, options, nameprep, parseError, status); - + /* close the profile*/ usprep_close(nameprep); - + return retLen; } @@ -650,18 +649,18 @@ uidna_toUnicode(const UChar* src, int32_t srcLength, if( (src==NULL) || (srcLength < -1) || (destCapacity<0) || (!dest && destCapacity > 0)){ *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; - } + } UStringPrepProfile* nameprep = usprep_openByType(USPREP_RFC3491_NAMEPREP, status); - + if(U_FAILURE(*status)){ return -1; } - + int32_t retLen = _internal_toUnicode(src, srcLength, dest, destCapacity, options, nameprep, parseError, status); usprep_close(nameprep); - + return retLen; } @@ -684,12 +683,12 @@ uidna_IDNToASCII( const UChar *src, int32_t srcLength, int32_t reqLength = 0; UStringPrepProfile* nameprep = usprep_openByType(USPREP_RFC3491_NAMEPREP, status); - + if(U_FAILURE(*status)){ return 0; } - //initialize pointers + //initialize pointers UChar *delimiter = (UChar*)src; UChar *labelStart = (UChar*)src; UChar *currentDest = (UChar*) dest; @@ -704,24 +703,24 @@ uidna_IDNToASCII( const UChar *src, int32_t srcLength, labelLen = getNextSeparator(labelStart,remainingLen, &delimiter,&done); labelReqLength = 0; if(!(labelLen==0 && done)){// make sure this is not a root label separator. - - labelReqLength = _internal_toASCII( labelStart, labelLen, - currentDest, remainingDestCapacity, - options, nameprep, + + labelReqLength = _internal_toASCII( labelStart, labelLen, + currentDest, remainingDestCapacity, + options, nameprep, parseError, status); - + if(*status == U_BUFFER_OVERFLOW_ERROR){ - + *status = U_ZERO_ERROR; // reset error remainingDestCapacity = 0; } } - + if(U_FAILURE(*status)){ break; } - + reqLength +=labelReqLength; // adjust the destination pointer if(labelReqLength < remainingDestCapacity){ @@ -755,7 +754,7 @@ uidna_IDNToASCII( const UChar *src, int32_t srcLength, } usprep_close(nameprep); - + return u_terminateUChars(dest, destCapacity, reqLength, status); } @@ -765,7 +764,7 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, int32_t options, UParseError* parseError, UErrorCode* status){ - + if(status == NULL || U_FAILURE(*status)){ return 0; } @@ -777,7 +776,7 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, int32_t reqLength = 0; UStringPrepProfile* nameprep = usprep_openByType(USPREP_RFC3491_NAMEPREP, status); - + if(U_FAILURE(*status)){ return 0; } @@ -794,21 +793,21 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, for(;;){ labelLen = getNextSeparator(labelStart,remainingLen, &delimiter,&done); - - // The RFC states that + + // The RFC states that // // ToUnicode never fails. If any step fails, then the original input // is returned immediately in that step. // // _internal_toUnicode will copy the label. - /*if(labelLen==0 && done==FALSE){ + /*if(labelLen==0 && done==FALSE){ *status = U_IDNA_ZERO_LENGTH_LABEL_ERROR; break; }*/ - - labelReqLength = _internal_toUnicode(labelStart, labelLen, - currentDest, remainingDestCapacity, - options, nameprep, + + labelReqLength = _internal_toUnicode(labelStart, labelLen, + currentDest, remainingDestCapacity, + options, nameprep, parseError, status); if(*status == U_BUFFER_OVERFLOW_ERROR){ @@ -819,7 +818,7 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, if(U_FAILURE(*status)){ break; } - + reqLength +=labelReqLength; // adjust the destination pointer if(labelReqLength < remainingDestCapacity){ @@ -854,7 +853,7 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, } usprep_close(nameprep); - + return u_terminateUChars(dest, destCapacity, reqLength, status); } @@ -872,7 +871,7 @@ uidna_compare( const UChar *s1, int32_t length1, UChar *b1 = b1Stack, *b2 = b2Stack; int32_t b1Len, b2Len, b1Capacity = MAX_IDN_BUFFER_SIZE, b2Capacity = MAX_IDN_BUFFER_SIZE; int32_t result=-1; - + UParseError parseError; b1Len = uidna_IDNToASCII(s1, length1, b1, b1Capacity, options, &parseError, status); @@ -885,9 +884,9 @@ uidna_compare( const UChar *s1, int32_t length1, } *status = U_ZERO_ERROR; // reset error - + b1Len = uidna_IDNToASCII(s1,length1,b1,b1Len, options, &parseError, status); - + } b2Len = uidna_IDNToASCII(s2,length2, b2,b2Capacity, options, &parseError, status); @@ -900,9 +899,9 @@ uidna_compare( const UChar *s1, int32_t length1, } *status = U_ZERO_ERROR; // reset error - + b2Len = uidna_IDNToASCII(s2, length2, b2, b2Len, options, &parseError, status); - + } // when toASCII is applied all label separators are replaced with FULL_STOP result = compareCaseInsensitiveASCII(b1,b1Len,b2,b2Len); diff --git a/deps/icu-small/source/common/uinvchar.cpp b/deps/icu-small/source/common/uinvchar.cpp index 2e0f42d9274d2a..05bcf10df48921 100644 --- a/deps/icu-small/source/common/uinvchar.cpp +++ b/deps/icu-small/source/common/uinvchar.cpp @@ -207,7 +207,8 @@ u_UCharsToChars(const UChar *us, char *cs, int32_t length) { while(length>0) { u=*us++; if(!UCHAR_IS_INVARIANT(u)) { - UPRV_UNREACHABLE; /* Variant characters were used. These are not portable in ICU. */ + U_ASSERT(FALSE); /* Variant characters were used. These are not portable in ICU. */ + u=0; } *cs++=(char)UCHAR_TO_CHAR(u); --length; @@ -445,6 +446,13 @@ uprv_copyEbcdic(const UDataSwapper *ds, return length; } +U_CFUNC UBool +uprv_isEbcdicAtSign(char c) { + static const uint8_t ebcdicAtSigns[] = { + 0x7C, 0x44, 0x66, 0x80, 0xAC, 0xAE, 0xAF, 0xB5, 0xEC, 0xEF, 0x00 }; + return c != 0 && uprv_strchr((const char *)ebcdicAtSigns, c) != nullptr; +} + /* compare invariant strings; variant characters compare less than others and unlike each other */ U_CFUNC int32_t uprv_compareInvAscii(const UDataSwapper *ds, @@ -561,6 +569,11 @@ uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2) { } } +U_CAPI char U_EXPORT2 +uprv_ebcdicToAscii(char c) { + return (char)asciiFromEbcdic[(uint8_t)c]; +} + U_CAPI char U_EXPORT2 uprv_ebcdicToLowercaseAscii(char c) { return (char)lowercaseAsciiFromEbcdic[(uint8_t)c]; @@ -571,7 +584,7 @@ uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n) { uint8_t *orig_dst = dst; - if(n==-1) { + if(n==-1) { n = static_cast(uprv_strlen((const char*)src)+1); /* copy NUL */ } /* copy non-null */ @@ -592,7 +605,7 @@ uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n) { uint8_t *orig_dst = dst; - if(n==-1) { + if(n==-1) { n = static_cast(uprv_strlen((const char*)src)+1); /* copy NUL */ } /* copy non-null */ @@ -611,3 +624,4 @@ uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n) } return orig_dst; } + diff --git a/deps/icu-small/source/common/uinvchar.h b/deps/icu-small/source/common/uinvchar.h index 56dddfa8fde9bb..a43cfcd98286fe 100644 --- a/deps/icu-small/source/common/uinvchar.h +++ b/deps/icu-small/source/common/uinvchar.h @@ -68,6 +68,75 @@ uprv_isInvariantUString(const UChar *s, int32_t length); # error Unknown charset family! #endif +#ifdef __cplusplus + +U_NAMESPACE_BEGIN + +/** + * Like U_UPPER_ORDINAL(x) but with validation. + * Returns 0..25 for A..Z else a value outside 0..25. + */ +inline int32_t uprv_upperOrdinal(int32_t c) { +#if U_CHARSET_FAMILY==U_ASCII_FAMILY + return c - 'A'; +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY + // EBCDIC: A-Z (26 letters) is split into three ranges A-I (9 letters), J-R (9), S-Z (8). + // https://en.wikipedia.org/wiki/EBCDIC_037#Codepage_layout + if (c <= 'I') { return c - 'A'; } // A-I --> 0-8 + if (c < 'J') { return -1; } + if (c <= 'R') { return c - 'J' + 9; } // J-R --> 9..17 + if (c < 'S') { return -1; } + return c - 'S' + 18; // S-Z --> 18..25 +#else +# error Unknown charset family! +#endif +} + +// Like U_UPPER_ORDINAL(x) but for lowercase and with validation. +// Returns 0..25 for a..z else a value outside 0..25. +inline int32_t uprv_lowerOrdinal(int32_t c) { +#if U_CHARSET_FAMILY==U_ASCII_FAMILY + return c - 'a'; +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY + // EBCDIC: a-z (26 letters) is split into three ranges a-i (9 letters), j-r (9), s-z (8). + // https://en.wikipedia.org/wiki/EBCDIC_037#Codepage_layout + if (c <= 'i') { return c - 'a'; } // a-i --> 0-8 + if (c < 'j') { return -1; } + if (c <= 'r') { return c - 'j' + 9; } // j-r --> 9..17 + if (c < 's') { return -1; } + return c - 's' + 18; // s-z --> 18..25 +#else +# error Unknown charset family! +#endif +} + +U_NAMESPACE_END + +#endif + +/** + * Returns true if c == '@' is possible. + * The @ sign is variant, and the @ sign used on one + * EBCDIC machine won't be compiled the same way on other EBCDIC based machines. + * @internal + */ +U_CFUNC UBool +uprv_isEbcdicAtSign(char c); + +/** + * \def uprv_isAtSign + * Returns true if c == '@' is possible. + * For ASCII, checks for exactly '@'. For EBCDIC, calls uprv_isEbcdicAtSign(). + * @internal + */ +#if U_CHARSET_FAMILY==U_ASCII_FAMILY +# define uprv_isAtSign(c) ((c)=='@') +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY +# define uprv_isAtSign(c) uprv_isEbcdicAtSign(c) +#else +# error Unknown charset family! +#endif + /** * Compare two EBCDIC invariant-character strings in ASCII order. * @internal @@ -88,6 +157,26 @@ uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2); # error Unknown charset family! #endif +/** + * Converts an EBCDIC invariant character to ASCII. + * @internal + */ +U_INTERNAL char U_EXPORT2 +uprv_ebcdicToAscii(char c); + +/** + * \def uprv_invCharToAscii + * Converts an invariant character to ASCII. + * @internal + */ +#if U_CHARSET_FAMILY==U_ASCII_FAMILY +# define uprv_invCharToAscii(c) (c) +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY +# define uprv_invCharToAscii(c) uprv_ebcdicToAscii(c) +#else +# error Unknown charset family! +#endif + /** * Converts an EBCDIC invariant character to lowercase ASCII. * @internal diff --git a/deps/icu-small/source/common/ulist.cpp b/deps/icu-small/source/common/ulist.cpp index 07cbcc8303ac91..c5180431c31b75 100644 --- a/deps/icu-small/source/common/ulist.cpp +++ b/deps/icu-small/source/common/ulist.cpp @@ -15,10 +15,10 @@ typedef struct UListNode UListNode; struct UListNode { void *data; - + UListNode *next; UListNode *previous; - + /* When data is created with uprv_malloc, needs to be freed during deleteList function. */ UBool forceDelete; }; @@ -27,7 +27,7 @@ struct UList { UListNode *curr; UListNode *head; UListNode *tail; - + int32_t size; }; @@ -35,22 +35,22 @@ static void ulist_addFirstItem(UList *list, UListNode *newItem); U_CAPI UList *U_EXPORT2 ulist_createEmptyList(UErrorCode *status) { UList *newList = NULL; - + if (U_FAILURE(*status)) { return NULL; } - + newList = (UList *)uprv_malloc(sizeof(UList)); if (newList == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return NULL; } - + newList->curr = NULL; newList->head = NULL; newList->tail = NULL; newList->size = 0; - + return newList; } @@ -90,14 +90,14 @@ static void ulist_removeItem(UList *list, UListNode *p) { U_CAPI void U_EXPORT2 ulist_addItemEndList(UList *list, const void *data, UBool forceDelete, UErrorCode *status) { UListNode *newItem = NULL; - + if (U_FAILURE(*status) || list == NULL || data == NULL) { if (forceDelete) { uprv_free((void *)data); } return; } - + newItem = (UListNode *)uprv_malloc(sizeof(UListNode)); if (newItem == NULL) { if (forceDelete) { @@ -108,7 +108,7 @@ U_CAPI void U_EXPORT2 ulist_addItemEndList(UList *list, const void *data, UBool } newItem->data = (void *)(data); newItem->forceDelete = forceDelete; - + if (list->size == 0) { ulist_addFirstItem(list, newItem); } else { @@ -117,20 +117,20 @@ U_CAPI void U_EXPORT2 ulist_addItemEndList(UList *list, const void *data, UBool list->tail->next = newItem; list->tail = newItem; } - + list->size++; } U_CAPI void U_EXPORT2 ulist_addItemBeginList(UList *list, const void *data, UBool forceDelete, UErrorCode *status) { UListNode *newItem = NULL; - + if (U_FAILURE(*status) || list == NULL || data == NULL) { if (forceDelete) { uprv_free((void *)data); } return; } - + newItem = (UListNode *)uprv_malloc(sizeof(UListNode)); if (newItem == NULL) { if (forceDelete) { @@ -141,7 +141,7 @@ U_CAPI void U_EXPORT2 ulist_addItemBeginList(UList *list, const void *data, UBoo } newItem->data = (void *)(data); newItem->forceDelete = forceDelete; - + if (list->size == 0) { ulist_addFirstItem(list, newItem); } else { @@ -150,7 +150,7 @@ U_CAPI void U_EXPORT2 ulist_addItemBeginList(UList *list, const void *data, UBoo list->head->previous = newItem; list->head = newItem; } - + list->size++; } @@ -184,14 +184,14 @@ U_CAPI UBool U_EXPORT2 ulist_removeString(UList *list, const char *data) { U_CAPI void *U_EXPORT2 ulist_getNext(UList *list) { UListNode *curr = NULL; - + if (list == NULL || list->curr == NULL) { return NULL; } - + curr = list->curr; list->curr = curr->next; - + return curr->data; } @@ -199,7 +199,7 @@ U_CAPI int32_t U_EXPORT2 ulist_getListSize(const UList *list) { if (list != NULL) { return list->size; } - + return -1; } @@ -240,7 +240,7 @@ U_CAPI int32_t U_EXPORT2 ulist_count_keyword_values(UEnumeration *en, UErrorCode if (U_FAILURE(*status)) { return -1; } - + return ulist_getListSize((UList *)(en->context)); } @@ -261,7 +261,7 @@ U_CAPI void U_EXPORT2 ulist_reset_keyword_values_iterator(UEnumeration *en, UErr if (U_FAILURE(*status)) { return ; } - + ulist_resetList((UList *)(en->context)); } diff --git a/deps/icu-small/source/common/uloc.cpp b/deps/icu-small/source/common/uloc.cpp index 73b43204b814b9..6a9bfcfbff5999 100644 --- a/deps/icu-small/source/common/uloc.cpp +++ b/deps/icu-small/source/common/uloc.cpp @@ -148,7 +148,8 @@ static const char * const LANGUAGES[] = { "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", "mdf", "mdh", "mdr", "men", "mer", "mfe", "mg", "mga", "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", - "ml", "mn", "mnc", "mni", "moh", "mos", "mr", "mrj", + "ml", "mn", "mnc", "mni", "mo", + "moh", "mos", "mr", "mrj", "ms", "mt", "mua", "mul", "mus", "mwl", "mwr", "mwv", "my", "mye", "myv", "mzn", "na", "nan", "nap", "naq", "nb", "nd", "nds", "ne", @@ -264,7 +265,8 @@ static const char * const LANGUAGES_3[] = { "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", "mdf", "mdh", "mdr", "men", "mer", "mfe", "mlg", "mga", "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", - "mal", "mon", "mnc", "mni", "moh", "mos", "mar", "mrj", + "mal", "mon", "mnc", "mni", "mol", + "moh", "mos", "mar", "mrj", "msa", "mlt", "mua", "mul", "mus", "mwl", "mwr", "mwv", "mya", "mye", "myv", "mzn", "nau", "nan", "nap", "naq", "nob", "nde", "nds", "nep", @@ -480,14 +482,15 @@ static const CanonicalizationMap CANONICALIZE_MAP[] = { /* Test if the locale id has BCP47 u extension and does not have '@' */ #define _hasBCP47Extension(id) (id && uprv_strstr(id, "@") == NULL && getShortestSubtagLength(localeID) == 1) /* Converts the BCP47 id to Unicode id. Does nothing to id if conversion fails */ -#define _ConvertBCP47(finalID, id, buffer, length,err) \ - if (uloc_forLanguageTag(id, buffer, length, NULL, err) <= 0 || \ - U_FAILURE(*err) || *err == U_STRING_NOT_TERMINATED_WARNING) { \ - finalID=id; \ - if (*err == U_STRING_NOT_TERMINATED_WARNING) { *err = U_BUFFER_OVERFLOW_ERROR; } \ - } else { \ - finalID=buffer; \ - } +#define _ConvertBCP47(finalID, id, buffer, length,err) UPRV_BLOCK_MACRO_BEGIN { \ + if (uloc_forLanguageTag(id, buffer, length, NULL, err) <= 0 || \ + U_FAILURE(*err) || *err == U_STRING_NOT_TERMINATED_WARNING) { \ + finalID=id; \ + if (*err == U_STRING_NOT_TERMINATED_WARNING) { *err = U_BUFFER_OVERFLOW_ERROR; } \ + } else { \ + finalID=buffer; \ + } \ +} UPRV_BLOCK_MACRO_END /* Gets the size of the shortest subtag in the given localeID. */ static int32_t getShortestSubtagLength(const char *localeID) { int32_t localeIDLength = static_cast(uprv_strlen(localeID)); @@ -1454,31 +1457,29 @@ static const UEnumeration gKeywordsEnum = { U_CAPI UEnumeration* U_EXPORT2 uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCode* status) { - UKeywordsContext *myContext = NULL; - UEnumeration *result = NULL; + LocalMemory myContext; + LocalMemory result; - if(U_FAILURE(*status)) { - return NULL; + if (U_FAILURE(*status)) { + return nullptr; } - result = (UEnumeration *)uprv_malloc(sizeof(UEnumeration)); - /* Null pointer test */ - if (result == NULL) { + myContext.adoptInstead(static_cast(uprv_malloc(sizeof(UKeywordsContext)))); + result.adoptInstead(static_cast(uprv_malloc(sizeof(UEnumeration)))); + if (myContext.isNull() || result.isNull()) { *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - uprv_memcpy(result, &gKeywordsEnum, sizeof(UEnumeration)); - myContext = static_cast(uprv_malloc(sizeof(UKeywordsContext))); - if (myContext == NULL) { + uprv_memcpy(result.getAlias(), &gKeywordsEnum, sizeof(UEnumeration)); + myContext->keywords = static_cast(uprv_malloc(keywordListSize+1)); + if (myContext->keywords == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; - uprv_free(result); - return NULL; + return nullptr; } - myContext->keywords = (char *)uprv_malloc(keywordListSize+1); uprv_memcpy(myContext->keywords, keywordList, keywordListSize); myContext->keywords[keywordListSize] = 0; myContext->current = myContext->keywords; - result->context = myContext; - return result; + result->context = myContext.orphan(); + return result.orphan(); } U_CAPI UEnumeration* U_EXPORT2 diff --git a/deps/icu-small/source/common/uloc_keytype.cpp b/deps/icu-small/source/common/uloc_keytype.cpp index 25f35b5ced42d5..019da058cf491d 100644 --- a/deps/icu-small/source/common/uloc_keytype.cpp +++ b/deps/icu-small/source/common/uloc_keytype.cpp @@ -531,3 +531,4 @@ ulocimp_toLegacyType(const char* key, const char* type, UBool* isKnownKey, UBool } return NULL; } + diff --git a/deps/icu-small/source/common/uloc_tag.cpp b/deps/icu-small/source/common/uloc_tag.cpp index c732170cb62b9c..1c10c48182c887 100644 --- a/deps/icu-small/source/common/uloc_tag.cpp +++ b/deps/icu-small/source/common/uloc_tag.cpp @@ -930,7 +930,7 @@ _addExtensionToList(ExtensionListEntry **first, ExtensionListEntry *ext, UBool l cmp = *(ext->key) - *(cur->key); } } else if (len == 1) { - cmp = *(ext->key) - LDMLEXT; + cmp = *(ext->key) - LDMLEXT; } else if (curlen == 1) { cmp = LDMLEXT - *(cur->key); } else { @@ -1558,10 +1558,8 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT return; } - if (!_addAttributeToList(&attrFirst, attr)) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } + // duplicate attribute is ignored, causes no error. + _addAttributeToList(&attrFirst, attr); /* next tag */ pTag += len; @@ -1739,7 +1737,7 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT pType = LOCALE_TYPE_YES; } - /* Special handling for u-va-posix, since we want to treat this as a variant, + /* Special handling for u-va-posix, since we want to treat this as a variant, not as a keyword */ if (!variantExists && !uprv_strcmp(pKey, POSIX_KEY) && !uprv_strcmp(pType, POSIX_VALUE) ) { *posixVariant = TRUE; diff --git a/deps/icu-small/source/common/ulocimp.h b/deps/icu-small/source/common/ulocimp.h index dac82872e6ed40..31d3c44d0bec68 100644 --- a/deps/icu-small/source/common/ulocimp.h +++ b/deps/icu-small/source/common/ulocimp.h @@ -41,10 +41,10 @@ uloc_getTableStringWithFallback( /*returns TRUE if a is an ID separator FALSE otherwise*/ #define _isIDSeparator(a) (a == '_' || a == '-') -U_CFUNC const char* +U_CFUNC const char* uloc_getCurrentCountryID(const char* oldID); -U_CFUNC const char* +U_CFUNC const char* uloc_getCurrentLanguageID(const char* oldID); U_CFUNC int32_t @@ -123,7 +123,7 @@ ulocimp_forLanguageTag(const char* langtag, * (3) if inferRegion is TRUE, the region suggested by * getLikelySubtags on the localeID. * If no region is found, returns length 0. - * + * * @param localeID * The complete locale ID (with keywords) from which * to get the region to use for supplemental data. @@ -132,7 +132,7 @@ ulocimp_forLanguageTag(const char* langtag, * no other region is found. * @param region * Buffer in which to put the region ID found; should - * have a capacity at least ULOC_COUNTRY_CAPACITY. + * have a capacity at least ULOC_COUNTRY_CAPACITY. * @param regionCapacity * The actual capacity of the region buffer. * @param status diff --git a/deps/icu-small/source/common/umapfile.cpp b/deps/icu-small/source/common/umapfile.cpp index 40b543fb2219bc..3e714876a4dc62 100644 --- a/deps/icu-small/source/common/umapfile.cpp +++ b/deps/icu-small/source/common/umapfile.cpp @@ -136,7 +136,7 @@ typedef HANDLE MemoryMap; /* open the input file */ #if U_PLATFORM_HAS_WINUWP_API == 0 - // Note: In the non-UWP code-path (ie: Win32), the value of the path variable might have come from + // Note: In the non-UWP code-path (ie: Win32), the value of the path variable might have come from // the CRT 'getenv' function, and would be therefore be encoded in the default ANSI code page. // This means that we can't call the *W version of API below, whereas in the UWP code-path // there is no 'getenv' call, and thus the string will be only UTF-8/Invariant characters. @@ -178,7 +178,7 @@ typedef HANDLE MemoryMap; CloseHandle(file); if (map == nullptr) { - // If we failed to create the mapping due to an out-of-memory error, then + // If we failed to create the mapping due to an out-of-memory error, then // we want to report that error back to the caller. if (HRESULT_FROM_WIN32(GetLastError()) == E_OUTOFMEMORY) { *status = U_MEMORY_ALLOCATION_ERROR; @@ -360,14 +360,14 @@ typedef HANDLE MemoryMap; } return dest; } - + /*------------------------------------------------------------------------------ - * - * computeDirPath given a user-supplied path of an item to be opened, - * compute and return - * - the full directory path to be used + * + * computeDirPath given a user-supplied path of an item to be opened, + * compute and return + * - the full directory path to be used * when opening the file. - * - Pointer to null at end of above returned path + * - Pointer to null at end of above returned path * * Parameters: * path: input path. Buffer is not altered. @@ -379,23 +379,23 @@ typedef HANDLE MemoryMap; * TODO: This works the way ICU historically has, but the * whole data fallback search path is so complicated that * probably almost no one will ever really understand it, - * the potential for confusion is large. (It's not just + * the potential for confusion is large. (It's not just * this one function, but the whole scheme.) - * + * *------------------------------------------------------------------------------*/ static char *uprv_computeDirPath(const char *path, char *pathBuffer) { char *finalSlash; /* Ptr to last dir separator in input path, or null if none. */ int32_t pathLen; /* Length of the returned directory path */ - + finalSlash = 0; if (path != 0) { finalSlash = uprv_strrchr(path, U_FILE_SEP_CHAR); } - + *pathBuffer = 0; if (finalSlash == 0) { - /* No user-supplied path. + /* No user-supplied path. * Copy the ICU_DATA path to the path buffer and return that*/ const char *icuDataDir; icuDataDir=u_getDataDirectory(); @@ -405,8 +405,8 @@ typedef HANDLE MemoryMap; /* there is no icuDataDir either. Just return the empty pathBuffer. */ return pathBuffer; } - } - + } + /* User supplied path did contain a directory portion. * Copy it to the output path buffer */ pathLen = (int32_t)(finalSlash - path + 1); @@ -414,7 +414,7 @@ typedef HANDLE MemoryMap; *(pathBuffer+pathLen) = 0; return pathBuffer+pathLen; } - + # define DATA_TYPE "dat" @@ -522,7 +522,7 @@ typedef HANDLE MemoryMap; pData->map = nullptr; pData->mapAddr = nullptr; pData->pHeader = nullptr; - } + } } #else diff --git a/deps/icu-small/source/common/umath.cpp b/deps/icu-small/source/common/umath.cpp index 3ab72ab482386c..7cf4b317494083 100644 --- a/deps/icu-small/source/common/umath.cpp +++ b/deps/icu-small/source/common/umath.cpp @@ -23,3 +23,4 @@ uprv_min(int32_t x, int32_t y) { return (x > y ? y : x); } + diff --git a/deps/icu-small/source/common/umutex.cpp b/deps/icu-small/source/common/umutex.cpp index 20b03d6cd3e416..ccbee9960a39e7 100644 --- a/deps/icu-small/source/common/umutex.cpp +++ b/deps/icu-small/source/common/umutex.cpp @@ -24,6 +24,7 @@ #include "unicode/utypes.h" #include "uassert.h" +#include "ucln_cmn.h" #include "cmemory.h" U_NAMESPACE_BEGIN @@ -35,60 +36,94 @@ U_NAMESPACE_BEGIN #error U_USER_MUTEX_CPP not supported #endif + /************************************************************************************************* * * ICU Mutex wrappers. * *************************************************************************************************/ -// The ICU global mutex. Used when ICU implementation code passes NULL for the mutex pointer. -static UMutex *globalMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +namespace { +std::mutex *initMutex; +std::condition_variable *initCondition; -U_CAPI void U_EXPORT2 -umtx_lock(UMutex *mutex) { - if (mutex == nullptr) { - mutex = globalMutex(); - } - mutex->fMutex.lock(); -} +// The ICU global mutex. +// Used when ICU implementation code passes nullptr for the mutex pointer. +UMutex globalMutex; +std::once_flag initFlag; +std::once_flag *pInitFlag = &initFlag; -U_CAPI void U_EXPORT2 -umtx_unlock(UMutex* mutex) -{ - if (mutex == nullptr) { - mutex = globalMutex(); - } - mutex->fMutex.unlock(); -} +} // Anonymous namespace -UConditionVar::UConditionVar() : fCV() { +U_CDECL_BEGIN +static UBool U_CALLCONV umtx_cleanup() { + initMutex->~mutex(); + initCondition->~condition_variable(); + UMutex::cleanup(); + + // Reset the once_flag, by destructing it and creating a fresh one in its place. + // Do not use this trick anywhere else in ICU; use umtx_initOnce, not std::call_once(). + pInitFlag->~once_flag(); + pInitFlag = new(&initFlag) std::once_flag(); + return true; } -UConditionVar::~UConditionVar() { +static void U_CALLCONV umtx_init() { + initMutex = STATIC_NEW(std::mutex); + initCondition = STATIC_NEW(std::condition_variable); + ucln_common_registerCleanup(UCLN_COMMON_MUTEX, umtx_cleanup); +} +U_CDECL_END + + +std::mutex *UMutex::getMutex() { + std::mutex *retPtr = fMutex.load(std::memory_order_acquire); + if (retPtr == nullptr) { + std::call_once(*pInitFlag, umtx_init); + std::lock_guard guard(*initMutex); + retPtr = fMutex.load(std::memory_order_acquire); + if (retPtr == nullptr) { + fMutex = new(fStorage) std::mutex(); + retPtr = fMutex; + fListLink = gListHead; + gListHead = this; + } + } + U_ASSERT(retPtr != nullptr); + return retPtr; } -U_CAPI void U_EXPORT2 -umtx_condWait(UConditionVar *cond, UMutex *mutex) { - if (mutex == nullptr) { - mutex = globalMutex(); +UMutex *UMutex::gListHead = nullptr; + +void UMutex::cleanup() { + UMutex *next = nullptr; + for (UMutex *m = gListHead; m != nullptr; m = next) { + (*m->fMutex).~mutex(); + m->fMutex = nullptr; + next = m->fListLink; + m->fListLink = nullptr; } - cond->fCV.wait(mutex->fMutex); + gListHead = nullptr; } -U_CAPI void U_EXPORT2 -umtx_condBroadcast(UConditionVar *cond) { - cond->fCV.notify_all(); +U_CAPI void U_EXPORT2 +umtx_lock(UMutex *mutex) { + if (mutex == nullptr) { + mutex = &globalMutex; + } + mutex->lock(); } -U_CAPI void U_EXPORT2 -umtx_condSignal(UConditionVar *cond) { - cond->fCV.notify_one(); +U_CAPI void U_EXPORT2 +umtx_unlock(UMutex* mutex) +{ + if (mutex == nullptr) { + mutex = &globalMutex; + } + mutex->unlock(); } @@ -98,17 +133,6 @@ umtx_condSignal(UConditionVar *cond) { * *************************************************************************************************/ -static std::mutex &initMutex() { - static std::mutex m; - return m; -} - -static std::condition_variable &initCondition() { - static std::condition_variable cv; - return cv; -} - - // This function is called when a test of a UInitOnce::fState reveals that // initialization has not completed, that we either need to call the init // function on this thread, or wait for some other thread to complete. @@ -119,8 +143,8 @@ static std::condition_variable &initCondition() { // U_COMMON_API UBool U_EXPORT2 umtx_initImplPreInit(UInitOnce &uio) { - std::unique_lock lock(initMutex()); - + std::call_once(*pInitFlag, umtx_init); + std::unique_lock lock(*initMutex); if (umtx_loadAcquire(uio.fState) == 0) { umtx_storeRelease(uio.fState, 1); return true; // Caller will next call the init function. @@ -128,7 +152,7 @@ umtx_initImplPreInit(UInitOnce &uio) { while (umtx_loadAcquire(uio.fState) == 1) { // Another thread is currently running the initialization. // Wait until it completes. - initCondition().wait(lock); + initCondition->wait(lock); } U_ASSERT(uio.fState == 2); return false; @@ -145,10 +169,10 @@ umtx_initImplPreInit(UInitOnce &uio) { U_COMMON_API void U_EXPORT2 umtx_initImplPostInit(UInitOnce &uio) { { - std::unique_lock lock(initMutex()); + std::unique_lock lock(*initMutex); umtx_storeRelease(uio.fState, 2); } - initCondition().notify_all(); + initCondition->notify_all(); } U_NAMESPACE_END diff --git a/deps/icu-small/source/common/umutex.h b/deps/icu-small/source/common/umutex.h index 1674d00bb2d59b..2503aa4a29144c 100755 --- a/deps/icu-small/source/common/umutex.h +++ b/deps/icu-small/source/common/umutex.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "unicode/utypes.h" #include "unicode/uclean.h" @@ -36,10 +37,11 @@ #error U_USER_ATOMICS and U_USER_MUTEX_H are not supported #endif - -// Export an explicit template instantiation of std::atomic. +// Export an explicit template instantiation of std::atomic. // When building DLLs for Windows this is required as it is used as a data member of the exported SharedObject class. // See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples. +// +// Similar story for std::atomic, and the exported UMutex class. #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN) #if defined(__clang__) || defined(_MSC_VER) #if defined(__clang__) @@ -48,12 +50,14 @@ #pragma clang diagnostic ignored "-Winstantiation-after-specialization" #endif template struct U_COMMON_API std::atomic; +template struct U_COMMON_API std::atomic; #if defined(__clang__) #pragma clang diagnostic pop #endif #elif defined(__GNUC__) // For GCC this class is already exported/visible, so no need for U_COMMON_API. template struct std::atomic; +template struct std::atomic; #endif #endif @@ -180,49 +184,78 @@ template void umtx_initOnce(UInitOnce &uio, void (U_CALLCONV *fp)(T, UE } } +// UMutex should be constexpr-constructible, so that no initialization code +// is run during startup. +// This works on all C++ libraries except MS VS before VS2019. +#if (defined(_CPPLIB_VER) && !defined(_MSVC_STL_VERSION)) || \ + (defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION < 142) + // (VS std lib older than VS2017) || (VS std lib version < VS2019) +# define UMUTEX_CONSTEXPR +#else +# define UMUTEX_CONSTEXPR constexpr +#endif -/************************************************************************************************* +/** + * UMutex - ICU Mutex class. * - * ICU Mutex wrappers. Originally wrapped operating system mutexes, giving the rest of ICU a - * platform independent set of mutex operations. Now vestigial, wrapping std::mutex only. - * For internal ICU use only. + * This is the preferred Mutex class for use within ICU implementation code. + * It is a thin wrapper over C++ std::mutex, with these additions: + * - Static instances are safe, not triggering static construction or destruction, + * and the associated order of construction or destruction issues. + * - Plumbed into u_cleanup() for destructing the underlying std::mutex, + * which frees any OS level resources they may be holding. * - *************************************************************************************************/ + * Limitations: + * - Static or global instances only. Cannot be heap allocated. Cannot appear as a + * member of another class. + * - No condition variables or other advanced features. If needed, you will need to use + * std::mutex and std::condition_variable directly. For an example, see unifiedcache.cpp + * + * Typical Usage: + * static UMutex myMutex; + * + * { + * Mutex lock(myMutex); + * ... // Do stuff that is protected by myMutex; + * } // myMutex is released when lock goes out of scope. + */ -struct UMutex : public icu::UMemory { - UMutex() = default; +class U_COMMON_API UMutex { +public: + UMUTEX_CONSTEXPR UMutex() {} ~UMutex() = default; + UMutex(const UMutex &other) = delete; UMutex &operator =(const UMutex &other) = delete; + void *operator new(size_t) = delete; - std::mutex fMutex = {}; // Note: struct - pubic members - because most access is from - // // plain C style functions (umtx_lock(), etc.) -}; + // requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard + void lock() { + std::mutex *m = fMutex.load(std::memory_order_acquire); + if (m == nullptr) { m = getMutex(); } + m->lock(); + } + void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } + static void cleanup(); -struct UConditionVar : public icu::UMemory { - U_COMMON_API UConditionVar(); - U_COMMON_API ~UConditionVar(); - UConditionVar(const UConditionVar &other) = delete; - UConditionVar &operator =(const UConditionVar &other) = delete; +private: + alignas(std::mutex) char fStorage[sizeof(std::mutex)] {}; + std::atomic fMutex { nullptr }; - std::condition_variable_any fCV; -}; + /** All initialized UMutexes are kept in a linked list, so that they can be found, + * and the underlying std::mutex destructed, by u_cleanup(). + */ + UMutex *fListLink { nullptr }; + static UMutex *gListHead; -#define U_MUTEX_INITIALIZER {} -#define U_CONDITION_INITIALIZER {} + /** Out-of-line function to lazily initialize a UMutex on first use. + * Initial fast check is inline, in lock(). The returned value may never + * be nullptr. + */ + std::mutex *getMutex(); +}; -// Implementation notes for UConditionVar: -// -// Use an out-of-line constructor to reduce problems with the ICU dependency checker. -// On Linux, the default constructor of std::condition_variable_any -// produces an in-line reference to global operator new(), which the -// dependency checker flags for any file that declares a UConditionVar. With -// an out-of-line constructor, the dependency is constrained to umutex.o -// -// Do not export (U_COMMON_API) the entire class, but only the constructor -// and destructor, to avoid Windows build problems with attempting to export the -// std::condition_variable_any. /* Lock a mutex. * @param mutex The given mutex to be locked. Pass NULL to specify @@ -237,30 +270,6 @@ U_INTERNAL void U_EXPORT2 umtx_lock(UMutex* mutex); */ U_INTERNAL void U_EXPORT2 umtx_unlock (UMutex* mutex); -/* - * Wait on a condition variable. - * The calling thread will unlock the mutex and wait on the condition variable. - * The mutex must be locked by the calling thread when invoking this function. - * - * @param cond the condition variable to wait on. - * @param mutex the associated mutex. - */ - -U_INTERNAL void U_EXPORT2 umtx_condWait(UConditionVar *cond, UMutex *mutex); - - -/* - * Broadcast wakeup of all threads waiting on a Condition. - * - * @param cond the condition variable. - */ -U_INTERNAL void U_EXPORT2 umtx_condBroadcast(UConditionVar *cond); - -/* - * Signal a condition variable, waking up one waiting thread. - */ -U_INTERNAL void U_EXPORT2 umtx_condSignal(UConditionVar *cond); - U_NAMESPACE_END diff --git a/deps/icu-small/source/common/unames.cpp b/deps/icu-small/source/common/unames.cpp index 038743004ea589..cde8b5ad7e51d4 100644 --- a/deps/icu-small/source/common/unames.cpp +++ b/deps/icu-small/source/common/unames.cpp @@ -144,7 +144,7 @@ static const char * const charCatNames[U_CHAR_EXTENDED_CATEGORY_COUNT] = { "format", "private use area", "surrogate", - "dash punctuation", + "dash punctuation", "start punctuation", "end punctuation", "connector punctuation", @@ -212,13 +212,13 @@ isDataLoaded(UErrorCode *pErrorCode) { return U_SUCCESS(*pErrorCode); } -#define WRITE_CHAR(buffer, bufferLength, bufferPos, c) { \ +#define WRITE_CHAR(buffer, bufferLength, bufferPos, c) UPRV_BLOCK_MACRO_BEGIN { \ if((bufferLength)>0) { \ *(buffer)++=c; \ --(bufferLength); \ } \ ++(bufferPos); \ -} +} UPRV_BLOCK_MACRO_END #define U_ISO_COMMENT U_CHAR_NAME_CHOICE_COUNT @@ -451,7 +451,7 @@ static uint16_t getExtName(uint32_t code, char *buffer, uint16_t bufferLength) { UChar32 cp; int ndigits, i; - + WRITE_CHAR(buffer, bufferLength, length, '<'); while (catname[length - 1]) { WRITE_CHAR(buffer, bufferLength, length, catname[length - 1]); @@ -639,7 +639,7 @@ enumGroupNames(UCharNames *names, const uint16_t *group, * It only needs to do it if it is called with a real function and not * with the dummy DO_FIND_NAME, because u_charFromName() does a check * for extended names by itself. - */ + */ static UBool enumExtNames(UChar32 start, UChar32 end, UEnumCharNamesFn *fn, void *context) @@ -647,7 +647,7 @@ enumExtNames(UChar32 start, UChar32 end, if(fn!=DO_FIND_NAME) { char buffer[200]; uint16_t length; - + while(start<=end) { buffer[length = getExtName(start, buffer, sizeof(buffer))] = 0; /* here, we assume that the buffer is large enough */ @@ -765,7 +765,7 @@ enumNames(UCharNames *names, } return enumExtNames(start, limit - 1, fn, context); } - + return TRUE; } diff --git a/deps/icu-small/source/common/unicode/appendable.h b/deps/icu-small/source/common/unicode/appendable.h index 8512c2f30311b8..4beacaf6583620 100644 --- a/deps/icu-small/source/common/unicode/appendable.h +++ b/deps/icu-small/source/common/unicode/appendable.h @@ -23,6 +23,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" U_NAMESPACE_BEGIN @@ -231,4 +234,6 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __APPENDABLE_H__ diff --git a/deps/icu-small/source/common/unicode/brkiter.h b/deps/icu-small/source/common/unicode/brkiter.h index ac1bf1df29f214..b944497345479b 100644 --- a/deps/icu-small/source/common/unicode/brkiter.h +++ b/deps/icu-small/source/common/unicode/brkiter.h @@ -29,6 +29,10 @@ * \brief C++ API: Break Iterator. */ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #if UCONFIG_NO_BREAK_ITERATION U_NAMESPACE_BEGIN @@ -135,7 +139,7 @@ class U_COMMON_API BreakIterator : public UObject { * method which subclasses implement. * @stable ICU 2.0 */ - virtual BreakIterator* clone(void) const = 0; + virtual BreakIterator* clone() const = 0; /** * Return a polymorphic class ID for this object. Different subclasses @@ -493,6 +497,7 @@ class U_COMMON_API BreakIterator : public UObject { static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, UnicodeString& name); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Deprecated functionality. Use clone() instead. * @@ -515,6 +520,7 @@ class U_COMMON_API BreakIterator : public UObject { virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, UErrorCode &status) = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API #ifndef U_HIDE_DEPRECATED_API @@ -658,5 +664,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // BRKITER_H //eof diff --git a/deps/icu-small/source/common/unicode/bytestream.h b/deps/icu-small/source/common/unicode/bytestream.h index 61d1e8aca651d7..0d60492fe23556 100644 --- a/deps/icu-small/source/common/unicode/bytestream.h +++ b/deps/icu-small/source/common/unicode/bytestream.h @@ -38,6 +38,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/std_string.h" @@ -133,7 +136,7 @@ class U_COMMON_API ByteSink : public UMemory { // ------------------------------------------------------------- // Some standard implementations -/** +/** * Implementation of ByteSink that writes to a flat byte array, * with bounds-checking: * This sink will not write more than capacity bytes to outbuf. @@ -223,7 +226,7 @@ class U_COMMON_API CheckedArrayByteSink : public ByteSink { CheckedArrayByteSink &operator=(const CheckedArrayByteSink &) = delete; }; -/** +/** * Implementation of ByteSink that writes to a "string". * The StringClass is usually instantiated with a std::string. * @stable ICU 4.2 @@ -239,7 +242,7 @@ class StringByteSink : public ByteSink { StringByteSink(StringClass* dest) : dest_(dest) { } /** * Constructs a ByteSink that reserves append capacity and will append bytes to the dest string. - * + * * @param dest pointer to string object to append to * @param initialAppendCapacity capacity beyond dest->length() to be reserve()d * @stable ICU 60 @@ -267,4 +270,6 @@ class StringByteSink : public ByteSink { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTREAM_H__ diff --git a/deps/icu-small/source/common/unicode/bytestrie.h b/deps/icu-small/source/common/unicode/bytestrie.h index c57b8ccfeb5960..51405f64a10e64 100644 --- a/deps/icu-small/source/common/unicode/bytestrie.h +++ b/deps/icu-small/source/common/unicode/bytestrie.h @@ -23,6 +23,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringpiece.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" @@ -94,6 +97,41 @@ class U_COMMON_API BytesTrie : public UMemory { return *this; } +#ifndef U_HIDE_DRAFT_API + /** + * Returns the state of this trie as a 64-bit integer. + * The state value is never 0. + * + * @return opaque state value + * @see resetToState64 + * @draft ICU 65 + */ + uint64_t getState64() const { + return (static_cast(remainingMatchLength_ + 2) << kState64RemainingShift) | + (uint64_t)(pos_ - bytes_); + } + + /** + * Resets this trie to the saved state. + * Unlike resetToState(State), the 64-bit state value + * must be from getState64() from the same trie object or + * from one initialized the exact same way. + * Because of no validation, this method is faster. + * + * @param state The opaque trie state value from getState64(). + * @return *this + * @see getState64 + * @see resetToState + * @see reset + * @draft ICU 65 + */ + BytesTrie &resetToState64(uint64_t state) { + remainingMatchLength_ = static_cast(state >> kState64RemainingShift) - 2; + pos_ = bytes_ + (state & kState64PosMask); + return *this; + } +#endif /* U_HIDE_DRAFT_API */ + /** * BytesTrie state object, for saving a trie's current state * and resetting the trie back to this state later. @@ -502,6 +540,13 @@ class U_COMMON_API BytesTrie : public UMemory { static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1; // 0x2fff static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1; // 0xdffff + // For getState64(): + // The remainingMatchLength_ is -1..14=(kMaxLinearMatchLength=0x10)-2 + // so we need at least 5 bits for that. + // We add 2 to store it as a positive value 1..16=kMaxLinearMatchLength. + static constexpr int32_t kState64RemainingShift = 59; + static constexpr uint64_t kState64PosMask = (UINT64_C(1) << kState64RemainingShift) - 1; + uint8_t *ownedArray_; // Fixed value referencing the BytesTrie bytes. @@ -517,4 +562,6 @@ class U_COMMON_API BytesTrie : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTRIE_H__ diff --git a/deps/icu-small/source/common/unicode/bytestriebuilder.h b/deps/icu-small/source/common/unicode/bytestriebuilder.h index b164e3bbd685f7..b98374bb8fdbc1 100644 --- a/deps/icu-small/source/common/unicode/bytestriebuilder.h +++ b/deps/icu-small/source/common/unicode/bytestriebuilder.h @@ -23,6 +23,9 @@ #define __BYTESTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/bytestrie.h" #include "unicode/stringpiece.h" #include "unicode/stringtriebuilder.h" @@ -153,7 +156,7 @@ class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder { private: const char *s; }; - + virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length, Node *nextNode) const; @@ -179,4 +182,6 @@ class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/caniter.h b/deps/icu-small/source/common/unicode/caniter.h index b47e35da07bb7f..13e524ff6ad316 100644 --- a/deps/icu-small/source/common/unicode/caniter.h +++ b/deps/icu-small/source/common/unicode/caniter.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_NORMALIZATION #include "unicode/uobject.h" @@ -21,7 +23,7 @@ * \file * \brief C++ API: Canonical Iterator */ - + /** Should permutation skip characters with combining class zero * Should be either TRUE or FALSE. This is a compile time option * @stable ICU 2.4 @@ -207,4 +209,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_NORMALIZATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/casemap.h b/deps/icu-small/source/common/unicode/casemap.h index 477eb484d136b6..53af84fa74d65f 100644 --- a/deps/icu-small/source/common/unicode/casemap.h +++ b/deps/icu-small/source/common/unicode/casemap.h @@ -8,6 +8,9 @@ #define __CASEMAP_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringpiece.h" #include "unicode/uobject.h" @@ -489,4 +492,6 @@ class U_COMMON_API CaseMap U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CASEMAP_H__ diff --git a/deps/icu-small/source/common/unicode/char16ptr.h b/deps/icu-small/source/common/unicode/char16ptr.h index a7c5f1a0c5ed56..c8a9ae6c35d646 100644 --- a/deps/icu-small/source/common/unicode/char16ptr.h +++ b/deps/icu-small/source/common/unicode/char16ptr.h @@ -7,9 +7,12 @@ #ifndef __CHAR16PTR_H__ #define __CHAR16PTR_H__ -#include #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + +#include + /** * \file * \brief C++ API: char16_t pointer wrappers with @@ -305,4 +308,6 @@ inline OldUChar *toOldUCharPtr(char16_t *p) { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CHAR16PTR_H__ diff --git a/deps/icu-small/source/common/unicode/chariter.h b/deps/icu-small/source/common/unicode/chariter.h index 292794f6d65832..db86f79e42ee2e 100644 --- a/deps/icu-small/source/common/unicode/chariter.h +++ b/deps/icu-small/source/common/unicode/chariter.h @@ -13,13 +13,16 @@ #define CHARITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" /** * \file * \brief C++ API: Character Iterator */ - + U_NAMESPACE_BEGIN /** * Abstract class that defines an API for forward-only iteration @@ -68,7 +71,7 @@ U_NAMESPACE_BEGIN * * * Example: - * \code + * \code * void function1(ForwardCharacterIterator &it) { * UChar32 c; * while(it.hasNext()) { @@ -96,27 +99,27 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * @stable ICU 2.0 */ enum { DONE = 0xffff }; - + /** - * Destructor. + * Destructor. * @stable ICU 2.0 */ virtual ~ForwardCharacterIterator(); - + /** * Returns true when both iterators refer to the same - * character in the same character-storage object. + * character in the same character-storage object. * @param that The ForwardCharacterIterator to be compared for equality * @return true when both iterators refer to the same * character in the same character-storage object * @stable ICU 2.0 */ virtual UBool operator==(const ForwardCharacterIterator& that) const = 0; - + /** * Returns true when the iterators refer to different * text-storage objects, or to different characters in the - * same text-storage object. + * same text-storage object. * @param that The ForwardCharacterIterator to be compared for inequality * @return true when the iterators refer to different * text-storage objects, or to different characters in the @@ -124,23 +127,23 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * @stable ICU 2.0 */ inline UBool operator!=(const ForwardCharacterIterator& that) const; - + /** - * Generates a hash code for this iterator. + * Generates a hash code for this iterator. * @return the hash code. * @stable ICU 2.0 */ virtual int32_t hashCode(void) const = 0; - + /** * Returns a UClassID for this ForwardCharacterIterator ("poor man's * RTTI").

Despite the fact that this function is public, - * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! - * @return a UClassID for this ForwardCharacterIterator + * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! + * @return a UClassID for this ForwardCharacterIterator * @stable ICU 2.0 */ virtual UClassID getDynamicClassID(void) const = 0; - + /** * Gets the current code unit for returning and advances to the next code unit * in the iteration range @@ -150,7 +153,7 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * @stable ICU 2.0 */ virtual char16_t nextPostInc(void) = 0; - + /** * Gets the current code point for returning and advances to the next code point * in the iteration range @@ -160,7 +163,7 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * @stable ICU 2.0 */ virtual UChar32 next32PostInc(void) = 0; - + /** * Returns FALSE if there are no more code units or code points * at or after the current position in the iteration range. @@ -171,14 +174,14 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * @stable ICU 2.0 */ virtual UBool hasNext() = 0; - + protected: /** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/ ForwardCharacterIterator(); - + /** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/ ForwardCharacterIterator(const ForwardCharacterIterator &other); - + /** * Assignment operator to be overridden in the implementing class. * @stable ICU 2.0 @@ -290,7 +293,7 @@ class U_COMMON_API ForwardCharacterIterator : public UObject { * \endcode * * Traverse the text from start to finish - *

+ * 
 
  * \code
  *  void traverseForward(CharacterIterator& iter)
  *  {
@@ -311,7 +314,7 @@ class U_COMMON_API ForwardCharacterIterator : public UObject {
  *  }
  * \endcode
  * 
- * Traverse both forward and backward from a given position in the text. + * Traverse both forward and backward from a given position in the text. * Calls to notBoundary() in this example represents some additional stopping criteria. *
  * \code
@@ -326,7 +329,7 @@ class U_COMMON_API ForwardCharacterIterator : public UObject {
  *          c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
  *          c = iter.previous()) {}
  *      int32_t start = iter.getIndex() + 1;
- *
+ *  
  *      cout << "start: " << start << " end: " << end << endl;
  *      for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {
  *          processChar(c);
@@ -373,11 +376,11 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * Returns a pointer to a new CharacterIterator of the same
      * concrete class as this one, and referring to the same
      * character in the same text-storage object as this one.  The
-     * caller is responsible for deleting the new clone.
+     * caller is responsible for deleting the new clone.  
      * @return a pointer to a new CharacterIterator
      * @stable ICU 2.0
      */
-    virtual CharacterIterator* clone(void) const = 0;
+    virtual CharacterIterator* clone() const = 0;
 
     /**
      * Sets the iterator to refer to the first code unit in its
@@ -436,7 +439,7 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * @stable ICU 2.0
      */
     virtual char16_t         last(void) = 0;
-
+        
     /**
      * Sets the iterator to refer to the last code point in its
      * iteration range, and returns that code unit.
@@ -458,7 +461,7 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
     /**
      * Sets the iterator to refer to the "position"-th code unit
      * in the text-storage object the iterator refers to, and
-     * returns that code unit.
+     * returns that code unit.  
      * @param position the "position"-th code unit in the text-storage object
      * @return the "position"-th code unit.
      * @stable ICU 2.0
@@ -479,19 +482,19 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
     virtual UChar32       setIndex32(int32_t position) = 0;
 
     /**
-     * Returns the code unit the iterator currently refers to.
-     * @return the current code unit.
+     * Returns the code unit the iterator currently refers to. 
+     * @return the current code unit. 
      * @stable ICU 2.0
      */
     virtual char16_t         current(void) const = 0;
-
+        
     /**
-     * Returns the code point the iterator currently refers to.
+     * Returns the code point the iterator currently refers to.  
      * @return the current code point.
      * @stable ICU 2.0
      */
     virtual UChar32       current32(void) const = 0;
-
+        
     /**
      * Advances to the next code unit in the iteration range
      * (toward endIndex()), and returns that code unit.  If there are
@@ -500,7 +503,7 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * @stable ICU 2.0
      */
     virtual char16_t         next(void) = 0;
-
+        
     /**
      * Advances to the next code point in the iteration range
      * (toward endIndex()), and returns that code point.  If there are
@@ -512,11 +515,11 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * @stable ICU 2.0
      */
     virtual UChar32       next32(void) = 0;
-
+        
     /**
      * Advances to the previous code unit in the iteration range
      * (toward startIndex()), and returns that code unit.  If there are
-     * no more code units to return, returns DONE.
+     * no more code units to return, returns DONE.  
      * @return the previous code unit.
      * @stable ICU 2.0
      */
@@ -525,8 +528,8 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
     /**
      * Advances to the previous code point in the iteration range
      * (toward startIndex()), and returns that code point.  If there are
-     * no more code points to return, returns DONE.
-     * @return the previous code point.
+     * no more code points to return, returns DONE. 
+     * @return the previous code point. 
      * @stable ICU 2.0
      */
     virtual UChar32       previous32(void) = 0;
@@ -547,29 +550,29 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * object of the character returned by first().  Since it's
      * possible to create an iterator that iterates across only
      * part of a text-storage object, this number isn't
-     * necessarily 0.
+     * necessarily 0.  
      * @returns the numeric index in the underlying text-storage
      * object of the character returned by first().
      * @stable ICU 2.0
      */
     inline int32_t       startIndex(void) const;
-
+        
     /**
      * Returns the numeric index in the underlying text-storage
      * object of the position immediately BEYOND the character
-     * returned by last().
+     * returned by last().  
      * @return the numeric index in the underlying text-storage
      * object of the position immediately BEYOND the character
      * returned by last().
      * @stable ICU 2.0
      */
     inline int32_t       endIndex(void) const;
-
+        
     /**
      * Returns the numeric index in the underlying text-storage
      * object of the character the iterator currently refers to
-     * (i.e., the character returned by current()).
-     * @return the numeric index in the text-storage object of
+     * (i.e., the character returned by current()).  
+     * @return the numeric index in the text-storage object of 
      * the character the iterator currently refers to
      * @stable ICU 2.0
      */
@@ -615,8 +618,8 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
 
     /**
      * Copies the text under iteration into the UnicodeString
-     * referred to by "result".
-     * @param result Receives a copy of the text under iteration.
+     * referred to by "result".  
+     * @param result Receives a copy of the text under iteration.  
      * @stable ICU 2.0
      */
     virtual void            getText(UnicodeString&  result) = 0;
@@ -645,7 +648,7 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
      * @stable ICU 2.0
      */
     CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
-
+  
     /**
      * Copy constructor.
      *
@@ -725,4 +728,7 @@ CharacterIterator::getLength(void) const {
 }
 
 U_NAMESPACE_END
+
+#endif /* U_SHOW_CPLUSPLUS_API */
+
 #endif
diff --git a/deps/icu-small/source/common/unicode/dbbi.h b/deps/icu-small/source/common/unicode/dbbi.h
index 62509c5227b9da..3de9cc381408c5 100644
--- a/deps/icu-small/source/common/unicode/dbbi.h
+++ b/deps/icu-small/source/common/unicode/dbbi.h
@@ -13,6 +13,10 @@
 #ifndef DBBI_H
 #define DBBI_H
 
+#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
+
 #include "unicode/rbbi.h"
 
 #if !UCONFIG_NO_BREAK_ITERATION
@@ -21,7 +25,7 @@
  * \file
  * \brief C++ API: Dictionary Based Break Iterator
  */
-
+ 
 U_NAMESPACE_BEGIN
 
 #ifndef U_HIDE_DEPRECATED_API
@@ -39,4 +43,6 @@ U_NAMESPACE_END
 
 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
 
+#endif /* U_SHOW_CPLUSPLUS_API */
+
 #endif
diff --git a/deps/icu-small/source/common/unicode/docmain.h b/deps/icu-small/source/common/unicode/docmain.h
index 89906799877622..704139a85ed558 100644
--- a/deps/icu-small/source/common/unicode/docmain.h
+++ b/deps/icu-small/source/common/unicode/docmain.h
@@ -1,7 +1,7 @@
 // © 2016 and later: Unicode, Inc. and others.
 // License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
- * COPYRIGHT:
+ * COPYRIGHT: 
  * Copyright (c) 1997-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  *
@@ -22,7 +22,7 @@
 /*! \mainpage
  *
  * \section API API Reference Usage
- *
+ * 
  * 

C++ Programmers:

*

Use Class Hierarchy or Alphabetical List * or Compound List @@ -31,7 +31,7 @@ * "BreakIterator". Once you are at the class, you will find an inheritance * chart, a list of the public members, a detailed description of the class, * then detailed member descriptions.

- * + * *

C Programmers:

*

Use Module List or File Members * to find a list of all the functions and constants. @@ -46,7 +46,7 @@ * *

API References for Previous Releases

*

The API References for each release of ICU are also available as - * a zip file from the ICU + * a zip file from the ICU * download page.

* *
@@ -99,7 +99,7 @@ * * * Codepage Conversion - * ucnv.h, ucnvsel.hb + * ucnv.h, ucnvsel.h * C API * * @@ -115,7 +115,7 @@ * * Locales * uloc.h - * icu::Locale, icu::LocaleBuilder + * icu::Locale, icu::LocaleBuilder, icu::LocaleMatcher * * * Resource Bundles diff --git a/deps/icu-small/source/common/unicode/dtintrv.h b/deps/icu-small/source/common/unicode/dtintrv.h index 625456f0c868e9..15e15c9d405b69 100644 --- a/deps/icu-small/source/common/unicode/dtintrv.h +++ b/deps/icu-small/source/common/unicode/dtintrv.h @@ -6,7 +6,7 @@ * others. All Rights Reserved. ******************************************************************************* * -* File DTINTRV.H +* File DTINTRV.H * ******************************************************************************* */ @@ -15,6 +15,9 @@ #define __DTINTRV_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -22,7 +25,6 @@ * \brief C++ API: Date Interval data type */ - U_NAMESPACE_BEGIN @@ -34,7 +36,7 @@ U_NAMESPACE_BEGIN class U_COMMON_API DateInterval : public UObject { public: - /** + /** * Construct a DateInterval given a from date and a to date. * @param fromDate The from date in date interval. * @param toDate The to date in date interval. @@ -47,15 +49,15 @@ class U_COMMON_API DateInterval : public UObject { * @stable ICU 4.0 */ virtual ~DateInterval(); - - /** + + /** * Get the from date. * @return the from date in dateInterval. * @stable ICU 4.0 */ inline UDate getFromDate() const; - /** + /** * Get the to date. * @return the to date in dateInterval. * @stable ICU 4.0 @@ -89,7 +91,7 @@ class U_COMMON_API DateInterval : public UObject { */ virtual UClassID getDynamicClassID(void) const; - + /** * Copy constructor. * @stable ICU 4.0 @@ -118,7 +120,7 @@ class U_COMMON_API DateInterval : public UObject { /** - * clone this object. + * clone this object. * The caller owns the result and should delete it when done. * @return a cloned DateInterval * @stable ICU 4.0 @@ -126,7 +128,7 @@ class U_COMMON_API DateInterval : public UObject { virtual DateInterval* clone() const; private: - /** + /** * Default constructor, not implemented. */ DateInterval(); @@ -137,24 +139,26 @@ class U_COMMON_API DateInterval : public UObject { } ;// end class DateInterval -inline UDate -DateInterval::getFromDate() const { - return fromDate; +inline UDate +DateInterval::getFromDate() const { + return fromDate; } -inline UDate -DateInterval::getToDate() const { - return toDate; +inline UDate +DateInterval::getToDate() const { + return toDate; } -inline UBool -DateInterval::operator!=(const DateInterval& other) const { +inline UBool +DateInterval::operator!=(const DateInterval& other) const { return ( !operator==(other) ); } U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/edits.h b/deps/icu-small/source/common/unicode/edits.h index 79e98b0cc27ac6..c3ceaccb3b3802 100644 --- a/deps/icu-small/source/common/unicode/edits.h +++ b/deps/icu-small/source/common/unicode/edits.h @@ -8,6 +8,9 @@ #define __EDITS_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -159,7 +162,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory { * @return TRUE if U_FAILURE(outErrorCode) * @stable ICU 59 */ - UBool copyErrorTo(UErrorCode &outErrorCode); + UBool copyErrorTo(UErrorCode &outErrorCode) const; /** * How much longer is the new text compared with the old text? @@ -523,4 +526,6 @@ class U_COMMON_API Edits U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __EDITS_H__ diff --git a/deps/icu-small/source/common/unicode/enumset.h b/deps/icu-small/source/common/unicode/enumset.h index 82d633ed016b5e..bde8c455c0dd2b 100644 --- a/deps/icu-small/source/common/unicode/enumset.h +++ b/deps/icu-small/source/common/unicode/enumset.h @@ -25,7 +25,7 @@ U_NAMESPACE_BEGIN /* Can't use #ifndef U_HIDE_INTERNAL_API for the entire EnumSet class, needed in .h file declarations */ /** - * enum bitset for boolean fields. Similar to Java EnumSet<>. + * enum bitset for boolean fields. Similar to Java EnumSet<>. * Needs to range check. Used for private instance variables. * @internal * \cond @@ -49,9 +49,9 @@ class EnumSet { fBools = other.fBools; return *this; } - + inline uint32_t getAll() const { - return fBools; + return fBools; } #endif /* U_HIDE_INTERNAL_API */ diff --git a/deps/icu-small/source/common/unicode/errorcode.h b/deps/icu-small/source/common/unicode/errorcode.h index 1e5df8f03e88fe..fe7b5183232cd1 100644 --- a/deps/icu-small/source/common/unicode/errorcode.h +++ b/deps/icu-small/source/common/unicode/errorcode.h @@ -20,12 +20,15 @@ #define __ERRORCODE_H__ /** - * \file + * \file * \brief C++ API: ErrorCode class intended to make it easier to use * ICU C and C++ APIs from C++ user code. */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" U_NAMESPACE_BEGIN @@ -136,4 +139,6 @@ class U_COMMON_API ErrorCode: public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __ERRORCODE_H__ diff --git a/deps/icu-small/source/common/unicode/filteredbrk.h b/deps/icu-small/source/common/unicode/filteredbrk.h index 2444114e9a14bf..42936763259e2d 100644 --- a/deps/icu-small/source/common/unicode/filteredbrk.h +++ b/deps/icu-small/source/common/unicode/filteredbrk.h @@ -11,6 +11,9 @@ #define FILTEREDBRK_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/brkiter.h" #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION @@ -101,6 +104,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject { */ virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * This function has been deprecated in favor of wrapIteratorWithFilter() * The behavior is identical. @@ -111,6 +115,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject { * @see wrapBreakIteratorWithFilter() */ virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& status) = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Wrap (adopt) an existing break iterator in a new filtered instance. @@ -142,4 +147,6 @@ U_NAMESPACE_END #endif // #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // #ifndef FILTEREDBRK_H diff --git a/deps/icu-small/source/common/unicode/icudataver.h b/deps/icu-small/source/common/unicode/icudataver.h index d5c728da880f8f..1cb202e3d45c62 100644 --- a/deps/icu-small/source/common/unicode/icudataver.h +++ b/deps/icu-small/source/common/unicode/icudataver.h @@ -32,10 +32,10 @@ /** * Retrieves the data version from icuver and stores it in dataVersionFillin. - * + * * @param dataVersionFillin icuver data version information to be filled in if not-null * @param status stores the error code from the calls to resource bundle - * + * * @stable ICU 49 */ U_STABLE void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status); diff --git a/deps/icu-small/source/common/unicode/icuplug.h b/deps/icu-small/source/common/unicode/icuplug.h index 827cbe94b61cf8..2e57b149e14ede 100644 --- a/deps/icu-small/source/common/unicode/icuplug.h +++ b/deps/icu-small/source/common/unicode/icuplug.h @@ -17,7 +17,7 @@ /** * \file - * \brief C API: ICU Plugin API + * \brief C API: ICU Plugin API * *

C API: ICU Plugin API

* @@ -25,31 +25,31 @@ * *

Loading and Configuration

* - *

At ICU startup time, the environment variable "ICU_PLUGINS" will be - * queried for a directory name. If it is not set, the preprocessor symbol + *

At ICU startup time, the environment variable "ICU_PLUGINS" will be + * queried for a directory name. If it is not set, the preprocessor symbol * "DEFAULT_ICU_PLUGINS" will be checked for a default value.

* - *

Within the above-named directory, the file "icuplugins##.txt" will be - * opened, if present, where ## is the major+minor number of the currently + *

Within the above-named directory, the file "icuplugins##.txt" will be + * opened, if present, where ## is the major+minor number of the currently * running ICU (such as, 44 for ICU 4.4, thus icuplugins44.txt)

* *

The configuration file has this format:

* *
    *
  • Hash (#) begins a comment line
  • - * + * *
  • Non-comment lines have two or three components: * LIBRARYNAME ENTRYPOINT [ CONFIGURATION .. ]
  • * *
  • Tabs or spaces separate the three items.
  • * - *
  • LIBRARYNAME is the name of a shared library, either a short name if + *
  • LIBRARYNAME is the name of a shared library, either a short name if * it is on the loader path, or a full pathname.
  • * - *
  • ENTRYPOINT is the short (undecorated) symbol name of the plugin's + *
  • ENTRYPOINT is the short (undecorated) symbol name of the plugin's * entrypoint, as above.
  • * - *
  • CONFIGURATION is the entire rest of the line . It's passed as-is to + *
  • CONFIGURATION is the entire rest of the line . It's passed as-is to * the plugin.
  • *
* @@ -59,25 +59,25 @@ * # this is icuplugins44.txt * testplug.dll myPlugin hello=world * \endcode - *

Plugins are categorized as "high" or "low" level. Low level are those - * which must be run BEFORE high level plugins, and before any operations - * which cause ICU to be 'initialized'. If a plugin is low level but - * causes ICU to allocate memory or become initialized, that plugin is said + *

Plugins are categorized as "high" or "low" level. Low level are those + * which must be run BEFORE high level plugins, and before any operations + * which cause ICU to be 'initialized'. If a plugin is low level but + * causes ICU to allocate memory or become initialized, that plugin is said * to cause a 'level change'.

* - *

At load time, ICU first queries all plugins to determine their level, - * then loads all 'low' plugins first, and then loads all 'high' plugins. + *

At load time, ICU first queries all plugins to determine their level, + * then loads all 'low' plugins first, and then loads all 'high' plugins. * Plugins are otherwise loaded in the order listed in the configuration file.

- * + * *

Implementing a Plugin

* \code - * U_CAPI UPlugTokenReturn U_EXPORT2 + * U_CAPI UPlugTokenReturn U_EXPORT2 * myPlugin (UPlugData *plug, UPlugReason reason, UErrorCode *status) { * if(reason==UPLUG_REASON_QUERY) { * uplug_setPlugName(plug, "Simple Plugin"); * uplug_setPlugLevel(plug, UPLUG_LEVEL_HIGH); * } else if(reason==UPLUG_REASON_LOAD) { - * ... Set up some ICU things here.... + * ... Set up some ICU things here.... * } else if(reason==UPLUG_REASON_UNLOAD) { * ... unload, clean up ... * } @@ -85,20 +85,20 @@ * } * \endcode * - *

The UPlugData* is an opaque pointer to the plugin-specific data, and is + *

The UPlugData* is an opaque pointer to the plugin-specific data, and is * used in all other API calls.

* *

The API contract is:

- *
  1. The plugin MUST always return UPLUG_TOKEN as a return value- to + *
    1. The plugin MUST always return UPLUG_TOKEN as a return value- to * indicate that it is a valid plugin.
    2. * - *
    3. When the 'reason' parameter is set to UPLUG_REASON_QUERY, the - * plugin MUST call uplug_setPlugLevel() to indicate whether it is a high + *
    4. When the 'reason' parameter is set to UPLUG_REASON_QUERY, the + * plugin MUST call uplug_setPlugLevel() to indicate whether it is a high * level or low level plugin.
    5. * - *
    6. When the 'reason' parameter is UPLUG_REASON_QUERY, the plugin + *
    7. When the 'reason' parameter is UPLUG_REASON_QUERY, the plugin * SHOULD call uplug_setPlugName to indicate a human readable plugin name.
    - * + * * * \internal ICU 4.4 Technology Preview */ @@ -119,7 +119,7 @@ #ifndef U_HIDE_INTERNAL_API /** * @{ - * Opaque structure passed to/from a plugin. + * Opaque structure passed to/from a plugin. * use the APIs to access it. * @internal ICU 4.4 Technology Preview */ @@ -130,7 +130,7 @@ typedef struct UPlugData UPlugData; /** @} */ /** - * Random Token to identify a valid ICU plugin. Plugins must return this + * Random Token to identify a valid ICU plugin. Plugins must return this * from the entrypoint. * @internal ICU 4.4 Technology Preview */ @@ -144,7 +144,7 @@ typedef struct UPlugData UPlugData; /** - * Return value from a plugin entrypoint. + * Return value from a plugin entrypoint. * Must always be set to UPLUG_TOKEN * @see UPLUG_TOKEN * @internal ICU 4.4 Technology Preview @@ -188,7 +188,7 @@ typedef enum { /** * Entrypoint for an ICU plugin. - * @param plug the UPlugData handle. + * @param plug the UPlugData handle. * @param status the plugin's extended status code. * @return A valid plugin must return UPLUG_TOKEN * @internal ICU 4.4 Technology Preview @@ -208,7 +208,7 @@ typedef UPlugTokenReturn (U_EXPORT2 UPlugEntrypoint) ( * @param dontUnload set true if this plugin can't be unloaded * @internal ICU 4.4 Technology Preview */ -U_INTERNAL void U_EXPORT2 +U_INTERNAL void U_EXPORT2 uplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload); /** @@ -246,7 +246,7 @@ uplug_getCurrentLevel(void); * @internal ICU 4.4 Technology Preview */ U_INTERNAL UErrorCode U_EXPORT2 -uplug_getPlugLoadStatus(UPlugData *plug); +uplug_getPlugLoadStatus(UPlugData *plug); /** * Set the human-readable name of this plugin. @@ -287,7 +287,7 @@ uplug_getLibraryName(UPlugData *plug, UErrorCode *status); /** * Return the library used for this plugin, if known. - * Plugins could use this to load data out of their + * Plugins could use this to load data out of their * @param plug plugin data handle * @return the library, or NULL * @internal ICU 4.4 Technology Preview @@ -334,7 +334,7 @@ uplug_getConfiguration(UPlugData *plug); * } * \endcode * Not thread safe- do not call while plugs are added or removed. - * @param prior pass in 'NULL' to get the first (most recent) plug, + * @param prior pass in 'NULL' to get the first (most recent) plug, * otherwise pass the value returned on a prior call to uplug_nextPlug * @return the next oldest plugin, or NULL if no more. * @internal ICU 4.4 Technology Preview @@ -344,7 +344,7 @@ uplug_nextPlug(UPlugData *prior); /** * Inject a plugin as if it were loaded from a library. - * This is useful for testing plugins. + * This is useful for testing plugins. * Note that it will have a 'NULL' library pointer associated * with it, and therefore no llibrary will be closed at cleanup time. * Low level plugins may not be able to load, as ordering can't be enforced. @@ -372,7 +372,7 @@ U_INTERNAL UPlugData* U_EXPORT2 uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status); /** - * Remove a plugin. + * Remove a plugin. * Will request the plugin to be unloaded, and close the library if needed * @param plug plugin handle to close * @param status error result @@ -385,3 +385,4 @@ uplug_removePlug(UPlugData *plug, UErrorCode *status); #endif /* UCONFIG_ENABLE_PLUGINS */ #endif /* _ICUPLUG */ + diff --git a/deps/icu-small/source/common/unicode/idna.h b/deps/icu-small/source/common/unicode/idna.h index f08658e502e200..6dfcfe48db28f1 100644 --- a/deps/icu-small/source/common/unicode/idna.h +++ b/deps/icu-small/source/common/unicode/idna.h @@ -24,6 +24,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_IDNA #include "unicode/bytestream.h" @@ -322,4 +324,7 @@ class U_COMMON_API IDNAInfo : public UMemory { U_NAMESPACE_END #endif // UCONFIG_NO_IDNA + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __IDNA_H__ diff --git a/deps/icu-small/source/common/unicode/localebuilder.h b/deps/icu-small/source/common/unicode/localebuilder.h index 960e5980c03c2e..19e10f1c070924 100644 --- a/deps/icu-small/source/common/unicode/localebuilder.h +++ b/deps/icu-small/source/common/unicode/localebuilder.h @@ -3,11 +3,14 @@ #ifndef __LOCALEBUILDER_H__ #define __LOCALEBUILDER_H__ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/locid.h" +#include "unicode/localematcher.h" #include "unicode/stringpiece.h" #include "unicode/uobject.h" -#include "unicode/utypes.h" - #ifndef U_HIDE_DRAFT_API /** @@ -276,7 +279,24 @@ class U_COMMON_API LocaleBuilder : public UObject { */ Locale build(UErrorCode& status); +#ifndef U_HIDE_DRAFT_API + /** + * Sets the UErrorCode if an error occurred while recording sets. + * Preserves older error codes in the outErrorCode. + * @param outErrorCode Set to an error code that occurred while setting subtags. + * Unchanged if there is no such error or if outErrorCode + * already contained an error. + * @return TRUE if U_FAILURE(outErrorCode) + * @draft ICU 65 + */ + UBool copyErrorTo(UErrorCode &outErrorCode) const; +#endif /* U_HIDE_DRAFT_API */ + private: + friend class LocaleMatcher::Result; + + void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode); + UErrorCode status_; char language_[9]; char script_[5]; @@ -289,4 +309,7 @@ class U_COMMON_API LocaleBuilder : public UObject { U_NAMESPACE_END #endif // U_HIDE_DRAFT_API + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __LOCALEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/localematcher.h b/deps/icu-small/source/common/unicode/localematcher.h new file mode 100644 index 00000000000000..701123f750b222 --- /dev/null +++ b/deps/icu-small/source/common/unicode/localematcher.h @@ -0,0 +1,605 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localematcher.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCALEMATCHER_H__ +#define __LOCALEMATCHER_H__ + +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" + +/** + * \file + * \brief C++ API: Locale matcher: User's desired locales vs. application's supported locales. + */ + +#ifndef U_HIDE_DRAFT_API + +/** + * Builder option for whether the language subtag or the script subtag is most important. + * + * @see Builder#setFavorSubtag(FavorSubtag) + * @draft ICU 65 + */ +enum ULocMatchFavorSubtag { + /** + * Language differences are most important, then script differences, then region differences. + * (This is the default behavior.) + * + * @draft ICU 65 + */ + ULOCMATCH_FAVOR_LANGUAGE, + /** + * Makes script differences matter relatively more than language differences. + * + * @draft ICU 65 + */ + ULOCMATCH_FAVOR_SCRIPT +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchFavorSubtag ULocMatchFavorSubtag; +#endif + +/** + * Builder option for whether all desired locales are treated equally or + * earlier ones are preferred. + * + * @see Builder#setDemotionPerDesiredLocale(Demotion) + * @draft ICU 65 + */ +enum ULocMatchDemotion { + /** + * All desired locales are treated equally. + * + * @draft ICU 65 + */ + ULOCMATCH_DEMOTION_NONE, + /** + * Earlier desired locales are preferred. + * + *

    From each desired locale to the next, + * the distance to any supported locale is increased by an additional amount + * which is at least as large as most region mismatches. + * A later desired locale has to have a better match with some supported locale + * due to more than merely having the same region subtag. + * + *

    For example: Supported={en, sv} desired=[en-GB, sv] + * yields Result(en-GB, en) because + * with the demotion of sv its perfect match is no better than + * the region distance between the earlier desired locale en-GB and en=en-US. + * + *

    Notes: + *

      + *
    • In some cases, language and/or script differences can be as small as + * the typical region difference. (Example: sr-Latn vs. sr-Cyrl) + *
    • It is possible for certain region differences to be larger than usual, + * and larger than the demotion. + * (As of CLDR 35 there is no such case, but + * this is possible in future versions of the data.) + *
    + * + * @draft ICU 65 + */ + ULOCMATCH_DEMOTION_REGION +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchDemotion ULocMatchDemotion; +#endif + +struct UHashtable; + +U_NAMESPACE_BEGIN + +struct LSR; + +class LocaleDistance; +class LocaleLsrIterator; +class UVector; +class XLikelySubtags; + +/** + * Immutable class that picks the best match between a user's desired locales and + * an application's supported locales. + * Movable but not copyable. + * + *

    Example: + *

    + * UErrorCode errorCode = U_ZERO_ERROR;
    + * LocaleMatcher matcher = LocaleMatcher::Builder().setSupportedLocales("fr, en-GB, en").build(errorCode);
    + * Locale *bestSupported = matcher.getBestLocale(Locale.US, errorCode);  // "en"
    + * 
    + * + *

    A matcher takes into account when languages are close to one another, + * such as Danish and Norwegian, + * and when regional variants are close, like en-GB and en-AU as opposed to en-US. + * + *

    If there are multiple supported locales with the same (language, script, region) + * likely subtags, then the current implementation returns the first of those locales. + * It ignores variant subtags (except for pseudolocale variants) and extensions. + * This may change in future versions. + * + *

    For example, the current implementation does not distinguish between + * de, de-DE, de-Latn, de-1901, de-u-co-phonebk. + * + *

    If you prefer one equivalent locale over another, then provide only the preferred one, + * or place it earlier in the list of supported locales. + * + *

    Otherwise, the order of supported locales may have no effect on the best-match results. + * The current implementation compares each desired locale with supported locales + * in the following order: + * 1. Default locale, if supported; + * 2. CLDR "paradigm locales" like en-GB and es-419; + * 3. other supported locales. + * This may change in future versions. + * + *

    Often a product will just need one matcher instance, built with the languages + * that it supports. However, it may want multiple instances with different + * default languages based on additional information, such as the domain. + * + *

    This class is not intended for public subclassing. + * + * @draft ICU 65 + */ +class U_COMMON_API LocaleMatcher : public UMemory { +public: + /** + * Data for the best-matching pair of a desired and a supported locale. + * Movable but not copyable. + * + * @draft ICU 65 + */ + class U_COMMON_API Result : public UMemory { + public: + /** + * Move constructor; might modify the source. + * This object will have the same contents that the source object had. + * + * @param src Result to move contents from. + * @draft ICU 65 + */ + Result(Result &&src) U_NOEXCEPT; + + /** + * Destructor. + * + * @draft ICU 65 + */ + ~Result(); + + /** + * Move assignment; might modify the source. + * This object will have the same contents that the source object had. + * + * @param src Result to move contents from. + * @draft ICU 65 + */ + Result &operator=(Result &&src) U_NOEXCEPT; + + /** + * Returns the best-matching desired locale. + * nullptr if the list of desired locales is empty or if none matched well enough. + * + * @return the best-matching desired locale, or nullptr. + * @draft ICU 65 + */ + inline const Locale *getDesiredLocale() const { return desiredLocale; } + + /** + * Returns the best-matching supported locale. + * If none matched well enough, this is the default locale. + * The default locale is nullptr if the list of supported locales is empty and + * no explicit default locale is set. + * + * @return the best-matching supported locale, or nullptr. + * @draft ICU 65 + */ + inline const Locale *getSupportedLocale() const { return supportedLocale; } + + /** + * Returns the index of the best-matching desired locale in the input Iterable order. + * -1 if the list of desired locales is empty or if none matched well enough. + * + * @return the index of the best-matching desired locale, or -1. + * @draft ICU 65 + */ + inline int32_t getDesiredIndex() const { return desiredIndex; } + + /** + * Returns the index of the best-matching supported locale in the + * constructor’s or builder’s input order (“set” Collection plus “added” locales). + * If the matcher was built from a locale list string, then the iteration order is that + * of a LocalePriorityList built from the same string. + * -1 if the list of supported locales is empty or if none matched well enough. + * + * @return the index of the best-matching supported locale, or -1. + * @draft ICU 65 + */ + inline int32_t getSupportedIndex() const { return supportedIndex; } + + /** + * Takes the best-matching supported locale and adds relevant fields of the + * best-matching desired locale, such as the -t- and -u- extensions. + * May replace some fields of the supported locale. + * The result is the locale that should be used for date and number formatting, collation, etc. + * Returns the root locale if getSupportedLocale() returns nullptr. + * + *

    Example: desired=ar-SA-u-nu-latn, supported=ar-EG, resolved locale=ar-SA-u-nu-latn + * + * @return a locale combining the best-matching desired and supported locales. + * @draft ICU 65 + */ + Locale makeResolvedLocale(UErrorCode &errorCode) const; + + private: + Result(const Locale *desired, const Locale *supported, + int32_t desIndex, int32_t suppIndex, UBool owned) : + desiredLocale(desired), supportedLocale(supported), + desiredIndex(desIndex), supportedIndex(suppIndex), + desiredIsOwned(owned) {} + + Result(const Result &other) = delete; + Result &operator=(const Result &other) = delete; + + const Locale *desiredLocale; + const Locale *supportedLocale; + int32_t desiredIndex; + int32_t supportedIndex; + UBool desiredIsOwned; + + friend class LocaleMatcher; + }; + + /** + * LocaleMatcher builder. + * Movable but not copyable. + * + * @see LocaleMatcher#builder() + * @draft ICU 65 + */ + class U_COMMON_API Builder : public UMemory { + public: + /** + * Constructs a builder used in chaining parameters for building a LocaleMatcher. + * + * @return a new Builder object + * @draft ICU 65 + */ + Builder() {} + + /** + * Move constructor; might modify the source. + * This builder will have the same contents that the source builder had. + * + * @param src Builder to move contents from. + * @draft ICU 65 + */ + Builder(Builder &&src) U_NOEXCEPT; + + /** + * Destructor. + * + * @draft ICU 65 + */ + ~Builder(); + + /** + * Move assignment; might modify the source. + * This builder will have the same contents that the source builder had. + * + * @param src Builder to move contents from. + * @draft ICU 65 + */ + Builder &operator=(Builder &&src) U_NOEXCEPT; + + /** + * Parses an Accept-Language string + * (RFC 2616 Section 14.4), + * such as "af, en, fr;q=0.9", and sets the supported locales accordingly. + * Allows whitespace in more places but does not allow "*". + * Clears any previously set/added supported locales first. + * + * @param locales the Accept-Language string of locales to set + * @return this Builder object + * @draft ICU 65 + */ + Builder &setSupportedLocalesFromListString(StringPiece locales); + + /** + * Copies the supported locales, preserving iteration order. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * @param locales the list of locale + * @return this Builder object + * @draft ICU 65 + */ + Builder &setSupportedLocales(Locale::Iterator &locales); + + /** + * Copies the supported locales from the begin/end range, preserving iteration order. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @return this Builder object + * @draft ICU 65 + */ + template + Builder &setSupportedLocales(Iter begin, Iter end) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + while (begin != end) { + addSupportedLocale(*begin++); + } + return *this; + } + + /** + * Copies the supported locales from the begin/end range, preserving iteration order. + * Calls the converter to convert each *begin to a Locale or const Locale &. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @param converter Converter from *begin to const Locale & or compatible. + * @return this Builder object + * @draft ICU 65 + */ + template + Builder &setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + while (begin != end) { + addSupportedLocale(converter(*begin++)); + } + return *this; + } + + /** + * Adds another supported locale. + * Duplicates are allowed, and are not removed. + * + * @param locale another locale + * @return this Builder object + * @draft ICU 65 + */ + Builder &addSupportedLocale(const Locale &locale); + + /** + * Sets the default locale; if nullptr, or if it is not set explicitly, + * then the first supported locale is used as the default locale. + * + * @param defaultLocale the default locale (will be copied) + * @return this Builder object + * @draft ICU 65 + */ + Builder &setDefaultLocale(const Locale *defaultLocale); + + /** + * If ULOCMATCH_FAVOR_SCRIPT, then the language differences are smaller than script + * differences. + * This is used in situations (such as maps) where + * it is better to fall back to the same script than a similar language. + * + * @param subtag the subtag to favor + * @return this Builder object + * @draft ICU 65 + */ + Builder &setFavorSubtag(ULocMatchFavorSubtag subtag); + + /** + * Option for whether all desired locales are treated equally or + * earlier ones are preferred (this is the default). + * + * @param demotion the demotion per desired locale to set. + * @return this Builder object + * @draft ICU 65 + */ + Builder &setDemotionPerDesiredLocale(ULocMatchDemotion demotion); + + /** + * Sets the UErrorCode if an error occurred while setting parameters. + * Preserves older error codes in the outErrorCode. + * + * @param outErrorCode Set to an error code if it does not contain one already + * and an error occurred while setting parameters. + * Otherwise unchanged. + * @return TRUE if U_FAILURE(outErrorCode) + * @draft ICU 65 + */ + UBool copyErrorTo(UErrorCode &outErrorCode) const; + + /** + * Builds and returns a new locale matcher. + * This builder can continue to be used. + * + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return new LocaleMatcher. + * @draft ICU 65 + */ + LocaleMatcher build(UErrorCode &errorCode) const; + + private: + friend class LocaleMatcher; + + Builder(const Builder &other) = delete; + Builder &operator=(const Builder &other) = delete; + + void clearSupportedLocales(); + bool ensureSupportedLocaleVector(); + + UErrorCode errorCode_ = U_ZERO_ERROR; + UVector *supportedLocales_ = nullptr; + int32_t thresholdDistance_ = -1; + ULocMatchDemotion demotion_ = ULOCMATCH_DEMOTION_REGION; + Locale *defaultLocale_ = nullptr; + ULocMatchFavorSubtag favor_ = ULOCMATCH_FAVOR_LANGUAGE; + }; + + // FYI No public LocaleMatcher constructors in C++; use the Builder. + + /** + * Move copy constructor; might modify the source. + * This matcher will have the same settings that the source matcher had. + * @param src source matcher + * @draft ICU 65 + */ + LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT; + + /** + * Destructor. + * @draft ICU 65 + */ + ~LocaleMatcher(); + + /** + * Move assignment operator; might modify the source. + * This matcher will have the same settings that the source matcher had. + * The behavior is undefined if *this and src are the same object. + * @param src source matcher + * @return *this + * @draft ICU 65 + */ + LocaleMatcher &operator=(LocaleMatcher &&src) U_NOEXCEPT; + + /** + * Returns the supported locale which best matches the desired locale. + * + * @param desiredLocale Typically a user's language. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const; + + /** + * Returns the supported locale which best matches one of the desired locales. + * + * @param desiredLocales Typically a user's languages, in order of preference (descending). + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatch(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const; + + /** + * Parses an Accept-Language string + * (RFC 2616 Section 14.4), + * such as "af, en, fr;q=0.9", + * and returns the supported locale which best matches one of the desired locales. + * Allows whitespace in more places but does not allow "*". + * + * @param desiredLocaleList Typically a user's languages, as an Accept-Language string. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatchForListString(StringPiece desiredLocaleList, UErrorCode &errorCode) const; + + /** + * Returns the best match between the desired locale and the supported locales. + * If the result's desired locale is not nullptr, then it is the address of the input locale. + * It has not been cloned. + * + * @param desiredLocale Typically a user's language. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching pair of the desired and a supported locale. + * @draft ICU 65 + */ + Result getBestMatchResult(const Locale &desiredLocale, UErrorCode &errorCode) const; + + /** + * Returns the best match between the desired and supported locales. + * If the result's desired locale is not nullptr, then it is a clone of + * the best-matching desired locale. The Result object owns the clone. + * + * @param desiredLocales Typically a user's languages, in order of preference (descending). + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching pair of a desired and a supported locale. + * @draft ICU 65 + */ + Result getBestMatchResult(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const; + +#ifndef U_HIDE_INTERNAL_API + /** + * Returns a fraction between 0 and 1, where 1 means that the languages are a + * perfect match, and 0 means that they are completely different. + * + *

    This is mostly an implementation detail, and the precise values may change over time. + * The implementation may use either the maximized forms or the others ones, or both. + * The implementation may or may not rely on the forms to be consistent with each other. + * + *

    Callers should construct and use a matcher rather than match pairs of locales directly. + * + * @param desired Desired locale. + * @param supported Supported locale. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return value between 0 and 1, inclusive. + * @internal (has a known user) + */ + double internalMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const; +#endif // U_HIDE_INTERNAL_API + +private: + LocaleMatcher(const Builder &builder, UErrorCode &errorCode); + LocaleMatcher(const LocaleMatcher &other) = delete; + LocaleMatcher &operator=(const LocaleMatcher &other) = delete; + + int32_t getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter, UErrorCode &errorCode) const; + + const XLikelySubtags &likelySubtags; + const LocaleDistance &localeDistance; + int32_t thresholdDistance; + int32_t demotionPerDesiredLocale; + ULocMatchFavorSubtag favorSubtag; + + // These are in input order. + const Locale ** supportedLocales; + LSR *lsrs; + int32_t supportedLocalesLength; + // These are in preference order: 1. Default locale 2. paradigm locales 3. others. + UHashtable *supportedLsrToIndex; // Map stores index+1 because 0 is "not found" + // Array versions of the supportedLsrToIndex keys and values. + // The distance lookup loops over the supportedLSRs and returns the index of the best match. + const LSR **supportedLSRs; + int32_t *supportedIndexes; + int32_t supportedLSRsLength; + Locale *ownedDefaultLocale; + const Locale *defaultLocale; + int32_t defaultLocaleIndex; +}; + +U_NAMESPACE_END + +#endif // U_HIDE_DRAFT_API +#endif // U_SHOW_CPLUSPLUS_API +#endif // __LOCALEMATCHER_H__ diff --git a/deps/icu-small/source/common/unicode/locdspnm.h b/deps/icu-small/source/common/unicode/locdspnm.h index f6e778356feced..4f06f857044c6e 100644 --- a/deps/icu-small/source/common/unicode/locdspnm.h +++ b/deps/icu-small/source/common/unicode/locdspnm.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Provides display names of Locale and its components. @@ -204,4 +206,6 @@ U_NAMESPACE_END #endif +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/locid.h b/deps/icu-small/source/common/unicode/locid.h index 7350e381ffa540..57c669b3343173 100644 --- a/deps/icu-small/source/common/unicode/locid.h +++ b/deps/icu-small/source/common/unicode/locid.h @@ -31,11 +31,14 @@ #ifndef LOCID_H #define LOCID_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/bytestream.h" #include "unicode/localpointer.h" #include "unicode/strenum.h" #include "unicode/stringpiece.h" -#include "unicode/utypes.h" #include "unicode/uobject.h" #include "unicode/putil.h" #include "unicode/uloc.h" @@ -284,16 +287,14 @@ class U_COMMON_API Locale : public UObject { */ Locale(const Locale& other); -#ifndef U_HIDE_DRAFT_API /** * Move constructor; might leave source in bogus state. * This locale will have the same contents that the source locale had. * * @param other The Locale object being moved in. - * @draft ICU 63 + * @stable ICU 63 */ Locale(Locale&& other) U_NOEXCEPT; -#endif // U_HIDE_DRAFT_API /** * Destructor @@ -310,7 +311,6 @@ class U_COMMON_API Locale : public UObject { */ Locale& operator=(const Locale& other); -#ifndef U_HIDE_DRAFT_API /** * Move assignment operator; might leave source in bogus state. * This locale will have the same contents that the source locale had. @@ -318,10 +318,9 @@ class U_COMMON_API Locale : public UObject { * * @param other The Locale object being moved in. * @return *this - * @draft ICU 63 + * @stable ICU 63 */ Locale& operator=(Locale&& other) U_NOEXCEPT; -#endif // U_HIDE_DRAFT_API /** * Checks if two locale keys are the same. @@ -389,7 +388,6 @@ class U_COMMON_API Locale : public UObject { UErrorCode& success); #endif /* U_HIDE_SYSTEM_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns a Locale for the specified BCP47 language tag string. * If the specified language tag contains any ill-formed subtags, @@ -405,7 +403,7 @@ class U_COMMON_API Locale : public UObject { * @param tag the input BCP47 language tag. * @param status error information if creating the Locale failed. * @return the Locale for the specified BCP47 language tag. - * @draft ICU 63 + * @stable ICU 63 */ static Locale U_EXPORT2 forLanguageTag(StringPiece tag, UErrorCode& status); @@ -420,7 +418,7 @@ class U_COMMON_API Locale : public UObject { * @param sink the output sink receiving the BCP47 language * tag for this Locale. * @param status error information if creating the language tag failed. - * @draft ICU 63 + * @stable ICU 63 */ void toLanguageTag(ByteSink& sink, UErrorCode& status) const; @@ -432,11 +430,10 @@ class U_COMMON_API Locale : public UObject { * * @param status error information if creating the language tag failed. * @return the BCP47 language tag for this Locale. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass toLanguageTag(UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API /** * Creates a locale which has had minimal canonicalization @@ -508,7 +505,6 @@ class U_COMMON_API Locale : public UObject { */ const char * getBaseName() const; -#ifndef U_HIDE_DRAFT_API /** * Add the likely subtags for this Locale, per the algorithm described * in the following CLDR technical report: @@ -536,7 +532,7 @@ class U_COMMON_API Locale : public UObject { * @param status error information if maximizing this Locale failed. * If this Locale is not well-formed, the error code is * U_ILLEGAL_ARGUMENT_ERROR. - * @draft ICU 63 + * @stable ICU 63 */ void addLikelySubtags(UErrorCode& status); @@ -567,24 +563,21 @@ class U_COMMON_API Locale : public UObject { * @param status error information if maximizing this Locale failed. * If this Locale is not well-formed, the error code is * U_ILLEGAL_ARGUMENT_ERROR. - * @draft ICU 63 + * @stable ICU 63 */ void minimizeSubtags(UErrorCode& status); -#endif // U_HIDE_DRAFT_API /** * Gets the list of keywords for the specified locale. * * @param status the status code - * @return pointer to StringEnumeration class, or NULL if there are no keywords. + * @return pointer to StringEnumeration class, or NULL if there are no keywords. * Client must dispose of it by calling delete. * @see getKeywords * @stable ICU 2.8 */ StringEnumeration * createKeywords(UErrorCode &status) const; -#ifndef U_HIDE_DRAFT_API - /** * Gets the list of Unicode keywords for the specified locale. * @@ -592,7 +585,7 @@ class U_COMMON_API Locale : public UObject { * @return pointer to StringEnumeration class, or NULL if there are no keywords. * Client must dispose of it by calling delete. * @see getUnicodeKeywords - * @draft ICU 63 + * @stable ICU 63 */ StringEnumeration * createUnicodeKeywords(UErrorCode &status) const; @@ -605,7 +598,7 @@ class U_COMMON_API Locale : public UObject { * * @param iterator an STL style output iterator to write the keywords to. * @param status error information if creating set of keywords failed. - * @draft ICU 63 + * @stable ICU 63 */ template inline void getKeywords(OutputIterator iterator, UErrorCode& status) const; @@ -619,13 +612,11 @@ class U_COMMON_API Locale : public UObject { * * @param iterator an STL style output iterator to write the keywords to. * @param status error information if creating set of keywords failed. - * @draft ICU 63 + * @stable ICU 63 */ template inline void getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API - /** * Gets the value for a keyword. * @@ -644,7 +635,6 @@ class U_COMMON_API Locale : public UObject { */ int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const; -#ifndef U_HIDE_DRAFT_API /** * Gets the value for a keyword. * @@ -656,7 +646,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param sink the sink to receive the keyword value. * @param status error information if getting the value failed. - * @draft ICU 63 + * @stable ICU 63 */ void getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; @@ -671,7 +661,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param status error information if getting the value failed. * @return the keyword value. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass getKeywordValue(StringPiece keywordName, UErrorCode& status) const; @@ -687,7 +677,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param sink the sink to receive the keyword value. * @param status error information if getting the value failed. - * @draft ICU 63 + * @stable ICU 63 */ void getUnicodeKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; @@ -702,11 +692,10 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param status error information if getting the value failed. * @return the keyword value. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API /** * Sets or removes the value for a keyword. @@ -729,7 +718,6 @@ class U_COMMON_API Locale : public UObject { */ void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status); -#ifndef U_HIDE_DRAFT_API /** * Sets or removes the value for a keyword. * @@ -746,7 +734,7 @@ class U_COMMON_API Locale : public UObject { * NULL, will result in the keyword being removed. No error is given if * that keyword does not exist. * @param status Returns any error information while performing this operation. - * @draft ICU 63 + * @stable ICU 63 */ void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); @@ -766,10 +754,9 @@ class U_COMMON_API Locale : public UObject { * NULL, will result in the keyword being removed. No error is given if * that keyword does not exist. * @param status Returns any error information while performing this operation. - * @draft ICU 63 + * @stable ICU 63 */ void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); -#endif // U_HIDE_DRAFT_API /** * returns the locale's three-letter language code, as specified @@ -1008,6 +995,104 @@ class U_COMMON_API Locale : public UObject { */ virtual UClassID getDynamicClassID() const; +#ifndef U_HIDE_DRAFT_API + /** + * A Locale iterator interface similar to a Java Iterator. + * @draft ICU 65 + */ + class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ { + public: + /** @draft ICU 65 */ + virtual ~Iterator(); + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + virtual UBool hasNext() const = 0; + + /** + * @return the next locale. + * @draft ICU 65 + */ + virtual const Locale &next() = 0; + }; + + /** + * A generic Locale iterator implementation over Locale input iterators. + * @draft ICU 65 + */ + template + class RangeIterator : public Iterator, public UMemory { + public: + /** + * Constructs an iterator from a begin/end range. + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @draft ICU 65 + */ + RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {} + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + UBool hasNext() const override { return it_ != end_; } + + /** + * @return the next locale. + * @draft ICU 65 + */ + const Locale &next() override { return *it_++; } + + private: + Iter it_; + const Iter end_; + }; + + /** + * A generic Locale iterator implementation over Locale input iterators. + * Calls the converter to convert each *begin to a const Locale &. + * @draft ICU 65 + */ + template + class ConvertingIterator : public Iterator, public UMemory { + public: + /** + * Constructs an iterator from a begin/end range. + * Each of the iterator parameter values must be an + * input iterator whose value the converter converts to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @param converter Converter from *begin to const Locale & or compatible. + * @draft ICU 65 + */ + ConvertingIterator(Iter begin, Iter end, Conv converter) : + it_(begin), end_(end), converter_(converter) {} + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + UBool hasNext() const override { return it_ != end_; } + + /** + * @return the next locale. + * @draft ICU 65 + */ + const Locale &next() override { return converter_(*it_++); } + + private: + Iter it_; + const Iter end_; + Conv converter_; + }; +#endif // U_HIDE_DRAFT_API + protected: /* only protected for testing purposes. DO NOT USE. */ #ifndef U_HIDE_INTERNAL_API /** @@ -1074,7 +1159,6 @@ Locale::operator!=(const Locale& other) const return !operator==(other); } -#ifndef U_HIDE_DRAFT_API template inline StringClass Locale::toLanguageTag(UErrorCode& status) const { @@ -1083,7 +1167,6 @@ Locale::toLanguageTag(UErrorCode& status) const toLanguageTag(sink, status); return result; } -#endif // U_HIDE_DRAFT_API inline const char * Locale::getCountry() const @@ -1115,13 +1198,11 @@ Locale::getName() const return fullName; } -#ifndef U_HIDE_DRAFT_API - template inline void Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const { LocalPointer keys(createKeywords(status)); - if (U_FAILURE(status)) { + if (U_FAILURE(status) || keys.isNull()) { return; } for (;;) { @@ -1138,7 +1219,7 @@ template inline void Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const { LocalPointer keys(createUnicodeKeywords(status)); - if (U_FAILURE(status)) { + if (U_FAILURE(status) || keys.isNull()) { return; } for (;;) { @@ -1169,8 +1250,6 @@ Locale::getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) cons return result; } -#endif // U_HIDE_DRAFT_API - inline UBool Locale::isBogus(void) const { return fIsBogus; @@ -1178,4 +1257,6 @@ Locale::isBogus(void) const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/messagepattern.h b/deps/icu-small/source/common/unicode/messagepattern.h index 9f2a86551ca417..04f00a8757d783 100644 --- a/deps/icu-small/source/common/unicode/messagepattern.h +++ b/deps/icu-small/source/common/unicode/messagepattern.h @@ -24,6 +24,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/parseerr.h" @@ -942,4 +944,6 @@ U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __MESSAGEPATTERN_H__ diff --git a/deps/icu-small/source/common/unicode/normalizer2.h b/deps/icu-small/source/common/unicode/normalizer2.h index 4caa0e31034b2d..4aeb3bb3d82921 100644 --- a/deps/icu-small/source/common/unicode/normalizer2.h +++ b/deps/icu-small/source/common/unicode/normalizer2.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_NORMALIZATION #include "unicode/stringpiece.h" @@ -771,4 +773,7 @@ class U_COMMON_API FilteredNormalizer2 : public Normalizer2 { U_NAMESPACE_END #endif // !UCONFIG_NO_NORMALIZATION + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __NORMALIZER2_H__ diff --git a/deps/icu-small/source/common/unicode/normlzr.h b/deps/icu-small/source/common/unicode/normlzr.h index 82335ae6d7d19b..07a596bd11b918 100644 --- a/deps/icu-small/source/common/unicode/normlzr.h +++ b/deps/icu-small/source/common/unicode/normlzr.h @@ -13,11 +13,13 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: Unicode Normalization */ - + #if !UCONFIG_NO_NORMALIZATION #include "unicode/chariter.h" @@ -183,6 +185,7 @@ class U_COMMON_API Normalizer : public UObject { Normalizer(const CharacterIterator& iter, UNormalizationMode mode); #endif /* U_HIDE_DEPRECATED_API */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Copy constructor. * @param copy The object to be copied. @@ -195,7 +198,7 @@ class U_COMMON_API Normalizer : public UObject { * @deprecated ICU 56 Use Normalizer2 instead. */ virtual ~Normalizer(); - +#endif // U_FORCE_HIDE_DEPRECATED_API //------------------------------------------------------------------------- // Static utility methods @@ -599,7 +602,7 @@ class U_COMMON_API Normalizer : public UObject { * @return a pointer to a new Normalizer * @deprecated ICU 56 Use Normalizer2 instead. */ - Normalizer* clone(void) const; + Normalizer* clone() const; /** * Generates a hash code for this iterator. @@ -723,12 +726,14 @@ class U_COMMON_API Normalizer : public UObject { static UClassID U_EXPORT2 getStaticClassID(); #endif /* U_HIDE_DEPRECATED_API */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * ICU "poor man's RTTI", returns a UClassID for the actual class. * @return a UClassID for the actual class. * @deprecated ICU 56 Use Normalizer2 instead. */ virtual UClassID getDynamicClassID() const; +#endif // U_FORCE_HIDE_DEPRECATED_API private: //------------------------------------------------------------------------- @@ -807,3 +812,5 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_NORMALIZATION */ #endif // NORMLZR_H + +#endif /* U_SHOW_CPLUSPLUS_API */ diff --git a/deps/icu-small/source/common/unicode/parseerr.h b/deps/icu-small/source/common/unicode/parseerr.h index c05487601cb0d1..c23cc273b828eb 100644 --- a/deps/icu-small/source/common/unicode/parseerr.h +++ b/deps/icu-small/source/common/unicode/parseerr.h @@ -23,7 +23,7 @@ /** * The capacity of the context strings in UParseError. * @stable ICU 2.0 - */ + */ enum { U_PARSE_CONTEXT_LEN = 16 }; /** @@ -52,7 +52,7 @@ enum { U_PARSE_CONTEXT_LEN = 16 }; *

    Examples of engines which use UParseError (or may use it in the * future) are Transliterator, RuleBasedBreakIterator, and * RegexPattern. - * + * * @stable ICU 2.0 */ typedef struct UParseError { @@ -78,14 +78,14 @@ typedef struct UParseError { /** * Textual context before the error. Null-terminated. The empty * string if not supported by parser. - * @stable ICU 2.0 + * @stable ICU 2.0 */ UChar preContext[U_PARSE_CONTEXT_LEN]; /** * The error itself and/or textual context after the error. * Null-terminated. The empty string if not supported by parser. - * @stable ICU 2.0 + * @stable ICU 2.0 */ UChar postContext[U_PARSE_CONTEXT_LEN]; diff --git a/deps/icu-small/source/common/unicode/parsepos.h b/deps/icu-small/source/common/unicode/parsepos.h index c02c8169565738..909d288d48d0fe 100644 --- a/deps/icu-small/source/common/unicode/parsepos.h +++ b/deps/icu-small/source/common/unicode/parsepos.h @@ -19,16 +19,19 @@ #define PARSEPOS_H #include "unicode/utypes.h" -#include "unicode/uobject.h" +#if U_SHOW_CPLUSPLUS_API + +#include "unicode/uobject.h" + U_NAMESPACE_BEGIN /** * \file * \brief C++ API: Canonical Iterator */ -/** +/** * ParsePosition is a simple class used by Format * and its subclasses to keep track of the current position during parsing. * The parseObject method in the various Format @@ -229,4 +232,6 @@ ParsePosition::setErrorIndex(int32_t ei) } U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/platform.h b/deps/icu-small/source/common/unicode/platform.h index ee0d8b7a000303..ad75b298a42c52 100644 --- a/deps/icu-small/source/common/unicode/platform.h +++ b/deps/icu-small/source/common/unicode/platform.h @@ -135,6 +135,14 @@ /** Fuchsia is a POSIX-ish platform. @internal */ #define U_PF_FUCHSIA 4100 /* Maximum value for Linux-based platform is 4499 */ +/** + * Emscripten is a C++ transpiler for the Web that can target asm.js or + * WebAssembly. It provides some POSIX-compatible wrappers and stubs and + * some Linux-like functionality, but is not fully compatible with + * either. + * @internal + */ +#define U_PF_EMSCRIPTEN 5010 /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ #define U_PF_OS390 9000 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ @@ -192,6 +200,8 @@ # define U_PLATFORM U_PF_OS390 #elif defined(__OS400__) || defined(__TOS_OS400__) # define U_PLATFORM U_PF_OS400 +#elif defined(__EMSCRIPTEN__) +# define U_PLATFORM U_PF_EMSCRIPTEN #else # define U_PLATFORM U_PF_UNKNOWN #endif @@ -400,7 +410,7 @@ #endif /** - * \def U_HAVE_DEBUG_LOCATION_NEW + * \def U_HAVE_DEBUG_LOCATION_NEW * Define this to define the MFC debug version of the operator new. * * @stable ICU 3.4 @@ -414,26 +424,40 @@ #endif /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */ -#ifndef __has_attribute -# define __has_attribute(x) 0 +#ifdef __has_attribute +# define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +# define UPRV_HAS_ATTRIBUTE(x) 0 #endif -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 +#ifdef __has_cpp_attribute +# define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define UPRV_HAS_CPP_ATTRIBUTE(x) 0 #endif -#ifndef __has_declspec_attribute -# define __has_declspec_attribute(x) 0 +#ifdef __has_declspec_attribute +# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x) +#else +# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0 #endif -#ifndef __has_builtin -# define __has_builtin(x) 0 +#ifdef __has_builtin +# define UPRV_HAS_BUILTIN(x) __has_builtin(x) +#else +# define UPRV_HAS_BUILTIN(x) 0 #endif -#ifndef __has_feature -# define __has_feature(x) 0 +#ifdef __has_feature +# define UPRV_HAS_FEATURE(x) __has_feature(x) +#else +# define UPRV_HAS_FEATURE(x) 0 #endif -#ifndef __has_extension -# define __has_extension(x) 0 +#ifdef __has_extension +# define UPRV_HAS_EXTENSION(x) __has_extension(x) +#else +# define UPRV_HAS_EXTENSION(x) 0 #endif -#ifndef __has_warning -# define __has_warning(x) 0 +#ifdef __has_warning +# define UPRV_HAS_WARNING(x) __has_warning(x) +#else +# define UPRV_HAS_WARNING(x) 0 #endif /** @@ -452,7 +476,9 @@ * Attribute to specify the size of the allocated buffer for malloc-like functions * @internal */ -#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size) +#if (defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ + UPRV_HAS_ATTRIBUTE(alloc_size) # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) #else @@ -516,8 +542,9 @@ namespace std { #elif defined(__clang__) // Test for compiler vs. feature separately. // Other compilers might choke on the feature test. -# if __has_cpp_attribute(clang::fallthrough) || \ - (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")) +# if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \ + (UPRV_HAS_FEATURE(cxx_attributes) && \ + UPRV_HAS_WARNING("-Wimplicit-fallthrough")) # define U_FALLTHROUGH [[clang::fallthrough]] # endif #elif defined(__GNUC__) && (__GNUC__ >= 7) @@ -620,7 +647,8 @@ namespace std { */ #ifdef U_CHARSET_IS_UTF8 /* Use the predefined value. */ -#elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED +#elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \ + U_PLATFORM == U_PF_EMSCRIPTEN # define U_CHARSET_IS_UTF8 1 #else # define U_CHARSET_IS_UTF8 0 @@ -707,7 +735,7 @@ namespace std { * narrow-character strings are in EBCDIC. */ # define U_SIZEOF_WCHAR_T 2 -#else +# else /* * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. * Wide-character strings are in 16-bit EBCDIC, @@ -786,12 +814,13 @@ namespace std { /* Use the predefined value. */ #elif defined(U_STATIC_IMPLEMENTATION) # define U_EXPORT -#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \ + UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport)) # define U_EXPORT __declspec(dllexport) #elif defined(__GNUC__) # define U_EXPORT __attribute__((visibility("default"))) #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ - || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) + || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) # define U_EXPORT __global /*#elif defined(__HP_aCC) || defined(__HP_cc) # define U_EXPORT __declspec(dllexport)*/ @@ -810,11 +839,12 @@ namespace std { #ifdef U_IMPORT /* Use the predefined value. */ -#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \ + UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport)) /* Windows needs to export/import data. */ # define U_IMPORT __declspec(dllimport) #else -# define U_IMPORT +# define U_IMPORT #endif /** @@ -852,4 +882,4 @@ namespace std { #endif /* @} */ -#endif +#endif // _PLATFORM_H diff --git a/deps/icu-small/source/common/unicode/putil.h b/deps/icu-small/source/common/unicode/putil.h index 14bb99ccc545b2..759b136c13e4ac 100644 --- a/deps/icu-small/source/common/unicode/putil.h +++ b/deps/icu-small/source/common/unicode/putil.h @@ -43,7 +43,7 @@ */ /** - * Return the ICU data directory. + * Return the ICU data directory. * The data directory is where common format ICU data files (.dat files) * are loaded from. Note that normal use of the built-in ICU * facilities does not require loading of an external data file; @@ -56,21 +56,21 @@ * If a data directory was specified at ICU build time * * \code - * #define ICU_DATA_DIR "path" + * #define ICU_DATA_DIR "path" * \endcode * use that, * otherwise no data directory is available. * * @return the data directory, or an empty string ("") if no data directory has * been specified. - * + * * @stable ICU 2.0 */ U_STABLE const char* U_EXPORT2 u_getDataDirectory(void); -/** - * Set the ICU data directory. +/** + * Set the ICU data directory. * The data directory is where common format ICU data files (.dat files) * are loaded from. Note that normal use of the built-in ICU * facilities does not require loading of an external data file; @@ -98,7 +98,7 @@ U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory); * * @return the time zone data override directory. * @internal - */ + */ U_INTERNAL const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status); /** diff --git a/deps/icu-small/source/common/unicode/rbbi.h b/deps/icu-small/source/common/unicode/rbbi.h index 365ae2d3d2ac75..7825f603a51c1b 100644 --- a/deps/icu-small/source/common/unicode/rbbi.h +++ b/deps/icu-small/source/common/unicode/rbbi.h @@ -18,6 +18,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule Based Break Iterator @@ -272,7 +274,7 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { * @return a newly-constructed RuleBasedBreakIterator * @stable ICU 2.0 */ - virtual BreakIterator* clone() const; + virtual RuleBasedBreakIterator* clone() const; /** * Compute a hash code for this BreakIterator @@ -536,6 +538,7 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { */ static UClassID U_EXPORT2 getStaticClassID(void); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Deprecated functionality. Use clone() instead. * @@ -562,10 +565,10 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { * or if the stackBuffer was too small to hold the clone. * @deprecated ICU 52. Use clone() instead. */ - virtual BreakIterator * createBufferClone(void *stackBuffer, - int32_t &BufferSize, - UErrorCode &status); - + virtual RuleBasedBreakIterator *createBufferClone(void *stackBuffer, + int32_t &BufferSize, + UErrorCode &status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Return the binary form of compiled break rules, @@ -696,4 +699,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/rep.h b/deps/icu-small/source/common/unicode/rep.h index b1023a37a2daf1..6dd4530647e628 100644 --- a/deps/icu-small/source/common/unicode/rep.h +++ b/deps/icu-small/source/common/unicode/rep.h @@ -16,13 +16,17 @@ #ifndef REP_H #define REP_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** - * \file + * \file * \brief C++ API: Replaceable String */ - + U_NAMESPACE_BEGIN class UnicodeString; @@ -83,7 +87,7 @@ class U_COMMON_API Replaceable : public UObject { * Returns the number of 16-bit code units in the text. * @return number of 16-bit code units in text * @stable ICU 1.8 - */ + */ inline int32_t length() const; /** @@ -110,7 +114,7 @@ class U_COMMON_API Replaceable : public UObject { inline UChar32 char32At(int32_t offset) const; /** - * Copies characters in the range [start, limit) + * Copies characters in the range [start, limit) * into the UnicodeString target. * @param start offset of first character which will be copied * @param limit offset immediately following the last character to @@ -140,7 +144,7 @@ class U_COMMON_API Replaceable : public UObject { * @param limit the ending index, exclusive; start <= limit * <= length(). * @param text the text to replace characters start - * to limit - 1 + * to limit - 1 * @stable ICU 2.0 */ virtual void handleReplaceBetween(int32_t start, @@ -160,7 +164,7 @@ class U_COMMON_API Replaceable : public UObject { * Copies a substring of this object, retaining metadata. * This method is used to duplicate or reorder substrings. * The destination index must not overlap the source range. - * + * * @param start the beginning index, inclusive; 0 <= start <= * limit. * @param limit the ending index, exclusive; start <= limit <= @@ -189,9 +193,6 @@ class U_COMMON_API Replaceable : public UObject { * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a pointer to a Replaceable - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -223,7 +224,7 @@ class U_COMMON_API Replaceable : public UObject { /** * Virtual version of length(). * @stable ICU 2.4 - */ + */ virtual int32_t getLength() const = 0; /** @@ -260,4 +261,6 @@ Replaceable::char32At(int32_t offset) const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/resbund.h b/deps/icu-small/source/common/unicode/resbund.h index ab0b60bbb28fcc..2894067528724f 100644 --- a/deps/icu-small/source/common/unicode/resbund.h +++ b/deps/icu-small/source/common/unicode/resbund.h @@ -49,16 +49,19 @@ #define RESBUND_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/ures.h" #include "unicode/unistr.h" #include "unicode/locid.h" /** - * \file + * \file * \brief C++ API: Resource Bundle */ - + U_NAMESPACE_BEGIN /** @@ -82,8 +85,8 @@ class U_COMMON_API ResourceBundle : public UObject { /** * Constructor * - * @param packageName The packageName and locale together point to an ICU udata object, - * as defined by udata_open( packageName, "res", locale, err) + * @param packageName The packageName and locale together point to an ICU udata object, + * as defined by udata_open( packageName, "res", locale, err) * or equivalent. Typically, packageName will refer to a (.dat) file, or to * a package registered with udata_setAppData(). Using a full file or directory * pathname for packageName is deprecated. @@ -112,8 +115,8 @@ class U_COMMON_API ResourceBundle : public UObject { /** * Construct a resource bundle for the default bundle in the specified package. * - * @param packageName The packageName and locale together point to an ICU udata object, - * as defined by udata_open( packageName, "res", locale, err) + * @param packageName The packageName and locale together point to an ICU udata object, + * as defined by udata_open( packageName, "res", locale, err) * or equivalent. Typically, packageName will refer to a (.dat) file, or to * a package registered with udata_setAppData(). Using a full file or directory * pathname for packageName is deprecated. @@ -135,8 +138,8 @@ class U_COMMON_API ResourceBundle : public UObject { * Standard constructor, constructs a resource bundle for the locale-specific * bundle in the specified package. * - * @param packageName The packageName and locale together point to an ICU udata object, - * as defined by udata_open( packageName, "res", locale, err) + * @param packageName The packageName and locale together point to an ICU udata object, + * as defined by udata_open( packageName, "res", locale, err) * or equivalent. Typically, packageName will refer to a (.dat) file, or to * a package registered with udata_setAppData(). Using a full file or directory * pathname for packageName is deprecated. @@ -489,4 +492,7 @@ class U_COMMON_API ResourceBundle : public UObject { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/schriter.h b/deps/icu-small/source/common/unicode/schriter.h index 1a12769e8df106..1ca5b70fca5828 100644 --- a/deps/icu-small/source/common/unicode/schriter.h +++ b/deps/icu-small/source/common/unicode/schriter.h @@ -21,14 +21,17 @@ #define SCHRITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/chariter.h" #include "unicode/uchriter.h" /** - * \file + * \file * \brief C++ API: String Character Iterator */ - + U_NAMESPACE_BEGIN /** * A concrete subclass of CharacterIterator that iterates over the @@ -130,7 +133,7 @@ class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { * @return the newly cloned object. * @stable ICU 2.0 */ - virtual CharacterIterator* clone(void) const; + virtual StringCharacterIterator* clone() const; /** * Sets the iterator to iterate over the provided string. @@ -186,4 +189,7 @@ class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/simpleformatter.h b/deps/icu-small/source/common/unicode/simpleformatter.h index 3f7d93dc094a18..9414bca3085ad4 100644 --- a/deps/icu-small/source/common/unicode/simpleformatter.h +++ b/deps/icu-small/source/common/unicode/simpleformatter.h @@ -17,6 +17,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unistr.h" U_NAMESPACE_BEGIN @@ -333,4 +336,6 @@ class U_COMMON_API SimpleFormatter U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __SIMPLEFORMATTER_H__ diff --git a/deps/icu-small/source/common/unicode/std_string.h b/deps/icu-small/source/common/unicode/std_string.h index 729c56399506eb..bf87230167ecf2 100644 --- a/deps/icu-small/source/common/unicode/std_string.h +++ b/deps/icu-small/source/common/unicode/std_string.h @@ -27,6 +27,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + // Workaround for a libstdc++ bug before libstdc++4.6 (2011). // https://bugs.llvm.org/show_bug.cgi?id=13364 #if defined(__GLIBCXX__) @@ -34,4 +36,6 @@ namespace std { class type_info; } #endif #include +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STD_STRING_H__ diff --git a/deps/icu-small/source/common/unicode/strenum.h b/deps/icu-small/source/common/unicode/strenum.h index fa525d4f5227da..8601f1f7c401f7 100644 --- a/deps/icu-small/source/common/unicode/strenum.h +++ b/deps/icu-small/source/common/unicode/strenum.h @@ -12,14 +12,18 @@ #ifndef STRENUM_H #define STRENUM_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" /** - * \file + * \file * \brief C++ API: String Enumeration */ - + U_NAMESPACE_BEGIN /** @@ -52,9 +56,9 @@ U_NAMESPACE_BEGIN * ICU 2.8 adds some default implementations and helper functions * for subclasses. * - * @stable ICU 2.4 + * @stable ICU 2.4 */ -class U_COMMON_API StringEnumeration : public UObject { +class U_COMMON_API StringEnumeration : public UObject { public: /** * Destructor. @@ -67,9 +71,6 @@ class U_COMMON_API StringEnumeration : public UObject { * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a base class pointer - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -126,7 +127,7 @@ class U_COMMON_API StringEnumeration : public UObject { * @param resultLength a pointer to receive the length, can be NULL. * @return a pointer to the string, or NULL. * - * @stable ICU 2.4 + * @stable ICU 2.4 */ virtual const char* next(int32_t *resultLength, UErrorCode& status); @@ -151,7 +152,7 @@ class U_COMMON_API StringEnumeration : public UObject { * @param resultLength a ponter to receive the length, can be NULL. * @return a pointer to the string, or NULL. * - * @stable ICU 2.4 + * @stable ICU 2.4 */ virtual const char16_t* unext(int32_t *resultLength, UErrorCode& status); @@ -173,7 +174,7 @@ class U_COMMON_API StringEnumeration : public UObject { * @param status the error code. * @return a pointer to the string, or NULL. * - * @stable ICU 2.4 + * @stable ICU 2.4 */ virtual const UnicodeString* snext(UErrorCode& status); @@ -187,7 +188,7 @@ class U_COMMON_API StringEnumeration : public UObject { * * @param status the error code. * - * @stable ICU 2.4 + * @stable ICU 2.4 */ virtual void reset(UErrorCode& status) = 0; @@ -196,7 +197,7 @@ class U_COMMON_API StringEnumeration : public UObject { * * @param that The other string enumeration to compare this object to * @return TRUE if the enumerations are equal. FALSE if not. - * @stable ICU 3.6 + * @stable ICU 3.6 */ virtual UBool operator==(const StringEnumeration& that)const; /** @@ -204,7 +205,7 @@ class U_COMMON_API StringEnumeration : public UObject { * * @param that The other string enumeration to compare this object to * @return TRUE if the enumerations are equal. FALSE if not. - * @stable ICU 3.6 + * @stable ICU 3.6 */ virtual UBool operator!=(const StringEnumeration& that)const; @@ -274,5 +275,7 @@ class U_COMMON_API StringEnumeration : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + /* STRENUM_H */ #endif diff --git a/deps/icu-small/source/common/unicode/stringpiece.h b/deps/icu-small/source/common/unicode/stringpiece.h index 640fbac5a827d0..f581091f872070 100644 --- a/deps/icu-small/source/common/unicode/stringpiece.h +++ b/deps/icu-small/source/common/unicode/stringpiece.h @@ -23,11 +23,17 @@ #define __STRINGPIECE_H__ /** - * \file + * \file * \brief C++ API: StringPiece: Read-only byte string wrapper class. */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include +#include + #include "unicode/uobject.h" #include "unicode/std_string.h" @@ -74,6 +80,33 @@ class U_COMMON_API StringPiece : public UMemory { */ StringPiece(const std::string& str) : ptr_(str.data()), length_(static_cast(str.size())) { } +#ifndef U_HIDE_DRAFT_API + /** + * Constructs from some other implementation of a string piece class, from any + * C++ record type that has these two methods: + * + * \code{.cpp} + * + * struct OtherStringPieceClass { + * const char* data(); + * size_t size(); + * }; + * + * \endcode + * + * The other string piece class will typically be std::string_view from C++17 + * or absl::string_view from Abseil. + * + * @param str the other string piece + * @draft ICU 65 + */ + template ::value && + std::is_same::value>::type> + StringPiece(T str) + : ptr_(str.data()), length_(static_cast(str.size())) {} +#endif // U_HIDE_DRAFT_API /** * Constructs from a const char * pointer and a specified length. * @param offset a const char * pointer (need not be terminated) @@ -144,7 +177,7 @@ class U_COMMON_API StringPiece : public UMemory { /** * Reset the stringpiece to refer to new data. - * @param str a pointer to a NUL-terminated string. + * @param str a pointer to a NUL-terminated string. * @stable ICU 4.8 */ void set(const char* str); @@ -205,7 +238,7 @@ class U_COMMON_API StringPiece : public UMemory { * @return TRUE if the string data is equal * @stable ICU 4.8 */ -U_EXPORT UBool U_EXPORT2 +U_EXPORT UBool U_EXPORT2 operator==(const StringPiece& x, const StringPiece& y); /** @@ -221,4 +254,6 @@ inline UBool operator!=(const StringPiece& x, const StringPiece& y) { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STRINGPIECE_H__ diff --git a/deps/icu-small/source/common/unicode/stringtriebuilder.h b/deps/icu-small/source/common/unicode/stringtriebuilder.h index c27fbd67960d70..2c47dd415b1884 100644 --- a/deps/icu-small/source/common/unicode/stringtriebuilder.h +++ b/deps/icu-small/source/common/unicode/stringtriebuilder.h @@ -18,6 +18,9 @@ #define __STRINGTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -272,7 +275,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API, // it is needed for layout of other objects. /** - * @internal + * @internal */ class ValueNode : public Node { public: @@ -289,8 +292,8 @@ class U_COMMON_API StringTrieBuilder : public UObject { }; #ifndef U_HIDE_INTERNAL_API - /** - * @internal + /** + * @internal */ class IntermediateValueNode : public ValueNode { public: @@ -307,7 +310,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API, // it is needed for layout of other objects. /** - * @internal + * @internal */ class LinearMatchNode : public ValueNode { public: @@ -323,7 +326,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { #ifndef U_HIDE_INTERNAL_API /** - * @internal + * @internal */ class BranchNode : public Node { public: @@ -333,7 +336,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { }; /** - * @internal + * @internal */ class ListBranchNode : public BranchNode { public: @@ -365,7 +368,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { }; /** - * @internal + * @internal */ class SplitBranchNode : public BranchNode { public: @@ -418,4 +421,6 @@ class U_COMMON_API StringTrieBuilder : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STRINGTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/symtable.h b/deps/icu-small/source/common/unicode/symtable.h index c2dc95a61bc020..b64d877f97430f 100644 --- a/deps/icu-small/source/common/unicode/symtable.h +++ b/deps/icu-small/source/common/unicode/symtable.h @@ -13,14 +13,17 @@ #define SYMTABLE_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** - * \file + * \file * \brief C++ API: An interface that defines both lookup protocol and parsing of * symbolic names. */ - + U_NAMESPACE_BEGIN class ParsePosition; @@ -111,4 +114,6 @@ class U_COMMON_API SymbolTable /* not : public UObject because this is an interf }; U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/ucat.h b/deps/icu-small/source/common/unicode/ucat.h index f9c18b47d6c9b8..4d1ff3f6b28d1e 100644 --- a/deps/icu-small/source/common/unicode/ucat.h +++ b/deps/icu-small/source/common/unicode/ucat.h @@ -50,7 +50,7 @@ * 1%5 { "Good afternoon." } * 1%7 { "Good evening." } * 1%8 { "Good night." } - * + * * 4%14 { "Please " } * 4%19 { "Thank you." } * 4%20 { "Sincerely," } @@ -67,7 +67,7 @@ U_CDECL_BEGIN /** * An ICU message catalog descriptor, analogous to nl_catd. - * + * * @stable ICU 2.6 */ typedef UResourceBundle* u_nl_catd; @@ -100,7 +100,7 @@ typedef UResourceBundle* u_nl_catd; * is responsible for calling u_catclose() to close the message * catalog. If the ec parameter indicates failure, then NULL will be * returned. - * + * * @stable ICU 2.6 */ U_STABLE u_nl_catd U_EXPORT2 @@ -111,7 +111,7 @@ u_catopen(const char* name, const char* locale, UErrorCode* ec); * * @param catd a message catalog descriptor to be closed. May be NULL, * in which case no action is taken. - * + * * @stable ICU 2.6 */ U_STABLE void U_EXPORT2 @@ -146,7 +146,7 @@ u_catclose(u_nl_catd catd); * for any reason, then s is returned. This includes the situation in * which ec indicates a failing error code upon entry to this * function. - * + * * @stable ICU 2.6 */ U_STABLE const UChar* U_EXPORT2 diff --git a/deps/icu-small/source/common/unicode/uchar.h b/deps/icu-small/source/common/unicode/uchar.h index d70c964e38e5b8..1b7ee099be7ca2 100644 --- a/deps/icu-small/source/common/unicode/uchar.h +++ b/deps/icu-small/source/common/unicode/uchar.h @@ -2578,8 +2578,6 @@ typedef enum UVerticalOrientation { U_STABLE UBool U_EXPORT2 u_hasBinaryProperty(UChar32 c, UProperty which); -#ifndef U_HIDE_DRAFT_API - /** * Returns a frozen USet for a binary property. * The library retains ownership over the returned object. @@ -2593,13 +2591,11 @@ u_hasBinaryProperty(UChar32 c, UProperty which); * @see UProperty * @see u_hasBinaryProperty * @see Unicode::fromUSet - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI const USet * U_EXPORT2 u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode); -#endif // U_HIDE_DRAFT_API - /** * Check if a code point has the Alphabetic Unicode property. * Same as u_hasBinaryProperty(c, UCHAR_ALPHABETIC). @@ -2757,8 +2753,6 @@ u_getIntPropertyMinValue(UProperty which); U_STABLE int32_t U_EXPORT2 u_getIntPropertyMaxValue(UProperty which); -#ifndef U_HIDE_DRAFT_API - /** * Returns an immutable UCPMap for an enumerated/catalog/int-valued property. * The library retains ownership over the returned object. @@ -2772,13 +2766,11 @@ u_getIntPropertyMaxValue(UProperty which); * @return the property as a map * @see UProperty * @see u_getIntPropertyValue - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI const UCPMap * U_EXPORT2 u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode); -#endif // U_HIDE_DRAFT_API - /** * Get the numeric value for a Unicode code point as defined in the * Unicode Character Database. @@ -3197,15 +3189,14 @@ U_STABLE UBool U_EXPORT2 u_isprint(UChar32 c); /** - * Determines whether the specified code point is a base character. + * Non-standard: Determines whether the specified code point is a base character. * True for general categories "L" (letters), "N" (numbers), * "Mc" (spacing combining marks), and "Me" (enclosing marks). * - * Note that this is different from the Unicode definition in - * chapter 3.5, conformance clause D13, - * which defines base characters to be all characters (not Cn) - * that do not graphically combine with preceding characters (M) - * and that are neither control (Cc) or format (Cf) characters. + * Note that this is different from the Unicode Standard definition in + * chapter 3.6, conformance clause D51 “Base character”, + * which defines base characters as the code points with general categories + * Letter (L), Number (N), Punctuation (P), Symbol (S), or Space Separator (Zs). * * @param c the code point to be tested * @return TRUE if the code point is a base character according to this function diff --git a/deps/icu-small/source/common/unicode/ucharstrie.h b/deps/icu-small/source/common/unicode/ucharstrie.h index dfc93f6d0bae8a..d5729d944ee3a2 100644 --- a/deps/icu-small/source/common/unicode/ucharstrie.h +++ b/deps/icu-small/source/common/unicode/ucharstrie.h @@ -24,6 +24,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unistr.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" @@ -94,6 +97,41 @@ class U_COMMON_API UCharsTrie : public UMemory { return *this; } +#ifndef U_HIDE_DRAFT_API + /** + * Returns the state of this trie as a 64-bit integer. + * The state value is never 0. + * + * @return opaque state value + * @see resetToState64 + * @draft ICU 65 + */ + uint64_t getState64() const { + return (static_cast(remainingMatchLength_ + 2) << kState64RemainingShift) | + (uint64_t)(pos_ - uchars_); + } + + /** + * Resets this trie to the saved state. + * Unlike resetToState(State), the 64-bit state value + * must be from getState64() from the same trie object or + * from one initialized the exact same way. + * Because of no validation, this method is faster. + * + * @param state The opaque trie state value from getState64(). + * @return *this + * @see getState64 + * @see resetToState + * @see reset + * @draft ICU 65 + */ + UCharsTrie &resetToState64(uint64_t state) { + remainingMatchLength_ = static_cast(state >> kState64RemainingShift) - 2; + pos_ = uchars_ + (state & kState64PosMask); + return *this; + } +#endif /* U_HIDE_DRAFT_API */ + /** * UCharsTrie state object, for saving a trie's current state * and resetting the trie back to this state later. @@ -560,6 +598,13 @@ class U_COMMON_API UCharsTrie : public UMemory { static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1; // 0x03feffff + // For getState64(): + // The remainingMatchLength_ is -1..14=(kMaxLinearMatchLength=0x10)-2 + // so we need at least 5 bits for that. + // We add 2 to store it as a positive value 1..16=kMaxLinearMatchLength. + static constexpr int32_t kState64RemainingShift = 59; + static constexpr uint64_t kState64PosMask = (UINT64_C(1) << kState64RemainingShift) - 1; + char16_t *ownedArray_; // Fixed value referencing the UCharsTrie words. @@ -575,4 +620,6 @@ class U_COMMON_API UCharsTrie : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __UCHARSTRIE_H__ diff --git a/deps/icu-small/source/common/unicode/ucharstriebuilder.h b/deps/icu-small/source/common/unicode/ucharstriebuilder.h index 2aa4757e52cb07..540dcc047fd563 100644 --- a/deps/icu-small/source/common/unicode/ucharstriebuilder.h +++ b/deps/icu-small/source/common/unicode/ucharstriebuilder.h @@ -18,6 +18,9 @@ #define __UCHARSTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringtriebuilder.h" #include "unicode/ucharstrie.h" #include "unicode/unistr.h" @@ -184,4 +187,6 @@ class U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __UCHARSTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/uchriter.h b/deps/icu-small/source/common/unicode/uchriter.h index 38f67c5b454cba..a485259b808f2b 100644 --- a/deps/icu-small/source/common/unicode/uchriter.h +++ b/deps/icu-small/source/common/unicode/uchriter.h @@ -11,13 +11,16 @@ #define UCHRITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/chariter.h" /** - * \file + * \file * \brief C++ API: char16_t Character Iterator */ - + U_NAMESPACE_BEGIN /** @@ -132,7 +135,7 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator { * @return the CharacterIterator newly created * @stable ICU 2.0 */ - virtual CharacterIterator* clone(void) const; + virtual UCharCharacterIterator* clone() const; /** * Sets the iterator to refer to the first code unit in its @@ -384,4 +387,7 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/uclean.h b/deps/icu-small/source/common/unicode/uclean.h index ab0cd6da6ba780..7cef6dba68b815 100644 --- a/deps/icu-small/source/common/unicode/uclean.h +++ b/deps/icu-small/source/common/unicode/uclean.h @@ -22,7 +22,7 @@ * \file * \brief C API: Initialize and clean up ICU */ - + /** * Initialize ICU. * @@ -48,8 +48,8 @@ * failure, as usual. * * @stable ICU 2.6 - */ -U_STABLE void U_EXPORT2 + */ +U_STABLE void U_EXPORT2 u_init(UErrorCode *status); #ifndef U_HIDE_SYSTEM_API @@ -66,10 +66,10 @@ u_init(UErrorCode *status); * just before the library unload. *

    * u_cleanup() also clears any ICU heap functions, mutex functions or - * trace functions that may have been set for the process. + * trace functions that may have been set for the process. * This has the effect of restoring ICU to its initial condition, before * any of these override functions were installed. Refer to - * u_setMemoryFunctions(), u_setMutexFunctions and + * u_setMemoryFunctions(), u_setMutexFunctions and * utrace_setFunctions(). If ICU is to be reinitialized after * calling u_cleanup(), these runtime override functions will need to * be set up again if they are still required. @@ -85,7 +85,7 @@ u_init(UErrorCode *status); * calling u_init(). An application must invoke u_init() first from one single * thread before allowing other threads call u_init(). All threads existing * at the time of the first thread's call to u_init() must also call - * u_init() themselves before continuing with other ICU operations. + * u_init() themselves before continuing with other ICU operations. *

    * The use of u_cleanup() just before an application terminates is optional, * but it should be called only once for performance reasons. The primary @@ -98,7 +98,7 @@ u_init(UErrorCode *status); * @stable ICU 2.0 * @system */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 u_cleanup(void); U_CDECL_BEGIN @@ -147,9 +147,9 @@ typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem); * @param status Receives error values. * @stable ICU 2.8 * @system - */ -U_STABLE void U_EXPORT2 -u_setMemoryFunctions(const void *context, UMemAllocFn * U_CALLCONV_FPTR a, UMemReallocFn * U_CALLCONV_FPTR r, UMemFreeFn * U_CALLCONV_FPTR f, + */ +U_STABLE void U_EXPORT2 +u_setMemoryFunctions(const void *context, UMemAllocFn * U_CALLCONV_FPTR a, UMemReallocFn * U_CALLCONV_FPTR r, UMemFreeFn * U_CALLCONV_FPTR f, UErrorCode *status); U_CDECL_END @@ -182,8 +182,8 @@ U_CDECL_BEGIN * as a parameter. * @param context user supplied value, obtained from u_setMutexFunctions(). * @param mutex Receives a pointer that identifies the new mutex. - * The mutex init function must set the UMTX to a non-null value. - * Subsequent calls by ICU to lock, unlock, or destroy a mutex will + * The mutex init function must set the UMTX to a non-null value. + * Subsequent calls by ICU to lock, unlock, or destroy a mutex will * identify the mutex by the UMTX value. * @param status Error status. Report errors back to ICU by setting this variable * with an error code. @@ -213,7 +213,7 @@ U_CDECL_END * u_init() has been called. * @param context This pointer value will be saved, and then (later) passed as * a parameter to the user-supplied mutex functions each time they - * are called. + * are called. * @param init Pointer to a mutex initialization function. Must be non-null. * @param destroy Pointer to the mutex destroy function. Must be non-null. * @param lock pointer to the mutex lock function. Must be non-null. @@ -221,8 +221,8 @@ U_CDECL_END * @param status Receives error values. * @deprecated ICU 52. This function is no longer supported. * @system - */ -U_DEPRECATED void U_EXPORT2 + */ +U_DEPRECATED void U_EXPORT2 u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock, UErrorCode *status); @@ -245,14 +245,14 @@ typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p); * u_init() has been called. * @param context This pointer value will be saved, and then (later) passed as * a parameter to the increment and decrement functions each time they - * are called. This function can only be called + * are called. This function can only be called * @param inc Pointer to a function to do an atomic increment operation. Must be non-null. * @param dec Pointer to a function to do an atomic decrement operation. Must be non-null. * @param status Receives error values. * @deprecated ICU 52. This function is no longer supported. * @system - */ -U_DEPRECATED void U_EXPORT2 + */ +U_DEPRECATED void U_EXPORT2 u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec, UErrorCode *status); diff --git a/deps/icu-small/source/common/unicode/ucnv_cb.h b/deps/icu-small/source/common/unicode/ucnv_cb.h index 632cc0b35f26c5..14169ed61c14c9 100644 --- a/deps/icu-small/source/common/unicode/ucnv_cb.h +++ b/deps/icu-small/source/common/unicode/ucnv_cb.h @@ -8,52 +8,52 @@ * ucnv_cb.h: * External APIs for the ICU's codeset conversion library * Helena Shih - * + * * Modification History: * * Date Name Description */ /** - * \file + * \file * \brief C UConverter functions to aid the writers of callbacks * *

    Callback API for UConverter

    - * + * * These functions are provided here for the convenience of the callback * writer. If you are just looking for callback functions to use, please - * see ucnv_err.h. DO NOT call these functions directly when you are + * see ucnv_err.h. DO NOT call these functions directly when you are * working with converters, unless your code has been called as a callback * via ucnv_setFromUCallback or ucnv_setToUCallback !! - * + * * A note about error codes and overflow. Unlike other ICU functions, * these functions do not expect the error status to be U_ZERO_ERROR. * Callbacks must be much more careful about their error codes. * The error codes used here are in/out parameters, which should be passed * back in the callback's error parameter. - * - * For example, if you call ucnv_cbfromUWriteBytes to write data out - * to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if - * the data did not fit in the target. But this isn't a failing error, + * + * For example, if you call ucnv_cbfromUWriteBytes to write data out + * to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if + * the data did not fit in the target. But this isn't a failing error, * in fact, ucnv_cbfromUWriteBytes may be called AGAIN with the error * status still U_BUFFER_OVERFLOW_ERROR to attempt to write further bytes, * which will also go into the internal overflow buffers. - * + * * Concerning offsets, the 'offset' parameters here are relative to the start - * of SOURCE. For example, Suppose the string "ABCD" was being converted + * of SOURCE. For example, Suppose the string "ABCD" was being converted * from Unicode into a codepage which doesn't have a mapping for 'B'. * 'A' will be written out correctly, but * The FromU Callback will be called on an unassigned character for 'B'. * At this point, this is the state of the world: * Target: A [..] [points after A] * Source: A B [C] D [points to C - B has been consumed] - * 0 1 2 3 - * codePoint = "B" [the unassigned codepoint] - * + * 0 1 2 3 + * codePoint = "B" [the unassigned codepoint] + * * Now, suppose a callback wants to write the substitution character '?' to - * the target. It calls ucnv_cbFromUWriteBytes() to write the ?. - * It should pass ZERO as the offset, because the offset as far as the - * callback is concerned is relative to the SOURCE pointer [which points + * the target. It calls ucnv_cbFromUWriteBytes() to write the ?. + * It should pass ZERO as the offset, because the offset as far as the + * callback is concerned is relative to the SOURCE pointer [which points * before 'C'.] If the callback goes into the args and consumes 'C' also, * it would call FromUWriteBytes with an offset of 1 (and advance the source * pointer). @@ -78,8 +78,8 @@ * @param source source bytes to write * @param length length of bytes to write * @param offsetIndex the relative offset index from callback. - * @param err error status. If U_BUFFER_OVERFLOW is returned, then U_BUFFER_OVERFLOW must - * be returned to the user, because it means that not all data could be written into the target buffer, and some is + * @param err error status. If U_BUFFER_OVERFLOW is returned, then U_BUFFER_OVERFLOW must + * be returned to the user, because it means that not all data could be written into the target buffer, and some is * in the converter error buffer. * @see ucnv_cbFromUWriteSub * @stable ICU 2.0 @@ -92,25 +92,25 @@ ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args, UErrorCode * err); /** - * ONLY used by FromU callback functions. - * This function will write out the correct substitution character sequence + * ONLY used by FromU callback functions. + * This function will write out the correct substitution character sequence * to the target. * * @param args callback fromUnicode arguments * @param offsetIndex the relative offset index from the current source pointer to be used - * @param err error status. If U_BUFFER_OVERFLOW is returned, then U_BUFFER_OVERFLOW must - * be returned to the user, because it means that not all data could be written into the target buffer, and some is + * @param err error status. If U_BUFFER_OVERFLOW is returned, then U_BUFFER_OVERFLOW must + * be returned to the user, because it means that not all data could be written into the target buffer, and some is * in the converter error buffer. * @see ucnv_cbFromUWriteBytes * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorCode * err); /** - * ONLY used by fromU callback functions. + * ONLY used by fromU callback functions. * This function will write out the error character(s) to the target UChar buffer. * * @param args callback fromUnicode arguments @@ -129,7 +129,7 @@ U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args, /** * ONLY used by ToU callback functions. - * This function will write out the specified characters to the target + * This function will write out the specified characters to the target * UChar buffer. * * @param args callback toUnicode arguments @@ -147,7 +147,7 @@ U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args, UErrorCode * err); /** - * ONLY used by ToU callback functions. + * ONLY used by ToU callback functions. * This function will write out the Unicode substitution character (U+FFFD). * * @param args callback fromUnicode arguments diff --git a/deps/icu-small/source/common/unicode/ucnv_err.h b/deps/icu-small/source/common/unicode/ucnv_err.h index 08c96c14407c22..d234710a8b1880 100644 --- a/deps/icu-small/source/common/unicode/ucnv_err.h +++ b/deps/icu-small/source/common/unicode/ucnv_err.h @@ -108,7 +108,7 @@ typedef struct UConverter UConverter; #define UCNV_SKIP_STOP_ON_ILLEGAL "i" /** - * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) * @stable ICU 2.0 */ #define UCNV_ESCAPE_ICU NULL @@ -148,24 +148,24 @@ typedef struct UConverter UConverter; */ #define UCNV_ESCAPE_CSS2 "S" -/** - * The process condition code to be used with the callbacks. - * Codes which are greater than UCNV_IRREGULAR should be +/** + * The process condition code to be used with the callbacks. + * Codes which are greater than UCNV_IRREGULAR should be * passed on to any chained callbacks. * @stable ICU 2.0 */ typedef enum { UCNV_UNASSIGNED = 0, /**< The code point is unassigned. The error code U_INVALID_CHAR_FOUND will be set. */ - UCNV_ILLEGAL = 1, /**< The code point is illegal. For example, + UCNV_ILLEGAL = 1, /**< The code point is illegal. For example, \\x81\\x2E is illegal in SJIS because \\x2E - is not a valid trail byte for the \\x81 + is not a valid trail byte for the \\x81 lead byte. Also, starting with Unicode 3.0.1, non-shortest byte sequences in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061) are also illegal, not just irregular. The error code U_ILLEGAL_CHAR_FOUND will be set. */ - UCNV_IRREGULAR = 2, /**< The codepoint is not a regular sequence in + UCNV_IRREGULAR = 2, /**< The codepoint is not a regular sequence in the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF are irregular UTF-8 byte sequences for single surrogate code points. @@ -179,8 +179,8 @@ typedef enum { converter. the pointer available as the 'context' is an alias to the original converters' context pointer. If the context must be owned - by the new converter, the callback must clone - the data and call ucnv_setFromUCallback + by the new converter, the callback must clone + the data and call ucnv_setFromUCallback (or setToUCallback) with the correct pointer. @stable ICU 2.2 */ @@ -269,7 +269,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP ( * DO NOT CALL THIS FUNCTION DIRECTLY! * This From Unicode callback skips any ILLEGAL_SEQUENCE, or * skips only UNASSINGED_SEQUENCE depending on the context parameter - * simply ignoring those characters. + * simply ignoring those characters. * * @param context The function currently recognizes the callback options: * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, @@ -295,7 +295,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP ( /** * DO NOT CALL THIS FUNCTION DIRECTLY! - * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or + * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or * UNASSIGNED_SEQUENCE depending on context parameter, with the * current substitution string for the converter. This is the default * callback. @@ -330,33 +330,33 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE ( * * @param context The function currently recognizes the callback options: *
      - *
    • UCNV_ESCAPE_ICU: Substitues the ILLEGAL SEQUENCE with the hexadecimal - * representation in the format %UXXXX, e.g. "%uFFFE%u00AC%uC8FE"). - * In the Event the converter doesn't support the characters {%,U}[A-F][0-9], + *
    • UCNV_ESCAPE_ICU: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format %UXXXX, e.g. "%uFFFE%u00AC%uC8FE"). + * In the Event the converter doesn't support the characters {%,U}[A-F][0-9], * it will substitute the illegal sequence with the substitution characters. * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as * %UD84D%UDC56
    • - *
    • UCNV_ESCAPE_JAVA: Substitues the ILLEGAL SEQUENCE with the hexadecimal - * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). - * In the Event the converter doesn't support the characters {\,u}[A-F][0-9], + *
    • UCNV_ESCAPE_JAVA: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). + * In the Event the converter doesn't support the characters {\,u}[A-F][0-9], * it will substitute the illegal sequence with the substitution characters. * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as * \\uD84D\\uDC56
    • - *
    • UCNV_ESCAPE_C: Substitues the ILLEGAL SEQUENCE with the hexadecimal - * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). - * In the Event the converter doesn't support the characters {\,u,U}[A-F][0-9], + *
    • UCNV_ESCAPE_C: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). + * In the Event the converter doesn't support the characters {\,u,U}[A-F][0-9], * it will substitute the illegal sequence with the substitution characters. * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as * \\U00023456
    • - *
    • UCNV_ESCAPE_XML_DEC: Substitues the ILLEGAL SEQUENCE with the decimal - * representation in the format \htmlonly&#DDDDDDDD;, e.g. "&#65534;&#172;&#51454;")\endhtmlonly. - * In the Event the converter doesn't support the characters {&,#}[0-9], + *
    • UCNV_ESCAPE_XML_DEC: Substitues the ILLEGAL SEQUENCE with the decimal + * representation in the format \htmlonly&#DDDDDDDD;, e.g. "&#65534;&#172;&#51454;")\endhtmlonly. + * In the Event the converter doesn't support the characters {&,#}[0-9], * it will substitute the illegal sequence with the substitution characters. * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as * &#144470; and Zero padding is ignored.
    • - *
    • UCNV_ESCAPE_XML_HEX:Substitues the ILLEGAL SEQUENCE with the decimal - * representation in the format \htmlonly&#xXXXX; e.g. "&#xFFFE;&#x00AC;&#xC8FE;")\endhtmlonly. - * In the Event the converter doesn't support the characters {&,#,x}[0-9], + *
    • UCNV_ESCAPE_XML_HEX:Substitues the ILLEGAL SEQUENCE with the decimal + * representation in the format \htmlonly&#xXXXX; e.g. "&#xFFFE;&#x00AC;&#xC8FE;")\endhtmlonly. + * In the Event the converter doesn't support the characters {&,#,x}[0-9], * it will substitute the illegal sequence with the substitution characters. * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as * \htmlonly&#x23456;\endhtmlonly
    • @@ -384,7 +384,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE ( * DO NOT CALL THIS FUNCTION DIRECTLY! * This To Unicode callback skips any ILLEGAL_SEQUENCE, or * skips only UNASSINGED_SEQUENCE depending on the context parameter - * simply ignoring those characters. + * simply ignoring those characters. * * @param context The function currently recognizes the callback options: * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, @@ -408,7 +408,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP ( /** * DO NOT CALL THIS FUNCTION DIRECTLY! - * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or + * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or * UNASSIGNED_SEQUENCE depending on context parameter, with the * Unicode substitution character, U+FFFD. * @@ -462,4 +462,4 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE ( #endif -/*UCNV_ERR_H*/ +/*UCNV_ERR_H*/ diff --git a/deps/icu-small/source/common/unicode/ucnvsel.h b/deps/icu-small/source/common/unicode/ucnvsel.h index 5fee53f179ace7..d423845ceb6297 100644 --- a/deps/icu-small/source/common/unicode/ucnvsel.h +++ b/deps/icu-small/source/common/unicode/ucnvsel.h @@ -55,7 +55,7 @@ typedef struct UConverterSelector UConverterSelector; * If converterListSize is 0, build for all available converters. * If excludedCodePoints is NULL, don't exclude any code points. * - * @param converterList a pointer to encoding names needed to be involved. + * @param converterList a pointer to encoding names needed to be involved. * Can be NULL if converterListSize==0. * The list and the names will be cloned, and the caller * retains ownership of the original. diff --git a/deps/icu-small/source/common/unicode/uconfig.h b/deps/icu-small/source/common/unicode/uconfig.h index 9c82d828125603..bbc232d1ed8fdf 100644 --- a/deps/icu-small/source/common/unicode/uconfig.h +++ b/deps/icu-small/source/common/unicode/uconfig.h @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. @@ -76,7 +76,7 @@ #endif /** - * Determines whether to enable auto cleanup of libraries. + * Determines whether to enable auto cleanup of libraries. * @internal */ #ifndef UCLN_NO_AUTO_CLEANUP @@ -256,7 +256,7 @@ # define UCONFIG_NO_FILE_IO 0 #endif -#if UCONFIG_NO_FILE_IO && defined(U_TIMEZONE_FILES_DIR) +#if UCONFIG_NO_FILE_IO && defined(U_TIMEZONE_FILES_DIR) # error Contradictory file io switches in uconfig.h. #endif @@ -374,7 +374,7 @@ * On platforms where U_PLATFORM_HAS_WIN32_API is true, this switch determines * if the Windows platform APIs are used for LCID<->Locale Name conversions. * Otherwise, only the built-in ICU tables are used. - * + * * @internal ICU 64 */ #ifndef UCONFIG_USE_WINDOWS_LCID_MAPPING_API @@ -453,4 +453,4 @@ # define UCONFIG_NO_FILTERED_BREAK_ITERATION 0 #endif -#endif +#endif // __UCONFIG_H__ diff --git a/deps/icu-small/source/common/unicode/ucpmap.h b/deps/icu-small/source/common/unicode/ucpmap.h index f2c42b6b7f4bee..31e1365cac850a 100644 --- a/deps/icu-small/source/common/unicode/ucpmap.h +++ b/deps/icu-small/source/common/unicode/ucpmap.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - U_CDECL_BEGIN /** @@ -28,7 +26,7 @@ U_CDECL_BEGIN * * @see UCPTrie * @see UMutableCPTrie - * @draft ICU 63 + * @stable ICU 63 */ typedef struct UCPMap UCPMap; @@ -39,13 +37,13 @@ typedef struct UCPMap UCPMap; * @see ucpmap_getRange * @see ucptrie_getRange * @see umutablecptrie_getRange - * @draft ICU 63 + * @stable ICU 63 */ enum UCPMapRangeOption { /** * ucpmap_getRange() enumerates all same-value ranges as stored in the map. * Most users should use this option. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_NORMAL, /** @@ -61,7 +59,7 @@ enum UCPMapRangeOption { * special values optimized for UTF-16 string processing * or for special error behavior for unpaired surrogates, * but those values are not to be associated with the lead surrogate code *points*. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_FIXED_LEAD_SURROGATES, /** @@ -77,7 +75,7 @@ enum UCPMapRangeOption { * special values optimized for UTF-16 string processing * or for special error behavior for unpaired surrogates, * but those values are not to be associated with the lead surrogate code *points*. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_FIXED_ALL_SURROGATES }; @@ -93,7 +91,7 @@ typedef enum UCPMapRangeOption UCPMapRangeOption; * @param c the code point * @return the map value, * or an implementation-defined error value if the code point is not in the range 0..U+10FFFF - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 ucpmap_get(const UCPMap *map, UChar32 c); @@ -110,7 +108,7 @@ ucpmap_get(const UCPMap *map, UChar32 c); * @param context an opaque pointer, as passed into the getRange function * @param value a value from the map * @return the modified value - * @draft ICU 63 + * @stable ICU 63 */ typedef uint32_t U_CALLCONV UCPMapValueFilter(const void *context, uint32_t value); @@ -149,7 +147,7 @@ UCPMapValueFilter(const void *context, uint32_t value); * may have been modified by filter(context, map value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 ucpmap_getRange(const UCPMap *map, UChar32 start, @@ -158,5 +156,4 @@ ucpmap_getRange(const UCPMap *map, UChar32 start, U_CDECL_END -#endif // U_HIDE_DRAFT_API #endif diff --git a/deps/icu-small/source/common/unicode/ucptrie.h b/deps/icu-small/source/common/unicode/ucptrie.h index 2718c984e43197..be06a227928286 100644 --- a/deps/icu-small/source/common/unicode/ucptrie.h +++ b/deps/icu-small/source/common/unicode/ucptrie.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - #include "unicode/localpointer.h" #include "unicode/ucpmap.h" #include "unicode/utf8.h" @@ -55,7 +53,7 @@ typedef union UCPTrieData { * The macros will return bogus values, or may crash, if used on the wrong type or value width. * * @see UMutableCPTrie - * @draft ICU 63 + * @stable ICU 63 */ struct UCPTrie { #ifndef U_IN_DOXYGEN @@ -115,23 +113,23 @@ typedef struct UCPTrie UCPTrie; * @see umutablecptrie_buildImmutable * @see ucptrie_openFromBinary * @see ucptrie_getType - * @draft ICU 63 + * @stable ICU 63 */ enum UCPTrieType { /** * For ucptrie_openFromBinary() to accept any type. * ucptrie_getType() will return the actual type. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_ANY = -1, /** * Fast/simple/larger BMP data structure. Use functions and "fast" macros. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_FAST, /** * Small/slower BMP data structure. Use functions and "small" macros. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_SMALL }; @@ -145,30 +143,30 @@ typedef enum UCPTrieType UCPTrieType; * @see umutablecptrie_buildImmutable * @see ucptrie_openFromBinary * @see ucptrie_getValueWidth - * @draft ICU 63 + * @stable ICU 63 */ enum UCPTrieValueWidth { /** * For ucptrie_openFromBinary() to accept any data value width. * ucptrie_getValueWidth() will return the actual data value width. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_ANY = -1, /** * The trie stores 16 bits per data value. * It returns them as unsigned values 0..0xffff=65535. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_16, /** * The trie stores 32 bits per data value. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_32, /** * The trie stores 8 bits per data value. * It returns them as unsigned values 0..0xff=255. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_8 }; @@ -200,7 +198,7 @@ typedef enum UCPTrieValueWidth UCPTrieValueWidth; * @see umutablecptrie_open * @see umutablecptrie_buildImmutable * @see ucptrie_toBinary - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrie * U_EXPORT2 ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, @@ -211,30 +209,11 @@ ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, * Closes a trie and releases associated memory. * * @param trie the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 ucptrie_close(UCPTrie *trie); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUCPTriePointer - * "Smart pointer" class, closes a UCPTrie via ucptrie_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @draft ICU 63 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close); - -U_NAMESPACE_END - -#endif - /** * Returns the trie type. * @@ -242,7 +221,7 @@ U_NAMESPACE_END * @return the trie type * @see ucptrie_openFromBinary * @see UCPTRIE_TYPE_ANY - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrieType U_EXPORT2 ucptrie_getType(const UCPTrie *trie); @@ -254,7 +233,7 @@ ucptrie_getType(const UCPTrie *trie); * @return the number of bits in a trie data value * @see ucptrie_openFromBinary * @see UCPTRIE_VALUE_BITS_ANY - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrieValueWidth U_EXPORT2 ucptrie_getValueWidth(const UCPTrie *trie); @@ -271,7 +250,7 @@ ucptrie_getValueWidth(const UCPTrie *trie); * @param c the code point * @return the trie value, * or the trie error value if the code point is not in the range 0..U+10FFFF - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 ucptrie_get(const UCPTrie *trie, UChar32 c); @@ -310,7 +289,7 @@ ucptrie_get(const UCPTrie *trie, UChar32 c); * may have been modified by filter(context, trie value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 ucptrie_getRange(const UCPTrie *trie, UChar32 start, @@ -330,7 +309,7 @@ ucptrie_getRange(const UCPTrie *trie, UChar32 start, * @return the number of bytes written or (if buffer overflow) needed for the trie * * @see ucptrie_openFromBinary() - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI int32_t U_EXPORT2 ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode *pErrorCode); @@ -341,7 +320,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_16 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_16(trie, i) ((trie)->data.ptr16[i]) @@ -351,7 +330,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_32 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_32(trie, i) ((trie)->data.ptr32[i]) @@ -361,7 +340,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_8 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_8(trie, i) ((trie)->data.ptr8[i]) @@ -373,7 +352,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point * @return The code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_CP_INDEX(trie, 0xffff, c)) @@ -385,7 +364,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point * @return The code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_SMALL_GET(trie, dataAccess, c) \ dataAccess(trie, _UCPTRIE_CP_INDEX(trie, UCPTRIE_SMALL_MAX, c)) @@ -401,9 +380,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param limit (const UChar *, in) the limit pointer for the text, or NULL if NUL-terminated * @param c (UChar32, out) variable for the code point * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U16_NEXT(trie, dataAccess, src, limit, c, result) { \ +#define UCPTRIE_FAST_U16_NEXT(trie, dataAccess, src, limit, c, result) UPRV_BLOCK_MACRO_BEGIN { \ (c) = *(src)++; \ int32_t __index; \ if (!U16_IS_SURROGATE(c)) { \ @@ -419,7 +398,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-16: Reads the previous code point (UChar32 c, out), pre-decrements src, @@ -432,9 +411,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param src (const UChar *, in/out) the source text pointer * @param c (UChar32, out) variable for the code point * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U16_PREV(trie, dataAccess, start, src, c, result) { \ +#define UCPTRIE_FAST_U16_PREV(trie, dataAccess, start, src, c, result) UPRV_BLOCK_MACRO_BEGIN { \ (c) = *--(src); \ int32_t __index; \ if (!U16_IS_SURROGATE(c)) { \ @@ -450,7 +429,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-8: Post-increments src and gets a value from the trie. @@ -466,9 +445,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param src (const char *, in/out) the source text pointer * @param limit (const char *, in) the limit pointer for the text (must not be NULL) * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U8_NEXT(trie, dataAccess, src, limit, result) { \ +#define UCPTRIE_FAST_U8_NEXT(trie, dataAccess, src, limit, result) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __lead = (uint8_t)*(src)++; \ if (!U8_IS_SINGLE(__lead)) { \ uint8_t __t1, __t2, __t3; \ @@ -496,7 +475,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __lead); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-8: Pre-decrements src and gets a value from the trie. @@ -512,9 +491,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param start (const char *, in) the start pointer for the text * @param src (const char *, in/out) the source text pointer * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U8_PREV(trie, dataAccess, start, src, result) { \ +#define UCPTRIE_FAST_U8_PREV(trie, dataAccess, start, src, result) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __index = (uint8_t)*--(src); \ if (!U8_IS_SINGLE(__index)) { \ __index = ucptrie_internalU8PrevIndex((trie), __index, (const uint8_t *)(start), \ @@ -523,7 +502,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * __index >>= 3; \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * Returns a trie value for an ASCII code point, without range checking. @@ -532,7 +511,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point; must be U+0000..U+007F * @return The ASCII code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_ASCII_GET(trie, dataAccess, c) dataAccess(trie, c) @@ -545,7 +524,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point, must be U+0000..U+FFFF * @return The BMP code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_BMP_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_FAST_INDEX(trie, c)) @@ -557,7 +536,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point, must be U+10000..U+10FFFF * @return The supplementary code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_SUPP_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_SMALL_INDEX(trie, c)) @@ -642,5 +621,24 @@ ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c, U_CDECL_END #endif // U_IN_DOXYGEN -#endif // U_HIDE_DRAFT_API + +#if U_SHOW_CPLUSPLUS_API + +U_NAMESPACE_BEGIN + +/** + * \class LocalUCPTriePointer + * "Smart pointer" class, closes a UCPTrie via ucptrie_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 63 + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close); + +U_NAMESPACE_END + +#endif // U_SHOW_CPLUSPLUS_API + #endif diff --git a/deps/icu-small/source/common/unicode/ucurr.h b/deps/icu-small/source/common/unicode/ucurr.h index a1c6de80b772f7..f91cc0df7c61cc 100644 --- a/deps/icu-small/source/common/unicode/ucurr.h +++ b/deps/icu-small/source/common/unicode/ucurr.h @@ -13,7 +13,7 @@ #include "unicode/uenum.h" /** - * \file + * \file * \brief C API: Encapsulates information about a currency. * * The ucurr API encapsulates information about a currency, as defined by @@ -61,11 +61,11 @@ enum UCurrencyUsage { #endif // U_HIDE_DEPRECATED_API }; /** Currency Usage used for Decimal Format */ -typedef enum UCurrencyUsage UCurrencyUsage; +typedef enum UCurrencyUsage UCurrencyUsage; /** * Finds a currency code for the given locale. - * @param locale the locale for which to retrieve a currency code. + * @param locale the locale for which to retrieve a currency code. * Currency can be specified by the "currency" keyword * in which case it overrides the default currency code * @param buff fill in buffer. Can be NULL for preflighting. @@ -74,8 +74,8 @@ typedef enum UCurrencyUsage UCurrencyUsage; * must not be NULL. * @param ec error code * @return length of the currency string. It should always be 3. If 0, - * currency couldn't be found or the input values are - * invalid. + * currency couldn't be found or the input values are + * invalid. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -134,14 +134,14 @@ typedef const void* UCurrRegistryKey; * @stable ICU 2.6 */ U_STABLE UCurrRegistryKey U_EXPORT2 -ucurr_register(const UChar* isoCode, - const char* locale, +ucurr_register(const UChar* isoCode, + const char* locale, UErrorCode* status); /** * Unregister the previously-registered currency definitions using the * URegistryKey returned from ucurr_register. Key becomes invalid after - * a successful call and should not be used again. Any currency - * that might have been hidden by the original ucurr_register call is + * a successful call and should not be used again. Any currency + * that might have been hidden by the original ucurr_register call is * restored. * @param key the registry key returned by a previous call to ucurr_register * @param status the in/out status code, no special meanings are assigned @@ -159,14 +159,14 @@ ucurr_unregister(UCurrRegistryKey key, UErrorCode* status); * @param currency null-terminated 3-letter ISO 4217 code * @param locale locale in which to display currency * @param nameStyle selector for which kind of name to return - * @param isChoiceFormat fill-in set to TRUE if the returned value - * is a ChoiceFormat pattern; otherwise it is a static string + * @param isChoiceFormat always set to FALSE, or can be NULL; + * display names are static strings; + * since ICU 4.4, ChoiceFormat patterns are no longer supported * @param len fill-in parameter to receive length of result * @param ec error code * @return pointer to display string of 'len' UChars. If the resource * data contains no entry for 'currency', then 'currency' itself is - * returned. If *isChoiceFormat is TRUE, then the result is a - * ChoiceFormat pattern. Otherwise it is a static string. + * returned. * @stable ICU 2.6 */ U_STABLE const UChar* U_EXPORT2 @@ -183,8 +183,9 @@ ucurr_getName(const UChar* currency, * currency object in the en_US locale is "US dollar" or "US dollars". * @param currency null-terminated 3-letter ISO 4217 code * @param locale locale in which to display currency - * @param isChoiceFormat fill-in set to TRUE if the returned value - * is a ChoiceFormat pattern; otherwise it is a static string + * @param isChoiceFormat always set to FALSE, or can be NULL; + * display names are static strings; + * since ICU 4.4, ChoiceFormat patterns are no longer supported * @param pluralCount plural count * @param len fill-in parameter to receive length of result * @param ec error code @@ -240,7 +241,7 @@ ucurr_getDefaultFractionDigits(const UChar* currency, * @stable ICU 54 */ U_STABLE int32_t U_EXPORT2 -ucurr_getDefaultFractionDigitsForUsage(const UChar* currency, +ucurr_getDefaultFractionDigitsForUsage(const UChar* currency, const UCurrencyUsage usage, UErrorCode* ec); @@ -320,7 +321,7 @@ typedef enum UCurrCurrencyType { * Provides a UEnumeration object for listing ISO-4217 codes. * @param currType You can use one of several UCurrCurrencyType values for this * variable. You can also | (or) them together to get a specific list of - * currencies. Most people will want to use the (UCURR_CURRENCY|UCURR_NON_DEPRECATED) value to + * currencies. Most people will want to use the (UCURR_COMMON|UCURR_NON_DEPRECATED) value to * get a list of current currencies. * @param pErrorCode Error code * @stable ICU 3.2 @@ -329,38 +330,38 @@ U_STABLE UEnumeration * U_EXPORT2 ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode); /** - * Queries if the given ISO 4217 3-letter code is available on the specified date range. - * - * Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to' - * - * When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time. + * Queries if the given ISO 4217 3-letter code is available on the specified date range. + * + * Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to' + * + * When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time. * If 'from' and 'to' are same UDate value, this method checks if the specified currency is available on that date. - * - * @param isoCode - * The ISO 4217 3-letter code. - * - * @param from - * The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability - * of the currency any date before 'to' - * - * @param to - * The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of - * the currency any date after 'from' - * - * @param errorCode - * ICU error code - * - * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range. - * - * @stable ICU 4.8 - */ + * + * @param isoCode + * The ISO 4217 3-letter code. + * + * @param from + * The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability + * of the currency any date before 'to' + * + * @param to + * The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of + * the currency any date after 'from' + * + * @param errorCode + * ICU error code + * + * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range. + * + * @stable ICU 4.8 + */ U_STABLE UBool U_EXPORT2 -ucurr_isAvailable(const UChar* isoCode, - UDate from, - UDate to, +ucurr_isAvailable(const UChar* isoCode, + UDate from, + UDate to, UErrorCode* errorCode); -/** +/** * Finds the number of valid currency codes for the * given locale and date. * @param locale the locale for which to retrieve the @@ -375,36 +376,36 @@ ucurr_isAvailable(const UChar* isoCode, * @stable ICU 4.0 */ U_STABLE int32_t U_EXPORT2 -ucurr_countCurrencies(const char* locale, - UDate date, - UErrorCode* ec); +ucurr_countCurrencies(const char* locale, + UDate date, + UErrorCode* ec); -/** - * Finds a currency code for the given locale and date - * @param locale the locale for which to retrieve a currency code. - * Currency can be specified by the "currency" keyword - * in which case it overrides the default currency code - * @param date the date for which to retrieve a currency code for - * the given locale. +/** + * Finds a currency code for the given locale and date + * @param locale the locale for which to retrieve a currency code. + * Currency can be specified by the "currency" keyword + * in which case it overrides the default currency code + * @param date the date for which to retrieve a currency code for + * the given locale. * @param index the index within the available list of currency codes * for the given locale on the given date. - * @param buff fill in buffer. Can be NULL for preflighting. - * @param buffCapacity capacity of the fill in buffer. Can be 0 for - * preflighting. If it is non-zero, the buff parameter - * must not be NULL. - * @param ec error code - * @return length of the currency string. It should always be 3. - * If 0, currency couldn't be found or the input values are - * invalid. - * @stable ICU 4.0 - */ -U_STABLE int32_t U_EXPORT2 -ucurr_forLocaleAndDate(const char* locale, - UDate date, + * @param buff fill in buffer. Can be NULL for preflighting. + * @param buffCapacity capacity of the fill in buffer. Can be 0 for + * preflighting. If it is non-zero, the buff parameter + * must not be NULL. + * @param ec error code + * @return length of the currency string. It should always be 3. + * If 0, currency couldn't be found or the input values are + * invalid. + * @stable ICU 4.0 + */ +U_STABLE int32_t U_EXPORT2 +ucurr_forLocaleAndDate(const char* locale, + UDate date, int32_t index, - UChar* buff, - int32_t buffCapacity, - UErrorCode* ec); + UChar* buff, + int32_t buffCapacity, + UErrorCode* ec); /** * Given a key and a locale, returns an array of string values in a preferred diff --git a/deps/icu-small/source/common/unicode/udata.h b/deps/icu-small/source/common/unicode/udata.h index 6419c359f606af..325ffcf17db054 100644 --- a/deps/icu-small/source/common/unicode/udata.h +++ b/deps/icu-small/source/common/unicode/udata.h @@ -38,16 +38,16 @@ U_CDECL_BEGIN * * See the User Guide Data Management chapter. */ - + #ifndef U_HIDE_INTERNAL_API /** - * Character used to separate package names from tree names + * Character used to separate package names from tree names * @internal ICU 3.0 */ #define U_TREE_SEPARATOR '-' /** - * String used to separate package names from tree names + * String used to separate package names from tree names * @internal ICU 3.0 */ #define U_TREE_SEPARATOR_STRING "-" @@ -65,7 +65,7 @@ U_CDECL_BEGIN #define U_TREE_ENTRY_SEP_STRING "/" /** - * Alias for standard ICU data + * Alias for standard ICU data * @internal ICU 3.0 */ #define U_ICUDATA_ALIAS "ICUDATA" @@ -115,7 +115,7 @@ typedef struct { * @stable ICU 2.0 */ uint16_t size; - /** unused, set to 0 + /** unused, set to 0 * @stable ICU 2.0*/ uint16_t reservedWord; @@ -124,27 +124,27 @@ typedef struct { * @stable ICU 2.0 */ uint8_t isBigEndian; - /** see U_CHARSET_FAMILY values in utypes.h + /** see U_CHARSET_FAMILY values in utypes.h * @stable ICU 2.0*/ uint8_t charsetFamily; - /** sizeof(UChar), one of { 1, 2, 4 } + /** sizeof(UChar), one of { 1, 2, 4 } * @stable ICU 2.0*/ uint8_t sizeofUChar; - /** unused, set to 0 + /** unused, set to 0 * @stable ICU 2.0*/ uint8_t reservedByte; - /** data format identifier + /** data format identifier * @stable ICU 2.0*/ uint8_t dataFormat[4]; - /** versions: [0] major [1] minor [2] milli [3] micro + /** versions: [0] major [1] minor [2] milli [3] micro * @stable ICU 2.0*/ uint8_t formatVersion[4]; - /** versions: [0] major [1] minor [2] milli [3] micro + /** versions: [0] major [1] minor [2] milli [3] micro * @stable ICU 2.0*/ uint8_t dataVersion[4]; } UDataInfo; @@ -264,25 +264,6 @@ udata_openChoice(const char *path, const char *type, const char *name, U_STABLE void U_EXPORT2 udata_close(UDataMemory *pData); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUDataMemoryPointer - * "Smart pointer" class, closes a UDataMemory via udata_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 4.4 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close); - -U_NAMESPACE_END - -#endif - /** * Get the pointer to the actual data inside the data memory. * The data is read-only. @@ -421,17 +402,36 @@ typedef enum UDataFileAccess { /** * This function may be called to control how ICU loads data. It must be called - * before any ICU data is loaded, including application data loaded with - * ures/ResourceBundle or udata APIs. This function is not multithread safe. + * before any ICU data is loaded, including application data loaded with + * ures/ResourceBundle or udata APIs. This function is not multithread safe. * The results of calling it while other threads are loading data are undefined. * @param access The type of file access to be used * @param status Error code. * @see UDataFileAccess - * @stable ICU 3.4 + * @stable ICU 3.4 */ U_STABLE void U_EXPORT2 udata_setFileAccess(UDataFileAccess access, UErrorCode *status); U_CDECL_END +#if U_SHOW_CPLUSPLUS_API + +U_NAMESPACE_BEGIN + +/** + * \class LocalUDataMemoryPointer + * "Smart pointer" class, closes a UDataMemory via udata_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 4.4 + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close); + +U_NAMESPACE_END + +#endif // U_SHOW_CPLUSPLUS_API + #endif diff --git a/deps/icu-small/source/common/unicode/uenum.h b/deps/icu-small/source/common/unicode/uenum.h index eb8ecdf88b6ec5..c670eeafb1626b 100644 --- a/deps/icu-small/source/common/unicode/uenum.h +++ b/deps/icu-small/source/common/unicode/uenum.h @@ -30,9 +30,9 @@ U_NAMESPACE_END /** * \file - * \brief C API: String Enumeration + * \brief C API: String Enumeration */ - + /** * An enumeration object. * For usage in C programs. @@ -77,7 +77,7 @@ U_NAMESPACE_END * U_ENUM_OUT_OF_SYNC_ERROR. * This is a convenience function. It can end up being very * expensive as all the items might have to be pre-fetched (depending - * on the type of data being traversed). Use with caution and only + * on the type of data being traversed). Use with caution and only * when necessary. * @param en UEnumeration structure pointer * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the @@ -153,7 +153,7 @@ uenum_next(UEnumeration* en, * to start at the first element. * @param en the iterator object * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if - * the iterator is out of sync with its service. + * the iterator is out of sync with its service. * @stable ICU 2.2 */ U_STABLE void U_EXPORT2 diff --git a/deps/icu-small/source/common/unicode/uidna.h b/deps/icu-small/source/common/unicode/uidna.h index cb79ba8545008e..0dafb762017441 100644 --- a/deps/icu-small/source/common/unicode/uidna.h +++ b/deps/icu-small/source/common/unicode/uidna.h @@ -538,7 +538,7 @@ enum { * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations * multiple times to an input string will yield the same result as applying the operation * once. - * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) + * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string). * * @param src Input UChar array containing label in Unicode. @@ -549,18 +549,18 @@ enum { * * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points * and do not use STD3 ASCII rules - * If unassigned code points are found the operation fails with + * If unassigned code points are found the operation fails with * U_UNASSIGNED_ERROR error code. * * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations - * If this option is set, the unassigned code points are in the input + * If this option is set, the unassigned code points are in the input * are treated as normal Unicode code points. * * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions - * If this option is set and the input does not satisfy STD3 rules, + * If this option is set and the input does not satisfy STD3 rules, * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR * - * @param parseError Pointer to UParseError struct to receive information on position + * @param parseError Pointer to UParseError struct to receive information on position * of error if an error is encountered. Can be NULL. * @param status ICU in/out error code parameter. * U_INVALID_CHAR_FOUND if src contains @@ -573,7 +573,7 @@ enum { * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. */ U_DEPRECATED int32_t U_EXPORT2 -uidna_toASCII(const UChar* src, int32_t srcLength, +uidna_toASCII(const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UParseError* parseError, @@ -594,21 +594,21 @@ uidna_toASCII(const UChar* src, int32_t srcLength, * * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points * and do not use STD3 ASCII rules - * If unassigned code points are found the operation fails with + * If unassigned code points are found the operation fails with * U_UNASSIGNED_ERROR error code. * * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations - * If this option is set, the unassigned code points are in the input - * are treated as normal Unicode code points. Note: This option is - * required on toUnicode operation because the RFC mandates + * If this option is set, the unassigned code points are in the input + * are treated as normal Unicode code points. Note: This option is + * required on toUnicode operation because the RFC mandates * verification of decoded ACE input by applying toASCII and comparing * its output with source * * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions - * If this option is set and the input does not satisfy STD3 rules, + * If this option is set and the input does not satisfy STD3 rules, * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR * - * @param parseError Pointer to UParseError struct to receive information on position + * @param parseError Pointer to UParseError struct to receive information on position * of error if an error is encountered. Can be NULL. * @param status ICU in/out error code parameter. * U_INVALID_CHAR_FOUND if src contains @@ -630,14 +630,14 @@ uidna_toUnicode(const UChar* src, int32_t srcLength, /** * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. - * This operation is done on complete domain names, e.g: "www.example.com". - * It is important to note that this operation can fail. If it fails, then the input + * This operation is done on complete domain names, e.g: "www.example.com". + * It is important to note that this operation can fail. If it fails, then the input * domain name cannot be used as an Internationalized Domain Name and the application * should have methods defined to deal with the failure. * * Note: IDNA RFC specifies that a conformant application should divide a domain name - * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, - * and then convert. This function does not offer that level of granularity. The options once + * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, + * and then convert. This function does not offer that level of granularity. The options once * set will apply to all labels in the domain name * * @param src Input UChar array containing IDN in Unicode. @@ -648,18 +648,18 @@ uidna_toUnicode(const UChar* src, int32_t srcLength, * * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points * and do not use STD3 ASCII rules - * If unassigned code points are found the operation fails with + * If unassigned code points are found the operation fails with * U_UNASSIGNED_CODE_POINT_FOUND error code. * * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations - * If this option is set, the unassigned code points are in the input + * If this option is set, the unassigned code points are in the input * are treated as normal Unicode code points. * * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions - * If this option is set and the input does not satisfy STD3 rules, + * If this option is set and the input does not satisfy STD3 rules, * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR * - * @param parseError Pointer to UParseError struct to receive information on position + * @param parseError Pointer to UParseError struct to receive information on position * of error if an error is encountered. Can be NULL. * @param status ICU in/out error code parameter. * U_INVALID_CHAR_FOUND if src contains @@ -680,11 +680,11 @@ uidna_IDNToASCII( const UChar* src, int32_t srcLength, /** * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. - * This operation is done on complete domain names, e.g: "www.example.com". + * This operation is done on complete domain names, e.g: "www.example.com". * * Note: IDNA RFC specifies that a conformant application should divide a domain name - * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, - * and then convert. This function does not offer that level of granularity. The options once + * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, + * and then convert. This function does not offer that level of granularity. The options once * set will apply to all labels in the domain name * * @param src Input UChar array containing IDN in ASCII (ACE encoded) form. @@ -695,18 +695,18 @@ uidna_IDNToASCII( const UChar* src, int32_t srcLength, * * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points * and do not use STD3 ASCII rules - * If unassigned code points are found the operation fails with + * If unassigned code points are found the operation fails with * U_UNASSIGNED_CODE_POINT_FOUND error code. * * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations - * If this option is set, the unassigned code points are in the input + * If this option is set, the unassigned code points are in the input * are treated as normal Unicode code points. * * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions - * If this option is set and the input does not satisfy STD3 rules, + * If this option is set and the input does not satisfy STD3 rules, * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR * - * @param parseError Pointer to UParseError struct to receive information on position + * @param parseError Pointer to UParseError struct to receive information on position * of error if an error is encountered. Can be NULL. * @param status ICU in/out error code parameter. * U_INVALID_CHAR_FOUND if src contains @@ -728,10 +728,10 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, /** * IDNA2003: Compare two IDN strings for equivalence. * This function splits the domain names into labels and compares them. - * According to IDN RFC, whenever two labels are compared, they are - * considered equal if and only if their ASCII forms (obtained by + * According to IDN RFC, whenever two labels are compared, they are + * considered equal if and only if their ASCII forms (obtained by * applying toASCII) match using an case-insensitive ASCII comparison. - * Two domain names are considered a match if and only if all labels + * Two domain names are considered a match if and only if all labels * match regardless of whether label separators match. * * @param s1 First source string. @@ -743,15 +743,15 @@ uidna_IDNToUnicode( const UChar* src, int32_t srcLength, * * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points * and do not use STD3 ASCII rules - * If unassigned code points are found the operation fails with + * If unassigned code points are found the operation fails with * U_UNASSIGNED_CODE_POINT_FOUND error code. * * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations - * If this option is set, the unassigned code points are in the input + * If this option is set, the unassigned code points are in the input * are treated as normal Unicode code points. * * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions - * If this option is set and the input does not satisfy STD3 rules, + * If this option is set and the input does not satisfy STD3 rules, * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR * * @param status ICU error code in/out parameter. diff --git a/deps/icu-small/source/common/unicode/uiter.h b/deps/icu-small/source/common/unicode/uiter.h index 3b8537204cecfa..11ad75acd515c6 100644 --- a/deps/icu-small/source/common/unicode/uiter.h +++ b/deps/icu-small/source/common/unicode/uiter.h @@ -171,7 +171,7 @@ UCharIteratorHasNext(UCharIterator *iter); */ typedef UBool U_CALLCONV UCharIteratorHasPrevious(UCharIterator *iter); - + /** * Function type declaration for UCharIterator.current(). * diff --git a/deps/icu-small/source/common/unicode/uldnames.h b/deps/icu-small/source/common/unicode/uldnames.h index 3a3c0a06573c36..3ebffa23db5f12 100644 --- a/deps/icu-small/source/common/unicode/uldnames.h +++ b/deps/icu-small/source/common/unicode/uldnames.h @@ -45,11 +45,11 @@ typedef enum { */ struct ULocaleDisplayNames; -/** - * C typedef for struct ULocaleDisplayNames. - * @stable ICU 4.4 +/** + * C typedef for struct ULocaleDisplayNames. + * @stable ICU 4.4 */ -typedef struct ULocaleDisplayNames ULocaleDisplayNames; +typedef struct ULocaleDisplayNames ULocaleDisplayNames; #if !UCONFIG_NO_FORMATTING @@ -59,9 +59,9 @@ typedef struct ULocaleDisplayNames ULocaleDisplayNames; * dialectHandling. The usual value for dialectHandling is * ULOC_STANDARD_NAMES. * - * @param locale the display locale - * @param dialectHandling how to select names for locales - * @return a ULocaleDisplayNames instance + * @param locale the display locale + * @param dialectHandling how to select names for locales + * @return a ULocaleDisplayNames instance * @param pErrorCode the status code * @stable ICU 4.4 */ @@ -103,7 +103,7 @@ U_NAMESPACE_END * Returns the locale used to determine the display names. This is * not necessarily the same locale passed to {@link #uldn_open}. * @param ldn the LocaleDisplayNames instance - * @return the display locale + * @return the display locale * @stable ICU 4.4 */ U_STABLE const char * U_EXPORT2 @@ -272,14 +272,14 @@ uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn, * Returns an instance of LocaleDisplayNames that returns names formatted * for the provided locale, using the provided UDisplayContext settings. * -* @param locale The display locale +* @param locale The display locale * @param contexts List of one or more context settings (e.g. for dialect * handling, capitalization, etc. * @param length Number of items in the contexts list * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates * a failure status, the function will do nothing; otherwise this will be -* updated with any new status from the function. -* @return a ULocaleDisplayNames instance +* updated with any new status from the function. +* @return a ULocaleDisplayNames instance * @stable ICU 51 */ U_STABLE ULocaleDisplayNames * U_EXPORT2 @@ -292,7 +292,7 @@ uldn_openForContext(const char * locale, UDisplayContext *contexts, * @param type the UDisplayContextType whose value to return * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates * a failure status, the function will do nothing; otherwise this will be -* updated with any new status from the function. +* updated with any new status from the function. * @return the UDisplayContextValue for the specified type. * @stable ICU 51 */ diff --git a/deps/icu-small/source/common/unicode/uloc.h b/deps/icu-small/source/common/unicode/uloc.h index 5531070841187d..c45edad9e0942b 100644 --- a/deps/icu-small/source/common/unicode/uloc.h +++ b/deps/icu-small/source/common/unicode/uloc.h @@ -26,9 +26,9 @@ #include "unicode/utypes.h" #include "unicode/uenum.h" -/** +/** * \file - * \brief C API: Locale + * \brief C API: Locale * *

      ULoc C API for Locale

      * A Locale represents a specific geographical, political, @@ -46,9 +46,9 @@ *
        * \code
        *       newLanguage
      - *
      + * 
        *       newLanguage + newCountry
      - *
      + * 
        *       newLanguage + newCountry + newVariant
        * \endcode
        * 
      @@ -69,7 +69,7 @@ * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html * *

      - * The third option requires another additional information--the + * The third option requires another additional information--the * Variant. * The Variant codes are vendor and browser-specific. * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. @@ -119,7 +119,7 @@ *

      * The ICU provides a number of services that perform locale-sensitive * operations. For example, the unum_xxx functions format - * numbers, currency, or percentages in a locale-sensitive manner. + * numbers, currency, or percentages in a locale-sensitive manner. *

      * \htmlonly
      \endhtmlonly *
      @@ -127,12 +127,12 @@
        *     UErrorCode success = U_ZERO_ERROR;
        *     UNumberFormat *nf;
        *     const char* myLocale = "fr_FR";
      - *
      - *     nf = unum_open( UNUM_DEFAULT, NULL, success );
      + * 
      + *     nf = unum_open( UNUM_DEFAULT, NULL, success );          
        *     unum_close(nf);
        *     nf = unum_open( UNUM_CURRENCY, NULL, success );
        *     unum_close(nf);
      - *     nf = unum_open( UNUM_PERCENT, NULL, success );
      + *     nf = unum_open( UNUM_PERCENT, NULL, success );   
        *     unum_close(nf);
        * \endcode
        * 
      @@ -141,13 +141,13 @@ * and one without; the latter using the default locale. * \htmlonly
      \endhtmlonly *
      - * \code
      - *
      - *     nf = unum_open( UNUM_DEFAULT, myLocale, success );
      + * \code 
      + * 
      + *     nf = unum_open( UNUM_DEFAULT, myLocale, success );          
        *     unum_close(nf);
        *     nf = unum_open( UNUM_CURRENCY, myLocale, success );
        *     unum_close(nf);
      - *     nf = unum_open( UNUM_PERCENT, myLocale, success );
      + *     nf = unum_open( UNUM_PERCENT, myLocale, success );   
        *     unum_close(nf);
        * \endcode
        * 
      @@ -157,7 +157,7 @@ * just a mechanism for identifying these services. * *

      - * Each international service that performs locale-sensitive operations + * Each international service that performs locale-sensitive operations * allows you * to get all the available objects of that type. You can sift * through these objects by language, country, or variant, @@ -172,22 +172,22 @@ * int32_t uloc_countAvailable(); * int32_t * uloc_getDisplayName(const char* localeID, - * const char* inLocaleID, + * const char* inLocaleID, * UChar* result, * int32_t maxResultSize, * UErrorCode* err); - * + * * \endcode *

* \htmlonly\endhtmlonly *

- * Concerning POSIX/RFC1766 Locale IDs, + * Concerning POSIX/RFC1766 Locale IDs, * the getLanguage/getCountry/getVariant/getName functions do understand * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT * and if there is not an ICU-stype variant, uloc_getVariant() for example * will return the one listed after the \@at sign. As well, the hyphen * "-" is recognized as a country/variant separator similarly to RFC1766. - * So for example, "en-us" will be interpreted as en_US. + * So for example, "en-us" will be interpreted as en_US. * As a result, uloc_getName() is far from a no-op, and will have the * effect of converting POSIX/RFC1766 IDs into ICU form, although it does * NOT map any of the actual codes (i.e. russian->ru) in any way. @@ -304,7 +304,7 @@ /** * Unicode code point for '=' for assigning value to a keyword. * @see ULOC_KEYWORD_ASSIGN - * @stable ICU 4.6 + * @stable ICU 4.6 */ #define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D @@ -323,31 +323,31 @@ /** * Constants for *_getLocale() - * Allow user to select whether she wants information on + * Allow user to select whether she wants information on * requested, valid or actual locale. * For example, a collator for "en_US_CALIFORNIA" was - * requested. In the current state of ICU (2.0), + * requested. In the current state of ICU (2.0), * the requested locale is "en_US_CALIFORNIA", * the valid locale is "en_US" (most specific locale supported by ICU) - * and the actual locale is "root" (the collation data comes unmodified + * and the actual locale is "root" (the collation data comes unmodified * from the UCA) - * The locale is considered supported by ICU if there is a core ICU bundle + * The locale is considered supported by ICU if there is a core ICU bundle * for that locale (although it may be empty). * @stable ICU 2.1 */ typedef enum { - /** This is locale the data actually comes from + /** This is locale the data actually comes from * @stable ICU 2.1 */ ULOC_ACTUAL_LOCALE = 0, - /** This is the most specific locale supported by ICU + /** This is the most specific locale supported by ICU * @stable ICU 2.1 */ ULOC_VALID_LOCALE = 1, #ifndef U_HIDE_DEPRECATED_API /** This is the requested locale - * @deprecated ICU 2.8 + * @deprecated ICU 2.8 */ ULOC_REQUESTED_LOCALE = 2, @@ -361,12 +361,12 @@ typedef enum { #ifndef U_HIDE_SYSTEM_API /** - * Gets ICU's default locale. + * Gets ICU's default locale. * The returned string is a snapshot in time, and will remain valid * and unchanged even when uloc_setDefault() is called. * The returned storage is owned by ICU, and must not be altered or deleted * by the caller. - * + * * @return the ICU default locale * @system * @stable ICU 2.0 @@ -375,7 +375,7 @@ U_STABLE const char* U_EXPORT2 uloc_getDefault(void); /** - * Sets ICU's default locale. + * Sets ICU's default locale. * By default (without calling this function), ICU's default locale will be based * on information obtained from the underlying system environment. *

@@ -401,11 +401,11 @@ uloc_setDefault(const char* localeID, * * @param localeID the locale to get the ISO language code with * @param language the language code for localeID - * @param languageCapacity the size of the language buffer to store the + * @param languageCapacity the size of the language buffer to store the * language code with * @param err error information if retrieving the language code failed - * @return the actual buffer size needed for the language code. If it's greater - * than languageCapacity, the returned language code will be truncated. + * @return the actual buffer size needed for the language code. If it's greater + * than languageCapacity, the returned language code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -419,11 +419,11 @@ uloc_getLanguage(const char* localeID, * * @param localeID the locale to get the ISO language code with * @param script the language code for localeID - * @param scriptCapacity the size of the language buffer to store the + * @param scriptCapacity the size of the language buffer to store the * language code with * @param err error information if retrieving the language code failed - * @return the actual buffer size needed for the language code. If it's greater - * than scriptCapacity, the returned language code will be truncated. + * @return the actual buffer size needed for the language code. If it's greater + * than scriptCapacity, the returned language code will be truncated. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -437,11 +437,11 @@ uloc_getScript(const char* localeID, * * @param localeID the locale to get the country code with * @param country the country code for localeID - * @param countryCapacity the size of the country buffer to store the + * @param countryCapacity the size of the country buffer to store the * country code with * @param err error information if retrieving the country code failed - * @return the actual buffer size needed for the country code. If it's greater - * than countryCapacity, the returned country code will be truncated. + * @return the actual buffer size needed for the country code. If it's greater + * than countryCapacity, the returned country code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -455,11 +455,11 @@ uloc_getCountry(const char* localeID, * * @param localeID the locale to get the variant code with * @param variant the variant code for localeID - * @param variantCapacity the size of the variant buffer to store the + * @param variantCapacity the size of the variant buffer to store the * variant code with * @param err error information if retrieving the variant code failed - * @return the actual buffer size needed for the variant code. If it's greater - * than variantCapacity, the returned variant code will be truncated. + * @return the actual buffer size needed for the variant code. If it's greater + * than variantCapacity, the returned variant code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -481,8 +481,8 @@ uloc_getVariant(const char* localeID, * @param name fill in buffer for the name without keywords. * @param nameCapacity capacity of the fill in buffer. * @param err error information if retrieving the full name failed - * @return the actual buffer size needed for the full name. If it's greater - * than nameCapacity, the returned full name will be truncated. + * @return the actual buffer size needed for the full name. If it's greater + * than nameCapacity, the returned full name will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -501,11 +501,11 @@ uloc_getName(const char* localeID, * * @param localeID the locale to get the full name with * @param name the full name for localeID - * @param nameCapacity the size of the name buffer to store the + * @param nameCapacity the size of the name buffer to store the * full name with * @param err error information if retrieving the full name failed - * @return the actual buffer size needed for the full name. If it's greater - * than nameCapacity, the returned full name will be truncated. + * @return the actual buffer size needed for the full name. If it's greater + * than nameCapacity, the returned full name will be truncated. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -558,11 +558,11 @@ uloc_getLCID(const char* localeID); * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". * @param language the displayable language code for localeID - * @param languageCapacity the size of the language buffer to store the + * @param languageCapacity the size of the language buffer to store the * displayable language code with * @param status error information if retrieving the displayable language code failed - * @return the actual buffer size needed for the displayable language code. If it's greater - * than languageCapacity, the returned language code will be truncated. + * @return the actual buffer size needed for the displayable language code. If it's greater + * than languageCapacity, the returned language code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -581,11 +581,11 @@ uloc_getDisplayLanguage(const char* locale, * inLocale would result in "", while passing Locale::getGerman() * for inLocale would result in "". NULL may be used to specify the default. * @param script the displayable script for the localeID - * @param scriptCapacity the size of the script buffer to store the + * @param scriptCapacity the size of the script buffer to store the * displayable script code with * @param status error information if retrieving the displayable script code failed - * @return the actual buffer size needed for the displayable script code. If it's greater - * than scriptCapacity, the returned displayable script code will be truncated. + * @return the actual buffer size needed for the displayable script code. If it's greater + * than scriptCapacity, the returned displayable script code will be truncated. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -606,11 +606,11 @@ uloc_getDisplayScript(const char* locale, * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param country the displayable country code for localeID - * @param countryCapacity the size of the country buffer to store the + * @param countryCapacity the size of the country buffer to store the * displayable country code with * @param status error information if retrieving the displayable country code failed - * @return the actual buffer size needed for the displayable country code. If it's greater - * than countryCapacity, the returned displayable country code will be truncated. + * @return the actual buffer size needed for the displayable country code. If it's greater + * than countryCapacity, the returned displayable country code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -630,11 +630,11 @@ uloc_getDisplayCountry(const char* locale, * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param variant the displayable variant code for localeID - * @param variantCapacity the size of the variant buffer to store the + * @param variantCapacity the size of the variant buffer to store the * displayable variant code with * @param status error information if retrieving the displayable variant code failed - * @return the actual buffer size needed for the displayable variant code. If it's greater - * than variantCapacity, the returned displayable variant code will be truncated. + * @return the actual buffer size needed for the displayable variant code. If it's greater + * than variantCapacity, the returned displayable variant code will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -646,8 +646,8 @@ uloc_getDisplayVariant(const char* locale, /** * Gets the keyword name suitable for display for the specified locale. - * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display - * string for the keyword collation. + * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display + * string for the keyword collation. * Usage: * * UErrorCode status = U_ZERO_ERROR; @@ -676,11 +676,11 @@ uloc_getDisplayVariant(const char* locale, * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param dest the buffer to which the displayable keyword should be written. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param status error information if retrieving the displayable string failed. + * @param status error information if retrieving the displayable string failed. * Should not be NULL and should not indicate failure on entry. - * @return the actual buffer size needed for the displayable variant code. + * @return the actual buffer size needed for the displayable variant code. * @see #uloc_openKeywords * @stable ICU 2.8 */ @@ -692,7 +692,7 @@ uloc_getDisplayKeyword(const char* keyword, UErrorCode* status); /** * Gets the value of the keyword suitable for display for the specified locale. - * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display + * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. * * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default. @@ -703,11 +703,11 @@ uloc_getDisplayKeyword(const char* keyword, * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param dest the buffer to which the displayable keyword should be written. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param status error information if retrieving the displayable string failed. + * @param status error information if retrieving the displayable string failed. * Should not be NULL and must not indicate failure on entry. - * @return the actual buffer size needed for the displayable variant code. + * @return the actual buffer size needed for the displayable variant code. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -726,11 +726,11 @@ uloc_getDisplayKeywordValue( const char* locale, * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param result the displayable name for localeID - * @param maxResultSize the size of the name buffer to store the + * @param maxResultSize the size of the name buffer to store the * displayable full name with * @param err error information if retrieving the displayable name failed - * @return the actual buffer size needed for the displayable name. If it's greater - * than maxResultSize, the returned displayable name will be truncated. + * @return the actual buffer size needed for the displayable name. If it's greater + * than maxResultSize, the returned displayable name will be truncated. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 @@ -742,12 +742,18 @@ uloc_getDisplayName(const char* localeID, /** - * Gets the specified locale from a list of all available locales. - * The return value is a pointer to an item of - * a locale name array. Both this array and the pointers - * it contains are owned by ICU and should not be deleted or written through - * by the caller. The locale name is terminated by a null pointer. - * @param n the specific locale name index of the available locale list + * Gets the specified locale from a list of available locales. + * + * This method corresponds to uloc_openAvailableByType called with the + * ULOC_AVAILABLE_DEFAULT type argument. + * + * The return value is a pointer to an item of a locale name array. Both this + * array and the pointers it contains are owned by ICU and should not be + * deleted or written through by the caller. The locale name is terminated by + * a null pointer. + * + * @param n the specific locale name index of the available locale list; + * should not exceed the number returned by uloc_countAvailable. * @return a specified locale name of all available locales * @stable ICU 2.0 */ @@ -762,6 +768,72 @@ uloc_getAvailable(int32_t n); */ U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void); +#ifndef U_HIDE_DRAFT_API + +/** + * Types for uloc_getAvailableByType and uloc_countAvailableByType. + * + * @draft ICU 65 + */ +typedef enum ULocAvailableType { + /** + * Locales that return data when passed to ICU APIs, + * but not including legacy or alias locales. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_DEFAULT, + + /** + * Legacy or alias locales that return data when passed to ICU APIs. + * Examples of supported legacy or alias locales: + * + * - iw (alias to he) + * - mo (alias to ro) + * - zh_CN (alias to zh_Hans_CN) + * - sr_BA (alias to sr_Cyrl_BA) + * - ars (alias to ar_SA) + * + * The locales in this set are disjoint from the ones in + * ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use + * ULOC_AVAILABLE_WITH_LEGACY_ALIASES. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_ONLY_LEGACY_ALIASES, + + /** + * The union of the locales in ULOC_AVAILABLE_DEFAULT and + * ULOC_AVAILABLE_ONLY_LEGACY_ALIAS. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_WITH_LEGACY_ALIASES, + +#ifndef U_HIDE_INTERNAL_API + /** + * @internal + */ + ULOC_AVAILABLE_COUNT +#endif +} ULocAvailableType; + +/** + * Gets a list of available locales according to the type argument, allowing + * the user to access different sets of supported locales in ICU. + * + * The returned UEnumeration must be closed by the caller. + * + * @param type Type choice from ULocAvailableType. + * @param status Set if an error occurred. + * @return a UEnumeration owned by the caller, or nullptr on failure. + * @draft ICU 65 + */ +U_DRAFT UEnumeration* U_EXPORT2 +uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status); + +#endif // U_HIDE_DRAFT_API + /** * * Gets a list of all available 2-letter language codes defined in ISO 639, @@ -820,16 +892,16 @@ uloc_getParent(const char* localeID, * ICU format. It does NOT map aliased names in any way. * See the top of this header file. * - * This API strips off the keyword part, so "de_DE\@collation=phonebook" - * will become "de_DE". + * This API strips off the keyword part, so "de_DE\@collation=phonebook" + * will become "de_DE". * This API supports preflighting. * * @param localeID the locale to get the full name with * @param name fill in buffer for the name without keywords. * @param nameCapacity capacity of the fill in buffer. * @param err error information if retrieving the full name failed - * @return the actual buffer size needed for the full name. If it's greater - * than nameCapacity, the returned full name will be truncated. + * @return the actual buffer size needed for the full name. If it's greater + * than nameCapacity, the returned full name will be truncated. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -853,7 +925,7 @@ uloc_openKeywords(const char* localeID, /** * Get the value for a keyword. Locale name does not need to be normalized. - * + * * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") * @param keywordName name of the keyword for which we want the value; must not be * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive. @@ -888,7 +960,7 @@ uloc_getKeywordValue(const char* localeID, * @param keywordName name of the keyword to be set; must not be * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive. * @param keywordValue value of the keyword to be set. If 0-length or - * NULL, will result in the keyword being removed; no error is given if + * NULL, will result in the keyword being removed; no error is given if * that keyword does not exist. Otherwise, must consist only of * [A-Za-z0-9] and [/_+-]. * @param buffer input buffer containing well-formed locale ID to be @@ -939,7 +1011,7 @@ typedef enum { /** * Get the layout character orientation for the specified locale. - * + * * @param localeId locale name * @param status Error status * @return an enum indicating the layout orientation for characters. @@ -951,7 +1023,7 @@ uloc_getCharacterOrientation(const char* localeId, /** * Get the layout line orientation for the specified locale. - * + * * @param localeId locale name * @param status Error status * @return an enum indicating the layout orientation for lines. @@ -970,7 +1042,7 @@ uloc_getLineOrientation(const char* localeId, typedef enum { ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */ ULOC_ACCEPT_VALID = 1, /* An exact match was found. */ - ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example, + ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example, Accept list contained 'ja_JP' which matched available locale 'ja'. */ } UAcceptResult; @@ -1009,7 +1081,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, * @stable ICU 3.2 */ U_STABLE int32_t U_EXPORT2 -uloc_acceptLanguage(char *result, int32_t resultAvailable, +uloc_acceptLanguage(char *result, int32_t resultAvailable, UAcceptResult *outResult, const char **acceptList, int32_t acceptListCount, UEnumeration* availableLocales, @@ -1025,7 +1097,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable, * @param localeCapacity the size of the output buffer * @param status an error is returned if the LCID is unrecognized or the output buffer * is too small - * @return actual the actual size of the locale ID, not including NUL-termination + * @return actual the actual size of the locale ID, not including NUL-termination * @stable ICU 3.8 */ U_STABLE int32_t U_EXPORT2 @@ -1116,7 +1188,7 @@ uloc_minimizeSubtags(const char* localeID, * Returns a locale ID for the specified BCP47 language tag string. * If the specified language tag contains any ill-formed subtags, * the first such subtag and all following subtags are ignored. - *

+ *

* This implements the 'Language-Tag' production of BCP47, and so * supports grandfathered (regular and irregular) as well as private * use language tags. Private use tags are represented as 'x-whatever', @@ -1143,8 +1215,8 @@ uloc_forLanguageTag(const char* langtag, UErrorCode* err); /** - * Returns a well-formed language tag for this locale ID. - *

+ * Returns a well-formed language tag for this locale ID. + *

* Note: When strict is FALSE, any locale * fields which do not satisfy the BCP47 syntax requirement will * be omitted from the result. When strict is @@ -1180,14 +1252,14 @@ uloc_toLanguageTag(const char* localeID, * then the pointer to the input keyword itself will be returned. * For example, * uloc_toUnicodeLocaleKey("ZZ") returns "ZZ". - * + * * @param keyword the input locale keyword (either legacy key * such as "collation" or BCP 47 Unicode locale extension * key such as "co"). * @return the well-formed BCP 47 Unicode locale extension key, * or NULL if the specified locale keyword cannot be * mapped to a well-formed BCP 47 Unicode locale extension - * key. + * key. * @see uloc_toLegacyKey * @stable ICU 54 */ @@ -1209,7 +1281,7 @@ uloc_toUnicodeLocaleKey(const char* keyword); * For example, * uloc_toUnicodeLocaleType("Foo", "Bar") returns "Bar", * uloc_toUnicodeLocaleType("variableTop", "00A4") returns "00A4". - * + * * @param keyword the locale keyword (either legacy key such as * "collation" or BCP 47 Unicode locale extension * key such as "co"). @@ -1229,7 +1301,7 @@ uloc_toUnicodeLocaleType(const char* keyword, const char* value); * Converts the specified keyword (BCP 47 Unicode locale extension key, or * legacy key) to the legacy key. For example, legacy key "collation" is * returned for the input BCP 47 Unicode locale extension key "co". - * + * * @param keyword the input locale keyword (either BCP 47 Unicode locale * extension key or legacy key). * @return the well-formed legacy key, or NULL if the specified diff --git a/deps/icu-small/source/common/unicode/umachine.h b/deps/icu-small/source/common/unicode/umachine.h index 6d932cfcfb2ae4..c52984cef39566 100644 --- a/deps/icu-small/source/common/unicode/umachine.h +++ b/deps/icu-small/source/common/unicode/umachine.h @@ -95,7 +95,7 @@ # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) /** * \def U_ATTRIBUTE_DEPRECATED - * This is used for Visual C++ specific attributes + * This is used for Visual C++ specific attributes * @internal */ #elif defined(_MSC_VER) && (_MSC_VER >= 1400) @@ -140,6 +140,42 @@ #define U_FINAL final #endif +// Before ICU 65, function-like, multi-statement ICU macros were just defined as +// series of statements wrapped in { } blocks and the caller could choose to +// either treat them as if they were actual functions and end the invocation +// with a trailing ; creating an empty statement after the block or else omit +// this trailing ; using the knowledge that the macro would expand to { }. +// +// But doing so doesn't work well with macros that look like functions and +// compiler warnings about empty statements (ICU-20601) and ICU 65 therefore +// switches to the standard solution of wrapping such macros in do { } while. +// +// This will however break existing code that depends on being able to invoke +// these macros without a trailing ; so to be able to remain compatible with +// such code the wrapper is itself defined as macros so that it's possible to +// build ICU 65 and later with the old macro behaviour, like this: +// +// export CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""' +// runConfigureICU ... +// + +/** + * \def UPRV_BLOCK_MACRO_BEGIN + * Defined as the "do" keyword by default. + * @internal + */ +#ifndef UPRV_BLOCK_MACRO_BEGIN +#define UPRV_BLOCK_MACRO_BEGIN do +#endif + +/** + * \def UPRV_BLOCK_MACRO_END + * Defined as "while (FALSE)" by default. + * @internal + */ +#ifndef UPRV_BLOCK_MACRO_END +#define UPRV_BLOCK_MACRO_END while (FALSE) +#endif /*==========================================================================*/ /* limits for int32_t etc., like in POSIX inttypes.h */ @@ -392,7 +428,7 @@ typedef int32_t UChar32; * This value is intended for sentinel values for APIs that * (take or) return single code points (UChar32). * It is outside of the Unicode code point range 0..0x10ffff. - * + * * For example, a "done" or "error" value in a new API * could be indicated with U_SENTINEL. * diff --git a/deps/icu-small/source/common/unicode/umisc.h b/deps/icu-small/source/common/unicode/umisc.h index a46fa323c8c1a3..213290b9afa33c 100644 --- a/deps/icu-small/source/common/unicode/umisc.h +++ b/deps/icu-small/source/common/unicode/umisc.h @@ -21,29 +21,29 @@ /** * \file - * \brief C API:misc definitions + * \brief C API:misc definitions * - * This file contains miscellaneous definitions for the C APIs. + * This file contains miscellaneous definitions for the C APIs. */ U_CDECL_BEGIN -/** A struct representing a range of text containing a specific field +/** A struct representing a range of text containing a specific field * @stable ICU 2.0 */ typedef struct UFieldPosition { /** - * The field + * The field * @stable ICU 2.0 */ int32_t field; /** - * The start of the text range containing field + * The start of the text range containing field * @stable ICU 2.0 */ int32_t beginIndex; - /** - * The limit of the text range containing field + /** + * The limit of the text range containing field * @stable ICU 2.0 */ int32_t endIndex; diff --git a/deps/icu-small/source/common/unicode/umutablecptrie.h b/deps/icu-small/source/common/unicode/umutablecptrie.h index e75191a4495209..13e71ef25e8c87 100644 --- a/deps/icu-small/source/common/unicode/umutablecptrie.h +++ b/deps/icu-small/source/common/unicode/umutablecptrie.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - #include "unicode/localpointer.h" #include "unicode/ucpmap.h" #include "unicode/ucptrie.h" @@ -44,7 +42,7 @@ U_CDECL_BEGIN * * @see UCPTrie * @see umutablecptrie_buildImmutable - * @draft ICU 63 + * @stable ICU 63 */ typedef struct UMutableCPTrie UMutableCPTrie; @@ -59,7 +57,7 @@ typedef struct UMutableCPTrie UMutableCPTrie; * @param errorValue the value for out-of-range code points and ill-formed UTF-8/16 * @param pErrorCode an in/out ICU UErrorCode * @return the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_open(uint32_t initialValue, uint32_t errorValue, UErrorCode *pErrorCode); @@ -71,7 +69,7 @@ umutablecptrie_open(uint32_t initialValue, uint32_t errorValue, UErrorCode *pErr * @param other the trie to clone * @param pErrorCode an in/out ICU UErrorCode * @return the trie clone - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_clone(const UMutableCPTrie *other, UErrorCode *pErrorCode); @@ -80,7 +78,7 @@ umutablecptrie_clone(const UMutableCPTrie *other, UErrorCode *pErrorCode); * Closes a mutable trie and releases associated memory. * * @param trie the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_close(UMutableCPTrie *trie); @@ -96,7 +94,7 @@ U_NAMESPACE_BEGIN * * @see LocalPointerBase * @see LocalPointer - * @draft ICU 63 + * @stable ICU 63 */ U_DEFINE_LOCAL_OPEN_POINTER(LocalUMutableCPTriePointer, UMutableCPTrie, umutablecptrie_close); @@ -111,7 +109,7 @@ U_NAMESPACE_END * @param map the source map * @param pErrorCode an in/out ICU UErrorCode * @return the mutable trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_fromUCPMap(const UCPMap *map, UErrorCode *pErrorCode); @@ -123,7 +121,7 @@ umutablecptrie_fromUCPMap(const UCPMap *map, UErrorCode *pErrorCode); * @param trie the immutable trie * @param pErrorCode an in/out ICU UErrorCode * @return the mutable trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_fromUCPTrie(const UCPTrie *trie, UErrorCode *pErrorCode); @@ -134,7 +132,7 @@ umutablecptrie_fromUCPTrie(const UCPTrie *trie, UErrorCode *pErrorCode); * @param trie the trie * @param c the code point * @return the value - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 umutablecptrie_get(const UMutableCPTrie *trie, UChar32 c); @@ -166,7 +164,7 @@ umutablecptrie_get(const UMutableCPTrie *trie, UChar32 c); * may have been modified by filter(context, trie value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 umutablecptrie_getRange(const UMutableCPTrie *trie, UChar32 start, @@ -180,7 +178,7 @@ umutablecptrie_getRange(const UMutableCPTrie *trie, UChar32 start, * @param c the code point * @param value the value * @param pErrorCode an in/out ICU UErrorCode - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_set(UMutableCPTrie *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode); @@ -194,7 +192,7 @@ umutablecptrie_set(UMutableCPTrie *trie, UChar32 c, uint32_t value, UErrorCode * * @param end the last code point to get the value (inclusive) * @param value the value * @param pErrorCode an in/out ICU UErrorCode - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_setRange(UMutableCPTrie *trie, @@ -229,7 +227,7 @@ umutablecptrie_setRange(UMutableCPTrie *trie, * @param pErrorCode an in/out ICU UErrorCode * * @see umutablecptrie_fromUCPTrie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrie * U_EXPORT2 umutablecptrie_buildImmutable(UMutableCPTrie *trie, UCPTrieType type, UCPTrieValueWidth valueWidth, @@ -237,5 +235,4 @@ umutablecptrie_buildImmutable(UMutableCPTrie *trie, UCPTrieType type, UCPTrieVal U_CDECL_END -#endif // U_HIDE_DRAFT_API #endif diff --git a/deps/icu-small/source/common/unicode/unifilt.h b/deps/icu-small/source/common/unicode/unifilt.h index 99cce785b6eec8..420e1a190564f0 100644 --- a/deps/icu-small/source/common/unicode/unifilt.h +++ b/deps/icu-small/source/common/unicode/unifilt.h @@ -12,11 +12,15 @@ #ifndef UNIFILT_H #define UNIFILT_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unifunct.h" #include "unicode/unimatch.h" /** - * \file + * \file * \brief C++ API: Unicode Filter */ @@ -67,6 +71,14 @@ class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher */ virtual ~UnicodeFilter(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 2.4 + */ + virtual UnicodeFilter* clone() const = 0; + /** * Returns true for characters that are in the selected * subset. In other words, if a character is to be @@ -119,4 +131,6 @@ class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unifunct.h b/deps/icu-small/source/common/unicode/unifunct.h index 66a02ce7cd5ce8..7d31af7dafb772 100644 --- a/deps/icu-small/source/common/unicode/unifunct.h +++ b/deps/icu-small/source/common/unicode/unifunct.h @@ -13,13 +13,16 @@ #define UNIFUNCT_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** - * \file + * \file * \brief C++ API: Unicode Functor */ - + U_NAMESPACE_BEGIN class UnicodeMatcher; @@ -124,4 +127,6 @@ class U_COMMON_API UnicodeFunctor : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unimatch.h b/deps/icu-small/source/common/unicode/unimatch.h index 8bf39950187b1b..5a192b1b427da4 100644 --- a/deps/icu-small/source/common/unicode/unimatch.h +++ b/deps/icu-small/source/common/unicode/unimatch.h @@ -13,10 +13,11 @@ #include "unicode/utypes.h" /** - * \file + * \file * \brief C++ API: Unicode Matcher */ +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN @@ -38,7 +39,7 @@ enum UMatchDegree { * @stable ICU 2.4 */ U_MISMATCH, - + /** * Constant returned by matches() indicating a * partial match between the text and this matcher. This value is @@ -50,7 +51,7 @@ enum UMatchDegree { * @stable ICU 2.4 */ U_PARTIAL_MATCH, - + /** * Constant returned by matches() indicating a * complete match between the text and this matcher. For an @@ -84,7 +85,7 @@ class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an int * Matching in the forward direction is indicated by limit > * offset. Characters from offset forwards to limit-1 will be * considered for matching. - * + * * Matching in the reverse direction is indicated by limit < * offset. Characters from offset backwards to limit+1 will be * considered for matching. @@ -162,4 +163,6 @@ class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an int U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/uniset.h b/deps/icu-small/source/common/unicode/uniset.h index e5e7726d604a73..974231100353f5 100644 --- a/deps/icu-small/source/common/unicode/uniset.h +++ b/deps/icu-small/source/common/unicode/uniset.h @@ -13,6 +13,10 @@ #ifndef UNICODESET_H #define UNICODESET_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/ucpmap.h" #include "unicode/unifilt.h" #include "unicode/unistr.h" @@ -261,7 +265,7 @@ class RuleCharacterIterator; * * * \htmlonly\endhtmlonly - * + * *

Note: * - Most UnicodeSet methods do not take a UErrorCode parameter because * there are usually very few opportunities for failure other than a shortage @@ -501,7 +505,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see cloneAsThawed * @stable ICU 2.0 */ - virtual UnicodeFunctor* clone() const; + virtual UnicodeSet* clone() const; /** * Returns the hash code value for this set. @@ -531,7 +535,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @stable ICU 4.2 */ inline static const UnicodeSet *fromUSet(const USet *uset); - + /** * Produce a USet * pointer for this UnicodeSet. * USet is the plain C type for UnicodeSet @@ -579,7 +583,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see cloneAsThawed * @stable ICU 3.8 */ - UnicodeFunctor *freeze(); + UnicodeSet *freeze(); /** * Clone the set and make the clone mutable. @@ -589,7 +593,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see isFrozen * @stable ICU 3.8 */ - UnicodeFunctor *cloneAsThawed() const; + UnicodeSet *cloneAsThawed() const; //---------------------------------------------------------------- // Public API @@ -1651,11 +1655,10 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { const UnicodeSet* inclusions, UErrorCode &status); -#ifndef U_HIDE_DRAFT_API // Skipped: ucpmap.h is draft only. + // UCPMap is now stable ICU 63 void applyIntPropertyValue(const UCPMap *map, UCPMapValueFilter *filter, const void *context, UErrorCode &errorCode); -#endif /* U_HIDE_DRAFT_API */ /** * Set the new pattern to cache. @@ -1736,4 +1739,6 @@ inline int32_t UnicodeSet::spanBack(const UnicodeString &s, int32_t limit, USetS U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unistr.h b/deps/icu-small/source/common/unicode/unistr.h index 8fd144425e87c0..da79053765acf6 100644 --- a/deps/icu-small/source/common/unicode/unistr.h +++ b/deps/icu-small/source/common/unicode/unistr.h @@ -28,8 +28,11 @@ * \brief C++ API: Unicode String */ -#include #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include #include "unicode/char16ptr.h" #include "unicode/rep.h" #include "unicode/std_string.h" @@ -209,7 +212,9 @@ class UnicodeStringAppendable; // unicode/appendable.h * similar functionality as the Java String and StringBuffer/StringBuilder classes. * It is a concrete implementation of the abstract class Replaceable (for transliteration). * - * A UnicodeString may also "alias" an external array of characters + * The UnicodeString equivalent of std::string’s clear() is remove(). + * + * A UnicodeString may "alias" an external array of characters * (that is, point to it, rather than own the array) * whose lifetime must then at least match the lifetime of the aliasing object. * This aliasing may be preserved when returning a UnicodeString by value, @@ -2092,8 +2097,7 @@ class U_COMMON_API UnicodeString : public Replaceable * s.truncate(0); // set to an empty string (complete truncation), or * s=UnicodeString(); // assign an empty string, or * s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or - * static const char16_t nul=0; - * s.setTo(&nul, 0); // set to an empty C Unicode string + * s.setTo(u"", 0); // set to an empty C Unicode string * } * \endcode * @@ -2534,11 +2538,14 @@ class U_COMMON_API UnicodeString : public Replaceable /* Remove operations */ /** - * Remove all characters from the UnicodeString object. + * Removes all characters from the UnicodeString object and clears the bogus flag. + * This is the UnicodeString equivalent of std::string’s clear(). + * * @return a reference to this + * @see setToBogus * @stable ICU 2.0 */ - inline UnicodeString& remove(void); + inline UnicodeString& remove(); /** * Remove the characters in the range @@ -3034,11 +3041,11 @@ class U_COMMON_API UnicodeString : public Replaceable * uint16_t * constructor. * Delegates to UnicodeString(const char16_t *, int32_t). * @param text UTF-16 string - * @param length string length + * @param textLength string length * @stable ICU 59 */ - UnicodeString(const uint16_t *text, int32_t length) : - UnicodeString(ConstChar16Ptr(text), length) {} + UnicodeString(const uint16_t *text, int32_t textLength) : + UnicodeString(ConstChar16Ptr(text), textLength) {} #endif #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) @@ -3047,21 +3054,21 @@ class U_COMMON_API UnicodeString : public Replaceable * (Only defined if U_SIZEOF_WCHAR_T==2.) * Delegates to UnicodeString(const char16_t *, int32_t). * @param text NUL-terminated UTF-16 string - * @param length string length + * @param textLength string length * @stable ICU 59 */ - UnicodeString(const wchar_t *text, int32_t length) : - UnicodeString(ConstChar16Ptr(text), length) {} + UnicodeString(const wchar_t *text, int32_t textLength) : + UnicodeString(ConstChar16Ptr(text), textLength) {} #endif /** * nullptr_t constructor. * Effectively the same as the default constructor, makes an empty string object. * @param text nullptr - * @param length ignored + * @param textLength ignored * @stable ICU 59 */ - inline UnicodeString(const std::nullptr_t text, int32_t length); + inline UnicodeString(const std::nullptr_t text, int32_t textLength); /** * Readonly-aliasing char16_t* constructor. @@ -3266,13 +3273,13 @@ class U_COMMON_API UnicodeString : public Replaceable * } * \endcode * @param src String using only invariant characters. - * @param length Length of src, or -1 if NUL-terminated. + * @param textLength Length of src, or -1 if NUL-terminated. * @param inv Signature-distinguishing paramater, use US_INV. * * @see US_INV * @stable ICU 3.2 */ - UnicodeString(const char *src, int32_t length, enum EInvariant inv); + UnicodeString(const char *src, int32_t textLength, enum EInvariant inv); /** @@ -3323,9 +3330,6 @@ class U_COMMON_API UnicodeString : public Replaceable * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a pointer to a Replaceable - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -3334,7 +3338,7 @@ class U_COMMON_API UnicodeString : public Replaceable * @see getDynamicClassID * @stable ICU 2.6 */ - virtual Replaceable *clone() const; + virtual UnicodeString *clone() const; /** Destructor. * @stable ICU 2.0 @@ -4748,4 +4752,6 @@ UnicodeString::reverse(int32_t start, U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unorm.h b/deps/icu-small/source/common/unicode/unorm.h index 3839de129573c1..09dd366a968c1b 100644 --- a/deps/icu-small/source/common/unicode/unorm.h +++ b/deps/icu-small/source/common/unicode/unorm.h @@ -131,6 +131,8 @@ // Do not conditionalize the following enum with #ifndef U_HIDE_DEPRECATED_API, // it is needed for layout of Normalizer object. +#ifndef U_FORCE_HIDE_DEPRECATED_API + /** * Constants for normalization modes. * @deprecated ICU 56 Use unorm2.h instead. @@ -155,6 +157,8 @@ typedef enum { UNORM_MODE_COUNT } UNormalizationMode; +#endif // U_FORCE_HIDE_DEPRECATED_API + #ifndef U_HIDE_DEPRECATED_API /** diff --git a/deps/icu-small/source/common/unicode/uobject.h b/deps/icu-small/source/common/unicode/uobject.h index 53b8eb005f4cc0..eeb331ce973cf0 100644 --- a/deps/icu-small/source/common/unicode/uobject.h +++ b/deps/icu-small/source/common/unicode/uobject.h @@ -20,6 +20,9 @@ #define __UOBJECT_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/platform.h" /** @@ -34,16 +37,16 @@ * Previously, define this to define the throw() specification so * certain functions do not throw any exceptions * - * UMemory operator new methods should have the throw() specification - * appended to them, so that the compiler adds the additional NULL check - * before calling constructors. Without, if operator new returns NULL the - * constructor is still called, and if the constructor references member + * UMemory operator new methods should have the throw() specification + * appended to them, so that the compiler adds the additional NULL check + * before calling constructors. Without, if operator new returns NULL the + * constructor is still called, and if the constructor references member * data, (which it typically does), the result is a segmentation violation. * * @stable ICU 4.2. Since ICU 64, Use U_NOEXCEPT instead. See ICU-20422. */ #ifndef U_NO_THROW -#define U_NO_THROW throw() +#define U_NO_THROW U_NOEXCEPT #endif /*===========================================================================*/ @@ -113,7 +116,7 @@ class U_COMMON_API UMemory { public: /* test versions for debugging shaper heap memory problems */ -#ifdef SHAPER_MEMORY_DEBUG +#ifdef SHAPER_MEMORY_DEBUG static void * NewArray(int size, int count); static void * GrowArray(void * array, int newSize ); static void FreeArray(void * array ); @@ -172,19 +175,19 @@ class U_COMMON_API UMemory { #if U_HAVE_DEBUG_LOCATION_NEW /** * This method overrides the MFC debug version of the operator new - * + * * @param size The requested memory size * @param file The file where the allocation was requested - * @param line The line where the allocation was requested - */ + * @param line The line where the allocation was requested + */ static void * U_EXPORT2 operator new(size_t size, const char* file, int line) U_NOEXCEPT; /** * This method provides a matching delete for the MFC debug new - * + * * @param p The pointer to the allocated memory * @param file The file where the allocation was requested - * @param line The line where the allocation was requested - */ + * @param line The line where the allocation was requested + */ static void U_EXPORT2 operator delete(void* p, const char* file, int line) U_NOEXCEPT; #endif /* U_HAVE_DEBUG_LOCATION_NEW */ #endif /* U_OVERRIDE_CXX_ALLOCATION */ @@ -212,11 +215,8 @@ class U_COMMON_API UMemory { * The clone() function is not available in UObject because it is not * implemented by all ICU classes. * Many ICU services provide a clone() function for their class trees, - * defined on the service's C++ base class, and all subclasses within that - * service class tree return a pointer to the service base class + * defined on the service's C++ base class * (which itself is a subclass of UObject). - * This is because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * * @stable ICU 2.2 */ @@ -319,4 +319,6 @@ class U_COMMON_API UObject : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/urename.h b/deps/icu-small/source/common/unicode/urename.h index eaf56c9614d7f2..e302bf0976e01d 100644 --- a/deps/icu-small/source/common/unicode/urename.h +++ b/deps/icu-small/source/common/unicode/urename.h @@ -193,10 +193,13 @@ #define res_getAlias U_ICU_ENTRY_POINT_RENAME(res_getAlias) #define res_getArrayItem U_ICU_ENTRY_POINT_RENAME(res_getArrayItem) #define res_getBinary U_ICU_ENTRY_POINT_RENAME(res_getBinary) +#define res_getBinaryNoTrace U_ICU_ENTRY_POINT_RENAME(res_getBinaryNoTrace) #define res_getIntVector U_ICU_ENTRY_POINT_RENAME(res_getIntVector) +#define res_getIntVectorNoTrace U_ICU_ENTRY_POINT_RENAME(res_getIntVectorNoTrace) #define res_getPublicType U_ICU_ENTRY_POINT_RENAME(res_getPublicType) #define res_getResource U_ICU_ENTRY_POINT_RENAME(res_getResource) #define res_getString U_ICU_ENTRY_POINT_RENAME(res_getString) +#define res_getStringNoTrace U_ICU_ENTRY_POINT_RENAME(res_getStringNoTrace) #define res_getTableItemByIndex U_ICU_ENTRY_POINT_RENAME(res_getTableItemByIndex) #define res_getTableItemByKey U_ICU_ENTRY_POINT_RENAME(res_getTableItemByKey) #define res_load U_ICU_ENTRY_POINT_RENAME(res_load) @@ -523,6 +526,7 @@ #define ucal_getDefaultTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_getDefaultTimeZone) #define ucal_getFieldDifference U_ICU_ENTRY_POINT_RENAME(ucal_getFieldDifference) #define ucal_getGregorianChange U_ICU_ENTRY_POINT_RENAME(ucal_getGregorianChange) +#define ucal_getHostTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_getHostTimeZone) #define ucal_getKeywordValuesForLocale U_ICU_ENTRY_POINT_RENAME(ucal_getKeywordValuesForLocale) #define ucal_getLimit U_ICU_ENTRY_POINT_RENAME(ucal_getLimit) #define ucal_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ucal_getLocaleByType) @@ -575,7 +579,6 @@ #define ucasemap_getLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_getLocale) #define ucasemap_getOptions U_ICU_ENTRY_POINT_RENAME(ucasemap_getOptions) #define ucasemap_internalUTF8ToTitle U_ICU_ENTRY_POINT_RENAME(ucasemap_internalUTF8ToTitle) -#define ucasemap_mapUTF8 U_ICU_ENTRY_POINT_RENAME(ucasemap_mapUTF8) #define ucasemap_open U_ICU_ENTRY_POINT_RENAME(ucasemap_open) #define ucasemap_setBreakIterator U_ICU_ENTRY_POINT_RENAME(ucasemap_setBreakIterator) #define ucasemap_setLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_setLocale) @@ -930,16 +933,9 @@ #define ufieldpositer_close U_ICU_ENTRY_POINT_RENAME(ufieldpositer_close) #define ufieldpositer_next U_ICU_ENTRY_POINT_RENAME(ufieldpositer_next) #define ufieldpositer_open U_ICU_ENTRY_POINT_RENAME(ufieldpositer_open) -#define ufile_close_translit U_ICU_ENTRY_POINT_RENAME(ufile_close_translit) -#define ufile_fill_uchar_buffer U_ICU_ENTRY_POINT_RENAME(ufile_fill_uchar_buffer) -#define ufile_flush_io U_ICU_ENTRY_POINT_RENAME(ufile_flush_io) -#define ufile_flush_translit U_ICU_ENTRY_POINT_RENAME(ufile_flush_translit) #define ufile_getch U_ICU_ENTRY_POINT_RENAME(ufile_getch) #define ufile_getch32 U_ICU_ENTRY_POINT_RENAME(ufile_getch32) -#define ufmt_64tou U_ICU_ENTRY_POINT_RENAME(ufmt_64tou) #define ufmt_close U_ICU_ENTRY_POINT_RENAME(ufmt_close) -#define ufmt_defaultCPToUnicode U_ICU_ENTRY_POINT_RENAME(ufmt_defaultCPToUnicode) -#define ufmt_digitvalue U_ICU_ENTRY_POINT_RENAME(ufmt_digitvalue) #define ufmt_getArrayItemByIndex U_ICU_ENTRY_POINT_RENAME(ufmt_getArrayItemByIndex) #define ufmt_getArrayLength U_ICU_ENTRY_POINT_RENAME(ufmt_getArrayLength) #define ufmt_getDate U_ICU_ENTRY_POINT_RENAME(ufmt_getDate) @@ -951,11 +947,7 @@ #define ufmt_getType U_ICU_ENTRY_POINT_RENAME(ufmt_getType) #define ufmt_getUChars U_ICU_ENTRY_POINT_RENAME(ufmt_getUChars) #define ufmt_isNumeric U_ICU_ENTRY_POINT_RENAME(ufmt_isNumeric) -#define ufmt_isdigit U_ICU_ENTRY_POINT_RENAME(ufmt_isdigit) #define ufmt_open U_ICU_ENTRY_POINT_RENAME(ufmt_open) -#define ufmt_ptou U_ICU_ENTRY_POINT_RENAME(ufmt_ptou) -#define ufmt_uto64 U_ICU_ENTRY_POINT_RENAME(ufmt_uto64) -#define ufmt_utop U_ICU_ENTRY_POINT_RENAME(ufmt_utop) #define ufmtval_getString U_ICU_ENTRY_POINT_RENAME(ufmtval_getString) #define ufmtval_nextPosition U_ICU_ENTRY_POINT_RENAME(ufmtval_nextPosition) #define ugender_getInstance U_ICU_ENTRY_POINT_RENAME(ugender_getInstance) @@ -1103,6 +1095,7 @@ #define uloc_getVariant U_ICU_ENTRY_POINT_RENAME(uloc_getVariant) #define uloc_isRightToLeft U_ICU_ENTRY_POINT_RENAME(uloc_isRightToLeft) #define uloc_minimizeSubtags U_ICU_ENTRY_POINT_RENAME(uloc_minimizeSubtags) +#define uloc_openAvailableByType U_ICU_ENTRY_POINT_RENAME(uloc_openAvailableByType) #define uloc_openKeywordList U_ICU_ENTRY_POINT_RENAME(uloc_openKeywordList) #define uloc_openKeywords U_ICU_ENTRY_POINT_RENAME(uloc_openKeywords) #define uloc_setDefault U_ICU_ENTRY_POINT_RENAME(uloc_setDefault) @@ -1159,9 +1152,6 @@ #define umsg_toPattern U_ICU_ENTRY_POINT_RENAME(umsg_toPattern) #define umsg_vformat U_ICU_ENTRY_POINT_RENAME(umsg_vformat) #define umsg_vparse U_ICU_ENTRY_POINT_RENAME(umsg_vparse) -#define umtx_condBroadcast U_ICU_ENTRY_POINT_RENAME(umtx_condBroadcast) -#define umtx_condSignal U_ICU_ENTRY_POINT_RENAME(umtx_condSignal) -#define umtx_condWait U_ICU_ENTRY_POINT_RENAME(umtx_condWait) #define umtx_lock U_ICU_ENTRY_POINT_RENAME(umtx_lock) #define umtx_unlock U_ICU_ENTRY_POINT_RENAME(umtx_unlock) #define umutablecptrie_buildImmutable U_ICU_ENTRY_POINT_RENAME(umutablecptrie_buildImmutable) @@ -1327,7 +1317,6 @@ #define uprv_decNumberAbs U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAbs) #define uprv_decNumberAdd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAdd) #define uprv_decNumberAnd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAnd) -#define uprv_decNumberClass U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClass) #define uprv_decNumberClassToString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClassToString) #define uprv_decNumberCompare U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompare) #define uprv_decNumberCompareSignal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompareSignal) @@ -1393,6 +1382,7 @@ #define uprv_dlsym_func U_ICU_ENTRY_POINT_RENAME(uprv_dlsym_func) #define uprv_eastrncpy U_ICU_ENTRY_POINT_RENAME(uprv_eastrncpy) #define uprv_ebcdicFromAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicFromAscii) +#define uprv_ebcdicToAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicToAscii) #define uprv_ebcdicToLowercaseAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicToLowercaseAscii) #define uprv_ebcdictolower U_ICU_ENTRY_POINT_RENAME(uprv_ebcdictolower) #define uprv_fabs U_ICU_ENTRY_POINT_RENAME(uprv_fabs) @@ -1412,6 +1402,7 @@ #define uprv_getUTCtime U_ICU_ENTRY_POINT_RENAME(uprv_getUTCtime) #define uprv_int32Comparator U_ICU_ENTRY_POINT_RENAME(uprv_int32Comparator) #define uprv_isASCIILetter U_ICU_ENTRY_POINT_RENAME(uprv_isASCIILetter) +#define uprv_isEbcdicAtSign U_ICU_ENTRY_POINT_RENAME(uprv_isEbcdicAtSign) #define uprv_isInfinite U_ICU_ENTRY_POINT_RENAME(uprv_isInfinite) #define uprv_isInvariantString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantString) #define uprv_isInvariantUString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantUString) @@ -1579,6 +1570,7 @@ #define ures_getUTF8String U_ICU_ENTRY_POINT_RENAME(ures_getUTF8String) #define ures_getUTF8StringByIndex U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByIndex) #define ures_getUTF8StringByKey U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByKey) +#define ures_getValueWithFallback U_ICU_ENTRY_POINT_RENAME(ures_getValueWithFallback) #define ures_getVersion U_ICU_ENTRY_POINT_RENAME(ures_getVersion) #define ures_getVersionByKey U_ICU_ENTRY_POINT_RENAME(ures_getVersionByKey) #define ures_getVersionNumber U_ICU_ENTRY_POINT_RENAME(ures_getVersionNumber) diff --git a/deps/icu-small/source/common/unicode/urep.h b/deps/icu-small/source/common/unicode/urep.h index c54ba7c4661414..932202ddb04b1c 100644 --- a/deps/icu-small/source/common/unicode/urep.h +++ b/deps/icu-small/source/common/unicode/urep.h @@ -88,7 +88,7 @@ typedef struct UReplaceableCallbacks { */ UChar32 (*char32At)(const UReplaceable* rep, int32_t offset); - + /** * Function pointer that replaces text between start and limit in * this text with the given text. Attributes (out of band info) @@ -110,7 +110,7 @@ typedef struct UReplaceableCallbacks { int32_t limit, const UChar* text, int32_t textLength); - + /** * Function pointer that copies the characters in the range * [start, limit) into the array dst. @@ -148,7 +148,7 @@ typedef struct UReplaceableCallbacks { void (*copy)(UReplaceable* rep, int32_t start, int32_t limit, - int32_t dest); + int32_t dest); } UReplaceableCallbacks; diff --git a/deps/icu-small/source/common/unicode/uset.h b/deps/icu-small/source/common/unicode/uset.h index ef6bbb5c38f3fb..18482c10e73844 100644 --- a/deps/icu-small/source/common/unicode/uset.h +++ b/deps/icu-small/source/common/unicode/uset.h @@ -57,7 +57,7 @@ enum { * Ignore white space within patterns unless quoted or escaped. * @stable ICU 2.4 */ - USET_IGNORE_SPACE = 1, + USET_IGNORE_SPACE = 1, /** * Enable case insensitive matching. E.g., "[ab]" with this flag @@ -85,7 +85,7 @@ enum { * * @stable ICU 2.4 */ - USET_CASE_INSENSITIVE = 2, + USET_CASE_INSENSITIVE = 2, /** * Enable case insensitive matching. E.g., "[ab]" with this flag @@ -265,7 +265,7 @@ uset_openEmpty(void); /** * Creates a USet object that contains the range of characters - * start..end, inclusive. If start > end + * start..end, inclusive. If start > end * then an empty set is created (same as using uset_openEmpty()). * @param start first character of the range, inclusive * @param end last character of the range, inclusive @@ -402,11 +402,11 @@ uset_set(USet* set, /** * Modifies the set to represent the set specified by the given - * pattern. See the UnicodeSet class description for the syntax of + * pattern. See the UnicodeSet class description for the syntax of * the pattern language. See also the User Guide chapter about UnicodeSet. * Empties the set passed before applying the pattern. * A frozen set will not be modified. - * @param set The set to which the pattern is to be applied. + * @param set The set to which the pattern is to be applied. * @param pattern A pointer to UChar string specifying what characters are in the set. * The character at pattern[0] must be a '['. * @param patternLength The length of the UChar string. -1 if NUL terminated. @@ -414,14 +414,14 @@ uset_set(USet* set, * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE. * @param status Returns an error if the pattern cannot be parsed. * @return Upon successful parse, the value is either - * the index of the character after the closing ']' + * the index of the character after the closing ']' * of the parsed pattern. - * If the status code indicates failure, then the return value + * If the status code indicates failure, then the return value * is the index of the error in the source. * * @stable ICU 2.8 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uset_applyPattern(USet *set, const UChar *pattern, int32_t patternLength, uint32_t options, diff --git a/deps/icu-small/source/common/unicode/usetiter.h b/deps/icu-small/source/common/unicode/usetiter.h index 057adbc04f5f05..c6396fd76c7ff3 100644 --- a/deps/icu-small/source/common/unicode/usetiter.h +++ b/deps/icu-small/source/common/unicode/usetiter.h @@ -10,11 +10,14 @@ #define USETITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" /** - * \file + * \file * \brief C++ API: UnicodeSetIterator iterates over the contents of a UnicodeSet. */ @@ -162,14 +165,14 @@ class U_COMMON_API UnicodeSetIterator : public UObject { * Ownership of the returned string remains with the iterator. * The string is guaranteed to remain valid only until the iterator is * advanced to the next item, or until the iterator is deleted. - * + * * @stable ICU 2.4 */ const UnicodeString& getString(); /** - * Advances the iteration position to the next element in the set, - * which can be either a single code point or a string. + * Advances the iteration position to the next element in the set, + * which can be either a single code point or a string. * If there are no more elements in the set, return false. * *

@@ -317,4 +320,6 @@ inline UChar32 UnicodeSetIterator::getCodepointEnd() const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/ushape.h b/deps/icu-small/source/common/unicode/ushape.h index 3064e0857281c5..78b4d027a83f55 100644 --- a/deps/icu-small/source/common/unicode/ushape.h +++ b/deps/icu-small/source/common/unicode/ushape.h @@ -24,7 +24,7 @@ /** * \file * \brief C API: Arabic shaping - * + * */ /** @@ -117,7 +117,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, * This option is an alias to U_SHAPE_LENGTH_GROW_SHRINK * @stable ICU 4.2 */ -#define U_SHAPE_LAMALEF_RESIZE 0 +#define U_SHAPE_LAMALEF_RESIZE 0 /** * Memory option: the result must have the same length as the source. @@ -133,7 +133,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_NEAR * @stable ICU 4.2 */ -#define U_SHAPE_LAMALEF_NEAR 1 +#define U_SHAPE_LAMALEF_NEAR 1 /** * Memory option: the result must have the same length as the source. @@ -149,7 +149,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_AT_END * @stable ICU 4.2 */ -#define U_SHAPE_LAMALEF_END 2 +#define U_SHAPE_LAMALEF_END 2 /** * Memory option: the result must have the same length as the source. @@ -165,7 +165,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING * @stable ICU 4.2 */ -#define U_SHAPE_LAMALEF_BEGIN 3 +#define U_SHAPE_LAMALEF_BEGIN 3 /** @@ -174,14 +174,14 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, * If there is no space at end, use spaces at beginning of the buffer. If there * is no space at beginning of the buffer, use spaces at the near (i.e. the space * after the LAMALEF character). - * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) + * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) * will be set in pErrorCode * - * Deshaping Mode: Perform the same function as the flag equals U_SHAPE_LAMALEF_END. + * Deshaping Mode: Perform the same function as the flag equals U_SHAPE_LAMALEF_END. * Affects: LamAlef options * @stable ICU 4.2 */ -#define U_SHAPE_LAMALEF_AUTO 0x10000 +#define U_SHAPE_LAMALEF_AUTO 0x10000 /** Bit mask for memory options. @stable ICU 2.0 */ #define U_SHAPE_LENGTH_MASK 0x10003 /* Changed old value 3 */ @@ -301,7 +301,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** Bit mask for digit type options. @stable ICU 2.0 */ #define U_SHAPE_DIGIT_TYPE_MASK 0x300 /* I need to change this from 0x3f00 to 0x300 */ -/** +/** * Tashkeel aggregation option: * Replaces any combination of U+0651 with one of * U+064C, U+064D, U+064E, U+064F, U+0650 with @@ -314,28 +314,28 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** Bit mask for tashkeel aggregation. @stable ICU 3.6 */ #define U_SHAPE_AGGREGATE_TASHKEEL_MASK 0x4000 -/** +/** * Presentation form option: * Don't replace Arabic Presentation Forms-A and Arabic Presentation Forms-B * characters with 0+06xx characters, before shaping. * @stable ICU 3.6 */ #define U_SHAPE_PRESERVE_PRESENTATION 0x8000 -/** Presentation form option: - * Replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with +/** Presentation form option: + * Replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with * their unshaped correspondants in range 0+06xx, before shaping. - * @stable ICU 3.6 + * @stable ICU 3.6 */ #define U_SHAPE_PRESERVE_PRESENTATION_NOOP 0 /** Bit mask for preserve presentation form. @stable ICU 3.6 */ #define U_SHAPE_PRESERVE_PRESENTATION_MASK 0x8000 -/* Seen Tail option */ +/* Seen Tail option */ /** * Memory option: the result must have the same length as the source. - * Shaping mode: The SEEN family character will expand into two characters using space near + * Shaping mode: The SEEN family character will expand into two characters using space near * the SEEN family character(i.e. the space after the character). - * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) + * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) * will be set in pErrorCode * * De-shaping mode: Any Seen character followed by Tail character will be @@ -346,17 +346,17 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, #define U_SHAPE_SEEN_TWOCELL_NEAR 0x200000 /** - * Bit mask for Seen memory options. + * Bit mask for Seen memory options. * @stable ICU 4.2 */ #define U_SHAPE_SEEN_MASK 0x700000 -/* YehHamza option */ +/* YehHamza option */ /** * Memory option: the result must have the same length as the source. - * Shaping mode: The YEHHAMZA character will expand into two characters using space near it + * Shaping mode: The YEHHAMZA character will expand into two characters using space near it * (i.e. the space after the character - * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) + * If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) * will be set in pErrorCode * * De-shaping mode: Any Yeh (final or isolated) character followed by Hamza character will be @@ -368,15 +368,15 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** - * Bit mask for YehHamza memory options. + * Bit mask for YehHamza memory options. * @stable ICU 4.2 */ #define U_SHAPE_YEHHAMZA_MASK 0x3800000 -/* New Tashkeel options */ +/* New Tashkeel options */ /** * Memory option: the result must have the same length as the source. - * Shaping mode: Tashkeel characters will be replaced by spaces. + * Shaping mode: Tashkeel characters will be replaced by spaces. * Spaces will be placed at beginning of the buffer * * De-shaping mode: N/A @@ -387,7 +387,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** * Memory option: the result must have the same length as the source. - * Shaping mode: Tashkeel characters will be replaced by spaces. + * Shaping mode: Tashkeel characters will be replaced by spaces. * Spaces will be placed at end of the buffer * * De-shaping mode: N/A @@ -398,8 +398,8 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** * Memory option: allow the result to have a different length than the source. - * Shaping mode: Tashkeel characters will be removed, buffer length will shrink. - * De-shaping mode: N/A + * Shaping mode: Tashkeel characters will be removed, buffer length will shrink. + * De-shaping mode: N/A * * Affect: Tashkeel options * @stable ICU 4.2 @@ -417,46 +417,46 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, */ #define U_SHAPE_TASHKEEL_REPLACE_BY_TATWEEL 0xC0000 -/** - * Bit mask for Tashkeel replacement with Space or Tatweel memory options. +/** + * Bit mask for Tashkeel replacement with Space or Tatweel memory options. * @stable ICU 4.2 */ #define U_SHAPE_TASHKEEL_MASK 0xE0000 -/* Space location Control options */ +/* Space location Control options */ /** * This option affect the meaning of BEGIN and END options. if this option is not used the default - * for BEGIN and END will be as following: + * for BEGIN and END will be as following: * The Default (for both Visual LTR, Visual RTL and Logical Text) * 1. BEGIN always refers to the start address of physical memory. * 2. END always refers to the end address of physical memory. * - * If this option is used it will swap the meaning of BEGIN and END only for Visual LTR text. + * If this option is used it will swap the meaning of BEGIN and END only for Visual LTR text. * * The effect on BEGIN and END Memory Options will be as following: * A. BEGIN For Visual LTR text: This will be the beginning (right side) of the visual text( - * corresponding to the physical memory address end for Visual LTR text, Same as END in + * corresponding to the physical memory address end for Visual LTR text, Same as END in * default behavior) - * B. BEGIN For Logical text: Same as BEGIN in default behavior. + * B. BEGIN For Logical text: Same as BEGIN in default behavior. * C. END For Visual LTR text: This will be the end (left side) of the visual text (corresponding * to the physical memory address beginning for Visual LTR text, Same as BEGIN in default behavior. - * D. END For Logical text: Same as END in default behavior). + * D. END For Logical text: Same as END in default behavior). * Affects: All LamAlef BEGIN, END and AUTO options. * @stable ICU 4.2 */ #define U_SHAPE_SPACES_RELATIVE_TO_TEXT_BEGIN_END 0x4000000 /** - * Bit mask for swapping BEGIN and END for Visual LTR text + * Bit mask for swapping BEGIN and END for Visual LTR text * @stable ICU 4.2 */ #define U_SHAPE_SPACES_RELATIVE_TO_TEXT_MASK 0x4000000 /** - * If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73). + * If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73). * If this option is not specified (Default), old unofficial Unicode TAIL code point is used (i.e. 0x200B) - * De-shaping will not use this option as it will always search for both the new Unicode code point for the + * De-shaping will not use this option as it will always search for both the new Unicode code point for the * TAIL (i.e. 0xFE73) or the old unofficial Unicode TAIL code point (i.e. 0x200B) and de-shape the * Seen-Family letter accordingly. * @@ -468,7 +468,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, #define U_SHAPE_TAIL_NEW_UNICODE 0x8000000 /** - * Bit mask for new Unicode Tail option + * Bit mask for new Unicode Tail option * @stable ICU 4.8 */ #define U_SHAPE_TAIL_TYPE_MASK 0x8000000 diff --git a/deps/icu-small/source/common/unicode/usprep.h b/deps/icu-small/source/common/unicode/usprep.h index 7cdc6cdd18ea6b..914eb84871b4bb 100644 --- a/deps/icu-small/source/common/unicode/usprep.h +++ b/deps/icu-small/source/common/unicode/usprep.h @@ -20,7 +20,7 @@ #define __USPREP_H__ /** - * \file + * \file * \brief C API: Implements the StringPrep algorithm. */ @@ -35,14 +35,14 @@ * Unicode Strings are prepared. Each profiles contains tables which describe * how a code point should be treated. The tables are broadly classified into *

    - *
  • Unassigned Table: Contains code points that are unassigned - * in the Unicode Version supported by StringPrep. Currently + *
  • Unassigned Table: Contains code points that are unassigned + * in the Unicode Version supported by StringPrep. Currently * RFC 3454 supports Unicode 3.2.
  • *
  • Prohibited Table: Contains code points that are prohibited from * the output of the StringPrep processing function.
  • *
  • Mapping Table: Contains code points that are deleted from the output or case mapped.
  • *
- * + * * The procedure for preparing Unicode strings: *
    *
  1. Map: For each character in the input, check if it has a mapping @@ -70,17 +70,17 @@ typedef struct UStringPrepProfile UStringPrepProfile; -/** +/** * Option to prohibit processing of unassigned code points in the input - * + * * @see usprep_prepare * @stable ICU 2.8 */ #define USPREP_DEFAULT 0x0000 -/** +/** * Option to allow processing of unassigned code points in the input - * + * * @see usprep_prepare * @stable ICU 2.8 */ @@ -182,7 +182,7 @@ typedef enum UStringPrepProfileType { * @stable ICU 2.8 */ U_STABLE UStringPrepProfile* U_EXPORT2 -usprep_open(const char* path, +usprep_open(const char* path, const char* fileName, UErrorCode* status); @@ -233,7 +233,7 @@ U_NAMESPACE_END * checks for prohibited and BiDi characters in the order defined by RFC 3454 * depending on the options specified in the profile. * - * @param prep The profile to use + * @param prep The profile to use * @param src Pointer to UChar buffer containing the string to prepare * @param srcLength Number of characters in the source string * @param dest Pointer to the destination buffer to receive the output @@ -242,10 +242,10 @@ U_NAMESPACE_END * * - USPREP_DEFAULT Prohibit processing of unassigned code points in the input * - * - USPREP_ALLOW_UNASSIGNED Treat the unassigned code points are in the input + * - USPREP_ALLOW_UNASSIGNED Treat the unassigned code points are in the input * as normal Unicode code points. * - * @param parseError Pointer to UParseError struct to receive information on position + * @param parseError Pointer to UParseError struct to receive information on position * of error if an error is encountered. Can be NULL. * @param status ICU in/out error code parameter. * U_INVALID_CHAR_FOUND if src contains @@ -259,7 +259,7 @@ U_NAMESPACE_END U_STABLE int32_t U_EXPORT2 usprep_prepare( const UStringPrepProfile* prep, - const UChar* src, int32_t srcLength, + const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UParseError* parseError, diff --git a/deps/icu-small/source/common/unicode/ustring.h b/deps/icu-small/source/common/unicode/ustring.h index 0d2274a0cabb51..245b766545ab25 100644 --- a/deps/icu-small/source/common/unicode/ustring.h +++ b/deps/icu-small/source/common/unicode/ustring.h @@ -24,7 +24,7 @@ /** * \def UBRK_TYPEDEF_UBREAK_ITERATOR - * @internal + * @internal */ #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR @@ -141,11 +141,11 @@ u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number); * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 -u_strcat(UChar *dst, +u_strcat(UChar *dst, const UChar *src); /** - * Concatenate two ustrings. + * Concatenate two ustrings. * Appends at most n characters from src to dst. * Adds a terminating NUL. * If src is too long, then only n-1 characters will be copied @@ -159,8 +159,8 @@ u_strcat(UChar *dst, * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 -u_strncat(UChar *dst, - const UChar *src, +u_strncat(UChar *dst, + const UChar *src, int32_t n); /** @@ -410,7 +410,7 @@ u_strspn(const UChar *string, const UChar *matchSet); * @stable ICU 2.0 */ U_STABLE UChar * U_EXPORT2 -u_strtok_r(UChar *src, +u_strtok_r(UChar *src, const UChar *delim, UChar **saveState); @@ -425,7 +425,7 @@ u_strtok_r(UChar *src, * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 -u_strcmp(const UChar *s1, +u_strcmp(const UChar *s1, const UChar *s2); /** @@ -544,7 +544,7 @@ u_strCaseCompare(const UChar *s1, int32_t length1, UErrorCode *pErrorCode); /** - * Compare two ustrings for bitwise equality. + * Compare two ustrings for bitwise equality. * Compares at most n characters. * * @param ucs1 A string to compare (can be NULL/invalid if n<=0). @@ -556,8 +556,8 @@ u_strCaseCompare(const UChar *s1, int32_t length1, * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 -u_strncmp(const UChar *ucs1, - const UChar *ucs2, +u_strncmp(const UChar *ucs1, + const UChar *ucs2, int32_t n); /** @@ -655,7 +655,7 @@ u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options) * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 -u_strcpy(UChar *dst, +u_strcpy(UChar *dst, const UChar *src); /** @@ -670,8 +670,8 @@ u_strcpy(UChar *dst, * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 -u_strncpy(UChar *dst, - const UChar *src, +u_strncpy(UChar *dst, + const UChar *src, int32_t n); #if !UCONFIG_NO_CONVERSION @@ -913,10 +913,10 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count); * } * return u_strcmp(ustringVar1, ustringVar2); * } - * + * * Note that the macros will NOT consistently work if their argument is another #`define`. * The following will not work on all platforms, don't use it. - * + * * #define GLUCK "Mr. Gluck" * U_STRING_DECL(var, GLUCK, 9) * U_STRING_INIT(var, GLUCK, 9) @@ -1187,11 +1187,11 @@ u_strFoldCase(UChar *dest, int32_t destCapacity, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of wchar_t's). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1201,10 +1201,10 @@ u_strFoldCase(UChar *dest, int32_t destCapacity, * @stable ICU 2.0 */ U_STABLE wchar_t* U_EXPORT2 -u_strToWCS(wchar_t *dest, +u_strToWCS(wchar_t *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); /** @@ -1216,11 +1216,11 @@ u_strToWCS(wchar_t *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1231,7 +1231,7 @@ u_strToWCS(wchar_t *dest, */ U_STABLE UChar* U_EXPORT2 u_strFromWCS(UChar *dest, - int32_t destCapacity, + int32_t destCapacity, int32_t *pDestLength, const wchar_t *src, int32_t srcLength, @@ -1245,11 +1245,11 @@ u_strFromWCS(UChar *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of chars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1260,11 +1260,11 @@ u_strFromWCS(UChar *dest, * @see u_strToUTF8WithSub * @see u_strFromUTF8 */ -U_STABLE char* U_EXPORT2 -u_strToUTF8(char *dest, +U_STABLE char* U_EXPORT2 +u_strToUTF8(char *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); @@ -1275,11 +1275,11 @@ u_strToUTF8(char *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1291,10 +1291,10 @@ u_strToUTF8(char *dest, * @see u_strFromUTF8Lenient */ U_STABLE UChar* U_EXPORT2 -u_strFromUTF8(UChar *dest, +u_strFromUTF8(UChar *dest, int32_t destCapacity, int32_t *pDestLength, - const char *src, + const char *src, int32_t srcLength, UErrorCode *pErrorCode); @@ -1308,11 +1308,11 @@ u_strFromUTF8(UChar *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of chars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1352,11 +1352,11 @@ u_strToUTF8WithSub(char *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. @@ -1414,13 +1414,13 @@ u_strFromUTF8WithSub(UChar *dest, * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then - * dest may be NULL and the function will only return the length of the + * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * Unlike for other ICU functions, if srcLength>=0 then it * must be destCapacity>=srcLength. - * @param pDestLength A pointer to receive the number of units written to the destination. If - * pDestLength!=NULL then *pDestLength is always set to the - * number of output units corresponding to the transformation of + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * Unlike for other ICU functions, if srcLength>=0 but * destCapacitychunkOffset <= (ut)->nativeIndexingLimit? \ (ut)->chunkNativeStart+(ut)->chunkOffset : \ - (ut)->pFuncs->mapOffsetToNative(ut)) + (ut)->pFuncs->mapOffsetToNative(ut)) /** * inline version of utext_setNativeIndex(), for performance-critical situations. @@ -766,12 +766,14 @@ utext_extract(UText *ut, * * @stable ICU 3.8 */ -#define UTEXT_SETNATIVEINDEX(ut, ix) \ - { int64_t __offset = (ix) - (ut)->chunkNativeStart; \ - if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \ - (ut)->chunkOffset=(int32_t)__offset; \ - } else { \ - utext_setNativeIndex((ut), (ix)); } } +#define UTEXT_SETNATIVEINDEX(ut, ix) UPRV_BLOCK_MACRO_BEGIN { \ + int64_t __offset = (ix) - (ut)->chunkNativeStart; \ + if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \ + (ut)->chunkOffset=(int32_t)__offset; \ + } else { \ + utext_setNativeIndex((ut), (ix)); \ + } \ +} UPRV_BLOCK_MACRO_END @@ -882,7 +884,7 @@ utext_replace(UText *ut, * copied or moved. * @param move If TRUE, then the substring is moved, not copied/duplicated. * @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION - * + * * @stable ICU 3.4 */ U_STABLE void U_EXPORT2 @@ -948,7 +950,7 @@ enum { * There is meta data associated with the text. * @see Replaceable::hasMetaData() * @stable ICU 3.4 - */ + */ UTEXT_PROVIDER_HAS_META_DATA = 4, /** * Text provider owns the text storage. @@ -973,7 +975,7 @@ enum { * and be prepared to handle failures. * * A shallow clone replicates only the UText data structures; it does not make - * a copy of the underlying text. Shallow clones can be used as an efficient way to + * a copy of the underlying text. Shallow clones can be used as an efficient way to * have multiple iterators active in a single text string that is not being * modified. * @@ -1182,7 +1184,7 @@ UTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex); * Function type declaration for UText.utextClose(). * * A Text Provider close function is only required for provider types that make - * allocations in their open function (or other functions) that must be + * allocations in their open function (or other functions) that must be * cleaned when the UText is closed. * * The allocation of the UText struct itself and any "extra" storage @@ -1311,7 +1313,7 @@ struct UTextFuncs { * @internal */ UTextClose *spare1; - + /** * (private) Spare function pointer * @internal @@ -1380,9 +1382,9 @@ struct UText { * @stable ICU 3.4 */ int32_t sizeOfStruct; - + /* ------ 16 byte alignment boundary ----------- */ - + /** * (protected) Native index of the first character position following @@ -1407,7 +1409,7 @@ struct UText { int32_t nativeIndexingLimit; /* ---- 16 byte alignment boundary------ */ - + /** * (protected) Native index of the first character in the text chunk. * @stable ICU 3.6 @@ -1428,7 +1430,7 @@ struct UText { int32_t chunkLength; /* ---- 16 byte alignment boundary-- */ - + /** * (protected) pointer to a chunk of text in UTF-16 format. @@ -1466,7 +1468,7 @@ struct UText { * Not used by UText common code. * @stable ICU 3.6 */ - const void *p; + const void *p; /** * (protected) Pointer fields available for use by the text provider. * Not used by UText common code. @@ -1489,7 +1491,7 @@ struct UText { /* --- 16 byte alignment boundary--- */ - + /** * (protected) Integer field reserved for use by the text provider. diff --git a/deps/icu-small/source/common/unicode/utf.h b/deps/icu-small/source/common/unicode/utf.h index aa5698069154cc..ef512997f05a15 100644 --- a/deps/icu-small/source/common/unicode/utf.h +++ b/deps/icu-small/source/common/unicode/utf.h @@ -107,7 +107,7 @@ * * Usage: * ICU coding guidelines for if() statements should be followed when using these macros. - * Compound statements (curly braces {}) must be used for if-else-while... + * Compound statements (curly braces {}) must be used for if-else-while... * bodies and all macro statements should be terminated with semicolon. * * @stable ICU 2.4 @@ -167,7 +167,7 @@ * @stable ICU 2.8 */ #define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff) - + /** * Is this code point a lead surrogate (U+d800..U+dbff)? * @param c 32-bit code point diff --git a/deps/icu-small/source/common/unicode/utf16.h b/deps/icu-small/source/common/unicode/utf16.h index 0908b4f00e9bf1..9fd7d5c8a77279 100644 --- a/deps/icu-small/source/common/unicode/utf16.h +++ b/deps/icu-small/source/common/unicode/utf16.h @@ -19,7 +19,7 @@ /** * \file * \brief C API: 16-bit Unicode handling macros - * + * * This file defines macros to deal with 16-bit Unicode (UTF-16) code units and strings. * * For more information see utf.h and the ICU User Guide Strings chapter @@ -27,7 +27,7 @@ * * Usage: * ICU coding guidelines for if() statements should be followed when using these macros. - * Compound statements (curly braces {}) must be used for if-else-while... + * Compound statements (curly braces {}) must be used for if-else-while... * bodies and all macro statements should be terminated with semicolon. */ @@ -163,7 +163,7 @@ * @see U16_GET * @stable ICU 2.4 */ -#define U16_GET_UNSAFE(s, i, c) { \ +#define U16_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ if(U16_IS_SURROGATE_LEAD(c)) { \ @@ -172,7 +172,7 @@ (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -197,7 +197,7 @@ * @see U16_GET_UNSAFE * @stable ICU 2.4 */ -#define U16_GET(s, start, i, length, c) { \ +#define U16_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -211,7 +211,7 @@ } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -236,7 +236,7 @@ * @see U16_GET_UNSAFE * @stable ICU 60 */ -#define U16_GET_OR_FFFD(s, start, i, length, c) { \ +#define U16_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -254,7 +254,7 @@ } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ @@ -277,12 +277,12 @@ * @see U16_NEXT * @stable ICU 2.4 */ -#define U16_NEXT_UNSAFE(s, i, c) { \ +#define U16_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_LEAD(c)) { \ (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -305,7 +305,7 @@ * @see U16_NEXT_UNSAFE * @stable ICU 2.4 */ -#define U16_NEXT(s, i, length, c) { \ +#define U16_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_LEAD(c)) { \ uint16_t __c2; \ @@ -314,7 +314,7 @@ (c)=U16_GET_SUPPLEMENTARY((c), __c2); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -337,7 +337,7 @@ * @see U16_NEXT_UNSAFE * @stable ICU 60 */ -#define U16_NEXT_OR_FFFD(s, i, length, c) { \ +#define U16_NEXT_OR_FFFD(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -348,7 +348,7 @@ (c)=0xfffd; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 or 2 code units. @@ -363,14 +363,14 @@ * @see U16_APPEND * @stable ICU 2.4 */ -#define U16_APPEND_UNSAFE(s, i, c) { \ +#define U16_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 or 2 code units. @@ -389,7 +389,7 @@ * @see U16_APPEND_UNSAFE * @stable ICU 2.4 */ -#define U16_APPEND(s, i, capacity, c, isError) { \ +#define U16_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \ @@ -398,7 +398,7 @@ } else /* c>0x10ffff or not enough space */ { \ (isError)=TRUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -410,11 +410,11 @@ * @see U16_FWD_1 * @stable ICU 2.4 */ -#define U16_FWD_1_UNSAFE(s, i) { \ +#define U16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)++])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -429,11 +429,11 @@ * @see U16_FWD_1_UNSAFE * @stable ICU 2.4 */ -#define U16_FWD_1(s, i, length) { \ +#define U16_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)++]) && (i)!=(length) && U16_IS_TRAIL((s)[i])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -447,13 +447,13 @@ * @see U16_FWD_N * @stable ICU 2.4 */ -#define U16_FWD_N_UNSAFE(s, i, n) { \ +#define U16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U16_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -470,13 +470,13 @@ * @see U16_FWD_N_UNSAFE * @stable ICU 2.4 */ -#define U16_FWD_N(s, i, length, n) { \ +#define U16_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \ U16_FWD_1(s, i, length); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -491,11 +491,11 @@ * @see U16_SET_CP_START * @stable ICU 2.4 */ -#define U16_SET_CP_START_UNSAFE(s, i) { \ +#define U16_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[i])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -511,11 +511,11 @@ * @see U16_SET_CP_START_UNSAFE * @stable ICU 2.4 */ -#define U16_SET_CP_START(s, start, i) { \ +#define U16_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ @@ -539,12 +539,12 @@ * @see U16_PREV * @stable ICU 2.4 */ -#define U16_PREV_UNSAFE(s, i, c) { \ +#define U16_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_TRAIL(c)) { \ (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -566,7 +566,7 @@ * @see U16_PREV_UNSAFE * @stable ICU 2.4 */ -#define U16_PREV(s, start, i, c) { \ +#define U16_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_TRAIL(c)) { \ uint16_t __c2; \ @@ -575,7 +575,7 @@ (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -597,7 +597,7 @@ * @see U16_PREV_UNSAFE * @stable ICU 60 */ -#define U16_PREV_OR_FFFD(s, start, i, c) { \ +#define U16_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -608,7 +608,7 @@ (c)=0xfffd; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -621,11 +621,11 @@ * @see U16_BACK_1 * @stable ICU 2.4 */ -#define U16_BACK_1_UNSAFE(s, i) { \ +#define U16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[--(i)])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -639,11 +639,11 @@ * @see U16_BACK_1_UNSAFE * @stable ICU 2.4 */ -#define U16_BACK_1(s, start, i) { \ +#define U16_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -658,13 +658,13 @@ * @see U16_BACK_N * @stable ICU 2.4 */ -#define U16_BACK_N_UNSAFE(s, i, n) { \ +#define U16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U16_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -680,13 +680,13 @@ * @see U16_BACK_N_UNSAFE * @stable ICU 2.4 */ -#define U16_BACK_N(s, start, i, n) { \ +#define U16_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && (i)>(start)) { \ U16_BACK_1(s, start, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -701,11 +701,11 @@ * @see U16_SET_CP_LIMIT * @stable ICU 2.4 */ -#define U16_SET_CP_LIMIT_UNSAFE(s, i) { \ +#define U16_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)-1])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -724,10 +724,10 @@ * @see U16_SET_CP_LIMIT_UNSAFE * @stable ICU 2.4 */ -#define U16_SET_CP_LIMIT(s, start, i, length) { \ +#define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END #endif diff --git a/deps/icu-small/source/common/unicode/utf8.h b/deps/icu-small/source/common/unicode/utf8.h index 41155f119bbb86..4987a00e8e08bf 100644 --- a/deps/icu-small/source/common/unicode/utf8.h +++ b/deps/icu-small/source/common/unicode/utf8.h @@ -19,7 +19,7 @@ /** * \file * \brief C API: 8-bit Unicode handling macros - * + * * This file defines macros to deal with 8-bit Unicode (UTF-8) code units (bytes) and strings. * * For more information see utf.h and the ICU User Guide Strings chapter @@ -27,7 +27,7 @@ * * Usage: * ICU coding guidelines for if() statements should be followed when using these macros. - * Compound statements (curly braces {}) must be used for if-else-while... + * Compound statements (curly braces {}) must be used for if-else-while... * bodies and all macro statements should be terminated with semicolon. */ @@ -229,11 +229,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET * @stable ICU 2.4 */ -#define U8_GET_UNSAFE(s, i, c) { \ +#define U8_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_unsafe_index=(int32_t)(i); \ U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \ U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -256,11 +256,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET_UNSAFE * @stable ICU 2.4 */ -#define U8_GET(s, start, i, length, c) { \ +#define U8_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_index=(i); \ U8_SET_CP_START(s, start, _u8_get_index); \ U8_NEXT(s, _u8_get_index, length, c); \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -287,11 +287,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET * @stable ICU 51 */ -#define U8_GET_OR_FFFD(s, start, i, length, c) { \ +#define U8_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_index=(i); \ U8_SET_CP_START(s, start, _u8_get_index); \ U8_NEXT_OR_FFFD(s, _u8_get_index, length, c); \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ @@ -312,7 +312,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_NEXT * @stable ICU 2.4 */ -#define U8_NEXT_UNSAFE(s, i, c) { \ +#define U8_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[(i)++]; \ if(!U8_IS_SINGLE(c)) { \ if((c)<0xe0) { \ @@ -326,7 +326,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); (i)+=3; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -377,7 +377,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); #define U8_NEXT_OR_FFFD(s, i, length, c) U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, 0xfffd) /** @internal */ -#define U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, sub) { \ +#define U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, sub) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[(i)++]; \ if(!U8_IS_SINGLE(c)) { \ uint8_t __t = 0; \ @@ -403,7 +403,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); (c)=(sub); /* ill-formed*/ \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 to 4 bytes. @@ -418,7 +418,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_APPEND * @stable ICU 2.4 */ -#define U8_APPEND_UNSAFE(s, i, c) { \ +#define U8_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t __uc=(c); \ if(__uc<=0x7f) { \ (s)[(i)++]=(uint8_t)__uc; \ @@ -436,7 +436,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ (s)[(i)++]=(uint8_t)((__uc&0x3f)|0x80); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 to 4 bytes. @@ -455,7 +455,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_APPEND_UNSAFE * @stable ICU 2.4 */ -#define U8_APPEND(s, i, capacity, c, isError) { \ +#define U8_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t __uc=(c); \ if(__uc<=0x7f) { \ (s)[(i)++]=(uint8_t)__uc; \ @@ -474,7 +474,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } else { \ (isError)=TRUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -486,9 +486,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_1 * @stable ICU 2.4 */ -#define U8_FWD_1_UNSAFE(s, i) { \ +#define U8_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=1+U8_COUNT_TRAIL_BYTES_UNSAFE((s)[i]); \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -503,7 +503,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_1_UNSAFE * @stable ICU 2.4 */ -#define U8_FWD_1(s, i, length) { \ +#define U8_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __b=(s)[(i)++]; \ if(U8_IS_LEAD(__b) && (i)!=(length)) { \ uint8_t __t1=(s)[i]; \ @@ -524,7 +524,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -538,13 +538,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_N * @stable ICU 2.4 */ -#define U8_FWD_N_UNSAFE(s, i, n) { \ +#define U8_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U8_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -561,13 +561,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_N_UNSAFE * @stable ICU 2.4 */ -#define U8_FWD_N(s, i, length, n) { \ +#define U8_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \ U8_FWD_1(s, i, length); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -582,9 +582,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_START * @stable ICU 2.4 */ -#define U8_SET_CP_START_UNSAFE(s, i) { \ +#define U8_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(U8_IS_TRAIL((s)[i])) { --(i); } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -603,11 +603,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_TRUNCATE_IF_INCOMPLETE * @stable ICU 2.4 */ -#define U8_SET_CP_START(s, start, i) { \ +#define U8_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U8_IS_TRAIL((s)[(i)])) { \ (i)=utf8_back1SafeBody(s, start, (i)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * If the string ends with a UTF-8 byte sequence that is valid so far @@ -635,7 +635,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_START * @stable ICU 61 */ -#define U8_TRUNCATE_IF_INCOMPLETE(s, start, length) \ +#define U8_TRUNCATE_IF_INCOMPLETE(s, start, length) UPRV_BLOCK_MACRO_BEGIN { \ if((length)>(start)) { \ uint8_t __b1=s[(length)-1]; \ if(U8_IS_SINGLE(__b1)) { \ @@ -656,7 +656,8 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ @@ -679,7 +680,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV * @stable ICU 2.4 */ -#define U8_PREV_UNSAFE(s, i, c) { \ +#define U8_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(U8_IS_TRAIL(c)) { \ uint8_t __b, __count=1, __shift=6; \ @@ -699,7 +700,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -721,12 +722,12 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV_UNSAFE * @stable ICU 2.4 */ -#define U8_PREV(s, start, i, c) { \ +#define U8_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(!U8_IS_SINGLE(c)) { \ (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -1); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -752,12 +753,12 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV * @stable ICU 51 */ -#define U8_PREV_OR_FFFD(s, start, i, c) { \ +#define U8_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(!U8_IS_SINGLE(c)) { \ (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -3); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -770,9 +771,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_1 * @stable ICU 2.4 */ -#define U8_BACK_1_UNSAFE(s, i) { \ +#define U8_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(U8_IS_TRAIL((s)[--(i)])) {} \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -786,11 +787,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_1_UNSAFE * @stable ICU 2.4 */ -#define U8_BACK_1(s, start, i) { \ +#define U8_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U8_IS_TRAIL((s)[--(i)])) { \ (i)=utf8_back1SafeBody(s, start, (i)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -805,13 +806,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_N * @stable ICU 2.4 */ -#define U8_BACK_N_UNSAFE(s, i, n) { \ +#define U8_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U8_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -827,13 +828,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_N_UNSAFE * @stable ICU 2.4 */ -#define U8_BACK_N(s, start, i, n) { \ +#define U8_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && (i)>(start)) { \ U8_BACK_1(s, start, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -848,10 +849,10 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_LIMIT * @stable ICU 2.4 */ -#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \ +#define U8_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ U8_BACK_1_UNSAFE(s, i); \ U8_FWD_1_UNSAFE(s, i); \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -870,11 +871,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_LIMIT_UNSAFE * @stable ICU 2.4 */ -#define U8_SET_CP_LIMIT(s, start, i, length) { \ +#define U8_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if((start)<(i) && ((i)<(length) || (length)<0)) { \ U8_BACK_1(s, start, i); \ U8_FWD_1(s, i, length); \ } \ -} +} UPRV_BLOCK_MACRO_END #endif diff --git a/deps/icu-small/source/common/unicode/utf_old.h b/deps/icu-small/source/common/unicode/utf_old.h index 55c17c01df6db3..b2428e6b31e282 100644 --- a/deps/icu-small/source/common/unicode/utf_old.h +++ b/deps/icu-small/source/common/unicode/utf_old.h @@ -19,9 +19,6 @@ /** * \file * \brief C API: Deprecated macros for Unicode string handling - */ - -/** * * The macros in utf_old.h are all deprecated and their use discouraged. * Some of the design principles behind the set of UTF macros @@ -139,12 +136,16 @@ * *
    * - * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead. + * Deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead. */ #ifndef __UTF_OLD_H__ #define __UTF_OLD_H__ +#include "unicode/utf.h" +#include "unicode/utf8.h" +#include "unicode/utf16.h" + /** * \def U_HIDE_OBSOLETE_UTF_OLD_H * @@ -162,10 +163,6 @@ #if !defined(U_HIDE_DEPRECATED_API) && !U_HIDE_OBSOLETE_UTF_OLD_H -#include "unicode/utf.h" -#include "unicode/utf8.h" -#include "unicode/utf16.h" - /* Formerly utf.h, part 1 --------------------------------------------------- */ #ifdef U_USE_UTF_DEPRECATES @@ -365,21 +362,21 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF8_ARRAY_SIZE(size) ((5*(size))/2) /** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */ -#define UTF8_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \ UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */ -#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _utf8_get_char_safe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \ UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */ -#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if((uint8_t)((c)-0xc0)<0x35) { \ uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \ @@ -396,10 +393,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I break; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */ -#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ @@ -416,29 +413,29 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } \ (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */ -#define UTF8_FWD_1_UNSAFE(s, i) { \ +#define UTF8_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */ -#define UTF8_FWD_N_UNSAFE(s, i, n) { \ +#define UTF8_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */ -#define UTF8_SET_CHAR_START_UNSAFE(s, i) { \ +#define UTF8_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(UTF8_IS_TRAIL((s)[i])) { --(i); } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */ -#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if((c)>=0x80) { \ if(UTF8_IS_LEAD(c)) { \ @@ -447,16 +444,16 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF8_ERROR_VALUE_1; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */ -#define UTF8_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF8_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */ #define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length) @@ -468,7 +465,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */ -#define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF8_IS_TRAIL(c)) { \ uint8_t __b, __count=1, __shift=6; \ @@ -488,30 +485,30 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */ -#define UTF8_BACK_1_UNSAFE(s, i) { \ +#define UTF8_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(UTF8_IS_TRAIL((s)[--(i)])) {} \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */ -#define UTF8_BACK_N_UNSAFE(s, i, n) { \ +#define UTF8_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ -#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \ +#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ UTF8_BACK_1_UNSAFE(s, i); \ UTF8_FWD_1_UNSAFE(s, i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */ -#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if((c)>=0x80) { \ if((c)<=0xbf) { \ @@ -520,7 +517,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF8_ERROR_VALUE_1; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */ #define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i) @@ -593,7 +590,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that. * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */ -#define UTF16_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ if(UTF_IS_SURROGATE_FIRST(c)) { \ @@ -602,10 +599,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */ -#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -629,51 +626,51 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */ -#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */ -#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */ -#define UTF16_FWD_1_UNSAFE(s, i) { \ +#define UTF16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */ -#define UTF16_FWD_N_UNSAFE(s, i, n) { \ +#define UTF16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */ -#define UTF16_SET_CHAR_START_UNSAFE(s, i) { \ +#define UTF16_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_SECOND_SURROGATE((s)[i])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */ -#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ uint16_t __c2; \ @@ -689,10 +686,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I /* unmatched second surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */ -#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else if((uint32_t)(c)<=0x10ffff) { \ @@ -705,7 +702,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } else /* c>0x10ffff, write error value */ { \ (s)[(i)++]=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */ #define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length) @@ -717,38 +714,38 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */ -#define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */ -#define UTF16_BACK_1_UNSAFE(s, i) { \ +#define UTF16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */ -#define UTF16_BACK_N_UNSAFE(s, i, n) { \ +#define UTF16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ -#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \ +#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */ -#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ uint16_t __c2; \ @@ -764,7 +761,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I /* unmatched first surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */ #define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i) @@ -830,122 +827,122 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF32_ARRAY_SIZE(size) (size) /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (s)[(i)++]=(c); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_1_UNSAFE(s, i) { \ +#define UTF32_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ ++(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_N_UNSAFE(s, i, n) { \ +#define UTF32_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=(n); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_START_UNSAFE(s, i) { \ -} +#define UTF32_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x10ffff) { \ (s)[(i)++]=(c); \ } else /* c>0x10ffff, write 0xfffd */ { \ (s)[(i)++]=0xfffd; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_1_SAFE(s, i, length) { \ +#define UTF32_FWD_1_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ ++(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_N_SAFE(s, i, length, n) { \ +#define UTF32_FWD_N_SAFE(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ if(((i)+=(n))>(length)) { \ (i)=(length); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_START_SAFE(s, start, i) { \ -} +#define UTF32_SET_CHAR_START_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_1_UNSAFE(s, i) { \ +#define UTF32_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ --(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_N_UNSAFE(s, i, n) { \ +#define UTF32_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)-=(n); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \ -} +#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_1_SAFE(s, start, i) { \ +#define UTF32_BACK_1_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ --(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_N_SAFE(s, start, i, n) { \ +#define UTF32_BACK_N_SAFE(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)-=(n); \ if((i)<(start)) { \ (i)=(start); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \ -} +#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /* Formerly utf.h, part 2 --------------------------------------------------- */ diff --git a/deps/icu-small/source/common/unicode/utrace.h b/deps/icu-small/source/common/unicode/utrace.h index bf6fd036f06c41..5afcd9f4490828 100644 --- a/deps/icu-small/source/common/unicode/utrace.h +++ b/deps/icu-small/source/common/unicode/utrace.h @@ -27,15 +27,15 @@ /** * \file - * \brief C API: Definitions for ICU tracing/logging. + * \brief C API: Definitions for ICU tracing/logging. * * This provides API for debugging the internals of ICU without the use of * a traditional debugger. * - * By default, tracing is disabled in ICU. If you need to debug ICU with + * By default, tracing is disabled in ICU. If you need to debug ICU with * tracing, please compile ICU with the --enable-tracing configure option. */ - + U_CDECL_BEGIN /** @@ -66,6 +66,7 @@ typedef enum UTraceFunctionNumber { UTRACE_FUNCTION_START=0, UTRACE_U_INIT=UTRACE_FUNCTION_START, UTRACE_U_CLEANUP, + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. @@ -83,6 +84,7 @@ typedef enum UTraceFunctionNumber { UTRACE_UCNV_FLUSH_CACHE, UTRACE_UCNV_LOAD, UTRACE_UCNV_UNLOAD, + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. @@ -101,13 +103,80 @@ typedef enum UTraceFunctionNumber { UTRACE_UCOL_STRCOLLITER, UTRACE_UCOL_OPEN_FROM_SHORT_STRING, UTRACE_UCOL_STRCOLLUTF8, /**< @stable ICU 50 */ + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UTRACE_COLLATION_LIMIT + UTRACE_COLLATION_LIMIT, #endif // U_HIDE_DEPRECATED_API + +#ifndef U_HIDE_DRAFT_API + + /** + * The lowest resource/data location. + * @draft ICU 65 + */ + UTRACE_UDATA_START=0x3000, + + /** + * Indicates that a value was read from a resource bundle. Provides three + * C-style strings to UTraceData: type, file name, and resource path. The + * possible types are: + * + * - "string" (a string value was accessed) + * - "binary" (a binary value was accessed) + * - "intvector" (a integer vector value was accessed) + * - "int" (a signed integer value was accessed) + * - "uint" (a unsigned integer value was accessed) + * - "get" (a path was loaded, but the value was not accessed) + * - "getalias" (a path was loaded, and an alias was resolved) + * + * @draft ICU 65 + */ + UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START, + + /** + * Indicates that a resource bundle was opened. + * + * Provides one C-style string to UTraceData: file name. + * @draft ICU 65 + */ + UTRACE_UDATA_BUNDLE, + + /** + * Indicates that a data file was opened, but not *.res files. + * + * Provides one C-style string to UTraceData: file name. + * + * @draft ICU 65 + */ + UTRACE_UDATA_DATA_FILE, + + /** + * Indicates that a *.res file was opened. + * + * This differs from UTRACE_UDATA_BUNDLE because a res file is typically + * opened only once per application runtime, but the bundle corresponding + * to that res file may be opened many times. + * + * Provides one C-style string to UTraceData: file name. + * + * @draft ICU 65 + */ + UTRACE_UDATA_RES_FILE, + +#endif // U_HIDE_DRAFT_API + +#ifndef U_HIDE_INTERNAL_API + /** + * One more than the highest normal resource/data trace location. + * @internal The numeric value may change over time, see ICU ticket #12420. + */ + UTRACE_RES_DATA_LIMIT, +#endif // U_HIDE_INTERNAL_API + } UTraceFunctionNumber; /** @@ -151,7 +220,7 @@ UTraceEntry(const void *context, int32_t fnNumber); * @stable ICU 2.8 */ typedef void U_CALLCONV -UTraceExit(const void *context, int32_t fnNumber, +UTraceExit(const void *context, int32_t fnNumber, const char *fmt, va_list args); /** @@ -187,11 +256,11 @@ UTraceData(const void *context, int32_t fnNumber, int32_t level, * here will in turn be passed to each of the tracing * functions UTraceEntry, UTraceExit and UTraceData. * ICU does not use or alter this pointer. - * @param e Callback function to be called on entry to a + * @param e Callback function to be called on entry to a * a traced ICU function. * @param x Callback function to be called on exit from a * traced ICU function. - * @param d Callback function to be called from within a + * @param d Callback function to be called from within a * traced ICU function, for the purpose of providing * data to the trace. * @@ -259,7 +328,7 @@ utrace_getFunctions(const void **context, * - S A UChar * string. Requires two params, (ptr, length). Length=-1 for nul term. * - b A byte (8-bit integer). * - h A 16-bit integer. Also a 16 bit Unicode code unit. - * - d A 32-bit integer. Also a 20 bit Unicode code point value. + * - d A 32-bit integer. Also a 20 bit Unicode code point value. * - l A 64-bit integer. * - p A data pointer. * @@ -291,7 +360,7 @@ utrace_getFunctions(const void **context, * the type casts will not be necessary in actual code * * UTraceDataFunc(context, fnNumber, level, - * "There is a character %c in the string %s.", // Format String + * "There is a character %c in the string %s.", // Format String * (char)c, (const char *)s); // varargs parameters * -> There is a character 0x42 'B' in the string "Bravo". * @@ -330,7 +399,7 @@ utrace_getFunctions(const void **context, * @param fmt Format specification for the data to output * @param args Data to be formatted. * @return Length of formatted output, including the terminating NUL. - * If buffer capacity is insufficient, the required capacity is returned. + * If buffer capacity is insufficient, the required capacity is returned. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 @@ -351,7 +420,7 @@ utrace_vformat(char *outBuf, int32_t capacity, * @param fmt Format specification for the data to output * @param ... Data to be formatted. * @return Length of formatted output, including the terminating NUL. - * If buffer capacity is insufficient, the required capacity is returned. + * If buffer capacity is insufficient, the required capacity is returned. * @stable ICU 2.8 */ U_STABLE int32_t U_EXPORT2 diff --git a/deps/icu-small/source/common/unicode/utypes.h b/deps/icu-small/source/common/unicode/utypes.h index 49eb12cd40022c..8d8f54764e08bc 100644 --- a/deps/icu-small/source/common/unicode/utypes.h +++ b/deps/icu-small/source/common/unicode/utypes.h @@ -211,16 +211,16 @@ typedef double UDate; /** The number of milliseconds per day @stable ICU 2.0 */ #define U_MILLIS_PER_DAY (86400000) -/** - * Maximum UDate value - * @stable ICU 4.8 - */ +/** + * Maximum UDate value + * @stable ICU 4.8 + */ #define U_DATE_MAX DBL_MAX /** - * Minimum UDate value - * @stable ICU 4.8 - */ + * Minimum UDate value + * @stable ICU 4.8 + */ #define U_DATE_MIN -U_DATE_MAX /*===========================================================================*/ @@ -385,17 +385,31 @@ typedef double UDate; /*===========================================================================*/ /** - * Error code to replace exception handling, so that the code is compatible with all C++ compilers, - * and to use the same mechanism for C and C++. + * Standard ICU4C error code type, a substitute for exceptions. + * + * Initialize the UErrorCode with U_ZERO_ERROR, and check for success or + * failure using U_SUCCESS() or U_FAILURE(): + * + * UErrorCode errorCode = U_ZERO_ERROR; + * // call ICU API that needs an error code parameter. + * if (U_FAILURE(errorCode)) { + * // An error occurred. Handle it here. + * } + * + * C++ code should use icu::ErrorCode, available in unicode/errorcode.h, or a + * suitable subclass. + * + * For more information, see: + * http://icu-project.org/userguide/conventions + * + * Note: By convention, ICU functions that take a reference (C++) or a pointer + * (C) to a UErrorCode first test: + * + * if (U_FAILURE(errorCode)) { return immediately; } * - * \par - * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode - * first test if(U_FAILURE(errorCode)) { return immediately; } * so that in a chain of such functions the first one that sets an error code * causes the following ones to not perform any operations. * - * \par - * Error codes should be tested using U_FAILURE() and U_SUCCESS(). * @stable ICU 2.0 */ typedef enum UErrorCode { @@ -421,7 +435,7 @@ typedef enum UErrorCode { U_AMBIGUOUS_ALIAS_WARNING = -122, /**< This converter alias can go to different converter implementations */ U_DIFFERENT_UCA_VERSION = -121, /**< ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function */ - + U_PLUGIN_CHANGED_LEVEL_WARNING = -120, /**< A plugin caused a level change. May not be an error, but later plugins may not load. */ #ifndef U_HIDE_DEPRECATED_API @@ -642,7 +656,7 @@ typedef enum UErrorCode { U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR, U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR, U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR, - + /* * Error codes in the range 0x10500-0x105ff are reserved for Plugin related error codes. */ diff --git a/deps/icu-small/source/common/unicode/uvernum.h b/deps/icu-small/source/common/unicode/uvernum.h index 7c114be2cc87f1..0923c1d9189d0f 100644 --- a/deps/icu-small/source/common/unicode/uvernum.h +++ b/deps/icu-small/source/common/unicode/uvernum.h @@ -60,13 +60,13 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION_MAJOR_NUM 64 +#define U_ICU_VERSION_MAJOR_NUM 65 /** The current ICU minor version as an integer. * This value will change in the subsequent releases of ICU * @stable ICU 2.6 */ -#define U_ICU_VERSION_MINOR_NUM 2 +#define U_ICU_VERSION_MINOR_NUM 1 /** The current ICU patchlevel version as an integer. * This value will change in the subsequent releases of ICU @@ -86,7 +86,7 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.6 */ -#define U_ICU_VERSION_SUFFIX _64 +#define U_ICU_VERSION_SUFFIX _65 /** * \def U_DEF2_ICU_ENTRY_POINT_RENAME @@ -139,7 +139,7 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION "64.2" +#define U_ICU_VERSION "65.1" /** * The current ICU library major version number as a string, for library name suffixes. @@ -152,13 +152,13 @@ * * @stable ICU 2.6 */ -#define U_ICU_VERSION_SHORT "64" +#define U_ICU_VERSION_SHORT "65" #ifndef U_HIDE_INTERNAL_API /** Data version in ICU4C. * @internal ICU 4.4 Internal Use Only **/ -#define U_ICU_DATA_VERSION "64.2" +#define U_ICU_DATA_VERSION "65.1" #endif /* U_HIDE_INTERNAL_API */ /*=========================================================================== diff --git a/deps/icu-small/source/common/unicode/uversion.h b/deps/icu-small/source/common/unicode/uversion.h index 3f0251d3994bcb..5700f62cbff3b9 100644 --- a/deps/icu-small/source/common/unicode/uversion.h +++ b/deps/icu-small/source/common/unicode/uversion.h @@ -18,7 +18,7 @@ /** * \file - * \brief C API: API for accessing ICU version numbers. + * \brief C API: API for accessing ICU version numbers. */ /*===========================================================================*/ /* Main ICU version information */ @@ -62,26 +62,22 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; /* C++ namespace if supported. Versioned unless versioning is disabled. */ /*===========================================================================*/ +/* Define C++ namespace symbols. */ +#ifdef __cplusplus + /** * \def U_NAMESPACE_BEGIN - * This is used to begin a declaration of a public ICU C++ API. - * When not compiling for C++, it does nothing. - * When compiling for C++, it begins an extern "C++" linkage block (to protect - * against cases in which an external client includes ICU header files inside - * an extern "C" linkage block). + * This is used to begin a declaration of a public ICU C++ API within + * versioned-ICU-namespace block. * - * It also begins a versioned-ICU-namespace block. * @stable ICU 2.4 */ /** * \def U_NAMESPACE_END * This is used to end a declaration of a public ICU C++ API. - * When not compiling for C++, it does nothing. - * When compiling for C++, it ends the extern "C++" block begun by - * U_NAMESPACE_BEGIN. + * It ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN. * - * It also ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN. * @stable ICU 2.4 */ @@ -89,9 +85,6 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; * \def U_NAMESPACE_USE * This is used to specify that the rest of the code uses the * public ICU C++ API namespace. - * This is invoked by default; we recommend that you turn it off: - * See the "Recommended Build Options" section of the ICU4C readme - * (http://source.icu-project.org/repos/icu/icu/trunk/readme.html#RecBuild) * @stable ICU 2.4 */ @@ -105,8 +98,6 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; * @stable ICU 2.4 */ -/* Define C++ namespace symbols. */ -#ifdef __cplusplus # if U_DISABLE_RENAMING # define U_ICU_NAMESPACE icu namespace U_ICU_NAMESPACE { } @@ -116,8 +107,8 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; namespace icu = U_ICU_NAMESPACE; # endif -# define U_NAMESPACE_BEGIN extern "C++" { namespace U_ICU_NAMESPACE { -# define U_NAMESPACE_END } } +# define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE { +# define U_NAMESPACE_END } # define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE; # define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE:: @@ -133,12 +124,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; # if U_USING_ICU_NAMESPACE U_NAMESPACE_USE # endif -#else -# define U_NAMESPACE_BEGIN -# define U_NAMESPACE_END -# define U_NAMESPACE_USE -# define U_NAMESPACE_QUALIFIER -#endif +#endif /* __cplusplus */ /*===========================================================================*/ /* General version helper functions. Definitions in putil.c */ diff --git a/deps/icu-small/source/common/unifiedcache.cpp b/deps/icu-small/source/common/unifiedcache.cpp index 641f4ec6594e12..f2dd916559588c 100644 --- a/deps/icu-small/source/common/unifiedcache.cpp +++ b/deps/icu-small/source/common/unifiedcache.cpp @@ -13,22 +13,15 @@ #include "unifiedcache.h" #include // For std::max() +#include -#include "mutex.h" #include "uassert.h" #include "uhash.h" #include "ucln_cmn.h" -#include "umutex.h" static icu::UnifiedCache *gCache = NULL; -static icu::UMutex *gCacheMutex() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} -static icu::UConditionVar *gInProgressValueAddedCond() { - static icu::UConditionVar cv = U_CONDITION_INITIALIZER; - return &cv; -} +static std::mutex *gCacheMutex = nullptr; +static std::condition_variable *gInProgressValueAddedCond; static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; static const int32_t MAX_EVICT_ITERATIONS = 10; @@ -39,10 +32,12 @@ static const int32_t DEFAULT_PERCENTAGE_OF_IN_USE = 100; U_CDECL_BEGIN static UBool U_CALLCONV unifiedcache_cleanup() { gCacheInitOnce.reset(); - if (gCache) { - delete gCache; - gCache = NULL; - } + delete gCache; + gCache = nullptr; + gCacheMutex->~mutex(); + gCacheMutex = nullptr; + gInProgressValueAddedCond->~condition_variable(); + gInProgressValueAddedCond = nullptr; return TRUE; } U_CDECL_END @@ -77,6 +72,8 @@ static void U_CALLCONV cacheInit(UErrorCode &status) { ucln_common_registerCleanup( UCLN_COMMON_UNIFIED_CACHE, unifiedcache_cleanup); + gCacheMutex = STATIC_NEW(std::mutex); + gInProgressValueAddedCond = STATIC_NEW(std::condition_variable); gCache = new UnifiedCache(status); if (gCache == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -138,28 +135,28 @@ void UnifiedCache::setEvictionPolicy( status = U_ILLEGAL_ARGUMENT_ERROR; return; } - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); fMaxUnused = count; fMaxPercentageOfInUse = percentageOfInUseItems; } int32_t UnifiedCache::unusedCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return uhash_count(fHashtable) - fNumValuesInUse; } int64_t UnifiedCache::autoEvictedCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return fAutoEvictedCount; } int32_t UnifiedCache::keyCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return uhash_count(fHashtable); } void UnifiedCache::flush() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); // Use a loop in case cache items that are flushed held hard references to // other cache items making those additional cache items eligible for @@ -168,7 +165,7 @@ void UnifiedCache::flush() const { } void UnifiedCache::handleUnreferencedObject() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); --fNumValuesInUse; _runEvictionSlice(); } @@ -187,7 +184,7 @@ void UnifiedCache::dump() { } void UnifiedCache::dumpContents() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); _dumpContents(); } @@ -227,7 +224,7 @@ UnifiedCache::~UnifiedCache() { // Now all that should be left in the cache are entries that refer to // each other and entries with hard references from outside the cache. // Nothing we can do about these so proceed to wipe out the cache. - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); _flush(TRUE); } uhash_close(fHashtable); @@ -328,7 +325,7 @@ void UnifiedCache::_putIfAbsentAndGet( const CacheKeyBase &key, const SharedObject *&value, UErrorCode &status) const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); const UHashElement *element = uhash_find(fHashtable, &key); if (element != NULL && !_inProgress(element)) { _fetch(element, value, status); @@ -353,15 +350,15 @@ UBool UnifiedCache::_poll( UErrorCode &status) const { U_ASSERT(value == NULL); U_ASSERT(status == U_ZERO_ERROR); - Mutex lock(gCacheMutex()); + std::unique_lock lock(*gCacheMutex); const UHashElement *element = uhash_find(fHashtable, &key); // If the hash table contains an inProgress placeholder entry for this key, // this means that another thread is currently constructing the value object. // Loop, waiting for that construction to complete. while (element != NULL && _inProgress(element)) { - umtx_condWait(gInProgressValueAddedCond(), gCacheMutex()); - element = uhash_find(fHashtable, &key); + gInProgressValueAddedCond->wait(lock); + element = uhash_find(fHashtable, &key); } // If the hash table contains an entry for the key, @@ -433,7 +430,7 @@ void UnifiedCache::_put( // Tell waiting threads that we replace in-progress status with // an error. - umtx_condBroadcast(gInProgressValueAddedCond()); + gInProgressValueAddedCond->notify_all(); } void UnifiedCache::_fetch( diff --git a/deps/icu-small/source/common/unifiedcache.h b/deps/icu-small/source/common/unifiedcache.h index 5c0bd76f4a2b94..d6c9945126c222 100644 --- a/deps/icu-small/source/common/unifiedcache.h +++ b/deps/icu-small/source/common/unifiedcache.h @@ -39,7 +39,7 @@ class U_COMMON_API CacheKeyBase : public UObject { /** * Copy constructor. Needed to support cloning. */ - CacheKeyBase(const CacheKeyBase &other) + CacheKeyBase(const CacheKeyBase &other) : UObject(other), fCreationStatus(other.fCreationStatus), fIsMaster(FALSE) { } virtual ~CacheKeyBase(); @@ -95,7 +95,7 @@ class U_COMMON_API CacheKeyBase : public UObject { /** - * Templated version of CacheKeyBase. + * Templated version of CacheKeyBase. * A key of type LocaleCacheKey maps to a value of type T. */ template @@ -343,7 +343,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { virtual void handleUnreferencedObject() const; virtual ~UnifiedCache(); - + private: UHashtable *fHashtable; mutable int32_t fEvictPos; @@ -353,17 +353,17 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { int32_t fMaxPercentageOfInUse; mutable int64_t fAutoEvictedCount; SharedObject *fNoValue; - + UnifiedCache(const UnifiedCache &other); UnifiedCache &operator=(const UnifiedCache &other); - + /** * Flushes the contents of the cache. If cache values hold references to other * cache values then _flush should be called in a loop until it returns FALSE. - * + * * On entry, gCacheMutex must be held. * On exit, those values with are evictable are flushed. - * + * * @param all if false flush evictable items only, which are those with no external * references, plus those that can be safely recreated.
    * if true, flush all elements. Any values (sharedObjects) with remaining @@ -373,7 +373,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { * @return TRUE if any value in cache was flushed or FALSE otherwise. */ UBool _flush(UBool all) const; - + /** * Gets value out of cache. * On entry. gCacheMutex must not be held. value must be NULL. status @@ -406,10 +406,10 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { const CacheKeyBase &key, const SharedObject *&value, UErrorCode &status) const; - + /** * Places a new value and creationStatus in the cache for the given key. - * On entry, gCacheMutex must be held. key must not exist in the cache. + * On entry, gCacheMutex must be held. key must not exist in the cache. * On exit, value and creation status placed under key. Soft reference added * to value on successful add. On error sets status. */ @@ -418,15 +418,15 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { const SharedObject *value, const UErrorCode creationStatus, UErrorCode &status) const; - + /** * Places value and status at key if there is no value at key or if cache * entry for key is in progress. Otherwise, it leaves the current value and * status there. - * + * * On entry. gCacheMutex must not be held. Value must be * included in the reference count of the object to which it points. - * + * * On exit, value and status are changed to what was already in the cache if * something was there and not in progress. Otherwise, value and status are left * unchanged in which case they are placed in the cache on a best-effort basis. @@ -443,17 +443,17 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { * On entry, gCacheMutex must be held. */ const UHashElement *_nextElement() const; - + /** * Return the number of cache items that would need to be evicted * to bring usage into conformance with eviction policy. - * + * * An item corresponds to an entry in the hash table, a hash table element. - * + * * On entry, gCacheMutex must be held. */ int32_t _computeCountOfItemsToEvict() const; - + /** * Run an eviction slice. * On entry, gCacheMutex must be held. @@ -461,20 +461,20 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { * 10 entries in the cache round robin style evicting them if they are eligible. */ void _runEvictionSlice() const; - + /** * Register a master cache entry. A master key is the first key to create * a given SharedObject value. Subsequent keys whose create function * produce referneces to an already existing SharedObject are not masters - * they can be evicted and subsequently recreated. - * + * * On entry, gCacheMutex must be held. * On exit, items in use count incremented, entry is marked as a master * entry, and value registered with cache so that subsequent calls to * addRef() and removeRef() on it correctly interact with the cache. */ void _registerMaster(const CacheKeyBase *theKey, const SharedObject *value) const; - + /** * Store a value and creation error status in given hash entry. * On entry, gCacheMutex must be held. Hash entry element must be in progress. @@ -494,32 +494,32 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { * @param value the SharedObject to be acted on. */ void removeSoftRef(const SharedObject *value) const; - + /** * Increment the hard reference count of the given SharedObject. * gCacheMutex must be held by the caller. * Update numValuesEvictable on transitions between zero and one reference. - * + * * @param value The SharedObject to be referenced. * @return the hard reference count after the addition. */ int32_t addHardRef(const SharedObject *value) const; - + /** * Decrement the hard reference count of the given SharedObject. * gCacheMutex must be held by the caller. * Update numValuesEvictable on transitions between one and zero reference. - * + * * @param value The SharedObject to be referenced. * @return the hard reference count after the removal. */ int32_t removeHardRef(const SharedObject *value) const; - + #ifdef UNIFIED_CACHE_DEBUG void _dumpContents() const; #endif - + /** * Fetch value and error code from a particular hash entry. * On entry, gCacheMutex must be held. value must be either NULL or must be @@ -531,19 +531,19 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase { */ void _fetch(const UHashElement *element, const SharedObject *&value, UErrorCode &status) const; - + /** * Determine if given hash entry is in progress. * On entry, gCacheMutex must be held. */ UBool _inProgress(const UHashElement *element) const; - + /** * Determine if given hash entry is in progress. * On entry, gCacheMutex must be held. */ UBool _inProgress(const SharedObject *theValue, UErrorCode creationStatus) const; - + /** * Determine if given hash entry is eligible for eviction. * On entry, gCacheMutex must be held. diff --git a/deps/icu-small/source/common/uniset.cpp b/deps/icu-small/source/common/uniset.cpp index 1db382afe6f6ba..b73d612f246884 100644 --- a/deps/icu-small/source/common/uniset.cpp +++ b/deps/icu-small/source/common/uniset.cpp @@ -278,11 +278,11 @@ UnicodeSet& UnicodeSet::copyFrom(const UnicodeSet& o, UBool asThawed) { * to support cloning in order to allow classes using * UnicodeMatchers, such as Transliterator, to implement cloning. */ -UnicodeFunctor* UnicodeSet::clone() const { +UnicodeSet* UnicodeSet::clone() const { return new UnicodeSet(*this); } -UnicodeFunctor *UnicodeSet::cloneAsThawed() const { +UnicodeSet *UnicodeSet::cloneAsThawed() const { return new UnicodeSet(*this, TRUE); } @@ -1630,7 +1630,7 @@ UBool UnicodeSet::allocateStrings(UErrorCode &status) { delete strings; strings = NULL; return FALSE; - } + } return TRUE; } @@ -2172,7 +2172,7 @@ void UnicodeSet::setPattern(const char16_t *newPat, int32_t newPatLen) { // We can regenerate an equivalent pattern later when requested. } -UnicodeFunctor *UnicodeSet::freeze() { +UnicodeSet *UnicodeSet::freeze() { if(!isFrozen() && !isBogus()) { compact(); diff --git a/deps/icu-small/source/common/uniset_props.cpp b/deps/icu-small/source/common/uniset_props.cpp index 6f7918a91ab9ed..37277fcb751f44 100644 --- a/deps/icu-small/source/common/uniset_props.cpp +++ b/deps/icu-small/source/common/uniset_props.cpp @@ -365,7 +365,7 @@ void UnicodeSet::applyPattern(RuleCharacterIterator& chars, mode = 1; patLocal.append((UChar) 0x5B /*'['*/); chars.getPos(backup); // prepare to backup - c = chars.next(opts, literal, ec); + c = chars.next(opts, literal, ec); if (U_FAILURE(ec)) return; if (c == 0x5E /*'^'*/ && !literal) { invert = TRUE; @@ -802,7 +802,10 @@ static UBool mungeCharName(char* dst, const char* src, int32_t dstCapacity) { // Property set API //---------------------------------------------------------------- -#define FAIL(ec) {ec=U_ILLEGAL_ARGUMENT_ERROR; return *this;} +#define FAIL(ec) UPRV_BLOCK_MACRO_BEGIN { \ + ec=U_ILLEGAL_ARGUMENT_ERROR; \ + return *this; \ +} UPRV_BLOCK_MACRO_END UnicodeSet& UnicodeSet::applyIntPropertyValue(UProperty prop, int32_t value, UErrorCode& ec) { @@ -1113,7 +1116,7 @@ UnicodeSet& UnicodeSet::applyPropertyPattern(const UnicodeString& pattern, else { // Handle case where no '=' is seen, and \N{} pattern.extractBetween(pos, close, propName); - + // Handle \N{name} if (isName) { // This is a little inefficient since it means we have to @@ -1132,7 +1135,7 @@ UnicodeSet& UnicodeSet::applyPropertyPattern(const UnicodeString& pattern, if (invert) { complement(); } - + // Move to the limit position after the close delimiter if the // parse succeeded. ppos.setIndex(close + (posix ? 2 : 1)); diff --git a/deps/icu-small/source/common/unisetspan.cpp b/deps/icu-small/source/common/unisetspan.cpp index 0a8893472f958b..68e44d91ee7066 100644 --- a/deps/icu-small/source/common/unisetspan.cpp +++ b/deps/icu-small/source/common/unisetspan.cpp @@ -400,7 +400,7 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStri if(otherStringSpan.pSpanNotSet==&otherStringSpan.spanSet) { pSpanNotSet=&spanSet; } else { - pSpanNotSet=(UnicodeSet *)otherStringSpan.pSpanNotSet->clone(); + pSpanNotSet=otherStringSpan.pSpanNotSet->clone(); } // Allocate a block of meta data. @@ -436,7 +436,7 @@ void UnicodeSetStringSpan::addToSpanNotSet(UChar32 c) { if(spanSet.contains(c)) { return; // Nothing to do. } - UnicodeSet *newSet=(UnicodeSet *)spanSet.cloneAsThawed(); + UnicodeSet *newSet=spanSet.cloneAsThawed(); if(newSet==NULL) { return; // Out of memory. } else { diff --git a/deps/icu-small/source/common/unistr.cpp b/deps/icu-small/source/common/unistr.cpp index 31b0ed84bee07d..901bb3358ba56c 100644 --- a/deps/icu-small/source/common/unistr.cpp +++ b/deps/icu-small/source/common/unistr.cpp @@ -332,7 +332,7 @@ Replaceable::clone() const { } // UnicodeString overrides clone() with a real implementation -Replaceable * +UnicodeString * UnicodeString::clone() const { return new UnicodeString(*this); } @@ -672,7 +672,7 @@ UnicodeString::doCompare( int32_t start, if(isBogus()) { return -1; } - + // pin indices to legal values pinIndices(start, length); @@ -720,7 +720,7 @@ UnicodeString::doCompare( int32_t start, if(minLength > 0 && chars != srcChars) { int32_t result; -# if U_IS_BIG_ENDIAN +# if U_IS_BIG_ENDIAN // big-endian: byte comparison works result = uprv_memcmp(chars, srcChars, minLength * sizeof(UChar)); if(result != 0) { @@ -952,7 +952,7 @@ UnicodeString::extract(int32_t start, int32_t len, // else see unistr_cnv.cpp #endif -void +void UnicodeString::extractBetween(int32_t start, int32_t limit, UnicodeString& target) const { @@ -1021,7 +1021,7 @@ UnicodeString::toUTF32(UChar32 *utf32, int32_t capacity, UErrorCode &errorCode) return length32; } -int32_t +int32_t UnicodeString::indexOf(const UChar *srcChars, int32_t srcStart, int32_t srcLength, @@ -1085,7 +1085,7 @@ UnicodeString::doIndexOf(UChar32 c, } } -int32_t +int32_t UnicodeString::lastIndexOf(const UChar *srcChars, int32_t srcStart, int32_t srcLength, @@ -1157,7 +1157,7 @@ UnicodeString::doLastIndexOf(UChar32 c, // Write implementation //======================================== -UnicodeString& +UnicodeString& UnicodeString::findAndReplace(int32_t start, int32_t length, const UnicodeString& oldText, @@ -1611,7 +1611,7 @@ UnicodeString::handleReplaceBetween(int32_t start, /** * Replaceable API */ -void +void UnicodeString::copy(int32_t start, int32_t limit, int32_t dest) { if (limit <= start) { return; // Nothing to do; avoid bogus malloc call @@ -1620,7 +1620,7 @@ UnicodeString::copy(int32_t start, int32_t limit, int32_t dest) { // Check to make sure text is not null. if (text != NULL) { extractBetween(start, limit, text, 0); - insert(dest, text, 0, limit - start); + insert(dest, text, 0, limit - start); uprv_free(text); } } @@ -1688,7 +1688,7 @@ UnicodeString::doReverse(int32_t start, int32_t length) { return *this; } -UBool +UBool UnicodeString::padLeading(int32_t targetLength, UChar padChar) { @@ -1710,7 +1710,7 @@ UnicodeString::padLeading(int32_t targetLength, } } -UBool +UBool UnicodeString::padTrailing(int32_t targetLength, UChar padChar) { diff --git a/deps/icu-small/source/common/unistr_props.cpp b/deps/icu-small/source/common/unistr_props.cpp index 691bd085d6a923..40064757902ca8 100644 --- a/deps/icu-small/source/common/unistr_props.cpp +++ b/deps/icu-small/source/common/unistr_props.cpp @@ -25,7 +25,7 @@ U_NAMESPACE_BEGIN -UnicodeString& +UnicodeString& UnicodeString::trim() { if(isBogus()) { diff --git a/deps/icu-small/source/common/unistrappender.h b/deps/icu-small/source/common/unistrappender.h index 134f31497f1525..75fcb9e775f1eb 100644 --- a/deps/icu-small/source/common/unistrappender.h +++ b/deps/icu-small/source/common/unistrappender.h @@ -26,7 +26,7 @@ U_NAMESPACE_BEGIN * one character at a time in a loop. It stores appends in a buffer while * never actually calling append on the unicode string unless the buffer * fills up or is flushed. - * + * * proper usage: * { * UnicodeStringAppender appender(astring); @@ -38,7 +38,7 @@ U_NAMESPACE_BEGIN */ class UnicodeStringAppender : public UMemory { public: - + /** * dest is the UnicodeString being appended to. It must always * exist while this instance exists. diff --git a/deps/icu-small/source/common/unorm.cpp b/deps/icu-small/source/common/unorm.cpp index 93f77e66afb40e..2d9f46052ffc43 100644 --- a/deps/icu-small/source/common/unorm.cpp +++ b/deps/icu-small/source/common/unorm.cpp @@ -15,8 +15,8 @@ * 02/01/01 synwee Added normalization quickcheck enum and method. * 02/12/01 synwee Commented out quickcheck util api has been approved * Added private method for doing FCD checks -* 02/23/01 synwee Modified quickcheck and checkFCE to run through -* string for codepoints < 0x300 for the normalization +* 02/23/01 synwee Modified quickcheck and checkFCE to run through +* string for codepoints < 0x300 for the normalization * mode NFC. * 05/25/01+ Markus Scherer total rewrite, implement all normalization here * instead of just wrappers around normlzr.cpp, @@ -45,7 +45,7 @@ U_NAMESPACE_USE U_CAPI UNormalizationCheckResult U_EXPORT2 unorm_quickCheck(const UChar *src, - int32_t srcLength, + int32_t srcLength, UNormalizationMode mode, UErrorCode *pErrorCode) { const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode); @@ -53,7 +53,7 @@ unorm_quickCheck(const UChar *src, } U_CAPI UNormalizationCheckResult U_EXPORT2 -unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength, +unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength, UNormalizationMode mode, int32_t options, UErrorCode *pErrorCode) { const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode); diff --git a/deps/icu-small/source/common/unormimp.h b/deps/icu-small/source/common/unormimp.h index 7f280551f7ef8e..88c7975cc4e783 100644 --- a/deps/icu-small/source/common/unormimp.h +++ b/deps/icu-small/source/common/unormimp.h @@ -188,7 +188,7 @@ enum { * int32_t indexes[_NORM_INDEX_TOP]; -- _NORM_INDEX_TOP=32, see enum in this file * * UTrie normTrie; -- size in bytes=indexes[_NORM_INDEX_TRIE_SIZE] - * + * * uint16_t extraData[extraDataTop]; -- extraDataTop=indexes[_NORM_INDEX_UCHAR_COUNT] * extraData[0] contains the number of units for * FC_NFKC_Closure (formatVersion>=2.1) diff --git a/deps/icu-small/source/common/ures_cnv.cpp b/deps/icu-small/source/common/ures_cnv.cpp index 43515fda282972..1aa58e753ceeb4 100644 --- a/deps/icu-small/source/common/ures_cnv.cpp +++ b/deps/icu-small/source/common/ures_cnv.cpp @@ -27,8 +27,8 @@ #include "ustr_cnv.h" U_CAPI UResourceBundle * U_EXPORT2 -ures_openU(const UChar *myPath, - const char *localeID, +ures_openU(const UChar *myPath, + const char *localeID, UErrorCode *status) { char pathBuffer[1024]; diff --git a/deps/icu-small/source/common/uresbund.cpp b/deps/icu-small/source/common/uresbund.cpp index c9f2c860da7c33..6c0e760389d753 100644 --- a/deps/icu-small/source/common/uresbund.cpp +++ b/deps/icu-small/source/common/uresbund.cpp @@ -31,6 +31,7 @@ #include "ucln_cmn.h" #include "cmemory.h" #include "cstring.h" +#include "mutex.h" #include "uhash.h" #include "unicode/uenum.h" #include "uenumimp.h" @@ -38,6 +39,7 @@ #include "umutex.h" #include "putilimp.h" #include "uassert.h" +#include "uresdata.h" using namespace icu; @@ -47,12 +49,9 @@ TODO: This cache should probably be removed when the deprecated code is completely removed. */ static UHashtable *cache = NULL; -static icu::UInitOnce gCacheInitOnce; +static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; -static UMutex *resbMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex resbMutex; /* INTERNAL: hashes an entry */ static int32_t U_CALLCONV hashEntry(const UHashTok parm) { @@ -78,7 +77,7 @@ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { /** - * Internal function, gets parts of locale name according + * Internal function, gets parts of locale name according * to the position of '_' character */ static UBool chopLocale(char *name) { @@ -96,17 +95,16 @@ static UBool chopLocale(char *name) { * Internal function */ static void entryIncrease(UResourceDataEntry *entry) { - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); entry->fCountExisting++; while(entry->fParent != NULL) { entry = entry->fParent; entry->fCountExisting++; } - umtx_unlock(resbMutex()); } /** - * Internal function. Tries to find a resource in given Resource + * Internal function. Tries to find a resource in given Resource * Bundle, as well as in its parents */ static const ResourceData *getFallbackData(const UResourceBundle* resBundle, const char* * resTag, UResourceDataEntry* *realData, Resource *res, UErrorCode *status) { @@ -184,9 +182,8 @@ static int32_t ures_flushCache() /*if shared data hasn't even been lazy evaluated yet * return 0 */ - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); if (cache == NULL) { - umtx_unlock(resbMutex()); return 0; } @@ -218,7 +215,6 @@ static int32_t ures_flushCache() * got decremented by free_entry(). */ } while(deletedMore); - umtx_unlock(resbMutex()); return rbDeletedNum; } @@ -231,10 +227,9 @@ U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) { int32_t pos = UHASH_FIRST; const UHashElement *e; UResourceDataEntry *resB; - - umtx_lock(resbMutex()); + + Mutex lock(&resbMutex); if (cache == NULL) { - umtx_unlock(resbMutex()); fprintf(stderr,"%s:%d: RB Cache is NULL.\n", __FILE__, __LINE__); return FALSE; } @@ -249,13 +244,10 @@ U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) { resB->fPath?resB->fPath:"NULL", (void*)resB->fPool, (void*)resB->fAlias, - (void*)resB->fParent); + (void*)resB->fParent); } - + fprintf(stderr,"%s:%d: RB Cache still contains %d items.\n", __FILE__, __LINE__, uhash_count(cache)); - - umtx_unlock(resbMutex()); - return cacheNotEmpty; } @@ -278,7 +270,7 @@ static void U_CALLCONV createCache(UErrorCode &status) { cache = uhash_open(hashEntry, compareEntries, NULL, &status); ucln_common_registerCleanup(UCLN_COMMON_URES, ures_cleanup); } - + static void initCache(UErrorCode *status) { umtx_initOnce(gCacheInitOnce, &createCache, *status); } @@ -401,7 +393,8 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE /* We'll try to get alias string from the bundle */ aliasres = res_getResource(&(r->fData), "%%ALIAS"); if (aliasres != RES_BOGUS) { - const UChar *alias = res_getString(&(r->fData), aliasres, &aliasLen); + // No tracing: called during initial data loading + const UChar *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen); if(alias != NULL && aliasLen > 0) { /* if there is actual alias - unload and load new data */ u_UCharsToChars(alias, aliasName, aliasLen+1); r->fAlias = init_entry(aliasName, path, status); @@ -542,7 +535,8 @@ loadParentsExceptRoot(UResourceDataEntry *&t1, Resource parentRes = res_getResource(&t1->fData, "%%Parent"); if (parentRes != RES_BOGUS) { // An explicit parent was found. int32_t parentLocaleLen = 0; - const UChar *parentLocaleName = res_getString(&(t1->fData), parentRes, &parentLocaleLen); + // No tracing: called during initial data loading + const UChar *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen); if(parentLocaleName != NULL && 0 < parentLocaleLen && parentLocaleLen < nameCapacity) { u_UCharsToChars(parentLocaleName, name, parentLocaleLen + 1); if (uprv_strcmp(name, kRootLocaleName) == 0) { @@ -665,111 +659,109 @@ static UResourceDataEntry *entryOpen(const char* path, const char* localeID, usrDataPath[sizeof(usrDataPath) - 1] = 0; } } + + Mutex lock(&resbMutex); // Lock resbMutex until the end of this function. - umtx_lock(resbMutex()); - { /* umtx_lock */ - /* We're going to skip all the locales that do not have any data */ - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + /* We're going to skip all the locales that do not have any data */ + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + + if(r != NULL) { /* if there is one real locale, we can look for parents. */ + t1 = r; + hasRealData = TRUE; + if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ + UErrorCode usrStatus = U_ZERO_ERROR; + UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if ( u1 != NULL ) { + if(u1->fBogus == U_ZERO_ERROR) { + u1->fParent = t1; + r = u1; + } else { + /* the USR override data wasn't found, set it to be deleted */ + u1->fCountExisting = 0; + } + } + } + if (hasChopped && !isRoot) { + if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { + goto finish; + } + } + } + /* we could have reached this point without having any real data */ + /* if that is the case, we need to chain in the default locale */ + if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { + /* insert default locale */ + uprv_strcpy(name, uloc_getDefault()); + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); // If we failed due to out-of-memory, report the failure and exit early. if (intStatus == U_MEMORY_ALLOCATION_ERROR) { *status = intStatus; - goto finishUnlock; + goto finish; } - - if(r != NULL) { /* if there is one real locale, we can look for parents. */ + intStatus = U_USING_DEFAULT_WARNING; + if(r != NULL) { /* the default locale exists */ t1 = r; hasRealData = TRUE; - if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ - UErrorCode usrStatus = U_ZERO_ERROR; - UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } - if ( u1 != NULL ) { - if(u1->fBogus == U_ZERO_ERROR) { - u1->fParent = t1; - r = u1; - } else { - /* the USR override data wasn't found, set it to be deleted */ - u1->fCountExisting = 0; - } - } - } + isDefault = TRUE; + // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? if (hasChopped && !isRoot) { if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finishUnlock; + goto finish; } } } + } - /* we could have reached this point without having any real data */ - /* if that is the case, we need to chain in the default locale */ - if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { - /* insert default locale */ - uprv_strcpy(name, uloc_getDefault()); - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } + /* we could still have r == NULL at this point - maybe even default locale is not */ + /* present */ + if(r == NULL) { + uprv_strcpy(name, kRootLocaleName); + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if(r != NULL) { + t1 = r; intStatus = U_USING_DEFAULT_WARNING; - if(r != NULL) { /* the default locale exists */ - t1 = r; - hasRealData = TRUE; - isDefault = TRUE; - // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? - if (hasChopped && !isRoot) { - if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finishUnlock; - } - } - } + hasRealData = TRUE; + } else { /* we don't even have the root locale */ + *status = U_MISSING_RESOURCE_ERROR; + goto finish; } - - /* we could still have r == NULL at this point - maybe even default locale is not */ - /* present */ - if(r == NULL) { - uprv_strcpy(name, kRootLocaleName); - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } - if(r != NULL) { - t1 = r; - intStatus = U_USING_DEFAULT_WARNING; - hasRealData = TRUE; - } else { /* we don't even have the root locale */ - *status = U_MISSING_RESOURCE_ERROR; - goto finishUnlock; - } - } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && - t1->fParent == NULL && !r->fData.noFallback) { - if (!insertRootBundle(t1, status)) { - goto finishUnlock; - } - if(!hasRealData) { - r->fBogus = U_USING_DEFAULT_WARNING; - } + } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && + t1->fParent == NULL && !r->fData.noFallback) { + if (!insertRootBundle(t1, status)) { + goto finish; } - - // TODO: Does this ever loop? - while(r != NULL && !isRoot && t1->fParent != NULL) { - t1->fParent->fCountExisting++; - t1 = t1->fParent; + if(!hasRealData) { + r->fBogus = U_USING_DEFAULT_WARNING; } - } /* umtx_lock */ -finishUnlock: - umtx_unlock(resbMutex()); + } + + // TODO: Does this ever loop? + while(r != NULL && !isRoot && t1->fParent != NULL) { + t1->fParent->fCountExisting++; + t1 = t1->fParent; + } +finish: if(U_SUCCESS(*status)) { if(intStatus != U_ZERO_ERROR) { - *status = intStatus; + *status = intStatus; } return r; } else { @@ -790,7 +782,7 @@ entryOpenDirect(const char* path, const char* localeID, UErrorCode* status) { return NULL; } - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); // findFirstExisting() without fallbacks. UResourceDataEntry *r = init_entry(localeID, path, status); if(U_SUCCESS(*status)) { @@ -828,7 +820,6 @@ entryOpenDirect(const char* path, const char* localeID, UErrorCode* status) { t1 = t1->fParent; } } - umtx_unlock(resbMutex()); return r; } @@ -866,14 +857,13 @@ static void entryCloseInt(UResourceDataEntry *resB) { } } -/** +/** * API: closes a resource bundle and cleans up. */ static void entryClose(UResourceDataEntry *resB) { - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); entryCloseInt(resB); - umtx_unlock(resbMutex()); } /* @@ -881,7 +871,7 @@ U_CFUNC void ures_setResPath(UResourceBundle *resB, const char* toAdd) { if(resB->fResPath == NULL) { resB->fResPath = resB->fResBuf; *(resB->fResPath) = 0; - } + } resB->fResPathLen = uprv_strlen(toAdd); if(RES_BUFSIZE <= resB->fResPathLen+1) { if(resB->fResPath == resB->fResBuf) { @@ -899,7 +889,7 @@ static void ures_appendResPath(UResourceBundle *resB, const char* toAdd, int32_t resB->fResPath = resB->fResBuf; *(resB->fResPath) = 0; resB->fResPathLen = 0; - } + } resB->fResPathLen += lenToAdd; if(RES_BUFSIZE <= resB->fResPathLen+1) { if(resB->fResPath == resB->fResBuf) { @@ -961,10 +951,10 @@ ures_close(UResourceBundle* resB) ures_closeBundle(resB, TRUE); } -static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, - const char *key, int32_t idx, UResourceDataEntry *realData, +static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, + const char *key, int32_t idx, UResourceDataEntry *realData, const UResourceBundle *parent, int32_t noAlias, - UResourceBundle *resB, UErrorCode *status) + UResourceBundle *resB, UErrorCode *status) { if(status == NULL || U_FAILURE(*status)) { return resB; @@ -974,9 +964,9 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, return NULL; } if(RES_GET_TYPE(r) == URES_ALIAS) { /* This is an alias, need to exchange with real data */ - if(noAlias < URES_MAX_ALIAS_LEVEL) { + if(noAlias < URES_MAX_ALIAS_LEVEL) { int32_t len = 0; - const UChar *alias = res_getAlias(rdata, r, &len); + const UChar *alias = res_getAlias(rdata, r, &len); if(len > 0) { /* we have an alias, now let's cut it up */ char stackAlias[200]; @@ -1032,7 +1022,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, /* this is an XPath alias, starting with "/LOCALE/" */ /* it contains the path to a resource which should be looked up */ /* starting in the requested locale */ - keyPath = locale; + keyPath = locale; locale = parent->fTopLevelData->fName; /* this is the requested locale's name */ path = realData->fPath; /* we will be looking in the same package */ } else { @@ -1063,14 +1053,14 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, UResourceBundle *result = resB; const char* temp = NULL; UErrorCode intStatus = U_ZERO_ERROR; - UResourceBundle *mainRes = ures_openDirect(path, locale, &intStatus); + UResourceBundle *mainRes = ures_openDirect(path, locale, &intStatus); if(U_SUCCESS(intStatus)) { if(keyPath == NULL) { - /* no key path. This means that we are going to + /* no key path. This means that we are going to * to use the corresponding resource from * another bundle */ - /* first, we are going to get a corresponding parent + /* first, we are going to get a corresponding parent * resource to the one we are searching. */ char *aKey = parent->fResPath; @@ -1119,9 +1109,9 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, result = resB; } } else { - /* this one is a bit trickier. + /* this one is a bit trickier. * we start finding keys, but after we resolve one alias, the path might continue. - * Consider: + * Consider: * aliastest:alias { "testtypes/anotheralias/Sequence" } * anotheralias:alias { "/ICUDATA/sh/CollationElements" } * aliastest resource should finally have the sequence, not collation elements. @@ -1141,7 +1131,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, result = mainRes; /* now we have fallback following here */ do { - r = dataEntry->fData.rootRes; + r = dataEntry->fData.rootRes; /* this loop handles 'found' resources over several levels */ while(*myPath && U_SUCCESS(*status)) { r = res_findResource(&(dataEntry->fData), r, &myPath, &temp); @@ -1177,10 +1167,11 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, if(mainRes != result) { ures_close(mainRes); } + ResourceTracer(resB).maybeTrace("getalias"); return result; } } else { - /* bad alias, should be an error */ + /* bad alias, should be an error */ *status = U_ILLEGAL_ARGUMENT_ERROR; return resB; } @@ -1206,9 +1197,9 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, if(resB->fVersion != NULL) { uprv_free(resB->fVersion); } - /* + /* weiv: if stack object was passed in, it doesn't really need to be reinited, - since the purpose of initing is to remove stack junk. However, at this point + since the purpose of initing is to remove stack junk. However, at this point we would not do anything to an allocated object, so stack object should be treated the same */ @@ -1226,7 +1217,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, resB->fHasFallback = FALSE; resB->fIsTopLevel = FALSE; resB->fIndex = -1; - resB->fKey = key; + resB->fKey = key; /*resB->fParentRes = parent;*/ resB->fTopLevelData = parent->fTopLevelData; if(parent->fResPath && parent != resB) { @@ -1256,6 +1247,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, /*resB->fParent = parent->fRes;*/ uprv_memmove(&resB->fResData, rdata, sizeof(ResourceData)); resB->fSize = res_countArrayItems(&(resB->fResData), resB->fRes); + ResourceTracer(resB).trace("get"); return resB; } @@ -1304,7 +1296,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getString(const UResourceBundle* resB, int32_ *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - s = res_getString(&(resB->fResData), resB->fRes, len); + s = res_getString({resB}, &(resB->fResData), resB->fRes, len); if (s == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1383,7 +1375,7 @@ ures_getUTF8String(const UResourceBundle *resB, return ures_toUTF8String(s16, length16, dest, pLength, forceCopy, status); } -U_CAPI const uint8_t* U_EXPORT2 ures_getBinary(const UResourceBundle* resB, int32_t* len, +U_CAPI const uint8_t* U_EXPORT2 ures_getBinary(const UResourceBundle* resB, int32_t* len, UErrorCode* status) { const uint8_t *p; if (status==NULL || U_FAILURE(*status)) { @@ -1393,14 +1385,14 @@ U_CAPI const uint8_t* U_EXPORT2 ures_getBinary(const UResourceBundle* resB, int3 *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getBinary(&(resB->fResData), resB->fRes, len); + p = res_getBinary({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } return p; } -U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, int32_t* len, +U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, int32_t* len, UErrorCode* status) { const int32_t *p; if (status==NULL || U_FAILURE(*status)) { @@ -1410,14 +1402,14 @@ U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, i *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getIntVector(&(resB->fResData), resB->fRes, len); + p = res_getIntVector({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } return p; } -/* this function returns a signed integer */ +/* this function returns a signed integer */ /* it performs sign extension */ U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *status) { if (status==NULL || U_FAILURE(*status)) { @@ -1431,7 +1423,7 @@ U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *st *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return RES_GET_INT(resB->fRes); + return res_getInt({resB}, resB->fRes); } U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode *status) { @@ -1446,7 +1438,7 @@ U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode * *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return RES_GET_UINT(resB->fRes); + return res_getUInt({resB}, resB->fRes); } U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { @@ -1457,10 +1449,18 @@ U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { } U_CAPI const char * U_EXPORT2 ures_getKey(const UResourceBundle *resB) { + // + // TODO: Trace ures_getKey? I guess not usually. + // + // We usually get the key string to decide whether we want the value, or to + // make a key-value pair. Tracing the value should suffice. + // + // However, I believe we have some data (e.g., in res_index) where the key + // strings are the data. Tracing the enclosing table should suffice. + // if(resB == NULL) { return NULL; } - return(resB->fKey); } @@ -1468,7 +1468,7 @@ U_CAPI int32_t U_EXPORT2 ures_getSize(const UResourceBundle *resB) { if(resB == NULL) { return 0; } - + return resB->fSize; } @@ -1480,7 +1480,7 @@ static const UChar* ures_getStringWithAlias(const UResourceBundle *resB, Resourc ures_close(tempRes); return result; } else { - return res_getString(&(resB->fResData), r, len); + return res_getString({resB, sIndex}, &(resB->fResData), r, len); } } @@ -1500,7 +1500,7 @@ U_CAPI UBool U_EXPORT2 ures_hasNext(const UResourceBundle *resB) { U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* len, const char ** key, UErrorCode *status) { Resource r = RES_BOGUS; - + if (status==NULL || U_FAILURE(*status)) { return NULL; } @@ -1508,7 +1508,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - + if(resB->fIndex == resB->fSize-1) { *status = U_INDEX_OUTOFBOUNDS_ERROR; } else { @@ -1516,7 +1516,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1661,7 +1661,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByIndex(const UResourceBundle *resB, switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1711,9 +1711,9 @@ ures_getUTF8StringByIndex(const UResourceBundle *resB, }*/ U_CAPI UResourceBundle* U_EXPORT2 -ures_findResource(const char* path, UResourceBundle *fillIn, UErrorCode *status) +ures_findResource(const char* path, UResourceBundle *fillIn, UErrorCode *status) { - UResourceBundle *first = NULL; + UResourceBundle *first = NULL; UResourceBundle *result = fillIn; char *packageName = NULL; char *pathToResource = NULL, *save = NULL; @@ -1766,7 +1766,7 @@ ures_findResource(const char* path, UResourceBundle *fillIn, UErrorCode *status) } U_CAPI UResourceBundle* U_EXPORT2 -ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *fillIn, UErrorCode *status) +ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *fillIn, UErrorCode *status) { Resource res = RES_BOGUS; UResourceBundle *result = fillIn; @@ -1780,7 +1780,7 @@ ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *f /* this loop is here because aliasing is resolved on this level, not on res level */ /* so, when we encounter an alias, it is not an aggregate resource, so we return */ do { - res = res_findResource(&(resB->fResData), resB->fRes, &path, &key); + res = res_findResource(&(resB->fResData), resB->fRes, &path, &key); if(res != RES_BOGUS) { result = init_resb_result(&(resB->fResData), res, key, -1, resB->fData, resB, 0, fillIn, status); resB = result; @@ -1792,9 +1792,9 @@ ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *f return result; } -U_INTERNAL const UChar* U_EXPORT2 -ures_getStringByKeyWithFallback(const UResourceBundle *resB, - const char* inKey, +U_INTERNAL const UChar* U_EXPORT2 +ures_getStringByKeyWithFallback(const UResourceBundle *resB, + const char* inKey, int32_t* len, UErrorCode *status) { @@ -1821,7 +1821,7 @@ ures_getStringByKeyWithFallback(const UResourceBundle *resB, /* Like res_getTableItemByKey but accepts full paths like "NumberElements/latn/patternsShort". -*/ +*/ static Resource getTableItemByKeyPath(const ResourceData *pResData, Resource table, const char *key) { Resource resource = table; /* The current resource */ icu::CharString path; @@ -1842,7 +1842,7 @@ static Resource getTableItemByKeyPath(const ResourceData *pResData, Resource tab const char *pathP = pathPart; resource = res_getTableItemByKey(pResData, resource, &t, &pathP); type = (UResType)RES_GET_TYPE(resource); - pathPart = nextPathPart; + pathPart = nextPathPart; } if (*pathPart) { return RES_BOGUS; @@ -1850,10 +1850,10 @@ static Resource getTableItemByKeyPath(const ResourceData *pResData, Resource tab return resource; } -U_CAPI UResourceBundle* U_EXPORT2 -ures_getByKeyWithFallback(const UResourceBundle *resB, - const char* inKey, - UResourceBundle *fillIn, +U_CAPI UResourceBundle* U_EXPORT2 +ures_getByKeyWithFallback(const UResourceBundle *resB, + const char* inKey, + UResourceBundle *fillIn, UErrorCode *status) { Resource res = RES_BOGUS, rootRes = RES_BOGUS; /*UResourceDataEntry *realData = NULL;*/ @@ -1897,7 +1897,7 @@ ures_getByKeyWithFallback(const UResourceBundle *resB, res = res_findResource(&(dataEntry->fData), rootRes, &myPath, &key); if (RES_GET_TYPE(res) == URES_ALIAS && *myPath) { /* We hit an alias, but we didn't finish following the path. */ - helper = init_resb_result(&(dataEntry->fData), res, NULL, -1, dataEntry, resB, 0, helper, status); + helper = init_resb_result(&(dataEntry->fData), res, NULL, -1, dataEntry, resB, 0, helper, status); /*helper = init_resb_result(&(dataEntry->fData), res, inKey, -1, dataEntry, resB, 0, helper, status);*/ if(helper) { dataEntry = helper->fData; @@ -1928,7 +1928,7 @@ ures_getByKeyWithFallback(const UResourceBundle *resB, } else { fillIn = init_resb_result(&(resB->fResData), res, key, -1, resB->fData, resB, 0, fillIn, status); } - } + } else { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1953,10 +1953,10 @@ void getAllItemsWithFallback( // When the sink sees the no-fallback/no-inheritance marker, // then it would remove the parent's item. // We would deserialize parent values even though they are overridden in a child bundle. - value.pResData = &bundle->fResData; + value.setData(&bundle->fResData); UResourceDataEntry *parentEntry = bundle->fData->fParent; UBool hasParent = parentEntry != NULL && U_SUCCESS(parentEntry->fBogus); - value.setResource(bundle->fRes); + value.setResource(bundle->fRes, ResourceTracer(bundle)); sink.put(bundle->fKey, value, !hasParent, errorCode); if (hasParent) { // We might try to query the sink whether @@ -2001,31 +2001,60 @@ void getAllItemsWithFallback( } // namespace +// Requires a ResourceDataValue fill-in, so that we need not cast from a ResourceValue. +// Unfortunately, the caller must know which subclass to make and pass in. +// Alternatively, we could make it as polymorphic as in Java by +// returning a ResourceValue pointer (possibly wrapped into a LocalPointer) +// that the caller then owns. +// +// Also requires a UResourceBundle fill-in, so that the value's ResourceTracer +// can point to a non-local bundle. +// Without tracing, the child bundle could be a function-local object. +U_CAPI void U_EXPORT2 +ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, + UResourceBundle *tempFillIn, + ResourceDataValue &value, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + if (path == nullptr) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + const UResourceBundle *rb; + if (*path == 0) { + // empty path + rb = bundle; + } else { + rb = ures_getByKeyWithFallback(bundle, path, tempFillIn, &errorCode); + if (U_FAILURE(errorCode)) { + return; + } + } + value.setData(&rb->fResData); + value.setResource(rb->fRes, ResourceTracer(rb)); +} + U_CAPI void U_EXPORT2 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path, icu::ResourceSink &sink, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return; } - if (path == NULL) { + if (path == nullptr) { errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; } - UResourceBundle stackBundle; - ures_initStackObject(&stackBundle); + StackUResourceBundle stackBundle; const UResourceBundle *rb; if (*path == 0) { // empty path rb = bundle; } else { - rb = ures_getByKeyWithFallback(bundle, path, &stackBundle, &errorCode); + rb = ures_getByKeyWithFallback(bundle, path, stackBundle.getAlias(), &errorCode); if (U_FAILURE(errorCode)) { - ures_close(&stackBundle); return; } } // Get all table items with fallback. ResourceDataValue value; getAllItemsWithFallback(rb, value, sink, errorCode); - ures_close(&stackBundle); } U_CAPI UResourceBundle* U_EXPORT2 ures_getByKey(const UResourceBundle *resB, const char* inKey, UResourceBundle *fillIn, UErrorCode *status) { @@ -2061,7 +2090,7 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_getByKey(const UResourceBundle *resB, con } else { return init_resb_result(&(resB->fResData), res, key, -1, resB->fData, resB, 0, fillIn, status); } - } + } #if 0 /* this is a kind of TODO item. If we have an array with an index table, we could do this. */ /* not currently */ @@ -2074,7 +2103,7 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_getByKey(const UResourceBundle *resB, con *status = U_MISSING_RESOURCE_ERROR; } } -#endif +#endif else { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -2108,7 +2137,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString(rd, res, len); + return res_getString({resB, key}, rd, res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2130,7 +2159,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), res, len); + return res_getString({resB, key}, &(resB->fResData), res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2143,20 +2172,21 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c *status = U_RESOURCE_TYPE_MISMATCH; } } - } -#if 0 + } +#if 0 /* this is a kind of TODO item. If we have an array with an index table, we could do this. */ - /* not currently */ + /* not currently */ else if(RES_GET_TYPE(resB->fRes) == URES_ARRAY && resB->fHasFallback == TRUE) { /* here should go a first attempt to locate the key using index table */ const ResourceData *rd = getFallbackData(resB, &key, &realData, &res, status); if(U_SUCCESS(*status)) { + // TODO: Tracing return res_getString(rd, res, len); } else { *status = U_MISSING_RESOURCE_ERROR; } - } -#endif + } +#endif else { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -2177,7 +2207,7 @@ ures_getUTF8StringByKey(const UResourceBundle *resB, /* TODO: clean from here down */ /** - * INTERNAL: Get the name of the first real locale (not placeholder) + * INTERNAL: Get the name of the first real locale (not placeholder) * that has resource bundle data. */ U_INTERNAL const char* U_EXPORT2 @@ -2194,17 +2224,17 @@ ures_getLocaleInternal(const UResourceBundle* resourceBundle, UErrorCode* status } } -U_CAPI const char* U_EXPORT2 -ures_getLocale(const UResourceBundle* resourceBundle, +U_CAPI const char* U_EXPORT2 +ures_getLocale(const UResourceBundle* resourceBundle, UErrorCode* status) { return ures_getLocaleInternal(resourceBundle, status); } -U_CAPI const char* U_EXPORT2 -ures_getLocaleByType(const UResourceBundle* resourceBundle, - ULocDataLocaleType type, +U_CAPI const char* U_EXPORT2 +ures_getLocaleByType(const UResourceBundle* resourceBundle, + ULocDataLocaleType type, UErrorCode* status) { if (status==NULL || U_FAILURE(*status)) { return NULL; @@ -2296,6 +2326,8 @@ ures_openWithType(UResourceBundle *r, const char* path, const char* localeID, r->fSize = res_countArrayItems(&(r->fResData), r->fRes); r->fIndex = -1; + ResourceTracer(r).traceOpen(); + return r; } @@ -2310,7 +2342,7 @@ ures_openNoDefault(const char* path, const char* localeID, UErrorCode* status) { } /** - * Opens a resource bundle without "canonicalizing" the locale name. No fallback will be performed + * Opens a resource bundle without "canonicalizing" the locale name. No fallback will be performed * or sought. However, alias substitution will happen! */ U_CAPI UResourceBundle* U_EXPORT2 @@ -2319,10 +2351,10 @@ ures_openDirect(const char* path, const char* localeID, UErrorCode* status) { } /** - * Internal API: This function is used to open a resource bundle - * proper fallback chaining is executed while initialization. + * Internal API: This function is used to open a resource bundle + * proper fallback chaining is executed while initialization. * The result is stored in cache for later fallback search. - * + * * Same as ures_open(), but uses the fill-in parameter and does not allocate a new bundle. */ U_INTERNAL void U_EXPORT2 @@ -2366,7 +2398,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle, return 0; } ures_getByKey(resourceBundle, resourceKey, &resData, status); - + if(resData.fResData.data != NULL) { int32_t result = res_countArrayItems(&resData.fResData, resData.fRes); ures_close(&resData); @@ -2388,7 +2420,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle, * @see ures_getVersion * @internal */ -U_INTERNAL const char* U_EXPORT2 +U_INTERNAL const char* U_EXPORT2 ures_getVersionNumberInternal(const UResourceBundle *resourceBundle) { if (!resourceBundle) return NULL; @@ -2402,24 +2434,24 @@ ures_getVersionNumberInternal(const UResourceBundle *resourceBundle) int32_t len; const UChar* minor_version = ures_getStringByKey(resourceBundle, kVersionTag, &minor_len, &status); - + /* Determine the length of of the final version string. This is */ /* the length of the major part + the length of the separator */ /* (==1) + the length of the minor part (+ 1 for the zero byte at */ /* the end). */ len = (minor_len > 0) ? minor_len : 1; - + /* Allocate the string, and build it up. */ /* + 1 for zero byte */ - ((UResourceBundle *)resourceBundle)->fVersion = (char *)uprv_malloc(1 + len); + ((UResourceBundle *)resourceBundle)->fVersion = (char *)uprv_malloc(1 + len); /* Check for null pointer. */ if (((UResourceBundle *)resourceBundle)->fVersion == NULL) { return NULL; } - + if(minor_len > 0) { u_UCharsToChars(minor_version, resourceBundle->fVersion , minor_len); resourceBundle->fVersion[len] = '\0'; @@ -2495,8 +2527,8 @@ ures_loc_nextLocale(UEnumeration* en, return result; } -static void U_CALLCONV -ures_loc_resetLocales(UEnumeration* en, +static void U_CALLCONV +ures_loc_resetLocales(UEnumeration* en, UErrorCode* /*status*/) { UResourceBundle *res = &((ULocalesContext *)en->context)->installed; ures_resetIterator(res); @@ -2541,7 +2573,7 @@ ures_openAvailableLocales(const char *path, UErrorCode *status) ures_getByKey(idx, INDEX_TAG, &myContext->installed, status); if(U_SUCCESS(*status)) { #if defined(URES_TREE_DEBUG) - fprintf(stderr, "Got %s::%s::[%s] : %s\n", + fprintf(stderr, "Got %s::%s::[%s] : %s\n", path, INDEX_LOCALE_NAME, INDEX_TAG, ures_getKey(&myContext->installed)); #endif en->context = myContext; @@ -2554,9 +2586,9 @@ ures_openAvailableLocales(const char *path, UErrorCode *status) uprv_free(en); en = NULL; } - + ures_close(idx); - + return en; } @@ -2593,17 +2625,17 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, } uloc_getBaseName(locid, base, 1024-1,&subStatus); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "getFunctionalEquivalent: \"%s\" [%s=%s] in %s - %s\n", + fprintf(stderr, "getFunctionalEquivalent: \"%s\" [%s=%s] in %s - %s\n", locid, keyword, kwVal, base, u_errorName(subStatus)); #endif ures_initStackObject(&bund1); ures_initStackObject(&bund2); - - + + uprv_strcpy(parent, base); uprv_strcpy(found, base); - if(isAvailable) { + if(isAvailable) { UEnumeration *locEnum = ures_openAvailableLocales(path, &subStatus); *isAvailable = TRUE; if (U_SUCCESS(subStatus)) { @@ -2616,7 +2648,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, *status = subStatus; return 0; } - + do { subStatus = U_ZERO_ERROR; res = ures_open(path, parent, &subStatus); @@ -2626,7 +2658,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, *isAvailable = FALSE; } isAvailable = NULL; /* only want to set this the first time around */ - + #if defined(URES_TREE_DEBUG) fprintf(stderr, "%s;%s -> %s [%s]\n", path?path:"ICUDATA", parent, u_errorName(subStatus), ures_getLocale(res, &subStatus)); #endif @@ -2646,21 +2678,21 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, if(U_SUCCESS(subStatus) && defLen) { u_UCharsToChars(defUstr, defVal, u_strlen(defUstr)); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> default %s=%s, %s\n", + fprintf(stderr, "%s;%s -> default %s=%s, %s\n", path?path:"ICUDATA", parent, keyword, defVal, u_errorName(subStatus)); #endif uprv_strcpy(defLoc, parent); if(kwVal[0]==0) { uprv_strcpy(kwVal, defVal); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> kwVal = %s\n", + fprintf(stderr, "%s;%s -> kwVal = %s\n", path?path:"ICUDATA", parent, keyword, kwVal); #endif } } } } - + subStatus = U_ZERO_ERROR; if (res != NULL) { @@ -2670,11 +2702,11 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, uloc_getParent(found,parent,sizeof(parent),&subStatus); ures_close(res); } while(!defVal[0] && *found && uprv_strcmp(found, "root") != 0 && U_SUCCESS(*status)); - + /* Now, see if we can find the kwVal collator.. start the search over.. */ uprv_strcpy(parent, base); uprv_strcpy(found, base); - + do { subStatus = U_ZERO_ERROR; res = ures_open(path, parent, &subStatus); @@ -2682,9 +2714,9 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, *isAvailable = FALSE; } isAvailable = NULL; /* only want to set this the first time around */ - + #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> %s (looking for %s)\n", + fprintf(stderr, "%s;%s -> %s (looking for %s)\n", path?path:"ICUDATA", parent, u_errorName(subStatus), kwVal); #endif if(U_FAILURE(subStatus)) { @@ -2701,7 +2733,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, #endif if(subStatus == U_ZERO_ERROR) { #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> full0 %s=%s, %s\n", + fprintf(stderr, "%s;%s -> full0 %s=%s, %s\n", path?path:"ICUDATA", parent, keyword, kwVal, u_errorName(subStatus)); #endif uprv_strcpy(full, parent); @@ -2714,14 +2746,14 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, int32_t defLen; /* look for default item */ #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> recalculating Default0\n", + fprintf(stderr, "%s;%s -> recalculating Default0\n", path?path:"ICUDATA", full); #endif defUstr = ures_getStringByKey(&bund1, DEFAULT_TAG, &defLen, &subStatus); if(U_SUCCESS(subStatus) && defLen) { u_UCharsToChars(defUstr, defVal, u_strlen(defUstr)); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> default0 %s=%s, %s\n", + fprintf(stderr, "%s;%s -> default0 %s=%s, %s\n", path?path:"ICUDATA", full, keyword, defVal, u_errorName(subStatus)); #endif uprv_strcpy(defLoc, full); @@ -2734,20 +2766,20 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, #endif } else { #if defined(URES_TREE_DEBUG) - fprintf(stderr, "err=%s in %s looking for %s\n", + fprintf(stderr, "err=%s in %s looking for %s\n", u_errorName(subStatus), parent, kwVal); #endif } } } - + subStatus = U_ZERO_ERROR; - + uprv_strcpy(found, parent); uloc_getParent(found,parent,1023,&subStatus); ures_close(res); } while(!full[0] && *found && U_SUCCESS(*status)); - + if((full[0]==0) && uprv_strcmp(kwVal, defVal)) { #if defined(URES_TREE_DEBUG) fprintf(stderr, "Failed to locate kw %s - try default %s\n", kwVal, defVal); @@ -2755,7 +2787,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, uprv_strcpy(kwVal, defVal); uprv_strcpy(parent, base); uprv_strcpy(found, base); - + do { /* search for 'default' named item */ subStatus = U_ZERO_ERROR; res = ures_open(path, parent, &subStatus); @@ -2763,7 +2795,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, *isAvailable = FALSE; } isAvailable = NULL; /* only want to set this the first time around */ - + #if defined(URES_TREE_DEBUG) fprintf(stderr, "%s;%s -> %s (looking for default %s)\n", path?path:"ICUDATA", parent, u_errorName(subStatus), kwVal); @@ -2783,21 +2815,21 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, if(*full == 0) { uprv_strcpy(full, "root"); } - + /* now, recalculate default kw if need be */ if(uprv_strlen(defLoc) > uprv_strlen(full)) { const UChar *defUstr; int32_t defLen; /* look for default item */ #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> recalculating Default1\n", + fprintf(stderr, "%s;%s -> recalculating Default1\n", path?path:"ICUDATA", full); #endif defUstr = ures_getStringByKey(&bund1, DEFAULT_TAG, &defLen, &subStatus); if(U_SUCCESS(subStatus) && defLen) { u_UCharsToChars(defUstr, defVal, u_strlen(defUstr)); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s;%s -> default %s=%s, %s\n", + fprintf(stderr, "%s;%s -> default %s=%s, %s\n", path?path:"ICUDATA", full, keyword, defVal, u_errorName(subStatus)); #endif uprv_strcpy(defLoc, full); @@ -2812,13 +2844,13 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, } } subStatus = U_ZERO_ERROR; - + uprv_strcpy(found, parent); uloc_getParent(found,parent,1023,&subStatus); ures_close(res); } while(!full[0] && *found && U_SUCCESS(*status)); } - + if(U_SUCCESS(*status)) { if(!full[0]) { #if defined(URES_TREE_DEBUG) @@ -2828,7 +2860,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, } else if(omitDefault) { #if defined(URES_TREE_DEBUG) fprintf(stderr,"Trim? full=%s, defLoc=%s, found=%s\n", full, defLoc, found); -#endif +#endif if(uprv_strlen(defLoc) <= uprv_strlen(full)) { /* found the keyword in a *child* of where the default tag was present. */ if(!uprv_strcmp(kwVal, defVal)) { /* if the requested kw is default, */ @@ -2854,10 +2886,10 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, } } /* we found the default locale - no need to repeat it.*/ - + ures_close(&bund1); ures_close(&bund2); - + length = (int32_t)uprv_strlen(found); if(U_SUCCESS(*status)) { @@ -2866,7 +2898,7 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, uprv_strncpy(result, found, copyLength); } if(length == 0) { - *status = U_MISSING_RESOURCE_ERROR; + *status = U_MISSING_RESOURCE_ERROR; } } else { length = 0; @@ -2880,58 +2912,58 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) { #define VALUES_BUF_SIZE 2048 #define VALUES_LIST_SIZE 512 - + char valuesBuf[VALUES_BUF_SIZE]; int32_t valuesIndex = 0; const char *valuesList[VALUES_LIST_SIZE]; int32_t valuesCount = 0; - + const char *locale; int32_t locLen; - + UEnumeration *locs = NULL; - + UResourceBundle item; UResourceBundle subItem; - + ures_initStackObject(&item); ures_initStackObject(&subItem); locs = ures_openAvailableLocales(path, status); - + if(U_FAILURE(*status)) { ures_close(&item); ures_close(&subItem); return NULL; } - + valuesBuf[0]=0; valuesBuf[1]=0; - + while((locale = uenum_next(locs, &locLen, status)) != 0) { UResourceBundle *bund = NULL; UResourceBundle *subPtr = NULL; UErrorCode subStatus = U_ZERO_ERROR; /* don't fail if a bundle is unopenable */ bund = ures_openDirect(path, locale, &subStatus); - + #if defined(URES_TREE_DEBUG) if(!bund || U_FAILURE(subStatus)) { - fprintf(stderr, "%s-%s values: Can't open %s locale - skipping. (%s)\n", + fprintf(stderr, "%s-%s values: Can't open %s locale - skipping. (%s)\n", path?path:"", keyword, locale, u_errorName(subStatus)); } #endif - + ures_getByKey(bund, keyword, &item, &subStatus); - + if(!bund || U_FAILURE(subStatus)) { #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s-%s values: Can't find in %s - skipping. (%s)\n", + fprintf(stderr, "%s-%s values: Can't find in %s - skipping. (%s)\n", path?path:"", keyword, locale, u_errorName(subStatus)); #endif ures_close(bund); bund = NULL; continue; } - + while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) != 0 && U_SUCCESS(subStatus)) { const char *k; @@ -2972,12 +3004,12 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) ures_close(bund); } valuesBuf[valuesIndex++] = 0; /* terminate */ - + ures_close(&item); ures_close(&subItem); uenum_close(locs); #if defined(URES_TREE_DEBUG) - fprintf(stderr, "%s: size %d, #%d\n", u_errorName(*status), + fprintf(stderr, "%s: size %d, #%d\n", u_errorName(*status), valuesIndex, valuesCount); #endif return uloc_openKeywordList(valuesBuf, valuesIndex, status); @@ -3052,7 +3084,7 @@ ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo v str = ures_getStringByKey(res, key, &len, status); if(U_SUCCESS(*status)) { u_versionFromUString(ver, str); - } + } } /* eof */ diff --git a/deps/icu-small/source/common/uresdata.cpp b/deps/icu-small/source/common/uresdata.cpp index a0b8d3ba904ad6..b3c2e2e27ccf9a 100644 --- a/deps/icu-small/source/common/uresdata.cpp +++ b/deps/icu-small/source/common/uresdata.cpp @@ -33,6 +33,7 @@ #include "uinvchar.h" #include "uresdata.h" #include "uresimp.h" +#include "utracimp.h" /* * Resource access helpers @@ -307,7 +308,7 @@ res_getPublicType(Resource res) { } U_CAPI const UChar * U_EXPORT2 -res_getString(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const UChar *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -402,7 +403,8 @@ int32_t getStringArray(const ResourceData *pResData, const icu::ResourceArray &a } for(int32_t i = 0; i < length; ++i) { int32_t sLength; - const UChar *s = res_getString(pResData, array.internalGetResource(pResData, i), &sLength); + // No tracing: handled by the caller + const UChar *s = res_getStringNoTrace(pResData, array.internalGetResource(pResData, i), &sLength); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; return 0; @@ -434,7 +436,7 @@ res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength) { } U_CAPI const uint8_t * U_EXPORT2 -res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const uint8_t *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -454,7 +456,7 @@ res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength) { U_CAPI const int32_t * U_EXPORT2 -res_getIntVector(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const int32_t *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -507,7 +509,7 @@ const UChar *ResourceDataValue::getString(int32_t &length, UErrorCode &errorCode if(U_FAILURE(errorCode)) { return NULL; } - const UChar *s = res_getString(pResData, res, &length); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &length); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -518,7 +520,7 @@ const UChar *ResourceDataValue::getAliasString(int32_t &length, UErrorCode &erro if(U_FAILURE(errorCode)) { return NULL; } - const UChar *s = res_getAlias(pResData, res, &length); + const UChar *s = res_getAlias(&getData(), res, &length); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -532,7 +534,7 @@ int32_t ResourceDataValue::getInt(UErrorCode &errorCode) const { if(RES_GET_TYPE(res) != URES_INT) { errorCode = U_RESOURCE_TYPE_MISMATCH; } - return RES_GET_INT(res); + return res_getInt(fTraceInfo, res); } uint32_t ResourceDataValue::getUInt(UErrorCode &errorCode) const { @@ -542,14 +544,14 @@ uint32_t ResourceDataValue::getUInt(UErrorCode &errorCode) const { if(RES_GET_TYPE(res) != URES_INT) { errorCode = U_RESOURCE_TYPE_MISMATCH; } - return RES_GET_UINT(res); + return res_getUInt(fTraceInfo, res); } const int32_t *ResourceDataValue::getIntVector(int32_t &length, UErrorCode &errorCode) const { if(U_FAILURE(errorCode)) { return NULL; } - const int32_t *iv = res_getIntVector(pResData, res, &length); + const int32_t *iv = res_getIntVector(fTraceInfo, &getData(), res, &length); if(iv == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -560,7 +562,7 @@ const uint8_t *ResourceDataValue::getBinary(int32_t &length, UErrorCode &errorCo if(U_FAILURE(errorCode)) { return NULL; } - const uint8_t *b = res_getBinary(pResData, res, &length); + const uint8_t *b = res_getBinary(fTraceInfo, &getData(), res, &length); if(b == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -578,19 +580,19 @@ ResourceArray ResourceDataValue::getArray(UErrorCode &errorCode) const { switch(RES_GET_TYPE(res)) { case URES_ARRAY: if (offset!=0) { // empty if offset==0 - items32 = (const Resource *)pResData->pRoot+offset; + items32 = (const Resource *)getData().pRoot+offset; length = *items32++; } break; case URES_ARRAY16: - items16 = pResData->p16BitUnits+offset; + items16 = getData().p16BitUnits+offset; length = *items16++; break; default: errorCode = U_RESOURCE_TYPE_MISMATCH; return ResourceArray(); } - return ResourceArray(items16, items32, length); + return ResourceArray(items16, items32, length, fTraceInfo); } ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { @@ -606,19 +608,19 @@ ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { switch(RES_GET_TYPE(res)) { case URES_TABLE: if (offset != 0) { // empty if offset==0 - keys16 = (const uint16_t *)(pResData->pRoot+offset); + keys16 = (const uint16_t *)(getData().pRoot+offset); length = *keys16++; items32 = (const Resource *)(keys16+length+(~length&1)); } break; case URES_TABLE16: - keys16 = pResData->p16BitUnits+offset; + keys16 = getData().p16BitUnits+offset; length = *keys16++; items16 = keys16 + length; break; case URES_TABLE32: if (offset != 0) { // empty if offset==0 - keys32 = pResData->pRoot+offset; + keys32 = getData().pRoot+offset; length = *keys32++; items32 = (const Resource *)keys32 + length; } @@ -627,22 +629,22 @@ ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { errorCode = U_RESOURCE_TYPE_MISMATCH; return ResourceTable(); } - return ResourceTable(keys16, keys32, items16, items32, length); + return ResourceTable(keys16, keys32, items16, items32, length, fTraceInfo); } UBool ResourceDataValue::isNoInheritanceMarker() const { - return ::isNoInheritanceMarker(pResData, res); + return ::isNoInheritanceMarker(&getData(), res); } int32_t ResourceDataValue::getStringArray(UnicodeString *dest, int32_t capacity, UErrorCode &errorCode) const { - return ::getStringArray(pResData, getArray(errorCode), dest, capacity, errorCode); + return ::getStringArray(&getData(), getArray(errorCode), dest, capacity, errorCode); } int32_t ResourceDataValue::getStringArrayOrStringAsArray(UnicodeString *dest, int32_t capacity, UErrorCode &errorCode) const { if(URES_IS_ARRAY(res)) { - return ::getStringArray(pResData, getArray(errorCode), dest, capacity, errorCode); + return ::getStringArray(&getData(), getArray(errorCode), dest, capacity, errorCode); } if(U_FAILURE(errorCode)) { return 0; @@ -656,7 +658,7 @@ int32_t ResourceDataValue::getStringArrayOrStringAsArray(UnicodeString *dest, in return 1; } int32_t sLength; - const UChar *s = res_getString(pResData, res, &sLength); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength); if(s != NULL) { dest[0].setTo(TRUE, s, sLength); return 1; @@ -671,7 +673,7 @@ UnicodeString ResourceDataValue::getStringOrFirstOfArray(UErrorCode &errorCode) return us; } int32_t sLength; - const UChar *s = res_getString(pResData, res, &sLength); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength); if(s != NULL) { us.setTo(TRUE, s, sLength); return us; @@ -681,7 +683,8 @@ UnicodeString ResourceDataValue::getStringOrFirstOfArray(UErrorCode &errorCode) return us; } if(array.getSize() > 0) { - s = res_getString(pResData, array.internalGetResource(pResData, 0), &sLength); + // Tracing is already performed above (unimportant for trace that this is an array) + s = res_getStringNoTrace(&getData(), array.internalGetResource(&getData(), 0), &sLength); if(s != NULL) { us.setTo(TRUE, s, sLength); return us; @@ -818,18 +821,45 @@ UBool icu::ResourceTable::getKeyAndValue(int32_t i, const char *&key, icu::ResourceValue &value) const { if(0 <= i && i < length) { icu::ResourceDataValue &rdValue = static_cast(value); - if (keys16 != NULL) { - key = RES_GET_KEY16(rdValue.pResData, keys16[i]); + if (keys16 != nullptr) { + key = RES_GET_KEY16(&rdValue.getData(), keys16[i]); } else { - key = RES_GET_KEY32(rdValue.pResData, keys32[i]); + key = RES_GET_KEY32(&rdValue.getData(), keys32[i]); } Resource res; - if (items16 != NULL) { - res = makeResourceFrom16(rdValue.pResData, items16[i]); + if (items16 != nullptr) { + res = makeResourceFrom16(&rdValue.getData(), items16[i]); } else { res = items32[i]; } - rdValue.setResource(res); + // Note: the ResourceTracer keeps a reference to the field of this + // ResourceTable. This is OK because the ResourceTable should remain + // alive for the duration that fields are being read from it + // (including nested fields). + rdValue.setResource(res, ResourceTracer(fTraceInfo, key)); + return TRUE; + } + return FALSE; +} + +UBool icu::ResourceTable::findValue(const char *key, ResourceValue &value) const { + icu::ResourceDataValue &rdValue = static_cast(value); + const char *realKey = nullptr; + int32_t i; + if (keys16 != nullptr) { + i = _res_findTableItem(&rdValue.getData(), keys16, length, key, &realKey); + } else { + i = _res_findTable32Item(&rdValue.getData(), keys32, length, key, &realKey); + } + if (i >= 0) { + Resource res; + if (items16 != nullptr) { + res = makeResourceFrom16(&rdValue.getData(), items16[i]); + } else { + res = items32[i]; + } + // Same note about lifetime as in getKeyAndValue(). + rdValue.setResource(res, ResourceTracer(fTraceInfo, key)); return TRUE; } return FALSE; @@ -875,7 +905,13 @@ uint32_t icu::ResourceArray::internalGetResource(const ResourceData *pResData, i UBool icu::ResourceArray::getValue(int32_t i, icu::ResourceValue &value) const { if(0 <= i && i < length) { icu::ResourceDataValue &rdValue = static_cast(value); - rdValue.setResource(internalGetResource(rdValue.pResData, i)); + // Note: the ResourceTracer keeps a reference to the field of this + // ResourceArray. This is OK because the ResourceArray should remain + // alive for the duration that fields are being read from it + // (including nested fields). + rdValue.setResource( + internalGetResource(&rdValue.getData(), i), + ResourceTracer(fTraceInfo, i)); return TRUE; } return FALSE; @@ -899,13 +935,13 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch if(!URES_IS_CONTAINER(type)) { return RES_BOGUS; } - + while(nextSepP && *pathP && t1 != RES_BOGUS && URES_IS_CONTAINER(type)) { /* Iteration stops if: the path has been consumed, we found a non-existing * resource (t1 == RES_BOGUS) or we found a scalar resource (including alias) */ nextSepP = uprv_strchr(pathP, RES_PATH_SEPARATOR); - /* if there are more separators, terminate string + /* if there are more separators, terminate string * and set path to the remaining part of the string */ if(nextSepP != NULL) { @@ -924,7 +960,7 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch if(URES_IS_TABLE(type)) { *key = pathP; t2 = res_getTableItemByKey(pResData, t1, &indexR, key); - if(t2 == RES_BOGUS) { + if(t2 == RES_BOGUS) { /* if we fail to get the resource by key, maybe we got an index */ indexR = uprv_strtol(pathP, &closeIndex, 10); if(indexR >= 0 && *closeIndex == 0) { diff --git a/deps/icu-small/source/common/uresdata.h b/deps/icu-small/source/common/uresdata.h index 4e28ddccf63199..d1b67babf29049 100644 --- a/deps/icu-small/source/common/uresdata.h +++ b/deps/icu-small/source/common/uresdata.h @@ -69,14 +69,16 @@ typedef uint32_t Resource; #define RES_GET_OFFSET(res) ((res)&0x0fffffff) #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res)) -/* get signed and unsigned integer values directly from the Resource handle */ +/* get signed and unsigned integer values directly from the Resource handle + * NOTE: For proper logging, please use the res_getInt() constexpr + */ #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC -# define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L) +# define RES_GET_INT_NO_TRACE(res) (((int32_t)((res)<<4L))>>4L) #else -# define RES_GET_INT(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff) +# define RES_GET_INT_NO_TRACE(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff) #endif -#define RES_GET_UINT(res) ((res)&0x0fffffff) +#define RES_GET_UINT_NO_TRACE(res) ((res)&0x0fffffff) #define URES_IS_ARRAY(type) ((int32_t)(type)==URES_ARRAY || (int32_t)(type)==URES_ARRAY16) #define URES_IS_TABLE(type) ((int32_t)(type)==URES_TABLE || (int32_t)(type)==URES_TABLE16 || (int32_t)(type)==URES_TABLE32) @@ -423,22 +425,26 @@ res_unload(ResourceData *pResData); U_INTERNAL UResType U_EXPORT2 res_getPublicType(Resource res); +/////////////////////////////////////////////////////////////////////////// +// To enable tracing, use the inline versions of the res_get* functions. // +/////////////////////////////////////////////////////////////////////////// + /* * Return a pointer to a zero-terminated, const UChar* string * and set its length in *pLength. * Returns NULL if not found. */ U_INTERNAL const UChar * U_EXPORT2 -res_getString(const ResourceData *pResData, Resource res, int32_t *pLength); - -U_INTERNAL const UChar * U_EXPORT2 -res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL const uint8_t * U_EXPORT2 -res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL const int32_t * U_EXPORT2 -res_getIntVector(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); + +U_INTERNAL const UChar * U_EXPORT2 +res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL Resource U_EXPORT2 res_getResource(const ResourceData *pResData, const char *key); @@ -470,17 +476,55 @@ U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r, #ifdef __cplusplus #include "resource.h" +#include "restrace.h" U_NAMESPACE_BEGIN +inline const UChar* res_getString(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("string"); + return res_getStringNoTrace(pResData, res, pLength); +} + +inline const uint8_t* res_getBinary(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("binary"); + return res_getBinaryNoTrace(pResData, res, pLength); +} + +inline const int32_t* res_getIntVector(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("intvector"); + return res_getIntVectorNoTrace(pResData, res, pLength); +} + +inline int32_t res_getInt(const ResourceTracer& traceInfo, Resource res) { + traceInfo.trace("int"); + return RES_GET_INT_NO_TRACE(res); +} + +inline uint32_t res_getUInt(const ResourceTracer& traceInfo, Resource res) { + traceInfo.trace("uint"); + return RES_GET_UINT_NO_TRACE(res); +} + class ResourceDataValue : public ResourceValue { public: - ResourceDataValue() : pResData(NULL), res(static_cast(URES_NONE)) {} + ResourceDataValue() : + res(static_cast(URES_NONE)), + fTraceInfo() {} virtual ~ResourceDataValue(); - void setData(const ResourceData *data) { pResData = data; } - void setResource(Resource r) { res = r; } + void setData(const ResourceData *data) { + resData = *data; + } + void setResource(Resource r, ResourceTracer&& traceInfo) { + res = r; + fTraceInfo = traceInfo; + } + + const ResourceData &getData() const { return resData; } virtual UResType getType() const; virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const; virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const; @@ -497,10 +541,12 @@ class ResourceDataValue : public ResourceValue { UErrorCode &errorCode) const; virtual UnicodeString getStringOrFirstOfArray(UErrorCode &errorCode) const; - const ResourceData *pResData; - private: + // TODO(ICU-20769): If UResourceBundle.fResData becomes a pointer, + // then remove this value field again and just store a pResData pointer. + ResourceData resData; Resource res; + ResourceTracer fTraceInfo; }; U_NAMESPACE_END diff --git a/deps/icu-small/source/common/uresimp.h b/deps/icu-small/source/common/uresimp.h index 16144012a5bc0d..f453ddc004a9fd 100644 --- a/deps/icu-small/source/common/uresimp.h +++ b/deps/icu-small/source/common/uresimp.h @@ -67,6 +67,9 @@ struct UResourceBundle { char *fVersion; UResourceDataEntry *fTopLevelData; /* for getting the valid locale */ char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */ + // TODO(ICU-20769): Try to change the by-value fResData into a pointer, + // with the struct in only one place for each bundle. + // Also replace class ResourceDataValue.resData with a pResData pointer again. ResourceData fResData; char fResBuf[RES_BUFSIZE]; int32_t fResPathLen; @@ -169,10 +172,10 @@ U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle * Returns a resource that can be located using the pathToResource argument. One needs optional package, locale * and path inside the locale, for example: "/myData/en/zoneStrings/3". Keys and indexes are supported. Keys * need to reference data in named structures, while indexes can reference both named and anonymous resources. - * Features a fill-in parameter. - * + * Features a fill-in parameter. + * * Note, this function does NOT have a syntax for specifying items within a tree. May want to consider a - * syntax that delineates between package/tree and resource. + * syntax that delineates between package/tree and resource. * * @param pathToResource a path that will lead to the requested resource * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller. @@ -181,16 +184,16 @@ U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it */ U_CAPI UResourceBundle* U_EXPORT2 -ures_findResource(const char* pathToResource, - UResourceBundle *fillIn, UErrorCode *status); +ures_findResource(const char* pathToResource, + UResourceBundle *fillIn, UErrorCode *status); /** - * Returns a sub resource that can be located using the pathToResource argument. One needs a path inside + * Returns a sub resource that can be located using the pathToResource argument. One needs a path inside * the supplied resource, for example, if you have "en_US" resource bundle opened, you might ask for * "zoneStrings/3". Keys and indexes are supported. Keys - * need to reference data in named structures, while indexes can reference both + * need to reference data in named structures, while indexes can reference both * named and anonymous resources. - * Features a fill-in parameter. + * Features a fill-in parameter. * * @param resourceBundle a resource * @param pathToResource a path that will lead to the requested resource @@ -200,8 +203,8 @@ ures_findResource(const char* pathToResource, * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it */ U_CAPI UResourceBundle* U_EXPORT2 -ures_findSubResource(const UResourceBundle *resB, - char* pathToResource, +ures_findSubResource(const UResourceBundle *resB, + char* pathToResource, UResourceBundle *fillIn, UErrorCode *status); /** @@ -212,23 +215,23 @@ ures_findSubResource(const UResourceBundle *resB, * @param resName top level resource. Example: "collations" * @param keyword locale keyword. Example: "collation" * @param locid The requested locale - * @param isAvailable If non-null, pointer to fillin parameter that indicates whether the - * requested locale was available. The locale is defined as 'available' if it physically + * @param isAvailable If non-null, pointer to fillin parameter that indicates whether the + * requested locale was available. The locale is defined as 'available' if it physically * exists within the specified tree. * @param omitDefault if TRUE, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE' * @param status error code - * @return the actual buffer size needed for the full locale. If it's greater + * @return the actual buffer size needed for the full locale. If it's greater * than resultCapacity, the returned full name will be truncated and an error code will be returned. */ U_CAPI int32_t U_EXPORT2 -ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, +ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, const char *path, const char *resName, const char *keyword, const char *locid, UBool *isAvailable, UBool omitDefault, UErrorCode *status); /** * Given a tree path and keyword, return a string enumeration of all possible values for that keyword. * @param path path to the tree, or NULL for ICU data - * @param keyword a particular keyword to consider, must match a top level resource name + * @param keyword a particular keyword to consider, must match a top level resource name * within the tree. * @param status error code */ @@ -248,14 +251,14 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) * Alternatively, you can supply a struct to be filled by this function. * @param status: fills in the outgoing error code * could be U_MISSING_RESOURCE_ERROR if the key is not found - * could be a non-failing error + * could be a non-failing error * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it */ -U_CAPI UResourceBundle* U_EXPORT2 -ures_getByKeyWithFallback(const UResourceBundle *resB, - const char* inKey, - UResourceBundle *fillIn, +U_CAPI UResourceBundle* U_EXPORT2 +ures_getByKeyWithFallback(const UResourceBundle *resB, + const char* inKey, + UResourceBundle *fillIn, UErrorCode *status); @@ -269,18 +272,23 @@ ures_getByKeyWithFallback(const UResourceBundle *resB, * @param inKey a key associated with the requested resource * @param status: fills in the outgoing error code * could be U_MISSING_RESOURCE_ERROR if the key is not found - * could be a non-failing error + * could be a non-failing error * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it */ -U_CAPI const UChar* U_EXPORT2 -ures_getStringByKeyWithFallback(const UResourceBundle *resB, - const char* inKey, +U_CAPI const UChar* U_EXPORT2 +ures_getStringByKeyWithFallback(const UResourceBundle *resB, + const char* inKey, int32_t* len, UErrorCode *status); #ifdef __cplusplus +U_CAPI void U_EXPORT2 +ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, + UResourceBundle *tempFillIn, + icu::ResourceDataValue &value, UErrorCode &errorCode); + U_CAPI void U_EXPORT2 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path, icu::ResourceSink &sink, UErrorCode &errorCode); @@ -310,13 +318,13 @@ ures_getVersionByKey(const UResourceBundle *resB, * The caller does not own this string. * @see ures_getVersion */ -U_CAPI const char* U_EXPORT2 +U_CAPI const char* U_EXPORT2 ures_getVersionNumberInternal(const UResourceBundle *resourceBundle); /** * Return the name of the Locale associated with this ResourceBundle. This API allows - * you to query for the real locale of the resource. For example, if you requested - * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. + * you to query for the real locale of the resource. For example, if you requested + * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. * For subresources, the locale where this resource comes from will be returned. * If fallback has occured, getLocale will reflect this. * @@ -326,13 +334,13 @@ ures_getVersionNumberInternal(const UResourceBundle *resourceBundle); * @param status just for catching illegal arguments * @return A Locale name */ -U_CAPI const char* U_EXPORT2 -ures_getLocaleInternal(const UResourceBundle* resourceBundle, +U_CAPI const char* U_EXPORT2 +ures_getLocaleInternal(const UResourceBundle* resourceBundle, UErrorCode* status); /** * Same as ures_openDirect() but uses the fill-in parameter instead of allocating a new bundle. - * + * * @param r The existing UResourceBundle to fill in. If NULL then status will be * set to U_ILLEGAL_ARGUMENT_ERROR. * @param packageName The packageName and locale together point to an ICU udata object, diff --git a/deps/icu-small/source/common/usc_impl.cpp b/deps/icu-small/source/common/usc_impl.cpp index d69880326a4cbd..111029b97496e7 100644 --- a/deps/icu-small/source/common/usc_impl.cpp +++ b/deps/icu-small/source/common/usc_impl.cpp @@ -79,7 +79,7 @@ static void push(UScriptRun *scriptRun, int32_t pairIndex, UScriptCode scriptCod { scriptRun->pushCount = LIMIT_INC(scriptRun->pushCount); scriptRun->fixupCount = LIMIT_INC(scriptRun->fixupCount); - + scriptRun->parenSP = INC1(scriptRun->parenSP); scriptRun->parenStack[scriptRun->parenSP].pairIndex = pairIndex; scriptRun->parenStack[scriptRun->parenSP].scriptCode = scriptCode; @@ -90,14 +90,14 @@ static void pop(UScriptRun *scriptRun) if (STACK_IS_EMPTY(scriptRun)) { return; } - + if (scriptRun->fixupCount > 0) { scriptRun->fixupCount -= 1; } - + scriptRun->pushCount -= 1; scriptRun->parenSP = DEC1(scriptRun->parenSP); - + /* If the stack is now empty, reset the stack pointers to their initial values. */ @@ -109,7 +109,7 @@ static void pop(UScriptRun *scriptRun) static void fixup(UScriptRun *scriptRun, UScriptCode scriptCode) { int32_t fixupSP = DEC(scriptRun->parenSP, scriptRun->fixupCount); - + while (scriptRun->fixupCount-- > 0) { fixupSP = INC1(fixupSP); scriptRun->parenStack[fixupSP].scriptCode = scriptCode; @@ -263,7 +263,7 @@ uscript_nextRun(UScriptRun *scriptRun, int32_t *pRunStart, int32_t *pRunLimit, U if (scriptRun == NULL || scriptRun->scriptLimit >= scriptRun->textLength) { return FALSE; } - + SYNC_FIXUP(scriptRun); scriptRun->scriptCode = USCRIPT_COMMON; diff --git a/deps/icu-small/source/common/uset.cpp b/deps/icu-small/source/common/uset.cpp index 265a300b19060c..eae7981d52f0ce 100644 --- a/deps/icu-small/source/common/uset.cpp +++ b/deps/icu-small/source/common/uset.cpp @@ -83,7 +83,7 @@ uset_add(USet* set, UChar32 c) { U_CAPI void U_EXPORT2 uset_addRange(USet* set, UChar32 start, UChar32 end) { - ((UnicodeSet*) set)->UnicodeSet::add(start, end); + ((UnicodeSet*) set)->UnicodeSet::add(start, end); } U_CAPI void U_EXPORT2 @@ -527,40 +527,40 @@ uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, // efficiency. // --- // #define USET_GROW_DELTA 20 -// +// // static int32_t // findChar(const UChar32* array, int32_t length, UChar32 c) { // int32_t i; -// +// // /* check the last range limit first for more efficient appending */ // if(length>0) { // if(c>=array[length-1]) { // return length; // } -// +// // /* do not check the last range limit again in the loop below */ // --length; // } -// +// // for(i=0; i=array[i]; ++i) {} // return i; // } -// +// // static UBool // addRemove(USet* set, UChar32 c, int32_t doRemove) { // int32_t i, length, more; -// +// // if(set==NULL || (uint32_t)c>0x10ffff) { // return FALSE; // } -// +// // length=set->length; // i=findChar(set->array, length, c); // if((i&1)^doRemove) { // /* c is already in the set */ // return TRUE; // } -// +// // /* how many more array items do we need? */ // if(iarray[i]) { // /* c is just before the following range, extend that in-place by one */ @@ -600,7 +600,7 @@ uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, // /* insert two range limits c, c+1 */ // more=2; // } -// +// // /* insert range limits */ // if(length+more>set->capacity) { // /* reallocate */ @@ -611,13 +611,13 @@ uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, // } // set->capacity=newCapacity; // uprv_memcpy(newArray, set->array, length*4); -// +// // if(set->array!=set->staticBuffer) { // uprv_free(set->array); // } // set->array=newArray; // } -// +// // if(iarray+i+more, set->array+i, (length-i)*4); // } @@ -626,15 +626,15 @@ uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, // set->array[i+1]=c+1; // } // set->length+=more; -// +// // return TRUE; // } -// +// // U_CAPI UBool U_EXPORT2 // uset_add(USet* set, UChar32 c) { // return addRemove(set, c, 0); // } -// +// // U_CAPI void U_EXPORT2 // uset_remove(USet* set, UChar32 c) { // addRemove(set, c, 1); diff --git a/deps/icu-small/source/common/uset_imp.h b/deps/icu-small/source/common/uset_imp.h index 5f4a3113d9aaf7..7233b9303c3a17 100644 --- a/deps/icu-small/source/common/uset_imp.h +++ b/deps/icu-small/source/common/uset_imp.h @@ -59,3 +59,4 @@ typedef struct USetAdder USetAdder; U_CDECL_END #endif + diff --git a/deps/icu-small/source/common/uset_props.cpp b/deps/icu-small/source/common/uset_props.cpp index b68175c1d23b14..f08e760b10d4e1 100644 --- a/deps/icu-small/source/common/uset_props.cpp +++ b/deps/icu-small/source/common/uset_props.cpp @@ -69,13 +69,13 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength, } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uset_applyPattern(USet *set, const UChar *pattern, int32_t patternLength, uint32_t options, UErrorCode *status){ - // status code needs to be checked since we + // status code needs to be checked since we // dereference it if(status == NULL || U_FAILURE(*status)){ return 0; @@ -92,9 +92,9 @@ uset_applyPattern(USet *set, UnicodeString pat(pattern, patternLength); ParsePosition pos; - + ((UnicodeSet*) set)->applyPattern(pat, pos, options, NULL, *status); - + return pos.getIndex(); } diff --git a/deps/icu-small/source/common/usetiter.cpp b/deps/icu-small/source/common/usetiter.cpp index 5c9780548c182d..791516904944d3 100644 --- a/deps/icu-small/source/common/usetiter.cpp +++ b/deps/icu-small/source/common/usetiter.cpp @@ -120,7 +120,7 @@ void UnicodeSetIterator::reset() { } range = 0; endElement = -1; - nextElement = 0; + nextElement = 0; if (endRange >= 0) { loadRange(range); } diff --git a/deps/icu-small/source/common/ushape.cpp b/deps/icu-small/source/common/ushape.cpp index 792de50bbcc736..ae13b5c11834c5 100644 --- a/deps/icu-small/source/common/ushape.cpp +++ b/deps/icu-small/source/common/ushape.cpp @@ -816,9 +816,9 @@ handleGeneratedSpaces(UChar *dest, int32_t sourceLength, if(lamAlefOption || tashkeelOption){ uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR); - + i = j = sourceLength; count = 0; - + while(i >= 0) { if ( (lamAlefOption && dest[i] == LAMALEF_SPACE_SUB) || (tashkeelOption && dest[i] == TASHKEEL_SPACE_SUB) ){ diff --git a/deps/icu-small/source/common/usprep.cpp b/deps/icu-small/source/common/usprep.cpp index 9155ae077b3497..8351a773706c7a 100644 --- a/deps/icu-small/source/common/usprep.cpp +++ b/deps/icu-small/source/common/usprep.cpp @@ -45,13 +45,9 @@ U_CDECL_BEGIN Static cache for already opened StringPrep profiles */ static UHashtable *SHARED_DATA_HASHTABLE = NULL; -static icu::UInitOnce gSharedDataInitOnce; - -static UMutex *usprepMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UInitOnce gSharedDataInitOnce = U_INITONCE_INITIALIZER; +static UMutex usprepMutex; /* format version of spp file */ //static uint8_t formatVersion[4]={ 0, 0, 0, 0 }; @@ -78,7 +74,7 @@ static const char * const PROFILE_NAMES[] = { static UBool U_CALLCONV isSPrepAcceptable(void * /* context */, - const char * /* type */, + const char * /* type */, const char * /* name */, const UDataInfo *pInfo) { if( @@ -109,7 +105,7 @@ getSPrepFoldingOffset(uint32_t data) { } /* hashes an entry */ -static int32_t U_CALLCONV +static int32_t U_CALLCONV hashEntry(const UHashTok parm) { UStringPrepKey *b = (UStringPrepKey *)parm.pointer; UHashTok namekey, pathkey; @@ -121,7 +117,7 @@ hashEntry(const UHashTok parm) { } /* compares two entries */ -static UBool U_CALLCONV +static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { UStringPrepKey *b1 = (UStringPrepKey *)p1.pointer; UStringPrepKey *b2 = (UStringPrepKey *)p2.pointer; @@ -130,16 +126,16 @@ compareEntries(const UHashTok p1, const UHashTok p2) { name2.pointer = b2->name; path1.pointer = b1->path; path2.pointer = b2->path; - return ((UBool)(uhash_compareChars(name1, name2) & + return ((UBool)(uhash_compareChars(name1, name2) & uhash_compareChars(path1, path2))); } -static void +static void usprep_unload(UStringPrepProfile* data){ udata_close(data->sprepData); } -static int32_t +static int32_t usprep_internal_flushCache(UBool noRefCount){ UStringPrepProfile *profile = NULL; UStringPrepKey *key = NULL; @@ -151,9 +147,9 @@ usprep_internal_flushCache(UBool noRefCount){ * if shared data hasn't even been lazy evaluated yet * return 0 */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); if (SHARED_DATA_HASHTABLE == NULL) { - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); return 0; } @@ -163,7 +159,7 @@ usprep_internal_flushCache(UBool noRefCount){ profile = (UStringPrepProfile *) e->value.pointer; key = (UStringPrepKey *) e->key.pointer; - if ((noRefCount== FALSE && profile->refCount == 0) || + if ((noRefCount== FALSE && profile->refCount == 0) || noRefCount== TRUE) { deletedNum++; uhash_removeElement(SHARED_DATA_HASHTABLE, e); @@ -182,15 +178,15 @@ usprep_internal_flushCache(UBool noRefCount){ uprv_free(profile); uprv_free(key); } - + } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); return deletedNum; } -/* Works just like ucnv_flushCache() -static int32_t +/* Works just like ucnv_flushCache() +static int32_t usprep_flushCache(){ return usprep_internal_flushCache(FALSE); } @@ -220,18 +216,18 @@ createCache(UErrorCode &status) { ucln_common_registerCleanup(UCLN_COMMON_USPREP, usprep_cleanup); } -static void +static void initCache(UErrorCode *status) { umtx_initOnce(gSharedDataInitOnce, &createCache, *status); } static UBool U_CALLCONV -loadData(UStringPrepProfile* profile, - const char* path, - const char* name, - const char* type, +loadData(UStringPrepProfile* profile, + const char* path, + const char* name, + const char* type, UErrorCode* errorCode) { - /* load Unicode SPREP data from file */ + /* load Unicode SPREP data from file */ UTrie _sprepTrie={ 0,0,0,0,0,0,0 }; UDataMemory *dataMemory; const int32_t *p=NULL; @@ -262,7 +258,7 @@ loadData(UStringPrepProfile* profile, } /* in the mutex block, set the data for this process */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); if(profile->sprepData==NULL) { profile->sprepData=dataMemory; dataMemory=NULL; @@ -271,17 +267,17 @@ loadData(UStringPrepProfile* profile, } else { p=(const int32_t *)udata_getMemory(profile->sprepData); } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); /* initialize some variables */ profile->mappingData=(uint16_t *)((uint8_t *)(p+_SPREP_INDEX_TOP)+profile->indexes[_SPREP_INDEX_TRIE_SIZE]); - + u_getUnicodeVersion(normUnicodeVersion); - normUniVer = (normUnicodeVersion[0] << 24) + (normUnicodeVersion[1] << 16) + + normUniVer = (normUnicodeVersion[0] << 24) + (normUnicodeVersion[1] << 16) + (normUnicodeVersion[2] << 8 ) + (normUnicodeVersion[3]); - sprepUniVer = (dataVersion[0] << 24) + (dataVersion[1] << 16) + + sprepUniVer = (dataVersion[0] << 24) + (dataVersion[1] << 16) + (dataVersion[2] << 8 ) + (dataVersion[3]); normCorrVer = profile->indexes[_SPREP_NORM_CORRECTNS_LAST_UNI_VERSION]; - + if(U_FAILURE(*errorCode)){ udata_close(dataMemory); return FALSE; @@ -305,8 +301,8 @@ loadData(UStringPrepProfile* profile, return profile->isDataLoaded; } -static UStringPrepProfile* -usprep_getProfile(const char* path, +static UStringPrepProfile* +usprep_getProfile(const char* path, const char* name, UErrorCode *status){ @@ -319,22 +315,22 @@ usprep_getProfile(const char* path, } UStringPrepKey stackKey; - /* - * const is cast way to save malloc, strcpy and free calls - * we use the passed in pointers for fetching the data from the + /* + * const is cast way to save malloc, strcpy and free calls + * we use the passed in pointers for fetching the data from the * hash table which is safe */ stackKey.name = (char*) name; stackKey.path = (char*) path; /* fetch the data from the cache */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey)); if(profile != NULL) { profile->refCount++; } - umtx_unlock(usprepMutex()); - + umtx_unlock(&usprepMutex); + if(profile == NULL) { /* else load the data and put the data in the cache */ LocalMemory newProfile; @@ -365,7 +361,7 @@ usprep_getProfile(const char* path, return NULL; } - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); // If another thread already inserted the same key/value, refcount and cleanup our thread data profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey)); if(profile != NULL) { @@ -379,28 +375,28 @@ usprep_getProfile(const char* path, if(path != NULL){ key->path = keyPath.orphan(); uprv_strcpy(key->path, path); - } + } profile = newProfile.orphan(); - + /* add the data object to the cache */ profile->refCount = 1; uhash_put(SHARED_DATA_HASHTABLE, key.orphan(), profile, status); } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); } return profile; } U_CAPI UStringPrepProfile* U_EXPORT2 -usprep_open(const char* path, +usprep_open(const char* path, const char* name, UErrorCode* status){ if(status == NULL || U_FAILURE(*status)){ return NULL; } - + /* initialize the profile struct members */ return usprep_getProfile(path,name,status); } @@ -425,17 +421,17 @@ usprep_close(UStringPrepProfile* profile){ return; } - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); /* decrement the ref count*/ if(profile->refCount > 0){ profile->refCount--; } - umtx_unlock(usprepMutex()); - + umtx_unlock(&usprepMutex); + } -U_CFUNC void -uprv_syntaxError(const UChar* rules, +U_CFUNC void +uprv_syntaxError(const UChar* rules, int32_t pos, int32_t rulesLen, UParseError* parseError){ @@ -443,16 +439,16 @@ uprv_syntaxError(const UChar* rules, return; } parseError->offset = pos; - parseError->line = 0 ; // we are not using line numbers - + parseError->line = 0 ; // we are not using line numbers + // for pre-context int32_t start = (pos < U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1)); int32_t limit = pos; - + u_memcpy(parseError->preContext,rules+start,limit-start); //null terminate the buffer parseError->preContext[limit-start] = 0; - + // for post-context; include error rules[pos] start = pos; limit = start + (U_PARSE_CONTEXT_LEN-1); @@ -472,8 +468,8 @@ getValues(uint16_t trieWord, int16_t& value, UBool& isIndex){ UStringPrepType type; if(trieWord == 0){ - /* - * Initial value stored in the mapping table + /* + * Initial value stored in the mapping table * just return USPREP_TYPE_LIMIT .. so that * the source codepoint is copied to the destination */ @@ -496,7 +492,7 @@ getValues(uint16_t trieWord, int16_t& value, UBool& isIndex){ value = (int16_t)trieWord; value = (value >> 2); } - + if((trieWord>>2) == _SPREP_MAX_INDEX_VALUE){ type = USPREP_DELETE; isIndex =FALSE; @@ -507,14 +503,14 @@ getValues(uint16_t trieWord, int16_t& value, UBool& isIndex){ } // TODO: change to writing to UnicodeString not UChar * -static int32_t -usprep_map( const UStringPrepProfile* profile, - const UChar* src, int32_t srcLength, +static int32_t +usprep_map( const UStringPrepProfile* profile, + const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UParseError* parseError, UErrorCode* status ){ - + uint16_t result; int32_t destIndex=0; int32_t srcIndex; @@ -531,11 +527,11 @@ usprep_map( const UStringPrepProfile* profile, UChar32 ch; U16_NEXT(src,srcIndex,srcLength,ch); - + result=0; UTRIE_GET16(&profile->sprepTrie,ch,result); - + type = getValues(result, value, isIndex); // check if the source codepoint is unassigned @@ -544,9 +540,9 @@ usprep_map( const UStringPrepProfile* profile, uprv_syntaxError(src,srcIndex-U16_LENGTH(ch), srcLength,parseError); *status = U_STRINGPREP_UNASSIGNED_ERROR; return 0; - + }else if(type == USPREP_MAP){ - + int32_t index, length; if(isIndex){ @@ -562,7 +558,7 @@ usprep_map( const UStringPrepProfile* profile, length = 3; }else{ length = profile->mappingData[index++]; - + } /* copy mapping to destination */ @@ -571,7 +567,7 @@ usprep_map( const UStringPrepProfile* profile, dest[destIndex] = profile->mappingData[index+i]; } destIndex++; /* for pre-flighting */ - } + } continue; }else{ // subtract the delta to arrive at the code point @@ -595,27 +591,27 @@ usprep_map( const UStringPrepProfile* profile, } destIndex +=2; } - + } - + return u_terminateUChars(dest, destCapacity, destIndex, status); } /* 1) Map -- For each character in the input, check if it has a mapping - and, if so, replace it with its mapping. + and, if so, replace it with its mapping. 2) Normalize -- Possibly normalize the result of step 1 using Unicode - normalization. + normalization. 3) Prohibit -- Check for any characters that are not allowed in the - output. If any are found, return an error. + output. If any are found, return an error. 4) Check bidi -- Possibly check for right-to-left characters, and if any are found, make sure that the whole string satisfies the requirements for bidirectional strings. If the string does not satisfy the requirements for bidirectional strings, return an - error. + error. [Unicode3.2] defines several bidirectional categories; each character has one bidirectional category assigned to it. For the purposes of the requirements below, an "RandALCat character" is a character that @@ -641,7 +637,7 @@ usprep_map( const UStringPrepProfile* profile, */ U_CAPI int32_t U_EXPORT2 usprep_prepare( const UStringPrepProfile* profile, - const UChar* src, int32_t srcLength, + const UChar* src, int32_t srcLength, UChar* dest, int32_t destCapacity, int32_t options, UParseError* parseError, @@ -727,7 +723,7 @@ usprep_prepare( const UStringPrepProfile* profile, UBool isIndex; UStringPrepType type = getValues(result, value, isIndex); - if( type == USPREP_PROHIBITED || + if( type == USPREP_PROHIBITED || ((result < _SPREP_TYPE_THRESHOLD) && (result & 0x01) /* first bit says it the code point is prohibited*/) ){ *status = U_STRINGPREP_PROHIBITED_ERROR; @@ -759,7 +755,7 @@ usprep_prepare( const UStringPrepProfile* profile, } //satisfy 3 - if( rightToLeft == TRUE && + if( rightToLeft == TRUE && !((firstCharDir == U_RIGHT_TO_LEFT || firstCharDir == U_RIGHT_TO_LEFT_ARABIC) && (direction == U_RIGHT_TO_LEFT || direction == U_RIGHT_TO_LEFT_ARABIC)) ){ diff --git a/deps/icu-small/source/common/ustr_cnv.cpp b/deps/icu-small/source/common/ustr_cnv.cpp index d2c2afea1592b3..9a25a9905a2374 100644 --- a/deps/icu-small/source/common/ustr_cnv.cpp +++ b/deps/icu-small/source/common/ustr_cnv.cpp @@ -38,10 +38,10 @@ U_CAPI UConverter* U_EXPORT2 u_getDefaultConverter(UErrorCode *status) { UConverter *converter = NULL; - + if (gDefaultConverter != NULL) { icu::umtx_lock(NULL); - + /* need to check to make sure it wasn't taken out from under us */ if (gDefaultConverter != NULL) { converter = gDefaultConverter; @@ -87,10 +87,10 @@ U_CAPI void U_EXPORT2 u_flushDefaultConverter() { UConverter *converter = NULL; - + if (gDefaultConverter != NULL) { icu::umtx_lock(NULL); - + /* need to check to make sure it wasn't taken out from under us */ if (gDefaultConverter != NULL) { converter = gDefaultConverter; diff --git a/deps/icu-small/source/common/ustr_cnv.h b/deps/icu-small/source/common/ustr_cnv.h index 12e86ea02f7264..861e3ebff0613b 100644 --- a/deps/icu-small/source/common/ustr_cnv.h +++ b/deps/icu-small/source/common/ustr_cnv.h @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 1999-2010, International Business Machines * Corporation and others. All Rights Reserved. @@ -40,7 +40,7 @@ U_CAPI void U_EXPORT2 u_releaseDefaultConverter(UConverter *converter); /** - * Flush the default converter, if cached. + * Flush the default converter, if cached. * @internal */ U_CAPI void U_EXPORT2 diff --git a/deps/icu-small/source/common/ustr_imp.h b/deps/icu-small/source/common/ustr_imp.h index 943824fa197645..c555ee37ea8096 100644 --- a/deps/icu-small/source/common/ustr_imp.h +++ b/deps/icu-small/source/common/ustr_imp.h @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ********************************************************************** * Copyright (C) 1999-2015, International Business Machines * Corporation and others. All Rights Reserved. @@ -37,10 +37,10 @@ uprv_strCompare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, UBool strncmpStyle, UBool codePointOrder); -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 ustr_hashUCharsN(const UChar *str, int32_t length); -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 ustr_hashCharsN(const char *str, int32_t length); U_CAPI int32_t U_EXPORT2 diff --git a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp index 056b40eb4175f6..457905eb60da00 100644 --- a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp +++ b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp @@ -45,7 +45,7 @@ class WholeStringBreakIterator : public BreakIterator { WholeStringBreakIterator() : BreakIterator(), length(0) {} ~WholeStringBreakIterator() U_OVERRIDE; UBool operator==(const BreakIterator&) const U_OVERRIDE; - BreakIterator *clone() const U_OVERRIDE; + WholeStringBreakIterator *clone() const U_OVERRIDE; static UClassID U_EXPORT2 getStaticClassID(); UClassID getDynamicClassID() const U_OVERRIDE; CharacterIterator &getText() const U_OVERRIDE; @@ -62,9 +62,9 @@ class WholeStringBreakIterator : public BreakIterator { int32_t preceding(int32_t offset) U_OVERRIDE; UBool isBoundary(int32_t offset) U_OVERRIDE; int32_t next(int32_t n) U_OVERRIDE; - BreakIterator *createBufferClone(void *stackBuffer, int32_t &BufferSize, - UErrorCode &errorCode) U_OVERRIDE; - BreakIterator &refreshInputText(UText *input, UErrorCode &errorCode) U_OVERRIDE; + WholeStringBreakIterator *createBufferClone(void *stackBuffer, int32_t &BufferSize, + UErrorCode &errorCode) U_OVERRIDE; + WholeStringBreakIterator &refreshInputText(UText *input, UErrorCode &errorCode) U_OVERRIDE; private: int32_t length; @@ -74,7 +74,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(WholeStringBreakIterator) WholeStringBreakIterator::~WholeStringBreakIterator() {} UBool WholeStringBreakIterator::operator==(const BreakIterator&) const { return FALSE; } -BreakIterator *WholeStringBreakIterator::clone() const { return nullptr; } +WholeStringBreakIterator *WholeStringBreakIterator::clone() const { return nullptr; } CharacterIterator &WholeStringBreakIterator::getText() const { UPRV_UNREACHABLE; // really should not be called @@ -113,14 +113,14 @@ int32_t WholeStringBreakIterator::preceding(int32_t /*offset*/) { return 0; } UBool WholeStringBreakIterator::isBoundary(int32_t /*offset*/) { return FALSE; } int32_t WholeStringBreakIterator::next(int32_t /*n*/) { return length; } -BreakIterator *WholeStringBreakIterator::createBufferClone( +WholeStringBreakIterator *WholeStringBreakIterator::createBufferClone( void * /*stackBuffer*/, int32_t & /*BufferSize*/, UErrorCode &errorCode) { if (U_SUCCESS(errorCode)) { errorCode = U_UNSUPPORTED_ERROR; } return nullptr; } -BreakIterator &WholeStringBreakIterator::refreshInputText( +WholeStringBreakIterator &WholeStringBreakIterator::refreshInputText( UText * /*input*/, UErrorCode &errorCode) { if (U_SUCCESS(errorCode)) { errorCode = U_UNSUPPORTED_ERROR; diff --git a/deps/icu-small/source/common/ustr_wcs.cpp b/deps/icu-small/source/common/ustr_wcs.cpp index 0372824f21f615..e9f278e9691f76 100644 --- a/deps/icu-small/source/common/ustr_wcs.cpp +++ b/deps/icu-small/source/common/ustr_wcs.cpp @@ -35,7 +35,7 @@ #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) // TODO: We should use CharString for char buffers and UnicodeString for UChar buffers. // Then we could change this to work only with wchar_t buffers. -static inline UBool +static inline UBool u_growAnyBufferFromStatic(void *context, void **pBuffer, int32_t *pCapacity, int32_t reqCapacity, int32_t length, int32_t size) { @@ -61,11 +61,11 @@ u_growAnyBufferFromStatic(void *context, } /* helper function */ -static wchar_t* -_strToWCS(wchar_t *dest, +static wchar_t* +_strToWCS(wchar_t *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode){ @@ -78,20 +78,20 @@ _strToWCS(wchar_t *dest, wchar_t* intTarget=NULL; int32_t intTargetCapacity=0; int count=0,retVal=0; - + const UChar *pSrcLimit =NULL; const UChar *pSrc = src; conv = u_getDefaultConverter(pErrorCode); - + if(U_FAILURE(*pErrorCode)){ return NULL; } - + if(srcLength == -1){ srcLength = u_strlen(pSrc); } - + pSrcLimit = pSrc + srcLength; for(;;) { @@ -101,11 +101,11 @@ _strToWCS(wchar_t *dest, /* convert to chars using default converter */ ucnv_fromUnicode(conv,&tempBuf,tempBufLimit,&pSrc,pSrcLimit,NULL,(UBool)(pSrc==pSrcLimit),pErrorCode); count =(tempBuf - saveBuf); - + /* This should rarely occur */ if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR){ tempBuf = saveBuf; - + /* we dont have enough room on the stack grow the buffer */ int32_t newCapacity = 2 * srcLength; if(newCapacity <= tempBufCapacity) { @@ -115,7 +115,7 @@ _strToWCS(wchar_t *dest, newCapacity, count, 1)) { goto cleanup; } - + saveBuf = tempBuf; tempBufLimit = tempBuf + tempBufCapacity; tempBuf = tempBuf + count; @@ -133,18 +133,18 @@ _strToWCS(wchar_t *dest, if(count>=tempBufCapacity){ tempBuf = saveBuf; /* we dont have enough room on the stack grow the buffer */ - if(!u_growAnyBufferFromStatic(stackBuffer,(void**) &tempBuf, &tempBufCapacity, + if(!u_growAnyBufferFromStatic(stackBuffer,(void**) &tempBuf, &tempBufCapacity, count+1, count, 1)) { goto cleanup; - } + } saveBuf = tempBuf; } - + saveBuf[count]=0; + - - /* allocate more space than required - * here we assume that every char requires + /* allocate more space than required + * here we assume that every char requires * no more than 2 wchar_ts */ intTargetCapacity = (count * _BUFFER_CAPACITY_MULTIPLIER + 1) /*for null termination */; @@ -156,15 +156,15 @@ _strToWCS(wchar_t *dest, int32_t remaining = intTargetCapacity; wchar_t* pIntTarget=intTarget; tempBuf = saveBuf; - + /* now convert the mbs to wcs */ for(;;){ - + /* we can call the system API since we are sure that * there is atleast 1 null in the input */ retVal = uprv_mbstowcs(pIntTarget,(tempBuf+nulLen),remaining); - + if(retVal==-1){ *pErrorCode = U_INVALID_CHAR_FOUND; break; @@ -189,10 +189,10 @@ _strToWCS(wchar_t *dest, /* we donot check for limit since tempBuf is null terminated */ while(tempBuf[nulLen++] != 0){ } - nulVal = (nulLen < srcLength) ? 1 : 0; + nulVal = (nulLen < srcLength) ? 1 : 0; pIntTarget = pIntTarget + retVal+nulVal; remaining -=(retVal+nulVal); - + /* check if we have reached the source limit*/ if(nulLen>=(count)){ break; @@ -200,10 +200,10 @@ _strToWCS(wchar_t *dest, } } count = (int32_t)(pIntTarget-intTarget); - + if(0 < count && count <= destCapacity){ uprv_memcpy(dest, intTarget, (size_t)count*sizeof(wchar_t)); - } + } if(pDestLength){ *pDestLength = count; @@ -229,10 +229,10 @@ _strToWCS(wchar_t *dest, #endif U_CAPI wchar_t* U_EXPORT2 -u_strToWCS(wchar_t *dest, +u_strToWCS(wchar_t *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode){ @@ -240,14 +240,14 @@ u_strToWCS(wchar_t *dest, if(pErrorCode==NULL || U_FAILURE(*pErrorCode)){ return NULL; } - + if( (src==NULL && srcLength!=0) || srcLength < -1 || (destCapacity<0) || (dest == NULL && destCapacity > 0) ) { *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - + #ifdef U_WCHAR_IS_UTF16 /* wchar_t is UTF-16 just do a memcpy */ if(srcLength == -1){ @@ -265,23 +265,23 @@ u_strToWCS(wchar_t *dest, return dest; #elif defined U_WCHAR_IS_UTF32 - + return (wchar_t*)u_strToUTF32((UChar32*)dest, destCapacity, pDestLength, src, srcLength, pErrorCode); #else - + return _strToWCS(dest,destCapacity,pDestLength,src,srcLength, pErrorCode); - + #endif } #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) /* helper function */ -static UChar* +static UChar* _strFromWCS( UChar *dest, - int32_t destCapacity, + int32_t destCapacity, int32_t *pDestLength, const wchar_t *src, int32_t srcLength, @@ -292,7 +292,7 @@ _strFromWCS( UChar *dest, UChar* pTarget = NULL; UChar* pTargetLimit = NULL; UChar* target = NULL; - + UChar uStack [_STACK_BUFFER_CAPACITY]; wchar_t wStack[_STACK_BUFFER_CAPACITY]; @@ -316,7 +316,7 @@ _strFromWCS( UChar *dest, for(;;){ /* convert wchars to chars */ retVal = uprv_wcstombs(pCSrc,src, cStackCap); - + if(retVal == -1){ *pErrorCode = U_ILLEGAL_CHAR_FOUND; goto cleanup; @@ -331,14 +331,14 @@ _strFromWCS( UChar *dest, break; } } - + }else{ - /* here the source is not null terminated + /* here the source is not null terminated * so it may have nulls embeded and we need to - * do some extra processing + * do some extra processing */ int32_t remaining =cStackCap; - + pSrcLimit = src + srcLength; for(;;){ @@ -363,7 +363,7 @@ _strFromWCS( UChar *dest, remaining = cStackCap-(pCSrc - pCSave); } - /* we have found a null so convert the + /* we have found a null so convert the * chunk from begining of non-null char to null */ retVal = uprv_wcstombs(pCSrc,pSrc,remaining); @@ -382,7 +382,7 @@ _strFromWCS( UChar *dest, }else{ - /* the source is not null terminated and we are + /* the source is not null terminated and we are * end of source so we copy the source to a temp buffer * null terminate it and convert wchar_ts to chars */ @@ -399,10 +399,10 @@ _strFromWCS( UChar *dest, /* copy the contents to tempStack */ uprv_memcpy(pWStack, pSrc, (size_t)nulLen*sizeof(wchar_t)); } - + /* null terminate the tempBuffer */ pWStack[nulLen] =0 ; - + if(remaining < (nulLen * MB_CUR_MAX)){ /* Should rarely occur */ int32_t len = (pCSrc-pCSave); @@ -417,7 +417,7 @@ _strFromWCS( UChar *dest, } /* convert to chars */ retVal = uprv_wcstombs(pCSrc,pWStack,remaining); - + pCSrc += retVal; pSrc += nulLen; srcLength-=nulLen; /* decrement the srcLength */ @@ -426,30 +426,30 @@ _strFromWCS( UChar *dest, } } - /* OK..now we have converted from wchar_ts to chars now - * convert chars to UChars + /* OK..now we have converted from wchar_ts to chars now + * convert chars to UChars */ pCSrcLimit = pCSrc; pCSrc = pCSave; pTarget = target= dest; - pTargetLimit = dest + destCapacity; - + pTargetLimit = dest + destCapacity; + conv= u_getDefaultConverter(pErrorCode); - + if(U_FAILURE(*pErrorCode)|| conv==NULL){ goto cleanup; } - + for(;;) { - + *pErrorCode = U_ZERO_ERROR; - + /* convert to stack buffer*/ ucnv_toUnicode(conv,&pTarget,pTargetLimit,(const char**)&pCSrc,pCSrcLimit,NULL,(UBool)(pCSrc==pCSrcLimit),pErrorCode); - + /* increment count to number written to stack */ count+= pTarget - target; - + if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR){ target = uStack; pTarget = uStack; @@ -457,17 +457,17 @@ _strFromWCS( UChar *dest, } else { break; } - + } - + if(pDestLength){ *pDestLength =count; } u_terminateUChars(dest,destCapacity,count,pErrorCode); - + cleanup: - + if(cStack != pCSave){ uprv_free(pCSave); } @@ -475,7 +475,7 @@ _strFromWCS( UChar *dest, if(wStack != pWStack){ uprv_free(pWStack); } - + u_releaseDefaultConverter(conv); return dest; @@ -484,7 +484,7 @@ _strFromWCS( UChar *dest, U_CAPI UChar* U_EXPORT2 u_strFromWCS(UChar *dest, - int32_t destCapacity, + int32_t destCapacity, int32_t *pDestLength, const wchar_t *src, int32_t srcLength, @@ -520,13 +520,13 @@ u_strFromWCS(UChar *dest, return dest; #elif defined U_WCHAR_IS_UTF32 - + return u_strFromUTF32(dest, destCapacity, pDestLength, (UChar32*)src, srcLength, pErrorCode); #else - return _strFromWCS(dest,destCapacity,pDestLength,src,srcLength,pErrorCode); + return _strFromWCS(dest,destCapacity,pDestLength,src,srcLength,pErrorCode); #endif diff --git a/deps/icu-small/source/common/ustrenum.cpp b/deps/icu-small/source/common/ustrenum.cpp index 8be79c98999256..ed23eaa232ec48 100644 --- a/deps/icu-small/source/common/ustrenum.cpp +++ b/deps/icu-small/source/common/ustrenum.cpp @@ -10,7 +10,7 @@ * Since: ICU 2.4 ********************************************************************** */ -#include "utypeinfo.h" // for 'typeid' to work +#include "utypeinfo.h" // for 'typeid' to work #include "unicode/ustring.h" #include "unicode/strenum.h" @@ -120,9 +120,9 @@ StringEnumeration::setChars(const char *s, int32_t length, UErrorCode &status) { return NULL; } -UBool +UBool StringEnumeration::operator==(const StringEnumeration& that)const { - return typeid(*this) == typeid(that); + return typeid(*this) == typeid(that); } UBool @@ -260,7 +260,7 @@ U_CDECL_END * delete it (regardless of error status). */ U_CAPI UEnumeration* U_EXPORT2 -uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec) { +uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec) { UEnumeration* result = NULL; if (U_SUCCESS(*ec) && adopted != NULL) { result = (UEnumeration*) uprv_malloc(sizeof(UEnumeration)); diff --git a/deps/icu-small/source/common/ustrenum.h b/deps/icu-small/source/common/ustrenum.h index 582727cd1f742b..a82162e2bde014 100644 --- a/deps/icu-small/source/common/ustrenum.h +++ b/deps/icu-small/source/common/ustrenum.h @@ -84,3 +84,4 @@ class U_COMMON_API UStringEnumeration : public StringEnumeration { U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/common/ustring.cpp b/deps/icu-small/source/common/ustring.cpp index a1a51f4b1e1734..67cb4544b9a80f 100644 --- a/deps/icu-small/source/common/ustring.cpp +++ b/deps/icu-small/source/common/ustring.cpp @@ -575,7 +575,7 @@ u_strspn(const UChar *string, const UChar *matchSet) /* ----- Text manipulation functions --- */ U_CAPI UChar* U_EXPORT2 -u_strtok_r(UChar *src, +u_strtok_r(UChar *src, const UChar *delim, UChar **saveState) { @@ -625,7 +625,7 @@ u_strtok_r(UChar *src, /* Miscellaneous functions -------------------------------------------------- */ U_CAPI UChar* U_EXPORT2 -u_strcat(UChar *dst, +u_strcat(UChar *dst, const UChar *src) { UChar *anchor = dst; /* save a pointer to start of dst */ @@ -640,9 +640,9 @@ u_strcat(UChar *dst, } U_CAPI UChar* U_EXPORT2 -u_strncat(UChar *dst, - const UChar *src, - int32_t n ) +u_strncat(UChar *dst, + const UChar *src, + int32_t n ) { if(n > 0) { UChar *anchor = dst; /* save a pointer to start of dst */ @@ -668,8 +668,8 @@ u_strncat(UChar *dst, /* ----- Text property functions --- */ U_CAPI int32_t U_EXPORT2 -u_strcmp(const UChar *s1, - const UChar *s2) +u_strcmp(const UChar *s1, + const UChar *s2) { UChar c1, c2; @@ -939,9 +939,9 @@ u_strcmpCodePointOrder(const UChar *s1, const UChar *s2) { } U_CAPI int32_t U_EXPORT2 -u_strncmp(const UChar *s1, - const UChar *s2, - int32_t n) +u_strncmp(const UChar *s1, + const UChar *s2, + int32_t n) { if(n > 0) { int32_t rc; @@ -964,8 +964,8 @@ u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n) { } U_CAPI UChar* U_EXPORT2 -u_strcpy(UChar *dst, - const UChar *src) +u_strcpy(UChar *dst, + const UChar *src) { UChar *anchor = dst; /* save a pointer to start of dst */ @@ -976,9 +976,9 @@ u_strcpy(UChar *dst, } U_CAPI UChar* U_EXPORT2 -u_strncpy(UChar *dst, - const UChar *src, - int32_t n) +u_strncpy(UChar *dst, + const UChar *src, + int32_t n) { UChar *anchor = dst; /* save a pointer to start of dst */ @@ -991,7 +991,7 @@ u_strncpy(UChar *dst, } U_CAPI int32_t U_EXPORT2 -u_strlen(const UChar *s) +u_strlen(const UChar *s) { #if U_SIZEOF_WCHAR_T == U_SIZEOF_UCHAR return (int32_t)uprv_wcslen((const wchar_t *)s); @@ -1221,7 +1221,7 @@ u_unescapeAt(UNESCAPE_CHAR_AT charAt, int8_t n = 0; int8_t minDig = 0; int8_t maxDig = 0; - int8_t bitsPerDigit = 4; + int8_t bitsPerDigit = 4; int8_t dig; int32_t i; UBool braces = FALSE; @@ -1428,7 +1428,7 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { * NUL-terminate a string no matter what its type. * Set warning and error codes accordingly. */ -#define __TERMINATE_STRING(dest, destCapacity, length, pErrorCode) \ +#define __TERMINATE_STRING(dest, destCapacity, length, pErrorCode) UPRV_BLOCK_MACRO_BEGIN { \ if(pErrorCode!=NULL && U_SUCCESS(*pErrorCode)) { \ /* not a public function, so no complete argument checking */ \ \ @@ -1448,7 +1448,8 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { /* even the string itself did not fit - set an error code */ \ *pErrorCode=U_BUFFER_OVERFLOW_ERROR; \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END U_CAPI int32_t U_EXPORT2 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode) { @@ -1488,7 +1489,7 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod the output range. [LIU] */ -#define STRING_HASH(TYPE, STR, STRLEN, DEREF) \ +#define STRING_HASH(TYPE, STR, STRLEN, DEREF) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t hash = 0; \ const TYPE *p = (const TYPE*) STR; \ if (p != NULL) { \ @@ -1500,7 +1501,8 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod p += inc; \ } \ } \ - return static_cast(hash) + return static_cast(hash); \ +} UPRV_BLOCK_MACRO_END /* Used by UnicodeString to compute its hashcode - Not public API. */ U_CAPI int32_t U_EXPORT2 diff --git a/deps/icu-small/source/common/ustrtrns.cpp b/deps/icu-small/source/common/ustrtrns.cpp index 583ec63c323aee..5dc032c02fb807 100644 --- a/deps/icu-small/source/common/ustrtrns.cpp +++ b/deps/icu-small/source/common/ustrtrns.cpp @@ -36,7 +36,7 @@ #include "ustr_imp.h" #include "uassert.h" -U_CAPI UChar* U_EXPORT2 +U_CAPI UChar* U_EXPORT2 u_strFromUTF32WithSub(UChar *dest, int32_t destCapacity, int32_t *pDestLength, @@ -132,13 +132,13 @@ u_strFromUTF32WithSub(UChar *dest, /* Terminate the buffer */ u_terminateUChars(dest, destCapacity, reqLength, pErrorCode); - + return dest; } -U_CAPI UChar* U_EXPORT2 +U_CAPI UChar* U_EXPORT2 u_strFromUTF32(UChar *dest, - int32_t destCapacity, + int32_t destCapacity, int32_t *pDestLength, const UChar32 *src, int32_t srcLength, @@ -150,7 +150,7 @@ u_strFromUTF32(UChar *dest, pErrorCode); } -U_CAPI UChar32* U_EXPORT2 +U_CAPI UChar32* U_EXPORT2 u_strToUTF32WithSub(UChar32 *dest, int32_t destCapacity, int32_t *pDestLength, @@ -242,11 +242,11 @@ u_strToUTF32WithSub(UChar32 *dest, return dest; } -U_CAPI UChar32* U_EXPORT2 -u_strToUTF32(UChar32 *dest, +U_CAPI UChar32* U_EXPORT2 +u_strToUTF32(UChar32 *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode) { return u_strToUTF32WithSub( @@ -566,7 +566,7 @@ u_strFromUTF8Lenient(UChar *dest, if(U_FAILURE(*pErrorCode)){ return NULL; } - + if( (src==NULL && srcLength!=0) || srcLength < -1 || (destCapacity<0) || (dest == NULL && destCapacity > 0) ) { @@ -788,8 +788,8 @@ _appendUTF8(uint8_t *pDest, UChar32 c) { return pDest; } - -U_CAPI char* U_EXPORT2 + +U_CAPI char* U_EXPORT2 u_strToUTF8WithSub(char *dest, int32_t destCapacity, int32_t *pDestLength, @@ -807,7 +807,7 @@ u_strToUTF8WithSub(char *dest, if(U_FAILURE(*pErrorCode)){ return NULL; } - + if( (pSrc==NULL && srcLength!=0) || srcLength < -1 || (destCapacity<0) || (dest == NULL && destCapacity > 0) || subchar > 0x10ffff || U_IS_SURROGATE(subchar) @@ -852,7 +852,7 @@ u_strToUTF8WithSub(char *dest, int32_t length; /*need not check for NUL because NUL fails U16_IS_TRAIL() anyway*/ - if(U16_IS_SURROGATE_LEAD(ch) && U16_IS_TRAIL(ch2=*pSrc)) { + if(U16_IS_SURROGATE_LEAD(ch) && U16_IS_TRAIL(ch2=*pSrc)) { ++pSrc; ch=U16_GET_SUPPLEMENTARY(ch, ch2); } else if(subchar>=0) { @@ -939,7 +939,7 @@ u_strToUTF8WithSub(char *dest, break; /* recompute count */ } - if(U16_IS_SURROGATE_LEAD(ch) && U16_IS_TRAIL(ch2=*pSrc)) { + if(U16_IS_SURROGATE_LEAD(ch) && U16_IS_TRAIL(ch2=*pSrc)) { ++pSrc; ch=U16_GET_SUPPLEMENTARY(ch, ch2); @@ -994,7 +994,7 @@ u_strToUTF8WithSub(char *dest, } else /* ch is a surrogate */ { int32_t length; - if(U16_IS_SURROGATE_LEAD(ch) && pSrc=0) { @@ -1053,7 +1053,7 @@ u_strToUTF8WithSub(char *dest, return dest; } -U_CAPI char* U_EXPORT2 +U_CAPI char* U_EXPORT2 u_strToUTF8(char *dest, int32_t destCapacity, int32_t *pDestLength, @@ -1309,12 +1309,12 @@ u_strFromJavaModifiedUTF8WithSub( return dest; } -U_CAPI char* U_EXPORT2 +U_CAPI char* U_EXPORT2 u_strToJavaModifiedUTF8( char *dest, int32_t destCapacity, int32_t *pDestLength, - const UChar *src, + const UChar *src, int32_t srcLength, UErrorCode *pErrorCode) { int32_t reqLength=0; diff --git a/deps/icu-small/source/common/utext.cpp b/deps/icu-small/source/common/utext.cpp index 5e3a005626e6b8..9a77228cfc6d18 100644 --- a/deps/icu-small/source/common/utext.cpp +++ b/deps/icu-small/source/common/utext.cpp @@ -567,7 +567,7 @@ enum { struct ExtendedUText { UText ut; - UAlignedMemory extension; + max_align_t extension; }; static const UText emptyText = UTEXT_INITIALIZER; @@ -582,7 +582,7 @@ utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status) { // We need to heap-allocate storage for the new UText int32_t spaceRequired = sizeof(UText); if (extraSpace > 0) { - spaceRequired = sizeof(ExtendedUText) + extraSpace - sizeof(UAlignedMemory); + spaceRequired = sizeof(ExtendedUText) + extraSpace - sizeof(max_align_t); } ut = (UText *)uprv_malloc(spaceRequired); if (ut == NULL) { @@ -1302,7 +1302,7 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) { // If index is at the end, there is no character there to look at. if (ix != ut->b) { // Note: this function will only move the index back if it is on a trail byte - // and there is a preceding lead byte and the sequence from the lead + // and there is a preceding lead byte and the sequence from the lead // through this trail could be part of a valid UTF-8 sequence // Otherwise the index remains unchanged. U8_SET_CP_START(s8, 0, ix); diff --git a/deps/icu-small/source/common/util.cpp b/deps/icu-small/source/common/util.cpp index 838a201a73d803..86e5c791bad98e 100644 --- a/deps/icu-small/source/common/util.cpp +++ b/deps/icu-small/source/common/util.cpp @@ -169,7 +169,7 @@ int32_t ICU_Utility::skipWhitespace(const UnicodeString& str, int32_t& pos, //? if (!isForward) { //? --pos; // pos is a limit, so back up by one //? } -//? +//? //? while (pos != stop && //? PatternProps::isWhiteSpace(c = text.char32At(pos))) { //? if (isForward) { @@ -276,6 +276,16 @@ int32_t ICU_Utility::parsePattern(const UnicodeString& pat, return -1; // text ended before end of pat } +int32_t ICU_Utility::parseAsciiInteger(const UnicodeString& str, int32_t& pos) { + int32_t result = 0; + UChar c; + while (pos < str.length() && (c = str.charAt(pos)) >= u'0' && c <= u'9') { + result = result * 10 + (c - u'0'); + pos++; + } + return result; +} + /** * Append a character to a rule that is being built up. To flush * the quoteBuf to rule, make one final call with isLiteral == TRUE. @@ -376,7 +386,7 @@ void ICU_Utility::appendToRule(UnicodeString& rule, quoteBuf.append(c); } } - + // Otherwise just append else { rule.append(c); diff --git a/deps/icu-small/source/common/util.h b/deps/icu-small/source/common/util.h index 92cdc9ef69a58a..f3f71dce458e6c 100644 --- a/deps/icu-small/source/common/util.h +++ b/deps/icu-small/source/common/util.h @@ -153,7 +153,7 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s */ static int32_t parsePattern(const UnicodeString& rule, int32_t pos, int32_t limit, const UnicodeString& pattern, int32_t* parsedInts); - + /** * Parse a pattern string within the given Replaceable and a parsing * pattern. Characters are matched literally and case-sensitively @@ -179,12 +179,21 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s * Parse an integer at pos, either of the form \d+ or of the form * 0x[0-9A-Fa-f]+ or 0[0-7]+, that is, in standard decimal, hex, * or octal format. - * @param pos INPUT-OUTPUT parameter. On input, the first - * character to parse. On output, the character after the last - * parsed character. + * @param pos INPUT-OUTPUT parameter. On input, the index of the first + * character to parse. On output, the index of the character after the + * last parsed character. */ static int32_t parseInteger(const UnicodeString& rule, int32_t& pos, int32_t limit); + /** + * Parse an integer at pos using only ASCII digits. + * Base 10 only. + * @param pos INPUT-OUTPUT parameter. On input, the index of the first + * character to parse. On output, the index of the character after the + * last parsed character. + */ + static int32_t parseAsciiInteger(const UnicodeString& str, int32_t& pos); + /** * Parse a Unicode identifier from the given string at the given * position. Return the identifier, or an empty string if there @@ -225,7 +234,7 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s UBool isLiteral, UBool escapeUnprintable, UnicodeString& quoteBuf); - + static void appendToRule(UnicodeString& rule, const UnicodeString& text, UBool isLiteral, diff --git a/deps/icu-small/source/common/util_props.cpp b/deps/icu-small/source/common/util_props.cpp index 36057a6066db94..95a112bc9122c3 100644 --- a/deps/icu-small/source/common/util_props.cpp +++ b/deps/icu-small/source/common/util_props.cpp @@ -214,3 +214,4 @@ int32_t ICU_Utility::parseNumber(const UnicodeString& text, } U_NAMESPACE_END + diff --git a/deps/icu-small/source/common/utrace.cpp b/deps/icu-small/source/common/utrace.cpp index 01bdb38e907518..c981546594706c 100644 --- a/deps/icu-small/source/common/utrace.cpp +++ b/deps/icu-small/source/common/utrace.cpp @@ -75,14 +75,14 @@ utrace_exit(int32_t fnNumber, int32_t returnType, ...) { va_end(args); } } + - - -U_CAPI void U_EXPORT2 + +U_CAPI void U_EXPORT2 utrace_data(int32_t fnNumber, int32_t level, const char *fmt, ...) { if (pTraceDataFunc != NULL) { va_list args; - va_start(args, fmt ); + va_start(args, fmt ); (*pTraceDataFunc)(gTraceContext, fnNumber, level, fmt, args); va_end(args); } @@ -146,7 +146,7 @@ static void outputPtrBytes(void *val, char *outBuf, int32_t *outIx, int32_t capa p += sizeof(void *) - 1; #endif - /* Loop through the bytes of the ptr as it sits in memory, from + /* Loop through the bytes of the ptr as it sits in memory, from * most significant to least significant end */ for (i=0; i 0) { outputHexBytes(longArg, charsToOutput, outBuf, &outIx, capacity); @@ -386,7 +386,7 @@ utrace_format(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, ...) { int32_t retVal; va_list args; - va_start(args, fmt ); + va_start(args, fmt ); retVal = utrace_vformat(outBuf, capacity, indent, fmt, args); va_end(args); return retVal; @@ -429,7 +429,7 @@ utrace_getLevel() { } -U_CFUNC UBool +U_CFUNC UBool utrace_cleanup() { pTraceEntryFunc = NULL; pTraceExitFunc = NULL; @@ -461,7 +461,7 @@ trConvNames[] = { NULL }; - + static const char * const trCollNames[] = { "ucol_open", @@ -477,6 +477,16 @@ trCollNames[] = { }; +static const char* const +trResDataNames[] = { + "resc", + "bundle-open", + "file-open", + "res-open", + NULL +}; + + U_CAPI const char * U_EXPORT2 utrace_functionName(int32_t fnNumber) { if(UTRACE_FUNCTION_START <= fnNumber && fnNumber < UTRACE_FUNCTION_LIMIT) { @@ -485,7 +495,10 @@ utrace_functionName(int32_t fnNumber) { return trConvNames[fnNumber - UTRACE_CONVERSION_START]; } else if(UTRACE_COLLATION_START <= fnNumber && fnNumber < UTRACE_COLLATION_LIMIT){ return trCollNames[fnNumber - UTRACE_COLLATION_START]; + } else if(UTRACE_UDATA_START <= fnNumber && fnNumber < UTRACE_RES_DATA_LIMIT){ + return trResDataNames[fnNumber - UTRACE_UDATA_START]; } else { return "[BOGUS Trace Function Number]"; } } + diff --git a/deps/icu-small/source/common/utracimp.h b/deps/icu-small/source/common/utracimp.h index c2819830e1ba52..f32fe1db394824 100644 --- a/deps/icu-small/source/common/utracimp.h +++ b/deps/icu-small/source/common/utracimp.h @@ -47,8 +47,8 @@ U_CDECL_BEGIN -/** - * Traced Function Exit return types. +/** + * Traced Function Exit return types. * Flags indicating the number and types of varargs included in a call * to a UTraceExit function. * Bits 0-3: The function return type. First variable param. @@ -117,15 +117,15 @@ U_CDECL_END #define UTRACE_LEVEL(level) (utrace_getLevel()>=(level)) /** - * Flag bit in utraceFnNumber, the local variable added to each function + * Flag bit in utraceFnNumber, the local variable added to each function * with tracing code to contains the function number. * * Set the flag if the function's entry is traced, which will cause the - * function's exit to also be traced. utraceFnNumber is uncoditionally + * function's exit to also be traced. utraceFnNumber is uncoditionally * set at entry, whether or not the entry is traced, so that it will * always be available for error trace output. * @internal - */ + */ #define UTRACE_TRACED_ENTRY 0x80000000 /** @@ -144,10 +144,12 @@ U_CDECL_END */ #define UTRACE_ENTRY(fnNumber) \ int32_t utraceFnNumber=(fnNumber); \ +UPRV_BLOCK_MACRO_BEGIN { \ if(utrace_getLevel()>=UTRACE_INFO) { \ utrace_entry(fnNumber); \ utraceFnNumber |= UTRACE_TRACED_ENTRY; \ - } + } \ +} UPRV_BLOCK_MACRO_END /** @@ -162,10 +164,12 @@ U_CDECL_END */ #define UTRACE_ENTRY_OC(fnNumber) \ int32_t utraceFnNumber=(fnNumber); \ +UPRV_BLOCK_MACRO_BEGIN { \ if(utrace_getLevel()>=UTRACE_OPEN_CLOSE) { \ utrace_entry(fnNumber); \ utraceFnNumber |= UTRACE_TRACED_ENTRY; \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement for each exit point of a function that has a UTRACE_ENTRY() @@ -179,10 +183,11 @@ U_CDECL_END * * @internal */ -#define UTRACE_EXIT() \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT() UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_NONE); \ - }} + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement for each exit point of a function that has a UTRACE_ENTRY() @@ -190,27 +195,31 @@ U_CDECL_END * * @param val The function's return value, int32_t or comatible type. * - * @internal + * @internal */ -#define UTRACE_EXIT_VALUE(val) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_VALUE(val) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_I32, val); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_STATUS(status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_STATUS(status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_STATUS, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_VALUE_STATUS(val, status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_VALUE_STATUS(val, status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_I32 | UTRACE_EXITV_STATUS), val, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_PTR_STATUS(ptr, status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_PTR_STATUS(ptr, status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_PTR | UTRACE_EXITV_STATUS), ptr, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -220,10 +229,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA0(level, fmt) \ +#define UTRACE_DATA0(level, fmt) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -233,10 +243,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA1(level, fmt, a) \ +#define UTRACE_DATA1(level, fmt, a) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -246,10 +257,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA2(level, fmt, a, b) \ +#define UTRACE_DATA2(level, fmt, a, b) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a), (b)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -259,10 +271,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA3(level, fmt, a, b, c) \ +#define UTRACE_DATA3(level, fmt, a, b, c) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -272,10 +285,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA4(level, fmt, a, b, c, d) \ +#define UTRACE_DATA4(level, fmt, a, b, c, d) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -285,10 +299,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA5(level, fmt, a, b, c, d, e) \ +#define UTRACE_DATA5(level, fmt, a, b, c, d, e) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -298,10 +313,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f) \ +#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -311,10 +327,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g) \ +#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -324,10 +341,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h) \ +#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -337,10 +355,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i) \ +#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h), (i)); \ - } + } \ +} UPRV_BLOCK_MACRO_END #else diff --git a/deps/icu-small/source/common/utrie.h b/deps/icu-small/source/common/utrie.h index 3e2197eda6c261..532ba778eb6ed1 100644 --- a/deps/icu-small/source/common/utrie.h +++ b/deps/icu-small/source/common/utrie.h @@ -182,7 +182,7 @@ typedef struct UTrie UTrie; ] /** Internal trie getter from a pair of surrogates */ -#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) { \ +#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __offset; \ \ /* get data for lead surrogate */ \ @@ -195,18 +195,18 @@ typedef struct UTrie UTrie; } else { \ (result)=(resultType)((trie)->initialValue); \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal trie getter from a BMP code point, treating a lead surrogate as a normal code point */ #define _UTRIE_GET_FROM_BMP(trie, data, c16) \ - _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16); + _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16) /** * Internal trie getter from a code point. * Could be faster(?) but longer with * if((c32)<=0xd7ff) { (result)=_UTRIE_GET_RAW(trie, data, 0, c32); } */ -#define _UTRIE_GET(trie, data, c32, result, resultType) \ +#define _UTRIE_GET(trie, data, c32, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c32)<=0xffff) { \ /* BMP code points */ \ (result)=_UTRIE_GET_FROM_BMP(trie, data, c32); \ @@ -217,10 +217,11 @@ typedef struct UTrie UTrie; } else { \ /* out of range */ \ (result)=(resultType)((trie)->initialValue); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** Internal next-post-increment: get the next code point (c, c2) and its data */ -#define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) { \ +#define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ (c)=*(src)++; \ if(!U16_IS_LEAD(c)) { \ (c2)=0; \ @@ -233,10 +234,10 @@ typedef struct UTrie UTrie; (c2)=0; \ (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal previous: get the previous code point (c, c2) and its data */ -#define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) { \ +#define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ (c)=*--(src); \ if(!U16_IS_SURROGATE(c)) { \ (c2)=0; \ @@ -257,7 +258,7 @@ typedef struct UTrie UTrie; (c2)=0; \ (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /* Public UTrie API ---------------------------------------------------------*/ diff --git a/deps/icu-small/source/common/utrie2.h b/deps/icu-small/source/common/utrie2.h index 75028ee23ac1e9..671f44e16a65cc 100644 --- a/deps/icu-small/source/common/utrie2.h +++ b/deps/icu-small/source/common/utrie2.h @@ -871,7 +871,7 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)] /** Internal next-post-increment: get the next code point (c) and its data. */ -#define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) { \ +#define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) UPRV_BLOCK_MACRO_BEGIN { \ { \ uint16_t __c2; \ (c)=*(src)++; \ @@ -885,10 +885,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal pre-decrement-previous: get the previous code point (c) and its data */ -#define _UTRIE2_U16_PREV(trie, data, start, src, c, result) { \ +#define _UTRIE2_U16_PREV(trie, data, start, src, c, result) UPRV_BLOCK_MACRO_BEGIN { \ { \ uint16_t __c2; \ (c)=*--(src); \ @@ -900,10 +900,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal UTF-8 next-post-increment: get the next code point's data. */ -#define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) { \ +#define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __lead=(uint8_t)*(src)++; \ if(U8_IS_SINGLE(__lead)) { \ (result)=(trie)->ascii[__lead]; \ @@ -935,10 +935,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=(trie)->data[__index>>3]; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal UTF-8 pre-decrement-previous: get the previous code point's data. */ -#define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) { \ +#define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __b=(uint8_t)*--(src); \ if(U8_IS_SINGLE(__b)) { \ (result)=(trie)->ascii[__b]; \ @@ -948,7 +948,7 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (src)-=__index&7; \ (result)=(trie)->data[__index>>3]; \ } \ -} +} UPRV_BLOCK_MACRO_END U_CDECL_END diff --git a/deps/icu-small/source/common/uvector.cpp b/deps/icu-small/source/common/uvector.cpp index ad3a813e3706ac..cf19edf646fb0a 100644 --- a/deps/icu-small/source/common/uvector.cpp +++ b/deps/icu-small/source/common/uvector.cpp @@ -26,7 +26,7 @@ U_NAMESPACE_BEGIN */ #define HINT_KEY_POINTER (1) #define HINT_KEY_INTEGER (0) - + UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UVector) UVector::UVector(UErrorCode &status) : @@ -335,17 +335,17 @@ UBool UVector::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) { } if (capacity < minimumCapacity) { if (capacity > (INT32_MAX - 1) / 2) { // integer overflow check - status = U_ILLEGAL_ARGUMENT_ERROR; - return FALSE; + status = U_ILLEGAL_ARGUMENT_ERROR; + return FALSE; } int32_t newCap = capacity * 2; if (newCap < minimumCapacity) { newCap = minimumCapacity; } if (newCap > (int32_t)(INT32_MAX / sizeof(UElement))) { // integer overflow check - // We keep the original memory contents on bad minimumCapacity. - status = U_ILLEGAL_ARGUMENT_ERROR; - return FALSE; + // We keep the original memory contents on bad minimumCapacity. + status = U_ILLEGAL_ARGUMENT_ERROR; + return FALSE; } UElement* newElems = (UElement *)uprv_realloc(elements, sizeof(UElement)*newCap); if (newElems == NULL) { @@ -492,7 +492,7 @@ void UVector::sortedInsert(UElement e, UElementComparator *compare, UErrorCode& * * The context pointer to this function is a pointer back * (with some extra indirection) to the user supplied comparator. - * + * */ static int32_t U_CALLCONV sortComparator(const void *context, const void *left, const void *right) { @@ -564,3 +564,4 @@ void UVector::sortWithUComparator(UComparator *compare, const void *context, UEr } U_NAMESPACE_END + diff --git a/deps/icu-small/source/common/uvector.h b/deps/icu-small/source/common/uvector.h index a7625cd01ac59a..98318d14c60063 100644 --- a/deps/icu-small/source/common/uvector.h +++ b/deps/icu-small/source/common/uvector.h @@ -135,7 +135,7 @@ class U_COMMON_API UVector : public UObject { void insertElementAt(void* obj, int32_t index, UErrorCode &status); void insertElementAt(int32_t elem, int32_t index, UErrorCode &status); - + void* elementAt(int32_t index) const; int32_t elementAti(int32_t index) const; @@ -314,11 +314,11 @@ class U_COMMON_API UStack : public UVector { inline void* peek(void) const; inline int32_t peeki(void) const; - + void* pop(void); - + int32_t popi(void); - + inline void* push(void* obj, UErrorCode &status); inline int32_t push(int32_t i, UErrorCode &status); diff --git a/deps/icu-small/source/common/uvectr32.cpp b/deps/icu-small/source/common/uvectr32.cpp index 6e0760d7184040..d1ae6599585086 100644 --- a/deps/icu-small/source/common/uvectr32.cpp +++ b/deps/icu-small/source/common/uvectr32.cpp @@ -23,7 +23,7 @@ U_NAMESPACE_BEGIN * or a pointer. If a hint bit is zero, then the associated * token is assumed to be an integer. This is needed for iSeries */ - + UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UVector32) UVector32::UVector32(UErrorCode &status) : @@ -253,7 +253,7 @@ void UVector32::setMaxCapacity(int32_t limit) { // Current capacity is within the new limit. return; } - + // New maximum capacity is smaller than the current size. // Realloc the storage to the new, smaller size. int32_t* newElems = (int32_t *)uprv_realloc(elements, sizeof(int32_t)*maxCapacity); @@ -288,7 +288,7 @@ void UVector32::setSize(int32_t newSize) { for (i=count; i immutableBucketList(createBucketList(errorCode)); - LocalPointer coll( - static_cast(collatorPrimaryOnly_->clone())); + LocalPointer coll(collatorPrimaryOnly_->clone()); if (immutableBucketList.isNull() || coll.isNull()) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; @@ -907,7 +906,7 @@ void AlphabeticIndex::init(const Locale *locale, UErrorCode &status) { return; } } - collatorPrimaryOnly_ = static_cast(collator_->clone()); + collatorPrimaryOnly_ = collator_->clone(); if (collatorPrimaryOnly_ == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return; @@ -958,7 +957,7 @@ collatorComparator(const void *context, const void *left, const void *right) { } if (leftString == NULL) { return 1; - }; + } if (rightString == NULL) { return -1; } @@ -1083,7 +1082,7 @@ AlphabeticIndex & AlphabeticIndex::addRecord(const UnicodeString &name, const vo clearBuckets(); //std::string ss; //std::string ss2; - //std::cout << "added record: name = \"" << r->name_.toUTF8String(ss) << "\"" << + //std::cout << "added record: name = \"" << r->name_.toUTF8String(ss) << "\"" << // " sortingName = \"" << r->sortingName_.toUTF8String(ss2) << "\"" << std::endl; return *this; } diff --git a/deps/icu-small/source/i18n/anytrans.cpp b/deps/icu-small/source/i18n/anytrans.cpp index 6e382b824b95b7..167b0185285371 100644 --- a/deps/icu-small/source/i18n/anytrans.cpp +++ b/deps/icu-small/source/i18n/anytrans.cpp @@ -226,7 +226,7 @@ AnyTransliterator::AnyTransliterator(const AnyTransliterator& o) : /** * Transliterator API. */ -Transliterator* AnyTransliterator::clone() const { +AnyTransliterator* AnyTransliterator::clone() const { return new AnyTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/anytrans.h b/deps/icu-small/source/i18n/anytrans.h index 703d42b6d4be55..627dee3c814e68 100644 --- a/deps/icu-small/source/i18n/anytrans.h +++ b/deps/icu-small/source/i18n/anytrans.h @@ -66,7 +66,7 @@ class AnyTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual AnyTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/astro.cpp b/deps/icu-small/source/i18n/astro.cpp index 0d521b037dd772..f17b6db91288d1 100644 --- a/deps/icu-small/source/i18n/astro.cpp +++ b/deps/icu-small/source/i18n/astro.cpp @@ -21,7 +21,7 @@ #include "putilimp.h" #include // for toString() -#if defined (PI) +#if defined (PI) #undef PI #endif @@ -65,10 +65,7 @@ static inline UBool isINVALID(double d) { return(uprv_isNaN(d)); } -static icu::UMutex *ccLock() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex ccLock; U_CDECL_BEGIN static UBool calendar_astro_cleanup(void) { @@ -1552,12 +1549,12 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu if(U_FAILURE(status)) { return 0; } - umtx_lock(ccLock()); + umtx_lock(&ccLock); if(*cache == NULL) { createCache(cache, status); if(U_FAILURE(status)) { - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return 0; } } @@ -1565,7 +1562,7 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu res = uhash_igeti((*cache)->fTable, key); U_DEBUG_ASTRO_MSG(("%p: GET: [%d] == %d\n", (*cache)->fTable, key, res)); - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return res; } @@ -1573,12 +1570,12 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro if(U_FAILURE(status)) { return; } - umtx_lock(ccLock()); + umtx_lock(&ccLock); if(*cache == NULL) { createCache(cache, status); if(U_FAILURE(status)) { - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return; } } @@ -1586,7 +1583,7 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro uhash_iputi((*cache)->fTable, key, value, &status); U_DEBUG_ASTRO_MSG(("%p: PUT: [%d] := %d\n", (*cache)->fTable, key, value)); - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); } CalendarCache::CalendarCache(int32_t size, UErrorCode &status) { diff --git a/deps/icu-small/source/i18n/basictz.cpp b/deps/icu-small/source/i18n/basictz.cpp index 6cd93f4d3c2c83..54ee5a1a2bff96 100644 --- a/deps/icu-small/source/i18n/basictz.cpp +++ b/deps/icu-small/source/i18n/basictz.cpp @@ -63,7 +63,7 @@ BasicTimeZone::hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UD } else { if (raw1 != raw2 || dst1 != dst2) { return FALSE; - } + } } // Check transitions in the range UDate time = start; @@ -159,7 +159,7 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial, if (((tr.getFrom()->getDSTSavings() == 0 && tr.getTo()->getDSTSavings() != 0) || (tr.getFrom()->getDSTSavings() != 0 && tr.getTo()->getDSTSavings() == 0)) && (date + MILLIS_PER_YEAR > nextTransitionTime)) { - + int32_t year, month, dom, dow, doy, mid; UDate d; @@ -375,13 +375,13 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UDate updatedTime = tzt.getTime(); if (updatedTime == time) { // Can get here if rules for start & end of daylight time have exactly - // the same time. + // the same time. // TODO: fix getNextTransition() to prevent it? status = U_INVALID_STATE_ERROR; goto error; } time = updatedTime; - + const TimeZoneRule *toRule = tzt.getTo(); for (i = 0; i < ruleCount; i++) { r = (TimeZoneRule*)orgRules->elementAt(i); diff --git a/deps/icu-small/source/i18n/bocsu.h b/deps/icu-small/source/i18n/bocsu.h index 6b8ed5197097fd..631e29aa768b9d 100644 --- a/deps/icu-small/source/i18n/bocsu.h +++ b/deps/icu-small/source/i18n/bocsu.h @@ -144,14 +144,14 @@ U_NAMESPACE_END * yields negative modulo results and quotients that are one more than * what we need here. */ -#define NEGDIVMOD(n, d, m) { \ +#define NEGDIVMOD(n, d, m) UPRV_BLOCK_MACRO_BEGIN { \ (m)=(n)%(d); \ (n)/=(d); \ if((m)<0) { \ --(n); \ (m)+=(d); \ } \ -} +} UPRV_BLOCK_MACRO_END U_CFUNC UChar32 u_writeIdenticalLevelRun(UChar32 prev, const UChar *s, int32_t length, icu::ByteSink &sink); diff --git a/deps/icu-small/source/i18n/brktrans.cpp b/deps/icu-small/source/i18n/brktrans.cpp index ac9e2afb7e4679..46b0e345dae97d 100644 --- a/deps/icu-small/source/i18n/brktrans.cpp +++ b/deps/icu-small/source/i18n/brktrans.cpp @@ -64,7 +64,7 @@ BreakTransliterator::BreakTransliterator(const BreakTransliterator& o) : /** * Transliterator API. */ -Transliterator* BreakTransliterator::clone(void) const { +BreakTransliterator* BreakTransliterator::clone() const { return new BreakTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/brktrans.h b/deps/icu-small/source/i18n/brktrans.h index fcc8bdd002ca76..cb3def9e926e79 100644 --- a/deps/icu-small/source/i18n/brktrans.h +++ b/deps/icu-small/source/i18n/brktrans.h @@ -28,7 +28,7 @@ class UVector32; /** * A transliterator that pInserts the specified characters at word breaks. * To restrict it to particular characters, use a filter. - * TODO: this is an internal class, and only temporary. + * TODO: this is an internal class, and only temporary. * Remove it once we have \b notation in Transliterator. */ class BreakTransliterator : public Transliterator { @@ -54,7 +54,7 @@ class BreakTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual BreakTransliterator* clone() const; virtual const UnicodeString &getInsertion() const; diff --git a/deps/icu-small/source/i18n/buddhcal.cpp b/deps/icu-small/source/i18n/buddhcal.cpp index b6ccbc4749955a..6083349ecd623a 100644 --- a/deps/icu-small/source/i18n/buddhcal.cpp +++ b/deps/icu-small/source/i18n/buddhcal.cpp @@ -53,7 +53,7 @@ BuddhistCalendar& BuddhistCalendar::operator= ( const BuddhistCalendar& right) return *this; } -Calendar* BuddhistCalendar::clone(void) const +BuddhistCalendar* BuddhistCalendar::clone() const { return new BuddhistCalendar(*this); } @@ -71,7 +71,7 @@ int32_t BuddhistCalendar::handleGetExtendedYear() if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) { year = internalGet(UCAL_EXTENDED_YEAR, kGregorianEpoch); } else { - // extended year is a gregorian year, where 1 = 1AD, 0 = 1BC, -1 = 2BC, etc + // extended year is a gregorian year, where 1 = 1AD, 0 = 1BC, -1 = 2BC, etc year = internalGet(UCAL_YEAR, kGregorianEpoch - kBuddhistEraStart) + kBuddhistEraStart; } @@ -133,7 +133,7 @@ void BuddhistCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& stat */ static UDate gSystemDefaultCenturyStart = DBL_MIN; static int32_t gSystemDefaultCenturyStartYear = -1; -static icu::UInitOnce gBCInitOnce; +static icu::UInitOnce gBCInitOnce = U_INITONCE_INITIALIZER; UBool BuddhistCalendar::haveDefaultCentury() const @@ -170,7 +170,7 @@ UDate BuddhistCalendar::defaultCenturyStart() const int32_t BuddhistCalendar::defaultCenturyStartYear() const { - // lazy-evaluate systemDefaultCenturyStartYear and systemDefaultCenturyStart + // lazy-evaluate systemDefaultCenturyStartYear and systemDefaultCenturyStart umtx_initOnce(gBCInitOnce, &initializeSystemDefaultCentury); return gSystemDefaultCenturyStartYear; } diff --git a/deps/icu-small/source/i18n/buddhcal.h b/deps/icu-small/source/i18n/buddhcal.h index 89e3f3dec36625..0ad0886df120e8 100644 --- a/deps/icu-small/source/i18n/buddhcal.h +++ b/deps/icu-small/source/i18n/buddhcal.h @@ -94,7 +94,7 @@ class BuddhistCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual BuddhistCalendar* clone() const; public: /** @@ -145,7 +145,7 @@ class BuddhistCalendar : public GregorianCalendar { virtual int32_t handleGetExtendedYear(); /** * Subclasses may override this method to compute several fields - * specific to each calendar system. + * specific to each calendar system. * @internal */ virtual void handleComputeFields(int32_t julianDay, UErrorCode& status); @@ -199,3 +199,4 @@ U_NAMESPACE_END #endif // _GREGOCAL //eof + diff --git a/deps/icu-small/source/i18n/calendar.cpp b/deps/icu-small/source/i18n/calendar.cpp index 85a387ef49ed16..c043bb31861ad8 100644 --- a/deps/icu-small/source/i18n/calendar.cpp +++ b/deps/icu-small/source/i18n/calendar.cpp @@ -268,6 +268,8 @@ static ECalType getCalendarTypeForLocale(const char *locid) { // canonicalize, so grandfathered variant will be transformed to keywords // e.g ja_JP_TRADITIONAL -> ja_JP@calendar=japanese + // NOTE: Since ICU-20187, ja_JP_TRADITIONAL no longer canonicalizes, and + // the Gregorian calendar is returned instead. int32_t canonicalLen = uloc_canonicalize(locid, canonicalName, sizeof(canonicalName) - 1, &status); if (U_FAILURE(status)) { return CALTYPE_GREGORIAN; @@ -748,6 +750,7 @@ fSkippedWallTime(UCAL_WALLTIME_LAST) validLocale[0] = 0; actualLocale[0] = 0; if (U_FAILURE(success)) { + delete zone; return; } if(zone == 0) { @@ -1164,8 +1167,8 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) { if(isLenient()) { millis = MIN_MILLIS; } else { - status = U_ILLEGAL_ARGUMENT_ERROR; - return; + status = U_ILLEGAL_ARGUMENT_ERROR; + return; } } @@ -2592,7 +2595,7 @@ Calendar::isWeekend(UDate date, UErrorCode &status) const return FALSE; } // clone the calendar so we don't mess with the real one. - Calendar *work = (Calendar*)this->clone(); + Calendar *work = this->clone(); if (work == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return FALSE; @@ -2752,7 +2755,7 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const // clone the calendar so we don't mess with the real one, and set it to // accept anything for the field values - Calendar *work = (Calendar*)this->clone(); + Calendar *work = this->clone(); if (work == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return 0; diff --git a/deps/icu-small/source/i18n/casetrn.cpp b/deps/icu-small/source/i18n/casetrn.cpp index f08d448881d364..bb650f8fa29e17 100644 --- a/deps/icu-small/source/i18n/casetrn.cpp +++ b/deps/icu-small/source/i18n/casetrn.cpp @@ -90,7 +90,7 @@ UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(CaseMapTransliterator) /** * Constructs a transliterator. */ -CaseMapTransliterator::CaseMapTransliterator(const UnicodeString &id, UCaseMapFull *map) : +CaseMapTransliterator::CaseMapTransliterator(const UnicodeString &id, UCaseMapFull *map) : Transliterator(id, 0), fMap(map) { @@ -125,7 +125,7 @@ CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) : /** * Transliterator API. */ -/*Transliterator* CaseMapTransliterator::clone(void) const { +/*CaseMapTransliterator* CaseMapTransliterator::clone() const { return new CaseMapTransliterator(*this); }*/ @@ -133,7 +133,7 @@ CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) : * Implements {@link Transliterator#handleTransliterate}. */ void CaseMapTransliterator::handleTransliterate(Replaceable& text, - UTransPosition& offsets, + UTransPosition& offsets, UBool isIncremental) const { if (offsets.start >= offsets.limit) { diff --git a/deps/icu-small/source/i18n/casetrn.h b/deps/icu-small/source/i18n/casetrn.h index eee443fc81d4e6..2ec3e736deb845 100644 --- a/deps/icu-small/source/i18n/casetrn.h +++ b/deps/icu-small/source/i18n/casetrn.h @@ -58,7 +58,7 @@ class CaseMapTransliterator : public Transliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const = 0; + virtual CaseMapTransliterator* clone() const = 0; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. @@ -81,7 +81,7 @@ class CaseMapTransliterator : public Transliterator { * pos.contextLimit. Otherwise, assume the text is complete. */ virtual void handleTransliterate(Replaceable& text, - UTransPosition& offsets, + UTransPosition& offsets, UBool isIncremental) const; UCaseMapFull *fMap; diff --git a/deps/icu-small/source/i18n/cecal.cpp b/deps/icu-small/source/i18n/cecal.cpp index 458fe2f3049b9d..00faa8ac07a0f8 100644 --- a/deps/icu-small/source/i18n/cecal.cpp +++ b/deps/icu-small/source/i18n/cecal.cpp @@ -54,7 +54,7 @@ CECalendar::CECalendar(const Locale& aLocale, UErrorCode& success) setTimeInMillis(getNow(), success); } -CECalendar::CECalendar (const CECalendar& other) +CECalendar::CECalendar (const CECalendar& other) : Calendar(other) { } diff --git a/deps/icu-small/source/i18n/chnsecal.cpp b/deps/icu-small/source/i18n/chnsecal.cpp index 3c4ad2a846619f..4c03812715927d 100644 --- a/deps/icu-small/source/i18n/chnsecal.cpp +++ b/deps/icu-small/source/i18n/chnsecal.cpp @@ -51,10 +51,7 @@ static void debug_chnsecal_msg(const char *pat, ...) // --- The cache -- -static icu::UMutex *astroLock() { // Protects access to gChineseCalendarAstro. - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex astroLock; static icu::CalendarAstronomer *gChineseCalendarAstro = NULL; // Lazy Creation & Access synchronized by class CalendarCache with a mutex. @@ -121,7 +118,7 @@ U_NAMESPACE_BEGIN //------------------------------------------------------------------------- -Calendar* ChineseCalendar::clone() const { +ChineseCalendar* ChineseCalendar::clone() const { return new ChineseCalendar(*this); } @@ -154,7 +151,7 @@ ChineseCalendar::~ChineseCalendar() { } -const char *ChineseCalendar::getType() const { +const char *ChineseCalendar::getType() const { return "chinese"; } @@ -258,7 +255,7 @@ int32_t ChineseCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont *
  2. DAY_OF_MONTH *
  3. DAY_OF_YEAR *
  4. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -313,7 +310,7 @@ const UFieldResolutionTable* ChineseCalendar::getFieldResolutionTable() const { /** * Return the Julian day number of day before the first day of the * given month in the given extended year. - * + * *

    Note: This method reads the IS_LEAP_MONTH field to determine * whether the given month is a leap month. * @param eyear the extended year @@ -338,7 +335,7 @@ int32_t ChineseCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U int32_t gyear = eyear + fEpochYear - 1; // Gregorian year int32_t theNewYear = newYear(gyear); int32_t newMoon = newMoonNear(theNewYear + month * 29, TRUE); - + int32_t julianDay = newMoon + kEpochStartAsJulianDay; // Save fields for later restoration @@ -352,10 +349,10 @@ int32_t ChineseCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U nonConstThis->computeGregorianFields(julianDay, status); if (U_FAILURE(status)) return 0; - + // This will modify the MONTH and IS_LEAP_MONTH fields (only) nonConstThis->computeChineseFields(newMoon, getGregorianYear(), - getGregorianMonth(), FALSE); + getGregorianMonth(), FALSE); if (month != internalGet(UCAL_MONTH) || isLeapMonth != internalGet(UCAL_IS_LEAP_MONTH)) { @@ -382,7 +379,7 @@ void ChineseCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& if (U_FAILURE(status)) break; int32_t day = get(UCAL_JULIAN_DAY, status) - kEpochStartAsJulianDay; // Get local day if (U_FAILURE(status)) break; - int32_t moon = day - dom + 1; // New moon + int32_t moon = day - dom + 1; // New moon offsetMonth(moon, dom, amount); } break; @@ -473,13 +470,13 @@ void ChineseCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status /** * Convert local days to UTC epoch milliseconds. - * This is not an accurate conversion in that getTimezoneOffset - * takes the milliseconds in GMT (not local time). In theory, more - * accurate algorithm can be implemented but practically we do not need - * to go through that complication as long as the historical timezone - * changes did not happen around the 'tricky' new moon (new moon around - * midnight). - * + * This is not an accurate conversion in that getTimezoneOffset + * takes the milliseconds in GMT (not local time). In theory, more + * accurate algorithm can be implemented but practically we do not need + * to go through that complication as long as the historical timezone + * changes did not happen around the 'tricky' new moon (new moon around + * midnight). + * * @param days days after January 1, 1970 0:00 in the astronomical base zone * @return milliseconds after January 1, 1970 0:00 GMT */ @@ -490,7 +487,7 @@ double ChineseCalendar::daysToMillis(double days) const { UErrorCode status = U_ZERO_ERROR; fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status); if (U_SUCCESS(status)) { - return millis - (double)(rawOffset + dstOffset); + return millis - (double)(rawOffset + dstOffset); } } return millis - (double)CHINA_OFFSET; @@ -507,7 +504,7 @@ double ChineseCalendar::millisToDays(double millis) const { UErrorCode status = U_ZERO_ERROR; fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status); if (U_SUCCESS(status)) { - return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay); + return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay); } } return ClockMath::floorDivide(millis + (double)CHINA_OFFSET, kOneDay); @@ -538,14 +535,14 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const { // PST 1298 with a final result of Dec 14 10:31:59 PST 1299. double ms = daysToMillis(Grego::fieldsToDay(gyear, UCAL_DECEMBER, 1)); - umtx_lock(astroLock()); + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(ms); UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), TRUE); - umtx_unlock(astroLock()); + umtx_unlock(&astroLock); // Winter solstice is 270 degrees solar longitude aka Dongzhi cacheValue = (int32_t)millisToDays(solarLong); @@ -567,16 +564,16 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const { * new moon after or before days */ int32_t ChineseCalendar::newMoonNear(double days, UBool after) const { - - umtx_lock(astroLock()); + + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(daysToMillis(days)); UDate newMoon = gChineseCalendarAstro->getMoonTime(CalendarAstronomer::NEW_MOON(), after); - umtx_unlock(astroLock()); - + umtx_unlock(&astroLock); + return (int32_t) millisToDays(newMoon); } @@ -599,15 +596,15 @@ int32_t ChineseCalendar::synodicMonthsBetween(int32_t day1, int32_t day2) const * @param days days after January 1, 1970 0:00 Asia/Shanghai */ int32_t ChineseCalendar::majorSolarTerm(int32_t days) const { - - umtx_lock(astroLock()); + + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(daysToMillis(days)); UDate solarLongitude = gChineseCalendarAstro->getSunLongitude(); - umtx_unlock(astroLock()); + umtx_unlock(&astroLock); // Compute (floor(solarLongitude / (pi/6)) + 2) % 12 int32_t term = ( ((int32_t)(6 * solarLongitude / CalendarAstronomer::PI)) + 2 ) % 12; @@ -716,7 +713,7 @@ void ChineseCalendar::computeChineseFields(int32_t days, int32_t gyear, int32_t if (setAllFields) { // Extended year and cycle year is based on the epoch year - + int32_t extended_year = gyear - fEpochYear; int cycle_year = gyear - CHINESE_EPOCH_YEAR; if (month < 11 || @@ -770,7 +767,7 @@ int32_t ChineseCalendar::newYear(int32_t gyear) const { int32_t newMoon1 = newMoonNear(solsticeBefore + 1, TRUE); int32_t newMoon2 = newMoonNear(newMoon1 + SYNODIC_GAP, TRUE); int32_t newMoon11 = newMoonNear(solsticeAfter + 1, FALSE); - + if (synodicMonthsBetween(newMoon1, newMoon11) == 12 && (hasNoMajorSolarTerm(newMoon1) || hasNoMajorSolarTerm(newMoon2))) { cacheValue = newMoonNear(newMoon2 + SYNODIC_GAP, TRUE); @@ -833,7 +830,7 @@ UBool ChineseCalendar::inDaylightTime(UErrorCode& status) const { // copied from GregorianCalendar - if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) + if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) return FALSE; // Force an update of the state of the Calendar. @@ -902,3 +899,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ChineseCalendar) U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/chnsecal.h b/deps/icu-small/source/i18n/chnsecal.h index 1b27d2d1bcc78b..a0c21b6b5c2f86 100644 --- a/deps/icu-small/source/i18n/chnsecal.h +++ b/deps/icu-small/source/i18n/chnsecal.h @@ -71,10 +71,10 @@ U_NAMESPACE_BEGIN * obtain a formatter for this calendar. * *

    References:

      - * + * *
    • Dershowitz and Reingold, Calendrical Calculations, * Cambridge University Press, 1997
    • - * + * *
    • Helmer Aslaksen's * * Chinese Calendar page
    • @@ -87,7 +87,7 @@ U_NAMESPACE_BEGIN *

      * This class should only be subclassed to implement variants of the Chinese lunar calendar.

      *

      - * ChineseCalendar usually should be instantiated using + * ChineseCalendar usually should be instantiated using * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a ULocale * with the tag "@calendar=chinese".

      * @@ -114,7 +114,7 @@ class U_I18N_API ChineseCalendar : public Calendar { ChineseCalendar(const Locale& aLocale, UErrorCode &success); protected: - + /** * Constructs a ChineseCalendar based on the current time in the default time zone * with the given locale, using the specified epoch year and time zone for @@ -144,14 +144,14 @@ class U_I18N_API ChineseCalendar : public Calendar { virtual ~ChineseCalendar(); // clone - virtual Calendar* clone() const; + virtual ChineseCalendar* clone() const; private: //------------------------------------------------------------------------- // Internal data.... //------------------------------------------------------------------------- - + UBool isLeapYear; int32_t fEpochYear; // Start year of this Chinese calendar instance. const TimeZone* fZoneAstroCalc; // Zone used for the astronomical calculation @@ -198,7 +198,7 @@ class U_I18N_API ChineseCalendar : public Calendar { const TimeZone* getChineseCalZoneAstroCalc(void) const; // UObject stuff - public: + public: /** * @return The class ID for this object. All objects of a given class have the * same class ID. Objects of other classes have different class IDs. @@ -263,13 +263,13 @@ class U_I18N_API ChineseCalendar : public Calendar { private: // default century stuff. /** - * Returns the beginning date of the 100-year window that dates + * Returns the beginning date of the 100-year window that dates * with 2-digit years are considered to fall within. */ UDate internalGetDefaultCenturyStart(void) const; /** - * Returns the first year of the 100-year window that dates with + * Returns the first year of the 100-year window that dates with * 2-digit years are considered to fall within. */ int32_t internalGetDefaultCenturyStartYear(void) const; diff --git a/deps/icu-small/source/i18n/choicfmt.cpp b/deps/icu-small/source/i18n/choicfmt.cpp index 1b846704bfe1e4..7e26bb7a1f6d97 100644 --- a/deps/icu-small/source/i18n/choicfmt.cpp +++ b/deps/icu-small/source/i18n/choicfmt.cpp @@ -12,11 +12,11 @@ * * Date Name Description * 02/19/97 aliu Converted from java. -* 03/20/97 helena Finished first cut of implementation and got rid +* 03/20/97 helena Finished first cut of implementation and got rid * of nextDouble/previousDouble and replaced with * boolean array. * 4/10/97 aliu Clean up. Modified to work on AIX. -* 06/04/97 helena Fixed applyPattern(), toPattern() and not to include +* 06/04/97 helena Fixed applyPattern(), toPattern() and not to include * wchar.h. * 07/09/97 helena Made ParsePosition into a class. * 08/06/97 nos removed overloaded constructor, fixed 'format(array)' @@ -83,11 +83,11 @@ ChoiceFormat::ChoiceFormat(const UnicodeString& newPattern, } // ------------------------------------- -// Creates a ChoiceFormat instance with the limit array and +// Creates a ChoiceFormat instance with the limit array and // format strings for each limit. -ChoiceFormat::ChoiceFormat(const double* limits, - const UnicodeString* formats, +ChoiceFormat::ChoiceFormat(const double* limits, + const UnicodeString* formats, int32_t cnt ) : constructorErrorCode(U_ZERO_ERROR), msgPattern(constructorErrorCode) @@ -97,9 +97,9 @@ ChoiceFormat::ChoiceFormat(const double* limits, // ------------------------------------- -ChoiceFormat::ChoiceFormat(const double* limits, +ChoiceFormat::ChoiceFormat(const double* limits, const UBool* closures, - const UnicodeString* formats, + const UnicodeString* formats, int32_t cnt ) : constructorErrorCode(U_ZERO_ERROR), msgPattern(constructorErrorCode) @@ -110,7 +110,7 @@ ChoiceFormat::ChoiceFormat(const double* limits, // ------------------------------------- // copy constructor -ChoiceFormat::ChoiceFormat(const ChoiceFormat& that) +ChoiceFormat::ChoiceFormat(const ChoiceFormat& that) : NumberFormat(that), constructorErrorCode(that.constructorErrorCode), msgPattern(that.msgPattern) @@ -118,8 +118,8 @@ ChoiceFormat::ChoiceFormat(const ChoiceFormat& that) } // ------------------------------------- -// Private constructor that creates a -// ChoiceFormat instance based on the +// Private constructor that creates a +// ChoiceFormat instance based on the // pattern and populates UParseError ChoiceFormat::ChoiceFormat(const UnicodeString& newPattern, @@ -250,10 +250,10 @@ ChoiceFormat::toPattern(UnicodeString& result) const } // ------------------------------------- -// Sets the limit and format arrays. +// Sets the limit and format arrays. void -ChoiceFormat::setChoices( const double* limits, - const UnicodeString* formats, +ChoiceFormat::setChoices( const double* limits, + const UnicodeString* formats, int32_t cnt ) { UErrorCode errorCode = U_ZERO_ERROR; @@ -261,11 +261,11 @@ ChoiceFormat::setChoices( const double* limits, } // ------------------------------------- -// Sets the limit and format arrays. +// Sets the limit and format arrays. void -ChoiceFormat::setChoices( const double* limits, +ChoiceFormat::setChoices( const double* limits, const UBool* closures, - const UnicodeString* formats, + const UnicodeString* formats, int32_t cnt ) { UErrorCode errorCode = U_ZERO_ERROR; @@ -344,7 +344,7 @@ ChoiceFormat::setChoices(const double* limits, // Gets the limit array. const double* -ChoiceFormat::getLimits(int32_t& cnt) const +ChoiceFormat::getLimits(int32_t& cnt) const { cnt = 0; return NULL; @@ -354,7 +354,7 @@ ChoiceFormat::getLimits(int32_t& cnt) const // Gets the closures array. const UBool* -ChoiceFormat::getClosures(int32_t& cnt) const +ChoiceFormat::getClosures(int32_t& cnt) const { cnt = 0; return NULL; @@ -376,8 +376,8 @@ ChoiceFormat::getFormats(int32_t& cnt) const // from the input number because of this. UnicodeString& -ChoiceFormat::format(int64_t number, - UnicodeString& appendTo, +ChoiceFormat::format(int64_t number, + UnicodeString& appendTo, FieldPosition& status) const { return format((double) number, appendTo, status); @@ -388,8 +388,8 @@ ChoiceFormat::format(int64_t number, // a double. UnicodeString& -ChoiceFormat::format(int32_t number, - UnicodeString& appendTo, +ChoiceFormat::format(int32_t number, + UnicodeString& appendTo, FieldPosition& status) const { return format((double) number, appendTo, status); @@ -399,8 +399,8 @@ ChoiceFormat::format(int32_t number, // Formats a double number. UnicodeString& -ChoiceFormat::format(double number, - UnicodeString& appendTo, +ChoiceFormat::format(double number, + UnicodeString& appendTo, FieldPosition& /*pos*/) const { if (msgPattern.countParts() == 0) { @@ -464,7 +464,7 @@ ChoiceFormat::findSubMessage(const MessagePattern &pattern, int32_t partIndex, d // ------------------------------------- // Formats an array of objects. Checks if the data type of the objects -// to get the right value for formatting. +// to get the right value for formatting. UnicodeString& ChoiceFormat::format(const Formattable* objs, @@ -495,7 +495,7 @@ ChoiceFormat::format(const Formattable* objs, // ------------------------------------- void -ChoiceFormat::parse(const UnicodeString& text, +ChoiceFormat::parse(const UnicodeString& text, Formattable& result, ParsePosition& pos) const { @@ -563,7 +563,7 @@ ChoiceFormat::matchStringUntilLimitPart( // ------------------------------------- -Format* +ChoiceFormat* ChoiceFormat::clone() const { ChoiceFormat *aCopy = new ChoiceFormat(*this); diff --git a/deps/icu-small/source/i18n/coleitr.cpp b/deps/icu-small/source/i18n/coleitr.cpp index 40fe149830fe8a..64d3ab4d2bfe73 100644 --- a/deps/icu-small/source/i18n/coleitr.cpp +++ b/deps/icu-small/source/i18n/coleitr.cpp @@ -20,7 +20,7 @@ * 08/03/98 erm Synched with 1.2 version of CollationElementIterator.java * 12/10/99 aliu Ported Thai collation support from Java. * 01/25/01 swquek Modified to a C++ wrapper calling C APIs (ucoliter.h) -* 02/19/01 swquek Removed CollationElementIterator() since it is +* 02/19/01 swquek Removed CollationElementIterator() since it is * private constructor and no calls are made to it * 2012-2014 markus Rewritten in C++ again. */ @@ -53,7 +53,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CollationElementIterator) /* CollationElementIterator public constructor/destructor ------------------ */ CollationElementIterator::CollationElementIterator( - const CollationElementIterator& other) + const CollationElementIterator& other) : UObject(other), iter_(NULL), rbc_(NULL), otherHalf_(0), dir_(0), offsets_(NULL) { *this = other; } @@ -98,7 +98,7 @@ int32_t CollationElementIterator::getOffset() const /** * Get the ordering priority of the next character in the string. -* @return the next character's ordering. Returns NULLORDER if an error has +* @return the next character's ordering. Returns NULLORDER if an error has * occured or if the end of string has been reached */ int32_t CollationElementIterator::next(UErrorCode& status) @@ -161,7 +161,7 @@ UBool CollationElementIterator::operator==( /** * Get the ordering priority of the previous collation element in the string. * @param status the error code status. -* @return the previous element's ordering. Returns NULLORDER if an error has +* @return the previous element's ordering. Returns NULLORDER if an error has * occured or if the start of string has been reached. */ int32_t CollationElementIterator::previous(UErrorCode& status) @@ -227,7 +227,7 @@ void CollationElementIterator::reset() dir_ = 0; } -void CollationElementIterator::setOffset(int32_t newOffset, +void CollationElementIterator::setOffset(int32_t newOffset, UErrorCode& status) { if (U_FAILURE(status)) { return; } @@ -297,10 +297,10 @@ void CollationElementIterator::setText(const UnicodeString& source, } // Sets the source to the new character iterator. -void CollationElementIterator::setText(CharacterIterator& source, +void CollationElementIterator::setText(CharacterIterator& source, UErrorCode& status) { - if (U_FAILURE(status)) + if (U_FAILURE(status)) return; source.getText(string_); @@ -323,7 +323,7 @@ int32_t CollationElementIterator::strengthOrder(int32_t order) const /* CollationElementIterator private constructors/destructors --------------- */ -/** +/** * This is the "real" constructor for this class; it constructs an iterator * over the source text using the specified collator */ @@ -335,8 +335,8 @@ CollationElementIterator::CollationElementIterator( setText(source, status); } -/** -* This is the "real" constructor for this class; it constructs an iterator over +/** +* This is the "real" constructor for this class; it constructs an iterator over * the source text using the specified collator */ CollationElementIterator::CollationElementIterator( diff --git a/deps/icu-small/source/i18n/coll.cpp b/deps/icu-small/source/i18n/coll.cpp index 8bbe133664c2cd..7b87b41dff24ec 100644 --- a/deps/icu-small/source/i18n/coll.cpp +++ b/deps/icu-small/source/i18n/coll.cpp @@ -33,14 +33,14 @@ * 05/06/97 helena Added memory allocation error detection. * 05/08/97 helena Added createInstance(). * 6/20/97 helena Java class name change. - * 04/23/99 stephen Removed EDecompositionMode, merged with + * 04/23/99 stephen Removed EDecompositionMode, merged with * Normalizer::EMode * 11/23/9 srl Inlining of some critical functions * 01/29/01 synwee Modified into a C++ wrapper calling C APIs (ucol.h) * 2012-2014 markus Rewritten in C++ again. */ -#include "utypeinfo.h" // for 'typeid' to work +#include "utypeinfo.h" // for 'typeid' to work #include "unicode/utypes.h" @@ -67,7 +67,7 @@ static int32_t availableLocaleListCount; static icu::ICULocaleService* gService = NULL; static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER; #endif -static icu::UInitOnce gAvailableLocaleListInitOnce; +static icu::UInitOnce gAvailableLocaleListInitOnce = U_INITONCE_INITIALIZER; /** * Release all static memory held by collator. @@ -114,8 +114,8 @@ CollatorFactory::visible(void) const { //------------------------------------------- -UnicodeString& -CollatorFactory::getDisplayName(const Locale& objectLocale, +UnicodeString& +CollatorFactory::getDisplayName(const Locale& objectLocale, const Locale& displayLocale, UnicodeString& result) { @@ -143,7 +143,7 @@ ICUCollatorFactory::create(const ICUServiceKey& key, const ICUService* /* servic // default LocaleFactory uses currentLocale since that's the one vetted by handlesKey // but for ICU rb resources we use the actual one since it will fallback again lkey.canonicalLocale(loc); - + return Collator::makeInstance(loc, status); } return NULL; @@ -165,7 +165,7 @@ class ICUCollatorService : public ICULocaleService { virtual UObject* cloneInstance(UObject* instance) const { return ((Collator*)instance)->clone(); } - + virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* actualID, UErrorCode& status) const { LocaleKey& lkey = (LocaleKey&)key; if (actualID) { @@ -178,7 +178,7 @@ class ICUCollatorService : public ICULocaleService { lkey.canonicalLocale(loc); return Collator::makeInstance(loc, status); } - + virtual UObject* getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const { UnicodeString ar; if (actualReturn == NULL) { @@ -202,7 +202,7 @@ static void U_CALLCONV initService() { } -static ICULocaleService* +static ICULocaleService* getService(void) { umtx_initOnce(gServiceInitOnce, &initService); @@ -212,7 +212,7 @@ getService(void) // ------------------------------------- static inline UBool -hasService(void) +hasService(void) { UBool retVal = !gServiceInitOnce.isReset() && (getService() != NULL); return retVal; @@ -220,7 +220,7 @@ hasService(void) #endif /* UCONFIG_NO_SERVICE */ -static void U_CALLCONV +static void U_CALLCONV initAvailableLocaleList(UErrorCode &status) { U_ASSERT(availableLocaleListCount == 0); U_ASSERT(availableLocaleList == NULL); @@ -228,14 +228,14 @@ initAvailableLocaleList(UErrorCode &status) { UResourceBundle *index = NULL; StackUResourceBundle installed; int32_t i = 0; - + index = ures_openDirect(U_ICUDATA_COLL, "res_index", &status); ures_getByKey(index, "InstalledLocales", installed.getAlias(), &status); if(U_SUCCESS(status)) { availableLocaleListCount = ures_getSize(installed.getAlias()); availableLocaleList = new Locale[availableLocaleListCount]; - + if (availableLocaleList != NULL) { ures_resetIterator(installed.getAlias()); while(ures_hasNext(installed.getAlias())) { @@ -421,7 +421,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er } // namespace -Collator* U_EXPORT2 Collator::createInstance(UErrorCode& success) +Collator* U_EXPORT2 Collator::createInstance(UErrorCode& success) { return createInstance(Locale::getDefault(), success); } @@ -429,7 +429,7 @@ Collator* U_EXPORT2 Collator::createInstance(UErrorCode& success) Collator* U_EXPORT2 Collator::createInstance(const Locale& desiredLocale, UErrorCode& status) { - if (U_FAILURE(status)) + if (U_FAILURE(status)) return 0; if (desiredLocale.isBogus()) { // Locale constructed from malformed locale ID or language tag. @@ -488,7 +488,7 @@ Collator::safeClone() const { } // implement deprecated, previously abstract method -Collator::EComparisonResult Collator::compare(const UnicodeString& source, +Collator::EComparisonResult Collator::compare(const UnicodeString& source, const UnicodeString& target) const { UErrorCode ec = U_ZERO_ERROR; @@ -506,7 +506,7 @@ Collator::EComparisonResult Collator::compare(const UnicodeString& source, // implement deprecated, previously abstract method Collator::EComparisonResult Collator::compare(const UChar* source, int32_t sourceLength, - const UChar* target, int32_t targetLength) + const UChar* target, int32_t targetLength) const { UErrorCode ec = U_ZERO_ERROR; @@ -535,21 +535,21 @@ UCollationResult Collator::compareUTF8(const StringPiece &source, return compare(sIter, tIter, status); } -UBool Collator::equals(const UnicodeString& source, +UBool Collator::equals(const UnicodeString& source, const UnicodeString& target) const { UErrorCode ec = U_ZERO_ERROR; return (compare(source, target, ec) == UCOL_EQUAL); } -UBool Collator::greaterOrEqual(const UnicodeString& source, +UBool Collator::greaterOrEqual(const UnicodeString& source, const UnicodeString& target) const { UErrorCode ec = U_ZERO_ERROR; return (compare(source, target, ec) != UCOL_LESS); } -UBool Collator::greater(const UnicodeString& source, +UBool Collator::greater(const UnicodeString& source, const UnicodeString& target) const { UErrorCode ec = U_ZERO_ERROR; @@ -558,7 +558,7 @@ UBool Collator::greater(const UnicodeString& source, // this API ignores registered collators, since it returns an // array of indefinite lifetime -const Locale* U_EXPORT2 Collator::getAvailableLocales(int32_t& count) +const Locale* U_EXPORT2 Collator::getAvailableLocales(int32_t& count) { UErrorCode status = U_ZERO_ERROR; Locale *result = NULL; @@ -587,7 +587,7 @@ UnicodeString& U_EXPORT2 Collator::getDisplayName(const Locale& objectLocale, UnicodeString& U_EXPORT2 Collator::getDisplayName(const Locale& objectLocale, UnicodeString& name) -{ +{ return getDisplayName(objectLocale, Locale::getDefault(), name); } @@ -616,7 +616,7 @@ Collator::Collator() * Constructor. * Empty constructor, does not handle the arguments. * This constructor is done for backward compatibility with 1.7 and 1.8. -* The task for handling the argument collation strength and normalization +* The task for handling the argument collation strength and normalization * mode is left to the child class. * @param collationStrength collation strength * @param decompositionMode @@ -675,7 +675,7 @@ UnicodeSet *Collator::getTailoredSet(UErrorCode &status) const #if !UCONFIG_NO_SERVICE URegistryKey U_EXPORT2 -Collator::registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status) +Collator::registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status) { if (U_SUCCESS(status)) { // Set the collator locales while registering so that createInstance() @@ -693,9 +693,9 @@ class CFactory : public LocaleKeyFactory { private: CollatorFactory* _delegate; Hashtable* _ids; - + public: - CFactory(CollatorFactory* delegate, UErrorCode& status) + CFactory(CollatorFactory* delegate, UErrorCode& status) : LocaleKeyFactory(delegate->visible() ? VISIBLE : INVISIBLE) , _delegate(delegate) , _ids(NULL) @@ -722,7 +722,7 @@ class CFactory : public LocaleKeyFactory { virtual ~CFactory(); virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const; - + protected: virtual const Hashtable* getSupportedIDs(UErrorCode& status) const { @@ -731,7 +731,7 @@ class CFactory : public LocaleKeyFactory { } return NULL; } - + virtual UnicodeString& getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeString& result) const; }; @@ -742,7 +742,7 @@ CFactory::~CFactory() delete _ids; } -UObject* +UObject* CFactory::create(const ICUServiceKey& key, const ICUService* /* service */, UErrorCode& status) const { if (handlesKey(key, status)) { @@ -755,7 +755,7 @@ CFactory::create(const ICUServiceKey& key, const ICUService* /* service */, UErr } UnicodeString& -CFactory::getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeString& result) const +CFactory::getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeString& result) const { if ((_coverage & 0x1) == 0) { UErrorCode status = U_ZERO_ERROR; @@ -786,7 +786,7 @@ Collator::registerFactory(CollatorFactory* toAdopt, UErrorCode& status) // ------------------------------------- UBool U_EXPORT2 -Collator::unregister(URegistryKey key, UErrorCode& status) +Collator::unregister(URegistryKey key, UErrorCode& status) { if (U_SUCCESS(status)) { if (hasService()) { diff --git a/deps/icu-small/source/i18n/collationdatabuilder.cpp b/deps/icu-small/source/i18n/collationdatabuilder.cpp index fdd264f8aaa65a..53361b86c7c707 100644 --- a/deps/icu-small/source/i18n/collationdatabuilder.cpp +++ b/deps/icu-small/source/i18n/collationdatabuilder.cpp @@ -502,7 +502,7 @@ CollationDataBuilder::addCE32(uint32_t ce32, UErrorCode &errorCode) { for(int32_t i = 0; i < length; ++i) { if(ce32 == (uint32_t)ce32s.elementAti(i)) { return i; } } - ce32s.addElement((int32_t)ce32, errorCode); + ce32s.addElement((int32_t)ce32, errorCode); return length; } diff --git a/deps/icu-small/source/i18n/collationiterator.cpp b/deps/icu-small/source/i18n/collationiterator.cpp index 961c9e9acef675..18ccf014f0a48c 100644 --- a/deps/icu-small/source/i18n/collationiterator.cpp +++ b/deps/icu-small/source/i18n/collationiterator.cpp @@ -872,7 +872,7 @@ CollationIterator::previousCE(UVector32 &offsets, UErrorCode &errorCode) { // consistent with forward iteration. while(offsets.size() <= ceBuffer.length) { offsets.addElement(limitOffset, errorCode); - }; + } } return ceBuffer.get(--ceBuffer.length); } else { @@ -932,7 +932,7 @@ CollationIterator::previousCEUnsafe(UChar32 c, UVector32 &offsets, UErrorCode &e offset = getOffset(); while(offsets.size() < ceBuffer.length) { offsets.addElement(offset, errorCode); - }; + } } U_ASSERT(offsets.size() == ceBuffer.length); // End offset corresponding to just after the unsafe-backwards segment. diff --git a/deps/icu-small/source/i18n/collationweights.cpp b/deps/icu-small/source/i18n/collationweights.cpp index aec0037861a36f..05458962c6d959 100644 --- a/deps/icu-small/source/i18n/collationweights.cpp +++ b/deps/icu-small/source/i18n/collationweights.cpp @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ******************************************************************************* * * Copyright (C) 1999-2015, International Business Machines diff --git a/deps/icu-small/source/i18n/collationweights.h b/deps/icu-small/source/i18n/collationweights.h index d8cee79e33fd87..b4158821844767 100644 --- a/deps/icu-small/source/i18n/collationweights.h +++ b/deps/icu-small/source/i18n/collationweights.h @@ -1,6 +1,6 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -/* +/* ******************************************************************************* * * Copyright (C) 1999-2014, International Business Machines diff --git a/deps/icu-small/source/i18n/collunsafe.h b/deps/icu-small/source/i18n/collunsafe.h index c2b3760ccb8d57..0767254a8ae2f4 100644 --- a/deps/icu-small/source/i18n/collunsafe.h +++ b/deps/icu-small/source/i18n/collunsafe.h @@ -16,7 +16,7 @@ #define COLLUNSAFE_COLL_VERSION "9.64" #define COLLUNSAFE_SERIALIZE 1 static const int32_t unsafe_serializedCount = 850; -static const uint16_t unsafe_serializedData[850] = { +static const uint16_t unsafe_serializedData[850] = { 0x8350, 0x01B8, 0x0034, 0x0035, 0x004C, 0x004D, 0x00A0, 0x00A1, // 8 0x0300, 0x034F, 0x0350, 0x0370, 0x03A9, 0x03AA, 0x03E2, 0x03E3, // 16 0x042F, 0x0430, 0x0483, 0x0488, 0x0531, 0x0532, 0x0591, 0x05BE, // 24 diff --git a/deps/icu-small/source/i18n/compactdecimalformat.cpp b/deps/icu-small/source/i18n/compactdecimalformat.cpp index 4dd2241b23d0a6..a4c9dad25c408f 100644 --- a/deps/icu-small/source/i18n/compactdecimalformat.cpp +++ b/deps/icu-small/source/i18n/compactdecimalformat.cpp @@ -30,9 +30,9 @@ CompactDecimalFormat::CompactDecimalFormat(const Locale& inLocale, UNumberCompac : DecimalFormat(new DecimalFormatSymbols(inLocale, status), status) { if (U_FAILURE(status)) return; // Minimal properties: let the non-shim code path do most of the logic for us. - fields->properties->compactStyle = style; - fields->properties->groupingSize = -2; // do not forward grouping information - fields->properties->minimumGroupingDigits = 2; + fields->properties.compactStyle = style; + fields->properties.groupingSize = -2; // do not forward grouping information + fields->properties.minimumGroupingDigits = 2; touch(status); } @@ -45,7 +45,7 @@ CompactDecimalFormat& CompactDecimalFormat::operator=(const CompactDecimalFormat return *this; } -Format* CompactDecimalFormat::clone() const { +CompactDecimalFormat* CompactDecimalFormat::clone() const { return new CompactDecimalFormat(*this); } diff --git a/deps/icu-small/source/i18n/coptccal.cpp b/deps/icu-small/source/i18n/coptccal.cpp index 39691217d0fcb5..9c2b1ebbb7ffdb 100644 --- a/deps/icu-small/source/i18n/coptccal.cpp +++ b/deps/icu-small/source/i18n/coptccal.cpp @@ -31,7 +31,7 @@ CopticCalendar::CopticCalendar(const Locale& aLocale, UErrorCode& success) { } -CopticCalendar::CopticCalendar (const CopticCalendar& other) +CopticCalendar::CopticCalendar (const CopticCalendar& other) : CECalendar(other) { } @@ -40,7 +40,7 @@ CopticCalendar::~CopticCalendar() { } -Calendar* +CopticCalendar* CopticCalendar::clone() const { return new CopticCalendar(*this); @@ -98,7 +98,7 @@ CopticCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/) /** * The system maintains a static default century start date and Year. They are - * initialized the first time they are used. Once the system default century date + * initialized the first time they are used. Once the system default century date * and year are set, they do not change. */ static UDate gSystemDefaultCenturyStart = DBL_MIN; diff --git a/deps/icu-small/source/i18n/coptccal.h b/deps/icu-small/source/i18n/coptccal.h index 0b82c36088fb0d..e9e812dbc7fc82 100644 --- a/deps/icu-small/source/i18n/coptccal.h +++ b/deps/icu-small/source/i18n/coptccal.h @@ -24,90 +24,90 @@ U_NAMESPACE_BEGIN * @internal */ class CopticCalendar : public CECalendar { - + public: /** * Useful constants for CopticCalendar. * @internal */ enum EMonths { - /** + /** * Constant for ωογτ/تﻮﺗ, - * the 1st month of the Coptic year. + * the 1st month of the Coptic year. */ TOUT, - - /** + + /** * Constant for Παοπι/ﻪﺑﺎﺑ, - * the 2nd month of the Coptic year. + * the 2nd month of the Coptic year. */ BABA, - /** + /** * Constant for Αθορ/رﻮﺗﺎﻫ, - * the 3rd month of the Coptic year. + * the 3rd month of the Coptic year. */ HATOR, - /** + /** * Constant for Χοιακ/ﻚﻬﻴﻛ, - * the 4th month of the Coptic year. + * the 4th month of the Coptic year. */ KIAHK, - /** + /** * Constant for Τωβι/طﻮﺒﻫ, - * the 5th month of the Coptic year. + * the 5th month of the Coptic year. */ TOBA, - /** + /** * Constant for Μεϣιρ/ﺮﻴﺸﻣأ, - * the 6th month of the Coptic year. + * the 6th month of the Coptic year. */ AMSHIR, - /** + /** * Constant for Παρεμϩατ/تﺎﻬﻣﺮﺑ, - * the 7th month of the Coptic year. + * the 7th month of the Coptic year. */ BARAMHAT, - /** - * Constant for Φαρμοθι/هدﻮﻣﺮﺑ, - * the 8th month of the Coptic year. + /** + * Constant for Φαρμοθι/هدﻮﻣﺮﺑ, + * the 8th month of the Coptic year. */ BARAMOUDA, - /** + /** * Constant for Παϣαν/ﺲﻨﺸﺑ, - * the 9th month of the Coptic year. + * the 9th month of the Coptic year. */ BASHANS, - /** + /** * Constant for Παωνι/ﻪﻧؤﻮﺑ, - * the 10th month of the Coptic year. + * the 10th month of the Coptic year. */ PAONA, - /** + /** * Constant for Επηπ/ﺐﻴﺑأ, - * the 11th month of the Coptic year. + * the 11th month of the Coptic year. */ EPEP, - /** + /** * Constant for Μεϲωρη/ىﺮﺴﻣ, - * the 12th month of the Coptic year. + * the 12th month of the Coptic year. */ MESRA, - /** + /** * Constant for Πικογϫι * μαβοτ/ﺮﻴﻐﺼﻟا * ﺮﻬﺸﻟا, - * the 13th month of the Coptic year. + * the 13th month of the Coptic year. */ NASIE }; @@ -145,7 +145,7 @@ class CopticCalendar : public CECalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual CopticCalendar* clone() const; /** * return the calendar type, "coptic" @@ -215,7 +215,7 @@ class CopticCalendar : public CECalendar { * @return The class ID for all objects of this class. * @internal */ - U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); + U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); #if 0 // We do not want to introduce this API in ICU4C. diff --git a/deps/icu-small/source/i18n/cpdtrans.cpp b/deps/icu-small/source/i18n/cpdtrans.cpp index a204de5a5352dd..82ee54a77b5607 100644 --- a/deps/icu-small/source/i18n/cpdtrans.cpp +++ b/deps/icu-small/source/i18n/cpdtrans.cpp @@ -59,7 +59,7 @@ CompoundTransliterator::CompoundTransliterator( /** * Splits an ID of the form "ID;ID;..." into a compound using each - * of the IDs. + * of the IDs. * @param id of above form * @param forward if false, does the list in reverse order, and * takes the inverse of each ID. @@ -323,7 +323,7 @@ CompoundTransliterator& CompoundTransliterator::operator=( /** * Transliterator API. */ -Transliterator* CompoundTransliterator::clone(void) const { +CompoundTransliterator* CompoundTransliterator::clone() const { return new CompoundTransliterator(*this); } @@ -499,7 +499,7 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi * - start' is the value of start after calling handleKT * - limit' is the value of limit after calling handleKT */ - + /** * Example: 3 transliterators. This example illustrates the * mechanics we need to implement. C, S, and L are the contextStart, @@ -509,25 +509,25 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi * 1. h-u, changes hex to Unicode * * 4 7 a d 0 4 7 a - * abc/u0061/u => abca/u + * abc/u0061/u => abca/u * C S L C S L gl=f->a * * 2. upup, changes "x" to "XX" * * 4 7 a 4 7 a - * abca/u => abcAA/u - * C SL C S + * abca/u => abcAA/u + * C SL C S * L gl=a->b * 3. u-h, changes Unicode to hex * * 4 7 a 4 7 a d 0 3 - * abcAA/u => abc/u0041/u0041/u + * abcAA/u => abc/u0041/u0041/u * C S L C S * L gl=b->15 * 4. return * * 4 7 a d 0 3 - * abc/u0041/u0041/u + * abc/u0041/u0041/u * C S L */ @@ -545,7 +545,7 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi // compoundStart is the start for the entire compound // operation. int32_t compoundStart = index.start; - + int32_t delta = 0; // delta in length // Give each transliterator a crack at the run of characters. @@ -553,14 +553,14 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi for (int32_t i=0; ifilteredTransliterate(text, index, incremental); - + // In a properly written transliterator, start == limit after // handleTransliterate() returns when incremental is false. // Catch cases where the subclass doesn't do this, and throw @@ -575,7 +575,7 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi // Cumulative delta for insertions/deletions delta += index.limit - limit; - + if (incremental) { // In the incremental case, only allow subsequent // transliterators to modify what has already been diff --git a/deps/icu-small/source/i18n/cpdtrans.h b/deps/icu-small/source/i18n/cpdtrans.h index 29f3ba83fc1d57..a2c7abbd691d7f 100644 --- a/deps/icu-small/source/i18n/cpdtrans.h +++ b/deps/icu-small/source/i18n/cpdtrans.h @@ -98,7 +98,7 @@ class U_I18N_API CompoundTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone(void) const; + virtual CompoundTransliterator* clone() const; /** * Returns the number of transliterators in this chain. @@ -192,7 +192,7 @@ class U_I18N_API CompoundTransliterator : public Transliterator { int32_t numAnonymousRBTs, UParseError& parseError, UErrorCode& status); - + CompoundTransliterator(UVector& list, UParseError& parseError, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/csdetect.cpp b/deps/icu-small/source/i18n/csdetect.cpp index ad3565155dd382..babb3084302ffb 100644 --- a/deps/icu-small/source/i18n/csdetect.cpp +++ b/deps/icu-small/source/i18n/csdetect.cpp @@ -47,7 +47,7 @@ struct CSRecognizerInfo : public UMemory { U_NAMESPACE_END static icu::CSRecognizerInfo **fCSRecognizers = NULL; -static icu::UInitOnce gCSRecognizersInitOnce; +static icu::UInitOnce gCSRecognizersInitOnce = U_INITONCE_INITIALIZER; static int32_t fCSRecognizers_size = 0; U_CDECL_BEGIN @@ -126,7 +126,7 @@ static void U_CALLCONV initRecognizers(UErrorCode &status) { if (fCSRecognizers == NULL) { status = U_MEMORY_ALLOCATION_ERROR; - } + } else { fCSRecognizers_size = rCount; for (int32_t r = 0; r < rCount; r += 1) { @@ -224,7 +224,7 @@ int32_t CharsetDetector::getDetectableCount() setRecognizers(status); - return fCSRecognizers_size; + return fCSRecognizers_size; } const CharsetMatch *CharsetDetector::detect(UErrorCode &status) diff --git a/deps/icu-small/source/i18n/csmatch.cpp b/deps/icu-small/source/i18n/csmatch.cpp index 7ed6e0ee1a8d53..83bf5316656d6b 100644 --- a/deps/icu-small/source/i18n/csmatch.cpp +++ b/deps/icu-small/source/i18n/csmatch.cpp @@ -30,7 +30,7 @@ void CharsetMatch::set(InputText *input, const CharsetRecognizer *cr, int32_t co const char *csName, const char *lang) { textIn = input; - confidence = conf; + confidence = conf; fCharsetName = csName; fLang = lang; if (cr != NULL) { @@ -45,12 +45,12 @@ void CharsetMatch::set(InputText *input, const CharsetRecognizer *cr, int32_t co const char* CharsetMatch::getName()const { - return fCharsetName; + return fCharsetName; } const char* CharsetMatch::getLanguage()const { - return fLang; + return fLang; } int32_t CharsetMatch::getConfidence()const diff --git a/deps/icu-small/source/i18n/csmatch.h b/deps/icu-small/source/i18n/csmatch.h index 0dc0a9e468c5dd..fe379ceea7e203 100644 --- a/deps/icu-small/source/i18n/csmatch.h +++ b/deps/icu-small/source/i18n/csmatch.h @@ -47,10 +47,10 @@ class CharsetMatch : public UMemory * Default (NULL) parameters for names will be filled by calling the * corresponding getters on the recognizer. */ - void set(InputText *input, - const CharsetRecognizer *cr, - int32_t conf, - const char *csName=NULL, + void set(InputText *input, + const CharsetRecognizer *cr, + int32_t conf, + const char *csName=NULL, const char *lang=NULL); /** diff --git a/deps/icu-small/source/i18n/csr2022.cpp b/deps/icu-small/source/i18n/csr2022.cpp index aa7f8446eb947c..ff26e5e9116bef 100644 --- a/deps/icu-small/source/i18n/csr2022.cpp +++ b/deps/icu-small/source/i18n/csr2022.cpp @@ -24,8 +24,8 @@ U_NAMESPACE_BEGIN * Counts up the number of legal and unrecognized escape sequences in * the sample of text, and computes a score based on the total number & * the proportion that fit the encoding. - * - * + * + * * @param text the byte buffer containing text to analyse * @param textLen the size of the text in the byte. * @param escapeSequences the byte escape sequences to test for. @@ -84,7 +84,7 @@ int32_t CharsetRecog_2022::match_2022(const uint8_t *text, int32_t textLen, cons // // Initial quality is based on relative proportion of recongized vs. - // unrecognized escape sequences. + // unrecognized escape sequences. // All good: quality = 100; // half or less good: quality = 0; // linear inbetween. @@ -122,7 +122,7 @@ static const uint8_t escapeSequences_2022JP[][5] = { #if !UCONFIG_ONLY_HTML_CONVERSION static const uint8_t escapeSequences_2022KR[][5] = { - {0x1b, 0x24, 0x29, 0x43, 0x00} + {0x1b, 0x24, 0x29, 0x43, 0x00} }; static const uint8_t escapeSequences_2022CN[][5] = { @@ -147,9 +147,9 @@ const char *CharsetRecog_2022JP::getName() const { } UBool CharsetRecog_2022JP::match(InputText *textIn, CharsetMatch *results) const { - int32_t confidence = match_2022(textIn->fInputBytes, - textIn->fInputLen, - escapeSequences_2022JP, + int32_t confidence = match_2022(textIn->fInputBytes, + textIn->fInputLen, + escapeSequences_2022JP, UPRV_LENGTHOF(escapeSequences_2022JP)); results->set(textIn, this, confidence); return (confidence > 0); @@ -163,9 +163,9 @@ const char *CharsetRecog_2022KR::getName() const { } UBool CharsetRecog_2022KR::match(InputText *textIn, CharsetMatch *results) const { - int32_t confidence = match_2022(textIn->fInputBytes, - textIn->fInputLen, - escapeSequences_2022KR, + int32_t confidence = match_2022(textIn->fInputBytes, + textIn->fInputLen, + escapeSequences_2022KR, UPRV_LENGTHOF(escapeSequences_2022KR)); results->set(textIn, this, confidence); return (confidence > 0); diff --git a/deps/icu-small/source/i18n/csr2022.h b/deps/icu-small/source/i18n/csr2022.h index 6d5b7bffccacc5..cde9019b4669d6 100644 --- a/deps/icu-small/source/i18n/csr2022.h +++ b/deps/icu-small/source/i18n/csr2022.h @@ -25,15 +25,15 @@ class CharsetMatch; * This is a superclass for the individual detectors for * each of the detectable members of the ISO 2022 family * of encodings. - * + * * The separate classes are nested within this class. - * + * * @internal */ class CharsetRecog_2022 : public CharsetRecognizer { -public: +public: virtual ~CharsetRecog_2022() = 0; protected: @@ -43,8 +43,8 @@ class CharsetRecog_2022 : public CharsetRecognizer * Counts up the number of legal an unrecognized escape sequences in * the sample of text, and computes a score based on the total number & * the proportion that fit the encoding. - * - * + * + * * @param text the byte buffer containing text to analyse * @param textLen the size of the text in the byte. * @param escapeSequences the byte escape sequences to test for. diff --git a/deps/icu-small/source/i18n/csrecog.cpp b/deps/icu-small/source/i18n/csrecog.cpp index d02be2bef68666..31fce5dd012f52 100644 --- a/deps/icu-small/source/i18n/csrecog.cpp +++ b/deps/icu-small/source/i18n/csrecog.cpp @@ -25,6 +25,6 @@ const char *CharsetRecognizer::getLanguage() const return ""; } -U_NAMESPACE_END +U_NAMESPACE_END #endif diff --git a/deps/icu-small/source/i18n/csrecog.h b/deps/icu-small/source/i18n/csrecog.h index 51c25396adbe14..713fd4e86b8a52 100644 --- a/deps/icu-small/source/i18n/csrecog.h +++ b/deps/icu-small/source/i18n/csrecog.h @@ -32,13 +32,13 @@ class CharsetRecognizer : public UMemory * @return the charset name. */ virtual const char *getName() const = 0; - + /** * Get the ISO language code for this charset. * @return the language code, or null if the language cannot be determined. */ virtual const char *getLanguage() const; - + /* * Try the given input text against this Charset, and fill in the results object * with the quality of the match plus other information related to the match. diff --git a/deps/icu-small/source/i18n/csrmbcs.cpp b/deps/icu-small/source/i18n/csrmbcs.cpp index 46d626bb3f4ffe..5579ba8ec3febf 100644 --- a/deps/icu-small/source/i18n/csrmbcs.cpp +++ b/deps/icu-small/source/i18n/csrmbcs.cpp @@ -114,7 +114,7 @@ static int32_t binarySearch(const uint16_t *array, int32_t len, uint16_t value) return -1; } -IteratedChar::IteratedChar() : +IteratedChar::IteratedChar() : charValue(0), index(-1), nextIndex(0), error(FALSE), done(FALSE) { // nothing else to do. diff --git a/deps/icu-small/source/i18n/csrsbcs.cpp b/deps/icu-small/source/i18n/csrsbcs.cpp index 3d0b7269ccac3b..0b0d8967e7d690 100644 --- a/deps/icu-small/source/i18n/csrsbcs.cpp +++ b/deps/icu-small/source/i18n/csrsbcs.cpp @@ -145,22 +145,22 @@ int32_t NGramParser::parse(InputText *det) #if !UCONFIG_ONLY_HTML_CONVERSION static const uint8_t unshapeMap_IBM420[] = { /* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F */ -/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 4- */ 0x40, 0x40, 0x42, 0x42, 0x44, 0x45, 0x46, 0x47, 0x47, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, -/* 5- */ 0x50, 0x49, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x58, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, -/* 6- */ 0x60, 0x61, 0x62, 0x63, 0x63, 0x65, 0x65, 0x67, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, -/* 7- */ 0x69, 0x71, 0x71, 0x73, 0x74, 0x75, 0x76, 0x77, 0x77, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, -/* 8- */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x80, 0x8B, 0x8B, 0x8D, 0x8D, 0x8F, -/* 9- */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9A, 0x9A, 0x9A, 0x9E, 0x9E, -/* A- */ 0x9E, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x9E, 0xAB, 0xAB, 0xAD, 0xAD, 0xAF, -/* B- */ 0xAF, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xB1, 0xBB, 0xBB, 0xBD, 0xBD, 0xBF, -/* C- */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xBF, 0xCC, 0xBF, 0xCE, 0xCF, -/* D- */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDA, 0xDC, 0xDC, 0xDC, 0xDF, -/* E- */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, -/* F- */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, +/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 4- */ 0x40, 0x40, 0x42, 0x42, 0x44, 0x45, 0x46, 0x47, 0x47, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, +/* 5- */ 0x50, 0x49, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x58, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, +/* 6- */ 0x60, 0x61, 0x62, 0x63, 0x63, 0x65, 0x65, 0x67, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, +/* 7- */ 0x69, 0x71, 0x71, 0x73, 0x74, 0x75, 0x76, 0x77, 0x77, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, +/* 8- */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x80, 0x8B, 0x8B, 0x8D, 0x8D, 0x8F, +/* 9- */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9A, 0x9A, 0x9A, 0x9E, 0x9E, +/* A- */ 0x9E, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x9E, 0xAB, 0xAB, 0xAD, 0xAD, 0xAF, +/* B- */ 0xAF, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xB1, 0xBB, 0xBB, 0xBD, 0xBD, 0xBF, +/* C- */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xBF, 0xCC, 0xBF, 0xCE, 0xCF, +/* D- */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDA, 0xDC, 0xDC, 0xDC, 0xDF, +/* E- */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, +/* F- */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, }; NGramParser_IBM420::NGramParser_IBM420(const int32_t *theNgramList, const uint8_t *theCharMap):NGramParser(theNgramList, theCharMap) @@ -173,13 +173,13 @@ NGramParser_IBM420::~NGramParser_IBM420() {} int32_t NGramParser_IBM420::isLamAlef(int32_t b) { if(b == 0xB2 || b == 0xB3){ - return 0x47; + return 0x47; }else if(b == 0xB4 || b == 0xB5){ - return 0x49; + return 0x49; }else if(b == 0xB8 || b == 0xB9){ - return 0x56; + return 0x56; }else - return 0x00; + return 0x00; } /* @@ -188,23 +188,23 @@ int32_t NGramParser_IBM420::isLamAlef(int32_t b) * convert the bytes to Unicode code points but that would leave us dependent * on CharsetICU which we try to avoid. IBM420 converter amongst different versions * of JDK can produce different results and therefore is also avoided. -*/ +*/ int32_t NGramParser_IBM420::nextByte(InputText *det) { - + if (byteIndex >= det->fInputLen || det->fInputBytes[byteIndex] == 0) { return -1; - } + } int next; - + alef = isLamAlef(det->fInputBytes[byteIndex]); if(alef != 0x00) next = 0xB1 & 0xFF; else next = unshapeMap_IBM420[det->fInputBytes[byteIndex]& 0xFF] & 0xFF; - + byteIndex++; - + return next; } @@ -223,19 +223,19 @@ void NGramParser_IBM420::parseCharacters(InputText *det) } ignoreSpace = (mb == 0x20); } - + if(alef != 0x00){ mb = charMap[alef & 0xFF]; - + // TODO: 0x20 might not be a space in all character sets... if (mb != 0) { if (!(mb == 0x20 && ignoreSpace)) { - addByte(mb); + addByte(mb); } - + ignoreSpace = (mb == 0x20); } - + } } } @@ -262,382 +262,382 @@ int32_t CharsetRecog_sbcs::match_sbcs(InputText *det, const int32_t ngrams[], c } static const uint8_t charMap_8859_1[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, - 0x20, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, + 0x20, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, }; static const uint8_t charMap_8859_2[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0xB1, 0x20, 0xB3, 0x20, 0xB5, 0xB6, 0x20, - 0x20, 0xB9, 0xBA, 0xBB, 0xBC, 0x20, 0xBE, 0xBF, - 0x20, 0xB1, 0x20, 0xB3, 0x20, 0xB5, 0xB6, 0xB7, - 0x20, 0xB9, 0xBA, 0xBB, 0xBC, 0x20, 0xBE, 0xBF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0xB1, 0x20, 0xB3, 0x20, 0xB5, 0xB6, 0x20, + 0x20, 0xB9, 0xBA, 0xBB, 0xBC, 0x20, 0xBE, 0xBF, + 0x20, 0xB1, 0x20, 0xB3, 0x20, 0xB5, 0xB6, 0xB7, + 0x20, 0xB9, 0xBA, 0xBB, 0xBC, 0x20, 0xBE, 0xBF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x20, }; static const uint8_t charMap_8859_5[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x20, 0xFE, 0xFF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x20, 0xFE, 0xFF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x20, 0xFE, 0xFF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x20, 0xFE, 0xFF, }; static const uint8_t charMap_8859_6[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, - 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD8, 0xD9, 0xDA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, }; static const uint8_t charMap_8859_7[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0xA1, 0xA2, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xDC, 0x20, - 0xDD, 0xDE, 0xDF, 0x20, 0xFC, 0x20, 0xFD, 0xFE, - 0xC0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0x20, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0xA1, 0xA2, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xDC, 0x20, + 0xDD, 0xDE, 0xDF, 0x20, 0xFC, 0x20, 0xFD, 0xFE, + 0xC0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0x20, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x20, }; static const uint8_t charMap_8859_8[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0x20, 0x20, 0x20, 0x20, 0x20, }; static const uint8_t charMap_8859_9[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, - 0x20, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x69, 0xFE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, + 0x20, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x69, 0xFE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0x20, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, }; static const int32_t ngrams_windows_1251[] = { - 0x20E220, 0x20E2EE, 0x20E4EE, 0x20E7E0, 0x20E820, 0x20EAE0, 0x20EAEE, 0x20EDE0, 0x20EDE5, 0x20EEE1, 0x20EFEE, 0x20EFF0, 0x20F0E0, 0x20F1EE, 0x20F1F2, 0x20F2EE, - 0x20F7F2, 0x20FDF2, 0xE0EDE8, 0xE0F2FC, 0xE3EE20, 0xE5EBFC, 0xE5EDE8, 0xE5F1F2, 0xE5F220, 0xE820EF, 0xE8E520, 0xE8E820, 0xE8FF20, 0xEBE5ED, 0xEBE820, 0xEBFCED, - 0xEDE020, 0xEDE520, 0xEDE8E5, 0xEDE8FF, 0xEDEE20, 0xEDEEE2, 0xEE20E2, 0xEE20EF, 0xEE20F1, 0xEEE220, 0xEEE2E0, 0xEEE3EE, 0xEEE920, 0xEEEBFC, 0xEEEC20, 0xEEF1F2, - 0xEFEEEB, 0xEFF0E5, 0xEFF0E8, 0xEFF0EE, 0xF0E0E2, 0xF0E5E4, 0xF1F2E0, 0xF1F2E2, 0xF1F2E8, 0xF1FF20, 0xF2E5EB, 0xF2EE20, 0xF2EEF0, 0xF2FC20, 0xF7F2EE, 0xFBF520, + 0x20E220, 0x20E2EE, 0x20E4EE, 0x20E7E0, 0x20E820, 0x20EAE0, 0x20EAEE, 0x20EDE0, 0x20EDE5, 0x20EEE1, 0x20EFEE, 0x20EFF0, 0x20F0E0, 0x20F1EE, 0x20F1F2, 0x20F2EE, + 0x20F7F2, 0x20FDF2, 0xE0EDE8, 0xE0F2FC, 0xE3EE20, 0xE5EBFC, 0xE5EDE8, 0xE5F1F2, 0xE5F220, 0xE820EF, 0xE8E520, 0xE8E820, 0xE8FF20, 0xEBE5ED, 0xEBE820, 0xEBFCED, + 0xEDE020, 0xEDE520, 0xEDE8E5, 0xEDE8FF, 0xEDEE20, 0xEDEEE2, 0xEE20E2, 0xEE20EF, 0xEE20F1, 0xEEE220, 0xEEE2E0, 0xEEE3EE, 0xEEE920, 0xEEEBFC, 0xEEEC20, 0xEEF1F2, + 0xEFEEEB, 0xEFF0E5, 0xEFF0E8, 0xEFF0EE, 0xF0E0E2, 0xF0E5E4, 0xF1F2E0, 0xF1F2E2, 0xF1F2E8, 0xF1FF20, 0xF2E5EB, 0xF2EE20, 0xF2EEF0, 0xF2FC20, 0xF7F2EE, 0xFBF520, }; static const uint8_t charMap_windows_1251[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x90, 0x83, 0x20, 0x83, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x9A, 0x20, 0x9C, 0x9D, 0x9E, 0x9F, - 0x90, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x9A, 0x20, 0x9C, 0x9D, 0x9E, 0x9F, - 0x20, 0xA2, 0xA2, 0xBC, 0x20, 0xB4, 0x20, 0x20, - 0xB8, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0xBF, - 0x20, 0x20, 0xB3, 0xB3, 0xB4, 0xB5, 0x20, 0x20, - 0xB8, 0x20, 0xBA, 0x20, 0xBC, 0xBE, 0xBE, 0xBF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x90, 0x83, 0x20, 0x83, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x9A, 0x20, 0x9C, 0x9D, 0x9E, 0x9F, + 0x90, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x9A, 0x20, 0x9C, 0x9D, 0x9E, 0x9F, + 0x20, 0xA2, 0xA2, 0xBC, 0x20, 0xB4, 0x20, 0x20, + 0xB8, 0x20, 0xBA, 0x20, 0x20, 0x20, 0x20, 0xBF, + 0x20, 0x20, 0xB3, 0xB3, 0xB4, 0xB5, 0x20, 0x20, + 0xB8, 0x20, 0xBA, 0x20, 0xBC, 0xBE, 0xBE, 0xBF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, }; static const int32_t ngrams_windows_1256[] = { - 0x20C7E1, 0x20C7E4, 0x20C8C7, 0x20DAE1, 0x20DDED, 0x20E1E1, 0x20E3E4, 0x20E6C7, 0xC720C7, 0xC7C120, 0xC7CA20, 0xC7D120, 0xC7E120, 0xC7E1C3, 0xC7E1C7, 0xC7E1C8, - 0xC7E1CA, 0xC7E1CC, 0xC7E1CD, 0xC7E1CF, 0xC7E1D3, 0xC7E1DA, 0xC7E1DE, 0xC7E1E3, 0xC7E1E6, 0xC7E1ED, 0xC7E320, 0xC7E420, 0xC7E4CA, 0xC820C7, 0xC920C7, 0xC920DD, - 0xC920E1, 0xC920E3, 0xC920E6, 0xCA20C7, 0xCF20C7, 0xCFC920, 0xD120C7, 0xD1C920, 0xD320C7, 0xDA20C7, 0xDAE1EC, 0xDDED20, 0xE120C7, 0xE1C920, 0xE1EC20, 0xE1ED20, - 0xE320C7, 0xE3C720, 0xE3C920, 0xE3E420, 0xE420C7, 0xE520C7, 0xE5C720, 0xE6C7E1, 0xE6E420, 0xEC20C7, 0xED20C7, 0xED20E3, 0xED20E6, 0xEDC920, 0xEDD120, 0xEDE420, + 0x20C7E1, 0x20C7E4, 0x20C8C7, 0x20DAE1, 0x20DDED, 0x20E1E1, 0x20E3E4, 0x20E6C7, 0xC720C7, 0xC7C120, 0xC7CA20, 0xC7D120, 0xC7E120, 0xC7E1C3, 0xC7E1C7, 0xC7E1C8, + 0xC7E1CA, 0xC7E1CC, 0xC7E1CD, 0xC7E1CF, 0xC7E1D3, 0xC7E1DA, 0xC7E1DE, 0xC7E1E3, 0xC7E1E6, 0xC7E1ED, 0xC7E320, 0xC7E420, 0xC7E4CA, 0xC820C7, 0xC920C7, 0xC920DD, + 0xC920E1, 0xC920E3, 0xC920E6, 0xCA20C7, 0xCF20C7, 0xCFC920, 0xD120C7, 0xD1C920, 0xD320C7, 0xDA20C7, 0xDAE1EC, 0xDDED20, 0xE120C7, 0xE1C920, 0xE1EC20, 0xE1ED20, + 0xE320C7, 0xE3C720, 0xE3C920, 0xE3E420, 0xE420C7, 0xE520C7, 0xE5C720, 0xE6C7E1, 0xE6E420, 0xEC20C7, 0xED20C7, 0xED20E3, 0xED20E6, 0xEDC920, 0xEDD120, 0xEDE420, }; static const uint8_t charMap_windows_1256[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x81, 0x20, 0x83, 0x20, 0x20, 0x20, 0x20, - 0x88, 0x20, 0x8A, 0x20, 0x9C, 0x8D, 0x8E, 0x8F, - 0x90, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x98, 0x20, 0x9A, 0x20, 0x9C, 0x20, 0x20, 0x9F, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, - 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0x20, - 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0x20, 0x20, 0x20, 0x20, 0xF4, 0x20, 0x20, 0x20, - 0x20, 0xF9, 0x20, 0xFB, 0xFC, 0x20, 0x20, 0xFF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x81, 0x20, 0x83, 0x20, 0x20, 0x20, 0x20, + 0x88, 0x20, 0x8A, 0x20, 0x9C, 0x8D, 0x8E, 0x8F, + 0x90, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x98, 0x20, 0x9A, 0x20, 0x9C, 0x20, 0x20, 0x9F, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0xAA, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0xB5, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0x20, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0x20, 0x20, 0x20, 0x20, 0xF4, 0x20, 0x20, 0x20, + 0x20, 0xF9, 0x20, 0xFB, 0xFC, 0x20, 0x20, 0xFF, }; static const int32_t ngrams_KOI8_R[] = { - 0x20C4CF, 0x20C920, 0x20CBC1, 0x20CBCF, 0x20CEC1, 0x20CEC5, 0x20CFC2, 0x20D0CF, 0x20D0D2, 0x20D2C1, 0x20D3CF, 0x20D3D4, 0x20D4CF, 0x20D720, 0x20D7CF, 0x20DAC1, - 0x20DCD4, 0x20DED4, 0xC1CEC9, 0xC1D4D8, 0xC5CCD8, 0xC5CEC9, 0xC5D3D4, 0xC5D420, 0xC7CF20, 0xC920D0, 0xC9C520, 0xC9C920, 0xC9D120, 0xCCC5CE, 0xCCC920, 0xCCD8CE, - 0xCEC120, 0xCEC520, 0xCEC9C5, 0xCEC9D1, 0xCECF20, 0xCECFD7, 0xCF20D0, 0xCF20D3, 0xCF20D7, 0xCFC7CF, 0xCFCA20, 0xCFCCD8, 0xCFCD20, 0xCFD3D4, 0xCFD720, 0xCFD7C1, - 0xD0CFCC, 0xD0D2C5, 0xD0D2C9, 0xD0D2CF, 0xD2C1D7, 0xD2C5C4, 0xD3D120, 0xD3D4C1, 0xD3D4C9, 0xD3D4D7, 0xD4C5CC, 0xD4CF20, 0xD4CFD2, 0xD4D820, 0xD9C820, 0xDED4CF, + 0x20C4CF, 0x20C920, 0x20CBC1, 0x20CBCF, 0x20CEC1, 0x20CEC5, 0x20CFC2, 0x20D0CF, 0x20D0D2, 0x20D2C1, 0x20D3CF, 0x20D3D4, 0x20D4CF, 0x20D720, 0x20D7CF, 0x20DAC1, + 0x20DCD4, 0x20DED4, 0xC1CEC9, 0xC1D4D8, 0xC5CCD8, 0xC5CEC9, 0xC5D3D4, 0xC5D420, 0xC7CF20, 0xC920D0, 0xC9C520, 0xC9C920, 0xC9D120, 0xCCC5CE, 0xCCC920, 0xCCD8CE, + 0xCEC120, 0xCEC520, 0xCEC9C5, 0xCEC9D1, 0xCECF20, 0xCECFD7, 0xCF20D0, 0xCF20D3, 0xCF20D7, 0xCFC7CF, 0xCFCA20, 0xCFCCD8, 0xCFCD20, 0xCFD3D4, 0xCFD720, 0xCFD7C1, + 0xD0CFCC, 0xD0D2C5, 0xD0D2C9, 0xD0D2CF, 0xD2C1D7, 0xD2C5C4, 0xD3D120, 0xD3D4C1, 0xD3D4C9, 0xD3D4D7, 0xD4C5CC, 0xD4CF20, 0xD4CFD2, 0xD4D820, 0xD9C820, 0xDED4CF, }; static const uint8_t charMap_KOI8_R[] = { - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0xA3, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0xA3, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, - 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, - 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0xA3, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0xA3, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, }; #if !UCONFIG_ONLY_HTML_CONVERSION static const int32_t ngrams_IBM424_he_rtl[] = { - 0x404146, 0x404148, 0x404151, 0x404171, 0x404251, 0x404256, 0x404541, 0x404546, 0x404551, 0x404556, 0x404562, 0x404569, 0x404571, 0x405441, 0x405445, 0x405641, - 0x406254, 0x406954, 0x417140, 0x454041, 0x454042, 0x454045, 0x454054, 0x454056, 0x454069, 0x454641, 0x464140, 0x465540, 0x465740, 0x466840, 0x467140, 0x514045, - 0x514540, 0x514671, 0x515155, 0x515540, 0x515740, 0x516840, 0x517140, 0x544041, 0x544045, 0x544140, 0x544540, 0x554041, 0x554042, 0x554045, 0x554054, 0x554056, - 0x554069, 0x564540, 0x574045, 0x584540, 0x585140, 0x585155, 0x625440, 0x684045, 0x685155, 0x695440, 0x714041, 0x714042, 0x714045, 0x714054, 0x714056, 0x714069, + 0x404146, 0x404148, 0x404151, 0x404171, 0x404251, 0x404256, 0x404541, 0x404546, 0x404551, 0x404556, 0x404562, 0x404569, 0x404571, 0x405441, 0x405445, 0x405641, + 0x406254, 0x406954, 0x417140, 0x454041, 0x454042, 0x454045, 0x454054, 0x454056, 0x454069, 0x454641, 0x464140, 0x465540, 0x465740, 0x466840, 0x467140, 0x514045, + 0x514540, 0x514671, 0x515155, 0x515540, 0x515740, 0x516840, 0x517140, 0x544041, 0x544045, 0x544140, 0x544540, 0x554041, 0x554042, 0x554045, 0x554054, 0x554056, + 0x554069, 0x564540, 0x574045, 0x584540, 0x585140, 0x585155, 0x625440, 0x684045, 0x685155, 0x695440, 0x714041, 0x714042, 0x714045, 0x714054, 0x714056, 0x714069, }; static const int32_t ngrams_IBM424_he_ltr[] = { @@ -649,22 +649,22 @@ static const int32_t ngrams_IBM424_he_ltr[] = { static const uint8_t charMap_IBM424_he[] = { /* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F */ -/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 4- */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 5- */ 0x40, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 6- */ 0x40, 0x40, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 7- */ 0x40, 0x71, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x40, 0x40, -/* 8- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 9- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* A- */ 0xA0, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* B- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* C- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* D- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* E- */ 0x40, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* F- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 4- */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 5- */ 0x40, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 6- */ 0x40, 0x40, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 7- */ 0x40, 0x71, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x40, 0x40, +/* 8- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 9- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* A- */ 0xA0, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* B- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* C- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* D- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* E- */ 0x40, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* F- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, }; static const int32_t ngrams_IBM420_ar_rtl[] = { @@ -675,7 +675,7 @@ static const int32_t ngrams_IBM420_ar_rtl[] = { }; static const int32_t ngrams_IBM420_ar_ltr[] = { - 0x404656, 0x4056BB, 0x4056BF, 0x406273, 0x406275, 0x4062B1, 0x4062BB, 0x4062DC, 0x406356, 0x407556, 0x4075DC, 0x40B156, 0x40BB56, 0x40BD56, 0x40BDBB, 0x40BDCF, + 0x404656, 0x4056BB, 0x4056BF, 0x406273, 0x406275, 0x4062B1, 0x4062BB, 0x4062DC, 0x406356, 0x407556, 0x4075DC, 0x40B156, 0x40BB56, 0x40BD56, 0x40BDBB, 0x40BDCF, 0x40BDDC, 0x40DAB1, 0x40DCAB, 0x40DCB1, 0x49B156, 0x564056, 0x564058, 0x564062, 0x564063, 0x564073, 0x564075, 0x564078, 0x56409A, 0x5640B1, 0x5640BB, 0x5640BD, 0x5640BF, 0x5640DA, 0x5640DC, 0x565840, 0x56B156, 0x56CF40, 0x58B156, 0x63B156, 0x63BD56, 0x67B156, 0x69B156, 0x73B156, 0x78B156, 0x9AB156, 0xAB4062, 0xADB156, 0xB14062, 0xB15640, 0xB156CF, 0xB19A40, 0xB1B140, 0xBB4062, 0xBB40DC, 0xBBB156, 0xBD5640, 0xBDBB40, 0xCF4062, 0xCF40DC, 0xCFB156, 0xDAB19A, 0xDCAB40, 0xDCB156 @@ -683,22 +683,22 @@ static const int32_t ngrams_IBM420_ar_ltr[] = { static const uint8_t charMap_IBM420_ar[]= { /* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F */ -/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 4- */ 0x40, 0x40, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 5- */ 0x40, 0x51, 0x52, 0x40, 0x40, 0x55, 0x56, 0x57, 0x58, 0x59, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 6- */ 0x40, 0x40, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 7- */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, -/* 8- */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, -/* 9- */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, -/* A- */ 0xA0, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, -/* B- */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0x40, 0x40, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, -/* C- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0xCB, 0x40, 0xCD, 0x40, 0xCF, -/* D- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, -/* E- */ 0x40, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xEA, 0xEB, 0x40, 0xED, 0xEE, 0xEF, -/* F- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xFB, 0xFC, 0xFD, 0xFE, 0x40, +/* 0- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 1- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 2- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 3- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 4- */ 0x40, 0x40, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 5- */ 0x40, 0x51, 0x52, 0x40, 0x40, 0x55, 0x56, 0x57, 0x58, 0x59, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 6- */ 0x40, 0x40, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 7- */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, +/* 8- */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, +/* 9- */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, +/* A- */ 0xA0, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, +/* B- */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0x40, 0x40, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, +/* C- */ 0x40, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x40, 0xCB, 0x40, 0xCD, 0x40, 0xCF, +/* D- */ 0x40, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, +/* E- */ 0x40, 0x40, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xEA, 0xEB, 0x40, 0xED, 0xEE, 0xEF, +/* F- */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xFB, 0xFC, 0xFD, 0xFE, 0x40, }; #endif @@ -710,39 +710,39 @@ struct NGramsPlusLang { }; static const NGramsPlusLang ngrams_8859_1[] = { - { + { { - 0x206120, 0x20616E, 0x206265, 0x20636F, 0x20666F, 0x206861, 0x206865, 0x20696E, 0x206D61, 0x206F66, 0x207072, 0x207265, 0x207361, 0x207374, 0x207468, 0x20746F, - 0x207768, 0x616964, 0x616C20, 0x616E20, 0x616E64, 0x617320, 0x617420, 0x617465, 0x617469, 0x642061, 0x642074, 0x652061, 0x652073, 0x652074, 0x656420, 0x656E74, - 0x657220, 0x657320, 0x666F72, 0x686174, 0x686520, 0x686572, 0x696420, 0x696E20, 0x696E67, 0x696F6E, 0x697320, 0x6E2061, 0x6E2074, 0x6E6420, 0x6E6720, 0x6E7420, - 0x6F6620, 0x6F6E20, 0x6F7220, 0x726520, 0x727320, 0x732061, 0x732074, 0x736169, 0x737420, 0x742074, 0x746572, 0x746861, 0x746865, 0x74696F, 0x746F20, 0x747320, + 0x206120, 0x20616E, 0x206265, 0x20636F, 0x20666F, 0x206861, 0x206865, 0x20696E, 0x206D61, 0x206F66, 0x207072, 0x207265, 0x207361, 0x207374, 0x207468, 0x20746F, + 0x207768, 0x616964, 0x616C20, 0x616E20, 0x616E64, 0x617320, 0x617420, 0x617465, 0x617469, 0x642061, 0x642074, 0x652061, 0x652073, 0x652074, 0x656420, 0x656E74, + 0x657220, 0x657320, 0x666F72, 0x686174, 0x686520, 0x686572, 0x696420, 0x696E20, 0x696E67, 0x696F6E, 0x697320, 0x6E2061, 0x6E2074, 0x6E6420, 0x6E6720, 0x6E7420, + 0x6F6620, 0x6F6E20, 0x6F7220, 0x726520, 0x727320, 0x732061, 0x732074, 0x736169, 0x737420, 0x742074, 0x746572, 0x746861, 0x746865, 0x74696F, 0x746F20, 0x747320, }, "en" }, - { + { { - 0x206166, 0x206174, 0x206465, 0x20656E, 0x206572, 0x20666F, 0x206861, 0x206920, 0x206D65, 0x206F67, 0x2070E5, 0x207369, 0x207374, 0x207469, 0x207669, 0x616620, - 0x616E20, 0x616E64, 0x617220, 0x617420, 0x646520, 0x64656E, 0x646572, 0x646574, 0x652073, 0x656420, 0x656465, 0x656E20, 0x656E64, 0x657220, 0x657265, 0x657320, - 0x657420, 0x666F72, 0x676520, 0x67656E, 0x676572, 0x696765, 0x696C20, 0x696E67, 0x6B6520, 0x6B6B65, 0x6C6572, 0x6C6967, 0x6C6C65, 0x6D6564, 0x6E6465, 0x6E6520, - 0x6E6720, 0x6E6765, 0x6F6720, 0x6F6D20, 0x6F7220, 0x70E520, 0x722064, 0x722065, 0x722073, 0x726520, 0x737465, 0x742073, 0x746520, 0x746572, 0x74696C, 0x766572, + 0x206166, 0x206174, 0x206465, 0x20656E, 0x206572, 0x20666F, 0x206861, 0x206920, 0x206D65, 0x206F67, 0x2070E5, 0x207369, 0x207374, 0x207469, 0x207669, 0x616620, + 0x616E20, 0x616E64, 0x617220, 0x617420, 0x646520, 0x64656E, 0x646572, 0x646574, 0x652073, 0x656420, 0x656465, 0x656E20, 0x656E64, 0x657220, 0x657265, 0x657320, + 0x657420, 0x666F72, 0x676520, 0x67656E, 0x676572, 0x696765, 0x696C20, 0x696E67, 0x6B6520, 0x6B6B65, 0x6C6572, 0x6C6967, 0x6C6C65, 0x6D6564, 0x6E6465, 0x6E6520, + 0x6E6720, 0x6E6765, 0x6F6720, 0x6F6D20, 0x6F7220, 0x70E520, 0x722064, 0x722065, 0x722073, 0x726520, 0x737465, 0x742073, 0x746520, 0x746572, 0x74696C, 0x766572, }, "da" }, - { + { { - 0x20616E, 0x206175, 0x206265, 0x206461, 0x206465, 0x206469, 0x206569, 0x206765, 0x206861, 0x20696E, 0x206D69, 0x207363, 0x207365, 0x20756E, 0x207665, 0x20766F, - 0x207765, 0x207A75, 0x626572, 0x636820, 0x636865, 0x636874, 0x646173, 0x64656E, 0x646572, 0x646965, 0x652064, 0x652073, 0x65696E, 0x656974, 0x656E20, 0x657220, - 0x657320, 0x67656E, 0x68656E, 0x687420, 0x696368, 0x696520, 0x696E20, 0x696E65, 0x697420, 0x6C6963, 0x6C6C65, 0x6E2061, 0x6E2064, 0x6E2073, 0x6E6420, 0x6E6465, - 0x6E6520, 0x6E6720, 0x6E6765, 0x6E7465, 0x722064, 0x726465, 0x726569, 0x736368, 0x737465, 0x742064, 0x746520, 0x74656E, 0x746572, 0x756E64, 0x756E67, 0x766572, + 0x20616E, 0x206175, 0x206265, 0x206461, 0x206465, 0x206469, 0x206569, 0x206765, 0x206861, 0x20696E, 0x206D69, 0x207363, 0x207365, 0x20756E, 0x207665, 0x20766F, + 0x207765, 0x207A75, 0x626572, 0x636820, 0x636865, 0x636874, 0x646173, 0x64656E, 0x646572, 0x646965, 0x652064, 0x652073, 0x65696E, 0x656974, 0x656E20, 0x657220, + 0x657320, 0x67656E, 0x68656E, 0x687420, 0x696368, 0x696520, 0x696E20, 0x696E65, 0x697420, 0x6C6963, 0x6C6C65, 0x6E2061, 0x6E2064, 0x6E2073, 0x6E6420, 0x6E6465, + 0x6E6520, 0x6E6720, 0x6E6765, 0x6E7465, 0x722064, 0x726465, 0x726569, 0x736368, 0x737465, 0x742064, 0x746520, 0x74656E, 0x746572, 0x756E64, 0x756E67, 0x766572, }, "de" }, { { - 0x206120, 0x206361, 0x20636F, 0x206465, 0x20656C, 0x20656E, 0x206573, 0x20696E, 0x206C61, 0x206C6F, 0x207061, 0x20706F, 0x207072, 0x207175, 0x207265, 0x207365, - 0x20756E, 0x207920, 0x612063, 0x612064, 0x612065, 0x61206C, 0x612070, 0x616369, 0x61646F, 0x616C20, 0x617220, 0x617320, 0x6369F3, 0x636F6E, 0x646520, 0x64656C, - 0x646F20, 0x652064, 0x652065, 0x65206C, 0x656C20, 0x656E20, 0x656E74, 0x657320, 0x657374, 0x69656E, 0x69F36E, 0x6C6120, 0x6C6F73, 0x6E2065, 0x6E7465, 0x6F2064, - 0x6F2065, 0x6F6E20, 0x6F7220, 0x6F7320, 0x706172, 0x717565, 0x726120, 0x726573, 0x732064, 0x732065, 0x732070, 0x736520, 0x746520, 0x746F20, 0x756520, 0xF36E20, + 0x206120, 0x206361, 0x20636F, 0x206465, 0x20656C, 0x20656E, 0x206573, 0x20696E, 0x206C61, 0x206C6F, 0x207061, 0x20706F, 0x207072, 0x207175, 0x207265, 0x207365, + 0x20756E, 0x207920, 0x612063, 0x612064, 0x612065, 0x61206C, 0x612070, 0x616369, 0x61646F, 0x616C20, 0x617220, 0x617320, 0x6369F3, 0x636F6E, 0x646520, 0x64656C, + 0x646F20, 0x652064, 0x652065, 0x65206C, 0x656C20, 0x656E20, 0x656E74, 0x657320, 0x657374, 0x69656E, 0x69F36E, 0x6C6120, 0x6C6F73, 0x6E2065, 0x6E7465, 0x6F2064, + 0x6F2065, 0x6F6E20, 0x6F7220, 0x6F7320, 0x706172, 0x717565, 0x726120, 0x726573, 0x732064, 0x732065, 0x732070, 0x736520, 0x746520, 0x746F20, 0x756520, 0xF36E20, }, "es" }, @@ -1025,7 +1025,7 @@ CharsetRecog_8859_8::~CharsetRecog_8859_8() // nothing to do } -const char *CharsetRecog_8859_8::getName() const +const char *CharsetRecog_8859_8::getName() const { return "ISO-8859-8"; } @@ -1220,14 +1220,14 @@ const char *CharsetRecog_IBM420_ar::getLanguage() const return "ar"; } - + int32_t CharsetRecog_IBM420_ar::match_sbcs(InputText *det, const int32_t ngrams[], const uint8_t byteMap[]) const { NGramParser_IBM420 parser(ngrams, byteMap); int32_t result; - + result = parser.parse(det); - + return result; } @@ -1268,3 +1268,4 @@ UBool CharsetRecog_IBM420_ar_ltr::match(InputText *textIn, CharsetMatch *results U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/csrsbcs.h b/deps/icu-small/source/i18n/csrsbcs.h index bae124c05a8426..97687836795fde 100644 --- a/deps/icu-small/source/i18n/csrsbcs.h +++ b/deps/icu-small/source/i18n/csrsbcs.h @@ -22,7 +22,7 @@ class NGramParser : public UMemory { private: int32_t ngram; - const int32_t *ngramList; + const int32_t *ngramList; int32_t ngramCount; int32_t hitCount; @@ -44,7 +44,7 @@ class NGramParser : public UMemory int32_t search(const int32_t *table, int32_t value); void lookup(int32_t thisNgram); - + virtual int32_t nextByte(InputText *det); virtual void parseCharacters(InputText *det); @@ -122,7 +122,7 @@ class CharsetRecog_8859_8 : public CharsetRecog_sbcs { public: virtual ~CharsetRecog_8859_8(); - + virtual const char *getName() const; }; @@ -170,7 +170,7 @@ class CharsetRecog_8859_8_I_he : public CharsetRecog_8859_8 { public: virtual ~CharsetRecog_8859_8_I_he(); - + const char *getName() const; const char *getLanguage() const; @@ -247,17 +247,17 @@ class CharsetRecog_IBM424_he : public CharsetRecog_sbcs class CharsetRecog_IBM424_he_rtl : public CharsetRecog_IBM424_he { public: virtual ~CharsetRecog_IBM424_he_rtl(); - + const char *getName() const; - + virtual UBool match(InputText *det, CharsetMatch *results) const; }; class CharsetRecog_IBM424_he_ltr : public CharsetRecog_IBM424_he { virtual ~CharsetRecog_IBM424_he_ltr(); - + const char *getName() const; - + virtual UBool match(InputText *det, CharsetMatch *results) const; }; @@ -268,23 +268,23 @@ class CharsetRecog_IBM420_ar : public CharsetRecog_sbcs const char *getLanguage() const; int32_t match_sbcs(InputText *det, const int32_t ngrams[], const uint8_t charMap[]) const; - + }; class CharsetRecog_IBM420_ar_rtl : public CharsetRecog_IBM420_ar { public: virtual ~CharsetRecog_IBM420_ar_rtl(); - + const char *getName() const; - + virtual UBool match(InputText *det, CharsetMatch *results) const; }; class CharsetRecog_IBM420_ar_ltr : public CharsetRecog_IBM420_ar { virtual ~CharsetRecog_IBM420_ar_ltr(); - + const char *getName() const; - + virtual UBool match(InputText *det, CharsetMatch *results) const; }; #endif diff --git a/deps/icu-small/source/i18n/csrucode.cpp b/deps/icu-small/source/i18n/csrucode.cpp index b84011c259095a..59f2dbe284c0f5 100644 --- a/deps/icu-small/source/i18n/csrucode.cpp +++ b/deps/icu-small/source/i18n/csrucode.cpp @@ -35,7 +35,7 @@ const char *CharsetRecog_UTF_16_BE::getName() const // Any 8 bit non-control characters bump the confidence up. These have a zero high byte, // and are very likely to be UTF-16, although they could also be part of a UTF-32 code. // NULs are a contra-indication, they will appear commonly if the actual encoding is UTF-32. -// NULs should be rare in actual text. +// NULs should be rare in actual text. static int32_t adjustConfidence(UChar codeUnit, int32_t confidence) { if (codeUnit == 0) { @@ -151,7 +151,7 @@ UBool CharsetRecog_UTF_32::match(InputText* textIn, CharsetMatch *results) const } else if (hasBOM && numValid > numInvalid*10) { confidence = 80; } else if (numValid > 3 && numInvalid == 0) { - confidence = 100; + confidence = 100; } else if (numValid > 0 && numInvalid == 0) { confidence = 80; } else if (numValid > numInvalid*10) { @@ -177,7 +177,7 @@ int32_t CharsetRecog_UTF_32_BE::getChar(const uint8_t *input, int32_t index) con { return input[index + 0] << 24 | input[index + 1] << 16 | input[index + 2] << 8 | input[index + 3]; -} +} CharsetRecog_UTF_32_LE::~CharsetRecog_UTF_32_LE() { @@ -197,3 +197,4 @@ int32_t CharsetRecog_UTF_32_LE::getChar(const uint8_t *input, int32_t index) con U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/csrucode.h b/deps/icu-small/source/i18n/csrucode.h index 4465bf35a1a917..cef35447fb750b 100644 --- a/deps/icu-small/source/i18n/csrucode.h +++ b/deps/icu-small/source/i18n/csrucode.h @@ -21,10 +21,10 @@ U_NAMESPACE_BEGIN /** * This class matches UTF-16 and UTF-32, both big- and little-endian. The * BOM will be used if it is present. - * + * * @internal */ -class CharsetRecog_Unicode : public CharsetRecognizer +class CharsetRecog_Unicode : public CharsetRecognizer { public: diff --git a/deps/icu-small/source/i18n/csrutf8.cpp b/deps/icu-small/source/i18n/csrutf8.cpp index bc06fa8bb8dd4e..b42bd8b39e65cb 100644 --- a/deps/icu-small/source/i18n/csrutf8.cpp +++ b/deps/icu-small/source/i18n/csrutf8.cpp @@ -35,7 +35,7 @@ UBool CharsetRecog_UTF8::match(InputText* input, CharsetMatch *results) const { int32_t trailBytes = 0; int32_t confidence; - if (input->fRawLength >= 3 && + if (input->fRawLength >= 3 && inputBytes[0] == 0xEF && inputBytes[1] == 0xBB && inputBytes[2] == 0xBF) { hasBOM = TRUE; } diff --git a/deps/icu-small/source/i18n/csrutf8.h b/deps/icu-small/source/i18n/csrutf8.h index dc4f79b8246118..6089eb6f75cb77 100644 --- a/deps/icu-small/source/i18n/csrutf8.h +++ b/deps/icu-small/source/i18n/csrutf8.h @@ -26,8 +26,8 @@ U_NAMESPACE_BEGIN class CharsetRecog_UTF8: public CharsetRecognizer { public: - - virtual ~CharsetRecog_UTF8(); + + virtual ~CharsetRecog_UTF8(); const char *getName() const; @@ -35,7 +35,7 @@ class CharsetRecog_UTF8: public CharsetRecognizer { * @see com.ibm.icu.text.CharsetRecognizer#match(com.ibm.icu.text.CharsetDetector) */ UBool match(InputText *input, CharsetMatch *results) const; - + }; U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/curramt.cpp b/deps/icu-small/source/i18n/curramt.cpp index 019c17df8e3379..6fd2ea2fda5d0d 100644 --- a/deps/icu-small/source/i18n/curramt.cpp +++ b/deps/icu-small/source/i18n/curramt.cpp @@ -38,13 +38,13 @@ CurrencyAmount& CurrencyAmount::operator=(const CurrencyAmount& other) { return *this; } -UObject* CurrencyAmount::clone() const { +CurrencyAmount* CurrencyAmount::clone() const { return new CurrencyAmount(*this); } CurrencyAmount::~CurrencyAmount() { } - + UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyAmount) U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/currfmt.cpp b/deps/icu-small/source/i18n/currfmt.cpp index 8f20f783d25031..0ad0492ee7afbc 100644 --- a/deps/icu-small/source/i18n/currfmt.cpp +++ b/deps/icu-small/source/i18n/currfmt.cpp @@ -33,7 +33,7 @@ CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) : CurrencyFormat::~CurrencyFormat() { } -Format* CurrencyFormat::clone() const { +CurrencyFormat* CurrencyFormat::clone() const { return new CurrencyFormat(*this); } diff --git a/deps/icu-small/source/i18n/currfmt.h b/deps/icu-small/source/i18n/currfmt.h index cc9bb3c1bacd05..69a031957bcea9 100644 --- a/deps/icu-small/source/i18n/currfmt.h +++ b/deps/icu-small/source/i18n/currfmt.h @@ -57,7 +57,7 @@ class CurrencyFormat : public MeasureFormat { /** * Override Format API. */ - virtual Format* clone() const; + virtual CurrencyFormat* clone() const; using MeasureFormat::format; diff --git a/deps/icu-small/source/i18n/currpinf.cpp b/deps/icu-small/source/i18n/currpinf.cpp index f5d27e28d8ebfa..af9c837af89e44 100644 --- a/deps/icu-small/source/i18n/currpinf.cpp +++ b/deps/icu-small/source/i18n/currpinf.cpp @@ -78,7 +78,7 @@ CurrencyPluralInfo::CurrencyPluralInfo(const Locale& locale, UErrorCode& status) initialize(locale, status); } -CurrencyPluralInfo::CurrencyPluralInfo(const CurrencyPluralInfo& info) +CurrencyPluralInfo::CurrencyPluralInfo(const CurrencyPluralInfo& info) : UObject(info), fPluralCountToCurrencyUnitPattern(nullptr), fPluralRules(nullptr), @@ -101,7 +101,7 @@ CurrencyPluralInfo::operator=(const CurrencyPluralInfo& info) { deleteHash(fPluralCountToCurrencyUnitPattern); fPluralCountToCurrencyUnitPattern = initHash(fInternalStatus); - copyHash(info.fPluralCountToCurrencyUnitPattern, + copyHash(info.fPluralCountToCurrencyUnitPattern, fPluralCountToCurrencyUnitPattern, fInternalStatus); if ( U_FAILURE(fInternalStatus) ) { return *this; @@ -176,7 +176,7 @@ CurrencyPluralInfo::clone() const { return newObj; } -const PluralRules* +const PluralRules* CurrencyPluralInfo::getPluralRules() const { return fPluralRules; } @@ -184,16 +184,16 @@ CurrencyPluralInfo::getPluralRules() const { UnicodeString& CurrencyPluralInfo::getCurrencyPluralPattern(const UnicodeString& pluralCount, UnicodeString& result) const { - const UnicodeString* currencyPluralPattern = + const UnicodeString* currencyPluralPattern = (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(pluralCount); if (currencyPluralPattern == nullptr) { // fall back to "other" if (pluralCount.compare(gPluralCountOther, 5)) { - currencyPluralPattern = + currencyPluralPattern = (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(UnicodeString(TRUE, gPluralCountOther, 5)); } if (currencyPluralPattern == nullptr) { - // no currencyUnitPatterns defined, + // no currencyUnitPatterns defined, // fallback to predefined default. // This should never happen when ICU resource files are // available, since currencyUnitPattern of "other" is always @@ -242,13 +242,13 @@ CurrencyPluralInfo::setLocale(const Locale& loc, UErrorCode& status) { initialize(loc, status); } -void +void CurrencyPluralInfo::initialize(const Locale& loc, UErrorCode& status) { if (U_FAILURE(status)) { return; } delete fLocale; - fLocale = nullptr; + fLocale = nullptr; delete fPluralRules; fPluralRules = nullptr; @@ -266,7 +266,7 @@ CurrencyPluralInfo::initialize(const Locale& loc, UErrorCode& status) { fPluralRules = PluralRules::forLocale(loc, status); setupCurrencyPluralPattern(loc, status); } - + void CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status) { if (U_FAILURE(status)) { @@ -325,7 +325,7 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st LocalUResourceBundlePointer currRb(ures_open(U_ICUDATA_CURR, loc.getName(), &ec)); LocalUResourceBundlePointer currencyRes(ures_getByKeyWithFallback(currRb.getAlias(), gCurrUnitPtnTag, nullptr, &ec)); - + #ifdef CURRENCY_PLURAL_INFO_DEBUG std::cout << "in set up\n"; #endif @@ -351,13 +351,13 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st pattern->extract(0, pattern->length(), result_1, "UTF-8"); std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n"; #endif - pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3), + pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3), UnicodeString(numberStylePattern, numberStylePatternLen)); pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3)); if (hasSeparator) { UnicodeString negPattern(patternChars, ptnLength); - negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3), + negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3), UnicodeString(negNumberStylePattern, negNumberStylePatternLen)); negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3)); pattern->append(gNumberPatternSeparator); diff --git a/deps/icu-small/source/i18n/currunit.cpp b/deps/icu-small/source/i18n/currunit.cpp index 39c49e468d117d..dab6dda536826b 100644 --- a/deps/icu-small/source/i18n/currunit.cpp +++ b/deps/icu-small/source/i18n/currunit.cpp @@ -109,13 +109,13 @@ CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { return *this; } -UObject* CurrencyUnit::clone() const { +CurrencyUnit* CurrencyUnit::clone() const { return new CurrencyUnit(*this); } CurrencyUnit::~CurrencyUnit() { } - + UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit) U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/dangical.cpp b/deps/icu-small/source/i18n/dangical.cpp index bc3951f210ec45..02db40368ec8c1 100644 --- a/deps/icu-small/source/i18n/dangical.cpp +++ b/deps/icu-small/source/i18n/dangical.cpp @@ -56,7 +56,7 @@ DangiCalendar::DangiCalendar(const Locale& aLocale, UErrorCode& success) { } -DangiCalendar::DangiCalendar (const DangiCalendar& other) +DangiCalendar::DangiCalendar (const DangiCalendar& other) : ChineseCalendar(other) { } @@ -65,43 +65,43 @@ DangiCalendar::~DangiCalendar() { } -Calendar* +DangiCalendar* DangiCalendar::clone() const { return new DangiCalendar(*this); } -const char *DangiCalendar::getType() const { +const char *DangiCalendar::getType() const { return "dangi"; } /** * The time zone used for performing astronomical computations for - * Dangi calendar. In Korea various timezones have been used historically - * (cf. http://www.math.snu.ac.kr/~kye/others/lunar.html): - * - * - 1908/04/01: GMT+8 - * 1908/04/01 - 1911/12/31: GMT+8.5 - * 1912/01/01 - 1954/03/20: GMT+9 - * 1954/03/21 - 1961/08/09: GMT+8.5 - * 1961/08/10 - : GMT+9 - * - * Note that, in 1908-1911, the government did not apply the timezone change - * but used GMT+8. In addition, 1954-1961's timezone change does not affect - * the lunar date calculation. Therefore, the following simpler rule works: - * - * -1911: GMT+8 - * 1912-: GMT+9 - * - * Unfortunately, our astronomer's approximation doesn't agree with the - * references (http://www.math.snu.ac.kr/~kye/others/lunar.html and - * http://astro.kasi.re.kr/Life/ConvertSolarLunarForm.aspx?MenuID=115) - * in 1897/7/30. So the following ad hoc fix is used here: - * - * -1896: GMT+8 - * 1897: GMT+7 - * 1898-1911: GMT+8 - * 1912- : GMT+9 + * Dangi calendar. In Korea various timezones have been used historically + * (cf. http://www.math.snu.ac.kr/~kye/others/lunar.html): + * + * - 1908/04/01: GMT+8 + * 1908/04/01 - 1911/12/31: GMT+8.5 + * 1912/01/01 - 1954/03/20: GMT+9 + * 1954/03/21 - 1961/08/09: GMT+8.5 + * 1961/08/10 - : GMT+9 + * + * Note that, in 1908-1911, the government did not apply the timezone change + * but used GMT+8. In addition, 1954-1961's timezone change does not affect + * the lunar date calculation. Therefore, the following simpler rule works: + * + * -1911: GMT+8 + * 1912-: GMT+9 + * + * Unfortunately, our astronomer's approximation doesn't agree with the + * references (http://www.math.snu.ac.kr/~kye/others/lunar.html and + * http://astro.kasi.re.kr/Life/ConvertSolarLunarForm.aspx?MenuID=115) + * in 1897/7/30. So the following ad hoc fix is used here: + * + * -1896: GMT+8 + * 1897: GMT+7 + * 1898-1911: GMT+8 + * 1912- : GMT+9 */ static void U_CALLCONV initDangiCalZoneAstroCalc(void) { U_ASSERT(gDangiCalendarZoneAstroCalc == NULL); @@ -138,3 +138,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DangiCalendar) U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/dangical.h b/deps/icu-small/source/i18n/dangical.h index 1a1e06b9020295..ece805e36d378c 100644 --- a/deps/icu-small/source/i18n/dangical.h +++ b/deps/icu-small/source/i18n/dangical.h @@ -27,7 +27,7 @@ U_NAMESPACE_BEGIN *

      DangiCalendar is a concrete subclass of {@link Calendar} * that implements a traditional Korean lunisolar calendar.

      * - *

      DangiCalendar usually should be instantiated using + *

      DangiCalendar usually should be instantiated using * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a ULocale * with the tag "@calendar=dangi".

      * @@ -66,7 +66,7 @@ class DangiCalendar : public ChineseCalendar { * Clone. * @internal */ - virtual Calendar* clone() const; + virtual DangiCalendar* clone() const; //---------------------------------------------------------------------- // Internal methods & astronomical calculations @@ -77,7 +77,7 @@ class DangiCalendar : public ChineseCalendar { const TimeZone* getDangiCalZoneAstroCalc(void) const; // UObject stuff - public: + public: /** * @return The class ID for this object. All objects of a given class have the * same class ID. Objects of other classes have different class IDs. @@ -108,7 +108,7 @@ class DangiCalendar : public ChineseCalendar { private: - + DangiCalendar(); // default constructor not implemented }; @@ -116,3 +116,6 @@ U_NAMESPACE_END #endif #endif + + + diff --git a/deps/icu-small/source/i18n/datefmt.cpp b/deps/icu-small/source/i18n/datefmt.cpp index 039f5bc226bb0a..a0e039cd5074e5 100644 --- a/deps/icu-small/source/i18n/datefmt.cpp +++ b/deps/icu-small/source/i18n/datefmt.cpp @@ -65,7 +65,7 @@ const DateFmtBestPattern *LocaleCacheKey::createObject( return NULL; } -class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey { +class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey { private: UnicodeString fSkeleton; public: @@ -84,7 +84,7 @@ class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey::operator==(other)) { @@ -105,7 +105,7 @@ class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey pattern( new DateFmtBestPattern( dtpg->getBestPattern(fSkeleton, status)), @@ -154,7 +154,7 @@ DateFormat& DateFormat::operator=(const DateFormat& other) fCalendar = NULL; } if(other.fNumberFormat) { - fNumberFormat = (NumberFormat*)other.fNumberFormat->clone(); + fNumberFormat = other.fNumberFormat->clone(); } else { fNumberFormat = NULL; } @@ -598,7 +598,7 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat) void DateFormat::setNumberFormat(const NumberFormat& newNumberFormat) { - NumberFormat* newNumFmtClone = (NumberFormat*)newNumberFormat.clone(); + NumberFormat* newNumFmtClone = newNumberFormat.clone(); if (newNumFmtClone != NULL) { adoptNumberFormat(newNumFmtClone); } @@ -726,10 +726,10 @@ UDisplayContext DateFormat::getContext(UDisplayContextType type, UErrorCode& sta //---------------------------------------------------------------------- -DateFormat& +DateFormat& DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, - UBool newValue, - UErrorCode &status) { + UBool newValue, + UErrorCode &status) { if(!fBoolFlags.isValidValue(newValue)) { status = U_ILLEGAL_ARGUMENT_ERROR; } else { @@ -741,7 +741,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, //---------------------------------------------------------------------- -UBool +UBool DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const { return static_cast(fBoolFlags.get(attr)); diff --git a/deps/icu-small/source/i18n/dcfmtsym.cpp b/deps/icu-small/source/i18n/dcfmtsym.cpp index 04113785f27308..d8b1ecdbea1e68 100644 --- a/deps/icu-small/source/i18n/dcfmtsym.cpp +++ b/deps/icu-small/source/i18n/dcfmtsym.cpp @@ -164,8 +164,8 @@ DecimalFormatSymbols::operator=(const DecimalFormatSymbols& rhs) locale = rhs.locale; uprv_strcpy(validLocale, rhs.validLocale); uprv_strcpy(actualLocale, rhs.actualLocale); - fIsCustomCurrencySymbol = rhs.fIsCustomCurrencySymbol; - fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol; + fIsCustomCurrencySymbol = rhs.fIsCustomCurrencySymbol; + fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol; fCodePointZero = rhs.fCodePointZero; } return *this; @@ -179,12 +179,12 @@ DecimalFormatSymbols::operator==(const DecimalFormatSymbols& that) const if (this == &that) { return TRUE; } - if (fIsCustomCurrencySymbol != that.fIsCustomCurrencySymbol) { - return FALSE; - } - if (fIsCustomIntlCurrencySymbol != that.fIsCustomIntlCurrencySymbol) { - return FALSE; - } + if (fIsCustomCurrencySymbol != that.fIsCustomCurrencySymbol) { + return FALSE; + } + if (fIsCustomIntlCurrencySymbol != that.fIsCustomIntlCurrencySymbol) { + return FALSE; + } for(int32_t i = 0; i < (int32_t)kFormatSymbolCount; ++i) { if(fSymbols[(ENumberFormatSymbol)i] != that.fSymbols[(ENumberFormatSymbol)i]) { return FALSE; @@ -547,9 +547,9 @@ DecimalFormatSymbols::initialize() { fSymbols[kInfinitySymbol] = (UChar)0x221e; // 'oo' infinite fSymbols[kNaNSymbol] = (UChar)0xfffd; // SUB NaN fSymbols[kSignificantDigitSymbol] = (UChar)0x0040; // '@' significant digit - fSymbols[kMonetaryGroupingSeparatorSymbol].remove(); // + fSymbols[kMonetaryGroupingSeparatorSymbol].remove(); // fSymbols[kExponentMultiplicationSymbol] = (UChar)0xd7; // 'x' multiplication symbol for exponents - fIsCustomCurrencySymbol = FALSE; + fIsCustomCurrencySymbol = FALSE; fIsCustomIntlCurrencySymbol = FALSE; fCodePointZero = 0x30; U_ASSERT(fCodePointZero == fSymbols[kZeroDigitSymbol].char32At(0)); diff --git a/deps/icu-small/source/i18n/decContext.cpp b/deps/icu-small/source/i18n/decContext.cpp index bead83efff7b83..6ec6d32afb56e1 100644 --- a/deps/icu-small/source/i18n/decContext.cpp +++ b/deps/icu-small/source/i18n/decContext.cpp @@ -429,3 +429,4 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextZeroStatus(decContext *context) { context->status=0; return context; } /* decContextZeroStatus */ + diff --git a/deps/icu-small/source/i18n/decContext.h b/deps/icu-small/source/i18n/decContext.h index 1fd18e5d3df537..e145777d1e7aad 100644 --- a/deps/icu-small/source/i18n/decContext.h +++ b/deps/icu-small/source/i18n/decContext.h @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------ */ /* Modified version, for use from within ICU. - * Renamed public functions, to avoid an unwanted export of the + * Renamed public functions, to avoid an unwanted export of the * standard names from the ICU library. * * Use ICU's uprv_malloc() and uprv_free() diff --git a/deps/icu-small/source/i18n/decNumber.cpp b/deps/icu-small/source/i18n/decNumber.cpp index c19493bdf3bbee..cee2f8e9498403 100644 --- a/deps/icu-small/source/i18n/decNumber.cpp +++ b/deps/icu-small/source/i18n/decNumber.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------ */ /* Modified version, for use from within ICU. - * Renamed public functions, to avoid an unwanted export of the + * Renamed public functions, to avoid an unwanted export of the * standard names from the ICU library. * * Use ICU's uprv_malloc() and uprv_free() diff --git a/deps/icu-small/source/i18n/decNumber.h b/deps/icu-small/source/i18n/decNumber.h index 92be8e8c0acd64..7182e789e5a1c5 100644 --- a/deps/icu-small/source/i18n/decNumber.h +++ b/deps/icu-small/source/i18n/decNumber.h @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------ */ /* Modified version, for use from within ICU. - * Renamed public functions, to avoid an unwanted export of the + * Renamed public functions, to avoid an unwanted export of the * standard names from the ICU library. * * Use ICU's uprv_malloc() and uprv_free() diff --git a/deps/icu-small/source/i18n/decNumberLocal.h b/deps/icu-small/source/i18n/decNumberLocal.h index f6c291a9ad3359..e8d1b38653eb9d 100644 --- a/deps/icu-small/source/i18n/decNumberLocal.h +++ b/deps/icu-small/source/i18n/decNumberLocal.h @@ -259,7 +259,7 @@ /* 2,000,000,000 (as is needed for negative exponents of */ /* subnormals). The unsigned integer pow is used as a temporary */ /* variable. */ - #define TODIGIT(u, cut, c, pow) { \ + #define TODIGIT(u, cut, c, pow) UPRV_BLOCK_MACRO_BEGIN { \ *(c)='0'; \ pow=DECPOWERS[cut]*2; \ if ((u)>pow) { \ @@ -272,7 +272,7 @@ if ((u)>=pow) {(u)-=pow; *(c)+=2;} \ pow/=2; \ if ((u)>=pow) {(u)-=pow; *(c)+=1;} \ - } + } UPRV_BLOCK_MACRO_END /* ---------------------------------------------------------------- */ /* Definitions for fixed-precision modules (only valid after */ diff --git a/deps/icu-small/source/i18n/decimfmt.cpp b/deps/icu-small/source/i18n/decimfmt.cpp index 2a1e9347fa10d0..d19f6518880498 100644 --- a/deps/icu-small/source/i18n/decimfmt.cpp +++ b/deps/icu-small/source/i18n/decimfmt.cpp @@ -95,7 +95,7 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* new CurrencyPluralInfo(fields->symbols->getLocale(), status), status); if (U_FAILURE(status)) { return; } - fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); } touch(status); } @@ -111,21 +111,14 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC status = U_MEMORY_ALLOCATION_ERROR; return; } - fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status); - fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); - fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); if (adoptedSymbols.isNull()) { fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(status), status); } else { fields->symbols.adoptInsteadAndCheckErrorCode(adoptedSymbols.orphan(), status); } - // In order to simplify error handling logic in the various getters/setters/etc, we do not allow - // any partially populated DecimalFormatFields object. We must have a fully complete fields object - // or else we set it to nullptr. - if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) { + if (U_FAILURE(status)) { delete fields; fields = nullptr; - status = U_MEMORY_ALLOCATION_ERROR; } } @@ -133,8 +126,8 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC void DecimalFormat::setParseAllInput(UNumberFormatAttributeValue value) { if (fields == nullptr) { return; } - if (value == fields->properties->parseAllInput) { return; } - fields->properties->parseAllInput = value; + if (value == fields->properties.parseAllInput) { return; } + fields->properties.parseAllInput = value; } #endif @@ -276,7 +269,7 @@ DecimalFormat::setAttribute(UNumberFormatAttribute attr, int32_t newValue, UErro int32_t DecimalFormat::getAttribute(UNumberFormatAttribute attr, UErrorCode& status) const { if (U_FAILURE(status)) { return -1; } - + if (fields == nullptr) { // We only get here if an OOM error happend during construction, copy construction, assignment, or modification. status = U_MEMORY_ALLOCATION_ERROR; @@ -379,9 +372,9 @@ void DecimalFormat::setGroupingUsed(UBool enabled) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(enabled) == fields->properties->groupingUsed) { return; } + if (UBOOL_TO_BOOL(enabled) == fields->properties.groupingUsed) { return; } NumberFormat::setGroupingUsed(enabled); // to set field for compatibility - fields->properties->groupingUsed = enabled; + fields->properties.groupingUsed = enabled; touchNoError(); } @@ -389,9 +382,9 @@ void DecimalFormat::setParseIntegerOnly(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseIntegerOnly) { return; } + if (UBOOL_TO_BOOL(value) == fields->properties.parseIntegerOnly) { return; } NumberFormat::setParseIntegerOnly(value); // to set field for compatibility - fields->properties->parseIntegerOnly = value; + fields->properties.parseIntegerOnly = value; touchNoError(); } @@ -400,9 +393,9 @@ void DecimalFormat::setLenient(UBool enable) { return; } ParseMode mode = enable ? PARSE_MODE_LENIENT : PARSE_MODE_STRICT; - if (!fields->properties->parseMode.isNull() && mode == fields->properties->parseMode.getNoError()) { return; } + if (!fields->properties.parseMode.isNull() && mode == fields->properties.parseMode.getNoError()) { return; } NumberFormat::setLenient(enable); // to set field for compatibility - fields->properties->parseMode = mode; + fields->properties.parseMode = mode; touchNoError(); } @@ -441,19 +434,16 @@ DecimalFormat::DecimalFormat(const DecimalFormat& source) : NumberFormat(source) // Note: it is not safe to copy fields->formatter or fWarehouse directly because fields->formatter might have // dangling pointers to fields inside fWarehouse. The safe thing is to re-construct fields->formatter from // the property bag, despite being somewhat slower. - fields = new DecimalFormatFields(); + fields = new DecimalFormatFields(source.fields->properties); if (fields == nullptr) { return; // no way to report an error. } UErrorCode status = U_ZERO_ERROR; - fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status); - fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(*source.fields->properties), status); fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(*source.fields->symbols), status); - fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); // In order to simplify error handling logic in the various getters/setters/etc, we do not allow // any partially populated DecimalFormatFields object. We must have a fully complete fields object // or else we set it to nullptr. - if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) { + if (U_FAILURE(status)) { delete fields; fields = nullptr; return; @@ -470,8 +460,8 @@ DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) { if (fields == nullptr || rhs.fields == nullptr) { return *this; // unfortunately, no way to report an error. } - *fields->properties = *rhs.fields->properties; - fields->exportedProperties->clear(); + fields->properties = rhs.fields->properties; + fields->exportedProperties.clear(); UErrorCode status = U_ZERO_ERROR; LocalPointer dfs(new DecimalFormatSymbols(*rhs.fields->symbols), status); if (U_FAILURE(status)) { @@ -495,7 +485,7 @@ DecimalFormat::~DecimalFormat() { delete fields; } -Format* DecimalFormat::clone() const { +DecimalFormat* DecimalFormat::clone() const { // can only clone valid objects. if (fields == nullptr) { return nullptr; @@ -517,7 +507,7 @@ UBool DecimalFormat::operator==(const Format& other) const { if (fields == nullptr || otherDF->fields == nullptr) { return false; } - return *fields->properties == *otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols; + return fields->properties == otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols; } UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const { @@ -529,7 +519,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie return appendTo; } UErrorCode localStatus = U_ZERO_ERROR; - FormattedNumber output = fields->formatter->formatDouble(number, localStatus); + FormattedNumber output = fields->formatter.formatDouble(number, localStatus); fieldPositionHelper(output, pos, appendTo.length(), localStatus); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, localStatus); @@ -550,7 +540,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie if (pos.getField() == FieldPosition::DONT_CARE && fastFormatDouble(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatDouble(number, status); + FormattedNumber output = fields->formatter.formatDouble(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -572,7 +562,7 @@ DecimalFormat::format(double number, UnicodeString& appendTo, FieldPositionItera if (posIter == nullptr && fastFormatDouble(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatDouble(number, status); + FormattedNumber output = fields->formatter.formatDouble(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -603,7 +593,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi return appendTo; } UErrorCode localStatus = U_ZERO_ERROR; - FormattedNumber output = fields->formatter->formatInt(number, localStatus); + FormattedNumber output = fields->formatter.formatInt(number, localStatus); fieldPositionHelper(output, pos, appendTo.length(), localStatus); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, localStatus); @@ -624,7 +614,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi if (pos.getField() == FieldPosition::DONT_CARE && fastFormatInt64(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatInt(number, status); + FormattedNumber output = fields->formatter.formatInt(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -646,7 +636,7 @@ DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPositionIter if (posIter == nullptr && fastFormatInt64(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatInt(number, status); + FormattedNumber output = fields->formatter.formatInt(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -665,7 +655,7 @@ DecimalFormat::format(StringPiece number, UnicodeString& appendTo, FieldPosition appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimal(number, status); + FormattedNumber output = fields->formatter.formatDecimal(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -683,7 +673,7 @@ UnicodeString& DecimalFormat::format(const DecimalQuantity& number, UnicodeStrin appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status); + FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -702,7 +692,7 @@ DecimalFormat::format(const DecimalQuantity& number, UnicodeString& appendTo, Fi appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status); + FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -823,7 +813,7 @@ const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo(void) const { if (fields == nullptr) { return nullptr; } - return fields->properties->currencyPluralInfo.fPtr.getAlias(); + return fields->properties.currencyPluralInfo.fPtr.getAlias(); } void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) { @@ -833,7 +823,7 @@ void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) { if (fields == nullptr) { return; } - fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); touchNoError(); } @@ -841,11 +831,11 @@ void DecimalFormat::setCurrencyPluralInfo(const CurrencyPluralInfo& info) { if (fields == nullptr) { return; } - if (fields->properties->currencyPluralInfo.fPtr.isNull()) { + if (fields->properties.currencyPluralInfo.fPtr.isNull()) { // Note: clone() can fail with OOM error, but we have no way to report it. :( - fields->properties->currencyPluralInfo.fPtr.adoptInstead(info.clone()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(info.clone()); } else { - *fields->properties->currencyPluralInfo.fPtr = info; // copy-assignment operator + *fields->properties.currencyPluralInfo.fPtr = info; // copy-assignment operator } touchNoError(); } @@ -856,7 +846,7 @@ UnicodeString& DecimalFormat::getPositivePrefix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(true, false, result, status); + fields->formatter.getAffixImpl(true, false, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -865,8 +855,8 @@ void DecimalFormat::setPositivePrefix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->positivePrefix) { return; } - fields->properties->positivePrefix = newValue; + if (newValue == fields->properties.positivePrefix) { return; } + fields->properties.positivePrefix = newValue; touchNoError(); } @@ -876,7 +866,7 @@ UnicodeString& DecimalFormat::getNegativePrefix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(true, true, result, status); + fields->formatter.getAffixImpl(true, true, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -885,8 +875,8 @@ void DecimalFormat::setNegativePrefix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->negativePrefix) { return; } - fields->properties->negativePrefix = newValue; + if (newValue == fields->properties.negativePrefix) { return; } + fields->properties.negativePrefix = newValue; touchNoError(); } @@ -896,7 +886,7 @@ UnicodeString& DecimalFormat::getPositiveSuffix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(false, false, result, status); + fields->formatter.getAffixImpl(false, false, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -905,8 +895,8 @@ void DecimalFormat::setPositiveSuffix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->positiveSuffix) { return; } - fields->properties->positiveSuffix = newValue; + if (newValue == fields->properties.positiveSuffix) { return; } + fields->properties.positiveSuffix = newValue; touchNoError(); } @@ -916,7 +906,7 @@ UnicodeString& DecimalFormat::getNegativeSuffix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(false, true, result, status); + fields->formatter.getAffixImpl(false, true, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -925,8 +915,8 @@ void DecimalFormat::setNegativeSuffix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->negativeSuffix) { return; } - fields->properties->negativeSuffix = newValue; + if (newValue == fields->properties.negativeSuffix) { return; } + fields->properties.negativeSuffix = newValue; touchNoError(); } @@ -935,13 +925,13 @@ UBool DecimalFormat::isSignAlwaysShown() const { if (fields == nullptr) { return DecimalFormatProperties::getDefault().signAlwaysShown; } - return fields->properties->signAlwaysShown; + return fields->properties.signAlwaysShown; } void DecimalFormat::setSignAlwaysShown(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->signAlwaysShown) { return; } - fields->properties->signAlwaysShown = value; + if (UBOOL_TO_BOOL(value) == fields->properties.signAlwaysShown) { return; } + fields->properties.signAlwaysShown = value; touchNoError(); } @@ -952,7 +942,7 @@ int32_t DecimalFormat::getMultiplier(void) const { // Fallback to using the default instance of DecimalFormatProperties. dfp = &(DecimalFormatProperties::getDefault()); } else { - dfp = fields->properties.getAlias(); + dfp = &fields->properties; } if (dfp->multiplier != 1) { return dfp->multiplier; @@ -984,11 +974,11 @@ void DecimalFormat::setMultiplier(int32_t multiplier) { value = temp; } if (delta != -1) { - fields->properties->magnitudeMultiplier = delta; - fields->properties->multiplier = 1; + fields->properties.magnitudeMultiplier = delta; + fields->properties.multiplier = 1; } else { - fields->properties->magnitudeMultiplier = 0; - fields->properties->multiplier = multiplier; + fields->properties.magnitudeMultiplier = 0; + fields->properties.multiplier = multiplier; } touchNoError(); } @@ -999,13 +989,13 @@ int32_t DecimalFormat::getMultiplierScale() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().multiplierScale; } - return fields->properties->multiplierScale; + return fields->properties.multiplierScale; } void DecimalFormat::setMultiplierScale(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->multiplierScale) { return; } - fields->properties->multiplierScale = newValue; + if (newValue == fields->properties.multiplierScale) { return; } + fields->properties.multiplierScale = newValue; touchNoError(); } @@ -1015,13 +1005,13 @@ double DecimalFormat::getRoundingIncrement(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().roundingIncrement; } - return fields->exportedProperties->roundingIncrement; + return fields->exportedProperties.roundingIncrement; } void DecimalFormat::setRoundingIncrement(double newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->roundingIncrement) { return; } - fields->properties->roundingIncrement = newValue; + if (newValue == fields->properties.roundingIncrement) { return; } + fields->properties.roundingIncrement = newValue; touchNoError(); } @@ -1032,17 +1022,17 @@ ERoundingMode DecimalFormat::getRoundingMode(void) const { return static_cast(DecimalFormatProperties::getDefault().roundingMode.getNoError()); } // UNumberFormatRoundingMode and ERoundingMode have the same values. - return static_cast(fields->exportedProperties->roundingMode.getNoError()); + return static_cast(fields->exportedProperties.roundingMode.getNoError()); } void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) { if (fields == nullptr) { return; } auto uRoundingMode = static_cast(roundingMode); - if (!fields->properties->roundingMode.isNull() && uRoundingMode == fields->properties->roundingMode.getNoError()) { + if (!fields->properties.roundingMode.isNull() && uRoundingMode == fields->properties.roundingMode.getNoError()) { return; } NumberFormat::setMaximumIntegerDigits(roundingMode); // to set field for compatibility - fields->properties->roundingMode = uRoundingMode; + fields->properties.roundingMode = uRoundingMode; touchNoError(); } @@ -1052,52 +1042,52 @@ int32_t DecimalFormat::getFormatWidth(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().formatWidth; } - return fields->properties->formatWidth; + return fields->properties.formatWidth; } void DecimalFormat::setFormatWidth(int32_t width) { if (fields == nullptr) { return; } - if (width == fields->properties->formatWidth) { return; } - fields->properties->formatWidth = width; + if (width == fields->properties.formatWidth) { return; } + fields->properties.formatWidth = width; touchNoError(); } UnicodeString DecimalFormat::getPadCharacterString() const { - if (fields == nullptr || fields->properties->padString.isBogus()) { + if (fields == nullptr || fields->properties.padString.isBogus()) { // Readonly-alias the static string kFallbackPaddingString return {TRUE, kFallbackPaddingString, -1}; } else { - return fields->properties->padString; + return fields->properties.padString; } } void DecimalFormat::setPadCharacter(const UnicodeString& padChar) { if (fields == nullptr) { return; } - if (padChar == fields->properties->padString) { return; } + if (padChar == fields->properties.padString) { return; } if (padChar.length() > 0) { - fields->properties->padString = UnicodeString(padChar.char32At(0)); + fields->properties.padString = UnicodeString(padChar.char32At(0)); } else { - fields->properties->padString.setToBogus(); + fields->properties.padString.setToBogus(); } touchNoError(); } EPadPosition DecimalFormat::getPadPosition(void) const { - if (fields == nullptr || fields->properties->padPosition.isNull()) { + if (fields == nullptr || fields->properties.padPosition.isNull()) { return EPadPosition::kPadBeforePrefix; } else { // UNumberFormatPadPosition and EPadPosition have the same values. - return static_cast(fields->properties->padPosition.getNoError()); + return static_cast(fields->properties.padPosition.getNoError()); } } void DecimalFormat::setPadPosition(EPadPosition padPos) { if (fields == nullptr) { return; } auto uPadPos = static_cast(padPos); - if (!fields->properties->padPosition.isNull() && uPadPos == fields->properties->padPosition.getNoError()) { + if (!fields->properties.padPosition.isNull() && uPadPos == fields->properties.padPosition.getNoError()) { return; } - fields->properties->padPosition = uPadPos; + fields->properties.padPosition = uPadPos; touchNoError(); } @@ -1107,17 +1097,17 @@ UBool DecimalFormat::isScientificNotation(void) const { // Fallback to using the default instance of DecimalFormatProperties. return (DecimalFormatProperties::getDefault().minimumExponentDigits != -1); } - return (fields->properties->minimumExponentDigits != -1); + return (fields->properties.minimumExponentDigits != -1); } void DecimalFormat::setScientificNotation(UBool useScientific) { if (fields == nullptr) { return; } int32_t minExp = useScientific ? 1 : -1; - if (fields->properties->minimumExponentDigits == minExp) { return; } + if (fields->properties.minimumExponentDigits == minExp) { return; } if (useScientific) { - fields->properties->minimumExponentDigits = 1; + fields->properties.minimumExponentDigits = 1; } else { - fields->properties->minimumExponentDigits = -1; + fields->properties.minimumExponentDigits = -1; } touchNoError(); } @@ -1128,13 +1118,13 @@ int8_t DecimalFormat::getMinimumExponentDigits(void) const { // Fallback to using the default instance of DecimalFormatProperties. return static_cast(DecimalFormatProperties::getDefault().minimumExponentDigits); } - return static_cast(fields->properties->minimumExponentDigits); + return static_cast(fields->properties.minimumExponentDigits); } void DecimalFormat::setMinimumExponentDigits(int8_t minExpDig) { if (fields == nullptr) { return; } - if (minExpDig == fields->properties->minimumExponentDigits) { return; } - fields->properties->minimumExponentDigits = minExpDig; + if (minExpDig == fields->properties.minimumExponentDigits) { return; } + fields->properties.minimumExponentDigits = minExpDig; touchNoError(); } @@ -1144,13 +1134,13 @@ UBool DecimalFormat::isExponentSignAlwaysShown(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().exponentSignAlwaysShown; } - return fields->properties->exponentSignAlwaysShown; + return fields->properties.exponentSignAlwaysShown; } void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(expSignAlways) == fields->properties->exponentSignAlwaysShown) { return; } - fields->properties->exponentSignAlwaysShown = expSignAlways; + if (UBOOL_TO_BOOL(expSignAlways) == fields->properties.exponentSignAlwaysShown) { return; } + fields->properties.exponentSignAlwaysShown = expSignAlways; touchNoError(); } @@ -1161,7 +1151,7 @@ int32_t DecimalFormat::getGroupingSize(void) const { // Fallback to using the default instance of DecimalFormatProperties. groupingSize = DecimalFormatProperties::getDefault().groupingSize; } else { - groupingSize = fields->properties->groupingSize; + groupingSize = fields->properties.groupingSize; } if (groupingSize < 0) { return 0; @@ -1171,8 +1161,8 @@ int32_t DecimalFormat::getGroupingSize(void) const { void DecimalFormat::setGroupingSize(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->groupingSize) { return; } - fields->properties->groupingSize = newValue; + if (newValue == fields->properties.groupingSize) { return; } + fields->properties.groupingSize = newValue; touchNoError(); } @@ -1183,7 +1173,7 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const { // Fallback to using the default instance of DecimalFormatProperties. grouping2 = DecimalFormatProperties::getDefault().secondaryGroupingSize; } else { - grouping2 = fields->properties->secondaryGroupingSize; + grouping2 = fields->properties.secondaryGroupingSize; } if (grouping2 < 0) { return 0; @@ -1193,8 +1183,8 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const { void DecimalFormat::setSecondaryGroupingSize(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->secondaryGroupingSize) { return; } - fields->properties->secondaryGroupingSize = newValue; + if (newValue == fields->properties.secondaryGroupingSize) { return; } + fields->properties.secondaryGroupingSize = newValue; touchNoError(); } @@ -1204,13 +1194,13 @@ int32_t DecimalFormat::getMinimumGroupingDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().minimumGroupingDigits; } - return fields->properties->minimumGroupingDigits; + return fields->properties.minimumGroupingDigits; } void DecimalFormat::setMinimumGroupingDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumGroupingDigits) { return; } - fields->properties->minimumGroupingDigits = newValue; + if (newValue == fields->properties.minimumGroupingDigits) { return; } + fields->properties.minimumGroupingDigits = newValue; touchNoError(); } @@ -1220,13 +1210,13 @@ UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().decimalSeparatorAlwaysShown; } - return fields->properties->decimalSeparatorAlwaysShown; + return fields->properties.decimalSeparatorAlwaysShown; } void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalSeparatorAlwaysShown) { return; } - fields->properties->decimalSeparatorAlwaysShown = newValue; + if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalSeparatorAlwaysShown) { return; } + fields->properties.decimalSeparatorAlwaysShown = newValue; touchNoError(); } @@ -1236,13 +1226,13 @@ UBool DecimalFormat::isDecimalPatternMatchRequired(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().decimalPatternMatchRequired; } - return fields->properties->decimalPatternMatchRequired; + return fields->properties.decimalPatternMatchRequired; } void DecimalFormat::setDecimalPatternMatchRequired(UBool newValue) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalPatternMatchRequired) { return; } - fields->properties->decimalPatternMatchRequired = newValue; + if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalPatternMatchRequired) { return; } + fields->properties.decimalPatternMatchRequired = newValue; touchNoError(); } @@ -1252,13 +1242,13 @@ UBool DecimalFormat::isParseNoExponent() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().parseNoExponent; } - return fields->properties->parseNoExponent; + return fields->properties.parseNoExponent; } void DecimalFormat::setParseNoExponent(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseNoExponent) { return; } - fields->properties->parseNoExponent = value; + if (UBOOL_TO_BOOL(value) == fields->properties.parseNoExponent) { return; } + fields->properties.parseNoExponent = value; touchNoError(); } @@ -1268,13 +1258,13 @@ UBool DecimalFormat::isParseCaseSensitive() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().parseCaseSensitive; } - return fields->properties->parseCaseSensitive; + return fields->properties.parseCaseSensitive; } void DecimalFormat::setParseCaseSensitive(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseCaseSensitive) { return; } - fields->properties->parseCaseSensitive = value; + if (UBOOL_TO_BOOL(value) == fields->properties.parseCaseSensitive) { return; } + fields->properties.parseCaseSensitive = value; touchNoError(); } @@ -1284,13 +1274,13 @@ UBool DecimalFormat::isFormatFailIfMoreThanMaxDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().formatFailIfMoreThanMaxDigits; } - return fields->properties->formatFailIfMoreThanMaxDigits; + return fields->properties.formatFailIfMoreThanMaxDigits; } void DecimalFormat::setFormatFailIfMoreThanMaxDigits(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->formatFailIfMoreThanMaxDigits) { return; } - fields->properties->formatFailIfMoreThanMaxDigits = value; + if (UBOOL_TO_BOOL(value) == fields->properties.formatFailIfMoreThanMaxDigits) { return; } + fields->properties.formatFailIfMoreThanMaxDigits = value; touchNoError(); } @@ -1305,7 +1295,7 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const { // so that CurrencyUsage is reflected properly. // TODO: Consider putting this logic in number_patternstring.cpp instead. ErrorCode localStatus; - DecimalFormatProperties tprops(*fields->properties); + DecimalFormatProperties tprops(fields->properties); bool useCurrency = ( !tprops.currency.isNull() || !tprops.currencyPluralInfo.fPtr.isNull() || @@ -1315,9 +1305,9 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const { AffixUtils::hasCurrencySymbols(tprops.negativePrefixPattern, localStatus) || AffixUtils::hasCurrencySymbols(tprops.negativeSuffixPattern, localStatus)); if (useCurrency) { - tprops.minimumFractionDigits = fields->exportedProperties->minimumFractionDigits; - tprops.maximumFractionDigits = fields->exportedProperties->maximumFractionDigits; - tprops.roundingIncrement = fields->exportedProperties->roundingIncrement; + tprops.minimumFractionDigits = fields->exportedProperties.minimumFractionDigits; + tprops.maximumFractionDigits = fields->exportedProperties.maximumFractionDigits; + tprops.roundingIncrement = fields->exportedProperties.roundingIncrement; } result = PatternStringUtils::propertiesToPatternString(tprops, localStatus); return result; @@ -1373,49 +1363,53 @@ void DecimalFormat::applyLocalizedPattern(const UnicodeString& localizedPattern, void DecimalFormat::setMaximumIntegerDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->maximumIntegerDigits) { return; } + if (newValue == fields->properties.maximumIntegerDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t min = fields->properties->minimumIntegerDigits; + int32_t min = fields->properties.minimumIntegerDigits; if (min >= 0 && min > newValue) { - fields->properties->minimumIntegerDigits = newValue; + fields->properties.minimumIntegerDigits = newValue; } - fields->properties->maximumIntegerDigits = newValue; + fields->properties.maximumIntegerDigits = newValue; touchNoError(); } void DecimalFormat::setMinimumIntegerDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumIntegerDigits) { return; } + if (newValue == fields->properties.minimumIntegerDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t max = fields->properties->maximumIntegerDigits; + int32_t max = fields->properties.maximumIntegerDigits; if (max >= 0 && max < newValue) { - fields->properties->maximumIntegerDigits = newValue; + fields->properties.maximumIntegerDigits = newValue; } - fields->properties->minimumIntegerDigits = newValue; + fields->properties.minimumIntegerDigits = newValue; touchNoError(); } void DecimalFormat::setMaximumFractionDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->maximumFractionDigits) { return; } + if (newValue == fields->properties.maximumFractionDigits) { return; } + // cap for backward compatibility, formerly 340, now 999 + if (newValue > kMaxIntFracSig) { + newValue = kMaxIntFracSig; + } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t min = fields->properties->minimumFractionDigits; + int32_t min = fields->properties.minimumFractionDigits; if (min >= 0 && min > newValue) { - fields->properties->minimumFractionDigits = newValue; + fields->properties.minimumFractionDigits = newValue; } - fields->properties->maximumFractionDigits = newValue; + fields->properties.maximumFractionDigits = newValue; touchNoError(); } void DecimalFormat::setMinimumFractionDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumFractionDigits) { return; } + if (newValue == fields->properties.minimumFractionDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t max = fields->properties->maximumFractionDigits; + int32_t max = fields->properties.maximumFractionDigits; if (max >= 0 && max < newValue) { - fields->properties->maximumFractionDigits = newValue; + fields->properties.maximumFractionDigits = newValue; } - fields->properties->minimumFractionDigits = newValue; + fields->properties.minimumFractionDigits = newValue; touchNoError(); } @@ -1425,7 +1419,7 @@ int32_t DecimalFormat::getMinimumSignificantDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().minimumSignificantDigits; } - return fields->exportedProperties->minimumSignificantDigits; + return fields->exportedProperties.minimumSignificantDigits; } int32_t DecimalFormat::getMaximumSignificantDigits() const { @@ -1434,28 +1428,28 @@ int32_t DecimalFormat::getMaximumSignificantDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().maximumSignificantDigits; } - return fields->exportedProperties->maximumSignificantDigits; + return fields->exportedProperties.maximumSignificantDigits; } void DecimalFormat::setMinimumSignificantDigits(int32_t value) { if (fields == nullptr) { return; } - if (value == fields->properties->minimumSignificantDigits) { return; } - int32_t max = fields->properties->maximumSignificantDigits; + if (value == fields->properties.minimumSignificantDigits) { return; } + int32_t max = fields->properties.maximumSignificantDigits; if (max >= 0 && max < value) { - fields->properties->maximumSignificantDigits = value; + fields->properties.maximumSignificantDigits = value; } - fields->properties->minimumSignificantDigits = value; + fields->properties.minimumSignificantDigits = value; touchNoError(); } void DecimalFormat::setMaximumSignificantDigits(int32_t value) { if (fields == nullptr) { return; } - if (value == fields->properties->maximumSignificantDigits) { return; } - int32_t min = fields->properties->minimumSignificantDigits; + if (value == fields->properties.maximumSignificantDigits) { return; } + int32_t min = fields->properties.minimumSignificantDigits; if (min >= 0 && min > value) { - fields->properties->minimumSignificantDigits = value; + fields->properties.minimumSignificantDigits = value; } - fields->properties->maximumSignificantDigits = value; + fields->properties.maximumSignificantDigits = value; touchNoError(); } @@ -1466,30 +1460,30 @@ UBool DecimalFormat::areSignificantDigitsUsed() const { // Fallback to using the default instance of DecimalFormatProperties. dfp = &(DecimalFormatProperties::getDefault()); } else { - dfp = fields->properties.getAlias(); + dfp = &fields->properties; } - return dfp->minimumSignificantDigits != -1 || dfp->maximumSignificantDigits != -1; + return dfp->minimumSignificantDigits != -1 || dfp->maximumSignificantDigits != -1; } void DecimalFormat::setSignificantDigitsUsed(UBool useSignificantDigits) { if (fields == nullptr) { return; } - + // These are the default values from the old implementation. if (useSignificantDigits) { - if (fields->properties->minimumSignificantDigits != -1 || - fields->properties->maximumSignificantDigits != -1) { + if (fields->properties.minimumSignificantDigits != -1 || + fields->properties.maximumSignificantDigits != -1) { return; } } else { - if (fields->properties->minimumSignificantDigits == -1 && - fields->properties->maximumSignificantDigits == -1) { + if (fields->properties.minimumSignificantDigits == -1 && + fields->properties.maximumSignificantDigits == -1) { return; } } int32_t minSig = useSignificantDigits ? 1 : -1; int32_t maxSig = useSignificantDigits ? 6 : -1; - fields->properties->minimumSignificantDigits = minSig; - fields->properties->maximumSignificantDigits = maxSig; + fields->properties.minimumSignificantDigits = minSig; + fields->properties.maximumSignificantDigits = maxSig; touchNoError(); } @@ -1503,11 +1497,11 @@ void DecimalFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) { } CurrencyUnit currencyUnit(theCurrency, ec); if (U_FAILURE(ec)) { return; } - if (!fields->properties->currency.isNull() && fields->properties->currency.getNoError() == currencyUnit) { + if (!fields->properties.currency.isNull() && fields->properties.currency.getNoError() == currencyUnit) { return; } NumberFormat::setCurrency(theCurrency, ec); // to set field for compatibility - fields->properties->currency = currencyUnit; + fields->properties.currency = currencyUnit; // TODO: Set values in fields->symbols, too? touchNoError(); } @@ -1525,20 +1519,20 @@ void DecimalFormat::setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec) { *ec = U_MEMORY_ALLOCATION_ERROR; return; } - if (!fields->properties->currencyUsage.isNull() && newUsage == fields->properties->currencyUsage.getNoError()) { + if (!fields->properties.currencyUsage.isNull() && newUsage == fields->properties.currencyUsage.getNoError()) { return; } - fields->properties->currencyUsage = newUsage; + fields->properties.currencyUsage = newUsage; touch(*ec); } UCurrencyUsage DecimalFormat::getCurrencyUsage() const { // CurrencyUsage is not exported, so we have to get it from the input property bag. // TODO: Should we export CurrencyUsage instead? - if (fields == nullptr || fields->properties->currencyUsage.isNull()) { + if (fields == nullptr || fields->properties.currencyUsage.isNull()) { return UCURR_USAGE_STANDARD; } - return fields->properties->currencyUsage.getNoError(); + return fields->properties.currencyUsage.getNoError(); } void @@ -1550,7 +1544,7 @@ DecimalFormat::formatToDecimalQuantity(double number, DecimalQuantity& output, U status = U_MEMORY_ALLOCATION_ERROR; return; } - fields->formatter->formatDouble(number, status).getDecimalQuantity(output, status); + fields->formatter.formatDouble(number, status).getDecimalQuantity(output, status); } void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQuantity& output, @@ -1564,7 +1558,7 @@ void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQu } UFormattedNumberData obj; number.populateDecimalQuantity(obj.quantity, status); - fields->formatter->formatImpl(&obj, status); + fields->formatter.formatImpl(&obj, status); output = std::move(obj.quantity); } @@ -1576,12 +1570,7 @@ const number::LocalizedNumberFormatter* DecimalFormat::toNumberFormatter(UErrorC status = U_MEMORY_ALLOCATION_ERROR; return nullptr; } - return &*fields->formatter; -} - -const number::LocalizedNumberFormatter& DecimalFormat::toNumberFormatter() const { - UErrorCode localStatus = U_ZERO_ERROR; - return *toNumberFormatter(localStatus); + return &fields->formatter; } /** Rebuilds the formatter object from the property bag. */ @@ -1605,12 +1594,12 @@ void DecimalFormat::touch(UErrorCode& status) { // so automatically recompute it here. The parser is a bit more expensive and is not needed until the // parse method is called, so defer that until needed. // TODO: Only update the pieces that changed instead of re-computing the whole formatter? - + // Since memory has already been allocated for the formatter, we can move assign a stack-allocated object // and don't need to call new. (Which is slower and could possibly fail). - *fields->formatter = NumberPropertyMapper::create( - *fields->properties, *fields->symbols, fields->warehouse, *fields->exportedProperties, status).locale( - locale); + fields->formatter = NumberPropertyMapper::create( + fields->properties, *fields->symbols, fields->warehouse, fields->exportedProperties, status + ).locale(locale); // Do this after fields->exportedProperties are set up setupFastFormat(); @@ -1620,13 +1609,13 @@ void DecimalFormat::touch(UErrorCode& status) { delete fields->atomicCurrencyParser.exchange(nullptr); // In order for the getters to work, we need to populate some fields in NumberFormat. - NumberFormat::setCurrency(fields->exportedProperties->currency.get(status).getISOCurrency(), status); - NumberFormat::setMaximumIntegerDigits(fields->exportedProperties->maximumIntegerDigits); - NumberFormat::setMinimumIntegerDigits(fields->exportedProperties->minimumIntegerDigits); - NumberFormat::setMaximumFractionDigits(fields->exportedProperties->maximumFractionDigits); - NumberFormat::setMinimumFractionDigits(fields->exportedProperties->minimumFractionDigits); + NumberFormat::setCurrency(fields->exportedProperties.currency.get(status).getISOCurrency(), status); + NumberFormat::setMaximumIntegerDigits(fields->exportedProperties.maximumIntegerDigits); + NumberFormat::setMinimumIntegerDigits(fields->exportedProperties.minimumIntegerDigits); + NumberFormat::setMaximumFractionDigits(fields->exportedProperties.maximumFractionDigits); + NumberFormat::setMinimumFractionDigits(fields->exportedProperties.minimumFractionDigits); // fImpl->properties, not fields->exportedProperties, since this information comes from the pattern: - NumberFormat::setGroupingUsed(fields->properties->groupingUsed); + NumberFormat::setGroupingUsed(fields->properties.groupingUsed); } void DecimalFormat::touchNoError() { @@ -1639,7 +1628,7 @@ void DecimalFormat::setPropertiesFromPattern(const UnicodeString& pattern, int32 if (U_SUCCESS(status)) { // Cast workaround to get around putting the enum in the public header file auto actualIgnoreRounding = static_cast(ignoreRounding); - PatternParser::parseToExistingProperties(pattern, *fields->properties, actualIgnoreRounding, status); + PatternParser::parseToExistingProperties(pattern, fields->properties, actualIgnoreRounding, status); } } @@ -1658,7 +1647,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getParser(UErrorCode& sta } // Try computing the parser on our own - auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, false, status); + auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, false, status); if (U_FAILURE(status)) { return nullptr; } @@ -1691,7 +1680,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC } // Try computing the parser on our own - auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, true, status); + auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, true, status); if (temp == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; // although we may still dereference, call sites should be guarded @@ -1739,7 +1728,7 @@ DecimalFormat::fieldPositionIteratorHelper(const number::FormattedNumber& format void DecimalFormat::setupFastFormat() { // Check the majority of properties: - if (!fields->properties->equalsDefaultExceptFastFormat()) { + if (!fields->properties.equalsDefaultExceptFastFormat()) { trace("no fast format: equality\n"); fields->canUseFastFormat = false; return; @@ -1747,12 +1736,12 @@ void DecimalFormat::setupFastFormat() { // Now check the remaining properties. // Nontrivial affixes: - UBool trivialPP = fields->properties->positivePrefixPattern.isEmpty(); - UBool trivialPS = fields->properties->positiveSuffixPattern.isEmpty(); - UBool trivialNP = fields->properties->negativePrefixPattern.isBogus() || ( - fields->properties->negativePrefixPattern.length() == 1 && - fields->properties->negativePrefixPattern.charAt(0) == u'-'); - UBool trivialNS = fields->properties->negativeSuffixPattern.isEmpty(); + UBool trivialPP = fields->properties.positivePrefixPattern.isEmpty(); + UBool trivialPS = fields->properties.positiveSuffixPattern.isEmpty(); + UBool trivialNP = fields->properties.negativePrefixPattern.isBogus() || ( + fields->properties.negativePrefixPattern.length() == 1 && + fields->properties.negativePrefixPattern.charAt(0) == u'-'); + UBool trivialNS = fields->properties.negativeSuffixPattern.isEmpty(); if (!trivialPP || !trivialPS || !trivialNP || !trivialNS) { trace("no fast format: affixes\n"); fields->canUseFastFormat = false; @@ -1760,8 +1749,8 @@ void DecimalFormat::setupFastFormat() { } // Grouping (secondary grouping is forbidden in equalsDefaultExceptFastFormat): - bool groupingUsed = fields->properties->groupingUsed; - int32_t groupingSize = fields->properties->groupingSize; + bool groupingUsed = fields->properties.groupingUsed; + int32_t groupingSize = fields->properties.groupingSize; bool unusualGroupingSize = groupingSize > 0 && groupingSize != 3; const UnicodeString& groupingString = fields->symbols->getConstSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol); if (groupingUsed && (unusualGroupingSize || groupingString.length() != 1)) { @@ -1771,8 +1760,8 @@ void DecimalFormat::setupFastFormat() { } // Integer length: - int32_t minInt = fields->exportedProperties->minimumIntegerDigits; - int32_t maxInt = fields->exportedProperties->maximumIntegerDigits; + int32_t minInt = fields->exportedProperties.minimumIntegerDigits; + int32_t maxInt = fields->exportedProperties.maximumIntegerDigits; // Fastpath supports up to only 10 digits (length of INT32_MIN) if (minInt > 10) { trace("no fast format: integer\n"); @@ -1781,7 +1770,7 @@ void DecimalFormat::setupFastFormat() { } // Fraction length (no fraction part allowed in fast path): - int32_t minFrac = fields->exportedProperties->minimumFractionDigits; + int32_t minFrac = fields->exportedProperties.minimumFractionDigits; if (minFrac > 0) { trace("no fast format: fraction\n"); fields->canUseFastFormat = false; diff --git a/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp b/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp index 2add399f87c91f..a95910df0421d1 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp +++ b/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp @@ -49,7 +49,7 @@ U_NAMESPACE_BEGIN namespace double_conversion { static int NormalizedExponent(uint64_t significand, int exponent) { - ASSERT(significand != 0); + DOUBLE_CONVERSION_ASSERT(significand != 0); while ((significand & Double::kHiddenBit) == 0) { significand = significand << 1; exponent = exponent - 1; @@ -90,26 +90,26 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // Generates 'requested_digits' after the decimal point. static void BignumToFixed(int requested_digits, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length); + Vector buffer, int* length); // Generates 'count' digits of numerator/denominator. // Once 'count' digits have been produced rounds the result depending on the // remainder (remainders of exactly .5 round upwards). Might update the // decimal_point when rounding up (for example for 0.9999). static void GenerateCountedDigits(int count, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length); + Vector buffer, int* length); void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, Vector buffer, int* length, int* decimal_point) { - ASSERT(v > 0); - ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(v > 0); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); uint64_t significand; int exponent; bool lower_boundary_is_closer; if (mode == BIGNUM_DTOA_SHORTEST_SINGLE) { float f = static_cast(v); - ASSERT(f == v); + DOUBLE_CONVERSION_ASSERT(f == v); significand = Single(f).Significand(); exponent = Single(f).Exponent(); lower_boundary_is_closer = Single(f).LowerBoundaryIsCloser(); @@ -148,7 +148,7 @@ void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, // 4e-324. In this case the denominator needs fewer than 324*4 binary digits. // The maximum double is 1.7976931348623157e308 which needs fewer than // 308*4 binary digits. - ASSERT(Bignum::kMaxSignificantBits >= 324*4); + DOUBLE_CONVERSION_ASSERT(Bignum::kMaxSignificantBits >= 324*4); InitialScaledStartValues(significand, exponent, lower_boundary_is_closer, estimated_power, need_boundary_deltas, &numerator, &denominator, @@ -177,7 +177,7 @@ void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, buffer, length); break; default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } buffer[*length] = '\0'; } @@ -209,7 +209,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, for (;;) { uint16_t digit; digit = numerator->DivideModuloIntBignum(*denominator); - ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. + DOUBLE_CONVERSION_ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. // digit = numerator / denominator (integer division). // numerator = numerator % denominator. buffer[(*length)++] = static_cast(digit + '0'); @@ -255,7 +255,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // loop would have stopped earlier. // We still have an assert here in case the preconditions were not // satisfied. - ASSERT(buffer[(*length) - 1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); buffer[(*length) - 1]++; } else { // Halfway case. @@ -266,7 +266,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, if ((buffer[(*length) - 1] - '0') % 2 == 0) { // Round down => Do nothing. } else { - ASSERT(buffer[(*length) - 1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); buffer[(*length) - 1]++; } } @@ -278,9 +278,9 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // Round up. // Note again that the last digit could not be '9' since this would have // stopped the loop earlier. - // We still have an ASSERT here, in case the preconditions were not + // We still have an DOUBLE_CONVERSION_ASSERT here, in case the preconditions were not // satisfied. - ASSERT(buffer[(*length) -1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) -1] != '9'); buffer[(*length) - 1]++; return; } @@ -297,11 +297,11 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, static void GenerateCountedDigits(int count, int* decimal_point, Bignum* numerator, Bignum* denominator, Vector buffer, int* length) { - ASSERT(count >= 0); + DOUBLE_CONVERSION_ASSERT(count >= 0); for (int i = 0; i < count - 1; ++i) { uint16_t digit; digit = numerator->DivideModuloIntBignum(*denominator); - ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. + DOUBLE_CONVERSION_ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. // digit = numerator / denominator (integer division). // numerator = numerator % denominator. buffer[i] = static_cast(digit + '0'); @@ -314,7 +314,7 @@ static void GenerateCountedDigits(int count, int* decimal_point, if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) { digit++; } - ASSERT(digit <= 10); + DOUBLE_CONVERSION_ASSERT(digit <= 10); buffer[count - 1] = static_cast(digit + '0'); // Correct bad digits (in case we had a sequence of '9's). Propagate the // carry until we hat a non-'9' or til we reach the first digit. @@ -339,7 +339,7 @@ static void GenerateCountedDigits(int count, int* decimal_point, // Input verifies: 1 <= (numerator + delta) / denominator < 10. static void BignumToFixed(int requested_digits, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length) { + Vector buffer, int* length) { // Note that we have to look at more than just the requested_digits, since // a number could be rounded up. Example: v=0.5 with requested_digits=0. // Even though the power of v equals 0 we can't just stop here. @@ -355,7 +355,7 @@ static void BignumToFixed(int requested_digits, int* decimal_point, } else if (-(*decimal_point) == requested_digits) { // We only need to verify if the number rounds down or up. // Ex: 0.04 and 0.06 with requested_digits == 1. - ASSERT(*decimal_point == -requested_digits); + DOUBLE_CONVERSION_ASSERT(*decimal_point == -requested_digits); // Initially the fraction lies in range (1, 10]. Multiply the denominator // by 10 so that we can compare more easily. denominator->Times10(); @@ -434,7 +434,7 @@ static void InitialScaledStartValuesPositiveExponent( Bignum* numerator, Bignum* denominator, Bignum* delta_minus, Bignum* delta_plus) { // A positive exponent implies a positive power. - ASSERT(estimated_power >= 0); + DOUBLE_CONVERSION_ASSERT(estimated_power >= 0); // Since the estimated_power is positive we simply multiply the denominator // by 10^estimated_power. @@ -520,7 +520,7 @@ static void InitialScaledStartValuesNegativeExponentNegativePower( // numerator = v * 10^-estimated_power * 2 * 2^-exponent. // Remember: numerator has been abused as power_ten. So no need to assign it // to itself. - ASSERT(numerator == power_ten); + DOUBLE_CONVERSION_ASSERT(numerator == power_ten); numerator->MultiplyByUInt64(significand); // denominator = 2 * 2^-exponent with exponent < 0. diff --git a/deps/icu-small/source/i18n/double-conversion-bignum.cpp b/deps/icu-small/source/i18n/double-conversion-bignum.cpp index 5356923921c3c1..996d75c9f60a14 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum.cpp +++ b/deps/icu-small/source/i18n/double-conversion-bignum.cpp @@ -34,6 +34,9 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING +#include +#include + // ICU PATCH: Customize header file paths for ICU. #include "double-conversion-bignum.h" @@ -44,136 +47,129 @@ U_NAMESPACE_BEGIN namespace double_conversion { -Bignum::Bignum() - : bigits_buffer_(), bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) { - for (int i = 0; i < kBigitCapacity; ++i) { - bigits_[i] = 0; - } +Bignum::Chunk& Bignum::RawBigit(const int index) { + DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); + return bigits_buffer_[index]; +} + + +const Bignum::Chunk& Bignum::RawBigit(const int index) const { + DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); + return bigits_buffer_[index]; } template -static int BitSize(S value) { +static int BitSize(const S value) { (void) value; // Mark variable as used. return 8 * sizeof(value); } // Guaranteed to lie in one Bigit. -void Bignum::AssignUInt16(uint16_t value) { - ASSERT(kBigitSize >= BitSize(value)); +void Bignum::AssignUInt16(const uint16_t value) { + DOUBLE_CONVERSION_ASSERT(kBigitSize >= BitSize(value)); Zero(); - if (value == 0) return; - - EnsureCapacity(1); - bigits_[0] = value; - used_digits_ = 1; + if (value > 0) { + RawBigit(0) = value; + used_bigits_ = 1; + } } void Bignum::AssignUInt64(uint64_t value) { - const int kUInt64Size = 64; - Zero(); - if (value == 0) return; - - int needed_bigits = kUInt64Size / kBigitSize + 1; - EnsureCapacity(needed_bigits); - for (int i = 0; i < needed_bigits; ++i) { - bigits_[i] = value & kBigitMask; - value = value >> kBigitSize; + for(int i = 0; value > 0; ++i) { + RawBigit(i) = value & kBigitMask; + value >>= kBigitSize; + ++used_bigits_; } - used_digits_ = needed_bigits; - Clamp(); } void Bignum::AssignBignum(const Bignum& other) { exponent_ = other.exponent_; - for (int i = 0; i < other.used_digits_; ++i) { - bigits_[i] = other.bigits_[i]; + for (int i = 0; i < other.used_bigits_; ++i) { + RawBigit(i) = other.RawBigit(i); } - // Clear the excess digits (if there were any). - for (int i = other.used_digits_; i < used_digits_; ++i) { - bigits_[i] = 0; - } - used_digits_ = other.used_digits_; + used_bigits_ = other.used_bigits_; } -static uint64_t ReadUInt64(Vector buffer, - int from, - int digits_to_read) { +static uint64_t ReadUInt64(const Vector buffer, + const int from, + const int digits_to_read) { uint64_t result = 0; for (int i = from; i < from + digits_to_read; ++i) { - int digit = buffer[i] - '0'; - ASSERT(0 <= digit && digit <= 9); + const int digit = buffer[i] - '0'; + DOUBLE_CONVERSION_ASSERT(0 <= digit && digit <= 9); result = result * 10 + digit; } return result; } -void Bignum::AssignDecimalString(Vector value) { +void Bignum::AssignDecimalString(const Vector value) { // 2^64 = 18446744073709551616 > 10^19 - const int kMaxUint64DecimalDigits = 19; + static const int kMaxUint64DecimalDigits = 19; Zero(); int length = value.length(); - unsigned int pos = 0; + unsigned pos = 0; // Let's just say that each digit needs 4 bits. while (length >= kMaxUint64DecimalDigits) { - uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); + const uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); pos += kMaxUint64DecimalDigits; length -= kMaxUint64DecimalDigits; MultiplyByPowerOfTen(kMaxUint64DecimalDigits); AddUInt64(digits); } - uint64_t digits = ReadUInt64(value, pos, length); + const uint64_t digits = ReadUInt64(value, pos, length); MultiplyByPowerOfTen(length); AddUInt64(digits); Clamp(); } -static int HexCharValue(char c) { - if ('0' <= c && c <= '9') return c - '0'; - if ('a' <= c && c <= 'f') return 10 + c - 'a'; - ASSERT('A' <= c && c <= 'F'); +static uint64_t HexCharValue(const int c) { + if ('0' <= c && c <= '9') { + return c - '0'; + } + if ('a' <= c && c <= 'f') { + return 10 + c - 'a'; + } + DOUBLE_CONVERSION_ASSERT('A' <= c && c <= 'F'); return 10 + c - 'A'; } +// Unlike AssignDecimalString(), this function is "only" used +// for unit-tests and therefore not performance critical. void Bignum::AssignHexString(Vector value) { Zero(); - int length = value.length(); - - int needed_bigits = length * 4 / kBigitSize + 1; - EnsureCapacity(needed_bigits); - int string_index = length - 1; - for (int i = 0; i < needed_bigits - 1; ++i) { - // These bigits are guaranteed to be "full". - Chunk current_bigit = 0; - for (int j = 0; j < kBigitSize / 4; j++) { - current_bigit += HexCharValue(value[string_index--]) << (j * 4); + // Required capacity could be reduced by ignoring leading zeros. + EnsureCapacity(((value.length() * 4) + kBigitSize - 1) / kBigitSize); + DOUBLE_CONVERSION_ASSERT(sizeof(uint64_t) * 8 >= kBigitSize + 4); // TODO: static_assert + // Accumulates converted hex digits until at least kBigitSize bits. + // Works with non-factor-of-four kBigitSizes. + uint64_t tmp = 0; // Accumulates converted hex digits until at least + for (int cnt = 0; !value.is_empty(); value.pop_back()) { + tmp |= (HexCharValue(value.last()) << cnt); + if ((cnt += 4) >= kBigitSize) { + RawBigit(used_bigits_++) = (tmp & kBigitMask); + cnt -= kBigitSize; + tmp >>= kBigitSize; } - bigits_[i] = current_bigit; - } - used_digits_ = needed_bigits - 1; - - Chunk most_significant_bigit = 0; // Could be = 0; - for (int j = 0; j <= string_index; ++j) { - most_significant_bigit <<= 4; - most_significant_bigit += HexCharValue(value[j]); } - if (most_significant_bigit != 0) { - bigits_[used_digits_] = most_significant_bigit; - used_digits_++; + if (tmp > 0) { + RawBigit(used_bigits_++) = tmp; } Clamp(); } -void Bignum::AddUInt64(uint64_t operand) { - if (operand == 0) return; +void Bignum::AddUInt64(const uint64_t operand) { + if (operand == 0) { + return; + } Bignum other; other.AssignUInt64(operand); AddBignum(other); @@ -181,8 +177,8 @@ void Bignum::AddUInt64(uint64_t operand) { void Bignum::AddBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); // If this has a greater exponent than other append zero-bigits to this. // After this call exponent_ <= other.exponent_. @@ -200,48 +196,52 @@ void Bignum::AddBignum(const Bignum& other) { // cccccccccccc 0000 // In both cases we might need a carry bigit. - EnsureCapacity(1 + Max(BigitLength(), other.BigitLength()) - exponent_); + EnsureCapacity(1 + (std::max)(BigitLength(), other.BigitLength()) - exponent_); Chunk carry = 0; int bigit_pos = other.exponent_ - exponent_; - ASSERT(bigit_pos >= 0); - for (int i = 0; i < other.used_digits_; ++i) { - Chunk sum = bigits_[bigit_pos] + other.bigits_[i] + carry; - bigits_[bigit_pos] = sum & kBigitMask; + DOUBLE_CONVERSION_ASSERT(bigit_pos >= 0); + for (int i = used_bigits_; i < bigit_pos; ++i) { + RawBigit(i) = 0; + } + for (int i = 0; i < other.used_bigits_; ++i) { + const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; + const Chunk sum = my + other.RawBigit(i) + carry; + RawBigit(bigit_pos) = sum & kBigitMask; carry = sum >> kBigitSize; - bigit_pos++; + ++bigit_pos; } - while (carry != 0) { - Chunk sum = bigits_[bigit_pos] + carry; - bigits_[bigit_pos] = sum & kBigitMask; + const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; + const Chunk sum = my + carry; + RawBigit(bigit_pos) = sum & kBigitMask; carry = sum >> kBigitSize; - bigit_pos++; + ++bigit_pos; } - used_digits_ = Max(bigit_pos, used_digits_); - ASSERT(IsClamped()); + used_bigits_ = (std::max)(bigit_pos, static_cast(used_bigits_)); + DOUBLE_CONVERSION_ASSERT(IsClamped()); } void Bignum::SubtractBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); // We require this to be bigger than other. - ASSERT(LessEqual(other, *this)); + DOUBLE_CONVERSION_ASSERT(LessEqual(other, *this)); Align(other); - int offset = other.exponent_ - exponent_; + const int offset = other.exponent_ - exponent_; Chunk borrow = 0; int i; - for (i = 0; i < other.used_digits_; ++i) { - ASSERT((borrow == 0) || (borrow == 1)); - Chunk difference = bigits_[i + offset] - other.bigits_[i] - borrow; - bigits_[i + offset] = difference & kBigitMask; + for (i = 0; i < other.used_bigits_; ++i) { + DOUBLE_CONVERSION_ASSERT((borrow == 0) || (borrow == 1)); + const Chunk difference = RawBigit(i + offset) - other.RawBigit(i) - borrow; + RawBigit(i + offset) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); } while (borrow != 0) { - Chunk difference = bigits_[i + offset] - borrow; - bigits_[i + offset] = difference & kBigitMask; + const Chunk difference = RawBigit(i + offset) - borrow; + RawBigit(i + offset) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); ++i; } @@ -249,91 +249,105 @@ void Bignum::SubtractBignum(const Bignum& other) { } -void Bignum::ShiftLeft(int shift_amount) { - if (used_digits_ == 0) return; - exponent_ += shift_amount / kBigitSize; - int local_shift = shift_amount % kBigitSize; - EnsureCapacity(used_digits_ + 1); +void Bignum::ShiftLeft(const int shift_amount) { + if (used_bigits_ == 0) { + return; + } + exponent_ += (shift_amount / kBigitSize); + const int local_shift = shift_amount % kBigitSize; + EnsureCapacity(used_bigits_ + 1); BigitsShiftLeft(local_shift); } -void Bignum::MultiplyByUInt32(uint32_t factor) { - if (factor == 1) return; +void Bignum::MultiplyByUInt32(const uint32_t factor) { + if (factor == 1) { + return; + } if (factor == 0) { Zero(); return; } - if (used_digits_ == 0) return; - + if (used_bigits_ == 0) { + return; + } // The product of a bigit with the factor is of size kBigitSize + 32. // Assert that this number + 1 (for the carry) fits into double chunk. - ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1); + DOUBLE_CONVERSION_ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1); DoubleChunk carry = 0; - for (int i = 0; i < used_digits_; ++i) { - DoubleChunk product = static_cast(factor) * bigits_[i] + carry; - bigits_[i] = static_cast(product & kBigitMask); + for (int i = 0; i < used_bigits_; ++i) { + const DoubleChunk product = static_cast(factor) * RawBigit(i) + carry; + RawBigit(i) = static_cast(product & kBigitMask); carry = (product >> kBigitSize); } while (carry != 0) { - EnsureCapacity(used_digits_ + 1); - bigits_[used_digits_] = carry & kBigitMask; - used_digits_++; + EnsureCapacity(used_bigits_ + 1); + RawBigit(used_bigits_) = carry & kBigitMask; + used_bigits_++; carry >>= kBigitSize; } } -void Bignum::MultiplyByUInt64(uint64_t factor) { - if (factor == 1) return; +void Bignum::MultiplyByUInt64(const uint64_t factor) { + if (factor == 1) { + return; + } if (factor == 0) { Zero(); return; } - ASSERT(kBigitSize < 32); + if (used_bigits_ == 0) { + return; + } + DOUBLE_CONVERSION_ASSERT(kBigitSize < 32); uint64_t carry = 0; - uint64_t low = factor & 0xFFFFFFFF; - uint64_t high = factor >> 32; - for (int i = 0; i < used_digits_; ++i) { - uint64_t product_low = low * bigits_[i]; - uint64_t product_high = high * bigits_[i]; - uint64_t tmp = (carry & kBigitMask) + product_low; - bigits_[i] = tmp & kBigitMask; + const uint64_t low = factor & 0xFFFFFFFF; + const uint64_t high = factor >> 32; + for (int i = 0; i < used_bigits_; ++i) { + const uint64_t product_low = low * RawBigit(i); + const uint64_t product_high = high * RawBigit(i); + const uint64_t tmp = (carry & kBigitMask) + product_low; + RawBigit(i) = tmp & kBigitMask; carry = (carry >> kBigitSize) + (tmp >> kBigitSize) + (product_high << (32 - kBigitSize)); } while (carry != 0) { - EnsureCapacity(used_digits_ + 1); - bigits_[used_digits_] = carry & kBigitMask; - used_digits_++; + EnsureCapacity(used_bigits_ + 1); + RawBigit(used_bigits_) = carry & kBigitMask; + used_bigits_++; carry >>= kBigitSize; } } -void Bignum::MultiplyByPowerOfTen(int exponent) { - const uint64_t kFive27 = UINT64_2PART_C(0x6765c793, fa10079d); - const uint16_t kFive1 = 5; - const uint16_t kFive2 = kFive1 * 5; - const uint16_t kFive3 = kFive2 * 5; - const uint16_t kFive4 = kFive3 * 5; - const uint16_t kFive5 = kFive4 * 5; - const uint16_t kFive6 = kFive5 * 5; - const uint32_t kFive7 = kFive6 * 5; - const uint32_t kFive8 = kFive7 * 5; - const uint32_t kFive9 = kFive8 * 5; - const uint32_t kFive10 = kFive9 * 5; - const uint32_t kFive11 = kFive10 * 5; - const uint32_t kFive12 = kFive11 * 5; - const uint32_t kFive13 = kFive12 * 5; - const uint32_t kFive1_to_12[] = +void Bignum::MultiplyByPowerOfTen(const int exponent) { + static const uint64_t kFive27 = DOUBLE_CONVERSION_UINT64_2PART_C(0x6765c793, fa10079d); + static const uint16_t kFive1 = 5; + static const uint16_t kFive2 = kFive1 * 5; + static const uint16_t kFive3 = kFive2 * 5; + static const uint16_t kFive4 = kFive3 * 5; + static const uint16_t kFive5 = kFive4 * 5; + static const uint16_t kFive6 = kFive5 * 5; + static const uint32_t kFive7 = kFive6 * 5; + static const uint32_t kFive8 = kFive7 * 5; + static const uint32_t kFive9 = kFive8 * 5; + static const uint32_t kFive10 = kFive9 * 5; + static const uint32_t kFive11 = kFive10 * 5; + static const uint32_t kFive12 = kFive11 * 5; + static const uint32_t kFive13 = kFive12 * 5; + static const uint32_t kFive1_to_12[] = { kFive1, kFive2, kFive3, kFive4, kFive5, kFive6, kFive7, kFive8, kFive9, kFive10, kFive11, kFive12 }; - ASSERT(exponent >= 0); - if (exponent == 0) return; - if (used_digits_ == 0) return; + DOUBLE_CONVERSION_ASSERT(exponent >= 0); + if (exponent == 0) { + return; + } + if (used_bigits_ == 0) { + return; + } // We shift by exponent at the end just before returning. int remaining_exponent = exponent; while (remaining_exponent >= 27) { @@ -352,8 +366,8 @@ void Bignum::MultiplyByPowerOfTen(int exponent) { void Bignum::Square() { - ASSERT(IsClamped()); - int product_length = 2 * used_digits_; + DOUBLE_CONVERSION_ASSERT(IsClamped()); + const int product_length = 2 * used_bigits_; EnsureCapacity(product_length); // Comba multiplication: compute each column separately. @@ -368,64 +382,64 @@ void Bignum::Square() { // // Assert that the additional number of bits in a DoubleChunk are enough to // sum up used_digits of Bigit*Bigit. - if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_digits_) { - UNIMPLEMENTED(); + if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_bigits_) { + DOUBLE_CONVERSION_UNIMPLEMENTED(); } DoubleChunk accumulator = 0; // First shift the digits so we don't overwrite them. - int copy_offset = used_digits_; - for (int i = 0; i < used_digits_; ++i) { - bigits_[copy_offset + i] = bigits_[i]; + const int copy_offset = used_bigits_; + for (int i = 0; i < used_bigits_; ++i) { + RawBigit(copy_offset + i) = RawBigit(i); } // We have two loops to avoid some 'if's in the loop. - for (int i = 0; i < used_digits_; ++i) { + for (int i = 0; i < used_bigits_; ++i) { // Process temporary digit i with power i. // The sum of the two indices must be equal to i. int bigit_index1 = i; int bigit_index2 = 0; // Sum all of the sub-products. while (bigit_index1 >= 0) { - Chunk chunk1 = bigits_[copy_offset + bigit_index1]; - Chunk chunk2 = bigits_[copy_offset + bigit_index2]; + const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); + const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); accumulator += static_cast(chunk1) * chunk2; bigit_index1--; bigit_index2++; } - bigits_[i] = static_cast(accumulator) & kBigitMask; + RawBigit(i) = static_cast(accumulator) & kBigitMask; accumulator >>= kBigitSize; } - for (int i = used_digits_; i < product_length; ++i) { - int bigit_index1 = used_digits_ - 1; + for (int i = used_bigits_; i < product_length; ++i) { + int bigit_index1 = used_bigits_ - 1; int bigit_index2 = i - bigit_index1; // Invariant: sum of both indices is again equal to i. // Inner loop runs 0 times on last iteration, emptying accumulator. - while (bigit_index2 < used_digits_) { - Chunk chunk1 = bigits_[copy_offset + bigit_index1]; - Chunk chunk2 = bigits_[copy_offset + bigit_index2]; + while (bigit_index2 < used_bigits_) { + const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); + const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); accumulator += static_cast(chunk1) * chunk2; bigit_index1--; bigit_index2++; } - // The overwritten bigits_[i] will never be read in further loop iterations, + // The overwritten RawBigit(i) will never be read in further loop iterations, // because bigit_index1 and bigit_index2 are always greater - // than i - used_digits_. - bigits_[i] = static_cast(accumulator) & kBigitMask; + // than i - used_bigits_. + RawBigit(i) = static_cast(accumulator) & kBigitMask; accumulator >>= kBigitSize; } // Since the result was guaranteed to lie inside the number the // accumulator must be 0 now. - ASSERT(accumulator == 0); + DOUBLE_CONVERSION_ASSERT(accumulator == 0); // Don't forget to update the used_digits and the exponent. - used_digits_ = product_length; + used_bigits_ = product_length; exponent_ *= 2; Clamp(); } -void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { - ASSERT(base != 0); - ASSERT(power_exponent >= 0); +void Bignum::AssignPowerUInt16(uint16_t base, const int power_exponent) { + DOUBLE_CONVERSION_ASSERT(base != 0); + DOUBLE_CONVERSION_ASSERT(power_exponent >= 0); if (power_exponent == 0) { AssignUInt16(1); return; @@ -445,7 +459,7 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { tmp_base >>= 1; bit_size++; } - int final_size = bit_size * power_exponent; + const int final_size = bit_size * power_exponent; // 1 extra bigit for the shifting, and one for rounded final_size. EnsureCapacity(final_size / kBigitSize + 2); @@ -466,10 +480,10 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { // Verify that there is enough space in this_value to perform the // multiplication. The first bit_size bits must be 0. if ((power_exponent & mask) != 0) { - ASSERT(bit_size > 0); - uint64_t base_bits_mask = - ~((static_cast(1) << (64 - bit_size)) - 1); - bool high_bits_zero = (this_value & base_bits_mask) == 0; + DOUBLE_CONVERSION_ASSERT(bit_size > 0); + const uint64_t base_bits_mask = + ~((static_cast(1) << (64 - bit_size)) - 1); + const bool high_bits_zero = (this_value & base_bits_mask) == 0; if (high_bits_zero) { this_value *= base; } else { @@ -499,9 +513,9 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { // Precondition: this/other < 16bit. uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); - ASSERT(other.used_digits_ > 0); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.used_bigits_ > 0); // Easy case: if we have less digits than the divisor than the result is 0. // Note: this handles the case where this == 0, too. @@ -519,34 +533,34 @@ uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { // This naive approach is extremely inefficient if `this` divided by other // is big. This function is implemented for doubleToString where // the result should be small (less than 10). - ASSERT(other.bigits_[other.used_digits_ - 1] >= ((1 << kBigitSize) / 16)); - ASSERT(bigits_[used_digits_ - 1] < 0x10000); + DOUBLE_CONVERSION_ASSERT(other.RawBigit(other.used_bigits_ - 1) >= ((1 << kBigitSize) / 16)); + DOUBLE_CONVERSION_ASSERT(RawBigit(used_bigits_ - 1) < 0x10000); // Remove the multiples of the first digit. // Example this = 23 and other equals 9. -> Remove 2 multiples. - result += static_cast(bigits_[used_digits_ - 1]); - SubtractTimes(other, bigits_[used_digits_ - 1]); + result += static_cast(RawBigit(used_bigits_ - 1)); + SubtractTimes(other, RawBigit(used_bigits_ - 1)); } - ASSERT(BigitLength() == other.BigitLength()); + DOUBLE_CONVERSION_ASSERT(BigitLength() == other.BigitLength()); // Both bignums are at the same length now. // Since other has more than 0 digits we know that the access to - // bigits_[used_digits_ - 1] is safe. - Chunk this_bigit = bigits_[used_digits_ - 1]; - Chunk other_bigit = other.bigits_[other.used_digits_ - 1]; + // RawBigit(used_bigits_ - 1) is safe. + const Chunk this_bigit = RawBigit(used_bigits_ - 1); + const Chunk other_bigit = other.RawBigit(other.used_bigits_ - 1); - if (other.used_digits_ == 1) { + if (other.used_bigits_ == 1) { // Shortcut for easy (and common) case. int quotient = this_bigit / other_bigit; - bigits_[used_digits_ - 1] = this_bigit - other_bigit * quotient; - ASSERT(quotient < 0x10000); + RawBigit(used_bigits_ - 1) = this_bigit - other_bigit * quotient; + DOUBLE_CONVERSION_ASSERT(quotient < 0x10000); result += static_cast(quotient); Clamp(); return result; } - int division_estimate = this_bigit / (other_bigit + 1); - ASSERT(division_estimate < 0x10000); + const int division_estimate = this_bigit / (other_bigit + 1); + DOUBLE_CONVERSION_ASSERT(division_estimate < 0x10000); result += static_cast(division_estimate); SubtractTimes(other, division_estimate); @@ -566,7 +580,7 @@ uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { template static int SizeInHexChars(S number) { - ASSERT(number > 0); + DOUBLE_CONVERSION_ASSERT(number > 0); int result = 0; while (number != 0) { number >>= 4; @@ -576,29 +590,35 @@ static int SizeInHexChars(S number) { } -static char HexCharOfValue(int value) { - ASSERT(0 <= value && value <= 16); - if (value < 10) return static_cast(value + '0'); +static char HexCharOfValue(const int value) { + DOUBLE_CONVERSION_ASSERT(0 <= value && value <= 16); + if (value < 10) { + return static_cast(value + '0'); + } return static_cast(value - 10 + 'A'); } -bool Bignum::ToHexString(char* buffer, int buffer_size) const { - ASSERT(IsClamped()); +bool Bignum::ToHexString(char* buffer, const int buffer_size) const { + DOUBLE_CONVERSION_ASSERT(IsClamped()); // Each bigit must be printable as separate hex-character. - ASSERT(kBigitSize % 4 == 0); - const int kHexCharsPerBigit = kBigitSize / 4; + DOUBLE_CONVERSION_ASSERT(kBigitSize % 4 == 0); + static const int kHexCharsPerBigit = kBigitSize / 4; - if (used_digits_ == 0) { - if (buffer_size < 2) return false; + if (used_bigits_ == 0) { + if (buffer_size < 2) { + return false; + } buffer[0] = '0'; buffer[1] = '\0'; return true; } // We add 1 for the terminating '\0' character. - int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit + - SizeInHexChars(bigits_[used_digits_ - 1]) + 1; - if (needed_chars > buffer_size) return false; + const int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit + + SizeInHexChars(RawBigit(used_bigits_ - 1)) + 1; + if (needed_chars > buffer_size) { + return false; + } int string_index = needed_chars - 1; buffer[string_index--] = '\0'; for (int i = 0; i < exponent_; ++i) { @@ -606,15 +626,15 @@ bool Bignum::ToHexString(char* buffer, int buffer_size) const { buffer[string_index--] = '0'; } } - for (int i = 0; i < used_digits_ - 1; ++i) { - Chunk current_bigit = bigits_[i]; + for (int i = 0; i < used_bigits_ - 1; ++i) { + Chunk current_bigit = RawBigit(i); for (int j = 0; j < kHexCharsPerBigit; ++j) { buffer[string_index--] = HexCharOfValue(current_bigit & 0xF); current_bigit >>= 4; } } // And finally the last bigit. - Chunk most_significant_bigit = bigits_[used_digits_ - 1]; + Chunk most_significant_bigit = RawBigit(used_bigits_ - 1); while (most_significant_bigit != 0) { buffer[string_index--] = HexCharOfValue(most_significant_bigit & 0xF); most_significant_bigit >>= 4; @@ -623,25 +643,37 @@ bool Bignum::ToHexString(char* buffer, int buffer_size) const { } -Bignum::Chunk Bignum::BigitAt(int index) const { - if (index >= BigitLength()) return 0; - if (index < exponent_) return 0; - return bigits_[index - exponent_]; +Bignum::Chunk Bignum::BigitOrZero(const int index) const { + if (index >= BigitLength()) { + return 0; + } + if (index < exponent_) { + return 0; + } + return RawBigit(index - exponent_); } int Bignum::Compare(const Bignum& a, const Bignum& b) { - ASSERT(a.IsClamped()); - ASSERT(b.IsClamped()); - int bigit_length_a = a.BigitLength(); - int bigit_length_b = b.BigitLength(); - if (bigit_length_a < bigit_length_b) return -1; - if (bigit_length_a > bigit_length_b) return +1; - for (int i = bigit_length_a - 1; i >= Min(a.exponent_, b.exponent_); --i) { - Chunk bigit_a = a.BigitAt(i); - Chunk bigit_b = b.BigitAt(i); - if (bigit_a < bigit_b) return -1; - if (bigit_a > bigit_b) return +1; + DOUBLE_CONVERSION_ASSERT(a.IsClamped()); + DOUBLE_CONVERSION_ASSERT(b.IsClamped()); + const int bigit_length_a = a.BigitLength(); + const int bigit_length_b = b.BigitLength(); + if (bigit_length_a < bigit_length_b) { + return -1; + } + if (bigit_length_a > bigit_length_b) { + return +1; + } + for (int i = bigit_length_a - 1; i >= (std::min)(a.exponent_, b.exponent_); --i) { + const Chunk bigit_a = a.BigitOrZero(i); + const Chunk bigit_b = b.BigitOrZero(i); + if (bigit_a < bigit_b) { + return -1; + } + if (bigit_a > bigit_b) { + return +1; + } // Otherwise they are equal up to this digit. Try the next digit. } return 0; @@ -649,14 +681,18 @@ int Bignum::Compare(const Bignum& a, const Bignum& b) { int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) { - ASSERT(a.IsClamped()); - ASSERT(b.IsClamped()); - ASSERT(c.IsClamped()); + DOUBLE_CONVERSION_ASSERT(a.IsClamped()); + DOUBLE_CONVERSION_ASSERT(b.IsClamped()); + DOUBLE_CONVERSION_ASSERT(c.IsClamped()); if (a.BigitLength() < b.BigitLength()) { return PlusCompare(b, a, c); } - if (a.BigitLength() + 1 < c.BigitLength()) return -1; - if (a.BigitLength() > c.BigitLength()) return +1; + if (a.BigitLength() + 1 < c.BigitLength()) { + return -1; + } + if (a.BigitLength() > c.BigitLength()) { + return +1; + } // The exponent encodes 0-bigits. So if there are more 0-digits in 'a' than // 'b' has digits, then the bigit-length of 'a'+'b' must be equal to the one // of 'a'. @@ -666,92 +702,83 @@ int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) { Chunk borrow = 0; // Starting at min_exponent all digits are == 0. So no need to compare them. - int min_exponent = Min(Min(a.exponent_, b.exponent_), c.exponent_); + const int min_exponent = (std::min)((std::min)(a.exponent_, b.exponent_), c.exponent_); for (int i = c.BigitLength() - 1; i >= min_exponent; --i) { - Chunk chunk_a = a.BigitAt(i); - Chunk chunk_b = b.BigitAt(i); - Chunk chunk_c = c.BigitAt(i); - Chunk sum = chunk_a + chunk_b; + const Chunk chunk_a = a.BigitOrZero(i); + const Chunk chunk_b = b.BigitOrZero(i); + const Chunk chunk_c = c.BigitOrZero(i); + const Chunk sum = chunk_a + chunk_b; if (sum > chunk_c + borrow) { return +1; } else { borrow = chunk_c + borrow - sum; - if (borrow > 1) return -1; + if (borrow > 1) { + return -1; + } borrow <<= kBigitSize; } } - if (borrow == 0) return 0; + if (borrow == 0) { + return 0; + } return -1; } void Bignum::Clamp() { - while (used_digits_ > 0 && bigits_[used_digits_ - 1] == 0) { - used_digits_--; + while (used_bigits_ > 0 && RawBigit(used_bigits_ - 1) == 0) { + used_bigits_--; } - if (used_digits_ == 0) { + if (used_bigits_ == 0) { // Zero. exponent_ = 0; } } -bool Bignum::IsClamped() const { - return used_digits_ == 0 || bigits_[used_digits_ - 1] != 0; -} - - -void Bignum::Zero() { - for (int i = 0; i < used_digits_; ++i) { - bigits_[i] = 0; - } - used_digits_ = 0; - exponent_ = 0; -} - - void Bignum::Align(const Bignum& other) { if (exponent_ > other.exponent_) { - // If "X" represents a "hidden" digit (by the exponent) then we are in the + // If "X" represents a "hidden" bigit (by the exponent) then we are in the // following case (a == this, b == other): // a: aaaaaaXXXX or a: aaaaaXXX // b: bbbbbbX b: bbbbbbbbXX // We replace some of the hidden digits (X) of a with 0 digits. // a: aaaaaa000X or a: aaaaa0XX - int zero_digits = exponent_ - other.exponent_; - EnsureCapacity(used_digits_ + zero_digits); - for (int i = used_digits_ - 1; i >= 0; --i) { - bigits_[i + zero_digits] = bigits_[i]; + const int zero_bigits = exponent_ - other.exponent_; + EnsureCapacity(used_bigits_ + zero_bigits); + for (int i = used_bigits_ - 1; i >= 0; --i) { + RawBigit(i + zero_bigits) = RawBigit(i); } - for (int i = 0; i < zero_digits; ++i) { - bigits_[i] = 0; + for (int i = 0; i < zero_bigits; ++i) { + RawBigit(i) = 0; } - used_digits_ += zero_digits; - exponent_ -= zero_digits; - ASSERT(used_digits_ >= 0); - ASSERT(exponent_ >= 0); + used_bigits_ += zero_bigits; + exponent_ -= zero_bigits; + + DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0); + DOUBLE_CONVERSION_ASSERT(exponent_ >= 0); } } -void Bignum::BigitsShiftLeft(int shift_amount) { - ASSERT(shift_amount < kBigitSize); - ASSERT(shift_amount >= 0); +void Bignum::BigitsShiftLeft(const int shift_amount) { + DOUBLE_CONVERSION_ASSERT(shift_amount < kBigitSize); + DOUBLE_CONVERSION_ASSERT(shift_amount >= 0); Chunk carry = 0; - for (int i = 0; i < used_digits_; ++i) { - Chunk new_carry = bigits_[i] >> (kBigitSize - shift_amount); - bigits_[i] = ((bigits_[i] << shift_amount) + carry) & kBigitMask; + for (int i = 0; i < used_bigits_; ++i) { + const Chunk new_carry = RawBigit(i) >> (kBigitSize - shift_amount); + RawBigit(i) = ((RawBigit(i) << shift_amount) + carry) & kBigitMask; carry = new_carry; } if (carry != 0) { - bigits_[used_digits_] = carry; - used_digits_++; + RawBigit(used_bigits_) = carry; + used_bigits_++; } } -void Bignum::SubtractTimes(const Bignum& other, int factor) { - ASSERT(exponent_ <= other.exponent_); +void Bignum::SubtractTimes(const Bignum& other, const int factor) { + DOUBLE_CONVERSION_ASSERT(exponent_ <= other.exponent_); if (factor < 3) { for (int i = 0; i < factor; ++i) { SubtractBignum(other); @@ -759,19 +786,21 @@ void Bignum::SubtractTimes(const Bignum& other, int factor) { return; } Chunk borrow = 0; - int exponent_diff = other.exponent_ - exponent_; - for (int i = 0; i < other.used_digits_; ++i) { - DoubleChunk product = static_cast(factor) * other.bigits_[i]; - DoubleChunk remove = borrow + product; - Chunk difference = bigits_[i + exponent_diff] - (remove & kBigitMask); - bigits_[i + exponent_diff] = difference & kBigitMask; + const int exponent_diff = other.exponent_ - exponent_; + for (int i = 0; i < other.used_bigits_; ++i) { + const DoubleChunk product = static_cast(factor) * other.RawBigit(i); + const DoubleChunk remove = borrow + product; + const Chunk difference = RawBigit(i + exponent_diff) - (remove & kBigitMask); + RawBigit(i + exponent_diff) = difference & kBigitMask; borrow = static_cast((difference >> (kChunkSize - 1)) + (remove >> kBigitSize)); } - for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) { - if (borrow == 0) return; - Chunk difference = bigits_[i] - borrow; - bigits_[i] = difference & kBigitMask; + for (int i = other.used_bigits_ + exponent_diff; i < used_bigits_; ++i) { + if (borrow == 0) { + return; + } + const Chunk difference = RawBigit(i) - borrow; + RawBigit(i) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); } Clamp(); diff --git a/deps/icu-small/source/i18n/double-conversion-bignum.h b/deps/icu-small/source/i18n/double-conversion-bignum.h index d39a3dee010d8b..bae900a15a7420 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum.h +++ b/deps/icu-small/source/i18n/double-conversion-bignum.h @@ -53,26 +53,27 @@ class Bignum { // exponent. static const int kMaxSignificantBits = 3584; - Bignum(); - void AssignUInt16(uint16_t value); + Bignum() : used_bigits_(0), exponent_(0) {} + + void AssignUInt16(const uint16_t value); void AssignUInt64(uint64_t value); void AssignBignum(const Bignum& other); - void AssignDecimalString(Vector value); - void AssignHexString(Vector value); + void AssignDecimalString(const Vector value); + void AssignHexString(const Vector value); - void AssignPowerUInt16(uint16_t base, int exponent); + void AssignPowerUInt16(uint16_t base, const int exponent); - void AddUInt64(uint64_t operand); + void AddUInt64(const uint64_t operand); void AddBignum(const Bignum& other); // Precondition: this >= other. void SubtractBignum(const Bignum& other); void Square(); - void ShiftLeft(int shift_amount); - void MultiplyByUInt32(uint32_t factor); - void MultiplyByUInt64(uint64_t factor); - void MultiplyByPowerOfTen(int exponent); + void ShiftLeft(const int shift_amount); + void MultiplyByUInt32(const uint32_t factor); + void MultiplyByUInt64(const uint64_t factor); + void MultiplyByPowerOfTen(const int exponent); void Times10() { return MultiplyByUInt32(10); } // Pseudocode: // int result = this / other; @@ -80,7 +81,7 @@ class Bignum { // In the worst case this function is in O(this/other). uint16_t DivideModuloIntBignum(const Bignum& other); - bool ToHexString(char* buffer, int buffer_size) const; + bool ToHexString(char* buffer, const int buffer_size) const; // Returns // -1 if a < b, @@ -124,33 +125,40 @@ class Bignum { // grow. There are no checks if the stack-allocated space is sufficient. static const int kBigitCapacity = kMaxSignificantBits / kBigitSize; - void EnsureCapacity(int size) { + static void EnsureCapacity(const int size) { if (size > kBigitCapacity) { - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } } void Align(const Bignum& other); void Clamp(); - bool IsClamped() const; - void Zero(); + bool IsClamped() const { + return used_bigits_ == 0 || RawBigit(used_bigits_ - 1) != 0; + } + void Zero() { + used_bigits_ = 0; + exponent_ = 0; + } // Requires this to have enough capacity (no tests done). - // Updates used_digits_ if necessary. + // Updates used_bigits_ if necessary. // shift_amount must be < kBigitSize. - void BigitsShiftLeft(int shift_amount); - // BigitLength includes the "hidden" digits encoded in the exponent. - int BigitLength() const { return used_digits_ + exponent_; } - Chunk BigitAt(int index) const; - void SubtractTimes(const Bignum& other, int factor); - + void BigitsShiftLeft(const int shift_amount); + // BigitLength includes the "hidden" bigits encoded in the exponent. + int BigitLength() const { return used_bigits_ + exponent_; } + Chunk& RawBigit(const int index); + const Chunk& RawBigit(const int index) const; + Chunk BigitOrZero(const int index) const; + void SubtractTimes(const Bignum& other, const int factor); + + // The Bignum's value is value(bigits_buffer_) * 2^(exponent_ * kBigitSize), + // where the value of the buffer consists of the lower kBigitSize bits of + // the first used_bigits_ Chunks in bigits_buffer_, first chunk has lowest + // significant bits. + int16_t used_bigits_; + int16_t exponent_; Chunk bigits_buffer_[kBigitCapacity]; - // A vector backed by bigits_buffer_. This way accesses to the array are - // checked for out-of-bounds errors. - Vector bigits_; - int used_digits_; - // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). - int exponent_; - - DC_DISALLOW_COPY_AND_ASSIGN(Bignum); + + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Bignum); }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp b/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp index e1b66d2c65c82e..3bc35c8aaf81dc 100644 --- a/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp +++ b/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp @@ -49,6 +49,8 @@ U_NAMESPACE_BEGIN namespace double_conversion { +namespace PowersOfTenCache { + struct CachedPower { uint64_t significand; int16_t binary_exponent; @@ -56,103 +58,99 @@ struct CachedPower { }; static const CachedPower kCachedPowers[] = { - {UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348}, - {UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340}, - {UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332}, - {UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324}, - {UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316}, - {UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308}, - {UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300}, - {UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292}, - {UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284}, - {UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276}, - {UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268}, - {UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260}, - {UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252}, - {UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244}, - {UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236}, - {UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228}, - {UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220}, - {UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212}, - {UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204}, - {UINT64_2PART_C(0xef340a98, 172aace5), -715, -196}, - {UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188}, - {UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180}, - {UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172}, - {UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164}, - {UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156}, - {UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148}, - {UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140}, - {UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132}, - {UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124}, - {UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116}, - {UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108}, - {UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100}, - {UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92}, - {UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84}, - {UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76}, - {UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68}, - {UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60}, - {UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52}, - {UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44}, - {UINT64_2PART_C(0xaa242499, 697392d3), -183, -36}, - {UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28}, - {UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20}, - {UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12}, - {UINT64_2PART_C(0xd1b71758, e219652c), -77, -4}, - {UINT64_2PART_C(0x9c400000, 00000000), -50, 4}, - {UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12}, - {UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20}, - {UINT64_2PART_C(0x813f3978, f8940984), 30, 28}, - {UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36}, - {UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44}, - {UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52}, - {UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60}, - {UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68}, - {UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76}, - {UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84}, - {UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92}, - {UINT64_2PART_C(0x924d692c, a61be758), 269, 100}, - {UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108}, - {UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116}, - {UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124}, - {UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132}, - {UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140}, - {UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148}, - {UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156}, - {UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164}, - {UINT64_2PART_C(0xa59bc234, db398c25), 508, 172}, - {UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180}, - {UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188}, - {UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196}, - {UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204}, - {UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212}, - {UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220}, - {UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228}, - {UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236}, - {UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244}, - {UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252}, - {UINT64_2PART_C(0xd01fef10, a657842c), 800, 260}, - {UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268}, - {UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276}, - {UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284}, - {UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292}, - {UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300}, - {UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308}, - {UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316}, - {UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324}, - {UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332}, - {UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xef340a98, 172aace5), -715, -196}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaa242499, 697392d3), -183, -36}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd1b71758, e219652c), -77, -4}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9c400000, 00000000), -50, 4}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x813f3978, f8940984), 30, 28}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x924d692c, a61be758), 269, 100}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa59bc234, db398c25), 508, 172}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd01fef10, a657842c), 800, 260}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340}, }; static const int kCachedPowersOffset = 348; // -1 * the first decimal_exponent. static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) -// Difference between the decimal exponents in the table above. -const int PowersOfTenCache::kDecimalExponentDistance = 8; -const int PowersOfTenCache::kMinDecimalExponent = -348; -const int PowersOfTenCache::kMaxDecimalExponent = 340; -void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( +void GetCachedPowerForBinaryExponentRange( int min_exponent, int max_exponent, DiyFp* power, @@ -162,30 +160,32 @@ void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( int foo = kCachedPowersOffset; int index = (foo + static_cast(k) - 1) / kDecimalExponentDistance + 1; - ASSERT(0 <= index && index < static_cast(ARRAY_SIZE(kCachedPowers))); + DOUBLE_CONVERSION_ASSERT(0 <= index && index < static_cast(DOUBLE_CONVERSION_ARRAY_SIZE(kCachedPowers))); CachedPower cached_power = kCachedPowers[index]; - ASSERT(min_exponent <= cached_power.binary_exponent); + DOUBLE_CONVERSION_ASSERT(min_exponent <= cached_power.binary_exponent); (void) max_exponent; // Mark variable as used. - ASSERT(cached_power.binary_exponent <= max_exponent); + DOUBLE_CONVERSION_ASSERT(cached_power.binary_exponent <= max_exponent); *decimal_exponent = cached_power.decimal_exponent; *power = DiyFp(cached_power.significand, cached_power.binary_exponent); } -void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_exponent, - DiyFp* power, - int* found_exponent) { - ASSERT(kMinDecimalExponent <= requested_exponent); - ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance); +void GetCachedPowerForDecimalExponent(int requested_exponent, + DiyFp* power, + int* found_exponent) { + DOUBLE_CONVERSION_ASSERT(kMinDecimalExponent <= requested_exponent); + DOUBLE_CONVERSION_ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance); int index = (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance; CachedPower cached_power = kCachedPowers[index]; *power = DiyFp(cached_power.significand, cached_power.binary_exponent); *found_exponent = cached_power.decimal_exponent; - ASSERT(*found_exponent <= requested_exponent); - ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); + DOUBLE_CONVERSION_ASSERT(*found_exponent <= requested_exponent); + DOUBLE_CONVERSION_ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); } +} // namespace PowersOfTenCache + } // namespace double_conversion // ICU PATCH: Close ICU namespace diff --git a/deps/icu-small/source/i18n/double-conversion-cached-powers.h b/deps/icu-small/source/i18n/double-conversion-cached-powers.h index 438746b143293f..ade27baef8b0c7 100644 --- a/deps/icu-small/source/i18n/double-conversion-cached-powers.h +++ b/deps/icu-small/source/i18n/double-conversion-cached-powers.h @@ -46,32 +46,32 @@ U_NAMESPACE_BEGIN namespace double_conversion { -class PowersOfTenCache { - public: +namespace PowersOfTenCache { // Not all powers of ten are cached. The decimal exponent of two neighboring // cached numbers will differ by kDecimalExponentDistance. - static const int kDecimalExponentDistance; + static const int kDecimalExponentDistance = 8; - static const int kMinDecimalExponent; - static const int kMaxDecimalExponent; + static const int kMinDecimalExponent = -348; + static const int kMaxDecimalExponent = 340; // Returns a cached power-of-ten with a binary exponent in the range // [min_exponent; max_exponent] (boundaries included). - static void GetCachedPowerForBinaryExponentRange(int min_exponent, - int max_exponent, - DiyFp* power, - int* decimal_exponent); + void GetCachedPowerForBinaryExponentRange(int min_exponent, + int max_exponent, + DiyFp* power, + int* decimal_exponent); // Returns a cached power of ten x ~= 10^k such that // k <= decimal_exponent < k + kCachedPowersDecimalDistance. // The given decimal_exponent must satisfy // kMinDecimalExponent <= requested_exponent, and // requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance. - static void GetCachedPowerForDecimalExponent(int requested_exponent, - DiyFp* power, - int* found_exponent); -}; + void GetCachedPowerForDecimalExponent(int requested_exponent, + DiyFp* power, + int* found_exponent); + +} // namespace PowersOfTenCache } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp b/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp deleted file mode 100644 index f38430c6c3c90f..00000000000000 --- a/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// © 2018 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html -// -// From the double-conversion library. Original license: -// -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING -#include "unicode/utypes.h" -#if !UCONFIG_NO_FORMATTING - -// ICU PATCH: Customize header file paths for ICU. - -#include "double-conversion-diy-fp.h" -#include "double-conversion-utils.h" - -// ICU PATCH: Wrap in ICU namespace -U_NAMESPACE_BEGIN - -namespace double_conversion { - -void DiyFp::Multiply(const DiyFp& other) { - // Simply "emulates" a 128 bit multiplication. - // However: the resulting number only contains 64 bits. The least - // significant 64 bits are only used for rounding the most significant 64 - // bits. - const uint64_t kM32 = 0xFFFFFFFFU; - uint64_t a = f_ >> 32; - uint64_t b = f_ & kM32; - uint64_t c = other.f_ >> 32; - uint64_t d = other.f_ & kM32; - uint64_t ac = a * c; - uint64_t bc = b * c; - uint64_t ad = a * d; - uint64_t bd = b * d; - uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32); - // By adding 1U << 31 to tmp we round the final result. - // Halfway cases will be round up. - tmp += 1U << 31; - uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); - e_ += other.e_ + 64; - f_ = result_f; -} - -} // namespace double_conversion - -// ICU PATCH: Close ICU namespace -U_NAMESPACE_END -#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-diy-fp.h b/deps/icu-small/source/i18n/double-conversion-diy-fp.h index 21896851d22d32..5820abedf35405 100644 --- a/deps/icu-small/source/i18n/double-conversion-diy-fp.h +++ b/deps/icu-small/source/i18n/double-conversion-diy-fp.h @@ -50,36 +50,55 @@ namespace double_conversion { // with a uint64 significand and an int exponent. Normalized DiyFp numbers will // have the most significant bit of the significand set. // Multiplication and Subtraction do not normalize their results. -// DiyFp are not designed to contain special doubles (NaN and Infinity). +// DiyFp store only non-negative numbers and are not designed to contain special +// doubles (NaN and Infinity). class DiyFp { public: static const int kSignificandSize = 64; DiyFp() : f_(0), e_(0) {} - DiyFp(uint64_t significand, int exponent) : f_(significand), e_(exponent) {} + DiyFp(const uint64_t significand, const int32_t exponent) : f_(significand), e_(exponent) {} - // this = this - other. + // this -= other. // The exponents of both numbers must be the same and the significand of this - // must be bigger than the significand of other. + // must be greater or equal than the significand of other. // The result will not be normalized. void Subtract(const DiyFp& other) { - ASSERT(e_ == other.e_); - ASSERT(f_ >= other.f_); + DOUBLE_CONVERSION_ASSERT(e_ == other.e_); + DOUBLE_CONVERSION_ASSERT(f_ >= other.f_); f_ -= other.f_; } // Returns a - b. - // The exponents of both numbers must be the same and this must be bigger - // than other. The result will not be normalized. + // The exponents of both numbers must be the same and a must be greater + // or equal than b. The result will not be normalized. static DiyFp Minus(const DiyFp& a, const DiyFp& b) { DiyFp result = a; result.Subtract(b); return result; } - - // this = this * other. - void Multiply(const DiyFp& other); + // this *= other. + void Multiply(const DiyFp& other) { + // Simply "emulates" a 128 bit multiplication. + // However: the resulting number only contains 64 bits. The least + // significant 64 bits are only used for rounding the most significant 64 + // bits. + const uint64_t kM32 = 0xFFFFFFFFU; + const uint64_t a = f_ >> 32; + const uint64_t b = f_ & kM32; + const uint64_t c = other.f_ >> 32; + const uint64_t d = other.f_ & kM32; + const uint64_t ac = a * c; + const uint64_t bc = b * c; + const uint64_t ad = a * d; + const uint64_t bd = b * d; + // By adding 1U << 31 to tmp we round the final result. + // Halfway cases will be rounded up. + const uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32) + (1U << 31); + e_ += other.e_ + 64; + f_ = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); + } // returns a * b; static DiyFp Times(const DiyFp& a, const DiyFp& b) { @@ -89,13 +108,13 @@ class DiyFp { } void Normalize() { - ASSERT(f_ != 0); + DOUBLE_CONVERSION_ASSERT(f_ != 0); uint64_t significand = f_; - int exponent = e_; + int32_t exponent = e_; - // This method is mainly called for normalizing boundaries. In general - // boundaries need to be shifted by 10 bits. We thus optimize for this case. - const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000); + // This method is mainly called for normalizing boundaries. In general, + // boundaries need to be shifted by 10 bits, and we optimize for this case. + const uint64_t k10MSBits = DOUBLE_CONVERSION_UINT64_2PART_C(0xFFC00000, 00000000); while ((significand & k10MSBits) == 0) { significand <<= 10; exponent -= 10; @@ -115,16 +134,16 @@ class DiyFp { } uint64_t f() const { return f_; } - int e() const { return e_; } + int32_t e() const { return e_; } void set_f(uint64_t new_value) { f_ = new_value; } - void set_e(int new_value) { e_ = new_value; } + void set_e(int32_t new_value) { e_ = new_value; } private: - static const uint64_t kUint64MSB = UINT64_2PART_C(0x80000000, 00000000); + static const uint64_t kUint64MSB = DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); uint64_t f_; - int e_; + int32_t e_; }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp b/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp new file mode 100644 index 00000000000000..44c176f4f9c958 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp @@ -0,0 +1,450 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#include +#include +#include + +// ICU PATCH: Customize header file paths for ICU. +// The file fixed-dtoa.h is not needed. + +#include "double-conversion-double-to-string.h" + +#include "double-conversion-bignum-dtoa.h" +#include "double-conversion-fast-dtoa.h" +#include "double-conversion-ieee.h" +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +#if 0 // not needed for ICU +const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { + int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; + static DoubleToStringConverter converter(flags, + "Infinity", + "NaN", + 'e', + -6, 21, + 6, 0); + return converter; +} + + +bool DoubleToStringConverter::HandleSpecialValues( + double value, + StringBuilder* result_builder) const { + Double double_inspect(value); + if (double_inspect.IsInfinite()) { + if (infinity_symbol_ == NULL) return false; + if (value < 0) { + result_builder->AddCharacter('-'); + } + result_builder->AddString(infinity_symbol_); + return true; + } + if (double_inspect.IsNan()) { + if (nan_symbol_ == NULL) return false; + result_builder->AddString(nan_symbol_); + return true; + } + return false; +} + + +void DoubleToStringConverter::CreateExponentialRepresentation( + const char* decimal_digits, + int length, + int exponent, + StringBuilder* result_builder) const { + DOUBLE_CONVERSION_ASSERT(length != 0); + result_builder->AddCharacter(decimal_digits[0]); + if (length != 1) { + result_builder->AddCharacter('.'); + result_builder->AddSubstring(&decimal_digits[1], length-1); + } + result_builder->AddCharacter(exponent_character_); + if (exponent < 0) { + result_builder->AddCharacter('-'); + exponent = -exponent; + } else { + if ((flags_ & EMIT_POSITIVE_EXPONENT_SIGN) != 0) { + result_builder->AddCharacter('+'); + } + } + if (exponent == 0) { + result_builder->AddCharacter('0'); + return; + } + DOUBLE_CONVERSION_ASSERT(exponent < 1e4); + // Changing this constant requires updating the comment of DoubleToStringConverter constructor + const int kMaxExponentLength = 5; + char buffer[kMaxExponentLength + 1]; + buffer[kMaxExponentLength] = '\0'; + int first_char_pos = kMaxExponentLength; + while (exponent > 0) { + buffer[--first_char_pos] = '0' + (exponent % 10); + exponent /= 10; + } + // Add prefix '0' to make exponent width >= min(min_exponent_with_, kMaxExponentLength) + // For example: convert 1e+9 -> 1e+09, if min_exponent_with_ is set to 2 + while(kMaxExponentLength - first_char_pos < std::min(min_exponent_width_, kMaxExponentLength)) { + buffer[--first_char_pos] = '0'; + } + result_builder->AddSubstring(&buffer[first_char_pos], + kMaxExponentLength - first_char_pos); +} + + +void DoubleToStringConverter::CreateDecimalRepresentation( + const char* decimal_digits, + int length, + int decimal_point, + int digits_after_point, + StringBuilder* result_builder) const { + // Create a representation that is padded with zeros if needed. + if (decimal_point <= 0) { + // "0.00000decimal_rep" or "0.000decimal_rep00". + result_builder->AddCharacter('0'); + if (digits_after_point > 0) { + result_builder->AddCharacter('.'); + result_builder->AddPadding('0', -decimal_point); + DOUBLE_CONVERSION_ASSERT(length <= digits_after_point - (-decimal_point)); + result_builder->AddSubstring(decimal_digits, length); + int remaining_digits = digits_after_point - (-decimal_point) - length; + result_builder->AddPadding('0', remaining_digits); + } + } else if (decimal_point >= length) { + // "decimal_rep0000.00000" or "decimal_rep.0000". + result_builder->AddSubstring(decimal_digits, length); + result_builder->AddPadding('0', decimal_point - length); + if (digits_after_point > 0) { + result_builder->AddCharacter('.'); + result_builder->AddPadding('0', digits_after_point); + } + } else { + // "decima.l_rep000". + DOUBLE_CONVERSION_ASSERT(digits_after_point > 0); + result_builder->AddSubstring(decimal_digits, decimal_point); + result_builder->AddCharacter('.'); + DOUBLE_CONVERSION_ASSERT(length - decimal_point <= digits_after_point); + result_builder->AddSubstring(&decimal_digits[decimal_point], + length - decimal_point); + int remaining_digits = digits_after_point - (length - decimal_point); + result_builder->AddPadding('0', remaining_digits); + } + if (digits_after_point == 0) { + if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) { + result_builder->AddCharacter('.'); + } + if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) { + result_builder->AddCharacter('0'); + } + } +} + + +bool DoubleToStringConverter::ToShortestIeeeNumber( + double value, + StringBuilder* result_builder, + DoubleToStringConverter::DtoaMode mode) const { + DOUBLE_CONVERSION_ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE); + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + int decimal_point; + bool sign; + const int kDecimalRepCapacity = kBase10MaximalLength + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + + DoubleToAscii(value, mode, 0, decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + + bool unique_zero = (flags_ & UNIQUE_ZERO) != 0; + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + int exponent = decimal_point - 1; + if ((decimal_in_shortest_low_ <= exponent) && + (exponent < decimal_in_shortest_high_)) { + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, + decimal_point, + (std::max)(0, decimal_rep_length - decimal_point), + result_builder); + } else { + CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent, + result_builder); + } + return true; +} + + +bool DoubleToStringConverter::ToFixed(double value, + int requested_digits, + StringBuilder* result_builder) const { + DOUBLE_CONVERSION_ASSERT(kMaxFixedDigitsBeforePoint == 60); + const double kFirstNonFixed = 1e60; + + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (requested_digits > kMaxFixedDigitsAfterPoint) return false; + if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false; + + // Find a sufficiently precise decimal representation of n. + int decimal_point; + bool sign; + // Add space for the '\0' byte. + const int kDecimalRepCapacity = + kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + DoubleToAscii(value, FIXED, requested_digits, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, + requested_digits, result_builder); + return true; +} + + +bool DoubleToStringConverter::ToExponential( + double value, + int requested_digits, + StringBuilder* result_builder) const { + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (requested_digits < -1) return false; + if (requested_digits > kMaxExponentialDigits) return false; + + int decimal_point; + bool sign; + // Add space for digit before the decimal point and the '\0' character. + const int kDecimalRepCapacity = kMaxExponentialDigits + 2; + DOUBLE_CONVERSION_ASSERT(kDecimalRepCapacity > kBase10MaximalLength); + char decimal_rep[kDecimalRepCapacity]; +#ifndef NDEBUG + // Problem: there is an assert in StringBuilder::AddSubstring() that + // will pass this buffer to strlen(), and this buffer is not generally + // null-terminated. + memset(decimal_rep, 0, sizeof(decimal_rep)); +#endif + int decimal_rep_length; + + if (requested_digits == -1) { + DoubleToAscii(value, SHORTEST, 0, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + } else { + DoubleToAscii(value, PRECISION, requested_digits + 1, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + DOUBLE_CONVERSION_ASSERT(decimal_rep_length <= requested_digits + 1); + + for (int i = decimal_rep_length; i < requested_digits + 1; ++i) { + decimal_rep[i] = '0'; + } + decimal_rep_length = requested_digits + 1; + } + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + int exponent = decimal_point - 1; + CreateExponentialRepresentation(decimal_rep, + decimal_rep_length, + exponent, + result_builder); + return true; +} + + +bool DoubleToStringConverter::ToPrecision(double value, + int precision, + StringBuilder* result_builder) const { + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) { + return false; + } + + // Find a sufficiently precise decimal representation of n. + int decimal_point; + bool sign; + // Add one for the terminating null character. + const int kDecimalRepCapacity = kMaxPrecisionDigits + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + + DoubleToAscii(value, PRECISION, precision, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + DOUBLE_CONVERSION_ASSERT(decimal_rep_length <= precision); + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + // The exponent if we print the number as x.xxeyyy. That is with the + // decimal point after the first digit. + int exponent = decimal_point - 1; + + int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0; + if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) || + (decimal_point - precision + extra_zero > + max_trailing_padding_zeroes_in_precision_mode_)) { + // Fill buffer to contain 'precision' digits. + // Usually the buffer is already at the correct length, but 'DoubleToAscii' + // is allowed to return less characters. + for (int i = decimal_rep_length; i < precision; ++i) { + decimal_rep[i] = '0'; + } + + CreateExponentialRepresentation(decimal_rep, + precision, + exponent, + result_builder); + } else { + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, + (std::max)(0, precision - decimal_point), + result_builder); + } + return true; +} +#endif // not needed for ICU + + +static BignumDtoaMode DtoaToBignumDtoaMode( + DoubleToStringConverter::DtoaMode dtoa_mode) { + switch (dtoa_mode) { + case DoubleToStringConverter::SHORTEST: return BIGNUM_DTOA_SHORTEST; + case DoubleToStringConverter::SHORTEST_SINGLE: + return BIGNUM_DTOA_SHORTEST_SINGLE; + case DoubleToStringConverter::FIXED: return BIGNUM_DTOA_FIXED; + case DoubleToStringConverter::PRECISION: return BIGNUM_DTOA_PRECISION; + default: + DOUBLE_CONVERSION_UNREACHABLE(); + } +} + + +void DoubleToStringConverter::DoubleToAscii(double v, + DtoaMode mode, + int requested_digits, + char* buffer, + int buffer_length, + bool* sign, + int* length, + int* point) { + Vector vector(buffer, buffer_length); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE || requested_digits >= 0); + + if (Double(v).Sign() < 0) { + *sign = true; + v = -v; + } else { + *sign = false; + } + + if (mode == PRECISION && requested_digits == 0) { + vector[0] = '\0'; + *length = 0; + return; + } + + if (v == 0) { + vector[0] = '0'; + vector[1] = '\0'; + *length = 1; + *point = 1; + return; + } + + bool fast_worked; + switch (mode) { + case SHORTEST: + fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point); + break; +#if 0 // not needed for ICU + case SHORTEST_SINGLE: + fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST_SINGLE, 0, + vector, length, point); + break; + case FIXED: + fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point); + break; + case PRECISION: + fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits, + vector, length, point); + break; +#endif // not needed for ICU + default: + fast_worked = false; + DOUBLE_CONVERSION_UNREACHABLE(); + } + if (fast_worked) return; + + // If the fast dtoa didn't succeed use the slower bignum version. + BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode); + BignumDtoa(v, bignum_mode, requested_digits, vector, length, point); + vector[*length] = '\0'; +} + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-double-to-string.h b/deps/icu-small/source/i18n/double-conversion-double-to-string.h new file mode 100644 index 00000000000000..27bd86784895f8 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-double-to-string.h @@ -0,0 +1,419 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#ifndef DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ +#define DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ + +// ICU PATCH: Customize header file paths for ICU. + +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +class DoubleToStringConverter { + public: +#if 0 // not needed for ICU + // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint + // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the + // function returns false. + static const int kMaxFixedDigitsBeforePoint = 60; + static const int kMaxFixedDigitsAfterPoint = 60; + + // When calling ToExponential with a requested_digits + // parameter > kMaxExponentialDigits then the function returns false. + static const int kMaxExponentialDigits = 120; + + // When calling ToPrecision with a requested_digits + // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits + // then the function returns false. + static const int kMinPrecisionDigits = 1; + static const int kMaxPrecisionDigits = 120; + + enum Flags { + NO_FLAGS = 0, + EMIT_POSITIVE_EXPONENT_SIGN = 1, + EMIT_TRAILING_DECIMAL_POINT = 2, + EMIT_TRAILING_ZERO_AFTER_POINT = 4, + UNIQUE_ZERO = 8 + }; + + // Flags should be a bit-or combination of the possible Flags-enum. + // - NO_FLAGS: no special flags. + // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent + // form, emits a '+' for positive exponents. Example: 1.2e+2. + // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is + // converted into decimal format then a trailing decimal point is appended. + // Example: 2345.0 is converted to "2345.". + // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point + // emits a trailing '0'-character. This flag requires the + // EXMIT_TRAILING_DECIMAL_POINT flag. + // Example: 2345.0 is converted to "2345.0". + // - UNIQUE_ZERO: "-0.0" is converted to "0.0". + // + // Infinity symbol and nan_symbol provide the string representation for these + // special values. If the string is NULL and the special value is encountered + // then the conversion functions return false. + // + // The exponent_character is used in exponential representations. It is + // usually 'e' or 'E'. + // + // When converting to the shortest representation the converter will + // represent input numbers in decimal format if they are in the interval + // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[ + // (lower boundary included, greater boundary excluded). + // Example: with decimal_in_shortest_low = -6 and + // decimal_in_shortest_high = 21: + // ToShortest(0.000001) -> "0.000001" + // ToShortest(0.0000001) -> "1e-7" + // ToShortest(111111111111111111111.0) -> "111111111111111110000" + // ToShortest(100000000000000000000.0) -> "100000000000000000000" + // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" + // + // When converting to precision mode the converter may add + // max_leading_padding_zeroes before returning the number in exponential + // format. + // Example with max_leading_padding_zeroes_in_precision_mode = 6. + // ToPrecision(0.0000012345, 2) -> "0.0000012" + // ToPrecision(0.00000012345, 2) -> "1.2e-7" + // Similarily the converter may add up to + // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid + // returning an exponential representation. A zero added by the + // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: + // ToPrecision(230.0, 2) -> "230" + // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. + // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. + // + // The min_exponent_width is used for exponential representations. + // The converter adds leading '0's to the exponent until the exponent + // is at least min_exponent_width digits long. + // The min_exponent_width is clamped to 5. + // As such, the exponent may never have more than 5 digits in total. + DoubleToStringConverter(int flags, + const char* infinity_symbol, + const char* nan_symbol, + char exponent_character, + int decimal_in_shortest_low, + int decimal_in_shortest_high, + int max_leading_padding_zeroes_in_precision_mode, + int max_trailing_padding_zeroes_in_precision_mode, + int min_exponent_width = 0) + : flags_(flags), + infinity_symbol_(infinity_symbol), + nan_symbol_(nan_symbol), + exponent_character_(exponent_character), + decimal_in_shortest_low_(decimal_in_shortest_low), + decimal_in_shortest_high_(decimal_in_shortest_high), + max_leading_padding_zeroes_in_precision_mode_( + max_leading_padding_zeroes_in_precision_mode), + max_trailing_padding_zeroes_in_precision_mode_( + max_trailing_padding_zeroes_in_precision_mode), + min_exponent_width_(min_exponent_width) { + // When 'trailing zero after the point' is set, then 'trailing point' + // must be set too. + DOUBLE_CONVERSION_ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) || + !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0)); + } + + // Returns a converter following the EcmaScript specification. + static const DoubleToStringConverter& EcmaScriptConverter(); + + // Computes the shortest string of digits that correctly represent the input + // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high + // (see constructor) it then either returns a decimal representation, or an + // exponential representation. + // Example with decimal_in_shortest_low = -6, + // decimal_in_shortest_high = 21, + // EMIT_POSITIVE_EXPONENT_SIGN activated, and + // EMIT_TRAILING_DECIMAL_POINT deactived: + // ToShortest(0.000001) -> "0.000001" + // ToShortest(0.0000001) -> "1e-7" + // ToShortest(111111111111111111111.0) -> "111111111111111110000" + // ToShortest(100000000000000000000.0) -> "100000000000000000000" + // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" + // + // Note: the conversion may round the output if the returned string + // is accurate enough to uniquely identify the input-number. + // For example the most precise representation of the double 9e59 equals + // "899999999999999918767229449717619953810131273674690656206848", but + // the converter will return the shorter (but still correct) "9e59". + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except when the input value is special and no infinity_symbol or + // nan_symbol has been given to the constructor. + bool ToShortest(double value, StringBuilder* result_builder) const { + return ToShortestIeeeNumber(value, result_builder, SHORTEST); + } + + // Same as ToShortest, but for single-precision floats. + bool ToShortestSingle(float value, StringBuilder* result_builder) const { + return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE); + } + + + // Computes a decimal representation with a fixed number of digits after the + // decimal point. The last emitted digit is rounded. + // + // Examples: + // ToFixed(3.12, 1) -> "3.1" + // ToFixed(3.1415, 3) -> "3.142" + // ToFixed(1234.56789, 4) -> "1234.5679" + // ToFixed(1.23, 5) -> "1.23000" + // ToFixed(0.1, 4) -> "0.1000" + // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00" + // ToFixed(0.1, 30) -> "0.100000000000000005551115123126" + // ToFixed(0.1, 17) -> "0.10000000000000001" + // + // If requested_digits equals 0, then the tail of the result depends on + // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT. + // Examples, for requested_digits == 0, + // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be + // - false and false: then 123.45 -> 123 + // 0.678 -> 1 + // - true and false: then 123.45 -> 123. + // 0.678 -> 1. + // - true and true: then 123.45 -> 123.0 + // 0.678 -> 1.0 + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - 'value' > 10^kMaxFixedDigitsBeforePoint, or + // - 'requested_digits' > kMaxFixedDigitsAfterPoint. + // The last two conditions imply that the result will never contain more than + // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters + // (one additional character for the sign, and one for the decimal point). + bool ToFixed(double value, + int requested_digits, + StringBuilder* result_builder) const; + + // Computes a representation in exponential format with requested_digits + // after the decimal point. The last emitted digit is rounded. + // If requested_digits equals -1, then the shortest exponential representation + // is computed. + // + // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and + // exponent_character set to 'e'. + // ToExponential(3.12, 1) -> "3.1e0" + // ToExponential(5.0, 3) -> "5.000e0" + // ToExponential(0.001, 2) -> "1.00e-3" + // ToExponential(3.1415, -1) -> "3.1415e0" + // ToExponential(3.1415, 4) -> "3.1415e0" + // ToExponential(3.1415, 3) -> "3.142e0" + // ToExponential(123456789000000, 3) -> "1.235e14" + // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30" + // ToExponential(1000000000000000019884624838656.0, 32) -> + // "1.00000000000000001988462483865600e30" + // ToExponential(1234, 0) -> "1e3" + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - 'requested_digits' > kMaxExponentialDigits. + // The last condition implies that the result will never contain more than + // kMaxExponentialDigits + 8 characters (the sign, the digit before the + // decimal point, the decimal point, the exponent character, the + // exponent's sign, and at most 3 exponent digits). + bool ToExponential(double value, + int requested_digits, + StringBuilder* result_builder) const; + + // Computes 'precision' leading digits of the given 'value' and returns them + // either in exponential or decimal format, depending on + // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the + // constructor). + // The last computed digit is rounded. + // + // Example with max_leading_padding_zeroes_in_precision_mode = 6. + // ToPrecision(0.0000012345, 2) -> "0.0000012" + // ToPrecision(0.00000012345, 2) -> "1.2e-7" + // Similarily the converter may add up to + // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid + // returning an exponential representation. A zero added by the + // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: + // ToPrecision(230.0, 2) -> "230" + // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. + // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no + // EMIT_TRAILING_ZERO_AFTER_POINT: + // ToPrecision(123450.0, 6) -> "123450" + // ToPrecision(123450.0, 5) -> "123450" + // ToPrecision(123450.0, 4) -> "123500" + // ToPrecision(123450.0, 3) -> "123000" + // ToPrecision(123450.0, 2) -> "1.2e5" + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - precision < kMinPericisionDigits + // - precision > kMaxPrecisionDigits + // The last condition implies that the result will never contain more than + // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the + // exponent character, the exponent's sign, and at most 3 exponent digits). + bool ToPrecision(double value, + int precision, + StringBuilder* result_builder) const; +#endif // not needed for ICU + + enum DtoaMode { + // Produce the shortest correct representation. + // For example the output of 0.299999999999999988897 is (the less accurate + // but correct) 0.3. + SHORTEST, + // Same as SHORTEST, but for single-precision floats. + SHORTEST_SINGLE, + // Produce a fixed number of digits after the decimal point. + // For instance fixed(0.1, 4) becomes 0.1000 + // If the input number is big, the output will be big. + FIXED, + // Fixed number of digits (independent of the decimal point). + PRECISION + }; + + // The maximal number of digits that are needed to emit a double in base 10. + // A higher precision can be achieved by using more digits, but the shortest + // accurate representation of any double will never use more digits than + // kBase10MaximalLength. + // Note that DoubleToAscii null-terminates its input. So the given buffer + // should be at least kBase10MaximalLength + 1 characters long. + static const int kBase10MaximalLength = 17; + + // Converts the given double 'v' to digit characters. 'v' must not be NaN, + // +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also + // applies to 'v' after it has been casted to a single-precision float. That + // is, in this mode static_cast(v) must not be NaN, +Infinity or + // -Infinity. + // + // The result should be interpreted as buffer * 10^(point-length). + // + // The digits are written to the buffer in the platform's charset, which is + // often UTF-8 (with ASCII-range digits) but may be another charset, such + // as EBCDIC. + // + // The output depends on the given mode: + // - SHORTEST: produce the least amount of digits for which the internal + // identity requirement is still satisfied. If the digits are printed + // (together with the correct exponent) then reading this number will give + // 'v' again. The buffer will choose the representation that is closest to + // 'v'. If there are two at the same distance, than the one farther away + // from 0 is chosen (halfway cases - ending with 5 - are rounded up). + // In this mode the 'requested_digits' parameter is ignored. + // - SHORTEST_SINGLE: same as SHORTEST but with single-precision. + // - FIXED: produces digits necessary to print a given number with + // 'requested_digits' digits after the decimal point. The produced digits + // might be too short in which case the caller has to fill the remainder + // with '0's. + // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. + // Halfway cases are rounded towards +/-Infinity (away from 0). The call + // toFixed(0.15, 2) thus returns buffer="2", point=0. + // The returned buffer may contain digits that would be truncated from the + // shortest representation of the input. + // - PRECISION: produces 'requested_digits' where the first digit is not '0'. + // Even though the length of produced digits usually equals + // 'requested_digits', the function is allowed to return fewer digits, in + // which case the caller has to fill the missing digits with '0's. + // Halfway cases are again rounded away from 0. + // DoubleToAscii expects the given buffer to be big enough to hold all + // digits and a terminating null-character. In SHORTEST-mode it expects a + // buffer of at least kBase10MaximalLength + 1. In all other modes the + // requested_digits parameter and the padding-zeroes limit the size of the + // output. Don't forget the decimal point, the exponent character and the + // terminating null-character when computing the maximal output size. + // The given length is only used in debug mode to ensure the buffer is big + // enough. + // ICU PATCH: Export this as U_I18N_API for unit tests. + static void U_I18N_API DoubleToAscii(double v, + DtoaMode mode, + int requested_digits, + char* buffer, + int buffer_length, + bool* sign, + int* length, + int* point); + +#if 0 // not needed for ICU + private: + // Implementation for ToShortest and ToShortestSingle. + bool ToShortestIeeeNumber(double value, + StringBuilder* result_builder, + DtoaMode mode) const; + + // If the value is a special value (NaN or Infinity) constructs the + // corresponding string using the configured infinity/nan-symbol. + // If either of them is NULL or the value is not special then the + // function returns false. + bool HandleSpecialValues(double value, StringBuilder* result_builder) const; + // Constructs an exponential representation (i.e. 1.234e56). + // The given exponent assumes a decimal point after the first decimal digit. + void CreateExponentialRepresentation(const char* decimal_digits, + int length, + int exponent, + StringBuilder* result_builder) const; + // Creates a decimal representation (i.e 1234.5678). + void CreateDecimalRepresentation(const char* decimal_digits, + int length, + int decimal_point, + int digits_after_point, + StringBuilder* result_builder) const; + + const int flags_; + const char* const infinity_symbol_; + const char* const nan_symbol_; + const char exponent_character_; + const int decimal_in_shortest_low_; + const int decimal_in_shortest_high_; + const int max_leading_padding_zeroes_in_precision_mode_; + const int max_trailing_padding_zeroes_in_precision_mode_; + const int min_exponent_width_; +#endif // not needed for ICU + + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); +}; + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END + +#endif // DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp b/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp index 8d1499a79b4a2e..87a3d536bf111f 100644 --- a/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp +++ b/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp @@ -152,7 +152,7 @@ static bool RoundWeed(Vector buffer, // Conceptually rest ~= too_high - buffer // We need to do the following tests in this order to avoid over- and // underflows. - ASSERT(rest <= unsafe_interval); + DOUBLE_CONVERSION_ASSERT(rest <= unsafe_interval); while (rest < small_distance && // Negated condition 1 unsafe_interval - rest >= ten_kappa && // Negated condition 2 (rest + ten_kappa < small_distance || // buffer{-1} > w_high @@ -198,7 +198,7 @@ static bool RoundWeedCounted(Vector buffer, uint64_t ten_kappa, uint64_t unit, int* kappa) { - ASSERT(rest < ten_kappa); + DOUBLE_CONVERSION_ASSERT(rest < ten_kappa); // The following tests are done in a specific order to avoid overflows. They // will work correctly with any uint64 values of rest < ten_kappa and unit. // @@ -255,7 +255,7 @@ static void BiggestPowerTen(uint32_t number, int number_bits, uint32_t* power, int* exponent_plus_one) { - ASSERT(number < (1u << (number_bits + 1))); + DOUBLE_CONVERSION_ASSERT(number < (1u << (number_bits + 1))); // 1233/4096 is approximately 1/lg(10). int exponent_plus_one_guess = ((number_bits + 1) * 1233 >> 12); // We increment to skip over the first entry in the kPowersOf10 table. @@ -317,9 +317,9 @@ static bool DigitGen(DiyFp low, Vector buffer, int* length, int* kappa) { - ASSERT(low.e() == w.e() && w.e() == high.e()); - ASSERT(low.f() + 1 <= high.f() - 1); - ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); + DOUBLE_CONVERSION_ASSERT(low.e() == w.e() && w.e() == high.e()); + DOUBLE_CONVERSION_ASSERT(low.f() + 1 <= high.f() - 1); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); // low, w and high are imprecise, but by less than one ulp (unit in the last // place). // If we remove (resp. add) 1 ulp from low (resp. high) we are certain that @@ -361,7 +361,7 @@ static bool DigitGen(DiyFp low, // that is smaller than integrals. while (*kappa > 0) { int digit = integrals / divisor; - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; integrals %= divisor; @@ -388,16 +388,16 @@ static bool DigitGen(DiyFp low, // data (like the interval or 'unit'), too. // Note that the multiplication by 10 does not overflow, because w.e >= -60 // and thus one.e >= -60. - ASSERT(one.e() >= -60); - ASSERT(fractionals < one.f()); - ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); + DOUBLE_CONVERSION_ASSERT(one.e() >= -60); + DOUBLE_CONVERSION_ASSERT(fractionals < one.f()); + DOUBLE_CONVERSION_ASSERT(DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); for (;;) { fractionals *= 10; unit *= 10; unsafe_interval.set_f(unsafe_interval.f() * 10); // Integer division by one. int digit = static_cast(fractionals >> -one.e()); - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; fractionals &= one.f() - 1; // Modulo by one. @@ -444,9 +444,9 @@ static bool DigitGenCounted(DiyFp w, Vector buffer, int* length, int* kappa) { - ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); - ASSERT(kMinimalTargetExponent >= -60); - ASSERT(kMaximalTargetExponent <= -32); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent >= -60); + DOUBLE_CONVERSION_ASSERT(kMaximalTargetExponent <= -32); // w is assumed to have an error less than 1 unit. Whenever w is scaled we // also scale its error. uint64_t w_error = 1; @@ -472,7 +472,7 @@ static bool DigitGenCounted(DiyFp w, // that is smaller than 'integrals'. while (*kappa > 0) { int digit = integrals / divisor; - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; requested_digits--; @@ -498,15 +498,15 @@ static bool DigitGenCounted(DiyFp w, // data (the 'unit'), too. // Note that the multiplication by 10 does not overflow, because w.e >= -60 // and thus one.e >= -60. - ASSERT(one.e() >= -60); - ASSERT(fractionals < one.f()); - ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); + DOUBLE_CONVERSION_ASSERT(one.e() >= -60); + DOUBLE_CONVERSION_ASSERT(fractionals < one.f()); + DOUBLE_CONVERSION_ASSERT(DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); while (requested_digits > 0 && fractionals > w_error) { fractionals *= 10; w_error *= 10; // Integer division by one. int digit = static_cast(fractionals >> -one.e()); - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; requested_digits--; @@ -544,11 +544,11 @@ static bool Grisu3(double v, if (mode == FAST_DTOA_SHORTEST) { Double(v).NormalizedBoundaries(&boundary_minus, &boundary_plus); } else { - ASSERT(mode == FAST_DTOA_SHORTEST_SINGLE); + DOUBLE_CONVERSION_ASSERT(mode == FAST_DTOA_SHORTEST_SINGLE); float single_v = static_cast(v); Single(single_v).NormalizedBoundaries(&boundary_minus, &boundary_plus); } - ASSERT(boundary_plus.e() == w.e()); + DOUBLE_CONVERSION_ASSERT(boundary_plus.e() == w.e()); DiyFp ten_mk; // Cached power of ten: 10^-k int mk; // -k int ten_mk_minimal_binary_exponent = @@ -559,7 +559,7 @@ static bool Grisu3(double v, ten_mk_minimal_binary_exponent, ten_mk_maximal_binary_exponent, &ten_mk, &mk); - ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + + DOUBLE_CONVERSION_ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + DiyFp::kSignificandSize) && (kMaximalTargetExponent >= w.e() + ten_mk.e() + DiyFp::kSignificandSize)); @@ -573,7 +573,7 @@ static bool Grisu3(double v, // In other words: let f = scaled_w.f() and e = scaled_w.e(), then // (f-1) * 2^e < w*10^k < (f+1) * 2^e DiyFp scaled_w = DiyFp::Times(w, ten_mk); - ASSERT(scaled_w.e() == + DOUBLE_CONVERSION_ASSERT(scaled_w.e() == boundary_plus.e() + ten_mk.e() + DiyFp::kSignificandSize); // In theory it would be possible to avoid some recomputations by computing // the difference between w and boundary_minus/plus (a power of 2) and to @@ -618,7 +618,7 @@ static bool Grisu3Counted(double v, ten_mk_minimal_binary_exponent, ten_mk_maximal_binary_exponent, &ten_mk, &mk); - ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + + DOUBLE_CONVERSION_ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + DiyFp::kSignificandSize) && (kMaximalTargetExponent >= w.e() + ten_mk.e() + DiyFp::kSignificandSize)); @@ -652,8 +652,8 @@ bool FastDtoa(double v, Vector buffer, int* length, int* decimal_point) { - ASSERT(v > 0); - ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(v > 0); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); bool result = false; int decimal_exponent = 0; @@ -667,7 +667,7 @@ bool FastDtoa(double v, buffer, length, &decimal_exponent); break; default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } if (result) { *decimal_point = *length + decimal_exponent; diff --git a/deps/icu-small/source/i18n/double-conversion-ieee.h b/deps/icu-small/source/i18n/double-conversion-ieee.h index c83c8d9abbb46e..f4c62a9a9f8d99 100644 --- a/deps/icu-small/source/i18n/double-conversion-ieee.h +++ b/deps/icu-small/source/i18n/double-conversion-ieee.h @@ -55,12 +55,14 @@ static float uint32_to_float(uint32_t d32) { return BitCast(d32); } // Helper functions for doubles. class Double { public: - static const uint64_t kSignMask = UINT64_2PART_C(0x80000000, 00000000); - static const uint64_t kExponentMask = UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kSignificandMask = UINT64_2PART_C(0x000FFFFF, FFFFFFFF); - static const uint64_t kHiddenBit = UINT64_2PART_C(0x00100000, 00000000); + static const uint64_t kSignMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); + static const uint64_t kExponentMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); + static const uint64_t kSignificandMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x000FFFFF, FFFFFFFF); + static const uint64_t kHiddenBit = DOUBLE_CONVERSION_UINT64_2PART_C(0x00100000, 00000000); static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit. static const int kSignificandSize = 53; + static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; + static const int kMaxExponent = 0x7FF - kExponentBias; Double() : d64_(0) {} explicit Double(double d) : d64_(double_to_uint64(d)) {} @@ -71,14 +73,14 @@ class Double { // The value encoded by this Double must be greater or equal to +0.0. // It must not be special (infinity, or NaN). DiyFp AsDiyFp() const { - ASSERT(Sign() > 0); - ASSERT(!IsSpecial()); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(!IsSpecial()); return DiyFp(Significand(), Exponent()); } // The value encoded by this Double must be strictly greater than 0. DiyFp AsNormalizedDiyFp() const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); uint64_t f = Significand(); int e = Exponent(); @@ -174,7 +176,7 @@ class Double { // Precondition: the value encoded by this Double must be greater or equal // than +0.0. DiyFp UpperBoundary() const { - ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); return DiyFp(Significand() * 2 + 1, Exponent() - 1); } @@ -183,7 +185,7 @@ class Double { // exponent as m_plus. // Precondition: the value encoded by this Double must be greater than 0. void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); DiyFp v = this->AsDiyFp(); DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); DiyFp m_minus; @@ -236,11 +238,9 @@ class Double { } private: - static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; static const int kDenormalExponent = -kExponentBias + 1; - static const int kMaxExponent = 0x7FF - kExponentBias; - static const uint64_t kInfinity = UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kNaN = UINT64_2PART_C(0x7FF80000, 00000000); + static const uint64_t kInfinity = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); + static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000); const uint64_t d64_; @@ -271,7 +271,7 @@ class Double { (biased_exponent << kPhysicalSignificandSize); } - DC_DISALLOW_COPY_AND_ASSIGN(Double); + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Double); }; class Single { @@ -290,8 +290,8 @@ class Single { // The value encoded by this Single must be greater or equal to +0.0. // It must not be special (infinity, or NaN). DiyFp AsDiyFp() const { - ASSERT(Sign() > 0); - ASSERT(!IsSpecial()); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(!IsSpecial()); return DiyFp(Significand(), Exponent()); } @@ -354,7 +354,7 @@ class Single { // exponent as m_plus. // Precondition: the value encoded by this Single must be greater than 0. void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); DiyFp v = this->AsDiyFp(); DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); DiyFp m_minus; @@ -372,7 +372,7 @@ class Single { // Precondition: the value encoded by this Single must be greater or equal // than +0.0. DiyFp UpperBoundary() const { - ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); return DiyFp(Significand() * 2 + 1, Exponent() - 1); } @@ -408,7 +408,7 @@ class Single { const uint32_t d32_; - DC_DISALLOW_COPY_AND_ASSIGN(Single); + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Single); }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion.cpp b/deps/icu-small/source/i18n/double-conversion-string-to-double.cpp similarity index 63% rename from deps/icu-small/source/i18n/double-conversion.cpp rename to deps/icu-small/source/i18n/double-conversion-string-to-double.cpp index 1a60afbd64b6b7..946b2b26e77aa4 100644 --- a/deps/icu-small/source/i18n/double-conversion.cpp +++ b/deps/icu-small/source/i18n/double-conversion-string-to-double.cpp @@ -37,16 +37,13 @@ // ICU PATCH: Do not include std::locale. #include -//#include +// #include #include // ICU PATCH: Customize header file paths for ICU. -// The file fixed-dtoa.h is not needed. -#include "double-conversion.h" +#include "double-conversion-string-to-double.h" -#include "double-conversion-bignum-dtoa.h" -#include "double-conversion-fast-dtoa.h" #include "double-conversion-ieee.h" #include "double-conversion-strtod.h" #include "double-conversion-utils.h" @@ -56,385 +53,6 @@ U_NAMESPACE_BEGIN namespace double_conversion { -#if 0 // not needed for ICU -const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { - int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; - static DoubleToStringConverter converter(flags, - "Infinity", - "NaN", - 'e', - -6, 21, - 6, 0); - return converter; -} - - -bool DoubleToStringConverter::HandleSpecialValues( - double value, - StringBuilder* result_builder) const { - Double double_inspect(value); - if (double_inspect.IsInfinite()) { - if (infinity_symbol_ == NULL) return false; - if (value < 0) { - result_builder->AddCharacter('-'); - } - result_builder->AddString(infinity_symbol_); - return true; - } - if (double_inspect.IsNan()) { - if (nan_symbol_ == NULL) return false; - result_builder->AddString(nan_symbol_); - return true; - } - return false; -} - - -void DoubleToStringConverter::CreateExponentialRepresentation( - const char* decimal_digits, - int length, - int exponent, - StringBuilder* result_builder) const { - ASSERT(length != 0); - result_builder->AddCharacter(decimal_digits[0]); - if (length != 1) { - result_builder->AddCharacter('.'); - result_builder->AddSubstring(&decimal_digits[1], length-1); - } - result_builder->AddCharacter(exponent_character_); - if (exponent < 0) { - result_builder->AddCharacter('-'); - exponent = -exponent; - } else { - if ((flags_ & EMIT_POSITIVE_EXPONENT_SIGN) != 0) { - result_builder->AddCharacter('+'); - } - } - if (exponent == 0) { - result_builder->AddCharacter('0'); - return; - } - ASSERT(exponent < 1e4); - const int kMaxExponentLength = 5; - char buffer[kMaxExponentLength + 1]; - buffer[kMaxExponentLength] = '\0'; - int first_char_pos = kMaxExponentLength; - while (exponent > 0) { - buffer[--first_char_pos] = '0' + (exponent % 10); - exponent /= 10; - } - result_builder->AddSubstring(&buffer[first_char_pos], - kMaxExponentLength - first_char_pos); -} - - -void DoubleToStringConverter::CreateDecimalRepresentation( - const char* decimal_digits, - int length, - int decimal_point, - int digits_after_point, - StringBuilder* result_builder) const { - // Create a representation that is padded with zeros if needed. - if (decimal_point <= 0) { - // "0.00000decimal_rep" or "0.000decimal_rep00". - result_builder->AddCharacter('0'); - if (digits_after_point > 0) { - result_builder->AddCharacter('.'); - result_builder->AddPadding('0', -decimal_point); - ASSERT(length <= digits_after_point - (-decimal_point)); - result_builder->AddSubstring(decimal_digits, length); - int remaining_digits = digits_after_point - (-decimal_point) - length; - result_builder->AddPadding('0', remaining_digits); - } - } else if (decimal_point >= length) { - // "decimal_rep0000.00000" or "decimal_rep.0000". - result_builder->AddSubstring(decimal_digits, length); - result_builder->AddPadding('0', decimal_point - length); - if (digits_after_point > 0) { - result_builder->AddCharacter('.'); - result_builder->AddPadding('0', digits_after_point); - } - } else { - // "decima.l_rep000". - ASSERT(digits_after_point > 0); - result_builder->AddSubstring(decimal_digits, decimal_point); - result_builder->AddCharacter('.'); - ASSERT(length - decimal_point <= digits_after_point); - result_builder->AddSubstring(&decimal_digits[decimal_point], - length - decimal_point); - int remaining_digits = digits_after_point - (length - decimal_point); - result_builder->AddPadding('0', remaining_digits); - } - if (digits_after_point == 0) { - if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) { - result_builder->AddCharacter('.'); - } - if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) { - result_builder->AddCharacter('0'); - } - } -} - - -bool DoubleToStringConverter::ToShortestIeeeNumber( - double value, - StringBuilder* result_builder, - DoubleToStringConverter::DtoaMode mode) const { - ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE); - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - int decimal_point; - bool sign; - const int kDecimalRepCapacity = kBase10MaximalLength + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - DoubleToAscii(value, mode, 0, decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - - bool unique_zero = (flags_ & UNIQUE_ZERO) != 0; - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - int exponent = decimal_point - 1; - if ((decimal_in_shortest_low_ <= exponent) && - (exponent < decimal_in_shortest_high_)) { - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, - decimal_point, - Max(0, decimal_rep_length - decimal_point), - result_builder); - } else { - CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent, - result_builder); - } - return true; -} - - -bool DoubleToStringConverter::ToFixed(double value, - int requested_digits, - StringBuilder* result_builder) const { - ASSERT(kMaxFixedDigitsBeforePoint == 60); - const double kFirstNonFixed = 1e60; - - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (requested_digits > kMaxFixedDigitsAfterPoint) return false; - if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false; - - // Find a sufficiently precise decimal representation of n. - int decimal_point; - bool sign; - // Add space for the '\0' byte. - const int kDecimalRepCapacity = - kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - DoubleToAscii(value, FIXED, requested_digits, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, - requested_digits, result_builder); - return true; -} - - -bool DoubleToStringConverter::ToExponential( - double value, - int requested_digits, - StringBuilder* result_builder) const { - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (requested_digits < -1) return false; - if (requested_digits > kMaxExponentialDigits) return false; - - int decimal_point; - bool sign; - // Add space for digit before the decimal point and the '\0' character. - const int kDecimalRepCapacity = kMaxExponentialDigits + 2; - ASSERT(kDecimalRepCapacity > kBase10MaximalLength); - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - if (requested_digits == -1) { - DoubleToAscii(value, SHORTEST, 0, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - } else { - DoubleToAscii(value, PRECISION, requested_digits + 1, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - ASSERT(decimal_rep_length <= requested_digits + 1); - - for (int i = decimal_rep_length; i < requested_digits + 1; ++i) { - decimal_rep[i] = '0'; - } - decimal_rep_length = requested_digits + 1; - } - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - int exponent = decimal_point - 1; - CreateExponentialRepresentation(decimal_rep, - decimal_rep_length, - exponent, - result_builder); - return true; -} - - -bool DoubleToStringConverter::ToPrecision(double value, - int precision, - StringBuilder* result_builder) const { - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) { - return false; - } - - // Find a sufficiently precise decimal representation of n. - int decimal_point; - bool sign; - // Add one for the terminating null character. - const int kDecimalRepCapacity = kMaxPrecisionDigits + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - DoubleToAscii(value, PRECISION, precision, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - ASSERT(decimal_rep_length <= precision); - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - // The exponent if we print the number as x.xxeyyy. That is with the - // decimal point after the first digit. - int exponent = decimal_point - 1; - - int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0; - if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) || - (decimal_point - precision + extra_zero > - max_trailing_padding_zeroes_in_precision_mode_)) { - // Fill buffer to contain 'precision' digits. - // Usually the buffer is already at the correct length, but 'DoubleToAscii' - // is allowed to return less characters. - for (int i = decimal_rep_length; i < precision; ++i) { - decimal_rep[i] = '0'; - } - - CreateExponentialRepresentation(decimal_rep, - precision, - exponent, - result_builder); - } else { - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, - Max(0, precision - decimal_point), - result_builder); - } - return true; -} -#endif // not needed for ICU - - -static BignumDtoaMode DtoaToBignumDtoaMode( - DoubleToStringConverter::DtoaMode dtoa_mode) { - switch (dtoa_mode) { - case DoubleToStringConverter::SHORTEST: return BIGNUM_DTOA_SHORTEST; - case DoubleToStringConverter::SHORTEST_SINGLE: - return BIGNUM_DTOA_SHORTEST_SINGLE; - case DoubleToStringConverter::FIXED: return BIGNUM_DTOA_FIXED; - case DoubleToStringConverter::PRECISION: return BIGNUM_DTOA_PRECISION; - default: - UNREACHABLE(); - } -} - - -void DoubleToStringConverter::DoubleToAscii(double v, - DtoaMode mode, - int requested_digits, - char* buffer, - int buffer_length, - bool* sign, - int* length, - int* point) { - Vector vector(buffer, buffer_length); - ASSERT(!Double(v).IsSpecial()); - ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE || requested_digits >= 0); - - if (Double(v).Sign() < 0) { - *sign = true; - v = -v; - } else { - *sign = false; - } - - if (mode == PRECISION && requested_digits == 0) { - vector[0] = '\0'; - *length = 0; - return; - } - - if (v == 0) { - vector[0] = '0'; - vector[1] = '\0'; - *length = 1; - *point = 1; - return; - } - - bool fast_worked; - switch (mode) { - case SHORTEST: - fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point); - break; -#if 0 // not needed for ICU - case SHORTEST_SINGLE: - fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST_SINGLE, 0, - vector, length, point); - break; - case FIXED: - fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point); - break; - case PRECISION: - fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits, - vector, length, point); - break; -#endif // not needed for ICU - default: - fast_worked = false; - UNREACHABLE(); - } - if (fast_worked) return; - - // If the fast dtoa didn't succeed use the slower bignum version. - BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode); - BignumDtoa(v, bignum_mode, requested_digits, vector, length, point); - vector[*length] = '\0'; -} - - namespace { inline char ToLower(char ch) { @@ -444,7 +62,7 @@ inline char ToLower(char ch) { return cType.tolower(ch); #else (void)ch; - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); #endif } @@ -457,7 +75,7 @@ static inline bool ConsumeSubStringImpl(Iterator* current, Iterator end, const char* substring, Converter converter) { - ASSERT(converter(**current) == *substring); + DOUBLE_CONVERSION_ASSERT(converter(**current) == *substring); for (substring++; *substring != '\0'; substring++) { ++*current; if (*current == end || converter(**current) != *substring) { @@ -474,8 +92,8 @@ template static bool ConsumeSubString(Iterator* current, Iterator end, const char* substring, - bool allow_case_insensibility) { - if (allow_case_insensibility) { + bool allow_case_insensitivity) { + if (allow_case_insensitivity) { return ConsumeSubStringImpl(current, end, substring, ToLower); } else { return ConsumeSubStringImpl(current, end, substring, Pass); @@ -485,8 +103,8 @@ static bool ConsumeSubString(Iterator* current, // Consumes first character of the str is equal to ch inline bool ConsumeFirstCharacter(char ch, const char* str, - bool case_insensibility) { - return case_insensibility ? ToLower(ch) == str[0] : ch == str[0]; + bool case_insensitivity) { + return case_insensitivity ? ToLower(ch) == str[0] : ch == str[0]; } } // namespace @@ -501,15 +119,14 @@ const int kMaxSignificantDigits = 772; static const char kWhitespaceTable7[] = { 32, 13, 10, 9, 11, 12 }; -static const int kWhitespaceTable7Length = ARRAY_SIZE(kWhitespaceTable7); +static const int kWhitespaceTable7Length = DOUBLE_CONVERSION_ARRAY_SIZE(kWhitespaceTable7); static const uc16 kWhitespaceTable16[] = { 160, 8232, 8233, 5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279 }; -static const int kWhitespaceTable16Length = ARRAY_SIZE(kWhitespaceTable16); - +static const int kWhitespaceTable16Length = DOUBLE_CONVERSION_ARRAY_SIZE(kWhitespaceTable16); static bool isWhitespace(int x) { @@ -609,7 +226,7 @@ static bool IsHexFloatString(Iterator start, Iterator end, uc16 separator, bool allow_trailing_junk) { - ASSERT(start != end); + DOUBLE_CONVERSION_ASSERT(start != end); Iterator current = start; @@ -624,8 +241,8 @@ static bool IsHexFloatString(Iterator start, saw_digit = true; if (Advance(¤t, separator, 16, end)) return false; } - if (!saw_digit) return false; // Only the '.', but no digits. } + if (!saw_digit) return false; if (*current != 'p' && *current != 'P') return false; if (Advance(¤t, separator, 16, end)) return false; if (*current == '+' || *current == '-') { @@ -654,8 +271,8 @@ static double RadixStringToIeee(Iterator* current, double junk_string_value, bool read_as_double, bool* result_is_junk) { - ASSERT(*current != end); - ASSERT(!parse_as_hex_float || + DOUBLE_CONVERSION_ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(!parse_as_hex_float || IsHexFloatString(*current, end, separator, allow_trailing_junk)); const int kDoubleSize = Double::kSignificandSize; @@ -693,7 +310,7 @@ static double RadixStringToIeee(Iterator* current, } else if (parse_as_hex_float && **current == '.') { post_decimal = true; Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); continue; } else if (parse_as_hex_float && (**current == 'p' || **current == 'P')) { break; @@ -728,7 +345,7 @@ static double RadixStringToIeee(Iterator* current, // Just run over the '.'. We are just trying to see whether there is // a non-zero digit somewhere. Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); post_decimal = true; } if (!isDigit(**current, radix)) break; @@ -763,27 +380,31 @@ static double RadixStringToIeee(Iterator* current, if (Advance(current, separator, radix, end)) break; } - ASSERT(number < ((int64_t)1 << kSignificandSize)); - ASSERT(static_cast(static_cast(number)) == number); + DOUBLE_CONVERSION_ASSERT(number < ((int64_t)1 << kSignificandSize)); + DOUBLE_CONVERSION_ASSERT(static_cast(static_cast(number)) == number); *result_is_junk = false; if (parse_as_hex_float) { - ASSERT(**current == 'p' || **current == 'P'); + DOUBLE_CONVERSION_ASSERT(**current == 'p' || **current == 'P'); Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); bool is_negative = false; if (**current == '+') { Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); } else if (**current == '-') { is_negative = true; Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); } int written_exponent = 0; while (IsDecimalDigitForRadix(**current, 10)) { - written_exponent = 10 * written_exponent + **current - '0'; + // No need to read exponents if they are too big. That could potentially overflow + // the `written_exponent` variable. + if (abs(written_exponent) <= 100 * Double::kMaxExponent) { + written_exponent = 10 * written_exponent + **current - '0'; + } if (Advance(current, separator, radix, end)) break; } if (is_negative) written_exponent = -written_exponent; @@ -798,7 +419,7 @@ static double RadixStringToIeee(Iterator* current, return static_cast(number); } - ASSERT(number != 0); + DOUBLE_CONVERSION_ASSERT(number != 0); double result = Double(DiyFp(number, exponent)).value(); return sign ? -result : result; } @@ -818,7 +439,7 @@ double StringToDoubleConverter::StringToIeee( const bool allow_leading_spaces = (flags_ & ALLOW_LEADING_SPACES) != 0; const bool allow_trailing_spaces = (flags_ & ALLOW_TRAILING_SPACES) != 0; const bool allow_spaces_after_sign = (flags_ & ALLOW_SPACES_AFTER_SIGN) != 0; - const bool allow_case_insensibility = (flags_ & ALLOW_CASE_INSENSIBILITY) != 0; + const bool allow_case_insensitivity = (flags_ & ALLOW_CASE_INSENSITIVITY) != 0; // To make sure that iterator dereferencing is valid the following // convention is used: @@ -868,8 +489,8 @@ double StringToDoubleConverter::StringToIeee( } if (infinity_symbol_ != NULL) { - if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensibility)) { - if (!ConsumeSubString(¤t, end, infinity_symbol_, allow_case_insensibility)) { + if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) { + if (!ConsumeSubString(¤t, end, infinity_symbol_, allow_case_insensitivity)) { return junk_string_value_; } @@ -880,15 +501,15 @@ double StringToDoubleConverter::StringToIeee( return junk_string_value_; } - ASSERT(buffer_pos == 0); + DOUBLE_CONVERSION_ASSERT(buffer_pos == 0); *processed_characters_count = static_cast(current - input); return sign ? -Double::Infinity() : Double::Infinity(); } } if (nan_symbol_ != NULL) { - if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensibility)) { - if (!ConsumeSubString(¤t, end, nan_symbol_, allow_case_insensibility)) { + if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) { + if (!ConsumeSubString(¤t, end, nan_symbol_, allow_case_insensitivity)) { return junk_string_value_; } @@ -899,7 +520,7 @@ double StringToDoubleConverter::StringToIeee( return junk_string_value_; } - ASSERT(buffer_pos == 0); + DOUBLE_CONVERSION_ASSERT(buffer_pos == 0); *processed_characters_count = static_cast(current - input); return sign ? -Double::NaN() : Double::NaN(); } @@ -919,10 +540,11 @@ double StringToDoubleConverter::StringToIeee( (*current == 'x' || *current == 'X')) { ++current; + if (current == end) return junk_string_value_; // "0x" + bool parse_as_hex_float = (flags_ & ALLOW_HEX_FLOATS) && IsHexFloatString(current, end, separator_, allow_trailing_junk); - if (current == end) return junk_string_value_; // "0x" if (!parse_as_hex_float && !isDigit(*current, 16)) { return junk_string_value_; } @@ -958,7 +580,7 @@ double StringToDoubleConverter::StringToIeee( // Copy significant digits of the integer part (if any) to the buffer. while (*current >= '0' && *current <= '9') { if (significant_digits < kMaxSignificantDigits) { - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos++] = static_cast(*current); significant_digits++; // Will later check if it's an octal in the buffer. @@ -1003,7 +625,7 @@ double StringToDoubleConverter::StringToIeee( // We don't emit a '.', but adjust the exponent instead. while (*current >= '0' && *current <= '9') { if (significant_digits < kMaxSignificantDigits) { - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos++] = static_cast(*current); significant_digits++; exponent--; @@ -1061,7 +683,7 @@ double StringToDoubleConverter::StringToIeee( } const int max_exponent = INT_MAX / 2; - ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2); + DOUBLE_CONVERSION_ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2); int num = 0; do { // Check overflow. @@ -1104,7 +726,7 @@ double StringToDoubleConverter::StringToIeee( junk_string_value_, read_as_double, &result_is_junk); - ASSERT(!result_is_junk); + DOUBLE_CONVERSION_ASSERT(!result_is_junk); *processed_characters_count = static_cast(current - input); return result; } @@ -1114,7 +736,7 @@ double StringToDoubleConverter::StringToIeee( exponent--; } - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos] = '\0'; double converted; diff --git a/deps/icu-small/source/i18n/double-conversion-string-to-double.h b/deps/icu-small/source/i18n/double-conversion-string-to-double.h new file mode 100644 index 00000000000000..2eb0c1f8979838 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-string-to-double.h @@ -0,0 +1,244 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#ifndef DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ +#define DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ + +// ICU PATCH: Customize header file paths for ICU. + +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +class StringToDoubleConverter { + public: + // Enumeration for allowing octals and ignoring junk when converting + // strings to numbers. + enum Flags { + NO_FLAGS = 0, + ALLOW_HEX = 1, + ALLOW_OCTALS = 2, + ALLOW_TRAILING_JUNK = 4, + ALLOW_LEADING_SPACES = 8, + ALLOW_TRAILING_SPACES = 16, + ALLOW_SPACES_AFTER_SIGN = 32, + ALLOW_CASE_INSENSITIVITY = 64, + ALLOW_CASE_INSENSIBILITY = 64, // Deprecated + ALLOW_HEX_FLOATS = 128, + }; + + static const uc16 kNoSeparator = '\0'; + + // Flags should be a bit-or combination of the possible Flags-enum. + // - NO_FLAGS: no special flags. + // - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers. + // Ex: StringToDouble("0x1234") -> 4660.0 + // In StringToDouble("0x1234.56") the characters ".56" are trailing + // junk. The result of the call is hence dependent on + // the ALLOW_TRAILING_JUNK flag and/or the junk value. + // With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK, + // the string will not be parsed as "0" followed by junk. + // + // - ALLOW_OCTALS: recognizes the prefix "0" for octals: + // If a sequence of octal digits starts with '0', then the number is + // read as octal integer. Octal numbers may only be integers. + // Ex: StringToDouble("01234") -> 668.0 + // StringToDouble("012349") -> 12349.0 // Not a sequence of octal + // // digits. + // In StringToDouble("01234.56") the characters ".56" are trailing + // junk. The result of the call is hence dependent on + // the ALLOW_TRAILING_JUNK flag and/or the junk value. + // In StringToDouble("01234e56") the characters "e56" are trailing + // junk, too. + // - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of + // a double literal. + // - ALLOW_LEADING_SPACES: skip over leading whitespace, including spaces, + // new-lines, and tabs. + // - ALLOW_TRAILING_SPACES: ignore trailing whitespace. + // - ALLOW_SPACES_AFTER_SIGN: ignore whitespace after the sign. + // Ex: StringToDouble("- 123.2") -> -123.2. + // StringToDouble("+ 123.2") -> 123.2 + // - ALLOW_CASE_INSENSITIVITY: ignore case of characters for special values: + // infinity and nan. + // - ALLOW_HEX_FLOATS: allows hexadecimal float literals. + // This *must* start with "0x" and separate the exponent with "p". + // Examples: 0x1.2p3 == 9.0 + // 0x10.1p0 == 16.0625 + // ALLOW_HEX and ALLOW_HEX_FLOATS are indendent. + // + // empty_string_value is returned when an empty string is given as input. + // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string + // containing only spaces is converted to the 'empty_string_value', too. + // + // junk_string_value is returned when + // a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not + // part of a double-literal) is found. + // b) ALLOW_TRAILING_JUNK is set, but the string does not start with a + // double literal. + // + // infinity_symbol and nan_symbol are strings that are used to detect + // inputs that represent infinity and NaN. They can be null, in which case + // they are ignored. + // The conversion routine first reads any possible signs. Then it compares the + // following character of the input-string with the first character of + // the infinity, and nan-symbol. If either matches, the function assumes, that + // a match has been found, and expects the following input characters to match + // the remaining characters of the special-value symbol. + // This means that the following restrictions apply to special-value symbols: + // - they must not start with signs ('+', or '-'), + // - they must not have the same first character. + // - they must not start with digits. + // + // If the separator character is not kNoSeparator, then that specific + // character is ignored when in between two valid digits of the significant. + // It is not allowed to appear in the exponent. + // It is not allowed to lead or trail the number. + // It is not allowed to appear twice next to each other. + // + // Examples: + // flags = ALLOW_HEX | ALLOW_TRAILING_JUNK, + // empty_string_value = 0.0, + // junk_string_value = NaN, + // infinity_symbol = "infinity", + // nan_symbol = "nan": + // StringToDouble("0x1234") -> 4660.0. + // StringToDouble("0x1234K") -> 4660.0. + // StringToDouble("") -> 0.0 // empty_string_value. + // StringToDouble(" ") -> NaN // junk_string_value. + // StringToDouble(" 1") -> NaN // junk_string_value. + // StringToDouble("0x") -> NaN // junk_string_value. + // StringToDouble("-123.45") -> -123.45. + // StringToDouble("--123.45") -> NaN // junk_string_value. + // StringToDouble("123e45") -> 123e45. + // StringToDouble("123E45") -> 123e45. + // StringToDouble("123e+45") -> 123e45. + // StringToDouble("123E-45") -> 123e-45. + // StringToDouble("123e") -> 123.0 // trailing junk ignored. + // StringToDouble("123e-") -> 123.0 // trailing junk ignored. + // StringToDouble("+NaN") -> NaN // NaN string literal. + // StringToDouble("-infinity") -> -inf. // infinity literal. + // StringToDouble("Infinity") -> NaN // junk_string_value. + // + // flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES, + // empty_string_value = 0.0, + // junk_string_value = NaN, + // infinity_symbol = NULL, + // nan_symbol = NULL: + // StringToDouble("0x1234") -> NaN // junk_string_value. + // StringToDouble("01234") -> 668.0. + // StringToDouble("") -> 0.0 // empty_string_value. + // StringToDouble(" ") -> 0.0 // empty_string_value. + // StringToDouble(" 1") -> 1.0 + // StringToDouble("0x") -> NaN // junk_string_value. + // StringToDouble("0123e45") -> NaN // junk_string_value. + // StringToDouble("01239E45") -> 1239e45. + // StringToDouble("-infinity") -> NaN // junk_string_value. + // StringToDouble("NaN") -> NaN // junk_string_value. + // + // flags = NO_FLAGS, + // separator = ' ': + // StringToDouble("1 2 3 4") -> 1234.0 + // StringToDouble("1 2") -> NaN // junk_string_value + // StringToDouble("1 000 000.0") -> 1000000.0 + // StringToDouble("1.000 000") -> 1.0 + // StringToDouble("1.0e1 000") -> NaN // junk_string_value + StringToDoubleConverter(int flags, + double empty_string_value, + double junk_string_value, + const char* infinity_symbol, + const char* nan_symbol, + uc16 separator = kNoSeparator) + : flags_(flags), + empty_string_value_(empty_string_value), + junk_string_value_(junk_string_value), + infinity_symbol_(infinity_symbol), + nan_symbol_(nan_symbol), + separator_(separator) { + } + + // Performs the conversion. + // The output parameter 'processed_characters_count' is set to the number + // of characters that have been processed to read the number. + // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included + // in the 'processed_characters_count'. Trailing junk is never included. + double StringToDouble(const char* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToDouble above but for 16 bit characters. + double StringToDouble(const uc16* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToDouble but reads a float. + // Note that this is not equivalent to static_cast(StringToDouble(...)) + // due to potential double-rounding. + float StringToFloat(const char* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToFloat above but for 16 bit characters. + float StringToFloat(const uc16* buffer, + int length, + int* processed_characters_count) const; + + private: + const int flags_; + const double empty_string_value_; + const double junk_string_value_; + const char* const infinity_symbol_; + const char* const nan_symbol_; + const uc16 separator_; + + template + double StringToIeee(Iterator start_pointer, + int length, + bool read_as_double, + int* processed_characters_count) const; + + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); +}; + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END + +#endif // DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-strtod.cpp b/deps/icu-small/source/i18n/double-conversion-strtod.cpp index be9b0b3bce0e76..9cf4854426756c 100644 --- a/deps/icu-small/source/i18n/double-conversion-strtod.cpp +++ b/deps/icu-small/source/i18n/double-conversion-strtod.cpp @@ -34,16 +34,15 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING -#include -#include +#include +#include // ICU PATCH: Customize header file paths for ICU. -// The file fixed-dtoa.h is not needed. -#include "double-conversion-strtod.h" #include "double-conversion-bignum.h" #include "double-conversion-cached-powers.h" #include "double-conversion-ieee.h" +#include "double-conversion-strtod.h" // ICU PATCH: Wrap in ICU namespace U_NAMESPACE_BEGIN @@ -67,7 +66,7 @@ static const int kMaxDecimalPower = 309; static const int kMinDecimalPower = -324; // 2^64 = 18446744073709551616 -static const uint64_t kMaxUint64 = UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF); +static const uint64_t kMaxUint64 = DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF); static const double exact_powers_of_ten[] = { @@ -96,7 +95,7 @@ static const double exact_powers_of_ten[] = { // 10^22 = 0x21e19e0c9bab2400000 = 0x878678326eac9 * 2^22 10000000000000000000000.0 }; -static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten); +static const int kExactPowersOfTenSize = DOUBLE_CONVERSION_ARRAY_SIZE(exact_powers_of_ten); // Maximum number of significant digits in the decimal representation. // In fact the value is 772 (see conversions.cc), but to give us some margin @@ -132,7 +131,7 @@ static void CutToMaxSignificantDigits(Vector buffer, } // The input buffer has been trimmed. Therefore the last digit must be // different from '0'. - ASSERT(buffer[buffer.length() - 1] != '0'); + DOUBLE_CONVERSION_ASSERT(buffer[buffer.length() - 1] != '0'); // Set the last digit to be non-zero. This is sufficient to guarantee // correct rounding. significant_buffer[kMaxSignificantDecimalDigits - 1] = '1'; @@ -153,7 +152,7 @@ static void TrimAndCut(Vector buffer, int exponent, exponent += left_trimmed.length() - right_trimmed.length(); if (right_trimmed.length() > kMaxSignificantDecimalDigits) { (void) space_size; // Mark variable as used. - ASSERT(space_size >= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(space_size >= kMaxSignificantDecimalDigits); CutToMaxSignificantDigits(right_trimmed, exponent, buffer_copy_space, updated_exponent); *trimmed = Vector(buffer_copy_space, @@ -176,7 +175,7 @@ static uint64_t ReadUint64(Vector buffer, int i = 0; while (i < buffer.length() && result <= (kMaxUint64 / 10 - 1)) { int digit = buffer[i++] - '0'; - ASSERT(0 <= digit && digit <= 9); + DOUBLE_CONVERSION_ASSERT(0 <= digit && digit <= 9); result = 10 * result + digit; } *number_of_read_digits = i; @@ -220,7 +219,7 @@ static bool DoubleStrtod(Vector trimmed, // Note that the ARM simulator is compiled for 32bits. It therefore exhibits // the same problem. return false; -#endif +#else if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) { int read_digits; // The trimmed input fits into a double. @@ -232,14 +231,14 @@ static bool DoubleStrtod(Vector trimmed, if (exponent < 0 && -exponent < kExactPowersOfTenSize) { // 10^-exponent fits into a double. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result /= exact_powers_of_ten[-exponent]; return true; } if (0 <= exponent && exponent < kExactPowersOfTenSize) { // 10^exponent fits into a double. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result *= exact_powers_of_ten[exponent]; return true; } @@ -251,34 +250,35 @@ static bool DoubleStrtod(Vector trimmed, // 10^remaining_digits. As a result the remaining exponent now fits // into a double too. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result *= exact_powers_of_ten[remaining_digits]; *result *= exact_powers_of_ten[exponent - remaining_digits]; return true; } } return false; +#endif } // Returns 10^exponent as an exact DiyFp. // The given exponent must be in the range [1; kDecimalExponentDistance[. static DiyFp AdjustmentPowerOfTen(int exponent) { - ASSERT(0 < exponent); - ASSERT(exponent < PowersOfTenCache::kDecimalExponentDistance); + DOUBLE_CONVERSION_ASSERT(0 < exponent); + DOUBLE_CONVERSION_ASSERT(exponent < PowersOfTenCache::kDecimalExponentDistance); // Simply hardcode the remaining powers for the given decimal exponent // distance. - ASSERT(PowersOfTenCache::kDecimalExponentDistance == 8); + DOUBLE_CONVERSION_ASSERT(PowersOfTenCache::kDecimalExponentDistance == 8); switch (exponent) { - case 1: return DiyFp(UINT64_2PART_C(0xa0000000, 00000000), -60); - case 2: return DiyFp(UINT64_2PART_C(0xc8000000, 00000000), -57); - case 3: return DiyFp(UINT64_2PART_C(0xfa000000, 00000000), -54); - case 4: return DiyFp(UINT64_2PART_C(0x9c400000, 00000000), -50); - case 5: return DiyFp(UINT64_2PART_C(0xc3500000, 00000000), -47); - case 6: return DiyFp(UINT64_2PART_C(0xf4240000, 00000000), -44); - case 7: return DiyFp(UINT64_2PART_C(0x98968000, 00000000), -40); + case 1: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xa0000000, 00000000), -60); + case 2: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xc8000000, 00000000), -57); + case 3: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xfa000000, 00000000), -54); + case 4: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0x9c400000, 00000000), -50); + case 5: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xc3500000, 00000000), -47); + case 6: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xf4240000, 00000000), -44); + case 7: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0x98968000, 00000000), -40); default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } } @@ -307,7 +307,7 @@ static bool DiyFpStrtod(Vector buffer, input.Normalize(); error <<= old_e - input.e(); - ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent); + DOUBLE_CONVERSION_ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent); if (exponent < PowersOfTenCache::kMinDecimalExponent) { *result = 0.0; return true; @@ -325,7 +325,7 @@ static bool DiyFpStrtod(Vector buffer, if (kMaxUint64DecimalDigits - buffer.length() >= adjustment_exponent) { // The product of input with the adjustment power fits into a 64 bit // integer. - ASSERT(DiyFp::kSignificandSize == 64); + DOUBLE_CONVERSION_ASSERT(DiyFp::kSignificandSize == 64); } else { // The adjustment power is exact. There is hence only an error of 0.5. error += kDenominator / 2; @@ -367,8 +367,8 @@ static bool DiyFpStrtod(Vector buffer, precision_digits_count -= shift_amount; } // We use uint64_ts now. This only works if the DiyFp uses uint64_ts too. - ASSERT(DiyFp::kSignificandSize == 64); - ASSERT(precision_digits_count < 64); + DOUBLE_CONVERSION_ASSERT(DiyFp::kSignificandSize == 64); + DOUBLE_CONVERSION_ASSERT(precision_digits_count < 64); uint64_t one64 = 1; uint64_t precision_bits_mask = (one64 << precision_digits_count) - 1; uint64_t precision_bits = input.f() & precision_bits_mask; @@ -407,14 +407,14 @@ static bool DiyFpStrtod(Vector buffer, static int CompareBufferWithDiyFp(Vector buffer, int exponent, DiyFp diy_fp) { - ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1); - ASSERT(buffer.length() + exponent > kMinDecimalPower); - ASSERT(buffer.length() <= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1); + DOUBLE_CONVERSION_ASSERT(buffer.length() + exponent > kMinDecimalPower); + DOUBLE_CONVERSION_ASSERT(buffer.length() <= kMaxSignificantDecimalDigits); // Make sure that the Bignum will be able to hold all our numbers. // Our Bignum implementation has a separate field for exponents. Shifts will // consume at most one bigit (< 64 bits). // ln(10) == 3.3219... - ASSERT(((kMaxDecimalPower + 1) * 333 / 100) < Bignum::kMaxSignificantBits); + DOUBLE_CONVERSION_ASSERT(((kMaxDecimalPower + 1) * 333 / 100) < Bignum::kMaxSignificantBits); Bignum buffer_bignum; Bignum diy_fp_bignum; buffer_bignum.AssignDecimalString(buffer); @@ -460,18 +460,33 @@ static bool ComputeGuess(Vector trimmed, int exponent, return false; } -double Strtod(Vector buffer, int exponent) { - char copy_buffer[kMaxSignificantDecimalDigits]; - Vector trimmed; - int updated_exponent; - TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits, - &trimmed, &updated_exponent); - exponent = updated_exponent; +#if U_DEBUG // needed for ICU only in debug mode +static bool IsDigit(const char d) { + return ('0' <= d) && (d <= '9'); +} - double guess; - bool is_correct = ComputeGuess(trimmed, exponent, &guess); - if (is_correct) return guess; +static bool IsNonZeroDigit(const char d) { + return ('1' <= d) && (d <= '9'); +} + +static bool AssertTrimmedDigits(const Vector& buffer) { + for(int i = 0; i < buffer.length(); ++i) { + if(!IsDigit(buffer[i])) { + return false; + } + } + return (buffer.length() == 0) || (IsNonZeroDigit(buffer[0]) && IsNonZeroDigit(buffer[buffer.length()-1])); +} +#endif // needed for ICU only in debug mode +double StrtodTrimmed(Vector trimmed, int exponent) { + DOUBLE_CONVERSION_ASSERT(trimmed.length() <= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(AssertTrimmedDigits(trimmed)); + double guess; + const bool is_correct = ComputeGuess(trimmed, exponent, &guess); + if (is_correct) { + return guess; + } DiyFp upper_boundary = Double(guess).UpperBoundary(); int comparison = CompareBufferWithDiyFp(trimmed, exponent, upper_boundary); if (comparison < 0) { @@ -486,6 +501,39 @@ double Strtod(Vector buffer, int exponent) { } } +double Strtod(Vector buffer, int exponent) { + char copy_buffer[kMaxSignificantDecimalDigits]; + Vector trimmed; + int updated_exponent; + TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits, + &trimmed, &updated_exponent); + return StrtodTrimmed(trimmed, updated_exponent); +} + +static float SanitizedDoubletof(double d) { + DOUBLE_CONVERSION_ASSERT(d >= 0.0); + // ASAN has a sanitize check that disallows casting doubles to floats if + // they are too big. + // https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks + // The behavior should be covered by IEEE 754, but some projects use this + // flag, so work around it. + float max_finite = 3.4028234663852885981170418348451692544e+38; + // The half-way point between the max-finite and infinity value. + // Since infinity has an even significand everything equal or greater than + // this value should become infinity. + double half_max_finite_infinity = + 3.40282356779733661637539395458142568448e+38; + if (d >= max_finite) { + if (d >= half_max_finite_infinity) { + return Single::Infinity(); + } else { + return max_finite; + } + } else { + return static_cast(d); + } +} + float Strtof(Vector buffer, int exponent) { char copy_buffer[kMaxSignificantDecimalDigits]; Vector trimmed; @@ -497,7 +545,7 @@ float Strtof(Vector buffer, int exponent) { double double_guess; bool is_correct = ComputeGuess(trimmed, exponent, &double_guess); - float float_guess = static_cast(double_guess); + float float_guess = SanitizedDoubletof(double_guess); if (float_guess == double_guess) { // This shortcut triggers for integer values. return float_guess; @@ -520,18 +568,18 @@ float Strtof(Vector buffer, int exponent) { double double_next = Double(double_guess).NextDouble(); double double_previous = Double(double_guess).PreviousDouble(); - float f1 = static_cast(double_previous); + float f1 = SanitizedDoubletof(double_previous); float f2 = float_guess; - float f3 = static_cast(double_next); + float f3 = SanitizedDoubletof(double_next); float f4; if (is_correct) { f4 = f3; } else { double double_next2 = Double(double_next).NextDouble(); - f4 = static_cast(double_next2); + f4 = SanitizedDoubletof(double_next2); } (void) f2; // Mark variable as used. - ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4); + DOUBLE_CONVERSION_ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4); // If the guess doesn't lie near a single-precision boundary we can simply // return its float-value. @@ -539,11 +587,11 @@ float Strtof(Vector buffer, int exponent) { return float_guess; } - ASSERT((f1 != f2 && f2 == f3 && f3 == f4) || + DOUBLE_CONVERSION_ASSERT((f1 != f2 && f2 == f3 && f3 == f4) || (f1 == f2 && f2 != f3 && f3 == f4) || (f1 == f2 && f2 == f3 && f3 != f4)); - // guess and next are the two possible canditates (in the same way that + // guess and next are the two possible candidates (in the same way that // double_guess was the lower candidate for a double-precision guess). float guess = f1; float next = f4; diff --git a/deps/icu-small/source/i18n/double-conversion-strtod.h b/deps/icu-small/source/i18n/double-conversion-strtod.h index e2d6d3c2fe5d7d..50ef746401a908 100644 --- a/deps/icu-small/source/i18n/double-conversion-strtod.h +++ b/deps/icu-small/source/i18n/double-conversion-strtod.h @@ -54,6 +54,11 @@ double Strtod(Vector buffer, int exponent); // contain a dot or a sign. It must not start with '0', and must not be empty. float Strtof(Vector buffer, int exponent); +// For special use cases, the heart of the Strtod() function is also available +// separately, it assumes that 'trimmed' is as produced by TrimAndCut(), i.e. +// no leading or trailing zeros, also no lone zero, and not 'too many' digits. +double StrtodTrimmed(Vector trimmed, int exponent); + } // namespace double_conversion // ICU PATCH: Close ICU namespace diff --git a/deps/icu-small/source/i18n/double-conversion-utils.h b/deps/icu-small/source/i18n/double-conversion-utils.h index 1e44fcaa0e398d..099298460c63d9 100644 --- a/deps/icu-small/source/i18n/double-conversion-utils.h +++ b/deps/icu-small/source/i18n/double-conversion-utils.h @@ -42,10 +42,12 @@ // ICU PATCH: Use U_ASSERT instead of #include "uassert.h" -#define ASSERT U_ASSERT - -#ifndef UNIMPLEMENTED -#define UNIMPLEMENTED() (abort()) +#ifndef DOUBLE_CONVERSION_ASSERT +#define DOUBLE_CONVERSION_ASSERT(condition) \ + U_ASSERT(condition); +#endif +#ifndef DOUBLE_CONVERSION_UNIMPLEMENTED +#define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort()) #endif #ifndef DOUBLE_CONVERSION_NO_RETURN #ifdef _MSC_VER @@ -54,16 +56,23 @@ #define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn)) #endif #endif -#ifndef UNREACHABLE +#ifndef DOUBLE_CONVERSION_UNREACHABLE #ifdef _MSC_VER void DOUBLE_CONVERSION_NO_RETURN abort_noreturn(); inline void abort_noreturn() { abort(); } -#define UNREACHABLE() (abort_noreturn()) +#define DOUBLE_CONVERSION_UNREACHABLE() (abort_noreturn()) #else -#define UNREACHABLE() (abort()) +#define DOUBLE_CONVERSION_UNREACHABLE() (abort()) #endif #endif +#ifndef DOUBLE_CONVERSION_UNUSED +#ifdef __GNUC__ +#define DOUBLE_CONVERSION_UNUSED __attribute__((unused)) +#else +#define DOUBLE_CONVERSION_UNUSED +#endif +#endif // Double operations detection based on target architecture. // Linux uses a 80bit wide floating point stack on x86. This induces double @@ -99,9 +108,9 @@ int main(int argc, char** argv) { defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \ defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ defined(__SH4__) || defined(__alpha__) || \ - defined(_MIPS_ARCH_MIPS32R2) || \ + defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\ defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \ - defined(__riscv) || \ + defined(__riscv) || defined(__e2k__) || \ defined(__or1k__) || defined(__arc__) || \ defined(__EMSCRIPTEN__) #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 @@ -141,24 +150,24 @@ typedef uint16_t uc16; // The following macro works on both 32 and 64-bit platforms. // Usage: instead of writing 0x1234567890123456 -// write UINT64_2PART_C(0x12345678,90123456); -#define UINT64_2PART_C(a, b) (((static_cast(a) << 32) + 0x##b##u)) +// write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456); +#define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) (((static_cast(a) << 32) + 0x##b##u)) -// The expression ARRAY_SIZE(a) is a compile-time constant of type +// The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of type // size_t which represents the number of elements of the given -// array. You should only use ARRAY_SIZE on statically allocated +// array. You should only use DOUBLE_CONVERSION_ARRAY_SIZE on statically allocated // arrays. -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) \ +#ifndef DOUBLE_CONVERSION_ARRAY_SIZE +#define DOUBLE_CONVERSION_ARRAY_SIZE(a) \ ((sizeof(a) / sizeof(*(a))) / \ static_cast(!(sizeof(a) % sizeof(*(a))))) #endif // A macro to disallow the evil copy constructor and operator= functions // This should be used in the private: declarations for a class -#ifndef DC_DISALLOW_COPY_AND_ASSIGN -#define DC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ +#ifndef DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN +#define DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) #endif @@ -169,10 +178,10 @@ typedef uint16_t uc16; // This should be used in the private: declarations for a class // that wants to prevent anyone from instantiating it. This is // especially useful for classes containing only static methods. -#ifndef DC_DISALLOW_IMPLICIT_CONSTRUCTORS -#define DC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ +#ifndef DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS +#define DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ TypeName(); \ - DC_DISALLOW_COPY_AND_ASSIGN(TypeName) + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) #endif // ICU PATCH: Wrap in ICU namespace @@ -180,25 +189,9 @@ U_NAMESPACE_BEGIN namespace double_conversion { -static const int kCharSize = sizeof(char); - -// Returns the maximum of the two parameters. -template -static T Max(T a, T b) { - return a < b ? b : a; -} - - -// Returns the minimum of the two parameters. -template -static T Min(T a, T b) { - return a < b ? a : b; -} - - inline int StrLength(const char* string) { size_t length = strlen(string); - ASSERT(length == static_cast(static_cast(length))); + DOUBLE_CONVERSION_ASSERT(length == static_cast(static_cast(length))); return static_cast(length); } @@ -208,15 +201,15 @@ class Vector { public: Vector() : start_(NULL), length_(0) {} Vector(T* data, int len) : start_(data), length_(len) { - ASSERT(len == 0 || (len > 0 && data != NULL)); + DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL)); } // Returns a vector using the same backing storage as this one, // spanning from and including 'from', to but not including 'to'. Vector SubVector(int from, int to) { - ASSERT(to <= length_); - ASSERT(from < to); - ASSERT(0 <= from); + DOUBLE_CONVERSION_ASSERT(to <= length_); + DOUBLE_CONVERSION_ASSERT(from < to); + DOUBLE_CONVERSION_ASSERT(0 <= from); return Vector(start() + from, to - from); } @@ -231,7 +224,7 @@ class Vector { // Access individual vector elements - checks bounds in debug mode. T& operator[](int index) const { - ASSERT(0 <= index && index < length_); + DOUBLE_CONVERSION_ASSERT(0 <= index && index < length_); return start_[index]; } @@ -239,6 +232,11 @@ class Vector { T& last() { return start_[length_ - 1]; } + void pop_back() { + DOUBLE_CONVERSION_ASSERT(!is_empty()); + --length_; + } + private: T* start_; int length_; @@ -259,7 +257,7 @@ class StringBuilder { // Get the current position in the builder. int position() const { - ASSERT(!is_finalized()); + DOUBLE_CONVERSION_ASSERT(!is_finalized()); return position_; } @@ -270,8 +268,8 @@ class StringBuilder { // 0-characters; use the Finalize() method to terminate the string // instead. void AddCharacter(char c) { - ASSERT(c != '\0'); - ASSERT(!is_finalized() && position_ < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(c != '\0'); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); buffer_[position_++] = c; } @@ -284,9 +282,9 @@ class StringBuilder { // Add the first 'n' characters of the given string 's' to the // builder. The input string must have enough characters. void AddSubstring(const char* s, int n) { - ASSERT(!is_finalized() && position_ + n < buffer_.length()); - ASSERT(static_cast(n) <= strlen(s)); - memmove(&buffer_[position_], s, n * kCharSize); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ + n < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(static_cast(n) <= strlen(s)); + memmove(&buffer_[position_], s, n); position_ += n; } @@ -301,13 +299,13 @@ class StringBuilder { // Finalize the string by 0-terminating it and returning the buffer. char* Finalize() { - ASSERT(!is_finalized() && position_ < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); buffer_[position_] = '\0'; // Make sure nobody managed to add a 0-character to the // buffer while building the string. - ASSERT(strlen(buffer_.start()) == static_cast(position_)); + DOUBLE_CONVERSION_ASSERT(strlen(buffer_.start()) == static_cast(position_)); position_ = -1; - ASSERT(is_finalized()); + DOUBLE_CONVERSION_ASSERT(is_finalized()); return buffer_.start(); } @@ -317,7 +315,7 @@ class StringBuilder { bool is_finalized() const { return position_ < 0; } - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); }; // The type-based aliasing rule allows the compiler to assume that pointers of @@ -345,13 +343,14 @@ class StringBuilder { // enough that it can no longer see that you have cast one pointer type to // another thus avoiding the warning. template -inline Dest BitCast(const Source& source) { +Dest BitCast(const Source& source) { // Compile time assertion: sizeof(Dest) == sizeof(Source) // A compile error here means your Dest and Source have different sizes. #if __cplusplus >= 201103L static_assert(sizeof(Dest) == sizeof(Source), "source and destination size mismatch"); #else + DOUBLE_CONVERSION_UNUSED typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1]; #endif @@ -361,7 +360,7 @@ inline Dest BitCast(const Source& source) { } template -inline Dest BitCast(Source* source) { +Dest BitCast(Source* source) { return BitCast(reinterpret_cast(source)); } diff --git a/deps/icu-small/source/i18n/double-conversion.h b/deps/icu-small/source/i18n/double-conversion.h index 377c710bf791e7..eddc38763becdc 100644 --- a/deps/icu-small/source/i18n/double-conversion.h +++ b/deps/icu-small/source/i18n/double-conversion.h @@ -39,561 +39,8 @@ // ICU PATCH: Customize header file paths for ICU. -#include "double-conversion-utils.h" - -// ICU PATCH: Wrap in ICU namespace -U_NAMESPACE_BEGIN - -namespace double_conversion { - -class DoubleToStringConverter { - public: -#if 0 // not needed for ICU - // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint - // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the - // function returns false. - static const int kMaxFixedDigitsBeforePoint = 60; - static const int kMaxFixedDigitsAfterPoint = 60; - - // When calling ToExponential with a requested_digits - // parameter > kMaxExponentialDigits then the function returns false. - static const int kMaxExponentialDigits = 120; - - // When calling ToPrecision with a requested_digits - // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits - // then the function returns false. - static const int kMinPrecisionDigits = 1; - static const int kMaxPrecisionDigits = 120; - - enum Flags { - NO_FLAGS = 0, - EMIT_POSITIVE_EXPONENT_SIGN = 1, - EMIT_TRAILING_DECIMAL_POINT = 2, - EMIT_TRAILING_ZERO_AFTER_POINT = 4, - UNIQUE_ZERO = 8 - }; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent - // form, emits a '+' for positive exponents. Example: 1.2e+2. - // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is - // converted into decimal format then a trailing decimal point is appended. - // Example: 2345.0 is converted to "2345.". - // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point - // emits a trailing '0'-character. This flag requires the - // EXMIT_TRAILING_DECIMAL_POINT flag. - // Example: 2345.0 is converted to "2345.0". - // - UNIQUE_ZERO: "-0.0" is converted to "0.0". - // - // Infinity symbol and nan_symbol provide the string representation for these - // special values. If the string is NULL and the special value is encountered - // then the conversion functions return false. - // - // The exponent_character is used in exponential representations. It is - // usually 'e' or 'E'. - // - // When converting to the shortest representation the converter will - // represent input numbers in decimal format if they are in the interval - // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[ - // (lower boundary included, greater boundary excluded). - // Example: with decimal_in_shortest_low = -6 and - // decimal_in_shortest_high = 21: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // When converting to precision mode the converter may add - // max_leading_padding_zeroes before returning the number in exponential - // format. - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - DoubleToStringConverter(int flags, - const char* infinity_symbol, - const char* nan_symbol, - char exponent_character, - int decimal_in_shortest_low, - int decimal_in_shortest_high, - int max_leading_padding_zeroes_in_precision_mode, - int max_trailing_padding_zeroes_in_precision_mode) - : flags_(flags), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol), - exponent_character_(exponent_character), - decimal_in_shortest_low_(decimal_in_shortest_low), - decimal_in_shortest_high_(decimal_in_shortest_high), - max_leading_padding_zeroes_in_precision_mode_( - max_leading_padding_zeroes_in_precision_mode), - max_trailing_padding_zeroes_in_precision_mode_( - max_trailing_padding_zeroes_in_precision_mode) { - // When 'trailing zero after the point' is set, then 'trailing point' - // must be set too. - ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) || - !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0)); - } - - // Returns a converter following the EcmaScript specification. - static const DoubleToStringConverter& EcmaScriptConverter(); - - // Computes the shortest string of digits that correctly represent the input - // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high - // (see constructor) it then either returns a decimal representation, or an - // exponential representation. - // Example with decimal_in_shortest_low = -6, - // decimal_in_shortest_high = 21, - // EMIT_POSITIVE_EXPONENT_SIGN activated, and - // EMIT_TRAILING_DECIMAL_POINT deactived: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // Note: the conversion may round the output if the returned string - // is accurate enough to uniquely identify the input-number. - // For example the most precise representation of the double 9e59 equals - // "899999999999999918767229449717619953810131273674690656206848", but - // the converter will return the shorter (but still correct) "9e59". - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except when the input value is special and no infinity_symbol or - // nan_symbol has been given to the constructor. - bool ToShortest(double value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST); - } - - // Same as ToShortest, but for single-precision floats. - bool ToShortestSingle(float value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE); - } - - - // Computes a decimal representation with a fixed number of digits after the - // decimal point. The last emitted digit is rounded. - // - // Examples: - // ToFixed(3.12, 1) -> "3.1" - // ToFixed(3.1415, 3) -> "3.142" - // ToFixed(1234.56789, 4) -> "1234.5679" - // ToFixed(1.23, 5) -> "1.23000" - // ToFixed(0.1, 4) -> "0.1000" - // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00" - // ToFixed(0.1, 30) -> "0.100000000000000005551115123126" - // ToFixed(0.1, 17) -> "0.10000000000000001" - // - // If requested_digits equals 0, then the tail of the result depends on - // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples, for requested_digits == 0, - // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be - // - false and false: then 123.45 -> 123 - // 0.678 -> 1 - // - true and false: then 123.45 -> 123. - // 0.678 -> 1. - // - true and true: then 123.45 -> 123.0 - // 0.678 -> 1.0 - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'value' > 10^kMaxFixedDigitsBeforePoint, or - // - 'requested_digits' > kMaxFixedDigitsAfterPoint. - // The last two conditions imply that the result will never contain more than - // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters - // (one additional character for the sign, and one for the decimal point). - bool ToFixed(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes a representation in exponential format with requested_digits - // after the decimal point. The last emitted digit is rounded. - // If requested_digits equals -1, then the shortest exponential representation - // is computed. - // - // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and - // exponent_character set to 'e'. - // ToExponential(3.12, 1) -> "3.1e0" - // ToExponential(5.0, 3) -> "5.000e0" - // ToExponential(0.001, 2) -> "1.00e-3" - // ToExponential(3.1415, -1) -> "3.1415e0" - // ToExponential(3.1415, 4) -> "3.1415e0" - // ToExponential(3.1415, 3) -> "3.142e0" - // ToExponential(123456789000000, 3) -> "1.235e14" - // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30" - // ToExponential(1000000000000000019884624838656.0, 32) -> - // "1.00000000000000001988462483865600e30" - // ToExponential(1234, 0) -> "1e3" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'requested_digits' > kMaxExponentialDigits. - // The last condition implies that the result will never contain more than - // kMaxExponentialDigits + 8 characters (the sign, the digit before the - // decimal point, the decimal point, the exponent character, the - // exponent's sign, and at most 3 exponent digits). - bool ToExponential(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes 'precision' leading digits of the given 'value' and returns them - // either in exponential or decimal format, depending on - // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the - // constructor). - // The last computed digit is rounded. - // - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no - // EMIT_TRAILING_ZERO_AFTER_POINT: - // ToPrecision(123450.0, 6) -> "123450" - // ToPrecision(123450.0, 5) -> "123450" - // ToPrecision(123450.0, 4) -> "123500" - // ToPrecision(123450.0, 3) -> "123000" - // ToPrecision(123450.0, 2) -> "1.2e5" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - precision < kMinPericisionDigits - // - precision > kMaxPrecisionDigits - // The last condition implies that the result will never contain more than - // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the - // exponent character, the exponent's sign, and at most 3 exponent digits). - bool ToPrecision(double value, - int precision, - StringBuilder* result_builder) const; -#endif // not needed for ICU - - enum DtoaMode { - // Produce the shortest correct representation. - // For example the output of 0.299999999999999988897 is (the less accurate - // but correct) 0.3. - SHORTEST, - // Same as SHORTEST, but for single-precision floats. - SHORTEST_SINGLE, - // Produce a fixed number of digits after the decimal point. - // For instance fixed(0.1, 4) becomes 0.1000 - // If the input number is big, the output will be big. - FIXED, - // Fixed number of digits (independent of the decimal point). - PRECISION - }; - - // The maximal number of digits that are needed to emit a double in base 10. - // A higher precision can be achieved by using more digits, but the shortest - // accurate representation of any double will never use more digits than - // kBase10MaximalLength. - // Note that DoubleToAscii null-terminates its input. So the given buffer - // should be at least kBase10MaximalLength + 1 characters long. - static const int kBase10MaximalLength = 17; - - // Converts the given double 'v' to digit characters. 'v' must not be NaN, - // +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also - // applies to 'v' after it has been casted to a single-precision float. That - // is, in this mode static_cast(v) must not be NaN, +Infinity or - // -Infinity. - // - // The result should be interpreted as buffer * 10^(point-length). - // - // The digits are written to the buffer in the platform's charset, which is - // often UTF-8 (with ASCII-range digits) but may be another charset, such - // as EBCDIC. - // - // The output depends on the given mode: - // - SHORTEST: produce the least amount of digits for which the internal - // identity requirement is still satisfied. If the digits are printed - // (together with the correct exponent) then reading this number will give - // 'v' again. The buffer will choose the representation that is closest to - // 'v'. If there are two at the same distance, than the one farther away - // from 0 is chosen (halfway cases - ending with 5 - are rounded up). - // In this mode the 'requested_digits' parameter is ignored. - // - SHORTEST_SINGLE: same as SHORTEST but with single-precision. - // - FIXED: produces digits necessary to print a given number with - // 'requested_digits' digits after the decimal point. The produced digits - // might be too short in which case the caller has to fill the remainder - // with '0's. - // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. - // Halfway cases are rounded towards +/-Infinity (away from 0). The call - // toFixed(0.15, 2) thus returns buffer="2", point=0. - // The returned buffer may contain digits that would be truncated from the - // shortest representation of the input. - // - PRECISION: produces 'requested_digits' where the first digit is not '0'. - // Even though the length of produced digits usually equals - // 'requested_digits', the function is allowed to return fewer digits, in - // which case the caller has to fill the missing digits with '0's. - // Halfway cases are again rounded away from 0. - // DoubleToAscii expects the given buffer to be big enough to hold all - // digits and a terminating null-character. In SHORTEST-mode it expects a - // buffer of at least kBase10MaximalLength + 1. In all other modes the - // requested_digits parameter and the padding-zeroes limit the size of the - // output. Don't forget the decimal point, the exponent character and the - // terminating null-character when computing the maximal output size. - // The given length is only used in debug mode to ensure the buffer is big - // enough. - // ICU PATCH: Export this as U_I18N_API for unit tests. - static void U_I18N_API DoubleToAscii(double v, - DtoaMode mode, - int requested_digits, - char* buffer, - int buffer_length, - bool* sign, - int* length, - int* point); - -#if 0 // not needed for ICU - private: - // Implementation for ToShortest and ToShortestSingle. - bool ToShortestIeeeNumber(double value, - StringBuilder* result_builder, - DtoaMode mode) const; - - // If the value is a special value (NaN or Infinity) constructs the - // corresponding string using the configured infinity/nan-symbol. - // If either of them is NULL or the value is not special then the - // function returns false. - bool HandleSpecialValues(double value, StringBuilder* result_builder) const; - // Constructs an exponential representation (i.e. 1.234e56). - // The given exponent assumes a decimal point after the first decimal digit. - void CreateExponentialRepresentation(const char* decimal_digits, - int length, - int exponent, - StringBuilder* result_builder) const; - // Creates a decimal representation (i.e 1234.5678). - void CreateDecimalRepresentation(const char* decimal_digits, - int length, - int decimal_point, - int digits_after_point, - StringBuilder* result_builder) const; - - const int flags_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - const char exponent_character_; - const int decimal_in_shortest_low_; - const int decimal_in_shortest_high_; - const int max_leading_padding_zeroes_in_precision_mode_; - const int max_trailing_padding_zeroes_in_precision_mode_; -#endif // not needed for ICU - - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); -}; - - -class StringToDoubleConverter { - public: - // Enumeration for allowing octals and ignoring junk when converting - // strings to numbers. - enum Flags { - NO_FLAGS = 0, - ALLOW_HEX = 1, - ALLOW_OCTALS = 2, - ALLOW_TRAILING_JUNK = 4, - ALLOW_LEADING_SPACES = 8, - ALLOW_TRAILING_SPACES = 16, - ALLOW_SPACES_AFTER_SIGN = 32, - ALLOW_CASE_INSENSIBILITY = 64, - ALLOW_HEX_FLOATS = 128, - }; - - static const uc16 kNoSeparator = '\0'; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers. - // Ex: StringToDouble("0x1234") -> 4660.0 - // In StringToDouble("0x1234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK, - // the string will not be parsed as "0" followed by junk. - // - // - ALLOW_OCTALS: recognizes the prefix "0" for octals: - // If a sequence of octal digits starts with '0', then the number is - // read as octal integer. Octal numbers may only be integers. - // Ex: StringToDouble("01234") -> 668.0 - // StringToDouble("012349") -> 12349.0 // Not a sequence of octal - // // digits. - // In StringToDouble("01234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // In StringToDouble("01234e56") the characters "e56" are trailing - // junk, too. - // - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of - // a double literal. - // - ALLOW_LEADING_SPACES: skip over leading whitespace, including spaces, - // new-lines, and tabs. - // - ALLOW_TRAILING_SPACES: ignore trailing whitespace. - // - ALLOW_SPACES_AFTER_SIGN: ignore whitespace after the sign. - // Ex: StringToDouble("- 123.2") -> -123.2. - // StringToDouble("+ 123.2") -> 123.2 - // - ALLOW_CASE_INSENSIBILITY: ignore case of characters for special values: - // infinity and nan. - // - ALLOW_HEX_FLOATS: allows hexadecimal float literals. - // This *must* start with "0x" and separate the exponent with "p". - // Examples: 0x1.2p3 == 9.0 - // 0x10.1p0 == 16.0625 - // ALLOW_HEX and ALLOW_HEX_FLOATS are indendent. - // - // empty_string_value is returned when an empty string is given as input. - // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string - // containing only spaces is converted to the 'empty_string_value', too. - // - // junk_string_value is returned when - // a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not - // part of a double-literal) is found. - // b) ALLOW_TRAILING_JUNK is set, but the string does not start with a - // double literal. - // - // infinity_symbol and nan_symbol are strings that are used to detect - // inputs that represent infinity and NaN. They can be null, in which case - // they are ignored. - // The conversion routine first reads any possible signs. Then it compares the - // following character of the input-string with the first character of - // the infinity, and nan-symbol. If either matches, the function assumes, that - // a match has been found, and expects the following input characters to match - // the remaining characters of the special-value symbol. - // This means that the following restrictions apply to special-value symbols: - // - they must not start with signs ('+', or '-'), - // - they must not have the same first character. - // - they must not start with digits. - // - // If the separator character is not kNoSeparator, then that specific - // character is ignored when in between two valid digits of the significant. - // It is not allowed to appear in the exponent. - // It is not allowed to lead or trail the number. - // It is not allowed to appear twice next to each other. - // - // Examples: - // flags = ALLOW_HEX | ALLOW_TRAILING_JUNK, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = "infinity", - // nan_symbol = "nan": - // StringToDouble("0x1234") -> 4660.0. - // StringToDouble("0x1234K") -> 4660.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> NaN // junk_string_value. - // StringToDouble(" 1") -> NaN // junk_string_value. - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("-123.45") -> -123.45. - // StringToDouble("--123.45") -> NaN // junk_string_value. - // StringToDouble("123e45") -> 123e45. - // StringToDouble("123E45") -> 123e45. - // StringToDouble("123e+45") -> 123e45. - // StringToDouble("123E-45") -> 123e-45. - // StringToDouble("123e") -> 123.0 // trailing junk ignored. - // StringToDouble("123e-") -> 123.0 // trailing junk ignored. - // StringToDouble("+NaN") -> NaN // NaN string literal. - // StringToDouble("-infinity") -> -inf. // infinity literal. - // StringToDouble("Infinity") -> NaN // junk_string_value. - // - // flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = NULL, - // nan_symbol = NULL: - // StringToDouble("0x1234") -> NaN // junk_string_value. - // StringToDouble("01234") -> 668.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> 0.0 // empty_string_value. - // StringToDouble(" 1") -> 1.0 - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("0123e45") -> NaN // junk_string_value. - // StringToDouble("01239E45") -> 1239e45. - // StringToDouble("-infinity") -> NaN // junk_string_value. - // StringToDouble("NaN") -> NaN // junk_string_value. - // - // flags = NO_FLAGS, - // separator = ' ': - // StringToDouble("1 2 3 4") -> 1234.0 - // StringToDouble("1 2") -> NaN // junk_string_value - // StringToDouble("1 000 000.0") -> 1000000.0 - // StringToDouble("1.000 000") -> 1.0 - // StringToDouble("1.0e1 000") -> NaN // junk_string_value - StringToDoubleConverter(int flags, - double empty_string_value, - double junk_string_value, - const char* infinity_symbol, - const char* nan_symbol, - uc16 separator = kNoSeparator) - : flags_(flags), - empty_string_value_(empty_string_value), - junk_string_value_(junk_string_value), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol), - separator_(separator) { - } - - // Performs the conversion. - // The output parameter 'processed_characters_count' is set to the number - // of characters that have been processed to read the number. - // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included - // in the 'processed_characters_count'. Trailing junk is never included. - double StringToDouble(const char* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToDouble above but for 16 bit characters. - double StringToDouble(const uc16* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToDouble but reads a float. - // Note that this is not equivalent to static_cast(StringToDouble(...)) - // due to potential double-rounding. - float StringToFloat(const char* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToFloat above but for 16 bit characters. - float StringToFloat(const uc16* buffer, - int length, - int* processed_characters_count) const; - - private: - const int flags_; - const double empty_string_value_; - const double junk_string_value_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - const uc16 separator_; - - template - double StringToIeee(Iterator start_pointer, - int length, - bool read_as_double, - int* processed_characters_count) const; - - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); -}; - -} // namespace double_conversion - -// ICU PATCH: Close ICU namespace -U_NAMESPACE_END +#include "double-conversion-string-to-double.h" +#include "double-conversion-double-to-string.h" #endif // DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ #endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/dtfmtsym.cpp b/deps/icu-small/source/i18n/dtfmtsym.cpp index 04aa01eb4c2459..690f6a4cae6c72 100644 --- a/deps/icu-small/source/i18n/dtfmtsym.cpp +++ b/deps/icu-small/source/i18n/dtfmtsym.cpp @@ -1246,7 +1246,7 @@ const UnicodeString** DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const { const UnicodeString **result = NULL; - static UMutex LOCK = U_MUTEX_INITIALIZER; + static UMutex LOCK; umtx_lock(&LOCK); if (fZoneStrings == NULL) { @@ -1497,7 +1497,7 @@ struct CalendarDataSink : public ResourceSink { Hashtable arrays; Hashtable arraySizes; Hashtable maps; - /** + /** * Whenever there are aliases, the same object will be added twice to 'map'. * To avoid double deletion, 'maps' won't take ownership of the objects. Instead, * 'mapRefs' will own them and will delete them when CalendarDataSink is deleted. @@ -2177,16 +2177,16 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError // The ordering of the following statements is important. if (fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].setTo(fLeapMonthPatterns[kLeapMonthPatternStandaloneNarrow]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev]); - }; + } // end of hack fLeapMonthPatternsCount = kMonthPatternsCount; } else { @@ -2338,11 +2338,21 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError assignArray(fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, fShortMonths, fShortMonthsCount); } - // Load AM/PM markers + // Load AM/PM markers; if wide or narrow not available, use short + UErrorCode ampmStatus = U_ZERO_ERROR; initField(&fAmPms, fAmPmsCount, calendarSink, - buildResourcePath(path, gAmPmMarkersTag, status), status); + buildResourcePath(path, gAmPmMarkersTag, ampmStatus), ampmStatus); + if (U_FAILURE(ampmStatus)) { + initField(&fAmPms, fAmPmsCount, calendarSink, + buildResourcePath(path, gAmPmMarkersAbbrTag, status), status); + } + ampmStatus = U_ZERO_ERROR; initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink, - buildResourcePath(path, gAmPmMarkersNarrowTag, status), status); + buildResourcePath(path, gAmPmMarkersNarrowTag, ampmStatus), ampmStatus); + if (U_FAILURE(ampmStatus)) { + initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink, + buildResourcePath(path, gAmPmMarkersAbbrTag, status), status); + } // Load quarters initField(&fQuarters, fQuartersCount, calendarSink, diff --git a/deps/icu-small/source/i18n/dtitv_impl.h b/deps/icu-small/source/i18n/dtitv_impl.h index 18fe0b8c9b527d..c7addf37fb6219 100644 --- a/deps/icu-small/source/i18n/dtitv_impl.h +++ b/deps/icu-small/source/i18n/dtitv_impl.h @@ -19,7 +19,7 @@ * \file * \brief C++ API: Defines macros for interval format implementation */ - + #if !UCONFIG_NO_FORMATTING #include "unicode/unistr.h" @@ -88,10 +88,10 @@ #define MAX_E_COUNT 5 #define MAX_M_COUNT 5 //#define MAX_INTERVAL_INDEX 4 -#define MAX_POSITIVE_INT 56632; +#define MAX_POSITIVE_INT 56632 #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif +#endif //eof diff --git a/deps/icu-small/source/i18n/dtitvfmt.cpp b/deps/icu-small/source/i18n/dtitvfmt.cpp index 0e124f5624002b..f47e7708ccc128 100644 --- a/deps/icu-small/source/i18n/dtitvfmt.cpp +++ b/deps/icu-small/source/i18n/dtitvfmt.cpp @@ -82,10 +82,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateIntervalFormat) // Mutex, protects access to fDateFormat, fFromCalendar and fToCalendar. // Needed because these data members are modified by const methods of DateIntervalFormat. -static UMutex *gFormatterMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gFormatterMutex; DateIntervalFormat* U_EXPORT2 DateIntervalFormat::createInstance(const UnicodeString& skeleton, @@ -171,9 +168,9 @@ DateIntervalFormat::operator=(const DateIntervalFormat& itvfmt) { delete fTimePattern; delete fDateTimeFormat; { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); if ( itvfmt.fDateFormat ) { - fDateFormat = (SimpleDateFormat*)itvfmt.fDateFormat->clone(); + fDateFormat = itvfmt.fDateFormat->clone(); } else { fDateFormat = NULL; } @@ -199,9 +196,9 @@ DateIntervalFormat::operator=(const DateIntervalFormat& itvfmt) { fIntervalPatterns[i] = itvfmt.fIntervalPatterns[i]; } fLocale = itvfmt.fLocale; - fDatePattern = (itvfmt.fDatePattern)? (UnicodeString*)itvfmt.fDatePattern->clone(): NULL; - fTimePattern = (itvfmt.fTimePattern)? (UnicodeString*)itvfmt.fTimePattern->clone(): NULL; - fDateTimeFormat = (itvfmt.fDateTimeFormat)? (UnicodeString*)itvfmt.fDateTimeFormat->clone(): NULL; + fDatePattern = (itvfmt.fDatePattern)? itvfmt.fDatePattern->clone(): NULL; + fTimePattern = (itvfmt.fTimePattern)? itvfmt.fTimePattern->clone(): NULL; + fDateTimeFormat = (itvfmt.fDateTimeFormat)? itvfmt.fDateTimeFormat->clone(): NULL; } return *this; } @@ -218,8 +215,8 @@ DateIntervalFormat::~DateIntervalFormat() { } -Format* -DateIntervalFormat::clone(void) const { +DateIntervalFormat* +DateIntervalFormat::clone() const { return new DateIntervalFormat(*this); } @@ -233,7 +230,7 @@ DateIntervalFormat::operator==(const Format& other) const { if ((fInfo != fmt->fInfo) && (fInfo == NULL || fmt->fInfo == NULL)) {return FALSE;} if (fInfo && fmt->fInfo && (*fInfo != *fmt->fInfo )) {return FALSE;} { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); if (fDateFormat != fmt->fDateFormat && (fDateFormat == NULL || fmt->fDateFormat == NULL)) {return FALSE;} if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;} } @@ -295,7 +292,7 @@ DateIntervalFormat::format(const DateInterval* dtInterval, handler.setAcceptFirstOnly(TRUE); int8_t ignore; - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return formatIntervalImpl(*dtInterval, appendTo, ignore, handler, status); } @@ -312,7 +309,7 @@ FormattedDateInterval DateIntervalFormat::formatToValue( auto handler = result->getHandler(status); handler.setCategory(UFIELD_CATEGORY_DATE); { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); formatIntervalImpl(dtInterval, string, firstIndex, handler, status); } handler.getError(status); @@ -344,7 +341,7 @@ DateIntervalFormat::format(Calendar& fromCalendar, handler.setAcceptFirstOnly(TRUE); int8_t ignore; - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return formatImpl(fromCalendar, toCalendar, appendTo, ignore, handler, status); } @@ -362,7 +359,7 @@ FormattedDateInterval DateIntervalFormat::formatToValue( auto handler = result->getHandler(status); handler.setCategory(UFIELD_CATEGORY_DATE); { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); formatImpl(fromCalendar, toCalendar, string, firstIndex, handler, status); } handler.getError(status); @@ -600,7 +597,7 @@ const TimeZone& DateIntervalFormat::getTimeZone() const { if (fDateFormat != NULL) { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return fDateFormat->getTimeZone(); } // If fDateFormat is NULL (unexpected), create default timezone. diff --git a/deps/icu-small/source/i18n/dtitvinf.cpp b/deps/icu-small/source/i18n/dtitvinf.cpp index c0a6980e5567bc..35ee8c16261934 100644 --- a/deps/icu-small/source/i18n/dtitvinf.cpp +++ b/deps/icu-small/source/i18n/dtitvinf.cpp @@ -42,7 +42,9 @@ U_NAMESPACE_BEGIN #ifdef DTITVINF_DEBUG -#define PRINTMESG(msg) { std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; } +#define PRINTMESG(msg) UPRV_BLOCK_MACRO_BEGIN { \ + std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; \ +} UPRV_BLOCK_MACRO_END #endif UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateIntervalInfo) diff --git a/deps/icu-small/source/i18n/dtptngen.cpp b/deps/icu-small/source/i18n/dtptngen.cpp index 9ca29a3cc7e608..c5f8618a6d63c3 100644 --- a/deps/icu-small/source/i18n/dtptngen.cpp +++ b/deps/icu-small/source/i18n/dtptngen.cpp @@ -28,6 +28,7 @@ #include "unicode/ures.h" #include "unicode/ustring.h" #include "unicode/rep.h" +#include "unicode/region.h" #include "cpputils.h" #include "mutex.h" #include "umutex.h" @@ -610,32 +611,59 @@ U_CFUNC void U_CALLCONV DateTimePatternGenerator::loadAllowedHourFormatsData(UEr // into the hashmap, store 6 single-value sub-arrays right at the beginning of the // vector (at index enum*2) for easy data sharing, copy sub-arrays into runtime // object. Remember to clean up the vector, too. - ures_getAllItemsWithFallback(rb.getAlias(), "timeData", sink, status); + ures_getAllItemsWithFallback(rb.getAlias(), "timeData", sink, status); } -void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErrorCode &status) { - if (U_FAILURE(status)) { return; } - Locale maxLocale(locale); - maxLocale.addLikelySubtags(status); - if (U_FAILURE(status)) { - return; - } - - const char *country = maxLocale.getCountry(); - if (*country == '\0') { country = "001"; } - const char *language = maxLocale.getLanguage(); - +static int32_t* getAllowedHourFormatsLangCountry(const char* language, const char* country, UErrorCode& status) { CharString langCountry; - langCountry.append(language, static_cast(uprv_strlen(language)), status); + langCountry.append(language, status); langCountry.append('_', status); - langCountry.append(country, static_cast(uprv_strlen(country)), status); + langCountry.append(country, status); - int32_t *allowedFormats; + int32_t* allowedFormats; allowedFormats = (int32_t *)uhash_get(localeToAllowedHourFormatsMap, langCountry.data()); if (allowedFormats == nullptr) { allowedFormats = (int32_t *)uhash_get(localeToAllowedHourFormatsMap, const_cast(country)); } + return allowedFormats; +} + +void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErrorCode &status) { + if (U_FAILURE(status)) { return; } + + const char *language = locale.getLanguage(); + const char *country = locale.getCountry(); + Locale maxLocale; // must be here for correct lifetime + if (*language == '\0' || *country == '\0') { + maxLocale = locale; + UErrorCode localStatus = U_ZERO_ERROR; + maxLocale.addLikelySubtags(localStatus); + if (U_SUCCESS(localStatus)) { + language = maxLocale.getLanguage(); + country = maxLocale.getCountry(); + } + } + if (*language == '\0') { + // Unexpected, but fail gracefully + language = "und"; + } + if (*country == '\0') { + country = "001"; + } + + int32_t* allowedFormats = getAllowedHourFormatsLangCountry(language, country, status); + + // Check if the region has an alias + if (allowedFormats == nullptr) { + UErrorCode localStatus = U_ZERO_ERROR; + const Region* region = Region::getInstance(country, localStatus); + if (U_SUCCESS(localStatus)) { + country = region->getRegionCode(); // the real region code + allowedFormats = getAllowedHourFormatsLangCountry(language, country, status); + } + } + if (allowedFormats != nullptr) { // Lookup is successful // Here allowedFormats points to a list consisting of key for preferredFormat, // followed by one or more keys for allowedFormats, then followed by ALLOWED_HOUR_FORMAT_UNKNOWN. @@ -787,6 +815,7 @@ void DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err) { destination.clear().append(DT_DateTimeGregorianTag, -1, err); // initial default if ( U_SUCCESS(err) ) { + UErrorCode localStatus = U_ZERO_ERROR; char localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY]; // obtain a locale that always has the calendar key value that should be used ures_getFunctionalEquivalent( @@ -798,8 +827,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& locale.getName(), nullptr, FALSE, - &err); - if (U_FAILURE(err)) { return; } + &localStatus); localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY-1] = 0; // ensure null termination // now get the calendar key value from that locale char calendarType[ULOC_KEYWORDS_CAPACITY]; @@ -808,13 +836,17 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& "calendar", calendarType, ULOC_KEYWORDS_CAPACITY, - &err); - if (U_FAILURE(err)) { return; } + &localStatus); + // If the input locale was invalid, don't fail with missing resource error, instead + // continue with default of Gregorian. + if (U_FAILURE(localStatus) && localStatus != U_MISSING_RESOURCE_ERROR) { + err = localStatus; + return; + } if (calendarTypeLen < ULOC_KEYWORDS_CAPACITY) { destination.clear().append(calendarType, -1, err); if (U_FAILURE(err)) { return; } } - err = U_ZERO_ERROR; } } @@ -2543,7 +2575,8 @@ UChar SkeletonFields::getFirstChar() const { } -PtnSkeleton::PtnSkeleton() { +PtnSkeleton::PtnSkeleton() + : addedDefaultDayPeriod(FALSE) { } PtnSkeleton::PtnSkeleton(const PtnSkeleton& other) { @@ -2554,6 +2587,7 @@ void PtnSkeleton::copyFrom(const PtnSkeleton& other) { uprv_memcpy(type, other.type, sizeof(type)); original.copyFrom(other.original); baseOriginal.copyFrom(other.baseOriginal); + addedDefaultDayPeriod = other.addedDefaultDayPeriod; } void PtnSkeleton::clear() { @@ -2640,7 +2674,7 @@ DTSkeletonEnumeration::DTSkeletonEnumeration(PatternMap& patternMap, dtStrEnum t } if ( !isCanonicalItem(s) ) { LocalPointer newElem(new UnicodeString(s), status); - if (U_FAILURE(status)) { + if (U_FAILURE(status)) { return; } fSkeletons->addElement(newElem.getAlias(), status); @@ -2763,7 +2797,7 @@ DTRedundantEnumeration::~DTRedundantEnumeration() { delete s; } } - } + } } U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/erarules.cpp b/deps/icu-small/source/i18n/erarules.cpp index 7e21a71c333f6f..e375740bd6b10a 100644 --- a/deps/icu-small/source/i18n/erarules.cpp +++ b/deps/icu-small/source/i18n/erarules.cpp @@ -322,3 +322,5 @@ void EraRules::initCurrentEra() { U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ + + diff --git a/deps/icu-small/source/i18n/esctrn.cpp b/deps/icu-small/source/i18n/esctrn.cpp index 900bed7e45734b..ba0e4c2c7bb618 100644 --- a/deps/icu-small/source/i18n/esctrn.cpp +++ b/deps/icu-small/source/i18n/esctrn.cpp @@ -122,7 +122,7 @@ EscapeTransliterator::~EscapeTransliterator() { /** * Transliterator API. */ -Transliterator* EscapeTransliterator::clone() const { +EscapeTransliterator* EscapeTransliterator::clone() const { return new EscapeTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/esctrn.h b/deps/icu-small/source/i18n/esctrn.h index 60ecc74b498456..2a2c6dcfe9af10 100644 --- a/deps/icu-small/source/i18n/esctrn.h +++ b/deps/icu-small/source/i18n/esctrn.h @@ -115,7 +115,7 @@ class EscapeTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual EscapeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/ethpccal.cpp b/deps/icu-small/source/i18n/ethpccal.cpp index 4377c59b325a1b..7c7c0ba37b7f69 100644 --- a/deps/icu-small/source/i18n/ethpccal.cpp +++ b/deps/icu-small/source/i18n/ethpccal.cpp @@ -46,7 +46,7 @@ EthiopicCalendar::~EthiopicCalendar() { } -Calendar* +EthiopicCalendar* EthiopicCalendar::clone() const { return new EthiopicCalendar(*this); @@ -66,7 +66,7 @@ EthiopicCalendar::setAmeteAlemEra(UBool onOff) { eraType = onOff ? AMETE_ALEM_ERA : AMETE_MIHRET_ERA; } - + UBool EthiopicCalendar::isAmeteAlemEra() const { @@ -138,7 +138,7 @@ EthiopicCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType /** * The system maintains a static default century start date and Year. They are - * initialized the first time they are used. Once the system default century date + * initialized the first time they are used. Once the system default century date * and year are set, they do not change. */ static UDate gSystemDefaultCenturyStart = DBL_MIN; diff --git a/deps/icu-small/source/i18n/ethpccal.h b/deps/icu-small/source/i18n/ethpccal.h index 5fae2fb1bea2c7..d1e8f424b57104 100644 --- a/deps/icu-small/source/i18n/ethpccal.h +++ b/deps/icu-small/source/i18n/ethpccal.h @@ -28,7 +28,7 @@ class EthiopicCalendar : public CECalendar { public: /** * Calendar type - use Amete Alem era for all the time or not - * @internal + * @internal */ enum EEraType { AMETE_MIHRET_ERA, @@ -40,68 +40,68 @@ class EthiopicCalendar : public CECalendar { * @internal */ enum EMonths { - /** + /** * Constant for መስከረም, the 1st month of the Ethiopic year. */ MESKEREM, - /** + /** * Constant for ጥቅምት, the 2nd month of the Ethiopic year. */ TEKEMT, - /** - * Constant for ኅዳር, the 3rd month of the Ethiopic year. + /** + * Constant for ኅዳር, the 3rd month of the Ethiopic year. */ HEDAR, - /** - * Constant for ታኅሣሥ, the 4th month of the Ethiopic year. + /** + * Constant for ታኅሣሥ, the 4th month of the Ethiopic year. */ TAHSAS, - /** - * Constant for ጥር, the 5th month of the Ethiopic year. + /** + * Constant for ጥር, the 5th month of the Ethiopic year. */ TER, - /** - * Constant for የካቲት, the 6th month of the Ethiopic year. + /** + * Constant for የካቲት, the 6th month of the Ethiopic year. */ YEKATIT, - /** - * Constant for መጋቢት, the 7th month of the Ethiopic year. + /** + * Constant for መጋቢት, the 7th month of the Ethiopic year. */ MEGABIT, - /** - * Constant for ሚያዝያ, the 8th month of the Ethiopic year. + /** + * Constant for ሚያዝያ, the 8th month of the Ethiopic year. */ MIAZIA, - /** - * Constant for ግንቦት, the 9th month of the Ethiopic year. + /** + * Constant for ግንቦት, the 9th month of the Ethiopic year. */ GENBOT, - /** - * Constant for ሰኔ, the 10th month of the Ethiopic year. + /** + * Constant for ሰኔ, the 10th month of the Ethiopic year. */ SENE, - /** - * Constant for ሐምሌ, the 11th month of the Ethiopic year. + /** + * Constant for ሐምሌ, the 11th month of the Ethiopic year. */ HAMLE, - /** - * Constant for ነሐሴ, the 12th month of the Ethiopic year. + /** + * Constant for ነሐሴ, the 12th month of the Ethiopic year. */ NEHASSA, - /** - * Constant for ጳጉሜን, the 13th month of the Ethiopic year. + /** + * Constant for ጳጉሜን, the 13th month of the Ethiopic year. */ PAGUMEN }; @@ -141,7 +141,7 @@ class EthiopicCalendar : public CECalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone() const; + virtual EthiopicCalendar* clone() const; /** * return the calendar type, "ethiopic" @@ -242,7 +242,7 @@ class EthiopicCalendar : public CECalendar { * @return The class ID for all objects of this class. * @internal */ - U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); + U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); #if 0 // We do not want to introduce this API in ICU4C. diff --git a/deps/icu-small/source/i18n/fmtable.cpp b/deps/icu-small/source/i18n/fmtable.cpp index 9baa5ff480db6a..dbfd3c26bad8a7 100644 --- a/deps/icu-small/source/i18n/fmtable.cpp +++ b/deps/icu-small/source/i18n/fmtable.cpp @@ -106,7 +106,7 @@ void Formattable::init() { fType = kLong; fDecimalStr = NULL; fDecimalQuantity = NULL; - fBogus.setToBogus(); + fBogus.setToBogus(); } // ------------------------------------- @@ -369,7 +369,7 @@ Formattable::clone() const { } // ------------------------------------- -// Gets the data type of this Formattable object. +// Gets the data type of this Formattable object. Formattable::Type Formattable::getType() const { @@ -396,9 +396,9 @@ Formattable::getLong(UErrorCode& status) const if (U_FAILURE(status)) { return 0; } - + switch (fType) { - case Formattable::kLong: + case Formattable::kLong: return (int32_t)fValue.fInt64; case Formattable::kInt64: if (fValue.fInt64 > INT32_MAX) { @@ -450,10 +450,10 @@ Formattable::getInt64(UErrorCode& status) const if (U_FAILURE(status)) { return 0; } - + switch (fType) { - case Formattable::kLong: - case Formattable::kInt64: + case Formattable::kLong: + case Formattable::kInt64: return fValue.fInt64; case Formattable::kDouble: if (fValue.fDouble > (double)U_INT64_MAX) { @@ -472,7 +472,7 @@ Formattable::getInt64(UErrorCode& status) const } } else { return (int64_t)fValue.fDouble; - } + } case Formattable::kObject: if (fValue.fObject == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -496,9 +496,9 @@ Formattable::getDouble(UErrorCode& status) const if (U_FAILURE(status)) { return 0; } - + switch (fType) { - case Formattable::kLong: + case Formattable::kLong: case Formattable::kInt64: // loses precision return (double)fValue.fInt64; case Formattable::kDouble: @@ -623,8 +623,8 @@ Formattable::adoptObject(UObject* objectToAdopt) { } // ------------------------------------- -UnicodeString& -Formattable::getString(UnicodeString& result, UErrorCode& status) const +UnicodeString& +Formattable::getString(UnicodeString& result, UErrorCode& status) const { if (fType != kString) { setError(status, U_INVALID_FORMAT_ERROR); @@ -640,8 +640,8 @@ Formattable::getString(UnicodeString& result, UErrorCode& status) const } // ------------------------------------- -const UnicodeString& -Formattable::getString(UErrorCode& status) const +const UnicodeString& +Formattable::getString(UErrorCode& status) const { if (fType != kString) { setError(status, U_INVALID_FORMAT_ERROR); @@ -655,30 +655,30 @@ Formattable::getString(UErrorCode& status) const } // ------------------------------------- -UnicodeString& -Formattable::getString(UErrorCode& status) +UnicodeString& +Formattable::getString(UErrorCode& status) { if (fType != kString) { setError(status, U_INVALID_FORMAT_ERROR); return *getBogus(); } if (fValue.fString == NULL) { - setError(status, U_MEMORY_ALLOCATION_ERROR); - return *getBogus(); + setError(status, U_MEMORY_ALLOCATION_ERROR); + return *getBogus(); } return *fValue.fString; } // ------------------------------------- -const Formattable* -Formattable::getArray(int32_t& count, UErrorCode& status) const +const Formattable* +Formattable::getArray(int32_t& count, UErrorCode& status) const { if (fType != kArray) { setError(status, U_INVALID_FORMAT_ERROR); count = 0; return NULL; } - count = fValue.fArrayAndCount.fCount; + count = fValue.fArrayAndCount.fCount; return fValue.fArrayAndCount.fArray; } @@ -686,7 +686,7 @@ Formattable::getArray(int32_t& count, UErrorCode& status) const // Gets the bogus string, ensures mondo bogosity. UnicodeString* -Formattable::getBogus() const +Formattable::getBogus() const { return (UnicodeString*)&fBogus; /* cast away const :-( */ } @@ -736,7 +736,7 @@ CharString *Formattable::internalGetCharString(UErrorCode &status) { fDecimalStr->append("Infinity", status); } else if (fDecimalQuantity->isNaN()) { fDecimalStr->append("NaN", status); - } else if (fDecimalQuantity->isZero()) { + } else if (fDecimalQuantity->isZeroish()) { fDecimalStr->append("0", -1, status); } else if (fType==kLong || fType==kInt64 || // use toPlainString for integer types (fDecimalQuantity->getMagnitude() != INT32_MIN && std::abs(fDecimalQuantity->getMagnitude()) < 5)) { @@ -845,7 +845,7 @@ FormattableStreamer::streamOut(ostream& stream, const Formattable& obj) UnicodeString buffer; switch(obj.getType()) { - case Formattable::kDate : + case Formattable::kDate : // Creates a DateFormat instance for formatting the // Date instance. if (defDateFormat == 0) { diff --git a/deps/icu-small/source/i18n/fmtableimp.h b/deps/icu-small/source/i18n/fmtableimp.h index 78b7caff548e82..2707d6ece2e2eb 100644 --- a/deps/icu-small/source/i18n/fmtableimp.h +++ b/deps/icu-small/source/i18n/fmtableimp.h @@ -16,7 +16,7 @@ U_NAMESPACE_BEGIN -/** +/** * Maximum int64_t value that can be stored in a double without chancing losing precision. * IEEE doubles have 53 bits of mantissa, 10 bits exponent, 1 bit sign. * IBM Mainframes have 56 bits of mantissa, 7 bits of base 16 exponent, 1 bit sign. diff --git a/deps/icu-small/source/i18n/number_stringbuilder.cpp b/deps/icu-small/source/i18n/formatted_string_builder.cpp similarity index 58% rename from deps/icu-small/source/i18n/number_stringbuilder.cpp rename to deps/icu-small/source/i18n/formatted_string_builder.cpp index 03300b33ac5e21..3024bff6addacc 100644 --- a/deps/icu-small/source/i18n/number_stringbuilder.cpp +++ b/deps/icu-small/source/i18n/formatted_string_builder.cpp @@ -5,14 +5,9 @@ #if !UCONFIG_NO_FORMATTING -#include "number_stringbuilder.h" -#include "static_unicode_sets.h" +#include "formatted_string_builder.h" +#include "unicode/ustring.h" #include "unicode/utf16.h" -#include "number_utils.h" - -using namespace icu; -using namespace icu::number; -using namespace icu::number::impl; namespace { @@ -34,7 +29,10 @@ inline void uprv_memmove2(void* dest, const void* src, size_t len) { } // namespace -NumberStringBuilder::NumberStringBuilder() { + +U_NAMESPACE_BEGIN + +FormattedStringBuilder::FormattedStringBuilder() { #if U_DEBUG // Initializing the memory to non-zero helps catch some bugs that involve // reading from an improperly terminated string. @@ -44,18 +42,18 @@ NumberStringBuilder::NumberStringBuilder() { #endif } -NumberStringBuilder::~NumberStringBuilder() { +FormattedStringBuilder::~FormattedStringBuilder() { if (fUsingHeap) { uprv_free(fChars.heap.ptr); uprv_free(fFields.heap.ptr); } } -NumberStringBuilder::NumberStringBuilder(const NumberStringBuilder &other) { +FormattedStringBuilder::FormattedStringBuilder(const FormattedStringBuilder &other) { *this = other; } -NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &other) { +FormattedStringBuilder &FormattedStringBuilder::operator=(const FormattedStringBuilder &other) { // Check for self-assignment if (this == &other) { return *this; @@ -78,7 +76,7 @@ NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &o // UErrorCode is not available; fail silently. uprv_free(newChars); uprv_free(newFields); - *this = NumberStringBuilder(); // can't fail + *this = FormattedStringBuilder(); // can't fail return *this; } @@ -97,15 +95,15 @@ NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &o return *this; } -int32_t NumberStringBuilder::length() const { +int32_t FormattedStringBuilder::length() const { return fLength; } -int32_t NumberStringBuilder::codePointCount() const { +int32_t FormattedStringBuilder::codePointCount() const { return u_countChar32(getCharPtr() + fZero, fLength); } -UChar32 NumberStringBuilder::getFirstCodePoint() const { +UChar32 FormattedStringBuilder::getFirstCodePoint() const { if (fLength == 0) { return -1; } @@ -114,7 +112,7 @@ UChar32 NumberStringBuilder::getFirstCodePoint() const { return cp; } -UChar32 NumberStringBuilder::getLastCodePoint() const { +UChar32 FormattedStringBuilder::getLastCodePoint() const { if (fLength == 0) { return -1; } @@ -125,13 +123,13 @@ UChar32 NumberStringBuilder::getLastCodePoint() const { return cp; } -UChar32 NumberStringBuilder::codePointAt(int32_t index) const { +UChar32 FormattedStringBuilder::codePointAt(int32_t index) const { UChar32 cp; U16_GET(getCharPtr() + fZero, 0, index, fLength, cp); return cp; } -UChar32 NumberStringBuilder::codePointBefore(int32_t index) const { +UChar32 FormattedStringBuilder::codePointBefore(int32_t index) const { int32_t offset = index; U16_BACK_1(getCharPtr() + fZero, 0, offset); UChar32 cp; @@ -139,19 +137,15 @@ UChar32 NumberStringBuilder::codePointBefore(int32_t index) const { return cp; } -NumberStringBuilder &NumberStringBuilder::clear() { +FormattedStringBuilder &FormattedStringBuilder::clear() { // TODO: Reset the heap here? fZero = getCapacity() / 2; fLength = 0; return *this; } -int32_t NumberStringBuilder::appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status) { - return insertCodePoint(fLength, codePoint, field, status); -} - int32_t -NumberStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status) { +FormattedStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status) { int32_t count = U16_LENGTH(codePoint); int32_t position = prepareForInsert(index, count, status); if (U_FAILURE(status)) { @@ -168,11 +162,7 @@ NumberStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field fie return count; } -int32_t NumberStringBuilder::append(const UnicodeString &unistr, Field field, UErrorCode &status) { - return insert(fLength, unistr, field, status); -} - -int32_t NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, Field field, +int32_t FormattedStringBuilder::insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status) { if (unistr.length() == 0) { // Nothing to insert. @@ -186,7 +176,7 @@ int32_t NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, } int32_t -NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, +FormattedStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, UErrorCode &status) { int32_t count = end - start; int32_t position = prepareForInsert(index, count, status); @@ -201,7 +191,7 @@ NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t } int32_t -NumberStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, +FormattedStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, int32_t startOther, int32_t endOther, Field field, UErrorCode& status) { int32_t thisLength = endThis - startThis; int32_t otherLength = endOther - startOther; @@ -224,12 +214,12 @@ NumberStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeSt return count; } -int32_t NumberStringBuilder::append(const NumberStringBuilder &other, UErrorCode &status) { +int32_t FormattedStringBuilder::append(const FormattedStringBuilder &other, UErrorCode &status) { return insert(fLength, other, status); } int32_t -NumberStringBuilder::insert(int32_t index, const NumberStringBuilder &other, UErrorCode &status) { +FormattedStringBuilder::insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status) { if (this == &other) { status = U_ILLEGAL_ARGUMENT_ERROR; return 0; @@ -250,7 +240,7 @@ NumberStringBuilder::insert(int32_t index, const NumberStringBuilder &other, UEr return count; } -void NumberStringBuilder::writeTerminator(UErrorCode& status) { +void FormattedStringBuilder::writeTerminator(UErrorCode& status) { int32_t position = prepareForInsert(fLength, 1, status); if (U_FAILURE(status)) { return; @@ -260,7 +250,7 @@ void NumberStringBuilder::writeTerminator(UErrorCode& status) { fLength--; } -int32_t NumberStringBuilder::prepareForInsert(int32_t index, int32_t count, UErrorCode &status) { +int32_t FormattedStringBuilder::prepareForInsert(int32_t index, int32_t count, UErrorCode &status) { U_ASSERT(index >= 0); U_ASSERT(index <= fLength); U_ASSERT(count >= 0); @@ -279,7 +269,7 @@ int32_t NumberStringBuilder::prepareForInsert(int32_t index, int32_t count, UErr } } -int32_t NumberStringBuilder::prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status) { +int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status) { int32_t oldCapacity = getCapacity(); int32_t oldZero = fZero; char16_t *oldChars = getCharPtr(); @@ -342,7 +332,7 @@ int32_t NumberStringBuilder::prepareForInsertHelper(int32_t index, int32_t count return fZero + index; } -int32_t NumberStringBuilder::remove(int32_t index, int32_t count) { +int32_t FormattedStringBuilder::remove(int32_t index, int32_t count) { // TODO: Reset the heap here? (If the string after removal can fit on stack?) int32_t position = index + fZero; uprv_memmove2(getCharPtr() + position, @@ -355,18 +345,18 @@ int32_t NumberStringBuilder::remove(int32_t index, int32_t count) { return position; } -UnicodeString NumberStringBuilder::toUnicodeString() const { +UnicodeString FormattedStringBuilder::toUnicodeString() const { return UnicodeString(getCharPtr() + fZero, fLength); } -const UnicodeString NumberStringBuilder::toTempUnicodeString() const { +const UnicodeString FormattedStringBuilder::toTempUnicodeString() const { // Readonly-alias constructor: return UnicodeString(FALSE, getCharPtr() + fZero, fLength); } -UnicodeString NumberStringBuilder::toDebugString() const { +UnicodeString FormattedStringBuilder::toDebugString() const { UnicodeString sb; - sb.append(u"= UNUM_FIELD_COUNT) { - status = U_ILLEGAL_ARGUMENT_ERROR; - return FALSE; - } - - ConstrainedFieldPosition cfpos; - cfpos.constrainField(UFIELD_CATEGORY_NUMBER, rawField); - cfpos.setState(UFIELD_CATEGORY_NUMBER, rawField, fp.getBeginIndex(), fp.getEndIndex()); - if (nextPosition(cfpos, 0, status)) { - fp.setBeginIndex(cfpos.getStart()); - fp.setEndIndex(cfpos.getLimit()); - return true; - } - - // Special case: fraction should start after integer if fraction is not present - if (rawField == UNUM_FRACTION_FIELD && fp.getEndIndex() == 0) { - bool inside = false; - int32_t i = fZero; - for (; i < fZero + fLength; i++) { - if (isIntOrGroup(getFieldPtr()[i]) || getFieldPtr()[i] == UNUM_DECIMAL_SEPARATOR_FIELD) { - inside = true; - } else if (inside) { - break; - } - } - fp.setBeginIndex(i - fZero); - fp.setEndIndex(i - fZero); - } - - return false; -} - -void NumberStringBuilder::getAllFieldPositions(FieldPositionIteratorHandler& fpih, - UErrorCode& status) const { - ConstrainedFieldPosition cfpos; - while (nextPosition(cfpos, 0, status)) { - fpih.addAttribute(cfpos.getField(), cfpos.getStart(), cfpos.getLimit()); - } -} - -// Signal the end of the string using a field that doesn't exist and that is -// different from UNUM_FIELD_COUNT, which is used for "null number field". -static constexpr Field kEndField = 0xff; - -bool NumberStringBuilder::nextPosition(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& /*status*/) const { - auto numericCAF = NumFieldUtils::expand(numericField); - int32_t fieldStart = -1; - Field currField = UNUM_FIELD_COUNT; - for (int32_t i = fZero + cfpos.getLimit(); i <= fZero + fLength; i++) { - Field _field = (i < fZero + fLength) ? getFieldPtr()[i] : kEndField; - // Case 1: currently scanning a field. - if (currField != UNUM_FIELD_COUNT) { - if (currField != _field) { - int32_t end = i - fZero; - // Grouping separators can be whitespace; don't throw them out! - if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { - end = trimBack(i - fZero); - } - if (end <= fieldStart) { - // Entire field position is ignorable; skip. - fieldStart = -1; - currField = UNUM_FIELD_COUNT; - i--; // look at this index again - continue; - } - int32_t start = fieldStart; - if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { - start = trimFront(start); - } - auto caf = NumFieldUtils::expand(currField); - cfpos.setState(caf.category, caf.field, start, end); - return true; - } - continue; - } - // Special case: coalesce the INTEGER if we are pointing at the end of the INTEGER. - if (cfpos.matchesField(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD) - && i > fZero - // don't return the same field twice in a row: - && i - fZero > cfpos.getLimit() - && isIntOrGroup(getFieldPtr()[i - 1]) - && !isIntOrGroup(_field)) { - int j = i - 1; - for (; j >= fZero && isIntOrGroup(getFieldPtr()[j]); j--) {} - cfpos.setState(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, j - fZero + 1, i - fZero); - return true; - } - // Special case: coalesce NUMERIC if we are pointing at the end of the NUMERIC. - if (numericField != 0 - && cfpos.matchesField(numericCAF.category, numericCAF.field) - && i > fZero - // don't return the same field twice in a row: - && (i - fZero > cfpos.getLimit() - || cfpos.getCategory() != numericCAF.category - || cfpos.getField() != numericCAF.field) - && isNumericField(getFieldPtr()[i - 1]) - && !isNumericField(_field)) { - int j = i - 1; - for (; j >= fZero && isNumericField(getFieldPtr()[j]); j--) {} - cfpos.setState(numericCAF.category, numericCAF.field, j - fZero + 1, i - fZero); - return true; - } - // Special case: skip over INTEGER; will be coalesced later. - if (_field == UNUM_INTEGER_FIELD) { - _field = UNUM_FIELD_COUNT; - } - // Case 2: no field starting at this position. - if (_field == UNUM_FIELD_COUNT || _field == kEndField) { - continue; - } - // Case 3: check for field starting at this position - auto caf = NumFieldUtils::expand(_field); - if (cfpos.matchesField(caf.category, caf.field)) { - fieldStart = i - fZero; - currField = _field; - } - } - - U_ASSERT(currField == UNUM_FIELD_COUNT); - return false; -} - -bool NumberStringBuilder::containsField(Field field) const { +bool FormattedStringBuilder::containsField(Field field) const { for (int32_t i = 0; i < fLength; i++) { if (field == fieldAt(i)) { return true; @@ -573,27 +434,6 @@ bool NumberStringBuilder::containsField(Field field) const { return false; } -bool NumberStringBuilder::isIntOrGroup(Field field) { - return field == UNUM_INTEGER_FIELD - || field == UNUM_GROUPING_SEPARATOR_FIELD; -} - -bool NumberStringBuilder::isNumericField(Field field) { - return NumFieldUtils::isNumericField(field); -} - -int32_t NumberStringBuilder::trimBack(int32_t limit) const { - return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack( - getCharPtr() + fZero, - limit, - USET_SPAN_CONTAINED); -} - -int32_t NumberStringBuilder::trimFront(int32_t start) const { - return start + unisets::get(unisets::DEFAULT_IGNORABLES)->span( - getCharPtr() + fZero + start, - fLength - start, - USET_SPAN_CONTAINED); -} +U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/formatted_string_builder.h b/deps/icu-small/source/i18n/formatted_string_builder.h new file mode 100644 index 00000000000000..2949ae73e0ff9e --- /dev/null +++ b/deps/icu-small/source/i18n/formatted_string_builder.h @@ -0,0 +1,253 @@ +// © 2017 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMBER_STRINGBUILDER_H__ +#define __NUMBER_STRINGBUILDER_H__ + + +#include +#include "unicode/unum.h" // for UNUM_FIELD_COUNT +#include "cstring.h" +#include "uassert.h" +#include "fphdlimp.h" + +U_NAMESPACE_BEGIN + +class FormattedValueStringBuilderImpl; + +/** + * A StringBuilder optimized for formatting. It implements the following key + * features beyond a UnicodeString: + * + *
        + *
      1. Efficient prepend as well as append. + *
      2. Keeps tracks of Fields in an efficient manner. + *
      + * + * See also FormattedValueStringBuilderImpl. + * + * @author sffc (Shane Carr) + */ +class U_I18N_API FormattedStringBuilder : public UMemory { + private: + static const int32_t DEFAULT_CAPACITY = 40; + + template + union ValueOrHeapArray { + T value[DEFAULT_CAPACITY]; + struct { + T *ptr; + int32_t capacity; + } heap; + }; + + public: + FormattedStringBuilder(); + + ~FormattedStringBuilder(); + + FormattedStringBuilder(const FormattedStringBuilder &other); + + // Convention: bottom 4 bits for field, top 4 bits for field category. + // Field category 0 implies the number category so that the number field + // literals can be directly passed as a Field type. + // See the helper functions in "StringBuilderFieldUtils" below. + typedef uint8_t Field; + + FormattedStringBuilder &operator=(const FormattedStringBuilder &other); + + int32_t length() const; + + int32_t codePointCount() const; + + inline char16_t charAt(int32_t index) const { + U_ASSERT(index >= 0); + U_ASSERT(index < fLength); + return getCharPtr()[fZero + index]; + } + + inline Field fieldAt(int32_t index) const { + U_ASSERT(index >= 0); + U_ASSERT(index < fLength); + return getFieldPtr()[fZero + index]; + } + + UChar32 getFirstCodePoint() const; + + UChar32 getLastCodePoint() const; + + UChar32 codePointAt(int32_t index) const; + + UChar32 codePointBefore(int32_t index) const; + + FormattedStringBuilder &clear(); + + /** Appends a UTF-16 code unit. */ + inline int32_t appendChar16(char16_t codeUnit, Field field, UErrorCode& status) { + // appendCodePoint handles both code units and code points. + return insertCodePoint(fLength, codeUnit, field, status); + } + + /** Inserts a UTF-16 code unit. Note: insert at index 0 is very efficient. */ + inline int32_t insertChar16(int32_t index, char16_t codeUnit, Field field, UErrorCode& status) { + // insertCodePoint handles both code units and code points. + return insertCodePoint(index, codeUnit, field, status); + } + + /** Appends a Unicode code point. */ + inline int32_t appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status) { + return insertCodePoint(fLength, codePoint, field, status); + } + + /** Inserts a Unicode code point. Note: insert at index 0 is very efficient. */ + int32_t insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status); + + /** Appends a string. */ + inline int32_t append(const UnicodeString &unistr, Field field, UErrorCode &status) { + return insert(fLength, unistr, field, status); + } + + /** Inserts a string. Note: insert at index 0 is very efficient. */ + int32_t insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status); + + /** Inserts a substring. Note: insert at index 0 is very efficient. + * + * @param start Start index of the substring of unistr to be inserted. + * @param end End index of the substring of unistr to be inserted (exclusive). + */ + int32_t insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, + UErrorCode &status); + + /** Deletes a substring and then inserts a string at that same position. + * Similar to JavaScript Array.prototype.splice(). + * + * @param startThis Start of the span to delete. + * @param endThis End of the span to delete (exclusive). + * @param unistr The string to insert at the deletion position. + * @param startOther Start index of the substring of unistr to be inserted. + * @param endOther End index of the substring of unistr to be inserted (exclusive). + */ + int32_t splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, + int32_t startOther, int32_t endOther, Field field, UErrorCode& status); + + /** Appends a formatted string. */ + int32_t append(const FormattedStringBuilder &other, UErrorCode &status); + + /** Inserts a formatted string. Note: insert at index 0 is very efficient. */ + int32_t insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status); + + /** + * Ensures that the string buffer contains a NUL terminator. The NUL terminator does + * not count toward the string length. Any further changes to the string (insert or + * append) may invalidate the NUL terminator. + * + * You should call this method after the formatted string is completely built if you + * plan to return a pointer to the string from a C API. + */ + void writeTerminator(UErrorCode& status); + + /** + * Gets a "safe" UnicodeString that can be used even after the FormattedStringBuilder is destructed. + */ + UnicodeString toUnicodeString() const; + + /** + * Gets an "unsafe" UnicodeString that is valid only as long as the FormattedStringBuilder is alive and + * unchanged. Slightly faster than toUnicodeString(). + */ + const UnicodeString toTempUnicodeString() const; + + UnicodeString toDebugString() const; + + const char16_t *chars() const; + + bool contentEquals(const FormattedStringBuilder &other) const; + + bool containsField(Field field) const; + + private: + bool fUsingHeap = false; + ValueOrHeapArray fChars; + ValueOrHeapArray fFields; + int32_t fZero = DEFAULT_CAPACITY / 2; + int32_t fLength = 0; + + inline char16_t *getCharPtr() { + return fUsingHeap ? fChars.heap.ptr : fChars.value; + } + + inline const char16_t *getCharPtr() const { + return fUsingHeap ? fChars.heap.ptr : fChars.value; + } + + inline Field *getFieldPtr() { + return fUsingHeap ? fFields.heap.ptr : fFields.value; + } + + inline const Field *getFieldPtr() const { + return fUsingHeap ? fFields.heap.ptr : fFields.value; + } + + inline int32_t getCapacity() const { + return fUsingHeap ? fChars.heap.capacity : DEFAULT_CAPACITY; + } + + int32_t prepareForInsert(int32_t index, int32_t count, UErrorCode &status); + + int32_t prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status); + + int32_t remove(int32_t index, int32_t count); + + friend class FormattedValueStringBuilderImpl; +}; + +/** + * Helper functions for dealing with the Field typedef, which stores fields + * in a compressed format. + */ +class StringBuilderFieldUtils { +public: + struct CategoryFieldPair { + int32_t category; + int32_t field; + }; + + /** Compile-time function to construct a Field from a category and a field */ + template + static constexpr FormattedStringBuilder::Field compress() { + static_assert(category != 0, "cannot use Undefined category in FieldUtils"); + static_assert(category <= 0xf, "only 4 bits for category"); + static_assert(field <= 0xf, "only 4 bits for field"); + return static_cast((category << 4) | field); + } + + /** Runtime inline function to unpack the category and field from the Field */ + static inline CategoryFieldPair expand(FormattedStringBuilder::Field field) { + if (field == UNUM_FIELD_COUNT) { + return {UFIELD_CATEGORY_UNDEFINED, 0}; + } + CategoryFieldPair ret = { + (field >> 4), + (field & 0xf) + }; + if (ret.category == 0) { + ret.category = UFIELD_CATEGORY_NUMBER; + } + return ret; + } + + static inline bool isNumericField(FormattedStringBuilder::Field field) { + int8_t category = field >> 4; + return category == 0 || category == UFIELD_CATEGORY_NUMBER; + } +}; + +U_NAMESPACE_END + + +#endif //__NUMBER_STRINGBUILDER_H__ + +#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/formattedval_impl.h b/deps/icu-small/source/i18n/formattedval_impl.h index 69ba0922edc81f..9aab36a52fecda 100644 --- a/deps/icu-small/source/i18n/formattedval_impl.h +++ b/deps/icu-small/source/i18n/formattedval_impl.h @@ -18,7 +18,7 @@ #include "fphdlimp.h" #include "util.h" #include "uvectr32.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" /** @@ -67,7 +67,9 @@ typedef enum UCFPosConstraintType { U_NAMESPACE_BEGIN -/** Implementation using FieldPositionHandler to accept fields. */ +/** + * Implementation of FormattedValue using FieldPositionHandler to accept fields. + */ class FormattedValueFieldPositionIteratorImpl : public UMemory, public FormattedValue { public: @@ -91,7 +93,7 @@ class FormattedValueFieldPositionIteratorImpl : public UMemory, public Formatted /** * Computes the spans for duplicated values. * For example, if the string has fields: - * + * * ...aa..[b.cc]..d.[bb.e.c]..a.. * * then the spans will be the bracketed regions. @@ -112,12 +114,21 @@ class FormattedValueFieldPositionIteratorImpl : public UMemory, public Formatted }; -class FormattedValueNumberStringBuilderImpl : public UMemory, public FormattedValue { +/** + * Implementation of FormattedValue based on FormattedStringBuilder. + * + * The implementation currently revolves around numbers and number fields. + * However, it can be generalized in the future when there is a need. + * + * @author sffc (Shane Carr) + */ +// Exported as U_I18N_API for tests +class U_I18N_API FormattedValueStringBuilderImpl : public UMemory, public FormattedValue { public: - FormattedValueNumberStringBuilderImpl(number::impl::Field numericField); + FormattedValueStringBuilderImpl(FormattedStringBuilder::Field numericField); - virtual ~FormattedValueNumberStringBuilderImpl(); + virtual ~FormattedValueStringBuilderImpl(); // Implementation of FormattedValue (const): @@ -126,17 +137,25 @@ class FormattedValueNumberStringBuilderImpl : public UMemory, public FormattedVa Appendable& appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE; UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; - inline number::impl::NumberStringBuilder& getStringRef() { + // Additional helper functions: + UBool nextFieldPosition(FieldPosition& fp, UErrorCode& status) const; + void getAllFieldPositions(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; + inline FormattedStringBuilder& getStringRef() { return fString; } - - inline const number::impl::NumberStringBuilder& getStringRef() const { + inline const FormattedStringBuilder& getStringRef() const { return fString; } private: - number::impl::NumberStringBuilder fString; - number::impl::Field fNumericField; + FormattedStringBuilder fString; + FormattedStringBuilder::Field fNumericField; + + bool nextPositionImpl(ConstrainedFieldPosition& cfpos, FormattedStringBuilder::Field numericField, UErrorCode& status) const; + static bool isIntOrGroup(FormattedStringBuilder::Field field); + static bool isNumericField(FormattedStringBuilder::Field field); + int32_t trimBack(int32_t limit) const; + int32_t trimFront(int32_t start) const; }; diff --git a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp index 1fbecf25ac6bb6..ca28f222813afc 100644 --- a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp +++ b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp @@ -9,35 +9,203 @@ // Other independent implementations should go into their own cpp file for // better dependency modularization. +#include "unicode/ustring.h" #include "formattedval_impl.h" +#include "number_types.h" +#include "formatted_string_builder.h" +#include "number_utils.h" +#include "static_unicode_sets.h" U_NAMESPACE_BEGIN -FormattedValueNumberStringBuilderImpl::FormattedValueNumberStringBuilderImpl(number::impl::Field numericField) +typedef FormattedStringBuilder::Field Field; + + +FormattedValueStringBuilderImpl::FormattedValueStringBuilderImpl(Field numericField) : fNumericField(numericField) { } -FormattedValueNumberStringBuilderImpl::~FormattedValueNumberStringBuilderImpl() { +FormattedValueStringBuilderImpl::~FormattedValueStringBuilderImpl() { } -UnicodeString FormattedValueNumberStringBuilderImpl::toString(UErrorCode&) const { +UnicodeString FormattedValueStringBuilderImpl::toString(UErrorCode&) const { return fString.toUnicodeString(); } -UnicodeString FormattedValueNumberStringBuilderImpl::toTempString(UErrorCode&) const { +UnicodeString FormattedValueStringBuilderImpl::toTempString(UErrorCode&) const { return fString.toTempUnicodeString(); } -Appendable& FormattedValueNumberStringBuilderImpl::appendTo(Appendable& appendable, UErrorCode&) const { +Appendable& FormattedValueStringBuilderImpl::appendTo(Appendable& appendable, UErrorCode&) const { appendable.appendString(fString.chars(), fString.length()); return appendable; } -UBool FormattedValueNumberStringBuilderImpl::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { +UBool FormattedValueStringBuilderImpl::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fString.nextPosition(cfpos, fNumericField, status) ? TRUE : FALSE; + return nextPositionImpl(cfpos, fNumericField, status) ? TRUE : FALSE; +} + +UBool FormattedValueStringBuilderImpl::nextFieldPosition(FieldPosition& fp, UErrorCode& status) const { + int32_t rawField = fp.getField(); + + if (rawField == FieldPosition::DONT_CARE) { + return FALSE; + } + + if (rawField < 0 || rawField >= UNUM_FIELD_COUNT) { + status = U_ILLEGAL_ARGUMENT_ERROR; + return FALSE; + } + + ConstrainedFieldPosition cfpos; + cfpos.constrainField(UFIELD_CATEGORY_NUMBER, rawField); + cfpos.setState(UFIELD_CATEGORY_NUMBER, rawField, fp.getBeginIndex(), fp.getEndIndex()); + if (nextPositionImpl(cfpos, 0, status)) { + fp.setBeginIndex(cfpos.getStart()); + fp.setEndIndex(cfpos.getLimit()); + return TRUE; + } + + // Special case: fraction should start after integer if fraction is not present + if (rawField == UNUM_FRACTION_FIELD && fp.getEndIndex() == 0) { + bool inside = false; + int32_t i = fString.fZero; + for (; i < fString.fZero + fString.fLength; i++) { + if (isIntOrGroup(fString.getFieldPtr()[i]) || fString.getFieldPtr()[i] == UNUM_DECIMAL_SEPARATOR_FIELD) { + inside = true; + } else if (inside) { + break; + } + } + fp.setBeginIndex(i - fString.fZero); + fp.setEndIndex(i - fString.fZero); + } + + return FALSE; +} + +void FormattedValueStringBuilderImpl::getAllFieldPositions(FieldPositionIteratorHandler& fpih, + UErrorCode& status) const { + ConstrainedFieldPosition cfpos; + while (nextPositionImpl(cfpos, 0, status)) { + fpih.addAttribute(cfpos.getField(), cfpos.getStart(), cfpos.getLimit()); + } +} + +// Signal the end of the string using a field that doesn't exist and that is +// different from UNUM_FIELD_COUNT, which is used for "null number field". +static constexpr Field kEndField = 0xff; + +bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& /*status*/) const { + auto numericCAF = StringBuilderFieldUtils::expand(numericField); + int32_t fieldStart = -1; + Field currField = UNUM_FIELD_COUNT; + for (int32_t i = fString.fZero + cfpos.getLimit(); i <= fString.fZero + fString.fLength; i++) { + Field _field = (i < fString.fZero + fString.fLength) ? fString.getFieldPtr()[i] : kEndField; + // Case 1: currently scanning a field. + if (currField != UNUM_FIELD_COUNT) { + if (currField != _field) { + int32_t end = i - fString.fZero; + // Grouping separators can be whitespace; don't throw them out! + if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { + end = trimBack(i - fString.fZero); + } + if (end <= fieldStart) { + // Entire field position is ignorable; skip. + fieldStart = -1; + currField = UNUM_FIELD_COUNT; + i--; // look at this index again + continue; + } + int32_t start = fieldStart; + if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { + start = trimFront(start); + } + auto caf = StringBuilderFieldUtils::expand(currField); + cfpos.setState(caf.category, caf.field, start, end); + return true; + } + continue; + } + // Special case: coalesce the INTEGER if we are pointing at the end of the INTEGER. + if (cfpos.matchesField(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD) + && i > fString.fZero + // don't return the same field twice in a row: + && i - fString.fZero > cfpos.getLimit() + && isIntOrGroup(fString.getFieldPtr()[i - 1]) + && !isIntOrGroup(_field)) { + int j = i - 1; + for (; j >= fString.fZero && isIntOrGroup(fString.getFieldPtr()[j]); j--) {} + cfpos.setState( + UFIELD_CATEGORY_NUMBER, + UNUM_INTEGER_FIELD, + j - fString.fZero + 1, + i - fString.fZero); + return true; + } + // Special case: coalesce NUMERIC if we are pointing at the end of the NUMERIC. + if (numericField != 0 + && cfpos.matchesField(numericCAF.category, numericCAF.field) + && i > fString.fZero + // don't return the same field twice in a row: + && (i - fString.fZero > cfpos.getLimit() + || cfpos.getCategory() != numericCAF.category + || cfpos.getField() != numericCAF.field) + && isNumericField(fString.getFieldPtr()[i - 1]) + && !isNumericField(_field)) { + int j = i - 1; + for (; j >= fString.fZero && isNumericField(fString.getFieldPtr()[j]); j--) {} + cfpos.setState( + numericCAF.category, + numericCAF.field, + j - fString.fZero + 1, + i - fString.fZero); + return true; + } + // Special case: skip over INTEGER; will be coalesced later. + if (_field == UNUM_INTEGER_FIELD) { + _field = UNUM_FIELD_COUNT; + } + // Case 2: no field starting at this position. + if (_field == UNUM_FIELD_COUNT || _field == kEndField) { + continue; + } + // Case 3: check for field starting at this position + auto caf = StringBuilderFieldUtils::expand(_field); + if (cfpos.matchesField(caf.category, caf.field)) { + fieldStart = i - fString.fZero; + currField = _field; + } + } + + U_ASSERT(currField == UNUM_FIELD_COUNT); + return false; +} + +bool FormattedValueStringBuilderImpl::isIntOrGroup(Field field) { + return field == UNUM_INTEGER_FIELD + || field == UNUM_GROUPING_SEPARATOR_FIELD; +} + +bool FormattedValueStringBuilderImpl::isNumericField(Field field) { + return StringBuilderFieldUtils::isNumericField(field); +} + +int32_t FormattedValueStringBuilderImpl::trimBack(int32_t limit) const { + return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack( + fString.getCharPtr() + fString.fZero, + limit, + USET_SPAN_CONTAINED); +} + +int32_t FormattedValueStringBuilderImpl::trimFront(int32_t start) const { + return start + unisets::get(unisets::DEFAULT_IGNORABLES)->span( + fString.getCharPtr() + fString.fZero + start, + fString.fLength - start, + USET_SPAN_CONTAINED); } diff --git a/deps/icu-small/source/i18n/fpositer.cpp b/deps/icu-small/source/i18n/fpositer.cpp index b6e1b58309b4e0..75d529eb8c929f 100644 --- a/deps/icu-small/source/i18n/fpositer.cpp +++ b/deps/icu-small/source/i18n/fpositer.cpp @@ -111,3 +111,4 @@ UBool FieldPositionIterator::next(FieldPosition& fp) { U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ + diff --git a/deps/icu-small/source/i18n/funcrepl.cpp b/deps/icu-small/source/i18n/funcrepl.cpp index 30bcebbf908794..7dd54ed8d2b6a7 100644 --- a/deps/icu-small/source/i18n/funcrepl.cpp +++ b/deps/icu-small/source/i18n/funcrepl.cpp @@ -59,7 +59,7 @@ FunctionReplacer::~FunctionReplacer() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* FunctionReplacer::clone() const { +FunctionReplacer* FunctionReplacer::clone() const { return new FunctionReplacer(*this); } @@ -70,7 +70,7 @@ UnicodeFunctor* FunctionReplacer::clone() const { UnicodeReplacer* FunctionReplacer::toReplacer() const { FunctionReplacer *nonconst_this = const_cast(this); UnicodeReplacer *nonconst_base = static_cast(nonconst_this); - + return nonconst_base; } diff --git a/deps/icu-small/source/i18n/funcrepl.h b/deps/icu-small/source/i18n/funcrepl.h index a835d5be7c2173..fe41f6caaa6d10 100644 --- a/deps/icu-small/source/i18n/funcrepl.h +++ b/deps/icu-small/source/i18n/funcrepl.h @@ -70,7 +70,7 @@ class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { /** * Implement UnicodeFunctor */ - virtual UnicodeFunctor* clone() const; + virtual FunctionReplacer* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer diff --git a/deps/icu-small/source/i18n/gender.cpp b/deps/icu-small/source/i18n/gender.cpp index 106cf424c59d88..32ddbf9a667a7a 100644 --- a/deps/icu-small/source/i18n/gender.cpp +++ b/deps/icu-small/source/i18n/gender.cpp @@ -98,7 +98,7 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat return NULL; } - static UMutex gGenderMetaLock = U_MUTEX_INITIALIZER; + static UMutex gGenderMetaLock; const GenderInfo* result = NULL; const char* key = locale.getName(); { @@ -166,7 +166,7 @@ const GenderInfo* GenderInfo::loadInstance(const Locale& locale, UErrorCode& sta return &gObjs[NEUTRAL]; } if (uprv_strcmp(type_str, gMixedNeutralStr) == 0) { - return &gObjs[MIXED_NEUTRAL]; + return &gObjs[MIXED_NEUTRAL]; } if (uprv_strcmp(type_str, gMailTaintsStr) == 0) { return &gObjs[MALE_TAINTS]; diff --git a/deps/icu-small/source/i18n/gregocal.cpp b/deps/icu-small/source/i18n/gregocal.cpp index 4db66758df1f1f..6b15171c12b9ac 100644 --- a/deps/icu-small/source/i18n/gregocal.cpp +++ b/deps/icu-small/source/i18n/gregocal.cpp @@ -27,7 +27,7 @@ * add() from Java source. * 07/28/98 stephen Sync up with JDK 1.2 * 09/14/98 stephen Changed type of kOneDay, kOneWeek to double. -* Fixed bug in roll() +* Fixed bug in roll() * 10/15/99 aliu Fixed j31, incorrect WEEK_OF_YEAR computation. * 10/15/99 aliu Fixed j32, cannot set date to Feb 29 2000 AD. * {JDK bug 4210209 4209272} @@ -105,7 +105,7 @@ static const int32_t kGregorianCalendarLimits[UCAL_FIELD_COUNT][4] = { /* *
      -*                            Greatest       Least
      +*                            Greatest       Least 
       * Field name        Minimum   Minimum     Maximum     Maximum
       * ----------        -------   -------     -------     -------
       * ERA                     0         0           1           1
      @@ -286,7 +286,7 @@ fIsGregorian(source.fIsGregorian), fInvertGregorian(source.fInvertGregorian)
       
       // -------------------------------------
       
      -Calendar* GregorianCalendar::clone() const
      +GregorianCalendar* GregorianCalendar::clone() const
       {
           return new GregorianCalendar(*this);
       }
      @@ -321,29 +321,29 @@ UBool GregorianCalendar::isEquivalentTo(const Calendar& other) const
       void
       GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status)
       {
      -    if (U_FAILURE(status))
      +    if (U_FAILURE(status)) 
               return;
       
      -    fGregorianCutover = date;
      -
           // Precompute two internal variables which we use to do the actual
           // cutover computations.  These are the normalized cutover, which is the
           // midnight at or before the cutover, and the cutover year.  The
           // normalized cutover is in pure date milliseconds; it contains no time
           // of day or timezone component, and it used to compare against other
           // pure date values.
      -    int32_t cutoverDay = (int32_t)ClockMath::floorDivide(fGregorianCutover, (double)kOneDay);
      -    fNormalizedGregorianCutover = cutoverDay * kOneDay;
      -
      -    // Handle the rare case of numeric overflow.  If the user specifies a
      -    // change of UDate(Long.MIN_VALUE), in order to get a pure Gregorian
      -    // calendar, then the epoch day is -106751991168, which when multiplied
      -    // by ONE_DAY gives 9223372036794351616 -- the negative value is too
      -    // large for 64 bits, and overflows into a positive value.  We correct
      -    // this by using the next day, which for all intents is semantically
      -    // equivalent.
      -    if (cutoverDay < 0 && fNormalizedGregorianCutover > 0) {
      -        fNormalizedGregorianCutover = (cutoverDay + 1) * kOneDay;
      +    double cutoverDay = ClockMath::floorDivide(date, (double)kOneDay);
      +
      +    // Handle the rare case of numeric overflow where the user specifies a time
      +    // outside of INT32_MIN .. INT32_MAX number of days.
      +    
      +    if (cutoverDay <= INT32_MIN) {
      +        cutoverDay = INT32_MIN;
      +        fGregorianCutover = fNormalizedGregorianCutover = cutoverDay * kOneDay;
      +    } else if (cutoverDay >= INT32_MAX) {
      +        cutoverDay = INT32_MAX;
      +        fGregorianCutover = fNormalizedGregorianCutover = cutoverDay * kOneDay;
      +    } else {
      +        fNormalizedGregorianCutover = cutoverDay * kOneDay;
      +        fGregorianCutover = date;
           }
       
           // Normalize the year so BC values are represented as 0 and negative
      @@ -358,9 +358,9 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status)
               return;
           cal->setTime(date, status);
           fGregorianCutoverYear = cal->get(UCAL_YEAR, status);
      -    if (cal->get(UCAL_ERA, status) == BC)
      +    if (cal->get(UCAL_ERA, status) == BC) 
               fGregorianCutoverYear = 1 - fGregorianCutoverYear;
      -    fCutoverJulianDay = cutoverDay;
      +    fCutoverJulianDay = (int32_t)cutoverDay;
           delete cal;
       }
       
      @@ -369,12 +369,12 @@ void GregorianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& statu
           int32_t eyear, month, dayOfMonth, dayOfYear, unusedRemainder;
       
       
      -    if(U_FAILURE(status)) {
      -        return;
      +    if(U_FAILURE(status)) { 
      +        return; 
           }
       
       #if defined (U_DEBUG_CAL)
      -    fprintf(stderr, "%s:%d: jd%d- (greg's %d)- [cut=%d]\n",
      +    fprintf(stderr, "%s:%d: jd%d- (greg's %d)- [cut=%d]\n", 
               __FILE__, __LINE__, julianDay, getGregorianDayOfYear(), fCutoverJulianDay);
       #endif
       
      @@ -413,11 +413,11 @@ void GregorianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& statu
               ++dayOfYear;
       #if defined (U_DEBUG_CAL)
               //     fprintf(stderr, "%d - %d[%d] + 1\n", dayOfYear, isLeap?kLeapNumDays[month]:kNumDays[month], month );
      -        //           fprintf(stderr, "%s:%d:  greg's HCF %d -> %d/%d/%d not %d/%d/%d\n",
      +        //           fprintf(stderr, "%s:%d:  greg's HCF %d -> %d/%d/%d not %d/%d/%d\n", 
               //                   __FILE__, __LINE__,julianDay,
               //          eyear,month,dayOfMonth,
               //          getGregorianYear(), getGregorianMonth(), getGregorianDayOfMonth()  );
      -        fprintf(stderr, "%s:%d: doy %d (greg's %d)- [cut=%d]\n",
      +        fprintf(stderr, "%s:%d: doy %d (greg's %d)- [cut=%d]\n", 
                   __FILE__, __LINE__, dayOfYear, getGregorianDayOfYear(), fCutoverJulianDay);
       #endif
       
      @@ -458,7 +458,7 @@ GregorianCalendar::getGregorianChange() const
       
       // -------------------------------------
       
      -UBool
      +UBool 
       GregorianCalendar::isLeapYear(int32_t year) const
       {
           // MSVC complains bitterly if we try to use Grego::isLeapYear here
      @@ -470,15 +470,15 @@ GregorianCalendar::isLeapYear(int32_t year) const
       
       // -------------------------------------
       
      -int32_t GregorianCalendar::handleComputeJulianDay(UCalendarDateFields bestField)
      +int32_t GregorianCalendar::handleComputeJulianDay(UCalendarDateFields bestField) 
       {
           fInvertGregorian = FALSE;
       
           int32_t jd = Calendar::handleComputeJulianDay(bestField);
       
           if((bestField == UCAL_WEEK_OF_YEAR) &&  // if we are doing WOY calculations, we are counting relative to Jan 1 *julian*
      -        (internalGet(UCAL_EXTENDED_YEAR)==fGregorianCutoverYear) &&
      -        jd >= fCutoverJulianDay) {
      +        (internalGet(UCAL_EXTENDED_YEAR)==fGregorianCutoverYear) && 
      +        jd >= fCutoverJulianDay) { 
                   fInvertGregorian = TRUE;  // So that the Julian Jan 1 will be used in handleComputeMonthStart
                   return Calendar::handleComputeJulianDay(bestField);
               }
      @@ -489,20 +489,20 @@ int32_t GregorianCalendar::handleComputeJulianDay(UCalendarDateFields bestField)
               //if ((fIsGregorian==TRUE) != (jd >= fCutoverJulianDay)) {  /*  cutoverJulianDay)) { */
               if ((fIsGregorian==TRUE) != (jd >= fCutoverJulianDay)) {  /*  cutoverJulianDay)) { */
       #if defined (U_DEBUG_CAL)
      -            fprintf(stderr, "%s:%d: jd [invert] %d\n",
      +            fprintf(stderr, "%s:%d: jd [invert] %d\n", 
                       __FILE__, __LINE__, jd);
       #endif
                   fInvertGregorian = TRUE;
                   jd = Calendar::handleComputeJulianDay(bestField);
       #if defined (U_DEBUG_CAL)
      -            fprintf(stderr, "%s:%d:  fIsGregorian %s, fInvertGregorian %s - ",
      +            fprintf(stderr, "%s:%d:  fIsGregorian %s, fInvertGregorian %s - ", 
                       __FILE__, __LINE__,fIsGregorian?"T":"F", fInvertGregorian?"T":"F");
      -            fprintf(stderr, " jd NOW %d\n",
      +            fprintf(stderr, " jd NOW %d\n", 
                       jd);
       #endif
               } else {
       #if defined (U_DEBUG_CAL)
      -            fprintf(stderr, "%s:%d: jd [==] %d - %sfIsGregorian %sfInvertGregorian, %d\n",
      +            fprintf(stderr, "%s:%d: jd [==] %d - %sfIsGregorian %sfInvertGregorian, %d\n", 
                       __FILE__, __LINE__, jd, fIsGregorian?"T":"F", fInvertGregorian?"T":"F", bestField);
       #endif
               }
      @@ -511,14 +511,14 @@ int32_t GregorianCalendar::handleComputeJulianDay(UCalendarDateFields bestField)
                   int32_t gregShift = Grego::gregorianShift(internalGet(UCAL_EXTENDED_YEAR));
                   if (bestField == UCAL_DAY_OF_YEAR) {
       #if defined (U_DEBUG_CAL)
      -                fprintf(stderr, "%s:%d: [DOY%d] gregorian shift of JD %d += %d\n",
      +                fprintf(stderr, "%s:%d: [DOY%d] gregorian shift of JD %d += %d\n", 
                           __FILE__, __LINE__, fFields[bestField],jd, gregShift);
       #endif
                       jd -= gregShift;
                   } else if ( bestField == UCAL_WEEK_OF_MONTH ) {
                       int32_t weekShift = 14;
       #if defined (U_DEBUG_CAL)
      -                fprintf(stderr, "%s:%d: [WOY/WOM] gregorian week shift of %d += %d\n",
      +                fprintf(stderr, "%s:%d: [WOY/WOM] gregorian week shift of %d += %d\n", 
                           __FILE__, __LINE__, jd, weekShift);
       #endif
                       jd += weekShift; // shift by weeks for week based fields.
      @@ -546,7 +546,7 @@ int32_t GregorianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month,
       
           nonConstThis->fIsGregorian = (eyear >= fGregorianCutoverYear);
       #if defined (U_DEBUG_CAL)
      -    fprintf(stderr, "%s:%d: (hcms%d/%d) fIsGregorian %s, fInvertGregorian %s\n",
      +    fprintf(stderr, "%s:%d: (hcms%d/%d) fIsGregorian %s, fInvertGregorian %s\n", 
               __FILE__, __LINE__, eyear,month, fIsGregorian?"T":"F", fInvertGregorian?"T":"F");
       #endif
           if (fInvertGregorian) {
      @@ -558,7 +558,7 @@ int32_t GregorianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month,
               // Julian calendar
               int32_t gregShift = Grego::gregorianShift(eyear);
       #if defined (U_DEBUG_CAL)
      -        fprintf(stderr, "%s:%d: (hcms%d/%d) gregorian shift of %d += %d\n",
      +        fprintf(stderr, "%s:%d: (hcms%d/%d) gregorian shift of %d += %d\n", 
                   __FILE__, __LINE__, eyear, month, julianDay, gregShift);
       #endif
               julianDay += gregShift;
      @@ -630,12 +630,12 @@ GregorianCalendar::yearLength() const
       * 3, we want it to go to Feb 28.  Adjustments which might run into this
       * problem call this method to retain the proper month.
       */
      -void
      -GregorianCalendar::pinDayOfMonth()
      +void 
      +GregorianCalendar::pinDayOfMonth() 
       {
           int32_t monthLen = monthLength(internalGet(UCAL_MONTH));
           int32_t dom = internalGet(UCAL_DATE);
      -    if(dom > monthLen)
      +    if(dom > monthLen) 
               set(UCAL_DATE, monthLen);
       }
       
      @@ -691,8 +691,8 @@ GregorianCalendar::boundsCheck(int32_t value, UCalendarDateFields field) const
       
       // -------------------------------------
       
      -UDate
      -GregorianCalendar::getEpochDay(UErrorCode& status)
      +UDate 
      +GregorianCalendar::getEpochDay(UErrorCode& status) 
       {
           complete(status);
           // Divide by 1000 (convert to seconds) in order to prevent overflow when
      @@ -784,7 +784,7 @@ double GregorianCalendar::computeJulianDayOfYear(UBool isGregorian,
       
       // -------------------------------------
       
      -double
      +double 
       GregorianCalendar::millisToJulianDay(UDate millis)
       {
           return (double)kEpochStartAsJulianDay + ClockMath::floorDivide(millis, (double)kOneDay);
      @@ -801,9 +801,9 @@ GregorianCalendar::julianDayToMillis(double julian)
       // -------------------------------------
       
       int32_t
      -GregorianCalendar::aggregateStamp(int32_t stamp_a, int32_t stamp_b)
      +GregorianCalendar::aggregateStamp(int32_t stamp_a, int32_t stamp_b) 
       {
      -    return (((stamp_a != kUnset && stamp_b != kUnset)
      +    return (((stamp_a != kUnset && stamp_b != kUnset) 
               ? uprv_max(stamp_a, stamp_b)
               : (int32_t)kUnset));
       }
      @@ -815,9 +815,9 @@ GregorianCalendar::aggregateStamp(int32_t stamp_a, int32_t stamp_b)
       * Note: This will be made public later. [LIU]
       */
       
      -void
      +void 
       GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status) {
      -    roll((UCalendarDateFields) field, amount, status);
      +    roll((UCalendarDateFields) field, amount, status); 
       }
       
       void
      @@ -904,7 +904,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                                   }
       
           case UCAL_DAY_OF_MONTH:
      -        if( !inCutoverMonth ) {
      +        if( !inCutoverMonth ) { 
                   Calendar::roll(field, amount, status);
                   return;
               } else {
      @@ -919,7 +919,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                       msIntoMonth += monthLen;
                   }
       #if defined (U_DEBUG_CAL)
      -            fprintf(stderr, "%s:%d: roll DOM %d  -> %.0lf ms  \n",
      +            fprintf(stderr, "%s:%d: roll DOM %d  -> %.0lf ms  \n", 
                       __FILE__, __LINE__,amount, cMonthLen, cMonthStart+msIntoMonth);
       #endif
                   setTimeInMillis(cMonthStart + msIntoMonth, status);
      @@ -927,16 +927,16 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
               }
       
           case UCAL_WEEK_OF_MONTH:
      -        if( !inCutoverMonth ) {
      +        if( !inCutoverMonth ) { 
                   Calendar::roll(field, amount, status);
                   return;
               } else {
       #if defined (U_DEBUG_CAL)
      -            fprintf(stderr, "%s:%d: roll WOM %d ??????????????????? \n",
      +            fprintf(stderr, "%s:%d: roll WOM %d ??????????????????? \n", 
                       __FILE__, __LINE__,amount);
       #endif
                   // NOTE: following copied from  the old
      -            //     GregorianCalendar::roll( WEEK_OF_MONTH )  code
      +            //     GregorianCalendar::roll( WEEK_OF_MONTH )  code 
       
                   // This is tricky, because during the roll we may have to shift
                   // to a different day of the week.  For example:
      @@ -974,7 +974,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                   // Normalize the DAY_OF_WEEK so that 0 is the first day of the week
                   // in this locale.  We have dow in 0..6.
                   int32_t dow = internalGet(UCAL_DAY_OF_WEEK) - getFirstDayOfWeek();
      -            if (dow < 0)
      +            if (dow < 0) 
                       dow += 7;
       
                   // Find the day of month, compensating for cutover discontinuity.
      @@ -983,7 +983,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                   // Find the day of the week (normalized for locale) for the first
                   // of the month.
                   int32_t fdm = (dow - dom + 1) % 7;
      -            if (fdm < 0)
      +            if (fdm < 0) 
                       fdm += 7;
       
                   // Get the first day of the first full week of the month,
      @@ -1011,14 +1011,14 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                   // Now roll between start and (limit - 1).
                   int32_t gap = limit - start;
                   int32_t newDom = (dom + amount*7 - start) % gap;
      -            if (newDom < 0)
      +            if (newDom < 0) 
                       newDom += gap;
                   newDom += start;
       
                   // Finally, pin to the real start and end of the month.
      -            if (newDom < 1)
      +            if (newDom < 1) 
                       newDom = 1;
      -            if (newDom > monthLen)
      +            if (newDom > monthLen) 
                       newDom = monthLen;
       
                   // Set the DAY_OF_MONTH.  We rely on the fact that this field
      @@ -1031,7 +1031,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
                   // If we are in the cutover month, manipulate ms directly.  Don't do
                   // this in general because it doesn't work across DST boundaries
                   // (details, details).  This takes care of the discontinuity.
      -            setTimeInMillis(cMonthStart + (newDom-1)*kOneDay, status);
      +            setTimeInMillis(cMonthStart + (newDom-1)*kOneDay, status);                
                   return;
               }
       
      @@ -1212,7 +1212,7 @@ int32_t GregorianCalendar::handleGetExtendedYear() {
               year = handleGetExtendedYearFromWeekFields(internalGet(UCAL_YEAR_WOY), internalGet(UCAL_WEEK_OF_YEAR));
       #if defined (U_DEBUG_CAL)
               //    if(internalGet(UCAL_YEAR_WOY) != year) {
      -        fprintf(stderr, "%s:%d: hGEYFWF[%d,%d] ->  %d\n",
      +        fprintf(stderr, "%s:%d: hGEYFWF[%d,%d] ->  %d\n", 
                   __FILE__, __LINE__,internalGet(UCAL_YEAR_WOY),internalGet(UCAL_WEEK_OF_YEAR),year);
               //}
       #endif
      @@ -1240,7 +1240,7 @@ int32_t GregorianCalendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy,
       UBool
       GregorianCalendar::inDaylightTime(UErrorCode& status) const
       {
      -    if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
      +    if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) 
               return FALSE;
       
           // Force an update of the state of the Calendar.
      @@ -1269,7 +1269,7 @@ GregorianCalendar::getType() const {
       
       /**
        * The system maintains a static default century start date and Year.  They are
      - * initialized the first time they are used.  Once the system default century date
      + * initialized the first time they are used.  Once the system default century date 
        * and year are set, they do not change.
        */
       static UDate           gSystemDefaultCenturyStart       = DBL_MIN;
      diff --git a/deps/icu-small/source/i18n/gregoimp.cpp b/deps/icu-small/source/i18n/gregoimp.cpp
      index cc31e274131906..537aa19d8a40ed 100644
      --- a/deps/icu-small/source/i18n/gregoimp.cpp
      +++ b/deps/icu-small/source/i18n/gregoimp.cpp
      @@ -116,9 +116,9 @@ void Grego::dayToFields(double day, int32_t& year, int32_t& month,
           } else {
               ++year;
           }
      -
      +    
           UBool isLeap = isLeapYear(year);
      -
      +    
           // Gregorian day zero is a Monday.
           dow = (int32_t) uprv_fmod(day + 1, 7);
           dow += (dow < 0) ? (UCAL_SUNDAY + 7) : UCAL_SUNDAY;
      diff --git a/deps/icu-small/source/i18n/gregoimp.h b/deps/icu-small/source/i18n/gregoimp.h
      index eb3844f8523eeb..06eb32384511e4 100644
      --- a/deps/icu-small/source/i18n/gregoimp.h
      +++ b/deps/icu-small/source/i18n/gregoimp.h
      @@ -179,7 +179,7 @@ class Grego {
            * @return the day number, with day 0 == Jan 1 1970
            */
           static double fieldsToDay(int32_t year, int32_t month, int32_t dom);
      -
      +    
           /**
            * Convert a 1970-epoch day number to proleptic Gregorian year,
            * month, day-of-month, and day-of-week.
      @@ -252,9 +252,9 @@ class Grego {
            */
           static inline int32_t millisToJulianDay(double millis);
       
      -    /**
      +    /** 
            * Calculates the Gregorian day shift value for an extended year.
      -     * @param eyear Extended year
      +     * @param eyear Extended year 
            * @returns number of days to ADD to Julian in order to convert from J->G
            */
           static inline int32_t gregorianShift(int32_t eyear);
      diff --git a/deps/icu-small/source/i18n/hebrwcal.cpp b/deps/icu-small/source/i18n/hebrwcal.cpp
      index 66a3e47a4f1e0f..c8fb8a16795868 100644
      --- a/deps/icu-small/source/i18n/hebrwcal.cpp
      +++ b/deps/icu-small/source/i18n/hebrwcal.cpp
      @@ -169,7 +169,7 @@ const char *HebrewCalendar::getType() const {
           return "hebrew";
       }
       
      -Calendar* HebrewCalendar::clone() const {
      +HebrewCalendar* HebrewCalendar::clone() const {
           return new HebrewCalendar(*this);
       }
       
      @@ -187,7 +187,7 @@ HebrewCalendar::HebrewCalendar(const HebrewCalendar& other) : Calendar(other) {
       /**
       * Add a signed amount to a specified field, using this calendar's rules.
       * For example, to add three days to the current date, you can call
      -* add(Calendar.DATE, 3).
      +* add(Calendar.DATE, 3). 
       * 

      * When adding to certain fields, the values of other fields may conflict and * need to be changed. For example, when adding one to the {@link #MONTH MONTH} field @@ -217,7 +217,7 @@ void HebrewCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& return; } switch (field) { - case UCAL_MONTH: + case UCAL_MONTH: { // We can't just do a set(MONTH, get(MONTH) + amount). The // reason is ADAR_1. Suppose amount is +2 and we land in @@ -281,7 +281,7 @@ void HebrewCalendar::add(EDateFields field, int32_t amount, UErrorCode& status) * example, to roll the current date up by three days, you can call * roll(Calendar.DATE, 3). If the * field is rolled past its maximum allowable value, it will "wrap" back -* to its minimum and continue rolling. +* to its minimum and continue rolling. * For example, calling roll(Calendar.DATE, 10) * on a Hebrew calendar set to "25 Av 5758" will result in the date "5 Av 5758". *

      @@ -553,7 +553,7 @@ void HebrewCalendar::validateField(UCalendarDateFields field, UErrorCode &status *

    • DAY_OF_MONTH *
    • DAY_OF_YEAR *
    • EXTENDED_YEAR
    -* +* * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, * which will be set when this method is called. Subclasses can * also call the getGregorianXxx() methods to obtain Gregorian @@ -608,7 +608,7 @@ void HebrewCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) internalSet(UCAL_EXTENDED_YEAR, year); internalSet(UCAL_MONTH, month); internalSet(UCAL_DAY_OF_MONTH, dayOfMonth); - internalSet(UCAL_DAY_OF_YEAR, dayOfYear); + internalSet(UCAL_DAY_OF_YEAR, dayOfYear); } //------------------------------------------------------------------------- @@ -669,7 +669,7 @@ UBool HebrewCalendar::inDaylightTime(UErrorCode& status) const { // copied from GregorianCalendar - if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) + if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) return FALSE; // Force an update of the state of the Calendar. @@ -680,7 +680,7 @@ HebrewCalendar::inDaylightTime(UErrorCode& status) const /** * The system maintains a static default century start date and Year. They are - * initialized the first time they are used. Once the system default century date + * initialized the first time they are used. Once the system default century date * and year are set, they do not change. */ static UDate gSystemDefaultCenturyStart = DBL_MIN; @@ -729,3 +729,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HebrewCalendar) U_NAMESPACE_END #endif // UCONFIG_NO_FORMATTING + diff --git a/deps/icu-small/source/i18n/hebrwcal.h b/deps/icu-small/source/i18n/hebrwcal.h index 9323ad62aa72fa..08136de32a936e 100644 --- a/deps/icu-small/source/i18n/hebrwcal.h +++ b/deps/icu-small/source/i18n/hebrwcal.h @@ -89,26 +89,26 @@ class U_I18N_API HebrewCalendar : public Calendar { * @internal */ enum EEras { - /** - * Constant for Tishri, the 1st month of the Hebrew year. + /** + * Constant for Tishri, the 1st month of the Hebrew year. */ TISHRI, /** - * Constant for Heshvan, the 2nd month of the Hebrew year. + * Constant for Heshvan, the 2nd month of the Hebrew year. */ HESHVAN, /** - * Constant for Kislev, the 3rd month of the Hebrew year. + * Constant for Kislev, the 3rd month of the Hebrew year. */ KISLEV, /** - * Constant for Tevet, the 4th month of the Hebrew year. + * Constant for Tevet, the 4th month of the Hebrew year. */ TEVET, /** - * Constant for Shevat, the 5th month of the Hebrew year. + * Constant for Shevat, the 5th month of the Hebrew year. */ SHEVAT, @@ -119,38 +119,38 @@ class U_I18N_API HebrewCalendar : public Calendar { */ ADAR_1, - /** - * Constant for the Adar, the 7th month of the Hebrew year. + /** + * Constant for the Adar, the 7th month of the Hebrew year. */ ADAR, /** - * Constant for Nisan, the 8th month of the Hebrew year. + * Constant for Nisan, the 8th month of the Hebrew year. */ NISAN, /** - * Constant for Iyar, the 9th month of the Hebrew year. + * Constant for Iyar, the 9th month of the Hebrew year. */ IYAR, /** - * Constant for Sivan, the 10th month of the Hebrew year. + * Constant for Sivan, the 10th month of the Hebrew year. */ SIVAN, /** - * Constant for Tammuz, the 11th month of the Hebrew year. + * Constant for Tammuz, the 11th month of the Hebrew year. */ TAMUZ, /** - * Constant for Av, the 12th month of the Hebrew year. + * Constant for Av, the 12th month of the Hebrew year. */ AV, /** - * Constant for Elul, the 13th month of the Hebrew year. + * Constant for Elul, the 13th month of the Hebrew year. */ ELUL }; @@ -192,8 +192,8 @@ class U_I18N_API HebrewCalendar : public Calendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; - + virtual HebrewCalendar* clone() const; + public: /** * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual @@ -276,7 +276,7 @@ class U_I18N_API HebrewCalendar : public Calendar { virtual void roll(EDateFields field, int32_t amount, UErrorCode& status); /** - * @internal + * @internal */ static UBool isLeapYear(int32_t year) ; @@ -431,14 +431,14 @@ class U_I18N_API HebrewCalendar : public Calendar { static int32_t startOfYear(int32_t year, UErrorCode& status); static int32_t absoluteDayToDayOfWeek(int32_t day) ; - + /** - * @internal + * @internal */ int32_t yearType(int32_t year) const; /** - * @internal + * @internal */ static int32_t monthsInYear(int32_t year) ; }; @@ -447,5 +447,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif +#endif //eof + diff --git a/deps/icu-small/source/i18n/i18n.rc b/deps/icu-small/source/i18n/i18n.rc index 62fcbc738dd6f3..c31ef3ad5f78cd 100644 --- a/deps/icu-small/source/i18n/i18n.rc +++ b/deps/icu-small/source/i18n/i18n.rc @@ -18,7 +18,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// +// LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252) @@ -29,17 +29,17 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "../common/msvcres.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include \0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -107,3 +107,4 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + diff --git a/deps/icu-small/source/i18n/indiancal.cpp b/deps/icu-small/source/i18n/indiancal.cpp index 667b6f2d7a32c5..f1ab853b948c15 100644 --- a/deps/icu-small/source/i18n/indiancal.cpp +++ b/deps/icu-small/source/i18n/indiancal.cpp @@ -35,7 +35,7 @@ U_NAMESPACE_BEGIN //------------------------------------------------------------------------- -Calendar* IndianCalendar::clone() const { +IndianCalendar* IndianCalendar::clone() const { return new IndianCalendar(*this); } @@ -51,10 +51,10 @@ IndianCalendar::IndianCalendar(const IndianCalendar& other) : Calendar(other) { IndianCalendar::~IndianCalendar() { } -const char *IndianCalendar::getType() const { +const char *IndianCalendar::getType() const { return "indian"; } - + static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = { // Minimum Greatest Least Maximum // Minimum Maximum @@ -92,13 +92,13 @@ int32_t IndianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType lim } /* - * Determine whether the given gregorian year is a Leap year + * Determine whether the given gregorian year is a Leap year */ static UBool isGregorianLeap(int32_t year) { - return ((year % 4) == 0) && (!(((year % 100) == 0) && ((year % 400) != 0))); + return ((year % 4) == 0) && (!(((year % 100) == 0) && ((year % 400) != 0))); } - + //---------------------------------------------------------------------- // Calendar framework //---------------------------------------------------------------------- @@ -190,7 +190,7 @@ static int32_t* jdToGregorian(double jd, int32_t gregorianDate[3]) { return gregorianDate; } - + //------------------------------------------------------------------------- // Functions for converting from field values to milliseconds.... //------------------------------------------------------------------------- @@ -204,7 +204,7 @@ static double IndianToJD(int32_t year, int32_t month, int32_t date) { if(isGregorianLeap(gyear)) { leapMonth = 31; start = gregorianToJD(gyear, 3, 21); - } + } else { leapMonth = 30; start = gregorianToJD(gyear, 3, 22); @@ -240,7 +240,7 @@ static double IndianToJD(int32_t year, int32_t month, int32_t date) { */ int32_t IndianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UBool /* useMonth */ ) const { - //month is 0 based; converting it to 1-based + //month is 0 based; converting it to 1-based int32_t imonth; // If the month is out of range, adjust it into range, and adjust the extended eyar accordingly @@ -251,9 +251,9 @@ int32_t IndianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UB if(month == 12){ imonth = 1; } else { - imonth = month + 1; + imonth = month + 1; } - + double jd = IndianToJD(eyear ,imonth, 1); return (int32_t)jd; @@ -284,7 +284,7 @@ int32_t IndianCalendar::handleGetExtendedYear() { *
  5. MONTH *
  6. DAY_OF_MONTH *
  7. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -331,7 +331,7 @@ void IndianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& /* stat internalSet(UCAL_MONTH, IndianMonth); internalSet(UCAL_DAY_OF_MONTH, IndianDayOfMonth); internalSet(UCAL_DAY_OF_YEAR, yday + 1); // yday is 0-based -} +} UBool IndianCalendar::inDaylightTime(UErrorCode& status) const @@ -408,3 +408,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndianCalendar) U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/indiancal.h b/deps/icu-small/source/i18n/indiancal.h index ffd4ae8b8a40cd..e259d9bc174210 100644 --- a/deps/icu-small/source/i18n/indiancal.h +++ b/deps/icu-small/source/i18n/indiancal.h @@ -75,28 +75,28 @@ class U_I18N_API IndianCalendar : public Calendar { * @internal */ enum EEras { - /** - * Constant for Chaitra, the 1st month of the Indian year. + /** + * Constant for Chaitra, the 1st month of the Indian year. */ CHAITRA, /** - * Constant for Vaisakha, the 2nd month of the Indian year. + * Constant for Vaisakha, the 2nd month of the Indian year. */ VAISAKHA, /** - * Constant for Jyaistha, the 3rd month of the Indian year. + * Constant for Jyaistha, the 3rd month of the Indian year. */ JYAISTHA, /** - * Constant for Asadha, the 4th month of the Indian year. + * Constant for Asadha, the 4th month of the Indian year. */ ASADHA, /** - * Constant for Sravana, the 5th month of the Indian year. + * Constant for Sravana, the 5th month of the Indian year. */ SRAVANA, @@ -105,33 +105,33 @@ class U_I18N_API IndianCalendar : public Calendar { */ BHADRA, - /** - * Constant for the Asvina, the 7th month of the Indian year. + /** + * Constant for the Asvina, the 7th month of the Indian year. */ ASVINA, /** - * Constant for Kartika, the 8th month of the Indian year. + * Constant for Kartika, the 8th month of the Indian year. */ KARTIKA, /** - * Constant for Agrahayana, the 9th month of the Indian year. + * Constant for Agrahayana, the 9th month of the Indian year. */ AGRAHAYANA, /** - * Constant for Pausa, the 10th month of the Indian year. + * Constant for Pausa, the 10th month of the Indian year. */ PAUSA, /** - * Constant for Magha, the 11th month of the Indian year. + * Constant for Magha, the 11th month of the Indian year. */ MAGHA, /** - * Constant for Phalguna, the 12th month of the Indian year. + * Constant for Phalguna, the 12th month of the Indian year. */ PHALGUNA }; @@ -173,7 +173,7 @@ class U_I18N_API IndianCalendar : public Calendar { * @internal */ //void setCivil(ECivil beCivil, UErrorCode &status); - + /** * Returns true if this object is using the fixed-cycle civil * calendar, or false if using the religious, astronomical @@ -186,11 +186,11 @@ class U_I18N_API IndianCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual IndianCalendar* clone() const; private: /** - * Determine whether a year is the gregorian year a leap year + * Determine whether a year is the gregorian year a leap year */ //static UBool isGregorianLeap(int32_t year); //---------------------------------------------------------------------- @@ -201,7 +201,7 @@ class U_I18N_API IndianCalendar : public Calendar { * @internal */ virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; - + /** * Return the length (in days) of the given month. * @@ -210,7 +210,7 @@ class U_I18N_API IndianCalendar : public Calendar { * @internal */ virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const; - + /** * Return the number of days in the given Indian year * @internal @@ -246,7 +246,7 @@ class U_I18N_API IndianCalendar : public Calendar { *
  8. DAY_OF_MONTH *
  9. DAY_OF_YEAR *
  10. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -255,7 +255,7 @@ class U_I18N_API IndianCalendar : public Calendar { virtual void handleComputeFields(int32_t julianDay, UErrorCode &status); // UObject stuff - public: + public: /** * @return The class ID for this object. All objects of a given class have the * same class ID. Objects of other classes have different class IDs. @@ -326,3 +326,6 @@ U_NAMESPACE_END #endif #endif + + + diff --git a/deps/icu-small/source/i18n/inputext.cpp b/deps/icu-small/source/i18n/inputext.cpp index 96e59b24d878ff..2d4f8a388af612 100644 --- a/deps/icu-small/source/i18n/inputext.cpp +++ b/deps/icu-small/source/i18n/inputext.cpp @@ -68,7 +68,7 @@ void InputText::setDeclaredEncoding(const char* encoding, int32_t len) } } -UBool InputText::isSet() const +UBool InputText::isSet() const { return fRawInput != NULL; } @@ -76,7 +76,7 @@ UBool InputText::isSet() const /** * MungeInput - after getting a set of raw input data to be analyzed, preprocess * it by removing what appears to be html markup. -* +* * @internal */ void InputText::MungeInput(UBool fStripTags) { @@ -124,7 +124,7 @@ void InputText::MungeInput(UBool fStripTags) { // essentially nothing but markup abandon the markup stripping. // Detection will have to work on the unstripped input. // - if (openTags<5 || openTags/5 < badTags || + if (openTags<5 || openTags/5 < badTags || (fInputLen < 100 && fRawLength>600)) { int32_t limit = fRawLength; @@ -161,3 +161,4 @@ void InputText::MungeInput(UBool fStripTags) { U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/inputext.h b/deps/icu-small/source/i18n/inputext.h index 06ad627c622d47..8edc561fc64bcc 100644 --- a/deps/icu-small/source/i18n/inputext.h +++ b/deps/icu-small/source/i18n/inputext.h @@ -23,7 +23,7 @@ #if !UCONFIG_NO_CONVERSION -U_NAMESPACE_BEGIN +U_NAMESPACE_BEGIN class InputText : public UMemory { @@ -35,7 +35,7 @@ class InputText : public UMemory void setText(const char *in, int32_t len); void setDeclaredEncoding(const char *encoding, int32_t len); - UBool isSet() const; + UBool isSet() const; void MungeInput(UBool fStripTags); // The text to be checked. Markup will have been @@ -44,14 +44,14 @@ class InputText : public UMemory int32_t fInputLen; // Length of the byte data in fInputBytes. // byte frequency statistics for the input text. // Value is percent, not absolute. - // Value is rounded up, so zero really means zero occurences. + // Value is rounded up, so zero really means zero occurences. int16_t *fByteStats; UBool fC1Bytes; // True if any bytes in the range 0x80 - 0x9F are in the input;false by default char *fDeclaredEncoding; const uint8_t *fRawInput; // Original, untouched input bytes. // If user gave us a byte array, this is it. - // If user gave us a stream, it's read to a + // If user gave us a stream, it's read to a // buffer here. int32_t fRawLength; // Length of data in fRawInput array. diff --git a/deps/icu-small/source/i18n/islamcal.cpp b/deps/icu-small/source/i18n/islamcal.cpp index 8d6171af011e5d..582b3365a64aca 100644 --- a/deps/icu-small/source/i18n/islamcal.cpp +++ b/deps/icu-small/source/i18n/islamcal.cpp @@ -227,7 +227,7 @@ const char *IslamicCalendar::getType() const { return sType; } -Calendar* IslamicCalendar::clone() const { +IslamicCalendar* IslamicCalendar::clone() const { return new IslamicCalendar(*this); } @@ -366,7 +366,7 @@ UBool IslamicCalendar::civilLeapYear(int32_t year) */ int32_t IslamicCalendar::yearStart(int32_t year) const{ if (cType == CIVIL || cType == TBLA || - (cType == UMALQURA && (year < UMALQURA_YEAR_START || year > UMALQURA_YEAR_END))) + (cType == UMALQURA && (year < UMALQURA_YEAR_START || year > UMALQURA_YEAR_END))) { return (year-1)*354 + ClockMath::floorDivide((3+11*year),30); } else if(cType==ASTRONOMICAL){ @@ -418,7 +418,7 @@ int32_t IslamicCalendar::trueMonthStart(int32_t month) const if (start==0) { // Make a guess at when the month started, using the average length - UDate origin = HIJRA_MILLIS + UDate origin = HIJRA_MILLIS + uprv_floor(month * CalendarAstronomer::SYNODIC_MONTH) * kOneDay; // moonAge will fail due to memory allocation error @@ -460,7 +460,7 @@ trueMonthStartEnd : /** * Return the "age" of the moon at the given time; this is the difference * in ecliptic latitude between the moon and the sun. This method simply -* calls CalendarAstronomer.moonAge, converts to degrees, +* calls CalendarAstronomer.moonAge, converts to degrees, * and adjusts the result to be in the range [-180, 180]. * * @param time The time at which the moon's age is desired, @@ -470,7 +470,7 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status) { double age = 0; - static UMutex astroLock = U_MUTEX_INITIALIZER; // pod bay door lock + static UMutex astroLock; // pod bay door lock umtx_lock(&astroLock); if(gIslamicCalendarAstro == NULL) { gIslamicCalendarAstro = new CalendarAstronomer(); @@ -567,7 +567,7 @@ int32_t IslamicCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U month = (month % 12) + 11; } return monthStart(eyear, month) + ((cType == TBLA)? ASTRONOMICAL_EPOC: CIVIL_EPOC) - 1; -} +} //------------------------------------------------------------------------- // Functions for converting from milliseconds to field values @@ -596,7 +596,7 @@ int32_t IslamicCalendar::handleGetExtendedYear() { *
  11. DAY_OF_MONTH *
  12. DAY_OF_YEAR *
  13. EXTENDED_YEAR -* +* * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -652,14 +652,14 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) }else{ int y =UMALQURA_YEAR_START-1, m =0; long d = 1; - while(d > 0){ - y++; + while(d > 0){ + y++; d = days - yearStart(y) +1; if(d == handleGetYearLength(y)){ m=11; break; }else if(d < handleGetYearLength(y) ){ - int monthLen = handleGetMonthLength(y, m); + int monthLen = handleGetMonthLength(y, m); m=0; while(d > monthLen){ d -= monthLen; @@ -687,14 +687,14 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) internalSet(UCAL_EXTENDED_YEAR, year); internalSet(UCAL_MONTH, month); internalSet(UCAL_DAY_OF_MONTH, dayOfMonth); - internalSet(UCAL_DAY_OF_YEAR, dayOfYear); -} + internalSet(UCAL_DAY_OF_YEAR, dayOfYear); +} UBool IslamicCalendar::inDaylightTime(UErrorCode& status) const { // copied from GregorianCalendar - if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) + if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) return FALSE; // Force an update of the state of the Calendar. @@ -705,7 +705,7 @@ IslamicCalendar::inDaylightTime(UErrorCode& status) const /** * The system maintains a static default century start date and Year. They are - * initialized the first time they are used. Once the system default century date + * initialized the first time they are used. Once the system default century date * and year are set, they do not change. */ static UDate gSystemDefaultCenturyStart = DBL_MIN; @@ -759,3 +759,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicCalendar) U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/islamcal.h b/deps/icu-small/source/i18n/islamcal.h index 17fb6687ef7b63..fde58478c0ab02 100644 --- a/deps/icu-small/source/i18n/islamcal.h +++ b/deps/icu-small/source/i18n/islamcal.h @@ -32,7 +32,7 @@ U_NAMESPACE_BEGIN * is used as the civil calendar in most of the Arab world and the * liturgical calendar of the Islamic faith worldwide. This calendar * is also known as the "Hijri" calendar, since it starts at the time - * of Mohammed's emigration (or "hijra") to Medinah on Thursday, + * of Mohammed's emigration (or "hijra") to Medinah on Thursday, * July 15, 622 AD (Julian). *

    * The Islamic calendar is strictly lunar, and thus an Islamic year of twelve @@ -88,10 +88,10 @@ class U_I18N_API IslamicCalendar : public Calendar { //------------------------------------------------------------------------- // Constants... //------------------------------------------------------------------------- - + /** * Calendar type - civil or religious or um alqura - * @internal + * @internal */ enum ECalculationType { ASTRONOMICAL, @@ -99,86 +99,86 @@ class U_I18N_API IslamicCalendar : public Calendar { UMALQURA, TBLA }; - + /** * Constants for the months * @internal */ enum EMonths { /** - * Constant for Muharram, the 1st month of the Islamic year. + * Constant for Muharram, the 1st month of the Islamic year. * @internal */ MUHARRAM = 0, /** - * Constant for Safar, the 2nd month of the Islamic year. + * Constant for Safar, the 2nd month of the Islamic year. * @internal */ SAFAR = 1, /** - * Constant for Rabi' al-awwal (or Rabi' I), the 3rd month of the Islamic year. - * @internal + * Constant for Rabi' al-awwal (or Rabi' I), the 3rd month of the Islamic year. + * @internal */ RABI_1 = 2, /** - * Constant for Rabi' al-thani or (Rabi' II), the 4th month of the Islamic year. - * @internal + * Constant for Rabi' al-thani or (Rabi' II), the 4th month of the Islamic year. + * @internal */ RABI_2 = 3, /** - * Constant for Jumada al-awwal or (Jumada I), the 5th month of the Islamic year. - * @internal + * Constant for Jumada al-awwal or (Jumada I), the 5th month of the Islamic year. + * @internal */ JUMADA_1 = 4, /** - * Constant for Jumada al-thani or (Jumada II), the 6th month of the Islamic year. - * @internal + * Constant for Jumada al-thani or (Jumada II), the 6th month of the Islamic year. + * @internal */ JUMADA_2 = 5, /** - * Constant for Rajab, the 7th month of the Islamic year. - * @internal + * Constant for Rajab, the 7th month of the Islamic year. + * @internal */ RAJAB = 6, /** - * Constant for Sha'ban, the 8th month of the Islamic year. - * @internal + * Constant for Sha'ban, the 8th month of the Islamic year. + * @internal */ SHABAN = 7, /** - * Constant for Ramadan, the 9th month of the Islamic year. - * @internal + * Constant for Ramadan, the 9th month of the Islamic year. + * @internal */ RAMADAN = 8, /** - * Constant for Shawwal, the 10th month of the Islamic year. - * @internal + * Constant for Shawwal, the 10th month of the Islamic year. + * @internal */ SHAWWAL = 9, /** - * Constant for Dhu al-Qi'dah, the 11th month of the Islamic year. - * @internal + * Constant for Dhu al-Qi'dah, the 11th month of the Islamic year. + * @internal */ DHU_AL_QIDAH = 10, /** - * Constant for Dhu al-Hijjah, the 12th month of the Islamic year. - * @internal + * Constant for Dhu al-Hijjah, the 12th month of the Islamic year. + * @internal */ DHU_AL_HIJJAH = 11, - + ISLAMIC_MONTH_MAX - }; + }; //------------------------------------------------------------------------- @@ -217,7 +217,7 @@ class U_I18N_API IslamicCalendar : public Calendar { * @internal */ void setCalculationType(ECalculationType type, UErrorCode &status); - + /** * Returns true if this object is using the fixed-cycle civil * calendar, or false if using the religious, astronomical @@ -230,14 +230,14 @@ class U_I18N_API IslamicCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual IslamicCalendar* clone() const; private: /** * Determine whether a year is a leap year in the Islamic civil calendar */ static UBool civilLeapYear(int32_t year); - + /** * Return the day # on which the given year starts. Days are counted * from the Hijri epoch, origin 0. @@ -252,7 +252,7 @@ class U_I18N_API IslamicCalendar : public Calendar { * @param year The hijri month, 0-based */ int32_t monthStart(int32_t year, int32_t month) const; - + /** * Find the day number on which a particular month of the true/lunar * Islamic calendar starts. @@ -266,7 +266,7 @@ class U_I18N_API IslamicCalendar : public Calendar { /** * Return the "age" of the moon at the given time; this is the difference * in ecliptic latitude between the moon and the sun. This method simply - * calls CalendarAstronomer.moonAge, converts to degrees, + * calls CalendarAstronomer.moonAge, converts to degrees, * and adjusts the resultto be in the range [-180, 180]. * * @param time The time at which the moon's age is desired, @@ -277,7 +277,7 @@ class U_I18N_API IslamicCalendar : public Calendar { //------------------------------------------------------------------------- // Internal data.... // - + /** * CIVIL if this object uses the fixed-cycle Islamic civil calendar, * and ASTRONOMICAL if it approximates the true religious calendar using @@ -293,7 +293,7 @@ class U_I18N_API IslamicCalendar : public Calendar { * @internal */ virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; - + /** * Return the length (in days) of the given month. * @@ -302,13 +302,13 @@ class U_I18N_API IslamicCalendar : public Calendar { * @internal */ virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const; - + /** * Return the number of days in the given Islamic year * @internal */ virtual int32_t handleGetYearLength(int32_t extendedYear) const; - + //------------------------------------------------------------------------- // Functions for converting from field values to milliseconds.... //------------------------------------------------------------------------- @@ -338,7 +338,7 @@ class U_I18N_API IslamicCalendar : public Calendar { *

  14. DAY_OF_MONTH *
  15. DAY_OF_YEAR *
  16. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -347,7 +347,7 @@ class U_I18N_API IslamicCalendar : public Calendar { virtual void handleComputeFields(int32_t julianDay, UErrorCode &status); // UObject stuff - public: + public: /** * @return The class ID for this object. All objects of a given class have the * same class ID. Objects of other classes have different class IDs. @@ -426,3 +426,6 @@ U_NAMESPACE_END #endif #endif + + + diff --git a/deps/icu-small/source/i18n/japancal.cpp b/deps/icu-small/source/i18n/japancal.cpp index cc061fd1410d84..75a248f406ffe1 100644 --- a/deps/icu-small/source/i18n/japancal.cpp +++ b/deps/icu-small/source/i18n/japancal.cpp @@ -136,7 +136,7 @@ JapaneseCalendar& JapaneseCalendar::operator= ( const JapaneseCalendar& right) return *this; } -Calendar* JapaneseCalendar::clone(void) const +JapaneseCalendar* JapaneseCalendar::clone() const { return new JapaneseCalendar(*this); } @@ -146,7 +146,7 @@ const char *JapaneseCalendar::getType() const return "japanese"; } -int32_t JapaneseCalendar::getDefaultMonthInYear(int32_t eyear) +int32_t JapaneseCalendar::getDefaultMonthInYear(int32_t eyear) { int32_t era = internalGetEra(); // TODO do we assume we can trust 'era'? What if it is denormalized? @@ -167,7 +167,7 @@ int32_t JapaneseCalendar::getDefaultMonthInYear(int32_t eyear) return month; } -int32_t JapaneseCalendar::getDefaultDayInMonth(int32_t eyear, int32_t month) +int32_t JapaneseCalendar::getDefaultDayInMonth(int32_t eyear, int32_t month) { int32_t era = internalGetEra(); int32_t day = 1; @@ -226,7 +226,7 @@ void JapaneseCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status } /* -Disable pivoting +Disable pivoting */ UBool JapaneseCalendar::haveDefaultCentury() const { diff --git a/deps/icu-small/source/i18n/japancal.h b/deps/icu-small/source/i18n/japancal.h index a32f3db5635473..03e6361c9f9a52 100644 --- a/deps/icu-small/source/i18n/japancal.h +++ b/deps/icu-small/source/i18n/japancal.h @@ -43,7 +43,7 @@ U_NAMESPACE_BEGIN * of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest * of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class * handles this distinction correctly when computing dates. However, in lenient - * mode either form of date is acceptable as input. + * mode either form of date is acceptable as input. *

    * In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji), * July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants @@ -67,7 +67,7 @@ class JapaneseCalendar : public GregorianCalendar { public: /** - * Check environment variable. + * Check environment variable. * @internal */ U_I18N_API static UBool U_EXPORT2 enableTentativeEra(void); @@ -116,10 +116,10 @@ class JapaneseCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual JapaneseCalendar* clone() const; /** - * Return the extended year defined by the current fields. In the + * Return the extended year defined by the current fields. In the * Japanese calendar case, this is equal to the equivalent extended Gregorian year. * @internal */ @@ -168,7 +168,7 @@ class JapaneseCalendar : public GregorianCalendar { /** * @return FALSE - no default century in Japanese - * @internal + * @internal */ virtual UBool haveDefaultCentury() const; @@ -187,7 +187,7 @@ class JapaneseCalendar : public GregorianCalendar { JapaneseCalendar(); // default constructor not implemented protected: - /** + /** * Calculate the era for internal computation * @internal */ @@ -207,7 +207,7 @@ class JapaneseCalendar : public GregorianCalendar { /*** * Called by computeJulianDay. Returns the default month (0-based) for the year, - * taking year and era into account. Will return the first month of the given era, if + * taking year and era into account. Will return the first month of the given era, if * the current year is an ascension year. * @param eyear the extended year * @internal @@ -231,3 +231,4 @@ U_NAMESPACE_END #endif //eof + diff --git a/deps/icu-small/source/i18n/listformatter.cpp b/deps/icu-small/source/i18n/listformatter.cpp index 64d2e36ae15059..2ee5e123749c7d 100644 --- a/deps/icu-small/source/i18n/listformatter.cpp +++ b/deps/icu-small/source/i18n/listformatter.cpp @@ -144,7 +144,7 @@ const ListFormatInternal* ListFormatter::getListFormatInternal( keyBuffer.append(':', errorCode).append(style, errorCode); UnicodeString key(keyBuffer.data(), -1, US_INV); ListFormatInternal* result = nullptr; - static UMutex listFormatterMutex = U_MUTEX_INITIALIZER; + static UMutex listFormatterMutex; { Mutex m(&listFormatterMutex); if (listPatternHash == nullptr) { @@ -478,8 +478,8 @@ UnicodeString& ListFormatter::format_( if (index == 0) { offset = 0; } - int32_t offsetFirst; - int32_t offsetSecond; + int32_t offsetFirst = 0; + int32_t offsetSecond = 0; int32_t prefixLength = 0; // for n items, there are 2 * (n + 1) boundary including 0 and the upper // edge. @@ -569,7 +569,7 @@ UnicodeString& ListFormatter::format_( } appendTo += result; } -#endif +#endif return appendTo; } diff --git a/deps/icu-small/source/i18n/measfmt.cpp b/deps/icu-small/source/i18n/measfmt.cpp index 03e4417e64da6a..1949f17b13723d 100644 --- a/deps/icu-small/source/i18n/measfmt.cpp +++ b/deps/icu-small/source/i18n/measfmt.cpp @@ -55,28 +55,23 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureFormat) class NumericDateFormatters : public UMemory { public: // Formats like H:mm - SimpleDateFormat hourMinute; + UnicodeString hourMinute; // formats like M:ss - SimpleDateFormat minuteSecond; + UnicodeString minuteSecond; // formats like H:mm:ss - SimpleDateFormat hourMinuteSecond; + UnicodeString hourMinuteSecond; // Constructor that takes the actual patterns for hour-minute, // minute-second, and hour-minute-second respectively. NumericDateFormatters( const UnicodeString &hm, const UnicodeString &ms, - const UnicodeString &hms, - UErrorCode &status) : - hourMinute(hm, status), - minuteSecond(ms, status), - hourMinuteSecond(hms, status) { - const TimeZone *gmt = TimeZone::getGMT(); - hourMinute.setTimeZone(*gmt); - minuteSecond.setTimeZone(*gmt); - hourMinuteSecond.setTimeZone(*gmt); + const UnicodeString &hms) : + hourMinute(hm), + minuteSecond(ms), + hourMinuteSecond(hms) { } private: NumericDateFormatters(const NumericDateFormatters &other); @@ -233,8 +228,7 @@ static NumericDateFormatters *loadNumericDateFormatters( NumericDateFormatters *result = new NumericDateFormatters( loadNumericDateFormatterPattern(resource, "hm", status), loadNumericDateFormatterPattern(resource, "ms", status), - loadNumericDateFormatterPattern(resource, "hms", status), - status); + loadNumericDateFormatterPattern(resource, "hms", status)); if (U_FAILURE(status)) { delete result; return NULL; @@ -367,7 +361,7 @@ MeasureFormat::MeasureFormat( const Locale &locale, UMeasureFormatWidth w, NumberFormat *nfToAdopt, - UErrorCode &status) + UErrorCode &status) : cache(NULL), numberFormat(NULL), pluralRules(NULL), @@ -466,7 +460,7 @@ UBool MeasureFormat::operator==(const Format &other) const { **numberFormat == **rhs.numberFormat); } -Format *MeasureFormat::clone() const { +MeasureFormat *MeasureFormat::clone() const { return new MeasureFormat(*this); } @@ -647,7 +641,7 @@ UBool MeasureFormat::setMeasureFormatLocale(const Locale &locale, UErrorCode &st } initMeasureFormat(locale, fWidth, NULL, status); return U_SUCCESS(status); -} +} const NumberFormat &MeasureFormat::getNumberFormatInternal() const { return **numberFormat; @@ -691,9 +685,19 @@ UnicodeString &MeasureFormat::formatMeasure( } auto* df = dynamic_cast(&nf); if (df == nullptr) { - // Don't know how to handle other types of NumberFormat - status = U_UNSUPPORTED_ERROR; - return appendTo; + // Handle other types of NumberFormat using the ICU 63 code, modified to + // get the unitPattern from LongNameHandler and handle fallback to OTHER. + UnicodeString formattedNumber; + StandardPlural::Form pluralForm = QuantityFormatter::selectPlural( + amtNumber, nf, **pluralRules, formattedNumber, pos, status); + UnicodeString pattern = number::impl::LongNameHandler::getUnitPattern(getLocale(status), + amtUnit, getUnitWidth(fWidth), pluralForm, status); + // The above handles fallback from other widths to short, and from other plural forms to OTHER + if (U_FAILURE(status)) { + return appendTo; + } + SimpleFormatter formatter(pattern, 0, 1, status); + return QuantityFormatter::format(formatter, formattedNumber, appendTo, pos, status); } number::FormattedNumber result; if (auto* lnf = df->toNumberFormatter(status)) { @@ -706,135 +710,112 @@ UnicodeString &MeasureFormat::formatMeasure( return appendTo; } -// Formats hours-minutes-seconds as 5:37:23 or similar. + +// Formats numeric time duration as 5:00:47 or 3:54. UnicodeString &MeasureFormat::formatNumeric( const Formattable *hms, // always length 3 - int32_t bitMap, // 1=hourset, 2=minuteset, 4=secondset + int32_t bitMap, // 1=hour set, 2=minute set, 4=second set UnicodeString &appendTo, UErrorCode &status) const { if (U_FAILURE(status)) { return appendTo; } - UDate millis = - (UDate) (((uprv_trunc(hms[0].getDouble(status)) * 60.0 - + uprv_trunc(hms[1].getDouble(status))) * 60.0 - + uprv_trunc(hms[2].getDouble(status))) * 1000.0); - switch (bitMap) { - case 5: // hs - case 7: // hms - return formatNumeric( - millis, - cache->getNumericDateFormatters()->hourMinuteSecond, - UDAT_SECOND_FIELD, - hms[2], - appendTo, - status); - break; - case 6: // ms - return formatNumeric( - millis, - cache->getNumericDateFormatters()->minuteSecond, - UDAT_SECOND_FIELD, - hms[2], - appendTo, - status); - break; - case 3: // hm - return formatNumeric( - millis, - cache->getNumericDateFormatters()->hourMinute, - UDAT_MINUTE_FIELD, - hms[1], - appendTo, - status); - break; - default: - status = U_INTERNAL_PROGRAM_ERROR; - return appendTo; - break; - } -} -static void appendRange( - const UnicodeString &src, - int32_t start, - int32_t end, - UnicodeString &dest) { - dest.append(src, start, end - start); -} + UnicodeString pattern; -static void appendRange( - const UnicodeString &src, - int32_t end, - UnicodeString &dest) { - dest.append(src, end, src.length() - end); -} - -// Formats time like 5:37:23 -UnicodeString &MeasureFormat::formatNumeric( - UDate date, // Time since epoch 1:30:00 would be 5400000 - const DateFormat &dateFmt, // h:mm, m:ss, or h:mm:ss - UDateFormatField smallestField, // seconds in 5:37:23.5 - const Formattable &smallestAmount, // 23.5 for 5:37:23.5 - UnicodeString &appendTo, - UErrorCode &status) const { + double hours = hms[0].getDouble(status); + double minutes = hms[1].getDouble(status); + double seconds = hms[2].getDouble(status); if (U_FAILURE(status)) { return appendTo; } - // Format the smallest amount with this object's NumberFormat - UnicodeString smallestAmountFormatted; - - // We keep track of the integer part of smallest amount so that - // we can replace it later so that we get '0:00:09.3' instead of - // '0:00:9.3' - FieldPosition intFieldPosition(UNUM_INTEGER_FIELD); - (*numberFormat)->format( - smallestAmount, smallestAmountFormatted, intFieldPosition, status); - if ( - intFieldPosition.getBeginIndex() == 0 && - intFieldPosition.getEndIndex() == 0) { + + // All possible combinations: "h", "m", "s", "hm", "hs", "ms", "hms" + if (bitMap == 5 || bitMap == 7) { // "hms" & "hs" (we add minutes if "hs") + pattern = cache->getNumericDateFormatters()->hourMinuteSecond; + hours = uprv_trunc(hours); + minutes = uprv_trunc(minutes); + } else if (bitMap == 3) { // "hm" + pattern = cache->getNumericDateFormatters()->hourMinute; + hours = uprv_trunc(hours); + } else if (bitMap == 6) { // "ms" + pattern = cache->getNumericDateFormatters()->minuteSecond; + minutes = uprv_trunc(minutes); + } else { // h m s, handled outside formatNumeric. No value is also an error. status = U_INTERNAL_PROGRAM_ERROR; return appendTo; } - // Format time. draft becomes something like '5:30:45' - // #13606: DateFormat is not thread-safe, but MeasureFormat advertises itself as thread-safe. - FieldPosition smallestFieldPosition(smallestField); - UnicodeString draft; - static UMutex dateFmtMutex = U_MUTEX_INITIALIZER; - umtx_lock(&dateFmtMutex); - dateFmt.format(date, draft, smallestFieldPosition, status); - umtx_unlock(&dateFmtMutex); - - // If we find field for smallest amount replace it with the formatted - // smallest amount from above taking care to replace the integer part - // with what is in original time. For example, If smallest amount - // is 9.35s and the formatted time is 0:00:09 then 9.35 becomes 09.35 - // and replacing yields 0:00:09.35 - if (smallestFieldPosition.getBeginIndex() != 0 || - smallestFieldPosition.getEndIndex() != 0) { - appendRange(draft, 0, smallestFieldPosition.getBeginIndex(), appendTo); - appendRange( - smallestAmountFormatted, - 0, - intFieldPosition.getBeginIndex(), - appendTo); - appendRange( - draft, - smallestFieldPosition.getBeginIndex(), - smallestFieldPosition.getEndIndex(), - appendTo); - appendRange( - smallestAmountFormatted, - intFieldPosition.getEndIndex(), - appendTo); - appendRange( - draft, - smallestFieldPosition.getEndIndex(), - appendTo); + const DecimalFormat *numberFormatter = dynamic_cast(numberFormat->get()); + if (!numberFormatter) { + status = U_INTERNAL_PROGRAM_ERROR; + return appendTo; + } + number::LocalizedNumberFormatter numberFormatter2; + if (auto* lnf = numberFormatter->toNumberFormatter(status)) { + numberFormatter2 = lnf->integerWidth(number::IntegerWidth::zeroFillTo(2)); } else { - appendTo.append(draft); + return appendTo; } + + FormattedStringBuilder fsb; + + UBool protect = FALSE; + const int32_t patternLength = pattern.length(); + for (int32_t i = 0; i < patternLength; i++) { + char16_t c = pattern[i]; + + // Also set the proper field in this switch + // We don't use DateFormat.Field because this is not a date / time, is a duration. + double value = 0; + switch (c) { + case u'H': value = hours; break; + case u'm': value = minutes; break; + case u's': value = seconds; break; + } + + // For undefined field we use UNUM_FIELD_COUNT, for historical reasons. + // See cleanup bug: https://unicode-org.atlassian.net/browse/ICU-20665 + // But we give it a clear name, to keep "the ugly part" in one place. + constexpr UNumberFormatFields undefinedField = UNUM_FIELD_COUNT; + + // There is not enough info to add Field(s) for the unit because all we have are plain + // text patterns. For example in "21:51" there is no text for something like "hour", + // while in something like "21h51" there is ("h"). But we can't really tell... + switch (c) { + case u'H': + case u'm': + case u's': + if (protect) { + fsb.appendChar16(c, undefinedField, status); + } else { + UnicodeString tmp; + if ((i + 1 < patternLength) && pattern[i + 1] == c) { // doubled + tmp = numberFormatter2.formatDouble(value, status).toString(status); + i++; + } else { + numberFormatter->format(value, tmp, status); + } + // TODO: Use proper Field + fsb.append(tmp, undefinedField, status); + } + break; + case u'\'': + // '' is escaped apostrophe + if ((i + 1 < patternLength) && pattern[i + 1] == c) { + fsb.appendChar16(c, undefinedField, status); + i++; + } else { + protect = !protect; + } + break; + default: + fsb.appendChar16(c, undefinedField, status); + } + } + + appendTo.append(fsb.toTempUnicodeString()); + return appendTo; } diff --git a/deps/icu-small/source/i18n/measunit.cpp b/deps/icu-small/source/i18n/measunit.cpp index 428283e6dda8d4..7a0a6060536aec 100644 --- a/deps/icu-small/source/i18n/measunit.cpp +++ b/deps/icu-small/source/i18n/measunit.cpp @@ -43,21 +43,22 @@ static const int32_t gOffsets[] = { 29, 328, 339, - 354, - 358, - 366, + 355, + 359, 368, - 372, - 393, - 395, - 409, - 412, + 370, + 374, + 381, + 402, + 404, 418, - 426, - 430, - 434, - 436, - 463 + 421, + 427, + 437, + 441, + 445, + 447, + 474 }; static const int32_t gIndexes[] = { @@ -69,21 +70,22 @@ static const int32_t gIndexes[] = { 29, 29, 40, - 55, - 59, - 67, + 56, + 60, 69, - 73, - 94, - 96, - 110, - 113, + 71, + 75, + 82, + 103, + 105, 119, - 127, - 131, - 135, - 137, - 164 + 122, + 128, + 138, + 142, + 146, + 148, + 175 }; // Must be sorted alphabetically. @@ -100,6 +102,7 @@ static const char * const gTypes[] = { "energy", "force", "frequency", + "graphics", "length", "light", "mass", @@ -456,6 +459,7 @@ static const char * const gSubTypes[] = { "century", "day", "day-person", + "decade", "hour", "microsecond", "millisecond", @@ -480,12 +484,20 @@ static const char * const gSubTypes[] = { "kilocalorie", "kilojoule", "kilowatt-hour", + "therm-us", "newton", "pound-force", "gigahertz", "hertz", "kilohertz", "megahertz", + "dot-per-centimeter", + "dot-per-inch", + "em", + "megapixel", + "pixel", + "pixel-per-centimeter", + "pixel-per-inch", "astronomical-unit", "centimeter", "decimeter", @@ -533,12 +545,14 @@ static const char * const gSubTypes[] = { "milliwatt", "watt", "atmosphere", + "bar", "hectopascal", "inch-hg", "kilopascal", "megapascal", "millibar", "millimeter-of-mercury", + "pascal", "pound-per-square-inch", "kilometer-per-hour", "knot", @@ -581,18 +595,20 @@ static const char * const gSubTypes[] = { // Must be sorted by first value and then second value. static int32_t unitPerUnitToSingleUnit[][4] = { - {379, 342, 18, 0}, - {381, 349, 18, 2}, - {383, 342, 18, 3}, - {383, 452, 4, 2}, - {383, 453, 4, 3}, - {402, 449, 3, 1}, - {405, 12, 17, 7}, - {455, 379, 4, 1} + {378, 382, 12, 5}, + {378, 387, 12, 6}, + {388, 343, 19, 0}, + {390, 350, 19, 2}, + {392, 343, 19, 3}, + {392, 463, 4, 2}, + {392, 464, 4, 3}, + {411, 460, 3, 1}, + {414, 12, 18, 9}, + {466, 388, 4, 1} }; // Shortcuts to the base unit in order to make the default constructor fast -static const int32_t kBaseTypeIdx = 15; +static const int32_t kBaseTypeIdx = 16; static const int32_t kBaseSubTypeIdx = 0; MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) { @@ -939,102 +955,110 @@ MeasureUnit MeasureUnit::getDayPerson() { return MeasureUnit(7, 2); } -MeasureUnit *MeasureUnit::createHour(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDecade(UErrorCode &status) { return MeasureUnit::create(7, 3, status); } -MeasureUnit MeasureUnit::getHour() { +MeasureUnit MeasureUnit::getDecade() { return MeasureUnit(7, 3); } -MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createHour(UErrorCode &status) { return MeasureUnit::create(7, 4, status); } -MeasureUnit MeasureUnit::getMicrosecond() { +MeasureUnit MeasureUnit::getHour() { return MeasureUnit(7, 4); } -MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) { return MeasureUnit::create(7, 5, status); } -MeasureUnit MeasureUnit::getMillisecond() { +MeasureUnit MeasureUnit::getMicrosecond() { return MeasureUnit(7, 5); } -MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) { return MeasureUnit::create(7, 6, status); } -MeasureUnit MeasureUnit::getMinute() { +MeasureUnit MeasureUnit::getMillisecond() { return MeasureUnit(7, 6); } -MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) { return MeasureUnit::create(7, 7, status); } -MeasureUnit MeasureUnit::getMonth() { +MeasureUnit MeasureUnit::getMinute() { return MeasureUnit(7, 7); } -MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) { return MeasureUnit::create(7, 8, status); } -MeasureUnit MeasureUnit::getMonthPerson() { +MeasureUnit MeasureUnit::getMonth() { return MeasureUnit(7, 8); } -MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) { return MeasureUnit::create(7, 9, status); } -MeasureUnit MeasureUnit::getNanosecond() { +MeasureUnit MeasureUnit::getMonthPerson() { return MeasureUnit(7, 9); } -MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) { return MeasureUnit::create(7, 10, status); } -MeasureUnit MeasureUnit::getSecond() { +MeasureUnit MeasureUnit::getNanosecond() { return MeasureUnit(7, 10); } -MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) { +MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) { return MeasureUnit::create(7, 11, status); } -MeasureUnit MeasureUnit::getWeek() { +MeasureUnit MeasureUnit::getSecond() { return MeasureUnit(7, 11); } -MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) { return MeasureUnit::create(7, 12, status); } -MeasureUnit MeasureUnit::getWeekPerson() { +MeasureUnit MeasureUnit::getWeek() { return MeasureUnit(7, 12); } -MeasureUnit *MeasureUnit::createYear(UErrorCode &status) { +MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) { return MeasureUnit::create(7, 13, status); } -MeasureUnit MeasureUnit::getYear() { +MeasureUnit MeasureUnit::getWeekPerson() { return MeasureUnit(7, 13); } -MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createYear(UErrorCode &status) { return MeasureUnit::create(7, 14, status); } -MeasureUnit MeasureUnit::getYearPerson() { +MeasureUnit MeasureUnit::getYear() { return MeasureUnit(7, 14); } +MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) { + return MeasureUnit::create(7, 15, status); +} + +MeasureUnit MeasureUnit::getYearPerson() { + return MeasureUnit(7, 15); +} + MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) { return MeasureUnit::create(8, 0, status); } @@ -1131,6 +1155,14 @@ MeasureUnit MeasureUnit::getKilowattHour() { return MeasureUnit(9, 7); } +MeasureUnit *MeasureUnit::createThermUs(UErrorCode &status) { + return MeasureUnit::create(9, 8, status); +} + +MeasureUnit MeasureUnit::getThermUs() { + return MeasureUnit(9, 8); +} + MeasureUnit *MeasureUnit::createNewton(UErrorCode &status) { return MeasureUnit::create(10, 0, status); } @@ -1179,708 +1211,780 @@ MeasureUnit MeasureUnit::getMegahertz() { return MeasureUnit(11, 3); } -MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) { return MeasureUnit::create(12, 0, status); } -MeasureUnit MeasureUnit::getAstronomicalUnit() { +MeasureUnit MeasureUnit::getDotPerCentimeter() { return MeasureUnit(12, 0); } -MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) { return MeasureUnit::create(12, 1, status); } -MeasureUnit MeasureUnit::getCentimeter() { +MeasureUnit MeasureUnit::getDotPerInch() { return MeasureUnit(12, 1); } -MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) { +MeasureUnit *MeasureUnit::createEm(UErrorCode &status) { return MeasureUnit::create(12, 2, status); } -MeasureUnit MeasureUnit::getDecimeter() { +MeasureUnit MeasureUnit::getEm() { return MeasureUnit(12, 2); } -MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) { return MeasureUnit::create(12, 3, status); } -MeasureUnit MeasureUnit::getFathom() { +MeasureUnit MeasureUnit::getMegapixel() { return MeasureUnit(12, 3); } -MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) { return MeasureUnit::create(12, 4, status); } -MeasureUnit MeasureUnit::getFoot() { +MeasureUnit MeasureUnit::getPixel() { return MeasureUnit(12, 4); } -MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) { return MeasureUnit::create(12, 5, status); } -MeasureUnit MeasureUnit::getFurlong() { +MeasureUnit MeasureUnit::getPixelPerCentimeter() { return MeasureUnit(12, 5); } -MeasureUnit *MeasureUnit::createInch(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) { return MeasureUnit::create(12, 6, status); } -MeasureUnit MeasureUnit::getInch() { +MeasureUnit MeasureUnit::getPixelPerInch() { return MeasureUnit(12, 6); } +MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) { + return MeasureUnit::create(13, 0, status); +} + +MeasureUnit MeasureUnit::getAstronomicalUnit() { + return MeasureUnit(13, 0); +} + +MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) { + return MeasureUnit::create(13, 1, status); +} + +MeasureUnit MeasureUnit::getCentimeter() { + return MeasureUnit(13, 1); +} + +MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) { + return MeasureUnit::create(13, 2, status); +} + +MeasureUnit MeasureUnit::getDecimeter() { + return MeasureUnit(13, 2); +} + +MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) { + return MeasureUnit::create(13, 3, status); +} + +MeasureUnit MeasureUnit::getFathom() { + return MeasureUnit(13, 3); +} + +MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) { + return MeasureUnit::create(13, 4, status); +} + +MeasureUnit MeasureUnit::getFoot() { + return MeasureUnit(13, 4); +} + +MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) { + return MeasureUnit::create(13, 5, status); +} + +MeasureUnit MeasureUnit::getFurlong() { + return MeasureUnit(13, 5); +} + +MeasureUnit *MeasureUnit::createInch(UErrorCode &status) { + return MeasureUnit::create(13, 6, status); +} + +MeasureUnit MeasureUnit::getInch() { + return MeasureUnit(13, 6); +} + MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) { - return MeasureUnit::create(12, 7, status); + return MeasureUnit::create(13, 7, status); } MeasureUnit MeasureUnit::getKilometer() { - return MeasureUnit(12, 7); + return MeasureUnit(13, 7); } MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) { - return MeasureUnit::create(12, 8, status); + return MeasureUnit::create(13, 8, status); } MeasureUnit MeasureUnit::getLightYear() { - return MeasureUnit(12, 8); + return MeasureUnit(13, 8); } MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) { - return MeasureUnit::create(12, 9, status); + return MeasureUnit::create(13, 9, status); } MeasureUnit MeasureUnit::getMeter() { - return MeasureUnit(12, 9); + return MeasureUnit(13, 9); } MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) { - return MeasureUnit::create(12, 10, status); + return MeasureUnit::create(13, 10, status); } MeasureUnit MeasureUnit::getMicrometer() { - return MeasureUnit(12, 10); + return MeasureUnit(13, 10); } MeasureUnit *MeasureUnit::createMile(UErrorCode &status) { - return MeasureUnit::create(12, 11, status); + return MeasureUnit::create(13, 11, status); } MeasureUnit MeasureUnit::getMile() { - return MeasureUnit(12, 11); + return MeasureUnit(13, 11); } MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) { - return MeasureUnit::create(12, 12, status); + return MeasureUnit::create(13, 12, status); } MeasureUnit MeasureUnit::getMileScandinavian() { - return MeasureUnit(12, 12); + return MeasureUnit(13, 12); } MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) { - return MeasureUnit::create(12, 13, status); + return MeasureUnit::create(13, 13, status); } MeasureUnit MeasureUnit::getMillimeter() { - return MeasureUnit(12, 13); + return MeasureUnit(13, 13); } MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) { - return MeasureUnit::create(12, 14, status); + return MeasureUnit::create(13, 14, status); } MeasureUnit MeasureUnit::getNanometer() { - return MeasureUnit(12, 14); + return MeasureUnit(13, 14); } MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) { - return MeasureUnit::create(12, 15, status); + return MeasureUnit::create(13, 15, status); } MeasureUnit MeasureUnit::getNauticalMile() { - return MeasureUnit(12, 15); + return MeasureUnit(13, 15); } MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) { - return MeasureUnit::create(12, 16, status); + return MeasureUnit::create(13, 16, status); } MeasureUnit MeasureUnit::getParsec() { - return MeasureUnit(12, 16); + return MeasureUnit(13, 16); } MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) { - return MeasureUnit::create(12, 17, status); + return MeasureUnit::create(13, 17, status); } MeasureUnit MeasureUnit::getPicometer() { - return MeasureUnit(12, 17); + return MeasureUnit(13, 17); } MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) { - return MeasureUnit::create(12, 18, status); + return MeasureUnit::create(13, 18, status); } MeasureUnit MeasureUnit::getPoint() { - return MeasureUnit(12, 18); + return MeasureUnit(13, 18); } MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) { - return MeasureUnit::create(12, 19, status); + return MeasureUnit::create(13, 19, status); } MeasureUnit MeasureUnit::getSolarRadius() { - return MeasureUnit(12, 19); + return MeasureUnit(13, 19); } MeasureUnit *MeasureUnit::createYard(UErrorCode &status) { - return MeasureUnit::create(12, 20, status); + return MeasureUnit::create(13, 20, status); } MeasureUnit MeasureUnit::getYard() { - return MeasureUnit(12, 20); + return MeasureUnit(13, 20); } MeasureUnit *MeasureUnit::createLux(UErrorCode &status) { - return MeasureUnit::create(13, 0, status); + return MeasureUnit::create(14, 0, status); } MeasureUnit MeasureUnit::getLux() { - return MeasureUnit(13, 0); + return MeasureUnit(14, 0); } MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) { - return MeasureUnit::create(13, 1, status); + return MeasureUnit::create(14, 1, status); } MeasureUnit MeasureUnit::getSolarLuminosity() { - return MeasureUnit(13, 1); + return MeasureUnit(14, 1); } MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) { - return MeasureUnit::create(14, 0, status); + return MeasureUnit::create(15, 0, status); } MeasureUnit MeasureUnit::getCarat() { - return MeasureUnit(14, 0); + return MeasureUnit(15, 0); } MeasureUnit *MeasureUnit::createDalton(UErrorCode &status) { - return MeasureUnit::create(14, 1, status); + return MeasureUnit::create(15, 1, status); } MeasureUnit MeasureUnit::getDalton() { - return MeasureUnit(14, 1); + return MeasureUnit(15, 1); } MeasureUnit *MeasureUnit::createEarthMass(UErrorCode &status) { - return MeasureUnit::create(14, 2, status); + return MeasureUnit::create(15, 2, status); } MeasureUnit MeasureUnit::getEarthMass() { - return MeasureUnit(14, 2); + return MeasureUnit(15, 2); } MeasureUnit *MeasureUnit::createGram(UErrorCode &status) { - return MeasureUnit::create(14, 3, status); + return MeasureUnit::create(15, 3, status); } MeasureUnit MeasureUnit::getGram() { - return MeasureUnit(14, 3); + return MeasureUnit(15, 3); } MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) { - return MeasureUnit::create(14, 4, status); + return MeasureUnit::create(15, 4, status); } MeasureUnit MeasureUnit::getKilogram() { - return MeasureUnit(14, 4); + return MeasureUnit(15, 4); } MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) { - return MeasureUnit::create(14, 5, status); + return MeasureUnit::create(15, 5, status); } MeasureUnit MeasureUnit::getMetricTon() { - return MeasureUnit(14, 5); + return MeasureUnit(15, 5); } MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) { - return MeasureUnit::create(14, 6, status); + return MeasureUnit::create(15, 6, status); } MeasureUnit MeasureUnit::getMicrogram() { - return MeasureUnit(14, 6); + return MeasureUnit(15, 6); } MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) { - return MeasureUnit::create(14, 7, status); + return MeasureUnit::create(15, 7, status); } MeasureUnit MeasureUnit::getMilligram() { - return MeasureUnit(14, 7); + return MeasureUnit(15, 7); } MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) { - return MeasureUnit::create(14, 8, status); + return MeasureUnit::create(15, 8, status); } MeasureUnit MeasureUnit::getOunce() { - return MeasureUnit(14, 8); + return MeasureUnit(15, 8); } MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) { - return MeasureUnit::create(14, 9, status); + return MeasureUnit::create(15, 9, status); } MeasureUnit MeasureUnit::getOunceTroy() { - return MeasureUnit(14, 9); + return MeasureUnit(15, 9); } MeasureUnit *MeasureUnit::createPound(UErrorCode &status) { - return MeasureUnit::create(14, 10, status); + return MeasureUnit::create(15, 10, status); } MeasureUnit MeasureUnit::getPound() { - return MeasureUnit(14, 10); + return MeasureUnit(15, 10); } MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) { - return MeasureUnit::create(14, 11, status); + return MeasureUnit::create(15, 11, status); } MeasureUnit MeasureUnit::getSolarMass() { - return MeasureUnit(14, 11); + return MeasureUnit(15, 11); } MeasureUnit *MeasureUnit::createStone(UErrorCode &status) { - return MeasureUnit::create(14, 12, status); + return MeasureUnit::create(15, 12, status); } MeasureUnit MeasureUnit::getStone() { - return MeasureUnit(14, 12); + return MeasureUnit(15, 12); } MeasureUnit *MeasureUnit::createTon(UErrorCode &status) { - return MeasureUnit::create(14, 13, status); + return MeasureUnit::create(15, 13, status); } MeasureUnit MeasureUnit::getTon() { - return MeasureUnit(14, 13); + return MeasureUnit(15, 13); } MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) { - return MeasureUnit::create(16, 0, status); + return MeasureUnit::create(17, 0, status); } MeasureUnit MeasureUnit::getGigawatt() { - return MeasureUnit(16, 0); + return MeasureUnit(17, 0); } MeasureUnit *MeasureUnit::createHorsepower(UErrorCode &status) { - return MeasureUnit::create(16, 1, status); + return MeasureUnit::create(17, 1, status); } MeasureUnit MeasureUnit::getHorsepower() { - return MeasureUnit(16, 1); + return MeasureUnit(17, 1); } MeasureUnit *MeasureUnit::createKilowatt(UErrorCode &status) { - return MeasureUnit::create(16, 2, status); + return MeasureUnit::create(17, 2, status); } MeasureUnit MeasureUnit::getKilowatt() { - return MeasureUnit(16, 2); + return MeasureUnit(17, 2); } MeasureUnit *MeasureUnit::createMegawatt(UErrorCode &status) { - return MeasureUnit::create(16, 3, status); + return MeasureUnit::create(17, 3, status); } MeasureUnit MeasureUnit::getMegawatt() { - return MeasureUnit(16, 3); + return MeasureUnit(17, 3); } MeasureUnit *MeasureUnit::createMilliwatt(UErrorCode &status) { - return MeasureUnit::create(16, 4, status); + return MeasureUnit::create(17, 4, status); } MeasureUnit MeasureUnit::getMilliwatt() { - return MeasureUnit(16, 4); + return MeasureUnit(17, 4); } MeasureUnit *MeasureUnit::createWatt(UErrorCode &status) { - return MeasureUnit::create(16, 5, status); + return MeasureUnit::create(17, 5, status); } MeasureUnit MeasureUnit::getWatt() { - return MeasureUnit(16, 5); + return MeasureUnit(17, 5); } MeasureUnit *MeasureUnit::createAtmosphere(UErrorCode &status) { - return MeasureUnit::create(17, 0, status); + return MeasureUnit::create(18, 0, status); } MeasureUnit MeasureUnit::getAtmosphere() { - return MeasureUnit(17, 0); + return MeasureUnit(18, 0); +} + +MeasureUnit *MeasureUnit::createBar(UErrorCode &status) { + return MeasureUnit::create(18, 1, status); +} + +MeasureUnit MeasureUnit::getBar() { + return MeasureUnit(18, 1); } MeasureUnit *MeasureUnit::createHectopascal(UErrorCode &status) { - return MeasureUnit::create(17, 1, status); + return MeasureUnit::create(18, 2, status); } MeasureUnit MeasureUnit::getHectopascal() { - return MeasureUnit(17, 1); + return MeasureUnit(18, 2); } MeasureUnit *MeasureUnit::createInchHg(UErrorCode &status) { - return MeasureUnit::create(17, 2, status); + return MeasureUnit::create(18, 3, status); } MeasureUnit MeasureUnit::getInchHg() { - return MeasureUnit(17, 2); + return MeasureUnit(18, 3); } MeasureUnit *MeasureUnit::createKilopascal(UErrorCode &status) { - return MeasureUnit::create(17, 3, status); + return MeasureUnit::create(18, 4, status); } MeasureUnit MeasureUnit::getKilopascal() { - return MeasureUnit(17, 3); + return MeasureUnit(18, 4); } MeasureUnit *MeasureUnit::createMegapascal(UErrorCode &status) { - return MeasureUnit::create(17, 4, status); + return MeasureUnit::create(18, 5, status); } MeasureUnit MeasureUnit::getMegapascal() { - return MeasureUnit(17, 4); + return MeasureUnit(18, 5); } MeasureUnit *MeasureUnit::createMillibar(UErrorCode &status) { - return MeasureUnit::create(17, 5, status); + return MeasureUnit::create(18, 6, status); } MeasureUnit MeasureUnit::getMillibar() { - return MeasureUnit(17, 5); + return MeasureUnit(18, 6); } MeasureUnit *MeasureUnit::createMillimeterOfMercury(UErrorCode &status) { - return MeasureUnit::create(17, 6, status); + return MeasureUnit::create(18, 7, status); } MeasureUnit MeasureUnit::getMillimeterOfMercury() { - return MeasureUnit(17, 6); + return MeasureUnit(18, 7); +} + +MeasureUnit *MeasureUnit::createPascal(UErrorCode &status) { + return MeasureUnit::create(18, 8, status); +} + +MeasureUnit MeasureUnit::getPascal() { + return MeasureUnit(18, 8); } MeasureUnit *MeasureUnit::createPoundPerSquareInch(UErrorCode &status) { - return MeasureUnit::create(17, 7, status); + return MeasureUnit::create(18, 9, status); } MeasureUnit MeasureUnit::getPoundPerSquareInch() { - return MeasureUnit(17, 7); + return MeasureUnit(18, 9); } MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) { - return MeasureUnit::create(18, 0, status); + return MeasureUnit::create(19, 0, status); } MeasureUnit MeasureUnit::getKilometerPerHour() { - return MeasureUnit(18, 0); + return MeasureUnit(19, 0); } MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) { - return MeasureUnit::create(18, 1, status); + return MeasureUnit::create(19, 1, status); } MeasureUnit MeasureUnit::getKnot() { - return MeasureUnit(18, 1); + return MeasureUnit(19, 1); } MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) { - return MeasureUnit::create(18, 2, status); + return MeasureUnit::create(19, 2, status); } MeasureUnit MeasureUnit::getMeterPerSecond() { - return MeasureUnit(18, 2); + return MeasureUnit(19, 2); } MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) { - return MeasureUnit::create(18, 3, status); + return MeasureUnit::create(19, 3, status); } MeasureUnit MeasureUnit::getMilePerHour() { - return MeasureUnit(18, 3); + return MeasureUnit(19, 3); } MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) { - return MeasureUnit::create(19, 0, status); + return MeasureUnit::create(20, 0, status); } MeasureUnit MeasureUnit::getCelsius() { - return MeasureUnit(19, 0); + return MeasureUnit(20, 0); } MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) { - return MeasureUnit::create(19, 1, status); + return MeasureUnit::create(20, 1, status); } MeasureUnit MeasureUnit::getFahrenheit() { - return MeasureUnit(19, 1); + return MeasureUnit(20, 1); } MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) { - return MeasureUnit::create(19, 2, status); + return MeasureUnit::create(20, 2, status); } MeasureUnit MeasureUnit::getGenericTemperature() { - return MeasureUnit(19, 2); + return MeasureUnit(20, 2); } MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) { - return MeasureUnit::create(19, 3, status); + return MeasureUnit::create(20, 3, status); } MeasureUnit MeasureUnit::getKelvin() { - return MeasureUnit(19, 3); + return MeasureUnit(20, 3); } MeasureUnit *MeasureUnit::createNewtonMeter(UErrorCode &status) { - return MeasureUnit::create(20, 0, status); + return MeasureUnit::create(21, 0, status); } MeasureUnit MeasureUnit::getNewtonMeter() { - return MeasureUnit(20, 0); + return MeasureUnit(21, 0); } MeasureUnit *MeasureUnit::createPoundFoot(UErrorCode &status) { - return MeasureUnit::create(20, 1, status); + return MeasureUnit::create(21, 1, status); } MeasureUnit MeasureUnit::getPoundFoot() { - return MeasureUnit(20, 1); + return MeasureUnit(21, 1); } MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) { - return MeasureUnit::create(21, 0, status); + return MeasureUnit::create(22, 0, status); } MeasureUnit MeasureUnit::getAcreFoot() { - return MeasureUnit(21, 0); + return MeasureUnit(22, 0); } MeasureUnit *MeasureUnit::createBarrel(UErrorCode &status) { - return MeasureUnit::create(21, 1, status); + return MeasureUnit::create(22, 1, status); } MeasureUnit MeasureUnit::getBarrel() { - return MeasureUnit(21, 1); + return MeasureUnit(22, 1); } MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) { - return MeasureUnit::create(21, 2, status); + return MeasureUnit::create(22, 2, status); } MeasureUnit MeasureUnit::getBushel() { - return MeasureUnit(21, 2); + return MeasureUnit(22, 2); } MeasureUnit *MeasureUnit::createCentiliter(UErrorCode &status) { - return MeasureUnit::create(21, 3, status); + return MeasureUnit::create(22, 3, status); } MeasureUnit MeasureUnit::getCentiliter() { - return MeasureUnit(21, 3); + return MeasureUnit(22, 3); } MeasureUnit *MeasureUnit::createCubicCentimeter(UErrorCode &status) { - return MeasureUnit::create(21, 4, status); + return MeasureUnit::create(22, 4, status); } MeasureUnit MeasureUnit::getCubicCentimeter() { - return MeasureUnit(21, 4); + return MeasureUnit(22, 4); } MeasureUnit *MeasureUnit::createCubicFoot(UErrorCode &status) { - return MeasureUnit::create(21, 5, status); + return MeasureUnit::create(22, 5, status); } MeasureUnit MeasureUnit::getCubicFoot() { - return MeasureUnit(21, 5); + return MeasureUnit(22, 5); } MeasureUnit *MeasureUnit::createCubicInch(UErrorCode &status) { - return MeasureUnit::create(21, 6, status); + return MeasureUnit::create(22, 6, status); } MeasureUnit MeasureUnit::getCubicInch() { - return MeasureUnit(21, 6); + return MeasureUnit(22, 6); } MeasureUnit *MeasureUnit::createCubicKilometer(UErrorCode &status) { - return MeasureUnit::create(21, 7, status); + return MeasureUnit::create(22, 7, status); } MeasureUnit MeasureUnit::getCubicKilometer() { - return MeasureUnit(21, 7); + return MeasureUnit(22, 7); } MeasureUnit *MeasureUnit::createCubicMeter(UErrorCode &status) { - return MeasureUnit::create(21, 8, status); + return MeasureUnit::create(22, 8, status); } MeasureUnit MeasureUnit::getCubicMeter() { - return MeasureUnit(21, 8); + return MeasureUnit(22, 8); } MeasureUnit *MeasureUnit::createCubicMile(UErrorCode &status) { - return MeasureUnit::create(21, 9, status); + return MeasureUnit::create(22, 9, status); } MeasureUnit MeasureUnit::getCubicMile() { - return MeasureUnit(21, 9); + return MeasureUnit(22, 9); } MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) { - return MeasureUnit::create(21, 10, status); + return MeasureUnit::create(22, 10, status); } MeasureUnit MeasureUnit::getCubicYard() { - return MeasureUnit(21, 10); + return MeasureUnit(22, 10); } MeasureUnit *MeasureUnit::createCup(UErrorCode &status) { - return MeasureUnit::create(21, 11, status); + return MeasureUnit::create(22, 11, status); } MeasureUnit MeasureUnit::getCup() { - return MeasureUnit(21, 11); + return MeasureUnit(22, 11); } MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) { - return MeasureUnit::create(21, 12, status); + return MeasureUnit::create(22, 12, status); } MeasureUnit MeasureUnit::getCupMetric() { - return MeasureUnit(21, 12); + return MeasureUnit(22, 12); } MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) { - return MeasureUnit::create(21, 13, status); + return MeasureUnit::create(22, 13, status); } MeasureUnit MeasureUnit::getDeciliter() { - return MeasureUnit(21, 13); + return MeasureUnit(22, 13); } MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) { - return MeasureUnit::create(21, 14, status); + return MeasureUnit::create(22, 14, status); } MeasureUnit MeasureUnit::getFluidOunce() { - return MeasureUnit(21, 14); + return MeasureUnit(22, 14); } MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) { - return MeasureUnit::create(21, 15, status); + return MeasureUnit::create(22, 15, status); } MeasureUnit MeasureUnit::getFluidOunceImperial() { - return MeasureUnit(21, 15); + return MeasureUnit(22, 15); } MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) { - return MeasureUnit::create(21, 16, status); + return MeasureUnit::create(22, 16, status); } MeasureUnit MeasureUnit::getGallon() { - return MeasureUnit(21, 16); + return MeasureUnit(22, 16); } MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) { - return MeasureUnit::create(21, 17, status); + return MeasureUnit::create(22, 17, status); } MeasureUnit MeasureUnit::getGallonImperial() { - return MeasureUnit(21, 17); + return MeasureUnit(22, 17); } MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) { - return MeasureUnit::create(21, 18, status); + return MeasureUnit::create(22, 18, status); } MeasureUnit MeasureUnit::getHectoliter() { - return MeasureUnit(21, 18); + return MeasureUnit(22, 18); } MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) { - return MeasureUnit::create(21, 19, status); + return MeasureUnit::create(22, 19, status); } MeasureUnit MeasureUnit::getLiter() { - return MeasureUnit(21, 19); + return MeasureUnit(22, 19); } MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) { - return MeasureUnit::create(21, 20, status); + return MeasureUnit::create(22, 20, status); } MeasureUnit MeasureUnit::getMegaliter() { - return MeasureUnit(21, 20); + return MeasureUnit(22, 20); } MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) { - return MeasureUnit::create(21, 21, status); + return MeasureUnit::create(22, 21, status); } MeasureUnit MeasureUnit::getMilliliter() { - return MeasureUnit(21, 21); + return MeasureUnit(22, 21); } MeasureUnit *MeasureUnit::createPint(UErrorCode &status) { - return MeasureUnit::create(21, 22, status); + return MeasureUnit::create(22, 22, status); } MeasureUnit MeasureUnit::getPint() { - return MeasureUnit(21, 22); + return MeasureUnit(22, 22); } MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) { - return MeasureUnit::create(21, 23, status); + return MeasureUnit::create(22, 23, status); } MeasureUnit MeasureUnit::getPintMetric() { - return MeasureUnit(21, 23); + return MeasureUnit(22, 23); } MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) { - return MeasureUnit::create(21, 24, status); + return MeasureUnit::create(22, 24, status); } MeasureUnit MeasureUnit::getQuart() { - return MeasureUnit(21, 24); + return MeasureUnit(22, 24); } MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) { - return MeasureUnit::create(21, 25, status); + return MeasureUnit::create(22, 25, status); } MeasureUnit MeasureUnit::getTablespoon() { - return MeasureUnit(21, 25); + return MeasureUnit(22, 25); } MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) { - return MeasureUnit::create(21, 26, status); + return MeasureUnit::create(22, 26, status); } MeasureUnit MeasureUnit::getTeaspoon() { - return MeasureUnit(21, 26); + return MeasureUnit(22, 26); } // End generated code @@ -1923,7 +2027,7 @@ MeasureUnit &MeasureUnit::operator=(const MeasureUnit &other) { return *this; } -UObject *MeasureUnit::clone() const { +MeasureUnit *MeasureUnit::clone() const { return new MeasureUnit(*this); } @@ -2082,7 +2186,7 @@ void MeasureUnit::initTime(const char *timeId) { fTypeId = result; result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], timeId); U_ASSERT(result != -1); - fSubTypeId = result - gOffsets[fTypeId]; + fSubTypeId = result - gOffsets[fTypeId]; } void MeasureUnit::initCurrency(const char *isoCurrency) { diff --git a/deps/icu-small/source/i18n/measure.cpp b/deps/icu-small/source/i18n/measure.cpp index d9084f87db2baa..bffa44215e3cde 100644 --- a/deps/icu-small/source/i18n/measure.cpp +++ b/deps/icu-small/source/i18n/measure.cpp @@ -43,12 +43,12 @@ Measure& Measure::operator=(const Measure& other) { if (this != &other) { delete unit; number = other.number; - unit = (MeasureUnit*) other.unit->clone(); + unit = other.unit->clone(); } return *this; } -UObject *Measure::clone() const { +Measure *Measure::clone() const { return new Measure(*this); } diff --git a/deps/icu-small/source/i18n/msgfmt.cpp b/deps/icu-small/source/i18n/msgfmt.cpp index e39b26b969889f..3ca368ef954846 100644 --- a/deps/icu-small/source/i18n/msgfmt.cpp +++ b/deps/icu-small/source/i18n/msgfmt.cpp @@ -436,7 +436,7 @@ MessageFormat::operator==(const Format& rhs) const // ------------------------------------- // Creates a copy of this MessageFormat, the caller owns the copy. -Format* +MessageFormat* MessageFormat::clone() const { return new MessageFormat(*this); @@ -813,7 +813,7 @@ MessageFormat::getFormats(int32_t& cnt) const // Get total required capacity first (it's refreshed on each call). int32_t totalCapacity = 0; - for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0; ++totalCapacity) {}; + for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0; ++totalCapacity) {} MessageFormat* t = const_cast (this); cnt = 0; @@ -1873,7 +1873,7 @@ UBool MessageFormat::DummyFormat::operator==(const Format&) const { return TRUE; } -Format* MessageFormat::DummyFormat::clone() const { +MessageFormat::DummyFormat* MessageFormat::DummyFormat::clone() const { return new DummyFormat(); } diff --git a/deps/icu-small/source/i18n/msgfmt_impl.h b/deps/icu-small/source/i18n/msgfmt_impl.h index 0f77d12d0bb6e1..1cece1a09434e3 100644 --- a/deps/icu-small/source/i18n/msgfmt_impl.h +++ b/deps/icu-small/source/i18n/msgfmt_impl.h @@ -17,7 +17,7 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING - + #include "unicode/msgfmt.h" #include "uvector.h" #include "unicode/strenum.h" diff --git a/deps/icu-small/source/i18n/name2uni.cpp b/deps/icu-small/source/i18n/name2uni.cpp index d901eb126a8a46..52bab80e3dad65 100644 --- a/deps/icu-small/source/i18n/name2uni.cpp +++ b/deps/icu-small/source/i18n/name2uni.cpp @@ -100,7 +100,7 @@ NameUnicodeTransliterator::NameUnicodeTransliterator(const NameUnicodeTransliter /** * Transliterator API. */ -Transliterator* NameUnicodeTransliterator::clone(void) const { +NameUnicodeTransliterator* NameUnicodeTransliterator::clone() const { return new NameUnicodeTransliterator(*this); } @@ -219,7 +219,7 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos openPos = -1; // close off candidate continue; // *** reprocess char32At(cursor) } - + // Check if c is a legal char. We assume here that // legal.contains(OPEN_DELIM) is FALSE, so when we abort a // name, we don't have to go back to openPos+1. @@ -231,7 +231,7 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos mode = 0; } } - + // Invalid character else { --cursor; // Backup and reprocess this character @@ -243,7 +243,7 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos cursor += U16_LENGTH(c); } - + offsets.contextLimit += limit - offsets.limit; offsets.limit = limit; // In incremental mode, only advance the cursor up to the last diff --git a/deps/icu-small/source/i18n/name2uni.h b/deps/icu-small/source/i18n/name2uni.h index 4c743def32ede2..44ad85fb822cb3 100644 --- a/deps/icu-small/source/i18n/name2uni.h +++ b/deps/icu-small/source/i18n/name2uni.h @@ -49,7 +49,7 @@ class NameUnicodeTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual NameUnicodeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/nfrlist.h b/deps/icu-small/source/i18n/nfrlist.h index db28c4d36f8d18..3eb1882b2f957e 100644 --- a/deps/icu-small/source/i18n/nfrlist.h +++ b/deps/icu-small/source/i18n/nfrlist.h @@ -38,7 +38,7 @@ class NFRuleList : public UMemory { uint32_t fCount; uint32_t fCapacity; public: - NFRuleList(uint32_t capacity = 10) + NFRuleList(uint32_t capacity = 10) : fStuff(capacity ? (NFRule**)uprv_malloc(capacity * sizeof(NFRule*)) : NULL) , fCount(0) , fCapacity(capacity) {} @@ -52,9 +52,9 @@ class NFRuleList : public UMemory { } NFRule* operator[](uint32_t index) const { return fStuff != NULL ? fStuff[index] : NULL; } NFRule* remove(uint32_t index) { - if (fStuff == NULL) { - return NULL; - } + if (fStuff == NULL) { + return NULL; + } NFRule* result = fStuff[index]; fCount -= 1; for (uint32_t i = index; i < fCount; ++i) { // assumes small arrays @@ -68,10 +68,10 @@ class NFRuleList : public UMemory { fStuff = (NFRule**)uprv_realloc(fStuff, fCapacity * sizeof(NFRule*)); // assume success } if (fStuff != NULL) { - fStuff[fCount++] = thing; + fStuff[fCount++] = thing; } else { - fCapacity = 0; - fCount = 0; + fCapacity = 0; + fCount = 0; } } uint32_t size() const { return fCount; } diff --git a/deps/icu-small/source/i18n/nfrs.cpp b/deps/icu-small/source/i18n/nfrs.cpp index 659cfcbbf5a857..e7b17b46c3a056 100644 --- a/deps/icu-small/source/i18n/nfrs.cpp +++ b/deps/icu-small/source/i18n/nfrs.cpp @@ -821,7 +821,7 @@ int64_t util64_fromDouble(double d) { } else if (d > mant) { d = mant; } - UBool neg = d < 0; + UBool neg = d < 0; if (neg) { d = -d; } @@ -852,12 +852,12 @@ uint64_t util64_pow(uint32_t base, uint16_t exponent) { return result; } -static const uint8_t asciiDigits[] = { +static const uint8_t asciiDigits[] = { 0x30u, 0x31u, 0x32u, 0x33u, 0x34u, 0x35u, 0x36u, 0x37u, 0x38u, 0x39u, 0x61u, 0x62u, 0x63u, 0x64u, 0x65u, 0x66u, 0x67u, 0x68u, 0x69u, 0x6au, 0x6bu, 0x6cu, 0x6du, 0x6eu, 0x6fu, 0x70u, 0x71u, 0x72u, 0x73u, 0x74u, 0x75u, 0x76u, - 0x77u, 0x78u, 0x79u, 0x7au, + 0x77u, 0x78u, 0x79u, 0x7au, }; static const UChar kUMinus = (UChar)0x002d; @@ -938,7 +938,7 @@ int64_t util64_utoi(const UChar* str, uint32_t radix) } uint32_t util64_toa(int64_t w, char* buf, uint32_t len, uint32_t radix, UBool raw) -{ +{ if (radix > 36) { radix = 36; } else if (radix < 2) { @@ -984,7 +984,7 @@ uint32_t util64_toa(int64_t w, char* buf, uint32_t len, uint32_t radix, UBool ra #endif uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool raw) -{ +{ if (radix > 36) { radix = 36; } else if (radix < 2) { diff --git a/deps/icu-small/source/i18n/nfrs.h b/deps/icu-small/source/i18n/nfrs.h index c56fc0707851a7..db03c9039deda8 100644 --- a/deps/icu-small/source/i18n/nfrs.h +++ b/deps/icu-small/source/i18n/nfrs.h @@ -66,7 +66,7 @@ class NFRuleSet : public UMemory { const NFRule * findNormalRule(int64_t number) const; const NFRule * findDoubleRule(double number) const; const NFRule * findFractionRuleSetRule(double number) const; - + friend class NFSubstitution; private: diff --git a/deps/icu-small/source/i18n/nfrule.cpp b/deps/icu-small/source/i18n/nfrule.cpp index b5e7892d5e68cb..3ad0291649e66c 100644 --- a/deps/icu-small/source/i18n/nfrule.cpp +++ b/deps/icu-small/source/i18n/nfrule.cpp @@ -1107,14 +1107,14 @@ NFRule::stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosit { // if the prefix text is empty, dump out without doing anything if (prefix.length() != 0) { - UErrorCode status = U_ZERO_ERROR; + UErrorCode status = U_ZERO_ERROR; // use prefixLength() to match the beginning of // "text" against "prefix". This function returns the // number of characters from "text" that matched (or 0 if // we didn't match the whole prefix) int32_t pfl = prefixLength(text, prefix, status); if (U_FAILURE(status)) { // Memory allocation error. - return; + return; } if (pfl != 0) { // if we got a successful match, update the parse position @@ -1170,9 +1170,9 @@ NFRule::matchToDelimiter(const UnicodeString& text, // use "sub"'s doParse() method to match the text before the // instance of "delimiter" we just found. if (!allIgnorable(delimiter, status)) { - if (U_FAILURE(status)) { //Memory allocation error. - return 0; - } + if (U_FAILURE(status)) { //Memory allocation error. + return 0; + } ParsePosition tempPP; Formattable result; diff --git a/deps/icu-small/source/i18n/nfrule.h b/deps/icu-small/source/i18n/nfrule.h index 2b030390ea7dcb..ed33eaa5af7605 100644 --- a/deps/icu-small/source/i18n/nfrule.h +++ b/deps/icu-small/source/i18n/nfrule.h @@ -45,9 +45,9 @@ class NFRule : public UMemory { }; static void makeRules(UnicodeString& definition, - NFRuleSet* ruleSet, - const NFRule* predecessor, - const RuleBasedNumberFormat* rbnf, + NFRuleSet* ruleSet, + const NFRule* predecessor, + const RuleBasedNumberFormat* rbnf, NFRuleList& ruleList, UErrorCode& status); @@ -70,9 +70,9 @@ class NFRule : public UMemory { void doFormat(int64_t number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; void doFormat(double number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; - UBool doParse(const UnicodeString& text, - ParsePosition& pos, - UBool isFractional, + UBool doParse(const UnicodeString& text, + ParsePosition& pos, + UBool isFractional, double upperBound, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; @@ -81,7 +81,7 @@ class NFRule : public UMemory { void _appendRuleText(UnicodeString& result) const; - int32_t findTextLenient(const UnicodeString& str, const UnicodeString& key, + int32_t findTextLenient(const UnicodeString& str, const UnicodeString& key, int32_t startingAt, int32_t* resultCount) const; void setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorCode& status); @@ -90,18 +90,18 @@ class NFRule : public UMemory { void parseRuleDescriptor(UnicodeString& descriptor, UErrorCode& status); void extractSubstitutions(const NFRuleSet* ruleSet, const UnicodeString &ruleText, const NFRule* predecessor, UErrorCode& status); NFSubstitution* extractSubstitution(const NFRuleSet* ruleSet, const NFRule* predecessor, UErrorCode& status); - + int16_t expectedExponent() const; int32_t indexOfAnyRulePrefix() const; double matchToDelimiter(const UnicodeString& text, int32_t startPos, double baseValue, - const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub, + const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub, uint32_t nonNumericalExecutedRuleMask, double upperBound) const; void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosition& pp) const; int32_t prefixLength(const UnicodeString& str, const UnicodeString& prefix, UErrorCode& status) const; UBool allIgnorable(const UnicodeString& str, UErrorCode& status) const; - int32_t findText(const UnicodeString& str, const UnicodeString& key, + int32_t findText(const UnicodeString& str, const UnicodeString& key, int32_t startingAt, int32_t* resultCount) const; private: @@ -126,3 +126,4 @@ U_NAMESPACE_END // NFRULE_H #endif + diff --git a/deps/icu-small/source/i18n/nfsubs.cpp b/deps/icu-small/source/i18n/nfsubs.cpp index 3733f0ca74d3e3..208543d1acd4de 100644 --- a/deps/icu-small/source/i18n/nfsubs.cpp +++ b/deps/icu-small/source/i18n/nfsubs.cpp @@ -88,7 +88,7 @@ class MultiplierSubstitution : public NFSubstitution { } virtual ~MultiplierSubstitution(); - virtual void setDivisor(int32_t radix, int16_t exponent, UErrorCode& status) { + virtual void setDivisor(int32_t radix, int16_t exponent, UErrorCode& status) { divisor = util64_pow(radix, exponent); if(divisor == 0) { @@ -137,7 +137,7 @@ class ModulusSubstitution : public NFSubstitution { UErrorCode& status); virtual ~ModulusSubstitution(); - virtual void setDivisor(int32_t radix, int16_t exponent, UErrorCode& status) { + virtual void setDivisor(int32_t radix, int16_t exponent, UErrorCode& status) { divisor = util64_pow(radix, exponent); if (divisor == 0) { @@ -153,7 +153,7 @@ class ModulusSubstitution : public NFSubstitution { virtual int64_t transformNumber(int64_t number) const { return number % divisor; } virtual double transformNumber(double number) const { return uprv_fmod(number, static_cast(divisor)); } - virtual UBool doParse(const UnicodeString& text, + virtual UBool doParse(const UnicodeString& text, ParsePosition& parsePosition, double baseValue, double upperBound, @@ -278,7 +278,7 @@ class NumeratorSubstitution : public NFSubstitution { NFRuleSet* _ruleSet, const UnicodeString& description, UErrorCode& status) - : NFSubstitution(_pos, _ruleSet, fixdesc(description), status), denominator(_denominator) + : NFSubstitution(_pos, _ruleSet, fixdesc(description), status), denominator(_denominator) { ldenominator = util64_fromDouble(denominator); withZeros = description.endsWith(LTLT, 2); @@ -292,7 +292,7 @@ class NumeratorSubstitution : public NFSubstitution { virtual void doSubstitution(int64_t /*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/, int32_t /*recursionCount*/, UErrorCode& /*status*/) const {} virtual void doSubstitution(double number, UnicodeString& toInsertInto, int32_t pos, int32_t recursionCount, UErrorCode& status) const; - virtual UBool doParse(const UnicodeString& text, + virtual UBool doParse(const UnicodeString& text, ParsePosition& parsePosition, double baseValue, double upperBound, @@ -592,20 +592,20 @@ NFSubstitution::doSubstitution(int64_t number, UnicodeString& toInsertInto, int3 UnicodeString temp; numberFormat->format(numberToFormat, temp, status); toInsertInto.insert(_pos + this->pos, temp); - } - else { - // We have gone beyond double precision. Something has to give. - // We're favoring accuracy of the large number over potential rules - // that round like a CompactDecimalFormat, which is not a common use case. - // - // Perform a transformation on the number that is dependent - // on the type of substitution this is, then just call its - // rule set's format() method to format the result - int64_t numberToFormat = transformNumber(number); + } + else { + // We have gone beyond double precision. Something has to give. + // We're favoring accuracy of the large number over potential rules + // that round like a CompactDecimalFormat, which is not a common use case. + // + // Perform a transformation on the number that is dependent + // on the type of substitution this is, then just call its + // rule set's format() method to format the result + int64_t numberToFormat = transformNumber(number); UnicodeString temp; numberFormat->format(numberToFormat, temp, status); toInsertInto.insert(_pos + this->pos, temp); - } + } } } @@ -1075,7 +1075,7 @@ FractionalPartSubstitution::doSubstitution(double number, UnicodeString& toInser DecimalQuantity dl; dl.setToDouble(number); dl.roundToMagnitude(-20, UNUM_ROUND_HALFEVEN, status); // round to 20 fraction digits. - + UBool pad = FALSE; for (int32_t didx = dl.getLowerDisplayMagnitude(); didx<0; didx++) { // Loop iterates over fraction digits, starting with the LSD. @@ -1254,8 +1254,8 @@ NumeratorSubstitution::doSubstitution(double number, UnicodeString& toInsertInto } } -UBool -NumeratorSubstitution::doParse(const UnicodeString& text, +UBool +NumeratorSubstitution::doParse(const UnicodeString& text, ParsePosition& parsePosition, double baseValue, double upperBound, @@ -1337,8 +1337,9 @@ NumeratorSubstitution::operator==(const NFSubstitution& rhs) const UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NumeratorSubstitution) const UChar NumeratorSubstitution::LTLT[] = { 0x003c, 0x003c }; - + U_NAMESPACE_END /* U_HAVE_RBNF */ #endif + diff --git a/deps/icu-small/source/i18n/nfsubs.h b/deps/icu-small/source/i18n/nfsubs.h index 08de06f2a38e1e..948627c0cc9740 100644 --- a/deps/icu-small/source/i18n/nfsubs.h +++ b/deps/icu-small/source/i18n/nfsubs.h @@ -35,13 +35,13 @@ class NFSubstitution : public UObject { int32_t pos; const NFRuleSet* ruleSet; DecimalFormat* numberFormat; - + protected: NFSubstitution(int32_t pos, const NFRuleSet* ruleSet, const UnicodeString& description, UErrorCode& status); - + /** * Get the Ruleset of the object. * @return the Ruleset of the object. @@ -53,21 +53,21 @@ class NFSubstitution : public UObject { * @return the numberformat of this object. */ const DecimalFormat* getNumberFormat() const { return numberFormat; } - + public: - static NFSubstitution* makeSubstitution(int32_t pos, - const NFRule* rule, + static NFSubstitution* makeSubstitution(int32_t pos, + const NFRule* rule, const NFRule* predecessor, - const NFRuleSet* ruleSet, - const RuleBasedNumberFormat* rbnf, + const NFRuleSet* ruleSet, + const RuleBasedNumberFormat* rbnf, const UnicodeString& description, UErrorCode& status); - + /** * Destructor. */ virtual ~NFSubstitution(); - + /** * Return true if the given Format objects are semantically equal. * Objects of different subclasses are considered unequal. @@ -83,7 +83,7 @@ class NFSubstitution : public UObject { * @return true if the given Format objects are semantically unequal. */ UBool operator!=(const NFSubstitution& rhs) const { return !operator==(rhs); } - + /** * Sets the substitution's divisor. Used by NFRule.setBaseValue(). * A no-op for all substitutions except multiplier and modulus @@ -92,19 +92,19 @@ class NFSubstitution : public UObject { * @param exponent The exponent of the divisor */ virtual void setDivisor(int32_t radix, int16_t exponent, UErrorCode& status); - + /** * Replaces result with the string describing the substitution. * @param result Output param which will receive the string. */ virtual void toString(UnicodeString& result) const; - + void setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorCode& status); //----------------------------------------------------------------------- // formatting //----------------------------------------------------------------------- - + /** * Performs a mathematical operation on the number, formats it using * either ruleSet or decimalFormat, and inserts the result into @@ -128,7 +128,7 @@ class NFSubstitution : public UObject { * position to determine exactly where to insert the new text) */ virtual void doSubstitution(double number, UnicodeString& toInsertInto, int32_t pos, int32_t recursionCount, UErrorCode& status) const; - + protected: /** * Subclasses override this function to perform some kind of @@ -151,12 +151,12 @@ class NFSubstitution : public UObject { * @return The result of performing the opreration on the number */ virtual double transformNumber(double number) const = 0; - + public: //----------------------------------------------------------------------- // parsing //----------------------------------------------------------------------- - + /** * Parses a string using the rule set or DecimalFormat belonging * to this substitution. If there's a match, a mathematical @@ -186,14 +186,14 @@ class NFSubstitution : public UObject { * no match this is new Long(0) (not null), and parsePosition * is left unchanged. */ - virtual UBool doParse(const UnicodeString& text, - ParsePosition& parsePosition, + virtual UBool doParse(const UnicodeString& text, + ParsePosition& parsePosition, double baseValue, - double upperBound, + double upperBound, UBool lenientParse, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; - + /** * Derives a new value from the two values passed in. The two values * are typically either the base values of two rules (the one containing @@ -207,7 +207,7 @@ class NFSubstitution : public UObject { * partial parse result */ virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const = 0; - + /** * Calculates an upper bound when searching for a rule that matches * this substitution. Rules with base values greater than or equal @@ -218,24 +218,24 @@ class NFSubstitution : public UObject { * this substitution. */ virtual double calcUpperBound(double oldUpperBound) const = 0; - + //----------------------------------------------------------------------- // simple accessors //----------------------------------------------------------------------- - + /** * Returns the substitution's position in the rule that owns it. * @return The substitution's position in the rule that owns it. */ int32_t getPos() const { return pos; } - + /** * Returns the character used in the textual representation of * substitutions of this type. Used by toString(). * @return This substitution's token character. */ virtual UChar tokenChar() const = 0; - + /** * Returns true if this is a modulus substitution. (We didn't do this * with instanceof partially because it causes source files to @@ -243,7 +243,7 @@ class NFSubstitution : public UObject { * @return true if this object is an instance of ModulusSubstitution */ virtual UBool isModulusSubstitution() const; - + private: NFSubstitution(const NFSubstitution &other); // forbid copying of this class NFSubstitution &operator=(const NFSubstitution &other); // forbid copying of this class diff --git a/deps/icu-small/source/i18n/nortrans.cpp b/deps/icu-small/source/i18n/nortrans.cpp index 589c82482ec9b9..6a8d2c74194fb0 100644 --- a/deps/icu-small/source/i18n/nortrans.cpp +++ b/deps/icu-small/source/i18n/nortrans.cpp @@ -92,7 +92,7 @@ NormalizationTransliterator::NormalizationTransliterator(const NormalizationTran /** * Transliterator API. */ -Transliterator* NormalizationTransliterator::clone(void) const { +NormalizationTransliterator* NormalizationTransliterator::clone() const { return new NormalizationTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/nortrans.h b/deps/icu-small/source/i18n/nortrans.h index d309452f9a4d6a..198ed29c95e70f 100644 --- a/deps/icu-small/source/i18n/nortrans.h +++ b/deps/icu-small/source/i18n/nortrans.h @@ -44,7 +44,7 @@ class NormalizationTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual NormalizationTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/nounit.cpp b/deps/icu-small/source/i18n/nounit.cpp index db07387c590af8..076f76f199c737 100644 --- a/deps/icu-small/source/i18n/nounit.cpp +++ b/deps/icu-small/source/i18n/nounit.cpp @@ -29,7 +29,7 @@ NoUnit::NoUnit(const char* subtype) { NoUnit::NoUnit(const NoUnit& other) : MeasureUnit(other) { } -UObject* NoUnit::clone() const { +NoUnit* NoUnit::clone() const { return new NoUnit(*this); } diff --git a/deps/icu-small/source/i18n/nultrans.cpp b/deps/icu-small/source/i18n/nultrans.cpp index 62d1290ac75e93..439cc55d381a2a 100644 --- a/deps/icu-small/source/i18n/nultrans.cpp +++ b/deps/icu-small/source/i18n/nultrans.cpp @@ -24,7 +24,7 @@ NullTransliterator::NullTransliterator() : Transliterator(UNICODE_STRING_SIMPLE( NullTransliterator::~NullTransliterator() {} -Transliterator* NullTransliterator::clone(void) const { +NullTransliterator* NullTransliterator::clone() const { return new NullTransliterator(); } diff --git a/deps/icu-small/source/i18n/nultrans.h b/deps/icu-small/source/i18n/nultrans.h index a01b04e9ba1ec9..36c92fa7b189d3 100644 --- a/deps/icu-small/source/i18n/nultrans.h +++ b/deps/icu-small/source/i18n/nultrans.h @@ -45,7 +45,7 @@ class NullTransliterator : public Transliterator { * Transliterator API. * @internal Use transliterator factory methods instead since this class will be removed in that release. */ - virtual Transliterator* clone(void) const; + virtual NullTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/number_affixutils.cpp b/deps/icu-small/source/i18n/number_affixutils.cpp index 3eb9c59bf49090..1039a84c656124 100644 --- a/deps/icu-small/source/i18n/number_affixutils.cpp +++ b/deps/icu-small/source/i18n/number_affixutils.cpp @@ -156,7 +156,7 @@ Field AffixUtils::getFieldForType(AffixPatternType type) { } int32_t -AffixUtils::unescape(const UnicodeString &affixPattern, NumberStringBuilder &output, int32_t position, +AffixUtils::unescape(const UnicodeString &affixPattern, FormattedStringBuilder &output, int32_t position, const SymbolProvider &provider, Field field, UErrorCode &status) { int32_t length = 0; AffixTag tag; @@ -230,7 +230,7 @@ UnicodeString AffixUtils::replaceType(const UnicodeString &affixPattern, AffixPa UnicodeString output(affixPattern); // copy if (affixPattern.length() == 0) { return output; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); @@ -246,7 +246,7 @@ bool AffixUtils::containsOnlySymbolsAndIgnorables(const UnicodeString& affixPatt const UnicodeSet& ignorables, UErrorCode& status) { if (affixPattern.length() == 0) { return true; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); @@ -262,7 +262,7 @@ void AffixUtils::iterateWithConsumer(const UnicodeString& affixPattern, TokenCon UErrorCode& status) { if (affixPattern.length() == 0) { return; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); diff --git a/deps/icu-small/source/i18n/number_affixutils.h b/deps/icu-small/source/i18n/number_affixutils.h index f011a54b316166..5cfde61ffd0ca2 100644 --- a/deps/icu-small/source/i18n/number_affixutils.h +++ b/deps/icu-small/source/i18n/number_affixutils.h @@ -11,7 +11,7 @@ #include "number_types.h" #include "unicode/stringpiece.h" #include "unicode/unistr.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "unicode/uniset.h" U_NAMESPACE_BEGIN namespace number { @@ -134,16 +134,16 @@ class U_I18N_API AffixUtils { /** * Executes the unescape state machine. Replaces the unquoted characters "-", "+", "%", "‰", and * "¤" with the corresponding symbols provided by the {@link SymbolProvider}, and inserts the - * result into the NumberStringBuilder at the requested location. + * result into the FormattedStringBuilder at the requested location. * *

    Example input: "'-'¤x"; example output: "-$x" * * @param affixPattern The original string to be unescaped. - * @param output The NumberStringBuilder to mutate with the result. - * @param position The index into the NumberStringBuilder to insert the string. + * @param output The FormattedStringBuilder to mutate with the result. + * @param position The index into the FormattedStringBuilder to insert the string. * @param provider An object to generate locale symbols. */ - static int32_t unescape(const UnicodeString& affixPattern, NumberStringBuilder& output, + static int32_t unescape(const UnicodeString& affixPattern, FormattedStringBuilder& output, int32_t position, const SymbolProvider& provider, Field field, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/number_asformat.cpp b/deps/icu-small/source/i18n/number_asformat.cpp index 9d3ea69f578e1e..e876174fdce0ee 100644 --- a/deps/icu-small/source/i18n/number_asformat.cpp +++ b/deps/icu-small/source/i18n/number_asformat.cpp @@ -43,7 +43,7 @@ UBool LocalizedNumberFormatterAsFormat::operator==(const Format& other) const { return fFormatter.toSkeleton(localStatus) == _other->fFormatter.toSkeleton(localStatus); } -Format* LocalizedNumberFormatterAsFormat::clone() const { +LocalizedNumberFormatterAsFormat* LocalizedNumberFormatterAsFormat::clone() const { return new LocalizedNumberFormatterAsFormat(*this); } @@ -62,12 +62,12 @@ UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, // always return first occurrence: pos.setBeginIndex(0); pos.setEndIndex(0); - bool found = data.getStringRef().nextFieldPosition(pos, status); + bool found = data.nextFieldPosition(pos, status); if (found && appendTo.length() != 0) { pos.setBeginIndex(pos.getBeginIndex() + appendTo.length()); pos.setEndIndex(pos.getEndIndex() + appendTo.length()); } - appendTo.append(data.getStringRef().toTempUnicodeString()); + appendTo.append(data.toTempString(status)); return appendTo; } @@ -84,10 +84,10 @@ UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, if (U_FAILURE(status)) { return appendTo; } - appendTo.append(data.getStringRef().toTempUnicodeString()); + appendTo.append(data.toTempString(status)); if (posIter != nullptr) { FieldPositionIteratorHandler fpih(posIter, status); - data.getStringRef().getAllFieldPositions(fpih, status); + data.getAllFieldPositions(fpih, status); } return appendTo; } diff --git a/deps/icu-small/source/i18n/number_asformat.h b/deps/icu-small/source/i18n/number_asformat.h index bf82d72ae302a4..7b0a1dee6f438b 100644 --- a/deps/icu-small/source/i18n/number_asformat.h +++ b/deps/icu-small/source/i18n/number_asformat.h @@ -45,7 +45,7 @@ class U_I18N_API LocalizedNumberFormatterAsFormat : public Format { /** * Creates a copy of this object. */ - Format* clone() const U_OVERRIDE; + LocalizedNumberFormatterAsFormat* clone() const U_OVERRIDE; /** * Formats a Number using the wrapped LocalizedNumberFormatter. The provided formattable must be a diff --git a/deps/icu-small/source/i18n/number_capi.cpp b/deps/icu-small/source/i18n/number_capi.cpp index 712e0a6631db56..f802e211049eb1 100644 --- a/deps/icu-small/source/i18n/number_capi.cpp +++ b/deps/icu-small/source/i18n/number_capi.cpp @@ -204,3 +204,30 @@ unumf_close(UNumberFormatter* f) { #endif /* #if !UCONFIG_NO_FORMATTING */ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/icu-small/source/i18n/number_compact.cpp b/deps/icu-small/source/i18n/number_compact.cpp index f330251be38c88..3d259999d6ce52 100644 --- a/deps/icu-small/source/i18n/number_compact.cpp +++ b/deps/icu-small/source/i18n/number_compact.cpp @@ -272,15 +272,15 @@ void CompactHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micr parent->processQuantity(quantity, micros, status); if (U_FAILURE(status)) { return; } - // Treat zero as if it had magnitude 0 + // Treat zero, NaN, and infinity as if they had magnitude 0 int32_t magnitude; - if (quantity.isZero()) { + if (quantity.isZeroish()) { magnitude = 0; micros.rounder.apply(quantity, status); } else { // TODO: Revisit chooseMultiplierAndApply int32_t multiplier = micros.rounder.chooseMultiplierAndApply(quantity, data, status); - magnitude = quantity.isZero() ? 0 : quantity.getMagnitude(); + magnitude = quantity.isZeroish() ? 0 : quantity.getMagnitude(); magnitude -= multiplier; } diff --git a/deps/icu-small/source/i18n/number_currencysymbols.cpp b/deps/icu-small/source/i18n/number_currencysymbols.cpp index 0b79d6596f18c0..4d6fb2cb1d8dec 100644 --- a/deps/icu-small/source/i18n/number_currencysymbols.cpp +++ b/deps/icu-small/source/i18n/number_currencysymbols.cpp @@ -53,13 +53,12 @@ UnicodeString CurrencySymbols::getCurrencySymbol(UErrorCode& status) const { UnicodeString CurrencySymbols::loadSymbol(UCurrNameStyle selector, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency(); - UBool ignoredIsChoiceFormatFillIn = FALSE; int32_t symbolLen = 0; const char16_t* symbol = ucurr_getName( isoCode, fLocaleName.data(), selector, - &ignoredIsChoiceFormatFillIn, + nullptr /* isChoiceFormat */, &symbolLen, &status); // If given an unknown currency, ucurr_getName returns the input string, which we can't alias safely! @@ -82,12 +81,11 @@ UnicodeString CurrencySymbols::getIntlCurrencySymbol(UErrorCode&) const { UnicodeString CurrencySymbols::getPluralName(StandardPlural::Form plural, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency(); - UBool isChoiceFormat = FALSE; int32_t symbolLen = 0; const char16_t* symbol = ucurr_getPluralName( isoCode, fLocaleName.data(), - &isChoiceFormat, + nullptr /* isChoiceFormat */, StandardPlural::getKeyword(plural), &symbolLen, &status); diff --git a/deps/icu-small/source/i18n/number_decimalquantity.cpp b/deps/icu-small/source/i18n/number_decimalquantity.cpp index d899c27671181e..2c4c2ce7e9931b 100644 --- a/deps/icu-small/source/i18n/number_decimalquantity.cpp +++ b/deps/icu-small/source/i18n/number_decimalquantity.cpp @@ -205,7 +205,7 @@ void DecimalQuantity::roundToIncrement(double roundingIncrement, RoundingMode ro } void DecimalQuantity::multiplyBy(const DecNum& multiplicand, UErrorCode& status) { - if (isInfinite() || isZero() || isNaN()) { + if (isZeroish()) { return; } // Convert to DecNum, multiply, and convert back. @@ -218,7 +218,7 @@ void DecimalQuantity::multiplyBy(const DecNum& multiplicand, UErrorCode& status) } void DecimalQuantity::divideBy(const DecNum& divisor, UErrorCode& status) { - if (isInfinite() || isZero() || isNaN()) { + if (isZeroish()) { return; } // Convert to DecNum, multiply, and convert back. @@ -318,8 +318,14 @@ bool DecimalQuantity::isNegative() const { return (flags & NEGATIVE_FLAG) != 0; } -int8_t DecimalQuantity::signum() const { - return isNegative() ? -1 : isZero() ? 0 : 1; +Signum DecimalQuantity::signum() const { + if (isNegative()) { + return SIGNUM_NEG; + } else if (isZeroish() && !isInfinite()) { + return SIGNUM_ZERO; + } else { + return SIGNUM_POS; + } } bool DecimalQuantity::isInfinite() const { @@ -330,7 +336,7 @@ bool DecimalQuantity::isNaN() const { return (flags & NAN_FLAG) != 0; } -bool DecimalQuantity::isZero() const { +bool DecimalQuantity::isZeroish() const { return precision == 0; } @@ -548,7 +554,10 @@ uint64_t DecimalQuantity::toFractionLong(bool includeTrailingZeros) const { } bool DecimalQuantity::fitsInLong(bool ignoreFraction) const { - if (isZero()) { + if (isInfinite() || isNaN()) { + return false; + } + if (isZeroish()) { return true; } if (scale < 0 && !ignoreFraction) { diff --git a/deps/icu-small/source/i18n/number_decimalquantity.h b/deps/icu-small/source/i18n/number_decimalquantity.h index 06cc836c7796f2..4ec6c5a5b2bcf7 100644 --- a/deps/icu-small/source/i18n/number_decimalquantity.h +++ b/deps/icu-small/source/i18n/number_decimalquantity.h @@ -146,14 +146,17 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory { */ int32_t getMagnitude() const; - /** @return Whether the value represented by this {@link DecimalQuantity} is zero. */ - bool isZero() const; + /** + * @return Whether the value represented by this {@link DecimalQuantity} is + * zero, infinity, or NaN. + */ + bool isZeroish() const; /** @return Whether the value represented by this {@link DecimalQuantity} is less than zero. */ bool isNegative() const; - /** @return -1 if the value is negative; 1 if positive; or 0 if zero. */ - int8_t signum() const; + /** @return The appropriate value from the Signum enum. */ + Signum signum() const; /** @return Whether the value represented by this {@link DecimalQuantity} is infinite. */ bool isInfinite() const U_OVERRIDE; diff --git a/deps/icu-small/source/i18n/number_decnum.h b/deps/icu-small/source/i18n/number_decnum.h index a7793470b55695..0c7399dbddd43b 100644 --- a/deps/icu-small/source/i18n/number_decnum.h +++ b/deps/icu-small/source/i18n/number_decnum.h @@ -55,6 +55,8 @@ class U_I18N_API DecNum : public UMemory { bool isZero() const; + void toString(ByteSink& output, UErrorCode& status) const; + inline const decNumber* getRawDecNumber() const { return fData.getAlias(); } diff --git a/deps/icu-small/source/i18n/number_fluent.cpp b/deps/icu-small/source/i18n/number_fluent.cpp index 09e0905609eb30..2dbd2fa6cd5acf 100644 --- a/deps/icu-small/source/i18n/number_fluent.cpp +++ b/deps/icu-small/source/i18n/number_fluent.cpp @@ -696,8 +696,8 @@ void LocalizedNumberFormatter::formatImpl(impl::UFormattedNumberData* results, U void LocalizedNumberFormatter::getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const { - NumberStringBuilder string; - auto signum = static_cast(isNegative ? -1 : 1); + FormattedStringBuilder string; + auto signum = static_cast(isNegative ? SIGNUM_NEG : SIGNUM_POS); // Always return affixes for plural form OTHER. static const StandardPlural::Form plural = StandardPlural::OTHER; int32_t prefixLength; diff --git a/deps/icu-small/source/i18n/number_formatimpl.cpp b/deps/icu-small/source/i18n/number_formatimpl.cpp index 08b833beb7ad2e..2e2c4a9620c77c 100644 --- a/deps/icu-small/source/i18n/number_formatimpl.cpp +++ b/deps/icu-small/source/i18n/number_formatimpl.cpp @@ -72,7 +72,7 @@ NumberFormatterImpl::NumberFormatterImpl(const MacroProps& macros, UErrorCode& s } int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuantity& inValue, - NumberStringBuilder& outString, UErrorCode& status) { + FormattedStringBuilder& outString, UErrorCode& status) { NumberFormatterImpl impl(macros, false, status); MicroProps& micros = impl.preProcessUnsafe(inValue, status); if (U_FAILURE(status)) { return 0; } @@ -81,9 +81,9 @@ int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuant return length; } -int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, int8_t signum, +int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, Signum signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) { + FormattedStringBuilder& outString, UErrorCode& status) { NumberFormatterImpl impl(macros, false, status); return impl.getPrefixSuffixUnsafe(signum, plural, outString, status); } @@ -93,7 +93,7 @@ int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, int // The "unsafe" method simply re-uses fMicros, eliminating the extra copy operation. // See MicroProps::processQuantity() for details. -int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, NumberStringBuilder& outString, +int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const { MicroProps micros; preProcess(inValue, micros, status); @@ -129,8 +129,8 @@ MicroProps& NumberFormatterImpl::preProcessUnsafe(DecimalQuantity& inValue, UErr return fMicros; } -int32_t NumberFormatterImpl::getPrefixSuffix(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) const { +int32_t NumberFormatterImpl::getPrefixSuffix(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status) const { if (U_FAILURE(status)) { return 0; } // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle, aka pattern modifier). // Safe path: use fImmutablePatternModifier. @@ -140,8 +140,8 @@ int32_t NumberFormatterImpl::getPrefixSuffix(int8_t signum, StandardPlural::Form return modifier->getPrefixLength(); } -int32_t NumberFormatterImpl::getPrefixSuffixUnsafe(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) { +int32_t NumberFormatterImpl::getPrefixSuffixUnsafe(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status) { if (U_FAILURE(status)) { return 0; } // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle, aka pattern modifier). // Unsafe path: use fPatternModifier. @@ -215,7 +215,12 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (macros.symbols.isDecimalFormatSymbols()) { fMicros.symbols = macros.symbols.getDecimalFormatSymbols(); } else { - fMicros.symbols = new DecimalFormatSymbols(macros.locale, *ns, status); + auto newSymbols = new DecimalFormatSymbols(macros.locale, *ns, status); + if (newSymbols == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fMicros.symbols = newSymbols; // Give ownership to the NumberFormatterImpl. fSymbols.adoptInstead(fMicros.symbols); } @@ -229,7 +234,11 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (info.exists) { pattern = info.pattern; // It's clunky to clone an object here, but this code is not frequently executed. - auto* symbols = new DecimalFormatSymbols(*fMicros.symbols); + auto symbols = new DecimalFormatSymbols(*fMicros.symbols); + if (symbols == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fMicros.symbols = symbols; fSymbols.adoptInstead(symbols); symbols->setSymbol( @@ -260,6 +269,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, pattern = utils::getPatternForStyle(macros.locale, nsName, patternStyle, status); } auto patternInfo = new ParsedPatternInfo(); + if (patternInfo == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fPatternInfo.adoptInstead(patternInfo); PatternParser::parseToPatternInfo(UnicodeString(pattern), *patternInfo, status); @@ -337,7 +350,12 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, // Inner modifier (scientific notation) if (macros.notation.fType == Notation::NTN_SCIENTIFIC) { - fScientificHandler.adoptInstead(new ScientificHandler(¯os.notation, fMicros.symbols, chain)); + auto newScientificHandler = new ScientificHandler(¯os.notation, fMicros.symbols, chain); + if (newScientificHandler == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fScientificHandler.adoptInstead(newScientificHandler); chain = fScientificHandler.getAlias(); } else { // No inner modifier required @@ -346,6 +364,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, // Middle modifier (patterns, positive/negative, currency symbols, percent) auto patternModifier = new MutablePatternModifier(false); + if (patternModifier == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fPatternModifier.adoptInstead(patternModifier); patternModifier->setPatternInfo( macros.affixProvider != nullptr ? macros.affixProvider @@ -401,16 +423,20 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (macros.notation.fType == Notation::NTN_COMPACT) { CompactType compactType = (isCurrency && unitWidth != UNUM_UNIT_WIDTH_FULL_NAME) ? CompactType::TYPE_CURRENCY : CompactType::TYPE_DECIMAL; - fCompactHandler.adoptInstead( - new CompactHandler( - macros.notation.fUnion.compactStyle, - macros.locale, - nsName, - compactType, - resolvePluralRules(macros.rules, macros.locale, status), - safe ? patternModifier : nullptr, - chain, - status)); + auto newCompactHandler = new CompactHandler( + macros.notation.fUnion.compactStyle, + macros.locale, + nsName, + compactType, + resolvePluralRules(macros.rules, macros.locale, status), + safe ? patternModifier : nullptr, + chain, + status); + if (newCompactHandler == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fCompactHandler.adoptInstead(newCompactHandler); chain = fCompactHandler.getAlias(); } @@ -430,7 +456,7 @@ NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Local return fRules.getAlias(); } -int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, NumberStringBuilder& string, +int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStringBuilder& string, int32_t start, int32_t end, UErrorCode& status) { // Always apply the inner modifier (which is "strong"). int32_t length = micros.modInner->apply(string, start, end, status); @@ -445,7 +471,7 @@ int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, NumberString } int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int32_t length = 0; if (quantity.isInfinite()) { @@ -487,7 +513,7 @@ int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuanti } int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int length = 0; int integerCount = quantity.getUpperDisplayMagnitude() + 1; @@ -513,7 +539,7 @@ int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, Decima } int32_t NumberFormatterImpl::writeFractionDigits(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int length = 0; int fractionCount = -quantity.getLowerDisplayMagnitude(); diff --git a/deps/icu-small/source/i18n/number_formatimpl.h b/deps/icu-small/source/i18n/number_formatimpl.h index fd8708c532e131..206c5f58c576a1 100644 --- a/deps/icu-small/source/i18n/number_formatimpl.h +++ b/deps/icu-small/source/i18n/number_formatimpl.h @@ -8,7 +8,7 @@ #define __NUMBER_FORMATIMPL_H__ #include "number_types.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_patternstring.h" #include "number_utils.h" #include "number_patternmodifier.h" @@ -35,7 +35,7 @@ class NumberFormatterImpl : public UMemory { * Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once. */ static int32_t - formatStatic(const MacroProps ¯os, DecimalQuantity &inValue, NumberStringBuilder &outString, + formatStatic(const MacroProps ¯os, DecimalQuantity &inValue, FormattedStringBuilder &outString, UErrorCode &status); /** @@ -44,14 +44,14 @@ class NumberFormatterImpl : public UMemory { * @return The index into the output at which the prefix ends and the suffix starts; in other words, * the prefix length. */ - static int32_t getPrefixSuffixStatic(const MacroProps& macros, int8_t signum, - StandardPlural::Form plural, NumberStringBuilder& outString, + static int32_t getPrefixSuffixStatic(const MacroProps& macros, Signum signum, + StandardPlural::Form plural, FormattedStringBuilder& outString, UErrorCode& status); /** * Evaluates the "safe" MicroPropsGenerator created by "fromMacros". */ - int32_t format(DecimalQuantity& inValue, NumberStringBuilder& outString, UErrorCode& status) const; + int32_t format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const; /** * Like format(), but saves the result into an output MicroProps without additional processing. @@ -61,7 +61,7 @@ class NumberFormatterImpl : public UMemory { /** * Like getPrefixSuffixStatic() but uses the safe compiled object. */ - int32_t getPrefixSuffix(int8_t signum, StandardPlural::Form plural, NumberStringBuilder& outString, + int32_t getPrefixSuffix(Signum signum, StandardPlural::Form plural, FormattedStringBuilder& outString, UErrorCode& status) const; const MicroProps& getRawMicroProps() const { @@ -73,12 +73,12 @@ class NumberFormatterImpl : public UMemory { * This method formats only the main number, not affixes. */ static int32_t writeNumber(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, UErrorCode& status); + FormattedStringBuilder& string, int32_t index, UErrorCode& status); /** * Adds the affixes. Intended to be called immediately after formatNumber. */ - static int32_t writeAffixes(const MicroProps& micros, NumberStringBuilder& string, int32_t start, + static int32_t writeAffixes(const MicroProps& micros, FormattedStringBuilder& string, int32_t start, int32_t end, UErrorCode& status); private: @@ -109,8 +109,8 @@ class NumberFormatterImpl : public UMemory { MicroProps& preProcessUnsafe(DecimalQuantity &inValue, UErrorCode &status); - int32_t getPrefixSuffixUnsafe(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status); + int32_t getPrefixSuffixUnsafe(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status); /** * If rulesPtr is non-null, return it. Otherwise, return a PluralRules owned by this object for the @@ -136,11 +136,11 @@ class NumberFormatterImpl : public UMemory { macrosToMicroGenerator(const MacroProps ¯os, bool safe, UErrorCode &status); static int32_t - writeIntegerDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string, + writeIntegerDigits(const MicroProps µs, DecimalQuantity &quantity, FormattedStringBuilder &string, int32_t index, UErrorCode &status); static int32_t - writeFractionDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string, + writeFractionDigits(const MicroProps µs, DecimalQuantity &quantity, FormattedStringBuilder &string, int32_t index, UErrorCode &status); }; diff --git a/deps/icu-small/source/i18n/number_longnames.cpp b/deps/icu-small/source/i18n/number_longnames.cpp index 0cd160042a46d3..817aa0e0d9c39d 100644 --- a/deps/icu-small/source/i18n/number_longnames.cpp +++ b/deps/icu-small/source/i18n/number_longnames.cpp @@ -148,12 +148,11 @@ void getCurrencyLongNameData(const Locale &locale, const CurrencyUnit ¤cy, if (pattern.isBogus()) { continue; } - UBool isChoiceFormat = FALSE; int32_t longNameLen = 0; const char16_t *longName = ucurr_getPluralName( currency.getISOCurrency(), locale.getName(), - &isChoiceFormat, + nullptr /* isChoiceFormat */, StandardPlural::getKeyword(static_cast(i)), &longNameLen, &status); @@ -265,6 +264,26 @@ UnicodeString LongNameHandler::getUnitDisplayName( return simpleFormats[DNAM_INDEX]; } +UnicodeString LongNameHandler::getUnitPattern( + const Locale& loc, + const MeasureUnit& unit, + UNumberUnitWidth width, + StandardPlural::Form pluralForm, + UErrorCode& status) { + if (U_FAILURE(status)) { + return ICU_Utility::makeBogusString(); + } + UnicodeString simpleFormats[ARRAY_LENGTH]; + getMeasureData(loc, unit, width, simpleFormats, status); + // The above already handles fallback from other widths to short + if (U_FAILURE(status)) { + return ICU_Utility::makeBogusString(); + } + // Now handle fallback from other plural forms to OTHER + return (!(simpleFormats[pluralForm]).isBogus())? simpleFormats[pluralForm]: + simpleFormats[StandardPlural::Form::OTHER]; +} + LongNameHandler* LongNameHandler::forCurrencyLongNames(const Locale &loc, const CurrencyUnit ¤cy, const PluralRules *rules, const MicroPropsGenerator *parent, @@ -289,7 +308,7 @@ void LongNameHandler::simpleFormatsToModifiers(const UnicodeString *simpleFormat if (U_FAILURE(status)) { return; } SimpleFormatter compiledFormatter(simpleFormat, 0, 1, status); if (U_FAILURE(status)) { return; } - fModifiers[i] = SimpleModifier(compiledFormatter, field, false, {this, 0, plural}); + fModifiers[i] = SimpleModifier(compiledFormatter, field, false, {this, SIGNUM_ZERO, plural}); } } @@ -306,7 +325,7 @@ void LongNameHandler::multiSimpleFormatsToModifiers(const UnicodeString *leadFor if (U_FAILURE(status)) { return; } SimpleFormatter compoundCompiled(compoundFormat, 0, 1, status); if (U_FAILURE(status)) { return; } - fModifiers[i] = SimpleModifier(compoundCompiled, field, false, {this, 0, plural}); + fModifiers[i] = SimpleModifier(compoundCompiled, field, false, {this, SIGNUM_ZERO, plural}); } } @@ -317,7 +336,7 @@ void LongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps &mic micros.modOuter = &fModifiers[pluralForm]; } -const Modifier* LongNameHandler::getModifier(int8_t /*signum*/, StandardPlural::Form plural) const { +const Modifier* LongNameHandler::getModifier(Signum /*signum*/, StandardPlural::Form plural) const { return &fModifiers[plural]; } diff --git a/deps/icu-small/source/i18n/number_longnames.h b/deps/icu-small/source/i18n/number_longnames.h index 76fb82d744b6d4..a19425aa268af6 100644 --- a/deps/icu-small/source/i18n/number_longnames.h +++ b/deps/icu-small/source/i18n/number_longnames.h @@ -22,6 +22,13 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public UNumberUnitWidth width, UErrorCode& status); + static UnicodeString getUnitPattern( + const Locale& loc, + const MeasureUnit& unit, + UNumberUnitWidth width, + StandardPlural::Form pluralForm, + UErrorCode& status); + static LongNameHandler* forCurrencyLongNames(const Locale &loc, const CurrencyUnit ¤cy, const PluralRules *rules, const MicroPropsGenerator *parent, UErrorCode &status); @@ -34,7 +41,7 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public void processQuantity(DecimalQuantity &quantity, MicroProps µs, UErrorCode &status) const U_OVERRIDE; - const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const U_OVERRIDE; + const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE; private: SimpleModifier fModifiers[StandardPlural::Form::COUNT]; diff --git a/deps/icu-small/source/i18n/number_mapper.h b/deps/icu-small/source/i18n/number_mapper.h index d28e9cec393a05..de7d9c3865c8df 100644 --- a/deps/icu-small/source/i18n/number_mapper.h +++ b/deps/icu-small/source/i18n/number_mapper.h @@ -126,8 +126,14 @@ struct DecimalFormatWarehouse { * TODO: Make some of these fields by value instead of by LocalPointer? */ struct DecimalFormatFields : public UMemory { + + DecimalFormatFields() {} + + DecimalFormatFields(const DecimalFormatProperties& propsToCopy) + : properties(propsToCopy) {} + /** The property bag corresponding to user-specified settings and settings from the pattern string. */ - LocalPointer properties; + DecimalFormatProperties properties; /** The symbols for the current locale. */ LocalPointer symbols; @@ -136,7 +142,7 @@ struct DecimalFormatFields : public UMemory { * The pre-computed formatter object. Setters cause this to be re-computed atomically. The {@link * #format} method uses the formatter directly without needing to synchronize. */ - LocalPointer formatter; + LocalizedNumberFormatter formatter; /** The lazy-computed parser for .parse() */ std::atomic<::icu::numparse::impl::NumberParserImpl*> atomicParser = {}; @@ -148,7 +154,7 @@ struct DecimalFormatFields : public UMemory { DecimalFormatWarehouse warehouse; /** The effective properties as exported from the formatter object. Used by some getters. */ - LocalPointer exportedProperties; + DecimalFormatProperties exportedProperties; // Data for fastpath bool canUseFastFormat = false; diff --git a/deps/icu-small/source/i18n/number_modifiers.cpp b/deps/icu-small/source/i18n/number_modifiers.cpp index 1fcbe7b9b79301..3a44f8f6f15328 100644 --- a/deps/icu-small/source/i18n/number_modifiers.cpp +++ b/deps/icu-small/source/i18n/number_modifiers.cpp @@ -57,7 +57,7 @@ Modifier::Parameters::Parameters() : obj(nullptr) {} Modifier::Parameters::Parameters( - const ModifierStore* _obj, int8_t _signum, StandardPlural::Form _plural) + const ModifierStore* _obj, Signum _signum, StandardPlural::Form _plural) : obj(_obj), signum(_signum), plural(_plural) {} ModifierStore::~ModifierStore() = default; @@ -69,7 +69,7 @@ AdoptingModifierStore::~AdoptingModifierStore() { } -int32_t ConstantAffixModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t ConstantAffixModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { // Insert the suffix first since inserting the prefix will change the rightIndex int length = output.insert(rightIndex, fSuffix, fField, status); @@ -154,7 +154,7 @@ SimpleModifier::SimpleModifier() : fField(UNUM_FIELD_COUNT), fStrong(false), fPrefixLength(0), fSuffixLength(0) { } -int32_t SimpleModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t SimpleModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { return formatAsPrefixSuffix(output, leftIndex, rightIndex, status); } @@ -203,7 +203,7 @@ bool SimpleModifier::semanticallyEquivalent(const Modifier& other) const { int32_t -SimpleModifier::formatAsPrefixSuffix(NumberStringBuilder &result, int32_t startIndex, int32_t endIndex, +SimpleModifier::formatAsPrefixSuffix(FormattedStringBuilder &result, int32_t startIndex, int32_t endIndex, UErrorCode &status) const { if (fSuffixOffset == -1 && fPrefixLength + fSuffixLength > 0) { // There is no argument for the inner number; overwrite the entire segment with our string. @@ -227,7 +227,7 @@ SimpleModifier::formatAsPrefixSuffix(NumberStringBuilder &result, int32_t startI int32_t -SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, NumberStringBuilder& result, +SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, FormattedStringBuilder& result, int32_t index, int32_t* outPrefixLength, int32_t* outSuffixLength, Field field, UErrorCode& status) { const UnicodeString& compiledPattern = compiled.compiledPattern; @@ -284,7 +284,7 @@ SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, NumberStrin } -int32_t ConstantMultiFieldModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t ConstantMultiFieldModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { int32_t length = output.insert(leftIndex, fPrefix, status); if (fOverwrite) { @@ -333,8 +333,8 @@ bool ConstantMultiFieldModifier::semanticallyEquivalent(const Modifier& other) c } -CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, +CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const DecimalFormatSymbols &symbols, @@ -374,7 +374,7 @@ CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const NumberStrin } } -int32_t CurrencySpacingEnabledModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t CurrencySpacingEnabledModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { // Currency spacing logic int length = 0; @@ -395,7 +395,7 @@ int32_t CurrencySpacingEnabledModifier::apply(NumberStringBuilder &output, int l } int32_t -CurrencySpacingEnabledModifier::applyCurrencySpacing(NumberStringBuilder &output, int32_t prefixStart, +CurrencySpacingEnabledModifier::applyCurrencySpacing(FormattedStringBuilder &output, int32_t prefixStart, int32_t prefixLen, int32_t suffixStart, int32_t suffixLen, const DecimalFormatSymbols &symbols, @@ -414,7 +414,7 @@ CurrencySpacingEnabledModifier::applyCurrencySpacing(NumberStringBuilder &output } int32_t -CurrencySpacingEnabledModifier::applyCurrencySpacingAffix(NumberStringBuilder &output, int32_t index, +CurrencySpacingEnabledModifier::applyCurrencySpacingAffix(FormattedStringBuilder &output, int32_t index, EAffix affix, const DecimalFormatSymbols &symbols, UErrorCode &status) { diff --git a/deps/icu-small/source/i18n/number_modifiers.h b/deps/icu-small/source/i18n/number_modifiers.h index 495128bb149dcf..c84c6aa273ed76 100644 --- a/deps/icu-small/source/i18n/number_modifiers.h +++ b/deps/icu-small/source/i18n/number_modifiers.h @@ -12,7 +12,7 @@ #include "unicode/uniset.h" #include "unicode/simpleformatter.h" #include "standardplural.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_types.h" U_NAMESPACE_BEGIN namespace number { @@ -28,7 +28,7 @@ class U_I18N_API ConstantAffixModifier : public Modifier, public UObject { bool strong) : fPrefix(prefix), fSuffix(suffix), fField(field), fStrong(strong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -64,7 +64,7 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { // Default constructor for LongNameHandler.h SimpleModifier(); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -81,7 +81,7 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { /** * TODO: This belongs in SimpleFormatterImpl. The only reason I haven't moved it there yet is because - * NumberStringBuilder is an internal class and SimpleFormatterImpl feels like it should not depend on it. + * FormattedStringBuilder is an internal class and SimpleFormatterImpl feels like it should not depend on it. * *

    * Formats a value that is already stored inside the StringBuilder result between the indices @@ -100,22 +100,22 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { * @return The number of characters (UTF-16 code points) that were added to the StringBuilder. */ int32_t - formatAsPrefixSuffix(NumberStringBuilder& result, int32_t startIndex, int32_t endIndex, + formatAsPrefixSuffix(FormattedStringBuilder& result, int32_t startIndex, int32_t endIndex, UErrorCode& status) const; /** * TODO: Like above, this belongs with the rest of the SimpleFormatterImpl code. - * I put it here so that the SimpleFormatter uses in NumberStringBuilder are near each other. + * I put it here so that the SimpleFormatter uses in FormattedStringBuilder are near each other. * *

    - * Applies the compiled two-argument pattern to the NumberStringBuilder. + * Applies the compiled two-argument pattern to the FormattedStringBuilder. * *

    * This method is optimized for the case where the prefix and suffix are often empty, such as * in the range pattern like "{0}-{1}". */ static int32_t - formatTwoArgPattern(const SimpleFormatter& compiled, NumberStringBuilder& result, + formatTwoArgPattern(const SimpleFormatter& compiled, FormattedStringBuilder& result, int32_t index, int32_t* outPrefixLength, int32_t* outSuffixLength, Field field, UErrorCode& status); @@ -131,13 +131,13 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { /** * An implementation of {@link Modifier} that allows for multiple types of fields in the same modifier. Constructed - * based on the contents of two {@link NumberStringBuilder} instances (one for the prefix, one for the suffix). + * based on the contents of two {@link FormattedStringBuilder} instances (one for the prefix, one for the suffix). */ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { public: ConstantMultiFieldModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const Modifier::Parameters parameters) @@ -148,8 +148,8 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { fParameters(parameters) {} ConstantMultiFieldModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong) : fPrefix(prefix), @@ -157,7 +157,7 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { fOverwrite(overwrite), fStrong(strong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -173,10 +173,10 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE; protected: - // NOTE: In Java, these are stored as array pointers. In C++, the NumberStringBuilder is stored by + // NOTE: In Java, these are stored as array pointers. In C++, the FormattedStringBuilder is stored by // value and is treated internally as immutable. - NumberStringBuilder fPrefix; - NumberStringBuilder fSuffix; + FormattedStringBuilder fPrefix; + FormattedStringBuilder fSuffix; bool fOverwrite; bool fStrong; Modifier::Parameters fParameters; @@ -187,19 +187,19 @@ class U_I18N_API CurrencySpacingEnabledModifier : public ConstantMultiFieldModif public: /** Safe code path */ CurrencySpacingEnabledModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const DecimalFormatSymbols &symbols, UErrorCode &status); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; /** Unsafe code path */ static int32_t - applyCurrencySpacing(NumberStringBuilder &output, int32_t prefixStart, int32_t prefixLen, + applyCurrencySpacing(FormattedStringBuilder &output, int32_t prefixStart, int32_t prefixLen, int32_t suffixStart, int32_t suffixLen, const DecimalFormatSymbols &symbols, UErrorCode &status); @@ -218,7 +218,7 @@ class U_I18N_API CurrencySpacingEnabledModifier : public ConstantMultiFieldModif }; /** Unsafe code path */ - static int32_t applyCurrencySpacingAffix(NumberStringBuilder &output, int32_t index, EAffix affix, + static int32_t applyCurrencySpacingAffix(FormattedStringBuilder &output, int32_t index, EAffix affix, const DecimalFormatSymbols &symbols, UErrorCode &status); static UnicodeSet @@ -234,7 +234,7 @@ class U_I18N_API EmptyModifier : public Modifier, public UMemory { public: explicit EmptyModifier(bool isStrong) : fStrong(isStrong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE { (void)output; (void)leftIndex; @@ -289,7 +289,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { /** * Sets the Modifier with the specified signum and plural form. */ - void adoptModifier(int8_t signum, StandardPlural::Form plural, const Modifier *mod) { + void adoptModifier(Signum signum, StandardPlural::Form plural, const Modifier *mod) { U_ASSERT(mods[getModIndex(signum, plural)] == nullptr); mods[getModIndex(signum, plural)] = mod; } @@ -298,13 +298,13 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { * Sets the Modifier with the specified signum. * The modifier will apply to all plural forms. */ - void adoptModifierWithoutPlural(int8_t signum, const Modifier *mod) { + void adoptModifierWithoutPlural(Signum signum, const Modifier *mod) { U_ASSERT(mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] == nullptr); mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] = mod; } /** Returns a reference to the modifier; no ownership change. */ - const Modifier *getModifier(int8_t signum, StandardPlural::Form plural) const U_OVERRIDE { + const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE { const Modifier* modifier = mods[getModIndex(signum, plural)]; if (modifier == nullptr && plural != DEFAULT_STANDARD_PLURAL) { modifier = mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)]; @@ -313,7 +313,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { } /** Returns a reference to the modifier; no ownership change. */ - const Modifier *getModifierWithoutPlural(int8_t signum) const { + const Modifier *getModifierWithoutPlural(Signum signum) const { return mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)]; } @@ -321,7 +321,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { // NOTE: mods is zero-initialized (to nullptr) const Modifier *mods[3 * StandardPlural::COUNT] = {}; - inline static int32_t getModIndex(int8_t signum, StandardPlural::Form plural) { + inline static int32_t getModIndex(Signum signum, StandardPlural::Form plural) { U_ASSERT(signum >= -1 && signum <= 1); U_ASSERT(plural >= 0 && plural < StandardPlural::COUNT); return static_cast(plural) * 3 + (signum + 1); diff --git a/deps/icu-small/source/i18n/number_output.cpp b/deps/icu-small/source/i18n/number_output.cpp index 6f4e2482044f14..e2f069139a4b47 100644 --- a/deps/icu-small/source/i18n/number_output.cpp +++ b/deps/icu-small/source/i18n/number_output.cpp @@ -9,6 +9,7 @@ #include "number_utypes.h" #include "util.h" #include "number_decimalquantity.h" +#include "number_decnum.h" U_NAMESPACE_BEGIN namespace number { @@ -20,8 +21,7 @@ UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber) UBool FormattedNumber::nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) - // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fData->getStringRef().nextFieldPosition(fieldPosition, status) ? TRUE : FALSE; + return fData->nextFieldPosition(fieldPosition, status); } void FormattedNumber::getAllFieldPositions(FieldPositionIterator& iterator, UErrorCode& status) const { @@ -29,10 +29,17 @@ void FormattedNumber::getAllFieldPositions(FieldPositionIterator& iterator, UErr getAllFieldPositionsImpl(fpih, status); } +void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const { + UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) + impl::DecNum decnum; + fData->quantity.toDecNum(decnum, status); + decnum.toString(sink, status); +} + void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) - fData->getStringRef().getAllFieldPositions(fpih, status); + fData->getAllFieldPositions(fpih, status); } void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const { diff --git a/deps/icu-small/source/i18n/number_padding.cpp b/deps/icu-small/source/i18n/number_padding.cpp index 31684d7208b606..c68a9875b2055f 100644 --- a/deps/icu-small/source/i18n/number_padding.cpp +++ b/deps/icu-small/source/i18n/number_padding.cpp @@ -7,7 +7,7 @@ #include "unicode/numberformatter.h" #include "number_types.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_decimfmtprops.h" using namespace icu; @@ -17,7 +17,7 @@ using namespace icu::number::impl; namespace { int32_t -addPaddingHelper(UChar32 paddingCp, int32_t requiredPadding, NumberStringBuilder &string, int32_t index, +addPaddingHelper(UChar32 paddingCp, int32_t requiredPadding, FormattedStringBuilder &string, int32_t index, UErrorCode &status) { for (int32_t i = 0; i < requiredPadding; i++) { // TODO: If appending to the end, this will cause actual insertion operations. Improve. @@ -60,7 +60,7 @@ Padder Padder::forProperties(const DecimalFormatProperties& properties) { } int32_t Padder::padAndApply(const Modifier &mod1, const Modifier &mod2, - NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex, + FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const { int32_t modLength = mod1.getCodePointCount() + mod2.getCodePointCount(); int32_t requiredPadding = fWidth - modLength - string.codePointCount(); diff --git a/deps/icu-small/source/i18n/number_patternmodifier.cpp b/deps/icu-small/source/i18n/number_patternmodifier.cpp index 75de439f3ed2e1..724f5b9741cc52 100644 --- a/deps/icu-small/source/i18n/number_patternmodifier.cpp +++ b/deps/icu-small/source/i18n/number_patternmodifier.cpp @@ -43,7 +43,7 @@ void MutablePatternModifier::setSymbols(const DecimalFormatSymbols* symbols, fRules = rules; } -void MutablePatternModifier::setNumberProperties(int8_t signum, StandardPlural::Form plural) { +void MutablePatternModifier::setNumberProperties(Signum signum, StandardPlural::Form plural) { fSignum = signum; fPlural = plural; } @@ -79,12 +79,12 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren if (needsPlurals()) { // Slower path when we require the plural keyword. for (StandardPlural::Form plural : STANDARD_PLURAL_VALUES) { - setNumberProperties(1, plural); - pm->adoptModifier(1, plural, createConstantModifier(status)); - setNumberProperties(0, plural); - pm->adoptModifier(0, plural, createConstantModifier(status)); - setNumberProperties(-1, plural); - pm->adoptModifier(-1, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_POS, plural); + pm->adoptModifier(SIGNUM_POS, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_ZERO, plural); + pm->adoptModifier(SIGNUM_ZERO, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG, plural); + pm->adoptModifier(SIGNUM_NEG, plural, createConstantModifier(status)); } if (U_FAILURE(status)) { delete pm; @@ -93,12 +93,12 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren return new ImmutablePatternModifier(pm, fRules, parent); // adopts pm } else { // Faster path when plural keyword is not needed. - setNumberProperties(1, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(1, createConstantModifier(status)); - setNumberProperties(0, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(0, createConstantModifier(status)); - setNumberProperties(-1, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(-1, createConstantModifier(status)); + setNumberProperties(SIGNUM_POS, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_POS, createConstantModifier(status)); + setNumberProperties(SIGNUM_ZERO, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_ZERO, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_NEG, createConstantModifier(status)); if (U_FAILURE(status)) { delete pm; return nullptr; @@ -108,8 +108,8 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren } ConstantMultiFieldModifier* MutablePatternModifier::createConstantModifier(UErrorCode& status) { - NumberStringBuilder a; - NumberStringBuilder b; + FormattedStringBuilder a; + FormattedStringBuilder b; insertPrefix(a, 0, status); insertSuffix(b, 0, status); if (fPatternInfo->hasCurrencySign()) { @@ -140,7 +140,7 @@ void ImmutablePatternModifier::applyToMicros( } } -const Modifier* ImmutablePatternModifier::getModifier(int8_t signum, StandardPlural::Form plural) const { +const Modifier* ImmutablePatternModifier::getModifier(Signum signum, StandardPlural::Form plural) const { if (rules == nullptr) { return pm->getModifierWithoutPlural(signum); } else { @@ -170,7 +170,7 @@ void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& mi micros.modMiddle = this; } -int32_t MutablePatternModifier::apply(NumberStringBuilder& output, int32_t leftIndex, int32_t rightIndex, +int32_t MutablePatternModifier::apply(FormattedStringBuilder& output, int32_t leftIndex, int32_t rightIndex, UErrorCode& status) const { // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. @@ -248,13 +248,13 @@ bool MutablePatternModifier::semanticallyEquivalent(const Modifier& other) const UPRV_UNREACHABLE; } -int32_t MutablePatternModifier::insertPrefix(NumberStringBuilder& sb, int position, UErrorCode& status) { +int32_t MutablePatternModifier::insertPrefix(FormattedStringBuilder& sb, int position, UErrorCode& status) { prepareAffix(true); int32_t length = AffixUtils::unescape(currentAffix, sb, position, *this, fField, status); return length; } -int32_t MutablePatternModifier::insertSuffix(NumberStringBuilder& sb, int position, UErrorCode& status) { +int32_t MutablePatternModifier::insertSuffix(FormattedStringBuilder& sb, int position, UErrorCode& status) { prepareAffix(false); int32_t length = AffixUtils::unescape(currentAffix, sb, position, *this, fField, status); return length; diff --git a/deps/icu-small/source/i18n/number_patternmodifier.h b/deps/icu-small/source/i18n/number_patternmodifier.h index 27e293b64ce50f..b2c90e0af76354 100644 --- a/deps/icu-small/source/i18n/number_patternmodifier.h +++ b/deps/icu-small/source/i18n/number_patternmodifier.h @@ -48,7 +48,7 @@ class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator, public U void applyToMicros(MicroProps& micros, const DecimalQuantity& quantity, UErrorCode& status) const; - const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const; + const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const; private: ImmutablePatternModifier(AdoptingModifierStore* pm, const PluralRules* rules, @@ -142,7 +142,7 @@ class U_I18N_API MutablePatternModifier * The plural form of the number, required only if the pattern contains the triple * currency sign, "¤¤¤" (and as indicated by {@link #needsPlurals()}). */ - void setNumberProperties(int8_t signum, StandardPlural::Form plural); + void setNumberProperties(Signum signum, StandardPlural::Form plural); /** * Returns true if the pattern represented by this MurkyModifier requires a plural keyword in order to localize. @@ -184,7 +184,7 @@ class U_I18N_API MutablePatternModifier void processQuantity(DecimalQuantity &, MicroProps µs, UErrorCode &status) const U_OVERRIDE; - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -223,7 +223,7 @@ class U_I18N_API MutablePatternModifier const PluralRules *fRules; // Number details (initialized in setNumberProperties) - int8_t fSignum; + Signum fSignum; StandardPlural::Form fPlural; // QuantityChain details (initialized in addToChain) @@ -240,17 +240,17 @@ class U_I18N_API MutablePatternModifier * CREATES A NEW HEAP OBJECT; THE CALLER GETS OWNERSHIP. * * @param a - * A working NumberStringBuilder object; passed from the outside to prevent the need to create many new + * A working FormattedStringBuilder object; passed from the outside to prevent the need to create many new * instances if this method is called in a loop. * @param b - * Another working NumberStringBuilder object. + * Another working FormattedStringBuilder object. * @return The constant modifier object. */ ConstantMultiFieldModifier *createConstantModifier(UErrorCode &status); - int32_t insertPrefix(NumberStringBuilder &sb, int position, UErrorCode &status); + int32_t insertPrefix(FormattedStringBuilder &sb, int position, UErrorCode &status); - int32_t insertSuffix(NumberStringBuilder &sb, int position, UErrorCode &status); + int32_t insertSuffix(FormattedStringBuilder &sb, int position, UErrorCode &status); void prepareAffix(bool isPrefix); }; diff --git a/deps/icu-small/source/i18n/number_patternstring.cpp b/deps/icu-small/source/i18n/number_patternstring.cpp index 90754246633064..c7212c1e5c23fe 100644 --- a/deps/icu-small/source/i18n/number_patternstring.cpp +++ b/deps/icu-small/source/i18n/number_patternstring.cpp @@ -352,7 +352,7 @@ void ParsedPatternInfo::consumeIntegerFormat(UErrorCode& status) { result.groupingSizes += 1; result.integerNumerals += 1; result.integerTotal += 1; - if (!result.rounding.isZero() || state.peek() != u'0') { + if (!result.rounding.isZeroish() || state.peek() != u'0') { result.rounding.appendDigit(static_cast(state.peek() - u'0'), 0, true); } break; @@ -532,7 +532,7 @@ PatternParser::patternInfoToProperties(DecimalFormatProperties& properties, Pars properties.roundingIncrement = 0.0; properties.minimumSignificantDigits = positive.integerAtSigns; properties.maximumSignificantDigits = positive.integerAtSigns + positive.integerTrailingHashSigns; - } else if (!positive.rounding.isZero()) { + } else if (!positive.rounding.isZeroish()) { if (!ignoreRounding) { properties.minimumFractionDigits = minFrac; properties.maximumFractionDigits = positive.fractionTotal; @@ -1000,7 +1000,7 @@ PatternStringUtils::convertLocalized(const UnicodeString& input, const DecimalFo } void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider& patternInfo, bool isPrefix, - int8_t signum, UNumberSignDisplay signDisplay, + Signum signum, UNumberSignDisplay signDisplay, StandardPlural::Form plural, bool perMilleReplacesPercent, UnicodeString& output) { @@ -1014,6 +1014,7 @@ void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider& // Should we use the affix from the negative subpattern? (If not, we will use the positive // subpattern.) + // TODO: Deal with signum bool useNegativeAffixPattern = patternInfo.hasNegativeSubpattern() && ( signum == -1 || (patternInfo.negativeHasMinusSign() && plusReplacesMinusSign)); diff --git a/deps/icu-small/source/i18n/number_patternstring.h b/deps/icu-small/source/i18n/number_patternstring.h index 42e7c3916133d1..1191d29828795b 100644 --- a/deps/icu-small/source/i18n/number_patternstring.h +++ b/deps/icu-small/source/i18n/number_patternstring.h @@ -231,7 +231,7 @@ class U_I18N_API PatternStringUtils { * it should not be ignored if maxFrac is 2 or more (but a roundingIncrement of * 0.005 is treated like 0.001 for significance). * - * This test is needed for both NumberPropertyMapper::oldToNew and + * This test is needed for both NumberPropertyMapper::oldToNew and * PatternStringUtils::propertiesToPatternString. In Java it cannot be * exported by NumberPropertyMapper (package provate) so it is in * PatternStringUtils, do the same in C. @@ -295,7 +295,7 @@ class U_I18N_API PatternStringUtils { * substitution, and plural forms for CurrencyPluralInfo. */ static void patternInfoToStringBuilder(const AffixPatternProvider& patternInfo, bool isPrefix, - int8_t signum, UNumberSignDisplay signDisplay, + Signum signum, UNumberSignDisplay signDisplay, StandardPlural::Form plural, bool perMilleReplacesPercent, UnicodeString& output); diff --git a/deps/icu-small/source/i18n/number_rounding.cpp b/deps/icu-small/source/i18n/number_rounding.cpp index 9e369f7925fe2f..813d4b680d497b 100644 --- a/deps/icu-small/source/i18n/number_rounding.cpp +++ b/deps/icu-small/source/i18n/number_rounding.cpp @@ -33,7 +33,7 @@ int32_t getRoundingMagnitudeSignificant(const DecimalQuantity &value, int maxSig if (maxSig == -1) { return INT32_MIN; } - int magnitude = value.isZero() ? 0 : value.getMagnitude(); + int magnitude = value.isZeroish() ? 0 : value.getMagnitude(); return magnitude - maxSig + 1; } @@ -45,7 +45,7 @@ int32_t getDisplayMagnitudeFraction(int minFrac) { } int32_t getDisplayMagnitudeSignificant(const DecimalQuantity &value, int minSig) { - int magnitude = value.isZero() ? 0 : value.getMagnitude(); + int magnitude = value.isZeroish() ? 0 : value.getMagnitude(); return magnitude - minSig + 1; } @@ -306,8 +306,8 @@ bool RoundingImpl::isSignificantDigits() const { int32_t RoundingImpl::chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer, UErrorCode &status) { - // Do not call this method with zero. - U_ASSERT(!input.isZero()); + // Do not call this method with zero, NaN, or infinity. + U_ASSERT(!input.isZeroish()); // Perform the first attempt at rounding. int magnitude = input.getMagnitude(); @@ -316,7 +316,7 @@ RoundingImpl::chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl: apply(input, status); // If the number rounded to zero, exit. - if (input.isZero() || U_FAILURE(status)) { + if (input.isZeroish() || U_FAILURE(status)) { return multiplier; } @@ -374,7 +374,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const value.setMinFraction( uprv_max(0, -getDisplayMagnitudeSignificant(value, fPrecision.fUnion.fracSig.fMinSig))); // Make sure that digits are displayed on zero. - if (value.isZero() && fPrecision.fUnion.fracSig.fMinSig > 0) { + if (value.isZeroish() && fPrecision.fUnion.fracSig.fMinSig > 0) { value.setMinInteger(1); } break; @@ -436,7 +436,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const void RoundingImpl::apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode /*status*/) { // This method is intended for the one specific purpose of helping print "00.000E0". U_ASSERT(isSignificantDigits()); - U_ASSERT(value.isZero()); + U_ASSERT(value.isZeroish()); value.setMinFraction(fPrecision.fUnion.fracSig.fMinSig - minInt); } diff --git a/deps/icu-small/source/i18n/number_scientific.cpp b/deps/icu-small/source/i18n/number_scientific.cpp index 6df07b9cc9e988..f3de7414125368 100644 --- a/deps/icu-small/source/i18n/number_scientific.cpp +++ b/deps/icu-small/source/i18n/number_scientific.cpp @@ -8,7 +8,7 @@ #include #include "number_scientific.h" #include "number_utils.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "unicode/unum.h" #include "number_microprops.h" @@ -36,7 +36,7 @@ void ScientificModifier::set(int32_t exponent, const ScientificHandler *handler) fHandler = handler; } -int32_t ScientificModifier::apply(NumberStringBuilder &output, int32_t /*leftIndex*/, int32_t rightIndex, +int32_t ScientificModifier::apply(FormattedStringBuilder &output, int32_t /*leftIndex*/, int32_t rightIndex, UErrorCode &status) const { // FIXME: Localized exponent separator location. int i = rightIndex; @@ -115,7 +115,7 @@ bool ScientificModifier::semanticallyEquivalent(const Modifier& other) const { // Note: Visual Studio does not compile this function without full name space. Why? icu::number::impl::ScientificHandler::ScientificHandler(const Notation *notation, const DecimalFormatSymbols *symbols, - const MicroPropsGenerator *parent) : + const MicroPropsGenerator *parent) : fSettings(notation->fUnion.scientific), fSymbols(symbols), fParent(parent) {} void ScientificHandler::processQuantity(DecimalQuantity &quantity, MicroProps µs, @@ -123,9 +123,15 @@ void ScientificHandler::processQuantity(DecimalQuantity &quantity, MicroProps &m fParent->processQuantity(quantity, micros, status); if (U_FAILURE(status)) { return; } + // Do not apply scientific notation to special doubles + if (quantity.isInfinite() || quantity.isNaN()) { + micros.modInner = µs.helpers.emptyStrongModifier; + return; + } + // Treat zero as if it had magnitude 0 int32_t exponent; - if (quantity.isZero()) { + if (quantity.isZeroish()) { if (fSettings.fRequireMinInt && micros.rounder.isSignificantDigits()) { // Show "00.000E0" on pattern "00.000E0" micros.rounder.apply(quantity, fSettings.fEngineeringInterval, status); diff --git a/deps/icu-small/source/i18n/number_scientific.h b/deps/icu-small/source/i18n/number_scientific.h index e377bd941efaeb..1c9ce1efa80a3f 100644 --- a/deps/icu-small/source/i18n/number_scientific.h +++ b/deps/icu-small/source/i18n/number_scientific.h @@ -21,7 +21,7 @@ class U_I18N_API ScientificModifier : public UMemory, public Modifier { void set(int32_t exponent, const ScientificHandler *handler); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; diff --git a/deps/icu-small/source/i18n/number_skeletons.cpp b/deps/icu-small/source/i18n/number_skeletons.cpp index 4c280ad11dd8da..4025539239b786 100644 --- a/deps/icu-small/source/i18n/number_skeletons.cpp +++ b/deps/icu-small/source/i18n/number_skeletons.cpp @@ -20,6 +20,7 @@ #include "unicode/numberformatter.h" #include "uinvchar.h" #include "charstr.h" +#include "string_segment.h" using namespace icu; using namespace icu::number; @@ -119,17 +120,17 @@ inline void appendMultiple(UnicodeString& sb, UChar32 cp, int32_t count) { #define CHECK_NULL(seen, field, status) (void)(seen); /* for auto-format line wrapping */ \ -{ \ +UPRV_BLOCK_MACRO_BEGIN { \ if ((seen).field) { \ (status) = U_NUMBER_SKELETON_SYNTAX_ERROR; \ return STATE_NULL; \ } \ (seen).field = true; \ -} +} UPRV_BLOCK_MACRO_END #define SKELETON_UCHAR_TO_CHAR(dest, src, start, end, status) (void)(dest); \ -{ \ +UPRV_BLOCK_MACRO_BEGIN { \ UErrorCode conversionStatus = U_ZERO_ERROR; \ (dest).appendInvariantChars({FALSE, (src).getBuffer() + (start), (end) - (start)}, conversionStatus); \ if (conversionStatus == U_INVARIANT_CONVERSION_ERROR) { \ @@ -140,7 +141,7 @@ inline void appendMultiple(UnicodeString& sb, UChar32 cp, int32_t count) { (status) = conversionStatus; \ return; \ } \ -} +} UPRV_BLOCK_MACRO_END } // anonymous namespace @@ -1217,7 +1218,7 @@ void blueprint_helpers::parseIntegerWidthOption(const StringSegment& segment, Ma maxInt = 0; } for (; offset < segment.length(); offset++) { - if (segment.charAt(offset) == u'#') { + if (maxInt != -1 && segment.charAt(offset) == u'#') { maxInt++; } else { break; diff --git a/deps/icu-small/source/i18n/number_skeletons.h b/deps/icu-small/source/i18n/number_skeletons.h index bc228bd0d7408e..59af771928fbd0 100644 --- a/deps/icu-small/source/i18n/number_skeletons.h +++ b/deps/icu-small/source/i18n/number_skeletons.h @@ -10,10 +10,10 @@ #include "number_types.h" #include "numparse_types.h" #include "unicode/ucharstrie.h" +#include "string_segment.h" -using icu::numparse::impl::StringSegment; - -U_NAMESPACE_BEGIN namespace number { +U_NAMESPACE_BEGIN +namespace number { namespace impl { // Forward-declaration diff --git a/deps/icu-small/source/i18n/number_stringbuilder.h b/deps/icu-small/source/i18n/number_stringbuilder.h deleted file mode 100644 index d48f6e106cf87e..00000000000000 --- a/deps/icu-small/source/i18n/number_stringbuilder.h +++ /dev/null @@ -1,164 +0,0 @@ -// © 2017 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING -#ifndef __NUMBER_STRINGBUILDER_H__ -#define __NUMBER_STRINGBUILDER_H__ - - -#include -#include "unicode/numfmt.h" -#include "unicode/ustring.h" -#include "cstring.h" -#include "uassert.h" -#include "number_types.h" -#include "fphdlimp.h" - -U_NAMESPACE_BEGIN namespace number { -namespace impl { - -class U_I18N_API NumberStringBuilder : public UMemory { - private: - static const int32_t DEFAULT_CAPACITY = 40; - - template - union ValueOrHeapArray { - T value[DEFAULT_CAPACITY]; - struct { - T *ptr; - int32_t capacity; - } heap; - }; - - public: - NumberStringBuilder(); - - ~NumberStringBuilder(); - - NumberStringBuilder(const NumberStringBuilder &other); - - NumberStringBuilder &operator=(const NumberStringBuilder &other); - - int32_t length() const; - - int32_t codePointCount() const; - - inline char16_t charAt(int32_t index) const { - U_ASSERT(index >= 0); - U_ASSERT(index < fLength); - return getCharPtr()[fZero + index]; - } - - inline Field fieldAt(int32_t index) const { - U_ASSERT(index >= 0); - U_ASSERT(index < fLength); - return getFieldPtr()[fZero + index]; - } - - UChar32 getFirstCodePoint() const; - - UChar32 getLastCodePoint() const; - - UChar32 codePointAt(int32_t index) const; - - UChar32 codePointBefore(int32_t index) const; - - NumberStringBuilder &clear(); - - int32_t appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status); - - int32_t insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status); - - int32_t append(const UnicodeString &unistr, Field field, UErrorCode &status); - - int32_t insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status); - - int32_t insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, - UErrorCode &status); - - int32_t splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, - int32_t startOther, int32_t endOther, Field field, UErrorCode& status); - - int32_t append(const NumberStringBuilder &other, UErrorCode &status); - - int32_t insert(int32_t index, const NumberStringBuilder &other, UErrorCode &status); - - void writeTerminator(UErrorCode& status); - - /** - * Gets a "safe" UnicodeString that can be used even after the NumberStringBuilder is destructed. - * */ - UnicodeString toUnicodeString() const; - - /** - * Gets an "unsafe" UnicodeString that is valid only as long as the NumberStringBuilder is alive and - * unchanged. Slightly faster than toUnicodeString(). - */ - const UnicodeString toTempUnicodeString() const; - - UnicodeString toDebugString() const; - - const char16_t *chars() const; - - bool contentEquals(const NumberStringBuilder &other) const; - - bool nextFieldPosition(FieldPosition& fp, UErrorCode& status) const; - - void getAllFieldPositions(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; - - bool nextPosition(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& status) const; - - bool containsField(Field field) const; - - private: - bool fUsingHeap = false; - ValueOrHeapArray fChars; - ValueOrHeapArray fFields; - int32_t fZero = DEFAULT_CAPACITY / 2; - int32_t fLength = 0; - - inline char16_t *getCharPtr() { - return fUsingHeap ? fChars.heap.ptr : fChars.value; - } - - inline const char16_t *getCharPtr() const { - return fUsingHeap ? fChars.heap.ptr : fChars.value; - } - - inline Field *getFieldPtr() { - return fUsingHeap ? fFields.heap.ptr : fFields.value; - } - - inline const Field *getFieldPtr() const { - return fUsingHeap ? fFields.heap.ptr : fFields.value; - } - - inline int32_t getCapacity() const { - return fUsingHeap ? fChars.heap.capacity : DEFAULT_CAPACITY; - } - - int32_t prepareForInsert(int32_t index, int32_t count, UErrorCode &status); - - int32_t prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status); - - int32_t remove(int32_t index, int32_t count); - - static bool isIntOrGroup(Field field); - - static bool isNumericField(Field field); - - int32_t trimBack(int32_t limit) const; - - int32_t trimFront(int32_t start) const; -}; - -} // namespace impl -} // namespace number -U_NAMESPACE_END - - -#endif //__NUMBER_STRINGBUILDER_H__ - -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/number_types.h b/deps/icu-small/source/i18n/number_types.h index 225d1e57750490..d62aa6a66b30d3 100644 --- a/deps/icu-small/source/i18n/number_types.h +++ b/deps/icu-small/source/i18n/number_types.h @@ -17,17 +17,16 @@ #include "unicode/platform.h" #include "unicode/uniset.h" #include "standardplural.h" +#include "formatted_string_builder.h" -U_NAMESPACE_BEGIN namespace number { +U_NAMESPACE_BEGIN +namespace number { namespace impl { -// Typedef several enums for brevity and for easier comparison to Java. +// For convenience and historical reasons, import the Field typedef to the namespace. +typedef FormattedStringBuilder::Field Field; -// Convention: bottom 4 bits for field, top 4 bits for field category. -// Field category 0 implies the number category so that the number field -// literals can be directly passed as a Field type. -// See the helper functions in "NumFieldUtils" in number_utils.h -typedef uint8_t Field; +// Typedef several enums for brevity and for easier comparison to Java. typedef UNumberFormatRoundingMode RoundingMode; @@ -49,7 +48,6 @@ static constexpr char16_t kFallbackPaddingString[] = u" "; class Modifier; class MutablePatternModifier; class DecimalQuantity; -class NumberStringBuilder; class ModifierStore; struct MicroProps; @@ -93,6 +91,12 @@ enum CompactType { TYPE_DECIMAL, TYPE_CURRENCY }; +enum Signum { + SIGNUM_NEG = -1, + SIGNUM_ZERO = 0, + SIGNUM_POS = 1 +}; + class U_I18N_API AffixPatternProvider { public: @@ -160,7 +164,7 @@ class U_I18N_API Modifier { * formatted. * @return The number of characters (UTF-16 code units) that were added to the string builder. */ - virtual int32_t apply(NumberStringBuilder& output, int leftIndex, int rightIndex, + virtual int32_t apply(FormattedStringBuilder& output, int leftIndex, int rightIndex, UErrorCode& status) const = 0; /** @@ -196,11 +200,11 @@ class U_I18N_API Modifier { */ struct U_I18N_API Parameters { const ModifierStore* obj = nullptr; - int8_t signum; + Signum signum; StandardPlural::Form plural; Parameters(); - Parameters(const ModifierStore* _obj, int8_t _signum, StandardPlural::Form _plural); + Parameters(const ModifierStore* _obj, Signum _signum, StandardPlural::Form _plural); }; /** @@ -231,7 +235,7 @@ class U_I18N_API ModifierStore { /** * Returns a Modifier with the given parameters (best-effort). */ - virtual const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const = 0; + virtual const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const = 0; }; diff --git a/deps/icu-small/source/i18n/number_utils.cpp b/deps/icu-small/source/i18n/number_utils.cpp index 0983b7b0726ec2..91d7f335cd82d3 100644 --- a/deps/icu-small/source/i18n/number_utils.cpp +++ b/deps/icu-small/source/i18n/number_utils.cpp @@ -252,4 +252,15 @@ bool DecNum::isZero() const { return decNumberIsZero(fData.getAlias()); } +void DecNum::toString(ByteSink& output, UErrorCode& status) const { + if (U_FAILURE(status)) { + return; + } + // "string must be at least dn->digits+14 characters long" + int32_t minCapacity = fData.getAlias()->digits + 14; + MaybeStackArray buffer(minCapacity); + uprv_decNumberToString(fData, buffer.getAlias()); + output.Append(buffer.getAlias(), static_cast(uprv_strlen(buffer.getAlias()))); +} + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/number_utils.h b/deps/icu-small/source/i18n/number_utils.h index 203dec6d83b92b..93195f080b2787 100644 --- a/deps/icu-small/source/i18n/number_utils.h +++ b/deps/icu-small/source/i18n/number_utils.h @@ -17,6 +17,7 @@ #include "number_roundingutils.h" #include "decNumber.h" #include "charstr.h" +#include "formatted_string_builder.h" U_NAMESPACE_BEGIN @@ -32,52 +33,10 @@ enum CldrPatternStyle { CLDR_PATTERN_STYLE_COUNT, }; - -/** - * Helper functions for dealing with the Field typedef, which stores fields - * in a compressed format. - */ -class NumFieldUtils { -public: - struct CategoryFieldPair { - int32_t category; - int32_t field; - }; - - /** Compile-time function to construct a Field from a category and a field */ - template - static constexpr Field compress() { - static_assert(category != 0, "cannot use Undefined category in NumFieldUtils"); - static_assert(category <= 0xf, "only 4 bits for category"); - static_assert(field <= 0xf, "only 4 bits for field"); - return static_cast((category << 4) | field); - } - - /** Runtime inline function to unpack the category and field from the Field */ - static inline CategoryFieldPair expand(Field field) { - if (field == UNUM_FIELD_COUNT) { - return {UFIELD_CATEGORY_UNDEFINED, 0}; - } - CategoryFieldPair ret = { - (field >> 4), - (field & 0xf) - }; - if (ret.category == 0) { - ret.category = UFIELD_CATEGORY_NUMBER; - } - return ret; - } - - static inline bool isNumericField(Field field) { - int8_t category = field >> 4; - return category == 0 || category == UFIELD_CATEGORY_NUMBER; - } -}; - // Namespace for naked functions namespace utils { -inline int32_t insertDigitFromSymbols(NumberStringBuilder& output, int32_t index, int8_t digit, +inline int32_t insertDigitFromSymbols(FormattedStringBuilder& output, int32_t index, int8_t digit, const DecimalFormatSymbols& symbols, Field field, UErrorCode& status) { if (symbols.getCodePointZero() != -1) { diff --git a/deps/icu-small/source/i18n/number_utypes.h b/deps/icu-small/source/i18n/number_utypes.h index 88b493cbc254c9..6dbe5bee68fb71 100644 --- a/deps/icu-small/source/i18n/number_utypes.h +++ b/deps/icu-small/source/i18n/number_utypes.h @@ -10,7 +10,7 @@ #include "unicode/numberformatter.h" #include "number_types.h" #include "number_decimalquantity.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "formattedval_impl.h" U_NAMESPACE_BEGIN namespace number { @@ -31,9 +31,9 @@ const DecimalQuantity* validateUFormattedNumberToDecimalQuantity( * The DecimalQuantity is not currently being used by FormattedNumber, but at some point it could be used * to add a toDecNumber() or similar method. */ -class UFormattedNumberData : public FormattedValueNumberStringBuilderImpl { +class UFormattedNumberData : public FormattedValueStringBuilderImpl { public: - UFormattedNumberData() : FormattedValueNumberStringBuilderImpl(0) {} + UFormattedNumberData() : FormattedValueStringBuilderImpl(0) {} virtual ~UFormattedNumberData(); DecimalQuantity quantity; diff --git a/deps/icu-small/source/i18n/numfmt.cpp b/deps/icu-small/source/i18n/numfmt.cpp index 21efd184558778..7c3a0551c32992 100644 --- a/deps/icu-small/source/i18n/numfmt.cpp +++ b/deps/icu-small/source/i18n/numfmt.cpp @@ -122,7 +122,7 @@ static const UChar * const gLastResortNumberPatterns[UNUM_FORMAT_STYLE_COUNT] = gLastResortIsoCurrencyPat, // UNUM_CURRENCY_ISO gLastResortPluralCurrencyPat, // UNUM_CURRENCY_PLURAL gLastResortAccountingCurrencyPat, // UNUM_CURRENCY_ACCOUNTING - gLastResortCurrencyPat, // UNUM_CASH_CURRENCY + gLastResortCurrencyPat, // UNUM_CASH_CURRENCY NULL, // UNUM_DECIMAL_COMPACT_SHORT NULL, // UNUM_DECIMAL_COMPACT_LONG gLastResortCurrencyPat, // UNUM_CURRENCY_STANDARD @@ -434,13 +434,13 @@ NumberFormat::format(int64_t number, // ------------------------------------- -// Decimal Number format() default implementation +// Decimal Number format() default implementation // Subclasses do not normally override this function, but rather the DigitList // formatting functions.. // The expected call chain from here is // this function -> // NumberFormat::format(Formattable -> -// DecimalFormat::format(DigitList +// DecimalFormat::format(DigitList // // Or, for subclasses of Formattable that do not know about DigitList, // this Function -> @@ -569,7 +569,7 @@ NumberFormat::format(const Formattable& obj, if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) { // trying to format a different currency. // Right now, we clone. - LocalPointer cloneFmt((NumberFormat*)this->clone()); + LocalPointer cloneFmt(this->clone()); cloneFmt->setCurrency(iso, status); // next line should NOT recurse, because n is numeric whereas obj was a wrapper around currency amount. return cloneFmt->format(*n, appendTo, pos, status); @@ -624,7 +624,7 @@ NumberFormat::format(const Formattable& obj, if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) { // trying to format a different currency. // Right now, we clone. - LocalPointer cloneFmt((NumberFormat*)this->clone()); + LocalPointer cloneFmt(this->clone()); cloneFmt->setCurrency(iso, status); // next line should NOT recurse, because n is numeric whereas obj was a wrapper around currency amount. return cloneFmt->format(*n, appendTo, posIter, status); @@ -986,15 +986,19 @@ static UBool haveService() { URegistryKey U_EXPORT2 NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status) { - ICULocaleService *service = getNumberFormatService(); - if (service) { - NFFactory *tempnnf = new NFFactory(toAdopt); - if (tempnnf != NULL) { - return service->registerFactory(tempnnf, status); - } - } - status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + if (U_FAILURE(status)) { + delete toAdopt; + return nullptr; + } + ICULocaleService *service = getNumberFormatService(); + if (service) { + NFFactory *tempnnf = new NFFactory(toAdopt); + if (tempnnf != NULL) { + return service->registerFactory(tempnnf, status); + } + } + status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } // ------------------------------------- @@ -1055,14 +1059,14 @@ NumberFormat::createInstance(const Locale& loc, UNumberFormatStyle kind, UErrorC if (U_FAILURE(status)) { return NULL; } - NumberFormat *result = static_cast((*shared)->clone()); + NumberFormat *result = (*shared)->clone(); shared->removeRef(); if (result == NULL) { status = U_MEMORY_ALLOCATION_ERROR; } return result; } - + // ------------------------------------- // Checks if the thousand/10 thousand grouping is used in the @@ -1362,7 +1366,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale, // TODO: Bad hash key usage, see ticket #8504. int32_t hashKey = desiredLocale.hashCode(); - static icu::UMutex nscacheMutex = U_MUTEX_INITIALIZER; + static UMutex nscacheMutex; Mutex lock(&nscacheMutex); ns = (NumberingSystem *)uhash_iget(NumberingSystem_cache, hashKey); if (ns == NULL) { @@ -1408,7 +1412,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale, if (U_FAILURE(status)) { return NULL; } - if(style==UNUM_CURRENCY || style == UNUM_CURRENCY_ISO || style == UNUM_CURRENCY_ACCOUNTING + if(style==UNUM_CURRENCY || style == UNUM_CURRENCY_ISO || style == UNUM_CURRENCY_ACCOUNTING || style == UNUM_CASH_CURRENCY || style == UNUM_CURRENCY_STANDARD){ const UChar* currPattern = symbolsToAdopt->getCurrencyPattern(); if(currPattern!=NULL){ diff --git a/deps/icu-small/source/i18n/numparse_affixes.cpp b/deps/icu-small/source/i18n/numparse_affixes.cpp index 12543a641b5946..cf8bab4d81f3aa 100644 --- a/deps/icu-small/source/i18n/numparse_affixes.cpp +++ b/deps/icu-small/source/i18n/numparse_affixes.cpp @@ -13,6 +13,7 @@ #include "numparse_affixes.h" #include "numparse_utils.h" #include "number_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -280,7 +281,9 @@ void AffixMatcherWarehouse::createAffixMatchers(const AffixPatternProvider& patt AffixPatternMatcher* posSuffix = nullptr; // Pre-process the affix strings to resolve LDML rules like sign display. - for (int8_t signum = 1; signum >= -1; signum--) { + for (int8_t signumInt = 1; signumInt >= -1; signumInt--) { + auto signum = static_cast(signumInt); + // Generate Prefix bool hasPrefix = false; PatternStringUtils::patternInfoToStringBuilder( @@ -435,3 +438,28 @@ UnicodeString AffixMatcher::toString() const { #endif /* #if !UCONFIG_NO_FORMATTING */ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/icu-small/source/i18n/numparse_affixes.h b/deps/icu-small/source/i18n/numparse_affixes.h index e498483fbca8cf..e02b17ba2d0852 100644 --- a/deps/icu-small/source/i18n/numparse_affixes.h +++ b/deps/icu-small/source/i18n/numparse_affixes.h @@ -52,7 +52,7 @@ class CodePointMatcher : public NumberParseMatcher, public UMemory { // (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) // Note: These need to be outside of the numparse::impl namespace, or Clang will generate a compile error. #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN -template class U_I18N_API MaybeStackArray; +template class U_I18N_API MaybeStackArray; template class U_I18N_API MaybeStackArray; template class U_I18N_API MemoryPool; template class U_I18N_API numparse::impl::CompactUnicodeString<4>; diff --git a/deps/icu-small/source/i18n/numparse_compositions.cpp b/deps/icu-small/source/i18n/numparse_compositions.cpp index 19253da805f0bf..2f7e1ab28d1d22 100644 --- a/deps/icu-small/source/i18n/numparse_compositions.cpp +++ b/deps/icu-small/source/i18n/numparse_compositions.cpp @@ -11,6 +11,7 @@ #include "numparse_types.h" #include "numparse_compositions.h" +#include "string_segment.h" #include "unicode/uniset.h" using namespace icu; diff --git a/deps/icu-small/source/i18n/numparse_currency.cpp b/deps/icu-small/source/i18n/numparse_currency.cpp index 598ace56533c36..6b53a73edf3b85 100644 --- a/deps/icu-small/source/i18n/numparse_currency.cpp +++ b/deps/icu-small/source/i18n/numparse_currency.cpp @@ -14,6 +14,7 @@ #include "ucurrimp.h" #include "unicode/errorcode.h" #include "numparse_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; diff --git a/deps/icu-small/source/i18n/numparse_decimal.cpp b/deps/icu-small/source/i18n/numparse_decimal.cpp index b120c5c6ad2f91..cf1e8156726d01 100644 --- a/deps/icu-small/source/i18n/numparse_decimal.cpp +++ b/deps/icu-small/source/i18n/numparse_decimal.cpp @@ -16,6 +16,7 @@ #include "unicode/uchar.h" #include "putilimp.h" #include "number_decimalquantity.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; diff --git a/deps/icu-small/source/i18n/numparse_impl.cpp b/deps/icu-small/source/i18n/numparse_impl.cpp index 412ea89c86b651..bf5829061a1511 100644 --- a/deps/icu-small/source/i18n/numparse_impl.cpp +++ b/deps/icu-small/source/i18n/numparse_impl.cpp @@ -39,7 +39,7 @@ NumberParserImpl::createSimpleParser(const Locale& locale, const UnicodeString& LocalPointer parser(new NumberParserImpl(parseFlags)); DecimalFormatSymbols symbols(locale, status); - parser->fLocalMatchers.ignorables = {unisets::DEFAULT_IGNORABLES}; + parser->fLocalMatchers.ignorables = {parseFlags}; IgnorablesMatcher& ignorables = parser->fLocalMatchers.ignorables; DecimalFormatSymbols dfs(locale, status); @@ -114,6 +114,7 @@ NumberParserImpl::createParserFromProperties(const number::impl::DecimalFormatPr parseFlags |= PARSE_FLAG_STRICT_SEPARATORS; parseFlags |= PARSE_FLAG_USE_FULL_AFFIXES; parseFlags |= PARSE_FLAG_EXACT_AFFIX; + parseFlags |= PARSE_FLAG_STRICT_IGNORABLES; } else { parseFlags |= PARSE_FLAG_INCLUDE_UNPAIRED_AFFIXES; } @@ -129,8 +130,7 @@ NumberParserImpl::createParserFromProperties(const number::impl::DecimalFormatPr LocalPointer parser(new NumberParserImpl(parseFlags)); - parser->fLocalMatchers.ignorables = { - isStrict ? unisets::STRICT_IGNORABLES : unisets::DEFAULT_IGNORABLES}; + parser->fLocalMatchers.ignorables = {parseFlags}; IgnorablesMatcher& ignorables = parser->fLocalMatchers.ignorables; ////////////////////// diff --git a/deps/icu-small/source/i18n/numparse_impl.h b/deps/icu-small/source/i18n/numparse_impl.h index 7d5f0b6f0bd07b..380d9aa4c64289 100644 --- a/deps/icu-small/source/i18n/numparse_impl.h +++ b/deps/icu-small/source/i18n/numparse_impl.h @@ -18,6 +18,7 @@ #include "unicode/localpointer.h" #include "numparse_validators.h" #include "number_multiplier.h" +#include "string_segment.h" U_NAMESPACE_BEGIN diff --git a/deps/icu-small/source/i18n/numparse_parsednumber.cpp b/deps/icu-small/source/i18n/numparse_parsednumber.cpp index 3145f718dc26b5..4b373a3c312254 100644 --- a/deps/icu-small/source/i18n/numparse_parsednumber.cpp +++ b/deps/icu-small/source/i18n/numparse_parsednumber.cpp @@ -11,6 +11,7 @@ #include "numparse_types.h" #include "number_decimalquantity.h" +#include "string_segment.h" #include "putilimp.h" #include @@ -73,7 +74,7 @@ double ParsedNumber::getDouble(UErrorCode& status) const { status = U_INVALID_STATE_ERROR; return 0.0; } - if (quantity.isZero() && quantity.isNegative()) { + if (quantity.isZeroish() && quantity.isNegative()) { return -0.0; } @@ -106,7 +107,7 @@ void ParsedNumber::populateFormattable(Formattable& output, parse_flags_t parseF } } U_ASSERT(!quantity.bogus); - if (quantity.isZero() && quantity.isNegative() && !integerOnly) { + if (quantity.isZeroish() && quantity.isNegative() && !integerOnly) { output.setDouble(-0.0); return; } diff --git a/deps/icu-small/source/i18n/numparse_scientific.cpp b/deps/icu-small/source/i18n/numparse_scientific.cpp index de38957440817c..4b88cd998fee09 100644 --- a/deps/icu-small/source/i18n/numparse_scientific.cpp +++ b/deps/icu-small/source/i18n/numparse_scientific.cpp @@ -12,6 +12,7 @@ #include "numparse_types.h" #include "numparse_scientific.h" #include "static_unicode_sets.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -33,7 +34,8 @@ inline const UnicodeSet& plusSignSet() { ScientificMatcher::ScientificMatcher(const DecimalFormatSymbols& dfs, const Grouper& grouper) : fExponentSeparatorString(dfs.getConstSymbol(DecimalFormatSymbols::kExponentialSymbol)), - fExponentMatcher(dfs, grouper, PARSE_FLAG_INTEGER_ONLY | PARSE_FLAG_GROUPING_DISABLED) { + fExponentMatcher(dfs, grouper, PARSE_FLAG_INTEGER_ONLY | PARSE_FLAG_GROUPING_DISABLED), + fIgnorablesMatcher(PARSE_FLAG_STRICT_IGNORABLES) { const UnicodeString& minusSign = dfs.getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol); if (minusSignSet().contains(minusSign)) { @@ -63,15 +65,25 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr // First match the scientific separator, and then match another number after it. // NOTE: This is guarded by the smoke test; no need to check fExponentSeparatorString length again. - int overlap1 = segment.getCommonPrefixLength(fExponentSeparatorString); - if (overlap1 == fExponentSeparatorString.length()) { + int32_t initialOffset = segment.getOffset(); + int32_t overlap = segment.getCommonPrefixLength(fExponentSeparatorString); + if (overlap == fExponentSeparatorString.length()) { // Full exponent separator match. // First attempt to get a code point, returning true if we can't get one. - if (segment.length() == overlap1) { + if (segment.length() == overlap) { + return true; + } + segment.adjustOffset(overlap); + + // Allow ignorables before the sign. + // Note: call site is guarded by the segment.length() check above. + // Note: the ignorables matcher should not touch the result. + fIgnorablesMatcher.match(segment, result, status); + if (segment.length() == 0) { + segment.setOffset(initialOffset); return true; } - segment.adjustOffset(overlap1); // Allow a sign, and then try to match digits. int8_t exponentSign = 1; @@ -81,24 +93,37 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr } else if (segment.startsWith(plusSignSet())) { segment.adjustOffsetByCodePoint(); } else if (segment.startsWith(fCustomMinusSign)) { - // Note: call site is guarded with startsWith, which returns false on empty string - int32_t overlap2 = segment.getCommonPrefixLength(fCustomMinusSign); - if (overlap2 != fCustomMinusSign.length()) { - // Partial custom sign match; un-match the exponent separator. - segment.adjustOffset(-overlap1); + overlap = segment.getCommonPrefixLength(fCustomMinusSign); + if (overlap != fCustomMinusSign.length()) { + // Partial custom sign match + segment.setOffset(initialOffset); return true; } exponentSign = -1; - segment.adjustOffset(overlap2); + segment.adjustOffset(overlap); } else if (segment.startsWith(fCustomPlusSign)) { - // Note: call site is guarded with startsWith, which returns false on empty string - int32_t overlap2 = segment.getCommonPrefixLength(fCustomPlusSign); - if (overlap2 != fCustomPlusSign.length()) { - // Partial custom sign match; un-match the exponent separator. - segment.adjustOffset(-overlap1); + overlap = segment.getCommonPrefixLength(fCustomPlusSign); + if (overlap != fCustomPlusSign.length()) { + // Partial custom sign match + segment.setOffset(initialOffset); return true; } - segment.adjustOffset(overlap2); + segment.adjustOffset(overlap); + } + + // Return true if the segment is empty. + if (segment.length() == 0) { + segment.setOffset(initialOffset); + return true; + } + + // Allow ignorables after the sign. + // Note: call site is guarded by the segment.length() check above. + // Note: the ignorables matcher should not touch the result. + fIgnorablesMatcher.match(segment, result, status); + if (segment.length() == 0) { + segment.setOffset(initialOffset); + return true; } // We are supposed to accept E0 after NaN, so we need to make sure result.quantity is available. @@ -112,12 +137,12 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr // At least one exponent digit was matched. result.flags |= FLAG_HAS_EXPONENT; } else { - // No exponent digits were matched; un-match the exponent separator. - segment.adjustOffset(-overlap1); + // No exponent digits were matched + segment.setOffset(initialOffset); } return digitsReturnValue; - } else if (overlap1 == segment.length()) { + } else if (overlap == segment.length()) { // Partial exponent separator match return true; } diff --git a/deps/icu-small/source/i18n/numparse_scientific.h b/deps/icu-small/source/i18n/numparse_scientific.h index ddecf858af3584..5617c0c6a60822 100644 --- a/deps/icu-small/source/i18n/numparse_scientific.h +++ b/deps/icu-small/source/i18n/numparse_scientific.h @@ -9,6 +9,7 @@ #include "numparse_types.h" #include "numparse_decimal.h" +#include "numparse_symbols.h" #include "unicode/numberformatter.h" using icu::number::impl::Grouper; @@ -32,6 +33,7 @@ class ScientificMatcher : public NumberParseMatcher, public UMemory { private: UnicodeString fExponentSeparatorString; DecimalMatcher fExponentMatcher; + IgnorablesMatcher fIgnorablesMatcher; UnicodeString fCustomMinusSign; UnicodeString fCustomPlusSign; }; diff --git a/deps/icu-small/source/i18n/numparse_stringsegment.h b/deps/icu-small/source/i18n/numparse_stringsegment.h deleted file mode 100644 index 7a84444d414889..00000000000000 --- a/deps/icu-small/source/i18n/numparse_stringsegment.h +++ /dev/null @@ -1,24 +0,0 @@ -// © 2018 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING -#ifndef __NUMPARSE_STRINGSEGMENT_H__ -#define __NUMPARSE_STRINGSEGMENT_H__ - -#include "numparse_types.h" -#include "number_types.h" -#include "unicode/unistr.h" - -U_NAMESPACE_BEGIN -namespace numparse { -namespace impl { - - -} // namespace impl -} // namespace numparse -U_NAMESPACE_END - -#endif //__NUMPARSE_STRINGSEGMENT_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/numparse_symbols.cpp b/deps/icu-small/source/i18n/numparse_symbols.cpp index e0daab9374f8b1..608f4f5c8b0ee7 100644 --- a/deps/icu-small/source/i18n/numparse_symbols.cpp +++ b/deps/icu-small/source/i18n/numparse_symbols.cpp @@ -12,6 +12,7 @@ #include "numparse_types.h" #include "numparse_symbols.h" #include "numparse_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -68,8 +69,12 @@ UnicodeString SymbolMatcher::toString() const { } -IgnorablesMatcher::IgnorablesMatcher(unisets::Key key) - : SymbolMatcher({}, key) { +IgnorablesMatcher::IgnorablesMatcher(parse_flags_t parseFlags) : + SymbolMatcher( + {}, + (0 != (parseFlags & PARSE_FLAG_STRICT_IGNORABLES)) ? + unisets::STRICT_IGNORABLES : + unisets::DEFAULT_IGNORABLES) { } bool IgnorablesMatcher::isFlexible() const { diff --git a/deps/icu-small/source/i18n/numparse_symbols.h b/deps/icu-small/source/i18n/numparse_symbols.h index 8912ee95b0d009..beb133f7d07a53 100644 --- a/deps/icu-small/source/i18n/numparse_symbols.h +++ b/deps/icu-small/source/i18n/numparse_symbols.h @@ -50,7 +50,7 @@ class U_I18N_API IgnorablesMatcher : public SymbolMatcher { public: IgnorablesMatcher() = default; // WARNING: Leaves the object in an unusable state - IgnorablesMatcher(unisets::Key key); + IgnorablesMatcher(parse_flags_t parseFlags); bool isFlexible() const override; diff --git a/deps/icu-small/source/i18n/numparse_types.h b/deps/icu-small/source/i18n/numparse_types.h index f837d8d2795a2b..b4007c2ff5b52c 100644 --- a/deps/icu-small/source/i18n/numparse_types.h +++ b/deps/icu-small/source/i18n/numparse_types.h @@ -9,12 +9,13 @@ #include "unicode/uobject.h" #include "number_decimalquantity.h" +#include "string_segment.h" -U_NAMESPACE_BEGIN namespace numparse { +U_NAMESPACE_BEGIN +namespace numparse { namespace impl { // Forward-declarations -class StringSegment; class ParsedNumber; typedef int32_t result_flags_t; @@ -50,6 +51,7 @@ enum ParseFlags { // PARSE_FLAG_FORCE_BIG_DECIMAL = 0x1000, // not used in ICU4C PARSE_FLAG_NO_FOREIGN_CURRENCY = 0x2000, PARSE_FLAG_ALLOW_INFINITE_RECURSION = 0x4000, + PARSE_FLAG_STRICT_IGNORABLES = 0x8000, }; @@ -169,115 +171,6 @@ class U_I18N_API ParsedNumber { }; -/** - * A mutable class allowing for a String with a variable offset and length. The charAt, length, and - * subSequence methods all operate relative to the fixed offset into the String. - * - * @author sffc - */ -// Exported as U_I18N_API for tests -class U_I18N_API StringSegment : public UMemory { - public: - StringSegment(const UnicodeString& str, bool ignoreCase); - - int32_t getOffset() const; - - void setOffset(int32_t start); - - /** - * Equivalent to setOffset(getOffset()+delta). - * - *

    - * This method is usually called by a Matcher to register that a char was consumed. If the char is - * strong (it usually is, except for things like whitespace), follow this with a call to - * {@link ParsedNumber#setCharsConsumed}. For more information on strong chars, see that method. - */ - void adjustOffset(int32_t delta); - - /** - * Adjusts the offset by the width of the current code point, either 1 or 2 chars. - */ - void adjustOffsetByCodePoint(); - - void setLength(int32_t length); - - void resetLength(); - - int32_t length() const; - - char16_t charAt(int32_t index) const; - - UChar32 codePointAt(int32_t index) const; - - UnicodeString toUnicodeString() const; - - const UnicodeString toTempUnicodeString() const; - - /** - * Returns the first code point in the string segment, or -1 if the string starts with an invalid - * code point. - * - *

    - * Important: Most of the time, you should use {@link #matches}, which handles case - * folding logic, instead of this method. - */ - UChar32 getCodePoint() const; - - /** - * Returns true if the first code point of this StringSegment equals the given code point. - * - *

    - * This method will perform case folding if case folding is enabled for the parser. - */ - bool startsWith(UChar32 otherCp) const; - - /** - * Returns true if the first code point of this StringSegment is in the given UnicodeSet. - */ - bool startsWith(const UnicodeSet& uniset) const; - - /** - * Returns true if there is at least one code point of overlap between this StringSegment and the - * given UnicodeString. - */ - bool startsWith(const UnicodeString& other) const; - - /** - * Returns the length of the prefix shared by this StringSegment and the given CharSequence. For - * example, if this string segment is "aab", and the char sequence is "aac", this method returns 2, - * since the first 2 characters are the same. - * - *

    - * This method only returns offsets along code point boundaries. - * - *

    - * This method will perform case folding if case folding was enabled in the constructor. - * - *

    - * IMPORTANT: The given UnicodeString must not be empty! It is the caller's responsibility to check. - */ - int32_t getCommonPrefixLength(const UnicodeString& other); - - /** - * Like {@link #getCommonPrefixLength}, but never performs case folding, even if case folding is - * enabled for the parser. - */ - int32_t getCaseSensitivePrefixLength(const UnicodeString& other); - - bool operator==(const UnicodeString& other) const; - - private: - const UnicodeString& fStr; - int32_t fStart; - int32_t fEnd; - bool fFoldCase; - - int32_t getPrefixLengthInternal(const UnicodeString& other, bool foldCase); - - static bool codePointsEqual(UChar32 cp1, UChar32 cp2, bool foldCase); -}; - - /** * The core interface implemented by all matchers used for number parsing. * diff --git a/deps/icu-small/source/i18n/numrange_fluent.cpp b/deps/icu-small/source/i18n/numrange_fluent.cpp index b284561cdc2b6f..654cafaf00bc82 100644 --- a/deps/icu-small/source/i18n/numrange_fluent.cpp +++ b/deps/icu-small/source/i18n/numrange_fluent.cpp @@ -382,7 +382,7 @@ UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange) UBool FormattedNumberRange::nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fData->getStringRef().nextFieldPosition(fieldPosition, status) ? TRUE : FALSE; + return fData->nextFieldPosition(fieldPosition, status); } void FormattedNumberRange::getAllFieldPositions(FieldPositionIterator& iterator, UErrorCode& status) const { @@ -393,7 +393,7 @@ void FormattedNumberRange::getAllFieldPositions(FieldPositionIterator& iterator, void FormattedNumberRange::getAllFieldPositionsImpl( FieldPositionIteratorHandler& fpih, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) - fData->getStringRef().getAllFieldPositions(fpih, status); + fData->getAllFieldPositions(fpih, status); } UnicodeString FormattedNumberRange::getFirstDecimal(UErrorCode& status) const { diff --git a/deps/icu-small/source/i18n/numrange_impl.cpp b/deps/icu-small/source/i18n/numrange_impl.cpp index 05eb2b84de3d87..7d732b31ec177a 100644 --- a/deps/icu-small/source/i18n/numrange_impl.cpp +++ b/deps/icu-small/source/i18n/numrange_impl.cpp @@ -397,7 +397,7 @@ void NumberRangeFormatterImpl::formatRange(UFormattedNumberRangeData& data, break; } - NumberStringBuilder& string = data.getStringRef(); + FormattedStringBuilder& string = data.getStringRef(); int32_t lengthPrefix = 0; int32_t length1 = 0; int32_t lengthInfix = 0; diff --git a/deps/icu-small/source/i18n/numrange_impl.h b/deps/icu-small/source/i18n/numrange_impl.h index dc25dd4d67bfeb..f88e300913642d 100644 --- a/deps/icu-small/source/i18n/numrange_impl.h +++ b/deps/icu-small/source/i18n/numrange_impl.h @@ -13,7 +13,7 @@ #include "number_types.h" #include "number_decimalquantity.h" #include "number_formatimpl.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "formattedval_impl.h" U_NAMESPACE_BEGIN namespace number { @@ -29,9 +29,9 @@ namespace impl { * Possible magic number: 0x46445200 * Reads in ASCII as "FDR" (FormatteDnumberRange with room at the end) */ -class UFormattedNumberRangeData : public FormattedValueNumberStringBuilderImpl { +class UFormattedNumberRangeData : public FormattedValueStringBuilderImpl { public: - UFormattedNumberRangeData() : FormattedValueNumberStringBuilderImpl(0) {} + UFormattedNumberRangeData() : FormattedValueStringBuilderImpl(0) {} virtual ~UFormattedNumberRangeData(); DecimalQuantity quantity1; diff --git a/deps/icu-small/source/i18n/numsys.cpp b/deps/icu-small/source/i18n/numsys.cpp index 80056f925b027f..ee530e8d333b6b 100644 --- a/deps/icu-small/source/i18n/numsys.cpp +++ b/deps/icu-small/source/i18n/numsys.cpp @@ -37,7 +37,7 @@ U_NAMESPACE_BEGIN // Useful constants -#define DEFAULT_DIGITS UNICODE_STRING_SIMPLE("0123456789"); +#define DEFAULT_DIGITS UNICODE_STRING_SIMPLE("0123456789") static const char gNumberingSystems[] = "numberingSystems"; static const char gNumberElements[] = "NumberElements"; static const char gDefault[] = "default"; @@ -72,7 +72,7 @@ NumberingSystem::NumberingSystem() { * @draft ICU 4.2 */ -NumberingSystem::NumberingSystem(const NumberingSystem& other) +NumberingSystem::NumberingSystem(const NumberingSystem& other) : UObject(other) { *this=other; } @@ -128,7 +128,7 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) { if ( count > 0 ) { // @numbers keyword was specified in the locale U_ASSERT(count < ULOC_KEYWORDS_CAPACITY); buffer[count] = '\0'; // Make sure it is null terminated. - if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) || + if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) { nsResolved = FALSE; } @@ -159,10 +159,10 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) { u_UCharsToChars(nsName, buffer, count); buffer[count] = '\0'; // Make sure it is null terminated. nsResolved = TRUE; - } + } if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default - if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) { + if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) { uprv_strcpy(buffer,gDefault); } else if (!uprv_strcmp(buffer,gTraditional)) { uprv_strcpy(buffer,gNative); diff --git a/deps/icu-small/source/i18n/numsys_impl.h b/deps/icu-small/source/i18n/numsys_impl.h index c0690b47d78802..e76e634dd23c07 100644 --- a/deps/icu-small/source/i18n/numsys_impl.h +++ b/deps/icu-small/source/i18n/numsys_impl.h @@ -17,7 +17,7 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING - + #include "unicode/numsys.h" #include "uvector.h" #include "unicode/strenum.h" diff --git a/deps/icu-small/source/i18n/olsontz.cpp b/deps/icu-small/source/i18n/olsontz.cpp index 95fc56bcd71b54..d21e6e99297b06 100644 --- a/deps/icu-small/source/i18n/olsontz.cpp +++ b/deps/icu-small/source/i18n/olsontz.cpp @@ -205,7 +205,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, if (U_SUCCESS(ec)) { UnicodeString ruleID(TRUE, ruleIdUStr, len); UResourceBundle *rule = TimeZone::loadRule(top, ruleID, NULL, ec); - const int32_t *ruleData = ures_getIntVector(rule, &len, &ec); + const int32_t *ruleData = ures_getIntVector(rule, &len, &ec); if (U_SUCCESS(ec) && len == 11) { UnicodeString emptyStr; finalZone = new SimpleTimeZone( @@ -224,7 +224,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, finalStartYear = ruleYear; // Note: Setting finalStartYear to the finalZone is problematic. When a date is around - // year boundary, SimpleTimeZone may return false result when DST is observed at the + // year boundary, SimpleTimeZone may return false result when DST is observed at the // beginning of year. We could apply safe margin (day or two), but when one of recurrent // rules falls around year boundary, it could return false result. Without setting the // start year, finalZone works fine around the year boundary of the start year. @@ -287,8 +287,7 @@ OlsonTimeZone& OlsonTimeZone::operator=(const OlsonTimeZone& other) { typeMapData = other.typeMapData; delete finalZone; - finalZone = (other.finalZone != 0) ? - (SimpleTimeZone*) other.finalZone->clone() : 0; + finalZone = (other.finalZone != 0) ? other.finalZone->clone() : 0; finalStartYear = other.finalStartYear; finalStartMillis = other.finalStartMillis; @@ -319,7 +318,7 @@ UBool OlsonTimeZone::operator==(const TimeZone& other) const { /** * TimeZone API. */ -TimeZone* OlsonTimeZone::clone() const { +OlsonTimeZone* OlsonTimeZone::clone() const { return new OlsonTimeZone(*this); } @@ -438,7 +437,7 @@ void printTime(double ms) { int32_t year, month, dom, dow; double millis=0; double days = ClockMath::floorDivide(((double)ms), (double)U_MILLIS_PER_DAY, millis); - + Grego::dayToFields(days, year, month, dom, dow); U_DEBUG_TZ_MSG((" getHistoricalOffset: time %.1f (%04d.%02d.%02d+%.1fh)\n", ms, year, month+1, dom, (millis/kOneHour))); @@ -447,7 +446,7 @@ void printTime(double ms) { int64_t OlsonTimeZone::transitionTimeInSeconds(int16_t transIdx) const { - U_ASSERT(transIdx >= 0 && transIdx < transitionCount()); + U_ASSERT(transIdx >= 0 && transIdx < transitionCount()); if (transIdx < transitionCountPre32) { return (((int64_t)((uint32_t)transitionTimesPre32[transIdx << 1])) << 32) @@ -502,7 +501,7 @@ OlsonTimeZone::getHistoricalOffset(UDate date, UBool local, UBool dstToStd = dstBefore && !dstAfter; UBool stdToDst = !dstBefore && dstAfter; - + if (offsetAfter - offsetBefore >= 0) { // Positive transition, which makes a non-existing local time range if (((NonExistingTimeOpt & kStdDstMask) == kStandard && dstToStd) @@ -588,7 +587,7 @@ UBool OlsonTimeZone::useDaylightTime() const { } return FALSE; } -int32_t +int32_t OlsonTimeZone::getDSTSavings() const{ if (finalZone != NULL){ return finalZone->getDSTSavings(); @@ -620,7 +619,7 @@ OlsonTimeZone::hasSameRules(const TimeZone &other) const { if (typeMapData == z->typeMapData) { return TRUE; } - + // If the pointers are not equal, the zones may still // be equal if their rules and transitions are equal if ((finalZone == NULL && z->finalZone != NULL) @@ -693,7 +692,7 @@ OlsonTimeZone::deleteTransitionRules(void) { static void U_CALLCONV initRules(OlsonTimeZone *This, UErrorCode &status) { This->initTransitionRules(status); } - + void OlsonTimeZone::checkTransitionRules(UErrorCode& status) const { OlsonTimeZone *ncThis = const_cast(this); @@ -816,7 +815,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) { * For now, we do not set the valid start year when the construction time * and create a clone and set the start year when extracting rules. */ - finalZoneWithStartYear = (SimpleTimeZone*)finalZone->clone(); + finalZoneWithStartYear = finalZone->clone(); // Check to make sure finalZone was actually cloned. if (finalZoneWithStartYear == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -837,7 +836,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) { startTime = tzt.getTime(); } else { // final rule with no transitions - finalZoneWithStartYear = (SimpleTimeZone*)finalZone->clone(); + finalZoneWithStartYear = finalZone->clone(); // Check to make sure finalZone was actually cloned. if (finalZoneWithStartYear == NULL) { status = U_MEMORY_ALLOCATION_ERROR; diff --git a/deps/icu-small/source/i18n/olsontz.h b/deps/icu-small/source/i18n/olsontz.h index 6f0d36e5de5db0..a3b7dcc8f3d4b0 100644 --- a/deps/icu-small/source/i18n/olsontz.h +++ b/deps/icu-small/source/i18n/olsontz.h @@ -44,52 +44,52 @@ class SimpleTimeZone; * * a. Zone (table). A zone is a table resource contains several * type of resources below: - * + * * - typeOffsets:intvector (Required) - * + * * Sets of UTC raw/dst offset pairs in seconds. Entries at * 2n represents raw offset and 2n+1 represents dst offset * paired with the raw offset at 2n. The very first pair represents * the initial zone offset (before the first transition) always. * - * - trans:intvector (Optional) - * + * - trans:intvector (Optional) + * * List of transition times represented by 32bit seconds from the * epoch (1970-01-01T00:00Z) in ascending order. - * + * * - transPre32/transPost32:intvector (Optional) - * + * * List of transition times before/after 32bit minimum seconds. * Each time is represented by a pair of 32bit integer. - * + * * - typeMap:bin (Optional) - * + * * Array of bytes representing the mapping between each transition * time (transPre32/trans/transPost32) and its corresponding offset * data (typeOffsets). - * + * * - finalRule:string (Optional) - * + * * If a recurrent transition rule is applicable to a zone forever * after the final transition time, finalRule represents the rule * in Rules data. - * + * * - finalRaw:int (Optional) - * + * * When finalRule is available, finalRaw is required and specifies * the raw (base) offset of the rule. - * + * * - finalYear:int (Optional) - * + * * When finalRule is available, finalYear is required and specifies * the start year of the rule. - * + * * - links:intvector (Optional) - * + * * When this zone data is shared with other zones, links specifies * all zones including the zone itself. Each zone is referenced by * integer index. - * + * * b. Link (int, length 1). A link zone is an int resource. The * integer is the zone number of the target zone. The key of this * resource is an alternate name for the target zone. This data @@ -151,7 +151,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone { /** * TimeZone API. */ - virtual TimeZone* clone() const; + virtual OlsonTimeZone* clone() const; /** * TimeZone API. @@ -162,7 +162,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone { * TimeZone API. */ virtual UClassID getDynamicClassID() const; - + /** * TimeZone API. Do not call this; prefer getOffset(UDate,...). */ @@ -398,7 +398,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone { TimeArrayTimeZoneRule **historicRules; int16_t historicRuleCount; SimpleTimeZone *finalZoneWithStartYear; // hack - UInitOnce transitionRulesInitOnce; + UInitOnce transitionRulesInitOnce = U_INITONCE_INITIALIZER; }; inline int16_t diff --git a/deps/icu-small/source/i18n/persncal.cpp b/deps/icu-small/source/i18n/persncal.cpp index 3d391f4e3fbe8e..26fd294ceebe81 100644 --- a/deps/icu-small/source/i18n/persncal.cpp +++ b/deps/icu-small/source/i18n/persncal.cpp @@ -70,11 +70,11 @@ static const int32_t PERSIAN_EPOCH = 1948320; // Constructors... //------------------------------------------------------------------------- -const char *PersianCalendar::getType() const { +const char *PersianCalendar::getType() const { return "persian"; } -Calendar* PersianCalendar::clone() const { +PersianCalendar* PersianCalendar::clone() const { return new PersianCalendar(*this); } @@ -113,7 +113,7 @@ UBool PersianCalendar::isLeapYear(int32_t year) ClockMath::floorDivide(25 * year + 11, 33, remainder); return (remainder < 8); } - + /** * Return the day # on which the given year starts. Days are counted * from the Persian epoch, origin 0. @@ -121,7 +121,7 @@ UBool PersianCalendar::isLeapYear(int32_t year) int32_t PersianCalendar::yearStart(int32_t year) { return handleComputeMonthStart(year,0,FALSE); } - + /** * Return the day # on which the given month starts. Days are counted * from the Persian epoch, origin 0. @@ -132,7 +132,7 @@ int32_t PersianCalendar::yearStart(int32_t year) { int32_t PersianCalendar::monthStart(int32_t year, int32_t month) const { return handleComputeMonthStart(year,month,TRUE); } - + //---------------------------------------------------------------------- // Calendar framework //---------------------------------------------------------------------- @@ -159,7 +159,7 @@ int32_t PersianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont int32_t PersianCalendar::handleGetYearLength(int32_t extendedYear) const { return isLeapYear(extendedYear) ? 366 : 365; } - + //------------------------------------------------------------------------- // Functions for converting from field values to milliseconds.... //------------------------------------------------------------------------- @@ -205,7 +205,7 @@ int32_t PersianCalendar::handleGetExtendedYear() { *

  17. DAY_OF_MONTH *
  18. DAY_OF_YEAR *
  19. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. */ @@ -231,13 +231,13 @@ void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*statu internalSet(UCAL_MONTH, month); internalSet(UCAL_DAY_OF_MONTH, dayOfMonth); internalSet(UCAL_DAY_OF_YEAR, dayOfYear); -} +} UBool PersianCalendar::inDaylightTime(UErrorCode& status) const { // copied from GregorianCalendar - if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) + if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) return FALSE; // Force an update of the state of the Calendar. @@ -292,3 +292,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PersianCalendar) U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/persncal.h b/deps/icu-small/source/i18n/persncal.h index ec818822b33a41..ce6d7397bf4a3b 100644 --- a/deps/icu-small/source/i18n/persncal.h +++ b/deps/icu-small/source/i18n/persncal.h @@ -58,79 +58,79 @@ class PersianCalendar : public Calendar { */ enum EMonths { /** - * Constant for Farvardin, the 1st month of the Persian year. + * Constant for Farvardin, the 1st month of the Persian year. * @internal */ FARVARDIN = 0, /** - * Constant for Ordibehesht, the 2nd month of the Persian year. + * Constant for Ordibehesht, the 2nd month of the Persian year. * @internal */ ORDIBEHESHT = 1, /** - * Constant for Khordad, the 3rd month of the Persian year. - * @internal + * Constant for Khordad, the 3rd month of the Persian year. + * @internal */ KHORDAD = 2, /** - * Constant for Tir, the 4th month of the Persian year. - * @internal + * Constant for Tir, the 4th month of the Persian year. + * @internal */ TIR = 3, /** - * Constant for Mordad, the 5th month of the Persian year. - * @internal + * Constant for Mordad, the 5th month of the Persian year. + * @internal */ MORDAD = 4, /** - * Constant for Shahrivar, the 6th month of the Persian year. - * @internal + * Constant for Shahrivar, the 6th month of the Persian year. + * @internal */ SHAHRIVAR = 5, /** - * Constant for Mehr, the 7th month of the Persian year. - * @internal + * Constant for Mehr, the 7th month of the Persian year. + * @internal */ MEHR = 6, /** - * Constant for Aban, the 8th month of the Persian year. - * @internal + * Constant for Aban, the 8th month of the Persian year. + * @internal */ ABAN = 7, /** - * Constant for Azar, the 9th month of the Persian year. - * @internal + * Constant for Azar, the 9th month of the Persian year. + * @internal */ AZAR = 8, /** - * Constant for Dei, the 10th month of the Persian year. - * @internal + * Constant for Dei, the 10th month of the Persian year. + * @internal */ DEI = 9, /** - * Constant for Bahman, the 11th month of the Persian year. - * @internal + * Constant for Bahman, the 11th month of the Persian year. + * @internal */ BAHMAN = 10, /** - * Constant for Esfand, the 12th month of the Persian year. - * @internal + * Constant for Esfand, the 12th month of the Persian year. + * @internal */ ESFAND = 11, - + PERSIAN_MONTH_MAX - }; + }; @@ -164,14 +164,14 @@ class PersianCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual PersianCalendar* clone() const; private: /** * Determine whether a year is a leap year in the Persian calendar */ static UBool isLeapYear(int32_t year); - + /** * Return the day # on which the given year starts. Days are counted * from the Hijri epoch, origin 0. @@ -186,7 +186,7 @@ class PersianCalendar : public Calendar { * @param year The hijri shamsi month, 0-based */ int32_t monthStart(int32_t year, int32_t month) const; - + //---------------------------------------------------------------------- // Calendar framework //---------------------------------------------------------------------- @@ -195,7 +195,7 @@ class PersianCalendar : public Calendar { * @internal */ virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; - + /** * Return the length (in days) of the given month. * @@ -204,13 +204,13 @@ class PersianCalendar : public Calendar { * @internal */ virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const; - + /** * Return the number of days in the given Persian year * @internal */ virtual int32_t handleGetYearLength(int32_t extendedYear) const; - + //------------------------------------------------------------------------- // Functions for converting from field values to milliseconds.... //------------------------------------------------------------------------- @@ -240,7 +240,7 @@ class PersianCalendar : public Calendar { *
  20. DAY_OF_MONTH *
  21. DAY_OF_YEAR *
  22. EXTENDED_YEAR - * + * * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this * method is called. The getGregorianXxx() methods return Gregorian * calendar equivalents for the given Julian day. @@ -249,7 +249,7 @@ class PersianCalendar : public Calendar { virtual void handleComputeFields(int32_t julianDay, UErrorCode &status); // UObject stuff - public: + public: /** * @return The class ID for this object. All objects of a given class have the * same class ID. Objects of other classes have different class IDs. @@ -318,3 +318,6 @@ U_NAMESPACE_END #endif #endif + + + diff --git a/deps/icu-small/source/i18n/plurfmt.cpp b/deps/icu-small/source/i18n/plurfmt.cpp index 678d91b9c824bc..b99437630e67b5 100644 --- a/deps/icu-small/source/i18n/plurfmt.cpp +++ b/deps/icu-small/source/i18n/plurfmt.cpp @@ -159,7 +159,7 @@ PluralFormat::copyObjects(const PluralFormat& other) { if (other.numberFormat == NULL) { numberFormat = NumberFormat::createInstance(locale, status); } else { - numberFormat = (NumberFormat*)other.numberFormat->clone(); + numberFormat = other.numberFormat->clone(); } if (other.pluralRulesWrapper.pluralRules == NULL) { pluralRulesWrapper.pluralRules = PluralRules::forLocale(locale, status); @@ -277,7 +277,14 @@ PluralFormat::format(const Formattable& numberObject, double number, UnicodeString numberString; auto *decFmt = dynamic_cast(numberFormat); if(decFmt != nullptr) { - decFmt->toNumberFormatter().formatImpl(&data, status); // mutates &data + const number::LocalizedNumberFormatter* lnf = decFmt->toNumberFormatter(status); + if (U_FAILURE(status)) { + return appendTo; + } + lnf->formatImpl(&data, status); // mutates &data + if (U_FAILURE(status)) { + return appendTo; + } numberString = data.getStringRef().toUnicodeString(); } else { if (offset == 0) { @@ -346,7 +353,7 @@ PluralFormat::setNumberFormat(const NumberFormat* format, UErrorCode& status) { if (U_FAILURE(status)) { return; } - NumberFormat* nf = (NumberFormat*)format->clone(); + NumberFormat* nf = format->clone(); if (nf != NULL) { delete numberFormat; numberFormat = nf; @@ -355,7 +362,7 @@ PluralFormat::setNumberFormat(const NumberFormat* format, UErrorCode& status) { } } -Format* +PluralFormat* PluralFormat::clone() const { return new PluralFormat(*this); diff --git a/deps/icu-small/source/i18n/plurrule.cpp b/deps/icu-small/source/i18n/plurrule.cpp index aa950a51f0f0c6..fd193560708172 100644 --- a/deps/icu-small/source/i18n/plurrule.cpp +++ b/deps/icu-small/source/i18n/plurrule.cpp @@ -929,7 +929,7 @@ RuleChain::RuleChain(const RuleChain& other) : fIntegerSamples(other.fIntegerSamples), fDecimalSamplesUnbounded(other.fDecimalSamplesUnbounded), fIntegerSamplesUnbounded(other.fIntegerSamplesUnbounded), fInternalStatus(other.fInternalStatus) { if (U_FAILURE(this->fInternalStatus)) { - return; // stop early if the object we are copying from is invalid. + return; // stop early if the object we are copying from is invalid. } if (other.ruleHeader != nullptr) { this->ruleHeader = new OrConstraint(*(other.ruleHeader)); @@ -1489,7 +1489,7 @@ PluralOperand tokenTypeToPluralOperand(tokenType tt) { FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) { init(n, v, f); // check values. TODO make into unit test. - // + // // long visiblePower = (int) Math.pow(10, v); // if (decimalDigits > visiblePower) { // throw new IllegalArgumentException(); @@ -1646,7 +1646,7 @@ int32_t FixedDecimal::decimals(double n) { // v is the number of visible fraction digits in the displayed form of the number. // Example: n = 1001.234, v = 6, result = 234000 // TODO: need to think through how this is used in the plural rule context. -// This function can easily encounter integer overflow, +// This function can easily encounter integer overflow, // and can easily return noise digits when the precision of a double is exceeded. int64_t FixedDecimal::getFractionalDigits(double n, int32_t v) { diff --git a/deps/icu-small/source/i18n/plurrule_impl.h b/deps/icu-small/source/i18n/plurrule_impl.h index f23ae168569d66..3a919ea9f5d9bd 100644 --- a/deps/icu-small/source/i18n/plurrule_impl.h +++ b/deps/icu-small/source/i18n/plurrule_impl.h @@ -319,7 +319,7 @@ class AndConstraint : public UMemory { tokenType digitsType = none; // n | i | v | f constraint. AndConstraint *next = nullptr; // Internal error status, used for errors that occur during the copy constructor. - UErrorCode fInternalStatus = U_ZERO_ERROR; + UErrorCode fInternalStatus = U_ZERO_ERROR; AndConstraint() = default; AndConstraint(const AndConstraint& other); diff --git a/deps/icu-small/source/i18n/quant.cpp b/deps/icu-small/source/i18n/quant.cpp index 1908a504846b07..ed3393338775e9 100644 --- a/deps/icu-small/source/i18n/quant.cpp +++ b/deps/icu-small/source/i18n/quant.cpp @@ -47,7 +47,7 @@ Quantifier::~Quantifier() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* Quantifier::clone() const { +Quantifier* Quantifier::clone() const { return new Quantifier(*this); } @@ -58,7 +58,7 @@ UnicodeFunctor* Quantifier::clone() const { UnicodeMatcher* Quantifier::toMatcher() const { Quantifier *nonconst_this = const_cast(this); UnicodeMatcher *nonconst_base = static_cast(nonconst_this); - + return nonconst_base; } diff --git a/deps/icu-small/source/i18n/quant.h b/deps/icu-small/source/i18n/quant.h index 1abb0db61aa386..d5aa8e5eeeedee 100644 --- a/deps/icu-small/source/i18n/quant.h +++ b/deps/icu-small/source/i18n/quant.h @@ -45,7 +45,7 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher { * Implement UnicodeFunctor * @return a copy of the object. */ - virtual UnicodeFunctor* clone() const; + virtual Quantifier* clone() const; /** * Implement UnicodeMatcher diff --git a/deps/icu-small/source/i18n/quantityformatter.cpp b/deps/icu-small/source/i18n/quantityformatter.cpp index 9182f9e7d379a8..e88b70fbd71795 100644 --- a/deps/icu-small/source/i18n/quantityformatter.cpp +++ b/deps/icu-small/source/i18n/quantityformatter.cpp @@ -26,7 +26,7 @@ #include "uassert.h" #include "number_decimalquantity.h" #include "number_utypes.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" U_NAMESPACE_BEGIN @@ -180,7 +180,7 @@ void QuantityFormatter::formatAndSelect( double quantity, const NumberFormat& fmt, const PluralRules& rules, - number::impl::NumberStringBuilder& output, + FormattedStringBuilder& output, StandardPlural::Form& pluralForm, UErrorCode& status) { UnicodeString pluralKeyword; @@ -188,7 +188,11 @@ void QuantityFormatter::formatAndSelect( if (df != nullptr) { number::impl::UFormattedNumberData fn; fn.quantity.setToDouble(quantity); - df->toNumberFormatter().formatImpl(&fn, status); + const number::LocalizedNumberFormatter* lnf = df->toNumberFormatter(status); + if (U_FAILURE(status)) { + return; + } + lnf->formatImpl(&fn, status); if (U_FAILURE(status)) { return; } diff --git a/deps/icu-small/source/i18n/quantityformatter.h b/deps/icu-small/source/i18n/quantityformatter.h index 3e3f29de57323d..daaef4f060acdb 100644 --- a/deps/icu-small/source/i18n/quantityformatter.h +++ b/deps/icu-small/source/i18n/quantityformatter.h @@ -26,12 +26,7 @@ class PluralRules; class NumberFormat; class Formattable; class FieldPosition; - -namespace number { -namespace impl { -class NumberStringBuilder; -} -} +class FormattedStringBuilder; /** * A plural aware formatter that is good for expressing a single quantity and @@ -41,10 +36,10 @@ class NumberStringBuilder; * There must be a pattern for the "other" variant. * Then use the format() method. *

    - * Concurrent calls only to const methods on a QuantityFormatter object are + * Concurrent calls only to const methods on a QuantityFormatter object are * safe, but concurrent const and non-const method calls on a QuantityFormatter * object are not safe and require synchronization. - * + * */ class U_I18N_API QuantityFormatter : public UMemory { public: @@ -99,7 +94,7 @@ class U_I18N_API QuantityFormatter : public UMemory { * Formats a number with this object appending the result to appendTo. * At least the "other" variant must be added to this object for this * method to work. - * + * * @param number the single number. * @param fmt formats the number * @param rules computes the plural variant to use. @@ -129,7 +124,7 @@ class U_I18N_API QuantityFormatter : public UMemory { /** * Formats a quantity and selects its plural form. The output is appended - * to a NumberStringBuilder in order to retain field information. + * to a FormattedStringBuilder in order to retain field information. * * @param quantity The number to format. * @param fmt The formatter to use to format the number. @@ -144,7 +139,7 @@ class U_I18N_API QuantityFormatter : public UMemory { double quantity, const NumberFormat& fmt, const PluralRules& rules, - number::impl::NumberStringBuilder& output, + FormattedStringBuilder& output, StandardPlural::Form& pluralForm, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/rbnf.cpp b/deps/icu-small/source/i18n/rbnf.cpp index 74707ccd22d2ac..17319fb6d59fe4 100644 --- a/deps/icu-small/source/i18n/rbnf.cpp +++ b/deps/icu-small/source/i18n/rbnf.cpp @@ -83,34 +83,34 @@ class LocalizationInfo : public UMemory { protected: virtual ~LocalizationInfo(); uint32_t refcount; - + public: LocalizationInfo() : refcount(0) {} - + LocalizationInfo* ref(void) { ++refcount; return this; } - + LocalizationInfo* unref(void) { if (refcount && --refcount == 0) { delete this; } return NULL; } - + virtual UBool operator==(const LocalizationInfo* rhs) const; inline UBool operator!=(const LocalizationInfo* rhs) const { return !operator==(rhs); } - + virtual int32_t getNumberOfRuleSets(void) const = 0; virtual const UChar* getRuleSetName(int32_t index) const = 0; virtual int32_t getNumberOfDisplayLocales(void) const = 0; virtual const UChar* getLocaleName(int32_t index) const = 0; virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const = 0; - + virtual int32_t indexForLocale(const UChar* locale) const; virtual int32_t indexForRuleSet(const UChar* ruleset) const; - + // virtual UClassID getDynamicClassID() const = 0; // static UClassID getStaticClassID(void); }; @@ -120,7 +120,7 @@ LocalizationInfo::~LocalizationInfo() {} //UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(LocalizationInfo) // if both strings are NULL, this returns TRUE -static UBool +static UBool streq(const UChar* lhs, const UChar* rhs) { if (rhs == lhs) { return TRUE; @@ -137,7 +137,7 @@ LocalizationInfo::operator==(const LocalizationInfo* rhs) const { if (this == rhs) { return TRUE; } - + int32_t rsc = getNumberOfRuleSets(); if (rsc == rhs->getNumberOfRuleSets()) { for (int i = 0; i < rsc; ++i) { @@ -199,22 +199,22 @@ class VArray { Fn_Deleter deleter; public: VArray() : buf(NULL), cap(0), size(0), deleter(NULL) {} - + VArray(Fn_Deleter del) : buf(NULL), cap(0), size(0), deleter(del) {} - + ~VArray() { if (deleter) { for (int i = 0; i < size; ++i) { (*deleter)(buf[i]); } } - uprv_free(buf); + uprv_free(buf); } - + int32_t length() { return size; } - + void add(void* elem, UErrorCode& status) { if (U_SUCCESS(status)) { if (size == cap) { @@ -242,7 +242,7 @@ class VArray { buf[size++] = elem; } } - + void** release(void) { void** result = buf; buf = NULL; @@ -266,20 +266,20 @@ friend class LocDataParser; : info(i), data(d), numRuleSets(numRS), numLocales(numLocs) { } - + public: static StringLocalizationInfo* create(const UnicodeString& info, UParseError& perror, UErrorCode& status); - + virtual ~StringLocalizationInfo(); virtual int32_t getNumberOfRuleSets(void) const { return numRuleSets; } virtual const UChar* getRuleSetName(int32_t index) const; virtual int32_t getNumberOfDisplayLocales(void) const { return numLocales; } virtual const UChar* getLocaleName(int32_t index) const; virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const; - + // virtual UClassID getDynamicClassID() const; // static UClassID getStaticClassID(void); - + private: void init(UErrorCode& status) const; }; @@ -304,20 +304,20 @@ class LocDataParser { UChar ch; UParseError& pe; UErrorCode& ec; - + public: - LocDataParser(UParseError& parseError, UErrorCode& status) + LocDataParser(UParseError& parseError, UErrorCode& status) : data(NULL), e(NULL), p(NULL), ch(0xffff), pe(parseError), ec(status) {} ~LocDataParser() {} - + /* * On a successful parse, return a StringLocalizationInfo*, otherwise delete locData, set perror and status, * and return NULL. The StringLocalizationInfo will adopt locData if it is created. */ StringLocalizationInfo* parse(UChar* data, int32_t len); - + private: - + inline void inc(void) { ++p; ch = 0xffff; @@ -347,31 +347,37 @@ class LocDataParser { return *list == c; } void parseError(const char* msg); - + StringLocalizationInfo* doParse(void); - + UChar** nextArray(int32_t& requiredLength); UChar* nextString(void); }; #ifdef RBNF_DEBUG -#define ERROR(msg) parseError(msg); return NULL; +#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \ + parseError(msg); \ + return NULL; \ +} UPRV_BLOCK_MACRO_END #define EXPLANATION_ARG explanationArg #else -#define ERROR(msg) parseError(NULL); return NULL; +#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \ + parseError(NULL); \ + return NULL; \ +} UPRV_BLOCK_MACRO_END #define EXPLANATION_ARG #endif + - -static const UChar DQUOTE_STOPLIST[] = { +static const UChar DQUOTE_STOPLIST[] = { QUOTE, 0 }; -static const UChar SQUOTE_STOPLIST[] = { +static const UChar SQUOTE_STOPLIST[] = { TICK, 0 }; -static const UChar NOQUOTE_STOPLIST[] = { +static const UChar NOQUOTE_STOPLIST[] = { SPACE, COMMA, CLOSE_ANGLE, OPEN_ANGLE, TICK, QUOTE, 0 }; @@ -455,11 +461,11 @@ LocDataParser::doParse(void) { if (U_SUCCESS(ec)) { int32_t numLocs = array.length() - 2; // subtract first, NULL UChar*** result = (UChar***)array.release(); - + return new StringLocalizationInfo(data, result, requiredLength-2, numLocs); // subtract first, NULL } } - + ERROR("Unknown error"); } @@ -468,7 +474,7 @@ LocDataParser::nextArray(int32_t& requiredLength) { if (U_FAILURE(ec)) { return NULL; } - + skipWhitespace(); if (!checkInc(OPEN_ANGLE)) { ERROR("Missing open angle"); @@ -508,7 +514,7 @@ LocDataParser::nextArray(int32_t& requiredLength) { ec = U_ILLEGAL_ARGUMENT_ERROR; ERROR("Array not of required length"); } - + return (UChar**)array.release(); } ERROR("Unknown Error"); @@ -517,7 +523,7 @@ LocDataParser::nextArray(int32_t& requiredLength) { UChar* LocDataParser::nextString() { UChar* result = NULL; - + skipWhitespace(); if (p < e) { const UChar* terminators; @@ -534,7 +540,7 @@ LocDataParser::nextString() { if (p == e) { ERROR("Unexpected end of data"); } - + UChar x = *p; if (p > start) { ch = x; @@ -582,7 +588,7 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG) u_strncpy(pe.postContext, p, (int32_t)(limit-p)); pe.postContext[limit-p] = 0; pe.offset = (int32_t)(p - data); - + #ifdef RBNF_DEBUG fprintf(stderr, "%s at or near character %ld: ", EXPLANATION_ARG, p-data); @@ -591,7 +597,7 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG) msg.append((UChar)0x002f); /* SOLIDUS/SLASH */ msg.append(p, limit-p); msg.append(UNICODE_STRING_SIMPLE("'")); - + char buf[128]; int32_t len = msg.extract(0, msg.length(), buf, 128); if (len >= 128) { @@ -602,12 +608,12 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG) fprintf(stderr, "%s\n", buf); fflush(stderr); #endif - + uprv_free(data); data = NULL; p = NULL; e = NULL; - + if (U_SUCCESS(ec)) { ec = U_PARSE_ERROR; } @@ -615,17 +621,17 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG) //UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringLocalizationInfo) -StringLocalizationInfo* +StringLocalizationInfo* StringLocalizationInfo::create(const UnicodeString& info, UParseError& perror, UErrorCode& status) { if (U_FAILURE(status)) { return NULL; } - + int32_t len = info.length(); if (len == 0) { return NULL; // no error; } - + UChar* p = (UChar*)uprv_malloc(len * sizeof(UChar)); if (!p) { status = U_MEMORY_ALLOCATION_ERROR; @@ -635,7 +641,7 @@ StringLocalizationInfo::create(const UnicodeString& info, UParseError& perror, U if (!U_FAILURE(status)) { status = U_ZERO_ERROR; // clear warning about non-termination } - + LocDataParser parser(perror, status); return parser.parse(p, len); } @@ -677,7 +683,7 @@ StringLocalizationInfo::getDisplayName(int32_t localeIndex, int32_t ruleIndex) c // ---------- -RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, +RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const UnicodeString& locs, const Locale& alocale, UParseError& perror, UErrorCode& status) : fRuleSets(NULL) @@ -702,7 +708,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, init(description, locinfo, perror, status); } -RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, +RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const UnicodeString& locs, UParseError& perror, UErrorCode& status) : fRuleSets(NULL) @@ -727,7 +733,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, init(description, locinfo, perror, status); } -RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, +RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* info, const Locale& alocale, UParseError& perror, UErrorCode& status) : fRuleSets(NULL) @@ -751,9 +757,9 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, init(description, info, perror, status); } -RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, - UParseError& perror, - UErrorCode& status) +RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, + UParseError& perror, + UErrorCode& status) : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) @@ -775,10 +781,10 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, init(description, NULL, perror, status); } -RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, +RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const Locale& aLocale, - UParseError& perror, - UErrorCode& status) + UParseError& perror, + UErrorCode& status) : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) @@ -924,8 +930,8 @@ RuleBasedNumberFormat::~RuleBasedNumberFormat() dispose(); } -Format* -RuleBasedNumberFormat::clone(void) const +RuleBasedNumberFormat* +RuleBasedNumberFormat::clone() const { return new RuleBasedNumberFormat(*this); } @@ -944,9 +950,9 @@ RuleBasedNumberFormat::operator==(const Format& other) const // the info here is just derived from that. if (locale == rhs.locale && lenient == rhs.lenient && - (localizations == NULL - ? rhs.localizations == NULL - : (rhs.localizations == NULL + (localizations == NULL + ? rhs.localizations == NULL + : (rhs.localizations == NULL ? FALSE : *localizations == rhs.localizations))) { @@ -1020,7 +1026,7 @@ RuleBasedNumberFormat::getNumberOfRuleSetNames() const return result; } -int32_t +int32_t RuleBasedNumberFormat::getNumberOfRuleSetDisplayNameLocales(void) const { if (localizations) { return localizations->getNumberOfDisplayLocales(); @@ -1028,7 +1034,7 @@ RuleBasedNumberFormat::getNumberOfRuleSetDisplayNameLocales(void) const { return 0; } -Locale +Locale RuleBasedNumberFormat::getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const { if (U_FAILURE(status)) { return Locale(""); @@ -1057,10 +1063,10 @@ RuleBasedNumberFormat::getRuleSetDisplayNameLocale(int32_t index, UErrorCode& st return retLocale; } -UnicodeString +UnicodeString RuleBasedNumberFormat::getRuleSetDisplayName(int32_t index, const Locale& localeParam) { if (localizations && index >= 0 && index < localizations->getNumberOfRuleSets()) { - UnicodeString localeName(localeParam.getBaseName(), -1, UnicodeString::kInvariant); + UnicodeString localeName(localeParam.getBaseName(), -1, UnicodeString::kInvariant); int32_t len = localeName.length(); UChar* localeStr = localeName.getBuffer(len + 1); while (len >= 0) { @@ -1070,7 +1076,7 @@ RuleBasedNumberFormat::getRuleSetDisplayName(int32_t index, const Locale& locale UnicodeString name(TRUE, localizations->getDisplayName(ix, index), -1); return name; } - + // trim trailing portion, skipping over ommitted sections do { --len;} while (len > 0 && localeStr[len] != 0x005f); // underscore while (len > 0 && localeStr[len-1] == 0x005F) --len; @@ -1083,7 +1089,7 @@ RuleBasedNumberFormat::getRuleSetDisplayName(int32_t index, const Locale& locale return bogus; } -UnicodeString +UnicodeString RuleBasedNumberFormat::getRuleSetDisplayName(const UnicodeString& ruleSetName, const Locale& localeParam) { if (localizations) { UnicodeString rsn(ruleSetName); @@ -1110,45 +1116,6 @@ RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status return NULL; } -UnicodeString& -RuleBasedNumberFormat::format(const DecimalQuantity &number, - UnicodeString &appendTo, - FieldPositionIterator *posIter, - UErrorCode &status) const { - if (U_FAILURE(status)) { - return appendTo; - } - DecimalQuantity copy(number); - if (copy.fitsInLong()) { - format(number.toLong(), appendTo, posIter, status); - } - else { - copy.roundToMagnitude(0, number::impl::RoundingMode::UNUM_ROUND_HALFEVEN, status); - if (copy.fitsInLong()) { - format(number.toDouble(), appendTo, posIter, status); - } - else { - // We're outside of our normal range that this framework can handle. - // The DecimalFormat will provide more accurate results. - - // TODO this section should probably be optimized. The DecimalFormat is shared in ICU4J. - LocalPointer decimalFormat(NumberFormat::createInstance(locale, UNUM_DECIMAL, status), status); - if (decimalFormat.isNull()) { - return appendTo; - } - Formattable f; - LocalPointer decimalQuantity(new DecimalQuantity(number), status); - if (decimalQuantity.isNull()) { - return appendTo; - } - f.adoptDecimalQuantity(decimalQuantity.orphan()); // f now owns decimalQuantity. - decimalFormat->format(f, appendTo, posIter, status); - } - } - return appendTo; -} - - UnicodeString& RuleBasedNumberFormat::format(const DecimalQuantity &number, UnicodeString& appendTo, @@ -1441,7 +1408,7 @@ RuleBasedNumberFormat::setLenient(UBool enabled) #endif -void +void RuleBasedNumberFormat::setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& status) { if (U_SUCCESS(status)) { if (ruleSetName.isEmpty()) { @@ -1473,7 +1440,7 @@ RuleBasedNumberFormat::getDefaultRuleSetName() const { return result; } -void +void RuleBasedNumberFormat::initDefaultRuleSet() { defaultRuleSet = NULL; @@ -1645,7 +1612,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali // by appending more rule sets to the end) // {dlf} Initialization of a fraction rule set requires the default rule - // set to be known. For purposes of initialization, this is always the + // set to be known. For purposes of initialization, this is always the // last public rule set, no matter what the localization data says. initDefaultRuleSet(); @@ -1664,7 +1631,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali // The C code keeps the localization array as is, rather than building // a separate array of the public rule set names, so we have less work // to do here-- but we still need to check the names. - + if (localizationInfos) { // confirm the names, if any aren't in the rules, that's an error // it is ok if the rules contain public rule sets that are not in this list @@ -1691,10 +1658,10 @@ RuleBasedNumberFormat::setContext(UDisplayContext value, UErrorCode& status) { NumberFormat::setContext(value, status); if (U_SUCCESS(status)) { - if (!capitalizationInfoSet && - (value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE)) { - initCapitalizationContextInfo(locale); - capitalizationInfoSet = TRUE; + if (!capitalizationInfoSet && + (value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE)) { + initCapitalizationContextInfo(locale); + capitalizationInfoSet = TRUE; } #if !UCONFIG_NO_BREAK_ITERATION if ( capitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || diff --git a/deps/icu-small/source/i18n/rbt.cpp b/deps/icu-small/source/i18n/rbt.cpp index 8ba6a60ff42218..4cef242e582da2 100644 --- a/deps/icu-small/source/i18n/rbt.cpp +++ b/deps/icu-small/source/i18n/rbt.cpp @@ -62,7 +62,7 @@ void RuleBasedTransliterator::_construct(const UnicodeString& rules, * @param rules rules, separated by ';' * @param direction either FORWARD or REVERSE. * @param adoptedFilter the filter for this transliterator. - * @param parseError Struct to recieve information on position + * @param parseError Struct to recieve information on position * of error if an error is encountered * @param status Output param set to success/failure code. * @exception IllegalArgumentException if rules are malformed @@ -191,8 +191,8 @@ RuleBasedTransliterator::~RuleBasedTransliterator() { } } -Transliterator* // Covariant return NOT ALLOWED (for portability) -RuleBasedTransliterator::clone(void) const { +RuleBasedTransliterator* +RuleBasedTransliterator::clone() const { return new RuleBasedTransliterator(*this); } @@ -235,16 +235,16 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition& } // Transliterator locking. Rule-based Transliterators are not thread safe; concurrent - // operations must be prevented. + // operations must be prevented. // A Complication: compound transliterators can result in recursive entries to this - // function, sometimes with different "This" objects, always with the same text. + // function, sometimes with different "This" objects, always with the same text. // Double-locking must be prevented in these cases. - // + // UBool lockedMutexAtThisLevel = FALSE; // Test whether this request is operating on the same text string as - // some other transliteration that is still in progress and holding the + // some other transliteration that is still in progress and holding the // transliteration mutex. If so, do not lock the transliteration // mutex again. // @@ -253,7 +253,7 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition& // // TODO(andy): Need a better scheme for handling this. - static UMutex transliteratorDataMutex = U_MUTEX_INITIALIZER; + static UMutex transliteratorDataMutex; UBool needToLock; { Mutex m; @@ -265,7 +265,7 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition& gLockedText = &text; lockedMutexAtThisLevel = TRUE; } - + // Check to make sure we don't dereference a null pointer. if (fData != NULL) { while (index.start < index.limit && diff --git a/deps/icu-small/source/i18n/rbt.h b/deps/icu-small/source/i18n/rbt.h index a18452ab2ecb49..97ef01e140af04 100644 --- a/deps/icu-small/source/i18n/rbt.h +++ b/deps/icu-small/source/i18n/rbt.h @@ -144,7 +144,7 @@ class RuleBasedTransliterator : public Transliterator { * Implement Transliterator API. * @internal Use transliterator factory methods instead since this class will be removed in that release. */ - virtual Transliterator* clone(void) const; + virtual RuleBasedTransliterator* clone() const; protected: /** @@ -200,7 +200,7 @@ class RuleBasedTransliterator : public Transliterator { * is to implement a simple version of RTTI, since not all C++ * compilers support genuine RTTI. Polymorphic operator==() and * clone() methods call this method. - * + * * @return The class ID for this object. All objects of a given * class have the same class ID. Objects of other classes have * different class IDs. diff --git a/deps/icu-small/source/i18n/rbt_data.cpp b/deps/icu-small/source/i18n/rbt_data.cpp index 7a9707b988b42e..4b596ac6c4a2b1 100644 --- a/deps/icu-small/source/i18n/rbt_data.cpp +++ b/deps/icu-small/source/i18n/rbt_data.cpp @@ -51,7 +51,7 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData& new UnicodeString(*(const UnicodeString*)e->value.pointer); // Exit out if value could not be created. if (value == NULL) { - return; + return; } variableNames.put(*(UnicodeString*)e->key.pointer, value, status); } diff --git a/deps/icu-small/source/i18n/rbt_pars.cpp b/deps/icu-small/source/i18n/rbt_pars.cpp index e07cc8b63a408c..1ae5b81f034d8f 100644 --- a/deps/icu-small/source/i18n/rbt_pars.cpp +++ b/deps/icu-small/source/i18n/rbt_pars.cpp @@ -369,10 +369,10 @@ int32_t RuleHalf::parse(const UnicodeString& rule, int32_t pos, int32_t limit, U if (cursorOffset > 0 && cursor != cursorOffsetPos) { return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status); } - + return pos; } - + /** * Parse a section of one side of a rule, stopping at either * the limit, the END_OF_RULE character, an operator, or a @@ -409,7 +409,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l int32_t varStart = -1; // Most recent $variableReference int32_t varLimit = -1; int32_t bufStart = buf.length(); - + while (pos < limit && !done) { // Since all syntax characters are in the BMP, fetching // 16-bit code units suffices here. @@ -437,7 +437,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l if (U_FAILURE(status)) { return syntaxError(U_MALFORMED_SET, rule, start, status); } - pos = pp.getIndex(); + pos = pp.getIndex(); continue; } // Handle escapes @@ -505,7 +505,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l } switch (c) { - + //------------------------------------------------------ // Elements allowed within and out of segments //------------------------------------------------------ @@ -522,15 +522,15 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l // bufSegStart is the offset in buf to the first // character of the segment we are parsing. int32_t bufSegStart = buf.length(); - + // Record segment number now, since nextSegmentNumber // will be incremented during the call to parseSection // if there are nested segments. int32_t segmentNumber = nextSegmentNumber++; // 1-based - + // Parse the segment pos = parseSection(rule, pos, limit, buf, UnicodeString(TRUE, ILLEGAL_SEG, -1), TRUE, status); - + // After parsing a segment, the relevant characters are // in buf, starting at offset bufSegStart. Extract them // into a string matcher, and replace them with a @@ -541,7 +541,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l if (m == NULL) { return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status); } - + // Record and associate object and segment number parser.setSegmentObject(segmentNumber, m, status); buf.truncate(bufSegStart); @@ -559,20 +559,20 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l !ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) { return syntaxError(U_INVALID_FUNCTION, rule, start, status); } - + Transliterator *t = single->createInstance(); delete single; if (t == NULL) { return syntaxError(U_INVALID_FUNCTION, rule, start, status); } - + // bufSegStart is the offset in buf to the first // character of the segment we are parsing. int32_t bufSegStart = buf.length(); - + // Parse the segment pos = parseSection(rule, iref, limit, buf, UnicodeString(TRUE, ILLEGAL_FUNC, -1), TRUE, status); - + // After parsing a segment, the relevant characters are // in buf, starting at offset bufSegStart. UnicodeString output; @@ -582,7 +582,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l if (r == NULL) { return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status); } - + // Replace the buffer contents with a stand-in buf.truncate(bufSegStart); buf.append(parser.generateStandInFor(r, status)); @@ -864,7 +864,7 @@ TransliteratorParser::parse(const UnicodeString& rules, /** * Return the compound filter parsed by parse(). Caller owns result. - */ + */ UnicodeSet* TransliteratorParser::orphanCompoundFilter() { UnicodeSet* f = compoundFilter; compoundFilter = NULL; @@ -893,7 +893,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, UBool parsingIDs = TRUE; int32_t ruleCount = 0; - + while (!dataVector.isEmpty()) { delete (TransliterationRuleData*)(dataVector.orphanElementAt(0)); } @@ -956,7 +956,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, // keep track of how many rules we've seen ++ruleCount; - + // We've found the start of a rule or ID. c is its first // character, and pos points past c. --pos; @@ -972,7 +972,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, } int32_t p = pos; - + if (!parsingIDs) { if (curData != NULL) { if (direction == UTRANS_FORWARD) @@ -1083,7 +1083,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, else dataVector.insertElementAt(curData, 0, status); } - + if (U_SUCCESS(status)) { // Convert the set vector to an array int32_t i, dataVectorSize = dataVector.size(); @@ -1106,12 +1106,12 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, data->variables[j] = static_cast(variablesVector.elementAt(j)); } - + data->variableNames.removeAll(); int32_t p = UHASH_FIRST; const UHashElement* he = variableNames.nextElement(p); while (he != NULL) { - UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->value.pointer))->clone()); + UnicodeString* tempus = ((UnicodeString*)(he->value.pointer))->clone(); if (tempus == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return; @@ -1129,7 +1129,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, (direction == UTRANS_REVERSE && compoundFilterOffset != ruleCount)) { status = U_MISPLACED_COMPOUND_FILTER; } - } + } for (i = 0; i < dataVectorSize; i++) { TransliterationRuleData* data = (TransliterationRuleData*)dataVector.elementAt(i); @@ -1149,7 +1149,7 @@ void TransliteratorParser::setVariableRange(int32_t start, int32_t end, UErrorCo status = U_MALFORMED_PRAGMA; return; } - + curData->variablesBase = (UChar) start; if (dataVector.size() == 0) { variableNext = (UChar) start; @@ -1214,12 +1214,12 @@ UBool TransliteratorParser::resemblesPragma(const UnicodeString& rule, int32_t p */ int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) { int32_t array[2]; - + // resemblesPragma() has already returned true, so we // know that pos points to /use\s/i; we can skip 4 characters // immediately pos += 4; - + // Here are the pragmas we recognize: // use variable range 0xE000 0xEFFF; // use maximum backup 16; @@ -1230,25 +1230,25 @@ int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos setVariableRange(array[0], array[1], status); return p; } - + p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_MAXIMUM_BACKUP, -1), array); if (p >= 0) { pragmaMaximumBackup(array[0]); return p; } - + p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFD_RULES, -1), NULL); if (p >= 0) { pragmaNormalizeRules(UNORM_NFD); return p; } - + p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFC_RULES, -1), NULL); if (p >= 0) { pragmaNormalizeRules(UNORM_NFC); return p; } - + // Syntax error: unable to parse pragma return -1; } @@ -1345,7 +1345,7 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, if (left->anchorStart || left->anchorEnd || right->anchorStart || right->anchorEnd) { return syntaxError(U_MALFORMED_VARIABLE_DEFINITION, rule, start, status); - } + } // We allow anything on the right, including an empty string. UnicodeString* value = new UnicodeString(right->text); // NULL pointer check @@ -1379,7 +1379,7 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen } } - + // If the direction we want doesn't match the rule // direction, do nothing. if (op != FWDREV_RULE_OP && @@ -1477,20 +1477,20 @@ int32_t TransliteratorParser::syntaxError(UErrorCode parseErrorCode, { parseError.offset = pos; parseError.line = 0 ; /* we are not using line numbers */ - + // for pre-context const int32_t LEN = U_PARSE_CONTEXT_LEN - 1; int32_t start = uprv_max(pos - LEN, 0); int32_t stop = pos; - + rule.extract(start,stop-start,parseError.preContext); //null terminate the buffer parseError.preContext[stop-start] = 0; - + //for post-context start = pos; stop = uprv_min(pos + LEN, rule.length()); - + rule.extract(start,stop-start,parseError.postContext); //null terminate the buffer parseError.postContext[stop-start]= 0; @@ -1523,7 +1523,7 @@ UChar TransliteratorParser::parseSet(const UnicodeString& rule, */ UChar TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status) { // assert(obj != null); - + // Look up previous stand-in, if any. This is a short list // (typical n is 0, 1, or 2); linear search is optimal. for (int32_t i=0; ivariablesBase + i); } } - + if (variableNext >= variableLimit) { delete adopted; status = U_VARIABLE_RANGE_EXHAUSTED; diff --git a/deps/icu-small/source/i18n/rbt_pars.h b/deps/icu-small/source/i18n/rbt_pars.h index d51f2e852bb5b4..61ce9727e05f9d 100644 --- a/deps/icu-small/source/i18n/rbt_pars.h +++ b/deps/icu-small/source/i18n/rbt_pars.h @@ -84,8 +84,8 @@ class TransliteratorParser : public UMemory { * Temporary table of variable names. When parsing is complete, this is * copied into data.variableNames. */ - Hashtable variableNames; - + Hashtable variableNames; + /** * String of standins for segments. Used during the parsing of a single * rule. segmentStandins.charAt(0) is the standin for "$1" and corresponds @@ -95,7 +95,7 @@ class TransliteratorParser : public UMemory { /** * Vector of StringMatcher objects for segments. Used during the - * parsing of a single rule. + * parsing of a single rule. * segmentStandins.charAt(0) is the standin for "$1" and corresponds * to StringMatcher object segmentObjects.elementAt(0), etc. */ @@ -156,7 +156,7 @@ class TransliteratorParser : public UMemory { * call returns. * @param rules rules, separated by ';' * @param direction either FORWARD or REVERSE. - * @param pe Struct to recieve information on position + * @param pe Struct to recieve information on position * of error if an error is encountered * @param ec Output param set to success/failure code. */ @@ -168,7 +168,7 @@ class TransliteratorParser : public UMemory { /** * Return the compound filter parsed by parse(). Caller owns result. * @return the compound filter parsed by parse(). - */ + */ UnicodeSet* orphanCompoundFilter(); private: @@ -328,7 +328,7 @@ class TransliteratorParser : public UMemory { * Copy constructor */ TransliteratorParser(const TransliteratorParser&); - + /** * Assignment operator */ diff --git a/deps/icu-small/source/i18n/rbt_rule.cpp b/deps/icu-small/source/i18n/rbt_rule.cpp index db02f76035c9ea..6cc5325c467eab 100644 --- a/deps/icu-small/source/i18n/rbt_rule.cpp +++ b/deps/icu-small/source/i18n/rbt_rule.cpp @@ -126,7 +126,7 @@ TransliterationRule::TransliterationRule(const UnicodeString& input, return; } } - + key = NULL; if (keyLength > 0) { key = new StringMatcher(pattern, anteContextLength, anteContextLength + keyLength, @@ -137,7 +137,7 @@ TransliterationRule::TransliterationRule(const UnicodeString& input, return; } } - + int32_t postContextLength = pattern.length() - keyLength - anteContextLength; postContext = NULL; if (postContextLength > 0) { @@ -180,13 +180,13 @@ TransliterationRule::TransliterationRule(TransliterationRule& other) : } if (other.anteContext != NULL) { - anteContext = (StringMatcher*) other.anteContext->clone(); + anteContext = other.anteContext->clone(); } if (other.key != NULL) { - key = (StringMatcher*) other.key->clone(); + key = other.key->clone(); } if (other.postContext != NULL) { - postContext = (StringMatcher*) other.postContext->clone(); + postContext = other.postContext->clone(); } output = other.output->clone(); } @@ -259,7 +259,7 @@ UBool TransliterationRule::masks(const TransliterationRule& r2) const { * r1: aakkkpppp * r2: aaakkkkkpppp * ^ - * + * * The strings must be aligned at the first character of the * key. The length of r1 to the left of the alignment point * must be <= the length of r2 to the left; ditto for the @@ -337,10 +337,10 @@ static inline int32_t posAfter(const Replaceable& str, int32_t pos) { * context and key characters match, but the text is not long * enough to match all of them. A full match means all context * and key characters match. - * + * * If a full match is obtained, perform a replacement, update pos, * and return U_MATCH. Otherwise both text and pos are unchanged. - * + * * @param text the text * @param pos the position indices * @param incremental if TRUE, test for partial matches that may @@ -383,7 +383,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, // 32-bit code points. This works because stand-ins are // always in the BMP and because we are doing a literal match // operation, which can be done 16-bits at a time. - + int32_t anteLimit = posBefore(text, pos.contextStart); UMatchDegree match; @@ -401,13 +401,13 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, minOText = posAfter(text, oText); // ------------------------ Start Anchor ------------------------ - + if (((flags & ANCHOR_START) != 0) && oText != anteLimit) { return U_MISMATCH; } // -------------------- Key and Post Context -------------------- - + oText = pos.start; if (key != NULL) { @@ -433,9 +433,9 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, return match; } } - + // ------------------------- Stop Anchor ------------------------ - + if (((flags & ANCHOR_END)) != 0) { if (oText != pos.contextLimit) { return U_MISMATCH; @@ -444,7 +444,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, return U_PARTIAL_MATCH; } } - + // =========================== REPLACE ========================== // We have a full match. The key is between pos.start and diff --git a/deps/icu-small/source/i18n/rbt_rule.h b/deps/icu-small/source/i18n/rbt_rule.h index eb8556df0cda5d..55019812667352 100644 --- a/deps/icu-small/source/i18n/rbt_rule.h +++ b/deps/icu-small/source/i18n/rbt_rule.h @@ -261,10 +261,10 @@ class TransliterationRule : public UMemory { * context and key characters match, but the text is not long * enough to match all of them. A full match means all context * and key characters match. - * + * * If a full match is obtained, perform a replacement, update pos, * and return U_MATCH. Otherwise both text and pos are unchanged. - * + * * @param text the text * @param pos the position indices * @param incremental if TRUE, test for partial matches that may diff --git a/deps/icu-small/source/i18n/rbt_set.cpp b/deps/icu-small/source/i18n/rbt_set.cpp index 939c0ea39ade63..d8d0384dda6f41 100644 --- a/deps/icu-small/source/i18n/rbt_set.cpp +++ b/deps/icu-small/source/i18n/rbt_set.cpp @@ -143,19 +143,19 @@ static void maskingError(const icu::TransliterationRule& rule1, int32_t len; parseError.line = parseError.offset = -1; - + // for pre-context rule1.toRule(r, FALSE); len = uprv_min(r.length(), U_PARSE_CONTEXT_LEN-1); r.extract(0, len, parseError.preContext); - parseError.preContext[len] = 0; - + parseError.preContext[len] = 0; + //for post-context r.truncate(0); rule2.toRule(r, FALSE); len = uprv_min(r.length(), U_PARSE_CONTEXT_LEN-1); r.extract(0, len, parseError.postContext); - parseError.postContext[len] = 0; + parseError.postContext[len] = 0; } U_NAMESPACE_BEGIN diff --git a/deps/icu-small/source/i18n/rbt_set.h b/deps/icu-small/source/i18n/rbt_set.h index 9b2b8b38dba5ca..b4b46786bf1d51 100644 --- a/deps/icu-small/source/i18n/rbt_set.h +++ b/deps/icu-small/source/i18n/rbt_set.h @@ -120,7 +120,7 @@ class TransliterationRuleSet : public UMemory { * @param status Output parameter filled in with success or failure status. */ virtual void freeze(UParseError& parseError, UErrorCode& status); - + /** * Transliterate the given text with the given UTransPosition * indices. Return TRUE if the transliteration should continue diff --git a/deps/icu-small/source/i18n/rbtz.cpp b/deps/icu-small/source/i18n/rbtz.cpp index b8dca395fc0403..3249a32a1cf095 100644 --- a/deps/icu-small/source/i18n/rbtz.cpp +++ b/deps/icu-small/source/i18n/rbtz.cpp @@ -149,7 +149,7 @@ RuleBasedTimeZone::addTransitionRule(TimeZoneRule* rule, UErrorCode& status) { void RuleBasedTimeZone::completeConst(UErrorCode& status) const { - static UMutex gLock = U_MUTEX_INITIALIZER; + static UMutex gLock; if (U_FAILURE(status)) { return; } @@ -356,8 +356,8 @@ RuleBasedTimeZone::complete(UErrorCode& status) { fUpToDate = FALSE; } -TimeZone* -RuleBasedTimeZone::clone(void) const { +RuleBasedTimeZone* +RuleBasedTimeZone::clone() const { return new RuleBasedTimeZone(*this); } @@ -449,7 +449,7 @@ RuleBasedTimeZone::getOffsetInternal(UDate date, UBool local, } if (rule == NULL) { // no final rules or the given time is before the first transition - // specified by the final rules -> use the last rule + // specified by the final rules -> use the last rule rule = ((Transition*)fHistoricTransitions->elementAt(idx))->to; } } else { @@ -749,7 +749,7 @@ RuleBasedTimeZone::findNext(UDate base, UBool inclusive, UDate& transitionTime, result = *tzt; found = TRUE; } else { - int32_t idx = fHistoricTransitions->size() - 1; + int32_t idx = fHistoricTransitions->size() - 1; tzt = (Transition*)fHistoricTransitions->elementAt(idx); tt = tzt->time; if (inclusive && tt == base) { @@ -832,7 +832,7 @@ RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime, result = *tzt; found = TRUE; } else if (tt < base) { - int32_t idx = fHistoricTransitions->size() - 1; + int32_t idx = fHistoricTransitions->size() - 1; tzt = (Transition*)fHistoricTransitions->elementAt(idx); tt = tzt->time; if (inclusive && tt == base) { @@ -956,3 +956,4 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ //eof + diff --git a/deps/icu-small/source/i18n/regexcmp.cpp b/deps/icu-small/source/i18n/regexcmp.cpp index 8d60986fd32ca6..cacc069e962cb5 100644 --- a/deps/icu-small/source/i18n/regexcmp.cpp +++ b/deps/icu-small/source/i18n/regexcmp.cpp @@ -450,7 +450,7 @@ UBool RegexCompile::doParseActions(int32_t action) case doBadNamedCapture: error(U_REGEX_INVALID_CAPTURE_GROUP_NAME); break; - + case doOpenCaptureParen: // Open Capturing Paren, possibly named. // Compile to a @@ -561,7 +561,7 @@ UBool RegexCompile::doParseActions(int32_t action) // sequence; don't change without making updates there too. // // Compiles to - // 1 START_LA dataLoc Saves SP, Input Pos + // 1 LA_START dataLoc Saves SP, Input Pos, Active input region. // 2. STATE_SAVE 4 on failure of lookahead, goto 4 // 3 JMP 6 continue ... // @@ -575,10 +575,14 @@ UBool RegexCompile::doParseActions(int32_t action) // 8. code for parenthesized stuff. // 9. LA_END // - // Two data slots are reserved, for saving the stack ptr and the input position. + // Four data slots are reserved, for saving state on entry to the look-around + // 0: stack pointer on entry. + // 1: input position on entry. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. { fixLiterals(); - int32_t dataLoc = allocateData(2); + int32_t dataLoc = allocateData(4); appendOp(URX_LA_START, dataLoc); appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2); appendOp(URX_JMP, fRXPat->fCompiledPat->size()+ 3); @@ -599,18 +603,23 @@ UBool RegexCompile::doParseActions(int32_t action) case doOpenLookAheadNeg: // Negated Lookahead. (?! stuff ) // Compiles to - // 1. START_LA dataloc + // 1. LA_START dataloc // 2. SAVE_STATE 7 // Fail within look-ahead block restores to this state, // // which continues with the match. // 3. NOP // Std. Open Paren sequence, for possible '|' // 4. code for parenthesized stuff. - // 5. END_LA // Cut back stack, remove saved state from step 2. + // 5. LA_END // Cut back stack, remove saved state from step 2. // 6. BACKTRACK // code in block succeeded, so neg. lookahead fails. // 7. END_LA // Restore match region, in case look-ahead was using // an alternate (transparent) region. + // Four data slots are reserved, for saving state on entry to the look-around + // 0: stack pointer on entry. + // 1: input position on entry. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. { fixLiterals(); - int32_t dataLoc = allocateData(2); + int32_t dataLoc = allocateData(4); appendOp(URX_LA_START, dataLoc); appendOp(URX_STATE_SAVE, 0); // dest address will be patched later. appendOp(URX_NOP, 0); @@ -644,14 +653,16 @@ UBool RegexCompile::doParseActions(int32_t action) // Allocate a block of matcher data, to contain (when running a match) // 0: Stack ptr on entry // 1: Input Index on entry - // 2: Start index of match current match attempt. - // 3: Original Input String len. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. + // 4: Start index of match current match attempt. + // The first four items must match the layout of data for LA_START / LA_END // Generate match code for any pending literals. fixLiterals(); // Allocate data space - int32_t dataLoc = allocateData(4); + int32_t dataLoc = allocateData(5); // Emit URX_LB_START appendOp(URX_LB_START, dataLoc); @@ -696,14 +707,16 @@ UBool RegexCompile::doParseActions(int32_t action) // Allocate a block of matcher data, to contain (when running a match) // 0: Stack ptr on entry // 1: Input Index on entry - // 2: Start index of match current match attempt. - // 3: Original Input String len. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. + // 4: Start index of match current match attempt. + // The first four items must match the layout of data for LA_START / LA_END // Generate match code for any pending literals. fixLiterals(); // Allocate data space - int32_t dataLoc = allocateData(4); + int32_t dataLoc = allocateData(5); // Emit URX_LB_START appendOp(URX_LB_START, dataLoc); @@ -1325,7 +1338,7 @@ UBool RegexCompile::doParseActions(int32_t action) error(U_MEMORY_ALLOCATION_ERROR); } break; - + case doContinueNamedBackRef: fCaptureName->append(fC.fChar); break; @@ -1352,7 +1365,7 @@ UBool RegexCompile::doParseActions(int32_t action) fCaptureName = NULL; break; } - + case doPossessivePlus: // Possessive ++ quantifier. // Compiles to @@ -2285,7 +2298,7 @@ void RegexCompile::handleCloseParen() { error(U_REGEX_LOOK_BEHIND_LIMIT); break; } - if (minML == INT32_MAX && maxML == 0) { + if (minML == INT32_MAX) { // This condition happens when no match is possible, such as with a // [set] expression containing no elements. // In principle, the generated code to evaluate the expression could be deleted, @@ -2328,7 +2341,7 @@ void RegexCompile::handleCloseParen() { error(U_REGEX_LOOK_BEHIND_LIMIT); break; } - if (minML == INT32_MAX && maxML == 0) { + if (minML == INT32_MAX) { // This condition happens when no match is possible, such as with a // [set] expression containing no elements. // In principle, the generated code to evaluate the expression could be deleted, @@ -2544,8 +2557,8 @@ UBool RegexCompile::compileInlineInterval() { //------------------------------------------------------------------------------ // -// caseInsensitiveStart given a single code point from a pattern string, determine the -// set of characters that could potentially begin a case-insensitive +// caseInsensitiveStart given a single code point from a pattern string, determine the +// set of characters that could potentially begin a case-insensitive // match of a string beginning with that character, using full Unicode // case insensitive matching. // @@ -2576,37 +2589,37 @@ void RegexCompile::findCaseInsensitiveStarters(UChar32 c, UnicodeSet *starterCh // Machine Generated Data. Do not hand edit. static const UChar32 RECaseFixCodePoints[] = { - 0x61, 0x66, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x77, 0x79, 0x2bc, - 0x3ac, 0x3ae, 0x3b1, 0x3b7, 0x3b9, 0x3c1, 0x3c5, 0x3c9, 0x3ce, 0x565, - 0x574, 0x57e, 0x1f00, 0x1f01, 0x1f02, 0x1f03, 0x1f04, 0x1f05, 0x1f06, 0x1f07, - 0x1f20, 0x1f21, 0x1f22, 0x1f23, 0x1f24, 0x1f25, 0x1f26, 0x1f27, 0x1f60, 0x1f61, + 0x61, 0x66, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x77, 0x79, 0x2bc, + 0x3ac, 0x3ae, 0x3b1, 0x3b7, 0x3b9, 0x3c1, 0x3c5, 0x3c9, 0x3ce, 0x565, + 0x574, 0x57e, 0x1f00, 0x1f01, 0x1f02, 0x1f03, 0x1f04, 0x1f05, 0x1f06, 0x1f07, + 0x1f20, 0x1f21, 0x1f22, 0x1f23, 0x1f24, 0x1f25, 0x1f26, 0x1f27, 0x1f60, 0x1f61, 0x1f62, 0x1f63, 0x1f64, 0x1f65, 0x1f66, 0x1f67, 0x1f70, 0x1f74, 0x1f7c, 0x110000}; static const int16_t RECaseFixStringOffsets[] = { - 0x0, 0x1, 0x6, 0x7, 0x8, 0x9, 0xd, 0xe, 0xf, 0x10, - 0x11, 0x12, 0x13, 0x17, 0x1b, 0x20, 0x21, 0x2a, 0x2e, 0x2f, - 0x30, 0x34, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f, 0x41, 0x43, - 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f, 0x51, 0x53, 0x55, 0x57, + 0x0, 0x1, 0x6, 0x7, 0x8, 0x9, 0xd, 0xe, 0xf, 0x10, + 0x11, 0x12, 0x13, 0x17, 0x1b, 0x20, 0x21, 0x2a, 0x2e, 0x2f, + 0x30, 0x34, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f, 0x41, 0x43, + 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f, 0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d, 0x5f, 0x61, 0x63, 0x65, 0x66, 0x67, 0}; static const int16_t RECaseFixCounts[] = { - 0x1, 0x5, 0x1, 0x1, 0x1, 0x4, 0x1, 0x1, 0x1, 0x1, - 0x1, 0x1, 0x4, 0x4, 0x5, 0x1, 0x9, 0x4, 0x1, 0x1, - 0x4, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, - 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x1, 0x5, 0x1, 0x1, 0x1, 0x4, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x4, 0x4, 0x5, 0x1, 0x9, 0x4, 0x1, 0x1, + 0x4, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0}; static const UChar RECaseFixData[] = { - 0x1e9a, 0xfb00, 0xfb01, 0xfb02, 0xfb03, 0xfb04, 0x1e96, 0x130, 0x1f0, 0xdf, - 0x1e9e, 0xfb05, 0xfb06, 0x1e97, 0x1e98, 0x1e99, 0x149, 0x1fb4, 0x1fc4, 0x1fb3, - 0x1fb6, 0x1fb7, 0x1fbc, 0x1fc3, 0x1fc6, 0x1fc7, 0x1fcc, 0x390, 0x1fd2, 0x1fd3, - 0x1fd6, 0x1fd7, 0x1fe4, 0x3b0, 0x1f50, 0x1f52, 0x1f54, 0x1f56, 0x1fe2, 0x1fe3, - 0x1fe6, 0x1fe7, 0x1ff3, 0x1ff6, 0x1ff7, 0x1ffc, 0x1ff4, 0x587, 0xfb13, 0xfb14, - 0xfb15, 0xfb17, 0xfb16, 0x1f80, 0x1f88, 0x1f81, 0x1f89, 0x1f82, 0x1f8a, 0x1f83, - 0x1f8b, 0x1f84, 0x1f8c, 0x1f85, 0x1f8d, 0x1f86, 0x1f8e, 0x1f87, 0x1f8f, 0x1f90, - 0x1f98, 0x1f91, 0x1f99, 0x1f92, 0x1f9a, 0x1f93, 0x1f9b, 0x1f94, 0x1f9c, 0x1f95, - 0x1f9d, 0x1f96, 0x1f9e, 0x1f97, 0x1f9f, 0x1fa0, 0x1fa8, 0x1fa1, 0x1fa9, 0x1fa2, - 0x1faa, 0x1fa3, 0x1fab, 0x1fa4, 0x1fac, 0x1fa5, 0x1fad, 0x1fa6, 0x1fae, 0x1fa7, + 0x1e9a, 0xfb00, 0xfb01, 0xfb02, 0xfb03, 0xfb04, 0x1e96, 0x130, 0x1f0, 0xdf, + 0x1e9e, 0xfb05, 0xfb06, 0x1e97, 0x1e98, 0x1e99, 0x149, 0x1fb4, 0x1fc4, 0x1fb3, + 0x1fb6, 0x1fb7, 0x1fbc, 0x1fc3, 0x1fc6, 0x1fc7, 0x1fcc, 0x390, 0x1fd2, 0x1fd3, + 0x1fd6, 0x1fd7, 0x1fe4, 0x3b0, 0x1f50, 0x1f52, 0x1f54, 0x1f56, 0x1fe2, 0x1fe3, + 0x1fe6, 0x1fe7, 0x1ff3, 0x1ff6, 0x1ff7, 0x1ffc, 0x1ff4, 0x587, 0xfb13, 0xfb14, + 0xfb15, 0xfb17, 0xfb16, 0x1f80, 0x1f88, 0x1f81, 0x1f89, 0x1f82, 0x1f8a, 0x1f83, + 0x1f8b, 0x1f84, 0x1f8c, 0x1f85, 0x1f8d, 0x1f86, 0x1f8e, 0x1f87, 0x1f8f, 0x1f90, + 0x1f98, 0x1f91, 0x1f99, 0x1f92, 0x1f9a, 0x1f93, 0x1f9b, 0x1f94, 0x1f9c, 0x1f95, + 0x1f9d, 0x1f96, 0x1f9e, 0x1f97, 0x1f9f, 0x1fa0, 0x1fa8, 0x1fa1, 0x1fa9, 0x1fa2, + 0x1faa, 0x1fa3, 0x1fab, 0x1fa4, 0x1fac, 0x1fa5, 0x1fad, 0x1fa6, 0x1fae, 0x1fa7, 0x1faf, 0x1fb2, 0x1fc2, 0x1ff2, 0}; // End of machine generated data. @@ -3381,7 +3394,7 @@ int32_t RegexCompile::minMatchLength(int32_t start, int32_t end) { // it assumes that the look-ahead match might be zero-length. // TODO: Positive lookahead could recursively do the block, then continue // with the longer of the block or the value coming in. Ticket 6060 - int32_t depth = (opType == URX_LA_START? 2: 1);; + int32_t depth = (opType == URX_LA_START? 2: 1); for (;;) { loc++; op = (int32_t)fRXPat->fCompiledPat->elementAti(loc); @@ -3463,7 +3476,6 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { U_ASSERT(start <= end); U_ASSERT(end < fRXPat->fCompiledPat->size()); - int32_t loc; int32_t op; int32_t opType; @@ -3660,7 +3672,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { U_ASSERT(loopEndLoc >= loc+4); int64_t blockLen = maxMatchLength(loc+4, loopEndLoc-1); // Recursive call. - int64_t updatedLen = (int64_t)currentLen + blockLen * maxLoopCount; + int64_t updatedLen = (int64_t)currentLen + blockLen * maxLoopCount; if (updatedLen >= INT32_MAX) { currentLen = INT32_MAX; break; @@ -3672,7 +3684,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { case URX_CTR_LOOP: case URX_CTR_LOOP_NG: - // These opcodes will be skipped over by code for URX_CRT_INIT. + // These opcodes will be skipped over by code for URX_CTR_INIT. // We shouldn't encounter them here. UPRV_UNREACHABLE; @@ -3700,21 +3712,15 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { { // Look-behind. Scan forward until the matching look-around end, // without processing the look-behind block. - int32_t depth = 0; - for (;;) { - loc++; + int32_t dataLoc = URX_VAL(op); + for (loc = loc + 1; loc < end; ++loc) { op = (int32_t)fRXPat->fCompiledPat->elementAti(loc); - if (URX_TYPE(op) == URX_LA_START || URX_TYPE(op) == URX_LB_START) { - depth++; - } - if (URX_TYPE(op) == URX_LA_END || URX_TYPE(op)==URX_LBN_END) { - if (depth == 0) { - break; - } - depth--; + int32_t opType = URX_TYPE(op); + if ((opType == URX_LA_END || opType == URX_LBN_END) && (URX_VAL(op) == dataLoc)) { + break; } - U_ASSERT(loc < end); } + U_ASSERT(loc < end); } break; @@ -4637,3 +4643,4 @@ void RegexCompile::setPushOp(int32_t op) { U_NAMESPACE_END #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS + diff --git a/deps/icu-small/source/i18n/regexcmp.h b/deps/icu-small/source/i18n/regexcmp.h index 85b7586793b9ff..f2aeea909e7442 100644 --- a/deps/icu-small/source/i18n/regexcmp.h +++ b/deps/icu-small/source/i18n/regexcmp.h @@ -59,7 +59,7 @@ class U_I18N_API RegexCompile : public UMemory { void compile(const UnicodeString &pat, UParseError &pp, UErrorCode &e); void compile(UText *pat, UParseError &pp, UErrorCode &e); - + virtual ~RegexCompile(); @@ -182,7 +182,7 @@ class U_I18N_API RegexCompile : public UMemory { // string will be cleared. int64_t fPatternLength; // Length of the input pattern string. - + UVector32 fParenStack; // parentheses stack. Each frame consists of // the positions of compiled pattern operations // needing fixup, followed by negative value. The diff --git a/deps/icu-small/source/i18n/regexcst.h b/deps/icu-small/source/i18n/regexcst.h index a07d85a277c3dd..8b12096ac7c5cc 100644 --- a/deps/icu-small/source/i18n/regexcst.h +++ b/deps/icu-small/source/i18n/regexcst.h @@ -7,8 +7,8 @@ // It is generated by the Perl script "regexcst.pl" from // the rule parser state definitions file "regexcst.txt". // -// Copyright (C) 2002-2016 International Business Machines Corporation -// and others. All rights reserved. +// Copyright (C) 2002-2016 International Business Machines Corporation +// and others. All rights reserved. // //--------------------------------------------------------------------------------- #ifndef RBBIRPT_H @@ -152,208 +152,208 @@ static const struct RegexTableEl gRuleParseStateTable[] = { {doNOP, 0, 0, 0, TRUE} , {doPatStart, 255, 2,0, FALSE} // 1 start , {doLiteralChar, 254, 14,0, TRUE} // 2 term - , {doLiteralChar, 130, 14,0, TRUE} // 3 - , {doSetBegin, 91 /* [ */, 123, 205, TRUE} // 4 - , {doNOP, 40 /* ( */, 27,0, TRUE} // 5 - , {doDotAny, 46 /* . */, 14,0, TRUE} // 6 - , {doCaret, 94 /* ^ */, 14,0, TRUE} // 7 - , {doDollar, 36 /* $ */, 14,0, TRUE} // 8 - , {doNOP, 92 /* \ */, 89,0, TRUE} // 9 - , {doOrOperator, 124 /* | */, 2,0, TRUE} // 10 - , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 11 - , {doPatFinish, 253, 2,0, FALSE} // 12 - , {doRuleError, 255, 206,0, FALSE} // 13 + , {doLiteralChar, 130, 14,0, TRUE} // 3 + , {doSetBegin, 91 /* [ */, 123, 205, TRUE} // 4 + , {doNOP, 40 /* ( */, 27,0, TRUE} // 5 + , {doDotAny, 46 /* . */, 14,0, TRUE} // 6 + , {doCaret, 94 /* ^ */, 14,0, TRUE} // 7 + , {doDollar, 36 /* $ */, 14,0, TRUE} // 8 + , {doNOP, 92 /* \ */, 89,0, TRUE} // 9 + , {doOrOperator, 124 /* | */, 2,0, TRUE} // 10 + , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 11 + , {doPatFinish, 253, 2,0, FALSE} // 12 + , {doRuleError, 255, 206,0, FALSE} // 13 , {doNOP, 42 /* * */, 68,0, TRUE} // 14 expr-quant - , {doNOP, 43 /* + */, 71,0, TRUE} // 15 - , {doNOP, 63 /* ? */, 74,0, TRUE} // 16 - , {doIntervalInit, 123 /* { */, 77,0, TRUE} // 17 - , {doNOP, 40 /* ( */, 23,0, TRUE} // 18 - , {doNOP, 255, 20,0, FALSE} // 19 + , {doNOP, 43 /* + */, 71,0, TRUE} // 15 + , {doNOP, 63 /* ? */, 74,0, TRUE} // 16 + , {doIntervalInit, 123 /* { */, 77,0, TRUE} // 17 + , {doNOP, 40 /* ( */, 23,0, TRUE} // 18 + , {doNOP, 255, 20,0, FALSE} // 19 , {doOrOperator, 124 /* | */, 2,0, TRUE} // 20 expr-cont - , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 21 - , {doNOP, 255, 2,0, FALSE} // 22 + , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 21 + , {doNOP, 255, 2,0, FALSE} // 22 , {doSuppressComments, 63 /* ? */, 25,0, TRUE} // 23 open-paren-quant - , {doNOP, 255, 27,0, FALSE} // 24 + , {doNOP, 255, 27,0, FALSE} // 24 , {doNOP, 35 /* # */, 50, 14, TRUE} // 25 open-paren-quant2 - , {doNOP, 255, 29,0, FALSE} // 26 + , {doNOP, 255, 29,0, FALSE} // 26 , {doSuppressComments, 63 /* ? */, 29,0, TRUE} // 27 open-paren - , {doOpenCaptureParen, 255, 2, 14, FALSE} // 28 + , {doOpenCaptureParen, 255, 2, 14, FALSE} // 28 , {doOpenNonCaptureParen, 58 /* : */, 2, 14, TRUE} // 29 open-paren-extended - , {doOpenAtomicParen, 62 /* > */, 2, 14, TRUE} // 30 - , {doOpenLookAhead, 61 /* = */, 2, 20, TRUE} // 31 - , {doOpenLookAheadNeg, 33 /* ! */, 2, 20, TRUE} // 32 - , {doNOP, 60 /* < */, 46,0, TRUE} // 33 - , {doNOP, 35 /* # */, 50, 2, TRUE} // 34 - , {doBeginMatchMode, 105 /* i */, 53,0, FALSE} // 35 - , {doBeginMatchMode, 100 /* d */, 53,0, FALSE} // 36 - , {doBeginMatchMode, 109 /* m */, 53,0, FALSE} // 37 - , {doBeginMatchMode, 115 /* s */, 53,0, FALSE} // 38 - , {doBeginMatchMode, 117 /* u */, 53,0, FALSE} // 39 - , {doBeginMatchMode, 119 /* w */, 53,0, FALSE} // 40 - , {doBeginMatchMode, 120 /* x */, 53,0, FALSE} // 41 - , {doBeginMatchMode, 45 /* - */, 53,0, FALSE} // 42 - , {doConditionalExpr, 40 /* ( */, 206,0, TRUE} // 43 - , {doPerlInline, 123 /* { */, 206,0, TRUE} // 44 - , {doBadOpenParenType, 255, 206,0, FALSE} // 45 + , {doOpenAtomicParen, 62 /* > */, 2, 14, TRUE} // 30 + , {doOpenLookAhead, 61 /* = */, 2, 20, TRUE} // 31 + , {doOpenLookAheadNeg, 33 /* ! */, 2, 20, TRUE} // 32 + , {doNOP, 60 /* < */, 46,0, TRUE} // 33 + , {doNOP, 35 /* # */, 50, 2, TRUE} // 34 + , {doBeginMatchMode, 105 /* i */, 53,0, FALSE} // 35 + , {doBeginMatchMode, 100 /* d */, 53,0, FALSE} // 36 + , {doBeginMatchMode, 109 /* m */, 53,0, FALSE} // 37 + , {doBeginMatchMode, 115 /* s */, 53,0, FALSE} // 38 + , {doBeginMatchMode, 117 /* u */, 53,0, FALSE} // 39 + , {doBeginMatchMode, 119 /* w */, 53,0, FALSE} // 40 + , {doBeginMatchMode, 120 /* x */, 53,0, FALSE} // 41 + , {doBeginMatchMode, 45 /* - */, 53,0, FALSE} // 42 + , {doConditionalExpr, 40 /* ( */, 206,0, TRUE} // 43 + , {doPerlInline, 123 /* { */, 206,0, TRUE} // 44 + , {doBadOpenParenType, 255, 206,0, FALSE} // 45 , {doOpenLookBehind, 61 /* = */, 2, 20, TRUE} // 46 open-paren-lookbehind - , {doOpenLookBehindNeg, 33 /* ! */, 2, 20, TRUE} // 47 - , {doBeginNamedCapture, 128, 64,0, FALSE} // 48 - , {doBadOpenParenType, 255, 206,0, FALSE} // 49 + , {doOpenLookBehindNeg, 33 /* ! */, 2, 20, TRUE} // 47 + , {doBeginNamedCapture, 128, 64,0, FALSE} // 48 + , {doBadOpenParenType, 255, 206,0, FALSE} // 49 , {doNOP, 41 /* ) */, 255,0, TRUE} // 50 paren-comment - , {doMismatchedParenErr, 253, 206,0, FALSE} // 51 - , {doNOP, 255, 50,0, TRUE} // 52 + , {doMismatchedParenErr, 253, 206,0, FALSE} // 51 + , {doNOP, 255, 50,0, TRUE} // 52 , {doMatchMode, 105 /* i */, 53,0, TRUE} // 53 paren-flag - , {doMatchMode, 100 /* d */, 53,0, TRUE} // 54 - , {doMatchMode, 109 /* m */, 53,0, TRUE} // 55 - , {doMatchMode, 115 /* s */, 53,0, TRUE} // 56 - , {doMatchMode, 117 /* u */, 53,0, TRUE} // 57 - , {doMatchMode, 119 /* w */, 53,0, TRUE} // 58 - , {doMatchMode, 120 /* x */, 53,0, TRUE} // 59 - , {doMatchMode, 45 /* - */, 53,0, TRUE} // 60 - , {doSetMatchMode, 41 /* ) */, 2,0, TRUE} // 61 - , {doMatchModeParen, 58 /* : */, 2, 14, TRUE} // 62 - , {doBadModeFlag, 255, 206,0, FALSE} // 63 + , {doMatchMode, 100 /* d */, 53,0, TRUE} // 54 + , {doMatchMode, 109 /* m */, 53,0, TRUE} // 55 + , {doMatchMode, 115 /* s */, 53,0, TRUE} // 56 + , {doMatchMode, 117 /* u */, 53,0, TRUE} // 57 + , {doMatchMode, 119 /* w */, 53,0, TRUE} // 58 + , {doMatchMode, 120 /* x */, 53,0, TRUE} // 59 + , {doMatchMode, 45 /* - */, 53,0, TRUE} // 60 + , {doSetMatchMode, 41 /* ) */, 2,0, TRUE} // 61 + , {doMatchModeParen, 58 /* : */, 2, 14, TRUE} // 62 + , {doBadModeFlag, 255, 206,0, FALSE} // 63 , {doContinueNamedCapture, 128, 64,0, TRUE} // 64 named-capture - , {doContinueNamedCapture, 129, 64,0, TRUE} // 65 - , {doOpenCaptureParen, 62 /* > */, 2, 14, TRUE} // 66 - , {doBadNamedCapture, 255, 206,0, FALSE} // 67 + , {doContinueNamedCapture, 129, 64,0, TRUE} // 65 + , {doOpenCaptureParen, 62 /* > */, 2, 14, TRUE} // 66 + , {doBadNamedCapture, 255, 206,0, FALSE} // 67 , {doNGStar, 63 /* ? */, 20,0, TRUE} // 68 quant-star - , {doPossessiveStar, 43 /* + */, 20,0, TRUE} // 69 - , {doStar, 255, 20,0, FALSE} // 70 + , {doPossessiveStar, 43 /* + */, 20,0, TRUE} // 69 + , {doStar, 255, 20,0, FALSE} // 70 , {doNGPlus, 63 /* ? */, 20,0, TRUE} // 71 quant-plus - , {doPossessivePlus, 43 /* + */, 20,0, TRUE} // 72 - , {doPlus, 255, 20,0, FALSE} // 73 + , {doPossessivePlus, 43 /* + */, 20,0, TRUE} // 72 + , {doPlus, 255, 20,0, FALSE} // 73 , {doNGOpt, 63 /* ? */, 20,0, TRUE} // 74 quant-opt - , {doPossessiveOpt, 43 /* + */, 20,0, TRUE} // 75 - , {doOpt, 255, 20,0, FALSE} // 76 + , {doPossessiveOpt, 43 /* + */, 20,0, TRUE} // 75 + , {doOpt, 255, 20,0, FALSE} // 76 , {doNOP, 129, 79,0, FALSE} // 77 interval-open - , {doIntervalError, 255, 206,0, FALSE} // 78 + , {doIntervalError, 255, 206,0, FALSE} // 78 , {doIntevalLowerDigit, 129, 79,0, TRUE} // 79 interval-lower - , {doNOP, 44 /* , */, 83,0, TRUE} // 80 - , {doIntervalSame, 125 /* } */, 86,0, TRUE} // 81 - , {doIntervalError, 255, 206,0, FALSE} // 82 + , {doNOP, 44 /* , */, 83,0, TRUE} // 80 + , {doIntervalSame, 125 /* } */, 86,0, TRUE} // 81 + , {doIntervalError, 255, 206,0, FALSE} // 82 , {doIntervalUpperDigit, 129, 83,0, TRUE} // 83 interval-upper - , {doNOP, 125 /* } */, 86,0, TRUE} // 84 - , {doIntervalError, 255, 206,0, FALSE} // 85 + , {doNOP, 125 /* } */, 86,0, TRUE} // 84 + , {doIntervalError, 255, 206,0, FALSE} // 85 , {doNGInterval, 63 /* ? */, 20,0, TRUE} // 86 interval-type - , {doPossessiveInterval, 43 /* + */, 20,0, TRUE} // 87 - , {doInterval, 255, 20,0, FALSE} // 88 + , {doPossessiveInterval, 43 /* + */, 20,0, TRUE} // 87 + , {doInterval, 255, 20,0, FALSE} // 88 , {doBackslashA, 65 /* A */, 2,0, TRUE} // 89 backslash - , {doBackslashB, 66 /* B */, 2,0, TRUE} // 90 - , {doBackslashb, 98 /* b */, 2,0, TRUE} // 91 - , {doBackslashd, 100 /* d */, 14,0, TRUE} // 92 - , {doBackslashD, 68 /* D */, 14,0, TRUE} // 93 - , {doBackslashG, 71 /* G */, 2,0, TRUE} // 94 - , {doBackslashh, 104 /* h */, 14,0, TRUE} // 95 - , {doBackslashH, 72 /* H */, 14,0, TRUE} // 96 - , {doNOP, 107 /* k */, 115,0, TRUE} // 97 - , {doNamedChar, 78 /* N */, 14,0, FALSE} // 98 - , {doProperty, 112 /* p */, 14,0, FALSE} // 99 - , {doProperty, 80 /* P */, 14,0, FALSE} // 100 - , {doBackslashR, 82 /* R */, 14,0, TRUE} // 101 - , {doEnterQuoteMode, 81 /* Q */, 2,0, TRUE} // 102 - , {doBackslashS, 83 /* S */, 14,0, TRUE} // 103 - , {doBackslashs, 115 /* s */, 14,0, TRUE} // 104 - , {doBackslashv, 118 /* v */, 14,0, TRUE} // 105 - , {doBackslashV, 86 /* V */, 14,0, TRUE} // 106 - , {doBackslashW, 87 /* W */, 14,0, TRUE} // 107 - , {doBackslashw, 119 /* w */, 14,0, TRUE} // 108 - , {doBackslashX, 88 /* X */, 14,0, TRUE} // 109 - , {doBackslashZ, 90 /* Z */, 2,0, TRUE} // 110 - , {doBackslashz, 122 /* z */, 2,0, TRUE} // 111 - , {doBackRef, 129, 14,0, TRUE} // 112 - , {doEscapeError, 253, 206,0, FALSE} // 113 - , {doEscapedLiteralChar, 255, 14,0, TRUE} // 114 + , {doBackslashB, 66 /* B */, 2,0, TRUE} // 90 + , {doBackslashb, 98 /* b */, 2,0, TRUE} // 91 + , {doBackslashd, 100 /* d */, 14,0, TRUE} // 92 + , {doBackslashD, 68 /* D */, 14,0, TRUE} // 93 + , {doBackslashG, 71 /* G */, 2,0, TRUE} // 94 + , {doBackslashh, 104 /* h */, 14,0, TRUE} // 95 + , {doBackslashH, 72 /* H */, 14,0, TRUE} // 96 + , {doNOP, 107 /* k */, 115,0, TRUE} // 97 + , {doNamedChar, 78 /* N */, 14,0, FALSE} // 98 + , {doProperty, 112 /* p */, 14,0, FALSE} // 99 + , {doProperty, 80 /* P */, 14,0, FALSE} // 100 + , {doBackslashR, 82 /* R */, 14,0, TRUE} // 101 + , {doEnterQuoteMode, 81 /* Q */, 2,0, TRUE} // 102 + , {doBackslashS, 83 /* S */, 14,0, TRUE} // 103 + , {doBackslashs, 115 /* s */, 14,0, TRUE} // 104 + , {doBackslashv, 118 /* v */, 14,0, TRUE} // 105 + , {doBackslashV, 86 /* V */, 14,0, TRUE} // 106 + , {doBackslashW, 87 /* W */, 14,0, TRUE} // 107 + , {doBackslashw, 119 /* w */, 14,0, TRUE} // 108 + , {doBackslashX, 88 /* X */, 14,0, TRUE} // 109 + , {doBackslashZ, 90 /* Z */, 2,0, TRUE} // 110 + , {doBackslashz, 122 /* z */, 2,0, TRUE} // 111 + , {doBackRef, 129, 14,0, TRUE} // 112 + , {doEscapeError, 253, 206,0, FALSE} // 113 + , {doEscapedLiteralChar, 255, 14,0, TRUE} // 114 , {doBeginNamedBackRef, 60 /* < */, 117,0, TRUE} // 115 named-backref - , {doBadNamedCapture, 255, 206,0, FALSE} // 116 + , {doBadNamedCapture, 255, 206,0, FALSE} // 116 , {doContinueNamedBackRef, 128, 119,0, TRUE} // 117 named-backref-2 - , {doBadNamedCapture, 255, 206,0, FALSE} // 118 + , {doBadNamedCapture, 255, 206,0, FALSE} // 118 , {doContinueNamedBackRef, 128, 119,0, TRUE} // 119 named-backref-3 - , {doContinueNamedBackRef, 129, 119,0, TRUE} // 120 - , {doCompleteNamedBackRef, 62 /* > */, 14,0, TRUE} // 121 - , {doBadNamedCapture, 255, 206,0, FALSE} // 122 + , {doContinueNamedBackRef, 129, 119,0, TRUE} // 120 + , {doCompleteNamedBackRef, 62 /* > */, 14,0, TRUE} // 121 + , {doBadNamedCapture, 255, 206,0, FALSE} // 122 , {doSetNegate, 94 /* ^ */, 126,0, TRUE} // 123 set-open - , {doSetPosixProp, 58 /* : */, 128,0, FALSE} // 124 - , {doNOP, 255, 126,0, FALSE} // 125 + , {doSetPosixProp, 58 /* : */, 128,0, FALSE} // 124 + , {doNOP, 255, 126,0, FALSE} // 125 , {doSetLiteral, 93 /* ] */, 141,0, TRUE} // 126 set-open2 - , {doNOP, 255, 131,0, FALSE} // 127 + , {doNOP, 255, 131,0, FALSE} // 127 , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 128 set-posix - , {doNOP, 58 /* : */, 131,0, FALSE} // 129 - , {doRuleError, 255, 206,0, FALSE} // 130 + , {doNOP, 58 /* : */, 131,0, FALSE} // 129 + , {doRuleError, 255, 206,0, FALSE} // 130 , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 131 set-start - , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 132 - , {doNOP, 92 /* \ */, 191,0, TRUE} // 133 - , {doNOP, 45 /* - */, 137,0, TRUE} // 134 - , {doNOP, 38 /* & */, 139,0, TRUE} // 135 - , {doSetLiteral, 255, 141,0, TRUE} // 136 + , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 132 + , {doNOP, 92 /* \ */, 191,0, TRUE} // 133 + , {doNOP, 45 /* - */, 137,0, TRUE} // 134 + , {doNOP, 38 /* & */, 139,0, TRUE} // 135 + , {doSetLiteral, 255, 141,0, TRUE} // 136 , {doRuleError, 45 /* - */, 206,0, FALSE} // 137 set-start-dash - , {doSetAddDash, 255, 141,0, FALSE} // 138 + , {doSetAddDash, 255, 141,0, FALSE} // 138 , {doRuleError, 38 /* & */, 206,0, FALSE} // 139 set-start-amp - , {doSetAddAmp, 255, 141,0, FALSE} // 140 + , {doSetAddAmp, 255, 141,0, FALSE} // 140 , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 141 set-after-lit - , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 142 - , {doNOP, 45 /* - */, 178,0, TRUE} // 143 - , {doNOP, 38 /* & */, 169,0, TRUE} // 144 - , {doNOP, 92 /* \ */, 191,0, TRUE} // 145 - , {doSetNoCloseError, 253, 206,0, FALSE} // 146 - , {doSetLiteral, 255, 141,0, TRUE} // 147 + , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 142 + , {doNOP, 45 /* - */, 178,0, TRUE} // 143 + , {doNOP, 38 /* & */, 169,0, TRUE} // 144 + , {doNOP, 92 /* \ */, 191,0, TRUE} // 145 + , {doSetNoCloseError, 253, 206,0, FALSE} // 146 + , {doSetLiteral, 255, 141,0, TRUE} // 147 , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 148 set-after-set - , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 149 - , {doNOP, 45 /* - */, 171,0, TRUE} // 150 - , {doNOP, 38 /* & */, 166,0, TRUE} // 151 - , {doNOP, 92 /* \ */, 191,0, TRUE} // 152 - , {doSetNoCloseError, 253, 206,0, FALSE} // 153 - , {doSetLiteral, 255, 141,0, TRUE} // 154 + , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 149 + , {doNOP, 45 /* - */, 171,0, TRUE} // 150 + , {doNOP, 38 /* & */, 166,0, TRUE} // 151 + , {doNOP, 92 /* \ */, 191,0, TRUE} // 152 + , {doSetNoCloseError, 253, 206,0, FALSE} // 153 + , {doSetLiteral, 255, 141,0, TRUE} // 154 , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 155 set-after-range - , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 156 - , {doNOP, 45 /* - */, 174,0, TRUE} // 157 - , {doNOP, 38 /* & */, 176,0, TRUE} // 158 - , {doNOP, 92 /* \ */, 191,0, TRUE} // 159 - , {doSetNoCloseError, 253, 206,0, FALSE} // 160 - , {doSetLiteral, 255, 141,0, TRUE} // 161 + , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 156 + , {doNOP, 45 /* - */, 174,0, TRUE} // 157 + , {doNOP, 38 /* & */, 176,0, TRUE} // 158 + , {doNOP, 92 /* \ */, 191,0, TRUE} // 159 + , {doSetNoCloseError, 253, 206,0, FALSE} // 160 + , {doSetLiteral, 255, 141,0, TRUE} // 161 , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 162 set-after-op - , {doSetOpError, 93 /* ] */, 206,0, FALSE} // 163 - , {doNOP, 92 /* \ */, 191,0, TRUE} // 164 - , {doSetLiteral, 255, 141,0, TRUE} // 165 + , {doSetOpError, 93 /* ] */, 206,0, FALSE} // 163 + , {doNOP, 92 /* \ */, 191,0, TRUE} // 164 + , {doSetLiteral, 255, 141,0, TRUE} // 165 , {doSetBeginIntersection1, 91 /* [ */, 123, 148, TRUE} // 166 set-set-amp - , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 167 - , {doSetAddAmp, 255, 141,0, FALSE} // 168 + , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 167 + , {doSetAddAmp, 255, 141,0, FALSE} // 168 , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 169 set-lit-amp - , {doSetAddAmp, 255, 141,0, FALSE} // 170 + , {doSetAddAmp, 255, 141,0, FALSE} // 170 , {doSetBeginDifference1, 91 /* [ */, 123, 148, TRUE} // 171 set-set-dash - , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 172 - , {doSetAddDash, 255, 141,0, FALSE} // 173 + , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 172 + , {doSetAddDash, 255, 141,0, FALSE} // 173 , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 174 set-range-dash - , {doSetAddDash, 255, 141,0, FALSE} // 175 + , {doSetAddDash, 255, 141,0, FALSE} // 175 , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 176 set-range-amp - , {doSetAddAmp, 255, 141,0, FALSE} // 177 + , {doSetAddAmp, 255, 141,0, FALSE} // 177 , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 178 set-lit-dash - , {doSetAddDash, 91 /* [ */, 141,0, FALSE} // 179 - , {doSetAddDash, 93 /* ] */, 141,0, FALSE} // 180 - , {doNOP, 92 /* \ */, 183,0, TRUE} // 181 - , {doSetRange, 255, 155,0, TRUE} // 182 + , {doSetAddDash, 91 /* [ */, 141,0, FALSE} // 179 + , {doSetAddDash, 93 /* ] */, 141,0, FALSE} // 180 + , {doNOP, 92 /* \ */, 183,0, TRUE} // 181 + , {doSetRange, 255, 155,0, TRUE} // 182 , {doSetOpError, 115 /* s */, 206,0, FALSE} // 183 set-lit-dash-escape - , {doSetOpError, 83 /* S */, 206,0, FALSE} // 184 - , {doSetOpError, 119 /* w */, 206,0, FALSE} // 185 - , {doSetOpError, 87 /* W */, 206,0, FALSE} // 186 - , {doSetOpError, 100 /* d */, 206,0, FALSE} // 187 - , {doSetOpError, 68 /* D */, 206,0, FALSE} // 188 - , {doSetNamedRange, 78 /* N */, 155,0, FALSE} // 189 - , {doSetRange, 255, 155,0, TRUE} // 190 + , {doSetOpError, 83 /* S */, 206,0, FALSE} // 184 + , {doSetOpError, 119 /* w */, 206,0, FALSE} // 185 + , {doSetOpError, 87 /* W */, 206,0, FALSE} // 186 + , {doSetOpError, 100 /* d */, 206,0, FALSE} // 187 + , {doSetOpError, 68 /* D */, 206,0, FALSE} // 188 + , {doSetNamedRange, 78 /* N */, 155,0, FALSE} // 189 + , {doSetRange, 255, 155,0, TRUE} // 190 , {doSetProp, 112 /* p */, 148,0, FALSE} // 191 set-escape - , {doSetProp, 80 /* P */, 148,0, FALSE} // 192 - , {doSetNamedChar, 78 /* N */, 141,0, FALSE} // 193 - , {doSetBackslash_s, 115 /* s */, 155,0, TRUE} // 194 - , {doSetBackslash_S, 83 /* S */, 155,0, TRUE} // 195 - , {doSetBackslash_w, 119 /* w */, 155,0, TRUE} // 196 - , {doSetBackslash_W, 87 /* W */, 155,0, TRUE} // 197 - , {doSetBackslash_d, 100 /* d */, 155,0, TRUE} // 198 - , {doSetBackslash_D, 68 /* D */, 155,0, TRUE} // 199 - , {doSetBackslash_h, 104 /* h */, 155,0, TRUE} // 200 - , {doSetBackslash_H, 72 /* H */, 155,0, TRUE} // 201 - , {doSetBackslash_v, 118 /* v */, 155,0, TRUE} // 202 - , {doSetBackslash_V, 86 /* V */, 155,0, TRUE} // 203 - , {doSetLiteralEscaped, 255, 141,0, TRUE} // 204 + , {doSetProp, 80 /* P */, 148,0, FALSE} // 192 + , {doSetNamedChar, 78 /* N */, 141,0, FALSE} // 193 + , {doSetBackslash_s, 115 /* s */, 155,0, TRUE} // 194 + , {doSetBackslash_S, 83 /* S */, 155,0, TRUE} // 195 + , {doSetBackslash_w, 119 /* w */, 155,0, TRUE} // 196 + , {doSetBackslash_W, 87 /* W */, 155,0, TRUE} // 197 + , {doSetBackslash_d, 100 /* d */, 155,0, TRUE} // 198 + , {doSetBackslash_D, 68 /* D */, 155,0, TRUE} // 199 + , {doSetBackslash_h, 104 /* h */, 155,0, TRUE} // 200 + , {doSetBackslash_H, 72 /* H */, 155,0, TRUE} // 201 + , {doSetBackslash_v, 118 /* v */, 155,0, TRUE} // 202 + , {doSetBackslash_V, 86 /* V */, 155,0, TRUE} // 203 + , {doSetLiteralEscaped, 255, 141,0, TRUE} // 204 , {doSetFinish, 255, 14,0, FALSE} // 205 set-finish , {doExit, 255, 206,0, TRUE} // 206 errorDeath }; diff --git a/deps/icu-small/source/i18n/regexcst.pl b/deps/icu-small/source/i18n/regexcst.pl index 6c06b4eb5fc56a..384281ffbad9fe 100755 --- a/deps/icu-small/source/i18n/regexcst.pl +++ b/deps/icu-small/source/i18n/regexcst.pl @@ -327,3 +327,6 @@ print "U_NAMESPACE_END\n"; print "#endif\n"; + + + diff --git a/deps/icu-small/source/i18n/regeximp.cpp b/deps/icu-small/source/i18n/regeximp.cpp index 454e7f836b3111..d55566962587e4 100644 --- a/deps/icu-small/source/i18n/regeximp.cpp +++ b/deps/icu-small/source/i18n/regeximp.cpp @@ -55,7 +55,7 @@ UChar32 CaseFoldingUTextIterator::next() { } return foldedC; } - + UBool CaseFoldingUTextIterator::inExpansion() { return fFoldChars != NULL; @@ -103,7 +103,7 @@ UChar32 CaseFoldingUCharIterator::next() { } return foldedC; } - + UBool CaseFoldingUCharIterator::inExpansion() { return fFoldChars != NULL; @@ -117,3 +117,4 @@ int64_t CaseFoldingUCharIterator::getIndex() { U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/regeximp.h b/deps/icu-small/source/i18n/regeximp.h index da4a861bde52dd..590d2168952d90 100644 --- a/deps/icu-small/source/i18n/regeximp.h +++ b/deps/icu-small/source/i18n/regeximp.h @@ -26,7 +26,7 @@ U_NAMESPACE_BEGIN // For debugging, define REGEX_DEBUG // To define with configure, -// CPPFLAGS="-DREGEX_DEBUG" ./runConfigureICU --enable-debug --disable-release Linux +// CPPFLAGS="-DREGEX_DEBUG" ./runConfigureICU --enable-debug --disable-release Linux #ifdef REGEX_DEBUG // @@ -123,7 +123,7 @@ enum { // saved input position, FAIL rather than taking // the JMP URX_LA_START = 37, // Starting a LookAround expression. - // Save InputPos and SP in static data. + // Save InputPos, SP and active region in static data. // Operand: Static data offset for the save URX_LA_END = 38, // Ending a Lookaround expression. // Restore InputPos and Stack to saved values. @@ -243,7 +243,7 @@ enum { "DOLLAR_MD", \ "URX_BACKSLASH_H", \ "URX_BACKSLASH_R", \ - "URX_BACKSLASH_V" + "URX_BACKSLASH_V" // @@ -411,3 +411,4 @@ class CaseFoldingUCharIterator: public UMemory { U_NAMESPACE_END #endif + diff --git a/deps/icu-small/source/i18n/regexst.cpp b/deps/icu-small/source/i18n/regexst.cpp index ad74ee508e7133..4f12e87bc66380 100644 --- a/deps/icu-small/source/i18n/regexst.cpp +++ b/deps/icu-small/source/i18n/regexst.cpp @@ -164,10 +164,10 @@ fEmptyText(NULL) fPropSets[URX_GC_T] = new UnicodeSet(UnicodeString(TRUE, gGC_TPattern, -1), *status); fPropSets[URX_GC_LV] = new UnicodeSet(UnicodeString(TRUE, gGC_LVPattern, -1), *status); fPropSets[URX_GC_LVT] = new UnicodeSet(UnicodeString(TRUE, gGC_LVTPattern, -1), *status); - + // Check for null pointers - if (fPropSets[URX_ISWORD_SET] == NULL || fPropSets[URX_ISSPACE_SET] == NULL || fPropSets[URX_GC_EXTEND] == NULL || - fPropSets[URX_GC_CONTROL] == NULL || fPropSets[URX_GC_L] == NULL || fPropSets[URX_GC_V] == NULL || + if (fPropSets[URX_ISWORD_SET] == NULL || fPropSets[URX_ISSPACE_SET] == NULL || fPropSets[URX_GC_EXTEND] == NULL || + fPropSets[URX_GC_CONTROL] == NULL || fPropSets[URX_GC_L] == NULL || fPropSets[URX_GC_V] == NULL || fPropSets[URX_GC_T] == NULL || fPropSets[URX_GC_LV] == NULL || fPropSets[URX_GC_LVT] == NULL) { goto ExitConstrDeleteAll; } @@ -191,7 +191,7 @@ fEmptyText(NULL) fPropSets[URX_GC_NORMAL] = new UnicodeSet(0, UnicodeSet::MAX_VALUE); // Null pointer check if (fPropSets[URX_GC_NORMAL] == NULL) { - goto ExitConstrDeleteAll; + goto ExitConstrDeleteAll; } fPropSets[URX_GC_NORMAL]->remove(0xac00, 0xd7a4); fPropSets[URX_GC_NORMAL]->removeAll(*fPropSets[URX_GC_CONTROL]); @@ -217,10 +217,10 @@ fEmptyText(NULL) for (i=0; i df(new DecimalFormat(status), status); LocalPointer continents(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status); LocalPointer groupings(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status); @@ -115,7 +114,6 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { } // now, initialize - df->setParseIntegerOnly(TRUE); uhash_setValueDeleter(newRegionIDMap.getAlias(), deleteRegion); // regionIDMap owns objs uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // regionAliases owns the string keys @@ -192,11 +190,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { r->idStr.extract(0,r->idStr.length(),r->id,sizeof(r->id),US_INV); r->fType = URGN_TERRITORY; // Only temporary - figure out the real type later once the aliases are known. - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(r->idStr,result,ps); - if ( U_SUCCESS(ps) ) { - r->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(r->idStr, pos); + if (pos > 0) { + r->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),r->code,(void *)(r.getAlias()),&status); r->fType = URGN_SUBCONTINENT; } else { @@ -221,7 +218,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { uhash_put(newRegionAliases.getAlias(),(void *)aliasFromStr.orphan(), (void *)aliasToRegion,&status); } else { if ( aliasFromRegion == NULL ) { // Deprecated region code not in the master codes list - so need to create a deprecated region for it. - LocalPointer newRgn(new Region, status); + LocalPointer newRgn(new Region, status); if ( U_SUCCESS(status) ) { aliasFromRegion = newRgn.orphan(); } else { @@ -230,11 +227,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { aliasFromRegion->idStr.setTo(*aliasFromStr); aliasFromRegion->idStr.extract(0,aliasFromRegion->idStr.length(),aliasFromRegion->id,sizeof(aliasFromRegion->id),US_INV); uhash_put(newRegionIDMap.getAlias(),(void *)&(aliasFromRegion->idStr),(void *)aliasFromRegion,&status); - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(aliasFromRegion->idStr,result,ps); - if ( U_SUCCESS(ps) ) { - aliasFromRegion->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(aliasFromRegion->idStr, pos); + if ( pos > 0 ) { + aliasFromRegion->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),aliasFromRegion->code,(void *)aliasFromRegion,&status); } else { aliasFromRegion->code = -1; @@ -279,11 +275,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { Region *r = (Region *)uhash_get(newRegionIDMap.getAlias(),(void *)&codeMappingID); if ( r ) { - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(codeMappingNumber,result,ps); - if ( U_SUCCESS(ps) ) { - r->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(codeMappingNumber, pos); + if ( pos > 0 ) { + r->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),r->code,(void *)r,&status); } LocalPointer code3(new UnicodeString(codeMapping3Letter), status); @@ -385,7 +380,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { } availableRegions[ar->fType]->addElement((void *)arString.orphan(),status); } - + ucln_i18n_registerCleanup(UCLN_I18N_REGION, region_cleanup); // copy hashtables numericCodeMap = newNumericCodeMap.orphan(); @@ -516,15 +511,8 @@ Region::getInstance (int32_t code, UErrorCode &status) { Region *r = (Region *)uhash_iget(numericCodeMap,code); if ( !r ) { // Just in case there's an alias that's numeric, try to find it. - UnicodeString pat = UNICODE_STRING_SIMPLE("0"); - LocalPointer df(new DecimalFormat(pat,status), status); - if( U_FAILURE(status) ) { - return NULL; - } UnicodeString id; - id.remove(); - FieldPosition posIter; - df->format(code,id, posIter, status); + ICU_Utility::appendNumber(id, code, 10, 1); r = (Region *)uhash_get(regionAliases,&id); } diff --git a/deps/icu-small/source/i18n/region_impl.h b/deps/icu-small/source/i18n/region_impl.h index c0702af7dfb3d1..5e5a64529adde3 100644 --- a/deps/icu-small/source/i18n/region_impl.h +++ b/deps/icu-small/source/i18n/region_impl.h @@ -17,7 +17,7 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING - + #include "uvector.h" #include "unicode/strenum.h" diff --git a/deps/icu-small/source/i18n/reldatefmt.cpp b/deps/icu-small/source/i18n/reldatefmt.cpp index cda2564b9a0539..f66092ba948e5d 100644 --- a/deps/icu-small/source/i18n/reldatefmt.cpp +++ b/deps/icu-small/source/i18n/reldatefmt.cpp @@ -43,7 +43,7 @@ #include "standardplural.h" #include "unifiedcache.h" #include "util.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_utypes.h" #include "number_modifiers.h" #include "formattedval_impl.h" @@ -315,6 +315,10 @@ struct RelDateTimeFmtDataSink : public ResourceSink { return UDAT_ABSOLUTE_FRIDAY; case SATURDAY: return UDAT_ABSOLUTE_SATURDAY; + case HOUR: + return UDAT_ABSOLUTE_HOUR; + case MINUTE: + return UDAT_ABSOLUTE_MINUTE; default: return -1; } @@ -725,14 +729,14 @@ const RelativeDateTimeCacheData *LocaleCacheKey::crea static constexpr number::impl::Field kRDTNumericField - = number::impl::NumFieldUtils::compress(); + = StringBuilderFieldUtils::compress(); static constexpr number::impl::Field kRDTLiteralField - = number::impl::NumFieldUtils::compress(); + = StringBuilderFieldUtils::compress(); -class FormattedRelativeDateTimeData : public FormattedValueNumberStringBuilderImpl { +class FormattedRelativeDateTimeData : public FormattedValueStringBuilderImpl { public: - FormattedRelativeDateTimeData() : FormattedValueNumberStringBuilderImpl(kRDTNumericField) {} + FormattedRelativeDateTimeData() : FormattedValueStringBuilderImpl(kRDTNumericField) {} virtual ~FormattedRelativeDateTimeData(); }; @@ -1135,7 +1139,7 @@ void RelativeDateTimeFormatter::formatRelativeImpl( case 100/* 1*/: direction = UDAT_DIRECTION_NEXT; break; case 200/* 2*/: direction = UDAT_DIRECTION_NEXT_2; break; default: break; - } + } } UDateAbsoluteUnit absunit = UDAT_ABSOLUTE_UNIT_COUNT; switch (unit) { @@ -1157,6 +1161,8 @@ void RelativeDateTimeFormatter::formatRelativeImpl( case UDAT_REL_UNIT_THURSDAY: absunit = UDAT_ABSOLUTE_THURSDAY; break; case UDAT_REL_UNIT_FRIDAY: absunit = UDAT_ABSOLUTE_FRIDAY; break; case UDAT_REL_UNIT_SATURDAY: absunit = UDAT_ABSOLUTE_SATURDAY; break; + case UDAT_REL_UNIT_HOUR: absunit = UDAT_ABSOLUTE_HOUR; break; + case UDAT_REL_UNIT_MINUTE: absunit = UDAT_ABSOLUTE_MINUTE; break; default: break; } if (direction != UDAT_DIRECTION_COUNT && absunit != UDAT_ABSOLUTE_UNIT_COUNT) { @@ -1184,7 +1190,7 @@ UnicodeString& RelativeDateTimeFormatter::adjustForContext(UnicodeString &str) c // Must guarantee that one thread at a time accesses the shared break // iterator. - static icu::UMutex gBrkIterMutex = U_MUTEX_INITIALIZER; + static UMutex gBrkIterMutex; Mutex lock(&gBrkIterMutex); str.toTitle( fOptBreakIterator->get(), diff --git a/deps/icu-small/source/i18n/reldtfmt.cpp b/deps/icu-small/source/i18n/reldtfmt.cpp index 753672d905f16b..c8ffd046460704 100644 --- a/deps/icu-small/source/i18n/reldtfmt.cpp +++ b/deps/icu-small/source/i18n/reldtfmt.cpp @@ -51,7 +51,7 @@ RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) : fCapitalizationBrkIter(NULL) { if(other.fDateTimeFormatter != NULL) { - fDateTimeFormatter = (SimpleDateFormat*)other.fDateTimeFormatter->clone(); + fDateTimeFormatter = other.fDateTimeFormatter->clone(); } if(other.fCombinedFormat != NULL) { fCombinedFormat = new SimpleFormatter(*other.fCombinedFormat); @@ -131,7 +131,7 @@ RelativeDateFormat::~RelativeDateFormat() { } -Format* RelativeDateFormat::clone(void) const { +RelativeDateFormat* RelativeDateFormat::clone() const { return new RelativeDateFormat(*this); } @@ -154,11 +154,11 @@ static const UChar APOSTROPHE = (UChar)0x0027; UnicodeString& RelativeDateFormat::format( Calendar& cal, UnicodeString& appendTo, FieldPosition& pos) const { - + UErrorCode status = U_ZERO_ERROR; UnicodeString relativeDayString; UDisplayContext capitalizationContext = getContext(UDISPCTX_TYPE_CAPITALIZATION, status); - + // calculate the difference, in days, between 'cal' and now. int dayDiff = dayDifference(cal, status); @@ -170,7 +170,7 @@ UnicodeString& RelativeDateFormat::format( Calendar& cal, relativeDayString.setTo(theString, len); } - if ( relativeDayString.length() > 0 && !fDatePattern.isEmpty() && + if ( relativeDayString.length() > 0 && !fDatePattern.isEmpty() && (fTimePattern.isEmpty() || fCombinedFormat == NULL || fCombinedHasDateAtStart)) { #if !UCONFIG_NO_BREAK_ITERATION // capitalize relativeDayString according to context for relative, set formatter no context @@ -221,8 +221,8 @@ UnicodeString& RelativeDateFormat::format( Calendar& cal, UnicodeString& -RelativeDateFormat::format(const Formattable& obj, - UnicodeString& appendTo, +RelativeDateFormat::format(const Formattable& obj, + UnicodeString& appendTo, FieldPosition& pos, UErrorCode& status) const { @@ -258,7 +258,7 @@ void RelativeDateFormat::parse( const UnicodeString& text, cal.setTime(Calendar::getNow(),status); cal.add(UCAL_DATE,fDates[n].offset, status); - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { // failure in setting calendar field, set offset to beginning of rel day string pos.setErrorIndex(startIndex); } else { @@ -289,7 +289,7 @@ void RelativeDateFormat::parse( const UnicodeString& text, // Set the calendar to now+offset tempCal->setTime(Calendar::getNow(),status); tempCal->add(UCAL_DATE,fDates[n].offset, status); - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { pos.setErrorIndex(startIndex); delete tempCal; return; @@ -582,7 +582,7 @@ int32_t RelativeDateFormat::dayDifference(Calendar &cal, UErrorCode &status) { nowCal->setTime(Calendar::getNow(), status); // For the day difference, we are interested in the difference in the (modified) julian day number - // which is midnight to midnight. Using fieldDifference() is NOT correct here, because + // which is midnight to midnight. Using fieldDifference() is NOT correct here, because // 6pm Jan 4th to 10am Jan 5th should be considered "tomorrow". int32_t dayDiff = cal.get(UCAL_JULIAN_DAY, status) - nowCal->get(UCAL_JULIAN_DAY, status); diff --git a/deps/icu-small/source/i18n/reldtfmt.h b/deps/icu-small/source/i18n/reldtfmt.h index 0403da11efda76..ff48d3b5c48f8d 100644 --- a/deps/icu-small/source/i18n/reldtfmt.h +++ b/deps/icu-small/source/i18n/reldtfmt.h @@ -71,7 +71,7 @@ class RelativeDateFormat : public DateFormat { * @return A copy of the object. * @internal ICU 3.8 */ - virtual Format* clone(void) const; + virtual RelativeDateFormat* clone() const; /** * Return true if the given Format objects are semantically equal. Objects @@ -242,7 +242,7 @@ class RelativeDateFormat : public DateFormat { * @param value The UDisplayContext value to set. * @param status Input/output status. If at entry this indicates a failure * status, the function will do nothing; otherwise this will be - * updated with any new status from the function. + * updated with any new status from the function. * @internal ICU 53 */ virtual void setContext(UDisplayContext value, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/rematch.cpp b/deps/icu-small/source/i18n/rematch.cpp index 3b8d2333d82098..6d6ea0fb5dd4e9 100644 --- a/deps/icu-small/source/i18n/rematch.cpp +++ b/deps/icu-small/source/i18n/rematch.cpp @@ -2069,7 +2069,7 @@ int32_t RegexMatcher::split(UText *input, // if (U_FAILURE(status)) { return 0; - }; + } if (destCapacity < 1) { status = U_ILLEGAL_ARGUMENT_ERROR; @@ -3805,11 +3805,13 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LA_START: { - // Entering a lookahead block. + // Entering a look around block. // Save Stack Ptr, Input Pos. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; + fData[opValue+2] = fActiveStart; + fData[opValue+3] = fActiveLimit; fActiveStart = fLookStart; // Set the match region change for fActiveLimit = fLookLimit; // transparent bounds. } @@ -3819,7 +3821,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { { // Leaving a look-ahead block. // restore Stack Ptr, Input Pos to positions they had on entry to block. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); int32_t stackSize = fStack->size(); int32_t newStackSize =(int32_t)fData[opValue]; U_ASSERT(stackSize >= newStackSize); @@ -3839,8 +3841,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // Restore the active region bounds in the input string; they may have // been changed because of transparent bounds on a Region. - fActiveStart = fRegionStart; - fActiveLimit = fRegionLimit; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -3916,17 +3920,19 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LB_START: { // Entering a look-behind block. - // Save Stack Ptr, Input Pos. + // Save Stack Ptr, Input Pos and active input region. // TODO: implement transparent bounds. Ticket #6067 - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; - // Init the variable containing the start index for attempted matches. - fData[opValue+2] = -1; // Save input string length, then reset to pin any matches to end at // the current position. + fData[opValue+2] = fActiveStart; fData[opValue+3] = fActiveLimit; + fActiveStart = fRegionStart; fActiveLimit = fp->fInputIdx; + // Init the variable containing the start index for attempted matches. + fData[opValue+4] = -1; } break; @@ -3949,8 +3955,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { U_ASSERT(minML >= 0); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -3976,10 +3982,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // getting a match. Backtrack out, and out of the // Look Behind altogether. fp = (REStackFrame *)fStack->popFrame(fFrameSize); - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); break; } @@ -3993,7 +3999,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LB_END: // End of a look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -4004,13 +4010,13 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { break; } - // Look-behind match is good. Restore the orignal input string length, + // Look-behind match is good. Restore the orignal input string region, // which had been truncated to pin the end of the lookbehind match to the // position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -4035,8 +4041,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { U_ASSERT(continueLoc > fp->fPatIdx); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -4061,10 +4067,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // We have tried all potential match starting points without // getting a match, which means that the negative lookbehind as // a whole has succeeded. Jump forward to the continue location - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); fp->fPatIdx = continueLoc; break; } @@ -4079,7 +4085,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LBN_END: // End of a negative look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -4096,10 +4102,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // Restore the orignal input string length, which had been truncated // inorder to pin the end of the lookbehind match // to the position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); // Restore original stack position, discarding any state saved // by the successful pattern match. @@ -5336,11 +5342,13 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LA_START: { - // Entering a lookahead block. + // Entering a look around block. // Save Stack Ptr, Input Pos. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; + fData[opValue+2] = fActiveStart; + fData[opValue+3] = fActiveLimit; fActiveStart = fLookStart; // Set the match region change for fActiveLimit = fLookLimit; // transparent bounds. } @@ -5348,9 +5356,9 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LA_END: { - // Leaving a look-ahead block. + // Leaving a look around block. // restore Stack Ptr, Input Pos to positions they had on entry to block. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); int32_t stackSize = fStack->size(); int32_t newStackSize = (int32_t)fData[opValue]; U_ASSERT(stackSize >= newStackSize); @@ -5370,8 +5378,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // Restore the active region bounds in the input string; they may have // been changed because of transparent bounds on a Region. - fActiveStart = fRegionStart; - fActiveLimit = fRegionLimit; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -5434,17 +5444,19 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LB_START: { // Entering a look-behind block. - // Save Stack Ptr, Input Pos. + // Save Stack Ptr, Input Pos and active input region. // TODO: implement transparent bounds. Ticket #6067 - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; - // Init the variable containing the start index for attempted matches. - fData[opValue+2] = -1; // Save input string length, then reset to pin any matches to end at // the current position. + fData[opValue+2] = fActiveStart; fData[opValue+3] = fActiveLimit; + fActiveStart = fRegionStart; fActiveLimit = fp->fInputIdx; + // Init the variable containing the start index for attempted matches. + fData[opValue+4] = -1; } break; @@ -5462,8 +5474,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu U_ASSERT(minML >= 0); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -5485,10 +5497,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // getting a match. Backtrack out, and out of the // Look Behind altogether. fp = (REStackFrame *)fStack->popFrame(fFrameSize); - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); break; } @@ -5502,7 +5514,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LB_END: // End of a look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -5513,13 +5525,13 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu break; } - // Look-behind match is good. Restore the orignal input string length, + // Look-behind match is good. Restore the orignal input string region, // which had been truncated to pin the end of the lookbehind match to the // position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -5539,8 +5551,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu U_ASSERT(continueLoc > fp->fPatIdx); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -5561,10 +5573,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // We have tried all potential match starting points without // getting a match, which means that the negative lookbehind as // a whole has succeeded. Jump forward to the continue location - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); fp->fPatIdx = continueLoc; break; } @@ -5579,7 +5591,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LBN_END: // End of a negative look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -5596,10 +5608,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // Restore the orignal input string length, which had been truncated // inorder to pin the end of the lookbehind match // to the position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); // Restore original stack position, discarding any state saved // by the successful pattern match. @@ -5816,3 +5828,4 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegexMatcher) U_NAMESPACE_END #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS + diff --git a/deps/icu-small/source/i18n/remtrans.cpp b/deps/icu-small/source/i18n/remtrans.cpp index 70a6ed3935b579..03b878575ca86c 100644 --- a/deps/icu-small/source/i18n/remtrans.cpp +++ b/deps/icu-small/source/i18n/remtrans.cpp @@ -48,10 +48,10 @@ RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE RemoveTransliterator::~RemoveTransliterator() {} -Transliterator* RemoveTransliterator::clone(void) const { - Transliterator* result = new RemoveTransliterator(); +RemoveTransliterator* RemoveTransliterator::clone() const { + RemoveTransliterator* result = new RemoveTransliterator(); if (result != NULL && getFilter() != 0) { - result->adoptFilter((UnicodeFilter*)(getFilter()->clone())); + result->adoptFilter(getFilter()->clone()); } return result; } diff --git a/deps/icu-small/source/i18n/remtrans.h b/deps/icu-small/source/i18n/remtrans.h index ed038d5f2fe0d5..13de01594a3fd9 100644 --- a/deps/icu-small/source/i18n/remtrans.h +++ b/deps/icu-small/source/i18n/remtrans.h @@ -47,7 +47,7 @@ class RemoveTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual RemoveTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/repattrn.cpp b/deps/icu-small/source/i18n/repattrn.cpp index b03873066c9016..1386d186c4d205 100644 --- a/deps/icu-small/source/i18n/repattrn.cpp +++ b/deps/icu-small/source/i18n/repattrn.cpp @@ -120,8 +120,8 @@ RegexPattern &RegexPattern::operator = (const RegexPattern &other) { int32_t numSets = other.fSets->size(); fSets8 = new Regex8BitSet[numSets]; if (fSets8 == NULL) { - fDeferredStatus = U_MEMORY_ALLOCATION_ERROR; - return *this; + fDeferredStatus = U_MEMORY_ALLOCATION_ERROR; + return *this; } for (i=1; ibreakIter = other.m_search_->breakIter; m_search_->isCanonicalMatch = other.m_search_->isCanonicalMatch; m_search_->isOverlap = other.m_search_->isOverlap; @@ -83,7 +83,7 @@ USearchAttributeValue SearchIterator::getAttribute( case USEARCH_OVERLAP : return (m_search_->isOverlap == TRUE ? USEARCH_ON : USEARCH_OFF); case USEARCH_CANONICAL_MATCH : - return (m_search_->isCanonicalMatch == TRUE ? USEARCH_ON : + return (m_search_->isCanonicalMatch == TRUE ? USEARCH_ON : USEARCH_OFF); case USEARCH_ELEMENT_COMPARISON : { @@ -98,7 +98,7 @@ USearchAttributeValue SearchIterator::getAttribute( return USEARCH_DEFAULT; } } - + int32_t SearchIterator::getMatchedStart() const { return m_search_->matchedIndex; @@ -108,20 +108,20 @@ int32_t SearchIterator::getMatchedLength() const { return m_search_->matchedLength; } - + void SearchIterator::getMatchedText(UnicodeString &result) const { int32_t matchedindex = m_search_->matchedIndex; int32_t matchedlength = m_search_->matchedLength; if (matchedindex != USEARCH_DONE && matchedlength != 0) { - result.setTo(m_search_->text + matchedindex, matchedlength); + result.setTo(m_search_->text + matchedindex, matchedlength); } else { result.remove(); } } - -void SearchIterator::setBreakIterator(BreakIterator *breakiter, + +void SearchIterator::setBreakIterator(BreakIterator *breakiter, UErrorCode &status) { if (U_SUCCESS(status)) { @@ -139,11 +139,11 @@ void SearchIterator::setBreakIterator(BreakIterator *breakiter, // any subclass of BreakIterator should work fine here... m_search_->breakIter = (UBreakIterator *) breakiter; #endif - + m_breakiterator_ = breakiter; } } - + const BreakIterator * SearchIterator::getBreakIterator(void) const { return m_breakiterator_; @@ -170,7 +170,7 @@ void SearchIterator::setText(CharacterIterator &text, UErrorCode &status) setText(m_text_, status); } } - + const UnicodeString & SearchIterator::getText(void) const { return m_text_; @@ -191,7 +191,7 @@ UBool SearchIterator::operator==(const SearchIterator &that) const m_search_->matchedLength == that.m_search_->matchedLength && m_search_->textLength == that.m_search_->textLength && getOffset() == that.getOffset() && - (uprv_memcmp(m_search_->text, that.m_search_->text, + (uprv_memcmp(m_search_->text, that.m_search_->text, m_search_->textLength * sizeof(UChar)) == 0)); } @@ -206,7 +206,7 @@ int32_t SearchIterator::first(UErrorCode &status) return handleNext(0, status); } -int32_t SearchIterator::following(int32_t position, +int32_t SearchIterator::following(int32_t position, UErrorCode &status) { if (U_FAILURE(status)) { @@ -215,7 +215,7 @@ int32_t SearchIterator::following(int32_t position, setOffset(position, status); return handleNext(position, status); } - + int32_t SearchIterator::last(UErrorCode &status) { if (U_FAILURE(status)) { @@ -225,7 +225,7 @@ int32_t SearchIterator::last(UErrorCode &status) return handlePrev(m_search_->textLength, status); } -int32_t SearchIterator::preceding(int32_t position, +int32_t SearchIterator::preceding(int32_t position, UErrorCode &status) { if (U_FAILURE(status)) { @@ -244,19 +244,19 @@ int32_t SearchIterator::next(UErrorCode &status) m_search_->reset = FALSE; if (m_search_->isForwardSearching == TRUE) { int32_t textlength = m_search_->textLength; - if (offset == textlength || matchindex == textlength || - (matchindex != USEARCH_DONE && + if (offset == textlength || matchindex == textlength || + (matchindex != USEARCH_DONE && matchindex + matchlength >= textlength)) { // not enough characters to match setMatchNotFound(); - return USEARCH_DONE; + return USEARCH_DONE; } } else { - // switching direction. - // if matchedIndex == USEARCH_DONE, it means that either a + // switching direction. + // if matchedIndex == USEARCH_DONE, it means that either a // setOffset has been called or that previous ran off the text - // string. the iterator would have been set to offset 0 if a + // string. the iterator would have been set to offset 0 if a // match is not found. m_search_->isForwardSearching = TRUE; if (m_search_->matchedIndex != USEARCH_DONE) { @@ -293,13 +293,13 @@ int32_t SearchIterator::previous(UErrorCode &status) else { offset = getOffset(); } - + int32_t matchindex = m_search_->matchedIndex; if (m_search_->isForwardSearching == TRUE) { - // switching direction. - // if matchedIndex == USEARCH_DONE, it means that either a + // switching direction. + // if matchedIndex == USEARCH_DONE, it means that either a // setOffset has been called or that next ran off the text - // string. the iterator would have been set to offset textLength if + // string. the iterator would have been set to offset textLength if // a match is not found. m_search_->isForwardSearching = FALSE; if (matchindex != USEARCH_DONE) { @@ -310,7 +310,7 @@ int32_t SearchIterator::previous(UErrorCode &status) if (offset == 0 || matchindex == 0) { // not enough characters to match setMatchNotFound(); - return USEARCH_DONE; + return USEARCH_DONE; } } @@ -319,7 +319,7 @@ int32_t SearchIterator::previous(UErrorCode &status) matchindex += m_search_->matchedLength - 2; } - return handlePrev(matchindex, status); + return handlePrev(matchindex, status); } return handlePrev(offset, status); @@ -358,7 +358,7 @@ SearchIterator::SearchIterator() m_breakiterator_ = NULL; } -SearchIterator::SearchIterator(const UnicodeString &text, +SearchIterator::SearchIterator(const UnicodeString &text, BreakIterator *breakiter) : m_breakiterator_(breakiter), m_text_(text) @@ -376,7 +376,7 @@ SearchIterator::SearchIterator(const UnicodeString &text, m_search_->textLength = text.length(); } -SearchIterator::SearchIterator(CharacterIterator &text, +SearchIterator::SearchIterator(CharacterIterator &text, BreakIterator *breakiter) : m_breakiterator_(breakiter) { @@ -424,12 +424,12 @@ void SearchIterator::setMatchStart(int32_t position) m_search_->matchedIndex = position; } -void SearchIterator::setMatchNotFound() +void SearchIterator::setMatchNotFound() { setMatchStart(USEARCH_DONE); setMatchLength(0); UErrorCode status = U_ZERO_ERROR; - // by default no errors should be returned here since offsets are within + // by default no errors should be returned here since offsets are within // range. if (m_search_->isForwardSearching) { setOffset(m_search_->textLength, status); diff --git a/deps/icu-small/source/i18n/selfmt.cpp b/deps/icu-small/source/i18n/selfmt.cpp index 29aee3645751f2..47e53d75dec36f 100644 --- a/deps/icu-small/source/i18n/selfmt.cpp +++ b/deps/icu-small/source/i18n/selfmt.cpp @@ -151,7 +151,7 @@ int32_t SelectFormat::findSubMessage(const MessagePattern& pattern, int32_t part return msgStart; } -Format* SelectFormat::clone() const +SelectFormat* SelectFormat::clone() const { return new SelectFormat(*this); } diff --git a/deps/icu-small/source/i18n/selfmtimpl.h b/deps/icu-small/source/i18n/selfmtimpl.h index 74d6dc218135e7..a36d1a5c347fb4 100644 --- a/deps/icu-small/source/i18n/selfmtimpl.h +++ b/deps/icu-small/source/i18n/selfmtimpl.h @@ -1,10 +1,10 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2011, International Business Machines Corporation and * others. All Rights Reserved. - * Copyright (C) 2010 , Yahoo! Inc. + * Copyright (C) 2010 , Yahoo! Inc. ******************************************************************** * File selectfmtimpl.h * diff --git a/deps/icu-small/source/i18n/simpletz.cpp b/deps/icu-small/source/i18n/simpletz.cpp index 1af5292a823324..7972e2bb040dfd 100644 --- a/deps/icu-small/source/i18n/simpletz.cpp +++ b/deps/icu-small/source/i18n/simpletz.cpp @@ -33,6 +33,7 @@ #include "unicode/gregocal.h" #include "unicode/smpdtfmt.h" +#include "cmemory.h" #include "gregoimp.h" #include "umutex.h" @@ -242,7 +243,7 @@ SimpleTimeZone::operator==(const TimeZone& that) const // ------------------------------------- // Called by TimeZone::createDefault() inside a Mutex - be careful. -TimeZone* +SimpleTimeZone* SimpleTimeZone::clone() const { return new SimpleTimeZone(*this); @@ -304,7 +305,7 @@ SimpleTimeZone::setStartYear(int32_t year) * @param time the daylight savings starting time. Please see the member * description for an example. */ - + void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, int32_t time, TimeMode mode, UErrorCode& status) @@ -320,17 +321,17 @@ SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t da // ------------------------------------- -void -SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, - int32_t time, TimeMode mode, UErrorCode& status) +void +SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, + int32_t time, TimeMode mode, UErrorCode& status) { setStartRule(month, dayOfMonth, 0, time, mode, status); } // ------------------------------------- -void -SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, +void +SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, int32_t time, TimeMode mode, UBool after, UErrorCode& status) { setStartRule(month, after ? dayOfMonth : -dayOfMonth, @@ -372,8 +373,8 @@ SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayO // ------------------------------------- -void -SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, +void +SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, TimeMode mode, UErrorCode& status) { setEndRule(month, dayOfMonth, 0, time, mode, status); @@ -381,8 +382,8 @@ SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, // ------------------------------------- -void -SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, +void +SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, int32_t time, TimeMode mode, UBool after, UErrorCode& status) { setEndRule(month, after ? dayOfMonth : -dayOfMonth, @@ -410,9 +411,9 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, return getOffset(era, year, month, day, dayOfWeek, millis, Grego::monthLength(year, month), status); } -int32_t +int32_t SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, - uint8_t dayOfWeek, int32_t millis, + uint8_t dayOfWeek, int32_t millis, int32_t /*monthLength*/, UErrorCode& status) const { // Check the month before calling Grego::monthLength(). This @@ -437,9 +438,9 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, status); } -int32_t +int32_t SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, - uint8_t dayOfWeek, int32_t millis, + uint8_t dayOfWeek, int32_t millis, int32_t monthLength, int32_t prevMonthLength, UErrorCode& status) const { @@ -465,7 +466,7 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, int32_t result = rawOffset; // Bail out if we are before the onset of daylight savings time - if(!useDaylight || year < startYear || era != GregorianCalendar::AD) + if(!useDaylight || year < startYear || era != GregorianCalendar::AD) return result; // Check for southern hemisphere. We assume that the start and end @@ -567,7 +568,7 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32 * @return 1 if the date is after the rule date, -1 if the date is before * the rule date, or 0 if the date is equal to the rule date. */ -int32_t +int32_t SimpleTimeZone::compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen, int8_t dayOfMonth, int8_t dayOfWeek, int32_t millis, int32_t millisDelta, @@ -628,7 +629,7 @@ SimpleTimeZone::compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen if (ruleDay > 0) ruleDayOfMonth = 1 + (ruleDay - 1) * 7 + (7 + ruleDayOfWeek - (dayOfWeek - dayOfMonth + 1)) % 7; - + // if ruleDay is negative (we assume it's not zero here), we have to do // the same calculation figuring backward from the last day of the month. else @@ -683,8 +684,8 @@ SimpleTimeZone::setRawOffset(int32_t offsetMillis) // ------------------------------------- -void -SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status) +void +SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status) { if (millisSavedDuringDST == 0) { status = U_ILLEGAL_ARGUMENT_ERROR; @@ -697,7 +698,7 @@ SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status) // ------------------------------------- -int32_t +int32_t SimpleTimeZone::getDSTSavings() const { return dstSavings; @@ -742,7 +743,7 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const * @param other the TimeZone object to be compared with * @return true if the given zone has the same rules and offset as this one */ -UBool +UBool SimpleTimeZone::hasSameRules(const TimeZone& other) const { if (this == &other) return TRUE; @@ -833,7 +834,7 @@ SimpleTimeZone::hasSameRules(const TimeZone& other) const * This method also recognizes a startDay or endDay of zero as indicating * no DST. */ -void +void SimpleTimeZone::decodeRules(UErrorCode& status) { decodeStartRule(status); @@ -864,8 +865,8 @@ SimpleTimeZone::decodeRules(UErrorCode& status) * While arguably the start range should still be 0..ONEDAY-1, we keep * the start and end ranges the same for consistency. */ -void -SimpleTimeZone::decodeStartRule(UErrorCode& status) +void +SimpleTimeZone::decodeStartRule(UErrorCode& status) { if(U_FAILURE(status)) return; @@ -919,8 +920,8 @@ SimpleTimeZone::decodeStartRule(UErrorCode& status) * analogous to decodeStartRule(). * @see decodeStartRule */ -void -SimpleTimeZone::decodeEndRule(UErrorCode& status) +void +SimpleTimeZone::decodeEndRule(UErrorCode& status) { if(U_FAILURE(status)) return; @@ -1083,7 +1084,7 @@ SimpleTimeZone::checkTransitionRules(UErrorCode& status) const { if (U_FAILURE(status)) { return; } - static UMutex gLock = U_MUTEX_INITIALIZER; + static UMutex gLock; umtx_lock(&gLock); if (!transitionRulesInitialized) { SimpleTimeZone *ncThis = const_cast(this); @@ -1137,14 +1138,14 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) { // For now, use ID + "(DST)" as the name dstRule = new AnnualTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), getDSTSavings(), dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR); - + // Check for Null pointer if (dstRule == NULL) { status = U_MEMORY_ALLOCATION_ERROR; deleteTransitionRules(); return; } - + // Calculate the first DST start time dstRule->getFirstStart(getRawOffset(), 0, firstDstStart); @@ -1165,7 +1166,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) { dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, false, endTime, timeRuleType); break; } - + // Check for Null pointer if (dtRule == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -1175,7 +1176,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) { // For now, use ID + "(STD)" as the name stdRule = new AnnualTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0, dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR); - + //Check for Null pointer if (stdRule == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -1209,7 +1210,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) { deleteTransitionRules(); return; } - + } else { // Create a TimeZoneRule for initial time initialRule = new InitialTimeZoneRule(tzid, getRawOffset(), 0); diff --git a/deps/icu-small/source/i18n/smpdtfmt.cpp b/deps/icu-small/source/i18n/smpdtfmt.cpp index e67c4538287b9e..5fcbb5875b2bfb 100644 --- a/deps/icu-small/source/i18n/smpdtfmt.cpp +++ b/deps/icu-small/source/i18n/smpdtfmt.cpp @@ -230,10 +230,7 @@ static const int32_t gFieldRangeBias[] = { static const int32_t HEBREW_CAL_CUR_MILLENIUM_START_YEAR = 5000; static const int32_t HEBREW_CAL_CUR_MILLENIUM_END_YEAR = 6000; -static UMutex *LOCK() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex LOCK; UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleDateFormat) @@ -623,7 +620,7 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other) //---------------------------------------------------------------------- -Format* +SimpleDateFormat* SimpleDateFormat::clone() const { return new SimpleDateFormat(*this); @@ -1223,10 +1220,14 @@ _appendSymbolWithMonthPattern(UnicodeString& dst, int32_t value, const UnicodeSt //---------------------------------------------------------------------- static number::LocalizedNumberFormatter* -createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt) { - return new number::LocalizedNumberFormatter( - df->toNumberFormatter() - .integerWidth(number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt))); +createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt, UErrorCode& status) { + const number::LocalizedNumberFormatter* lnfBase = df->toNumberFormatter(status); + if (U_FAILURE(status)) { + return nullptr; + } + return lnfBase->integerWidth( + number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt) + ).clone().orphan(); } void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) { @@ -1237,11 +1238,11 @@ void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) { if (df == nullptr) { return; } - fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10); - fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10); - fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10); - fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10); - fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2); + fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2, status); } void SimpleDateFormat::freeFastNumberFormatters() { @@ -1266,14 +1267,14 @@ SimpleDateFormat::initNumberFormatters(const Locale &locale,UErrorCode &status) if ( fDateOverride.isBogus() && fTimeOverride.isBogus() ) { return; } - umtx_lock(LOCK()); + umtx_lock(&LOCK); if (fSharedNumberFormatters == NULL) { fSharedNumberFormatters = allocSharedNumberFormatters(); if (fSharedNumberFormatters == NULL) { status = U_MEMORY_ALLOCATION_ERROR; } } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (U_FAILURE(status)) { return; @@ -1980,9 +1981,11 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, break; } if (titlecase) { + BreakIterator* const mutableCapitalizationBrkIter = fCapitalizationBrkIter->clone(); UnicodeString firstField(appendTo, beginOffset); - firstField.toTitle(fCapitalizationBrkIter, fLocale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); + firstField.toTitle(mutableCapitalizationBrkIter, fLocale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); appendTo.replaceBetween(beginOffset, appendTo.length(), firstField); + delete mutableCapitalizationBrkIter; } } #endif @@ -2107,7 +2110,7 @@ SimpleDateFormat::zeroPaddingNumber( // Fall back to slow path (clone and mutate the NumberFormat) if (currentNumberFormat != nullptr) { FieldPosition pos(FieldPosition::DONT_CARE); - LocalPointer nf(dynamic_cast(currentNumberFormat->clone())); + LocalPointer nf(currentNumberFormat->clone()); nf->setMinimumIntegerDigits(minDigits); nf->setMaximumIntegerDigits(maxDigits); nf->format(value, appendTo, pos); // 3rd arg is there to speed up processing @@ -3770,7 +3773,7 @@ void SimpleDateFormat::parseInt(const UnicodeString& text, auto* fmtAsDF = dynamic_cast(fmt); LocalPointer df; if (!allowNegative && fmtAsDF != nullptr) { - df.adoptInstead(dynamic_cast(fmtAsDF->clone())); + df.adoptInstead(fmtAsDF->clone()); if (df.isNull()) { // Memory allocation error return; @@ -3901,11 +3904,11 @@ SimpleDateFormat::applyPattern(const UnicodeString& pattern) } else if (fDateOverride.isBogus() && fHasHanYearChar) { // No current override (=> no Gannen numbering) but new pattern needs it; // use procedures from initNUmberFormatters / adoptNumberFormat - umtx_lock(LOCK()); + umtx_lock(&LOCK); if (fSharedNumberFormatters == NULL) { fSharedNumberFormatters = allocSharedNumberFormatters(); } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (fSharedNumberFormatters != NULL) { Locale ovrLoc(fLocale.getLanguage(),fLocale.getCountry(),fLocale.getVariant(),"numbers=jpanyear"); UErrorCode status = U_ZERO_ERROR; @@ -3998,6 +4001,7 @@ void SimpleDateFormat::adoptCalendar(Calendar* calendarToAdopt) DateFormatSymbols *newSymbols = DateFormatSymbols::createForLocale(calLocale, status); if (U_FAILURE(status)) { + delete calendarToAdopt; return; } DateFormat::adoptCalendar(calendarToAdopt); @@ -4237,7 +4241,7 @@ SimpleDateFormat::skipUWhiteSpace(const UnicodeString& text, int32_t pos) const TimeZoneFormat * SimpleDateFormat::tzFormat(UErrorCode &status) const { if (fTimeZoneFormat == NULL) { - umtx_lock(LOCK()); + umtx_lock(&LOCK); { if (fTimeZoneFormat == NULL) { TimeZoneFormat *tzfmt = TimeZoneFormat::createInstance(fLocale, status); @@ -4248,7 +4252,7 @@ SimpleDateFormat::tzFormat(UErrorCode &status) const { const_cast(this)->fTimeZoneFormat = tzfmt; } } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); } return fTimeZoneFormat; } diff --git a/deps/icu-small/source/i18n/smpdtfst.cpp b/deps/icu-small/source/i18n/smpdtfst.cpp index ff0dec232d29f7..db59a4b4ab7f8f 100644 --- a/deps/icu-small/source/i18n/smpdtfst.cpp +++ b/deps/icu-small/source/i18n/smpdtfst.cpp @@ -110,7 +110,7 @@ UnicodeSet *SimpleDateFormatStaticSets::getIgnorables(UDateFormatField fieldInde if (U_FAILURE(status)) { return NULL; } - + switch (fieldIndex) { case UDAT_YEAR_FIELD: case UDAT_MONTH_FIELD: @@ -118,7 +118,7 @@ UnicodeSet *SimpleDateFormatStaticSets::getIgnorables(UDateFormatField fieldInde case UDAT_STANDALONE_DAY_FIELD: case UDAT_STANDALONE_MONTH_FIELD: return gStaticSets->fDateIgnorables; - + case UDAT_HOUR_OF_DAY1_FIELD: case UDAT_HOUR_OF_DAY0_FIELD: case UDAT_MINUTE_FIELD: @@ -126,7 +126,7 @@ UnicodeSet *SimpleDateFormatStaticSets::getIgnorables(UDateFormatField fieldInde case UDAT_HOUR1_FIELD: case UDAT_HOUR0_FIELD: return gStaticSets->fTimeIgnorables; - + default: return gStaticSets->fOtherIgnorables; } diff --git a/deps/icu-small/source/i18n/smpdtfst.h b/deps/icu-small/source/i18n/smpdtfst.h index ed8ce4371f6d6d..cc80909c88e93a 100644 --- a/deps/icu-small/source/i18n/smpdtfst.h +++ b/deps/icu-small/source/i18n/smpdtfst.h @@ -33,12 +33,12 @@ class SimpleDateFormatStaticSets : public UMemory public: SimpleDateFormatStaticSets(UErrorCode &status); ~SimpleDateFormatStaticSets(); - + static void initSets(UErrorCode *status); static UBool cleanup(); - + static UnicodeSet *getIgnorables(UDateFormatField fieldIndex); - + private: UnicodeSet *fDateIgnorables; UnicodeSet *fTimeIgnorables; diff --git a/deps/icu-small/source/i18n/sortkey.cpp b/deps/icu-small/source/i18n/sortkey.cpp index fb030c499083e6..12289482ec07aa 100644 --- a/deps/icu-small/source/i18n/sortkey.cpp +++ b/deps/icu-small/source/i18n/sortkey.cpp @@ -278,7 +278,7 @@ CollationKey::hashCode() const U_NAMESPACE_END U_CAPI int32_t U_EXPORT2 -ucol_keyHashCode(const uint8_t *key, +ucol_keyHashCode(const uint8_t *key, int32_t length) { return icu::computeHashCode(key, length); diff --git a/deps/icu-small/source/i18n/numparse_stringsegment.cpp b/deps/icu-small/source/i18n/string_segment.cpp similarity index 96% rename from deps/icu-small/source/i18n/numparse_stringsegment.cpp rename to deps/icu-small/source/i18n/string_segment.cpp index 3db4fe618a603a..5d19ac57f5e0d1 100644 --- a/deps/icu-small/source/i18n/numparse_stringsegment.cpp +++ b/deps/icu-small/source/i18n/string_segment.cpp @@ -10,14 +10,12 @@ #define UNISTR_FROM_STRING_EXPLICIT #include "numparse_types.h" -#include "numparse_stringsegment.h" +#include "string_segment.h" #include "putilimp.h" #include "unicode/utf16.h" #include "unicode/uniset.h" -using namespace icu; -using namespace icu::numparse; -using namespace icu::numparse::impl; +U_NAMESPACE_BEGIN StringSegment::StringSegment(const UnicodeString& str, bool ignoreCase) @@ -143,4 +141,5 @@ bool StringSegment::operator==(const UnicodeString& other) const { } +U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/string_segment.h b/deps/icu-small/source/i18n/string_segment.h new file mode 100644 index 00000000000000..b581f7e57599eb --- /dev/null +++ b/deps/icu-small/source/i18n/string_segment.h @@ -0,0 +1,134 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMPARSE_STRINGSEGMENT_H__ +#define __NUMPARSE_STRINGSEGMENT_H__ + +#include "unicode/unistr.h" +#include "unicode/uniset.h" + +U_NAMESPACE_BEGIN + + +/** + * A mutable UnicodeString wrapper with a variable offset and length and + * support for case folding. The charAt, length, and subSequence methods all + * operate relative to the fixed offset into the UnicodeString. + * + * Intended to be useful for parsing. + * + * CAUTION: Since this class is mutable, it must not be used anywhere that an + * immutable object is required, like in a cache or as the key of a hash map. + * + * @author sffc (Shane Carr) + */ +// Exported as U_I18N_API for tests +class U_I18N_API StringSegment : public UMemory { + public: + StringSegment(const UnicodeString& str, bool ignoreCase); + + int32_t getOffset() const; + + void setOffset(int32_t start); + + /** + * Equivalent to setOffset(getOffset()+delta). + * + *

    + * This method is usually called by a Matcher to register that a char was consumed. If the char is + * strong (it usually is, except for things like whitespace), follow this with a call to + * {@link ParsedNumber#setCharsConsumed}. For more information on strong chars, see that method. + */ + void adjustOffset(int32_t delta); + + /** + * Adjusts the offset by the width of the current code point, either 1 or 2 chars. + */ + void adjustOffsetByCodePoint(); + + void setLength(int32_t length); + + void resetLength(); + + int32_t length() const; + + char16_t charAt(int32_t index) const; + + UChar32 codePointAt(int32_t index) const; + + UnicodeString toUnicodeString() const; + + const UnicodeString toTempUnicodeString() const; + + /** + * Returns the first code point in the string segment, or -1 if the string starts with an invalid + * code point. + * + *

    + * Important: Most of the time, you should use {@link #startsWith}, which handles case + * folding logic, instead of this method. + */ + UChar32 getCodePoint() const; + + /** + * Returns true if the first code point of this StringSegment equals the given code point. + * + *

    + * This method will perform case folding if case folding is enabled for the parser. + */ + bool startsWith(UChar32 otherCp) const; + + /** + * Returns true if the first code point of this StringSegment is in the given UnicodeSet. + */ + bool startsWith(const UnicodeSet& uniset) const; + + /** + * Returns true if there is at least one code point of overlap between this StringSegment and the + * given UnicodeString. + */ + bool startsWith(const UnicodeString& other) const; + + /** + * Returns the length of the prefix shared by this StringSegment and the given UnicodeString. For + * example, if this string segment is "aab", and the char sequence is "aac", this method returns 2, + * since the first 2 characters are the same. + * + *

    + * This method only returns offsets along code point boundaries. + * + *

    + * This method will perform case folding if case folding was enabled in the constructor. + * + *

    + * IMPORTANT: The given UnicodeString must not be empty! It is the caller's responsibility to check. + */ + int32_t getCommonPrefixLength(const UnicodeString& other); + + /** + * Like {@link #getCommonPrefixLength}, but never performs case folding, even if case folding is + * enabled for the parser. + */ + int32_t getCaseSensitivePrefixLength(const UnicodeString& other); + + bool operator==(const UnicodeString& other) const; + + private: + const UnicodeString& fStr; + int32_t fStart; + int32_t fEnd; + bool fFoldCase; + + int32_t getPrefixLengthInternal(const UnicodeString& other, bool foldCase); + + static bool codePointsEqual(UChar32 cp1, UChar32 cp2, bool foldCase); +}; + + +U_NAMESPACE_END + +#endif //__NUMPARSE_STRINGSEGMENT_H__ +#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/strmatch.cpp b/deps/icu-small/source/i18n/strmatch.cpp index d5b018aa6b62b6..a20f7873fec73e 100644 --- a/deps/icu-small/source/i18n/strmatch.cpp +++ b/deps/icu-small/source/i18n/strmatch.cpp @@ -58,7 +58,7 @@ StringMatcher::~StringMatcher() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* StringMatcher::clone() const { +StringMatcher* StringMatcher::clone() const { return new StringMatcher(*this); } @@ -69,7 +69,7 @@ UnicodeFunctor* StringMatcher::clone() const { UnicodeMatcher* StringMatcher::toMatcher() const { StringMatcher *nonconst_this = const_cast(this); UnicodeMatcher *nonconst_base = static_cast(nonconst_this); - + return nonconst_base; } @@ -80,7 +80,7 @@ UnicodeMatcher* StringMatcher::toMatcher() const { UnicodeReplacer* StringMatcher::toReplacer() const { StringMatcher *nonconst_this = const_cast(this); UnicodeReplacer *nonconst_base = static_cast(nonconst_this); - + return nonconst_base; } @@ -221,9 +221,9 @@ int32_t StringMatcher::replace(Replaceable& text, int32_t start, int32_t limit, int32_t& /*cursor*/) { - + int32_t outLen = 0; - + // Copy segment with out-of-band data int32_t dest = limit; // If there was no match, that means that a quantifier @@ -234,9 +234,9 @@ int32_t StringMatcher::replace(Replaceable& text, outLen = matchLimit - matchStart; } } - + text.handleReplaceBetween(start, limit, UnicodeString()); // delete original text - + return outLen; } diff --git a/deps/icu-small/source/i18n/strmatch.h b/deps/icu-small/source/i18n/strmatch.h index 7152a24a0765e4..71ae9849511b23 100644 --- a/deps/icu-small/source/i18n/strmatch.h +++ b/deps/icu-small/source/i18n/strmatch.h @@ -68,7 +68,7 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico * @param o the object to be copied. */ StringMatcher(const StringMatcher& o); - + /** * Destructor */ @@ -78,7 +78,7 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico * Implement UnicodeFunctor * @return a copy of the object. */ - virtual UnicodeFunctor* clone() const; + virtual StringMatcher* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer @@ -137,7 +137,7 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico * offset). This is used by RuleBasedTransliterator for * indexing. * @param v the given value - * @return TRUE if this matcher will match a character c, + * @return TRUE if this matcher will match a character c, * where c & 0xFF == v */ virtual UBool matchesIndexValue(uint8_t v) const; diff --git a/deps/icu-small/source/i18n/strrepl.cpp b/deps/icu-small/source/i18n/strrepl.cpp index 132c844c2dff27..9fafeb2659ce47 100644 --- a/deps/icu-small/source/i18n/strrepl.cpp +++ b/deps/icu-small/source/i18n/strrepl.cpp @@ -87,7 +87,7 @@ StringReplacer::~StringReplacer() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* StringReplacer::clone() const { +StringReplacer* StringReplacer::clone() const { return new StringReplacer(*this); } @@ -199,7 +199,7 @@ int32_t StringReplacer::replace(Replaceable& text, // Delete the old text (the key) text.handleReplaceBetween(start + outLen, limit + outLen, UnicodeString()); - } + } if (hasCursor) { // Adjust the cursor for positions outside the key. These diff --git a/deps/icu-small/source/i18n/strrepl.h b/deps/icu-small/source/i18n/strrepl.h index feec058152a8a3..7f74d0d94507f6 100644 --- a/deps/icu-small/source/i18n/strrepl.h +++ b/deps/icu-small/source/i18n/strrepl.h @@ -111,7 +111,7 @@ class StringReplacer : public UnicodeFunctor, public UnicodeReplacer { /** * Implement UnicodeFunctor */ - virtual UnicodeFunctor* clone() const; + virtual StringReplacer* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer diff --git a/deps/icu-small/source/i18n/stsearch.cpp b/deps/icu-small/source/i18n/stsearch.cpp index bf4d80b6db8ed0..3e6ed4648be94f 100644 --- a/deps/icu-small/source/i18n/stsearch.cpp +++ b/deps/icu-small/source/i18n/stsearch.cpp @@ -282,7 +282,7 @@ void StringSearch::reset() usearch_reset(m_strsrch_); } -SearchIterator * StringSearch::safeClone(void) const +StringSearch * StringSearch::safeClone() const { UErrorCode status = U_ZERO_ERROR; StringSearch *result = new StringSearch(m_pattern_, m_text_, @@ -342,7 +342,7 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status) } ucol_setOffset(m_strsrch_->textIter, position, &status); - + #if 0 for (;;) { if (m_search_->isCanonicalMatch) { @@ -380,22 +380,22 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status) // then we don't need to check the match boundaries here because // usearch_handleNextXXX will already have done it. if (m_search_->isCanonicalMatch) { - // *could* actually use exact here 'cause no extra accents allowed... - usearch_handleNextCanonical(m_strsrch_, &status); + // *could* actually use exact here 'cause no extra accents allowed... + usearch_handleNextCanonical(m_strsrch_, &status); } else { - usearch_handleNextExact(m_strsrch_, &status); + usearch_handleNextExact(m_strsrch_, &status); } - + if (U_FAILURE(status)) { - return USEARCH_DONE; + return USEARCH_DONE; } - + if (m_search_->matchedIndex == USEARCH_DONE) { - ucol_setOffset(m_strsrch_->textIter, m_search_->textLength, &status); + ucol_setOffset(m_strsrch_->textIter, m_search_->textLength, &status); } else { - ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex, &status); + ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex, &status); } - + return m_search_->matchedIndex; #endif } @@ -431,7 +431,7 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status) setMatchNotFound(); return USEARCH_DONE; } - + for (;;) { if (m_search_->isCanonicalMatch) { // can't use exact here since extra accents are allowed. @@ -457,18 +457,18 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status) } #else ucol_setOffset(m_strsrch_->textIter, position, &status); - + if (m_search_->isCanonicalMatch) { - // *could* use exact match here since extra accents *not* allowed! - usearch_handlePreviousCanonical(m_strsrch_, &status); + // *could* use exact match here since extra accents *not* allowed! + usearch_handlePreviousCanonical(m_strsrch_, &status); } else { - usearch_handlePreviousExact(m_strsrch_, &status); + usearch_handlePreviousExact(m_strsrch_, &status); } - + if (U_FAILURE(status)) { - return USEARCH_DONE; + return USEARCH_DONE; } - + return m_search_->matchedIndex; #endif } diff --git a/deps/icu-small/source/i18n/taiwncal.cpp b/deps/icu-small/source/i18n/taiwncal.cpp index e2757dbd550dd9..27352aa10c32b2 100644 --- a/deps/icu-small/source/i18n/taiwncal.cpp +++ b/deps/icu-small/source/i18n/taiwncal.cpp @@ -30,7 +30,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TaiwanCalendar) static const int32_t kTaiwanEraStart = 1911; // 1911 (Gregorian) -static const int32_t kGregorianEpoch = 1970; +static const int32_t kGregorianEpoch = 1970; TaiwanCalendar::TaiwanCalendar(const Locale& aLocale, UErrorCode& success) : GregorianCalendar(aLocale, success) @@ -53,7 +53,7 @@ TaiwanCalendar& TaiwanCalendar::operator= ( const TaiwanCalendar& right) return *this; } -Calendar* TaiwanCalendar::clone(void) const +TaiwanCalendar* TaiwanCalendar::clone() const { return new TaiwanCalendar(*this); } @@ -135,7 +135,7 @@ void TaiwanCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& status /** * The system maintains a static default century start date and Year. They are - * initialized the first time they are used. Once the system default century date + * initialized the first time they are used. Once the system default century date * and year are set, they do not change. */ static UDate gSystemDefaultCenturyStart = DBL_MIN; diff --git a/deps/icu-small/source/i18n/taiwncal.h b/deps/icu-small/source/i18n/taiwncal.h index 99bbfb53f2b1ab..01d4d31e80b8ac 100644 --- a/deps/icu-small/source/i18n/taiwncal.h +++ b/deps/icu-small/source/i18n/taiwncal.h @@ -91,7 +91,7 @@ class TaiwanCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual TaiwanCalendar* clone() const; public: /** @@ -142,7 +142,7 @@ class TaiwanCalendar : public GregorianCalendar { virtual int32_t handleGetExtendedYear(); /** * Subclasses may override this method to compute several fields - * specific to each calendar system. + * specific to each calendar system. * @internal */ virtual void handleComputeFields(int32_t julianDay, UErrorCode& status); @@ -181,3 +181,4 @@ U_NAMESPACE_END #endif // _TAIWNCAL //eof + diff --git a/deps/icu-small/source/i18n/timezone.cpp b/deps/icu-small/source/i18n/timezone.cpp index 70169b5c1f576d..284334ebf7efbb 100644 --- a/deps/icu-small/source/i18n/timezone.cpp +++ b/deps/icu-small/source/i18n/timezone.cpp @@ -527,8 +527,10 @@ TimeZone::detectHostTimeZone() // ------------------------------------- +static UMutex gDefaultZoneMutex; + /** - * Initialize DEFAULT_ZONE from the system default time zone. + * Initialize DEFAULT_ZONE from the system default time zone. * Upon return, DEFAULT_ZONE will not be NULL, unless operator new() * returns NULL. */ @@ -536,12 +538,13 @@ static void U_CALLCONV initDefault() { ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup); + Mutex lock(&gDefaultZoneMutex); // If setDefault() has already been called we can skip getting the // default zone information from the system. if (DEFAULT_ZONE != NULL) { return; } - + // NOTE: this code is safely single threaded, being only // run via umtx_initOnce(). // @@ -557,9 +560,6 @@ static void U_CALLCONV initDefault() TimeZone *default_zone = TimeZone::detectHostTimeZone(); - // The only way for DEFAULT_ZONE to be non-null at this point is if the user - // made a thread-unsafe call to setDefault() or adoptDefault() in another - // thread while this thread was doing something that required getting the default. U_ASSERT(DEFAULT_ZONE == NULL); DEFAULT_ZONE = default_zone; @@ -571,7 +571,10 @@ TimeZone* U_EXPORT2 TimeZone::createDefault() { umtx_initOnce(gDefaultZoneInitOnce, initDefault); - return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL; + { + Mutex lock(&gDefaultZoneMutex); + return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL; + } } // ------------------------------------- @@ -581,9 +584,12 @@ TimeZone::adoptDefault(TimeZone* zone) { if (zone != NULL) { - TimeZone *old = DEFAULT_ZONE; - DEFAULT_ZONE = zone; - delete old; + { + Mutex lock(&gDefaultZoneMutex); + TimeZone *old = DEFAULT_ZONE; + DEFAULT_ZONE = zone; + delete old; + } ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup); } } @@ -1082,7 +1088,7 @@ TimeZone::dereferOlsonLink(const UnicodeString& id) { // open the zone bundle by index ures_getByKey(rb, kZONES, rb, &ec); - ures_getByIndex(rb, idx, rb, &ec); + ures_getByIndex(rb, idx, rb, &ec); if (U_SUCCESS(ec)) { if (ures_getType(rb) == URES_INT) { diff --git a/deps/icu-small/source/i18n/titletrn.cpp b/deps/icu-small/source/i18n/titletrn.cpp index 4e75c824a0f7f1..9c39b4676ad1cf 100644 --- a/deps/icu-small/source/i18n/titletrn.cpp +++ b/deps/icu-small/source/i18n/titletrn.cpp @@ -60,7 +60,7 @@ TitlecaseTransliterator::TitlecaseTransliterator(const TitlecaseTransliterator& /** * Transliterator API. */ -Transliterator* TitlecaseTransliterator::clone(void) const { +TitlecaseTransliterator* TitlecaseTransliterator::clone() const { return new TitlecaseTransliterator(*this); } @@ -88,7 +88,7 @@ void TitlecaseTransliterator::handleTransliterate( // Our mode; we are either converting letter toTitle or // toLower. UBool doTitle = TRUE; - + // Determine if there is a preceding context of cased case-ignorable*, // in which case we want to start in toLower mode. If the // prior context is anything else (including empty) then start @@ -106,7 +106,7 @@ void TitlecaseTransliterator::handleTransliterate( } // else (type<0) case-ignorable: continue } - + // Convert things after a cased character toLower; things // after an uncased, non-case-ignorable character toTitle. Case-ignorable // characters are copied directly and do not change the mode. diff --git a/deps/icu-small/source/i18n/titletrn.h b/deps/icu-small/source/i18n/titletrn.h index 166378fe9da5c2..4e45ac6f81fabc 100644 --- a/deps/icu-small/source/i18n/titletrn.h +++ b/deps/icu-small/source/i18n/titletrn.h @@ -52,7 +52,7 @@ class TitlecaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual TitlecaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/tmunit.cpp b/deps/icu-small/source/i18n/tmunit.cpp index 3e980105153da5..910489b1784eab 100644 --- a/deps/icu-small/source/i18n/tmunit.cpp +++ b/deps/icu-small/source/i18n/tmunit.cpp @@ -19,25 +19,25 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnit) /* * There are only 7 time units. - * So, TimeUnit could be made as singleton + * So, TimeUnit could be made as singleton * (similar to uniset_props.cpp, or unorm.cpp, - * in which a static TimeUnit* array is created, and + * in which a static TimeUnit* array is created, and * the creatInstance() returns a const TimeUnit*). * But the constraint is TimeUnit is a data member of Measure. * But Measure (which is an existing API) does not expect it's "unit" member * as singleton. Meaure takes ownership of the "unit" member. * In its constructor, it does not take a const "unit" pointer. * Also, Measure can clone and destruct the "unit" pointer. - * In order to preserve the old behavior and let Measure handle singleton "unit", - * 1. a flag need to be added in Measure; + * In order to preserve the old behavior and let Measure handle singleton "unit", + * 1. a flag need to be added in Measure; * 2. a new constructor which takes const "unit" as parameter need to be added, * and this new constructor will set the flag on. * 3. clone and destructor need to check upon this flag to distinguish on how - * to handle the "unit". - * + * to handle the "unit". + * * Since TimeUnit is such a light weight object, comparing with the heavy weight * format operation, we decided to avoid the above complication. - * + * * So, both TimeUnit and CurrencyUnit (the 2 subclasses of MeasureUnit) are * immutable and non-singleton. * @@ -45,18 +45,18 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnit) * If an application needs to create a long list of TimeUnitAmount on the same * time unit but different number, for example, * 1 hour, 2 hour, 3 hour, ................. 10,000 hour, - * there might be performance hit because 10,000 TimeUnit object, + * there might be performance hit because 10,000 TimeUnit object, * although all are the same time unit, will be created in heap and deleted. * * To address this performance issue, if there is any in the future, - * we should and need to change TimeUnitAmount and CurrencyAmount to be + * we should and need to change TimeUnitAmount and CurrencyAmount to be * immutable by allowing a setter on the number. - * Or we need to add 2 parallel mutable classes in order to + * Or we need to add 2 parallel mutable classes in order to * preserve the existing API. * Or we can use freezable. */ -TimeUnit* U_EXPORT2 -TimeUnit::createInstance(TimeUnit::UTimeUnitFields timeUnitField, +TimeUnit* U_EXPORT2 +TimeUnit::createInstance(TimeUnit::UTimeUnitFields timeUnitField, UErrorCode& status) { if (U_FAILURE(status)) { return NULL; @@ -98,11 +98,11 @@ TimeUnit::TimeUnit(TimeUnit::UTimeUnitFields timeUnitField) { } } -TimeUnit::TimeUnit(const TimeUnit& other) +TimeUnit::TimeUnit(const TimeUnit& other) : MeasureUnit(other), fTimeUnitField(other.fTimeUnitField) { } -UObject* +TimeUnit* TimeUnit::clone() const { return new TimeUnit(*this); } diff --git a/deps/icu-small/source/i18n/tmutamt.cpp b/deps/icu-small/source/i18n/tmutamt.cpp index 0e2b91fbb2bb6f..25464693ea9b33 100644 --- a/deps/icu-small/source/i18n/tmutamt.cpp +++ b/deps/icu-small/source/i18n/tmutamt.cpp @@ -5,7 +5,7 @@ * Copyright (C) 2008, Google, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* - */ + */ #include "unicode/tmutamt.h" @@ -16,17 +16,17 @@ U_NAMESPACE_BEGIN UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnitAmount) -TimeUnitAmount::TimeUnitAmount(const Formattable& number, +TimeUnitAmount::TimeUnitAmount(const Formattable& number, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode& status) : Measure(number, TimeUnit::createInstance(timeUnitField, status), status) { } -TimeUnitAmount::TimeUnitAmount(double amount, +TimeUnitAmount::TimeUnitAmount(double amount, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode& status) -: Measure(Formattable(amount), +: Measure(Formattable(amount), TimeUnit::createInstance(timeUnitField, status), status) { } @@ -38,7 +38,7 @@ TimeUnitAmount::TimeUnitAmount(const TimeUnitAmount& other) } -TimeUnitAmount& +TimeUnitAmount& TimeUnitAmount::operator=(const TimeUnitAmount& other) { Measure::operator=(other); return *this; @@ -50,12 +50,12 @@ TimeUnitAmount::operator==(const UObject& other) const { return Measure::operator==(other); } -UObject* +TimeUnitAmount* TimeUnitAmount::clone() const { return new TimeUnitAmount(*this); } - + TimeUnitAmount::~TimeUnitAmount() { } @@ -71,7 +71,7 @@ TimeUnit::UTimeUnitFields TimeUnitAmount::getTimeUnitField() const { return getTimeUnit().getTimeUnitField(); } - + U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/tmutfmt.cpp b/deps/icu-small/source/i18n/tmutfmt.cpp index dad8825e70ff33..231ea5799c3764 100644 --- a/deps/icu-small/source/i18n/tmutfmt.cpp +++ b/deps/icu-small/source/i18n/tmutfmt.cpp @@ -136,8 +136,8 @@ TimeUnitFormat::~TimeUnitFormat() { } -Format* -TimeUnitFormat::clone(void) const { +TimeUnitFormat* +TimeUnitFormat::clone() const { return new TimeUnitFormat(*this); } @@ -685,7 +685,7 @@ TimeUnitFormat::setNumberFormat(const NumberFormat& format, UErrorCode& status){ if (U_FAILURE(status)) { return; } - adoptNumberFormat((NumberFormat *)format.clone(), status); + adoptNumberFormat(format.clone(), status); } @@ -721,8 +721,8 @@ TimeUnitFormat::copyHash(const Hashtable* source, Hashtable* target, UErrorCode& const UHashTok valueTok = element->value; const MessageFormat** value = (const MessageFormat**)valueTok.pointer; MessageFormat** newVal = (MessageFormat**)uprv_malloc(UTMUTFMT_FORMAT_STYLE_COUNT*sizeof(MessageFormat*)); - newVal[0] = (MessageFormat*)value[0]->clone(); - newVal[1] = (MessageFormat*)value[1]->clone(); + newVal[0] = value[0]->clone(); + newVal[1] = value[1]->clone(); target->put(UnicodeString(*key), newVal, status); if ( U_FAILURE(status) ) { delete newVal[0]; diff --git a/deps/icu-small/source/i18n/tolowtrn.cpp b/deps/icu-small/source/i18n/tolowtrn.cpp index 063cc88d1c40ce..289327874e3185 100644 --- a/deps/icu-small/source/i18n/tolowtrn.cpp +++ b/deps/icu-small/source/i18n/tolowtrn.cpp @@ -27,7 +27,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LowercaseTransliterator) /** * Constructs a transliterator. */ -LowercaseTransliterator::LowercaseTransliterator() : +LowercaseTransliterator::LowercaseTransliterator() : CaseMapTransliterator(UNICODE_STRING("Any-Lower", 9), ucase_toFullLower) { } @@ -58,7 +58,7 @@ LowercaseTransliterator::LowercaseTransliterator(const LowercaseTransliterator& /** * Transliterator API. */ -Transliterator* LowercaseTransliterator::clone(void) const { +LowercaseTransliterator* LowercaseTransliterator::clone() const { return new LowercaseTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/tolowtrn.h b/deps/icu-small/source/i18n/tolowtrn.h index e311431224e5c2..2fbfb90e1bface 100644 --- a/deps/icu-small/source/i18n/tolowtrn.h +++ b/deps/icu-small/source/i18n/tolowtrn.h @@ -50,7 +50,7 @@ class LowercaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual LowercaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/toupptrn.cpp b/deps/icu-small/source/i18n/toupptrn.cpp index 098dba9a3ce4f9..2a8b78b9a69d2f 100644 --- a/deps/icu-small/source/i18n/toupptrn.cpp +++ b/deps/icu-small/source/i18n/toupptrn.cpp @@ -58,7 +58,7 @@ UppercaseTransliterator::UppercaseTransliterator(const UppercaseTransliterator& /** * Transliterator API. */ -Transliterator* UppercaseTransliterator::clone(void) const { +UppercaseTransliterator* UppercaseTransliterator::clone() const { return new UppercaseTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/toupptrn.h b/deps/icu-small/source/i18n/toupptrn.h index 677a04e5c771a9..e96ca8f0ba530a 100644 --- a/deps/icu-small/source/i18n/toupptrn.h +++ b/deps/icu-small/source/i18n/toupptrn.h @@ -50,7 +50,7 @@ class UppercaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual UppercaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/translit.cpp b/deps/icu-small/source/i18n/translit.cpp index 9f5563b4796c19..dae87d06d79111 100644 --- a/deps/icu-small/source/i18n/translit.cpp +++ b/deps/icu-small/source/i18n/translit.cpp @@ -91,10 +91,7 @@ static const char RB_RULE_BASED_IDS[] = "RuleBasedTransliteratorIDs"; /** * The mutex controlling access to registry object. */ -static icu::UMutex *registryMutex() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex registryMutex; /** * System transliterator registry; non-null when initialized. @@ -161,7 +158,7 @@ Transliterator::Transliterator(const Transliterator& other) : if (other.filter != 0) { // We own the filter, so we must have our own copy - filter = (UnicodeFilter*) other.filter->clone(); + filter = other.filter->clone(); } } @@ -178,7 +175,7 @@ Transliterator& Transliterator::operator=(const Transliterator& other) { ID.getTerminatedBuffer(); maximumContextLength = other.maximumContextLength; - adoptFilter((other.filter == 0) ? 0 : (UnicodeFilter*) other.filter->clone()); + adoptFilter((other.filter == 0) ? 0 : other.filter->clone()); return *this; } @@ -251,7 +248,7 @@ void Transliterator::transliterate(Replaceable& text) const { * pending transliterations, clients should call {@link * #finishKeyboardTransliteration} after the last call to this * method has been made. - * + * * @param text the buffer holding transliterated and untransliterated text * @param index an array of three integers. * @@ -455,7 +452,7 @@ void Transliterator::filteredTransliterate(Replaceable& text, // the changes made during the pass, extends the pass by one code point, // and tries again. //---------------------------------------------------------------------- - + // globalLimit is the limit value for the entire operation. We // set index.limit to the end of each unfiltered run before // calling handleTransliterate(), so we need to maintain the real @@ -463,7 +460,7 @@ void Transliterator::filteredTransliterate(Replaceable& text, // update globalLimit for insertions or deletions that have // happened. int32_t globalLimit = index.limit; - + // If there is a non-null filter, then break the input text up. Say the // input text has the form: // xxxabcxxdefxx @@ -473,7 +470,7 @@ void Transliterator::filteredTransliterate(Replaceable& text, // Each pass through the loop consumes a run of filtered // characters (which are ignored) and a subsequent run of // unfiltered characters (which are transliterated). - + for (;;) { if (filter != NULL) { @@ -509,7 +506,7 @@ void Transliterator::filteredTransliterate(Replaceable& text, // complete the transliteration for this run. UBool isIncrementalRun = (index.limit < globalLimit ? FALSE : incremental); - + int32_t delta; // Implement rollback. To understand the need for rollback, @@ -926,22 +923,24 @@ Transliterator::createInstance(const UnicodeString& ID, return NULL; } - UnicodeSet* globalFilter; + UnicodeSet* globalFilter = nullptr; // TODO add code for parseError...currently unused, but // later may be used by parsing code... if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) { status = U_INVALID_ID; + delete globalFilter; return NULL; } - + LocalPointer lpGlobalFilter(globalFilter); + TransliteratorIDParser::instantiateList(list, status); if (U_FAILURE(status)) { return NULL; } - + U_ASSERT(list.size() > 0); Transliterator* t = NULL; - + if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) { // [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only // has one child transliterator. This is so that toRules() will return the right thing @@ -956,8 +955,8 @@ Transliterator::createInstance(const UnicodeString& ID, // Check null pointer if (t != NULL) { t->setID(canonID); - if (globalFilter != NULL) { - t->adoptFilter(globalFilter); + if (lpGlobalFilter.isValid()) { + t->adoptFilter(lpGlobalFilter.orphan()); } } else if (U_SUCCESS(status)) { @@ -981,11 +980,11 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id, TransliteratorAlias* alias = 0; Transliterator* t = 0; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { t = registry->get(id, alias, ec); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); if (U_FAILURE(ec)) { delete t; @@ -1013,11 +1012,11 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id, alias = 0; // Step 2. reget - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { t = registry->reget(id, parser, alias, ec); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); // Step 3. Loop back around! } else { @@ -1104,6 +1103,10 @@ Transliterator::createFromRules(const UnicodeString& ID, UnicodeString* idBlock = (UnicodeString*)parser.idBlockVector.elementAt(i); if (!idBlock->isEmpty()) { Transliterator* temp = createInstance(*idBlock, UTRANS_FORWARD, parseError, status); + if (U_FAILURE(status)) { + delete temp; + return nullptr; + } if (temp != NULL && typeid(*temp) != typeid(NullTransliterator)) transliterators.addElement(temp, status); else @@ -1117,8 +1120,10 @@ Transliterator::createFromRules(const UnicodeString& ID, data, TRUE); // Check if NULL before adding it to transliterators to avoid future usage of NULL pointer. if (temprbt == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return t; + if (U_SUCCESS(status)) { + status = U_MEMORY_ALLOCATION_ERROR; + } + return t; } transliterators.addElement(temprbt, status); } @@ -1215,7 +1220,7 @@ UnicodeSet& Transliterator::getTargetSet(UnicodeSet& result) const { void U_EXPORT2 Transliterator::registerFactory(const UnicodeString& id, Transliterator::Factory factory, Transliterator::Token context) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerFactory(id, factory, context); @@ -1254,7 +1259,7 @@ void Transliterator::_registerSpecialInverse(const UnicodeString& target, * @see #unregister */ void U_EXPORT2 Transliterator::registerInstance(Transliterator* adoptedPrototype) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerInstance(adoptedPrototype); @@ -1268,7 +1273,7 @@ void Transliterator::_registerInstance(Transliterator* adoptedPrototype) { void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID, const UnicodeString& realID) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerAlias(aliasID, realID); @@ -1284,13 +1289,13 @@ void Transliterator::_registerAlias(const UnicodeString& aliasID, /** * Unregisters a transliterator or class. This may be either * a system transliterator or a user transliterator or class. - * + * * @param ID the ID of the transliterator or class * @see #registerInstance */ void U_EXPORT2 Transliterator::unregister(const UnicodeString& ID) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { registry->remove(ID); @@ -1305,7 +1310,7 @@ void U_EXPORT2 Transliterator::unregister(const UnicodeString& ID) { */ int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) { int32_t retVal = 0; - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { retVal = registry->countAvailableIDs(); @@ -1321,12 +1326,12 @@ int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) { */ const UnicodeString& U_EXPORT2 Transliterator::getAvailableID(int32_t index) { const UnicodeString* result = NULL; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { result = ®istry->getAvailableID(index); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); U_ASSERT(result != NULL); // fail if no registry return *result; } @@ -1334,11 +1339,11 @@ const UnicodeString& U_EXPORT2 Transliterator::getAvailableID(int32_t index) { StringEnumeration* U_EXPORT2 Transliterator::getAvailableIDs(UErrorCode& ec) { if (U_FAILURE(ec)) return NULL; StringEnumeration* result = NULL; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { result = registry->getAvailableIDs(); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); if (result == NULL) { ec = U_INTERNAL_TRANSLITERATOR_ERROR; } @@ -1346,14 +1351,14 @@ StringEnumeration* U_EXPORT2 Transliterator::getAvailableIDs(UErrorCode& ec) { } int32_t U_EXPORT2 Transliterator::countAvailableSources(void) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableSources() : 0; } UnicodeString& U_EXPORT2 Transliterator::getAvailableSource(int32_t index, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableSource(index, result); @@ -1362,7 +1367,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableSource(int32_t index, } int32_t U_EXPORT2 Transliterator::countAvailableTargets(const UnicodeString& source) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableTargets(source) : 0; } @@ -1370,7 +1375,7 @@ int32_t U_EXPORT2 Transliterator::countAvailableTargets(const UnicodeString& sou UnicodeString& U_EXPORT2 Transliterator::getAvailableTarget(int32_t index, const UnicodeString& source, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableTarget(index, source, result); @@ -1380,7 +1385,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableTarget(int32_t index, int32_t U_EXPORT2 Transliterator::countAvailableVariants(const UnicodeString& source, const UnicodeString& target) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableVariants(source, target) : 0; } @@ -1389,7 +1394,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableVariant(int32_t index, const UnicodeString& source, const UnicodeString& target, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableVariant(index, source, target, result); @@ -1488,13 +1493,13 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { * is the ID of the system transliterator being defined. These * are public IDs enumerated by Transliterator.getAvailableIDs(), * unless the second field is "internal". - * + * * is a ResourceReader resource name. Currently these refer * to file names under com/ibm/text/resources. This string is passed * directly to ResourceReader, together with . - * + * * is either "FORWARD" or "REVERSE". - * + * * is a string to be passed directly to * Transliterator.getInstance(). The returned Transliterator object * then has its ID changed to and is returned. @@ -1533,10 +1538,10 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { // 'file' or 'internal'; // row[2]=resource, row[3]=direction { - + resString = ures_getStringByKey(res, "resource", &len, &status); UBool visible = (type == 0x0066 /*f*/); - UTransDirection dir = + UTransDirection dir = (ures_getUnicodeStringByKey(res, "direction", &status).charAt(0) == 0x0046 /*F*/) ? UTRANS_FORWARD : UTRANS_REVERSE; @@ -1562,7 +1567,7 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { // Manually add prototypes that the system knows about to the // cache. This is how new non-rule-based transliterators are // added to the system. - + // This is to allow for null pointer check NullTransliterator* tempNullTranslit = new NullTransliterator(); LowercaseTransliterator* tempLowercaseTranslit = new LowercaseTransliterator(); @@ -1576,7 +1581,7 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { #endif // Check for null pointers if (tempNullTranslit == NULL || tempLowercaseTranslit == NULL || tempUppercaseTranslit == NULL || - tempTitlecaseTranslit == NULL || tempUnicodeTranslit == NULL || + tempTitlecaseTranslit == NULL || tempUnicodeTranslit == NULL || #if !UCONFIG_NO_BREAK_ITERATION tempBreakTranslit == NULL || #endif diff --git a/deps/icu-small/source/i18n/transreg.cpp b/deps/icu-small/source/i18n/transreg.cpp index 032a73fd146559..c412a20079e72e 100644 --- a/deps/icu-small/source/i18n/transreg.cpp +++ b/deps/icu-small/source/i18n/transreg.cpp @@ -131,7 +131,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe, return 0; } if (compoundFilter != 0) - t->adoptFilter((UnicodeSet*)compoundFilter->clone()); + t->adoptFilter(compoundFilter->clone()); break; case COMPOUND: { @@ -173,8 +173,8 @@ Transliterator* TransliteratorAlias::create(UParseError& pe, if (U_SUCCESS(ec)) { t = new CompoundTransliterator(ID, transliterators, - (compoundFilter ? (UnicodeSet*)(compoundFilter->clone()) : 0), - anonymousRBTs, pe, ec); + (compoundFilter ? compoundFilter->clone() : nullptr), + anonymousRBTs, pe, ec); if (t == 0) { ec = U_MEMORY_ALLOCATION_ERROR; return 0; @@ -592,7 +592,7 @@ Transliterator* TransliteratorRegistry::reget(const UnicodeString& ID, if (entry->entryType == TransliteratorEntry::RULES_FORWARD || entry->entryType == TransliteratorEntry::RULES_REVERSE || entry->entryType == TransliteratorEntry::LOCALE_RULES) { - + if (parser.idBlockVector.isEmpty() && parser.dataVector.isEmpty()) { entry->u.data = 0; entry->entryType = TransliteratorEntry::ALIAS; @@ -946,7 +946,7 @@ void TransliteratorRegistry::registerEntry(const UnicodeString& ID, if (visible) { registerSTV(source, target, variant); if (!availableIDs.contains((void*) &ID)) { - UnicodeString *newID = (UnicodeString *)ID.clone(); + UnicodeString *newID = ID.clone(); // Check to make sure newID was created. if (newID != NULL) { // NUL-terminate the ID string @@ -1194,12 +1194,12 @@ TransliteratorEntry* TransliteratorRegistry::find(const UnicodeString& ID) { * Top-level find method. Attempt to find a source-target/variant in * either the dynamic or the static (locale resource) store. Perform * fallback. - * + * * Lookup sequence for ss_SS_SSS-tt_TT_TTT/v: * * ss_SS_SSS-tt_TT_TTT/v -- in hashtable * ss_SS_SSS-tt_TT_TTT/v -- in ss_SS_SSS (no fallback) - * + * * repeat with t = tt_TT_TTT, tt_TT, tt, and tscript * * ss_SS_SSS-t/ * @@ -1214,7 +1214,7 @@ TransliteratorEntry* TransliteratorRegistry::find(const UnicodeString& ID) { TransliteratorEntry* TransliteratorRegistry::find(UnicodeString& source, UnicodeString& target, UnicodeString& variant) { - + TransliteratorSpec src(source); TransliteratorSpec trg(target); TransliteratorEntry* entry; @@ -1232,13 +1232,13 @@ TransliteratorEntry* TransliteratorRegistry::find(UnicodeString& source, } if (variant.length() != 0) { - + // Seek exact match in hashtable entry = findInDynamicStore(src, trg, variant); if (entry != 0) { return entry; } - + // Seek exact match in locale resources entry = findInStaticStore(src, trg, variant); if (entry != 0) { @@ -1254,7 +1254,7 @@ TransliteratorEntry* TransliteratorRegistry::find(UnicodeString& source, if (entry != 0) { return entry; } - + // Seek match in locale resources entry = findInStaticStore(src, trg, NO_VARIANT); if (entry != 0) { @@ -1360,7 +1360,7 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID // we modify the registry with the parsed data and retry. { TransliteratorParser parser(status); - + // We use the file name, taken from another resource bundle // 2-d array at static init time, as a locale language. We're // just using the locale mechanism to map through to a file @@ -1369,7 +1369,7 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID //UResourceBundle *bundle = ures_openDirect(0, ch, &status); UnicodeString rules = entry->stringArg; //ures_close(bundle); - + //if (U_FAILURE(status)) { // We have a failure of some kind. Remove the ID from the // registry so we don't keep trying. NOTE: This will throw off @@ -1379,7 +1379,7 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID // or unrecoverable run time memory failures. // remove(ID); //} else { - + // If the status indicates a failure, then we don't have any // rules -- there is probably an installation error. The list // in the root locale should correspond to all the installed diff --git a/deps/icu-small/source/i18n/tridpars.cpp b/deps/icu-small/source/i18n/tridpars.cpp index cbfdf03c427850..65bfc880633a3c 100644 --- a/deps/icu-small/source/i18n/tridpars.cpp +++ b/deps/icu-small/source/i18n/tridpars.cpp @@ -50,10 +50,7 @@ static UInitOnce gSpecialInversesInitOnce = U_INITONCE_INITIALIZER; /** * The mutex controlling access to SPECIAL_INVERSES */ -static UMutex *LOCK() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex LOCK; TransliteratorIDParser::Specs::Specs(const UnicodeString& s, const UnicodeString& t, const UnicodeString& v, UBool sawS, @@ -156,10 +153,10 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos, single = specsToID(specsA, FORWARD); // Null pointers check if (b == NULL || single == NULL) { - delete b; - delete single; - status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + delete b; + delete single; + status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } single->canonID.append(OPEN_REV) .append(b->canonID).append(CLOSE_REV); @@ -172,10 +169,10 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos, single = specsToID(specsB, FORWARD); // Check for null pointer. if (a == NULL || single == NULL) { - delete a; - delete single; - status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + delete a; + delete single; + status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } single->canonID.append(OPEN_REV) .append(a->canonID).append(CLOSE_REV); @@ -196,8 +193,8 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos, } // Check for NULL pointer if (single == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } single->filter = specsA->filter; } @@ -297,6 +294,7 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i pos = ppos.getIndex(); if (withParens == 1 && !ICU_Utility::parseChar(id, pos, CLOSE_REV)) { + delete filter; pos = start; return NULL; } @@ -662,20 +660,20 @@ void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target, bidirectional = FALSE; } - Mutex lock(LOCK()); + Mutex lock(&LOCK); UnicodeString *tempus = new UnicodeString(inverseTarget); // Used for null pointer check before usage. if (tempus == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return; + status = U_MEMORY_ALLOCATION_ERROR; + return; } SPECIAL_INVERSES->put(target, tempus, status); if (bidirectional) { - tempus = new UnicodeString(target); - if (tempus == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return; - } + tempus = new UnicodeString(target); + if (tempus == NULL) { + status = U_MEMORY_ALLOCATION_ERROR; + return; + } SPECIAL_INVERSES->put(inverseTarget, tempus, status); } } @@ -866,9 +864,9 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st UnicodeString* inverseTarget; - umtx_lock(LOCK()); + umtx_lock(&LOCK); inverseTarget = (UnicodeString*) SPECIAL_INVERSES->get(specs.target); - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (inverseTarget != NULL) { // If the original ID contained "Any-" then make the @@ -913,8 +911,8 @@ void U_CALLCONV TransliteratorIDParser::init(UErrorCode &status) { SPECIAL_INVERSES = new Hashtable(TRUE, status); if (SPECIAL_INVERSES == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return; + status = U_MEMORY_ALLOCATION_ERROR; + return; } SPECIAL_INVERSES->setValueDeleter(uprv_deleteUObject); } diff --git a/deps/icu-small/source/i18n/tridpars.h b/deps/icu-small/source/i18n/tridpars.h index 3d657ed17c9784..5e42f068a47cd7 100644 --- a/deps/icu-small/source/i18n/tridpars.h +++ b/deps/icu-small/source/i18n/tridpars.h @@ -61,7 +61,7 @@ class TransliteratorIDParser /* not : public UObject because all methods are sta * 'sawSource' is true if there was an explicit source in the * parsed id. If there was no explicit source, then an implied * source of ANY is returned and 'sawSource' is set to false. - * + * * 'filter' is the parsed filter pattern, or null if there was no * filter. */ @@ -222,7 +222,7 @@ class TransliteratorIDParser /* not : public UObject because all methods are sta * @param source the given source. * @param target the given target. * @param variant the given variant - * @param isSourcePresent If TRUE then the source is present. + * @param isSourcePresent If TRUE then the source is present. * If the source is not present, ANY will be * given as the source, and isSourcePresent will be null * @return an array of 4 strings: source, target, variant, and diff --git a/deps/icu-small/source/i18n/tzfmt.cpp b/deps/icu-small/source/i18n/tzfmt.cpp index c948c5f5e7b07c..f87f0f67b13b12 100644 --- a/deps/icu-small/source/i18n/tzfmt.cpp +++ b/deps/icu-small/source/i18n/tzfmt.cpp @@ -19,12 +19,15 @@ #include "unicode/udat.h" #include "unicode/ustring.h" #include "unicode/utf16.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "tzgnames.h" #include "cmemory.h" #include "cstring.h" #include "putilimp.h" #include "uassert.h" #include "ucln_in.h" +#include "ulocimp.h" #include "umutex.h" #include "uresimp.h" #include "ureslocs.h" @@ -103,7 +106,7 @@ static const UChar ALT_GMT_STRINGS[][4] = { }; // Order of GMT offset pattern parsing, *_HMS must be evaluated first -// because *_HM is most likely a substring of *_HMS +// because *_HM is most likely a substring of *_HMS static const int32_t PARSE_GMT_OFFSET_TYPES[] = { UTZFMT_PAT_POSITIVE_HMS, UTZFMT_PAT_NEGATIVE_HMS, @@ -147,10 +150,7 @@ static icu::UInitOnce gZoneIdTrieInitOnce = U_INITONCE_INITIALIZER; static TextTrieMap *gShortZoneIdTrie = NULL; static icu::UInitOnce gShortZoneIdTrieInitOnce = U_INITONCE_INITIALIZER; -static UMutex *gLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gLock; U_CDECL_BEGIN /** @@ -296,7 +296,7 @@ inline uint8_t GMTOffsetField::getWidth() const { return fWidth; } - + inline const UChar* GMTOffsetField::getPatternText(void) const { return fText; @@ -316,7 +316,7 @@ U_CDECL_END // ------------------------------------------------------------------ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneFormat) -TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status) +TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status) : fLocale(locale), fTimeZoneNames(NULL), fTimeZoneGenericNames(NULL), fDefParseOptionFlags(0), fTZDBTimeZoneNames(NULL) { @@ -327,10 +327,13 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status) const char* region = fLocale.getCountry(); int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } - regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status); + regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status); if (U_SUCCESS(status)) { fTargetRegion[regionLen] = 0; } else { @@ -502,7 +505,7 @@ TimeZoneFormat::operator==(const Format& other) const { return isEqual; } -Format* +TimeZoneFormat* TimeZoneFormat::clone() const { return new TimeZoneFormat(*this); } @@ -552,7 +555,7 @@ TimeZoneFormat::getDefaultParseOptions(void) const { } -UnicodeString& +UnicodeString& TimeZoneFormat::getGMTPattern(UnicodeString& pattern) const { return pattern.setTo(fGMTPattern); } @@ -825,7 +828,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par int32_t offset; // Styles using localized GMT format as fallback - UBool fallbackLocalizedGMT = + UBool fallbackLocalizedGMT = (style == UTZFMT_STYLE_SPECIFIC_LONG || style == UTZFMT_STYLE_GENERIC_LONG || style == UTZFMT_STYLE_GENERIC_LOCATION); UBool fallbackShortLocalizedGMT = (style == UTZFMT_STYLE_SPECIFIC_SHORT || style == UTZFMT_STYLE_GENERIC_SHORT); @@ -1385,12 +1388,12 @@ TimeZoneFormat::getTimeZoneGenericNames(UErrorCode& status) const { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); if (fTimeZoneGenericNames == NULL) { TimeZoneFormat *nonConstThis = const_cast(this); nonConstThis->fTimeZoneGenericNames = TimeZoneGenericNames::createInstance(fLocale, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); return fTimeZoneGenericNames; } @@ -1401,7 +1404,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); if (fTZDBTimeZoneNames == NULL) { TZDBTimeZoneNames *tzdbNames = new TZDBTimeZoneNames(fLocale); if (tzdbNames == NULL) { @@ -1411,7 +1414,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const { nonConstThis->fTZDBTimeZoneNames = tzdbNames; } } - umtx_unlock(gLock()); + umtx_unlock(&gLock); return fTZDBTimeZoneNames; } @@ -1875,7 +1878,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t while (len > 0) { UChar32 ch; int32_t chLen; - U16_GET(patStr, 0, 0, len, ch) + U16_GET(patStr, 0, 0, len, ch); if (PatternProps::isWhiteSpace(ch)) { chLen = U16_LENGTH(ch); len -= chLen; @@ -2734,7 +2737,7 @@ class ZoneIdMatchHandler : public TextTrieMapSearchResultHandler { const UChar* fID; }; -ZoneIdMatchHandler::ZoneIdMatchHandler() +ZoneIdMatchHandler::ZoneIdMatchHandler() : fLen(0), fID(NULL) { } @@ -2800,7 +2803,7 @@ TimeZoneFormat::parseZoneID(const UnicodeString& text, ParsePosition& pos, Unico if (U_SUCCESS(status)) { LocalPointer handler(new ZoneIdMatchHandler()); - gZoneIdTrie->search(text, start, handler.getAlias(), status); + gZoneIdTrie->search(text, start, handler.getAlias(), status); len = handler->getMatchLen(); if (len > 0) { tzID.setTo(handler->getID(), -1); @@ -2850,7 +2853,7 @@ TimeZoneFormat::parseShortZoneID(const UnicodeString& text, ParsePosition& pos, if (U_SUCCESS(status)) { LocalPointer handler(new ZoneIdMatchHandler()); - gShortZoneIdTrie->search(text, start, handler.getAlias(), status); + gShortZoneIdTrie->search(text, start, handler.getAlias(), status); len = handler->getMatchLen(); if (len > 0) { tzID.setTo(handler->getID(), -1); diff --git a/deps/icu-small/source/i18n/tzgnames.cpp b/deps/icu-small/source/i18n/tzgnames.cpp index 4e3ecb4c6073b8..e056461dc30a63 100644 --- a/deps/icu-small/source/i18n/tzgnames.cpp +++ b/deps/icu-small/source/i18n/tzgnames.cpp @@ -21,12 +21,15 @@ #include "unicode/strenum.h" #include "unicode/vtzone.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" #include "mutex.h" #include "uhash.h" #include "uassert.h" #include "umutex.h" +#include "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -269,10 +272,7 @@ GNameSearchHandler::getMatches(int32_t& maxMatchLen) { return results; } -static UMutex *gLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gLock; class TZGNCore : public UMemory { public: @@ -412,10 +412,13 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) { const char* region = fLocale.getCountry(); int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } - regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status); + regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status); if (U_SUCCESS(status)) { fTargetRegion[regionLen] = 0; } else { @@ -488,11 +491,11 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID, UnicodeStri const UChar *locname = NULL; TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { locname = nonConstThis->getGenericLocationName(tzCanonicalID); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (locname == NULL) { name.setToBogus(); @@ -743,11 +746,11 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID, const UChar *uplname = NULL; TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { uplname = nonConstThis->getPartialLocationName(tzCanonicalID, mzID, isLong, mzDisplayName); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (uplname == NULL) { name.setToBogus(); @@ -1010,11 +1013,11 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (U_FAILURE(status)) { return NULL; @@ -1041,7 +1044,7 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE // All names are not yet loaded into the local trie. // Load all available names into the trie. This could be very heavy. - umtx_lock(gLock()); + umtx_lock(&gLock); { if (!fGNamesTrieFullyLoaded) { StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status); @@ -1063,18 +1066,18 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE } } } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (U_FAILURE(status)) { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); { // now try it again fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); results = handler.getMatches(maxLen); if (results != NULL && maxLen > 0) { @@ -1115,10 +1118,7 @@ typedef struct TZGNCoreRef { } TZGNCoreRef; // TZGNCore object cache handling -static UMutex *gTZGNLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gTZGNLock; static UHashtable *gTZGNCoreCache = NULL; static UBool gTZGNCoreCacheInitialized = FALSE; @@ -1184,13 +1184,13 @@ TimeZoneGenericNames::TimeZoneGenericNames() } TimeZoneGenericNames::~TimeZoneGenericNames() { - umtx_lock(gTZGNLock()); + umtx_lock(&gTZGNLock); { U_ASSERT(fRef->refCount > 0); // Just decrement the reference count fRef->refCount--; } - umtx_unlock(gTZGNLock()); + umtx_unlock(&gTZGNLock); } TimeZoneGenericNames* @@ -1206,7 +1206,7 @@ TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) { TZGNCoreRef *cacheEntry = NULL; { - Mutex lock(gTZGNLock()); + Mutex lock(&gTZGNLock); if (!gTZGNCoreCacheInitialized) { // Create empty hashtable @@ -1298,13 +1298,13 @@ TimeZoneGenericNames* TimeZoneGenericNames::clone() const { TimeZoneGenericNames* other = new TimeZoneGenericNames(); if (other) { - umtx_lock(gTZGNLock()); + umtx_lock(&gTZGNLock); { // Just increments the reference count fRef->refCount++; other->fRef = fRef; } - umtx_unlock(gTZGNLock()); + umtx_unlock(&gTZGNLock); } return other; } diff --git a/deps/icu-small/source/i18n/tzgnames.h b/deps/icu-small/source/i18n/tzgnames.h index bcdf0f399ba8a1..71d9d84dc0402f 100644 --- a/deps/icu-small/source/i18n/tzgnames.h +++ b/deps/icu-small/source/i18n/tzgnames.h @@ -10,7 +10,7 @@ #define __TZGNAMES_H /** - * \file + * \file * \brief C API: Time zone generic names classe */ diff --git a/deps/icu-small/source/i18n/tznames.cpp b/deps/icu-small/source/i18n/tznames.cpp index acd6aecdc0ce7e..d789c123630260 100644 --- a/deps/icu-small/source/i18n/tznames.cpp +++ b/deps/icu-small/source/i18n/tznames.cpp @@ -29,10 +29,7 @@ U_NAMESPACE_BEGIN // TimeZoneNames object cache handling -static UMutex *gTimeZoneNamesLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gTimeZoneNamesLock; static UHashtable *gTimeZoneNamesCache = NULL; static UBool gTimeZoneNamesCacheInitialized = FALSE; @@ -109,7 +106,7 @@ class TimeZoneNamesDelegate : public TimeZoneNames { virtual UBool operator==(const TimeZoneNames& other) const; virtual UBool operator!=(const TimeZoneNames& other) const {return !operator==(other);} - virtual TimeZoneNames* clone() const; + virtual TimeZoneNamesDelegate* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; @@ -135,7 +132,7 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate() } TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& status) { - Mutex lock(gTimeZoneNamesLock()); + Mutex lock(&gTimeZoneNamesLock); if (!gTimeZoneNamesCacheInitialized) { // Create empty hashtable if it is not already initialized. gTimeZoneNamesCache = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status); @@ -211,7 +208,7 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s } TimeZoneNamesDelegate::~TimeZoneNamesDelegate() { - umtx_lock(gTimeZoneNamesLock()); + umtx_lock(&gTimeZoneNamesLock); { if (fTZnamesCacheEntry) { U_ASSERT(fTZnamesCacheEntry->refCount > 0); @@ -219,7 +216,7 @@ TimeZoneNamesDelegate::~TimeZoneNamesDelegate() { fTZnamesCacheEntry->refCount--; } } - umtx_unlock(gTimeZoneNamesLock()); + umtx_unlock(&gTimeZoneNamesLock); } UBool @@ -236,17 +233,17 @@ TimeZoneNamesDelegate::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TimeZoneNamesDelegate* TimeZoneNamesDelegate::clone() const { TimeZoneNamesDelegate* other = new TimeZoneNamesDelegate(); if (other != NULL) { - umtx_lock(gTimeZoneNamesLock()); + umtx_lock(&gTimeZoneNamesLock); { // Just increment the reference count fTZnamesCacheEntry->refCount++; other->fTZnamesCacheEntry = fTZnamesCacheEntry; } - umtx_unlock(gTimeZoneNamesLock()); + umtx_unlock(&gTimeZoneNamesLock); } return other; } diff --git a/deps/icu-small/source/i18n/tznames_impl.cpp b/deps/icu-small/source/i18n/tznames_impl.cpp index d6e0ee2fbb637a..186aaaf74d0649 100644 --- a/deps/icu-small/source/i18n/tznames_impl.cpp +++ b/deps/icu-small/source/i18n/tznames_impl.cpp @@ -21,11 +21,14 @@ #include "unicode/utf16.h" #include "tznames_impl.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" #include "uassert.h" #include "mutex.h" #include "resource.h" +#include "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -49,10 +52,7 @@ static const UChar NO_NAME[] = { 0 }; // for empty no-fallback time static const char* TZDBNAMES_KEYS[] = {"ss", "sd"}; static const int32_t TZDBNAMES_KEYS_SIZE = UPRV_LENGTHOF(TZDBNAMES_KEYS); -static UMutex *gDataMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gDataMutex; static UHashtable* gTZDBNamesMap = NULL; static icu::UInitOnce gTZDBNamesMapInitOnce = U_INITONCE_INITIALIZER; @@ -174,7 +174,7 @@ TextTrieMapSearchResultHandler::~TextTrieMapSearchResultHandler(){ // TextTrieMap class implementation // --------------------------------------------------- TextTrieMap::TextTrieMap(UBool ignoreCase, UObjectDeleter *valueDeleter) -: fIgnoreCase(ignoreCase), fNodes(NULL), fNodesCapacity(0), fNodesCount(0), +: fIgnoreCase(ignoreCase), fNodes(NULL), fNodesCapacity(0), fNodesCount(0), fLazyContents(NULL), fIsEmpty(TRUE), fValueDeleter(valueDeleter) { } @@ -189,7 +189,7 @@ TextTrieMap::~TextTrieMap() { if (fValueDeleter) { fValueDeleter(fLazyContents->elementAt(i+1)); } - } + } delete fLazyContents; } } @@ -206,7 +206,7 @@ int32_t TextTrieMap::isEmpty() const { // We defer actually building the TextTrieMap node structure until the first time a // search is performed. put() simply saves the parameters in case we do // eventually need to build it. -// +// void TextTrieMap::put(const UnicodeString &key, void *value, ZNStringPool &sp, UErrorCode &status) { const UChar *s = sp.get(key, status); @@ -373,7 +373,7 @@ void TextTrieMap::buildTrie(UErrorCode &status) { putImpl(keyString, val, status); } delete fLazyContents; - fLazyContents = NULL; + fLazyContents = NULL; } } @@ -388,7 +388,7 @@ TextTrieMap::search(const UnicodeString &text, int32_t start, // Don't do unless it's really required. // Mutex for protecting the lazy creation of the Trie node structure on the first call to search(). - static UMutex TextTrieMutex = U_MUTEX_INITIALIZER; + static UMutex TextTrieMutex; Mutex lock(&TextTrieMutex); if (fLazyContents != NULL) { @@ -470,9 +470,9 @@ ZNStringPool::ZNStringPool(UErrorCode &status) { return; } - fHash = uhash_open(uhash_hashUChars /* keyHash */, - uhash_compareUChars /* keyComp */, - uhash_compareUChars /* valueComp */, + fHash = uhash_open(uhash_hashUChars /* keyHash */, + uhash_compareUChars /* keyComp */, + uhash_compareUChars /* valueComp */, &status); if (U_FAILURE(status)) { return; @@ -521,13 +521,13 @@ const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) { } fChunks->fNext = oldChunk; } - + UChar *destString = &fChunks->fStrings[fChunks->fLimit]; u_strcpy(destString, s); fChunks->fLimit += (length + 1); uhash_put(fHash, destString, destString, &status); return destString; -} +} // @@ -550,7 +550,7 @@ const UChar *ZNStringPool::adopt(const UChar * s, UErrorCode &status) { return s; } - + const UChar *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) { UnicodeString &nonConstStr = const_cast(s); return this->get(nonConstStr.getTerminatedBuffer(), status); @@ -870,11 +870,11 @@ class MetaZoneIDsEnumeration : public StringEnumeration { UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MetaZoneIDsEnumeration) -MetaZoneIDsEnumeration::MetaZoneIDsEnumeration() +MetaZoneIDsEnumeration::MetaZoneIDsEnumeration() : fLen(0), fPos(0), fMetaZoneIDs(NULL), fLocalVector(NULL) { } -MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(const UVector& mzIDs) +MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(const UVector& mzIDs) : fPos(0), fMetaZoneIDs(&mzIDs), fLocalVector(NULL) { fLen = fMetaZoneIDs->size(); } @@ -929,7 +929,7 @@ class ZNameSearchHandler : public TextTrieMapSearchResultHandler { TimeZoneNames::MatchInfoCollection* fResults; }; -ZNameSearchHandler::ZNameSearchHandler(uint32_t types) +ZNameSearchHandler::ZNameSearchHandler(uint32_t types) : fTypes(types), fMaxMatchLen(0), fResults(NULL) { } @@ -1113,7 +1113,7 @@ TimeZoneNamesImpl::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TimeZoneNamesImpl* TimeZoneNamesImpl::clone() const { UErrorCode status = U_ZERO_ERROR; return new TimeZoneNamesImpl(fLocale, status); @@ -1214,7 +1214,7 @@ TimeZoneNamesImpl::getMetaZoneDisplayName(const UnicodeString& mzID, TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; znames = nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return name; } @@ -1240,7 +1240,7 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1263,7 +1263,7 @@ TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeStr TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1358,7 +1358,7 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types // Synchronize so that data is not loaded multiple times. // TODO: Consider more fine-grained synchronization. { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); // First try of lookup. matches = doFind(handler, text, start, status); @@ -1585,7 +1585,7 @@ void TimeZoneNamesImpl::loadAllDisplayNames(UErrorCode& status) { if (U_FAILURE(status)) return; { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); internalLoadAllDisplayNames(status); } } @@ -1602,7 +1602,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, // Load the time zone strings { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); tznames = (void*) nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return; } } @@ -1622,7 +1622,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, } else { // Load the meta zone strings // Mutex is scoped to the "else" statement - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); mznames = (void*) nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return; } // Note: when the metazone doesn't exist, in Java, loadMetaZoneNames returns @@ -1901,7 +1901,7 @@ class TZDBNameSearchHandler : public TextTrieMapSearchResultHandler { const char* fRegion; }; -TZDBNameSearchHandler::TZDBNameSearchHandler(uint32_t types, const char* region) +TZDBNameSearchHandler::TZDBNameSearchHandler(uint32_t types, const char* region) : fTypes(types), fMaxMatchLen(0), fResults(NULL), fRegion(region) { } @@ -2135,9 +2135,12 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale) int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { UErrorCode status = U_ZERO_ERROR; - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); - regionLen = uloc_getCountry(loc, fRegion, sizeof(fRegion), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } + regionLen = uloc_getCountry(loc.data(), fRegion, sizeof(fRegion), &status); if (U_SUCCESS(status) && regionLen < (int32_t)sizeof(fRegion)) { useWorld = FALSE; } @@ -2162,7 +2165,7 @@ TZDBTimeZoneNames::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TZDBTimeZoneNames* TZDBTimeZoneNames::clone() const { return new TZDBTimeZoneNames(fLocale); } @@ -2247,7 +2250,7 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu U_ASSERT(status == U_ZERO_ERROR); // already checked length above mzIDKey[mzID.length()] = 0; - static UMutex gTZDBNamesMapLock = U_MUTEX_INITIALIZER; + static UMutex gTZDBNamesMapLock; umtx_lock(&gTZDBNamesMapLock); { void *cacheVal = uhash_get(gTZDBNamesMap, mzIDKey); diff --git a/deps/icu-small/source/i18n/tznames_impl.h b/deps/icu-small/source/i18n/tznames_impl.h index 4db036e7475e35..1286eeb80dc503 100644 --- a/deps/icu-small/source/i18n/tznames_impl.h +++ b/deps/icu-small/source/i18n/tznames_impl.h @@ -174,7 +174,7 @@ class TimeZoneNamesImpl : public TimeZoneNames { virtual ~TimeZoneNamesImpl(); virtual UBool operator==(const TimeZoneNames& other) const; - virtual TimeZoneNames* clone() const; + virtual TimeZoneNamesImpl* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; @@ -236,7 +236,7 @@ class TZDBTimeZoneNames : public TimeZoneNames { virtual ~TZDBTimeZoneNames(); virtual UBool operator==(const TimeZoneNames& other) const; - virtual TimeZoneNames* clone() const; + virtual TZDBTimeZoneNames* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; diff --git a/deps/icu-small/source/i18n/tzrule.cpp b/deps/icu-small/source/i18n/tzrule.cpp index f60a5e0dd59a6a..759a2d4c673235 100644 --- a/deps/icu-small/source/i18n/tzrule.cpp +++ b/deps/icu-small/source/i18n/tzrule.cpp @@ -108,7 +108,7 @@ InitialTimeZoneRule::~InitialTimeZoneRule() { } InitialTimeZoneRule* -InitialTimeZoneRule::clone(void) const { +InitialTimeZoneRule::clone() const { return new InitialTimeZoneRule(*this); } @@ -182,7 +182,7 @@ const int32_t AnnualTimeZoneRule::MAX_YEAR = 0x7FFFFFFF; /* max signed int32 */ AnnualTimeZoneRule::AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, - int32_t dstSavings, + int32_t dstSavings, const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear) @@ -192,7 +192,7 @@ AnnualTimeZoneRule::AnnualTimeZoneRule(const UnicodeString& name, AnnualTimeZoneRule::AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, - int32_t dstSavings, + int32_t dstSavings, DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear) @@ -440,7 +440,7 @@ TimeArrayTimeZoneRule::operator=(const TimeArrayTimeZoneRule& right) { UErrorCode status = U_ZERO_ERROR; initStartTimes(right.fStartTimes, right.fNumStartTimes, status); //TODO - status? - fTimeRuleType = right.fTimeRuleType; + fTimeRuleType = right.fTimeRuleType; } return *this; } @@ -626,3 +626,4 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ //eof + diff --git a/deps/icu-small/source/i18n/ucal.cpp b/deps/icu-small/source/i18n/ucal.cpp index 4154eea83f2fa9..927b2d369791bd 100644 --- a/deps/icu-small/source/i18n/ucal.cpp +++ b/deps/icu-small/source/i18n/ucal.cpp @@ -34,7 +34,7 @@ U_NAMESPACE_USE static TimeZone* _createTimeZone(const UChar* zoneID, int32_t len, UErrorCode* ec) { TimeZone* zone = NULL; - if (ec!=NULL && U_SUCCESS(*ec)) { + if (ec != NULL && U_SUCCESS(*ec)) { // Note that if zoneID is invalid, we get back GMT. This odd // behavior is by design and goes back to the JDK. The only // failure we will see is a memory allocation failure. @@ -69,7 +69,7 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec) { U_CAPI int32_t U_EXPORT2 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) { int32_t len = 0; - if (ec!=NULL && U_SUCCESS(*ec)) { + if (ec != NULL && U_SUCCESS(*ec)) { TimeZone* zone = TimeZone::createDefault(); if (zone == NULL) { *ec = U_MEMORY_ALLOCATION_ERROR; @@ -91,6 +91,23 @@ ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) { } } +U_DRAFT int32_t U_EXPORT2 +ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) { + int32_t len = 0; + if (ec != NULL && U_SUCCESS(*ec)) { + TimeZone *zone = TimeZone::detectHostTimeZone(); + if (zone == NULL) { + *ec = U_MEMORY_ALLOCATION_ERROR; + } else { + UnicodeString id; + zone->getID(id); + delete zone; + len = id.extract(result, resultCapacity, *ec); + } + } + return len; +} + U_CAPI int32_t U_EXPORT2 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) { int32_t result = 0; @@ -139,9 +156,9 @@ ucal_open( const UChar* zoneID, { if(U_FAILURE(*status)) return 0; - - TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault() - : _createTimeZone(zoneID, len, status); + + LocalPointer zone( (zoneID==NULL) ? TimeZone::createDefault() + : _createTimeZone(zoneID, len, status), *status); if (U_FAILURE(*status)) { return NULL; @@ -157,9 +174,9 @@ ucal_open( const UChar* zoneID, if (U_FAILURE(*status)) { return NULL; } - return (UCalendar*)Calendar::createInstance(zone, Locale(localeBuf), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(localeBuf), *status); } - return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(locale), *status); } U_CAPI void U_EXPORT2 @@ -169,12 +186,12 @@ ucal_close(UCalendar *cal) delete (Calendar*) cal; } -U_CAPI UCalendar* U_EXPORT2 +U_CAPI UCalendar* U_EXPORT2 ucal_clone(const UCalendar* cal, UErrorCode* status) { if(U_FAILURE(*status)) return 0; - + Calendar* res = ((Calendar*)cal)->clone(); if(res == 0) { @@ -259,7 +276,7 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal, } U_CAPI UBool U_EXPORT2 -ucal_inDaylightTime( const UCalendar* cal, +ucal_inDaylightTime( const UCalendar* cal, UErrorCode* status ) { @@ -546,7 +563,7 @@ ucal_getLimit( const UCalendar* cal, } U_CAPI const char * U_EXPORT2 -ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status) +ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status) { if (cal == NULL) { if (U_SUCCESS(*status)) { @@ -643,7 +660,7 @@ static const UEnumeration defaultKeywordValues = { ulist_close_keyword_values_iterator, ulist_count_keyword_values, uenum_unextDefault, - ulist_next_keyword_value, + ulist_next_keyword_value, ulist_reset_keyword_values_iterator }; @@ -674,7 +691,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool // Resolve region char prefRegion[ULOC_COUNTRY_CAPACITY]; (void)ulocimp_getRegionForSupplementalData(locale, TRUE, prefRegion, sizeof(prefRegion), status); - + // Read preferred calendar values from supplementalData calendarPreference UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", status); ures_getByKey(rb, "calendarPreferenceData", rb, status); @@ -744,7 +761,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool return en; } -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type, UDate* transition, UErrorCode* status) { diff --git a/deps/icu-small/source/i18n/ucln_in.cpp b/deps/icu-small/source/i18n/ucln_in.cpp index 74c8acfab13ea4..f29cbe41dde05f 100644 --- a/deps/icu-small/source/i18n/ucln_in.cpp +++ b/deps/icu-small/source/i18n/ucln_in.cpp @@ -62,3 +62,4 @@ void ucln_i18n_registerCleanup(ECleanupI18NType type, ucln_registerAutomaticCleanup(); #endif } + diff --git a/deps/icu-small/source/i18n/ucol.cpp b/deps/icu-small/source/i18n/ucol.cpp index 7d3392da223503..f59333ede3c890 100644 --- a/deps/icu-small/source/i18n/ucol.cpp +++ b/deps/icu-small/source/i18n/ucol.cpp @@ -369,7 +369,7 @@ ucol_getStrength(const UCollator *coll) return ucol_getAttribute(coll, UCOL_STRENGTH, &status); } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 ucol_getReorderCodes(const UCollator *coll, int32_t *dest, int32_t destCapacity, @@ -381,7 +381,7 @@ ucol_getReorderCodes(const UCollator *coll, return Collator::fromUCollator(coll)->getReorderCodes(dest, destCapacity, *status); } -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 ucol_setReorderCodes(UCollator* coll, const int32_t* reorderCodes, int32_t reorderCodesLength, @@ -393,7 +393,7 @@ ucol_setReorderCodes(UCollator* coll, Collator::fromUCollator(coll)->setReorderCodes(reorderCodes, reorderCodesLength, *status); } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 ucol_getEquivalentReorderCodes(int32_t reorderCode, int32_t* dest, int32_t destCapacity, diff --git a/deps/icu-small/source/i18n/ucol_sit.cpp b/deps/icu-small/source/i18n/ucol_sit.cpp index 765613084f84e1..43c1f5d6732888 100644 --- a/deps/icu-small/source/i18n/ucol_sit.cpp +++ b/deps/icu-small/source/i18n/ucol_sit.cpp @@ -140,7 +140,7 @@ ucol_sit_letterToAttributeValue(char letter, UErrorCode *status) { *status = U_ILLEGAL_ARGUMENT_ERROR; #ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: unknown letter %c: %s\n", __FILE__, __LINE__, letter, u_errorName(*status)); -#endif +#endif return UCOL_DEFAULT; } @@ -201,7 +201,7 @@ _processCollatorOption(CollatorSpec *spec, uint32_t option, const char* string, if((*(++string) != '_' && *string) || U_FAILURE(*status)) { #ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: unknown collator option at '%s': %s\n", __FILE__, __LINE__, string, u_errorName(*status)); -#endif +#endif *status = U_ILLEGAL_ARGUMENT_ERROR; } return string; @@ -227,7 +227,7 @@ readHexCodeUnit(const char **string, UErrorCode *status) *status = U_ILLEGAL_ARGUMENT_ERROR; #ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: Bad hex char at '%s': %s\n", __FILE__, __LINE__, *string, u_errorName(*status)); -#endif +#endif return 0; } result = (result << 4) | (UChar)value; @@ -239,7 +239,7 @@ readHexCodeUnit(const char **string, UErrorCode *status) *status = U_ILLEGAL_ARGUMENT_ERROR; #ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: Short (only %d digits, wanted 4) at '%s': %s\n", __FILE__, __LINE__, noDigits,*string, u_errorName(*status)); -#endif +#endif } return result; } diff --git a/deps/icu-small/source/i18n/ucoleitr.cpp b/deps/icu-small/source/i18n/ucoleitr.cpp index 6842061bab0912..596ce032956d0c 100644 --- a/deps/icu-small/source/i18n/ucoleitr.cpp +++ b/deps/icu-small/source/i18n/ucoleitr.cpp @@ -11,7 +11,7 @@ * Modification History: * * Date Name Description -* 02/15/2001 synwee Modified all methods to process its own function +* 02/15/2001 synwee Modified all methods to process its own function * instead of calling the equivalent c++ api (coleitr.h) * 2012-2014 markus Rewritten in C++ again. ******************************************************************************/ @@ -313,7 +313,7 @@ ucol_reset(UCollationElements *elems) } U_CAPI int32_t U_EXPORT2 -ucol_next(UCollationElements *elems, +ucol_next(UCollationElements *elems, UErrorCode *status) { if (U_FAILURE(*status)) { @@ -397,7 +397,7 @@ UCollationPCE::previousProcessed( // buffer raw CEs up to non-ignorable primary RCEBuffer rceb; int32_t ce; - + // **** do we need to reset rceb, or will it always be empty at this point **** do { high = cei->getOffset(); @@ -433,14 +433,14 @@ UCollationPCE::previousProcessed( finish: if (pceBuffer.isEmpty()) { // **** Is -1 the right value for ixLow, ixHigh? **** - if (ixLow != NULL) { - *ixLow = -1; - } - - if (ixHigh != NULL) { - *ixHigh = -1 - ; - } + if (ixLow != NULL) { + *ixLow = -1; + } + + if (ixHigh != NULL) { + *ixHigh = -1 + ; + } return UCOL_PROCESSED_NULLORDER; } @@ -511,19 +511,19 @@ ucol_setOffset(UCollationElements *elems, } U_CAPI int32_t U_EXPORT2 -ucol_primaryOrder (int32_t order) +ucol_primaryOrder (int32_t order) { return (order >> 16) & 0xffff; } U_CAPI int32_t U_EXPORT2 -ucol_secondaryOrder (int32_t order) +ucol_secondaryOrder (int32_t order) { return (order >> 8) & 0xff; } U_CAPI int32_t U_EXPORT2 -ucol_tertiaryOrder (int32_t order) +ucol_tertiaryOrder (int32_t order) { return order & 0xff; } diff --git a/deps/icu-small/source/i18n/udat.cpp b/deps/icu-small/source/i18n/udat.cpp index b7d85cc179ef9a..ab91bcff4127ce 100644 --- a/deps/icu-small/source/i18n/udat.cpp +++ b/deps/icu-small/source/i18n/udat.cpp @@ -167,9 +167,13 @@ udat_open(UDateFormatStyle timeStyle, } } - if(fmt == 0) { + if(fmt == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; - return 0; + return nullptr; + } + if (U_FAILURE(*status)) { + delete fmt; + return nullptr; } if(tzID != 0) { @@ -416,8 +420,8 @@ udat_setLenient( UDateFormat* fmt, } U_DRAFT UBool U_EXPORT2 -udat_getBooleanAttribute(const UDateFormat* fmt, - UDateFormatBooleanAttribute attr, +udat_getBooleanAttribute(const UDateFormat* fmt, + UDateFormatBooleanAttribute attr, UErrorCode* status) { if(U_FAILURE(*status)) return FALSE; @@ -426,9 +430,9 @@ udat_getBooleanAttribute(const UDateFormat* fmt, } U_DRAFT void U_EXPORT2 -udat_setBooleanAttribute(UDateFormat *fmt, - UDateFormatBooleanAttribute attr, - UBool newValue, +udat_setBooleanAttribute(UDateFormat *fmt, + UDateFormatBooleanAttribute attr, + UBool newValue, UErrorCode* status) { if(U_FAILURE(*status)) return; @@ -448,7 +452,7 @@ udat_setCalendar(UDateFormat* fmt, ((DateFormat*)fmt)->setCalendar(*((Calendar*)calendarToSet)); } -U_DRAFT const UNumberFormat* U_EXPORT2 +U_DRAFT const UNumberFormat* U_EXPORT2 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field) { UErrorCode status = U_ZERO_ERROR; @@ -463,7 +467,7 @@ udat_getNumberFormat(const UDateFormat* fmt) return (const UNumberFormat*) ((DateFormat*)fmt)->getNumberFormat(); } -U_DRAFT void U_EXPORT2 +U_DRAFT void U_EXPORT2 udat_adoptNumberFormatForFields( UDateFormat* fmt, const UChar* fields, UNumberFormat* numberFormatToSet, @@ -471,7 +475,7 @@ udat_adoptNumberFormatForFields( UDateFormat* fmt, { verifyIsSimpleDateFormat(fmt, status); if (U_FAILURE(*status)) return; - + if (fields!=NULL) { UnicodeString overrideFields(fields); ((SimpleDateFormat*)fmt)->adoptNumberFormat(overrideFields, (NumberFormat*)numberFormatToSet, *status); @@ -578,7 +582,7 @@ udat_applyPattern( UDateFormat *format, if(U_FAILURE(status)) { return; } - + if(localized) ((SimpleDateFormat*)format)->applyLocalizedPattern(pat, status); else @@ -1197,7 +1201,7 @@ udat_setSymbols( UDateFormat *format, default: *status = U_UNSUPPORTED_ERROR; break; - + } } @@ -1248,7 +1252,7 @@ static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *statu } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 udat_toPatternRelativeDate(const UDateFormat *fmt, UChar *result, int32_t resultLength, @@ -1273,7 +1277,7 @@ udat_toPatternRelativeDate(const UDateFormat *fmt, return datePattern.extract(result, resultLength, *status); } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 udat_toPatternRelativeTime(const UDateFormat *fmt, UChar *result, int32_t resultLength, @@ -1298,7 +1302,7 @@ udat_toPatternRelativeTime(const UDateFormat *fmt, return timePattern.extract(result, resultLength, *status); } -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 udat_applyPatternRelative(UDateFormat *format, const UChar *datePattern, int32_t datePatternLength, diff --git a/deps/icu-small/source/i18n/ulocdata.cpp b/deps/icu-small/source/i18n/ulocdata.cpp index f651fee6fc4efa..7f4e7b9b116e09 100644 --- a/deps/icu-small/source/i18n/ulocdata.cpp +++ b/deps/icu-small/source/i18n/ulocdata.cpp @@ -104,8 +104,8 @@ U_CAPI USet* U_EXPORT2 ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn, uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status){ - static const char* const exemplarSetTypes[] = { "ExemplarCharacters", - "AuxExemplarCharacters", + static const char* const exemplarSetTypes[] = { "ExemplarCharacters", + "AuxExemplarCharacters", "ExemplarCharactersIndex", "ExemplarCharactersPunctuation"}; const UChar *exemplarChars = NULL; @@ -195,15 +195,15 @@ static UResourceBundle * measurementTypeBundleForLocale(const char *localeID, co char region[ULOC_COUNTRY_CAPACITY]; UResourceBundle *rb; UResourceBundle *measTypeBundle = NULL; - + ulocimp_getRegionForSupplementalData(localeID, TRUE, region, ULOC_COUNTRY_CAPACITY, status); - + rb = ures_openDirect(NULL, "supplementalData", status); ures_getByKey(rb, "measurementData", rb, status); if (rb != NULL) { UResourceBundle *measDataBundle = ures_getByKey(rb, region, NULL, status); if (U_SUCCESS(*status)) { - measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status); + measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status); } if (*status == U_MISSING_RESOURCE_ERROR) { *status = U_ZERO_ERROR; diff --git a/deps/icu-small/source/i18n/umsg.cpp b/deps/icu-small/source/i18n/umsg.cpp index 2aae3a4d4393e3..9a5344e0191a8c 100644 --- a/deps/icu-small/source/i18n/umsg.cpp +++ b/deps/icu-small/source/i18n/umsg.cpp @@ -18,7 +18,7 @@ * * 08/5/2001 Ram Added C wrappers for C++ API. Changed implementation of old API's * Removed pattern parser. -* +* */ #include "unicode/utypes.h" @@ -67,7 +67,7 @@ u_formatMessage(const char *locale, ...) { va_list ap; - int32_t actLen; + int32_t actLen; //argument checking defered to subsequent method calls // start vararg processing va_start(ap, status); @@ -286,7 +286,7 @@ umsg_clone(const UMessageFormat *fmt, *status = U_MEMORY_ALLOCATION_ERROR; return 0; } - return retVal; + return retVal; } U_CAPI void U_EXPORT2 @@ -296,7 +296,7 @@ umsg_setLocale(UMessageFormat *fmt, const char* locale) if(fmt==NULL){ return; } - ((MessageFormat*)fmt)->setLocale(Locale(locale)); + ((MessageFormat*)fmt)->setLocale(Locale(locale)); } U_CAPI const char* U_EXPORT2 @@ -331,12 +331,12 @@ umsg_applyPattern(UMessageFormat *fmt, } // UnicodeString(pattern, -1) calls u_strlen(). - ((MessageFormat*)fmt)->applyPattern(UnicodeString(pattern,patternLength),*parseError,*status); + ((MessageFormat*)fmt)->applyPattern(UnicodeString(pattern,patternLength),*parseError,*status); } U_CAPI int32_t U_EXPORT2 umsg_toPattern(const UMessageFormat *fmt, - UChar* result, + UChar* result, int32_t resultLength, UErrorCode* status) { @@ -368,12 +368,12 @@ umsg_format( const UMessageFormat *fmt, ...) { va_list ap; - int32_t actLen; + int32_t actLen; //argument checking defered to last method call umsg_vformat which //saves time when arguments are valid and we dont care when arguments are not //since we return an error anyway - + // start vararg processing va_start(ap, status); @@ -411,7 +411,7 @@ umsg_vformat( const UMessageFormat *fmt, // iterate through the vararg list, and get the arguments out for(int32_t i = 0; i < count; ++i) { - + UChar *stringVal; double tDouble=0; int32_t tInt =0; @@ -422,12 +422,12 @@ umsg_vformat( const UMessageFormat *fmt, tempDate = va_arg(ap, UDate); args[i].setDate(tempDate); break; - + case Formattable::kDouble: tDouble =va_arg(ap, double); args[i].setDouble(tDouble); break; - + case Formattable::kLong: tInt = va_arg(ap, int32_t); args[i].setLong(tInt); @@ -437,7 +437,7 @@ umsg_vformat( const UMessageFormat *fmt, tInt64 = va_arg(ap, int64_t); args[i].setInt64(tInt64); break; - + case Formattable::kString: // For some reason, a temporary is needed stringVal = va_arg(ap, UChar*); @@ -447,7 +447,7 @@ umsg_vformat( const UMessageFormat *fmt, *status=U_ILLEGAL_ARGUMENT_ERROR; } break; - + case Formattable::kArray: // throw away this argument // this is highly platform-dependent, and probably won't work @@ -468,7 +468,7 @@ umsg_vformat( const UMessageFormat *fmt, } UnicodeString resultStr; FieldPosition fieldPosition(FieldPosition::DONT_CARE); - + /* format the message */ ((const MessageFormat*)fmt)->format(args,count,resultStr,fieldPosition,*status); @@ -613,7 +613,7 @@ umsg_vparse(const UMessageFormat *fmt, #define MAppend(c) if (len < destCapacity) dest[len++] = c; else len++ -int32_t umsg_autoQuoteApostrophe(const UChar* pattern, +int32_t umsg_autoQuoteApostrophe(const UChar* pattern, int32_t patternLength, UChar* dest, int32_t destCapacity, diff --git a/deps/icu-small/source/i18n/unesctrn.cpp b/deps/icu-small/source/i18n/unesctrn.cpp index fcce9528e2f3dc..0636fe1d149b60 100644 --- a/deps/icu-small/source/i18n/unesctrn.cpp +++ b/deps/icu-small/source/i18n/unesctrn.cpp @@ -85,9 +85,9 @@ static UChar* copySpec(const UChar* spec) { } ++len; UChar *result = (UChar *)uprv_malloc(len*sizeof(UChar)); - // Check for memory allocation error. + // Check for memory allocation error. if (result != NULL) { - uprv_memcpy(result, spec, (size_t)len*sizeof(result[0])); + uprv_memcpy(result, spec, (size_t)len*sizeof(result[0])); } return result; } @@ -164,7 +164,7 @@ UnescapeTransliterator::~UnescapeTransliterator() { /** * Transliterator API. */ -Transliterator* UnescapeTransliterator::clone() const { +UnescapeTransliterator* UnescapeTransliterator::clone() const { return new UnescapeTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/unesctrn.h b/deps/icu-small/source/i18n/unesctrn.h index e8e171f2bc4a69..57dd8d32cf53f3 100644 --- a/deps/icu-small/source/i18n/unesctrn.h +++ b/deps/icu-small/source/i18n/unesctrn.h @@ -77,7 +77,7 @@ class UnescapeTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual UnescapeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/uni2name.cpp b/deps/icu-small/source/i18n/uni2name.cpp index 86d7a4904a815e..41d5c931e4099e 100644 --- a/deps/icu-small/source/i18n/uni2name.cpp +++ b/deps/icu-small/source/i18n/uni2name.cpp @@ -60,7 +60,7 @@ UnicodeNameTransliterator::UnicodeNameTransliterator(const UnicodeNameTransliter /** * Transliterator API. */ -Transliterator* UnicodeNameTransliterator::clone(void) const { +UnicodeNameTransliterator* UnicodeNameTransliterator::clone() const { return new UnicodeNameTransliterator(*this); } @@ -87,7 +87,7 @@ void UnicodeNameTransliterator::handleTransliterate(Replaceable& text, UTransPos offsets.start = offsets.limit; return; } - + int32_t cursor = offsets.start; int32_t limit = offsets.limit; diff --git a/deps/icu-small/source/i18n/uni2name.h b/deps/icu-small/source/i18n/uni2name.h index 4d6eaa0a9a6b65..99309c8e0f8785 100644 --- a/deps/icu-small/source/i18n/uni2name.h +++ b/deps/icu-small/source/i18n/uni2name.h @@ -48,7 +48,7 @@ class UnicodeNameTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone(void) const; + virtual UnicodeNameTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/unicode/alphaindex.h b/deps/icu-small/source/i18n/unicode/alphaindex.h index dfb6110a36cf11..e3c68ea7cce9e2 100644 --- a/deps/icu-small/source/i18n/unicode/alphaindex.h +++ b/deps/icu-small/source/i18n/unicode/alphaindex.h @@ -13,6 +13,9 @@ #define INDEXCHARS_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/locid.h" #include "unicode/unistr.h" @@ -84,7 +87,7 @@ class UVector; * AlphabeticIndex supports the creation of a UI index appropriate for a given language. * It can support either direct use, or use with a client that doesn't support localized collation. * The following is an example of what an index might look like in a UI: - * + * *

      *  ... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  ...
      *
    @@ -306,17 +309,17 @@ class U_I18N_API AlphabeticIndex: public UObject {
          */
          AlphabeticIndex(const Locale &locale, UErrorCode &status);
     
    -   /**
    +   /** 
          * Construct an AlphabeticIndex that uses a specific collator.
    -     *
    +     * 
          * The index will be created with no labels; the addLabels() function must be called
          * after creation to add the desired labels to the index.
    -     *
    -     * The index adopts the collator, and is responsible for deleting it.
    +     * 
    +     * The index adopts the collator, and is responsible for deleting it. 
          * The caller should make no further use of the collator after creating the index.
    -     *
    +     * 
          * @param collator The collator to use to order the contents of this index.
    -     * @param status Error code, will be set with the reason if the
    +     * @param status Error code, will be set with the reason if the 
          *               operation fails.
          * @stable ICU 51
          */
    @@ -327,7 +330,7 @@ class U_I18N_API AlphabeticIndex: public UObject {
          * that are already in the index; they do not replace the existing
          * ones.
          * @param additions The additional characters to add to the index, such as A-Z.
    -     * @param status Error code, will be set with the reason if the
    +     * @param status Error code, will be set with the reason if the 
          *               operation fails.
          * @return this, for chaining
          * @stable ICU 4.8
    @@ -342,7 +345,7 @@ class U_I18N_API AlphabeticIndex: public UObject {
          * when creating this Index.
          *
          * @param locale The locale whose index characters are to be added.
    -     * @param status Error code, will be set with the reason if the
    +     * @param status Error code, will be set with the reason if the 
          *               operation fails.
          * @return this, for chaining
          * @stable ICU 4.8
    @@ -757,4 +760,7 @@ class U_I18N_API AlphabeticIndex: public UObject {
     U_NAMESPACE_END
     
     #endif  // !UCONFIG_NO_COLLATION
    +
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif
    diff --git a/deps/icu-small/source/i18n/unicode/basictz.h b/deps/icu-small/source/i18n/unicode/basictz.h
    index eb62abaf0a679c..c4d08768987d69 100644
    --- a/deps/icu-small/source/i18n/unicode/basictz.h
    +++ b/deps/icu-small/source/i18n/unicode/basictz.h
    @@ -10,12 +10,14 @@
     #define BASICTZ_H
     
     /**
    - * \file
    + * \file 
      * \brief C++ API: ICU TimeZone base class
      */
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_FORMATTING
     
     #include "unicode/timezone.h"
    @@ -41,6 +43,14 @@ class U_I18N_API BasicTimeZone: public TimeZone {
          */
         virtual ~BasicTimeZone();
     
    +    /**
    +     * Clones this object polymorphically.
    +     * The caller owns the result and should delete it when done.
    +     * @return clone, or nullptr if an error occurred
    +     * @stable ICU 3.8
    +     */
    +    virtual BasicTimeZone* clone() const = 0;
    +
         /**
          * Gets the first time zone transition after the base time.
          * @param base      The base time.
    @@ -211,6 +221,8 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // BASICTZ_H
     
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/calendar.h b/deps/icu-small/source/i18n/unicode/calendar.h
    index 023cf053f254fb..2a8c2935ca8e24 100644
    --- a/deps/icu-small/source/i18n/unicode/calendar.h
    +++ b/deps/icu-small/source/i18n/unicode/calendar.h
    @@ -29,6 +29,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Calendar object
    @@ -184,7 +186,7 @@ class BasicTimeZone;
      */
     class U_I18N_API Calendar : public UObject {
     public:
    -
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
          * specific. Example ranges given are for illustration only; see specific Calendar
    @@ -227,6 +229,7 @@ class U_I18N_API Calendar : public UObject {
             FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
     #endif /* U_HIDE_DEPRECATED_API */
         };
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
     #ifndef U_HIDE_DEPRECATED_API
         /**
    @@ -287,7 +290,7 @@ class U_I18N_API Calendar : public UObject {
          * @return    a polymorphic copy of this calendar.
          * @stable ICU 2.0
          */
    -    virtual Calendar* clone(void) const = 0;
    +    virtual Calendar* clone() const = 0;
     
         /**
          * Creates a Calendar using the default timezone and locale. Clients are responsible
    @@ -518,6 +521,7 @@ class U_I18N_API Calendar : public UObject {
          */
         UBool after(const Calendar& when, UErrorCode& status) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
          * time field, based on the calendar's rules. For example, to subtract 5 days from
    @@ -539,6 +543,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
          */
         virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
    @@ -632,6 +637,7 @@ class U_I18N_API Calendar : public UObject {
          */
         inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Time Field Rolling function. Rolls by the given amount on the given
          * time field. For example, to roll the current date up by one day, call
    @@ -664,6 +670,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
          */
         virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Time Field Rolling function. Rolls by the given amount on the given
    @@ -698,6 +705,7 @@ class U_I18N_API Calendar : public UObject {
          */
         virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Return the difference between the given time and the time this
          * calendar object is set to.  If this calendar is set
    @@ -754,6 +762,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
          */
         virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Return the difference between the given time and the time this
    @@ -1010,6 +1019,7 @@ class U_I18N_API Calendar : public UObject {
          */
         uint8_t getMinimalDaysInFirstWeek(void) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Gets the minimum value for the given time field. e.g., for Gregorian
          * DAY_OF_MONTH, 1.
    @@ -1019,6 +1029,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
          */
         virtual int32_t getMinimum(EDateFields field) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Gets the minimum value for the given time field. e.g., for Gregorian
    @@ -1030,6 +1041,7 @@ class U_I18N_API Calendar : public UObject {
          */
         virtual int32_t getMinimum(UCalendarDateFields field) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
          * 31.
    @@ -1039,6 +1051,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
          */
         virtual int32_t getMaximum(EDateFields field) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
    @@ -1050,6 +1063,7 @@ class U_I18N_API Calendar : public UObject {
          */
         virtual int32_t getMaximum(UCalendarDateFields field) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Gets the highest minimum value for the given field if varies. Otherwise same as
          * getMinimum(). For Gregorian, no difference.
    @@ -1059,6 +1073,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
          */
         virtual int32_t getGreatestMinimum(EDateFields field) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Gets the highest minimum value for the given field if varies. Otherwise same as
    @@ -1070,6 +1085,7 @@ class U_I18N_API Calendar : public UObject {
          */
         virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Gets the lowest maximum value for the given field if varies. Otherwise same as
          * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
    @@ -1079,6 +1095,7 @@ class U_I18N_API Calendar : public UObject {
          * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
          */
         virtual int32_t getLeastMaximum(EDateFields field) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Gets the lowest maximum value for the given field if varies. Otherwise same as
    @@ -1895,11 +1912,13 @@ class U_I18N_API Calendar : public UObject {
          */
         int32_t     fFields[UCAL_FIELD_COUNT];
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * The flags which tell if a specified time field for the calendar is set.
          * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
          */
         UBool      fIsSet[UCAL_FIELD_COUNT];
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /** Special values of stamp[]
          * @stable ICU 2.0
    @@ -2281,7 +2300,6 @@ class U_I18N_API Calendar : public UObject {
          * should only be called if this calendar is not lenient.
          * @see #isLenient
          * @see #validateField(int, int&)
    -     * @internal
          */
         void validateFields(UErrorCode &status);
     
    @@ -2291,7 +2309,6 @@ class U_I18N_API Calendar : public UObject {
          * U_ILLEGAL_ARGUMENT_ERROR will be set.  Subclasses may
          * use this method in their implementation of {@link
          * #validateField(int, int&)}.
    -     * @internal
          */
         void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
     
    @@ -2529,4 +2546,6 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _CALENDAR
    diff --git a/deps/icu-small/source/i18n/unicode/choicfmt.h b/deps/icu-small/source/i18n/unicode/choicfmt.h
    index c9f0f1114f89ed..3b2f48cb1f853c 100644
    --- a/deps/icu-small/source/i18n/unicode/choicfmt.h
    +++ b/deps/icu-small/source/i18n/unicode/choicfmt.h
    @@ -26,13 +26,14 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Choice Format.
      */
     
     #if !UCONFIG_NO_FORMATTING
    -#ifndef U_HIDE_DEPRECATED_API
     
     #include "unicode/fieldpos.h"
     #include "unicode/format.h"
    @@ -40,6 +41,8 @@
     #include "unicode/numfmt.h"
     #include "unicode/unistr.h"
     
    +#ifndef U_HIDE_DEPRECATED_API
    +
     U_NAMESPACE_BEGIN
     
     class MessageFormat;
    @@ -248,7 +251,7 @@ class U_I18N_API ChoiceFormat: public NumberFormat {
          * @return a copy of this object
          * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
          */
    -    virtual Format* clone(void) const;
    +    virtual ChoiceFormat* clone() const;
     
         /**
          * Returns true if the given Format objects are semantically equal.
    @@ -592,5 +595,7 @@ U_NAMESPACE_END
     #endif  // U_HIDE_DEPRECATED_API
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // CHOICFMT_H
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/coleitr.h b/deps/icu-small/source/i18n/unicode/coleitr.h
    index bf0e1d51a41833..e3ec0e01a18ec3 100644
    --- a/deps/icu-small/source/i18n/unicode/coleitr.h
    +++ b/deps/icu-small/source/i18n/unicode/coleitr.h
    @@ -8,7 +8,7 @@
      */
     
     /**
    - * \file
    + * \file 
      * \brief C++ API: Collation Element Iterator.
      */
     
    @@ -25,7 +25,7 @@
     * 08/03/98    erm         Synched with 1.2 version CollationElementIterator.java
     * 12/10/99    aliu        Ported Thai collation support from Java.
     * 01/25/01    swquek      Modified into a C++ wrapper calling C APIs (ucoliter.h)
    -* 02/19/01    swquek      Removed CollationElementsIterator() since it is
    +* 02/19/01    swquek      Removed CollationElementsIterator() since it is 
     *                         private constructor and no calls are made to it
     * 2012-2014   markus      Rewritten in C++ again.
     */
    @@ -35,6 +35,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_COLLATION
     
     #include "unicode/unistr.h"
    @@ -54,10 +56,10 @@ class UCollationPCE;
     class UVector32;
     
     /**
    -* The CollationElementIterator class is used as an iterator to walk through
    +* The CollationElementIterator class is used as an iterator to walk through     
     * each character of an international string. Use the iterator to return the
    -* ordering priority of the positioned character. The ordering priority of a
    -* character, which we refer to as a key, defines how a character is collated in
    +* ordering priority of the positioned character. The ordering priority of a 
    +* character, which we refer to as a key, defines how a character is collated in 
     * the given collation object.
     * For example, consider the following in Slovak and in traditional Spanish collation:
     * 
    @@ -67,9 +69,9 @@ class UVector32;
     * 
     \htmlonly       "æb"-> the first key is key('a'), the second key is key('e'), and
     *        the third key is key('b'). \endhtmlonly 
    * The key of a character, is an integer composed of primary order(short), -* secondary order(char), and tertiary order(char). Java strictly defines the +* secondary order(char), and tertiary order(char). Java strictly defines the * size and signedness of its primitive data types. Therefore, the static -* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return +* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return * int32_t to ensure the correctness of the key value. *

    Example of the iterator usage: (without error checking) *

    @@ -95,8 +97,8 @@ class UVector32;
     * the comparison level of the collator. The method previous() returns the
     * collation order of the previous character based on the comparison level of
     * the collator. The Collation Element Iterator moves only in one direction
    -* between calls to reset(), setOffset(), or setText(). That is, next()
    -* and previous() can not be inter-used. Whenever previous() is to be called after
    +* between calls to reset(), setOffset(), or setText(). That is, next() 
    +* and previous() can not be inter-used. Whenever previous() is to be called after 
     * next() or vice versa, reset(), setOffset() or setText() has to be called first
     * to reset the status, shifting pointers to either the end or the start of
     * the string (reset() or setText()), or the specified position (setOffset()).
    @@ -107,9 +109,9 @@ class UVector32;
     * The result of a forward iterate (next()) and reversed result of the backward
     * iterate (previous()) on the same string are equivalent, if collation orders
     * with the value 0 are ignored.
    -* Character based on the comparison level of the collator.  A collation order
    -* consists of primary order, secondary order and tertiary order.  The data
    -* type of the collation order is int32_t.
    +* Character based on the comparison level of the collator.  A collation order 
    +* consists of primary order, secondary order and tertiary order.  The data 
    +* type of the collation order is int32_t. 
     *
     * Note, CollationElementIterator should not be subclassed.
     * @see     Collator
    @@ -117,7 +119,7 @@ class UVector32;
     * @version 1.8 Jan 16 2001
     */
     class U_I18N_API CollationElementIterator U_FINAL : public UObject {
    -public:
    +public: 
     
         // CollationElementIterator public data member ------------------------------
     
    @@ -139,7 +141,7 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         */
         CollationElementIterator(const CollationElementIterator& other);
     
    -    /**
    +    /** 
         * Destructor
         * @stable ICU 2.0
         */
    @@ -174,7 +176,7 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         /**
         * Gets the ordering priority of the next character in the string.
         * @param status the error code status.
    -    * @return the next character's ordering. otherwise returns NULLORDER if an
    +    * @return the next character's ordering. otherwise returns NULLORDER if an 
         *         error has occured or if the end of string has been reached
         * @stable ICU 2.0
         */
    @@ -183,7 +185,7 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         /**
         * Get the ordering priority of the previous collation element in the string.
         * @param status the error code status.
    -    * @return the previous element's ordering. otherwise returns NULLORDER if an
    +    * @return the previous element's ordering. otherwise returns NULLORDER if an 
         *         error has occured or if the start of string has been reached
         * @stable ICU 2.0
         */
    @@ -214,11 +216,11 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         static inline int32_t tertiaryOrder(int32_t order);
     
         /**
    -    * Return the maximum length of any expansion sequences that end with the
    +    * Return the maximum length of any expansion sequences that end with the 
         * specified comparison order.
         * @param order a collation order returned by previous or next.
    -    * @return maximum size of the expansion sequences ending with the collation
    -    *         element or 1 if collation element does not occur at the end of any
    +    * @return maximum size of the expansion sequences ending with the collation 
    +    *         element or 1 if collation element does not occur at the end of any 
         *         expansion sequence
         * @stable ICU 2.0
         */
    @@ -310,9 +312,9 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         friend class UCollationPCE;
     
         /**
    -    * CollationElementIterator constructor. This takes the source string and the
    -    * collation object. The cursor will walk thru the source string based on the
    -    * predefined collation rules. If the source string is empty, NULLORDER will
    +    * CollationElementIterator constructor. This takes the source string and the 
    +    * collation object. The cursor will walk thru the source string based on the 
    +    * predefined collation rules. If the source string is empty, NULLORDER will 
         * be returned on the calls to next().
         * @param sourceText    the source string.
         * @param order         the collation object.
    @@ -330,9 +332,9 @@ class U_I18N_API CollationElementIterator U_FINAL : public UObject {
         // but only contain the part of RBC== related to data and rules.
     
         /**
    -    * CollationElementIterator constructor. This takes the source string and the
    -    * collation object.  The cursor will walk thru the source string based on the
    -    * predefined collation rules.  If the source string is empty, NULLORDER will
    +    * CollationElementIterator constructor. This takes the source string and the 
    +    * collation object.  The cursor will walk thru the source string based on the 
    +    * predefined collation rules.  If the source string is empty, NULLORDER will 
         * be returned on the calls to next().
         * @param sourceText    the source string.
         * @param order         the collation object.
    @@ -404,4 +406,6 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_COLLATION */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif
    diff --git a/deps/icu-small/source/i18n/unicode/coll.h b/deps/icu-small/source/i18n/unicode/coll.h
    index 653434f54ca664..f5564c73944bcb 100644
    --- a/deps/icu-small/source/i18n/unicode/coll.h
    +++ b/deps/icu-small/source/i18n/unicode/coll.h
    @@ -54,6 +54,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_COLLATION
     
     #include "unicode/uobject.h"
    @@ -204,6 +206,7 @@ class U_I18N_API Collator : public UObject {
     
         // Cannot use #ifndef U_HIDE_DEPRECATED_API for the following, it is
         // used by virtual methods that cannot have that conditional.
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * LESS is returned if source string is compared to be less than target
          * string in the compare() method.
    @@ -220,6 +223,7 @@ class U_I18N_API Collator : public UObject {
             EQUAL = UCOL_EQUAL,  // 0
             GREATER = UCOL_GREATER  // 1
         };
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         // Collator public destructor -----------------------------------------
     
    @@ -265,7 +269,7 @@ class U_I18N_API Collator : public UObject {
          * @return a copy of this object, owned by the caller
          * @stable ICU 2.0
          */
    -    virtual Collator* clone(void) const = 0;
    +    virtual Collator* clone() const = 0;
     
         /**
          * Creates the Collator object for the current default locale.
    @@ -323,6 +327,7 @@ class U_I18N_API Collator : public UObject {
          */
         static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * The comparison function compares the character data stored in two
          * different strings. Returns information about whether a string is less
    @@ -336,6 +341,7 @@ class U_I18N_API Collator : public UObject {
          */
         virtual EComparisonResult compare(const UnicodeString& source,
                                           const UnicodeString& target) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * The comparison function compares the character data stored in two
    @@ -353,6 +359,7 @@ class U_I18N_API Collator : public UObject {
                                           const UnicodeString& target,
                                           UErrorCode &status) const = 0;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Does the same thing as compare but limits the comparison to a specified
          * length
    @@ -368,6 +375,7 @@ class U_I18N_API Collator : public UObject {
         virtual EComparisonResult compare(const UnicodeString& source,
                                           const UnicodeString& target,
                                           int32_t length) const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Does the same thing as compare but limits the comparison to a specified
    @@ -387,6 +395,7 @@ class U_I18N_API Collator : public UObject {
                                           int32_t length,
                                           UErrorCode &status) const = 0;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * The comparison function compares the character data stored in two
          * different string arrays. Returns information about whether a string array
    @@ -423,6 +432,7 @@ class U_I18N_API Collator : public UObject {
         virtual EComparisonResult compare(const char16_t* source, int32_t sourceLength,
                                           const char16_t* target, int32_t targetLength)
                                           const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * The comparison function compares the character data stored in two
    @@ -527,6 +537,7 @@ class U_I18N_API Collator : public UObject {
          */
         virtual int32_t hashCode(void) const = 0;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Gets the locale of the Collator
          *
    @@ -540,6 +551,7 @@ class U_I18N_API Collator : public UObject {
          * in ICU 3.0.
          */
         virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Convenience method for comparing two strings based on the collation rules.
    @@ -576,6 +588,7 @@ class U_I18N_API Collator : public UObject {
          */
         UBool equals(const UnicodeString& source, const UnicodeString& target) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Determines the minimum strength that will be used in comparison or
          * transformation.
    @@ -607,6 +620,7 @@ class U_I18N_API Collator : public UObject {
          * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead
          */
         virtual void setStrength(ECollationStrength newStrength);
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Retrieves the reordering codes for this collator.
    @@ -904,6 +918,7 @@ class U_I18N_API Collator : public UObject {
          */
         virtual UColReorderCode getMaxVariable() const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Sets the variable top to the primary weight of the specified string.
          *
    @@ -951,6 +966,7 @@ class U_I18N_API Collator : public UObject {
          * @deprecated ICU 53 Call setMaxVariable() instead.
          */
         virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Gets the variable top value of a Collator.
    @@ -972,6 +988,7 @@ class U_I18N_API Collator : public UObject {
          */
         virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Same as clone().
          * The base class implementation simply calls clone().
    @@ -979,7 +996,8 @@ class U_I18N_API Collator : public UObject {
          * @see clone()
          * @deprecated ICU 50 no need to have two methods for cloning
          */
    -    virtual Collator* safeClone(void) const;
    +    virtual Collator* safeClone() const;
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Get the sort key as an array of bytes from a UnicodeString.
    @@ -1271,4 +1289,6 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_COLLATION */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif
    diff --git a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
    index 9c1e9183f4657b..9c1e2009969279 100644
    --- a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
    +++ b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
    @@ -14,6 +14,9 @@
     #define __COMPACT_DECIMAL_FORMAT_H__
     
     #include "unicode/utypes.h"
    +
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Compatibility APIs for compact decimal number formatting.
    @@ -102,7 +105,7 @@ class U_I18N_API CompactDecimalFormat : public DecimalFormat {
          * @return    a polymorphic copy of this CompactDecimalFormat.
          * @stable ICU 51
          */
    -    Format* clone() const U_OVERRIDE;
    +    CompactDecimalFormat* clone() const U_OVERRIDE;
     
         using DecimalFormat::format;
     
    @@ -187,5 +190,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // __COMPACT_DECIMAL_FORMAT_H__
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/curramt.h b/deps/icu-small/source/i18n/unicode/curramt.h
    index 03ec856e3bf585..5cfe1cf75e6adc 100644
    --- a/deps/icu-small/source/i18n/unicode/curramt.h
    +++ b/deps/icu-small/source/i18n/unicode/curramt.h
    @@ -15,16 +15,18 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_FORMATTING
     
     #include "unicode/measure.h"
     #include "unicode/currunit.h"
     
     /**
    - * \file
    + * \file 
      * \brief C++ API: Currency Amount Object.
      */
    -
    + 
     U_NAMESPACE_BEGIN
     
     /**
    @@ -67,7 +69,7 @@ class U_I18N_API CurrencyAmount: public Measure {
          * @stable ICU 3.0
          */
         CurrencyAmount(const CurrencyAmount& other);
    -
    + 
         /**
          * Assignment operator
          * @stable ICU 3.0
    @@ -79,14 +81,14 @@ class U_I18N_API CurrencyAmount: public Measure {
          * have the same class as returned by getDynamicClassID().
          * @stable ICU 3.0
          */
    -    virtual UObject* clone() const;
    +    virtual CurrencyAmount* clone() const;
     
         /**
          * Destructor
          * @stable ICU 3.0
          */
         virtual ~CurrencyAmount();
    -
    +    
         /**
          * Returns a unique class ID for this object POLYMORPHICALLY.
          * This method implements a simple form of RTTI used by ICU.
    @@ -129,4 +131,7 @@ inline const char16_t* CurrencyAmount::getISOCurrency() const {
     U_NAMESPACE_END
     
     #endif // !UCONFIG_NO_FORMATTING
    +
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // __CURRENCYAMOUNT_H__
    diff --git a/deps/icu-small/source/i18n/unicode/currpinf.h b/deps/icu-small/source/i18n/unicode/currpinf.h
    index 80b046251323e9..fb0b2a7dbc0b8b 100644
    --- a/deps/icu-small/source/i18n/unicode/currpinf.h
    +++ b/deps/icu-small/source/i18n/unicode/currpinf.h
    @@ -11,6 +11,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Currency Plural Information used by Decimal Format
    @@ -27,13 +29,13 @@ class PluralRules;
     class Hashtable;
     
     /**
    - * This class represents the information needed by
    - * DecimalFormat to format currency plural,
    - * such as "3.00 US dollars" or "1.00 US dollar".
    + * This class represents the information needed by 
    + * DecimalFormat to format currency plural, 
    + * such as "3.00 US dollars" or "1.00 US dollar". 
      * DecimalFormat creates for itself an instance of
    - * CurrencyPluralInfo from its locale data.
    + * CurrencyPluralInfo from its locale data.  
      * If you need to change any of these symbols, you can get the
    - * CurrencyPluralInfo object from your
    + * CurrencyPluralInfo object from your 
      * DecimalFormat and modify it.
      *
      * Following are the information needed for currency plural format and parse:
    @@ -59,7 +61,7 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
          * @param status output param set to success/failure code on exit
          * @stable ICU 4.2
          */
    -    CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
    +    CurrencyPluralInfo(const Locale& locale, UErrorCode& status); 
     
         /**
          * Copy constructor
    @@ -118,7 +120,7 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
         const PluralRules* getPluralRules() const;
     
         /**
    -     * Given a plural count, gets currency plural pattern of this locale,
    +     * Given a plural count, gets currency plural pattern of this locale, 
          * used for currency plural format
          *
          * @param  pluralCount currency plural count
    @@ -127,10 +129,10 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
          * @stable ICU 4.2
          */
         UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
    -                                            UnicodeString& result) const;
    +                                            UnicodeString& result) const; 
     
         /**
    -     * Get locale
    +     * Get locale 
          *
          * @return locale
          * @stable ICU 4.2
    @@ -155,16 +157,16 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
          * Set currency plural pattern.
          * The currency plural pattern is set when CurrencyPluralInfo
          * instance is created.
    -     * You can call this method to reset currency plural pattern only if
    +     * You can call this method to reset currency plural pattern only if 
          * you want to modify the default currency plural pattern of the locale.
          *
    -     * @param pluralCount the plural count for which the currency pattern will
    +     * @param pluralCount the plural count for which the currency pattern will 
          *                    be overridden.
          * @param pattern     the new currency plural pattern
          * @param status      output param set to success/failure code on exit
          * @stable ICU 4.2
          */
    -    void setCurrencyPluralPattern(const UnicodeString& pluralCount,
    +    void setCurrencyPluralPattern(const UnicodeString& pluralCount, 
                                       const UnicodeString& pattern,
                                       UErrorCode& status);
     
    @@ -196,7 +198,7 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
         friend class DecimalFormatImpl;
     
         void initialize(const Locale& loc, UErrorCode& status);
    -
    +   
         void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
     
         /*
    @@ -260,11 +262,13 @@ class  U_I18N_API CurrencyPluralInfo : public UObject {
     inline UBool
     CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {
         return !operator==(info);
    -}
    +}  
     
     U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _CURRPINFO
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/currunit.h b/deps/icu-small/source/i18n/unicode/currunit.h
    index 63739c37fd569b..d536e2fc031dbb 100644
    --- a/deps/icu-small/source/i18n/unicode/currunit.h
    +++ b/deps/icu-small/source/i18n/unicode/currunit.h
    @@ -15,15 +15,17 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_FORMATTING
     
     #include "unicode/measunit.h"
     
     /**
    - * \file
    + * \file 
      * \brief C++ API: Currency Unit Information.
      */
    -
    + 
     U_NAMESPACE_BEGIN
     
     /**
    @@ -94,7 +96,7 @@ class U_I18N_API CurrencyUnit: public MeasureUnit {
          * have the same class as returned by getDynamicClassID().
          * @stable ICU 3.0
          */
    -    virtual UObject* clone() const;
    +    virtual CurrencyUnit* clone() const;
     
         /**
          * Destructor
    @@ -140,4 +142,7 @@ inline const char16_t* CurrencyUnit::getISOCurrency() const {
     U_NAMESPACE_END
     
     #endif // !UCONFIG_NO_FORMATTING
    +
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // __CURRENCYUNIT_H__
    diff --git a/deps/icu-small/source/i18n/unicode/datefmt.h b/deps/icu-small/source/i18n/unicode/datefmt.h
    index 13c63d937675ea..f106e821a762ae 100644
    --- a/deps/icu-small/source/i18n/unicode/datefmt.h
    +++ b/deps/icu-small/source/i18n/unicode/datefmt.h
    @@ -23,6 +23,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_FORMATTING
     
     #include "unicode/udat.h"
    @@ -50,7 +52,7 @@ class DateTimePatternGenerator;
      */
     #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN)
     template class U_I18N_API EnumSet;
     #endif
     /** \endcond */
    @@ -221,6 +223,14 @@ class U_I18N_API DateFormat : public Format {
          */
         virtual ~DateFormat();
     
    +    /**
    +     * Clones this object polymorphically.
    +     * The caller owns the result and should delete it when done.
    +     * @return clone, or nullptr if an error occurred
    +     * @stable ICU 2.0
    +     */
    +    virtual DateFormat* clone() const = 0;
    +
         /**
          * Equality operator.  Returns true if the two formats have the same behavior.
          * @stable ICU 2.0
    @@ -594,7 +604,7 @@ class U_I18N_API DateFormat : public Format {
     #endif  /* U_HIDE_INTERNAL_API */
     
         /**
    -     * Creates a date/time formatter for the given skeleton and
    +     * Creates a date/time formatter for the given skeleton and 
          * default locale.
          *
          * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
    @@ -670,20 +680,20 @@ class U_I18N_API DateFormat : public Format {
          * lenient parsing, the parser may use heuristics to interpret inputs that
          * do not precisely match this object's format.  Without lenient parsing,
          * inputs must match this object's format more closely.
    -     *
    -     * Note: ICU 53 introduced finer grained control of leniency (and added
    -     * new control points) making the preferred method a combination of
    -     * setCalendarLenient() & setBooleanAttribute() calls.
    -     * This method supports prior functionality but may not support all
    -     * future leniency control & behavior of DateFormat. For control of pre 53 leniency,
    -     * Calendar and DateFormat whitespace & numeric tolerance, this method is safe to
    -     * use. However, mixing leniency control via this method and modification of the
    -     * newer attributes via setBooleanAttribute() may produce undesirable
    +     * 
    +     * Note: ICU 53 introduced finer grained control of leniency (and added 
    +     * new control points) making the preferred method a combination of 
    +     * setCalendarLenient() & setBooleanAttribute() calls. 
    +     * This method supports prior functionality but may not support all 
    +     * future leniency control & behavior of DateFormat. For control of pre 53 leniency,  
    +     * Calendar and DateFormat whitespace & numeric tolerance, this method is safe to 
    +     * use. However, mixing leniency control via this method and modification of the 
    +     * newer attributes via setBooleanAttribute() may produce undesirable 
          * results.
          *
          * @param lenient  True specifies date/time interpretation to be lenient.
          * @see Calendar::setLenient
    -     * @stable ICU 2.0
    +     * @stable ICU 2.0     
          */
         virtual void setLenient(UBool lenient);
     
    @@ -789,7 +799,7 @@ class U_I18N_API DateFormat : public Format {
          * @param value The UDisplayContext value to set.
          * @param status Input/output status. If at entry this indicates a failure
          *               status, the function will do nothing; otherwise this will be
    -     *               updated with any new status from the function.
    +     *               updated with any new status from the function. 
          * @stable ICU 53
          */
         virtual void setContext(UDisplayContext value, UErrorCode& status);
    @@ -800,7 +810,7 @@ class U_I18N_API DateFormat : public Format {
          * @param type The UDisplayContextType whose value to return
          * @param status Input/output status. If at entry this indicates a failure
          *               status, the function will do nothing; otherwise this will be
    -     *               updated with any new status from the function.
    +     *               updated with any new status from the function. 
          * @return The UDisplayContextValue for the specified type.
          * @stable ICU 53
          */
    @@ -818,8 +828,8 @@ class U_I18N_API DateFormat : public Format {
          */
     
         virtual DateFormat&  U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribute attr,
    -									UBool newvalue,
    -									UErrorCode &status);
    +    									UBool newvalue,
    +    									UErrorCode &status);
     
         /**
          * Returns a boolean from this DateFormat
    @@ -882,7 +892,7 @@ class U_I18N_API DateFormat : public Format {
          */
         static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale& inLocale);
     
    -
    +     
         /**
          * enum set of active boolean attributes for this instance
          */
    @@ -953,5 +963,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _DATEFMT
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/dcfmtsym.h b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
    index 55e3d8a6b3b5ec..e1e0ab6b08c523 100644
    --- a/deps/icu-small/source/i18n/unicode/dcfmtsym.h
    +++ b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
    @@ -28,10 +28,12 @@
     #define DCFMTSYM_H
     
     #include "unicode/utypes.h"
    -#include "unicode/uchar.h"
    +
    +#if U_SHOW_CPLUSPLUS_API
     
     #if !UCONFIG_NO_FORMATTING
     
    +#include "unicode/uchar.h"
     #include "unicode/uobject.h"
     #include "unicode/locid.h"
     #include "unicode/numsys.h"
    @@ -455,13 +457,11 @@ class U_I18N_API DecimalFormatSymbols : public UObject {
          * to non-resource bundle strings,
          * then regular UnicodeString copies must be used instead of fastCopyFrom().
          *
    -     * @internal
          */
         UnicodeString fSymbols[kFormatSymbolCount];
     
         /**
          * Non-symbol variable for getConstSymbol(). Always empty.
    -     * @internal
          */
         UnicodeString fNoSymbol;
     
    @@ -582,5 +582,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _DCFMTSYM
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h
    index 097a38fb88f6b2..c33ec80cacc5e0 100644
    --- a/deps/icu-small/source/i18n/unicode/decimfmt.h
    +++ b/deps/icu-small/source/i18n/unicode/decimfmt.h
    @@ -28,6 +28,9 @@
     #define DECIMFMT_H
     
     #include "unicode/utypes.h"
    +
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Compatibility APIs for decimal formatting.
    @@ -896,7 +899,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          * @return    a polymorphic copy of this DecimalFormat.
          * @stable ICU 2.0
          */
    -    Format* clone(void) const U_OVERRIDE;
    +    DecimalFormat* clone() const U_OVERRIDE;
     
         /**
          * Return true if the given Format objects are semantically equal.
    @@ -1331,7 +1334,6 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          */
         virtual void setMultiplier(int32_t newValue);
     
    -#ifndef U_HIDE_DRAFT_API
         /**
          * Gets the power of ten by which number should be multiplied before formatting, which
          * can be combined with setMultiplier() to multiply by any arbitrary decimal value.
    @@ -1342,7 +1344,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          * This method is analogous to UNUM_SCALE in getAttribute.
          *
          * @return    the current value of the power-of-ten multiplier.
    -     * @draft ICU 62
    +     * @stable ICU 62
          */
         int32_t getMultiplierScale(void) const;
     
    @@ -1363,10 +1365,9 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          * This method is analogous to UNUM_SCALE in setAttribute.
          *
          * @param newValue    the new value of the power-of-ten multiplier.
    -     * @draft ICU 62
    +     * @stable ICU 62
          */
         void setMultiplierScale(int32_t newValue);
    -#endif  /* U_HIDE_DRAFT_API */
     
         /**
          * Get the rounding increment.
    @@ -2020,12 +2021,14 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          */
         void setCurrency(const char16_t* theCurrency, UErrorCode& ec) U_OVERRIDE;
     
    +#ifndef U_FORCE_HIDE_DEPRECATED_API
         /**
          * Sets the currency used to display currency amounts.  See
          * setCurrency(const char16_t*, UErrorCode&).
          * @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&).
          */
         virtual void setCurrency(const char16_t* theCurrency);
    +#endif  // U_FORCE_HIDE_DEPRECATED_API
     
         /**
          * Sets the `Currency Usage` object used to display currency.
    @@ -2071,7 +2074,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
          * You can use the returned LocalizedNumberFormatter to format numbers and
          * get a FormattedNumber, which contains a string as well as additional
          * annotations about the formatted value.
    -     *
    +     * 
          * If a memory allocation failure occurs, the return value of this method
          * might be null. If you are concerned about correct recovery from
          * out-of-memory situations, use this pattern:
    @@ -2113,22 +2116,6 @@ class U_I18N_API DecimalFormat : public NumberFormat {
         const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const;
     #endif  /* U_HIDE_DRAFT_API */
     
    -#ifndef U_HIDE_DEPRECATED_API
    -    /**
    -     * Deprecated: Like {@link #toNumberFormatter(UErrorCode&) const},
    -     * but does not take an error code.
    -     *
    -     * The new signature should be used in case an error occurs while returning the
    -     * LocalizedNumberFormatter.
    -     *
    -     * This old signature will be removed in ICU 65.
    -     *
    -     * @return A reference to an internal object.
    -     * @deprecated ICU 64
    -     */
    -    const number::LocalizedNumberFormatter& toNumberFormatter() const;
    -#endif  /* U_HIDE_DEPRECATED_API */
    -
         /**
          * Return the class ID for this class.  This is useful only for
          * comparing to a return value from getDynamicClassID().  For example:
    @@ -2216,5 +2203,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _DECIMFMT
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/dtfmtsym.h b/deps/icu-small/source/i18n/unicode/dtfmtsym.h
    index ed7c1898465e5d..c6d76fe98eb97e 100644
    --- a/deps/icu-small/source/i18n/unicode/dtfmtsym.h
    +++ b/deps/icu-small/source/i18n/unicode/dtfmtsym.h
    @@ -22,6 +22,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     #if !UCONFIG_NO_FORMATTING
     
     #include "unicode/calendar.h"
    @@ -597,7 +599,7 @@ class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
         Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
     
         /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
    -       they are needed for .h file declarations. */
    +       they are needed for .h file declarations. */ 
         /**
          * Constants for capitalization context usage types.
          * @internal
    @@ -814,7 +816,7 @@ class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
          * entry containing the localized names for a single TimeZone.
          *
          * Each such row contains (with i ranging from 0..n-1):
    -     *
    +     * 
          * zoneStrings[i][0] - time zone ID
          *  example: America/Los_Angeles
          * zoneStrings[i][1] - long name of zone in standard time
    @@ -900,7 +902,7 @@ class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
         int32_t         fStandaloneNarrowDayPeriodsCount;
     
     private:
    -    /** valid/actual locale information
    +    /** valid/actual locale information 
          *  these are always ICU locales, so the length should not be a problem
          */
         char validLocale[ULOC_FULLNAME_CAPACITY];
    @@ -1011,5 +1013,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _DTFMTSYM
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/dtitvfmt.h b/deps/icu-small/source/i18n/unicode/dtitvfmt.h
    index 42d77d041f8b28..23fc02e2a7b16b 100644
    --- a/deps/icu-small/source/i18n/unicode/dtitvfmt.h
    +++ b/deps/icu-small/source/i18n/unicode/dtitvfmt.h
    @@ -16,6 +16,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Format and parse date interval in a language-independent manner.
    @@ -432,7 +434,7 @@ class U_I18N_API DateIntervalFormat : public Format {
          * @return    A copy of the object.
          * @stable ICU 4.0
          */
    -    virtual Format* clone(void) const;
    +    virtual DateIntervalFormat* clone() const;
     
         /**
          * Return true if the given Format objects are semantically equal. Objects
    @@ -1151,5 +1153,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // _DTITVFMT_H__
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/dtitvinf.h b/deps/icu-small/source/i18n/unicode/dtitvinf.h
    index 65f568c0700218..a894d12ca4428b 100644
    --- a/deps/icu-small/source/i18n/unicode/dtitvinf.h
    +++ b/deps/icu-small/source/i18n/unicode/dtitvinf.h
    @@ -16,6 +16,8 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
      * \file
      * \brief C++ API: Date/Time interval patterns for formatting date/time interval
    @@ -195,7 +197,7 @@ class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
          * @return   a copy of the object
          * @stable ICU 4.0
          */
    -    virtual DateIntervalInfo* clone(void) const;
    +    virtual DateIntervalInfo* clone() const;
     
         /**
          * Destructor.
    @@ -515,4 +517,7 @@ U_NAMESPACE_END
     
     #endif
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif
    +
    diff --git a/deps/icu-small/source/i18n/unicode/dtptngen.h b/deps/icu-small/source/i18n/unicode/dtptngen.h
    index e50c01b4e360c9..a71938b31cf5d8 100644
    --- a/deps/icu-small/source/i18n/unicode/dtptngen.h
    +++ b/deps/icu-small/source/i18n/unicode/dtptngen.h
    @@ -14,6 +14,10 @@
     #ifndef __DTPTNGEN_H__
     #define __DTPTNGEN_H__
     
    +#include "unicode/utypes.h"
    +
    +#if U_SHOW_CPLUSPLUS_API
    +
     #include "unicode/datefmt.h"
     #include "unicode/locid.h"
     #include "unicode/udat.h"
    @@ -279,7 +283,7 @@ class U_I18N_API DateTimePatternGenerator : public UObject {
          *
          * @param field  The desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
          * @param width  The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
    -     * @return.      The display name for field
    +     * @return       The display name for field
          * @stable ICU 61
          */
         UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const;
    @@ -561,12 +565,10 @@ class U_I18N_API DateTimePatternGenerator : public UObject {
         void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
         void setDecimalSymbols(const Locale& locale, UErrorCode& status);
         UDateTimePatternField getAppendFormatNumber(const char* field) const;
    -#ifndef U_HIDE_DRAFT_API
    -    // The following three have to be U_HIDE_DRAFT_API (though private) because UDateTimePGDisplayWidth is
    +    // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61
         UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const;
         void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value);
         UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width);
    -#endif  // U_HIDE_DRAFT_API
         void getAppendName(UDateTimePatternField field, UnicodeString& value);
         UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status);
         const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0);
    @@ -587,4 +589,6 @@ class U_I18N_API DateTimePatternGenerator : public UObject {
     
     U_NAMESPACE_END
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif
    diff --git a/deps/icu-small/source/i18n/unicode/dtrule.h b/deps/icu-small/source/i18n/unicode/dtrule.h
    index 24dfc69de1df22..adab8967f634fa 100644
    --- a/deps/icu-small/source/i18n/unicode/dtrule.h
    +++ b/deps/icu-small/source/i18n/unicode/dtrule.h
    @@ -11,8 +11,10 @@
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
    - * \file
    + * \file 
      * \brief C++ API: Rule for specifying date and time in an year
      */
     
    @@ -25,7 +27,7 @@ U_NAMESPACE_BEGIN
      * DateTimeRule is a class representing a time in a year by
      * a rule specified by month, day of month, day of week and
      * time in the day.
    - *
    + * 
      * @stable ICU 3.8
      */
     class U_I18N_API DateTimeRule : public UObject {
    @@ -60,7 +62,7 @@ class U_I18N_API DateTimeRule : public UObject {
          * Constructs a DateTimeRule by the day of month and
          * the time rule.  The date rule type for an instance created by
          * this constructor is DOM.
    -     *
    +     * 
          * @param month         The rule month, for example, Calendar::JANUARY
          * @param dayOfMonth    The day of month, 1-based.
          * @param millisInDay   The milliseconds in the rule date.
    @@ -75,7 +77,7 @@ class U_I18N_API DateTimeRule : public UObject {
          * Constructs a DateTimeRule by the day of week and its oridinal
          * number and the time rule.  The date rule type for an instance created
          * by this constructor is DOW.
    -     *
    +     * 
          * @param month         The rule month, for example, Calendar::JANUARY.
          * @param weekInMonth   The ordinal number of the day of week.  Negative number
          *                      may be used for specifying a rule date counted from the
    @@ -94,7 +96,7 @@ class U_I18N_API DateTimeRule : public UObject {
          * on or after/before the day of month and the time rule.  The date rule
          * type for an instance created by this constructor is either
          * DOM_GEQ_DOM or DOM_LEQ_DOM.
    -     *
    +     * 
          * @param month         The rule month, for example, Calendar::JANUARY
          * @param dayOfMonth    The day of month, 1-based.
          * @param dayOfWeek     The day of week, for example, Calendar::SUNDAY.
    @@ -126,7 +128,7 @@ class U_I18N_API DateTimeRule : public UObject {
          * @return    A copy of the object.
          * @stable ICU 3.8
          */
    -    DateTimeRule* clone(void) const;
    +    DateTimeRule* clone() const;
     
         /**
          * Assignment operator.
    @@ -248,5 +250,7 @@ U_NAMESPACE_END
     
     #endif /* #if !UCONFIG_NO_FORMATTING */
     
    +#endif /* U_SHOW_CPLUSPLUS_API */
    +
     #endif // DTRULE_H
     //eof
    diff --git a/deps/icu-small/source/i18n/unicode/fieldpos.h b/deps/icu-small/source/i18n/unicode/fieldpos.h
    index 78561a4de7d8b1..23ee38624b746d 100644
    --- a/deps/icu-small/source/i18n/unicode/fieldpos.h
    +++ b/deps/icu-small/source/i18n/unicode/fieldpos.h
    @@ -20,14 +20,16 @@
     // *****************************************************************************
     // This file was generated from the java source file FieldPosition.java
     // *****************************************************************************
    -
    + 
     #ifndef FIELDPOS_H
     #define FIELDPOS_H
     
     #include "unicode/utypes.h"
     
    +#if U_SHOW_CPLUSPLUS_API
    +
     /**
    - * \file
    + * \file 
      * \brief C++ API: FieldPosition identifies the fields in a formatted output.
      */
     
    @@ -69,14 +71,14 @@ U_NAMESPACE_BEGIN
      *       double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,
      *                  12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
      *       int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));
    - *
    + *       
      *       UErrorCode status = U_ZERO_ERROR;
      *       DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
      *       fmt->setDecimalSeparatorAlwaysShown(true);
    - *
    + *       
      *       const int tempLen = 20;
      *       char temp[tempLen];
    - *
    + *       
      *       for (int i=0; i
    * * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static ScientificNotation scientific(); @@ -231,7 +233,7 @@ class U_I18N_API Notation : public UMemory { *
    * * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static ScientificNotation engineering(); @@ -274,7 +276,7 @@ class U_I18N_API Notation : public UMemory { *
    * * @return A CompactNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CompactNotation compactShort(); @@ -298,7 +300,7 @@ class U_I18N_API Notation : public UMemory { *
* * @return A CompactNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CompactNotation compactLong(); @@ -324,7 +326,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A SimpleNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static SimpleNotation simple(); @@ -391,7 +393,7 @@ class U_I18N_API Notation : public UMemory { *

* To create a ScientificNotation, use one of the factory methods in {@link Notation}. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API ScientificNotation : public Notation { public: @@ -406,7 +408,7 @@ class U_I18N_API ScientificNotation : public Notation { * @param minExponentDigits * The minimum number of digits to show in the exponent. * @return A ScientificNotation, for chaining. - * @draft ICU 60 + * @stable ICU 60 */ ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const; @@ -421,7 +423,7 @@ class U_I18N_API ScientificNotation : public Notation { * @param exponentSignDisplay * The strategy for displaying the sign in the exponent. * @return A ScientificNotation, for chaining. - * @draft ICU 60 + * @stable ICU 60 */ ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const; @@ -442,7 +444,7 @@ class U_I18N_API ScientificNotation : public Notation { /** * Extra name reserved in case it is needed in the future. * - * @draft ICU 63 + * @stable ICU 63 */ typedef Precision SignificantDigitsPrecision; @@ -452,7 +454,7 @@ typedef Precision SignificantDigitsPrecision; *

* To create a Precision, use one of the factory methods. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API Precision : public UMemory { @@ -472,7 +474,7 @@ class U_I18N_API Precision : public UMemory { * http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/ * * @return A Precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static Precision unlimited(); @@ -480,7 +482,7 @@ class U_I18N_API Precision : public UMemory { * Show numbers rounded if necessary to the nearest integer. * * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision integer(); @@ -509,7 +511,7 @@ class U_I18N_API Precision : public UMemory { * The minimum and maximum number of numerals to display after the decimal separator (rounding if too * long or padding with zeros if too short). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces); @@ -524,7 +526,7 @@ class U_I18N_API Precision : public UMemory { * The minimum number of numerals to display after the decimal separator (padding with zeros if * necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision minFraction(int32_t minFractionPlaces); @@ -536,7 +538,7 @@ class U_I18N_API Precision : public UMemory { * @param maxFractionPlaces * The maximum number of numerals to display after the decimal mark (rounding if necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision maxFraction(int32_t maxFractionPlaces); @@ -551,7 +553,7 @@ class U_I18N_API Precision : public UMemory { * @param maxFractionPlaces * The maximum number of numerals to display after the decimal separator (rounding if necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces); @@ -566,7 +568,7 @@ class U_I18N_API Precision : public UMemory { * The minimum and maximum number of significant digits to display (rounding if too long or padding with * zeros if too short). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits); @@ -580,7 +582,7 @@ class U_I18N_API Precision : public UMemory { * @param minSignificantDigits * The minimum number of significant digits to display (padding with zeros if too short). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits); @@ -590,7 +592,7 @@ class U_I18N_API Precision : public UMemory { * @param maxSignificantDigits * The maximum number of significant digits to display (rounding if too long). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits); @@ -603,7 +605,7 @@ class U_I18N_API Precision : public UMemory { * @param maxSignificantDigits * The maximum number of significant digits to display (rounding if necessary). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits); @@ -625,7 +627,7 @@ class U_I18N_API Precision : public UMemory { * @param roundingIncrement * The increment to which to round numbers. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static IncrementPrecision increment(double roundingIncrement); @@ -644,7 +646,7 @@ class U_I18N_API Precision : public UMemory { * Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may * be limited by the available denominations of cash or coins). * @return A CurrencyPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CurrencyPrecision currency(UCurrencyUsage currencyUsage); @@ -771,7 +773,7 @@ class U_I18N_API Precision : public UMemory { *

* To create a FractionPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API FractionPrecision : public Precision { public: @@ -789,7 +791,7 @@ class U_I18N_API FractionPrecision : public Precision { * @param minSignificantDigits * The number of significant figures to guarantee. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMinDigits(int32_t minSignificantDigits) const; @@ -808,7 +810,7 @@ class U_I18N_API FractionPrecision : public Precision { * @param maxSignificantDigits * Round the number to no more than this number of significant figures. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMaxDigits(int32_t maxSignificantDigits) const; @@ -827,7 +829,7 @@ class U_I18N_API FractionPrecision : public Precision { *

* To create a CurrencyPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API CurrencyPrecision : public Precision { public: @@ -846,7 +848,7 @@ class U_I18N_API CurrencyPrecision : public Precision { * @param currency * The currency to associate with this rounding precision. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withCurrency(const CurrencyUnit ¤cy) const; @@ -865,7 +867,7 @@ class U_I18N_API CurrencyPrecision : public Precision { *

* To create an IncrementPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API IncrementPrecision : public Precision { public: @@ -882,7 +884,7 @@ class U_I18N_API IncrementPrecision : public Precision { * * @param minFrac The minimum number of digits after the decimal separator. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMinFraction(int32_t minFrac) const; @@ -900,7 +902,7 @@ class U_I18N_API IncrementPrecision : public Precision { *

* To create an IntegerWidth, use one of the factory methods. * - * @draft ICU 60 + * @stable ICU 60 * @see NumberFormatter */ class U_I18N_API IntegerWidth : public UMemory { @@ -914,7 +916,7 @@ class U_I18N_API IntegerWidth : public UMemory { * @param minInt * The minimum number of places before the decimal separator. * @return An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter. - * @draft ICU 60 + * @stable ICU 60 */ static IntegerWidth zeroFillTo(int32_t minInt); @@ -927,7 +929,7 @@ class U_I18N_API IntegerWidth : public UMemory { * The maximum number of places before the decimal separator. maxInt == -1 means no * truncation. * @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter. - * @draft ICU 60 + * @stable ICU 60 */ IntegerWidth truncateAt(int32_t maxInt); @@ -994,7 +996,7 @@ class U_I18N_API IntegerWidth : public UMemory { *

* To create a Scale, use one of the factory methods. * - * @draft ICU 62 + * @stable ICU 62 */ class U_I18N_API Scale : public UMemory { public: @@ -1002,7 +1004,7 @@ class U_I18N_API Scale : public UMemory { * Do not change the value of numbers when formatting or parsing. * * @return A Scale to prevent any multiplication. - * @draft ICU 62 + * @stable ICU 62 */ static Scale none(); @@ -1014,7 +1016,7 @@ class U_I18N_API Scale : public UMemory { * * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale powerOfTen(int32_t power); @@ -1028,7 +1030,7 @@ class U_I18N_API Scale : public UMemory { * Also see the version of this method that takes a double. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDecimal(StringPiece multiplicand); @@ -1038,7 +1040,7 @@ class U_I18N_API Scale : public UMemory { * This method takes a double; also see the version of this method that takes an exact decimal. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDouble(double multiplicand); @@ -1046,26 +1048,26 @@ class U_I18N_API Scale : public UMemory { * Multiply a number by both a power of ten and by an arbitrary double value. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power); // We need a custom destructor for the DecNum, which means we need to declare // the copy/move constructor/assignment quartet. - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale(const Scale& other); - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale& operator=(const Scale& other); - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale(Scale&& src) U_NOEXCEPT; - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale& operator=(Scale&& src) U_NOEXCEPT; - /** @draft ICU 62 */ + /** @stable ICU 62 */ ~Scale(); #ifndef U_HIDE_INTERNAL_API @@ -1343,7 +1345,7 @@ class U_I18N_API Padder : public UMemory { } int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2, - impl::NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex, + FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const; // To allow MacroProps/MicroProps to initialize empty instances: @@ -1465,7 +1467,7 @@ class U_I18N_API NumberFormatterSettings { * The notation strategy to use. * @return The fluent chain. * @see Notation - * @draft ICU 60 + * @stable ICU 60 */ Derived notation(const Notation ¬ation) const &; @@ -1476,7 +1478,7 @@ class U_I18N_API NumberFormatterSettings { * The notation strategy to use. * @return The fluent chain. * @see #notation - * @draft ICU 62 + * @stable ICU 62 */ Derived notation(const Notation ¬ation) &&; @@ -1521,7 +1523,7 @@ class U_I18N_API NumberFormatterSettings { * @see Currency * @see NoUnit * @see #perUnit - * @draft ICU 60 + * @stable ICU 60 */ Derived unit(const icu::MeasureUnit &unit) const &; @@ -1532,7 +1534,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render. * @return The fluent chain. * @see #unit - * @draft ICU 62 + * @stable ICU 62 */ Derived unit(const icu::MeasureUnit &unit) &&; @@ -1547,7 +1549,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @see #unit * @see MeasureUnit - * @draft ICU 60 + * @stable ICU 60 */ Derived adoptUnit(icu::MeasureUnit *unit) const &; @@ -1558,7 +1560,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render. * @return The fluent chain. * @see #adoptUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptUnit(icu::MeasureUnit *unit) &&; @@ -1582,7 +1584,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain * @see #unit - * @draft ICU 61 + * @stable ICU 61 */ Derived perUnit(const icu::MeasureUnit &perUnit) const &; @@ -1593,7 +1595,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain. * @see #perUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived perUnit(const icu::MeasureUnit &perUnit) &&; @@ -1608,7 +1610,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @see #perUnit * @see MeasureUnit - * @draft ICU 61 + * @stable ICU 61 */ Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &; @@ -1619,7 +1621,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain. * @see #adoptPerUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&; @@ -1651,7 +1653,7 @@ class U_I18N_API NumberFormatterSettings { * The rounding precision to use. * @return The fluent chain. * @see Precision - * @draft ICU 62 + * @stable ICU 62 */ Derived precision(const Precision& precision) const &; @@ -1662,7 +1664,7 @@ class U_I18N_API NumberFormatterSettings { * The rounding precision to use. * @return The fluent chain. * @see #precision - * @draft ICU 62 + * @stable ICU 62 */ Derived precision(const Precision& precision) &&; @@ -1682,7 +1684,7 @@ class U_I18N_API NumberFormatterSettings { * * @param roundingMode The rounding mode to use. * @return The fluent chain. - * @draft ICU 62 + * @stable ICU 62 */ Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &; @@ -1692,7 +1694,7 @@ class U_I18N_API NumberFormatterSettings { * @param roundingMode The rounding mode to use. * @return The fluent chain. * @see #roundingMode - * @draft ICU 62 + * @stable ICU 62 */ Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&; @@ -1721,7 +1723,7 @@ class U_I18N_API NumberFormatterSettings { * @param strategy * The grouping strategy to use. * @return The fluent chain. - * @draft ICU 61 + * @stable ICU 61 */ Derived grouping(UNumberGroupingStrategy strategy) const &; @@ -1732,7 +1734,7 @@ class U_I18N_API NumberFormatterSettings { * The grouping strategy to use. * @return The fluent chain. * @see #grouping - * @draft ICU 62 + * @stable ICU 62 */ Derived grouping(UNumberGroupingStrategy strategy) &&; @@ -1758,7 +1760,7 @@ class U_I18N_API NumberFormatterSettings { * The integer width to use. * @return The fluent chain. * @see IntegerWidth - * @draft ICU 60 + * @stable ICU 60 */ Derived integerWidth(const IntegerWidth &style) const &; @@ -1769,7 +1771,7 @@ class U_I18N_API NumberFormatterSettings { * The integer width to use. * @return The fluent chain. * @see #integerWidth - * @draft ICU 62 + * @stable ICU 62 */ Derived integerWidth(const IntegerWidth &style) &&; @@ -1811,7 +1813,7 @@ class U_I18N_API NumberFormatterSettings { * The DecimalFormatSymbols to use. * @return The fluent chain. * @see DecimalFormatSymbols - * @draft ICU 60 + * @stable ICU 60 */ Derived symbols(const DecimalFormatSymbols &symbols) const &; @@ -1822,7 +1824,7 @@ class U_I18N_API NumberFormatterSettings { * The DecimalFormatSymbols to use. * @return The fluent chain. * @see #symbols - * @draft ICU 62 + * @stable ICU 62 */ Derived symbols(const DecimalFormatSymbols &symbols) &&; @@ -1857,7 +1859,7 @@ class U_I18N_API NumberFormatterSettings { * The NumberingSystem to use. * @return The fluent chain. * @see NumberingSystem - * @draft ICU 60 + * @stable ICU 60 */ Derived adoptSymbols(NumberingSystem *symbols) const &; @@ -1868,7 +1870,7 @@ class U_I18N_API NumberFormatterSettings { * The NumberingSystem to use. * @return The fluent chain. * @see #adoptSymbols - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptSymbols(NumberingSystem *symbols) &&; @@ -1895,7 +1897,7 @@ class U_I18N_API NumberFormatterSettings { * The width to use when rendering numbers. * @return The fluent chain * @see UNumberUnitWidth - * @draft ICU 60 + * @stable ICU 60 */ Derived unitWidth(UNumberUnitWidth width) const &; @@ -1906,7 +1908,7 @@ class U_I18N_API NumberFormatterSettings { * The width to use when rendering numbers. * @return The fluent chain. * @see #unitWidth - * @draft ICU 62 + * @stable ICU 62 */ Derived unitWidth(UNumberUnitWidth width) &&; @@ -1933,7 +1935,7 @@ class U_I18N_API NumberFormatterSettings { * The sign display strategy to use when rendering numbers. * @return The fluent chain * @see UNumberSignDisplay - * @draft ICU 60 + * @stable ICU 60 */ Derived sign(UNumberSignDisplay style) const &; @@ -1944,7 +1946,7 @@ class U_I18N_API NumberFormatterSettings { * The sign display strategy to use when rendering numbers. * @return The fluent chain. * @see #sign - * @draft ICU 62 + * @stable ICU 62 */ Derived sign(UNumberSignDisplay style) &&; @@ -1971,7 +1973,7 @@ class U_I18N_API NumberFormatterSettings { * The decimal separator display strategy to use when rendering numbers. * @return The fluent chain * @see UNumberDecimalSeparatorDisplay - * @draft ICU 60 + * @stable ICU 60 */ Derived decimal(UNumberDecimalSeparatorDisplay style) const &; @@ -1982,7 +1984,7 @@ class U_I18N_API NumberFormatterSettings { * The decimal separator display strategy to use when rendering numbers. * @return The fluent chain. * @see #decimal - * @draft ICU 62 + * @stable ICU 62 */ Derived decimal(UNumberDecimalSeparatorDisplay style) &&; @@ -2008,7 +2010,7 @@ class U_I18N_API NumberFormatterSettings { * @param scale * The scale to apply when rendering numbers. * @return The fluent chain - * @draft ICU 62 + * @stable ICU 62 */ Derived scale(const Scale &scale) const &; @@ -2019,7 +2021,7 @@ class U_I18N_API NumberFormatterSettings { * The scale to apply when rendering numbers. * @return The fluent chain. * @see #scale - * @draft ICU 62 + * @stable ICU 62 */ Derived scale(const Scale &scale) &&; @@ -2076,10 +2078,11 @@ class U_I18N_API NumberFormatterSettings { * behavior should produce the same skeleton. * * @return A number skeleton string with behavior corresponding to this number formatter. - * @draft ICU 62 + * @stable ICU 62 */ UnicodeString toSkeleton(UErrorCode& status) const; +#ifndef U_HIDE_DRAFT_API /** * Returns the current (Un)LocalizedNumberFormatter as a LocalPointer * wrapping a heap-allocated copy of the current object. @@ -2101,12 +2104,13 @@ class U_I18N_API NumberFormatterSettings { * @draft ICU 64 */ LocalPointer clone() &&; +#endif /* U_HIDE_DRAFT_API */ /** * Sets the UErrorCode if an error occurred in the fluent chain. * Preserves older error codes in the outErrorCode. * @return TRUE if U_FAILURE(outErrorCode) - * @draft ICU 60 + * @stable ICU 60 */ UBool copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { @@ -2139,7 +2143,7 @@ class U_I18N_API NumberFormatterSettings { * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API UnlocalizedNumberFormatter : public NumberFormatterSettings, public UMemory { @@ -2152,7 +2156,7 @@ class U_I18N_API UnlocalizedNumberFormatter * @param locale * The locale to use when loading data for number formatting. * @return The fluent chain. - * @draft ICU 60 + * @stable ICU 60 */ LocalizedNumberFormatter locale(const icu::Locale &locale) const &; @@ -2163,40 +2167,40 @@ class U_I18N_API UnlocalizedNumberFormatter * The locale to use when loading data for number formatting. * @return The fluent chain. * @see #locale - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter locale(const icu::Locale &locale) &&; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter() = default; /** * Returns a copy of this UnlocalizedNumberFormatter. - * @draft ICU 60 + * @stable ICU 60 */ UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other); /** * Move constructor: * The source UnlocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter(UnlocalizedNumberFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter& operator=(const UnlocalizedNumberFormatter& other); /** * Move assignment operator: * The source UnlocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter& operator=(UnlocalizedNumberFormatter&& src) U_NOEXCEPT; @@ -2219,7 +2223,7 @@ class U_I18N_API UnlocalizedNumberFormatter * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API LocalizedNumberFormatter : public NumberFormatterSettings, public UMemory { @@ -2233,7 +2237,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatInt(int64_t value, UErrorCode &status) const; @@ -2246,7 +2250,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatDouble(double value, UErrorCode &status) const; @@ -2262,7 +2266,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatDecimal(StringPiece value, UErrorCode& status) const; @@ -2303,40 +2307,40 @@ class U_I18N_API LocalizedNumberFormatter * The caller owns the returned object and must delete it when finished. * * @return A Format wrapping this LocalizedNumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ Format* toFormat(UErrorCode& status) const; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter() = default; /** * Returns a copy of this LocalizedNumberFormatter. - * @draft ICU 60 + * @stable ICU 60 */ LocalizedNumberFormatter(const LocalizedNumberFormatter &other); /** * Move constructor: * The source LocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter& operator=(const LocalizedNumberFormatter& other); /** * Move assignment operator: * The source LocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter& operator=(LocalizedNumberFormatter&& src) U_NOEXCEPT; @@ -2360,7 +2364,7 @@ class U_I18N_API LocalizedNumberFormatter /** * Destruct this LocalizedNumberFormatter, cleaning up any memory it might own. - * @draft ICU 60 + * @stable ICU 60 */ ~LocalizedNumberFormatter(); @@ -2401,27 +2405,30 @@ class U_I18N_API LocalizedNumberFormatter * * Instances of this class are immutable and thread-safe. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { public: + // Default constructor cannot have #ifndef U_HIDE_DRAFT_API +#ifndef U_FORCE_HIDE_DRAFT_API /** * Default constructor; makes an empty FormattedNumber. * @draft ICU 64 */ FormattedNumber() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {} +#endif // U_FORCE_HIDE_DRAFT_API /** * Move constructor: Leaves the source FormattedNumber in an undefined state. - * @draft ICU 62 + * @stable ICU 62 */ FormattedNumber(FormattedNumber&& src) U_NOEXCEPT; /** * Destruct an instance of FormattedNumber. - * @draft ICU 60 + * @stable ICU 60 */ virtual ~FormattedNumber() U_OVERRIDE; @@ -2433,7 +2440,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { /** * Move assignment: Leaves the source FormattedNumber in an undefined state. - * @draft ICU 62 + * @stable ICU 62 */ FormattedNumber& operator=(FormattedNumber&& src) U_NOEXCEPT; @@ -2443,7 +2450,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * * For more information, see FormattedValue::toString() * - * @draft ICU 62 + * @stable ICU 62 */ UnicodeString toString(UErrorCode& status) const U_OVERRIDE; @@ -2457,7 +2464,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * * For more information, see FormattedValue::appendTo() * - * @draft ICU 62 + * @stable ICU 62 */ Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE; @@ -2465,6 +2472,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { /** @copydoc FormattedValue::nextPosition() */ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; +#ifndef U_HIDE_DRAFT_API /** * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given * field in the output string. This allows you to determine the locations of, for example, @@ -2516,6 +2524,30 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * @see UNumberFormatFields */ void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const; +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Export the formatted number as a "numeric string" conforming to the + * syntax defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * + * This endpoint is useful for obtaining the exact number being printed + * after scaling and rounding have been applied by the number formatter. + * + * Example call site: + * + * auto decimalNumber = fn.toDecimalNumber(status); + * + * @tparam StringClass A string class compatible with StringByteSink; + * for example, std::string. + * @param status Set if an error occurs. + * @return A StringClass containing the numeric string. + * @draft ICU 65 + */ + template + inline StringClass toDecimalNumber(UErrorCode& status) const; +#endif // U_HIDE_DRAFT_API #ifndef U_HIDE_INTERNAL_API @@ -2550,6 +2582,9 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { explicit FormattedNumber(UErrorCode errorCode) : fData(nullptr), fErrorCode(errorCode) {} + // TODO(ICU-20775): Propose this as API. + void toDecimalNumber(ByteSink& sink, UErrorCode& status) const; + // To give LocalizedNumberFormatter format methods access to this class's constructor: friend class LocalizedNumberFormatter; @@ -2557,10 +2592,21 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { friend struct impl::UFormattedNumberImpl; }; +#ifndef U_HIDE_DRAFT_API +// Note: This is draft ICU 65 +template +StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const { + StringClass result; + StringByteSink sink(&result); + toDecimalNumber(sink, status); + return result; +}; +#endif // U_HIDE_DRAFT_API + /** * See the main description in numberformatter.h for documentation and examples. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API NumberFormatter final { public: @@ -2569,7 +2615,7 @@ class U_I18N_API NumberFormatter final { * the call site. * * @return An {@link UnlocalizedNumberFormatter}, to be used for chaining. - * @draft ICU 60 + * @stable ICU 60 */ static UnlocalizedNumberFormatter with(); @@ -2580,7 +2626,7 @@ class U_I18N_API NumberFormatter final { * @param locale * The locale from which to load formats and symbols for number formatting. * @return A {@link LocalizedNumberFormatter}, to be used for chaining. - * @draft ICU 60 + * @stable ICU 60 */ static LocalizedNumberFormatter withLocale(const Locale &locale); @@ -2596,10 +2642,11 @@ class U_I18N_API NumberFormatter final { * @param status * Set to U_NUMBER_SKELETON_SYNTAX_ERROR if the skeleton was invalid. * @return An UnlocalizedNumberFormatter, to be used for chaining. - * @draft ICU 62 + * @stable ICU 62 */ static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UErrorCode& status); +#ifndef U_HIDE_DRAFT_API /** * Call this method at the beginning of a NumberFormatter fluent chain to create an instance based * on a given number skeleton string. @@ -2619,6 +2666,7 @@ class U_I18N_API NumberFormatter final { */ static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UParseError& perror, UErrorCode& status); +#endif /** * Use factory methods instead of the constructor to create a NumberFormatter. @@ -2629,8 +2677,9 @@ class U_I18N_API NumberFormatter final { } // namespace number U_NAMESPACE_END -#endif // U_HIDE_DRAFT_API +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ #endif // __NUMBERFORMATTER_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h index 47c4bfe3f5ef76..0f0d2af5f5b2af 100644 --- a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h +++ b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h @@ -1,10 +1,15 @@ // © 2018 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -#if !UCONFIG_NO_FORMATTING #ifndef __NUMBERRANGEFORMATTER_H__ #define __NUMBERRANGEFORMATTER_H__ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#if !UCONFIG_NO_FORMATTING + #include #include "unicode/appendable.h" #include "unicode/fieldpos.h" @@ -12,8 +17,6 @@ #include "unicode/fpositer.h" #include "unicode/numberformatter.h" -#ifndef U_HIDE_DRAFT_API - /** * \file * \brief C++ API: Library for localized formatting of number, currency, and unit ranges. @@ -44,7 +47,7 @@ /** * Defines how to merge fields that are identical across the range sign. * - * @draft ICU 63 + * @stable ICU 63 */ typedef enum UNumberRangeCollapse { /** @@ -53,14 +56,14 @@ typedef enum UNumberRangeCollapse { * * The heuristics used for this option are subject to change over time. * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_AUTO, /** * Do not collapse any part of the number. Example: "3.2 thousand kilograms – 5.3 thousand kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_NONE, @@ -68,7 +71,7 @@ typedef enum UNumberRangeCollapse { * Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand – 5.3 thousand * kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_UNIT, @@ -76,7 +79,7 @@ typedef enum UNumberRangeCollapse { * Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the * number. Example: "3.2 – 5.3 thousand kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_ALL } UNumberRangeCollapse; @@ -85,14 +88,14 @@ typedef enum UNumberRangeCollapse { * Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect * when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ typedef enum UNumberRangeIdentityFallback { /** * Show the number as a single value rather than a range. Example: "$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_SINGLE_VALUE, @@ -100,7 +103,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding, * show the single value. Example: "~$5" or "$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, @@ -108,7 +111,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the * inputs are the same. Example: "~$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_APPROXIMATELY, @@ -116,7 +119,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the * same. Example (with RangeCollapse.NONE): "$5 – $5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_RANGE } UNumberRangeIdentityFallback; @@ -125,14 +128,14 @@ typedef enum UNumberRangeIdentityFallback { * Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range * were equal or not, and whether or not the identity fallback was applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING, @@ -140,7 +143,7 @@ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING, @@ -148,7 +151,7 @@ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_NOT_EQUAL, @@ -254,7 +257,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatter * The formatter to use for both numbers in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) const &; @@ -265,7 +268,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) &&; @@ -276,7 +279,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) const &; @@ -287,7 +290,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) &&; @@ -300,7 +303,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatterFirst * The formatter to use for the first number in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) const &; @@ -311,7 +314,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) &&; @@ -322,7 +325,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) const &; @@ -333,7 +336,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) &&; @@ -346,7 +349,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatterSecond * The formatter to use for the second number in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) const &; @@ -357,7 +360,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) &&; @@ -368,7 +371,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) const &; @@ -379,7 +382,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) &&; @@ -398,7 +401,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param collapse * The collapsing strategy to use for this range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived collapse(UNumberRangeCollapse collapse) const &; @@ -409,7 +412,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The collapsing strategy to use for this range. * @return The fluent chain. * @see #collapse - * @draft ICU 63 + * @stable ICU 63 */ Derived collapse(UNumberRangeCollapse collapse) &&; @@ -431,7 +434,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param identityFallback * The strategy to use when formatting two numbers that end up being the same. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived identityFallback(UNumberRangeIdentityFallback identityFallback) const &; @@ -442,10 +445,11 @@ class U_I18N_API NumberRangeFormatterSettings { * The strategy to use when formatting two numbers that end up being the same. * @return The fluent chain. * @see #identityFallback - * @draft ICU 63 + * @stable ICU 63 */ Derived identityFallback(UNumberRangeIdentityFallback identityFallback) &&; +#ifndef U_HIDE_DRAFT_API /** * Returns the current (Un)LocalizedNumberRangeFormatter as a LocalPointer * wrapping a heap-allocated copy of the current object. @@ -467,12 +471,13 @@ class U_I18N_API NumberRangeFormatterSettings { * @draft ICU 64 */ LocalPointer clone() &&; +#endif /* U_HIDE_DRAFT_API */ /** * Sets the UErrorCode if an error occurred in the fluent chain. * Preserves older error codes in the outErrorCode. * @return TRUE if U_FAILURE(outErrorCode) - * @draft ICU 63 + * @stable ICU 63 */ UBool copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { @@ -501,7 +506,7 @@ class U_I18N_API NumberRangeFormatterSettings { * Instances of this class are immutable and thread-safe. * * @see NumberRangeFormatter - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API UnlocalizedNumberRangeFormatter : public NumberRangeFormatterSettings, public UMemory { @@ -514,7 +519,7 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * @param locale * The locale to use when loading data for number formatting. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter locale(const icu::Locale &locale) const &; @@ -525,40 +530,40 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * The locale to use when loading data for number formatting. * @return The fluent chain. * @see #locale - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter locale(const icu::Locale &locale) &&; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter() = default; /** * Returns a copy of this UnlocalizedNumberRangeFormatter. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter(const UnlocalizedNumberRangeFormatter &other); /** * Move constructor: * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter& operator=(const UnlocalizedNumberRangeFormatter& other); /** * Move assignment operator: * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter& operator=(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; @@ -582,7 +587,7 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API LocalizedNumberRangeFormatter : public NumberRangeFormatterSettings, public UMemory { @@ -598,7 +603,7 @@ class U_I18N_API LocalizedNumberRangeFormatter * @param status * Set if an error occurs while formatting. * @return A FormattedNumberRange object; call .toString() to get the string. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange formatFormattableRange( const Formattable& first, const Formattable& second, UErrorCode& status) const; @@ -606,33 +611,33 @@ class U_I18N_API LocalizedNumberRangeFormatter /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter() = default; /** * Returns a copy of this LocalizedNumberRangeFormatter. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter(const LocalizedNumberRangeFormatter &other); /** * Move constructor: * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter& operator=(const LocalizedNumberRangeFormatter& other); /** * Move assignment operator: * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter& operator=(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; @@ -651,11 +656,11 @@ class U_I18N_API LocalizedNumberRangeFormatter void formatImpl(impl::UFormattedNumberRangeData& results, bool equalBeforeRounding, UErrorCode& status) const; -#endif +#endif /* U_HIDE_INTERNAL_API */ /** * Destruct this LocalizedNumberRangeFormatter, cleaning up any memory it might own. - * @draft ICU 63 + * @stable ICU 63 */ ~LocalizedNumberRangeFormatter(); @@ -690,7 +695,7 @@ class U_I18N_API LocalizedNumberRangeFormatter * * Instances of this class are immutable and thread-safe. * - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { public: @@ -700,7 +705,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * * For more information, see FormattedValue::toString() * - * @draft ICU 63 + * @stable ICU 63 */ UnicodeString toString(UErrorCode& status) const U_OVERRIDE; @@ -714,7 +719,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * * For more information, see FormattedValue::appendTo() * - * @draft ICU 63 + * @stable ICU 63 */ Appendable &appendTo(Appendable &appendable, UErrorCode& status) const U_OVERRIDE; @@ -722,6 +727,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** @copydoc FormattedValue::nextPosition() */ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; +#ifndef U_HIDE_DRAFT_API /** * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given * field in the output string. This allows you to determine the locations of, for example, @@ -772,7 +778,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * Export the first formatted number as a decimal number. This endpoint * is useful for obtaining the exact number being printed after scaling * and rounding have been applied by the number range formatting pipeline. - * + * * The syntax of the unformatted number is a "numeric string" * as defined in the Decimal Arithmetic Specification, available at * http://speleotrove.com/decimal @@ -788,7 +794,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * Export the second formatted number as a decimal number. This endpoint * is useful for obtaining the exact number being printed after scaling * and rounding have been applied by the number range formatting pipeline. - * + * * The syntax of the unformatted number is a "numeric string" * as defined in the Decimal Arithmetic Specification, available at * http://speleotrove.com/decimal @@ -799,6 +805,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * @see #getFirstDecimal */ UnicodeString getSecondDecimal(UErrorCode& status) const; +#endif // U_HIDE_DRAFT_API /** * Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was @@ -806,7 +813,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * identity fallback was used. * * @return An indication the resulting identity situation in the formatted number range. - * @draft ICU 63 + * @stable ICU 63 * @see UNumberRangeIdentityFallback */ UNumberRangeIdentityResult getIdentityResult(UErrorCode& status) const; @@ -824,20 +831,20 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * Move constructor: * Leaves the source FormattedNumberRange in an undefined state. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange(FormattedNumberRange&& src) U_NOEXCEPT; /** * Move assignment: * Leaves the source FormattedNumberRange in an undefined state. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange& operator=(FormattedNumberRange&& src) U_NOEXCEPT; /** * Destruct an instance of FormattedNumberRange, cleaning up any memory it might own. - * @draft ICU 63 + * @stable ICU 63 */ ~FormattedNumberRange(); @@ -850,7 +857,6 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * Internal constructor from data type. Adopts the data pointer. - * @internal */ explicit FormattedNumberRange(impl::UFormattedNumberRangeData *results) : fData(results), fErrorCode(U_ZERO_ERROR) {} @@ -867,7 +873,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * See the main description in numberrangeformatter.h for documentation and examples. * - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API NumberRangeFormatter final { public: @@ -876,7 +882,7 @@ class U_I18N_API NumberRangeFormatter final { * known at the call site. * * @return An {@link UnlocalizedNumberRangeFormatter}, to be used for chaining. - * @draft ICU 63 + * @stable ICU 63 */ static UnlocalizedNumberRangeFormatter with(); @@ -887,7 +893,7 @@ class U_I18N_API NumberRangeFormatter final { * @param locale * The locale from which to load formats and symbols for number range formatting. * @return A {@link LocalizedNumberRangeFormatter}, to be used for chaining. - * @draft ICU 63 + * @stable ICU 63 */ static LocalizedNumberRangeFormatter withLocale(const Locale &locale); @@ -900,8 +906,9 @@ class U_I18N_API NumberRangeFormatter final { } // namespace number U_NAMESPACE_END -#endif // U_HIDE_DRAFT_API +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ #endif // __NUMBERRANGEFORMATTER_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/numfmt.h b/deps/icu-small/source/i18n/unicode/numfmt.h index d8704754dc79c2..722e6b7e74cdec 100644 --- a/deps/icu-small/source/i18n/unicode/numfmt.h +++ b/deps/icu-small/source/i18n/unicode/numfmt.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Compatibility APIs for number formatting. @@ -77,7 +79,7 @@ class StringEnumeration; * #include "unicode/unistr.h" * #include "unicode/ustream.h" * using namespace std; - * + * * int main() { * double myNumber = 7.0; * UnicodeString myString; @@ -260,6 +262,14 @@ class U_I18N_API NumberFormat : public Format { */ virtual ~NumberFormat(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 2.0 + */ + virtual NumberFormat* clone() const = 0; + /** * Return true if the given Format objects are semantically equal. * Objects of different subclasses are considered unequal. @@ -639,7 +649,9 @@ class U_I18N_API NumberFormat : public Format { * @param result Formattable to be set to the parse result. * If parse fails, return contents are undefined. * @param status Output parameter set to a failure error code - * when a failure occurs. + * when a failure occurs. The error code when the + * string fails to parse is U_INVALID_FORMAT_ERROR, + * unless overridden by a subclass. * @see NumberFormat::isParseIntegerOnly * @stable ICU 2.0 */ @@ -1031,7 +1043,7 @@ class U_I18N_API NumberFormat : public Format { /** * Get the rounding mode. This will always return NumberFormat::ERoundingMode::kRoundUnnecessary - * if the subclass does not support rounding. + * if the subclass does not support rounding. * @return A rounding mode * @stable ICU 60 */ @@ -1255,5 +1267,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _NUMFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/numsys.h b/deps/icu-small/source/i18n/unicode/numsys.h index 9e32478cf8de73..b2b16fa0d0e723 100644 --- a/deps/icu-small/source/i18n/unicode/numsys.h +++ b/deps/icu-small/source/i18n/unicode/numsys.h @@ -20,6 +20,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: NumberingSystem object @@ -40,7 +42,7 @@ U_NAMESPACE_BEGIN constexpr const size_t kInternalNumSysNameCapacity = 8; /** - * Defines numbering systems. A numbering system describes the scheme by which + * Defines numbering systems. A numbering system describes the scheme by which * numbers are to be presented to the end user. In its simplest form, a numbering * system describes the set of digit characters that are to be used to display * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc., in a @@ -92,7 +94,7 @@ class U_I18N_API NumberingSystem : public UObject { static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status); /** - * Create a numbering system using the specified radix, type, and description. + * Create a numbering system using the specified radix, type, and description. * @param radix The radix (base) for this numbering system. * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric. * @param description The string representing the set of digits used in a numeric system, or the name of the RBNF @@ -210,5 +212,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _NUMSYS //eof diff --git a/deps/icu-small/source/i18n/unicode/plurfmt.h b/deps/icu-small/source/i18n/unicode/plurfmt.h index 6b757c88419316..2c2116586f6e84 100644 --- a/deps/icu-small/source/i18n/unicode/plurfmt.h +++ b/deps/icu-small/source/i18n/unicode/plurfmt.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: PluralFormat object @@ -387,7 +389,7 @@ class U_I18N_API PluralFormat : public Format { FieldPosition& pos, UErrorCode& status) const; -#ifndef U_HIDE_DEPRECATED_API +#ifndef U_HIDE_DEPRECATED_API /** * Sets the locale used by this PluraFormat object. * Note: Calling this method resets this PluraFormat object, @@ -448,12 +450,12 @@ class U_I18N_API PluralFormat : public Format { * result and should delete it when done. * @stable ICU 4.0 */ - virtual Format* clone(void) const; + virtual PluralFormat* clone() const; /** * Formats a plural message for a number taken from a Formattable object. * - * @param obj The object containing a number for which the + * @param obj The object containing a number for which the * plural message should be formatted. * The object must be of a numeric type. * @param appendTo output parameter to receive result. @@ -522,7 +524,7 @@ class U_I18N_API PluralFormat : public Format { private: /** - * @internal + * @internal (private) */ class U_I18N_API PluralSelector : public UMemory { public: @@ -534,14 +536,11 @@ class U_I18N_API PluralFormat : public Format { * @param number The number to be plural-formatted. * @param ec Error code. * @return The selected PluralFormat keyword. - * @internal + * @internal (private) */ virtual UnicodeString select(void *context, double number, UErrorCode& ec) const = 0; }; - /** - * @internal - */ class U_I18N_API PluralSelectorAdapter : public PluralSelector { public: PluralSelectorAdapter() : pluralRules(NULL) { @@ -549,7 +548,7 @@ class U_I18N_API PluralFormat : public Format { virtual ~PluralSelectorAdapter(); - virtual UnicodeString select(void *context, double number, UErrorCode& /*ec*/) const; /**< @internal */ + virtual UnicodeString select(void *context, double number, UErrorCode& /*ec*/) const; void reset(); @@ -573,7 +572,7 @@ class U_I18N_API PluralFormat : public Format { UnicodeString& format(const Formattable& numberObject, double number, UnicodeString& appendTo, FieldPosition& pos, - UErrorCode& status) const; /**< @internal */ + UErrorCode& status) const; /** * Finds the PluralFormat sub-message for the given number, or the "other" sub-message. @@ -601,5 +600,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _PLURFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/plurrule.h b/deps/icu-small/source/i18n/unicode/plurrule.h index 04bf3970ba0825..a1553567caf8f5 100644 --- a/deps/icu-small/source/i18n/unicode/plurrule.h +++ b/deps/icu-small/source/i18n/unicode/plurrule.h @@ -20,6 +20,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: PluralRules object @@ -533,5 +535,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _PLURRULE //eof diff --git a/deps/icu-small/source/i18n/unicode/rbnf.h b/deps/icu-small/source/i18n/unicode/rbnf.h index f7cd85a322d1f5..62b02324b14a5e 100644 --- a/deps/icu-small/source/i18n/unicode/rbnf.h +++ b/deps/icu-small/source/i18n/unicode/rbnf.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule Based Number Format @@ -696,7 +698,7 @@ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { * @return A copy of the object. * @stable ICU 2.6 */ - virtual Format* clone(void) const; + virtual RuleBasedNumberFormat* clone() const; /** * Return true if the given Format objects are semantically equal. @@ -866,28 +868,6 @@ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { UErrorCode& status) const; protected: - /** - * Format a decimal number. - * The number is a DigitList wrapper onto a floating point decimal number. - * The default implementation in NumberFormat converts the decimal number - * to a double and formats that. Subclasses of NumberFormat that want - * to specifically handle big decimal numbers must override this method. - * class DecimalFormat does so. - * - * @param number The number, a DigitList format Decimal Floating Point. - * @param appendTo Output parameter to receive result. - * Result is appended to existing contents. - * @param posIter On return, can be used to iterate over positions - * of fields generated by this format call. - * @param status Output param filled with success/failure status. - * @return Reference to 'appendTo' parameter. - * @internal - */ - virtual UnicodeString& format(const number::impl::DecimalQuantity &number, - UnicodeString& appendTo, - FieldPositionIterator* posIter, - UErrorCode& status) const; - /** * Format a decimal number. * The number is a DigitList wrapper onto a floating point decimal number. @@ -1004,7 +984,7 @@ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { * @param value The UDisplayContext value to set. * @param status Input/output status. If at entry this indicates a failure * status, the function will do nothing; otherwise this will be - * updated with any new status from the function. + * updated with any new status from the function. * @stable ICU 53 */ virtual void setContext(UDisplayContext value, UErrorCode& status); @@ -1135,5 +1115,7 @@ U_NAMESPACE_END /* U_HAVE_RBNF */ #endif +#endif /* U_SHOW_CPLUSPLUS_API */ + /* RBNF_H */ #endif diff --git a/deps/icu-small/source/i18n/unicode/rbtz.h b/deps/icu-small/source/i18n/unicode/rbtz.h index 542a7c140cda2b..d66e1f08ec85d6 100644 --- a/deps/icu-small/source/i18n/unicode/rbtz.h +++ b/deps/icu-small/source/i18n/unicode/rbtz.h @@ -11,8 +11,10 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: Rule based customizable time zone */ @@ -121,7 +123,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 3.8 */ - virtual TimeZone* clone(void) const; + virtual RuleBasedTimeZone* clone() const; /** * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add @@ -224,6 +226,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -238,6 +241,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -359,6 +363,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // RBTZ_H //eof diff --git a/deps/icu-small/source/i18n/unicode/regex.h b/deps/icu-small/source/i18n/unicode/regex.h index a0f9839fe75311..69fb7ecd093ce7 100644 --- a/deps/icu-small/source/i18n/unicode/regex.h +++ b/deps/icu-small/source/i18n/unicode/regex.h @@ -44,6 +44,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "unicode/uobject.h" @@ -344,7 +346,7 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { */ virtual RegexMatcher *matcher(const UnicodeString &input, UErrorCode &status) const; - + private: /** * Cause a compilation error if an application accidentally attempts to @@ -424,8 +426,8 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { * @stable ICU 2.4 */ virtual UnicodeString pattern() const; - - + + /** * Returns the regular expression from which this pattern was compiled. This method will work * even if the pattern was compiled from a UnicodeString. @@ -482,9 +484,9 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { * * If the delimiter pattern includes capture groups, the captured text will * also appear in the destination array of output strings, interspersed - * with the fields. This is similar to Perl, but differs from Java, + * with the fields. This is similar to Perl, but differs from Java, * which ignores the presence of capture groups in the pattern. - * + * * Trailing empty fields will always be returned, assuming sufficient * destination capacity. This differs from the default behavior for Java * and Perl where trailing empty fields are not returned. @@ -526,9 +528,9 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { * * If the delimiter pattern includes capture groups, the captured text will * also appear in the destination array of output strings, interspersed - * with the fields. This is similar to Perl, but differs from Java, + * with the fields. This is similar to Perl, but differs from Java, * which ignores the presence of capture groups in the pattern. - * + * * Trailing empty fields will always be returned, assuming sufficient * destination capacity. This differs from the default behavior for Java * and Perl where trailing empty fields are not returned. @@ -552,7 +554,7 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { * of fields, the trailing part of the input string, including any * field delimiters, is placed in the last destination string. * @param status A reference to a UErrorCode to receive any errors. - * @return The number of destination strings used. + * @return The number of destination strings used. * * @stable ICU 4.6 */ @@ -599,7 +601,7 @@ class U_I18N_API RegexPattern U_FINAL : public UObject { // >= this value. For some patterns, this calculated // value may be less than the true shortest // possible match. - + int32_t fFrameSize; // Size of a state stack frame in the // execution engine. @@ -774,7 +776,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { /** - * Resets the matcher, then attempts to match the input beginning + * Resets the matcher, then attempts to match the input beginning * at the specified startIndex, and extending to the end of the input. * The input region is reset to include the entire input string. * A successful match must extend to the end of the input. @@ -788,7 +790,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { /** * Attempts to match the input string, starting from the beginning of the region, - * against the pattern. Like the matches() method, this function + * against the pattern. Like the matches() method, this function * always starts at the beginning of the input region; * unlike that function, it does not require that the entire region be matched. * @@ -914,7 +916,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * * @stable ICU 4.6 */ - virtual UText *group(UText *dest, int64_t &group_len, UErrorCode &status) const; + virtual UText *group(UText *dest, int64_t &group_len, UErrorCode &status) const; /** * Returns a shallow clone of the entire live input string with the UText current native index @@ -1126,14 +1128,14 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * without changing any other aspect of the matching state. * The new and previous text strings must have the same content. * - * This function is intended for use in environments where ICU is operating on + * This function is intended for use in environments where ICU is operating on * strings that may move around in memory. It provides a mechanism for notifying * ICU that the string has been relocated, and providing a new UText to access the * string in its new position. * * Note that the regular expression implementation never copies the underlying text - * of a string being matched, but always operates directly on the original text - * provided by the user. Refreshing simply drops the references to the old text + * of a string being matched, but always operates directly on the original text + * provided by the user. Refreshing simply drops the references to the old text * and replaces them with references to the new. * * Caution: this function is normally used only by very specialized, @@ -1143,7 +1145,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @param input The new (moved) text string. * @param status Receives errors detected by this function. * - * @stable ICU 4.8 + * @stable ICU 4.8 */ virtual RegexMatcher &refreshInputText(UText *input, UErrorCode &status); @@ -1171,7 +1173,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 2.4 */ virtual const UnicodeString &input() const; - + /** * Returns the input string being matched. This is the live input text; it should not be * altered or deleted. This method will work even if the input was originally supplied as @@ -1181,7 +1183,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 4.6 */ virtual UText *inputText() const; - + /** * Returns the input string being matched, either by copying it into the provided * UText parameter or by returning a shallow clone of the live input. Note that copying @@ -1193,7 +1195,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 4.6 */ virtual UText *getInput(UText *dest, UErrorCode &status) const; - + /** Sets the limits of this matcher's region. * The region is the part of the input string that will be searched to find a match. @@ -1215,14 +1217,14 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { */ virtual RegexMatcher ®ion(int64_t start, int64_t limit, UErrorCode &status); - /** + /** * Identical to region(start, limit, status) but also allows a start position without * resetting the region state. * @param regionStart The region start * @param regionLimit the limit of the region * @param startIndex The (native) index within the region bounds at which to begin searches. * @param status A reference to a UErrorCode to receive any errors. - * If startIndex is not within the specified region bounds, + * If startIndex is not within the specified region bounds, * U_INDEX_OUTOFBOUNDS_ERROR is returned. * @stable ICU 4.6 */ @@ -1299,14 +1301,14 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { **/ virtual RegexMatcher &useTransparentBounds(UBool b); - + /** * Return true if this matcher is using anchoring bounds. * By default, matchers use anchoring region bounds. * * @return TRUE if this matcher is using anchoring bounds. * @stable ICU 4.0 - */ + */ virtual UBool hasAnchoringBounds() const; @@ -1399,7 +1401,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 4.6 */ virtual UText *replaceAll(UText *replacement, UText *dest, UErrorCode &status); - + /** * Replaces the first substring of the input that matches @@ -1422,7 +1424,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 2.4 */ virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status); - + /** * Replaces the first substring of the input that matches @@ -1449,8 +1451,8 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 4.6 */ virtual UText *replaceFirst(UText *replacement, UText *dest, UErrorCode &status); - - + + /** * Implements a replace operation intended to be used as part of an * incremental find-and-replace. @@ -1480,8 +1482,8 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { */ virtual RegexMatcher &appendReplacement(UnicodeString &dest, const UnicodeString &replacement, UErrorCode &status); - - + + /** * Implements a replace operation intended to be used as part of an * incremental find-and-replace. @@ -1598,10 +1600,10 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { UText *dest[], int32_t destCapacity, UErrorCode &status); - + /** * Set a processing time limit for match operations with this Matcher. - * + * * Some patterns, when matching certain strings, can run in exponential time. * For practical purposes, the match operation may appear to be in an * infinite loop. @@ -1652,7 +1654,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { * @stable ICU 4.0 */ virtual void setStackLimit(int32_t limit, UErrorCode &status); - + /** * Get the size of the heap storage available for use by the back tracking stack. * @@ -1684,7 +1686,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { /** * Get the callback function for this URegularExpression. * - * @param callback Out parameter, receives a pointer to the user-supplied + * @param callback Out parameter, receives a pointer to the user-supplied * callback function. * @param context Out parameter, receives the user context pointer that * was set when uregex_setMatchCallback() was called. @@ -1717,7 +1719,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { /** * Get the find progress callback function for this URegularExpression. * - * @param callback Out parameter, receives a pointer to the user-supplied + * @param callback Out parameter, receives a pointer to the user-supplied * callback function. * @param context Out parameter, receives the user context pointer that * was set when uregex_setFindProgressCallback() was called. @@ -1784,9 +1786,9 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { // Call user find callback function, if set. Return TRUE if operation should be interrupted. inline UBool findProgressInterrupt(int64_t matchIndex, UErrorCode &status); - + int64_t appendGroup(int32_t groupNum, UText *dest, UErrorCode &status) const; - + UBool findUsingChunk(UErrorCode &status); void MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &status); UBool isChunkWordBoundary(int32_t pos); @@ -1801,13 +1803,13 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { // Only created if the pattern contains backreferences. int64_t fInputLength; // Full length of the input text. int32_t fFrameSize; // The size of a frame in the backtrack stack. - + int64_t fRegionStart; // Start of the input region, default = 0. int64_t fRegionLimit; // End of input region, default to input.length. - + int64_t fAnchorStart; // Region bounds for anchoring operations (^ or $). int64_t fAnchorLimit; // See useAnchoringBounds - + int64_t fLookStart; // Region bounds for look-ahead/behind and int64_t fLookLimit; // and other boundary tests. See // useTransparentBounds @@ -1829,7 +1831,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { // or -1 if there was no previous match. int64_t fAppendPosition; // First position after the end of the previous // appendReplacement(). As described by the - // JavaDoc for Java Matcher, where it is called + // JavaDoc for Java Matcher, where it is called // "append position" UBool fHitEnd; // True if the last match touched the end of input. UBool fRequireEnd; // True if the last match required end-of-input @@ -1845,7 +1847,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { int32_t fTimeLimit; // Max time (in arbitrary steps) to let the // match engine run. Zero for unlimited. - + int32_t fTime; // Match time, accumulates while matching. int32_t fTickCounter; // Low bits counter for time. Counts down StateSaves. // Kept separately from fTime to keep as much @@ -1876,4 +1878,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { U_NAMESPACE_END #endif // UCONFIG_NO_REGULAR_EXPRESSIONS + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/region.h b/deps/icu-small/source/i18n/unicode/region.h index ccd63901a5d1b1..9ec8dd45156f09 100644 --- a/deps/icu-small/source/i18n/unicode/region.h +++ b/deps/icu-small/source/i18n/unicode/region.h @@ -11,15 +11,17 @@ #define REGION_H /** - * \file + * \file * \brief C++ API: Region classes (territory containment) */ #include "unicode/utypes.h" -#include "unicode/uregion.h" + +#if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING +#include "unicode/uregion.h" #include "unicode/uobject.h" #include "unicode/uniset.h" #include "unicode/unistr.h" @@ -28,23 +30,23 @@ U_NAMESPACE_BEGIN /** - * Region is the class representing a Unicode Region Code, also known as a + * Region is the class representing a Unicode Region Code, also known as a * Unicode Region Subtag, which is defined based upon the BCP 47 standard. We often think of * "regions" as "countries" when defining the characteristics of a locale. Region codes There are different * types of region codes that are important to distinguish. *

- * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or - * selected economic and other grouping" as defined in - * UN M.49 (http://unstats.un.org/unsd/methods/m49/m49regin.htm). - * These are typically 3-digit codes, but contain some 2-letter codes, such as the LDML code QO + * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or + * selected economic and other grouping" as defined in + * UN M.49 (http://unstats.un.org/unsd/methods/m49/m49regin.htm). + * These are typically 3-digit codes, but contain some 2-letter codes, such as the LDML code QO * added for Outlying Oceania. Not all UNM.49 codes are defined in LDML, but most of them are. * Macroregions are represented in ICU by one of three region types: WORLD ( region code 001 ), * CONTINENTS ( regions contained directly by WORLD ), and SUBCONTINENTS ( things contained directly * by a continent ). *

* TERRITORY - A Region that is not a Macroregion. These are typically codes for countries, but also - * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code - * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate + * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code + * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate * codes. The codes are typically 2-letter codes aligned with the ISO 3166 standard, but BCP47 allows * for the use of 3-digit codes in the future. *

@@ -55,7 +57,7 @@ U_NAMESPACE_BEGIN * usually due to a country splitting into multiple territories or changing its name. *

* GROUPING - A widely understood grouping of territories that has a well defined membership such - * that a region code has been assigned for it. Some of these are UNM.49 codes that do't fall into + * that a region code has been assigned for it. Some of these are UNM.49 codes that do't fall into * the world/continent/sub-continent hierarchy, while others are just well known groupings that have * their own region code. Region "EU" (European Union) is one such region code that is a grouping. * Groupings will never be returned by the getContainingRegion() API, since a different type of region @@ -86,20 +88,20 @@ class U_I18N_API Region : public UObject { * @stable ICU 51 */ UBool operator!=(const Region &that) const; - + /** * Returns a pointer to a Region using the given region code. The region code can be either 2-letter ISO code, * 3-letter ISO code, UNM.49 numeric code, or other valid Unicode Region Code as defined by the LDML specification. * The identifier will be canonicalized internally using the supplemental metadata as defined in the CLDR. * If the region code is NULL or not recognized, the appropriate error code will be set ( U_ILLEGAL_ARGUMENT_ERROR ) - * @stable ICU 51 + * @stable ICU 51 */ static const Region* U_EXPORT2 getInstance(const char *region_code, UErrorCode &status); /** * Returns a pointer to a Region using the given numeric region code. If the numeric region code is not recognized, * the appropriate error code will be set ( U_ILLEGAL_ARGUMENT_ERROR ). - * @stable ICU 51 + * @stable ICU 51 */ static const Region* U_EXPORT2 getInstance (int32_t code, UErrorCode &status); @@ -108,12 +110,12 @@ class U_I18N_API Region : public UObject { * @stable ICU 55 */ static StringEnumeration* U_EXPORT2 getAvailable(URegionType type, UErrorCode &status); - + /** * Returns a pointer to the region that contains this region. Returns NULL if this region is code "001" (World) * or "ZZ" (Unknown region). For example, calling this method with region "IT" (Italy) returns the * region "039" (Southern Europe). - * @stable ICU 51 + * @stable ICU 51 */ const Region* getContainingRegion() const; @@ -123,7 +125,7 @@ class U_I18N_API Region : public UObject { * that matches the given type. Note: The URegionTypes = "URGN_GROUPING", "URGN_DEPRECATED", or "URGN_UNKNOWN" * are not appropriate for use in this API. NULL will be returned in this case. For example, calling this method * with region "IT" (Italy) for type "URGN_CONTINENT" returns the region "150" ( Europe ). - * @stable ICU 51 + * @stable ICU 51 */ const Region* getContainingRegion(URegionType type) const; @@ -146,10 +148,10 @@ class U_I18N_API Region : public UObject { * @stable ICU 55 */ StringEnumeration* getContainedRegions( URegionType type, UErrorCode &status ) const; - + /** * Returns true if this region contains the supplied other region anywhere in the region hierarchy. - * @stable ICU 51 + * @stable ICU 51 */ UBool contains(const Region &other) const; @@ -157,33 +159,33 @@ class U_I18N_API Region : public UObject { * For deprecated regions, return an enumeration over the IDs of the regions that are the preferred replacement * regions for this region. Returns null for a non-deprecated region. For example, calling this method with region * "SU" (Soviet Union) would return a list of the regions containing "RU" (Russia), "AM" (Armenia), "AZ" (Azerbaijan), etc... - * @stable ICU 55 + * @stable ICU 55 */ StringEnumeration* getPreferredValues(UErrorCode &status) const; /** * Return this region's canonical region code. - * @stable ICU 51 + * @stable ICU 51 */ const char* getRegionCode() const; /** * Return this region's numeric code. * Returns a negative value if the given region does not have a numeric code assigned to it. - * @stable ICU 51 + * @stable ICU 51 */ int32_t getNumericCode() const; /** * Returns the region type of this region. - * @stable ICU 51 + * @stable ICU 51 */ URegionType getType() const; #ifndef U_HIDE_INTERNAL_API /** * Cleans up statically allocated memory. - * @internal + * @internal */ static void cleanupRegionData(); #endif /* U_HIDE_INTERNAL_API */ @@ -207,7 +209,7 @@ class U_I18N_API Region : public UObject { * Initializes the region data from the ICU resource bundles. The region data * contains the basic relationships such as which regions are known, what the numeric * codes are, any known aliases, and the territory containment data. - * + * * If the region data has already loaded, then this method simply returns without doing * anything meaningful. */ @@ -219,6 +221,9 @@ class U_I18N_API Region : public UObject { U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // REGION_H //eof diff --git a/deps/icu-small/source/i18n/unicode/reldatefmt.h b/deps/icu-small/source/i18n/unicode/reldatefmt.h index cfcba0902675cc..044465b10f665a 100644 --- a/deps/icu-small/source/i18n/unicode/reldatefmt.h +++ b/deps/icu-small/source/i18n/unicode/reldatefmt.h @@ -15,6 +15,9 @@ #define __RELDATEFMT_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/udisplaycontext.h" #include "unicode/ureldatefmt.h" @@ -166,12 +169,24 @@ typedef enum UDateAbsoluteUnit { */ UDAT_ABSOLUTE_NOW, -#ifndef U_HIDE_DRAFT_API /** * Quarter - * @draft ICU 63 + * @stable ICU 63 */ UDAT_ABSOLUTE_QUARTER, + +#ifndef U_HIDE_DRAFT_API + /** + * Hour + * @draft ICU 65 + */ + UDAT_ABSOLUTE_HOUR, + + /** + * Minute + * @draft ICU 65 + */ + UDAT_ABSOLUTE_MINUTE, #endif // U_HIDE_DRAFT_API #ifndef U_HIDE_DEPRECATED_API @@ -179,7 +194,7 @@ typedef enum UDateAbsoluteUnit { * One more than the highest normal UDateAbsoluteUnit value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 2 + UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 4 #endif // U_HIDE_DEPRECATED_API } UDateAbsoluteUnit; @@ -246,6 +261,7 @@ class SharedPluralRules; class SharedBreakIterator; class NumberFormat; class UnicodeString; +class FormattedRelativeDateTime; class FormattedRelativeDateTimeData; #ifndef U_HIDE_DRAFT_API @@ -552,7 +568,7 @@ class U_I18N_API RelativeDateTimeFormatter : public UObject { * * This method returns a String. To get more information about the * formatting result, use formatNumericToValue(). - * + * * @param offset The signed offset for the specified unit. This * will be formatted according to this object's * NumberFormat object. @@ -579,7 +595,7 @@ class U_I18N_API RelativeDateTimeFormatter : public UObject { * * This method returns a FormattedRelativeDateTime, which exposes more * information than the String returned by formatNumeric(). - * + * * @param offset The signed offset for the specified unit. This * will be formatted according to this object's * NumberFormat object. @@ -743,4 +759,7 @@ U_NAMESPACE_END #endif /* !UCONFIG_NO_BREAK_ITERATION */ #endif /* !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif /* __RELDATEFMT_H */ diff --git a/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h b/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h index 6c99a246625e2e..7f860d4f592ac1 100644 --- a/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h +++ b/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h @@ -11,13 +11,15 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/unistr.h" /** - * \file + * \file * \brief C++ API: Formats in scientific notation. */ @@ -157,7 +159,7 @@ class U_I18N_API ScientificNumberFormatter : public UObject { class U_I18N_API SuperscriptStyle : public Style { public: - virtual Style *clone() const; + virtual SuperscriptStyle *clone() const; protected: virtual UnicodeString &format( const UnicodeString &original, @@ -175,7 +177,7 @@ class U_I18N_API ScientificNumberFormatter : public UObject { : Style(), fBeginMarkup(beginMarkup), fEndMarkup(endMarkup) { } - virtual Style *clone() const; + virtual MarkupStyle *clone() const; protected: virtual UnicodeString &format( const UnicodeString &original, @@ -214,4 +216,7 @@ U_NAMESPACE_END #endif /* !UCONFIG_NO_FORMATTING */ -#endif + +#endif /* U_SHOW_CPLUSPLUS_API */ + +#endif diff --git a/deps/icu-small/source/i18n/unicode/search.h b/deps/icu-small/source/i18n/unicode/search.h index 12dd5c77278f67..2865366a33ff31 100644 --- a/deps/icu-small/source/i18n/unicode/search.h +++ b/deps/icu-small/source/i18n/unicode/search.h @@ -14,11 +14,13 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: SearchIterator object. */ - + #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION #include "unicode/uobject.h" @@ -40,27 +42,27 @@ U_NAMESPACE_BEGIN /** * - * SearchIterator is an abstract base class that provides + * SearchIterator is an abstract base class that provides * methods to search for a pattern within a text string. Instances of - * SearchIterator maintain a current position and scans over the - * target text, returning the indices the pattern is matched and the length + * SearchIterator maintain a current position and scans over the + * target text, returning the indices the pattern is matched and the length * of each match. *

- * SearchIterator defines a protocol for text searching. - * Subclasses provide concrete implementations of various search algorithms. - * For example, StringSearch implements language-sensitive pattern - * matching based on the comparison rules defined in a - * RuleBasedCollator object. - *

- * Other options for searching includes using a BreakIterator to restrict + * SearchIterator defines a protocol for text searching. + * Subclasses provide concrete implementations of various search algorithms. + * For example, StringSearch implements language-sensitive pattern + * matching based on the comparison rules defined in a + * RuleBasedCollator object. + *

+ * Other options for searching includes using a BreakIterator to restrict * the points at which matches are detected. *

* SearchIterator provides an API that is similar to that of - * other text iteration classes such as BreakIterator. Using - * this class, it is easy to scan through text looking for all occurances of - * a given pattern. The following example uses a StringSearch - * object to find all instances of "fox" in the target string. Any other - * subclass of SearchIterator can be used in an identical + * other text iteration classes such as BreakIterator. Using + * this class, it is easy to scan through text looking for all occurances of + * a given pattern. The following example uses a StringSearch + * object to find all instances of "fox" in the target string. Any other + * subclass of SearchIterator can be used in an identical * manner. *


  * UnicodeString target("The quick brown fox jumped over the lazy fox");
@@ -68,10 +70,9 @@ U_NAMESPACE_BEGIN
  *
  * SearchIterator *iter  = new StringSearch(pattern, target);
  * UErrorCode      error = U_ZERO_ERROR;
- * for (int pos = iter->first(error); pos != USEARCH_DONE;
+ * for (int pos = iter->first(error); pos != USEARCH_DONE; 
  *                               pos = iter->next(error)) {
- *     printf("Found match at %d pos, length is %d\n", pos,
- *                                             iter.getMatchLength());
+ *     printf("Found match at %d pos, length is %d\n", pos, iter.getMatchedLength());
  * }
  * 
* @@ -84,9 +85,9 @@ class U_I18N_API SearchIterator : public UObject { // public constructors and destructors ------------------------------- - /** - * Copy constructor that creates a SearchIterator instance with the same - * behavior, and iterating over the same text. + /** + * Copy constructor that creates a SearchIterator instance with the same + * behavior, and iterating over the same text. * @param other the SearchIterator instance to be copied. * @stable ICU 2.0 */ @@ -101,14 +102,14 @@ class U_I18N_API SearchIterator : public UObject { // public get and set methods ---------------------------------------- /** - * Sets the index to point to the given position, and clears any state + * Sets the index to point to the given position, and clears any state * that's affected. *

- * This method takes the argument index and sets the position in the text - * string accordingly without checking if the index is pointing to a - * valid starting point to begin searching. + * This method takes the argument index and sets the position in the text + * string accordingly without checking if the index is pointing to a + * valid starting point to begin searching. * @param position within the text to be set. If position is less - * than or greater than the text range for searching, + * than or greater than the text range for searching, * an U_INDEX_OUTOFBOUNDS_ERROR will be returned * @param status for errors if it occurs * @stable ICU 2.0 @@ -126,7 +127,7 @@ class U_I18N_API SearchIterator : public UObject { virtual int32_t getOffset(void) const = 0; /** - * Sets the text searching attributes located in the enum + * Sets the text searching attributes located in the enum * USearchAttribute with values from the enum USearchAttributeValue. * USEARCH_DEFAULT can be used for all attributes for resetting. * @param attribute text attribute (enum USearchAttribute) to be set @@ -138,23 +139,23 @@ class U_I18N_API SearchIterator : public UObject { USearchAttributeValue value, UErrorCode &status); - /** + /** * Gets the text searching attributes * @param attribute text attribute (enum USearchAttribute) to be retrieve * @return text attribute value * @stable ICU 2.0 */ USearchAttributeValue getAttribute(USearchAttribute attribute) const; - + /** * Returns the index to the match in the text string that was searched. - * This call returns a valid result only after a successful call to + * This call returns a valid result only after a successful call to * first, next, previous, or last. - * Just after construction, or after a searching method returns + * Just after construction, or after a searching method returns * USEARCH_DONE, this method will return USEARCH_DONE. *

* Use getMatchedLength to get the matched string length. - * @return index of a substring within the text string that is being + * @return index of a substring within the text string that is being * searched. * @see #first * @see #next @@ -165,10 +166,10 @@ class U_I18N_API SearchIterator : public UObject { int32_t getMatchedStart(void) const; /** - * Returns the length of text in the string which matches the search - * pattern. This call returns a valid result only after a successful call + * Returns the length of text in the string which matches the search + * pattern. This call returns a valid result only after a successful call * to first, next, previous, or last. - * Just after construction, or after a searching method returns + * Just after construction, or after a searching method returns * USEARCH_DONE, this method will return 0. * @return The length of the match in the target text, or 0 if there * is no match currently. @@ -179,13 +180,13 @@ class U_I18N_API SearchIterator : public UObject { * @stable ICU 2.0 */ int32_t getMatchedLength(void) const; - + /** - * Returns the text that was matched by the most recent call to + * Returns the text that was matched by the most recent call to * first, next, previous, or last. - * If the iterator is not pointing at a valid match (e.g. just after - * construction or after USEARCH_DONE has been returned, - * returns an empty string. + * If the iterator is not pointing at a valid match (e.g. just after + * construction or after USEARCH_DONE has been returned, + * returns an empty string. * @param result stores the matched string or an empty string if a match * is not found. * @see #first @@ -195,16 +196,16 @@ class U_I18N_API SearchIterator : public UObject { * @stable ICU 2.0 */ void getMatchedText(UnicodeString &result) const; - + /** * Set the BreakIterator that will be used to restrict the points - * at which matches are detected. The user is responsible for deleting + * at which matches are detected. The user is responsible for deleting * the breakiterator. - * @param breakiter A BreakIterator that will be used to restrict the - * points at which matches are detected. If a match is - * found, but the match's start or end index is not a - * boundary as determined by the BreakIterator, - * the match will be rejected and another will be searched + * @param breakiter A BreakIterator that will be used to restrict the + * points at which matches are detected. If a match is + * found, but the match's start or end index is not a + * boundary as determined by the BreakIterator, + * the match will be rejected and another will be searched * for. If this parameter is NULL, no break * detection is attempted. * @param status for errors if it occurs @@ -212,10 +213,10 @@ class U_I18N_API SearchIterator : public UObject { * @stable ICU 2.0 */ void setBreakIterator(BreakIterator *breakiter, UErrorCode &status); - + /** - * Returns the BreakIterator that is used to restrict the points at - * which matches are detected. This will be the same object that was + * Returns the BreakIterator that is used to restrict the points at + * which matches are detected. This will be the same object that was * passed to the constructor or to setBreakIterator. * Note that NULL is a legal value; it means that break * detection should not be attempted. @@ -226,34 +227,34 @@ class U_I18N_API SearchIterator : public UObject { const BreakIterator * getBreakIterator(void) const; /** - * Set the string text to be searched. Text iteration will hence begin at - * the start of the text string. This method is useful if you want to - * re-use an iterator to search for the same pattern within a different + * Set the string text to be searched. Text iteration will hence begin at + * the start of the text string. This method is useful if you want to + * re-use an iterator to search for the same pattern within a different * body of text. The user is responsible for deleting the text. * @param text string to be searched. - * @param status for errors. If the text length is 0, + * @param status for errors. If the text length is 0, * an U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ - virtual void setText(const UnicodeString &text, UErrorCode &status); + virtual void setText(const UnicodeString &text, UErrorCode &status); /** - * Set the string text to be searched. Text iteration will hence begin at - * the start of the text string. This method is useful if you want to - * re-use an iterator to search for the same pattern within a different + * Set the string text to be searched. Text iteration will hence begin at + * the start of the text string. This method is useful if you want to + * re-use an iterator to search for the same pattern within a different * body of text. *

- * Note: No parsing of the text within the CharacterIterator - * will be done during searching for this version. The block of text + * Note: No parsing of the text within the CharacterIterator + * will be done during searching for this version. The block of text * in CharacterIterator will be used as it is. * The user is responsible for deleting the text. * @param text string iterator to be searched. - * @param status for errors if any. If the text length is 0 then an + * @param status for errors if any. If the text length is 0 then an * U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ virtual void setText(CharacterIterator &text, UErrorCode &status); - + /** * Return the string text to be searched. * @return text string to be searched. @@ -264,9 +265,9 @@ class U_I18N_API SearchIterator : public UObject { // operator overloading ---------------------------------------------- /** - * Equality operator. + * Equality operator. * @param that SearchIterator instance to be compared. - * @return TRUE if both BreakIterators are of the same class, have the + * @return TRUE if both BreakIterators are of the same class, have the * same behavior, terates over the same text and have the same * attributes. FALSE otherwise. * @stable ICU 2.0 @@ -274,7 +275,7 @@ class U_I18N_API SearchIterator : public UObject { virtual UBool operator==(const SearchIterator &that) const; /** - * Not-equal operator. + * Not-equal operator. * @param that SearchIterator instance to be compared. * @return FALSE if operator== returns TRUE, and vice versa. * @stable ICU 2.0 @@ -284,7 +285,7 @@ class U_I18N_API SearchIterator : public UObject { // public methods ---------------------------------------------------- /** - * Returns a copy of SearchIterator with the same behavior, and + * Returns a copy of SearchIterator with the same behavior, and * iterating over the same text, as this one. Note that all data will be * replicated, except for the text string to be searched. * @return cloned object @@ -293,14 +294,14 @@ class U_I18N_API SearchIterator : public UObject { virtual SearchIterator* safeClone(void) const = 0; /** - * Returns the first index at which the string text matches the search - * pattern. The iterator is adjusted so that its current index (as - * returned by getOffset) is the match position if one + * Returns the first index at which the string text matches the search + * pattern. The iterator is adjusted so that its current index (as + * returned by getOffset) is the match position if one * was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE * @param status for errors if it occurs - * @return The character index of the first match, or + * @return The character index of the first match, or * USEARCH_DONE if there are no matches. * @see #getOffset * @stable ICU 2.0 @@ -308,33 +309,33 @@ class U_I18N_API SearchIterator : public UObject { int32_t first(UErrorCode &status); /** - * Returns the first index equal or greater than position at which the - * string text matches the search pattern. The iterator is adjusted so - * that its current index (as returned by getOffset) is the + * Returns the first index equal or greater than position at which the + * string text matches the search pattern. The iterator is adjusted so + * that its current index (as returned by getOffset) is the * match position if one was found. * If a match is not found, USEARCH_DONE will be returned and the * iterator will be adjusted to the index USEARCH_DONE. * @param position where search if to start from. If position is less - * than or greater than the text range for searching, + * than or greater than the text range for searching, * an U_INDEX_OUTOFBOUNDS_ERROR will be returned * @param status for errors if it occurs - * @return The character index of the first match following - * position, or USEARCH_DONE if there are no + * @return The character index of the first match following + * position, or USEARCH_DONE if there are no * matches. * @see #getOffset * @stable ICU 2.0 */ int32_t following(int32_t position, UErrorCode &status); - + /** - * Returns the last index in the target text at which it matches the - * search pattern. The iterator is adjusted so that its current index - * (as returned by getOffset) is the match position if one was + * Returns the last index in the target text at which it matches the + * search pattern. The iterator is adjusted so that its current index + * (as returned by getOffset) is the match position if one was * found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE. * @param status for errors if it occurs - * @return The index of the first match, or USEARCH_DONE if + * @return The index of the first match, or USEARCH_DONE if * there are no matches. * @see #getOffset * @stable ICU 2.0 @@ -342,11 +343,11 @@ class U_I18N_API SearchIterator : public UObject { int32_t last(UErrorCode &status); /** - * Returns the first index less than position at which the string - * text matches the search pattern. The iterator is adjusted so that its - * current index (as returned by getOffset) is the match - * position if one was found. If a match is not found, - * USEARCH_DONE will be returned and the iterator will be + * Returns the first index less than position at which the string + * text matches the search pattern. The iterator is adjusted so that its + * current index (as returned by getOffset) is the match + * position if one was found. If a match is not found, + * USEARCH_DONE will be returned and the iterator will be * adjusted to the index USEARCH_DONE *

* When USEARCH_OVERLAP option is off, the last index of the @@ -355,11 +356,11 @@ class U_I18N_API SearchIterator : public UObject { * position. * * @param position where search is to start from. If position is less - * than or greater than the text range for searching, + * than or greater than the text range for searching, * an U_INDEX_OUTOFBOUNDS_ERROR will be returned * @param status for errors if it occurs - * @return The character index of the first match preceding - * position, or USEARCH_DONE if there are + * @return The character index of the first match preceding + * position, or USEARCH_DONE if there are * no matches. * @see #getOffset * @stable ICU 2.0 @@ -369,10 +370,10 @@ class U_I18N_API SearchIterator : public UObject { /** * Returns the index of the next point at which the text matches the * search pattern, starting from the current position - * The iterator is adjusted so that its current index (as returned by + * The iterator is adjusted so that its current index (as returned by * getOffset) is the match position if one was found. * If a match is not found, USEARCH_DONE will be returned and - * the iterator will be adjusted to a position after the end of the text + * the iterator will be adjusted to a position after the end of the text * string. * @param status for errors if it occurs * @return The index of the next match after the current position, @@ -383,9 +384,9 @@ class U_I18N_API SearchIterator : public UObject { int32_t next(UErrorCode &status); /** - * Returns the index of the previous point at which the string text + * Returns the index of the previous point at which the string text * matches the search pattern, starting at the current position. - * The iterator is adjusted so that its current index (as returned by + * The iterator is adjusted so that its current index (as returned by * getOffset) is the match position if one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE @@ -397,12 +398,12 @@ class U_I18N_API SearchIterator : public UObject { */ int32_t previous(UErrorCode &status); - /** + /** * Resets the iteration. - * Search will begin at the start of the text string if a forward - * iteration is initiated before a backwards iteration. Otherwise if a - * backwards iteration is initiated before a forwards iteration, the - * search will begin at the end of the text string. + * Search will begin at the start of the text string if a forward + * iteration is initiated before a backwards iteration. Otherwise if a + * backwards iteration is initiated before a forwards iteration, the + * search will begin at the end of the text string. * @stable ICU 2.0 */ virtual void reset(); @@ -425,7 +426,7 @@ class U_I18N_API SearchIterator : public UObject { * @stable ICU 2.0 */ BreakIterator *m_breakiterator_; - + /** * Unicode string version of the search text * @stable ICU 2.0 @@ -444,35 +445,35 @@ class U_I18N_API SearchIterator : public UObject { /** * Constructor for use by subclasses. * @param text The target text to be searched. - * @param breakiter A {@link BreakIterator} that is used to restrict the - * points at which matches are detected. If - * handleNext or handlePrev finds a - * match, but the match's start or end index is not a - * boundary as determined by the BreakIterator, - * the match is rejected and handleNext or - * handlePrev is called again. If this parameter - * is NULL, no break detection is attempted. + * @param breakiter A {@link BreakIterator} that is used to restrict the + * points at which matches are detected. If + * handleNext or handlePrev finds a + * match, but the match's start or end index is not a + * boundary as determined by the BreakIterator, + * the match is rejected and handleNext or + * handlePrev is called again. If this parameter + * is NULL, no break detection is attempted. * @see #handleNext * @see #handlePrev * @stable ICU 2.0 */ - SearchIterator(const UnicodeString &text, + SearchIterator(const UnicodeString &text, BreakIterator *breakiter = NULL); /** * Constructor for use by subclasses. *

- * Note: No parsing of the text within the CharacterIterator - * will be done during searching for this version. The block of text + * Note: No parsing of the text within the CharacterIterator + * will be done during searching for this version. The block of text * in CharacterIterator will be used as it is. * @param text The target text to be searched. - * @param breakiter A {@link BreakIterator} that is used to restrict the - * points at which matches are detected. If - * handleNext or handlePrev finds a - * match, but the match's start or end index is not a - * boundary as determined by the BreakIterator, - * the match is rejected and handleNext or - * handlePrev is called again. If this parameter + * @param breakiter A {@link BreakIterator} that is used to restrict the + * points at which matches are detected. If + * handleNext or handlePrev finds a + * match, but the match's start or end index is not a + * boundary as determined by the BreakIterator, + * the match is rejected and handleNext or + * handlePrev is called again. If this parameter * is NULL, no break detection is attempted. * @see #handleNext * @see #handlePrev @@ -496,20 +497,20 @@ class U_I18N_API SearchIterator : public UObject { * subclasses to provide different search algorithms. *

* If a match is found, the implementation should return the index at - * which the match starts and should call - * setMatchLength with the number of characters - * in the target text that make up the match. If no match is found, the + * which the match starts and should call + * setMatchLength with the number of characters + * in the target text that make up the match. If no match is found, the * method should return USEARCH_DONE. *

- * @param position The index in the target text at which the search + * @param position The index in the target text at which the search * should start. * @param status for error codes if it occurs. - * @return index at which the match starts, else if match is not found + * @return index at which the match starts, else if match is not found * USEARCH_DONE is returned * @see #setMatchLength * @stable ICU 2.0 */ - virtual int32_t handleNext(int32_t position, UErrorCode &status) + virtual int32_t handleNext(int32_t position, UErrorCode &status) = 0; /** @@ -518,20 +519,20 @@ class U_I18N_API SearchIterator : public UObject { * subclasses to provide different search algorithms. *

* If a match is found, the implementation should return the index at - * which the match starts and should call - * setMatchLength with the number of characters - * in the target text that make up the match. If no match is found, the + * which the match starts and should call + * setMatchLength with the number of characters + * in the target text that make up the match. If no match is found, the * method should return USEARCH_DONE. *

- * @param position The index in the target text at which the search + * @param position The index in the target text at which the search * should start. * @param status for error codes if it occurs. - * @return index at which the match starts, else if match is not found + * @return index at which the match starts, else if match is not found * USEARCH_DONE is returned * @see #setMatchLength * @stable ICU 2.0 */ - virtual int32_t handlePrev(int32_t position, UErrorCode &status) + virtual int32_t handlePrev(int32_t position, UErrorCode &status) = 0; /** @@ -559,7 +560,7 @@ class U_I18N_API SearchIterator : public UObject { virtual void setMatchStart(int32_t position); /** - * sets match not found + * sets match not found * @stable ICU 2.0 */ void setMatchNotFound(); @@ -567,10 +568,13 @@ class U_I18N_API SearchIterator : public UObject { inline UBool SearchIterator::operator!=(const SearchIterator &that) const { - return !operator==(that); + return !operator==(that); } U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif + diff --git a/deps/icu-small/source/i18n/unicode/selfmt.h b/deps/icu-small/source/i18n/unicode/selfmt.h index 08e9d444ee9715..9b98f6db7adb76 100755 --- a/deps/icu-small/source/i18n/unicode/selfmt.h +++ b/deps/icu-small/source/i18n/unicode/selfmt.h @@ -18,9 +18,12 @@ #ifndef SELFMT #define SELFMT +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/messagepattern.h" #include "unicode/numfmt.h" -#include "unicode/utypes.h" /** * \file @@ -272,7 +275,7 @@ class U_I18N_API SelectFormat : public Format { * result and should delete it when done. * @stable ICU 4.4 */ - virtual Format* clone(void) const; + virtual SelectFormat* clone() const; /** * Format an object to produce a string. @@ -365,5 +368,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SELFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/simpletz.h b/deps/icu-small/source/i18n/unicode/simpletz.h index 7f5f1664cca503..980a1b8c62e0d4 100644 --- a/deps/icu-small/source/i18n/unicode/simpletz.h +++ b/deps/icu-small/source/i18n/unicode/simpletz.h @@ -28,11 +28,13 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: SimpleTimeZone is a concrete subclass of TimeZone. */ - + #if !UCONFIG_NO_FORMATTING #include "unicode/basictz.h" @@ -672,6 +674,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Returns true if the given date is within the period when daylight savings time * is in effect; false otherwise. If the TimeZone doesn't observe daylight savings @@ -687,6 +690,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Return true if this zone has the same rules and offset as another zone. @@ -703,7 +707,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 2.0 */ - virtual TimeZone* clone(void) const; + virtual SimpleTimeZone* clone() const; /** * Gets the first time zone transition after the base time. @@ -929,4 +933,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SIMPLETZ diff --git a/deps/icu-small/source/i18n/unicode/smpdtfmt.h b/deps/icu-small/source/i18n/unicode/smpdtfmt.h index a015c5be5c877a..79fa817d5afb89 100644 --- a/deps/icu-small/source/i18n/unicode/smpdtfmt.h +++ b/deps/icu-small/source/i18n/unicode/smpdtfmt.h @@ -28,6 +28,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Format and parse dates in a language-independent manner. @@ -865,7 +867,7 @@ class U_I18N_API SimpleDateFormat: public DateFormat { * @return A copy of the object. * @stable ICU 2.0 */ - virtual Format* clone(void) const; + virtual SimpleDateFormat* clone() const; /** * Return true if the given Format objects are semantically equal. Objects @@ -1643,7 +1645,7 @@ class U_I18N_API SimpleDateFormat: public DateFormat { UBool fHaveDefaultCentury; - BreakIterator* fCapitalizationBrkIter; + const BreakIterator* fCapitalizationBrkIter; }; inline UDate @@ -1656,5 +1658,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SMPDTFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/sortkey.h b/deps/icu-small/source/i18n/unicode/sortkey.h index 6895be7a2b0ee4..34ed7ee69217fb 100644 --- a/deps/icu-small/source/i18n/unicode/sortkey.h +++ b/deps/icu-small/source/i18n/unicode/sortkey.h @@ -25,11 +25,13 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file - * \brief C++ API: Keys for comparing strings multiple times. + * \file + * \brief C++ API: Keys for comparing strings multiple times. */ - + #if !UCONFIG_NO_COLLATION #include "unicode/uobject.h" @@ -184,7 +186,7 @@ class U_I18N_API CollationKey : public UObject { uint8_t* toByteArray(int32_t& count) const; #endif -#ifndef U_HIDE_DEPRECATED_API +#ifndef U_HIDE_DEPRECATED_API /** * Convenience method which does a string(bit-wise) comparison of the * two collation keys. @@ -337,4 +339,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/stsearch.h b/deps/icu-small/source/i18n/unicode/stsearch.h index 46bc51b30e2346..fcb5dbf2009f84 100644 --- a/deps/icu-small/source/i18n/unicode/stsearch.h +++ b/deps/icu-small/source/i18n/unicode/stsearch.h @@ -14,11 +14,13 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: Service for searching text based on RuleBasedCollator. */ - + #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION #include "unicode/tblcoll.h" @@ -27,7 +29,7 @@ U_NAMESPACE_BEGIN -/** +/** * * StringSearch is a SearchIterator that provides * language-sensitive text searching based on the comparison rules defined @@ -44,7 +46,7 @@ U_NAMESPACE_BEGIN *
* A pattern string P matches a text string S at the offsets [start, end] * if - *

+ * 
 
  * option 1. Some canonical equivalent of P matches some canonical equivalent
  *           of S'
  * option 2. P matches S' and if P starts or ends with a combining mark,
@@ -53,10 +55,10 @@ U_NAMESPACE_BEGIN
  * 
* Option 2. will be the default. *

- * This search has APIs similar to that of other text iteration mechanisms - * such as the break iterators in BreakIterator. Using these - * APIs, it is easy to scan through text looking for all occurrences of - * a given pattern. This search iterator allows changing of direction by + * This search has APIs similar to that of other text iteration mechanisms + * such as the break iterators in BreakIterator. Using these + * APIs, it is easy to scan through text looking for all occurrences of + * a given pattern. This search iterator allows changing of direction by * calling a reset followed by a next or previous. * Though a direction change can occur without calling reset first, * this operation comes with some speed penalty. @@ -99,7 +101,7 @@ U_NAMESPACE_BEGIN * from getCollator and using the APIs in coll.h. * Lastly to update StringSearch to the new collator attributes, * reset has to be called. - *

+ *

* Restriction:
* Currently there are no composite characters that consists of a * character with combining class > 0 before a character with combining @@ -116,11 +118,10 @@ U_NAMESPACE_BEGIN * UErrorCode error = U_ZERO_ERROR; * StringSearch iter(pattern, target, Locale::getUS(), NULL, status); * for (int pos = iter.first(error); - * pos != USEARCH_DONE; + * pos != USEARCH_DONE; * pos = iter.next(error)) * { - * printf("Found match at %d pos, length is %d\n", pos, - * iter.getMatchLength()); + * printf("Found match at %d pos, length is %d\n", pos, iter.getMatchedLength()); * } *

*

@@ -138,120 +139,120 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator // public constructors and destructors -------------------------------- /** - * Creating a StringSearch instance using the argument locale - * language rule set. A collator will be created in the process, which - * will be owned by this instance and will be deleted during + * Creating a StringSearch instance using the argument locale + * language rule set. A collator will be created in the process, which + * will be owned by this instance and will be deleted during * destruction * @param pattern The text for which this object will search. * @param text The text in which to search for the pattern. - * @param locale A locale which defines the language-sensitive - * comparison rules used to determine whether text in the - * pattern and target matches. - * @param breakiter A BreakIterator object used to constrain - * the matches that are found. Matches whose start and end - * indices in the target text are not boundaries as - * determined by the BreakIterator are - * ignored. If this behavior is not desired, + * @param locale A locale which defines the language-sensitive + * comparison rules used to determine whether text in the + * pattern and target matches. + * @param breakiter A BreakIterator object used to constrain + * the matches that are found. Matches whose start and end + * indices in the target text are not boundaries as + * determined by the BreakIterator are + * ignored. If this behavior is not desired, * NULL can be passed in instead. * @param status for errors if any. If pattern or text is NULL, or if - * either the length of pattern or text is 0 then an + * either the length of pattern or text is 0 then an * U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ StringSearch(const UnicodeString &pattern, const UnicodeString &text, - const Locale &locale, + const Locale &locale, BreakIterator *breakiter, UErrorCode &status); /** - * Creating a StringSearch instance using the argument collator - * language rule set. Note, user retains the ownership of this collator, + * Creating a StringSearch instance using the argument collator + * language rule set. Note, user retains the ownership of this collator, * it does not get destroyed during this instance's destruction. * @param pattern The text for which this object will search. * @param text The text in which to search for the pattern. - * @param coll A RuleBasedCollator object which defines - * the language-sensitive comparison rules used to - * determine whether text in the pattern and target + * @param coll A RuleBasedCollator object which defines + * the language-sensitive comparison rules used to + * determine whether text in the pattern and target * matches. User is responsible for the clearing of this * object. - * @param breakiter A BreakIterator object used to constrain - * the matches that are found. Matches whose start and end - * indices in the target text are not boundaries as - * determined by the BreakIterator are - * ignored. If this behavior is not desired, + * @param breakiter A BreakIterator object used to constrain + * the matches that are found. Matches whose start and end + * indices in the target text are not boundaries as + * determined by the BreakIterator are + * ignored. If this behavior is not desired, * NULL can be passed in instead. - * @param status for errors if any. If either the length of pattern or + * @param status for errors if any. If either the length of pattern or * text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ - StringSearch(const UnicodeString &pattern, + StringSearch(const UnicodeString &pattern, const UnicodeString &text, - RuleBasedCollator *coll, + RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status); /** - * Creating a StringSearch instance using the argument locale - * language rule set. A collator will be created in the process, which - * will be owned by this instance and will be deleted during + * Creating a StringSearch instance using the argument locale + * language rule set. A collator will be created in the process, which + * will be owned by this instance and will be deleted during * destruction *

- * Note: No parsing of the text within the CharacterIterator - * will be done during searching for this version. The block of text + * Note: No parsing of the text within the CharacterIterator + * will be done during searching for this version. The block of text * in CharacterIterator will be used as it is. * @param pattern The text for which this object will search. * @param text The text iterator in which to search for the pattern. - * @param locale A locale which defines the language-sensitive - * comparison rules used to determine whether text in the - * pattern and target matches. User is responsible for + * @param locale A locale which defines the language-sensitive + * comparison rules used to determine whether text in the + * pattern and target matches. User is responsible for * the clearing of this object. - * @param breakiter A BreakIterator object used to constrain - * the matches that are found. Matches whose start and end - * indices in the target text are not boundaries as - * determined by the BreakIterator are - * ignored. If this behavior is not desired, + * @param breakiter A BreakIterator object used to constrain + * the matches that are found. Matches whose start and end + * indices in the target text are not boundaries as + * determined by the BreakIterator are + * ignored. If this behavior is not desired, * NULL can be passed in instead. - * @param status for errors if any. If either the length of pattern or + * @param status for errors if any. If either the length of pattern or * text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ StringSearch(const UnicodeString &pattern, CharacterIterator &text, - const Locale &locale, + const Locale &locale, BreakIterator *breakiter, UErrorCode &status); /** - * Creating a StringSearch instance using the argument collator - * language rule set. Note, user retains the ownership of this collator, + * Creating a StringSearch instance using the argument collator + * language rule set. Note, user retains the ownership of this collator, * it does not get destroyed during this instance's destruction. *

- * Note: No parsing of the text within the CharacterIterator - * will be done during searching for this version. The block of text + * Note: No parsing of the text within the CharacterIterator + * will be done during searching for this version. The block of text * in CharacterIterator will be used as it is. * @param pattern The text for which this object will search. * @param text The text in which to search for the pattern. - * @param coll A RuleBasedCollator object which defines - * the language-sensitive comparison rules used to - * determine whether text in the pattern and target + * @param coll A RuleBasedCollator object which defines + * the language-sensitive comparison rules used to + * determine whether text in the pattern and target * matches. User is responsible for the clearing of this * object. - * @param breakiter A BreakIterator object used to constrain - * the matches that are found. Matches whose start and end - * indices in the target text are not boundaries as - * determined by the BreakIterator are - * ignored. If this behavior is not desired, + * @param breakiter A BreakIterator object used to constrain + * the matches that are found. Matches whose start and end + * indices in the target text are not boundaries as + * determined by the BreakIterator are + * ignored. If this behavior is not desired, * NULL can be passed in instead. - * @param status for errors if any. If either the length of pattern or + * @param status for errors if any. If either the length of pattern or * text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ StringSearch(const UnicodeString &pattern, CharacterIterator &text, - RuleBasedCollator *coll, + RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status); /** - * Copy constructor that creates a StringSearch instance with the same + * Copy constructor that creates a StringSearch instance with the same * behavior, and iterating over the same text. * @param that StringSearch instance to be copied. * @stable ICU 2.0 @@ -289,10 +290,10 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator StringSearch & operator=(const StringSearch &that); /** - * Equality operator. + * Equality operator. * @param that instance to be compared. - * @return TRUE if both instances have the same attributes, - * breakiterators, collators and iterate over the same text + * @return TRUE if both instances have the same attributes, + * breakiterators, collators and iterate over the same text * while looking for the same pattern. * @stable ICU 2.0 */ @@ -301,14 +302,14 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator // public get and set methods ---------------------------------------- /** - * Sets the index to point to the given position, and clears any state + * Sets the index to point to the given position, and clears any state * that's affected. *

- * This method takes the argument index and sets the position in the text - * string accordingly without checking if the index is pointing to a - * valid starting point to begin searching. + * This method takes the argument index and sets the position in the text + * string accordingly without checking if the index is pointing to a + * valid starting point to begin searching. * @param position within the text to be set. If position is less - * than or greater than the text range for searching, + * than or greater than the text range for searching, * an U_INDEX_OUTOFBOUNDS_ERROR will be returned * @param status for errors if it occurs * @stable ICU 2.0 @@ -327,28 +328,28 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator /** * Set the target text to be searched. - * Text iteration will hence begin at the start of the text string. - * This method is - * useful if you want to re-use an iterator to search for the same + * Text iteration will hence begin at the start of the text string. + * This method is + * useful if you want to re-use an iterator to search for the same * pattern within a different body of text. * @param text text string to be searched - * @param status for errors if any. If the text length is 0 then an + * @param status for errors if any. If the text length is 0 then an * U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ virtual void setText(const UnicodeString &text, UErrorCode &status); - + /** * Set the target text to be searched. - * Text iteration will hence begin at the start of the text string. - * This method is - * useful if you want to re-use an iterator to search for the same + * Text iteration will hence begin at the start of the text string. + * This method is + * useful if you want to re-use an iterator to search for the same * pattern within a different body of text. - * Note: No parsing of the text within the CharacterIterator - * will be done during searching for this version. The block of text + * Note: No parsing of the text within the CharacterIterator + * will be done during searching for this version. The block of text * in CharacterIterator will be used as it is. * @param text text string to be searched - * @param status for errors if any. If the text length is 0 then an + * @param status for errors if any. If the text length is 0 then an * U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ @@ -358,33 +359,33 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator * Gets the collator used for the language rules. *

* Caller may modify but must not delete the RuleBasedCollator! - * Modifications to this collator will affect the original collator passed in to + * Modifications to this collator will affect the original collator passed in to * the StringSearch> constructor or to setCollator, if any. * @return collator used for string search * @stable ICU 2.0 */ RuleBasedCollator * getCollator() const; - + /** - * Sets the collator used for the language rules. User retains the - * ownership of this collator, thus the responsibility of deletion lies + * Sets the collator used for the language rules. User retains the + * ownership of this collator, thus the responsibility of deletion lies * with the user. The iterator's position will not be changed by this method. - * @param coll collator + * @param coll collator * @param status for errors if any * @stable ICU 2.0 */ void setCollator(RuleBasedCollator *coll, UErrorCode &status); - + /** * Sets the pattern used for matching. * The iterator's position will not be changed by this method. * @param pattern search pattern to be found - * @param status for errors if any. If the pattern length is 0 then an + * @param status for errors if any. If the pattern length is 0 then an * U_ILLEGAL_ARGUMENT_ERROR is returned. * @stable ICU 2.0 */ void setPattern(const UnicodeString &pattern, UErrorCode &status); - + /** * Gets the search pattern. * @return pattern used for matching @@ -394,26 +395,26 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator // public methods ---------------------------------------------------- - /** + /** * Reset the iteration. - * Search will begin at the start of the text string if a forward - * iteration is initiated before a backwards iteration. Otherwise if - * a backwards iteration is initiated before a forwards iteration, the + * Search will begin at the start of the text string if a forward + * iteration is initiated before a backwards iteration. Otherwise if + * a backwards iteration is initiated before a forwards iteration, the * search will begin at the end of the text string. * @stable ICU 2.0 */ virtual void reset(); /** - * Returns a copy of StringSearch with the same behavior, and + * Returns a copy of StringSearch with the same behavior, and * iterating over the same text, as this one. Note that all data will be * replicated, except for the user-specified collator and the * breakiterator. * @return cloned object * @stable ICU 2.0 */ - virtual SearchIterator * safeClone(void) const; - + virtual StringSearch * safeClone() const; + /** * ICU "poor man's RTTI", returns a UClassID for the actual class. * @@ -434,23 +435,23 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator /** * Search forward for matching text, starting at a given location. - * Clients should not call this method directly; instead they should + * Clients should not call this method directly; instead they should * call {@link SearchIterator#next }. *

* If a match is found, this method returns the index at which the match - * starts and calls {@link SearchIterator#setMatchLength } with the number - * of characters in the target text that make up the match. If no match + * starts and calls {@link SearchIterator#setMatchLength } with the number + * of characters in the target text that make up the match. If no match * is found, the method returns USEARCH_DONE. *

- * The StringSearch is adjusted so that its current index - * (as returned by {@link #getOffset }) is the match position if one was + * The StringSearch is adjusted so that its current index + * (as returned by {@link #getOffset }) is the match position if one was * found. * If a match is not found, USEARCH_DONE will be returned and * the StringSearch will be adjusted to the index USEARCH_DONE. - * @param position The index in the target text at which the search + * @param position The index in the target text at which the search * starts * @param status for errors if any occurs - * @return The index at which the matched text in the target starts, or + * @return The index at which the matched text in the target starts, or * USEARCH_DONE if no match was found. * @stable ICU 2.0 */ @@ -462,24 +463,24 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator * SearchIterator.previous(), which this method overrides. *

* If a match is found, this method returns the index at which the match - * starts and calls {@link SearchIterator#setMatchLength } with the number - * of characters in the target text that make up the match. If no match + * starts and calls {@link SearchIterator#setMatchLength } with the number + * of characters in the target text that make up the match. If no match * is found, the method returns USEARCH_DONE. *

- * The StringSearch is adjusted so that its current index - * (as returned by {@link #getOffset }) is the match position if one was + * The StringSearch is adjusted so that its current index + * (as returned by {@link #getOffset }) is the match position if one was * found. * If a match is not found, USEARCH_DONE will be returned and * the StringSearch will be adjusted to the index USEARCH_DONE. - * @param position The index in the target text at which the search + * @param position The index in the target text at which the search * starts. * @param status for errors if any occurs - * @return The index at which the matched text in the target starts, or + * @return The index at which the matched text in the target starts, or * USEARCH_DONE if no match was found. * @stable ICU 2.0 */ virtual int32_t handlePrev(int32_t position, UErrorCode &status); - + private : StringSearch(); // default constructor not implemented @@ -502,4 +503,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif + diff --git a/deps/icu-small/source/i18n/unicode/tblcoll.h b/deps/icu-small/source/i18n/unicode/tblcoll.h index 24ba213b41eacc..f5dc135bc49fc1 100644 --- a/deps/icu-small/source/i18n/unicode/tblcoll.h +++ b/deps/icu-small/source/i18n/unicode/tblcoll.h @@ -64,6 +64,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_COLLATION #include "unicode/coll.h" @@ -228,7 +230,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @return a copy of this object, owned by the caller * @stable ICU 2.0 */ - virtual Collator* clone(void) const; + virtual RuleBasedCollator* clone() const; /** * Creates a collation element iterator for the source string. The caller of @@ -389,6 +391,7 @@ class U_I18N_API RuleBasedCollator : public Collator { */ virtual int32_t hashCode() const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the locale of the Collator * @param type can be either requested, valid or actual locale. For more @@ -400,6 +403,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback */ virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the tailoring rules for this collator. @@ -545,6 +549,7 @@ class U_I18N_API RuleBasedCollator : public Collator { */ virtual UColReorderCode getMaxVariable() const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Sets the variable top to the primary weight of the specified string. * @@ -592,6 +597,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @deprecated ICU 53 Call setMaxVariable() instead. */ virtual void setVariableTop(uint32_t varTop, UErrorCode &status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the variable top value of a Collator. @@ -874,4 +880,7 @@ class U_I18N_API RuleBasedCollator : public Collator { U_NAMESPACE_END #endif // !UCONFIG_NO_COLLATION + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TBLCOLL_H diff --git a/deps/icu-small/source/i18n/unicode/timezone.h b/deps/icu-small/source/i18n/unicode/timezone.h index 237ed911d09211..433e3b5c466690 100644 --- a/deps/icu-small/source/i18n/unicode/timezone.h +++ b/deps/icu-small/source/i18n/unicode/timezone.h @@ -31,8 +31,10 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: TimeZone object */ @@ -182,10 +184,10 @@ class U_I18N_API TimeZone : public UObject { * @param zoneType The system time zone type. * @param region The ISO 3166 two-letter country code or UN M.49 * three-digit area code. When NULL, no filtering - * done by region. + * done by region. * @param rawOffset An offset from GMT in milliseconds, ignoring * the effect of daylight savings time, if any. - * When NULL, no filtering done by zone offset. + * When NULL, no filtering done by zone offset. * @param ec Output param to filled in with a success or * an error. * @return an enumeration object, owned by the caller. @@ -280,9 +282,9 @@ class U_I18N_API TimeZone : public UObject { * system configuration. If the host system detection routines fail, * or if they specify a TimeZone or TimeZone offset which is not * recognized, then the special TimeZone "Etc/Unknown" is returned. - * + * * Note that ICU4C does not change the default time zone unless - * `TimeZone::adoptDefault(TimeZone*)` or + * `TimeZone::adoptDefault(TimeZone*)` or * `TimeZone::setDefault(const TimeZone&)` is explicitly called by a * user. This method does not update the current ICU's default, * and may return a different TimeZone from the one returned by @@ -321,10 +323,6 @@ class U_I18N_API TimeZone : public UObject { * zone is set to the default host time zone. This call adopts the TimeZone object * passed in; the client is no longer responsible for deleting it. * - *

This function is not thread safe. It is an error for multiple threads - * to concurrently attempt to set the default time zone, or for any thread - * to attempt to reference the default zone while another thread is setting it. - * * @param zone A pointer to the new TimeZone object to use as the default. * @stable ICU 2.0 */ @@ -335,8 +333,6 @@ class U_I18N_API TimeZone : public UObject { * Same as adoptDefault(), except that the TimeZone object passed in is NOT adopted; * the caller remains responsible for deleting it. * - *

See the thread safety note under adoptDefault(). - * * @param zone The given timezone. * @system * @stable ICU 2.0 @@ -689,7 +685,7 @@ class U_I18N_API TimeZone : public UObject { * @stable ICU 2.0 */ UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, const Locale& locale, UnicodeString& result) const; - + /** * Queries if this time zone uses daylight savings time. * @return true if this time zone uses daylight savings time, @@ -721,11 +717,12 @@ class U_I18N_API TimeZone : public UObject { * always returns a BasicTimeZone) provides a series of methods allowing * historic and future time zone rule iteration, so you can check if daylight saving * time is observed or not within a given period. - * + * * @stable ICU 2.0 */ virtual UBool useDaylightTime(void) const = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -740,6 +737,7 @@ class U_I18N_API TimeZone : public UObject { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -758,7 +756,7 @@ class U_I18N_API TimeZone : public UObject { * @return A new copy of this TimeZone object. * @stable ICU 2.0 */ - virtual TimeZone* clone(void) const = 0; + virtual TimeZone* clone() const = 0; /** * Return the class ID for this class. This is useful only for @@ -780,7 +778,7 @@ class U_I18N_API TimeZone : public UObject { * @stable ICU 2.0 */ virtual UClassID getDynamicClassID(void) const = 0; - + /** * Returns the amount of time to be added to local standard time * to get local wall clock time. @@ -805,7 +803,7 @@ class U_I18N_API TimeZone : public UObject { * When the time zone is not associated with a specific location, * for example - "Etc/UTC", "EST5EDT", then this method returns * "001" (UN M.49 area code for World). - * + * * @param id The system time zone ID. * @param region Output buffer for receiving the region code. * @param capacity The size of the output buffer. @@ -813,10 +811,10 @@ class U_I18N_API TimeZone : public UObject { * is not a known system time zone ID, * U_ILLEGAL_ARGUMENT_ERROR is set. * @return The length of the output region code. - * @stable ICU 4.8 - */ - static int32_t U_EXPORT2 getRegion(const UnicodeString& id, - char *region, int32_t capacity, UErrorCode& status); + * @stable ICU 4.8 + */ + static int32_t U_EXPORT2 getRegion(const UnicodeString& id, + char *region, int32_t capacity, UErrorCode& status); protected: @@ -972,5 +970,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif //_TIMEZONE //eof diff --git a/deps/icu-small/source/i18n/unicode/tmunit.h b/deps/icu-small/source/i18n/unicode/tmunit.h index fa59f104734baa..2e949ddfbd560d 100644 --- a/deps/icu-small/source/i18n/unicode/tmunit.h +++ b/deps/icu-small/source/i18n/unicode/tmunit.h @@ -16,6 +16,9 @@ * \brief C++ API: time unit object */ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API #include "unicode/measunit.h" @@ -70,7 +73,7 @@ class U_I18N_API TimeUnit: public MeasureUnit { * Override clone. * @stable ICU 4.2 */ - virtual UObject* clone() const; + virtual TimeUnit* clone() const; /** * Copy operator. @@ -132,6 +135,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUNIT_H__ //eof // diff --git a/deps/icu-small/source/i18n/unicode/tmutamt.h b/deps/icu-small/source/i18n/unicode/tmutamt.h index 1717b7605fb3c5..8bcc684d3a9cf0 100644 --- a/deps/icu-small/source/i18n/unicode/tmutamt.h +++ b/deps/icu-small/source/i18n/unicode/tmutamt.h @@ -5,7 +5,7 @@ * Copyright (C) 2009-2010, Google, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* - */ + */ #ifndef __TMUTAMT_H__ #define __TMUTAMT_H__ @@ -16,11 +16,15 @@ * \brief C++ API: time unit amount object. */ -#include "unicode/measure.h" -#include "unicode/tmunit.h" +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING +#include "unicode/measure.h" +#include "unicode/tmunit.h" + U_NAMESPACE_BEGIN @@ -34,27 +38,27 @@ class U_I18N_API TimeUnitAmount: public Measure { public: /** * Construct TimeUnitAmount object with the given number and the - * given time unit. + * given time unit. * @param number a numeric object; number.isNumeric() must be TRUE * @param timeUnitField the time unit field of a time unit - * @param status the input-output error code. + * @param status the input-output error code. * If the number is not numeric or the timeUnitField * is not valid, * then this will be set to a failing value: * U_ILLEGAL_ARGUMENT_ERROR. * @stable ICU 4.2 */ - TimeUnitAmount(const Formattable& number, + TimeUnitAmount(const Formattable& number, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode& status); /** * Construct TimeUnitAmount object with the given numeric amount and the - * given time unit. + * given time unit. * @param amount a numeric amount. * @param timeUnitField the time unit field on which a time unit amount * object will be created. - * @param status the input-output error code. + * @param status the input-output error code. * If the timeUnitField is not valid, * then this will be set to a failing value: * U_ILLEGAL_ARGUMENT_ERROR. @@ -65,7 +69,7 @@ class U_I18N_API TimeUnitAmount: public Measure { /** - * Copy constructor + * Copy constructor * @stable ICU 4.2 */ TimeUnitAmount(const TimeUnitAmount& other); @@ -79,22 +83,22 @@ class U_I18N_API TimeUnitAmount: public Measure { /** - * Clone. + * Clone. * @return a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID(). * @stable ICU 4.2 */ - virtual UObject* clone() const; - + virtual TimeUnitAmount* clone() const; + /** * Destructor * @stable ICU 4.2 */ virtual ~TimeUnitAmount(); - - /** - * Equality operator. + + /** + * Equality operator. * @param other the object to compare to. * @return true if this object is equal to the given object. * @stable ICU 4.2 @@ -102,8 +106,8 @@ class U_I18N_API TimeUnitAmount: public Measure { virtual UBool operator==(const UObject& other) const; - /** - * Not-equality operator. + /** + * Not-equality operator. * @param other the object to compare to. * @return true if this object is not equal to the given object. * @stable ICU 4.2 @@ -156,7 +160,7 @@ class U_I18N_API TimeUnitAmount: public Measure { -inline UBool +inline UBool TimeUnitAmount::operator!=(const UObject& other) const { return !operator==(other); } @@ -165,6 +169,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUTAMT_H__ //eof // diff --git a/deps/icu-small/source/i18n/unicode/tmutfmt.h b/deps/icu-small/source/i18n/unicode/tmutfmt.h index 8f245859a622ba..ad871f7c09fd4f 100644 --- a/deps/icu-small/source/i18n/unicode/tmutfmt.h +++ b/deps/icu-small/source/i18n/unicode/tmutfmt.h @@ -18,8 +18,9 @@ */ +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DEPRECATED_API #include "unicode/unistr.h" #include "unicode/tmunit.h" @@ -28,6 +29,7 @@ #include "unicode/numfmt.h" #include "unicode/plurrule.h" +#ifndef U_HIDE_DEPRECATED_API /** * Constants for various styles. @@ -124,7 +126,7 @@ class U_I18N_API TimeUnitFormat: public MeasureFormat { * @return A copy of the object. * @deprecated ICU 53 */ - virtual Format* clone(void) const; + virtual TimeUnitFormat* clone() const; /** * Assignment operator @@ -244,5 +246,7 @@ U_NAMESPACE_END #endif /* U_HIDE_DEPRECATED_API */ #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUTFMT_H__ //eof diff --git a/deps/icu-small/source/i18n/unicode/translit.h b/deps/icu-small/source/i18n/unicode/translit.h index 6b4888145f1be5..fe2568d50aa020 100644 --- a/deps/icu-small/source/i18n/unicode/translit.h +++ b/deps/icu-small/source/i18n/unicode/translit.h @@ -14,6 +14,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Tranforms text from one format to another. @@ -1588,4 +1590,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_TRANSLITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tzfmt.h b/deps/icu-small/source/i18n/unicode/tzfmt.h index d2aa768b8c8b34..6d3863b1e5add8 100644 --- a/deps/icu-small/source/i18n/unicode/tzfmt.h +++ b/deps/icu-small/source/i18n/unicode/tzfmt.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/format.h" @@ -305,7 +307,7 @@ class U_I18N_API TimeZoneFormat : public Format { * @return A copy of the object * @stable ICU 50 */ - virtual Format* clone() const; + virtual TimeZoneFormat* clone() const; /** * Creates an instance of TimeZoneFormat for the given locale. @@ -1094,4 +1096,7 @@ class U_I18N_API TimeZoneFormat : public Format { U_NAMESPACE_END #endif /* !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tznames.h b/deps/icu-small/source/i18n/unicode/tznames.h index 399265d85ae66c..860494221df4f8 100644 --- a/deps/icu-small/source/i18n/unicode/tznames.h +++ b/deps/icu-small/source/i18n/unicode/tznames.h @@ -15,6 +15,8 @@ */ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uloc.h" @@ -411,4 +413,7 @@ class U_I18N_API TimeZoneNames : public UObject { U_NAMESPACE_END #endif + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tzrule.h b/deps/icu-small/source/i18n/unicode/tzrule.h index 171486f1c79d2a..795806d90fb53c 100644 --- a/deps/icu-small/source/i18n/unicode/tzrule.h +++ b/deps/icu-small/source/i18n/unicode/tzrule.h @@ -10,12 +10,14 @@ #define TZRULE_H /** - * \file + * \file * \brief C++ API: Time zone rule classes */ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uobject.h" @@ -28,7 +30,7 @@ U_NAMESPACE_BEGIN * TimeZoneRule is a class representing a rule for time zone. * TimeZoneRule has a set of time zone attributes, such as zone name, * raw offset (UTC offset for standard time) and daylight saving time offset. - * + * * @stable ICU 3.8 */ class U_I18N_API TimeZoneRule : public UObject { @@ -45,7 +47,7 @@ class U_I18N_API TimeZoneRule : public UObject { * @return A copy of the object. * @stable ICU 3.8 */ - virtual TimeZoneRule* clone(void) const = 0; + virtual TimeZoneRule* clone() const = 0; /** * Return true if the given TimeZoneRule objects are semantically equal. Objects @@ -229,7 +231,7 @@ class U_I18N_API InitialTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual InitialTimeZoneRule* clone(void) const; + virtual InitialTimeZoneRule* clone() const; /** * Assignment operator. @@ -372,7 +374,7 @@ class U_I18N_API InitialTimeZoneRule : public TimeZoneRule { * AnnualTimeZoneRule is a class used for representing a time zone * rule which takes effect annually. The calenday system used for the rule is * is based on Gregorian calendar - * + * * @stable ICU 3.8 */ class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { @@ -440,7 +442,7 @@ class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual AnnualTimeZoneRule* clone(void) const; + virtual AnnualTimeZoneRule* clone() const; /** * Assignment operator. @@ -612,7 +614,7 @@ class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { /** * TimeArrayTimeZoneRule represents a time zone rule whose start times are * defined by an array of milliseconds since the standard base time. - * + * * @stable ICU 3.8 */ class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { @@ -656,7 +658,7 @@ class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual TimeArrayTimeZoneRule* clone(void) const; + virtual TimeArrayTimeZoneRule* clone() const; /** * Assignment operator. @@ -687,7 +689,7 @@ class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { * Gets the time type of the start times used by this rule. The return value * is either DateTimeRule::WALL_TIME or STANDARD_TIME * or UTC_TIME. - * + * * @return The time type used of the start times used by this rule. * @stable ICU 3.8 */ @@ -825,6 +827,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TZRULE_H //eof diff --git a/deps/icu-small/source/i18n/unicode/tztrans.h b/deps/icu-small/source/i18n/unicode/tztrans.h index 1276d67c312b9a..217d711eec3471 100644 --- a/deps/icu-small/source/i18n/unicode/tztrans.h +++ b/deps/icu-small/source/i18n/unicode/tztrans.h @@ -10,12 +10,14 @@ #define TZTRANS_H /** - * \file + * \file * \brief C++ API: Time zone transition */ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uobject.h" @@ -35,7 +37,7 @@ class U_I18N_API TimeZoneTransition : public UObject { /** * Constructs a TimeZoneTransition with the time and the rules before/after * the transition. - * + * * @param time The time of transition in milliseconds since the base time. * @param from The time zone rule used before the transition. * @param to The time zone rule used after the transition. @@ -68,7 +70,7 @@ class U_I18N_API TimeZoneTransition : public UObject { * @return A copy of the object. * @stable ICU 3.8 */ - TimeZoneTransition* clone(void) const; + TimeZoneTransition* clone() const; /** * Assignment operator. @@ -192,6 +194,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TZTRANS_H //eof diff --git a/deps/icu-small/source/i18n/unicode/ucal.h b/deps/icu-small/source/i18n/unicode/ucal.h index 71120b7aed6d0f..c198450ba2f823 100644 --- a/deps/icu-small/source/i18n/unicode/ucal.h +++ b/deps/icu-small/source/i18n/unicode/ucal.h @@ -168,7 +168,7 @@ */ typedef void* UCalendar; -/** Possible types of UCalendars +/** Possible types of UCalendars * @stable ICU 2.0 */ enum UCalendarType { @@ -193,25 +193,25 @@ enum UCalendarType { /** @stable ICU 2.0 */ typedef enum UCalendarType UCalendarType; -/** Possible fields in a UCalendar +/** Possible fields in a UCalendar * @stable ICU 2.0 */ enum UCalendarDateFields { - /** - * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. + /** + * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. * This is a calendar-specific value. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_ERA, /** * Field number indicating the year. This is a calendar-specific value. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_YEAR, /** - * Field number indicating the month. This is a calendar-specific value. + * Field number indicating the month. This is a calendar-specific value. * The first month of the year is * JANUARY; the last depends on the number of months in a year. * @see #UCAL_JANUARY @@ -227,7 +227,7 @@ enum UCalendarDateFields { * @see #UCAL_NOVEMBER * @see #UCAL_DECEMBER * @see #UCAL_UNDECIMBER - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_MONTH, @@ -240,7 +240,7 @@ enum UCalendarDateFields { * the year. * @see ucal_getAttribute * @see ucal_setAttribute - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_WEEK_OF_YEAR, @@ -255,7 +255,7 @@ enum UCalendarDateFields { * @see ucal_setAttribute * @see #UCAL_FIRST_DAY_OF_WEEK * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_WEEK_OF_MONTH, @@ -264,14 +264,14 @@ enum UCalendarDateFields { * day of the month. This is a synonym for DAY_OF_MONTH. * The first day of the month has value 1. * @see #UCAL_DAY_OF_MONTH - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_DATE, /** * Field number indicating the day * number within the current year. The first day of the year has value 1. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_DAY_OF_YEAR, @@ -287,7 +287,7 @@ enum UCalendarDateFields { * @see #UCAL_THURSDAY * @see #UCAL_FRIDAY * @see #UCAL_SATURDAY - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_DAY_OF_WEEK, @@ -312,7 +312,7 @@ enum UCalendarDateFields { * DAY_OF_WEEK_IN_MONTH 5 and the end of 4. * @see #UCAL_DAY_OF_WEEK * @see #UCAL_WEEK_OF_MONTH - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_DAY_OF_WEEK_IN_MONTH, @@ -323,7 +323,7 @@ enum UCalendarDateFields { * @see #UCAL_AM * @see #UCAL_PM * @see #UCAL_HOUR - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_AM_PM, @@ -334,7 +334,7 @@ enum UCalendarDateFields { * E.g., at 10:04:15.250 PM the HOUR is 10. * @see #UCAL_AM_PM * @see #UCAL_HOUR_OF_DAY - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_HOUR, @@ -343,7 +343,7 @@ enum UCalendarDateFields { * hour of the day. HOUR_OF_DAY is used for the 24-hour clock. * E.g., at 10:04:15.250 PM the HOUR_OF_DAY is 22. * @see #UCAL_HOUR - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_HOUR_OF_DAY, @@ -351,7 +351,7 @@ enum UCalendarDateFields { * Field number indicating the * minute within the hour. * E.g., at 10:04:15.250 PM the UCAL_MINUTE is 4. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_MINUTE, @@ -359,7 +359,7 @@ enum UCalendarDateFields { * Field number indicating the * second within the minute. * E.g., at 10:04:15.250 PM the UCAL_SECOND is 15. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_SECOND, @@ -367,26 +367,26 @@ enum UCalendarDateFields { * Field number indicating the * millisecond within the second. * E.g., at 10:04:15.250 PM the UCAL_MILLISECOND is 250. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_MILLISECOND, /** * Field number indicating the * raw offset from GMT in milliseconds. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_ZONE_OFFSET, /** * Field number indicating the * daylight savings offset in milliseconds. - * @stable ICU 2.6 + * @stable ICU 2.6 */ UCAL_DST_OFFSET, - + /** - * Field number + * Field number * indicating the extended year corresponding to the * UCAL_WEEK_OF_YEAR field. This may be one greater or less * than the value of UCAL_EXTENDED_YEAR. @@ -395,7 +395,7 @@ enum UCalendarDateFields { UCAL_YEAR_WOY, /** - * Field number + * Field number * indicating the localized day of week. This will be a value from 1 * to 7 inclusive, with 1 being the localized first day of the week. * @stable ICU 2.6 @@ -403,15 +403,15 @@ enum UCalendarDateFields { UCAL_DOW_LOCAL, /** - * Year of this calendar system, encompassing all supra-year fields. For example, + * Year of this calendar system, encompassing all supra-year fields. For example, * in Gregorian/Julian calendars, positive Extended Year values indicate years AD, - * 1 BC = 0 extended, 2 BC = -1 extended, and so on. - * @stable ICU 2.8 + * 1 BC = 0 extended, 2 BC = -1 extended, and so on. + * @stable ICU 2.8 */ UCAL_EXTENDED_YEAR, /** - * Field number + * Field number * indicating the modified Julian day number. This is different from * the conventional Julian day number in two regards. First, it * demarcates days at local zone midnight, rather than noon GMT. @@ -420,13 +420,13 @@ enum UCalendarDateFields { * the date-related fields. * @stable ICU 2.8 */ - UCAL_JULIAN_DAY, + UCAL_JULIAN_DAY, /** - * Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves exactly - * like a composite of all time-related fields, not including the zone fields. As such, + * Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves exactly + * like a composite of all time-related fields, not including the zone fields. As such, * it also reflects discontinuities of those fields on DST transition days. On a day - * of DST onset, it will jump forward. On a day of DST cessation, it will jump + * of DST onset, it will jump forward. On a day of DST cessation, it will jump * backward. This reflects the fact that it must be combined with the DST_OFFSET field * to obtain a unique local time value. * @stable ICU 2.8 @@ -441,11 +441,13 @@ enum UCalendarDateFields { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of Calendar, DateFormat, and other objects */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UCalendarDateFields value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UCAL_FIELD_COUNT, + UCAL_FIELD_COUNT, +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Field number indicating the @@ -465,7 +467,7 @@ typedef enum UCalendarDateFields UCalendarDateFields; * who create locale resources for the field of first-day-of-week should be aware of * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY. */ -/** Possible days of the week in a UCalendar +/** Possible days of the week in a UCalendar * @stable ICU 2.0 */ enum UCalendarDaysOfWeek { @@ -526,7 +528,7 @@ enum UCalendarMonths { /** @stable ICU 2.0 */ typedef enum UCalendarMonths UCalendarMonths; -/** Possible AM/PM values in a UCalendar +/** Possible AM/PM values in a UCalendar * @stable ICU 2.0 */ enum UCalendarAMPMs { @@ -566,13 +568,13 @@ enum USystemTimeZoneType { /** @stable ICU 4.8 */ typedef enum USystemTimeZoneType USystemTimeZoneType; -/** +/** * Create an enumeration over system time zone IDs with the given - * filter conditions. + * filter conditions. * @param zoneType The system time zone type. * @param region The ISO 3166 two-letter country code or UN M.49 * three-digit area code. When NULL, no filtering - * done by region. + * done by region. * @param rawOffset An offset from GMT in milliseconds, ignoring the * effect of daylight savings time, if any. When NULL, * no filtering done by zone offset. @@ -581,7 +583,7 @@ typedef enum USystemTimeZoneType USystemTimeZoneType; * using enum_close(), or NULL upon failure. In case of failure, * *ec will indicate the error. * @stable ICU 4.8 - */ + */ U_STABLE UEnumeration* U_EXPORT2 ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region, const int32_t* rawOffset, UErrorCode* ec); @@ -625,7 +627,7 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec); * routines fail, or if they specify a TimeZone or TimeZone offset * which is not recognized, then the special TimeZone "Etc/Unknown" * is returned. - * + * * The default may be changed with `ucal_setDefaultTimeZone()` or with * the C++ TimeZone API, `TimeZone::adoptDefault(TimeZone*)`. * @@ -637,9 +639,9 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec); * * @return The result string length, not including the terminating * null - * + * * @see #UCAL_UNKNOWN_ZONE_ID - * + * * @stable ICU 2.6 */ U_STABLE int32_t U_EXPORT2 @@ -657,6 +659,42 @@ ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec); U_STABLE void U_EXPORT2 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec); +#ifndef U_HIDE_DRAFT_API + +/** + * Return the current host time zone. The host time zone is detected from + * the current host system configuration by querying the host operating + * system. If the host system detection routines fail, or if they specify + * a TimeZone or TimeZone offset which is not recognized, then the special + * TimeZone "Etc/Unknown" is returned. + * + * Note that host time zone and the ICU default time zone can be different. + * + * The ICU default time zone does not change once initialized unless modified + * by calling `ucal_setDefaultTimeZone()` or with the C++ TimeZone API, + * `TimeZone::adoptDefault(TimeZone*)`. + * + * If the host operating system configuration has changed since ICU has + * initialized then the returned value can be different than the ICU default + * time zone, even if the default has not changed. + * + *

This function is not thread safe.

+ * + * @param result A buffer to receive the result, or NULL + * @param resultCapacity The capacity of the result buffer + * @param ec input/output error code + * @return The result string length, not including the terminating + * null + * + * @see #UCAL_UNKNOWN_ZONE_ID + * + * @draft ICU 65 + */ +U_DRAFT int32_t U_EXPORT2 +ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec); + +#endif // U_HIDE_DRAFT_API + /** * Return the amount of time in milliseconds that the clock is * advanced during daylight savings time for the given time zone, or @@ -682,7 +720,7 @@ ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec); * @return The current date and time. * @stable ICU 2.0 */ -U_STABLE UDate U_EXPORT2 +U_STABLE UDate U_EXPORT2 ucal_getNow(void); /** @@ -694,7 +732,7 @@ ucal_getNow(void); * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID * UCAL_UNKNOWN_ZONE_ID ("Etc/Unknown") without any errors/warnings. If you want * to check if a TimeZone ID is valid prior to this function, use ucal_getCanonicalTimeZoneID. - * + * * @param zoneID The desired TimeZone ID. If 0, use the default time zone. * @param len The length of zoneID, or -1 if null-terminated. * @param locale The desired locale @@ -708,7 +746,7 @@ ucal_getNow(void); * @see #UCAL_UNKNOWN_ZONE_ID * @stable ICU 2.0 */ -U_STABLE UCalendar* U_EXPORT2 +U_STABLE UCalendar* U_EXPORT2 ucal_open(const UChar* zoneID, int32_t len, const char* locale, @@ -721,7 +759,7 @@ ucal_open(const UChar* zoneID, * @param cal The UCalendar to close. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_close(UCalendar *cal); #if U_SHOW_CPLUSPLUS_API @@ -751,7 +789,7 @@ U_NAMESPACE_END * @return A pointer to a UCalendar identical to cal. * @stable ICU 4.0 */ -U_STABLE UCalendar* U_EXPORT2 +U_STABLE UCalendar* U_EXPORT2 ucal_clone(const UCalendar* cal, UErrorCode* status); @@ -764,30 +802,30 @@ ucal_clone(const UCalendar* cal, * @param status A pointer to an UErrorCode to receive any errors. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_setTimeZone(UCalendar* cal, const UChar* zoneID, int32_t len, UErrorCode* status); -/** - * Get the ID of the UCalendar's time zone. - * - * @param cal The UCalendar to query. - * @param result Receives the UCalendar's time zone ID. - * @param resultLength The maximum size of result. - * @param status Receives the status. - * @return The total buffer size needed; if greater than resultLength, the output was truncated. - * @stable ICU 51 - */ -U_STABLE int32_t U_EXPORT2 +/** + * Get the ID of the UCalendar's time zone. + * + * @param cal The UCalendar to query. + * @param result Receives the UCalendar's time zone ID. + * @param resultLength The maximum size of result. + * @param status Receives the status. + * @return The total buffer size needed; if greater than resultLength, the output was truncated. + * @stable ICU 51 + */ +U_STABLE int32_t U_EXPORT2 ucal_getTimeZoneID(const UCalendar *cal, UChar *result, int32_t resultLength, UErrorCode *status); /** - * Possible formats for a UCalendar's display name + * Possible formats for a UCalendar's display name * @stable ICU 2.0 */ enum UCalendarDisplayNameType { @@ -817,7 +855,7 @@ typedef enum UCalendarDisplayNameType UCalendarDisplayNameType; * @return The total buffer size needed; if greater than resultLength, the output was truncated. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_getTimeZoneDisplayName(const UCalendar* cal, UCalendarDisplayNameType type, const char* locale, @@ -833,7 +871,7 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal, * @return TRUE if cal is currently in daylight savings time, FALSE otherwise * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucal_inDaylightTime(const UCalendar* cal, UErrorCode* status ); @@ -884,7 +922,7 @@ U_STABLE UDate U_EXPORT2 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode); /** - * Types of UCalendar attributes + * Types of UCalendar attributes * @stable ICU 2.0 */ enum UCalendarAttribute { @@ -961,7 +999,7 @@ typedef enum UCalendarWallTimeOption UCalendarWallTimeOption; * @see ucal_setAttribute * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_getAttribute(const UCalendar* cal, UCalendarAttribute attr); @@ -976,7 +1014,7 @@ ucal_getAttribute(const UCalendar* cal, * @see ucal_getAttribute * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_setAttribute(UCalendar* cal, UCalendarAttribute attr, int32_t newValue); @@ -990,7 +1028,7 @@ ucal_setAttribute(UCalendar* cal, * @see ucal_countAvailable * @stable ICU 2.0 */ -U_STABLE const char* U_EXPORT2 +U_STABLE const char* U_EXPORT2 ucal_getAvailable(int32_t localeIndex); /** @@ -1001,7 +1039,7 @@ ucal_getAvailable(int32_t localeIndex); * @see ucal_getAvailable * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_countAvailable(void); /** @@ -1015,7 +1053,7 @@ ucal_countAvailable(void); * @see ucal_setDateTime * @stable ICU 2.0 */ -U_STABLE UDate U_EXPORT2 +U_STABLE UDate U_EXPORT2 ucal_getMillis(const UCalendar* cal, UErrorCode* status); @@ -1030,7 +1068,7 @@ ucal_getMillis(const UCalendar* cal, * @see ucal_setDateTime * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_setMillis(UCalendar* cal, UDate dateTime, UErrorCode* status ); @@ -1049,7 +1087,7 @@ ucal_setMillis(UCalendar* cal, * @see ucal_setDateTime * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_setDate(UCalendar* cal, int32_t year, int32_t month, @@ -1073,7 +1111,7 @@ ucal_setDate(UCalendar* cal, * @see ucal_setDate * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_setDateTime(UCalendar* cal, int32_t year, int32_t month, @@ -1092,7 +1130,7 @@ ucal_setDateTime(UCalendar* cal, * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise. * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucal_equivalentTo(const UCalendar* cal1, const UCalendar* cal2); @@ -1114,7 +1152,7 @@ ucal_equivalentTo(const UCalendar* cal1, * @see ucal_roll * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_add(UCalendar* cal, UCalendarDateFields field, int32_t amount, @@ -1144,7 +1182,7 @@ ucal_add(UCalendar* cal, * @see ucal_add * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_roll(UCalendar* cal, UCalendarDateFields field, int32_t amount, @@ -1166,7 +1204,7 @@ ucal_roll(UCalendar* cal, * @see ucal_clear * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_get(const UCalendar* cal, UCalendarDateFields field, UErrorCode* status ); @@ -1186,7 +1224,7 @@ ucal_get(const UCalendar* cal, * @see ucal_clear * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_set(UCalendar* cal, UCalendarDateFields field, int32_t value); @@ -1206,7 +1244,7 @@ ucal_set(UCalendar* cal, * @see ucal_clear * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucal_isSet(const UCalendar* cal, UCalendarDateFields field); @@ -1224,7 +1262,7 @@ ucal_isSet(const UCalendar* cal, * @see ucal_clear * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_clearField(UCalendar* cal, UCalendarDateFields field); @@ -1238,11 +1276,11 @@ ucal_clearField(UCalendar* cal, * @see ucal_clearField * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucal_clear(UCalendar* calendar); /** - * Possible limit values for a UCalendar + * Possible limit values for a UCalendar * @stable ICU 2.0 */ enum UCalendarLimitType { @@ -1277,7 +1315,7 @@ typedef enum UCalendarLimitType UCalendarLimitType; * @return The requested value. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_getLimit(const UCalendar* cal, UCalendarDateFields field, UCalendarLimitType type, @@ -1285,7 +1323,7 @@ ucal_getLimit(const UCalendar* cal, /** Get the locale for this calendar object. You can choose between valid and actual locale. * @param cal The calendar object - * @param type type of the locale we're looking for (valid or actual) + * @param type type of the locale we're looking for (valid or actual) * @param status error code for the operation * @return the locale name * @stable ICU 2.8 @@ -1362,24 +1400,24 @@ ucal_getKeywordValuesForLocale(const char* key, enum UCalendarWeekdayType { /** * Designates a full weekday (no part of the day is included in the weekend). - * @stable ICU 4.4 + * @stable ICU 4.4 */ UCAL_WEEKDAY, /** * Designates a full weekend day (the entire day is included in the weekend). - * @stable ICU 4.4 + * @stable ICU 4.4 */ UCAL_WEEKEND, /** * Designates a day that starts as a weekday and transitions to the weekend. * Call ucal_getWeekendTransition() to get the time of transition. - * @stable ICU 4.4 + * @stable ICU 4.4 */ UCAL_WEEKEND_ONSET, /** * Designates a day that starts as the weekend and transitions to a weekday. * Call ucal_getWeekendTransition() to get the time of transition. - * @stable ICU 4.4 + * @stable ICU 4.4 */ UCAL_WEEKEND_CEASE }; @@ -1451,7 +1489,7 @@ ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status); * * A typical way of using this function is to call it first with the largest field of interest, then * with progressively smaller fields. - * + * * @param cal The UCalendar to compare and update. * @param target The target date to compare to the current calendar setting. * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, @@ -1462,7 +1500,7 @@ ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status); * @return The date difference for the specified field. * @stable ICU 4.8 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucal_getFieldDifference(UCalendar* cal, UDate target, UCalendarDateFields field, @@ -1516,7 +1554,7 @@ typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 5 * otherwise. * @stable ICU 50 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type, UDate* transition, UErrorCode* status); diff --git a/deps/icu-small/source/i18n/unicode/ucol.h b/deps/icu-small/source/i18n/unicode/ucol.h index f084ac61e614f3..673af1c55a70c9 100644 --- a/deps/icu-small/source/i18n/unicode/ucol.h +++ b/deps/icu-small/source/i18n/unicode/ucol.h @@ -23,7 +23,7 @@ /** * \file - * \brief C API: Collator + * \brief C API: Collator * *

Collator C API

* @@ -31,12 +31,12 @@ * string comparison. You use this service to build * searching and sorting routines for natural language text. *

- * For more information about the collation service see + * For more information about the collation service see * the User Guide. *

- * Collation service provides correct sorting orders for most locales supported in ICU. + * Collation service provides correct sorting orders for most locales supported in ICU. * If specific data for a locale is not available, the orders eventually falls back - * to the CLDR root sort order. + * to the CLDR root sort order. *

* Sort ordering may be customized by providing your own set of rules. For more on * this subject see the @@ -52,7 +52,7 @@ * For usage in C programs. */ struct UCollator; -/** structure representing a collator object instance +/** structure representing a collator object instance * @stable ICU 2.0 */ typedef struct UCollator UCollator; @@ -67,7 +67,7 @@ typedef struct UCollator UCollator; * target string in the ucol_strcoll() method. * @see ucol_strcoll() *

- * Possible values for a comparison result + * Possible values for a comparison result * @stable ICU 2.0 */ typedef enum { @@ -82,8 +82,8 @@ typedef enum { /** Enum containing attribute values for controling collation behavior. * Here are all the allowable values. Not every attribute can take every value. The only - * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined - * value for that locale + * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined + * value for that locale * @stable ICU 2.0 */ typedef enum { @@ -105,21 +105,21 @@ typedef enum { UCOL_IDENTICAL=15, UCOL_STRENGTH_LIMIT, - /** Turn the feature off - works for UCOL_FRENCH_COLLATION, + /** Turn the feature off - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE & UCOL_DECOMPOSITION_MODE*/ UCOL_OFF = 16, - /** Turn the feature on - works for UCOL_FRENCH_COLLATION, + /** Turn the feature on - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE & UCOL_DECOMPOSITION_MODE*/ UCOL_ON = 17, - + /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */ UCOL_SHIFTED = 20, /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorable */ UCOL_NON_IGNORABLE = 21, - /** Valid for UCOL_CASE_FIRST - + /** Valid for UCOL_CASE_FIRST - lower case sorts before upper case */ UCOL_LOWER_FIRST = 24, /** upper case sorts before lower case */ @@ -148,55 +148,55 @@ typedef enum { * A special reordering code that is used to specify the default * reordering codes for a locale. * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_DEFAULT = -1, /** * A special reordering code that is used to specify no reordering codes. * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_NONE = USCRIPT_UNKNOWN, /** * A special reordering code that is used to specify all other codes used for * reordering except for the codes lised as UColReorderCode values and those * listed explicitly in a reordering. * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_OTHERS = USCRIPT_UNKNOWN, /** * Characters with the space property. * This is equivalent to the rule value "space". * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_SPACE = 0x1000, /** * The first entry in the enumeration of reordering groups. This is intended for use in * range checking and enumeration of the reorder codes. * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_FIRST = UCOL_REORDER_CODE_SPACE, /** * Characters with the punctuation property. * This is equivalent to the rule value "punct". * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_PUNCTUATION = 0x1001, /** * Characters with the symbol property. * This is equivalent to the rule value "symbol". * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_SYMBOL = 0x1002, /** * Characters with the currency property. * This is equivalent to the rule value "currency". * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_CURRENCY = 0x1003, /** * Characters with the digit property. * This is equivalent to the rule value "digit". * @stable ICU 4.8 - */ + */ UCOL_REORDER_CODE_DIGIT = 0x1004, #ifndef U_HIDE_DEPRECATED_API /** @@ -212,7 +212,7 @@ typedef enum { * level to UCOL_PRIMARY to ignore secondary and tertiary differences. * Use this to set the strength of a Collator object. * Example of primary difference, "abc" < "abd" - * + * * Diacritical differences on the same base letter represent a secondary * difference. Set comparison level to UCOL_SECONDARY to ignore tertiary * differences. Use this to set the strength of a Collator object. @@ -228,7 +228,7 @@ typedef enum { * unicode spellings. UCOL_IDENTICAL. * For example, "ä" == "ä". * - * UCollationStrength is also used to determine the strength of sort keys + * UCollationStrength is also used to determine the strength of sort keys * generated from UCollator objects * These values can be now found in the UColAttributeValue enum. * @stable ICU 2.0 @@ -236,7 +236,7 @@ typedef enum { typedef UColAttributeValue UCollationStrength; /** Attributes that collation service understands. All the attributes can take UCOL_DEFAULT - * value, as well as the values specific to each one. + * value, as well as the values specific to each one. * @stable ICU 2.0 */ typedef enum { @@ -246,32 +246,32 @@ typedef enum { * weights in the order they appear. * @stable ICU 2.0 */ - UCOL_FRENCH_COLLATION, + UCOL_FRENCH_COLLATION, /** Attribute for handling variable elements. * Acceptable values are UCOL_NON_IGNORABLE (default) - * which treats all the codepoints with non-ignorable + * which treats all the codepoints with non-ignorable * primary weights in the same way, - * and UCOL_SHIFTED which causes codepoints with primary + * and UCOL_SHIFTED which causes codepoints with primary * weights that are equal or below the variable top value - * to be ignored on primary level and moved to the quaternary + * to be ignored on primary level and moved to the quaternary * level. * @stable ICU 2.0 */ - UCOL_ALTERNATE_HANDLING, + UCOL_ALTERNATE_HANDLING, /** Controls the ordering of upper and lower case letters. * Acceptable values are UCOL_OFF (default), which orders * upper and lower case letters in accordance to their tertiary - * weights, UCOL_UPPER_FIRST which forces upper case letters to - * sort before lower case letters, and UCOL_LOWER_FIRST which does + * weights, UCOL_UPPER_FIRST which forces upper case letters to + * sort before lower case letters, and UCOL_LOWER_FIRST which does * the opposite. * @stable ICU 2.0 */ - UCOL_CASE_FIRST, + UCOL_CASE_FIRST, /** Controls whether an extra case level (positioned before the third - * level) is generated or not. Acceptable values are UCOL_OFF (default), + * level) is generated or not. Acceptable values are UCOL_OFF (default), * when case level is not generated, and UCOL_ON which causes the case * level to be generated. Contents of the case level are affected by - * the value of UCOL_CASE_FIRST attribute. A simple way to ignore + * the value of UCOL_CASE_FIRST attribute. A simple way to ignore * accent differences in a string is to set the strength to UCOL_PRIMARY * and enable case level. * @stable ICU 2.0 @@ -279,14 +279,14 @@ typedef enum { UCOL_CASE_LEVEL, /** Controls whether the normalization check and necessary normalizations * are performed. When set to UCOL_OFF (default) no normalization check - * is performed. The correctness of the result is guaranteed only if the + * is performed. The correctness of the result is guaranteed only if the * input data is in so-called FCD form (see users manual for more info). * When set to UCOL_ON, an incremental check is performed to see whether * the input data is in the FCD form. If the data is not in the FCD form, * incremental NFD normalization is performed. * @stable ICU 2.0 */ - UCOL_NORMALIZATION_MODE, + UCOL_NORMALIZATION_MODE, /** An alias for UCOL_NORMALIZATION_MODE attribute. * @stable ICU 2.0 */ @@ -295,7 +295,7 @@ typedef enum { * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength * for most locales (except Japanese) is tertiary. * - * Quaternary strength + * Quaternary strength * is useful when combined with shifted setting for alternate handling * attribute and for JIS X 4061 collation, when it is used to distinguish * between Katakana and Hiragana. @@ -303,13 +303,13 @@ typedef enum { * is affected only by the number of non-ignorable code points in * the string. * - * Identical strength is rarely useful, as it amounts + * Identical strength is rarely useful, as it amounts * to codepoints of the NFD form of the string. * @stable ICU 2.0 */ - UCOL_STRENGTH, + UCOL_STRENGTH, #ifndef U_HIDE_DEPRECATED_API - /** When turned on, this attribute positions Hiragana before all + /** When turned on, this attribute positions Hiragana before all * non-ignorables on quaternary level This is a sneaky way to produce JIS * sort order. * @@ -340,18 +340,20 @@ typedef enum { * * @stable ICU 2.8 */ - UCOL_NUMERIC_COLLATION = UCOL_STRENGTH + 2, + UCOL_NUMERIC_COLLATION = UCOL_STRENGTH + 2, /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of RuleBasedCollator object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UColAttribute value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UCOL_ATTRIBUTE_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API } UColAttribute; -/** Options for retrieving the rule string +/** Options for retrieving the rule string * @stable ICU 2.0 */ typedef enum { @@ -360,7 +362,7 @@ typedef enum { * Same as calling the version of getRules() without UColRuleOption. * @stable ICU 2.0 */ - UCOL_TAILORING_ONLY, + UCOL_TAILORING_ONLY, /** * Retrieves the "UCA rules" concatenated with the tailoring rules. * The "UCA rules" are an approximation of the root collator's sort order. @@ -368,7 +370,7 @@ typedef enum { * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales * @stable ICU 2.0 */ - UCOL_FULL_RULES + UCOL_FULL_RULES } UColRuleOption ; /** @@ -381,11 +383,11 @@ typedef enum { * or in language tag syntax ("el-u-kf-upper"). * See User Guide: Collation API. * - * The UCollator pointer is used in all the calls to the Collation + * The UCollator pointer is used in all the calls to the Collation * service. After finished, collator must be disposed of by calling * {@link #ucol_close }. - * @param loc The locale containing the required collation rules. - * Special values for locales can be passed in - + * @param loc The locale containing the required collation rules. + * Special values for locales can be passed in - * if NULL is passed for the locale, the default locale * collation rules will be used. If empty string ("") or * "root" are passed, the root collator will be returned. @@ -396,7 +398,7 @@ typedef enum { * @see ucol_close * @stable ICU 2.0 */ -U_STABLE UCollator* U_EXPORT2 +U_STABLE UCollator* U_EXPORT2 ucol_open(const char *loc, UErrorCode *status); /** @@ -424,7 +426,7 @@ ucol_open(const char *loc, UErrorCode *status); * @see ucol_close * @stable ICU 2.0 */ -U_STABLE UCollator* U_EXPORT2 +U_STABLE UCollator* U_EXPORT2 ucol_openRules( const UChar *rules, int32_t rulesLength, UColAttributeValue normalizationMode, @@ -433,31 +435,31 @@ ucol_openRules( const UChar *rules, UErrorCode *status); #ifndef U_HIDE_DEPRECATED_API -/** +/** * Open a collator defined by a short form string. * The structure and the syntax of the string is defined in the "Naming collators" - * section of the users guide: + * section of the users guide: * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme * Attributes are overriden by the subsequent attributes. So, for "S2_S3", final * strength will be 3. 3066bis locale overrides individual locale parts. - * The call to this function is equivalent to a call to ucol_open, followed by a + * The call to this function is equivalent to a call to ucol_open, followed by a * series of calls to ucol_setAttribute and ucol_setVariableTop. - * @param definition A short string containing a locale and a set of attributes. + * @param definition A short string containing a locale and a set of attributes. * Attributes not explicitly mentioned are left at the default * state for a locale. * @param parseError if not NULL, structure that will get filled with error's pre * and post context in case of error. - * @param forceDefaults if FALSE, the settings that are the same as the collator + * @param forceDefaults if FALSE, the settings that are the same as the collator * default settings will not be applied (for example, setting - * French secondary on a French collator would not be executed). - * If TRUE, all the settings will be applied regardless of the + * French secondary on a French collator would not be executed). + * If TRUE, all the settings will be applied regardless of the * collator default value. If the definition * strings are to be cached, should be set to FALSE. - * @param status Error code. Apart from regular error conditions connected to + * @param status Error code. Apart from regular error conditions connected to * instantiating collators (like out of memory or similar), this * API will return an error if an invalid attribute or attribute/value * combination is specified. - * @return A pointer to a UCollator or 0 if an error occured (including an + * @return A pointer to a UCollator or 0 if an error occured (including an * invalid attribute). * @see ucol_open * @see ucol_setAttribute @@ -477,11 +479,11 @@ ucol_openFromShortString( const char *definition, /** * Get a set containing the contractions defined by the collator. The set includes * both the root collator's contractions and the contractions defined by the collator. This set - * will contain only strings. If a tailoring explicitly suppresses contractions from + * will contain only strings. If a tailoring explicitly suppresses contractions from * the root collator (like Russian), removed contractions will not be in the resulting set. - * @param coll collator + * @param coll collator * @param conts the set to hold the result. It gets emptied before - * contractions are added. + * contractions are added. * @param status to hold the error code * @return the size of the contraction set * @@ -509,7 +511,7 @@ ucol_getContractionsAndExpansions( const UCollator *coll, USet *contractions, USet *expansions, UBool addPrefixes, UErrorCode *status); -/** +/** * Close a UCollator. * Once closed, a UCollator should not be used. Every open collator should * be closed. Otherwise, a memory leak will result. @@ -519,7 +521,7 @@ ucol_getContractionsAndExpansions( const UCollator *coll, * @see ucol_safeClone * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucol_close(UCollator *coll); #if U_SHOW_CPLUSPLUS_API @@ -556,31 +558,31 @@ U_NAMESPACE_END * @see ucol_equal * @stable ICU 2.0 */ -U_STABLE UCollationResult U_EXPORT2 +U_STABLE UCollationResult U_EXPORT2 ucol_strcoll( const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength); -/** -* Compare two strings in UTF-8. -* The strings will be compared using the options already specified. -* Note: When input string contains malformed a UTF-8 byte sequence, +/** +* Compare two strings in UTF-8. +* The strings will be compared using the options already specified. +* Note: When input string contains malformed a UTF-8 byte sequence, * this function treats these bytes as REPLACEMENT CHARACTER (U+FFFD). -* @param coll The UCollator containing the comparison rules. -* @param source The source UTF-8 string. -* @param sourceLength The length of source, or -1 if null-terminated. -* @param target The target UTF-8 string. -* @param targetLength The length of target, or -1 if null-terminated. -* @param status A pointer to a UErrorCode to receive any errors -* @return The result of comparing the strings; one of UCOL_EQUAL, -* UCOL_GREATER, UCOL_LESS -* @see ucol_greater -* @see ucol_greaterOrEqual -* @see ucol_equal -* @stable ICU 50 -*/ +* @param coll The UCollator containing the comparison rules. +* @param source The source UTF-8 string. +* @param sourceLength The length of source, or -1 if null-terminated. +* @param target The target UTF-8 string. +* @param targetLength The length of target, or -1 if null-terminated. +* @param status A pointer to a UErrorCode to receive any errors +* @return The result of comparing the strings; one of UCOL_EQUAL, +* UCOL_GREATER, UCOL_LESS +* @see ucol_greater +* @see ucol_greaterOrEqual +* @see ucol_equal +* @stable ICU 50 +*/ U_STABLE UCollationResult U_EXPORT2 ucol_strcollUTF8( const UCollator *coll, @@ -604,7 +606,7 @@ ucol_strcollUTF8( * @see ucol_equal * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucol_greater(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength); @@ -623,7 +625,7 @@ ucol_greater(const UCollator *coll, * @see ucol_equal * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucol_greaterOrEqual(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength); @@ -642,7 +644,7 @@ ucol_greaterOrEqual(const UCollator *coll, * @see ucol_greaterOrEqual * @stable ICU 2.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucol_equal(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength); @@ -659,7 +661,7 @@ ucol_equal(const UCollator *coll, * @see ucol_strcoll * @stable ICU 2.6 */ -U_STABLE UCollationResult U_EXPORT2 +U_STABLE UCollationResult U_EXPORT2 ucol_strcollIter( const UCollator *coll, UCharIterator *sIter, UCharIterator *tIter, @@ -674,19 +676,19 @@ ucol_strcollIter( const UCollator *coll, * @see ucol_setStrength * @stable ICU 2.0 */ -U_STABLE UCollationStrength U_EXPORT2 +U_STABLE UCollationStrength U_EXPORT2 ucol_getStrength(const UCollator *coll); /** * Set the collation strength used in a UCollator. * The strength influences how strings are compared. * @param coll The UCollator to set. - * @param strength The desired collation strength; one of UCOL_PRIMARY, + * @param strength The desired collation strength; one of UCOL_PRIMARY, * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT * @see ucol_getStrength * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucol_setStrength(UCollator *coll, UCollationStrength strength); @@ -695,9 +697,9 @@ ucol_setStrength(UCollator *coll, * These reordering codes are a combination of UScript codes and UColReorderCode entries. * @param coll The UCollator to query. * @param dest The array to fill with the script ordering. - * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function + * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function * will only return the length of the result without writing any codes (pre-flighting). - * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a + * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a * failure before the function call. * @return The number of reordering codes written to the dest array. * @see ucol_setReorderCodes @@ -706,41 +708,41 @@ ucol_setStrength(UCollator *coll, * @see UColReorderCode * @stable ICU 4.8 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getReorderCodes(const UCollator* coll, int32_t* dest, int32_t destCapacity, UErrorCode *pErrorCode); -/** +/** * Sets the reordering codes for this collator. * Collation reordering allows scripts and some other groups of characters * to be moved relative to each other. This reordering is done on top of - * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed + * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed * at the start and/or the end of the collation order. These groups are specified using * UScript codes and UColReorderCode entries. * - *

By default, reordering codes specified for the start of the order are placed in the + *

By default, reordering codes specified for the start of the order are placed in the * order given after several special non-script blocks. These special groups of characters * are space, punctuation, symbol, currency, and digit. These special groups are represented with - * UColReorderCode entries. Script groups can be intermingled with + * UColReorderCode entries. Script groups can be intermingled with * these special non-script groups if those special groups are explicitly specified in the reordering. * - *

The special code OTHERS stands for any script that is not explicitly + *

The special code OTHERS stands for any script that is not explicitly * mentioned in the list of reordering codes given. Anything that is after OTHERS * will go at the very end of the reordering in the order given. * *

The special reorder code DEFAULT will reset the reordering for this collator * to the default for this collator. The default reordering may be the DUCET/CLDR order or may be a reordering that - * was specified when this collator was created from resource data or from rules. The + * was specified when this collator was created from resource data or from rules. The * DEFAULT code must be the sole code supplied when it is used. * If not, then U_ILLEGAL_ARGUMENT_ERROR will be set. * *

The special reorder code NONE will remove any reordering for this collator. - * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The + * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The * NONE code must be the sole code supplied when it is used. * * @param coll The UCollator to set. - * @param reorderCodes An array of script codes in the new order. This can be NULL if the + * @param reorderCodes An array of script codes in the new order. This can be NULL if the * length is also set to 0. An empty array will clear any reordering codes on the collator. * @param reorderCodesLength The length of reorderCodes. * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a @@ -750,8 +752,8 @@ ucol_getReorderCodes(const UCollator* coll, * @see UScriptCode * @see UColReorderCode * @stable ICU 4.8 - */ -U_STABLE void U_EXPORT2 + */ +U_STABLE void U_EXPORT2 ucol_setReorderCodes(UCollator* coll, const int32_t* reorderCodes, int32_t reorderCodesLength, @@ -767,7 +769,7 @@ ucol_setReorderCodes(UCollator* coll, * @param dest The array to fill with the script ordering. * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function * will only return the length of the result without writing any codes (pre-flighting). - * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate + * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate * a failure before the function call. * @return The number of reordering codes written to the dest array. * @see ucol_setReorderCodes @@ -776,7 +778,7 @@ ucol_setReorderCodes(UCollator* coll, * @see UColReorderCode * @stable ICU 4.8 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getEquivalentReorderCodes(int32_t reorderCode, int32_t* dest, int32_t destCapacity, @@ -794,7 +796,7 @@ ucol_getEquivalentReorderCodes(int32_t reorderCode, * the output was truncated. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getDisplayName( const char *objLoc, const char *dispLoc, UChar *result, @@ -810,7 +812,7 @@ ucol_getDisplayName( const char *objLoc, * @see ucol_countAvailable * @stable ICU 2.0 */ -U_STABLE const char* U_EXPORT2 +U_STABLE const char* U_EXPORT2 ucol_getAvailable(int32_t localeIndex); /** @@ -821,7 +823,7 @@ ucol_getAvailable(int32_t localeIndex); * @see ucol_getAvailable * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_countAvailable(void); #if !UCONFIG_NO_SERVICE @@ -925,26 +927,26 @@ ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity, * Get the collation tailoring rules from a UCollator. * The rules will follow the rule syntax. * @param coll The UCollator to query. - * @param length + * @param length * @return The collation tailoring rules. * @stable ICU 2.0 */ -U_STABLE const UChar* U_EXPORT2 -ucol_getRules( const UCollator *coll, +U_STABLE const UChar* U_EXPORT2 +ucol_getRules( const UCollator *coll, int32_t *length); #ifndef U_HIDE_DEPRECATED_API /** Get the short definition string for a collator. This API harvests the collator's - * locale and the attribute set and produces a string that can be used for opening + * locale and the attribute set and produces a string that can be used for opening * a collator with the same attributes using the ucol_openFromShortString API. * This string will be normalized. * The structure and the syntax of the string is defined in the "Naming collators" - * section of the users guide: + * section of the users guide: * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme * This API supports preflighting. * @param coll a collator * @param locale a locale that will appear as a collators locale in the resulting - * short string definition. If NULL, the locale will be harvested + * short string definition. If NULL, the locale will be harvested * from the collator. * @param buffer space to hold the resulting string * @param capacity capacity of the buffer @@ -963,21 +965,21 @@ ucol_getShortDefinitionString(const UCollator *coll, /** Verifies and normalizes short definition string. * Normalized short definition string has all the option sorted by the argument name, - * so that equivalent definition strings are the same. + * so that equivalent definition strings are the same. * This API supports preflighting. * @param source definition string * @param destination space to hold the resulting string * @param capacity capacity of the buffer * @param parseError if not NULL, structure that will get filled with error's pre * and post context in case of error. - * @param status Error code. This API will return an error if an invalid attribute - * or attribute/value combination is specified. All the preflighting + * @param status Error code. This API will return an error if an invalid attribute + * or attribute/value combination is specified. All the preflighting * errors are also featured * @return length of the resulting normalized string. * * @see ucol_openFromShortString * @see ucol_getShortDefinitionString - * + * * @deprecated ICU 54 */ @@ -994,7 +996,7 @@ ucol_normalizeShortDefinitionString(const char *source, * Get a sort key for a string from a UCollator. * Sort keys may be compared using strcmp. * - * Note that sort keys are often less efficient than simply doing comparison. + * Note that sort keys are often less efficient than simply doing comparison. * For more details, see the ICU User Guide. * * Like ICU functions that write to an output buffer, the buffer contents @@ -1012,7 +1014,7 @@ ucol_normalizeShortDefinitionString(const char *source, * @see ucol_keyHashCode * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getSortKey(const UCollator *coll, const UChar *source, int32_t sourceLength, @@ -1029,29 +1031,29 @@ ucol_getSortKey(const UCollator *coll, * The generated sort key may or may not be compatible with * sort keys generated using ucol_getSortKey(). * @param coll The UCollator containing the collation rules. - * @param iter UCharIterator containing the string we need + * @param iter UCharIterator containing the string we need * the sort key to be calculated for. * @param state Opaque state of sortkey iteration. * @param dest Buffer to hold the resulting sortkey part * @param count number of sort key bytes required. * @param status error code indicator. * @return the actual number of bytes of a sortkey. It can be - * smaller than count if we have reached the end of + * smaller than count if we have reached the end of * the sort key. * @stable ICU 2.6 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_nextSortKeyPart(const UCollator *coll, UCharIterator *iter, uint32_t state[2], uint8_t *dest, int32_t count, UErrorCode *status); -/** enum that is taken by ucol_getBound API - * See below for explanation - * do not change the values assigned to the - * members of this enum. Underlying code - * depends on them having these numbers +/** enum that is taken by ucol_getBound API + * See below for explanation + * do not change the values assigned to the + * members of this enum. Underlying code + * depends on them having these numbers * @stable ICU 2.0 */ typedef enum { @@ -1072,11 +1074,11 @@ typedef enum { /** * Produce a bound for a given sortkey and a number of levels. - * Return value is always the number of bytes needed, regardless of + * Return value is always the number of bytes needed, regardless of * whether the result buffer was big enough or even valid.
* Resulting bounds can be used to produce a range of strings that are * between upper and lower bounds. For example, if bounds are produced - * for a sortkey of string "smith", strings between upper and lower + * for a sortkey of string "smith", strings between upper and lower * bounds with one level would include "Smith", "SMITH", "sMiTh".
* There are two upper bounds that can be produced. If UCOL_BOUND_UPPER * is produced, strings matched would be as above. However, if bound @@ -1086,28 +1088,28 @@ typedef enum { * TestBounds. * Sort keys may be compared using strcmp. * @param source The source sortkey. - * @param sourceLength The length of source, or -1 if null-terminated. - * (If an unmodified sortkey is passed, it is always null + * @param sourceLength The length of source, or -1 if null-terminated. + * (If an unmodified sortkey is passed, it is always null * terminated). - * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which - * produces a lower inclusive bound, UCOL_BOUND_UPPER, that - * produces upper bound that matches strings of the same length - * or UCOL_BOUND_UPPER_LONG that matches strings that have the + * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which + * produces a lower inclusive bound, UCOL_BOUND_UPPER, that + * produces upper bound that matches strings of the same length + * or UCOL_BOUND_UPPER_LONG that matches strings that have the * same starting substring as the source string. - * @param noOfLevels Number of levels required in the resulting bound (for most - * uses, the recommended value is 1). See users guide for + * @param noOfLevels Number of levels required in the resulting bound (for most + * uses, the recommended value is 1). See users guide for * explanation on number of levels a sortkey can have. * @param result A pointer to a buffer to receive the resulting sortkey. * @param resultLength The maximum size of result. - * @param status Used for returning error code if something went wrong. If the + * @param status Used for returning error code if something went wrong. If the * number of levels requested is higher than the number of levels - * in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is + * in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is * issued. - * @return The size needed to fully store the bound. + * @return The size needed to fully store the bound. * @see ucol_keyHashCode * @stable ICU 2.1 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getBound(const uint8_t *source, int32_t sourceLength, UColBoundMode boundType, @@ -1115,7 +1117,7 @@ ucol_getBound(const uint8_t *source, uint8_t *result, int32_t resultLength, UErrorCode *status); - + /** * Gets the version information for a Collator. Version is currently * an opaque 32-bit number which depends, among other things, on major @@ -1163,7 +1165,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info); * Example (uncompressed): *

191B1D 01 050505 01 910505 00
  * 1F2123 01 050505 01 910505 00
- * will be merged as + * will be merged as *
191B1D 02 1F2123 01 050505 02 050505 01 910505 02 910505 00
* * If the destination buffer is not big enough, then its contents are undefined. @@ -1184,7 +1186,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info); * in which cases the contents of dest is undefined * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, const uint8_t *src2, int32_t src2Length, uint8_t *dest, int32_t destCapacity); @@ -1192,7 +1194,7 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, /** * Universal attribute setter * @param coll collator which attributes are to be changed - * @param attr attribute type + * @param attr attribute type * @param value attribute value * @param status to indicate whether the operation went on smoothly or there were errors * @see UColAttribute @@ -1200,7 +1202,7 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, * @see ucol_getAttribute * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status); /** @@ -1214,7 +1216,7 @@ ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, * @see ucol_setAttribute * @stable ICU 2.0 */ -U_STABLE UColAttributeValue U_EXPORT2 +U_STABLE UColAttributeValue U_EXPORT2 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status); /** @@ -1267,16 +1269,16 @@ ucol_getMaxVariable(const UCollator *coll); * @see ucol_restoreVariableTop * @deprecated ICU 53 Call ucol_setMaxVariable() instead. */ -U_DEPRECATED uint32_t U_EXPORT2 -ucol_setVariableTop(UCollator *coll, - const UChar *varTop, int32_t len, +U_DEPRECATED uint32_t U_EXPORT2 +ucol_setVariableTop(UCollator *coll, + const UChar *varTop, int32_t len, UErrorCode *status); #endif /* U_HIDE_DEPRECATED_API */ -/** - * Gets the variable top value of a Collator. +/** + * Gets the variable top value of a Collator. * @param coll collator which variable top needs to be retrieved - * @param status error code (not changed by function). If error code is set, + * @param status error code (not changed by function). If error code is set, * the return value is undefined. * @return the variable top primary weight * @see ucol_getMaxVariable @@ -1301,7 +1303,7 @@ U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCod * @see ucol_setVariableTop * @deprecated ICU 53 Call ucol_setMaxVariable() instead. */ -U_DEPRECATED void U_EXPORT2 +U_DEPRECATED void U_EXPORT2 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status); #endif /* U_HIDE_DEPRECATED_API */ @@ -1309,15 +1311,15 @@ ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat * Thread safe cloning operation. The result is a clone of a given collator. * @param coll collator to be cloned * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
- * user allocated space for the new clone. - * If NULL new memory will be allocated. + * user allocated space for the new clone. + * If NULL new memory will be allocated. * If buffer is not large enough, new memory will be allocated. * Clients can use the U_COL_SAFECLONE_BUFFERSIZE. * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
- * pointer to size of allocated space. - * If *pBufferSize == 0, a sufficient size for use in cloning will + * pointer to size of allocated space. + * If *pBufferSize == 0, a sufficient size for use in cloning will * be returned ('pre-flighting') - * If *pBufferSize is not enough for a stack-based safe clone, + * If *pBufferSize is not enough for a stack-based safe clone, * new memory will be allocated. * @param status to indicate whether the operation went on smoothly or there were errors * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any @@ -1328,7 +1330,7 @@ ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat * @see ucol_close * @stable ICU 2.0 */ -U_STABLE UCollator* U_EXPORT2 +U_STABLE UCollator* U_EXPORT2 ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t *pBufferSize, @@ -1344,21 +1346,21 @@ ucol_safeClone(const UCollator *coll, #endif /* U_HIDE_DEPRECATED_API */ /** - * Returns current rules. Delta defines whether full rules are returned or just the tailoring. - * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough + * Returns current rules. Delta defines whether full rules are returned or just the tailoring. + * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough * to store rules, will store up to available space. * * ucol_getRules() should normally be used instead. * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales * @param coll collator to get the rules from - * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. + * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. * @param buffer buffer to store the result in. If NULL, you'll get no rules. * @param bufferLen length of buffer to store rules in. If less than needed you'll get only the part that fits in. * @return current rules * @stable ICU 2.0 * @see UCOL_FULL_RULES */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen); #ifndef U_HIDE_DEPRECATED_API @@ -1371,7 +1373,7 @@ ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int3 * locale. For description see the definition of * ULocDataLocaleType in uloc.h * @param status error code of the operation - * @return real locale name from which the collation data comes. + * @return real locale name from which the collation data comes. * If the collator was instantiated from rules, returns * NULL. * @deprecated ICU 2.8 Use ucol_getLocaleByType instead @@ -1389,7 +1391,7 @@ ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *statu * locale. For description see the definition of * ULocDataLocaleType in uloc.h * @param status error code of the operation - * @return real locale name from which the collation data comes. + * @return real locale name from which the collation data comes. * If the collator was instantiated from rules, returns * NULL. * @stable ICU 2.8 @@ -1398,7 +1400,7 @@ U_STABLE const char * U_EXPORT2 ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status); /** - * Get a Unicode set that contains all the characters and sequences tailored in + * Get a Unicode set that contains all the characters and sequences tailored in * this collator. The result must be disposed of by using uset_close. * @param coll The UCollator for which we want to get tailored chars * @param status error code of the operation @@ -1429,18 +1431,18 @@ ucol_getUnsafeSet( const UCollator *coll, /** Touches all resources needed for instantiating a collator from a short string definition, * thus filling up the cache. - * @param definition A short string containing a locale and a set of attributes. + * @param definition A short string containing a locale and a set of attributes. * Attributes not explicitly mentioned are left at the default * state for a locale. * @param parseError if not NULL, structure that will get filled with error's pre * and post context in case of error. - * @param forceDefaults if FALSE, the settings that are the same as the collator + * @param forceDefaults if FALSE, the settings that are the same as the collator * default settings will not be applied (for example, setting - * French secondary on a French collator would not be executed). - * If TRUE, all the settings will be applied regardless of the + * French secondary on a French collator would not be executed). + * If TRUE, all the settings will be applied regardless of the * collator default value. If the definition * strings are to be cached, should be set to FALSE. - * @param status Error code. Apart from regular error conditions connected to + * @param status Error code. Apart from regular error conditions connected to * instantiating collators (like out of memory or similar), this * API will return an error if an invalid attribute or attribute/value * combination is specified. @@ -1454,7 +1456,7 @@ ucol_prepareShortStringOpen( const char *definition, UErrorCode *status); #endif /* U_HIDE_INTERNAL_API */ -/** Creates a binary image of a collator. This binary image can be stored and +/** Creates a binary image of a collator. This binary image can be stored and * later used to instantiate a collator using ucol_openBinary. * This API supports preflighting. * @param coll Collator @@ -1471,8 +1473,8 @@ ucol_cloneBinary(const UCollator *coll, UErrorCode *status); /** Opens a collator from a collator binary image created using - * ucol_cloneBinary. Binary image used in instantiation of the - * collator remains owned by the user and should stay around for + * ucol_cloneBinary. Binary image used in instantiation of the + * collator remains owned by the user and should stay around for * the lifetime of the collator. The API also takes a base collator * which must be the root collator. * @param bin binary image owned by the user and required through the @@ -1488,8 +1490,8 @@ ucol_cloneBinary(const UCollator *coll, * @stable ICU 3.2 */ U_STABLE UCollator* U_EXPORT2 -ucol_openBinary(const uint8_t *bin, int32_t length, - const UCollator *base, +ucol_openBinary(const uint8_t *bin, int32_t length, + const UCollator *base, UErrorCode *status); diff --git a/deps/icu-small/source/i18n/unicode/ucoleitr.h b/deps/icu-small/source/i18n/unicode/ucoleitr.h index 96c67f2018a6c3..85ec8383d7cb2e 100644 --- a/deps/icu-small/source/i18n/unicode/ucoleitr.h +++ b/deps/icu-small/source/i18n/unicode/ucoleitr.h @@ -11,7 +11,7 @@ * Modification History: * * Date Name Description -* 02/15/2001 synwee Modified all methods to process its own function +* 02/15/2001 synwee Modified all methods to process its own function * instead of calling the equivalent c++ api (coleitr.h) *******************************************************************************/ @@ -22,8 +22,8 @@ #if !UCONFIG_NO_COLLATION -/** - * This indicates an error has occured during processing or if no more CEs is +/** + * This indicates an error has occured during processing or if no more CEs is * to be returned. * @stable ICU 2.0 */ @@ -31,7 +31,7 @@ #include "unicode/ucol.h" -/** +/** * The UCollationElements struct. * For usage in C programs. * @stable ICU 2.0 @@ -42,10 +42,10 @@ typedef struct UCollationElements UCollationElements; * \file * \brief C API: UCollationElements * - * The UCollationElements API is used as an iterator to walk through each + * The UCollationElements API is used as an iterator to walk through each * character of an international string. Use the iterator to return the - * ordering priority of the positioned character. The ordering priority of a - * character, which we refer to as a key, defines how a character is collated + * ordering priority of the positioned character. The ordering priority of a + * character, which we refer to as a key, defines how a character is collated * in the given collation object. * For example, consider the following in Slovak and in traditional Spanish collation: *
@@ -82,19 +82,19 @@ typedef struct UCollationElements UCollationElements;
  * ucol_next() returns the collation order of the next.
  * ucol_prev() returns the collation order of the previous character.
  * The Collation Element Iterator moves only in one direction between calls to
- * ucol_reset. That is, ucol_next() and ucol_prev can not be inter-used.
- * Whenever ucol_prev is to be called after ucol_next() or vice versa,
- * ucol_reset has to be called first to reset the status, shifting pointers to
- * either the end or the start of the string. Hence at the next call of
- * ucol_prev or ucol_next, the first or last collation order will be returned.
- * If a change of direction is done without a ucol_reset, the result is
+ * ucol_reset. That is, ucol_next() and ucol_prev can not be inter-used. 
+ * Whenever ucol_prev is to be called after ucol_next() or vice versa, 
+ * ucol_reset has to be called first to reset the status, shifting pointers to 
+ * either the end or the start of the string. Hence at the next call of 
+ * ucol_prev or ucol_next, the first or last collation order will be returned. 
+ * If a change of direction is done without a ucol_reset, the result is 
  * undefined.
- * The result of a forward iterate (ucol_next) and reversed result of the
- * backward iterate (ucol_prev) on the same string are equivalent, if
+ * The result of a forward iterate (ucol_next) and reversed result of the  
+ * backward iterate (ucol_prev) on the same string are equivalent, if 
  * collation orders with the value 0 are ignored.
- * Character based on the comparison level of the collator.  A collation order
- * consists of primary order, secondary order and tertiary order.  The data
- * type of the collation order is int32_t.
+ * Character based on the comparison level of the collator.  A collation order 
+ * consists of primary order, secondary order and tertiary order.  The data 
+ * type of the collation order is int32_t. 
  *
  * @see UCollator
  */
@@ -109,7 +109,7 @@ typedef struct UCollationElements UCollationElements;
  * @return a struct containing collation element information
  * @stable ICU 2.0
  */
-U_STABLE UCollationElements* U_EXPORT2
+U_STABLE UCollationElements* U_EXPORT2 
 ucol_openElements(const UCollator  *coll,
                   const UChar      *text,
                         int32_t    textLength,
@@ -123,7 +123,7 @@ ucol_openElements(const UCollator  *coll,
  * @return       the hash code.
  * @stable ICU 2.0
  */
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2 
 ucol_keyHashCode(const uint8_t* key, int32_t length);
 
 /**
@@ -132,7 +132,7 @@ ucol_keyHashCode(const uint8_t* key, int32_t length);
  * @param elems The UCollationElements to close.
  * @stable ICU 2.0
  */
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2 
 ucol_closeElements(UCollationElements *elems);
 
 /**
@@ -144,7 +144,7 @@ ucol_closeElements(UCollationElements *elems);
  * @see ucol_previous
  * @stable ICU 2.0
  */
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2 
 ucol_reset(UCollationElements *elems);
 
 /**
@@ -152,41 +152,41 @@ ucol_reset(UCollationElements *elems);
  * A single character may contain more than one collation element.
  * @param elems The UCollationElements containing the text.
  * @param status A pointer to a UErrorCode to receive any errors.
- * @return The next collation elements ordering, otherwise returns UCOL_NULLORDER
+ * @return The next collation elements ordering, otherwise returns UCOL_NULLORDER 
  *         if an error has occured or if the end of string has been reached
  * @stable ICU 2.0
  */
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2 
 ucol_next(UCollationElements *elems, UErrorCode *status);
 
 /**
  * Get the ordering priority of the previous collation element in the text.
  * A single character may contain more than one collation element.
- * Note that internally a stack is used to store buffered collation elements.
+ * Note that internally a stack is used to store buffered collation elements. 
  * @param elems The UCollationElements containing the text.
- * @param status A pointer to a UErrorCode to receive any errors. Noteably
+ * @param status A pointer to a UErrorCode to receive any errors. Noteably 
  *               a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack
  *               buffer has been exhausted.
- * @return The previous collation elements ordering, otherwise returns
- *         UCOL_NULLORDER if an error has occured or if the start of string has
+ * @return The previous collation elements ordering, otherwise returns 
+ *         UCOL_NULLORDER if an error has occured or if the start of string has 
  *         been reached.
  * @stable ICU 2.0
  */
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2 
 ucol_previous(UCollationElements *elems, UErrorCode *status);
 
 /**
- * Get the maximum length of any expansion sequences that end with the
+ * Get the maximum length of any expansion sequences that end with the 
  * specified comparison order.
  * This is useful for .... ?
  * @param elems The UCollationElements containing the text.
  * @param order A collation order returned by previous or next.
- * @return maximum size of the expansion sequences ending with the collation
- *         element or 1 if collation element does not occur at the end of any
+ * @return maximum size of the expansion sequences ending with the collation 
+ *         element or 1 if collation element does not occur at the end of any 
  *         expansion sequence
  * @stable ICU 2.0
  */
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2 
 ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
 
 /**
@@ -201,8 +201,8 @@ ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
  * @see ucol_getText
  * @stable ICU 2.0
  */
-U_STABLE void U_EXPORT2
-ucol_setText(      UCollationElements *elems,
+U_STABLE void U_EXPORT2 
+ucol_setText(      UCollationElements *elems, 
              const UChar              *text,
                    int32_t            textLength,
                    UErrorCode         *status);
@@ -216,7 +216,7 @@ ucol_setText(      UCollationElements *elems,
  * @see ucol_setOffset
  * @stable ICU 2.0
  */
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2 
 ucol_getOffset(const UCollationElements *elems);
 
 /**
@@ -231,7 +231,7 @@ ucol_getOffset(const UCollationElements *elems);
  * @see ucol_getOffset
  * @stable ICU 2.0
  */
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2 
 ucol_setOffset(UCollationElements *elems,
                int32_t        offset,
                UErrorCode         *status);
@@ -243,7 +243,7 @@ ucol_setOffset(UCollationElements *elems,
 * @stable ICU 2.6
 */
 U_STABLE int32_t U_EXPORT2
-ucol_primaryOrder (int32_t order);
+ucol_primaryOrder (int32_t order); 
 
 /**
 * Get the secondary order of a collation order.
@@ -252,7 +252,7 @@ ucol_primaryOrder (int32_t order);
 * @stable ICU 2.6
 */
 U_STABLE int32_t U_EXPORT2
-ucol_secondaryOrder (int32_t order);
+ucol_secondaryOrder (int32_t order); 
 
 /**
 * Get the tertiary order of a collation order.
@@ -261,7 +261,7 @@ ucol_secondaryOrder (int32_t order);
 * @stable ICU 2.6
 */
 U_STABLE int32_t U_EXPORT2
-ucol_tertiaryOrder (int32_t order);
+ucol_tertiaryOrder (int32_t order); 
 
 #endif /* #if !UCONFIG_NO_COLLATION */
 
diff --git a/deps/icu-small/source/i18n/unicode/ucsdet.h b/deps/icu-small/source/i18n/unicode/ucsdet.h
index 7a8564f9eabe37..52ed5ad0ee2eb5 100644
--- a/deps/icu-small/source/i18n/unicode/ucsdet.h
+++ b/deps/icu-small/source/i18n/unicode/ucsdet.h
@@ -29,7 +29,7 @@
 #include "unicode/uenum.h"
 
 /**
- * \file
+ * \file 
  * \brief C API: Charset Detection API
  *
  * This API provides a facility for detecting the
@@ -50,7 +50,7 @@
  * Compact Encoding Detector, https://github.com/google/compact_enc_det.
  * It often gives more accurate results, especially with short input samples.
  */
-
+ 
 
 struct UCharsetDetector;
 /**
@@ -152,8 +152,8 @@ ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t
 
 /**
  * Return the charset that best matches the supplied input data.
- *
- * Note though, that because the detection
+ * 
+ * Note though, that because the detection 
  * only looks at the start of the input data,
  * there is a possibility that the returned charset will fail to handle
  * the full set of input data.
@@ -177,7 +177,7 @@ ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t
  */
 U_STABLE const UCharsetMatch * U_EXPORT2
 ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);
-
+    
 
 /**
  *  Find all charset matches that appear to be consistent with the input,
@@ -190,14 +190,14 @@ ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);
  *  

* The returned UCharsetMatch objects are owned by the UCharsetDetector. * They will remain valid until the detector is closed or modified - * + * *

- * Return an error if + * Return an error if *

    *
  • no charsets appear to match the input data.
  • *
  • no input text has been provided
  • *
- * + * * @param ucsd the charset detector to be used. * @param matchesFound pointer to a variable that will be set to the * number of charsets identified that are consistent with @@ -297,7 +297,7 @@ ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status); * NUL character will be appended to the buffer if space is available. * * The number of UChars in the output string, not including the terminating - * NUL, is returned. + * NUL, is returned. * * If the supplied buffer is smaller than required to hold the output, * the contents of the buffer are undefined. The full output string length @@ -320,7 +320,7 @@ ucsdet_getUChars(const UCharsetMatch *ucsm, /** - * Get an iterator over the set of all detectable charsets - + * Get an iterator over the set of all detectable charsets - * over the charsets that are known to the charset detection * service. * @@ -415,3 +415,5 @@ ucsdet_setDetectableCharset(UCharsetDetector *ucsd, const char *encoding, UBool #endif #endif /* __UCSDET_H */ + + diff --git a/deps/icu-small/source/i18n/unicode/udat.h b/deps/icu-small/source/i18n/unicode/udat.h index c67a6d6d4b3a79..bdbd080c005821 100644 --- a/deps/icu-small/source/i18n/unicode/udat.h +++ b/deps/icu-small/source/i18n/unicode/udat.h @@ -923,11 +923,13 @@ typedef enum UDateFormatBooleanAttribute { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DateFormat object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UDateFormatBooleanAttribute value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 +#endif // U_FORCE_HIDE_DEPRECATED_API } UDateFormatBooleanAttribute; /** diff --git a/deps/icu-small/source/i18n/unicode/udateintervalformat.h b/deps/icu-small/source/i18n/unicode/udateintervalformat.h index 112f81b31e976b..b42223a5db34a3 100644 --- a/deps/icu-small/source/i18n/unicode/udateintervalformat.h +++ b/deps/icu-small/source/i18n/unicode/udateintervalformat.h @@ -43,7 +43,7 @@ * - The skeleton MMMd will produce * for en_US, "Mar 4-8" * for en_GB, "4-8 Mar" - * + * * Note: the "-" characters in the above sample output will actually be * Unicode 2013, EN_DASH, in all but the last example. * diff --git a/deps/icu-small/source/i18n/unicode/udatpg.h b/deps/icu-small/source/i18n/unicode/udatpg.h index 238a27b4f44a35..7f28b5a31978f2 100644 --- a/deps/icu-small/source/i18n/unicode/udatpg.h +++ b/deps/icu-small/source/i18n/unicode/udatpg.h @@ -27,15 +27,15 @@ * \file * \brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h). * - * UDateTimePatternGenerator provides flexible generation of date format patterns, - * like "yy-MM-dd". The user can build up the generator by adding successive - * patterns. Once that is done, a query can be made using a "skeleton", which is - * a pattern which just includes the desired fields and lengths. The generator + * UDateTimePatternGenerator provides flexible generation of date format patterns, + * like "yy-MM-dd". The user can build up the generator by adding successive + * patterns. Once that is done, a query can be made using a "skeleton", which is + * a pattern which just includes the desired fields and lengths. The generator * will return the "best fit" pattern corresponding to that skeleton. *

The main method people will use is udatpg_getBestPattern, since normally - * UDateTimePatternGenerator is pre-built with data from a particular locale. + * UDateTimePatternGenerator is pre-built with data from a particular locale. * However, generators can be built directly from other data as well. - *

Issue: may be useful to also have a function that returns the list of + *

Issue: may be useful to also have a function that returns the list of * fields in a pattern, in order, since we have that internally. * That would be useful for getting the UI order of field elements. */ @@ -88,11 +88,13 @@ typedef enum UDateTimePatternField { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DateTimePatternGenerator object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UDateTimePatternField value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UDATPG_FIELD_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API } UDateTimePatternField; /** @@ -212,13 +214,13 @@ udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); /** * Get the best pattern matching the input skeleton. It is guaranteed to * have all of the fields in the skeleton. - * + * * Note that this function uses a non-const UDateTimePatternGenerator: * It uses a stateful pattern parser which is set up for each generator object, * rather than creating one for each function call. * Consecutive calls to this function do not affect each other, * but this function cannot be used concurrently on a single generator object. - * + * * @param dtpg a pointer to UDateTimePatternGenerator. * @param skeleton * The skeleton is a pattern containing only the variable fields. @@ -241,13 +243,13 @@ udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, /** * Get the best pattern matching the input skeleton. It is guaranteed to * have all of the fields in the skeleton. - * + * * Note that this function uses a non-const UDateTimePatternGenerator: * It uses a stateful pattern parser which is set up for each generator object, * rather than creating one for each function call. * Consecutive calls to this function do not affect each other, * but this function cannot be used concurrently on a single generator object. - * + * * @param dtpg a pointer to UDateTimePatternGenerator. * @param skeleton * The skeleton is a pattern containing only the variable fields. @@ -278,7 +280,7 @@ udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, /** * Get a unique skeleton from a given pattern. For example, * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". - * + * * Note that this function uses a non-const UDateTimePatternGenerator: * It uses a stateful pattern parser which is set up for each generator object, * rather than creating one for each function call. @@ -336,7 +338,7 @@ udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg, * Adds a pattern to the generator. If the pattern has the same skeleton as * an existing pattern, and the override parameter is set, then the previous * value is overriden. Otherwise, the previous value is retained. In either - * case, the conflicting status is set and previous vale is stored in + * case, the conflicting status is set and previous vale is stored in * conflicting pattern. *

* Note that single-field patterns (like "MMM") are automatically added, and @@ -345,14 +347,14 @@ udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg, * @param dtpg a pointer to UDateTimePatternGenerator. * @param pattern input pattern, such as "dd/MMM" * @param patternLength the length of pattern. - * @param override When existing values are to be overridden use true, + * @param override When existing values are to be overridden use true, * otherwise use false. * @param conflictingPattern Previous pattern with the same skeleton. * @param capacity the capacity of conflictingPattern. * @param pLength a pointer to the length of conflictingPattern. * @param pErrorCode a pointer to the UErrorCode which must not indicate a * failure before the function call. - * @return conflicting status. The value could be UDATPG_NO_CONFLICT, + * @return conflicting status. The value could be UDATPG_NO_CONFLICT, * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. * @stable ICU 3.8 */ @@ -527,7 +529,7 @@ udatpg_setDecimal(UDateTimePatternGenerator *dtpg, /** * Getter corresponding to setDecimal. - * + * * @param dtpg a pointer to UDateTimePatternGenerator. * @param pLength A pointer that will receive the length of the decimal string. * @return corresponding to the decimal point. @@ -610,7 +612,7 @@ udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, /** * Return a UEnumeration list of all the skeletons in canonical form. * Call udatpg_getPatternForSkeleton() to get the corresponding pattern. - * + * * @param dtpg a pointer to UDateTimePatternGenerator. * @param pErrorCode a pointer to the UErrorCode which must not indicate a * failure before the function call @@ -636,9 +638,9 @@ udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErr /** * Get the pattern corresponding to a given skeleton. - * + * * @param dtpg a pointer to UDateTimePatternGenerator. - * @param skeleton + * @param skeleton * @param skeletonLength pointer to the length of skeleton. * @param pLength pointer to the length of return pattern. * @return pattern corresponding to a given skeleton. diff --git a/deps/icu-small/source/i18n/unicode/uformattedvalue.h b/deps/icu-small/source/i18n/unicode/uformattedvalue.h index d1c2ad1e49f94d..0b289e3b455150 100644 --- a/deps/icu-small/source/i18n/unicode/uformattedvalue.h +++ b/deps/icu-small/source/i18n/unicode/uformattedvalue.h @@ -7,14 +7,15 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DRAFT_API #include "unicode/ufieldpositer.h" +#ifndef U_HIDE_DRAFT_API + /** * \file * \brief C API: Abstract operations for localized strings. - * + * * This file contains declarations for classes that deal with formatted strings. A number * of APIs throughout ICU use these classes for expressing their localized output. */ @@ -23,7 +24,7 @@ /** * All possible field categories in ICU. Every entry in this enum corresponds * to another enum that exists in ICU. - * + * * In the APIs that take a UFieldCategory, an int32_t type is used. Field * categories having any of the top four bits turned on are reserved as * private-use for external APIs implementing FormattedValue. This means that @@ -35,7 +36,7 @@ typedef enum UFieldCategory { /** * For an undefined field category. - * + * * @draft ICU 64 */ UFIELD_CATEGORY_UNDEFINED = 0, @@ -152,7 +153,7 @@ ucfpos_close(UConstrainedFieldPosition* ucfpos); /** * Sets a constraint on the field category. - * + * * When this instance of UConstrainedFieldPosition is passed to ufmtval_nextPosition, * positions are skipped unless they have the given category. * @@ -184,7 +185,7 @@ ucfpos_constrainCategory( /** * Sets a constraint on the category and field. - * + * * When this instance of UConstrainedFieldPosition is passed to ufmtval_nextPosition, * positions are skipped unless they have the given category and field. * diff --git a/deps/icu-small/source/i18n/unicode/ulistformatter.h b/deps/icu-small/source/i18n/unicode/ulistformatter.h index 4327fd5ec1bece..1a39008889803b 100644 --- a/deps/icu-small/source/i18n/unicode/ulistformatter.h +++ b/deps/icu-small/source/i18n/unicode/ulistformatter.h @@ -21,7 +21,7 @@ * \file * \brief C API: Format a list in a locale-appropriate way. * - * A UListFormatter is used to format a list of items in a locale-appropriate way, + * A UListFormatter is used to format a list of items in a locale-appropriate way, * using data from CLDR. * Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted * as "Alice, Bob, Charlie, and Delta" in English. @@ -41,7 +41,7 @@ struct UFormattedList; * @draft ICU 64 */ typedef struct UFormattedList UFormattedList; -#endif /* U_HIDE_DRAFT_API */ +#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -61,7 +61,7 @@ typedef enum UListFormatterField { */ ULISTFMT_ELEMENT_FIELD } UListFormatterField; -#endif // U_HIDE_DRAFT_API +#endif /* U_HIDE_DRAFT_API */ /** * Open a new UListFormatter object using the rules for a given locale. diff --git a/deps/icu-small/source/i18n/unicode/umsg.h b/deps/icu-small/source/i18n/unicode/umsg.h index 68188206129148..5d235e42e80ba7 100644 --- a/deps/icu-small/source/i18n/unicode/umsg.h +++ b/deps/icu-small/source/i18n/unicode/umsg.h @@ -1,10 +1,10 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2011, International Business Machines Corporation and * others. All Rights Reserved. - * Copyright (C) 2010 , Yahoo! Inc. + * Copyright (C) 2010 , Yahoo! Inc. ******************************************************************** * * file name: umsg.h @@ -100,8 +100,8 @@ * u_uastrcpy(str, "MyDisk"); * u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}"); * for(i=0; i<3; i++){ - * resultlength=0; - * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); + * resultlength=0; + * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); * if(status==U_BUFFER_OVERFLOW_ERROR){ * status=U_ZERO_ERROR; * resultlength=resultLengthOut+1; @@ -175,7 +175,7 @@ * @see u_parseMessage * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 u_formatMessage(const char *locale, const UChar *pattern, int32_t patternLength, @@ -202,7 +202,7 @@ u_formatMessage(const char *locale, * @see u_parseMessage * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 u_vformatMessage( const char *locale, const UChar *pattern, int32_t patternLength, @@ -227,7 +227,7 @@ u_vformatMessage( const char *locale, * @see u_formatMessage * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 u_parseMessage( const char *locale, const UChar *pattern, int32_t patternLength, @@ -252,7 +252,7 @@ u_parseMessage( const char *locale, * @see u_formatMessage * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 u_vparseMessage(const char *locale, const UChar *pattern, int32_t patternLength, @@ -281,7 +281,7 @@ u_vparseMessage(const char *locale, * @see u_parseMessage * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 u_formatMessageWithError( const char *locale, const UChar *pattern, int32_t patternLength, @@ -310,7 +310,7 @@ u_formatMessageWithError( const char *locale, * output was truncated. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 u_vformatMessageWithError( const char *locale, const UChar *pattern, int32_t patternLength, @@ -338,7 +338,7 @@ u_vformatMessageWithError( const char *locale, * @see u_formatMessage * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 u_parseMessageWithError(const char *locale, const UChar *pattern, int32_t patternLength, @@ -366,7 +366,7 @@ u_parseMessageWithError(const char *locale, * @see u_formatMessage * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 u_vparseMessageWithError(const char *locale, const UChar *pattern, int32_t patternLength, @@ -377,7 +377,7 @@ u_vparseMessageWithError(const char *locale, UErrorCode* status); /*----------------------- New experimental API --------------------------- */ -/** +/** * The message format object * @stable ICU 2.0 */ @@ -389,14 +389,14 @@ typedef void* UMessageFormat; * @param pattern A pattern specifying the format to use. * @param patternLength Length of the pattern to use * @param locale The locale for which the messages are formatted. - * @param parseError A pointer to UParseError struct to receive any errors + * @param parseError A pointer to UParseError struct to receive any errors * occured during parsing. Can be NULL. * @param status A pointer to an UErrorCode to receive any errors. - * @return A pointer to a UMessageFormat to use for formatting - * messages, or 0 if an error occurred. + * @return A pointer to a UMessageFormat to use for formatting + * messages, or 0 if an error occurred. * @stable ICU 2.0 */ -U_STABLE UMessageFormat* U_EXPORT2 +U_STABLE UMessageFormat* U_EXPORT2 umsg_open( const UChar *pattern, int32_t patternLength, const char *locale, @@ -409,7 +409,7 @@ umsg_open( const UChar *pattern, * @param format The formatter to close. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 umsg_close(UMessageFormat* format); #if U_SHOW_CPLUSPLUS_API @@ -439,7 +439,7 @@ U_NAMESPACE_END * @return A pointer to a UDateFormat identical to fmt. * @stable ICU 2.0 */ -U_STABLE UMessageFormat U_EXPORT2 +U_STABLE UMessageFormat U_EXPORT2 umsg_clone(const UMessageFormat *fmt, UErrorCode *status); @@ -450,7 +450,7 @@ umsg_clone(const UMessageFormat *fmt, * @param locale The locale the formatter should use. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 umsg_setLocale(UMessageFormat *fmt, const char* locale); @@ -461,7 +461,7 @@ umsg_setLocale(UMessageFormat *fmt, * @return the locale. * @stable ICU 2.0 */ -U_STABLE const char* U_EXPORT2 +U_STABLE const char* U_EXPORT2 umsg_getLocale(const UMessageFormat *fmt); /** @@ -469,14 +469,14 @@ umsg_getLocale(const UMessageFormat *fmt); * @param fmt The formatter to use * @param pattern The pattern to be applied. * @param patternLength Length of the pattern to use - * @param parseError Struct to receive information on position + * @param parseError Struct to receive information on position * of error if an error is encountered.Can be NULL. * @param status Output param set to success/failure code on * exit. If the pattern is invalid, this will be * set to a failure result. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 umsg_applyPattern( UMessageFormat *fmt, const UChar* pattern, int32_t patternLength, @@ -490,13 +490,13 @@ umsg_applyPattern( UMessageFormat *fmt, * @param resultLength The maximum size of result. * @param status Output param set to success/failure code on * exit. If the pattern is invalid, this will be - * set to a failure result. + * set to a failure result. * @return the pattern of the format * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 umsg_toPattern(const UMessageFormat *fmt, - UChar* result, + UChar* result, int32_t resultLength, UErrorCode* status); @@ -509,13 +509,13 @@ umsg_toPattern(const UMessageFormat *fmt, * @param result A pointer to a buffer to receive the formatted message. * @param resultLength The maximum size of result. * @param status A pointer to an UErrorCode to receive any errors - * @param ... A variable-length argument list containing the arguments + * @param ... A variable-length argument list containing the arguments * specified in pattern. - * @return The total buffer size needed; if greater than resultLength, + * @return The total buffer size needed; if greater than resultLength, * the output was truncated. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 umsg_format( const UMessageFormat *fmt, UChar *result, int32_t resultLength, @@ -527,17 +527,17 @@ umsg_format( const UMessageFormat *fmt, * This function may perform re-ordering of the arguments depending on the * locale. For all numeric arguments, double is assumed unless the type is * explicitly integer. All choice format arguments must be of type double. - * @param fmt The formatter to use + * @param fmt The formatter to use * @param result A pointer to a buffer to receive the formatted message. * @param resultLength The maximum size of result. - * @param ap A variable-length argument list containing the arguments + * @param ap A variable-length argument list containing the arguments * @param status A pointer to an UErrorCode to receive any errors * specified in pattern. - * @return The total buffer size needed; if greater than resultLength, + * @return The total buffer size needed; if greater than resultLength, * the output was truncated. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 umsg_vformat( const UMessageFormat *fmt, UChar *result, int32_t resultLength, @@ -549,7 +549,7 @@ umsg_vformat( const UMessageFormat *fmt, * For numeric arguments, this function will always use doubles. Integer types * should not be passed. * This function is not able to parse all output from {@link #umsg_format }. - * @param fmt The formatter to use + * @param fmt The formatter to use * @param source The text to parse. * @param sourceLength The length of source, or -1 if null-terminated. * @param count Output param to receive number of elements returned. @@ -558,7 +558,7 @@ umsg_vformat( const UMessageFormat *fmt, * specified in pattern. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 umsg_parse( const UMessageFormat *fmt, const UChar *source, int32_t sourceLength, @@ -571,7 +571,7 @@ umsg_parse( const UMessageFormat *fmt, * For numeric arguments, this function will always use doubles. Integer types * should not be passed. * This function is not able to parse all output from {@link #umsg_format }. - * @param fmt The formatter to use + * @param fmt The formatter to use * @param source The text to parse. * @param sourceLength The length of source, or -1 if null-terminated. * @param count Output param to receive number of elements returned. @@ -581,7 +581,7 @@ umsg_parse( const UMessageFormat *fmt, * @see u_formatMessage * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 umsg_vparse(const UMessageFormat *fmt, const UChar *source, int32_t sourceLength, @@ -593,7 +593,7 @@ umsg_vparse(const UMessageFormat *fmt, /** * Convert an 'apostrophe-friendly' pattern into a standard * pattern. Standard patterns treat all apostrophes as - * quotes, which is problematic in some languages, e.g. + * quotes, which is problematic in some languages, e.g. * French, where apostrophe is commonly used. This utility * assumes that only an unpaired apostrophe immediately before * a brace is a true quote. Other unpaired apostrophes are paired, @@ -613,8 +613,8 @@ umsg_vparse(const UMessageFormat *fmt, * not * @stable ICU 3.4 */ -U_STABLE int32_t U_EXPORT2 -umsg_autoQuoteApostrophe(const UChar* pattern, +U_STABLE int32_t U_EXPORT2 +umsg_autoQuoteApostrophe(const UChar* pattern, int32_t patternLength, UChar* dest, int32_t destCapacity, diff --git a/deps/icu-small/source/i18n/unicode/unirepl.h b/deps/icu-small/source/i18n/unicode/unirepl.h index 8fb25d46890d9e..1ec627abcb9ce4 100644 --- a/deps/icu-small/source/i18n/unicode/unirepl.h +++ b/deps/icu-small/source/i18n/unicode/unirepl.h @@ -14,8 +14,10 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: UnicodeReplacer */ @@ -96,4 +98,6 @@ class U_I18N_API UnicodeReplacer /* not : public UObject because this is an inte U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/unum.h b/deps/icu-small/source/i18n/unicode/unum.h index c03131f372b8ca..4304538f059d2d 100644 --- a/deps/icu-small/source/i18n/unicode/unum.h +++ b/deps/icu-small/source/i18n/unicode/unum.h @@ -32,7 +32,7 @@ * \brief C API: Compatibility APIs for number formatting. * *

Number Format C API

- * + * *

IMPORTANT: New users with are strongly encouraged to * see if unumberformatter.h fits their use case. Although not deprecated, * this header is provided for backwards compatibility only. @@ -140,7 +140,7 @@ */ typedef void* UNumberFormat; -/** The possible number format styles. +/** The possible number format styles. * @stable ICU 2.0 */ typedef enum UNumberFormatStyle { @@ -180,24 +180,24 @@ typedef enum UNumberFormatStyle { * @stable ICU 2.0 */ UNUM_SPELLOUT=5, - /** + /** * Ordinal rule-based format . The default ruleset can be specified/changed using * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. * @stable ICU 3.0 */ UNUM_ORDINAL=6, - /** - * Duration rule-based format + /** + * Duration rule-based format * @stable ICU 3.0 */ UNUM_DURATION=7, - /** + /** * Numbering system rule-based format * @stable ICU 4.2 */ UNUM_NUMBERING_SYSTEM=8, - /** + /** * Rule-based format defined by a pattern string. * @stable ICU 3.0 */ @@ -221,7 +221,7 @@ typedef enum UNumberFormatStyle { */ UNUM_CURRENCY_ACCOUNTING=12, /** - * Currency format with a currency symbol given CASH usage, e.g., + * Currency format with a currency symbol given CASH usage, e.g., * "NT$3" instead of "NT$3.23". * @stable ICU 54 */ @@ -295,14 +295,14 @@ typedef enum UNumberFormatRoundingMode { #endif /* U_HIDE_DEPRECATED_API */ UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1, UNUM_ROUND_HALFUP, - /** + /** * ROUND_UNNECESSARY reports an error if formatted result is not exact. * @stable ICU 4.8 */ UNUM_ROUND_UNNECESSARY } UNumberFormatRoundingMode; -/** The possible number format pad positions. +/** The possible number format pad positions. * @stable ICU 2.0 */ typedef enum UNumberFormatPadPosition { @@ -338,11 +338,13 @@ enum UCurrencySpacing { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DecimalFormatSymbols object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UCurrencySpacing value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UNUM_CURRENCY_SPACING_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API }; typedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */ @@ -409,9 +411,9 @@ typedef enum UNumberFormatFields { * respectively. * *

NOTE:: New users with are strongly encouraged to - * use unumf_openWithSkeletonAndLocale instead of unum_open. + * use unumf_openForSkeletonAndLocale instead of unum_open. * - * @param pattern A pattern specifying the format to use. + * @param pattern A pattern specifying the format to use. * This parameter is ignored unless the style is * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED. * @param patternLength The number of characters in the pattern, or -1 @@ -429,7 +431,7 @@ typedef enum UNumberFormatFields { * @see DecimalFormat * @stable ICU 2.0 */ -U_STABLE UNumberFormat* U_EXPORT2 +U_STABLE UNumberFormat* U_EXPORT2 unum_open( UNumberFormatStyle style, const UChar* pattern, int32_t patternLength, @@ -444,7 +446,7 @@ unum_open( UNumberFormatStyle style, * @param fmt The formatter to close. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 unum_close(UNumberFormat* fmt); #if U_SHOW_CPLUSPLUS_API @@ -474,7 +476,7 @@ U_NAMESPACE_END * @return A pointer to a UNumberFormat identical to fmt. * @stable ICU 2.0 */ -U_STABLE UNumberFormat* U_EXPORT2 +U_STABLE UNumberFormat* U_EXPORT2 unum_clone(const UNumberFormat *fmt, UErrorCode *status); @@ -502,7 +504,7 @@ unum_clone(const UNumberFormat *fmt, * @see UFieldPosition * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_format( const UNumberFormat* fmt, int32_t number, UChar* result, @@ -534,7 +536,7 @@ unum_format( const UNumberFormat* fmt, * @see UFieldPosition * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_formatInt64(const UNumberFormat *fmt, int64_t number, UChar* result, @@ -566,7 +568,7 @@ unum_formatInt64(const UNumberFormat *fmt, * @see UFieldPosition * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_formatDouble( const UNumberFormat* fmt, double number, UChar* result, @@ -651,9 +653,9 @@ unum_formatDoubleForFields(const UNumberFormat* format, * @see unum_parseInt64 * @see unum_parseDouble * @see UFieldPosition -* @stable ICU 4.4 +* @stable ICU 4.4 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_formatDecimal( const UNumberFormat* fmt, const char * number, int32_t length, @@ -742,7 +744,7 @@ unum_formatUFormattable(const UNumberFormat* fmt, * @see unum_formatDouble * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_parse( const UNumberFormat* fmt, const UChar* text, int32_t textLength, @@ -768,7 +770,7 @@ unum_parse( const UNumberFormat* fmt, * @see unum_formatDouble * @stable ICU 2.8 */ -U_STABLE int64_t U_EXPORT2 +U_STABLE int64_t U_EXPORT2 unum_parseInt64(const UNumberFormat* fmt, const UChar* text, int32_t textLength, @@ -794,7 +796,7 @@ unum_parseInt64(const UNumberFormat* fmt, * @see unum_formatDouble * @stable ICU 2.0 */ -U_STABLE double U_EXPORT2 +U_STABLE double U_EXPORT2 unum_parseDouble( const UNumberFormat* fmt, const UChar* text, int32_t textLength, @@ -829,7 +831,7 @@ unum_parseDouble( const UNumberFormat* fmt, * @see unum_formatDouble * @stable ICU 4.4 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_parseDecimal(const UNumberFormat* fmt, const UChar* text, int32_t textLength, @@ -909,7 +911,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt, * @see DecimalFormat * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 unum_applyPattern( UNumberFormat *format, UBool localized, const UChar *pattern, @@ -928,7 +930,7 @@ unum_applyPattern( UNumberFormat *format, * @see unum_countAvailable * @stable ICU 2.0 */ -U_STABLE const char* U_EXPORT2 +U_STABLE const char* U_EXPORT2 unum_getAvailable(int32_t localeIndex); /** @@ -940,7 +942,7 @@ unum_getAvailable(int32_t localeIndex); * @see unum_getAvailable * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_countAvailable(void); #if UCONFIG_HAVE_PARSEALLINPUT @@ -1017,7 +1019,7 @@ typedef enum UNumberFormatAttribute { */ UNUM_PARSE_ALL_INPUT = 20, #endif - /** + /** * Scale, which adjusts the position of the * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale) * before they are formatted. The default value for the scale is 0 ( no adjustment ). @@ -1042,7 +1044,7 @@ typedef enum UNumberFormatAttribute { UNUM_MINIMUM_GROUPING_DIGITS = 22, #endif /* U_HIDE_DRAFT_API */ - /** + /** * if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose, * otherwise it is UNUM_CURRENCY_CASH purpose * Default: 0 (UNUM_CURRENCY_STANDARD purpose) @@ -1063,7 +1065,7 @@ typedef enum UNumberFormatAttribute { * @stable ICU 50 */ UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000, - /** + /** * if this attribute is set to 1, specifies that, if the pattern doesn't contain an exponent, the exponent will not be parsed. If the pattern does contain an exponent, this attribute has no effect. * Has no effect on formatting. * Default: 0 (unset) @@ -1071,8 +1073,8 @@ typedef enum UNumberFormatAttribute { */ UNUM_PARSE_NO_EXPONENT = 0x1001, - /** - * if this attribute is set to 1, specifies that, if the pattern contains a + /** + * if this attribute is set to 1, specifies that, if the pattern contains a * decimal mark the input is required to have one. If this attribute is set to 0, * specifies that input does not have to contain a decimal mark. * Has no effect on formatting. @@ -1127,7 +1129,7 @@ typedef enum UNumberFormatAttribute { * @see unum_setTextAttribute * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_getAttribute(const UNumberFormat* fmt, UNumberFormatAttribute attr); @@ -1150,7 +1152,7 @@ unum_getAttribute(const UNumberFormat* fmt, * @see unum_setTextAttribute * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 unum_setAttribute( UNumberFormat* fmt, UNumberFormatAttribute attr, int32_t newValue); @@ -1170,7 +1172,7 @@ unum_setAttribute( UNumberFormat* fmt, * @see unum_setTextAttribute * @stable ICU 2.0 */ -U_STABLE double U_EXPORT2 +U_STABLE double U_EXPORT2 unum_getDoubleAttribute(const UNumberFormat* fmt, UNumberFormatAttribute attr); @@ -1188,7 +1190,7 @@ unum_getDoubleAttribute(const UNumberFormat* fmt, * @see unum_setTextAttribute * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 unum_setDoubleAttribute( UNumberFormat* fmt, UNumberFormatAttribute attr, double newValue); @@ -1245,7 +1247,7 @@ typedef enum UNumberFormatTextAttribute { * @see unum_setAttribute * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_getTextAttribute( const UNumberFormat* fmt, UNumberFormatTextAttribute tag, UChar* result, @@ -1268,7 +1270,7 @@ unum_getTextAttribute( const UNumberFormat* fmt, * @see unum_setAttribute * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 unum_setTextAttribute( UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, @@ -1291,7 +1293,7 @@ unum_setTextAttribute( UNumberFormat* fmt, * @see DecimalFormat * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 unum_toPattern( const UNumberFormat* fmt, UBool isPatternLocalized, UChar* result, @@ -1339,7 +1341,7 @@ typedef enum UNumberFormatSymbol { /** Significant digit symbol * @stable ICU 3.0 */ UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, - /** The monetary grouping separator + /** The monetary grouping separator * @stable ICU 3.6 */ UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, @@ -1442,7 +1444,7 @@ unum_setSymbol(UNumberFormat *fmt, * Get the locale for this number format object. * You can choose between valid and actual locale. * @param fmt The formatter to get the locale from - * @param type type of the locale we're looking for (valid or actual) + * @param type type of the locale we're looking for (valid or actual) * @param status error code for the operation * @return the locale name * @stable ICU 2.8 @@ -1450,7 +1452,7 @@ unum_setSymbol(UNumberFormat *fmt, U_STABLE const char* U_EXPORT2 unum_getLocaleByType(const UNumberFormat *fmt, ULocDataLocaleType type, - UErrorCode* status); + UErrorCode* status); /** * Set a particular UDisplayContext value in the formatter, such as diff --git a/deps/icu-small/source/i18n/unicode/unumberformatter.h b/deps/icu-small/source/i18n/unicode/unumberformatter.h index e4c21a4e4ab1d1..b27507f7a8f561 100644 --- a/deps/icu-small/source/i18n/unicode/unumberformatter.h +++ b/deps/icu-small/source/i18n/unicode/unumberformatter.h @@ -77,8 +77,6 @@ *

*/ - -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123 * meters in en-CA: @@ -95,7 +93,7 @@ *

* This enum is similar to {@link UMeasureFormatWidth}. * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberUnitWidth { /** @@ -107,7 +105,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_NARROW, @@ -123,7 +121,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_SHORT, @@ -134,7 +132,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_FULL_NAME, @@ -145,7 +143,7 @@ typedef enum UNumberUnitWidth { *

* In CLDR, this option corresponds to the "¤¤" placeholder for currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_ISO_CODE, @@ -154,7 +152,7 @@ typedef enum UNumberUnitWidth { * monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is * equivalent to not specifying the unit at all. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_HIDDEN, @@ -165,9 +163,7 @@ typedef enum UNumberUnitWidth { */ UNUM_UNIT_WIDTH_COUNT } UNumberUnitWidth; -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * An enum declaring the strategy for when and how to display grouping separators (i.e., the * separator, often a comma or period, after every 2-3 powers of ten). The choices are several @@ -192,13 +188,13 @@ typedef enum UNumberUnitWidth { * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the * grouping separator, use the "symbols" setter. * - * @draft ICU 63 + * @stable ICU 63 */ typedef enum UNumberGroupingStrategy { /** * Do not display grouping separators in any locale. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_OFF, @@ -214,7 +210,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_MIN2, @@ -229,7 +225,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_AUTO, @@ -245,7 +241,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_ON_ALIGNED, @@ -253,7 +249,7 @@ typedef enum UNumberGroupingStrategy { * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use * locale data for determining the grouping strategy. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_THOUSANDS @@ -269,10 +265,6 @@ typedef enum UNumberGroupingStrategy { } UNumberGroupingStrategy; - -#endif /* U_HIDE_DRAFT_API */ - -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to denote positive and negative numbers. Example outputs when formatting * 123, 0, and -123 in en-US: @@ -290,14 +282,14 @@ typedef enum UNumberGroupingStrategy { *

* The exact format, including the position and the code point of the sign, differ by locale. * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberSignDisplay { /** * Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default * behavior. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_AUTO, @@ -305,14 +297,14 @@ typedef enum UNumberSignDisplay { * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero. * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ALWAYS, /** * Do not show the sign on positive or negative numbers. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_NEVER, @@ -328,7 +320,7 @@ typedef enum UNumberSignDisplay { * AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the * future. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ACCOUNTING, @@ -338,24 +330,25 @@ typedef enum UNumberSignDisplay { * ACCOUNTING sign display strategy. To hide the sign on zero, see * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ACCOUNTING_ALWAYS, /** * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a - * sign on zero. + * sign on zero or NaN, unless the sign bit is set (-0.0 gets a sign). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_SIGN_EXCEPT_ZERO, /** * Use the locale-dependent accounting format on negative numbers, and show the plus sign on - * positive numbers. Do not show a sign on zero. For more information on the accounting format, - * see the ACCOUNTING sign display strategy. + * positive numbers. Do not show a sign on zero or NaN, unless the sign bit is set (-0.0 gets a + * sign). For more information on the accounting format, see the ACCOUNTING sign display + * strategy. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO, @@ -366,9 +359,7 @@ typedef enum UNumberSignDisplay { */ UNUM_SIGN_COUNT } UNumberSignDisplay; -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to render the decimal separator. * @@ -378,21 +369,21 @@ typedef enum UNumberSignDisplay { *

  • UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1" * * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberDecimalSeparatorDisplay { /** * Show the decimal separator when there are one or more digits to display after the separator, and do not show * it otherwise. This is the default behavior. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_DECIMAL_SEPARATOR_AUTO, /** * Always show the decimal separator, even if there are no digits to display after the separator. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_DECIMAL_SEPARATOR_ALWAYS, @@ -403,7 +394,6 @@ typedef enum UNumberDecimalSeparatorDisplay { */ UNUM_DECIMAL_SEPARATOR_COUNT } UNumberDecimalSeparatorDisplay; -#endif /* U_HIDE_DRAFT_API */ struct UNumberFormatter; /** @@ -649,6 +639,13 @@ unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPosition UErrorCode* ec); +// TODO(ICU-20775): Propose this as API. +// NOTE: This is not currently implemented. +// U_DRAFT int32_t U_EXPORT2 +// unumf_resultToDecimalNumber(const UFormattedNumber* uresult, char* buffer, int32_t bufferCapacity, +// UErrorCode* ec); + + /** * Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale(). * diff --git a/deps/icu-small/source/i18n/unicode/unumsys.h b/deps/icu-small/source/i18n/unicode/unumsys.h index 84ceddf84f73f9..1631c234fd2795 100644 --- a/deps/icu-small/source/i18n/unicode/unumsys.h +++ b/deps/icu-small/source/i18n/unicode/unumsys.h @@ -21,7 +21,7 @@ * \file * \brief C API: UNumberingSystem, information about numbering systems * - * Defines numbering systems. A numbering system describes the scheme by which + * Defines numbering systems. A numbering system describes the scheme by which * numbers are to be presented to the end user. In its simplest form, a numbering * system describes the set of digit characters that are to be used to display * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc., in a diff --git a/deps/icu-small/source/i18n/unicode/uregex.h b/deps/icu-small/source/i18n/unicode/uregex.h index cb5e51ef01e856..131c492a55acd3 100644 --- a/deps/icu-small/source/i18n/unicode/uregex.h +++ b/deps/icu-small/source/i18n/unicode/uregex.h @@ -48,9 +48,9 @@ typedef struct URegularExpression URegularExpression; */ typedef enum URegexpFlag{ -#ifndef U_HIDE_DRAFT_API - /** Forces normalization of pattern and strings. - Not implemented yet, just a placeholder, hence draft. +#ifndef U_HIDE_DRAFT_API + /** Forces normalization of pattern and strings. + Not implemented yet, just a placeholder, hence draft. @draft ICU 2.4 */ UREGEX_CANON_EQ = 128, #endif /* U_HIDE_DRAFT_API */ @@ -63,10 +63,10 @@ typedef enum URegexpFlag{ /** If set, '.' matches line terminators, otherwise '.' matching stops at line end. * @stable ICU 2.4 */ UREGEX_DOTALL = 32, - - /** If set, treat the entire pattern as a literal string. - * Metacharacters or escape sequences in the input sequence will be given - * no special meaning. + + /** If set, treat the entire pattern as a literal string. + * Metacharacters or escape sequences in the input sequence will be given + * no special meaning. * * The flag UREGEX_CASE_INSENSITIVE retains its impact * on matching when used in conjunction with this flag. @@ -81,7 +81,7 @@ typedef enum URegexpFlag{ * otherwise, match only at start and end of input string. * @stable ICU 2.4 */ UREGEX_MULTILINE = 8, - + /** Unix-only line endings. * When this mode is enabled, only \\u000a is recognized as a line ending * in the behavior of ., ^, and $. @@ -114,9 +114,9 @@ typedef enum URegexpFlag{ * string form into an internal representation using the specified match mode flags. * The resulting regular expression handle can then be used to perform various * matching operations. + * * - * - * @param pattern The Regular Expression pattern to be compiled. + * @param pattern The Regular Expression pattern to be compiled. * @param patternLength The length of the pattern, or -1 if the pattern is * NUL terminated. * @param flags Flags that alter the default matching behavior for @@ -148,7 +148,7 @@ uregex_open( const UChar *pattern, * UText struct itself remains with the caller. This is to match the behavior of * uregex_open(). * - * @param pattern The Regular Expression pattern to be compiled. + * @param pattern The Regular Expression pattern to be compiled. * @param flags Flags that alter the default matching behavior for * the regular expression, UREGEX_CASE_INSENSITIVE, for * example. For default behavior, set this parameter to zero. @@ -175,8 +175,8 @@ uregex_openUText(UText *pattern, * This function is the same as uregex_open, except that the pattern * is supplied as an 8 bit char * string in the default code page. * - * @param pattern The Regular Expression pattern to be compiled, - * NUL terminated. + * @param pattern The Regular Expression pattern to be compiled, + * NUL terminated. * @param flags Flags that alter the default matching behavior for * the regular expression, UREGEX_CASE_INSENSITIVE, for * example. For default behavior, set this parameter to zero. @@ -207,7 +207,7 @@ uregex_openC( const char *pattern, * @param regexp The regular expression to be closed. * @stable ICU 3.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_close(URegularExpression *regexp); #if U_SHOW_CPLUSPLUS_API @@ -247,7 +247,7 @@ U_NAMESPACE_END * @return the cloned copy of the compiled regular expression. * @stable ICU 3.0 */ -U_STABLE URegularExpression * U_EXPORT2 +U_STABLE URegularExpression * U_EXPORT2 uregex_clone(const URegularExpression *regexp, UErrorCode *status); /** @@ -267,7 +267,7 @@ uregex_clone(const URegularExpression *regexp, UErrorCode *status); * will remain valid until the regular expression is closed. * @stable ICU 3.0 */ -U_STABLE const UChar * U_EXPORT2 +U_STABLE const UChar * U_EXPORT2 uregex_pattern(const URegularExpression *regexp, int32_t *patLength, UErrorCode *status); @@ -283,7 +283,7 @@ uregex_pattern(const URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_patternUText(const URegularExpression *regexp, UErrorCode *status); @@ -295,7 +295,7 @@ uregex_patternUText(const URegularExpression *regexp, * @see URegexpFlag * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_flags(const URegularExpression *regexp, UErrorCode *status); @@ -308,7 +308,7 @@ uregex_flags(const URegularExpression *regexp, * Regular expression matching operations work directly on the application's * string data. No copy is made. The subject string data must not be * altered after calling this function until after all regular expression - * operations involving this string data are completed. + * operations involving this string data are completed. *

    * Zero length strings are permitted. In this case, no subsequent match * operation will dereference the text string pointer. @@ -320,7 +320,7 @@ uregex_flags(const URegularExpression *regexp, * @param status Receives errors detected by this function. * @stable ICU 3.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_setText(URegularExpression *regexp, const UChar *text, int32_t textLength, @@ -335,7 +335,7 @@ uregex_setText(URegularExpression *regexp, * Regular expression matching operations work directly on the application's * string data; only a shallow clone is made. The subject string data must not be * altered after calling this function until after all regular expression - * operations involving this string data are completed. + * operations involving this string data are completed. * * @param regexp The compiled regular expression. * @param text The subject text string. @@ -343,13 +343,13 @@ uregex_setText(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_setUText(URegularExpression *regexp, UText *text, UErrorCode *status); /** - * Get the subject text that is currently associated with this + * Get the subject text that is currently associated with this * regular expression object. If the input was supplied using uregex_setText(), * that pointer will be returned. Otherwise, the characters in the input will * be extracted to a buffer and returned. In either case, ownership remains @@ -358,7 +358,7 @@ uregex_setUText(URegularExpression *regexp, * This function will work even if the input was originally specified as a UText. * * @param regexp The compiled regular expression. - * @param textLength The length of the string is returned in this output parameter. + * @param textLength The length of the string is returned in this output parameter. * A NULL pointer may be used here if the * text length is not needed, as would be the case if * the text is known in advance to be a NUL terminated @@ -368,13 +368,13 @@ uregex_setUText(URegularExpression *regexp, * this regular expression. * @stable ICU 3.0 */ -U_STABLE const UChar * U_EXPORT2 +U_STABLE const UChar * U_EXPORT2 uregex_getText(URegularExpression *regexp, int32_t *textLength, UErrorCode *status); /** - * Get the subject text that is currently associated with this + * Get the subject text that is currently associated with this * regular expression object. * * This function will work even if the input was originally specified as a UChar string. @@ -389,7 +389,7 @@ uregex_getText(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_getUText(URegularExpression *regexp, UText *dest, UErrorCode *status); @@ -399,19 +399,19 @@ uregex_getUText(URegularExpression *regexp, * without changing any other aspect of the matching state. * The new and previous text strings must have the same content. * - * This function is intended for use in environments where ICU is operating on + * This function is intended for use in environments where ICU is operating on * strings that may move around in memory. It provides a mechanism for notifying * ICU that the string has been relocated, and providing a new UText to access the * string in its new position. * * Note that the regular expression implementation never copies the underlying text - * of a string being matched, but always operates directly on the original text - * provided by the user. Refreshing simply drops the references to the old text + * of a string being matched, but always operates directly on the original text + * provided by the user. Refreshing simply drops the references to the old text * and replaces them with references to the new. * * Caution: this function is normally used only by very specialized - * system-level code. One example use case is with garbage collection - * that moves the text in memory. + * system-level code. One example use case is with garbage collection + * that moves the text in memory. * * @param regexp The compiled regular expression. * @param text The new (moved) text string. @@ -419,7 +419,7 @@ uregex_getUText(URegularExpression *regexp, * * @stable ICU 4.8 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_refreshUText(URegularExpression *regexp, UText *text, UErrorCode *status); @@ -444,7 +444,7 @@ uregex_refreshUText(URegularExpression *regexp, * @return TRUE if there is a match * @stable ICU 3.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_matches(URegularExpression *regexp, int32_t startIndex, UErrorCode *status); @@ -470,7 +470,7 @@ uregex_matches(URegularExpression *regexp, * @return TRUE if there is a match * @stable ICU 4.6 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_matches64(URegularExpression *regexp, int64_t startIndex, UErrorCode *status); @@ -483,7 +483,7 @@ uregex_matches64(URegularExpression *regexp, *

    If startIndex is >= 0 any input region that was set for this * URegularExpression is reset before the operation begins. * - *

    If the specified starting index == -1 the match begins at the start of the input + *

    If the specified starting index == -1 the match begins at the start of the input * region, or at the start of the full string if no region has been specified. * This corresponds directly with Matcher.lookingAt() in Java. * @@ -498,7 +498,7 @@ uregex_matches64(URegularExpression *regexp, * @return TRUE if there is a match. * @stable ICU 3.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_lookingAt(URegularExpression *regexp, int32_t startIndex, UErrorCode *status); @@ -512,7 +512,7 @@ uregex_lookingAt(URegularExpression *regexp, *

    If startIndex is >= 0 any input region that was set for this * URegularExpression is reset before the operation begins. * - *

    If the specified starting index == -1 the match begins at the start of the input + *

    If the specified starting index == -1 the match begins at the start of the input * region, or at the start of the full string if no region has been specified. * This corresponds directly with Matcher.lookingAt() in Java. * @@ -527,7 +527,7 @@ uregex_lookingAt(URegularExpression *regexp, * @return TRUE if there is a match. * @stable ICU 4.6 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_lookingAt64(URegularExpression *regexp, int64_t startIndex, UErrorCode *status); @@ -551,9 +551,9 @@ uregex_lookingAt64(URegularExpression *regexp, * @return TRUE if a match is found. * @stable ICU 3.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_find(URegularExpression *regexp, - int32_t startIndex, + int32_t startIndex, UErrorCode *status); /** @@ -576,15 +576,15 @@ uregex_find(URegularExpression *regexp, * @return TRUE if a match is found. * @stable ICU 4.6 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_find64(URegularExpression *regexp, - int64_t startIndex, + int64_t startIndex, UErrorCode *status); /** - * Find the next pattern match in the input string. Begin searching - * the input at the location following the end of he previous match, - * or at the start of the string (or region) if there is no + * Find the next pattern match in the input string. Begin searching + * the input at the location following the end of he previous match, + * or at the start of the string (or region) if there is no * previous match. If a match is found, uregex_start(), uregex_end(), and * uregex_group() will provide more information regarding the match. * @@ -594,7 +594,7 @@ uregex_find64(URegularExpression *regexp, * @see uregex_reset * @stable ICU 3.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_findNext(URegularExpression *regexp, UErrorCode *status); @@ -605,7 +605,7 @@ uregex_findNext(URegularExpression *regexp, * @return the number of capture groups * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_groupCount(URegularExpression *regexp, UErrorCode *status); @@ -671,7 +671,7 @@ uregex_groupNumberFromCName(URegularExpression *regexp, * or -1 if no applicable match. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_group(URegularExpression *regexp, int32_t groupNum, UChar *dest, @@ -700,7 +700,7 @@ uregex_group(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_groupUText(URegularExpression *regexp, int32_t groupNum, UText *dest, @@ -717,11 +717,11 @@ uregex_groupUText(URegularExpression *regexp, * @param regexp The compiled regular expression. * @param groupNum The capture group number * @param status A reference to a UErrorCode to receive any errors. - * @return the starting (native) position in the input of the text matched + * @return the starting (native) position in the input of the text matched * by the specified group. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_start(URegularExpression *regexp, int32_t groupNum, UErrorCode *status); @@ -737,11 +737,11 @@ uregex_start(URegularExpression *regexp, * @param regexp The compiled regular expression. * @param groupNum The capture group number * @param status A reference to a UErrorCode to receive any errors. - * @return the starting (native) position in the input of the text matched + * @return the starting (native) position in the input of the text matched * by the specified group. * @stable ICU 4.6 */ -U_STABLE int64_t U_EXPORT2 +U_STABLE int64_t U_EXPORT2 uregex_start64(URegularExpression *regexp, int32_t groupNum, UErrorCode *status); @@ -759,7 +759,7 @@ uregex_start64(URegularExpression *regexp, * @return the (native) index of the position following the last matched character. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_end(URegularExpression *regexp, int32_t groupNum, UErrorCode *status); @@ -778,7 +778,7 @@ uregex_end(URegularExpression *regexp, * @return the (native) index of the position following the last matched character. * @stable ICU 4.6 */ -U_STABLE int64_t U_EXPORT2 +U_STABLE int64_t U_EXPORT2 uregex_end64(URegularExpression *regexp, int32_t groupNum, UErrorCode *status); @@ -786,7 +786,7 @@ uregex_end64(URegularExpression *regexp, /** * Reset any saved state from the previous match. Has the effect of * causing uregex_findNext to begin at the specified index, and causing - * uregex_start(), uregex_end() and uregex_group() to return an error + * uregex_start(), uregex_end() and uregex_group() to return an error * indicating that there is no match information available. Clears any * match region that may have been set. * @@ -796,7 +796,7 @@ uregex_end64(URegularExpression *regexp, * @param status A reference to a UErrorCode to receive any errors. * @stable ICU 3.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_reset(URegularExpression *regexp, int32_t index, UErrorCode *status); @@ -805,7 +805,7 @@ uregex_reset(URegularExpression *regexp, * 64bit version of uregex_reset. * Reset any saved state from the previous match. Has the effect of * causing uregex_findNext to begin at the specified index, and causing - * uregex_start(), uregex_end() and uregex_group() to return an error + * uregex_start(), uregex_end() and uregex_group() to return an error * indicating that there is no match information available. Clears any * match region that may have been set. * @@ -815,7 +815,7 @@ uregex_reset(URegularExpression *regexp, * @param status A reference to a UErrorCode to receive any errors. * @stable ICU 4.6 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_reset64(URegularExpression *regexp, int64_t index, UErrorCode *status); @@ -823,7 +823,7 @@ uregex_reset64(URegularExpression *regexp, /** * Sets the limits of the matching region for this URegularExpression. * The region is the part of the input string that will be considered when matching. - * Invoking this method resets any saved state from the previous match, + * Invoking this method resets any saved state from the previous match, * then sets the region to start at the index specified by the start parameter * and end at the index specified by the end parameter. * @@ -850,7 +850,7 @@ uregex_setRegion(URegularExpression *regexp, * 64bit version of uregex_setRegion. * Sets the limits of the matching region for this URegularExpression. * The region is the part of the input string that will be considered when matching. - * Invoking this method resets any saved state from the previous match, + * Invoking this method resets any saved state from the previous match, * then sets the region to start at the index specified by the start parameter * and end at the index specified by the end parameter. * @@ -867,7 +867,7 @@ uregex_setRegion(URegularExpression *regexp, * @param status A pointer to a UErrorCode to receive any errors. * @stable ICU 4.6 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_setRegion64(URegularExpression *regexp, int64_t regionStart, int64_t regionLimit, @@ -882,12 +882,12 @@ uregex_setRegion64(URegularExpression *regexp, * @param regexp The compiled regular expression. * @param regionStart The (native) index to begin searches at. * @param regionLimit The (native) index to end searches at (exclusive). - * @param startIndex The index in the input text at which the next + * @param startIndex The index in the input text at which the next * match operation should begin. * @param status A pointer to a UErrorCode to receive any errors. * @stable ICU 4.6 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_setRegionAndStart(URegularExpression *regexp, int64_t regionStart, int64_t regionLimit, @@ -917,7 +917,7 @@ uregex_regionStart(const URegularExpression *regexp, * @return The starting (native) index of this matcher's region. * @stable ICU 4.6 */ -U_STABLE int64_t U_EXPORT2 +U_STABLE int64_t U_EXPORT2 uregex_regionStart64(const URegularExpression *regexp, UErrorCode *status); @@ -946,7 +946,7 @@ uregex_regionEnd(const URegularExpression *regexp, * @return The ending point (native) of this matcher's region. * @stable ICU 4.6 */ -U_STABLE int64_t U_EXPORT2 +U_STABLE int64_t U_EXPORT2 uregex_regionEnd64(const URegularExpression *regexp, UErrorCode *status); @@ -984,8 +984,8 @@ uregex_hasTransparentBounds(const URegularExpression *regexp, * @param status A pointer to a UErrorCode to receive any errors. * @stable ICU 4.0 **/ -U_STABLE void U_EXPORT2 -uregex_useTransparentBounds(URegularExpression *regexp, +U_STABLE void U_EXPORT2 +uregex_useTransparentBounds(URegularExpression *regexp, UBool b, UErrorCode *status); @@ -1047,7 +1047,7 @@ uregex_hitEnd(const URegularExpression *regexp, * @return TRUE if more input could cause the most recent match to no longer match. * @stable ICU 4.0 */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 uregex_requireEnd(const URegularExpression *regexp, UErrorCode *status); @@ -1060,7 +1060,7 @@ uregex_requireEnd(const URegularExpression *regexp, * with the given replacement string. This is a convenience function that * provides a complete find-and-replace-all operation. * - * This method scans the input string looking for matches of the pattern. + * This method scans the input string looking for matches of the pattern. * Input that is not part of any match is copied unchanged to the * destination buffer. Matched regions are replaced in the output * buffer by the replacement string. The replacement string may contain @@ -1079,7 +1079,7 @@ uregex_requireEnd(const URegularExpression *regexp, * is still the full length of the untruncated string. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_replaceAll(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, @@ -1092,7 +1092,7 @@ uregex_replaceAll(URegularExpression *regexp, * with the given replacement string. This is a convenience function that * provides a complete find-and-replace-all operation. * - * This method scans the input string looking for matches of the pattern. + * This method scans the input string looking for matches of the pattern. * Input that is not part of any match is copied unchanged to the * destination buffer. Matched regions are replaced in the output * buffer by the replacement string. The replacement string may contain @@ -1108,7 +1108,7 @@ uregex_replaceAll(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_replaceAllUText(URegularExpression *regexp, UText *replacement, UText *dest, @@ -1119,7 +1119,7 @@ uregex_replaceAllUText(URegularExpression *regexp, * with the given replacement string. This is a convenience function that * provides a complete find-and-replace operation. * - * This method scans the input string looking for a match of the pattern. + * This method scans the input string looking for a match of the pattern. * All input that is not part of the match is copied unchanged to the * destination buffer. The matched region is replaced in the output * buffer by the replacement string. The replacement string may contain @@ -1138,7 +1138,7 @@ uregex_replaceAllUText(URegularExpression *regexp, * is still the full length of the untruncated string. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_replaceFirst(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, @@ -1151,7 +1151,7 @@ uregex_replaceFirst(URegularExpression *regexp, * with the given replacement string. This is a convenience function that * provides a complete find-and-replace operation. * - * This method scans the input string looking for a match of the pattern. + * This method scans the input string looking for a match of the pattern. * All input that is not part of the match is copied unchanged to the * destination buffer. The matched region is replaced in the output * buffer by the replacement string. The replacement string may contain @@ -1167,7 +1167,7 @@ uregex_replaceFirst(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_replaceFirstUText(URegularExpression *regexp, UText *replacement, UText *dest, @@ -1196,7 +1196,7 @@ uregex_replaceFirstUText(URegularExpression *regexp, *

    For simple, prepackaged, non-incremental find-and-replace * operations, see replaceFirst() or replaceAll().

    * - * @param regexp The regular expression object. + * @param regexp The regular expression object. * @param replacementText The string that will replace the matched portion of the * input string as it is copied to the destination buffer. * The replacement text may contain references ($1, for @@ -1211,7 +1211,7 @@ uregex_replaceFirstUText(URegularExpression *regexp, * @param destCapacity The size of the output buffer, On return, this * parameter will be updated to reflect the space remaining * unused in the output buffer. - * @param status A reference to a UErrorCode to receive any errors. + * @param status A reference to a UErrorCode to receive any errors. * @return The length of the result string. In the event that * destCapacity is inadequate, the full length of the * untruncated output string is returned. @@ -1219,7 +1219,7 @@ uregex_replaceFirstUText(URegularExpression *regexp, * @stable ICU 3.0 * */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_appendReplacement(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, @@ -1239,17 +1239,17 @@ uregex_appendReplacement(URegularExpression *regexp, *

    For simple, prepackaged, non-incremental find-and-replace * operations, see replaceFirst() or replaceAll().

    * - * @param regexp The regular expression object. + * @param regexp The regular expression object. * @param replacementText The string that will replace the matched portion of the * input string as it is copied to the destination buffer. * The replacement text may contain references ($1, for * example) to capture groups from the match. * @param dest A mutable UText that will receive the result. Must not be NULL. - * @param status A reference to a UErrorCode to receive any errors. + * @param status A reference to a UErrorCode to receive any errors. * * @stable ICU 4.6 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 uregex_appendReplacementUText(URegularExpression *regexp, UText *replacementText, UText *dest, @@ -1258,11 +1258,11 @@ uregex_appendReplacementUText(URegularExpression *regexp, /** * As the final step in a find-and-replace operation, append the remainder * of the input string, starting at the position following the last match, - * to the destination string. uregex_appendTail() is intended + * to the destination string. uregex_appendTail() is intended * to be invoked after one or more invocations of the * uregex_appendReplacement() function. * - * @param regexp The regular expression object. This is needed to + * @param regexp The regular expression object. This is needed to * obtain the input string and with the position * of the last match within it. * @param destBuf The buffer in which the results of the @@ -1272,14 +1272,14 @@ uregex_appendReplacementUText(URegularExpression *regexp, * @param destCapacity The size of the output buffer, On return, this * value will be updated to reflect the space remaining * unused in the output buffer. - * @param status A reference to a UErrorCode to receive any errors. + * @param status A reference to a UErrorCode to receive any errors. * @return The length of the result string. In the event that * destCapacity is inadequate, the full length of the * untruncated output string is returned. * * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_appendTail(URegularExpression *regexp, UChar **destBuf, int32_t *destCapacity, @@ -1288,11 +1288,11 @@ uregex_appendTail(URegularExpression *regexp, /** * As the final step in a find-and-replace operation, append the remainder * of the input string, starting at the position following the last match, - * to the destination string. uregex_appendTailUText() is intended + * to the destination string. uregex_appendTailUText() is intended * to be invoked after one or more invocations of the * uregex_appendReplacementUText() function. * - * @param regexp The regular expression object. This is needed to + * @param regexp The regular expression object. This is needed to * obtain the input string and with the position * of the last match within it. * @param dest A mutable UText that will receive the result. Must not be NULL. @@ -1303,7 +1303,7 @@ uregex_appendTail(URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE UText * U_EXPORT2 +U_STABLE UText * U_EXPORT2 uregex_appendTailUText(URegularExpression *regexp, UText *dest, UErrorCode *status); @@ -1320,9 +1320,9 @@ uregex_appendTailUText(URegularExpression *regexp, * * If the delimiter pattern includes capture groups, the captured text will * also appear in the destination array of output strings, interspersed - * with the fields. This is similar to Perl, but differs from Java, + * with the fields. This is similar to Perl, but differs from Java, * which ignores the presence of capture groups in the pattern. - * + * * Trailing empty fields will always be returned, assuming sufficient * destination capacity. This differs from the default behavior for Java * and Perl where trailing empty fields are not returned. @@ -1330,7 +1330,7 @@ uregex_appendTailUText(URegularExpression *regexp, * The number of strings produced by the split operation is returned. * This count includes the strings from capture groups in the delimiter pattern. * This behavior differs from Java, which ignores capture groups. - * + * * @param regexp The compiled regular expression. * @param destBuf A (UChar *) buffer to receive the fields that * are extracted from the input string. These @@ -1340,7 +1340,7 @@ uregex_appendTailUText(URegularExpression *regexp, * set to NULL. * @param destCapacity The capacity of the destBuf. * @param requiredCapacity The actual capacity required of the destBuf. - * If destCapacity is too small, requiredCapacity will return + * If destCapacity is too small, requiredCapacity will return * the total capacity required to hold all of the output, and * a U_BUFFER_OVERFLOW_ERROR will be returned. * @param destFields An array to be filled with the position of each @@ -1359,7 +1359,7 @@ uregex_appendTailUText(URegularExpression *regexp, * @return The number of fields into which the input string was split. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_split( URegularExpression *regexp, UChar *destBuf, int32_t destCapacity, @@ -1394,7 +1394,7 @@ uregex_split( URegularExpression *regexp, * * @stable ICU 4.6 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 uregex_splitUText(URegularExpression *regexp, UText *destFields[], int32_t destFieldsCapacity, @@ -1489,7 +1489,7 @@ uregex_getStackLimit(const URegularExpression *regexp, * @param context context pointer. The callback function will be invoked * with the context specified at the time that * uregex_setMatchCallback() is called. - * @param steps the accumulated processing time, in match steps, + * @param steps the accumulated processing time, in match steps, * for this matching operation. * @return TRUE to continue the matching operation. * FALSE to terminate the matching operation. @@ -1526,7 +1526,7 @@ uregex_setMatchCallback(URegularExpression *regexp, * Get the callback function for this URegularExpression. * * @param regexp The compiled regular expression. - * @param callback Out parameter, receives a pointer to the user-supplied + * @param callback Out parameter, receives a pointer to the user-supplied * callback function. * @param context Out parameter, receives the user context pointer that * was set when uregex_setMatchCallback() was called. @@ -1541,7 +1541,7 @@ uregex_getMatchCallback(const URegularExpression *regexp, /** * Function pointer for a regular expression find callback function. - * + * * When set, a callback function will be called during a find operation * and for operations that depend on find, such as findNext, split and some replace * operations like replaceFirst. @@ -1553,7 +1553,7 @@ uregex_getMatchCallback(const URegularExpression *regexp, * When invoked, this callback will specify the index at which a match operation is about * to be attempted, giving the application the opportunity to terminate a long-running * find operation. - * + * * If the call back function returns FALSE, the find operation will be terminated early. * * Note: the callback function must not call other functions on this @@ -1597,7 +1597,7 @@ uregex_setFindProgressCallback(URegularExpression *regexp, * Get the find progress callback function for this URegularExpression. * * @param regexp The compiled regular expression. - * @param callback Out parameter, receives a pointer to the user-supplied + * @param callback Out parameter, receives a pointer to the user-supplied * callback function. * @param context Out parameter, receives the user context pointer that * was set when uregex_setFindProgressCallback() was called. diff --git a/deps/icu-small/source/i18n/unicode/uregion.h b/deps/icu-small/source/i18n/unicode/uregion.h index 9d0c1e99de3864..a5de49674b52d8 100644 --- a/deps/icu-small/source/i18n/unicode/uregion.h +++ b/deps/icu-small/source/i18n/unicode/uregion.h @@ -17,7 +17,7 @@ * \file * \brief C API: URegion (territory containment and mapping) * - * URegion objects represent data associated with a particular Unicode Region Code, also known as a + * URegion objects represent data associated with a particular Unicode Region Code, also known as a * Unicode Region Subtag, which is defined based upon the BCP 47 standard. These include: * * Two-letter codes defined by ISO 3166-1, with special LDML treatment of certain private-use or * reserved codes; @@ -25,7 +25,7 @@ * URegion objects can also provide mappings to and from additional codes. There are different types * of regions that are important to distinguish: *

    - * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or + * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or * selected economic and other grouping" as defined in UN M.49. These are typically 3-digit codes, * but contain some 2-letter codes for LDML extensions, such as "QO" for Outlying Oceania. * Macroregions are represented in ICU by one of three region types: WORLD (code 001), @@ -33,8 +33,8 @@ * by a continent ). *

    * TERRITORY - A Region that is not a Macroregion. These are typically codes for countries, but also - * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code - * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate + * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code + * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate * codes. The codes are typically 2-letter codes aligned with ISO 3166, but BCP47 allows for the use * of 3-digit codes in the future. *

    @@ -45,7 +45,7 @@ * usually due to a country splitting into multiple territories or changing its name. *

    * GROUPING - A widely understood grouping of territories that has a well defined membership such - * that a region code has been assigned for it. Some of these are UN M.49 codes that don't fall into + * that a region code has been assigned for it. Some of these are UN M.49 codes that don't fall into * the world/continent/sub-continent hierarchy, while others are just well-known groupings that have * their own region code. Region "EU" (European Union) is one such region code that is a grouping. * Groupings will never be returned by the uregion_getContainingRegion, since a different type of region @@ -59,51 +59,51 @@ * URegionType is an enumeration defining the different types of regions. Current possible * values are URGN_WORLD, URGN_CONTINENT, URGN_SUBCONTINENT, URGN_TERRITORY, URGN_GROUPING, * URGN_DEPRECATED, and URGN_UNKNOWN. - * - * @stable ICU 51 + * + * @stable ICU 51 */ typedef enum URegionType { /** * Type representing the unknown region. - * @stable ICU 51 + * @stable ICU 51 */ URGN_UNKNOWN, /** * Type representing a territory. - * @stable ICU 51 + * @stable ICU 51 */ URGN_TERRITORY, /** * Type representing the whole world. - * @stable ICU 51 + * @stable ICU 51 */ URGN_WORLD, /** * Type representing a continent. - * @stable ICU 51 + * @stable ICU 51 */ URGN_CONTINENT, /** * Type representing a sub-continent. - * @stable ICU 51 + * @stable ICU 51 */ URGN_SUBCONTINENT, /** * Type representing a grouping of territories that is not to be used in * the normal WORLD/CONTINENT/SUBCONTINENT/TERRITORY containment tree. - * @stable ICU 51 + * @stable ICU 51 */ URGN_GROUPING, /** * Type representing a region whose code has been deprecated, usually * due to a country splitting into multiple territories or changing its name. - * @stable ICU 51 + * @stable ICU 51 */ URGN_DEPRECATED, diff --git a/deps/icu-small/source/i18n/unicode/ureldatefmt.h b/deps/icu-small/source/i18n/unicode/ureldatefmt.h index 1aa554dc7c0d7a..0724d385594ff1 100644 --- a/deps/icu-small/source/i18n/unicode/ureldatefmt.h +++ b/deps/icu-small/source/i18n/unicode/ureldatefmt.h @@ -78,7 +78,7 @@ typedef enum UDateRelativeDateTimeFormatterStyle { typedef enum URelativeDateTimeUnit { /** * Specifies that relative unit is year, e.g. "last year", - * "in 5 years". + * "in 5 years". * @stable ICU 57 */ UDAT_REL_UNIT_YEAR, @@ -150,7 +150,7 @@ typedef enum URelativeDateTimeUnit { UDAT_REL_UNIT_WEDNESDAY, /** * Specifies that relative unit is Thursday, e.g. "last Thursday", - * "this Thursday", "next Thursday", "in 5 Thursdays". + * "this Thursday", "next Thursday", "in 5 Thursdays". * @stable ICU 57 */ UDAT_REL_UNIT_THURSDAY, diff --git a/deps/icu-small/source/i18n/unicode/usearch.h b/deps/icu-small/source/i18n/unicode/usearch.h index 6b495ef00140f1..080528e3474677 100644 --- a/deps/icu-small/source/i18n/unicode/usearch.h +++ b/deps/icu-small/source/i18n/unicode/usearch.h @@ -24,62 +24,62 @@ * \file * \brief C API: StringSearch * - * C Apis for an engine that provides language-sensitive text searching based + * C APIs for an engine that provides language-sensitive text searching based * on the comparison rules defined in a UCollator data struct, - * see ucol.h. This ensures that language eccentricity can be - * handled, e.g. for the German collator, characters ß and SS will be matched - * if case is chosen to be ignored. + * see ucol.h. This ensures that language eccentricity can be + * handled, e.g. for the German collator, characters ß and SS will be matched + * if case is chosen to be ignored. * See the * "ICU Collation Design Document" for more information. - *

    + *

    * The implementation may use a linear search or a modified form of the Boyer-Moore - * search; for more information on the latter see + * search; for more information on the latter see * - * "Efficient Text Searching in Java", published in Java Report + * "Efficient Text Searching in Java", published in Java Report * in February, 1999. *

    * There are 2 match options for selection:
    - * Let S' be the sub-string of a text string S between the offsets start and + * Let S' be the sub-string of a text string S between the offsets start and * end . *
    - * A pattern string P matches a text string S at the offsets + * A pattern string P matches a text string S at the offsets * if - *

    - * option 1. Some canonical equivalent of P matches some canonical equivalent
    + * 
     
    + * option 1. Some canonical equivalent of P matches some canonical equivalent 
      *           of S'
    - * option 2. P matches S' and if P starts or ends with a combining mark,
    - *           there exists no non-ignorable combining mark before or after S'
    - *           in S respectively.
    + * option 2. P matches S' and if P starts or ends with a combining mark, 
    + *           there exists no non-ignorable combining mark before or after S' 
    + *           in S respectively. 
      * 
    * Option 2. will be the default. *

    - * This search has APIs similar to that of other text iteration mechanisms - * such as the break iterators in ubrk.h. Using these - * APIs, it is easy to scan through text looking for all occurances of - * a given pattern. This search iterator allows changing of direction by - * calling a reset followed by a next or previous. - * Though a direction change can occur without calling reset first, + * This search has APIs similar to that of other text iteration mechanisms + * such as the break iterators in ubrk.h. Using these + * APIs, it is easy to scan through text looking for all occurrences of + * a given pattern. This search iterator allows changing of direction by + * calling a reset followed by a next or previous. + * Though a direction change can occur without calling reset first, * this operation comes with some speed penalty. - * Generally, match results in the forward direction will match the result + * Generally, match results in the forward direction will match the result * matches in the backwards direction in the reverse order *

    - * usearch.h provides APIs to specify the starting position + * usearch.h provides APIs to specify the starting position * within the text string to be searched, e.g. usearch_setOffset, - * usearch_preceding and usearch_following. Since the - * starting position will be set as it is specified, please take note that - * there are some dangerous positions which the search may render incorrect + * usearch_preceding and usearch_following. Since the + * starting position will be set as it is specified, please take note that + * there are some dangerous positions which the search may render incorrect * results: *

      *
    • The midst of a substring that requires normalization. *
    • If the following match is to be found, the position should not be the - * second character which requires to be swapped with the preceding - * character. Vice versa, if the preceding match is to be found, - * position to search from should not be the first character which + * second character which requires to be swapped with the preceding + * character. Vice versa, if the preceding match is to be found, + * position to search from should not be the first character which * requires to be swapped with the next character. E.g certain Thai and * Lao characters require swapping. - *
    • If a following pattern match is to be found, any position within a - * contracting sequence except the first will fail. Vice versa if a - * preceding pattern match is to be found, a invalid starting point + *
    • If a following pattern match is to be found, any position within a + * contracting sequence except the first will fail. Vice versa if a + * preceding pattern match is to be found, a invalid starting point * would be any character within a contracting sequence except the last. *
    *

    @@ -88,9 +88,9 @@ * boundaries given by the breakiterator. For instance the pattern "e" will * not be found in the string "\u00e9" if a character break iterator is used. *

    - * Options are provided to handle overlapping matches. - * E.g. In English, overlapping matches produces the result 0 and 2 - * for the pattern "abab" in the text "ababab", where else mutually + * Options are provided to handle overlapping matches. + * E.g. In English, overlapping matches produces the result 0 and 2 + * for the pattern "abab" in the text "ababab", where else mutually * exclusive matches only produce the result of 0. *

    * Options are also provided to implement "asymmetric search" as described in @@ -98,19 +98,19 @@ * UTS #10 Unicode Collation Algorithm, specifically the USearchAttribute * USEARCH_ELEMENT_COMPARISON and its values. *

    - * Though collator attributes will be taken into consideration while - * performing matches, there are no APIs here for setting and getting the + * Though collator attributes will be taken into consideration while + * performing matches, there are no APIs here for setting and getting the * attributes. These attributes can be set by getting the collator * from usearch_getCollator and using the APIs in ucol.h. - * Lastly to update String Search to the new collator attributes, + * Lastly to update String Search to the new collator attributes, * usearch_reset() has to be called. - *

    + *

    * Restriction:
    * Currently there are no composite characters that consists of a - * character with combining class > 0 before a character with combining - * class == 0. However, if such a character exists in the future, the + * character with combining class > 0 before a character with combining + * class == 0. However, if such a character exists in the future, the * search mechanism does not guarantee the results for option 1. - * + * *

    * Example of use:
    *

    
    @@ -122,15 +122,15 @@
      * u_uastrcpy(target, tgtstr);
      * u_uastrcpy(pattern, patstr);
      *
    - * UStringSearch *search = usearch_open(pattern, -1, target, -1, "en_US",
    + * UStringSearch *search = usearch_open(pattern, -1, target, -1, "en_US", 
      *                                  NULL, &status);
      * if (U_SUCCESS(status)) {
    - *     for (int pos = usearch_first(search, &status);
    - *          pos != USEARCH_DONE;
    + *     for (int pos = usearch_first(search, &status); 
    + *          pos != USEARCH_DONE; 
      *          pos = usearch_next(search, &status))
      *     {
    - *         printf("Found match at %d pos, length is %d\n", pos,
    - *                                        usearch_getMatchLength(search));
    + *         printf("Found match at %d pos, length is %d\n", pos, 
    + *                                        usearch_getMatchedLength(search));
      *     }
      * }
      *
    @@ -140,7 +140,7 @@
      */
     
     /**
    -* DONE is returned by previous() and next() after all valid matches have
    +* DONE is returned by previous() and next() after all valid matches have 
     * been returned, and by first() and last() if there are no matches at all.
     * @stable ICU 2.4
     */
    @@ -167,7 +167,7 @@ typedef enum {
          */
         USEARCH_OVERLAP = 0,
     #ifndef U_HIDE_DEPRECATED_API
    -    /**
    +    /** 
          * Option for canonical matches; option 1 in header documentation.
          * The default value will be USEARCH_OFF.
          * Note: Setting this option to USEARCH_ON currently has no effect on
    @@ -175,7 +175,7 @@ typedef enum {
          * canonical match behavior, you must set UCOL_NORMALIZATION_MODE
          * appropriately (to UCOL_OFF or UCOL_ON) in the UCollator used by
          * the UStringSearch object.
    -     * @see usearch_openFromCollator
    +     * @see usearch_openFromCollator 
          * @see usearch_getCollator
          * @see usearch_setCollator
          * @see ucol_getAttribute
    @@ -183,7 +183,7 @@ typedef enum {
          */
         USEARCH_CANONICAL_MATCH = 1,
     #endif  /* U_HIDE_DEPRECATED_API */
    -    /**
    +    /** 
          * Option to control how collation elements are compared.
          * The default value will be USEARCH_STANDARD_ELEMENT_COMPARISON.
          * @stable ICU 4.4
    @@ -203,7 +203,7 @@ typedef enum {
     * @stable ICU 2.4
     */
     typedef enum {
    -    /**
    +    /** 
          * Default value for any USearchAttribute
          * @stable ICU 2.4
          */
    @@ -212,20 +212,20 @@ typedef enum {
          * Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH
          * @stable ICU 2.4
          */
    -    USEARCH_OFF,
    +    USEARCH_OFF, 
         /**
          * Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH
          * @stable ICU 2.4
          */
         USEARCH_ON,
    -    /**
    +    /** 
          * Value (default) for USEARCH_ELEMENT_COMPARISON;
          * standard collation element comparison at the specified collator
          * strength.
          * @stable ICU 4.4
          */
         USEARCH_STANDARD_ELEMENT_COMPARISON,
    -    /**
    +    /** 
          * Value for USEARCH_ELEMENT_COMPARISON;
          * collation element comparison is modified to effectively provide
          * behavior between the specified strength and strength - 1. Collation
    @@ -244,7 +244,7 @@ typedef enum {
          * @stable ICU 4.4
          */
         USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD,
    -    /**
    +    /** 
          * Value for USEARCH_ELEMENT_COMPARISON.
          * collation element comparison is modified to effectively provide
          * behavior between the specified strength and strength - 1. Collation
    @@ -286,21 +286,21 @@ typedef enum {
     * @param textlength length of the text string, -1 for null-termination
     * @param locale name of locale for the rules to be used
     * @param breakiter A BreakIterator that will be used to restrict the points
    -*                  at which matches are detected. If a match is found, but
    -*                  the match's start or end index is not a boundary as
    -*                  determined by the BreakIterator, the match will
    -*                  be rejected and another will be searched for.
    -*                  If this parameter is NULL, no break detection is
    +*                  at which matches are detected. If a match is found, but 
    +*                  the match's start or end index is not a boundary as 
    +*                  determined by the BreakIterator, the match will 
    +*                  be rejected and another will be searched for. 
    +*                  If this parameter is NULL, no break detection is 
     *                  attempted.
     * @param status for errors if it occurs. If pattern or text is NULL, or if
    -*               patternlength or textlength is 0 then an
    +*               patternlength or textlength is 0 then an 
     *               U_ILLEGAL_ARGUMENT_ERROR is returned.
     * @return search iterator data structure, or NULL if there is an error.
     * @stable ICU 2.4
     */
    -U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern,
    -                                              int32_t         patternlength,
    -                                        const UChar          *text,
    +U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern, 
    +                                              int32_t         patternlength, 
    +                                        const UChar          *text, 
                                                   int32_t         textlength,
                                             const char           *locale,
                                                   UBreakIterator *breakiter,
    @@ -308,9 +308,9 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern,
     
     /**
     * Creating a search iterator data struct using the argument collator language
    -* rule set. Note, user retains the ownership of this collator, thus the
    +* rule set. Note, user retains the ownership of this collator, thus the 
     * responsibility of deletion lies with the user.
    -* NOTE: string search cannot be instantiated from a collator that has
    +* NOTE: string search cannot be instantiated from a collator that has 
     * collate digits as numbers (CODAN) turned on.
     * @param pattern for matching
     * @param patternlength length of the pattern, -1 for null-termination
    @@ -318,22 +318,22 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern,
     * @param textlength length of the text string, -1 for null-termination
     * @param collator used for the language rules
     * @param breakiter A BreakIterator that will be used to restrict the points
    -*                  at which matches are detected. If a match is found, but
    -*                  the match's start or end index is not a boundary as
    -*                  determined by the BreakIterator, the match will
    -*                  be rejected and another will be searched for.
    -*                  If this parameter is NULL, no break detection is
    +*                  at which matches are detected. If a match is found, but 
    +*                  the match's start or end index is not a boundary as 
    +*                  determined by the BreakIterator, the match will 
    +*                  be rejected and another will be searched for. 
    +*                  If this parameter is NULL, no break detection is 
     *                  attempted.
    -* @param status for errors if it occurs. If collator, pattern or text is NULL,
    -*               or if patternlength or textlength is 0 then an
    +* @param status for errors if it occurs. If collator, pattern or text is NULL, 
    +*               or if patternlength or textlength is 0 then an 
     *               U_ILLEGAL_ARGUMENT_ERROR is returned.
     * @return search iterator data structure, or NULL if there is an error.
     * @stable ICU 2.4
     */
     U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
    -                                         const UChar *pattern,
    +                                         const UChar *pattern, 
                                                    int32_t         patternlength,
    -                                         const UChar          *text,
    +                                         const UChar          *text, 
                                                    int32_t         textlength,
                                              const UCollator      *collator,
                                                    UBreakIterator *breakiter,
    @@ -369,34 +369,34 @@ U_NAMESPACE_END
     /* get and set methods -------------------------------------------------- */
     
     /**
    -* Sets the current position in the text string which the next search will
    -* start from. Clears previous states.
    -* This method takes the argument index and sets the position in the text
    -* string accordingly without checking if the index is pointing to a
    -* valid starting point to begin searching.
    +* Sets the current position in the text string which the next search will 
    +* start from. Clears previous states. 
    +* This method takes the argument index and sets the position in the text 
    +* string accordingly without checking if the index is pointing to a 
    +* valid starting point to begin searching. 
     * Search positions that may render incorrect results are highlighted in the
     * header comments
     * @param strsrch search iterator data struct
     * @param position position to start next search from. If position is less
    -*          than or greater than the text range for searching,
    +*          than or greater than the text range for searching, 
     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
     * @param status error status if any.
     * @stable ICU 2.4
     */
    -U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
    +U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, 
                                             int32_t    position,
                                             UErrorCode    *status);
     
     /**
     * Return the current index in the string text being searched.
    -* If the iteration has gone past the end of the text (or past the beginning
    +* If the iteration has gone past the end of the text (or past the beginning 
     * for a backwards search), USEARCH_DONE is returned.
     * @param strsrch search iterator data struct
     * @see #USEARCH_DONE
     * @stable ICU 2.4
     */
     U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
    -
    +    
     /**
     * Sets the text searching attributes located in the enum USearchAttribute
     * with values from the enum USearchAttributeValue.
    @@ -408,12 +408,12 @@ U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
     * @see #usearch_getAttribute
     * @stable ICU 2.4
     */
    -U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch         *strsrch,
    +U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch         *strsrch, 
                                                USearchAttribute       attribute,
                                                USearchAttributeValue  value,
                                                UErrorCode            *status);
     
    -/**
    +/**    
     * Gets the text searching attributes.
     * @param strsrch search iterator data struct
     * @param attribute text attribute to be retrieve
    @@ -427,15 +427,15 @@ U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
     
     /**
     * Returns the index to the match in the text string that was searched.
    -* This call returns a valid result only after a successful call to
    -* usearch_first, usearch_next, usearch_previous,
    +* This call returns a valid result only after a successful call to 
    +* usearch_first, usearch_next, usearch_previous, 
     * or usearch_last.
    -* Just after construction, or after a searching method returns
    +* Just after construction, or after a searching method returns 
     * USEARCH_DONE, this method will return USEARCH_DONE.
     * 

    * Use usearch_getMatchedLength to get the matched string length. * @param strsrch search iterator data struct -* @return index to a substring within the text string that is being +* @return index to a substring within the text string that is being * searched. * @see #usearch_first * @see #usearch_next @@ -446,16 +446,16 @@ U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute( */ U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart( const UStringSearch *strsrch); - + /** -* Returns the length of text in the string which matches the search pattern. -* This call returns a valid result only after a successful call to -* usearch_first, usearch_next, usearch_previous, +* Returns the length of text in the string which matches the search pattern. +* This call returns a valid result only after a successful call to +* usearch_first, usearch_next, usearch_previous, * or usearch_last. -* Just after construction, or after a searching method returns +* Just after construction, or after a searching method returns * USEARCH_DONE, this method will return 0. * @param strsrch search iterator data struct -* @return The length of the match in the string text, or 0 if there is no +* @return The length of the match in the string text, or 0 if there is no * match currently. * @see #usearch_first * @see #usearch_next @@ -468,18 +468,18 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength( const UStringSearch *strsrch); /** -* Returns the text that was matched by the most recent call to -* usearch_first, usearch_next, usearch_previous, +* Returns the text that was matched by the most recent call to +* usearch_first, usearch_next, usearch_previous, * or usearch_last. -* If the iterator is not pointing at a valid match (e.g. just after +* If the iterator is not pointing at a valid match (e.g. just after * construction or after USEARCH_DONE has been returned, returns * an empty string. If result is not large enough to store the matched text, -* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR -* will be returned in status. result will be null-terminated whenever -* possible. If the buffer fits the matched text exactly, a null-termination +* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR +* will be returned in status. result will be null-terminated whenever +* possible. If the buffer fits the matched text exactly, a null-termination * is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status. -* Pre-flighting can be either done with length = 0 or the API -* usearch_getMatchLength. +* Pre-flighting can be either done with length = 0 or the API +* usearch_getMatchedLength. * @param strsrch search iterator data struct * @param result UChar buffer to store the matched string * @param resultCapacity length of the result buffer @@ -492,37 +492,37 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength( * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, - UChar *result, - int32_t resultCapacity, +U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, + UChar *result, + int32_t resultCapacity, UErrorCode *status); #if !UCONFIG_NO_BREAK_ITERATION /** -* Set the BreakIterator that will be used to restrict the points at which +* Set the BreakIterator that will be used to restrict the points at which * matches are detected. * @param strsrch search iterator data struct * @param breakiter A BreakIterator that will be used to restrict the points -* at which matches are detected. If a match is found, but -* the match's start or end index is not a boundary as -* determined by the BreakIterator, the match will -* be rejected and another will be searched for. -* If this parameter is NULL, no break detection is +* at which matches are detected. If a match is found, but +* the match's start or end index is not a boundary as +* determined by the BreakIterator, the match will +* be rejected and another will be searched for. +* If this parameter is NULL, no break detection is * attempted. * @param status for errors if it occurs * @see #usearch_getBreakIterator * @stable ICU 2.4 */ -U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, +U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, UBreakIterator *breakiter, UErrorCode *status); /** -* Returns the BreakIterator that is used to restrict the points at which -* matches are detected. This will be the same object that was passed to the -* constructor or to usearch_setBreakIterator. Note that -* NULL +* Returns the BreakIterator that is used to restrict the points at which +* matches are detected. This will be the same object that was passed to the +* constructor or to usearch_setBreakIterator. Note that +* NULL * is a legal value; it means that break detection should not be attempted. * @param strsrch search iterator data struct * @return break iterator used @@ -531,23 +531,23 @@ U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, */ U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator( const UStringSearch *strsrch); - + #endif - + /** -* Set the string text to be searched. Text iteration will hence begin at the -* start of the text string. This method is useful if you want to re-use an +* Set the string text to be searched. Text iteration will hence begin at the +* start of the text string. This method is useful if you want to re-use an * iterator to search for the same pattern within a different body of text. * @param strsrch search iterator data struct * @param text new string to look for match * @param textlength length of the new string, -1 for null-termination -* @param status for errors if it occurs. If text is NULL, or textlength is 0 +* @param status for errors if it occurs. If text is NULL, or textlength is 0 * then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change * done to strsrch. * @see #usearch_getText * @stable ICU 2.4 */ -U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch, +U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch, const UChar *text, int32_t textlength, UErrorCode *status); @@ -556,17 +556,17 @@ U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch, * Return the string text to be searched. * @param strsrch search iterator data struct * @param length returned string text length -* @return string text +* @return string text * @see #usearch_setText * @stable ICU 2.4 */ -U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, +U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, int32_t *length); /** -* Gets the collator used for the language rules. +* Gets the collator used for the language rules. *

    -* Deleting the returned UCollator before calling +* Deleting the returned UCollator before calling * usearch_close would cause the string search to fail. * usearch_close will delete the collator if this search owns it. * @param strsrch search iterator data struct @@ -577,32 +577,32 @@ U_STABLE UCollator * U_EXPORT2 usearch_getCollator( const UStringSearch *strsrch); /** -* Sets the collator used for the language rules. User retains the ownership +* Sets the collator used for the language rules. User retains the ownership * of this collator, thus the responsibility of deletion lies with the user. -* This method causes internal data such as Boyer-Moore shift tables to +* This method causes internal data such as Boyer-Moore shift tables to * be recalculated, but the iterator's position is unchanged. * @param strsrch search iterator data struct * @param collator to be used * @param status for errors if it occurs * @stable ICU 2.4 */ -U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, +U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, const UCollator *collator, UErrorCode *status); /** * Sets the pattern used for matching. -* Internal data like the Boyer Moore table will be recalculated, but the +* Internal data like the Boyer Moore table will be recalculated, but the * iterator's position is unchanged. * @param strsrch search iterator data struct * @param pattern string * @param patternlength pattern length, -1 for null-terminated string -* @param status for errors if it occurs. If text is NULL, or textlength is 0 +* @param status for errors if it occurs. If text is NULL, or textlength is 0 * then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change * done to strsrch. * @stable ICU 2.4 */ -U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, +U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status); @@ -610,46 +610,46 @@ U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, /** * Gets the search pattern * @param strsrch search iterator data struct -* @param length return length of the pattern, -1 indicates that the pattern +* @param length return length of the pattern, -1 indicates that the pattern * is null-terminated * @return pattern string * @stable ICU 2.4 */ U_STABLE const UChar * U_EXPORT2 usearch_getPattern( - const UStringSearch *strsrch, + const UStringSearch *strsrch, int32_t *length); /* methods ------------------------------------------------------------- */ /** -* Returns the first index at which the string text matches the search -* pattern. -* The iterator is adjusted so that its current index (as returned by +* Returns the first index at which the string text matches the search +* pattern. +* The iterator is adjusted so that its current index (as returned by * usearch_getOffset) is the match position if one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE. * @param strsrch search iterator data struct * @param status for errors if it occurs -* @return The character index of the first match, or +* @return The character index of the first match, or * USEARCH_DONE if there are no matches. * @see #usearch_getOffset * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, +U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, UErrorCode *status); /** * Returns the first index equal or greater than position at which * the string text -* matches the search pattern. The iterator is adjusted so that its current -* index (as returned by usearch_getOffset) is the match position if +* matches the search pattern. The iterator is adjusted so that its current +* index (as returned by usearch_getOffset) is the match position if * one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE *

    * Search positions that may render incorrect results are highlighted in the -* header comments. If position is less than or greater than the text range +* header comments. If position is less than or greater than the text range * for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned * @param strsrch search iterator data struct * @param position to start the search at @@ -660,38 +660,38 @@ U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, - int32_t position, +U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, + int32_t position, UErrorCode *status); - + /** -* Returns the last index in the target text at which it matches the search -* pattern. The iterator is adjusted so that its current -* index (as returned by usearch_getOffset) is the match position if +* Returns the last index in the target text at which it matches the search +* pattern. The iterator is adjusted so that its current +* index (as returned by usearch_getOffset) is the match position if * one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE. * @param strsrch search iterator data struct * @param status for errors if it occurs -* @return The index of the first match, or USEARCH_DONE if there +* @return The index of the first match, or USEARCH_DONE if there * are no matches. * @see #usearch_getOffset * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, +U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, UErrorCode *status); /** -* Returns the first index less than position at which the string text -* matches the search pattern. The iterator is adjusted so that its current -* index (as returned by usearch_getOffset) is the match position if +* Returns the first index less than position at which the string text +* matches the search pattern. The iterator is adjusted so that its current +* index (as returned by usearch_getOffset) is the match position if * one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE *

    * Search positions that may render incorrect results are highlighted in the -* header comments. If position is less than or greater than the text range +* header comments. If position is less than or greater than the text range * for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned. *

    * When USEARCH_OVERLAP option is off, the last index of the @@ -707,35 +707,35 @@ U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, - int32_t position, +U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, + int32_t position, UErrorCode *status); - + /** * Returns the index of the next point at which the string text matches the * search pattern, starting from the current position. -* The iterator is adjusted so that its current -* index (as returned by usearch_getOffset) is the match position if +* The iterator is adjusted so that its current +* index (as returned by usearch_getOffset) is the match position if * one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE * @param strsrch search iterator data struct * @param status for errors if it occurs -* @return The index of the next match after the current position, or +* @return The index of the next match after the current position, or * USEARCH_DONE if there are no more matches. * @see #usearch_first * @see #usearch_getOffset * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, +U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, UErrorCode *status); /** * Returns the index of the previous point at which the string text matches * the search pattern, starting at the current position. -* The iterator is adjusted so that its current -* index (as returned by usearch_getOffset) is the match position if +* The iterator is adjusted so that its current +* index (as returned by usearch_getOffset) is the match position if * one was found. * If a match is not found, USEARCH_DONE will be returned and * the iterator will be adjusted to the index USEARCH_DONE @@ -748,13 +748,13 @@ U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, * @see #USEARCH_DONE * @stable ICU 2.4 */ -U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, +U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, UErrorCode *status); - -/** + +/** * Reset the iteration. -* Search will begin at the start of the text string if a forward iteration -* is initiated before a backwards iteration. Otherwise if a backwards +* Search will begin at the start of the text string if a forward iteration +* is initiated before a backwards iteration. Otherwise if a backwards * iteration is initiated before a forwards iteration, the search will begin * at the end of the text string. * @param strsrch search iterator data struct @@ -766,7 +766,7 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); #ifndef U_HIDE_INTERNAL_API /** * Simple forward search for the pattern, starting at a specified index, - * and using using a default set search options. + * and using a default set search options. * * This is an experimental function, and is not an official part of the * ICU API. @@ -783,21 +783,21 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); * are part of a combining sequence, as described below. * * A match will not include a partial combining sequence. Combining - * character sequences are considered to be inseperable units, + * character sequences are considered to be inseparable units, * and either match the pattern completely, or are considered to not match - * at all. Thus, for example, an A followed a combining accent mark will + * at all. Thus, for example, an A followed a combining accent mark will * not be found when searching for a plain (unaccented) A. (unless * the collation strength has been set to ignore all accents). * * When beginning a search, the initial starting position, startIdx, * is assumed to be an acceptable match boundary with respect to * combining characters. A combining sequence that spans across the - * starting point will not supress a match beginning at startIdx. + * starting point will not suppress a match beginning at startIdx. * * Characters that expand to multiple collation elements * (German sharp-S becoming 'ss', or the composed forms of accented * characters, for example) also must match completely. - * Searching for a single 's' in a string containing only a sharp-s will + * Searching for a single 's' in a string containing only a sharp-s will * find no match. * * @@ -812,7 +812,7 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); * in the input text. * This parameter may be NULL. * A value of -1 will be returned if no match was found. - * + * * @param status Report any errors. Note that no match found is not an error. * @return TRUE if a match was found, FALSE otherwise. * @@ -843,21 +843,21 @@ U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, * are part of a combining sequence, as described below. * * A match will not include a partial combining sequence. Combining - * character sequences are considered to be inseperable units, + * character sequences are considered to be inseparable units, * and either match the pattern completely, or are considered to not match - * at all. Thus, for example, an A followed a combining accent mark will + * at all. Thus, for example, an A followed a combining accent mark will * not be found when searching for a plain (unaccented) A. (unless * the collation strength has been set to ignore all accents). * * When beginning a search, the initial starting position, startIdx, * is assumed to be an acceptable match boundary with respect to * combining characters. A combining sequence that spans across the - * starting point will not supress a match beginning at startIdx. + * starting point will not suppress a match beginning at startIdx. * * Characters that expand to multiple collation elements * (German sharp-S becoming 'ss', or the composed forms of accented * characters, for example) also must match completely. - * Searching for a single 's' in a string containing only a sharp-s will + * Searching for a single 's' in a string containing only a sharp-s will * find no match. * * @@ -872,7 +872,7 @@ U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, * in the input text. * This parameter may be NULL. * A value of -1 will be returned if no match was found. - * + * * @param status Report any errors. Note that no match found is not an error. * @return TRUE if a match was found, FALSE otherwise. * diff --git a/deps/icu-small/source/i18n/unicode/uspoof.h b/deps/icu-small/source/i18n/unicode/uspoof.h index d15ba4b24235dc..63a13387b063be 100644 --- a/deps/icu-small/source/i18n/unicode/uspoof.h +++ b/deps/icu-small/source/i18n/unicode/uspoof.h @@ -353,6 +353,8 @@ * @stable ICU 4.6 */ +U_CDECL_BEGIN + struct USpoofChecker; /** * @stable ICU 4.2 @@ -471,7 +473,6 @@ typedef enum USpoofChecks { */ USPOOF_MIXED_NUMBERS = 128, -#ifndef U_HIDE_DRAFT_API /** * Check that an identifier does not have a combining character following a character in which that * combining character would be hidden; for example 'i' followed by a U+0307 combining dot. @@ -489,10 +490,9 @@ typedef enum USpoofChecks { * * This list and the number of combing characters considered by this check may grow over time. * - * @draft ICU 62 + * @stable ICU 62 */ USPOOF_HIDDEN_OVERLAY = 256, -#endif /* U_HIDE_DRAFT_API */ /** * Enable all spoof checks. @@ -674,25 +674,6 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen, U_STABLE void U_EXPORT2 uspoof_close(USpoofChecker *sc); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUSpoofCheckerPointer - * "Smart pointer" class, closes a USpoofChecker via uspoof_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 4.4 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); - -U_NAMESPACE_END - -#endif - /** * Clone a Spoof Checker. The clone will be set to perform the same checks * as the original source. @@ -901,54 +882,6 @@ U_STABLE const USet * U_EXPORT2 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Limit the acceptable characters to those specified by a Unicode Set. - * Any previously specified character limit is - * is replaced by the new settings. This includes limits on - * characters that were set with the uspoof_setAllowedLocales() function. - * - * The USPOOF_CHAR_LIMIT test is automatically enabled for this - * USoofChecker by this function. - * - * @param sc The USpoofChecker - * @param chars A Unicode Set containing the list of - * characters that are permitted. Ownership of the set - * remains with the caller. The incoming set is cloned by - * this function, so there are no restrictions on modifying - * or deleting the UnicodeSet after calling this function. - * @param status The error code, set if this function encounters a problem. - * @stable ICU 4.2 - */ -U_STABLE void U_EXPORT2 -uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status); - - -/** - * Get a UnicodeSet for the characters permitted in an identifier. - * This corresponds to the limits imposed by the Set Allowed Characters / - * UnicodeSet functions. Limitations imposed by other checks will not be - * reflected in the set returned by this function. - * - * The returned set will be frozen, meaning that it cannot be modified - * by the caller. - * - * Ownership of the returned set remains with the Spoof Detector. The - * returned set will become invalid if the spoof detector is closed, - * or if a new set of allowed characters is specified. - * - * - * @param sc The USpoofChecker - * @param status The error code, set if this function encounters a problem. - * @return A UnicodeSet containing the characters that are permitted by - * the USPOOF_CHAR_LIMIT test. - * @stable ICU 4.2 - */ -U_STABLE const icu::UnicodeSet * U_EXPORT2 -uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); -#endif - - /** * Check the specified string for possible security issues. * The text to be checked will typically be an identifier of some sort. @@ -1027,43 +960,6 @@ uspoof_checkUTF8(const USpoofChecker *sc, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Check the specified string for possible security issues. - * The text to be checked will typically be an identifier of some sort. - * The set of checks to be performed is specified with uspoof_setChecks(). - * - * \note - * Consider using the newer API, {@link uspoof_check2UnicodeString}, instead. - * The newer API exposes additional information from the check procedure - * and is otherwise identical to this method. - * - * @param sc The USpoofChecker - * @param id A identifier to be checked for possible security issues. - * @param position Deprecated in ICU 51. Always returns zero. - * Originally, an out parameter for the index of the first - * string position that failed a check. - * This parameter may be NULL. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Spoofing or security issues detected with the input string are - * not reported here, but through the function's return value. - * @return An integer value with bits set for any potential security - * or spoofing issues detected. The bits are defined by - * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) - * will be zero if the input string passes all of the - * enabled checks. - * @see uspoof_check2UnicodeString - * @stable ICU 4.2 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_checkUnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &id, - int32_t *position, - UErrorCode *status); -#endif - - /** * Check the specified string for possible security issues. * The text to be checked will typically be an identifier of some sort. @@ -1135,39 +1031,6 @@ uspoof_check2UTF8(const USpoofChecker *sc, USpoofCheckResult* checkResult, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Check the specified string for possible security issues. - * The text to be checked will typically be an identifier of some sort. - * The set of checks to be performed is specified with uspoof_setChecks(). - * - * @param sc The USpoofChecker - * @param id A identifier to be checked for possible security issues. - * @param checkResult An instance of USpoofCheckResult to be filled with - * details about the identifier. Can be NULL. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Spoofing or security issues detected with the input string are - * not reported here, but through the function's return value. - * @return An integer value with bits set for any potential security - * or spoofing issues detected. The bits are defined by - * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) - * will be zero if the input string passes all of the - * enabled checks. Any information in this bitmask will be - * consistent with the information saved in the optional - * checkResult parameter. - * @see uspoof_openCheckResult - * @see uspoof_check2 - * @see uspoof_check2UTF8 - * @stable ICU 58 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_check2UnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &id, - USpoofCheckResult* checkResult, - UErrorCode *status); -#endif - /** * Create a USpoofCheckResult, used by the {@link uspoof_check2} class of functions to return * information about the identifier. Information includes: @@ -1199,32 +1062,6 @@ uspoof_openCheckResult(UErrorCode *status); U_STABLE void U_EXPORT2 uspoof_closeCheckResult(USpoofCheckResult *checkResult); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUSpoofCheckResultPointer - * "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`. - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 58 - */ - -/** - * \cond - * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. - * For now, suppress with a Doxygen cond - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult); -/** \endcond */ - -U_NAMESPACE_END - -#endif - /** * Indicates which of the spoof check(s) have failed. The value is a bitwise OR of the constants for the tests * in question: USPOOF_RESTRICTION_LEVEL, USPOOF_CHAR_LIMIT, and so on. @@ -1355,36 +1192,6 @@ uspoof_areConfusableUTF8(const USpoofChecker *sc, -#if U_SHOW_CPLUSPLUS_API -/** - * A version of {@link uspoof_areConfusable} accepting UnicodeStrings. - * - * @param sc The USpoofChecker - * @param s1 The first of the two identifiers to be compared for - * confusability. The strings are in UTF-8 format. - * @param s2 The second of the two identifiers to be compared for - * confusability. The strings are in UTF-8 format. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Confusability of the identifiers is not reported here, - * but through this function's return value. - * @return An integer value with bit(s) set corresponding to - * the type of confusability found, as defined by - * enum USpoofChecks. Zero is returned if the identifiers - * are not confusable. - * - * @stable ICU 4.2 - * - * @see uspoof_areConfusable - */ -U_STABLE int32_t U_EXPORT2 -uspoof_areConfusableUnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &s1, - const icu::UnicodeString &s2, - UErrorCode *status); -#endif - - /** * Get the "skeleton" for an identifier. * Skeletons are a transformation of the input identifier; @@ -1463,38 +1270,6 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc, char *dest, int32_t destCapacity, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Get the "skeleton" for an identifier. - * Skeletons are a transformation of the input identifier; - * Two identifiers are confusable if their skeletons are identical. - * See Unicode UAX #39 for additional information. - * - * Using skeletons directly makes it possible to quickly check - * whether an identifier is confusable with any of some large - * set of existing identifiers, by creating an efficiently - * searchable collection of the skeletons. - * - * @param sc The USpoofChecker. - * @param type Deprecated in ICU 58. You may pass any number. - * Originally, controlled which of the Unicode confusable data - * tables to use. - * @param id The input identifier whose skeleton will be computed. - * @param dest The output identifier, to receive the skeleton string. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * @return A reference to the destination (skeleton) string. - * - * @stable ICU 4.2 - */ -U_I18N_API icu::UnicodeString & U_EXPORT2 -uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, - uint32_t type, - const icu::UnicodeString &id, - icu::UnicodeString &dest, - UErrorCode *status); -#endif /* U_SHOW_CPLUSPLUS_API */ - /** * Get the set of Candidate Characters for Inclusion in Identifiers, as defined * in http://unicode.org/Public/security/latest/xidmodifications.txt @@ -1525,8 +1300,243 @@ uspoof_getInclusionSet(UErrorCode *status); U_STABLE const USet * U_EXPORT2 uspoof_getRecommendedSet(UErrorCode *status); +/** + * Serialize the data for a spoof detector into a chunk of memory. + * The flattened spoof detection tables can later be used to efficiently + * instantiate a new Spoof Detector. + * + * The serialized spoof checker includes only the data compiled from the + * Unicode data tables by uspoof_openFromSource(); it does not include + * include any other state or configuration that may have been set. + * + * @param sc the Spoof Detector whose data is to be serialized. + * @param data a pointer to 32-bit-aligned memory to be filled with the data, + * can be NULL if capacity==0 + * @param capacity the number of bytes available at data, + * or 0 for preflighting + * @param status an in/out ICU UErrorCode; possible errors include: + * - U_BUFFER_OVERFLOW_ERROR if the data storage block is too small for serialization + * - U_ILLEGAL_ARGUMENT_ERROR the data or capacity parameters are bad + * @return the number of bytes written or needed for the spoof data + * + * @see utrie2_openFromSerialized() + * @stable ICU 4.2 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_serialize(USpoofChecker *sc, + void *data, int32_t capacity, + UErrorCode *status); + +U_CDECL_END + #if U_SHOW_CPLUSPLUS_API +U_NAMESPACE_BEGIN + +/** + * \class LocalUSpoofCheckerPointer + * "Smart pointer" class, closes a USpoofChecker via uspoof_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 4.4 + */ +/** + * \cond + * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. + * For now, suppress with a Doxygen cond + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); +/** \endcond */ + +/** + * \class LocalUSpoofCheckResultPointer + * "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`. + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 58 + */ + +/** + * \cond + * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. + * For now, suppress with a Doxygen cond + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult); +/** \endcond */ + +U_NAMESPACE_END + +/** + * Limit the acceptable characters to those specified by a Unicode Set. + * Any previously specified character limit is + * is replaced by the new settings. This includes limits on + * characters that were set with the uspoof_setAllowedLocales() function. + * + * The USPOOF_CHAR_LIMIT test is automatically enabled for this + * USoofChecker by this function. + * + * @param sc The USpoofChecker + * @param chars A Unicode Set containing the list of + * characters that are permitted. Ownership of the set + * remains with the caller. The incoming set is cloned by + * this function, so there are no restrictions on modifying + * or deleting the UnicodeSet after calling this function. + * @param status The error code, set if this function encounters a problem. + * @stable ICU 4.2 + */ +U_STABLE void U_EXPORT2 +uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status); + + +/** + * Get a UnicodeSet for the characters permitted in an identifier. + * This corresponds to the limits imposed by the Set Allowed Characters / + * UnicodeSet functions. Limitations imposed by other checks will not be + * reflected in the set returned by this function. + * + * The returned set will be frozen, meaning that it cannot be modified + * by the caller. + * + * Ownership of the returned set remains with the Spoof Detector. The + * returned set will become invalid if the spoof detector is closed, + * or if a new set of allowed characters is specified. + * + * + * @param sc The USpoofChecker + * @param status The error code, set if this function encounters a problem. + * @return A UnicodeSet containing the characters that are permitted by + * the USPOOF_CHAR_LIMIT test. + * @stable ICU 4.2 + */ +U_STABLE const icu::UnicodeSet * U_EXPORT2 +uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); + +/** + * Check the specified string for possible security issues. + * The text to be checked will typically be an identifier of some sort. + * The set of checks to be performed is specified with uspoof_setChecks(). + * + * \note + * Consider using the newer API, {@link uspoof_check2UnicodeString}, instead. + * The newer API exposes additional information from the check procedure + * and is otherwise identical to this method. + * + * @param sc The USpoofChecker + * @param id A identifier to be checked for possible security issues. + * @param position Deprecated in ICU 51. Always returns zero. + * Originally, an out parameter for the index of the first + * string position that failed a check. + * This parameter may be NULL. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Spoofing or security issues detected with the input string are + * not reported here, but through the function's return value. + * @return An integer value with bits set for any potential security + * or spoofing issues detected. The bits are defined by + * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) + * will be zero if the input string passes all of the + * enabled checks. + * @see uspoof_check2UnicodeString + * @stable ICU 4.2 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_checkUnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &id, + int32_t *position, + UErrorCode *status); + +/** + * Check the specified string for possible security issues. + * The text to be checked will typically be an identifier of some sort. + * The set of checks to be performed is specified with uspoof_setChecks(). + * + * @param sc The USpoofChecker + * @param id A identifier to be checked for possible security issues. + * @param checkResult An instance of USpoofCheckResult to be filled with + * details about the identifier. Can be NULL. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Spoofing or security issues detected with the input string are + * not reported here, but through the function's return value. + * @return An integer value with bits set for any potential security + * or spoofing issues detected. The bits are defined by + * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) + * will be zero if the input string passes all of the + * enabled checks. Any information in this bitmask will be + * consistent with the information saved in the optional + * checkResult parameter. + * @see uspoof_openCheckResult + * @see uspoof_check2 + * @see uspoof_check2UTF8 + * @stable ICU 58 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_check2UnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &id, + USpoofCheckResult* checkResult, + UErrorCode *status); + +/** + * A version of {@link uspoof_areConfusable} accepting UnicodeStrings. + * + * @param sc The USpoofChecker + * @param s1 The first of the two identifiers to be compared for + * confusability. The strings are in UTF-8 format. + * @param s2 The second of the two identifiers to be compared for + * confusability. The strings are in UTF-8 format. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Confusability of the identifiers is not reported here, + * but through this function's return value. + * @return An integer value with bit(s) set corresponding to + * the type of confusability found, as defined by + * enum USpoofChecks. Zero is returned if the identifiers + * are not confusable. + * + * @stable ICU 4.2 + * + * @see uspoof_areConfusable + */ +U_STABLE int32_t U_EXPORT2 +uspoof_areConfusableUnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &s1, + const icu::UnicodeString &s2, + UErrorCode *status); + +/** + * Get the "skeleton" for an identifier. + * Skeletons are a transformation of the input identifier; + * Two identifiers are confusable if their skeletons are identical. + * See Unicode UAX #39 for additional information. + * + * Using skeletons directly makes it possible to quickly check + * whether an identifier is confusable with any of some large + * set of existing identifiers, by creating an efficiently + * searchable collection of the skeletons. + * + * @param sc The USpoofChecker. + * @param type Deprecated in ICU 58. You may pass any number. + * Originally, controlled which of the Unicode confusable data + * tables to use. + * @param id The input identifier whose skeleton will be computed. + * @param dest The output identifier, to receive the skeleton string. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * @return A reference to the destination (skeleton) string. + * + * @stable ICU 4.2 + */ +U_I18N_API icu::UnicodeString & U_EXPORT2 +uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, + uint32_t type, + const icu::UnicodeString &id, + icu::UnicodeString &dest, + UErrorCode *status); + /** * Get the set of Candidate Characters for Inclusion in Identifiers, as defined * in http://unicode.org/Public/security/latest/xidmodifications.txt @@ -1559,34 +1569,6 @@ uspoof_getRecommendedUnicodeSet(UErrorCode *status); #endif /* U_SHOW_CPLUSPLUS_API */ -/** - * Serialize the data for a spoof detector into a chunk of memory. - * The flattened spoof detection tables can later be used to efficiently - * instantiate a new Spoof Detector. - * - * The serialized spoof checker includes only the data compiled from the - * Unicode data tables by uspoof_openFromSource(); it does not include - * include any other state or configuration that may have been set. - * - * @param sc the Spoof Detector whose data is to be serialized. - * @param data a pointer to 32-bit-aligned memory to be filled with the data, - * can be NULL if capacity==0 - * @param capacity the number of bytes available at data, - * or 0 for preflighting - * @param status an in/out ICU UErrorCode; possible errors include: - * - U_BUFFER_OVERFLOW_ERROR if the data storage block is too small for serialization - * - U_ILLEGAL_ARGUMENT_ERROR the data or capacity parameters are bad - * @return the number of bytes written or needed for the spoof data - * - * @see utrie2_openFromSerialized() - * @stable ICU 4.2 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_serialize(USpoofChecker *sc, - void *data, int32_t capacity, - UErrorCode *status); - - -#endif +#endif /* UCONFIG_NO_NORMALIZATION */ #endif /* USPOOF_H */ diff --git a/deps/icu-small/source/i18n/unicode/utmscale.h b/deps/icu-small/source/i18n/unicode/utmscale.h index 2392c6414e4f8b..d8b8a2e668af1d 100644 --- a/deps/icu-small/source/i18n/unicode/utmscale.h +++ b/deps/icu-small/source/i18n/unicode/utmscale.h @@ -14,7 +14,7 @@ #if !UCONFIG_NO_FORMATTING -/** +/** * \file * \brief C API: Universal Time Scale * @@ -217,7 +217,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_UNIX_TIME, - + /** * Used in IUC4C. Data is a double. Value * is milliseconds since January 1, 1970. @@ -225,7 +225,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_ICU4C_TIME, - + /** * Used in Windows for file times. Data is an int64_t. Value * is ticks (1 tick == 100 nanoseconds) since January 1, 1601. @@ -233,7 +233,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_WINDOWS_FILE_TIME, - + /** * Used in the .NET framework's System.DateTime structure. Data is an int64_t. Value * is ticks (1 tick == 100 nanoseconds) since January 1, 0001. @@ -241,7 +241,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_DOTNET_DATE_TIME, - + /** * Used in older Macintosh systems. Data is int32_t or int64_t. Value * is seconds since January 1, 1904. @@ -249,7 +249,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_MAC_OLD_TIME, - + /** * Used in newer Macintosh systems. Data is a double. Value * is seconds since January 1, 2001. @@ -257,7 +257,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_MAC_TIME, - + /** * Used in Excel. Data is an ?unknown?. Value * is days since December 31, 1899. @@ -265,7 +265,7 @@ typedef enum UDateTimeScale { * @stable ICU 3.2 */ UDTS_EXCEL_TIME, - + /** * Used in DB2. Data is an ?unknown?. Value * is days since December 31, 1899. @@ -305,7 +305,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the units vale * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -315,7 +315,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the epoch offset value * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -325,7 +325,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the minimum from value * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -335,7 +335,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the maximum from value * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -345,7 +345,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the minimum to value * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -355,7 +355,7 @@ typedef enum UTimeScaleValue { /** * The constant used to select the maximum to value * for a time scale. - * + * * @see utmscale_getTimeScaleValue * * @stable ICU 3.2 @@ -366,10 +366,10 @@ typedef enum UTimeScaleValue { /** * The constant used to select the epoch plus one value * for a time scale. - * + * * NOTE: This is an internal value. DO NOT USE IT. May not * actually be equal to the epoch offset value plus one. - * + * * @see utmscale_getTimeScaleValue * * @internal ICU 3.2 @@ -379,10 +379,10 @@ typedef enum UTimeScaleValue { /** * The constant used to select the epoch plus one value * for a time scale. - * + * * NOTE: This is an internal value. DO NOT USE IT. May not * actually be equal to the epoch offset value plus one. - * + * * @see utmscale_getTimeScaleValue * * @internal ICU 3.2 @@ -392,9 +392,9 @@ typedef enum UTimeScaleValue { /** * The constant used to select the units round value * for a time scale. - * + * * NOTE: This is an internal value. DO NOT USE IT. - * + * * @see utmscale_getTimeScaleValue * * @internal ICU 3.2 @@ -404,9 +404,9 @@ typedef enum UTimeScaleValue { /** * The constant used to select the minimum safe rounding value * for a time scale. - * + * * NOTE: This is an internal value. DO NOT USE IT. - * + * * @see utmscale_getTimeScaleValue * * @internal ICU 3.2 @@ -416,9 +416,9 @@ typedef enum UTimeScaleValue { /** * The constant used to select the maximum safe rounding value * for a time scale. - * + * * NOTE: This is an internal value. DO NOT USE IT. - * + * * @see utmscale_getTimeScaleValue * * @internal ICU 3.2 @@ -430,7 +430,7 @@ typedef enum UTimeScaleValue { #ifndef U_HIDE_DEPRECATED_API /** * The number of time scale values, in other words limit of this enum. - * + * * @see utmscale_getTimeScaleValue * @deprecated ICU 59 The numeric value may change over time, see ICU ticket #12420. */ @@ -441,12 +441,12 @@ typedef enum UTimeScaleValue { /** * Get a value associated with a particular time scale. - * + * * @param timeScale The time scale * @param value A constant representing the value to get * @param status The status code. Set to U_ILLEGAL_ARGUMENT_ERROR if arguments are invalid. * @return - the value. - * + * * @stable ICU 3.2 */ U_STABLE int64_t U_EXPORT2 @@ -460,7 +460,7 @@ U_STABLE int64_t U_EXPORT2 * @param otherTime The int64_t datetime * @param timeScale The time scale to convert from * @param status The status code. Set to U_ILLEGAL_ARGUMENT_ERROR if the conversion is out of range. - * + * * @return The datetime converted to the universal time scale * * @stable ICU 3.2 @@ -476,7 +476,7 @@ U_STABLE int64_t U_EXPORT2 * @param universalTime The datetime in the universal time scale * @param timeScale The time scale to convert to * @param status The status code. Set to U_ILLEGAL_ARGUMENT_ERROR if the conversion is out of range. - * + * * @return The datetime converted to the given time scale * * @stable ICU 3.2 @@ -487,3 +487,4 @@ U_STABLE int64_t U_EXPORT2 #endif /* #if !UCONFIG_NO_FORMATTING */ #endif + diff --git a/deps/icu-small/source/i18n/unicode/utrans.h b/deps/icu-small/source/i18n/unicode/utrans.h index 7672b4428fba3c..021af498a83d82 100644 --- a/deps/icu-small/source/i18n/unicode/utrans.h +++ b/deps/icu-small/source/i18n/unicode/utrans.h @@ -78,7 +78,7 @@ typedef void* UTransliterator; * @stable ICU 2.0 */ typedef enum UTransDirection { - + /** * UTRANS_FORWARD means from <source> to <target> for a * transliterator with ID <source>-<target>. For a transliterator @@ -130,7 +130,7 @@ typedef struct UTransPosition { * @stable ICU 2.4 */ int32_t contextStart; - + /** * Ending index, exclusive, of the context to be considered for a * transliteration operation. The transliterator will ignore @@ -140,18 +140,18 @@ typedef struct UTransPosition { * @stable ICU 2.4 */ int32_t contextLimit; - + /** - * Beginning index, inclusive, of the text to be transliteratd. + * Beginning index, inclusive, of the text to be transliterated. * INPUT/OUTPUT parameter: This parameter is advanced past * characters that have already been transliterated by a * transliteration operation. * @stable ICU 2.4 */ int32_t start; - + /** - * Ending index, exclusive, of the text to be transliteratd. + * Ending index, exclusive, of the text to be transliterated. * INPUT/OUTPUT parameter: This parameter is updated to reflect * changes in the length of the text, but points to the same * logical position in the text. @@ -166,9 +166,9 @@ typedef struct UTransPosition { ********************************************************************/ /** - * Open a custom transliterator, given a custom rules string - * OR - * a system transliterator, given its ID. + * Open a custom transliterator, given a custom rules string + * OR + * a system transliterator, given its ID. * Any non-NULL result from this function should later be closed with * utrans_close(). * @@ -212,7 +212,7 @@ utrans_openU(const UChar *id, * inverse of trans, or NULL if the open call fails. * @stable ICU 2.0 */ -U_STABLE UTransliterator* U_EXPORT2 +U_STABLE UTransliterator* U_EXPORT2 utrans_openInverse(const UTransliterator* trans, UErrorCode* status); @@ -226,7 +226,7 @@ utrans_openInverse(const UTransliterator* trans, * utrans_xxx() functions, or NULL if the clone call fails. * @stable ICU 2.0 */ -U_STABLE UTransliterator* U_EXPORT2 +U_STABLE UTransliterator* U_EXPORT2 utrans_clone(const UTransliterator* trans, UErrorCode* status); @@ -236,7 +236,7 @@ utrans_clone(const UTransliterator* trans, * @param trans the transliterator to be closed. * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_close(UTransliterator* trans); #if U_SHOW_CPLUSPLUS_API @@ -290,7 +290,7 @@ utrans_getUnicodeID(const UTransliterator *trans, * @param status a pointer to the UErrorCode * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_register(UTransliterator* adoptedTrans, UErrorCode* status); @@ -324,7 +324,7 @@ utrans_unregisterID(const UChar* id, int32_t idLength); * @see UnicodeSet * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_setFilter(UTransliterator* trans, const UChar* filterPattern, int32_t filterPatternLen, @@ -337,7 +337,7 @@ utrans_setFilter(UTransliterator* trans, * @return the number of system transliterators. * @stable ICU 2.0 */ -U_STABLE int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 utrans_countAvailableIDs(void); /** @@ -379,7 +379,7 @@ utrans_openIDs(UErrorCode *pErrorCode); * @param status a pointer to the UErrorCode * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_trans(const UTransliterator* trans, UReplaceable* rep, const UReplaceableCallbacks* repFunc, @@ -389,7 +389,7 @@ utrans_trans(const UTransliterator* trans, /** * Transliterate the portion of the UReplaceable text buffer that can - * be transliterated unambiguosly. This method is typically called + * be transliterated unambiguously. This method is typically called * after new text has been inserted, e.g. as a result of a keyboard * event. The transliterator will try to transliterate characters of * rep between index.cursor and @@ -430,7 +430,7 @@ utrans_trans(const UTransliterator* trans, * @param status a pointer to the UErrorCode * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_transIncremental(const UTransliterator* trans, UReplaceable* rep, const UReplaceableCallbacks* repFunc, @@ -454,8 +454,7 @@ utrans_transIncremental(const UTransliterator* trans, * zero-terminated. Upon return, the new length is stored in * *textLength. If textLength is NULL then the string is assumed to * be zero-terminated. - * @param textCapacity a pointer to the length of the text buffer. - * Upon return, + * @param textCapacity the length of the text buffer * @param start the beginning index, inclusive; 0 <= start <= * limit. * @param limit pointer to the ending index, exclusive; start <= @@ -468,7 +467,7 @@ utrans_transIncremental(const UTransliterator* trans, * @param status a pointer to the UErrorCode * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_transUChars(const UTransliterator* trans, UChar* text, int32_t* textLength, @@ -479,7 +478,7 @@ utrans_transUChars(const UTransliterator* trans, /** * Transliterate the portion of the UChar* text buffer that can be - * transliterated unambiguosly. See utrans_transIncremental(). The + * transliterated unambiguously. See utrans_transIncremental(). The * string is passed in in a UChar* buffer. The string is modified in * place. If the result is longer than textCapacity, it is truncated. * The actual length of the result is returned in *textLength, if @@ -503,7 +502,7 @@ utrans_transUChars(const UTransliterator* trans, * @see utrans_transIncremental * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 utrans_transIncrementalUChars(const UTransliterator* trans, UChar* text, int32_t* textLength, @@ -567,16 +566,16 @@ utrans_getSourceSet(const UTransliterator* trans, /** * Deprecated, use utrans_openU() instead. - * Open a custom transliterator, given a custom rules string - * OR - * a system transliterator, given its ID. + * Open a custom transliterator, given a custom rules string + * OR + * a system transliterator, given its ID. * Any non-NULL result from this function should later be closed with * utrans_close(). * * @param id a valid ID, as returned by utrans_getAvailableID() * @param dir the desired direction * @param rules the transliterator rules. See the C++ header rbt.h - * for rules syntax. If NULL then a system transliterator matching + * for rules syntax. If NULL then a system transliterator matching * the ID is returned. * @param rulesLength the length of the rules, or -1 if the rules * are zero-terminated. @@ -588,11 +587,11 @@ utrans_getSourceSet(const UTransliterator* trans, * utrans_xxx() functions, or NULL if the open call fails. * @deprecated ICU 2.8 Use utrans_openU() instead, see utrans.h */ -U_DEPRECATED UTransliterator* U_EXPORT2 +U_DEPRECATED UTransliterator* U_EXPORT2 utrans_open(const char* id, UTransDirection dir, const UChar* rules, /* may be Null */ - int32_t rulesLength, /* -1 if null-terminated */ + int32_t rulesLength, /* -1 if null-terminated */ UParseError* parseError, /* may be Null */ UErrorCode* status); @@ -611,7 +610,7 @@ utrans_open(const char* id, * zero-termination. This may be greater than bufCapacity. * @deprecated ICU 2.8 Use utrans_getUnicodeID() instead, see utrans.h */ -U_DEPRECATED int32_t U_EXPORT2 +U_DEPRECATED int32_t U_EXPORT2 utrans_getID(const UTransliterator* trans, char* buf, int32_t bufCapacity); @@ -625,7 +624,7 @@ utrans_getID(const UTransliterator* trans, * @param id a zero-terminated ID * @deprecated ICU 2.8 Use utrans_unregisterID() instead, see utrans.h */ -U_DEPRECATED void U_EXPORT2 +U_DEPRECATED void U_EXPORT2 utrans_unregister(const char* id); /** @@ -646,7 +645,7 @@ utrans_unregister(const char* id); * zero-termination. This may be greater than bufCapacity. * @deprecated ICU 2.8 Use utrans_openIDs() instead, see utrans.h */ -U_DEPRECATED int32_t U_EXPORT2 +U_DEPRECATED int32_t U_EXPORT2 utrans_getAvailableID(int32_t index, char* buf, int32_t bufCapacity); diff --git a/deps/icu-small/source/i18n/unicode/vtzone.h b/deps/icu-small/source/i18n/unicode/vtzone.h index 5d161778682313..2743b6c474f785 100644 --- a/deps/icu-small/source/i18n/unicode/vtzone.h +++ b/deps/icu-small/source/i18n/unicode/vtzone.h @@ -11,8 +11,10 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** - * \file + * \file * \brief C++ API: RFC2445 VTIMEZONE support */ @@ -103,7 +105,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { /** * Create a VTimeZone instance by RFC2445 VTIMEZONE data - * + * * @param vtzdata The string including VTIMEZONE data block * @param status Output param to filled in with a success or an error. * @return A VTimeZone initialized by the VTIMEZONE data or @@ -185,7 +187,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 3.8 */ - virtual TimeZone* clone(void) const; + virtual VTimeZone* clone() const; /** * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add @@ -288,6 +290,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -302,6 +305,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -453,5 +457,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // VTZONE_H //eof diff --git a/deps/icu-small/source/i18n/unum.cpp b/deps/icu-small/source/i18n/unum.cpp index 907a1cd95e138f..cce3db7d0bc4c2 100644 --- a/deps/icu-small/source/i18n/unum.cpp +++ b/deps/icu-small/source/i18n/unum.cpp @@ -38,7 +38,7 @@ U_NAMESPACE_USE U_CAPI UNumberFormat* U_EXPORT2 -unum_open( UNumberFormatStyle style, +unum_open( UNumberFormatStyle style, const UChar* pattern, int32_t patternLength, const char* locale, @@ -93,11 +93,11 @@ unum_open( UNumberFormatStyle style, UParseError tErr; /* UnicodeString can handle the case when patternLength = -1. */ const UnicodeString pat(pattern, patternLength); - + if(parseErr==NULL){ parseErr = &tErr; } - + retVal = new RuleBasedNumberFormat(pat, Locale(locale), *parseErr, *status); } break; @@ -135,6 +135,11 @@ unum_open( UNumberFormatStyle style, *status = U_MEMORY_ALLOCATION_ERROR; } + if (U_FAILURE(*status) && retVal != NULL) { + delete retVal; + retVal = NULL; + } + return reinterpret_cast(retVal); } @@ -150,7 +155,7 @@ unum_clone(const UNumberFormat *fmt, { if(U_FAILURE(*status)) return 0; - + Format *res = 0; const NumberFormat* nf = reinterpret_cast(fmt); const DecimalFormat* df = dynamic_cast(nf); @@ -166,7 +171,7 @@ unum_clone(const UNumberFormat *fmt, *status = U_MEMORY_ALLOCATION_ERROR; return 0; } - + return (UNumberFormat*) res; } @@ -191,26 +196,26 @@ unum_formatInt64(const UNumberFormat* fmt, { if(U_FAILURE(*status)) return -1; - + UnicodeString res; if(!(result==NULL && resultLength==0)) { // NULL destination for pure preflighting: empty dummy string // otherwise, alias the destination buffer res.setTo(result, 0, resultLength); } - + FieldPosition fp; - + if(pos != 0) fp.setField(pos->field); - + ((const NumberFormat*)fmt)->format(number, res, fp, *status); if(pos != 0) { pos->beginIndex = fp.getBeginIndex(); pos->endIndex = fp.getEndIndex(); } - + return res.extract(result, resultLength, *status); } @@ -222,7 +227,7 @@ unum_formatDouble( const UNumberFormat* fmt, UFieldPosition *pos, /* 0 if ignore */ UErrorCode* status) { - + if(U_FAILURE(*status)) return -1; UnicodeString res; @@ -233,17 +238,17 @@ unum_formatDouble( const UNumberFormat* fmt, } FieldPosition fp; - + if(pos != 0) fp.setField(pos->field); - + ((const NumberFormat*)fmt)->format(number, res, fp, *status); - + if(pos != 0) { pos->beginIndex = fp.getBeginIndex(); pos->endIndex = fp.getEndIndex(); } - + return res.extract(result, resultLength, *status); } @@ -275,7 +280,7 @@ unum_formatDoubleForFields(const UNumberFormat* format, return res.extract(result, resultLength, *status); } -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 unum_formatDecimal(const UNumberFormat* fmt, const char * number, int32_t length, @@ -319,7 +324,7 @@ unum_formatDecimal(const UNumberFormat* fmt, -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 unum_formatDoubleCurrency(const UNumberFormat* fmt, double number, UChar* currency, @@ -335,7 +340,7 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt, // otherwise, alias the destination buffer res.setTo(result, 0, resultLength); } - + FieldPosition fp; if (pos != 0) { fp.setField(pos->field); @@ -348,12 +353,12 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt, } Formattable n(tempCurrAmnt); ((const NumberFormat*)fmt)->format(n, res, fp, *status); - + if (pos != 0) { pos->beginIndex = fp.getBeginIndex(); pos->endIndex = fp.getEndIndex(); } - + return res.extract(result, resultLength, *status); } @@ -367,15 +372,15 @@ parseRes(Formattable& res, { if(U_FAILURE(*status)) return; - + const UnicodeString src((UBool)(textLength == -1), text, textLength); ParsePosition pp; - + if(parsePos != 0) pp.setIndex(*parsePos); - + ((const NumberFormat*)fmt)->parse(src, res, pp); - + if(pp.getErrorIndex() != -1) { *status = U_PARSE_ERROR; if(parsePos != 0) { @@ -609,7 +614,7 @@ unum_setDoubleAttribute( UNumberFormat* fmt, { NumberFormat* nf = reinterpret_cast(fmt); DecimalFormat* df = dynamic_cast(nf); - if (df != NULL && attr == UNUM_ROUNDING_INCREMENT) { + if (df != NULL && attr == UNUM_ROUNDING_INCREMENT) { df->setRoundingIncrement(newValue); } } @@ -701,27 +706,27 @@ unum_setTextAttribute( UNumberFormat* fmt, case UNUM_POSITIVE_PREFIX: df->setPositivePrefix(val); break; - + case UNUM_POSITIVE_SUFFIX: df->setPositiveSuffix(val); break; - + case UNUM_NEGATIVE_PREFIX: df->setNegativePrefix(val); break; - + case UNUM_NEGATIVE_SUFFIX: df->setNegativeSuffix(val); break; - + case UNUM_PADDING_CHARACTER: df->setPadCharacter(val); break; - + case UNUM_CURRENCY_CODE: df->setCurrency(val.getTerminatedBuffer(), *status); break; - + default: *status = U_UNSUPPORTED_ERROR; break; @@ -746,7 +751,7 @@ unum_toPattern( const UNumberFormat* fmt, { if(U_FAILURE(*status)) return -1; - + UnicodeString pat; if(!(result==NULL && resultLength==0)) { // NULL destination for pure preflighting: empty dummy string @@ -833,15 +838,15 @@ unum_applyPattern( UNumberFormat *fmt, { UErrorCode tStatus = U_ZERO_ERROR; UParseError tParseError; - + if(parseError == NULL){ parseError = &tParseError; } - + if(status==NULL){ status = &tStatus; } - + int32_t len = (patternLength == -1 ? u_strlen(pattern) : patternLength); const UnicodeString pat((UChar*)pattern, len, len); diff --git a/deps/icu-small/source/i18n/uregex.cpp b/deps/icu-small/source/i18n/uregex.cpp index ff6e65b38e2d60..57c2febe9d02bc 100644 --- a/deps/icu-small/source/i18n/uregex.cpp +++ b/deps/icu-small/source/i18n/uregex.cpp @@ -1497,7 +1497,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp, // Scan for Named Capture Group, ${name}. UnicodeString groupName; U16_FWD_1(replacementText, replIdx, replacementLength); - while (U_SUCCESS(*status) && c32 != RIGHTBRACKET) { + while (U_SUCCESS(*status) && c32 != RIGHTBRACKET) { if (replIdx >= replacementLength) { *status = U_REGEX_INVALID_CAPTURE_GROUP_NAME; break; @@ -1976,3 +1976,4 @@ uregex_splitUText(URegularExpression *regexp2, #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS + diff --git a/deps/icu-small/source/i18n/uregexc.cpp b/deps/icu-small/source/i18n/uregexc.cpp index 8674b4f17f5876..c7d3bcd2c743fb 100644 --- a/deps/icu-small/source/i18n/uregexc.cpp +++ b/deps/icu-small/source/i18n/uregexc.cpp @@ -8,7 +8,7 @@ * file name: regexc.cpp * description: The purpose of this function is to separate the codepage * conversion from the rest of the uregex_ API. This can removes any -* dependency on codepage conversion, which reduces the overhead of +* dependency on codepage conversion, which reduces the overhead of */ #include "unicode/uregex.h" diff --git a/deps/icu-small/source/i18n/usearch.cpp b/deps/icu-small/source/i18n/usearch.cpp index 0e9b876d2babb7..8866de70337523 100644 --- a/deps/icu-small/source/i18n/usearch.cpp +++ b/deps/icu-small/source/i18n/usearch.cpp @@ -317,7 +317,7 @@ inline uint16_t initializePatternCETable(UStringSearch *strsrch, uprv_free(pattern->ces); } - uint16_t offset = 0; + uint32_t offset = 0; uint16_t result = 0; int32_t ce; @@ -388,7 +388,7 @@ inline uint16_t initializePatternPCETable(UStringSearch *strsrch, uprv_free(pattern->pces); } - uint16_t offset = 0; + uint32_t offset = 0; uint16_t result = 0; int64_t pce; @@ -1351,7 +1351,7 @@ inline int getUnblockedAccentIndex(UChar *accents, int32_t *accentsindex) * @param destinationlength target array size, returning the appended length * @param source1 null-terminated first array * @param source2 second array -* @param source2length length of seond array +* @param source2length length of second array * @param source3 null-terminated third array * @param status error status if any * @return new destination array, destination if there was no new allocation @@ -1560,7 +1560,7 @@ inline void cleanUpSafeText(const UStringSearch *strsrch, UChar *safetext, /** * Take the rearranged end accents and tries matching. If match failed at -* a seperate preceding set of accents (seperated from the rearranged on by +* a separate preceding set of accents (separated from the rearranged on by * at least a base character) then we rearrange the preceding accents and * tries matching again. * We allow skipping of the ends of the accent set if the ces do not match. @@ -2220,7 +2220,7 @@ int32_t doPreviousCanonicalSuffixMatch(UStringSearch *strsrch, /** * Take the rearranged start accents and tries matching. If match failed at -* a seperate following set of accents (seperated from the rearranged on by +* a separate following set of accents (separated from the rearranged on by * at least a base character) then we rearrange the preceding accents and * tries matching again. * We allow skipping of the ends of the accent set if the ces do not match. @@ -3544,7 +3544,12 @@ const CEI *CEIBuffer::get(int32_t index) { // Verify that it is the next one in sequence, which is all // that is allowed. if (index != limitIx) { - UPRV_UNREACHABLE; + U_ASSERT(FALSE); + // TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead + // which unconditionally calls abort(). However, there were cases where this was + // being hit. This change is reverted for now, restoring the existing behavior. + // ICU-20792 tracks the follow-up work/further investigation on this. + return NULL; } // Manage the circular CE buffer indexing @@ -3581,7 +3586,12 @@ const CEI *CEIBuffer::getPrevious(int32_t index) { // Verify that it is the next one in sequence, which is all // that is allowed. if (index != limitIx) { - UPRV_UNREACHABLE; + U_ASSERT(FALSE); + // TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead + // which unconditionally calls abort(). However, there were cases where this was + // being hit. This change is reverted for now, restoring the existing behavior. + // ICU-20792 tracks the follow-up work/further investigation on this. + return NULL; } // Manage the circular CE buffer indexing @@ -3760,7 +3770,7 @@ static UCompareCEsResult compareCE64s(int64_t targCE, int64_t patCE, int16_t com if (compareType == 0) { return U_CE_NO_MATCH; } - + int64_t targCEshifted = targCE >> 32; int64_t patCEshifted = patCE >> 32; int64_t mask; @@ -3791,7 +3801,7 @@ static UCompareCEsResult compareCE64s(int64_t targCE, int64_t patCE, int16_t com return (patLev2 == U_CE_LEVEL2_BASE || (compareType == USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD && targLev2 == U_CE_LEVEL2_BASE) )? U_CE_MATCH: U_CE_NO_MATCH; } - + mask = 0xFFFF0000; int32_t targLev3 = (int32_t)(targCE & mask); int32_t patLev3 = (int32_t)(patCE & mask); @@ -3852,7 +3862,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, #endif // Input parameter sanity check. - // TODO: should input indicies clip to the text length + // TODO: should input indices clip to the text length // in the same way that UText does. if(strsrch->pattern.cesLength == 0 || startIdx < 0 || @@ -3912,7 +3922,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, found = FALSE; break; } - + for (patIx=0; patIxpattern.pcesLength; patIx++) { patCE = strsrch->pattern.pces[patIx]; targetCEI = ceb.get(targetIx+patIx+targetIxOffset); @@ -4014,7 +4024,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, // Check for the start of the match being within an Collation Element Expansion, // meaning that the first char of the match is only partially matched. - // With exapnsions, the first CE will report the index of the source + // With expansions, the first CE will report the index of the source // character, and all subsequent (expansions) CEs will report the source index of the // _following_ character. int32_t secondIx = firstCEI->highIndex; diff --git a/deps/icu-small/source/i18n/uspoof.cpp b/deps/icu-small/source/i18n/uspoof.cpp index c8fbec27bb9b6f..5b7b326f1fd6cf 100644 --- a/deps/icu-small/source/i18n/uspoof.cpp +++ b/deps/icu-small/source/i18n/uspoof.cpp @@ -257,10 +257,10 @@ uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status) { return; } - // Verify that the requested checks are all ones (bits) that + // Verify that the requested checks are all ones (bits) that // are acceptable, known values. if (checks & ~(USPOOF_ALL_CHECKS | USPOOF_AUX_INFO)) { - *status = U_ILLEGAL_ARGUMENT_ERROR; + *status = U_ILLEGAL_ARGUMENT_ERROR; return; } @@ -349,7 +349,7 @@ uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCo *status = U_ILLEGAL_ARGUMENT_ERROR; return; } - UnicodeSet *clonedSet = static_cast(chars->clone()); + UnicodeSet *clonedSet = chars->clone(); if (clonedSet == NULL || clonedSet->isBogus()) { *status = U_MEMORY_ALLOCATION_ERROR; return; @@ -441,7 +441,7 @@ uspoof_areConfusable(const USpoofChecker *sc, *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; } - + UnicodeString id1Str((length1==-1), id1, length1); // Aliasing constructor UnicodeString id2Str((length2==-1), id2, length2); // Aliasing constructor return uspoof_areConfusableUnicodeString(sc, id1Str, id2Str, status); @@ -466,7 +466,7 @@ uspoof_areConfusableUTF8(const USpoofChecker *sc, int32_t results = uspoof_areConfusableUnicodeString(sc, id1Str, id2Str, status); return results; } - + U_CAPI int32_t U_EXPORT2 uspoof_areConfusableUnicodeString(const USpoofChecker *sc, @@ -480,7 +480,7 @@ uspoof_areConfusableUnicodeString(const USpoofChecker *sc, // // See section 4 of UAX 39 for the algorithm for checking whether two strings are confusable, // and for definitions of the types (single, whole, mixed-script) of confusables. - + // We only care about a few of the check flags. Ignore the others. // If no tests relavant to this function have been specified, return an error. // TODO: is this really the right thing to do? It's probably an error on the caller's part, @@ -607,9 +607,9 @@ int32_t checkImpl(const SpoofImpl* This, const UnicodeString& id, CheckResult* c int32_t i; UChar32 c; UChar32 firstNonspacingMark = 0; - UBool haveMultipleMarks = FALSE; + UBool haveMultipleMarks = FALSE; UnicodeSet marksSeenSoFar; // Set of combining marks in a single combining sequence. - + for (i=0; i( static_cast(left.pointer)); - const SPUString *sR = const_cast( - static_cast(right.pointer)); + const SPUString *sR = const_cast( + static_cast(right.pointer)); int32_t lenL = sL->fStr->length(); int32_t lenR = sR->fStr->length(); if (lenL < lenR) { @@ -475,3 +475,4 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { #endif #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS + diff --git a/deps/icu-small/source/i18n/uspoof_conf.h b/deps/icu-small/source/i18n/uspoof_conf.h index ad040edf105271..cfa80e7ca768f0 100644 --- a/deps/icu-small/source/i18n/uspoof_conf.h +++ b/deps/icu-small/source/i18n/uspoof_conf.h @@ -25,7 +25,7 @@ #if !UCONFIG_NO_NORMALIZATION -#if !UCONFIG_NO_REGULAR_EXPRESSIONS +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "unicode/uregex.h" #include "uhash.h" @@ -60,7 +60,7 @@ class SPUStringPool : public UMemory { public: SPUStringPool(UErrorCode &status); ~SPUStringPool(); - + // Add a string. Return the string from the table. // If the input parameter string is already in the table, delete the // input parameter and return the existing string. @@ -98,7 +98,7 @@ class ConfusabledataBuilder : public UMemory { UVector *fKeyVec; UVector *fValueVec; UnicodeString *fStringTable; - + SPUStringPool *stringPool; URegularExpression *fParseLine; URegularExpression *fParseHexNum; @@ -130,5 +130,5 @@ class ConfusabledataBuilder : public UMemory { U_NAMESPACE_END #endif -#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS #endif // __USPOOF_BUILDCONF_H__ diff --git a/deps/icu-small/source/i18n/uspoof_impl.cpp b/deps/icu-small/source/i18n/uspoof_impl.cpp index 85a028bdfa02f2..88245b7f8f9c22 100644 --- a/deps/icu-small/source/i18n/uspoof_impl.cpp +++ b/deps/icu-small/source/i18n/uspoof_impl.cpp @@ -73,7 +73,7 @@ void SpoofImpl::construct(UErrorCode& status) { // Copy Constructor, used by the user level clone() function. SpoofImpl::SpoofImpl(const SpoofImpl &src, UErrorCode &status) : - fChecks(USPOOF_ALL_CHECKS), fSpoofData(NULL), fAllowedCharsSet(NULL) , + fChecks(USPOOF_ALL_CHECKS), fSpoofData(NULL), fAllowedCharsSet(NULL) , fAllowedLocales(NULL) { if (U_FAILURE(status)) { return; @@ -82,7 +82,7 @@ SpoofImpl::SpoofImpl(const SpoofImpl &src, UErrorCode &status) : if (src.fSpoofData != NULL) { fSpoofData = src.fSpoofData->addReference(); } - fAllowedCharsSet = static_cast(src.fAllowedCharsSet->clone()); + fAllowedCharsSet = src.fAllowedCharsSet->clone(); fAllowedLocales = uprv_strdup(src.fAllowedLocales); if (fAllowedCharsSet == NULL || fAllowedLocales == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -170,7 +170,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) { if (fAllowedLocales == NULL || tmpSet == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return; - } + } tmpSet->freeze(); delete fAllowedCharsSet; fAllowedCharsSet = tmpSet; @@ -178,14 +178,14 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) { return; } - + // Add all common and inherited characters to the set of allowed chars. UnicodeSet tempSet; tempSet.applyIntPropertyValue(UCHAR_SCRIPT, USCRIPT_COMMON, status); allowedChars.addAll(tempSet); tempSet.applyIntPropertyValue(UCHAR_SCRIPT, USCRIPT_INHERITED, status); allowedChars.addAll(tempSet); - + // If anything went wrong, we bail out without changing // the state of the spoof checker. if (U_FAILURE(status)) { @@ -193,7 +193,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) { } // Store the updated spoof checker state. - tmpSet = static_cast(allowedChars.clone()); + tmpSet = allowedChars.clone(); const char *tmpLocalesList = uprv_strdup(localesList); if (tmpSet == NULL || tmpLocalesList == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -554,7 +554,7 @@ uspoof_cleanupDefaultData(void) { static void U_CALLCONV uspoof_loadDefaultData(UErrorCode& status) { UDataMemory *udm = udata_openChoice(nullptr, "cfu", "confusables", - spoofDataIsAcceptable, + spoofDataIsAcceptable, nullptr, // context, would receive dataVersion if supplied. &status); if (U_FAILURE(status)) { return; } @@ -633,7 +633,7 @@ SpoofData::SpoofData(UErrorCode &status) { // Just in case it's not, round it up. uint32_t initialSize = (sizeof(SpoofDataHeader) + 15) & ~15; U_ASSERT(initialSize == sizeof(SpoofDataHeader)); - + fRawData = static_cast(uprv_malloc(initialSize)); fMemLimit = initialSize; if (fRawData == NULL) { @@ -875,7 +875,7 @@ uspoof_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *ou const uint8_t *inBytes =(const uint8_t *)inData+headerSize; SpoofDataHeader *spoofDH = (SpoofDataHeader *)inBytes; if (ds->readUInt32(spoofDH->fMagic) != USPOOF_MAGIC || - ds->readUInt32(spoofDH->fLength) < sizeof(SpoofDataHeader)) + ds->readUInt32(spoofDH->fLength) < sizeof(SpoofDataHeader)) { udata_printError(ds, "uspoof_swap(): Spoof Data header is invalid.\n"); *status=U_UNSUPPORTED_ERROR; @@ -955,3 +955,5 @@ uspoof_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *ou } #endif + + diff --git a/deps/icu-small/source/i18n/uspoof_impl.h b/deps/icu-small/source/i18n/uspoof_impl.h index 8844a96446e2b5..b111d4b16a9376 100644 --- a/deps/icu-small/source/i18n/uspoof_impl.h +++ b/deps/icu-small/source/i18n/uspoof_impl.h @@ -66,7 +66,7 @@ class SpoofImpl : public UObject, /** Copy constructor, used by the user level uspoof_clone() function. */ SpoofImpl(const SpoofImpl &src, UErrorCode &status); - + USpoofChecker *asUSpoofChecker(); static SpoofImpl *validateThis(USpoofChecker *sc, UErrorCode &status); static const SpoofImpl *validateThis(const USpoofChecker *sc, UErrorCode &status); @@ -102,7 +102,7 @@ class SpoofImpl : public UObject, int32_t fChecks; // Bit vector of checks to perform. SpoofData *fSpoofData; - + const UnicodeSet *fAllowedCharsSet; // The UnicodeSet of allowed characters. // for this Spoof Checker. Defaults to all chars. @@ -211,7 +211,7 @@ class SpoofData: public UMemory { SpoofData(UErrorCode &status); // Create new spoof data wrapper. // Only used when building new data from rules. - + // Constructor for use when creating from prebuilt default data. // A UDataMemory is what the ICU internal data loading functions provide. // The udm is adopted by the SpoofData. @@ -231,7 +231,7 @@ class SpoofData: public UMemory { // Clone of a user-level spoof detector increments the ref count on the data. // Close of a user-level spoof detector decrements the ref count. // If the data is owned by us, it will be deleted when count goes to zero. - SpoofData *addReference(); + SpoofData *addReference(); void removeReference(); // Reset all fields to an initial state. @@ -340,3 +340,4 @@ uspoof_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *ou #endif #endif /* USPOOFIM_H */ + diff --git a/deps/icu-small/source/i18n/usrchimp.h b/deps/icu-small/source/i18n/usrchimp.h index 5438417e7e60aa..88b2e217db477a 100644 --- a/deps/icu-small/source/i18n/usrchimp.h +++ b/deps/icu-small/source/i18n/usrchimp.h @@ -43,7 +43,7 @@ #define isContinuation(CE) (((CE) & UCOL_CONTINUATION_MARKER) == UCOL_CONTINUATION_MARKER) /** - * This indicates an error has occured during processing or there are no more CEs + * This indicates an error has occured during processing or there are no more CEs * to be returned. */ #define UCOL_PROCESSED_NULLORDER ((int64_t)U_INT64_MAX) @@ -100,7 +100,7 @@ class UCollationPCE : public UMemory { * @param ixLow a pointer to an int32_t to receive the iterator index before fetching the CE. * @param ixHigh a pointer to an int32_t to receive the iterator index after fetching the CE. * @param status A pointer to an UErrorCode to receive any errors. - * @return The next collation elements ordering, otherwise returns UCOL_PROCESSED_NULLORDER + * @return The next collation elements ordering, otherwise returns UCOL_PROCESSED_NULLORDER * if an error has occured or if the end of string has been reached */ int64_t nextProcessed(int32_t *ixLow, int32_t *ixHigh, UErrorCode *status); @@ -110,10 +110,10 @@ class UCollationPCE : public UMemory { * * @param ixLow A pointer to an int32_t to receive the iterator index after fetching the CE * @param ixHigh A pointer to an int32_t to receiver the iterator index before fetching the CE - * @param status A pointer to an UErrorCode to receive any errors. Noteably + * @param status A pointer to an UErrorCode to receive any errors. Noteably * a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack * buffer has been exhausted. - * @return The previous collation elements ordering, otherwise returns + * @return The previous collation elements ordering, otherwise returns * UCOL_PROCESSED_NULLORDER if an error has occured or if the start of * string has been reached. */ @@ -139,10 +139,10 @@ struct USearch { UBreakIterator *internalBreakIter; //internal character breakiterator UBreakIterator *breakIter; // value USEARCH_DONE is the default value - // if we are not at the start of the text or the end of the text, - // depending on the iteration direction and matchedIndex is USEARCH_DONE + // if we are not at the start of the text or the end of the text, + // depending on the iteration direction and matchedIndex is USEARCH_DONE // it means that we can't find any more matches in that particular direction - int32_t matchedIndex; + int32_t matchedIndex; int32_t matchedLength; UBool isForwardSearching; UBool reset; @@ -174,7 +174,7 @@ struct UStringSearch { // if we are at the start of the text. UCollationElements *textIter; icu::UCollationPCE *textProcessedIter; - // utility collation element, used throughout program for temporary + // utility collation element, used throughout program for temporary // iteration. UCollationElements *utilIter; UBool ownCollator; @@ -189,21 +189,21 @@ struct UStringSearch { /** * Exact matches without checking for the ends for extra accents. * The match after the position within the collation element iterator is to be -* found. +* found. * After a match is found the offset in the collation element iterator will be * shifted to the start of the match. -* Implementation note: -* For tertiary we can't use the collator->tertiaryMask, that is a -* preprocessed mask that takes into account case options. since we are only +* Implementation note: +* For tertiary we can't use the collator->tertiaryMask, that is a +* preprocessed mask that takes into account case options. since we are only * concerned with exact matches, we don't need that. -* Alternate handling - since only the 16 most significant digits is only used, -* we can safely do a compare without masking if the ce is a variable, we mask -* and get only the primary values no shifting to quartenary is required since +* Alternate handling - since only the 16 most significant digits is only used, +* we can safely do a compare without masking if the ce is a variable, we mask +* and get only the primary values no shifting to quartenary is required since * all primary values less than variabletop will need to be masked off anyway. -* If the end character is composite and the pattern ce does not match the text -* ce, we skip it until we find a match in the end composite character or when +* If the end character is composite and the pattern ce does not match the text +* ce, we skip it until we find a match in the end composite character or when * it has passed the character. This is so that we can match pattern "a" with -* the text "\u00e6" +* the text "\u00e6" * @param strsrch string search data * @param status error status if any * @return TRUE if an exact match is found, FALSE otherwise @@ -213,7 +213,7 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status); /** * Canonical matches. -* According to the definition, matches found here will include the whole span +* According to the definition, matches found here will include the whole span * of beginning and ending accents if it overlaps that region. * @param strsrch string search data * @param status error status if any @@ -234,14 +234,14 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status); /** * Canonical matches. -* According to the definition, matches found here will include the whole span +* According to the definition, matches found here will include the whole span * of beginning and ending accents if it overlaps that region. * @param strsrch string search data * @param status error status if any * @return TRUE if a canonical match is found, FALSE otherwise */ U_CFUNC -UBool usearch_handlePreviousCanonical(UStringSearch *strsrch, +UBool usearch_handlePreviousCanonical(UStringSearch *strsrch, UErrorCode *status); #endif /* #if !UCONFIG_NO_COLLATION */ diff --git a/deps/icu-small/source/i18n/utmscale.cpp b/deps/icu-small/source/i18n/utmscale.cpp index 461985937acca4..7bf6eec331a13a 100644 --- a/deps/icu-small/source/i18n/utmscale.cpp +++ b/deps/icu-small/source/i18n/utmscale.cpp @@ -57,7 +57,7 @@ U_CAPI int64_t U_EXPORT2 utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status) { const int64_t *data; - + if (status == NULL || U_FAILURE(*status)) { return 0; } @@ -73,7 +73,7 @@ utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *stat *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; } - + return (otherTime + data[UTSV_EPOCH_OFFSET_VALUE]) * data[UTSV_UNITS_VALUE]; } @@ -81,7 +81,7 @@ U_CAPI int64_t U_EXPORT2 utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status) { const int64_t *data; - + if (status == NULL || U_FAILURE(*status)) { return 0; } @@ -97,19 +97,19 @@ utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *st *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; } - + if (universalTime < 0) { if (universalTime < data[UTSV_MIN_ROUND_VALUE]) { return (universalTime + data[UTSV_UNITS_ROUND_VALUE]) / data[UTSV_UNITS_VALUE] - data[UTSV_EPOCH_OFFSET_PLUS_1_VALUE]; } - + return (universalTime - data[UTSV_UNITS_ROUND_VALUE]) / data[UTSV_UNITS_VALUE] - data[UTSV_EPOCH_OFFSET_VALUE]; } - + if (universalTime > data[UTSV_MAX_ROUND_VALUE]) { return (universalTime - data[UTSV_UNITS_ROUND_VALUE]) / data[UTSV_UNITS_VALUE] - data[UTSV_EPOCH_OFFSET_MINUS_1_VALUE]; } - + return (universalTime + data[UTSV_UNITS_ROUND_VALUE]) / data[UTSV_UNITS_VALUE] - data[UTSV_EPOCH_OFFSET_VALUE]; } diff --git a/deps/icu-small/source/i18n/utrans.cpp b/deps/icu-small/source/i18n/utrans.cpp index 31070dd43fbe4e..29013ead1257c2 100644 --- a/deps/icu-small/source/i18n/utrans.cpp +++ b/deps/icu-small/source/i18n/utrans.cpp @@ -147,11 +147,11 @@ utrans_openU(const UChar *id, return NULL; } UParseError temp; - + if(parseError == NULL){ parseError = &temp; } - + UnicodeString ID(idLength<0, id, idLength); // r-o alias if(rules==NULL){ @@ -159,7 +159,7 @@ utrans_openU(const UChar *id, Transliterator *trans = NULL; trans = Transliterator::createInstance(ID, dir, *parseError, *status); - + if(U_FAILURE(*status)){ return NULL; } @@ -170,8 +170,8 @@ utrans_openU(const UChar *id, rulesLength); // r-o alias Transliterator *trans = NULL; - trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status); - if(U_FAILURE(*status)) { + trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status); + if(U_FAILURE(*status)) { return NULL; } @@ -183,7 +183,7 @@ U_CAPI UTransliterator* U_EXPORT2 utrans_open(const char* id, UTransDirection dir, const UChar* rules, /* may be Null */ - int32_t rulesLength, /* -1 if null-terminated */ + int32_t rulesLength, /* -1 if null-terminated */ UParseError* parseError, /* may be Null */ UErrorCode* status) { UnicodeString ID(id, -1, US_INV); // use invariant converter @@ -449,7 +449,7 @@ utrans_transUChars(const UTransliterator* trans, *status = U_ILLEGAL_ARGUMENT_ERROR; return; } - + int32_t textLen = (textLength == NULL || *textLength < 0) ? u_strlen(text) : *textLength; // writeable alias: for this ct, len CANNOT be -1 (why?) diff --git a/deps/icu-small/source/i18n/vtzone.cpp b/deps/icu-small/source/i18n/vtzone.cpp index e39eada51b7f61..fa8c3390b815a9 100644 --- a/deps/icu-small/source/i18n/vtzone.cpp +++ b/deps/icu-small/source/i18n/vtzone.cpp @@ -114,7 +114,7 @@ static int32_t parseAsciiDigits(const UnicodeString& str, int32_t start, int32_t } num = 10 * num + digit; } - return sign * num; + return sign * num; } static UnicodeString& appendAsciiDigits(int32_t number, uint8_t length, UnicodeString& str) { @@ -369,9 +369,9 @@ static void getDefaultTZName(const UnicodeString &tzid, UBool isDST, UnicodeStri /* * Parse individual RRULE - * + * * On return - - * + * * month calculated by BYMONTH-1, or -1 when not found * dow day of week in BYDAY, or 0 when not found * wim day of week ordinal number in BYDAY, or 0 when not found @@ -626,7 +626,7 @@ static TimeZoneRule* createRuleByRRULE(const UnicodeString& zonename, int rawOff if (tmp_until > until) { until = tmp_until; } - + // Check if BYMONTH + BYMONTHDAY + BYDAY rule if (tmp_month == -1 || tmp_dayOfWeek == 0 || tmp_daysCount == 0) { goto unsupportedRRule; @@ -965,7 +965,7 @@ VTimeZone::VTimeZone(const VTimeZone& source) tzurl(source.tzurl), lastmod(source.lastmod), olsonzid(source.olsonzid), icutzver(source.icutzver) { if (source.tz != NULL) { - tz = (BasicTimeZone*)source.tz->clone(); + tz = source.tz->clone(); } if (source.vtzlines != NULL) { UErrorCode status = U_ZERO_ERROR; @@ -1007,7 +1007,7 @@ VTimeZone::operator=(const VTimeZone& right) { tz = NULL; } if (right.tz != NULL) { - tz = (BasicTimeZone*)right.tz->clone(); + tz = right.tz->clone(); } if (vtzlines != NULL) { delete vtzlines; @@ -1092,7 +1092,7 @@ VTimeZone::createVTimeZoneFromBasicTimeZone(const BasicTimeZone& basic_time_zone status = U_MEMORY_ALLOCATION_ERROR; return NULL; } - vtz->tz = (BasicTimeZone *)basic_time_zone.clone(); + vtz->tz = basic_time_zone.clone(); if (vtz->tz == NULL) { status = U_MEMORY_ALLOCATION_ERROR; delete vtz; @@ -1177,8 +1177,8 @@ VTimeZone::writeSimple(UDate time, UnicodeString& result, UErrorCode& status) co writeSimple(time, writer, status); } -TimeZone* -VTimeZone::clone(void) const { +VTimeZone* +VTimeZone::clone() const { return new VTimeZone(*this); } @@ -1385,7 +1385,7 @@ VTimeZone::parse(UErrorCode& status) { } // Set the deleter to remove TimeZoneRule vectors to avoid memory leaks due to unowned TimeZoneRules. rules->setDeleter(deleteTimeZoneRule); - + dates = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status); if (U_FAILURE(status)) { goto cleanupParse; @@ -1526,7 +1526,7 @@ VTimeZone::parse(UErrorCode& status) { } else { // This is rare case.. just use 1 hour DST savings rawOffset = toOffset - DEF_DSTSAVINGS; - dstSavings = DEF_DSTSAVINGS; + dstSavings = DEF_DSTSAVINGS; } } else { rawOffset = toOffset; @@ -1957,7 +1957,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, && (atzrule = dynamic_cast(tzt.getTo())) != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR ) { - finalDstRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); + finalDstRule = atzrule->clone(); } if (dstCount > 0) { if (year == dstStartYear + dstCount @@ -1985,7 +1985,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, goto cleanupWriteZone; } } - } + } if (!sameRule) { // Reset this DST information dstName = name; @@ -2008,7 +2008,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, && (atzrule = dynamic_cast(tzt.getTo())) != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR ) { - finalStdRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); + finalStdRule = atzrule->clone(); } if (stdCount > 0) { if (year == stdStartYear + stdCount @@ -2067,9 +2067,9 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, isDst = (dst != 0); UnicodeString tzid; basictz.getID(tzid); - getDefaultTZName(tzid, isDst, name); + getDefaultTZName(tzid, isDst, name); writeZonePropsByTime(w, isDst, name, - offset, offset, DEF_TZSTARTTIME - offset, FALSE, status); + offset, offset, DEF_TZSTARTTIME - offset, FALSE, status); if (U_FAILURE(status)) { goto cleanupWriteZone; } @@ -2157,7 +2157,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, goto cleanupWriteZone; } } - } + } } writeFooter(w, status); @@ -2348,7 +2348,7 @@ VTimeZone::writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const Uni // Check if all days are in the same month int32_t startDay = dayOfMonth; int32_t currentMonthDays = 7; - + if (dayOfMonth <= 0) { // The start day is in previous month int32_t prevMonthDays = 1 - dayOfMonth; @@ -2374,7 +2374,7 @@ VTimeZone::writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const Uni currentMonthDays -= nextMonthDays; int32_t nextMonth = (month + 1) > 11 ? 0 : month + 1; - + writeZonePropsByDOW_GEQ_DOM_sub(writer, nextMonth, 1, dayOfWeek, nextMonthDays, MAX_MILLIS /* Do not use UNTIL */, fromOffset, status); if (U_FAILURE(status)) { @@ -2561,12 +2561,12 @@ VTimeZone::beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& z writer.write(COLON); writer.write(zonename); writer.write(ICAL_NEWLINE); - + // DTSTART writer.write(ICAL_DTSTART); writer.write(COLON); writer.write(getDateTimeString(startTime + fromOffset, dstr)); - writer.write(ICAL_NEWLINE); + writer.write(ICAL_NEWLINE); } /* diff --git a/deps/icu-small/source/i18n/vzone.cpp b/deps/icu-small/source/i18n/vzone.cpp index 6db3ba04c581f7..7e3a5544fd5e2f 100644 --- a/deps/icu-small/source/i18n/vzone.cpp +++ b/deps/icu-small/source/i18n/vzone.cpp @@ -8,7 +8,7 @@ */ /** - * \file + * \file * \brief C API: VTimeZone classes */ @@ -30,7 +30,7 @@ vzone_openID(const UChar* ID, int32_t idLength){ UnicodeString s(idLength==-1, ID, idLength); return (VZone*) (VTimeZone::createVTimeZoneByID(s)); } - + U_CAPI VZone* U_EXPORT2 vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) { UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength); @@ -59,7 +59,7 @@ vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) { urlLength = s.length(); memcpy(url,s.getBuffer(),urlLength); - + return b; } diff --git a/deps/icu-small/source/i18n/vzone.h b/deps/icu-small/source/i18n/vzone.h index 700687e0cb76ab..17df92e17b538a 100644 --- a/deps/icu-small/source/i18n/vzone.h +++ b/deps/icu-small/source/i18n/vzone.h @@ -86,7 +86,7 @@ vzone_equals(const VZone* zone1, const VZone* zone2); /** * Gets the RFC2445 TZURL property value. When a vzone instance was - * created from VTIMEZONE data, the initial value is set by the TZURL + * created from VTIMEZONE data, the initial value is set by the TZURL * property value in the data. Otherwise, the initial value is not set. * @param zone, the vzone to use * @param url Receives the RFC2445 TZURL property value. @@ -107,8 +107,8 @@ vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength); /** * Gets the RFC2445 LAST-MODIFIED property value. When a vzone instance - * was created from VTIMEZONE data, the initial value is set by the - * LAST-MODIFIED property value in the data. Otherwise, the initial value + * was created from VTIMEZONE data, the initial value is set by the + * LAST-MODIFIED property value in the data. Otherwise, the initial value * is not set. * @param zone, the vzone to use * @param lastModified Receives the last modified date. @@ -323,7 +323,7 @@ vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* re * Returns the number of TimeZoneRules which represents time transitions, * for this time zone, that is, all TimeZoneRules for this time zone except * InitialTimeZoneRule. The return value range is 0 or any positive value. - * @param zone, the vzone to use + * @param zone, the vzone to use * @param status Receives error status code. * @return The number of TimeZoneRules representing time transitions. */ diff --git a/deps/icu-small/source/i18n/windtfmt.cpp b/deps/icu-small/source/i18n/windtfmt.cpp index 983fd46c122e6f..bcf272bc612f1c 100644 --- a/deps/icu-small/source/i18n/windtfmt.cpp +++ b/deps/icu-small/source/i18n/windtfmt.cpp @@ -141,7 +141,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt // This means that it will fail for locales where ICU has a completely different // name (like ku vs ckb), and it will also not work for alternate sort locale // names like "de-DE-u-co-phonebk". - + // TODO: We could add some sort of exception table for cases like ku vs ckb. int length = ResolveLocaleName(bcp47Tag, windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName)); @@ -167,7 +167,7 @@ Win32DateFormat::Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyl // Note: In the previous code, it would look up the LCID for the locale, and if // the locale was not recognized then it would get an LCID of 0, which is a // synonym for LOCALE_USER_DEFAULT on Windows. - // If the above method fails, then fWindowsLocaleName will remain as nullptr, and + // If the above method fails, then fWindowsLocaleName will remain as nullptr, and // then we will pass nullptr to API GetLocaleInfoEx, which is the same as passing // LOCALE_USER_DEFAULT. @@ -213,7 +213,7 @@ Win32DateFormat &Win32DateFormat::operator=(const Win32DateFormat &other) return *this; } -Format *Win32DateFormat::clone(void) const +Win32DateFormat *Win32DateFormat::clone() const { return new Win32DateFormat(*this); } @@ -405,3 +405,4 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ #endif // U_PLATFORM_USES_ONLY_WIN32_API + diff --git a/deps/icu-small/source/i18n/windtfmt.h b/deps/icu-small/source/i18n/windtfmt.h index 43b6fe6dba269e..7fe7f68f450e84 100644 --- a/deps/icu-small/source/i18n/windtfmt.h +++ b/deps/icu-small/source/i18n/windtfmt.h @@ -27,7 +27,7 @@ #include "unicode/locid.h" /** - * \file + * \file * \brief C++ API: Format dates using Windows API. */ @@ -48,7 +48,7 @@ class Win32DateFormat : public DateFormat virtual ~Win32DateFormat(); - virtual Format *clone(void) const; + virtual Win32DateFormat *clone() const; Win32DateFormat &operator=(const Win32DateFormat &other); diff --git a/deps/icu-small/source/i18n/winnmfmt.cpp b/deps/icu-small/source/i18n/winnmfmt.cpp index b1724b62c27279..72da1be28b8ece 100644 --- a/deps/icu-small/source/i18n/winnmfmt.cpp +++ b/deps/icu-small/source/i18n/winnmfmt.cpp @@ -213,7 +213,7 @@ Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro // Note: In the previous code, it would look up the LCID for the locale, and if // the locale was not recognized then it would get an LCID of 0, which is a // synonym for LOCALE_USER_DEFAULT on Windows. - // If the above method fails, then fWindowsLocaleName will remain as nullptr, and + // If the above method fails, then fWindowsLocaleName will remain as nullptr, and // then we will pass nullptr to API GetLocaleInfoEx, which is the same as passing // LOCALE_USER_DEFAULT. @@ -275,7 +275,7 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other) this->fLCID = other.fLCID; this->fFractionDigitsSet = other.fFractionDigitsSet; this->fWindowsLocaleName = other.fWindowsLocaleName == NULL ? NULL : new UnicodeString(*other.fWindowsLocaleName); - + const wchar_t *localeName = nullptr; if (fWindowsLocaleName != nullptr) @@ -294,7 +294,7 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other) return *this; } -Format *Win32NumberFormat::clone(void) const +Win32NumberFormat *Win32NumberFormat::clone() const { return new Win32NumberFormat(*this); } diff --git a/deps/icu-small/source/i18n/winnmfmt.h b/deps/icu-small/source/i18n/winnmfmt.h index 7ea5da91705476..99571d2013824d 100644 --- a/deps/icu-small/source/i18n/winnmfmt.h +++ b/deps/icu-small/source/i18n/winnmfmt.h @@ -27,7 +27,7 @@ #if !UCONFIG_NO_FORMATTING /** - * \file + * \file * \brief C++ API: Format numbers using Windows API. */ @@ -44,7 +44,7 @@ class Win32NumberFormat : public NumberFormat virtual ~Win32NumberFormat(); - virtual Format *clone(void) const; + virtual Win32NumberFormat *clone() const; Win32NumberFormat &operator=(const Win32NumberFormat &other); diff --git a/deps/icu-small/source/i18n/wintzimpl.cpp b/deps/icu-small/source/i18n/wintzimpl.cpp index c55ed95fa8aea2..433ed4c29398c0 100644 --- a/deps/icu-small/source/i18n/wintzimpl.cpp +++ b/deps/icu-small/source/i18n/wintzimpl.cpp @@ -13,7 +13,7 @@ #include "unicode/utypes.h" -#if U_PLATFORM_USES_ONLY_WIN32_API && !UCONFIG_NO_FORMATTING +#if U_PLATFORM_USES_ONLY_WIN32_API && !UCONFIG_NO_FORMATTING #include "wintzimpl.h" @@ -51,7 +51,7 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY standardBias = 0; daylightBias = 0; // Do not use DST. Set 0 to all stadardDate/daylightDate fields - standardDate.wYear = standardDate.wMonth = standardDate.wDayOfWeek = standardDate.wDay = + standardDate.wYear = standardDate.wMonth = standardDate.wDayOfWeek = standardDate.wDay = standardDate.wHour = standardDate.wMinute = standardDate.wSecond = standardDate.wMilliseconds = 0; daylightDate.wYear = daylightDate.wMonth = daylightDate.wDayOfWeek = daylightDate.wDay = daylightDate.wHour = daylightDate.wMinute = daylightDate.wSecond = daylightDate.wMilliseconds = 0; @@ -121,7 +121,7 @@ static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar UBool result = FALSE; UnicodeString id = UnicodeString(icuid, length); TimeZone *tz = TimeZone::createTimeZone(id); - + if (tz != NULL) { int32_t bias; int32_t daylightBias; @@ -145,7 +145,7 @@ static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar } /* - * Given the timezone icuid, fill in zoneInfo by calling auxillary functions that creates a timezone and extract the + * Given the timezone icuid, fill in zoneInfo by calling auxillary functions that creates a timezone and extract the * information to put into zoneInfo. This includes bias and standard time date and daylight saving date. */ U_CAPI UBool U_EXPORT2 diff --git a/deps/icu-small/source/i18n/wintzimpl.h b/deps/icu-small/source/i18n/wintzimpl.h index c36f2ad5f5f057..772ea95bc52f3f 100644 --- a/deps/icu-small/source/i18n/wintzimpl.h +++ b/deps/icu-small/source/i18n/wintzimpl.h @@ -18,7 +18,7 @@ #if U_PLATFORM_USES_ONLY_WIN32_API /** - * \file + * \file * \brief C API: Utilities for dealing w/ Windows time zones. */ U_CDECL_BEGIN diff --git a/deps/icu-small/source/i18n/zonemeta.cpp b/deps/icu-small/source/i18n/zonemeta.cpp index 0e3ee893161122..72c590f424723f 100644 --- a/deps/icu-small/source/i18n/zonemeta.cpp +++ b/deps/icu-small/source/i18n/zonemeta.cpp @@ -30,10 +30,7 @@ #include "olsontz.h" #include "uinvchar.h" -static icu::UMutex *gZoneMetaLock() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex gZoneMetaLock; // CLDR Canonical ID mapping table static UHashtable *gCanonicalIDCache = NULL; @@ -266,11 +263,11 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { } // Check if it was already cached - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { canonicalID = (const UChar *)uhash_get(gCanonicalIDCache, utzid); } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (canonicalID != NULL) { return canonicalID; @@ -351,7 +348,7 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { U_ASSERT(canonicalID != NULL); // canocanilD must be non-NULL here // Put the resolved canonical ID to the cache - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { const UChar* idInCache = (const UChar *)uhash_get(gCanonicalIDCache, utzid); if (idInCache == NULL) { @@ -371,7 +368,7 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { } } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); } return canonicalID; @@ -449,14 +446,14 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, // Check if it was already cached UBool cached = FALSE; UBool singleZone = FALSE; - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { singleZone = cached = gSingleZoneCountries->contains((void*)region); if (!cached) { cached = gMultiZonesCountries->contains((void*)region); } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (!cached) { // We need to go through all zones associated with the region. @@ -475,7 +472,7 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, delete ids; // Cache the result - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { UErrorCode ec = U_ZERO_ERROR; if (singleZone) { @@ -488,7 +485,7 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, } } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); } if (singleZone) { @@ -575,11 +572,11 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { // get the mapping from cache const UVector *result = NULL; - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { result = (UVector*) uhash_get(gOlsonToMeta, tzidUChars); } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (result != NULL) { return result; @@ -593,7 +590,7 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { } // put the new one into the cache - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { // make sure it's already created result = (UVector*) uhash_get(gOlsonToMeta, tzidUChars); @@ -621,7 +618,7 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { delete tmpResult; } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); return result; } diff --git a/deps/icu-small/source/i18n/zrule.cpp b/deps/icu-small/source/i18n/zrule.cpp index c13411fc8e3f49..bdf84965b5f420 100644 --- a/deps/icu-small/source/i18n/zrule.cpp +++ b/deps/icu-small/source/i18n/zrule.cpp @@ -8,7 +8,7 @@ */ /** - * \file + * \file * \brief C API: Time zone rule classes */ @@ -115,25 +115,25 @@ izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2) { } U_CAPI UBool U_EXPORT2 -izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, +izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) { return ((const InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFirstStart(prevRawOffset, prevDSTSavings, result); } U_CAPI UBool U_EXPORT2 -izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, +izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) { return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFinalStart(prevRawOffset, prevDSTSavings, result); } U_CAPI UBool U_EXPORT2 -izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, +izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate& result) { return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getNextStart(base, prevRawOffset, prevDSTSavings, inclusive, result); } U_CAPI UBool U_EXPORT2 -izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, +izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate& result) { return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getPreviousStart(base, prevRawOffset, prevDSTSavings, inclusive, result); } diff --git a/deps/icu-small/source/i18n/zrule.h b/deps/icu-small/source/i18n/zrule.h index 272f954f06905b..f395ad4c3f3176 100644 --- a/deps/icu-small/source/i18n/zrule.h +++ b/deps/icu-small/source/i18n/zrule.h @@ -10,7 +10,7 @@ #define __ZRULE_H /** - * \file + * \file * \brief C API: Time zone rule classes */ @@ -195,12 +195,12 @@ izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2); * "result" is unchanged. */ U_CAPI UBool U_EXPORT2 -izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, +izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result); /** * Gets the final time when this rule takes effect. - * @param rule The IZrule to use + * @param rule The IZrule to use * @param prevRawOffset The standard time offset from UTC before this rule * takes effect in milliseconds. * @param prevDSTSavings The amount of daylight saving offset from the @@ -210,7 +210,7 @@ izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings * "result" is unchanged. */ U_CAPI UBool U_EXPORT2 -izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, +izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result); /** @@ -228,7 +228,7 @@ izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings * "result" is unchanged. */ U_CAPI UBool U_EXPORT2 -izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, +izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate& result); /** @@ -246,7 +246,7 @@ izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, * "result" is unchanged. */ U_CAPI UBool U_EXPORT2 -izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, +izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate& result); diff --git a/deps/icu-small/source/i18n/ztrans.cpp b/deps/icu-small/source/i18n/ztrans.cpp index d2d93da1334b3e..9dbe9bb0b9426c 100644 --- a/deps/icu-small/source/i18n/ztrans.cpp +++ b/deps/icu-small/source/i18n/ztrans.cpp @@ -8,7 +8,7 @@ */ /** - * \file + * \file * \brief C API: Time zone transition classes */ diff --git a/deps/icu-small/source/i18n/ztrans.h b/deps/icu-small/source/i18n/ztrans.h index 8b63eb47e88bbb..b23bb4fc706e69 100644 --- a/deps/icu-small/source/i18n/ztrans.h +++ b/deps/icu-small/source/i18n/ztrans.h @@ -10,7 +10,7 @@ #define __ZTRANS_H /** - * \file + * \file * \brief C API: Time zone transition classes */ @@ -34,7 +34,7 @@ typedef struct ZTrans ZTrans; /** * Constructs a time zone transition with the time and the rules before/after * the transition. - * + * * @param time The time of transition in milliseconds since the base time. * @param from The time zone rule used before the transition. * @param to The time zone rule used after the transition. diff --git a/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json new file mode 100644 index 00000000000000..2b7ff9989992a1 --- /dev/null +++ b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json @@ -0,0 +1,169 @@ +// Copyright (C) 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +{ + "$id": "http://unicode.org/icu-filter-schema", + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "JSON Schema for an ICU data filter file", + "type": "object", + "properties": { + "strategy": { + "type": "string", + "enum": ["additive", "subtractive"] + }, + "localeFilter": { "$ref": "#/definitions/filter" }, + "featureFilters": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { "$ref": "#/definitions/filter" }, + { + "type": "string", + "enum": ["include", "exclude"] + } + ] + } + }, + "resourceFilters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "categories": { + "type": "array", + "items": { "type": "string" } + }, + "files": { "$ref": "#/definitions/filter" }, + "rules": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[+-]/[\\S]*$" + } + } + }, + "required": ["categories", "rules"], + "additionalProperties": false + } + }, + "fileReplacements": { + "type": "object", + "properties": { + "directory": { + "type": "string", + "pattern": "^(\\$SRC|\\$FILTERS|\\$CWD|/$|/[^/]+)(/[^/]+)*$" + }, + "replacements": { + "type": "array", + "items": { + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "src": { "type": "string" }, + "dest": { "type": "string" } + }, + "additionalProperties": false, + "required": ["src", "dest"] + } + ] + } + } + }, + "additionalProperties": false, + "required": ["directory", "replacements"] + }, + "collationUCAData": { + "type": "string", + "enum": ["unihan", "implicithan"] + }, + "usePoolBundle": { + "type": "boolean" + } + }, + "additionalProperties": false, + "definitions": { + "filter": { + "type": "object", + "oneOf": [ + { + "properties": { + "filterType": { + "$ref": "#/definitions/blacklistWhitelistFilterTypes" + }, + "whitelist": { "$ref": "#/definitions/stringList" } + }, + "required": ["whitelist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "$ref": "#/definitions/blacklistWhitelistFilterTypes" + }, + "blacklist": { "$ref": "#/definitions/stringList" } + }, + "required": ["blacklist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["exclude"] + } + }, + "required": ["filterType"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["locale"] + }, + "includeChildren": { + "type": "boolean" + }, + "includeScripts": { + "type": "boolean" + }, + "whitelist": { "$ref": "#/definitions/stringList" } + }, + "required": ["filterType", "whitelist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["union"] + }, + "unionOf": { + "type": "array", + "items": { "$ref": "#/definitions/filter" } + } + }, + "required": ["filterType", "unionOf"], + "additionalProperties": false + } + ] + }, + "blacklistWhitelistFilterTypes": { + "type": "string", + "enum": [ + "language", + "regex" + ] + }, + "stringList": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } +} diff --git a/deps/icu-small/source/stubdata/stubdata.cpp b/deps/icu-small/source/stubdata/stubdata.cpp index de49b9a733a66e..0fcab4faa82c0b 100644 --- a/deps/icu-small/source/stubdata/stubdata.cpp +++ b/deps/icu-small/source/stubdata/stubdata.cpp @@ -32,7 +32,7 @@ typedef struct { uint32_t count, reserved; /* const struct { - const char *const name; + const char *const name; const void *const data; } toc[1]; */ @@ -55,14 +55,14 @@ extern "C" U_EXPORT const ICU_Data_Header U_ICUDATA_ENTRY_POINT = { #endif U_CHARSET_FAMILY, - sizeof(UChar), + sizeof(UChar), 0, /* reserved */ { /* data format identifier */ 0x54, 0x6f, 0x43, 0x50}, /* "ToCP" */ {1, 0, 0, 0}, /* format version major, minor, milli, micro */ {0, 0, 0, 0} /* dataVersion */ }, - {0,0,0,0,0,0,0,0}, /* Padding[8] */ + {0,0,0,0,0,0,0,0}, /* Padding[8] */ 0, /* count */ 0, /* Reserved */ { /* TOC structure */ @@ -72,3 +72,5 @@ extern "C" U_EXPORT const ICU_Data_Header U_ICUDATA_ENTRY_POINT = { /* } */ } }; + + diff --git a/deps/icu-small/source/tools/escapesrc/cptbl.h b/deps/icu-small/source/tools/escapesrc/cptbl.h index efaa9642e10e75..898e16c925d2f0 100644 --- a/deps/icu-small/source/tools/escapesrc/cptbl.h +++ b/deps/icu-small/source/tools/escapesrc/cptbl.h @@ -1,7 +1,7 @@ -// Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html +// Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html // generated by tblgen. You weren't going to edit it by hand, were you? -static const char cp1047_8859_1[256] = { +static const char cp1047_8859_1[256] = { (char)0x00, /* 00 */ (char)0x01, /* 01 */ (char)0x02, /* 02 */ @@ -260,7 +260,7 @@ static const char cp1047_8859_1[256] = { (char)0x9F, /* FF */ }; -static const bool oldIllegal[256] = { +static const bool oldIllegal[256] = { false, /* U+0000 */ false, /* U+0001 */ false, /* U+0002 */ @@ -518,3 +518,4 @@ static const bool oldIllegal[256] = { false, /* U+00FE */ false, /* U+00FF */ }; + diff --git a/deps/icu-small/source/tools/escapesrc/escapesrc.cpp b/deps/icu-small/source/tools/escapesrc/escapesrc.cpp index a056098ecebca6..ce14022bfc13bc 100644 --- a/deps/icu-small/source/tools/escapesrc/escapesrc.cpp +++ b/deps/icu-small/source/tools/escapesrc/escapesrc.cpp @@ -37,7 +37,7 @@ * %.o: _%.cpp * $(COMPILE.cc) ... $@ $< * - * In the Makefiles, SKIP_ESCAPING=YES is used to prevent escapesrc.cpp + * In the Makefiles, SKIP_ESCAPING=YES is used to prevent escapesrc.cpp * from being itself escaped. */ @@ -136,7 +136,7 @@ bool appendUtf8(std::string &outstr, tmp[chars] = 0; unsigned int c; sscanf(tmp, "%X", &c); - UChar32 ch = c & 0x1FFFFF; + UChar32 ch = c & 0x1FFFFF; // now to append \\x%% etc uint8_t bytesNeeded = U8_LENGTH(ch); @@ -194,7 +194,7 @@ bool fixu8(std::string &linestr, size_t origpos, size_t &endpos) { outstr += ('\"'); linestr.replace(origpos, (endpos-origpos+1), outstr); - + return false; // OK } @@ -207,7 +207,7 @@ bool fixu8(std::string &linestr, size_t origpos, size_t &endpos) { */ bool fixAt(std::string &linestr, size_t pos) { size_t origpos = pos; - + if(linestr[pos] != 'u') { fprintf(stderr, "Not a 'u'?"); return true; @@ -216,12 +216,12 @@ bool fixAt(std::string &linestr, size_t pos) { pos++; // past 'u' bool utf8 = false; - + if(linestr[pos] == '8') { // u8" utf8 = true; pos++; } - + char quote = linestr[pos]; if(quote != '\'' && quote != '\"') { @@ -268,7 +268,7 @@ bool fixAt(std::string &linestr, size_t pos) { } } #endif - + // Proceed to decode utf-8 const uint8_t *s = (const uint8_t*) (linestr.c_str()); int32_t length = linestr.size(); @@ -368,7 +368,7 @@ int convert(const std::string &infile, const std::string &outfile) { fprintf(stderr, "escapesrc: %s -> %s\n", infile.c_str(), outfile.c_str()); std::ifstream inf; - + inf.open(infile.c_str(), std::ios::in); if(!inf.is_open()) { diff --git a/deps/icu-small/source/tools/escapesrc/tblgen.cpp b/deps/icu-small/source/tools/escapesrc/tblgen.cpp index 9bf59a9db9a5df..e94fa9036bc58e 100644 --- a/deps/icu-small/source/tools/escapesrc/tblgen.cpp +++ b/deps/icu-small/source/tools/escapesrc/tblgen.cpp @@ -37,12 +37,12 @@ int main(int argc, const char *argv[]) { } printf("};\n\n"); - // + // // UnicodeSet oldIllegal("[:print:]", status); // [a-zA-Z0-9_}{#)(><%:;.?*+-/^&|~!=,\\u005b\\u005d\\u005c]", status); UnicodeSet oldIllegal("[0-9 a-z A-Z " "_ \\{ \\} \\[ \\] # \\( \\) < > % \\: ; . " "? * + \\- / \\^ \\& | ~ ! = , \\ \" ' ]", status); - + /* http://www.lirmm.fr/~ducour/Doc-objets/ISO+IEC+14882-1998.pdf ( note: 1998 ) page 10, section 2.2 says: @@ -65,7 +65,7 @@ So basically: printable ASCII plus 0x00-0x1F, 0x7F-0x9F, was all illegal. Some discussion at http://unicode.org/mail-arch/unicode-ml/y2003-m10/0471.html */ - + printf("static const bool oldIllegal[256] = { \n"); @@ -75,6 +75,6 @@ Some discussion at http://unicode.org/mail-arch/unicode-ml/y2003-m10/0471.html i); } printf("};\n\n"); - + return 0; } diff --git a/deps/icu-small/source/tools/genccode/genccode.c b/deps/icu-small/source/tools/genccode/genccode.c index d35b5890105d9c..91e94d7f5181c4 100644 --- a/deps/icu-small/source/tools/genccode/genccode.c +++ b/deps/icu-small/source/tools/genccode/genccode.c @@ -63,6 +63,7 @@ enum { kOptHelpH = 0, kOptHelpQuestionMark, kOptDestDir, + kOptQuiet, kOptName, kOptEntryPoint, #ifdef CAN_GENERATE_OBJECTS @@ -77,6 +78,7 @@ static UOption options[]={ /*0*/UOPTION_HELP_H, UOPTION_HELP_QUESTION_MARK, UOPTION_DESTDIR, + UOPTION_QUIET, UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG), UOPTION_DEF("entrypoint", 'e', UOPT_REQUIRES_ARG), #ifdef CAN_GENERATE_OBJECTS @@ -116,6 +118,7 @@ main(int argc, char* argv[]) { "options:\n" "\t-h or -? or --help this usage text\n" "\t-d or --destdir destination directory, followed by the path\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-n or --name symbol prefix, followed by the prefix\n" "\t-e or --entrypoint entry point name, followed by the name (_dat will be appended)\n" "\t-r or --revision Specify a version\n" @@ -159,6 +162,9 @@ main(int argc, char* argv[]) { writeCode = CALL_WRITECCODE; /* TODO: remove writeCode=&writeCCode; */ } + if (options[kOptQuiet].doesOccur) { + verbose = FALSE; + } while(--argc) { filename=getLongPathname(argv[argc]); if (verbose) { @@ -170,13 +176,15 @@ main(int argc, char* argv[]) { writeCCode(filename, options[kOptDestDir].value, options[kOptName].doesOccur ? options[kOptName].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; case CALL_WRITEASSEMBLY: writeAssemblyCode(filename, options[kOptDestDir].value, options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; #ifdef CAN_GENERATE_OBJECTS case CALL_WRITEOBJECT: @@ -184,7 +192,8 @@ main(int argc, char* argv[]) { options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; #endif default: diff --git a/deps/icu-small/source/tools/genrb/derb.cpp b/deps/icu-small/source/tools/genrb/derb.cpp index ac26d95be4ca01..997b400129532c 100644 --- a/deps/icu-small/source/tools/genrb/derb.cpp +++ b/deps/icu-small/source/tools/genrb/derb.cpp @@ -631,7 +631,7 @@ static const char *getEncodingName(const char *encoding) { if (!(enc = ucnv_getStandardName(encoding, "MIME", &err))) { err = U_ZERO_ERROR; if (!(enc = ucnv_getStandardName(encoding, "IANA", &err))) { - ; + // do nothing } } diff --git a/deps/icu-small/source/tools/genrb/filterrb.cpp b/deps/icu-small/source/tools/genrb/filterrb.cpp index d62d185d773224..dcc02fc6210903 100644 --- a/deps/icu-small/source/tools/genrb/filterrb.cpp +++ b/deps/icu-small/source/tools/genrb/filterrb.cpp @@ -23,6 +23,9 @@ ResKeyPath::ResKeyPath(const std::string& path, UErrorCode& status) { status = U_PARSE_ERROR; return; } + if (path.length() == 1) { + return; + } size_t i; size_t j = 0; while (true) { diff --git a/deps/icu-small/source/tools/genrb/genrb.cpp b/deps/icu-small/source/tools/genrb/genrb.cpp index 885f3039bf6d7b..6f3a13a0a6107c 100644 --- a/deps/icu-small/source/tools/genrb/genrb.cpp +++ b/deps/icu-small/source/tools/genrb/genrb.cpp @@ -205,10 +205,10 @@ main(int argc, "\t-c or --copyright include copyright notice\n"); fprintf(stderr, "\t-e or --encoding encoding of source files\n" - "\t-d of --destdir destination directory, followed by the path, defaults to %s\n" - "\t-s or --sourcedir source directory for files followed by path, defaults to %s\n" + "\t-d or --destdir destination directory, followed by the path, defaults to '%s'\n" + "\t-s or --sourcedir source directory for files followed by path, defaults to '%s'\n" "\t-i or --icudatadir directory for locating any needed intermediate data files,\n" - "\t followed by path, defaults to %s\n", + "\t followed by path, defaults to '%s'\n", u_getDataDirectory(), u_getDataDirectory(), u_getDataDirectory()); fprintf(stderr, "\t-j or --write-java write a Java ListResourceBundle for ICU4J, followed by optional encoding\n" @@ -240,7 +240,7 @@ main(int argc, "\t (--writePoolBundle and --usePoolBundle cannot be combined)\n"); fprintf(stderr, "\t --filterDir Input directory where filter files are available.\n" - "\t For more on filter files, see Python buildtool.\n"); + "\t For more on filter files, see ICU Data Build Tool.\n"); return illegalArg ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; } diff --git a/deps/icu-small/source/tools/genrb/parse.cpp b/deps/icu-small/source/tools/genrb/parse.cpp index 884d5d5666081a..18a8c76dbc5df1 100644 --- a/deps/icu-small/source/tools/genrb/parse.cpp +++ b/deps/icu-small/source/tools/genrb/parse.cpp @@ -274,11 +274,11 @@ expect(ParseState* state, enum ETokenType expectedToken, struct UString **tokenV } } -static char *getInvariantString(ParseState* state, uint32_t *line, struct UString *comment, UErrorCode *status) +static char *getInvariantString(ParseState* state, uint32_t *line, struct UString *comment, + int32_t &stringLength, UErrorCode *status) { struct UString *tokenValue; char *result; - uint32_t count; expect(state, TOK_STRING, &tokenValue, comment, line, status); @@ -287,14 +287,13 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin return NULL; } - count = u_strlen(tokenValue->fChars); - if(!uprv_isInvariantUString(tokenValue->fChars, count)) { + if(!uprv_isInvariantUString(tokenValue->fChars, tokenValue->fLength)) { *status = U_INVALID_FORMAT_ERROR; error(*line, "invariant characters required for table keys, binary data, etc."); return NULL; } - result = static_cast(uprv_malloc(count+1)); + result = static_cast(uprv_malloc(tokenValue->fLength+1)); if (result == NULL) { @@ -302,7 +301,8 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin return NULL; } - u_UCharsToChars(tokenValue->fChars, result, count+1); + u_UCharsToChars(tokenValue->fChars, result, tokenValue->fLength+1); + stringLength = tokenValue->fLength; return result; } @@ -1371,7 +1371,6 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US int32_t value; UBool readToken = FALSE; char *stopstring; - uint32_t len; struct UString memberComments; IntVectorResource *result = intvector_open(state->bundle, tag, comment, status); @@ -1404,7 +1403,8 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US return result; } - string = getInvariantString(state, NULL, NULL, status); + int32_t stringLength; + string = getInvariantString(state, NULL, NULL, stringLength, status); if (U_FAILURE(*status)) { @@ -1414,9 +1414,9 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US /* For handling illegal char in the Intvector */ value = uprv_strtoul(string, &stopstring, 0);/* make intvector support decimal,hexdigit,octal digit ranging from -2^31-2^32-1*/ - len=(uint32_t)(stopstring-string); + int32_t len = (int32_t)(stopstring-string); - if(len==uprv_strlen(string)) + if(len==stringLength) { result->add(value, *status); uprv_free(string); @@ -1454,7 +1454,8 @@ static struct SResource * parseBinary(ParseState* state, char *tag, uint32_t startline, const struct UString *comment, UErrorCode *status) { uint32_t line; - LocalMemory string(getInvariantString(state, &line, NULL, status)); + int32_t stringLength; + LocalMemory string(getInvariantString(state, &line, NULL, stringLength, status)); if (string.isNull() || U_FAILURE(*status)) { return NULL; @@ -1470,46 +1471,45 @@ parseBinary(ParseState* state, char *tag, uint32_t startline, const struct UStri printf(" binary %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - uint32_t count = (uint32_t)uprv_strlen(string.getAlias()); - if (count > 0){ - if((count % 2)==0){ - LocalMemory value; - if (value.allocateInsteadAndCopy(count) == NULL) - { - *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; - } - - char toConv[3] = {'\0', '\0', '\0'}; - for (uint32_t i = 0; i < count; i += 2) - { - toConv[0] = string[i]; - toConv[1] = string[i + 1]; + LocalMemory value; + int32_t count = 0; + if (stringLength > 0 && value.allocateInsteadAndCopy(stringLength) == NULL) + { + *status = U_MEMORY_ALLOCATION_ERROR; + return NULL; + } - char *stopstring; - value[i >> 1] = (uint8_t) uprv_strtoul(toConv, &stopstring, 16); - uint32_t len=(uint32_t)(stopstring-toConv); + char toConv[3] = {'\0', '\0', '\0'}; + for (int32_t i = 0; i < stringLength;) + { + // Skip spaces (which may have been line endings). + char c0 = string[i++]; + if (c0 == ' ') { continue; } + if (i == stringLength) { + *status=U_INVALID_CHAR_FOUND; + error(line, "Encountered invalid binary value (odd number of hex digits)"); + return NULL; + } + toConv[0] = c0; + toConv[1] = string[i++]; - if(len!=2) - { - *status=U_INVALID_CHAR_FOUND; - return NULL; - } - } + char *stopstring; + value[count++] = (uint8_t) uprv_strtoul(toConv, &stopstring, 16); + uint32_t len=(uint32_t)(stopstring-toConv); - return bin_open(state->bundle, tag, count >> 1, value.getAlias(), NULL, comment, status); - } - else + if(len!=2) { - *status = U_INVALID_CHAR_FOUND; - error(line, "Encountered invalid binary value (length is odd)"); + *status=U_INVALID_CHAR_FOUND; + error(line, "Encountered invalid binary value (not all pairs of hex digits)"); return NULL; } } - else - { + + if (count == 0) { warning(startline, "Encountered empty binary value"); return bin_open(state->bundle, tag, 0, NULL, "", comment, status); + } else { + return bin_open(state->bundle, tag, count, value.getAlias(), NULL, comment, status); } } @@ -1520,9 +1520,9 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr int32_t value; char *string; char *stopstring; - uint32_t len; - string = getInvariantString(state, NULL, NULL, status); + int32_t stringLength; + string = getInvariantString(state, NULL, NULL, stringLength, status); if (string == NULL || U_FAILURE(*status)) { @@ -1541,7 +1541,7 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr printf(" integer %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - if (uprv_strlen(string) <= 0) + if (stringLength == 0) { warning(startline, "Encountered empty integer. Default value is 0."); } @@ -1549,8 +1549,8 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr /* Allow integer support for hexdecimal, octal digit and decimal*/ /* and handle illegal char in the integer*/ value = uprv_strtoul(string, &stopstring, 0); - len=(uint32_t)(stopstring-string); - if(len==uprv_strlen(string)) + int32_t len = (int32_t)(stopstring-string); + if(len==stringLength) { result = int_open(state->bundle, tag, value, comment, status); } @@ -1567,7 +1567,8 @@ static struct SResource * parseImport(ParseState* state, char *tag, uint32_t startline, const struct UString* comment, UErrorCode *status) { uint32_t line; - LocalMemory filename(getInvariantString(state, &line, NULL, status)); + int32_t stringLength; + LocalMemory filename(getInvariantString(state, &line, NULL, stringLength, status)); if (U_FAILURE(*status)) { return NULL; @@ -1628,12 +1629,11 @@ parseInclude(ParseState* state, char *tag, uint32_t startline, const struct UStr UCHARBUF *ucbuf; char *fullname = NULL; - int32_t count = 0; const char* cp = NULL; const UChar* uBuffer = NULL; - filename = getInvariantString(state, &line, NULL, status); - count = (int32_t)uprv_strlen(filename); + int32_t stringLength; + filename = getInvariantString(state, &line, NULL, stringLength, status); if (U_FAILURE(*status)) { @@ -1652,7 +1652,7 @@ parseInclude(ParseState* state, char *tag, uint32_t startline, const struct UStr printf(" include %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - fullname = (char *) uprv_malloc(state->inputdirLength + count + 2); + fullname = (char *) uprv_malloc(state->inputdirLength + stringLength + 2); /* test for NULL */ if(fullname == NULL) { diff --git a/deps/icu-small/source/tools/genrb/prscmnts.cpp b/deps/icu-small/source/tools/genrb/prscmnts.cpp index 5d494cd9ad3f2b..5e44547ea1e816 100644 --- a/deps/icu-small/source/tools/genrb/prscmnts.cpp +++ b/deps/icu-small/source/tools/genrb/prscmnts.cpp @@ -43,9 +43,9 @@ const char *patternStrings[UPC_LIMIT]={ "^note\\s*(.*)" }; -U_CFUNC int32_t -removeText(UChar *source, int32_t srcLen, - UnicodeString patString,uint32_t options, +U_CFUNC int32_t +removeText(UChar *source, int32_t srcLen, + UnicodeString patString,uint32_t options, UnicodeString replaceText, UErrorCode *status){ if(status == NULL || U_FAILURE(*status)){ @@ -62,8 +62,8 @@ removeText(UChar *source, int32_t srcLen, dest = myMatcher.replaceAll(replaceText,*status); - - + + return dest.extract(source, srcLen, *status); } @@ -75,7 +75,7 @@ trim(UChar *src, int32_t srcLen, UErrorCode *status){ return srcLen; } -U_CFUNC int32_t +U_CFUNC int32_t removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status){ srcLen = trim(source, srcLen, status); UnicodeString patString("^\\s*?\\*\\s*?"); // remove pattern like " * " at the begining of the line @@ -83,12 +83,12 @@ removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status){ return removeText(source, srcLen, UnicodeString("[ \\r\\n]+"), 0, UnicodeString(" "), status);// remove new lines; } -U_CFUNC int32_t +U_CFUNC int32_t getText(const UChar* source, int32_t srcLen, UChar** dest, int32_t destCapacity, - UnicodeString patternString, + UnicodeString patternString, UErrorCode* status){ - + if(status == NULL || U_FAILURE(*status)){ return 0; } @@ -96,12 +96,12 @@ getText(const UChar* source, int32_t srcLen, UnicodeString stringArray[MAX_SPLIT_STRINGS]; RegexPattern *pattern = RegexPattern::compile(UnicodeString("@"), 0, *status); UnicodeString src (source,srcLen); - + if (U_FAILURE(*status)) { return 0; } pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status); - + RegexMatcher matcher(patternString, UREGEX_DOTALL, *status); if (U_FAILURE(*status)) { return 0; @@ -131,7 +131,7 @@ getDescription( const UChar* source, int32_t srcLen, UnicodeString stringArray[MAX_SPLIT_STRINGS]; RegexPattern *pattern = RegexPattern::compile(UnicodeString("@"), UREGEX_MULTILINE, *status); UnicodeString src(source, srcLen); - + if (U_FAILURE(*status)) { return 0; } @@ -145,9 +145,9 @@ getDescription( const UChar* source, int32_t srcLen, } U_CFUNC int32_t -getCount(const UChar* source, int32_t srcLen, +getCount(const UChar* source, int32_t srcLen, UParseCommentsOption option, UErrorCode *status){ - + if(status == NULL || U_FAILURE(*status)){ return 0; } @@ -161,12 +161,12 @@ getCount(const UChar* source, int32_t srcLen, return 0; } int32_t retLen = pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status); - + UnicodeString patternString(patternStrings[option]); RegexMatcher matcher(patternString, UREGEX_DOTALL, *status); if (U_FAILURE(*status)) { return 0; - } + } int32_t count = 0; for(int32_t i=0; isplit(src, stringArray, MAX_SPLIT_STRINGS, *status); - + UnicodeString patternString(patternStrings[option]); RegexMatcher matcher(patternString, UREGEX_DOTALL, *status); if (U_FAILURE(*status)) { return 0; - } + } int32_t count = 0; for(int32_t i=0; i=length) ? pad :length; - + /* Reverses the string */ for (j = 0; j < (num / 2); j++){ diff --git a/deps/icu-small/source/tools/genrb/read.c b/deps/icu-small/source/tools/genrb/read.c index c20b4510a28ac4..9135da248773ca 100644 --- a/deps/icu-small/source/tools/genrb/read.c +++ b/deps/icu-small/source/tools/genrb/read.c @@ -35,7 +35,7 @@ #define BADBOM 0xFFFE #define CR 0x000D #define LF 0x000A - + static int32_t lineCount; /* Protos */ @@ -187,7 +187,7 @@ static enum ETokenType getStringToken(UCHARBUF* buf, if(c == CR || c == LF){ isNLUnescaped = TRUE; } - } + } if(c==ESCAPE && !isFollowingCharEscaped){ isFollowingCharEscaped = TRUE; @@ -204,7 +204,7 @@ static enum ETokenType getStringToken(UCHARBUF* buf, isNLUnescaped = FALSE; } } - + if (U_FAILURE(*status)) { return TOK_ERROR; } @@ -218,7 +218,7 @@ static enum ETokenType getStringToken(UCHARBUF* buf, return TOK_ERROR; } } - + if(lastStringWasQuoted){ if(getShowWarning()){ warning(lineCount, "Mixing quoted and unquoted strings"); @@ -230,8 +230,8 @@ static enum ETokenType getStringToken(UCHARBUF* buf, } lastStringWasQuoted = FALSE; - - /* if we reach here we are mixing + + /* if we reach here we are mixing * quoted and unquoted strings * warn in normal mode and error in * pedantic mode @@ -251,7 +251,7 @@ static enum ETokenType getStringToken(UCHARBUF* buf, pTarget = target; ustr_uscat(token, pTarget,len, status); len=0; - + if (U_FAILURE(*status)) { return TOK_ERROR; } diff --git a/deps/icu-small/source/tools/genrb/reslist.cpp b/deps/icu-small/source/tools/genrb/reslist.cpp index bf57516047e901..3186c781e934f3 100644 --- a/deps/icu-small/source/tools/genrb/reslist.cpp +++ b/deps/icu-small/source/tools/genrb/reslist.cpp @@ -1371,7 +1371,7 @@ SRBRoot::compactKeys(UErrorCode &errorCode) { } int32_t keysCount = fUsePoolBundle->fKeysCount + fKeysCount; - if (U_FAILURE(errorCode) || fKeysCount == 0 || fKeyMap != NULL) { + if (U_FAILURE(errorCode) || fKeyMap != NULL) { return; } map = (KeyMapEntry *)uprv_malloc(keysCount * sizeof(KeyMapEntry)); diff --git a/deps/icu-small/source/tools/genrb/reslist.h b/deps/icu-small/source/tools/genrb/reslist.h index 34b710c4232670..07874fdbaa8785 100644 --- a/deps/icu-small/source/tools/genrb/reslist.h +++ b/deps/icu-small/source/tools/genrb/reslist.h @@ -124,7 +124,7 @@ struct SRBRoot { /* write a java resource file */ // TODO: C++ify -void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename, +void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename, int writtenFilenameLen, const char* packageName, const char* bundleName, UErrorCode *status); /* write a xml resource file */ @@ -219,7 +219,7 @@ struct SResource { /** * Applies the given filter with the given base path to this resource. * Removes child resources rejected by the filter recursively. - * + * * @param bundle Needed in order to access the key for this and child resources. */ virtual void applyFilter(const PathFilter& filter, ResKeyPath& path, const SRBRoot* bundle); diff --git a/deps/icu-small/source/tools/genrb/rle.c b/deps/icu-small/source/tools/genrb/rle.c index 08495c2b4f4666..279684aad03e4f 100644 --- a/deps/icu-small/source/tools/genrb/rle.c +++ b/deps/icu-small/source/tools/genrb/rle.c @@ -91,14 +91,14 @@ encodeRunByte(uint16_t* buffer,uint16_t* bufLimit, uint8_t value, int32_t length return buffer; } -#define APPEND( buffer, bufLimit, value, num, status){ \ +#define APPEND( buffer, bufLimit, value, num, status) UPRV_BLOCK_MACRO_BEGIN { \ if(bufferfCapacity < (dst->fLength + n)) { ustr_resize(dst, ALLOCATION(dst->fLength + n), status); if(U_FAILURE(*status)) return; } - + uprv_memcpy(dst->fChars + dst->fLength, src->fChars, sizeof(UChar) * n); dst->fLength += src->fLength; @@ -165,7 +165,7 @@ ustr_ucat(struct UString *dst, dst->fLength += 1; dst->fChars[dst->fLength] = 0x0000; } -U_CFUNC void +U_CFUNC void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status){ if(c > 0x10FFFF){ *status = U_ILLEGAL_CHAR_FOUND; @@ -183,7 +183,7 @@ ustr_uscat(struct UString *dst, const UChar* src,int len, UErrorCode *status) { - if(U_FAILURE(*status)) + if(U_FAILURE(*status)) return; if(dst->fCapacity < (dst->fLength + len)) { diff --git a/deps/icu-small/source/tools/genrb/ustr.h b/deps/icu-small/source/tools/genrb/ustr.h index 91483d1f0fc0a5..8a69e9d4d5cb98 100644 --- a/deps/icu-small/source/tools/genrb/ustr.h +++ b/deps/icu-small/source/tools/genrb/ustr.h @@ -22,7 +22,7 @@ #include "unicode/utypes.h" -#define U_APPEND_CHAR32(c,target,len) { \ +#define U_APPEND_CHAR32(c,target,len) UPRV_BLOCK_MACRO_BEGIN { \ if (c <= 0xffff) \ { \ *(target)++ = (UChar) c; \ @@ -35,9 +35,9 @@ len=2; \ target +=2; \ } \ -} +} UPRV_BLOCK_MACRO_END -#define U_APPEND_CHAR32_ONLY(c,target) { \ +#define U_APPEND_CHAR32_ONLY(c,target) UPRV_BLOCK_MACRO_BEGIN { \ if (c <= 0xffff) \ { \ *(target)++ = (UChar) c; \ @@ -48,7 +48,7 @@ target[1] = U16_TRAIL(c); \ target +=2; \ } \ -} +} UPRV_BLOCK_MACRO_END /* A C representation of a string "object" (to avoid realloc all the time) */ struct UString { diff --git a/deps/icu-small/source/tools/pkgdata/pkgdata.cpp b/deps/icu-small/source/tools/pkgdata/pkgdata.cpp index 9d512a3ae5b628..1f318ac0f3a31a 100644 --- a/deps/icu-small/source/tools/pkgdata/pkgdata.cpp +++ b/deps/icu-small/source/tools/pkgdata/pkgdata.cpp @@ -122,8 +122,9 @@ enum { QUIET, WITHOUT_ASSEMBLY, PDS_BUILD, - UWP_BUILD, - UWP_ARM_BUILD + WIN_UWP_BUILD, + WIN_DLL_ARCH, + WIN_DYNAMICBASE }; /* This sets the modes that are available */ @@ -167,7 +168,8 @@ static UOption options[]={ /*20*/ UOPTION_DEF( "without-assembly", 'w', UOPT_NO_ARG), /*21*/ UOPTION_DEF("zos-pds-build", 'z', UOPT_NO_ARG), /*22*/ UOPTION_DEF("windows-uwp-build", 'u', UOPT_NO_ARG), - /*23*/ UOPTION_DEF("windows-uwp-arm-build", 'a', UOPT_NO_ARG) + /*23*/ UOPTION_DEF("windows-DLL-arch", 'a', UOPT_REQUIRES_ARG), + /*24*/ UOPTION_DEF("windows-dynamicbase", 'b', UOPT_NO_ARG), }; /* This enum and the following char array should be kept in sync. */ @@ -258,7 +260,8 @@ const char options_help[][320]={ "Build the data without assembly code", "Build PDS dataset (zOS build only)", "Build for Universal Windows Platform (Windows build only)", - "Set DLL machine type for UWP to target windows ARM (Windows UWP build only)" + "Specify the DLL machine architecture for LINK.exe (Windows build only)", + "Ignored. Enable DYNAMICBASE on the DLL. This is now the default. (Windows build only)", }; const char *progname = "PKGDATA"; @@ -468,6 +471,10 @@ main(int argc, char* argv[]) { #endif } + if (options[WIN_DYNAMICBASE].doesOccur) { + fprintf(stdout, "Note: Ignoring option -b (windows-dynamicbase).\n"); + } + /* OK options are set up. Now the file lists. */ tail = NULL; for( n=1; nshortName); } - + if(o->verbose) { fprintf(stdout, "# Install: Files mode, copying files to %s..\n", targetDir); } @@ -713,12 +720,18 @@ static int32_t pkg_executeOptions(UPKGOptions *o) { if(o->verbose) { fprintf(stdout, "# Generating assembly code %s of type %s ..\n", gencFilePath, genccodeAssembly); } - + /* Offset genccodeAssembly by 3 because "-a " */ if (genccodeAssembly && (uprv_strlen(genccodeAssembly)>3) && checkAssemblyHeaderName(genccodeAssembly+3)) { - writeAssemblyCode(datFileNamePath, o->tmpDir, o->entryName, NULL, gencFilePath); + writeAssemblyCode( + datFileNamePath, + o->tmpDir, + o->entryName, + NULL, + gencFilePath, + sizeof(gencFilePath)); result = pkg_createWithAssemblyCode(targetDir, mode, gencFilePath); if (result != 0) { @@ -753,7 +766,14 @@ static int32_t pkg_executeOptions(UPKGOptions *o) { /* Try to detect the arch type, use NULL if unsuccessful */ char optMatchArch[10] = { 0 }; pkg_createOptMatchArch(optMatchArch); - writeObjectCode(datFileNamePath, o->tmpDir, o->entryName, (optMatchArch[0] == 0 ? NULL : optMatchArch), NULL, gencFilePath); + writeObjectCode( + datFileNamePath, + o->tmpDir, + o->entryName, + (optMatchArch[0] == 0 ? NULL : optMatchArch), + NULL, + gencFilePath, + sizeof(gencFilePath)); pkg_destroyOptMatchArch(optMatchArch); #if U_PLATFORM_IS_LINUX_BASED result = pkg_generateLibraryFile(targetDir, mode, gencFilePath); @@ -1027,7 +1047,7 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling) uprv_strcmp(libFileNames[LIB_FILE_VERSION], libFileNames[LIB_FILE_VERSION_MAJOR]) == 0) { return result; } - + sprintf(cmd, "cd %s && %s %s && %s %s %s", targetDir, RM_CMD, @@ -1291,18 +1311,18 @@ static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UB targetDir, libFileNames[LIB_FILE_VERSION_TMP]); - result = runCommand(cmd); - if (result != 0) { + result = runCommand(cmd); + if (result != 0) { fprintf(stderr, "Error creating archive library. Failed command: %s\n", cmd); - return result; - } - - sprintf(cmd, "%s %s%s", - pkgDataFlags[RANLIB], - targetDir, + return result; + } + + sprintf(cmd, "%s %s%s", + pkgDataFlags[RANLIB], + targetDir, libFileNames[LIB_FILE_VERSION]); - - result = runCommand(cmd); + + result = runCommand(cmd); if (result != 0) { fprintf(stderr, "Error creating archive library. Failed command: %s\n", cmd); return result; @@ -1367,11 +1387,11 @@ static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, c result = runCommand(cmd); if (result == 0) { - sprintf(cmd, "%s %s%s", - pkgDataFlags[RANLIB], - targetDir, - libFileNames[LIB_FILE_VERSION]); - + sprintf(cmd, "%s %s%s", + pkgDataFlags[RANLIB], + targetDir, + libFileNames[LIB_FILE_VERSION]); + result = runCommand(cmd); } } else /* if (IN_DLL_MODE(mode)) */ { @@ -1584,10 +1604,10 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD #ifdef USE_SINGLE_CCODE_FILE char icudtAll[SMALL_BUFFER_MAX_SIZE] = ""; FileStream *icudtAllFile = NULL; - + sprintf(icudtAll, "%s%s%sall.c", o->tmpDir, - PKGDATA_FILE_SEP_STRING, + PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE]); /* Remove previous icudtall.c file. */ if (T_FileStream_file_exists(icudtAll) && (result = remove(icudtAll)) != 0) { @@ -1628,18 +1648,18 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD #ifdef USE_SINGLE_CCODE_FILE uprv_strcpy(tempObjectFile, gencmnFile); tempObjectFile[uprv_strlen(tempObjectFile) - 1] = 'o'; - + sprintf(cmd, "%s %s -o %s %s", pkgDataFlags[COMPILER], pkgDataFlags[LIBFLAGS], tempObjectFile, gencmnFile); - + result = runCommand(cmd); if (result != 0) { break; } - + sprintf(buffer, "%s",tempObjectFile); #endif } else { @@ -1685,7 +1705,13 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD printf("# Generating %s \n", gencmnFile); } - writeCCode(file, o->tmpDir, dataName[0] != 0 ? dataName : o->shortName, newName[0] != 0 ? newName : NULL, gencmnFile); + writeCCode( + file, + o->tmpDir, + dataName[0] != 0 ? dataName : o->shortName, + newName[0] != 0 ? newName : NULL, + gencmnFile, + sizeof(gencmnFile)); #ifdef USE_SINGLE_CCODE_FILE sprintf(cmd, "#include \"%s\"\n", gencmnFile); @@ -1697,7 +1723,7 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD #ifndef USE_SINGLE_CCODE_FILE uprv_strcpy(tempObjectFile, gencmnFile); tempObjectFile[uprv_strlen(tempObjectFile) - 1] = 'o'; - + sprintf(cmd, "%s %s -o %s %s", pkgDataFlags[COMPILER], pkgDataFlags[LIBFLAGS], @@ -1713,7 +1739,7 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD uprv_strcat(buffer, tempObjectFile); #endif - + if (i > 0) { list = list->next; listNames = listNames->next; @@ -1730,7 +1756,7 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD pkgDataFlags[LIBFLAGS], tempObjectFile, icudtAll); - + result = runCommand(cmd); if (result == 0) { uprv_strcat(buffer, " "); @@ -1758,14 +1784,12 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD #ifdef WINDOWS_WITH_MSVC #define LINK_CMD "link.exe /nologo /release /out:" -#define LINK_FLAGS "/DLL /NOENTRY /MANIFEST:NO /implib:" -#ifdef _WIN64 -#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /DYNAMICBASE /APPCONTAINER " -#else -#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /SAFESEH /DYNAMICBASE /APPCONTAINER /MACHINE:X86" -#endif -#define LINK_EXTRA_UWP_FLAGS_ARM "/NXCOMPAT /DYNAMICBASE /APPCONTAINER /MACHINE:ARM" -#define LINK_EXTRA_NO_UWP_FLAGS "/base:0x4ad00000 " +#define LINK_FLAGS "/NXCOMPAT /DYNAMICBASE /DLL /NOENTRY /MANIFEST:NO /implib:" + +#define LINK_EXTRA_UWP_FLAGS "/APPCONTAINER " +#define LINK_EXTRA_UWP_FLAGS_X86_ONLY "/SAFESEH " + +#define LINK_EXTRA_FLAGS_MACHINE "/MACHINE:" #define LIB_CMD "LIB.exe /nologo /out:" #define LIB_FILE "icudt.lib" #define LIB_EXT UDATA_LIB_SUFFIX @@ -1814,7 +1838,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U #ifdef CYGWINMSVC uprv_strcat(libFilePath, o->libName); uprv_strcat(libFilePath, ".lib"); - + uprv_strcat(dllFilePath, o->libName); uprv_strcat(dllFilePath, o->version); #else @@ -1827,7 +1851,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U uprv_strcat(dllFilePath, o->entryName); #endif uprv_strcat(dllFilePath, DLL_EXT); - + uprv_strcpy(tmpResFilePath, o->tmpDir); uprv_strcat(tmpResFilePath, PKGDATA_FILE_SEP_STRING); uprv_strcat(tmpResFilePath, ICUDATA_RES_FILE); @@ -1845,23 +1869,23 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U return 0; } - char *extraFlags = ""; + char extraFlags[SMALL_BUFFER_MAX_SIZE] = ""; #ifdef WINDOWS_WITH_MSVC - if (options[UWP_BUILD].doesOccur) - { - if (options[UWP_ARM_BUILD].doesOccur) - { - extraFlags = LINK_EXTRA_UWP_FLAGS_ARM; - } - else - { - extraFlags = LINK_EXTRA_UWP_FLAGS; + if (options[WIN_UWP_BUILD].doesOccur) { + uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS); + + if (options[WIN_DLL_ARCH].doesOccur) { + if (uprv_strcmp(options[WIN_DLL_ARCH].value, "X86") == 0) { + uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS_X86_ONLY); + } } } - else - { - extraFlags = LINK_EXTRA_NO_UWP_FLAGS; + + if (options[WIN_DLL_ARCH].doesOccur) { + uprv_strcat(extraFlags, LINK_EXTRA_FLAGS_MACHINE); + uprv_strcat(extraFlags, options[WIN_DLL_ARCH].value); } + #endif sprintf(cmd, "%s\"%s\" %s %s\"%s\" \"%s\" %s", LINK_CMD, @@ -1976,9 +2000,9 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) { return NULL; } else { sprintf(tmpbuffer, "%s%s ", o->entryName, UDATA_CMN_INTERMEDIATE_SUFFIX); - + T_FileStream_writeLine(f, tmpbuffer); - + T_FileStream_close(f); } } @@ -2018,7 +2042,7 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) { #endif // Don't really need a return value, just need to stop compiler warnings about // the unused parameter 'o' on platforms where it is not otherwise used. - return o; + return o; } static void loadLists(UPKGOptions *o, UErrorCode *status) @@ -2152,7 +2176,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status) cmdBuf.append( U_FILE_SEP_STRING, status ); } cmdBuf.append( cmd, status ); - + if(verbose) { fprintf(stdout, "# Calling icu-config: %s\n", cmdBuf.data()); } diff --git a/deps/icu-small/source/tools/toolutil/dbgutil.cpp b/deps/icu-small/source/tools/toolutil/dbgutil.cpp index 29bab927535e78..a5a3f518bb67f1 100644 --- a/deps/icu-small/source/tools/toolutil/dbgutil.cpp +++ b/deps/icu-small/source/tools/toolutil/dbgutil.cpp @@ -113,7 +113,7 @@ U_CAPI int32_t U_EXPORT2 udbg_enumByString(UDebugEnumType type, const UnicodeSt } // from DataMap::utoi -U_CAPI int32_t +U_CAPI int32_t udbg_stoi(const UnicodeString &s) { char ch[256]; @@ -125,7 +125,7 @@ udbg_stoi(const UnicodeString &s) } -U_CAPI double +U_CAPI double udbg_stod(const UnicodeString &s) { char ch[256]; diff --git a/deps/icu-small/source/tools/toolutil/dbgutil.h b/deps/icu-small/source/tools/toolutil/dbgutil.h index 314a9ae885d5fa..43fe2171b4a84f 100644 --- a/deps/icu-small/source/tools/toolutil/dbgutil.h +++ b/deps/icu-small/source/tools/toolutil/dbgutil.h @@ -24,7 +24,7 @@ udbg_enumString(UDebugEnumType type, int32_t field); /** * @return enum offset, or UDBG_INVALID_ENUM on error - */ + */ U_CAPI int32_t U_EXPORT2 udbg_enumByString(UDebugEnumType type, const icu::UnicodeString& string); diff --git a/deps/icu-small/source/tools/toolutil/filestrm.cpp b/deps/icu-small/source/tools/toolutil/filestrm.cpp index a170c7b0f29e2e..a926848985a8e1 100644 --- a/deps/icu-small/source/tools/toolutil/filestrm.cpp +++ b/deps/icu-small/source/tools/toolutil/filestrm.cpp @@ -44,7 +44,7 @@ T_FileStream_open(const char* filename, const char* mode) U_CAPI FileStream* U_EXPORT2 T_FileStream_wopen(const wchar_t* filename, const wchar_t* mode) { - // TBD: _wfopen is believed to be MS-specific? + // TBD: _wfopen is believed to be MS-specific? #if U_PLATFORM_USES_ONLY_WIN32_API FILE* result = _wfopen(filename, mode); return (FileStream*)result; @@ -53,7 +53,7 @@ T_FileStream_wopen(const wchar_t* filename, const wchar_t* mode) char *fn, *md; FILE *result; - // convert from wchar_t to char + // convert from wchar_t to char fnMbsSize = wcstombs(NULL, filename, ((size_t)-1) >> 1); fn = (char*)uprv_malloc(fnMbsSize+2); wcstombs(fn, filename, fnMbsSize); @@ -182,7 +182,7 @@ T_FileStream_eof(FileStream* fileStream) } /* - Warning + Warning This function may not work consistently on all platforms (e.g. HP-UX, FreeBSD and MacOSX don't return an error when putc is used on a file opened as readonly) diff --git a/deps/icu-small/source/tools/toolutil/filetools.cpp b/deps/icu-small/source/tools/toolutil/filetools.cpp index 6e88c94b5200b5..0f0e9c59846774 100644 --- a/deps/icu-small/source/tools/toolutil/filetools.cpp +++ b/deps/icu-small/source/tools/toolutil/filetools.cpp @@ -65,7 +65,7 @@ isFileModTimeLater(const char *filePath, const char *checkAgainst, UBool isDir) if (U_FAILURE(status)) { fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, u_errorName(status)); return FALSE; - }; + } if ((subDirp = opendir(newpath.data())) != NULL) { /* If this new path is a directory, make a recursive call with the newpath. */ diff --git a/deps/icu-small/source/tools/toolutil/flagparser.cpp b/deps/icu-small/source/tools/toolutil/flagparser.cpp index c8d791c636d14a..464d6be9f52d3d 100644 --- a/deps/icu-small/source/tools/toolutil/flagparser.cpp +++ b/deps/icu-small/source/tools/toolutil/flagparser.cpp @@ -98,7 +98,7 @@ parseFlagsFile(const char *fileName, char **flagBuffer, int32_t flagBufferSize, uprv_free(buffer); T_FileStream_close(f); - + if (U_FAILURE(*status) && *status != U_BUFFER_OVERFLOW_ERROR) { return -1; } diff --git a/deps/icu-small/source/tools/toolutil/package.h b/deps/icu-small/source/tools/toolutil/package.h index 3263c84feb4c37..2c5bd169093340 100644 --- a/deps/icu-small/source/tools/toolutil/package.h +++ b/deps/icu-small/source/tools/toolutil/package.h @@ -199,3 +199,5 @@ class U_TOOLUTIL_API Package { U_NAMESPACE_END #endif + + diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp index 2a8425e334119e..3f71e00cb64154 100644 --- a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp +++ b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp @@ -48,6 +48,8 @@ #include "uoptions.h" #include "pkg_genc.h" #include "filetools.h" +#include "charstr.h" +#include "unicode/errorcode.h" #define MAX_COLUMN ((uint32_t)(0xFFFFFFFFU)) @@ -56,7 +58,15 @@ /* prototypes --------------------------------------------------------------- */ static void -getOutFilename(const char *inFilename, const char *destdir, char *outFilename, char *entryName, const char *newSuffix, const char *optFilename); +getOutFilename( + const char *inFilename, + const char *destdir, + char *outFilename, + int32_t outFilenameCapacity, + char *entryName, + int32_t entryNameCapacity, + const char *newSuffix, + const char *optFilename); static uint32_t write8(FileStream *out, uint8_t byte, uint32_t column); @@ -178,7 +188,7 @@ static const struct AssemblyType { "\t.type Drodata.rodata,@object\n" "\t.size Drodata.rodata,0\n" "\t.globl %s\n" - "\t.align 16\n" + "\t.align 16\n" "%s:\n", ".4byte ","",HEX_0X @@ -259,13 +269,21 @@ printAssemblyHeadersToStdErr(void) { } U_CAPI void U_EXPORT2 -writeAssemblyCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optFilename, char *outFilePath) { +writeAssemblyCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { uint32_t column = MAX_COLUMN; - char entry[64]; - uint32_t buffer[1024]; - char *bufferStr = (char *)buffer; + char entry[96]; + union { + uint32_t uint32s[1024]; + char chars[4096]; + } buffer; FileStream *in, *out; - size_t i, length; + size_t i, length, count; in=T_FileStream_open(filename, "rb"); if(in==NULL) { @@ -273,15 +291,27 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr exit(U_FILE_ACCESS_ERROR); } - getOutFilename(filename, destdir, bufferStr, entry, ".S", optFilename); - out=T_FileStream_open(bufferStr, "w"); + getOutFilename( + filename, + destdir, + buffer.chars, + sizeof(buffer.chars), + entry, + sizeof(entry), + ".S", + optFilename); + out=T_FileStream_open(buffer.chars, "w"); if(out==NULL) { - fprintf(stderr, "genccode: unable to open output file %s\n", bufferStr); + fprintf(stderr, "genccode: unable to open output file %s\n", buffer.chars); exit(U_FILE_ACCESS_ERROR); } if (outFilePath != NULL) { - uprv_strcpy(outFilePath, bufferStr); + if (uprv_strlen(buffer.chars) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + uprv_strcpy(outFilePath, buffer.chars); } #if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN @@ -302,29 +332,42 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr } } - sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].header, + count = snprintf( + buffer.chars, sizeof(buffer.chars), + assemblyHeader[assemblyHeaderIndex].header, entry, entry, entry, entry, entry, entry, entry, entry); - T_FileStream_writeLine(out, bufferStr); + if (count >= sizeof(buffer.chars)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + T_FileStream_writeLine(out, buffer.chars); T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine); for(;;) { - memset(buffer, 0, sizeof(buffer)); - length=T_FileStream_read(in, buffer, sizeof(buffer)); + memset(buffer.uint32s, 0, sizeof(buffer.uint32s)); + length=T_FileStream_read(in, buffer.uint32s, sizeof(buffer.uint32s)); if(length==0) { break; } - for(i=0; i<(length/sizeof(buffer[0])); i++) { - column = write32(out, buffer[i], column); + for(i=0; i<(length/sizeof(buffer.uint32s[0])); i++) { + // TODO: What if the last read sees length not as a multiple of 4? + column = write32(out, buffer.uint32s[i], column); } } T_FileStream_writeLine(out, "\n"); - sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].footer, + count = snprintf( + buffer.chars, sizeof(buffer.chars), + assemblyHeader[assemblyHeaderIndex].footer, entry, entry, entry, entry, entry, entry, entry, entry); - T_FileStream_writeLine(out, bufferStr); + if (count >= sizeof(buffer.chars)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + T_FileStream_writeLine(out, buffer.chars); if(T_FileStream_error(in)) { fprintf(stderr, "genccode: file read error while generating from file %s\n", filename); @@ -341,11 +384,17 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr } U_CAPI void U_EXPORT2 -writeCCode(const char *filename, const char *destdir, const char *optName, const char *optFilename, char *outFilePath) { +writeCCode( + const char *filename, + const char *destdir, + const char *optName, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { uint32_t column = MAX_COLUMN; - char buffer[4096], entry[64]; + char buffer[4096], entry[96]; FileStream *in, *out; - size_t i, length; + size_t i, length, count; in=T_FileStream_open(filename, "rb"); if(in==NULL) { @@ -354,16 +403,35 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const } if(optName != NULL) { /* prepend 'icudt28_' */ - strcpy(entry, optName); - strcat(entry, "_"); + // +2 includes the _ and the NUL + if (uprv_strlen(optName) + 2 > sizeof(entry)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + strcpy(entry, optName); + strcat(entry, "_"); } else { - entry[0] = 0; + entry[0] = 0; } - getOutFilename(filename, destdir, buffer, entry+uprv_strlen(entry), ".c", optFilename); + getOutFilename( + filename, + destdir, + buffer, + sizeof(buffer), + entry + uprv_strlen(entry), + sizeof(entry) - uprv_strlen(entry), + ".c", + optFilename); + if (outFilePath != NULL) { + if (uprv_strlen(buffer) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } uprv_strcpy(outFilePath, buffer); } + out=T_FileStream_open(buffer, "w"); if(out==NULL) { fprintf(stderr, "genccode: unable to open output file %s\n", buffer); @@ -391,7 +459,7 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const magic numbers we must still use the initial double. [grhoten 4/24/2003] */ - sprintf(buffer, + count = snprintf(buffer, sizeof(buffer), "#ifndef IN_GENERATED_CCODE\n" "#define IN_GENERATED_CCODE\n" "#define U_DISABLE_RENAMING 1\n" @@ -403,6 +471,10 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const " const char *bytes; \n" "} %s={ 0.0, \n", entry); + if (count >= sizeof(buffer)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } T_FileStream_writeLine(out, buffer); for(;;) { @@ -418,7 +490,7 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const T_FileStream_writeLine(out, "\"\n};\nU_CDECL_END\n"); #else /* Function renaming shouldn't be done in data */ - sprintf(buffer, + count = snprintf(buffer, sizeof(buffer), "#ifndef IN_GENERATED_CCODE\n" "#define IN_GENERATED_CCODE\n" "#define U_DISABLE_RENAMING 1\n" @@ -430,6 +502,10 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const " uint8_t bytes[%ld]; \n" "} %s={ 0.0, {\n", (long)T_FileStream_size(in), entry); + if (count >= sizeof(buffer)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } T_FileStream_writeLine(out, buffer); for(;;) { @@ -583,66 +659,84 @@ write8str(FileStream *out, uint8_t byte, uint32_t column) { #endif static void -getOutFilename(const char *inFilename, const char *destdir, char *outFilename, char *entryName, const char *newSuffix, const char *optFilename) { +getOutFilename( + const char *inFilename, + const char *destdir, + char *outFilename, + int32_t outFilenameCapacity, + char *entryName, + int32_t entryNameCapacity, + const char *newSuffix, + const char *optFilename) { const char *basename=findBasename(inFilename), *suffix=uprv_strrchr(basename, '.'); + icu::CharString outFilenameBuilder; + icu::CharString entryNameBuilder; + icu::ErrorCode status; + /* copy path */ if(destdir!=NULL && *destdir!=0) { - do { - *outFilename++=*destdir++; - } while(*destdir!=0); - if(*(outFilename-1)!=U_FILE_SEP_CHAR) { - *outFilename++=U_FILE_SEP_CHAR; - } - inFilename=basename; + outFilenameBuilder.append(destdir, status); + outFilenameBuilder.ensureEndsWithFileSeparator(status); } else { - while(inFilename= outFilenameCapacity) { + fprintf(stderr, "genccode: output filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + + if (entryNameBuilder.length() >= entryNameCapacity) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + + uprv_strcpy(outFilename, outFilenameBuilder.data()); + uprv_strcpy(entryName, entryNameBuilder.data()); } #ifdef CAN_GENERATE_OBJECTS @@ -777,7 +871,14 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char } U_CAPI void U_EXPORT2 -writeObjectCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optMatchArch, const char *optFilename, char *outFilePath) { +writeObjectCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optMatchArch, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { /* common variables */ char buffer[4096], entry[96]={ 0 }; FileStream *in, *out; @@ -1061,8 +1162,21 @@ writeObjectCode(const char *filename, const char *destdir, const char *optEntryP } size=T_FileStream_size(in); - getOutFilename(filename, destdir, buffer, entry+entryOffset, newSuffix, optFilename); + getOutFilename( + filename, + destdir, + buffer, + sizeof(buffer), + entry + entryOffset, + sizeof(entry) - entryOffset, + newSuffix, + optFilename); + if (outFilePath != NULL) { + if (uprv_strlen(buffer) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } uprv_strcpy(outFilePath, buffer); } diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.h b/deps/icu-small/source/tools/toolutil/pkg_genc.h index 5039f27db5e030..47e8304a6890c5 100644 --- a/deps/icu-small/source/tools/toolutil/pkg_genc.h +++ b/deps/icu-small/source/tools/toolutil/pkg_genc.h @@ -75,12 +75,31 @@ U_INTERNAL UBool U_EXPORT2 checkAssemblyHeaderName(const char* optAssembly); U_INTERNAL void U_EXPORT2 -writeCCode(const char *filename, const char *destdir, const char *optName, const char *optFilename, char *outFilePath); +writeCCode( + const char *filename, + const char *destdir, + const char *optName, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); U_INTERNAL void U_EXPORT2 -writeAssemblyCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optFilename, char *outFilePath); +writeAssemblyCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); U_INTERNAL void U_EXPORT2 -writeObjectCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optMatchArch, const char *optFilename, char *outFilePath); +writeObjectCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optMatchArch, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); #endif diff --git a/deps/icu-small/source/tools/toolutil/pkgitems.cpp b/deps/icu-small/source/tools/toolutil/pkgitems.cpp index dd414c2f873e22..7b86c55fa423bf 100644 --- a/deps/icu-small/source/tools/toolutil/pkgitems.cpp +++ b/deps/icu-small/source/tools/toolutil/pkgitems.cpp @@ -126,7 +126,7 @@ class NativeItem { * assemble the target item name from the source item name, an ID * and a suffix */ -static void +static void makeTargetName(const char *itemName, const char *id, int32_t idLength, const char *suffix, char *target, int32_t capacity, UErrorCode *pErrorCode) { @@ -160,7 +160,7 @@ makeTargetName(const char *itemName, const char *id, int32_t idLength, const cha memcpy(target+treeLength+idLength, suffix, suffixLength+1); // +1 includes the terminating NUL } -static void +static void checkIDSuffix(const char *itemName, const char *id, int32_t idLength, const char *suffix, CheckDependency check, void *context, UErrorCode *pErrorCode) { @@ -172,7 +172,7 @@ checkIDSuffix(const char *itemName, const char *id, int32_t idLength, const char } /* assemble the target item name from the item's parent item name */ -static void +static void checkParent(const char *itemName, CheckDependency check, void *context, UErrorCode *pErrorCode) { const char *itemID, *parent, *parentLimit, *suffix; @@ -305,7 +305,8 @@ ures_enumDependencies(const char *itemName, break; } int32_t length; - const UChar *alias=res_getString(pResData, res, &length); + // No tracing: build tool + const UChar *alias=res_getStringNoTrace(pResData, res, &length); checkAlias(itemName, res, alias, length, useResSuffix, check, context, pErrorCode); } break; diff --git a/deps/icu-small/source/tools/toolutil/toolutil.cpp b/deps/icu-small/source/tools/toolutil/toolutil.cpp index 21dca7fe5d6a82..a035f2326a69a1 100644 --- a/deps/icu-small/source/tools/toolutil/toolutil.cpp +++ b/deps/icu-small/source/tools/toolutil/toolutil.cpp @@ -16,7 +16,7 @@ * created by: Markus W. Scherer * * 6/25/08 - Added Cygwin specific code in uprv_mkdir - Brian Rower -* +* * This file contains utility functions for ICU tools like genccode. */ @@ -85,7 +85,7 @@ static int32_t currentYear = -1; U_CAPI int32_t U_EXPORT2 getCurrentYear() { #if !UCONFIG_NO_FORMATTING - UErrorCode status=U_ZERO_ERROR; + UErrorCode status=U_ZERO_ERROR; UCalendar *cal = NULL; if(currentYear == -1) { @@ -227,7 +227,7 @@ uprv_getModificationDate(const char *pathname, UErrorCode *status) } // TODO: handle case where stat is not available struct stat st; - + if(stat(pathname,&st) != 0) { *status = U_FILE_ACCESS_ERROR; @@ -243,7 +243,7 @@ struct UToolMemory { char name[64]; int32_t capacity, maxCapacity, size, idx; void *array; - UAlignedMemory staticArray[1]; + alignas(max_align_t) char staticArray[1]; }; U_CAPI UToolMemory * U_EXPORT2 diff --git a/deps/icu-small/source/tools/toolutil/toolutil.h b/deps/icu-small/source/tools/toolutil/toolutil.h index be07787a9fa950..7ab665cf5068a6 100644 --- a/deps/icu-small/source/tools/toolutil/toolutil.h +++ b/deps/icu-small/source/tools/toolutil/toolutil.h @@ -81,13 +81,13 @@ findBasename(const char *filename); /** * Find the directory name of a pathname, that is, everything - * up to but not including the last file separator. + * up to but not including the last file separator. * * If successful, copies the directory name into the output buffer along with - * a terminating NULL. + * a terminating NULL. * * If there isn't a directory name in the path, it returns an empty string. - * @param path the full pathname to inspect. + * @param path the full pathname to inspect. * @param buffer the output buffer * @param bufLen the output buffer length * @param status error code- may return U_BUFFER_OVERFLOW_ERROR if bufLen is too small. diff --git a/deps/icu-small/source/tools/toolutil/ucbuf.cpp b/deps/icu-small/source/tools/toolutil/ucbuf.cpp index 9b5e615d258c92..d1d4043dd4a45f 100644 --- a/deps/icu-small/source/tools/toolutil/ucbuf.cpp +++ b/deps/icu-small/source/tools/toolutil/ucbuf.cpp @@ -64,7 +64,7 @@ ucbuf_autodetect_fs(FileStream* in, const char** cp, UConverter** conv, int32_t* numRead=T_FileStream_read(in, start, sizeof(start)); *cp = ucnv_detectUnicodeSignature(start, numRead, signatureLength, error); - + /* unread the bytes beyond what was consumed for U+FEFF */ T_FileStream_rewind(in); if (*signatureLength > 0) { @@ -94,7 +94,7 @@ ucbuf_autodetect_fs(FileStream* in, const char** cp, UConverter** conv, int32_t* } - return TRUE; + return TRUE; } static UBool ucbuf_isCPKnown(const char* cp){ if(ucnv_compareNames("UTF-8",cp)==0){ @@ -142,7 +142,7 @@ ucbuf_autodetect(const char* fileName, const char** cp,UConverter** conv, int32_ } /* open the file */ in= T_FileStream_open(fileName,"rb"); - + if(in == NULL){ *error=U_FILE_ACCESS_ERROR; return NULL; @@ -186,13 +186,13 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* error){ /* read the file */ inputRead=T_FileStream_read(buf->in,cbuf,cbufSize-offset); buf->remaining-=inputRead; - + }else{ cbufSize = T_FileStream_size(buf->in); cbuf = (char*)uprv_malloc(cbufSize); if (cbuf == NULL) { - *error = U_MEMORY_ALLOCATION_ERROR; - return NULL; + *error = U_MEMORY_ALLOCATION_ERROR; + return NULL; } inputRead= T_FileStream_read(buf->in,cbuf,cbufSize); buf->remaining-=inputRead; @@ -233,7 +233,7 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* error){ int32_t pos =0; /* use erro1 to preserve the error code */ UErrorCode error1 =U_ZERO_ERROR; - + if( buf->showWarning==TRUE){ fprintf(stderr,"\n###WARNING: Encountered abnormal bytes while" " converting input stream to target encoding: %s\n", @@ -422,7 +422,7 @@ ucbuf_getcx32(UCHARBUF* buf,UErrorCode* error) { char context[CONTEXT_LEN+1]; int32_t len = CONTEXT_LEN; if(length < len) { - len = length; + len = length; } context[len]= 0 ; /* null terminate the buffer */ u_UCharsToChars( buf->currentPos, context, len); @@ -449,7 +449,7 @@ ucbuf_getcx32(UCHARBUF* buf,UErrorCode* error) { U_CAPI UCHARBUF* U_EXPORT2 ucbuf_open(const char* fileName,const char** cp,UBool showWarning, UBool buffered, UErrorCode* error){ - FileStream* in = NULL; + FileStream* in = NULL; int32_t fileSize=0; const char* knownCp; if(error==NULL || U_FAILURE(*error)){ @@ -461,10 +461,10 @@ ucbuf_open(const char* fileName,const char** cp,UBool showWarning, UBool buffere } if (!uprv_strcmp(fileName, "-")) { in = T_FileStream_stdin(); - }else{ + }else{ in = T_FileStream_open(fileName, "rb"); } - + if(in!=NULL){ UCHARBUF* buf =(UCHARBUF*) uprv_malloc(sizeof(UCHARBUF)); fileSize = T_FileStream_size(in); @@ -494,7 +494,7 @@ ucbuf_open(const char* fileName,const char** cp,UBool showWarning, UBool buffere T_FileStream_close(in); return NULL; } - + if((buf->conv==NULL) && (buf->showWarning==TRUE)){ fprintf(stderr,"###WARNING: No converter defined. Using codepage of system.\n"); } @@ -502,7 +502,7 @@ ucbuf_open(const char* fileName,const char** cp,UBool showWarning, UBool buffere if(buf->isBuffered){ buf->bufCapacity=MAX_U_BUF; }else{ - buf->bufCapacity=buf->remaining+buf->signatureLength+1/*for terminating nul*/; + buf->bufCapacity=buf->remaining+buf->signatureLength+1/*for terminating nul*/; } buf->buffer=(UChar*) uprv_malloc(U_SIZEOF_UCHAR * buf->bufCapacity ); if (buf->buffer == NULL) { @@ -663,7 +663,7 @@ ucbuf_resolveFileName(const char* inputDir, const char* fileName, char* target, target[0] = '\0'; /* - * append the input dir to openFileName if the first char in + * append the input dir to openFileName if the first char in * filename is not file seperation char and the last char input directory is not '.'. * This is to support : * genrb -s. /home/icu/data @@ -685,7 +685,7 @@ ucbuf_resolveFileName(const char* inputDir, const char* fileName, char* target, *status = U_BUFFER_OVERFLOW_ERROR; return NULL; } - + uprv_strcpy(target, inputDir); } @@ -695,7 +695,7 @@ ucbuf_resolveFileName(const char* inputDir, const char* fileName, char* target, /* * Unicode TR 13 says any of the below chars is * a new line char in a readline function in addition - * to CR+LF combination which needs to be + * to CR+LF combination which needs to be * handled seperately */ static UBool ucbuf_isCharNewLine(UChar c){ @@ -732,7 +732,7 @@ ucbuf_readline(UCHARBUF* buf,int32_t* len,UErrorCode* err){ }else{ ucbuf_fillucbuf(buf,err); if(U_FAILURE(*err)){ - return NULL; + return NULL; } } /* @@ -761,7 +761,7 @@ ucbuf_readline(UCHARBUF* buf,int32_t* len,UErrorCode* err){ */ for(;;){ c = *temp++; - + if(buf->currentPos==buf->bufLimit){ return NULL; /* end of file is reached return NULL */ } diff --git a/deps/icu-small/source/tools/toolutil/ucbuf.h b/deps/icu-small/source/tools/toolutil/ucbuf.h index 48d41ef4cd2d95..116da37e9bc677 100644 --- a/deps/icu-small/source/tools/toolutil/ucbuf.h +++ b/deps/icu-small/source/tools/toolutil/ucbuf.h @@ -32,11 +32,11 @@ typedef struct UCHARBUF UCHARBUF; /** * End of file value */ -#define U_EOF 0xFFFFFFFF +#define U_EOF ((int32_t)0xFFFFFFFF) /** * Error value if a sequence cannot be unescaped */ -#define U_ERR 0xFFFFFFFE +#define U_ERR ((int32_t)0xFFFFFFFE) typedef struct ULine ULine; @@ -215,3 +215,4 @@ ucbuf_resolveFileName(const char* inputDir, const char* fileName, char* target, #endif #endif + diff --git a/deps/icu-small/source/tools/toolutil/ucm.h b/deps/icu-small/source/tools/toolutil/ucm.h index 3af939758552d7..04e6b2030def41 100644 --- a/deps/icu-small/source/tools/toolutil/ucm.h +++ b/deps/icu-small/source/tools/toolutil/ucm.h @@ -299,3 +299,4 @@ U_CDECL_END #endif #endif + diff --git a/deps/icu-small/source/tools/toolutil/ucmstate.cpp b/deps/icu-small/source/tools/toolutil/ucmstate.cpp index 206c2f172eb1c5..ed1afb918eb90f 100644 --- a/deps/icu-small/source/tools/toolutil/ucmstate.cpp +++ b/deps/icu-small/source/tools/toolutil/ucmstate.cpp @@ -1050,3 +1050,4 @@ ucm_countChars(UCMStates *states, return count; } #endif + diff --git a/deps/icu-small/source/tools/toolutil/unewdata.cpp b/deps/icu-small/source/tools/toolutil/unewdata.cpp index 22d8540881f454..32b615c39b8eb2 100644 --- a/deps/icu-small/source/tools/toolutil/unewdata.cpp +++ b/deps/icu-small/source/tools/toolutil/unewdata.cpp @@ -56,14 +56,14 @@ udata_create(const char *dir, const char *type, const char *name, *pErrorCode=U_MEMORY_ALLOCATION_ERROR; return NULL; } - + /* Check that the full path won't be too long */ length = 0; /* Start with nothing */ if(dir != NULL && *dir !=0) /* Add directory length if one was given */ { - length += static_cast(strlen(dir)); - - /* Add 1 if dir doesn't end with path sep */ + length += static_cast(strlen(dir)); + + /* Add 1 if dir doesn't end with path sep */ if (dir[strlen(dir) - 1]!= U_FILE_SEP_CHAR) { length++; } @@ -74,15 +74,15 @@ udata_create(const char *dir, const char *type, const char *name, length += static_cast(strlen(type)); } - + /* LDH buffer Length error check */ if(length > ((int32_t)sizeof(filename) - 1)) { - *pErrorCode = U_BUFFER_OVERFLOW_ERROR; - uprv_free(pData); + *pErrorCode = U_BUFFER_OVERFLOW_ERROR; + uprv_free(pData); return NULL; } - + /* open the output file */ if(dir!=NULL && *dir!=0) { /* if dir has a value, we prepend it to the filename */ char *p=filename+strlen(dir); @@ -273,3 +273,4 @@ udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length) { * End: * */ + diff --git a/deps/icu-small/source/tools/toolutil/uoptions.h b/deps/icu-small/source/tools/toolutil/uoptions.h index a7a2e96c61b19f..e6d5cbf9d4536f 100644 --- a/deps/icu-small/source/tools/toolutil/uoptions.h +++ b/deps/icu-small/source/tools/toolutil/uoptions.h @@ -130,7 +130,7 @@ struct UOption { * where the error was detected. * * The OS/400 compiler requires that argv either be "char* argv[]", - * or "const char* const argv[]", and it will not accept, + * or "const char* const argv[]", and it will not accept, * "const char* argv[]" as a definition for main(). * * @param argv This parameter is modified diff --git a/deps/icu-small/source/tools/toolutil/uparse.cpp b/deps/icu-small/source/tools/toolutil/uparse.cpp index a932c171246435..486fcc9a98530e 100644 --- a/deps/icu-small/source/tools/toolutil/uparse.cpp +++ b/deps/icu-small/source/tools/toolutil/uparse.cpp @@ -370,7 +370,7 @@ u_parseUTF8(const char *source, int32_t sLen, char *dest, int32_t destCapacity, if(sLen == -1) { sLen = (int32_t)strlen(source); } - + while(read < source+sLen) { sscanf(read, "%2x", &value); if(i < destCapacity) { diff --git a/deps/icu-small/source/tools/toolutil/writesrc.cpp b/deps/icu-small/source/tools/toolutil/writesrc.cpp index 1a1dd3964d34a2..10b4ad246f6e0e 100644 --- a/deps/icu-small/source/tools/toolutil/writesrc.cpp +++ b/deps/icu-small/source/tools/toolutil/writesrc.cpp @@ -211,7 +211,7 @@ usrc_writeUTrie2Struct(FILE *f, " %s+%ld,\n" /* data16 */ " NULL,\n", /* data32 */ indexName, - indexName, + indexName, (long)pTrie->indexLength); } else { /* 32-bit trie */ @@ -321,7 +321,7 @@ usrc_writeArrayOfMostlyInvChars(FILE *f, c=(uint8_t)p[i]; if(i>0) { /* Break long lines. Try to break at interesting places, to minimize revision diffs. */ - if( + if( /* Very long line. */ col>=32 || /* Long line, break after terminating NUL. */ diff --git a/deps/icu-small/source/tools/toolutil/xmlparser.cpp b/deps/icu-small/source/tools/toolutil/xmlparser.cpp index ae7ef170207cf5..a9650cc599927f 100644 --- a/deps/icu-small/source/tools/toolutil/xmlparser.cpp +++ b/deps/icu-small/source/tools/toolutil/xmlparser.cpp @@ -64,62 +64,62 @@ UXMLParser::UXMLParser(UErrorCode &status) : // This is a sloppy implementation - just look for the leading // allow for a possible leading BOM. mXMLDecl(UnicodeString("(?s)\\uFEFF?<\\?xml.+?\\?>", -1, US_INV), 0, status), - + // XML Comment production #15 // example: " // note, does not detect an illegal "--" within comments mXMLComment(UnicodeString("(?s)", -1, US_INV), 0, status), - + // XML Spaces // production [3] mXMLSP(UnicodeString(XML_SPACES "+", -1, US_INV), 0, status), - + // XML Doctype decl production #28 // example " // or " // TODO: we don't actually parse the DOCTYPE or internal subsets. // Some internal dtd subsets could confuse this simple-minded // attempt at skipping over them, specifically, occcurences - // of closeing square brackets. These could appear in comments, + // of closeing square brackets. These could appear in comments, // or in parameter entity declarations, for example. mXMLDoctype(UnicodeString( "(?s)|\\[.*?\\].*?>)", -1, US_INV ), 0, status), - + // XML PI production #16 // example " mXMLPI(UnicodeString("(?s)<\\?.+?\\?>", -1, US_INV), 0, status), - + // XML Element Start Productions #40, #41 // example // capture #1: the tag name // mXMLElemStart (UnicodeString("(?s)<(" XML_NAME ")" // match "", -1, US_INV), 0, status), // match " >" - + // XML Element End production #42 // example mXMLElemEnd (UnicodeString("", -1, US_INV), 0, status), - + // XML Element Empty production #44 // example mXMLElemEmpty (UnicodeString("(?s)<(" XML_NAME ")" // match "", -1, US_INV), 0, status), // match " />" - + // XMLCharData. Everything but '<'. Note that & will be dealt with later. mXMLCharData(UnicodeString("(?s)[^<]*", -1, US_INV), 0, status), // Attribute name = "value". XML Productions 10, 40/41 - // Capture group 1 is name, + // Capture group 1 is name, // 2 is the attribute value, including the quotes. // // Note that attributes are scanned twice. The first time is with @@ -313,7 +313,7 @@ UXMLParser::parseFile(const char *filename, UErrorCode &errorCode) { // reached end of file, convert once more to flush the converter flush=TRUE; } - }; + } exit: ucnv_close(cnv); @@ -501,8 +501,8 @@ UXMLParser::createElement(RegexMatcher &mEl, UErrorCode &status) { // that parsed the attribue, which couldn't conveniently strip them. attValue.remove(0,1); // one char from the beginning attValue.truncate(attValue.length()-1); // and one from the end. - - // XML Attribue value normalization. + + // XML Attribue value normalization. // This is one of the really screwy parts of the XML spec. // See http://www.w3.org/TR/2004/REC-xml11-20040204/#AVNormalize // Note that non-validating parsers must treat all entities as type CDATA @@ -569,7 +569,7 @@ UXMLParser::scanContent(UErrorCode &status) { // Normalize the new-lines. (Before char ref substitution) mNewLineNormalizer.reset(result); result = mNewLineNormalizer.replaceAll(fOneLF, status); - + // TODO: handle CDATA fPos = mXMLCharData.end(0, status); } @@ -824,3 +824,4 @@ UXMLElement::getChildElement(const UnicodeString &name) const { U_NAMESPACE_END #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ + diff --git a/deps/icu-small/source/tools/toolutil/xmlparser.h b/deps/icu-small/source/tools/toolutil/xmlparser.h index 72f7ec8fa84645..75c8ed7e53d690 100644 --- a/deps/icu-small/source/tools/toolutil/xmlparser.h +++ b/deps/icu-small/source/tools/toolutil/xmlparser.h @@ -137,7 +137,7 @@ class U_TOOLUTIL_API UXMLElement : public UObject { const UXMLParser *fParser; const UnicodeString *fName; // The tag name of this element (owned by the UXMLParser) - UnicodeString fContent; // The text content of this node. All element content is + UnicodeString fContent; // The text content of this node. All element content is // concatenated even when there are intervening nested elements // (which doesn't happen with most xml files we care about) // Sections of content containing only white space are dropped, diff --git a/tools/icu/current_ver.dep b/tools/icu/current_ver.dep index 2d467a6fd01e75..2980335bdd4b3b 100644 --- a/tools/icu/current_ver.dep +++ b/tools/icu/current_ver.dep @@ -1,6 +1,6 @@ [ { - "url": "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-src.tgz", - "md5": "a3d18213beec454e3cdec9a3116d6b05" + "url": "https://github.com/unicode-org/icu/releases/download/release-65-1/icu4c-65_1-src.tgz", + "md5": "d1ff436e26cabcb28e6cb383d32d1339" } ]