(uprv_strlen(LEGACY[i+1]));
+ newTagLength = replacementLen + tagLen - checkLegacyLen;
if (tagLen < newTagLength) {
uprv_free(tagBuf);
tagBuf = (char*)uprv_malloc(newTagLength + 1);
@@ -2111,16 +2077,16 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
t->buf = tagBuf;
tagLen = newTagLength;
}
- parsedLenDelta = checkGrandfatheredLen - replacementLen;
- uprv_strcpy(t->buf, GRANDFATHERED[i + 1]);
- if (checkGrandfatheredLen != tagLen) {
- uprv_strcpy(t->buf + replacementLen, tag + checkGrandfatheredLen);
+ parsedLenDelta = checkLegacyLen - replacementLen;
+ uprv_strcpy(t->buf, LEGACY[i + 1]);
+ if (checkLegacyLen != tagLen) {
+ uprv_strcpy(t->buf + replacementLen, tag + checkLegacyLen);
}
break;
}
}
- if (grandfatheredLen == 0) {
+ if (legacyLen == 0) {
for (i = 0; i < UPRV_LENGTHOF(REDUNDANT); i += 2) {
const char* redundantTag = REDUNDANT[i];
size_t redundantTagLen = uprv_strlen(redundantTag);
@@ -2440,10 +2406,8 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
return t.orphan();
}
-/**
-* Ticket #12705 - Turn optimization back on.
-*/
-#if (defined(_MSC_VER) && (_MSC_VER >= 1900) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190024210))
+// Ticket #12705 - Turn optimization back on.
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && (_MSC_VER < 1924)
#pragma optimize( "", on )
#endif
@@ -2608,8 +2572,8 @@ ultag_getPrivateUse(const ULanguageTag* langtag) {
#if 0
static const char*
-ultag_getGrandfathered(const ULanguageTag* langtag) {
- return langtag->grandfathered;
+ultag_getLegacy(const ULanguageTag* langtag) {
+ return langtag->legacy;
}
#endif
@@ -2720,14 +2684,17 @@ ulocimp_toLanguageTag(const char* localeID,
key = uenum_next(kwdEnum.getAlias(), &len, &tmpStatus);
if (len == 1 && *key == PRIVATEUSE) {
- char buf[ULOC_KEYWORD_AND_VALUES_CAPACITY];
- buf[0] = PRIVATEUSE;
- buf[1] = SEP;
- len = uloc_getKeywordValue(localeID, key, &buf[2], sizeof(buf) - 2, &tmpStatus);
+ icu::CharString buf;
+ {
+ icu::CharStringByteSink sink(&buf);
+ ulocimp_getKeywordValue(localeID, key, sink, &tmpStatus);
+ }
if (U_SUCCESS(tmpStatus)) {
- if (ultag_isPrivateuseValueSubtags(&buf[2], len)) {
+ if (ultag_isPrivateuseValueSubtags(buf.data(), buf.length())) {
/* return private use only tag */
- sink.Append(buf, len + 2);
+ static const char PREFIX[] = { PRIVATEUSE, SEP };
+ sink.Append(PREFIX, sizeof(PREFIX));
+ sink.Append(buf.data(), buf.length());
done = TRUE;
} else if (strict) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
diff --git a/deps/icu-small/source/common/ulocimp.h b/deps/icu-small/source/common/ulocimp.h
index 98b95dddfe75bc..a686759f32e3e1 100644
--- a/deps/icu-small/source/common/ulocimp.h
+++ b/deps/icu-small/source/common/ulocimp.h
@@ -13,6 +13,8 @@
#include "unicode/bytestream.h"
#include "unicode/uloc.h"
+#include "charstr.h"
+
/**
* Create an iterator over the specified keywords list
* @param keywordList double-null terminated list. Will be copied.
@@ -38,7 +40,7 @@ uloc_getTableStringWithFallback(
int32_t *pLength,
UErrorCode *pErrorCode);
-/*returns TRUE if a is an ID separator FALSE otherwise*/
+/*returns true if a is an ID separator false otherwise*/
#define _isIDSeparator(a) (a == '_' || a == '-')
U_CFUNC const char*
@@ -47,42 +49,55 @@ uloc_getCurrentCountryID(const char* oldID);
U_CFUNC const char*
uloc_getCurrentLanguageID(const char* oldID);
-U_CFUNC int32_t
+U_CFUNC void
+ulocimp_getKeywords(const char *localeID,
+ char prev,
+ icu::ByteSink& sink,
+ UBool valuesToo,
+ UErrorCode *status);
+
+icu::CharString U_EXPORT2
ulocimp_getLanguage(const char *localeID,
- char *language, int32_t languageCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_CFUNC int32_t
+icu::CharString U_EXPORT2
ulocimp_getScript(const char *localeID,
- char *script, int32_t scriptCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_CFUNC int32_t
+icu::CharString U_EXPORT2
ulocimp_getCountry(const char *localeID,
- char *country, int32_t countryCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getName(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getBaseName(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_canonicalize(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
+U_CAPI void U_EXPORT2
+ulocimp_getKeywordValue(const char* localeID,
+ const char* keywordName,
+ icu::ByteSink& sink,
+ UErrorCode* status);
+
/**
* Writes a well-formed language tag for this locale ID.
*
- * **Note**: When `strict` is FALSE, any locale fields which do not satisfy the
+ * **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
- * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the `err` if any locale
+ * true, this function sets U_ILLEGAL_ARGUMENT_ERROR to the `err` if any locale
* fields do not satisfy the BCP47 syntax requirement.
*
* @param localeID the input locale ID
@@ -96,7 +111,7 @@ ulocimp_canonicalize(const char* localeID,
*
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_toLanguageTag(const char* localeID,
icu::ByteSink& sink,
UBool strict,
@@ -107,13 +122,17 @@ ulocimp_toLanguageTag(const char* localeID,
* 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',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @param langtag the input BCP47 language tag.
* @param tagLen the length of langtag, or -1 to call uprv_strlen().
* @param sink the output sink receiving a locale ID for the
@@ -135,7 +154,7 @@ ulocimp_forLanguageTag(const char* langtag,
* Get the region to use for supplemental data lookup. Uses
* (1) any region specified by locale tag "rg"; if none then
* (2) any unicode_region_tag in the locale ID; if none then
- * (3) if inferRegion is TRUE, the region suggested by
+ * (3) if inferRegion is true, the region suggested by
* getLikelySubtags on the localeID.
* If no region is found, returns length 0.
*
@@ -143,7 +162,7 @@ ulocimp_forLanguageTag(const char* langtag,
* The complete locale ID (with keywords) from which
* to get the region to use for supplemental data.
* @param inferRegion
- * If TRUE, will try to infer region from localeID if
+ * If true, will try to infer region from localeID if
* no other region is found.
* @param region
* Buffer in which to put the region ID found; should
@@ -189,7 +208,7 @@ ulocimp_getRegionForSupplementalData(const char *localeID, UBool inferRegion,
* or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_addLikelySubtags(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
@@ -223,7 +242,7 @@ ulocimp_addLikelySubtags(const char* localeID,
* or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_minimizeSubtags(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
@@ -279,4 +298,10 @@ ulocimp_toBcpType(const char* key, const char* type, UBool* isKnownKey, UBool* i
U_CFUNC const char*
ulocimp_toLegacyType(const char* key, const char* type, UBool* isKnownKey, UBool* isSpecialType);
+/* Function for testing purpose */
+U_CAPI const char* const* ulocimp_getKnownCanonicalizedLocaleForTest(int32_t* length);
+
+// Return true if the value is already canonicalized.
+U_CAPI bool ulocimp_isCanonicalizedLocaleForTest(const char* localeName);
+
#endif
diff --git a/deps/icu-small/source/common/umutex.h b/deps/icu-small/source/common/umutex.h
index 7588bcc5d9aed6..57955353d0d6ff 100644
--- a/deps/icu-small/source/common/umutex.h
+++ b/deps/icu-small/source/common/umutex.h
@@ -262,13 +262,13 @@ class U_COMMON_API UMutex {
* the global ICU mutex. Recursive locks are an error
* and may cause a deadlock on some platforms.
*/
-U_INTERNAL void U_EXPORT2 umtx_lock(UMutex* mutex);
+U_CAPI void U_EXPORT2 umtx_lock(UMutex* mutex);
/* Unlock a mutex.
* @param mutex The given mutex to be unlocked. Pass NULL to specify
* the global ICU mutex.
*/
-U_INTERNAL void U_EXPORT2 umtx_unlock (UMutex* mutex);
+U_CAPI void U_EXPORT2 umtx_unlock (UMutex* mutex);
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/unicode/appendable.h b/deps/icu-small/source/common/unicode/appendable.h
index 4beacaf6583620..fc99254de14e58 100644
--- a/deps/icu-small/source/common/unicode/appendable.h
+++ b/deps/icu-small/source/common/unicode/appendable.h
@@ -45,7 +45,7 @@ class UnicodeString;
*
* The methods do not take UErrorCode parameters.
* If an error occurs (e.g., out-of-memory),
- * in addition to returning FALSE from failing operations,
+ * in addition to returning false from failing operations,
* the implementation must prevent unexpected behavior (e.g., crashes)
* from further calls and should make the error condition available separately
* (e.g., store a UErrorCode, make/keep a UnicodeString bogus).
@@ -62,7 +62,7 @@ class U_COMMON_API Appendable : public UObject {
/**
* Appends a 16-bit code unit.
* @param c code unit
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodeUnit(char16_t c) = 0;
@@ -71,7 +71,7 @@ class U_COMMON_API Appendable : public UObject {
* Appends a code point.
* The default implementation calls appendCodeUnit(char16_t) once or twice.
* @param c code point 0..0x10ffff
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodePoint(UChar32 c);
@@ -81,7 +81,7 @@ class U_COMMON_API Appendable : public UObject {
* The default implementation calls appendCodeUnit(char16_t) for each code unit.
* @param s string, must not be NULL if length!=0
* @param length string length, or -1 if NUL-terminated
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendString(const char16_t *s, int32_t length);
@@ -90,9 +90,9 @@ class U_COMMON_API Appendable : public UObject {
* Tells the object that the caller is going to append roughly
* appendCapacity char16_ts. A subclass might use this to pre-allocate
* a larger buffer if necessary.
- * The default implementation does nothing. (It always returns TRUE.)
+ * The default implementation does nothing. (It always returns true.)
* @param appendCapacity estimated number of char16_ts that will be appended
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
@@ -171,7 +171,7 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable {
/**
* Appends a 16-bit code unit to the string.
* @param c code unit
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodeUnit(char16_t c);
@@ -179,7 +179,7 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable {
/**
* Appends a code point to the string.
* @param c code point 0..0x10ffff
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodePoint(UChar32 c);
@@ -188,7 +188,7 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable {
* Appends a string to the UnicodeString.
* @param s string, must not be NULL if length!=0
* @param length string length, or -1 if NUL-terminated
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendString(const char16_t *s, int32_t length);
@@ -197,7 +197,7 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable {
* Tells the UnicodeString that the caller is going to append roughly
* appendCapacity char16_ts.
* @param appendCapacity estimated number of char16_ts that will be appended
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
diff --git a/deps/icu-small/source/common/unicode/brkiter.h b/deps/icu-small/source/common/unicode/brkiter.h
index b944497345479b..9bba5fcccc319d 100644
--- a/deps/icu-small/source/common/unicode/brkiter.h
+++ b/deps/icu-small/source/common/unicode/brkiter.h
@@ -564,7 +564,7 @@ class U_COMMON_API BreakIterator : public UObject {
* BreakIterator::createXXXInstance to avoid undefined behavior.
* @param key the registry key returned by a previous call to registerInstance
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the iterator for the key was successfully unregistered
+ * @return true if the iterator for the key was successfully unregistered
* @stable ICU 2.4
*/
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
@@ -655,7 +655,7 @@ class U_COMMON_API BreakIterator : public UObject {
inline UBool BreakIterator::isBufferClone()
{
- return FALSE;
+ return false;
}
#endif /* U_HIDE_DEPRECATED_API */
diff --git a/deps/icu-small/source/common/unicode/bytestream.h b/deps/icu-small/source/common/unicode/bytestream.h
index 33505a34299818..73d498397c744c 100644
--- a/deps/icu-small/source/common/unicode/bytestream.h
+++ b/deps/icu-small/source/common/unicode/bytestream.h
@@ -197,7 +197,7 @@ class U_COMMON_API CheckedArrayByteSink : public ByteSink {
* Returns the sink to its original state, without modifying the buffer.
* Useful for reusing both the buffer and the sink for multiple streams.
* Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
- * and Overflowed()=FALSE.
+ * and Overflowed()=false.
* @return *this
* @stable ICU 4.6
*/
@@ -236,7 +236,7 @@ class U_COMMON_API CheckedArrayByteSink : public ByteSink {
/**
* Returns true if any bytes were discarded, i.e., if there was an
* attempt to write more than 'capacity' bytes.
- * @return TRUE if more than 'capacity' bytes were Append()ed
+ * @return true if more than 'capacity' bytes were Append()ed
* @stable ICU 4.2
*/
UBool Overflowed() const { return overflowed_; }
diff --git a/deps/icu-small/source/common/unicode/bytestrie.h b/deps/icu-small/source/common/unicode/bytestrie.h
index 51405f64a10e64..85f802df420262 100644
--- a/deps/icu-small/source/common/unicode/bytestrie.h
+++ b/deps/icu-small/source/common/unicode/bytestrie.h
@@ -97,14 +97,13 @@ 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
+ * @stable ICU 65
*/
uint64_t getState64() const {
return (static_cast(remainingMatchLength_ + 2) << kState64RemainingShift) |
@@ -123,14 +122,13 @@ class U_COMMON_API BytesTrie : public UMemory {
* @see getState64
* @see resetToState
* @see reset
- * @draft ICU 65
+ * @stable 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
@@ -253,16 +251,16 @@ class U_COMMON_API BytesTrie : public UMemory {
/**
* Determines whether all byte sequences reachable from the current state
* map to the same value.
- * @param uniqueValue Receives the unique value, if this function returns TRUE.
+ * @param uniqueValue Receives the unique value, if this function returns true.
* (output-only)
- * @return TRUE if all byte sequences reachable from the current state
+ * @return true if all byte sequences reachable from the current state
* map to the same value.
* @stable ICU 4.8
*/
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
const uint8_t *pos=pos_;
// Skip the rest of a pending linear-match node.
- return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
+ return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, false, uniqueValue);
}
/**
@@ -321,7 +319,7 @@ class U_COMMON_API BytesTrie : public UMemory {
Iterator &reset();
/**
- * @return TRUE if there are more elements.
+ * @return true if there are more elements.
* @stable ICU 4.8
*/
UBool hasNext() const;
@@ -337,7 +335,7 @@ class U_COMMON_API BytesTrie : public UMemory {
* 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 TRUE if there is another element.
+ * @return true if there is another element.
* @stable ICU 4.8
*/
UBool next(UErrorCode &errorCode);
diff --git a/deps/icu-small/source/common/unicode/bytestriebuilder.h b/deps/icu-small/source/common/unicode/bytestriebuilder.h
index e58f18755ef959..eafe5a28c3ef05 100644
--- a/deps/icu-small/source/common/unicode/bytestriebuilder.h
+++ b/deps/icu-small/source/common/unicode/bytestriebuilder.h
@@ -101,9 +101,10 @@ class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
* Multiple calls to buildStringPiece() return StringPieces referring to the
* builder's same byte array, without rebuilding.
* If buildStringPiece() is called after build(), the trie will be
- * re-serialized into a new array.
- * If build() is called after buildStringPiece(), the trie object will become
- * the owner of the previously returned array.
+ * re-serialized into a new array (because build() passes on ownership).
+ * If build() is called after buildStringPiece(), the trie object returned
+ * by build() will become the owner of the underlying string for the
+ * previously returned StringPiece.
* After clear() has been called, a new array will be used as well.
* @param buildOption Build option, see UStringTrieBuildOption.
* @param errorCode Standard ICU error code. Its input value must
@@ -139,7 +140,7 @@ class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const;
- virtual UBool matchNodesCanHaveValues() const { return FALSE; }
+ virtual UBool matchNodesCanHaveValues() const { return false; }
virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
diff --git a/deps/icu-small/source/common/unicode/caniter.h b/deps/icu-small/source/common/unicode/caniter.h
index 87c946c2b4db56..8ba4cc7daad3c1 100644
--- a/deps/icu-small/source/common/unicode/caniter.h
+++ b/deps/icu-small/source/common/unicode/caniter.h
@@ -25,11 +25,11 @@
*/
/** Should permutation skip characters with combining class zero
- * Should be either TRUE or FALSE. This is a compile time option
+ * Should be either true or false. This is a compile time option
* @stable ICU 2.4
*/
#ifndef CANITER_SKIP_ZEROES
-#define CANITER_SKIP_ZEROES TRUE
+#define CANITER_SKIP_ZEROES true
#endif
U_NAMESPACE_BEGIN
diff --git a/deps/icu-small/source/common/unicode/chariter.h b/deps/icu-small/source/common/unicode/chariter.h
index 7e4f446bb0f8a8..f7ecd8e0036ce2 100644
--- a/deps/icu-small/source/common/unicode/chariter.h
+++ b/deps/icu-small/source/common/unicode/chariter.h
@@ -65,7 +65,7 @@ U_NAMESPACE_BEGIN
* check for the end of the iteration. When there are no more
* characters in the text object:
*
- * - The hasNext() function returns FALSE.
+ * - The hasNext() function returns false.
* - nextPostInc() and next32PostInc() return DONE
* when one attempts to read beyond the end of the text object.
*
@@ -165,11 +165,11 @@ class U_COMMON_API ForwardCharacterIterator : public UObject {
virtual UChar32 next32PostInc(void) = 0;
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* This is used with nextPostInc() or next32PostInc() in forward
* iteration.
- * @returns FALSE if there are no more code units or code points
+ * @returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* @stable ICU 2.0
*/
@@ -535,12 +535,12 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
virtual UChar32 previous32(void) = 0;
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* before the current position in the iteration range.
* This is used with previous() or previous32() in backward
* iteration.
- * @return FALSE if there are no more code units or code points
- * before the current position in the iteration range, return TRUE otherwise.
+ * @return false if there are no more code units or code points
+ * before the current position in the iteration range, return true otherwise.
* @stable ICU 2.0
*/
virtual UBool hasPrevious() = 0;
diff --git a/deps/icu-small/source/common/unicode/docmain.h b/deps/icu-small/source/common/unicode/docmain.h
index 2b38692997dd9a..14491494c5ca7a 100644
--- a/deps/icu-small/source/common/unicode/docmain.h
+++ b/deps/icu-small/source/common/unicode/docmain.h
@@ -53,10 +53,10 @@
*
* Architecture (User's Guide)
*
*
*
@@ -143,13 +143,18 @@
* icu::MessageFormat |
*
*
+ * List Formatting |
+ * ulistformatter.h |
+ * icu::ListFormatter |
+ *
+ *
* Number Formatting (includes currency and unit formatting) |
* unumberformatter.h, unum.h |
* icu::number::NumberFormatter (ICU 60+) or icu::NumberFormat (older versions) |
*
*
* Number Range Formatting (includes currency and unit ranges) |
- * (no C API) |
+ * unumberrangeformatter.h |
* icu::number::NumberRangeFormatter |
*
*
diff --git a/deps/icu-small/source/common/unicode/dtintrv.h b/deps/icu-small/source/common/unicode/dtintrv.h
index 325faa3ccb92cb..7932ea660fa4dd 100644
--- a/deps/icu-small/source/common/unicode/dtintrv.h
+++ b/deps/icu-small/source/common/unicode/dtintrv.h
@@ -106,14 +106,14 @@ class U_COMMON_API DateInterval : public UObject {
/**
* Equality operator.
- * @return TRUE if the two DateIntervals are the same
+ * @return true if the two DateIntervals are the same
* @stable ICU 4.0
*/
virtual UBool operator==(const DateInterval& other) const;
/**
* Non-equality operator
- * @return TRUE if the two DateIntervals are not the same
+ * @return true if the two DateIntervals are not the same
* @stable ICU 4.0
*/
inline UBool operator!=(const DateInterval& other) const;
diff --git a/deps/icu-small/source/common/unicode/edits.h b/deps/icu-small/source/common/unicode/edits.h
index c3ceaccb3b3802..bfa07fa6765b73 100644
--- a/deps/icu-small/source/common/unicode/edits.h
+++ b/deps/icu-small/source/common/unicode/edits.h
@@ -159,7 +159,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @param outErrorCode Set to an error code if it does not contain one already
* and an error occurred while recording edits.
* Otherwise unchanged.
- * @return TRUE if U_FAILURE(outErrorCode)
+ * @return true if U_FAILURE(outErrorCode)
* @stable ICU 59
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
@@ -171,7 +171,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
*/
int32_t lengthDelta() const { return delta; }
/**
- * @return TRUE if there are any change edits
+ * @return true if there are any change edits
* @stable ICU 59
*/
UBool hasChanges() const { return numChanges != 0; }
@@ -207,8 +207,8 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
*/
Iterator() :
array(nullptr), index(0), length(0),
- remaining(0), onlyChanges_(FALSE), coarse(FALSE),
- dir(0), changed(FALSE), oldLength_(0), newLength_(0),
+ remaining(0), onlyChanges_(false), coarse(false),
+ dir(0), changed(false), oldLength_(0), newLength_(0),
srcIndex(0), replIndex(0), destIndex(0) {}
/**
* Copy constructor.
@@ -226,7 +226,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @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 TRUE if there is another edit
+ * @return true if there is another edit
* @stable ICU 59
*/
UBool next(UErrorCode &errorCode) { return next(onlyChanges_, errorCode); }
@@ -247,11 +247,11 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @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 TRUE if the edit for the source index was found
+ * @return true if the edit for the source index was found
* @stable ICU 59
*/
UBool findSourceIndex(int32_t i, UErrorCode &errorCode) {
- return findIndex(i, TRUE, errorCode) == 0;
+ return findIndex(i, true, errorCode) == 0;
}
/**
@@ -270,11 +270,11 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @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 TRUE if the edit for the destination index was found
+ * @return true if the edit for the destination index was found
* @stable ICU 60
*/
UBool findDestinationIndex(int32_t i, UErrorCode &errorCode) {
- return findIndex(i, FALSE, errorCode) == 0;
+ return findIndex(i, false, errorCode) == 0;
}
/**
@@ -328,8 +328,8 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
/**
* Returns whether the edit currently represented by the iterator is a change edit.
*
- * @return TRUE if this edit replaces oldLength() units with newLength() different ones.
- * FALSE if oldLength units remain unchanged.
+ * @return true if this edit replaces oldLength() units with newLength() different ones.
+ * false if oldLength units remain unchanged.
* @stable ICU 59
*/
UBool hasChange() const { return changed; }
@@ -347,8 +347,8 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* {@link #destinationIndex}, or in the replacement string, which starts at
* {@link #replacementIndex}.
*
- * @return the number of units in the modified string, if hasChange() is TRUE.
- * Same as oldLength if hasChange() is FALSE.
+ * @return the number of units in the modified string, if hasChange() is true.
+ * Same as oldLength if hasChange() is false.
* @stable ICU 59
*/
int32_t newLength() const { return newLength_; }
@@ -436,7 +436,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @stable ICU 59
*/
Iterator getCoarseChangesIterator() const {
- return Iterator(array, length, TRUE, TRUE);
+ return Iterator(array, length, true, true);
}
/**
@@ -448,7 +448,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @stable ICU 59
*/
Iterator getCoarseIterator() const {
- return Iterator(array, length, FALSE, TRUE);
+ return Iterator(array, length, false, true);
}
/**
@@ -460,7 +460,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @stable ICU 59
*/
Iterator getFineChangesIterator() const {
- return Iterator(array, length, TRUE, FALSE);
+ return Iterator(array, length, true, false);
}
/**
@@ -471,7 +471,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory {
* @stable ICU 59
*/
Iterator getFineIterator() const {
- return Iterator(array, length, FALSE, FALSE);
+ return Iterator(array, length, false, false);
}
/**
diff --git a/deps/icu-small/source/common/unicode/filteredbrk.h b/deps/icu-small/source/common/unicode/filteredbrk.h
index 42936763259e2d..8b07e39ae12bb6 100644
--- a/deps/icu-small/source/common/unicode/filteredbrk.h
+++ b/deps/icu-small/source/common/unicode/filteredbrk.h
@@ -85,8 +85,8 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
* by the iterator.
* @param string the string to suppress, such as "Mr."
* @param status error code
- * @return returns TRUE if the string was not present and now added,
- * FALSE if the call was a no-op because the string was already being suppressed.
+ * @return returns true if the string was not present and now added,
+ * false if the call was a no-op because the string was already being suppressed.
* @stable ICU 56
*/
virtual UBool suppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0;
@@ -98,8 +98,8 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
* locale data which may be suppressing certain strings.
* @param string the exception to remove
* @param status error code
- * @return returns TRUE if the string was present and now removed,
- * FALSE if the call was a no-op because the string was not being suppressed.
+ * @return returns true if the string was present and now removed,
+ * false if the call was a no-op because the string was not being suppressed.
* @stable ICU 56
*/
virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0;
diff --git a/deps/icu-small/source/common/unicode/icudataver.h b/deps/icu-small/source/common/unicode/icudataver.h
index d5c728da880f8f..a82cb3d89d9d99 100644
--- a/deps/icu-small/source/common/unicode/icudataver.h
+++ b/deps/icu-small/source/common/unicode/icudataver.h
@@ -38,6 +38,6 @@
*
* @stable ICU 49
*/
-U_STABLE void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status);
+U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status);
#endif
diff --git a/deps/icu-small/source/common/unicode/icuplug.h b/deps/icu-small/source/common/unicode/icuplug.h
index 827cbe94b61cf8..2bd51ff8dfc050 100644
--- a/deps/icu-small/source/common/unicode/icuplug.h
+++ b/deps/icu-small/source/common/unicode/icuplug.h
@@ -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_CAPI void U_EXPORT2
uplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload);
/**
@@ -217,7 +217,7 @@ uplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload);
* @param level the level of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setPlugLevel(UPlugData *plug, UPlugLevel level);
/**
@@ -226,7 +226,7 @@ uplug_setPlugLevel(UPlugData *plug, UPlugLevel level);
* @return the level of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugLevel U_EXPORT2
+U_CAPI UPlugLevel U_EXPORT2
uplug_getPlugLevel(UPlugData *plug);
/**
@@ -236,7 +236,7 @@ uplug_getPlugLevel(UPlugData *plug);
* @return the lowest level of plug which can currently load
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugLevel U_EXPORT2
+U_CAPI UPlugLevel U_EXPORT2
uplug_getCurrentLevel(void);
@@ -245,7 +245,7 @@ uplug_getCurrentLevel(void);
* @return The error code of this plugin's load attempt.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UErrorCode U_EXPORT2
+U_CAPI UErrorCode U_EXPORT2
uplug_getPlugLoadStatus(UPlugData *plug);
/**
@@ -254,7 +254,7 @@ uplug_getPlugLoadStatus(UPlugData *plug);
* @param name the name of this plugin. The first UPLUG_NAME_MAX characters willi be copied into a new buffer.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setPlugName(UPlugData *plug, const char *name);
/**
@@ -263,7 +263,7 @@ uplug_setPlugName(UPlugData *plug, const char *name);
* @return the name of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getPlugName(UPlugData *plug);
/**
@@ -272,7 +272,7 @@ uplug_getPlugName(UPlugData *plug);
* @return the symbol name, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getSymbolName(UPlugData *plug);
/**
@@ -282,7 +282,7 @@ uplug_getSymbolName(UPlugData *plug);
* @return the library name, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getLibraryName(UPlugData *plug, UErrorCode *status);
/**
@@ -292,7 +292,7 @@ uplug_getLibraryName(UPlugData *plug, UErrorCode *status);
* @return the library, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_getLibrary(UPlugData *plug);
/**
@@ -301,7 +301,7 @@ uplug_getLibrary(UPlugData *plug);
* @return the context, or NULL if not set
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_getContext(UPlugData *plug);
/**
@@ -310,7 +310,7 @@ uplug_getContext(UPlugData *plug);
* @param context new context to set
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setContext(UPlugData *plug, void *context);
@@ -321,7 +321,7 @@ uplug_setContext(UPlugData *plug, void *context);
* @return configuration string, or else null.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getConfiguration(UPlugData *plug);
/**
@@ -339,7 +339,7 @@ uplug_getConfiguration(UPlugData *plug);
* @return the next oldest plugin, or NULL if no more.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_nextPlug(UPlugData *prior);
/**
@@ -354,7 +354,7 @@ uplug_nextPlug(UPlugData *prior);
* @return the new UPlugData associated with this plugin, or NULL if error.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UErrorCode *status);
@@ -368,7 +368,7 @@ uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UE
* @return the new UPlugData associated with this plugin, or NULL if error.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status);
/**
@@ -378,7 +378,7 @@ uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *conf
* @param status error result
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_removePlug(UPlugData *plug, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
diff --git a/deps/icu-small/source/common/unicode/idna.h b/deps/icu-small/source/common/unicode/idna.h
index 6dfcfe48db28f1..1305dc604842eb 100644
--- a/deps/icu-small/source/common/unicode/idna.h
+++ b/deps/icu-small/source/common/unicode/idna.h
@@ -95,7 +95,7 @@ class U_COMMON_API IDNA : public UObject {
/**
* Converts a single domain name label into its ASCII form for DNS lookup.
- * If any processing step fails, then info.hasErrors() will be TRUE and
+ * If any processing step fails, then info.hasErrors() will be true and
* the result might not be an ASCII string.
* The label might be modified according to the types of errors.
* Labels with severe errors will be left in (or turned into) their Unicode form.
@@ -119,7 +119,7 @@ class U_COMMON_API IDNA : public UObject {
/**
* Converts a single domain name label into its Unicode form for human-readable display.
- * If any processing step fails, then info.hasErrors() will be TRUE.
+ * If any processing step fails, then info.hasErrors() will be true.
* The label might be modified according to the types of errors.
*
* The UErrorCode indicates an error only in exceptional cases,
@@ -141,7 +141,7 @@ class U_COMMON_API IDNA : public UObject {
/**
* Converts a whole domain name into its ASCII form for DNS lookup.
- * If any processing step fails, then info.hasErrors() will be TRUE and
+ * If any processing step fails, then info.hasErrors() will be true and
* the result might not be an ASCII string.
* The domain name might be modified according to the types of errors.
* Labels with severe errors will be left in (or turned into) their Unicode form.
@@ -165,7 +165,7 @@ class U_COMMON_API IDNA : public UObject {
/**
* Converts a whole domain name into its Unicode form for human-readable display.
- * If any processing step fails, then info.hasErrors() will be TRUE.
+ * If any processing step fails, then info.hasErrors() will be true.
* The domain name might be modified according to the types of errors.
*
* The UErrorCode indicates an error only in exceptional cases,
@@ -273,10 +273,10 @@ class U_COMMON_API IDNAInfo : public UMemory {
* Constructor for stack allocation.
* @stable ICU 4.6
*/
- IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
+ IDNAInfo() : errors(0), labelErrors(0), isTransDiff(false), isBiDi(false), isOkBiDi(true) {}
/**
* Were there IDNA processing errors?
- * @return TRUE if there were processing errors
+ * @return true if there were processing errors
* @stable ICU 4.6
*/
UBool hasErrors() const { return errors!=0; }
@@ -288,7 +288,7 @@ class U_COMMON_API IDNAInfo : public UMemory {
*/
uint32_t getErrors() const { return errors; }
/**
- * Returns TRUE if transitional and nontransitional processing produce different results.
+ * Returns true if transitional and nontransitional processing produce different results.
* This is the case when the input label or domain name contains
* one or more deviation characters outside a Punycode label (see UTS #46).
*
@@ -297,7 +297,7 @@ class U_COMMON_API IDNAInfo : public UMemory {
* - With transitional processing, such characters are
* mapped (sharp s/sigma) or removed (joiner/nonjoiner).
*
- * @return TRUE if transitional and nontransitional processing produce different results
+ * @return true if transitional and nontransitional processing produce different results
* @stable ICU 4.6
*/
UBool isTransitionalDifferent() const { return isTransDiff; }
@@ -310,9 +310,9 @@ class U_COMMON_API IDNAInfo : public UMemory {
void reset() {
errors=labelErrors=0;
- isTransDiff=FALSE;
- isBiDi=FALSE;
- isOkBiDi=TRUE;
+ isTransDiff=false;
+ isBiDi=false;
+ isOkBiDi=true;
}
uint32_t errors, labelErrors;
diff --git a/deps/icu-small/source/common/unicode/localebuilder.h b/deps/icu-small/source/common/unicode/localebuilder.h
index c5836fe27021b3..27a894de101def 100644
--- a/deps/icu-small/source/common/unicode/localebuilder.h
+++ b/deps/icu-small/source/common/unicode/localebuilder.h
@@ -1,5 +1,5 @@
// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __LOCALEBUILDER_H__
#define __LOCALEBUILDER_H__
@@ -92,11 +92,12 @@ class U_COMMON_API LocaleBuilder : public UObject {
/**
* Resets the LocaleBuilder to match the provided
* [Unicode Locale Identifier](http://www.unicode.org/reports/tr35/tr35.html#unicode_locale_id) .
- * Discards the existing state. the empty string cause the builder to be
- * reset, like {@link #clear}. Grandfathered tags are converted to their
- * canonical form before being processed. Otherwise, the language
- * tag
must be well-formed, or else the build() method will later
- * report an U_ILLEGAL_ARGUMENT_ERROR.
+ * Discards the existing state.
+ * The empty string causes the builder to be reset, like {@link #clear}.
+ * Legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * are converted to their canonical form before being processed.
+ * Otherwise, the language tag
must be well-formed,
+ * or else the build() method will later report an U_ILLEGAL_ARGUMENT_ERROR.
*
* This method clears the internal UErrorCode.
*
@@ -278,18 +279,16 @@ 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
+ * @return true if U_FAILURE(outErrorCode)
+ * @stable ICU 65
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
-#endif /* U_HIDE_DRAFT_API */
private:
friend class LocaleMatcher::Result;
diff --git a/deps/icu-small/source/common/unicode/localematcher.h b/deps/icu-small/source/common/unicode/localematcher.h
index 2e1a7a349f3983..63a68b0b7fb3d3 100644
--- a/deps/icu-small/source/common/unicode/localematcher.h
+++ b/deps/icu-small/source/common/unicode/localematcher.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// localematcher.h
// created: 2019may08 Markus W. Scherer
@@ -20,26 +20,24 @@
* \brief C++ API: Locale matcher: User's desired locales vs. application's supported locales.
*/
-#ifndef U_FORCE_HIDE_DRAFT_API
-
/**
* Builder option for whether the language subtag or the script subtag is most important.
*
- * @see Builder#setFavorSubtag(ULocMatchFavorSubtag)
- * @draft ICU 65
+ * @see LocaleMatcher::Builder#setFavorSubtag(ULocMatchFavorSubtag)
+ * @stable ICU 65
*/
enum ULocMatchFavorSubtag {
/**
* Language differences are most important, then script differences, then region differences.
* (This is the default behavior.)
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_FAVOR_LANGUAGE,
/**
* Makes script differences matter relatively more than language differences.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_FAVOR_SCRIPT
};
@@ -51,14 +49,14 @@ typedef enum ULocMatchFavorSubtag ULocMatchFavorSubtag;
* Builder option for whether all desired locales are treated equally or
* earlier ones are preferred.
*
- * @see Builder#setDemotionPerDesiredLocale(ULocMatchDemotion)
- * @draft ICU 65
+ * @see LocaleMatcher::Builder#setDemotionPerDesiredLocale(ULocMatchDemotion)
+ * @stable ICU 65
*/
enum ULocMatchDemotion {
/**
* All desired locales are treated equally.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_DEMOTION_NONE,
/**
@@ -85,7 +83,7 @@ enum ULocMatchDemotion {
* this is possible in future versions of the data.)
*
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_DEMOTION_REGION
};
@@ -93,6 +91,8 @@ enum ULocMatchDemotion {
typedef enum ULocMatchDemotion ULocMatchDemotion;
#endif
+#ifndef U_FORCE_HIDE_DRAFT_API
+
/**
* Builder option for whether to include or ignore one-way (fallback) match data.
* The LocaleMatcher uses CLDR languageMatch data which includes fallback (oneway=true) entries.
@@ -107,7 +107,7 @@ typedef enum ULocMatchDemotion ULocMatchDemotion;
* if there is a decent match for the original UI language, we want to use it,
* but not if it is merely a fallback.
*
- * @see Builder#setDirection(ULocMatchDirection)
+ * @see LocaleMatcher::Builder#setDirection(ULocMatchDirection)
* @draft ICU 67
*/
enum ULocMatchDirection {
@@ -129,6 +129,8 @@ enum ULocMatchDirection {
typedef enum ULocMatchDirection ULocMatchDirection;
#endif
+#endif // U_FORCE_HIDE_DRAFT_API
+
struct UHashtable;
U_NAMESPACE_BEGIN
@@ -181,7 +183,7 @@ class XLikelySubtags;
*
*
This class is not intended for public subclassing.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API LocaleMatcher : public UMemory {
public:
@@ -189,7 +191,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* Data for the best-matching pair of a desired and a supported locale.
* Movable but not copyable.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API Result : public UMemory {
public:
@@ -198,14 +200,14 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* This object will have the same contents that the source object had.
*
* @param src Result to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result(Result &&src) U_NOEXCEPT;
/**
* Destructor.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
~Result();
@@ -214,28 +216,27 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* This object will have the same contents that the source object had.
*
* @param src Result to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result &operator=(Result &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* 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
+ * @stable 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.
+ * The default locale is nullptr if Builder::setNoDefaultLocale() was called,
+ * or 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
+ * @stable ICU 65
*/
inline const Locale *getSupportedLocale() const { return supportedLocale; }
@@ -244,7 +245,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* -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
+ * @stable ICU 65
*/
inline int32_t getDesiredIndex() const { return desiredIndex; }
@@ -256,7 +257,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* -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
+ * @stable ICU 65
*/
inline int32_t getSupportedIndex() const { return supportedIndex; }
@@ -270,10 +271,9 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
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
+ * @stable ICU 65
*/
Locale makeResolvedLocale(UErrorCode &errorCode) const;
-#endif // U_HIDE_DRAFT_API
private:
Result(const Locale *desired, const Locale *supported,
@@ -298,8 +298,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* LocaleMatcher builder.
* Movable but not copyable.
*
- * @see LocaleMatcher#builder()
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API Builder : public UMemory {
public:
@@ -307,7 +306,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* Constructs a builder used in chaining parameters for building a LocaleMatcher.
*
* @return a new Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder() {}
@@ -316,14 +315,14 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* This builder will have the same contents that the source builder had.
*
* @param src Builder to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder(Builder &&src) U_NOEXCEPT;
/**
* Destructor.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
~Builder();
@@ -332,11 +331,10 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* This builder will have the same contents that the source builder had.
*
* @param src Builder to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &operator=(Builder &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* Parses an Accept-Language string
* (RFC 2616 Section 14.4),
@@ -346,7 +344,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
* @param locales the Accept-Language string of locales to set
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setSupportedLocalesFromListString(StringPiece locales);
@@ -357,7 +355,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
* @param locales the list of locale
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setSupportedLocales(Locale::Iterator &locales);
@@ -372,7 +370,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* @param begin Start of range.
* @param end Exclusive end of range.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
template
Builder &setSupportedLocales(Iter begin, Iter end) {
@@ -397,7 +395,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* @param end Exclusive end of range.
* @param converter Converter from *begin to const Locale & or compatible.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
template
Builder &setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter) {
@@ -415,17 +413,31 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
* @param locale another locale
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &addSupportedLocale(const Locale &locale);
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Sets no default locale.
+ * There will be no explicit or implicit default locale.
+ * If there is no good match, then the matcher will return nullptr for the
+ * best supported locale.
+ *
+ * @draft ICU 68
+ */
+ Builder &setNoDefaultLocale();
+#endif // U_HIDE_DRAFT_API
+
/**
* Sets the default locale; if nullptr, or if it is not set explicitly,
* then the first supported locale is used as the default locale.
+ * There is no default locale at all (nullptr will be returned instead)
+ * if setNoDefaultLocale() is called.
*
* @param defaultLocale the default locale (will be copied)
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setDefaultLocale(const Locale *defaultLocale);
@@ -437,7 +449,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
* @param subtag the subtag to favor
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setFavorSubtag(ULocMatchFavorSubtag subtag);
@@ -447,10 +459,11 @@ class U_COMMON_API LocaleMatcher : public UMemory {
*
* @param demotion the demotion per desired locale to set.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setDemotionPerDesiredLocale(ULocMatchDemotion demotion);
+#ifndef U_HIDE_DRAFT_API
/**
* Option for whether to include or ignore one-way (fallback) match data.
* By default, they are included.
@@ -465,6 +478,32 @@ class U_COMMON_API LocaleMatcher : public UMemory {
}
return *this;
}
+#endif // U_HIDE_DRAFT_API
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Sets the maximum distance for an acceptable match.
+ * The matcher will return a match for a pair of locales only if
+ * they match at least as well as the pair given here.
+ *
+ * For example, setMaxDistance(en-US, en-GB) limits matches to ones where the
+ * (desired, support) locales have a distance no greater than a region subtag difference.
+ * This is much stricter than the CLDR default.
+ *
+ * The details of locale matching are subject to changes in
+ * CLDR data and in the algorithm.
+ * Specifying a maximum distance in relative terms via a sample pair of locales
+ * insulates from changes that affect all distance metrics similarly,
+ * but some changes will necessarily affect relative distances between
+ * different pairs of locales.
+ *
+ * @param desired the desired locale for distance comparison.
+ * @param supported the supported locale for distance comparison.
+ * @return this Builder object
+ * @draft ICU 68
+ */
+ Builder &setMaxDistance(const Locale &desired, const Locale &supported);
+#endif // U_HIDE_DRAFT_API
/**
* Sets the UErrorCode if an error occurred while setting parameters.
@@ -473,8 +512,8 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* @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
+ * @return true if U_FAILURE(outErrorCode)
+ * @stable ICU 65
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
@@ -485,11 +524,10 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* @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
+ * @return LocaleMatcher
+ * @stable ICU 65
*/
LocaleMatcher build(UErrorCode &errorCode) const;
-#endif // U_HIDE_DRAFT_API
private:
friend class LocaleMatcher;
@@ -505,8 +543,11 @@ class U_COMMON_API LocaleMatcher : public UMemory {
int32_t thresholdDistance_ = -1;
ULocMatchDemotion demotion_ = ULOCMATCH_DEMOTION_REGION;
Locale *defaultLocale_ = nullptr;
+ bool withDefault_ = true;
ULocMatchFavorSubtag favor_ = ULOCMATCH_FAVOR_LANGUAGE;
ULocMatchDirection direction_ = ULOCMATCH_DIRECTION_WITH_ONE_WAY;
+ Locale *maxDistanceDesired_ = nullptr;
+ Locale *maxDistanceSupported_ = nullptr;
};
// FYI No public LocaleMatcher constructors in C++; use the Builder.
@@ -515,13 +556,13 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT;
/**
* Destructor.
- * @draft ICU 65
+ * @stable ICU 65
*/
~LocaleMatcher();
@@ -531,11 +572,10 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* The behavior is undefined if *this and src are the same object.
* @param src source matcher
* @return *this
- * @draft ICU 65
+ * @stable ICU 65
*/
LocaleMatcher &operator=(LocaleMatcher &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* Returns the supported locale which best matches the desired locale.
*
@@ -544,7 +584,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
const Locale *getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const;
@@ -556,7 +596,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
const Locale *getBestMatch(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const;
@@ -572,7 +612,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
const Locale *getBestMatchForListString(StringPiece desiredLocaleList, UErrorCode &errorCode) const;
@@ -586,7 +626,7 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
Result getBestMatchResult(const Locale &desiredLocale, UErrorCode &errorCode) const;
@@ -600,9 +640,25 @@ class U_COMMON_API LocaleMatcher : public UMemory {
* 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
+ * @stable ICU 65
*/
Result getBestMatchResult(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const;
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns true if the pair of locales matches acceptably.
+ * This is influenced by Builder options such as setDirection(), setFavorSubtag(),
+ * and setMaxDistance().
+ *
+ * @param desired The desired locale.
+ * @param supported The 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 true if the pair of locales matches acceptably.
+ * @draft ICU 68
+ */
+ UBool isMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const;
#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_INTERNAL_API
@@ -660,6 +716,5 @@ class U_COMMON_API LocaleMatcher : public UMemory {
U_NAMESPACE_END
-#endif // U_FORCE_HIDE_DRAFT_API
#endif // U_SHOW_CPLUSPLUS_API
#endif // __LOCALEMATCHER_H__
diff --git a/deps/icu-small/source/common/unicode/localpointer.h b/deps/icu-small/source/common/unicode/localpointer.h
index 61c3020918e578..2a65f2d382d2d8 100644
--- a/deps/icu-small/source/common/unicode/localpointer.h
+++ b/deps/icu-small/source/common/unicode/localpointer.h
@@ -88,13 +88,13 @@ class LocalPointerBase {
~LocalPointerBase() { /* delete ptr; */ }
/**
* NULL check.
- * @return TRUE if ==NULL
+ * @return true if ==NULL
* @stable ICU 4.4
*/
UBool isNull() const { return ptr==NULL; }
/**
* NULL check.
- * @return TRUE if !=NULL
+ * @return true if !=NULL
* @stable ICU 4.4
*/
UBool isValid() const { return ptr!=NULL; }
diff --git a/deps/icu-small/source/common/unicode/locid.h b/deps/icu-small/source/common/unicode/locid.h
index ee8697b0a57f3e..877c8014b0b3a7 100644
--- a/deps/icu-small/source/common/unicode/locid.h
+++ b/deps/icu-small/source/common/unicode/locid.h
@@ -253,7 +253,7 @@ class U_COMMON_API Locale : public UObject {
/**
* Construct a locale from language, country, variant.
* If an error occurs, then the constructed object will be "bogus"
- * (isBogus() will return TRUE).
+ * (isBogus() will return true).
*
* @param language Lowercase two-letter or three-letter ISO-639 code.
* This parameter can instead be an ICU style C locale (e.g. "en_US"),
@@ -393,13 +393,17 @@ class U_COMMON_API Locale : public UObject {
* 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',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @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.
@@ -795,14 +799,14 @@ class U_COMMON_API Locale : public UObject {
/**
* Returns whether this locale's script is written right-to-left.
* If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
- * If no likely script is known, then FALSE is returned.
+ * If no likely script is known, then false is returned.
*
* A script is right-to-left according to the CLDR script metadata
* which corresponds to whether the script's letters have Bidi_Class=R or AL.
*
- * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
+ * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl".
*
- * @return TRUE if the locale's script is written right-to-left
+ * @return true if the locale's script is written right-to-left
* @stable ICU 54
*/
UBool isRightToLeft() const;
@@ -956,7 +960,7 @@ class U_COMMON_API Locale : public UObject {
/**
* Gets the bogus state. Locale object can be bogus if it doesn't exist
- * @return FALSE if it is a real locale, TRUE if it is a bogus locale
+ * @return false if it is a real locale, true if it is a bogus locale
* @stable ICU 2.1
*/
inline UBool isBogus(void) const;
@@ -1005,32 +1009,31 @@ 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
+ * @stable ICU 65
*/
class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ {
public:
- /** @draft ICU 65 */
+ /** @stable ICU 65 */
virtual ~Iterator();
/**
- * @return TRUE if next() can be called again.
- * @draft ICU 65
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
virtual UBool hasNext() const = 0;
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
virtual const Locale &next() = 0;
};
/**
* A generic Locale iterator implementation over Locale input iterators.
- * @draft ICU 65
+ * @stable ICU 65
*/
template
class RangeIterator : public Iterator, public UMemory {
@@ -1042,19 +1045,19 @@ class U_COMMON_API Locale : public UObject {
*
* @param begin Start of range.
* @param end Exclusive end of range.
- * @draft ICU 65
+ * @stable ICU 65
*/
RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {}
/**
- * @return TRUE if next() can be called again.
- * @draft ICU 65
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
UBool hasNext() const override { return it_ != end_; }
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale &next() override { return *it_++; }
@@ -1066,7 +1069,7 @@ class U_COMMON_API Locale : public UObject {
/**
* A generic Locale iterator implementation over Locale input iterators.
* Calls the converter to convert each *begin to a const Locale &.
- * @draft ICU 65
+ * @stable ICU 65
*/
template
class ConvertingIterator : public Iterator, public UMemory {
@@ -1079,20 +1082,20 @@ class U_COMMON_API Locale : public UObject {
* @param begin Start of range.
* @param end Exclusive end of range.
* @param converter Converter from *begin to const Locale & or compatible.
- * @draft ICU 65
+ * @stable 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
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
UBool hasNext() const override { return it_ != end_; }
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale &next() override { return converter_(*it_++); }
@@ -1101,7 +1104,6 @@ class U_COMMON_API Locale : public UObject {
const Iter end_;
Conv converter_;
};
-#endif // U_HIDE_DRAFT_API
protected: /* only protected for testing purposes. DO NOT USE. */
#ifndef U_HIDE_INTERNAL_API
diff --git a/deps/icu-small/source/common/unicode/messagepattern.h b/deps/icu-small/source/common/unicode/messagepattern.h
index 04f00a8757d783..98e7b70b1fcc13 100644
--- a/deps/icu-small/source/common/unicode/messagepattern.h
+++ b/deps/icu-small/source/common/unicode/messagepattern.h
@@ -265,7 +265,7 @@ typedef enum UMessagePatternArgType UMessagePatternArgType;
/**
* \def UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE
- * Returns TRUE if the argument type has a plural style part sequence and semantics,
+ * Returns true if the argument type has a plural style part sequence and semantics,
* for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_SELECTORDINAL.
* @stable ICU 50
*/
@@ -523,14 +523,14 @@ class U_COMMON_API MessagePattern : public UObject {
/**
* @param other another object to compare with.
- * @return TRUE if this object is equivalent to the other one.
+ * @return true if this object is equivalent to the other one.
* @stable ICU 4.8
*/
UBool operator==(const MessagePattern &other) const;
/**
* @param other another object to compare with.
- * @return FALSE if this object is equivalent to the other one.
+ * @return false if this object is equivalent to the other one.
* @stable ICU 4.8
*/
inline UBool operator!=(const MessagePattern &other) const {
@@ -564,7 +564,7 @@ class U_COMMON_API MessagePattern : public UObject {
/**
* Does the parsed pattern have named arguments like {first_name}?
- * @return TRUE if the parsed pattern has at least one named argument.
+ * @return true if the parsed pattern has at least one named argument.
* @stable ICU 4.8
*/
UBool hasNamedArguments() const {
@@ -573,7 +573,7 @@ class U_COMMON_API MessagePattern : public UObject {
/**
* Does the parsed pattern have numbered arguments like {2}?
- * @return TRUE if the parsed pattern has at least one numbered argument.
+ * @return true if the parsed pattern has at least one numbered argument.
* @stable ICU 4.8
*/
UBool hasNumberedArguments() const {
@@ -664,7 +664,7 @@ class U_COMMON_API MessagePattern : public UObject {
* Compares the part's substring with the input string s.
* @param part a part of this MessagePattern.
* @param s a string.
- * @return TRUE if getSubstring(part).equals(s).
+ * @return true if getSubstring(part).equals(s).
* @stable ICU 4.8
*/
UBool partSubstringMatches(const Part &part, const UnicodeString &s) const {
@@ -785,7 +785,7 @@ class U_COMMON_API MessagePattern : public UObject {
* Indicates whether the Part type has a numeric value.
* If so, then that numeric value can be retrieved via MessagePattern.getNumericValue().
* @param type The Part type to be tested.
- * @return TRUE if the Part type has a numeric value.
+ * @return true if the Part type has a numeric value.
* @stable ICU 4.8
*/
static UBool hasNumericValue(UMessagePatternPartType type) {
@@ -794,14 +794,14 @@ class U_COMMON_API MessagePattern : public UObject {
/**
* @param other another object to compare with.
- * @return TRUE if this object is equivalent to the other one.
+ * @return true if this object is equivalent to the other one.
* @stable ICU 4.8
*/
UBool operator==(const Part &other) const;
/**
* @param other another object to compare with.
- * @return FALSE if this object is equivalent to the other one.
+ * @return false if this object is equivalent to the other one.
* @stable ICU 4.8
*/
inline UBool operator!=(const Part &other) const {
@@ -869,7 +869,7 @@ class U_COMMON_API MessagePattern : public UObject {
* Parses a number from the specified message substring.
* @param start start index into the message string
* @param limit limit index into the message string, must be startFALSE, only canonical
+ * If this argument is false
, only canonical
* decomposition will be performed.
* @param options the optional features to be enabled (0 for no options)
* @param result The composed string (on output).
@@ -256,7 +256,7 @@ class U_COMMON_API Normalizer : public UObject {
*
* @param source the string to be decomposed.
* @param compat Perform compatibility decomposition.
- * If this argument is FALSE
, only canonical
+ * If this argument is false
, only canonical
* decomposition will be performed.
* @param options the optional features to be enabled (0 for no options)
* @param result The decomposed string (on output).
@@ -315,7 +315,7 @@ class U_COMMON_API Normalizer : public UObject {
* never a "maybe".
* For NFD, NFKD, and FCD, both functions work exactly the same.
* For NFC and NFKC where quickCheck may return "maybe", this function will
- * perform further tests to arrive at a TRUE/FALSE result.
+ * perform further tests to arrive at a true/false result.
*
* @param src String that is to be tested if it is in a normalization format.
* @param mode Which normalization form to test for.
@@ -577,7 +577,7 @@ class U_COMMON_API Normalizer : public UObject {
int32_t endIndex(void) const;
/**
- * Returns TRUE when both iterators refer to the same character in the same
+ * Returns true when both iterators refer to the same character in the same
* input text.
*
* @param that a Normalizer object to compare this one to
@@ -587,7 +587,7 @@ class U_COMMON_API Normalizer : public UObject {
UBool operator==(const Normalizer& that) const;
/**
- * Returns FALSE when both iterators refer to the same character in the same
+ * Returns false when both iterators refer to the same character in the same
* input text.
*
* @param that a Normalizer object to compare this one to
@@ -655,8 +655,8 @@ class U_COMMON_API Normalizer : public UObject {
* It is possible to specify multiple options that are all turned on or off.
*
* @param option the option(s) whose value is/are to be set.
- * @param value the new setting for the option. Use TRUE
to
- * turn the option(s) on and FALSE
to turn it/them off.
+ * @param value the new setting for the option. Use true
to
+ * turn the option(s) on and false
to turn it/them off.
*
* @see #getOption
* @deprecated ICU 56 Use Normalizer2 instead.
@@ -666,11 +666,11 @@ class U_COMMON_API Normalizer : public UObject {
/**
* Determine whether an option is turned on or off.
- * If multiple options are specified, then the result is TRUE if any
+ * If multiple options are specified, then the result is true if any
* of them are set.
*
* @param option the option(s) that are to be checked
- * @return TRUE if any of the option(s) are set
+ * @return true if any of the option(s) are set
* @see #setOption
* @deprecated ICU 56 Use Normalizer2 instead.
*/
diff --git a/deps/icu-small/source/common/unicode/parsepos.h b/deps/icu-small/source/common/unicode/parsepos.h
index ae5754b8d75132..d6129fd4f1604f 100644
--- a/deps/icu-small/source/common/unicode/parsepos.h
+++ b/deps/icu-small/source/common/unicode/parsepos.h
@@ -97,14 +97,14 @@ class U_COMMON_API ParsePosition : public UObject {
/**
* Equality operator.
- * @return TRUE if the two parse positions are equal, FALSE otherwise.
+ * @return true if the two parse positions are equal, false otherwise.
* @stable ICU 2.0
*/
inline UBool operator==(const ParsePosition& that) const;
/**
* Equality operator.
- * @return TRUE if the two parse positions are not equal, FALSE otherwise.
+ * @return true if the two parse positions are not equal, false otherwise.
* @stable ICU 2.0
*/
inline UBool operator!=(const ParsePosition& that) const;
@@ -196,9 +196,9 @@ inline UBool
ParsePosition::operator==(const ParsePosition& copy) const
{
if(index != copy.index || errorIndex != copy.errorIndex)
- return FALSE;
+ return false;
else
- return TRUE;
+ return true;
}
inline UBool
diff --git a/deps/icu-small/source/common/unicode/putil.h b/deps/icu-small/source/common/unicode/putil.h
index 14bb99ccc545b2..f8c510dacc75fc 100644
--- a/deps/icu-small/source/common/unicode/putil.h
+++ b/deps/icu-small/source/common/unicode/putil.h
@@ -66,7 +66,7 @@
*
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
+U_CAPI const char* U_EXPORT2 u_getDataDirectory(void);
/**
@@ -88,7 +88,7 @@ U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
* @see u_init
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
+U_CAPI void U_EXPORT2 u_setDataDirectory(const char *directory);
#ifndef U_HIDE_INTERNAL_API
/**
@@ -99,7 +99,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);
+U_CAPI const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status);
/**
* Set the time zone files override directory.
@@ -109,7 +109,7 @@ U_INTERNAL const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status
* will access the time zone data.
* @internal
*/
-U_INTERNAL void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status);
+U_CAPI void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
@@ -155,7 +155,7 @@ U_INTERNAL void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCo
* @see U_CHARSET_FAMILY
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_charsToUChars(const char *cs, UChar *us, int32_t length);
/**
@@ -177,7 +177,7 @@ u_charsToUChars(const char *cs, UChar *us, int32_t length);
* @see U_CHARSET_FAMILY
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_UCharsToChars(const UChar *us, char *cs, int32_t length);
#endif
diff --git a/deps/icu-small/source/common/unicode/rbbi.h b/deps/icu-small/source/common/unicode/rbbi.h
index 7825f603a51c1b..65117f616cdf5b 100644
--- a/deps/icu-small/source/common/unicode/rbbi.h
+++ b/deps/icu-small/source/common/unicode/rbbi.h
@@ -32,6 +32,8 @@
#include "unicode/parseerr.h"
#include "unicode/schriter.h"
+struct UCPTrie;
+
U_NAMESPACE_BEGIN
/** @internal */
@@ -140,6 +142,11 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
*/
UBool fDone;
+ /**
+ * Array of look-ahead tentative results.
+ */
+ int32_t *fLookAheadMatches;
+
//=======================================================================
// constructors
//=======================================================================
@@ -246,20 +253,20 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
/**
- * Equality operator. Returns TRUE if both BreakIterators are of the
+ * Equality operator. Returns true if both BreakIterators are of the
* same class, have the same behavior, and iterate over the same text.
* @param that The BreakIterator to be compared for equality
- * @return TRUE if both BreakIterators are of the
+ * @return true if both BreakIterators are of the
* same class, have the same behavior, and iterate over the same text.
* @stable ICU 2.0
*/
virtual UBool operator==(const BreakIterator& that) const;
/**
- * Not-equal operator. If operator== returns TRUE, this returns FALSE,
+ * Not-equal operator. If operator== returns true, this returns false,
* and vice versa.
* @param that The BreakIterator to be compared for inequality
- * @return TRUE if both BreakIterators are not same.
+ * @return true if both BreakIterators are not same.
* @stable ICU 2.0
*/
inline UBool operator!=(const BreakIterator& that) const;
@@ -659,6 +666,28 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
*/
int32_t handleNext();
+ /*
+ * Templatized version of handleNext() and handleSafePrevious().
+ *
+ * There will be exactly four instantiations, two each for 8 and 16 bit tables,
+ * two each for 8 and 16 bit trie.
+ * Having separate instantiations for the table types keeps conditional tests of
+ * the table type out of the inner loops, at the expense of replicated code.
+ *
+ * The template parameter for the Trie access function is a value, not a type.
+ * Doing it this way, the compiler will inline the Trie function in the
+ * expanded functions. (Both the 8 and 16 bit access functions have the same type
+ * signature)
+ */
+
+ typedef uint16_t (*PTrieFunc)(const UCPTrie *, UChar32);
+
+ template
+ int32_t handleSafePrevious(int32_t fromPosition);
+
+ template
+ int32_t handleNext();
+
/**
* This function returns the appropriate LanguageBreakEngine for a
@@ -681,7 +710,6 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
* @internal
*/
void dumpTables();
-
#endif /* U_HIDE_INTERNAL_API */
};
diff --git a/deps/icu-small/source/common/unicode/resbund.h b/deps/icu-small/source/common/unicode/resbund.h
index 708a3423d2ae2b..63ffa506e77eec 100644
--- a/deps/icu-small/source/common/unicode/resbund.h
+++ b/deps/icu-small/source/common/unicode/resbund.h
@@ -286,7 +286,7 @@ class U_COMMON_API ResourceBundle : public UObject {
/**
* Checks whether the resource has another element to iterate over.
*
- * @return TRUE if there are more elements, FALSE if there is no more elements
+ * @return true if there are more elements, false if there is no more elements
* @stable ICU 2.0
*/
UBool
diff --git a/deps/icu-small/source/common/unicode/simpleformatter.h b/deps/icu-small/source/common/unicode/simpleformatter.h
index 9414bca3085ad4..6d9c04ace2359a 100644
--- a/deps/icu-small/source/common/unicode/simpleformatter.h
+++ b/deps/icu-small/source/common/unicode/simpleformatter.h
@@ -125,7 +125,7 @@ class U_COMMON_API SimpleFormatter U_FINAL : public UMemory {
* @param errorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* Set to U_ILLEGAL_ARGUMENT_ERROR for bad argument syntax.
- * @return TRUE if U_SUCCESS(errorCode).
+ * @return true if U_SUCCESS(errorCode).
* @stable ICU 57
*/
UBool applyPattern(const UnicodeString &pattern, UErrorCode &errorCode) {
@@ -144,7 +144,7 @@ class U_COMMON_API SimpleFormatter U_FINAL : public UMemory {
* Must fulfill U_SUCCESS before the function call.
* Set to U_ILLEGAL_ARGUMENT_ERROR for bad argument syntax and
* too few or too many arguments.
- * @return TRUE if U_SUCCESS(errorCode).
+ * @return true if U_SUCCESS(errorCode).
* @stable ICU 57
*/
UBool applyPatternMinMaxArguments(const UnicodeString &pattern,
diff --git a/deps/icu-small/source/common/unicode/strenum.h b/deps/icu-small/source/common/unicode/strenum.h
index e813cd84b3413a..5d1600156e32e9 100644
--- a/deps/icu-small/source/common/unicode/strenum.h
+++ b/deps/icu-small/source/common/unicode/strenum.h
@@ -196,7 +196,7 @@ class U_COMMON_API StringEnumeration : public UObject {
* Compares this enumeration to other to check if both are equal
*
* @param that The other string enumeration to compare this object to
- * @return TRUE if the enumerations are equal. FALSE if not.
+ * @return true if the enumerations are equal. false if not.
* @stable ICU 3.6
*/
virtual UBool operator==(const StringEnumeration& that)const;
@@ -204,7 +204,7 @@ class U_COMMON_API StringEnumeration : public UObject {
* Compares this enumeration to other to check if both are not equal
*
* @param that The other string enumeration to compare this object to
- * @return TRUE if the enumerations are equal. FALSE if not.
+ * @return true if the enumerations are equal. false if not.
* @stable ICU 3.6
*/
virtual UBool operator!=(const StringEnumeration& that)const;
diff --git a/deps/icu-small/source/common/unicode/stringpiece.h b/deps/icu-small/source/common/unicode/stringpiece.h
index 19fbe2e22eb032..58053cfd5c3108 100644
--- a/deps/icu-small/source/common/unicode/stringpiece.h
+++ b/deps/icu-small/source/common/unicode/stringpiece.h
@@ -111,7 +111,6 @@ class U_COMMON_API StringPiece : public UMemory {
#endif
#endif // U_HIDE_DRAFT_API
-#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:
@@ -132,7 +131,7 @@ class U_COMMON_API StringPiece : public UMemory {
* as from std::u8string_view.
*
* @param str the other string piece
- * @draft ICU 65
+ * @stable ICU 65
*/
template (str.data())),
length_(static_cast(str.size())) {}
-#endif // U_HIDE_DRAFT_API
/**
* Constructs from a const char * pointer and a specified length.
@@ -209,7 +207,7 @@ class U_COMMON_API StringPiece : public UMemory {
int32_t length() const { return length_; }
/**
* Returns whether the string is empty.
- * @return TRUE if the string is empty
+ * @return true if the string is empty
* @stable ICU 4.2
*/
UBool empty() const { return length_ == 0; }
@@ -331,7 +329,7 @@ class U_COMMON_API StringPiece : public UMemory {
* Global operator == for StringPiece
* @param x The first StringPiece to compare.
* @param y The second StringPiece to compare.
- * @return TRUE if the string data is equal
+ * @return true if the string data is equal
* @stable ICU 4.8
*/
U_EXPORT UBool U_EXPORT2
@@ -341,7 +339,7 @@ operator==(const StringPiece& x, const StringPiece& y);
* Global operator != for StringPiece
* @param x The first StringPiece to compare.
* @param y The second StringPiece to compare.
- * @return TRUE if the string data is not equal
+ * @return true if the string data is not equal
* @stable ICU 4.8
*/
inline UBool operator!=(const StringPiece& x, const StringPiece& y) {
diff --git a/deps/icu-small/source/common/unicode/stringtriebuilder.h b/deps/icu-small/source/common/unicode/stringtriebuilder.h
index 2860cbf5513b8e..efd2d49206ca2d 100644
--- a/deps/icu-small/source/common/unicode/stringtriebuilder.h
+++ b/deps/icu-small/source/common/unicode/stringtriebuilder.h
@@ -279,10 +279,10 @@ class U_COMMON_API StringTrieBuilder : public UObject {
*/
class ValueNode : public Node {
public:
- ValueNode(int32_t initialHash) : Node(initialHash), hasValue(FALSE), value(0) {}
+ ValueNode(int32_t initialHash) : Node(initialHash), hasValue(false), value(0) {}
virtual UBool operator==(const Node &other) const;
void setValue(int32_t v) {
- hasValue=TRUE;
+ hasValue=true;
value=v;
hash=hash*37u+v;
}
diff --git a/deps/icu-small/source/common/unicode/ubidi.h b/deps/icu-small/source/common/unicode/ubidi.h
index f4875c8801efd6..63d0e45cb7f3c5 100644
--- a/deps/icu-small/source/common/unicode/ubidi.h
+++ b/deps/icu-small/source/common/unicode/ubidi.h
@@ -21,7 +21,10 @@
#include "unicode/utypes.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
*\file
@@ -496,7 +499,7 @@ typedef struct UBiDi UBiDi;
* @return An empty UBiDi
object.
* @stable ICU 2.0
*/
-U_STABLE UBiDi * U_EXPORT2
+U_CAPI UBiDi * U_EXPORT2
ubidi_open(void);
/**
@@ -533,7 +536,7 @@ ubidi_open(void);
* @return An empty UBiDi
object with preallocated memory.
* @stable ICU 2.0
*/
-U_STABLE UBiDi * U_EXPORT2
+U_CAPI UBiDi * U_EXPORT2
ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
/**
@@ -556,7 +559,7 @@ ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
* @see ubidi_setLine
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_close(UBiDi *pBiDi);
#if U_SHOW_CPLUSPLUS_API
@@ -594,7 +597,7 @@ U_NAMESPACE_END
* this "inverse Bidi" and that the current implementation provides only an
* approximation of "inverse Bidi".
*
- * With isInverse
set to TRUE
,
+ *
With isInverse
set to true
,
* this function changes the behavior of some of the subsequent functions
* in a way that they can be used for the inverse Bidi algorithm.
* Specifically, runs of text with numeric characters will be treated in a
@@ -607,12 +610,12 @@ U_NAMESPACE_END
* the runs of the logically ordered output.
*
* Calling this function with argument isInverse
set to
- * TRUE
is equivalent to calling
+ * true
is equivalent to calling
* ubidi_setReorderingMode
with argument
* reorderingMode
* set to #UBIDI_REORDER_INVERSE_NUMBERS_AS_L
.
* Calling this function with argument isInverse
set to
- * FALSE
is equivalent to calling
+ * false
is equivalent to calling
* ubidi_setReorderingMode
with argument
* reorderingMode
* set to #UBIDI_REORDER_DEFAULT
.
@@ -626,18 +629,18 @@ U_NAMESPACE_END
* @see ubidi_setReorderingMode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
/**
* Is this Bidi object set to perform the inverse Bidi algorithm?
*
Note: calling this function after setting the reordering mode with
- * ubidi_setReorderingMode
will return TRUE
if the
+ * ubidi_setReorderingMode
will return true
if the
* reordering mode was set to #UBIDI_REORDER_INVERSE_NUMBERS_AS_L
,
- * FALSE
for all other values.
+ * false
for all other values.
*
* @param pBiDi is a UBiDi
object.
- * @return TRUE if the Bidi object is set to perform the inverse Bidi algorithm
+ * @return true if the Bidi object is set to perform the inverse Bidi algorithm
* by handling numbers as L.
*
* @see ubidi_setInverse
@@ -645,7 +648,7 @@ ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubidi_isInverse(UBiDi *pBiDi);
/**
@@ -668,7 +671,7 @@ ubidi_isInverse(UBiDi *pBiDi);
* @see ubidi_setPara
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
/**
@@ -676,13 +679,13 @@ ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
* successive paragraphs progress from left to right?
*
* @param pBiDi is a UBiDi
object.
- * @return TRUE if the Bidi object is set to allocate level 0 to block
+ * @return true if the Bidi object is set to allocate level 0 to block
* separators.
*
* @see ubidi_orderParagraphsLTR
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
/**
@@ -714,7 +717,7 @@ typedef enum UBiDiReorderingMode {
* @stable ICU 3.6 */
UBIDI_REORDER_RUNS_ONLY,
/** Visual to Logical algorithm which handles numbers like L
- * (same algorithm as selected by ubidi_setInverse(TRUE)
.
+ * (same algorithm as selected by ubidi_setInverse(true)
.
* @see ubidi_setInverse
* @stable ICU 3.6 */
UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
@@ -833,7 +836,7 @@ typedef enum UBiDiReorderingMode {
* reordered sequence (the option #UBIDI_INSERT_LRM_FOR_NUMERIC
can
* be used with function ubidi_writeReordered
to this end. This
* mode is equivalent to calling ubidi_setInverse()
with
- * argument isInverse
set to TRUE
.
+ * argument isInverse
set to true
.
*
* When the reordering mode is set to
* #UBIDI_REORDER_INVERSE_LIKE_DIRECT
, the "direct" Logical to Visual
@@ -886,7 +889,7 @@ typedef enum UBiDiReorderingMode {
* @see ubidi_writeReordered
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
/**
@@ -897,7 +900,7 @@ ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
* @see ubidi_setReorderingMode
* @stable ICU 3.6
*/
-U_STABLE UBiDiReorderingMode U_EXPORT2
+U_CAPI UBiDiReorderingMode U_EXPORT2
ubidi_getReorderingMode(UBiDi *pBiDi);
/**
@@ -935,7 +938,7 @@ typedef enum UBiDiReorderingOption {
*
* If this option is set in conjunction with reordering mode
* #UBIDI_REORDER_INVERSE_NUMBERS_AS_L
or with calling
- * ubidi_setInverse(TRUE)
, it implies
+ * ubidi_setInverse(true)
, it implies
* option #UBIDI_INSERT_LRM_FOR_NUMERIC
* in calls to function ubidi_writeReordered()
.
*
@@ -1016,7 +1019,7 @@ typedef enum UBiDiReorderingOption {
*
* When the UBIDI_OPTION_STREAMING
option is used,
* it is recommended to call ubidi_orderParagraphsLTR()
with
- * argument orderParagraphsLTR
set to TRUE
before
+ * argument orderParagraphsLTR
set to true
before
* calling ubidi_setPara
so that later paragraphs may be
* concatenated to previous paragraphs on the right.
*
@@ -1042,7 +1045,7 @@ typedef enum UBiDiReorderingOption {
* @see ubidi_getReorderingOptions
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
/**
@@ -1053,7 +1056,7 @@ ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
* @see ubidi_setReorderingOptions
* @stable ICU 3.6
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ubidi_getReorderingOptions(UBiDi *pBiDi);
/**
@@ -1140,7 +1143,7 @@ ubidi_getReorderingOptions(UBiDi *pBiDi);
* @see ubidi_setPara
* @stable ICU 4.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setContext(UBiDi *pBiDi,
const UChar *prologue, int32_t proLength,
const UChar *epilogue, int32_t epiLength,
@@ -1228,7 +1231,7 @@ ubidi_setContext(UBiDi *pBiDi,
* @param pErrorCode must be a valid pointer to an error code value.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
UErrorCode *pErrorCode);
@@ -1279,7 +1282,7 @@ ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setLine(const UBiDi *pParaBiDi,
int32_t start, int32_t limit,
UBiDi *pLineBiDi,
@@ -1300,7 +1303,7 @@ ubidi_setLine(const UBiDi *pParaBiDi,
* @see UBiDiDirection
* @stable ICU 2.0
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getDirection(const UBiDi *pBiDi);
/**
@@ -1330,7 +1333,7 @@ ubidi_getDirection(const UBiDi *pBiDi);
* @see UBiDiDirection
* @stable ICU 4.6
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getBaseDirection(const UChar *text, int32_t length );
/**
@@ -1344,7 +1347,7 @@ ubidi_getBaseDirection(const UChar *text, int32_t length );
* @see ubidi_setLine
* @stable ICU 2.0
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
ubidi_getText(const UBiDi *pBiDi);
/**
@@ -1355,7 +1358,7 @@ ubidi_getText(const UBiDi *pBiDi);
* @return The length of the text that the UBiDi object was created for.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getLength(const UBiDi *pBiDi);
/**
@@ -1373,7 +1376,7 @@ ubidi_getLength(const UBiDi *pBiDi);
* @see ubidi_getParagraphByIndex
* @stable ICU 2.0
*/
-U_STABLE UBiDiLevel U_EXPORT2
+U_CAPI UBiDiLevel U_EXPORT2
ubidi_getParaLevel(const UBiDi *pBiDi);
/**
@@ -1384,7 +1387,7 @@ ubidi_getParaLevel(const UBiDi *pBiDi);
* @return The number of paragraphs.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_countParagraphs(UBiDi *pBiDi);
/**
@@ -1421,7 +1424,7 @@ ubidi_countParagraphs(UBiDi *pBiDi);
* @see ubidi_getProcessedLength
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
int32_t *pParaLimit, UBiDiLevel *pParaLevel,
UErrorCode *pErrorCode);
@@ -1453,7 +1456,7 @@ ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
*
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
int32_t *pParaStart, int32_t *pParaLimit,
UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
@@ -1473,7 +1476,7 @@ ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE UBiDiLevel U_EXPORT2
+U_CAPI UBiDiLevel U_EXPORT2
ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
/**
@@ -1494,7 +1497,7 @@ ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE const UBiDiLevel * U_EXPORT2
+U_CAPI const UBiDiLevel * U_EXPORT2
ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
/**
@@ -1521,7 +1524,7 @@ ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
int32_t *pLogicalLimit, UBiDiLevel *pLevel);
@@ -1540,7 +1543,7 @@ ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
* @return The number of runs.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
/**
@@ -1599,7 +1602,7 @@ ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
* to avoid these issues.
* @stable ICU 2.0
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
int32_t *pLogicalStart, int32_t *pLength);
@@ -1640,7 +1643,7 @@ ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
/**
@@ -1675,7 +1678,7 @@ ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
/**
@@ -1718,7 +1721,7 @@ ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
/**
@@ -1754,7 +1757,7 @@ ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
/**
@@ -1777,7 +1780,7 @@ ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
* The index map will result in indexMap[logicalIndex]==visualIndex
.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
/**
@@ -1800,7 +1803,7 @@ ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap
* The index map will result in indexMap[visualIndex]==logicalIndex
.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
/**
@@ -1835,7 +1838,7 @@ ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
* @see UBIDI_MAP_NOWHERE
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
/** option flags for ubidi_writeReordered() */
@@ -1940,7 +1943,7 @@ ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
* @see UBIDI_OPTION_STREAMING
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getProcessedLength(const UBiDi *pBiDi);
/**
@@ -1970,7 +1973,7 @@ ubidi_getProcessedLength(const UBiDi *pBiDi);
* @see UBIDI_OPTION_REMOVE_CONTROLS
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getResultLength(const UBiDi *pBiDi);
U_CDECL_BEGIN
@@ -2028,7 +2031,7 @@ U_CDECL_END
* @see UBiDiClassCallback
* @stable ICU 3.6
*/
-U_STABLE UCharDirection U_EXPORT2
+U_CAPI UCharDirection U_EXPORT2
ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
/**
@@ -2058,7 +2061,7 @@ ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
* @see ubidi_getClassCallback
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
const void *newContext, UBiDiClassCallback **oldFn,
const void **oldContext, UErrorCode *pErrorCode);
@@ -2075,7 +2078,7 @@ ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
* @see ubidi_setClassCallback
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
/**
@@ -2143,7 +2146,7 @@ ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **conte
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_writeReordered(UBiDi *pBiDi,
UChar *dest, int32_t destSize,
uint16_t options,
@@ -2195,7 +2198,7 @@ ubidi_writeReordered(UBiDi *pBiDi,
* @return The length of the output string.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_writeReverse(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destSize,
uint16_t options,
diff --git a/deps/icu-small/source/common/unicode/ubiditransform.h b/deps/icu-small/source/common/unicode/ubiditransform.h
index 5c08ed5df0fd90..2dd7564010de17 100644
--- a/deps/icu-small/source/common/unicode/ubiditransform.h
+++ b/deps/icu-small/source/common/unicode/ubiditransform.h
@@ -21,7 +21,10 @@
#include "unicode/utypes.h"
#include "unicode/ubidi.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -147,10 +150,10 @@ typedef struct UBiDiTransform UBiDiTransform;
* calling ubidi_setPara
with
* paraLevel == UBIDI_DEFAULT_RTL
,
* : this is equivalent to
- * calling ubidi_setInverse(UBiDi*, TRUE)
and then
+ * calling ubidi_setInverse(UBiDi*, true)
and then
* ubidi_setPara
with paraLevel == UBIDI_LTR
,
* : this is equivalent to
- * calling ubidi_setInverse(UBiDi*, TRUE)
and then
+ * calling ubidi_setInverse(UBiDi*, true)
and then
* ubidi_setPara
with paraLevel == UBIDI_RTL
.
*
* All combinations that involve the Visual RTL scheme are unsupported by
@@ -245,7 +248,7 @@ typedef struct UBiDiTransform UBiDiTransform;
* @see u_shapeArabic
* @stable ICU 58
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ubiditransform_transform(UBiDiTransform *pBiDiTransform,
const UChar *src, int32_t srcLength,
UChar *dest, int32_t destSize,
@@ -291,14 +294,14 @@ ubiditransform_transform(UBiDiTransform *pBiDiTransform,
* @return An empty UBiDiTransform
object.
* @stable ICU 58
*/
-U_STABLE UBiDiTransform* U_EXPORT2
+U_CAPI UBiDiTransform* U_EXPORT2
ubiditransform_open(UErrorCode *pErrorCode);
/**
* Deallocates the given UBiDiTransform
object.
* @stable ICU 58
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubiditransform_close(UBiDiTransform *pBidiTransform);
#if U_SHOW_CPLUSPLUS_API
diff --git a/deps/icu-small/source/common/unicode/ubrk.h b/deps/icu-small/source/common/unicode/ubrk.h
index 73c1553b243957..37189a85984b68 100644
--- a/deps/icu-small/source/common/unicode/ubrk.h
+++ b/deps/icu-small/source/common/unicode/ubrk.h
@@ -13,7 +13,10 @@
#include "unicode/utypes.h"
#include "unicode/uloc.h"
#include "unicode/utext.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* A text-break iterator.
@@ -238,7 +241,7 @@ typedef enum USentenceBreakTag {
* @see ubrk_openRules
* @stable ICU 2.0
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_open(UBreakIteratorType type,
const char *locale,
const UChar *text,
@@ -260,7 +263,7 @@ ubrk_open(UBreakIteratorType type,
* @see ubrk_open
* @stable ICU 2.2
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_openRules(const UChar *rules,
int32_t rulesLength,
const UChar *text,
@@ -288,7 +291,7 @@ ubrk_openRules(const UChar *rules,
* @see ubrk_getBinaryRules
* @stable ICU 59
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
const UChar * text, int32_t textLength,
UErrorCode * status);
@@ -311,7 +314,7 @@ ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
* @return pointer to the new clone
* @stable ICU 2.0
*/
-U_STABLE UBreakIterator * U_EXPORT2
+U_CAPI UBreakIterator * U_EXPORT2
ubrk_safeClone(
const UBreakIterator *bi,
void *stackBuffer,
@@ -334,7 +337,7 @@ ubrk_safeClone(
* @param bi The break iterator to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_close(UBreakIterator *bi);
#if U_SHOW_CPLUSPLUS_API
@@ -368,7 +371,7 @@ U_NAMESPACE_END
* @param status The error code
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_setText(UBreakIterator* bi,
const UChar* text,
int32_t textLength,
@@ -392,7 +395,7 @@ ubrk_setText(UBreakIterator* bi,
* @param status The error code
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_setUText(UBreakIterator* bi,
UText* text,
UErrorCode* status);
@@ -407,7 +410,7 @@ ubrk_setUText(UBreakIterator* bi,
* \ref ubrk_first, or \ref ubrk_last.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_current(const UBreakIterator *bi);
/**
@@ -419,7 +422,7 @@ ubrk_current(const UBreakIterator *bi);
* @see ubrk_previous
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_next(UBreakIterator *bi);
/**
@@ -431,7 +434,7 @@ ubrk_next(UBreakIterator *bi);
* @see ubrk_next
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_previous(UBreakIterator *bi);
/**
@@ -441,7 +444,7 @@ ubrk_previous(UBreakIterator *bi);
* @see ubrk_last
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_first(UBreakIterator *bi);
/**
@@ -453,7 +456,7 @@ ubrk_first(UBreakIterator *bi);
* @see ubrk_first
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_last(UBreakIterator *bi);
/**
@@ -465,7 +468,7 @@ ubrk_last(UBreakIterator *bi);
* @see ubrk_following
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_preceding(UBreakIterator *bi,
int32_t offset);
@@ -478,7 +481,7 @@ ubrk_preceding(UBreakIterator *bi,
* @see ubrk_preceding
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_following(UBreakIterator *bi,
int32_t offset);
@@ -491,7 +494,7 @@ ubrk_following(UBreakIterator *bi,
* @see ubrk_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ubrk_getAvailable(int32_t index);
/**
@@ -502,7 +505,7 @@ ubrk_getAvailable(int32_t index);
* @see ubrk_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_countAvailable(void);
@@ -515,7 +518,7 @@ ubrk_countAvailable(void);
* @return True if "offset" is a boundary position.
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
/**
@@ -527,7 +530,7 @@ ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
* For word break iterators, the possible values are defined in enum UWordBreak.
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getRuleStatus(UBreakIterator *bi);
/**
@@ -547,7 +550,7 @@ ubrk_getRuleStatus(UBreakIterator *bi);
* the most recent boundary returned by the break iterator.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);
/**
@@ -559,7 +562,7 @@ ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity,
* @return locale string
* @stable ICU 2.8
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);
/**
@@ -587,7 +590,7 @@ ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCo
*
* @stable ICU 49
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_refreshUText(UBreakIterator *bi,
UText *text,
UErrorCode *status);
@@ -618,7 +621,7 @@ ubrk_refreshUText(UBreakIterator *bi,
* @see ubrk_openBinaryRules
* @stable ICU 59
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getBinaryRules(UBreakIterator *bi,
uint8_t * binaryRules, int32_t rulesCapacity,
UErrorCode * status);
diff --git a/deps/icu-small/source/common/unicode/ucasemap.h b/deps/icu-small/source/common/unicode/ucasemap.h
index 6b253e3d638475..d1c1b483ab337e 100644
--- a/deps/icu-small/source/common/unicode/ucasemap.h
+++ b/deps/icu-small/source/common/unicode/ucasemap.h
@@ -22,10 +22,13 @@
#define __UCASEMAP_H__
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/stringoptions.h"
#include "unicode/ustring.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Unicode case mapping functions using a UCaseMap service object.
@@ -69,7 +72,7 @@ typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable IC
* @see U_TITLECASE_NO_BREAK_ADJUSTMENT
* @stable ICU 3.4
*/
-U_STABLE UCaseMap * U_EXPORT2
+U_CAPI UCaseMap * U_EXPORT2
ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
/**
@@ -77,7 +80,7 @@ ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
* @param csm Object to be closed.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_close(UCaseMap *csm);
#if U_SHOW_CPLUSPLUS_API
@@ -105,7 +108,7 @@ U_NAMESPACE_END
* @return locale ID
* @stable ICU 3.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucasemap_getLocale(const UCaseMap *csm);
/**
@@ -114,7 +117,7 @@ ucasemap_getLocale(const UCaseMap *csm);
* @return options bit set
* @stable ICU 3.4
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ucasemap_getOptions(const UCaseMap *csm);
/**
@@ -128,7 +131,7 @@ ucasemap_getOptions(const UCaseMap *csm);
* @see ucasemap_open
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
/**
@@ -142,7 +145,7 @@ ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
* @see ucasemap_open
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
#if !UCONFIG_NO_BREAK_ITERATION
@@ -154,7 +157,7 @@ ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
* @return titlecasing break iterator
* @stable ICU 3.8
*/
-U_STABLE const UBreakIterator * U_EXPORT2
+U_CAPI const UBreakIterator * U_EXPORT2
ucasemap_getBreakIterator(const UCaseMap *csm);
/**
@@ -177,7 +180,7 @@ ucasemap_getBreakIterator(const UCaseMap *csm);
* @see ucasemap_utf8ToTitle
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode);
/**
@@ -226,7 +229,7 @@ ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode
* @see u_strToTitle
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_toTitle(UCaseMap *csm,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
@@ -257,7 +260,7 @@ ucasemap_toTitle(UCaseMap *csm,
* @see u_strToLower
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToLower(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -286,7 +289,7 @@ ucasemap_utf8ToLower(const UCaseMap *csm,
* @see u_strToUpper
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToUpper(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -338,7 +341,7 @@ ucasemap_utf8ToUpper(const UCaseMap *csm,
* @see U_TITLECASE_NO_BREAK_ADJUSTMENT
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToTitle(UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -376,7 +379,7 @@ ucasemap_utf8ToTitle(UCaseMap *csm,
* @see U_FOLD_CASE_EXCLUDE_SPECIAL_I
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8FoldCase(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
diff --git a/deps/icu-small/source/common/unicode/ucat.h b/deps/icu-small/source/common/unicode/ucat.h
index f9c18b47d6c9b8..a177639a76bfcb 100644
--- a/deps/icu-small/source/common/unicode/ucat.h
+++ b/deps/icu-small/source/common/unicode/ucat.h
@@ -103,7 +103,7 @@ typedef UResourceBundle* u_nl_catd;
*
* @stable ICU 2.6
*/
-U_STABLE u_nl_catd U_EXPORT2
+U_CAPI u_nl_catd U_EXPORT2
u_catopen(const char* name, const char* locale, UErrorCode* ec);
/**
@@ -114,7 +114,7 @@ u_catopen(const char* name, const char* locale, UErrorCode* ec);
*
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_catclose(u_nl_catd catd);
/**
@@ -149,7 +149,7 @@ u_catclose(u_nl_catd catd);
*
* @stable ICU 2.6
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,
const UChar* s,
int32_t* len, UErrorCode* ec);
diff --git a/deps/icu-small/source/common/unicode/uchar.h b/deps/icu-small/source/common/unicode/uchar.h
index 3b55b2326dfc1f..1e0f82e706c482 100644
--- a/deps/icu-small/source/common/unicode/uchar.h
+++ b/deps/icu-small/source/common/unicode/uchar.h
@@ -80,7 +80,7 @@ U_CDECL_BEGIN
* and the ICU User Guide chapter on Properties (http://icu-project.org/userguide/properties.html).
*
* Many properties are accessible via generic functions that take a UProperty selector.
- * - u_hasBinaryProperty() returns a binary value (TRUE/FALSE) per property and code point.
+ * - u_hasBinaryProperty() returns a binary value (true/false) per property and code point.
* - u_getIntPropertyValue() returns an integer value per property and code point.
* For each supported enumerated or catalog property, there is
* an enum type for all of the property's values, and
@@ -2586,8 +2586,8 @@ typedef enum UVerticalOrientation {
* @param c Code point to test.
* @param which UProperty selector constant, identifies which binary property to check.
* Must be UCHAR_BINARY_START<=which(remainingMatchLength_ + 2) << kState64RemainingShift) |
@@ -123,14 +122,13 @@ class U_COMMON_API UCharsTrie : public UMemory {
* @see getState64
* @see resetToState
* @see reset
- * @draft ICU 65
+ * @stable 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
@@ -268,16 +266,16 @@ class U_COMMON_API UCharsTrie : public UMemory {
/**
* Determines whether all strings reachable from the current state
* map to the same value.
- * @param uniqueValue Receives the unique value, if this function returns TRUE.
+ * @param uniqueValue Receives the unique value, if this function returns true.
* (output-only)
- * @return TRUE if all strings reachable from the current state
+ * @return true if all strings reachable from the current state
* map to the same value.
* @stable ICU 4.8
*/
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
const char16_t *pos=pos_;
// Skip the rest of a pending linear-match node.
- return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
+ return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, false, uniqueValue);
}
/**
@@ -335,7 +333,7 @@ class U_COMMON_API UCharsTrie : public UMemory {
Iterator &reset();
/**
- * @return TRUE if there are more elements.
+ * @return true if there are more elements.
* @stable ICU 4.8
*/
UBool hasNext() const;
@@ -351,7 +349,7 @@ class U_COMMON_API UCharsTrie : public UMemory {
* 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 TRUE if there is another element.
+ * @return true if there is another element.
* @stable ICU 4.8
*/
UBool next(UErrorCode &errorCode);
@@ -371,7 +369,7 @@ class U_COMMON_API UCharsTrie : public UMemory {
UBool truncateAndStop() {
pos_=NULL;
value_=-1; // no real value for str
- return TRUE;
+ return true;
}
const char16_t *branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode);
diff --git a/deps/icu-small/source/common/unicode/ucharstriebuilder.h b/deps/icu-small/source/common/unicode/ucharstriebuilder.h
index 540dcc047fd563..15657702f9d024 100644
--- a/deps/icu-small/source/common/unicode/ucharstriebuilder.h
+++ b/deps/icu-small/source/common/unicode/ucharstriebuilder.h
@@ -101,9 +101,10 @@ class U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder {
* Multiple calls to buildUnicodeString() set the UnicodeStrings to the
* builder's same char16_t array, without rebuilding.
* If buildUnicodeString() is called after build(), the trie will be
- * re-serialized into a new array.
- * If build() is called after buildUnicodeString(), the trie object will become
- * the owner of the previously returned array.
+ * re-serialized into a new array (because build() passes on ownership).
+ * If build() is called after buildUnicodeString(), the trie object returned
+ * by build() will become the owner of the underlying data for the
+ * previously returned UnicodeString.
* After clear() has been called, a new array will be used as well.
* @param buildOption Build option, see UStringTrieBuildOption.
* @param result A UnicodeString which will be set to the char16_t-serialized
@@ -147,7 +148,7 @@ class U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder {
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const;
- virtual UBool matchNodesCanHaveValues() const { return TRUE; }
+ virtual UBool matchNodesCanHaveValues() const { return true; }
virtual int32_t getMaxBranchLinearSubNodeLength() const { return UCharsTrie::kMaxBranchLinearSubNodeLength; }
virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }
diff --git a/deps/icu-small/source/common/unicode/uchriter.h b/deps/icu-small/source/common/unicode/uchriter.h
index bee842cc259f07..84309b2416d136 100644
--- a/deps/icu-small/source/common/unicode/uchriter.h
+++ b/deps/icu-small/source/common/unicode/uchriter.h
@@ -274,11 +274,11 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator {
virtual UChar32 next32PostInc(void);
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* This is used with nextPostInc() or next32PostInc() in forward
* iteration.
- * @return FALSE if there are no more code units or code points
+ * @return false if there are no more code units or code points
* at or after the current position in the iteration range.
* @stable ICU 2.0
*/
@@ -303,11 +303,11 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator {
virtual UChar32 previous32(void);
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* before the current position in the iteration range.
* This is used with previous() or previous32() in backward
* iteration.
- * @return FALSE if there are no more code units or code points
+ * @return false if there are no more code units or code points
* before the current position in the iteration range.
* @stable ICU 2.0
*/
diff --git a/deps/icu-small/source/common/unicode/uclean.h b/deps/icu-small/source/common/unicode/uclean.h
index ab0cd6da6ba780..f03593964a4edd 100644
--- a/deps/icu-small/source/common/unicode/uclean.h
+++ b/deps/icu-small/source/common/unicode/uclean.h
@@ -49,7 +49,7 @@
*
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_init(UErrorCode *status);
#ifndef U_HIDE_SYSTEM_API
@@ -98,7 +98,7 @@ u_init(UErrorCode *status);
* @stable ICU 2.0
* @system
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_cleanup(void);
U_CDECL_BEGIN
@@ -148,7 +148,7 @@ typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem);
* @stable ICU 2.8
* @system
*/
-U_STABLE void U_EXPORT2
+U_CAPI 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);
diff --git a/deps/icu-small/source/common/unicode/ucnv.h b/deps/icu-small/source/common/unicode/ucnv.h
index ec7c5f350b4973..58f271cfb5adf2 100644
--- a/deps/icu-small/source/common/unicode/ucnv.h
+++ b/deps/icu-small/source/common/unicode/ucnv.h
@@ -51,7 +51,10 @@
#include "unicode/ucnv_err.h"
#include "unicode/uenum.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
#if !defined(USET_DEFINED) && !defined(U_IN_DOXYGEN)
@@ -308,7 +311,7 @@ U_CDECL_END
* lexically follows name2.
* @stable ICU 2.0
*/
-U_STABLE int U_EXPORT2
+U_CAPI int U_EXPORT2
ucnv_compareNames(const char *name1, const char *name2);
@@ -362,7 +365,7 @@ ucnv_compareNames(const char *name1, const char *name2);
* @see ucnv_compareNames
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_open(const char *converterName, UErrorCode *err);
@@ -392,7 +395,7 @@ ucnv_open(const char *converterName, UErrorCode *err);
* @see ucnv_compareNames
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openU(const UChar *name,
UErrorCode *err);
@@ -460,7 +463,7 @@ ucnv_openU(const UChar *name,
* @see UConverterPlatform
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openCCSID(int32_t codepage,
UConverterPlatform platform,
UErrorCode * err);
@@ -476,7 +479,7 @@ ucnv_openCCSID(int32_t codepage,
* The name will NOT be looked up in the alias mechanism, nor will the converter be
* stored in the converter cache or the alias table. The only way to open further converters
* is call this function multiple times, or use the ucnv_safeClone() function to clone a
- * 'master' converter.
+ * 'primary' converter.
*
* A future version of ICU may add alias table lookups and/or caching
* to this function.
@@ -495,7 +498,7 @@ ucnv_openCCSID(int32_t codepage,
* @see ucnv_close
* @stable ICU 2.2
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
/**
@@ -537,7 +540,7 @@ ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode
* @return pointer to the new clone
* @stable ICU 2.0
*/
-U_STABLE UConverter * U_EXPORT2
+U_CAPI UConverter * U_EXPORT2
ucnv_safeClone(const UConverter *cnv,
void *stackBuffer,
int32_t *pBufferSize,
@@ -566,7 +569,7 @@ ucnv_safeClone(const UConverter *cnv,
* @see ucnv_openCCSID
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_close(UConverter * converter);
#if U_SHOW_CPLUSPLUS_API
@@ -605,7 +608,7 @@ U_NAMESPACE_END
* @see ucnv_setSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getSubstChars(const UConverter *converter,
char *subChars,
int8_t *len,
@@ -630,7 +633,7 @@ ucnv_getSubstChars(const UConverter *converter,
* @see ucnv_getSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setSubstChars(UConverter *converter,
const char *subChars,
int8_t len,
@@ -663,7 +666,7 @@ ucnv_setSubstChars(UConverter *converter,
* @see ucnv_getSubstChars
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setSubstString(UConverter *cnv,
const UChar *s,
int32_t length,
@@ -682,7 +685,7 @@ ucnv_setSubstString(UConverter *cnv,
* U_INDEX_OUTOFBOUNDS_ERROR will be returned.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getInvalidChars(const UConverter *converter,
char *errBytes,
int8_t *len,
@@ -701,7 +704,7 @@ ucnv_getInvalidChars(const UConverter *converter,
* U_INDEX_OUTOFBOUNDS_ERROR will be returned.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getInvalidUChars(const UConverter *converter,
UChar *errUChars,
int8_t *len,
@@ -714,7 +717,7 @@ ucnv_getInvalidUChars(const UConverter *converter,
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_reset(UConverter *converter);
/**
@@ -725,7 +728,7 @@ ucnv_reset(UConverter *converter);
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_resetToUnicode(UConverter *converter);
/**
@@ -736,7 +739,7 @@ ucnv_resetToUnicode(UConverter *converter);
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_resetFromUnicode(UConverter *converter);
/**
@@ -789,7 +792,7 @@ ucnv_resetFromUnicode(UConverter *converter);
* @see ucnv_getMinCharSize
* @stable ICU 2.0
*/
-U_STABLE int8_t U_EXPORT2
+U_CAPI int8_t U_EXPORT2
ucnv_getMaxCharSize(const UConverter *converter);
/**
@@ -822,7 +825,7 @@ ucnv_getMaxCharSize(const UConverter *converter);
* @see ucnv_getMaxCharSize
* @stable ICU 2.0
*/
-U_STABLE int8_t U_EXPORT2
+U_CAPI int8_t U_EXPORT2
ucnv_getMinCharSize(const UConverter *converter);
/**
@@ -839,7 +842,7 @@ ucnv_getMinCharSize(const UConverter *converter);
* @see ucnv_getName
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_getDisplayName(const UConverter *converter,
const char *displayLocale,
UChar *displayName,
@@ -856,7 +859,7 @@ ucnv_getDisplayName(const UConverter *converter,
* @see ucnv_getDisplayName
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getName(const UConverter *converter, UErrorCode *err);
/**
@@ -882,7 +885,7 @@ ucnv_getName(const UConverter *converter, UErrorCode *err);
* @see ucnv_getPlatform
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_getCCSID(const UConverter *converter,
UErrorCode *err);
@@ -896,7 +899,7 @@ ucnv_getCCSID(const UConverter *converter,
* @return The codepage platform
* @stable ICU 2.0
*/
-U_STABLE UConverterPlatform U_EXPORT2
+U_CAPI UConverterPlatform U_EXPORT2
ucnv_getPlatform(const UConverter *converter,
UErrorCode *err);
@@ -908,14 +911,14 @@ ucnv_getPlatform(const UConverter *converter,
* @return the type of the converter
* @stable ICU 2.0
*/
-U_STABLE UConverterType U_EXPORT2
+U_CAPI UConverterType U_EXPORT2
ucnv_getType(const UConverter * converter);
/**
* Gets the "starter" (lead) bytes for converters of type MBCS.
* Will fill in an U_ILLEGAL_ARGUMENT_ERROR if converter passed in
* is not MBCS. Fills in an array of type UBool, with the value of the byte
- * as offset to the array. For example, if (starters[0x20] == TRUE) at return,
+ * as offset to the array. For example, if (starters[0x20] == true) at return,
* it means that the byte 0x20 is a starter byte in this converter.
* Context pointers are always owned by the caller.
*
@@ -926,7 +929,7 @@ ucnv_getType(const UConverter * converter);
* @see ucnv_getType
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getStarters(const UConverter* converter,
UBool starters[256],
UErrorCode* err);
@@ -997,7 +1000,7 @@ typedef enum UConverterUnicodeSet {
* @see uset_close
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getUnicodeSet(const UConverter *cnv,
USet *setFillIn,
UConverterUnicodeSet whichSet,
@@ -1014,7 +1017,7 @@ ucnv_getUnicodeSet(const UConverter *cnv,
* @see ucnv_setToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getToUCallBack (const UConverter * converter,
UConverterToUCallback *action,
const void **context);
@@ -1030,7 +1033,7 @@ ucnv_getToUCallBack (const UConverter * converter,
* @see ucnv_setFromUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getFromUCallBack (const UConverter * converter,
UConverterFromUCallback *action,
const void **context);
@@ -1050,7 +1053,7 @@ ucnv_getFromUCallBack (const UConverter * converter,
* @see ucnv_getToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setToUCallBack (UConverter * converter,
UConverterToUCallback newAction,
const void* newContext,
@@ -1073,7 +1076,7 @@ ucnv_setToUCallBack (UConverter * converter,
* @see ucnv_getFromUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setFromUCallBack (UConverter * converter,
UConverterFromUCallback newAction,
const void *newContext,
@@ -1100,7 +1103,7 @@ ucnv_setFromUCallBack (UConverter * converter,
* consumed. At that point, the caller should reset the source and
* sourceLimit pointers to point to the next chunk.
*
- * At the end of the stream (flush==TRUE), the input is completely consumed
+ * At the end of the stream (flush==true), the input is completely consumed
* when *source==sourceLimit and no error code is set.
* The converter object is then automatically reset by this function.
* (This means that a converter need not be reset explicitly between data
@@ -1125,9 +1128,9 @@ ucnv_setFromUCallBack (UConverter * converter,
* e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6]
* For output data carried across calls, and other data without a specific source character
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
- * @param flush set to TRUE if the current source buffer is the last available
- * chunk of the source, FALSE otherwise. Note that if a failing status is returned,
- * this function may have to be called multiple times with flush set to TRUE until
+ * @param flush set to true if the current source buffer is the last available
+ * chunk of the source, false otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to true until
* the source buffer is consumed.
* @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the
* converter is NULL.
@@ -1139,7 +1142,7 @@ ucnv_setFromUCallBack (UConverter * converter,
* @see ucnv_setToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_fromUnicode (UConverter * converter,
char **target,
const char *targetLimit,
@@ -1169,7 +1172,7 @@ ucnv_fromUnicode (UConverter * converter,
* consumed. At that point, the caller should reset the source and
* sourceLimit pointers to point to the next chunk.
*
- * At the end of the stream (flush==TRUE), the input is completely consumed
+ * At the end of the stream (flush==true), the input is completely consumed
* when *source==sourceLimit and no error code is set
* The converter object is then automatically reset by this function.
* (This means that a converter need not be reset explicitly between data
@@ -1193,9 +1196,9 @@ ucnv_fromUnicode (UConverter * converter,
* e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6]
* For output data carried across calls, and other data without a specific source character
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
- * @param flush set to TRUE if the current source buffer is the last available
- * chunk of the source, FALSE otherwise. Note that if a failing status is returned,
- * this function may have to be called multiple times with flush set to TRUE until
+ * @param flush set to true if the current source buffer is the last available
+ * chunk of the source, false otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to true until
* the source buffer is consumed.
* @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the
* converter is NULL.
@@ -1208,7 +1211,7 @@ ucnv_fromUnicode (UConverter * converter,
* @see ucnv_getNextUChar
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_toUnicode(UConverter *converter,
UChar **target,
const UChar *targetLimit,
@@ -1245,7 +1248,7 @@ ucnv_toUnicode(UConverter *converter,
* @see UCNV_GET_MAX_BYTES_FOR_STRING
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_fromUChars(UConverter *cnv,
char *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
@@ -1277,7 +1280,7 @@ ucnv_fromUChars(UConverter *cnv,
* @see ucnv_convert
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_toUChars(UConverter *cnv,
UChar *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -1295,7 +1298,7 @@ ucnv_toUChars(UConverter *cnv,
* - Convenient.
*
* Limitations compared to ucnv_toUnicode():
- * - Always assumes flush=TRUE.
+ * - Always assumes flush=true.
* This makes ucnv_getNextUChar() unsuitable for "streaming" conversion,
* that is, for where the input is supplied in multiple buffers,
* because ucnv_getNextUChar() will assume the end of the input at the end
@@ -1306,7 +1309,7 @@ ucnv_toUChars(UConverter *cnv,
* ucnv_getNextUChar() uses the current state of the converter
* (unlike ucnv_toUChars() which always resets first).
* However, if ucnv_getNextUChar() is called after ucnv_toUnicode()
- * stopped in the middle of a character sequence (with flush=FALSE),
+ * stopped in the middle of a character sequence (with flush=false),
* then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()
* internally until the next character boundary.
* (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to
@@ -1353,7 +1356,7 @@ ucnv_toUChars(UConverter *cnv,
* @see ucnv_convert
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
ucnv_getNextUChar(UConverter * converter,
const char **source,
const char * sourceLimit,
@@ -1385,7 +1388,7 @@ ucnv_getNextUChar(UConverter * converter,
*
* ucnv_convertEx() also provides further convenience:
* - an option to reset the converters at the beginning
- * (if reset==TRUE, see parameters;
+ * (if reset==true, see parameters;
* also sets *pivotTarget=*pivotSource=pivotStart)
* - allow NUL-terminated input
* (only a single NUL byte, will not work for charsets with multi-byte NULs)
@@ -1442,7 +1445,7 @@ ucnv_getNextUChar(UConverter * converter,
* &target, u8+capacity,
* &s, s+length,
* NULL, NULL, NULL, NULL,
- * TRUE, TRUE,
+ * true, true,
* pErrorCode);
*
* myReleaseCachedUTF8Converter(utf8Cnv);
@@ -1474,7 +1477,7 @@ ucnv_getNextUChar(UConverter * converter,
* It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit
* and pivotStartNULL is returned. Owned by the library.
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
/**
@@ -1853,7 +1856,7 @@ ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorC
* @see ucnv_getStandardName
* @stable ICU 2.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
/**
@@ -1870,7 +1873,7 @@ ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErro
* @see ucnv_setDefaultName
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getDefaultName(void);
#ifndef U_HIDE_SYSTEM_API
@@ -1890,7 +1893,7 @@ ucnv_getDefaultName(void);
* @system
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setDefaultName(const char *name);
#endif /* U_HIDE_SYSTEM_API */
@@ -1911,18 +1914,18 @@ ucnv_setDefaultName(const char *name);
* @see ucnv_isAmbiguous
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
/**
* Determines if the converter contains ambiguous mappings of the same
* character or not.
* @param cnv the converter to be tested
- * @return TRUE if the converter contains ambiguous mapping of the same
- * character, FALSE otherwise.
+ * @return true if the converter contains ambiguous mapping of the same
+ * character, false otherwise.
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_isAmbiguous(const UConverter *cnv);
/**
@@ -1935,12 +1938,12 @@ ucnv_isAmbiguous(const UConverter *cnv);
* http://www.icu-project.org/userguide/conversion-data.html#ucmformat
*
* @param cnv The converter to set the fallback mapping usage on.
- * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback
- * mapping, FALSE otherwise.
+ * @param usesFallback true if the user wants the converter to take advantage of the fallback
+ * mapping, false otherwise.
* @stable ICU 2.0
* @see ucnv_usesFallback
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setFallback(UConverter *cnv, UBool usesFallback);
/**
@@ -1948,11 +1951,11 @@ ucnv_setFallback(UConverter *cnv, UBool usesFallback);
* This flag has restrictions, see ucnv_setFallback().
*
* @param cnv The converter to be tested
- * @return TRUE if the converter uses fallback, FALSE otherwise.
+ * @return true if the converter uses fallback, false otherwise.
* @stable ICU 2.0
* @see ucnv_setFallback
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_usesFallback(const UConverter *cnv);
/**
@@ -1984,7 +1987,7 @@ ucnv_usesFallback(const UConverter *cnv);
* @return The name of the encoding detected. NULL if encoding is not detected.
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ucnv_detectUnicodeSignature(const char* source,
int32_t sourceLength,
int32_t *signatureLength,
@@ -2001,7 +2004,7 @@ ucnv_detectUnicodeSignature(const char* source,
* @return The number of UChars in the state. -1 if an error is encountered.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
/**
@@ -2015,7 +2018,7 @@ ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
* @return The number of chars in the state. -1 if an error is encountered.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
/**
@@ -2027,13 +2030,13 @@ ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
* but a UTF-32 converter encodes each code point with 4 bytes.
* Note: This method is not intended to be used to determine whether the charset has a
* fixed ratio of bytes to Unicode codes units for any particular Unicode encoding form.
- * FALSE is returned with the UErrorCode if error occurs or cnv is NULL.
+ * false is returned with the UErrorCode if error occurs or cnv is NULL.
* @param cnv The converter to be tested
* @param status ICU error code in/out paramter
- * @return TRUE if the converter is fixed-width
+ * @return true if the converter is fixed-width
* @stable ICU 4.8
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
#endif
diff --git a/deps/icu-small/source/common/unicode/ucnv_cb.h b/deps/icu-small/source/common/unicode/ucnv_cb.h
index 632cc0b35f26c5..18240990dbaed9 100644
--- a/deps/icu-small/source/common/unicode/ucnv_cb.h
+++ b/deps/icu-small/source/common/unicode/ucnv_cb.h
@@ -84,7 +84,7 @@
* @see ucnv_cbFromUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,
const char* source,
int32_t length,
@@ -104,7 +104,7 @@ ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,
* @see ucnv_cbFromUWriteBytes
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,
int32_t offsetIndex,
UErrorCode * err);
@@ -121,7 +121,7 @@ ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,
* @see ucnv_cbToUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
const UChar** source,
const UChar* sourceLimit,
int32_t offsetIndex,
@@ -140,7 +140,7 @@ U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
* @see ucnv_cbToUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
const UChar* source,
int32_t length,
int32_t offsetIndex,
@@ -156,7 +156,7 @@ U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
* @see ucnv_cbToUWriteUChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,
int32_t offsetIndex,
UErrorCode * err);
#endif
diff --git a/deps/icu-small/source/common/unicode/ucnv_err.h b/deps/icu-small/source/common/unicode/ucnv_err.h
index 08c96c14407c22..bff90f0ba1e1d4 100644
--- a/deps/icu-small/source/common/unicode/ucnv_err.h
+++ b/deps/icu-small/source/common/unicode/ucnv_err.h
@@ -193,7 +193,7 @@ typedef enum {
*/
typedef struct {
uint16_t size; /**< The size of this struct. @stable ICU 2.0 */
- UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */
+ UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */
UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */
const UChar *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */
const UChar *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */
@@ -209,7 +209,7 @@ typedef struct {
*/
typedef struct {
uint16_t size; /**< The size of this struct @stable ICU 2.0 */
- UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */
+ UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */
UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */
const char *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */
const char *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */
@@ -233,7 +233,7 @@ typedef struct {
* @param err This should always be set to a failure status prior to calling.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -257,7 +257,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
* @param err This should always be set to a failure status prior to calling.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -284,7 +284,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -314,7 +314,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
* @see ucnv_setSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -370,7 +370,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -398,7 +398,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -424,7 +424,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -450,7 +450,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
diff --git a/deps/icu-small/source/common/unicode/ucnvsel.h b/deps/icu-small/source/common/unicode/ucnvsel.h
index 5fee53f179ace7..b84bc86bed2659 100644
--- a/deps/icu-small/source/common/unicode/ucnvsel.h
+++ b/deps/icu-small/source/common/unicode/ucnvsel.h
@@ -29,7 +29,10 @@
#include "unicode/utf16.h"
#include "unicode/uenum.h"
#include "unicode/ucnv.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -72,7 +75,7 @@ typedef struct UConverterSelector UConverterSelector;
*
* @stable ICU 4.2
*/
-U_STABLE UConverterSelector* U_EXPORT2
+U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_open(const char* const* converterList, int32_t converterListSize,
const USet* excludedCodePoints,
const UConverterUnicodeSet whichSet, UErrorCode* status);
@@ -90,7 +93,7 @@ ucnvsel_open(const char* const* converterList, int32_t converterListSize,
*
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnvsel_close(UConverterSelector *sel);
#if U_SHOW_CPLUSPLUS_API
@@ -127,7 +130,7 @@ U_NAMESPACE_END
*
* @stable ICU 4.2
*/
-U_STABLE UConverterSelector* U_EXPORT2
+U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status);
/**
@@ -144,7 +147,7 @@ ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* statu
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnvsel_serialize(const UConverterSelector* sel,
void* buffer, int32_t bufferCapacity, UErrorCode* status);
@@ -162,7 +165,7 @@ ucnvsel_serialize(const UConverterSelector* sel,
*
* @stable ICU 4.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForString(const UConverterSelector* sel,
const UChar *s, int32_t length, UErrorCode *status);
@@ -180,7 +183,7 @@ ucnvsel_selectForString(const UConverterSelector* sel,
*
* @stable ICU 4.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForUTF8(const UConverterSelector* sel,
const char *s, int32_t length, UErrorCode *status);
diff --git a/deps/icu-small/source/common/unicode/ucptrie.h b/deps/icu-small/source/common/unicode/ucptrie.h
index be06a227928286..b95491b183e9af 100644
--- a/deps/icu-small/source/common/unicode/ucptrie.h
+++ b/deps/icu-small/source/common/unicode/ucptrie.h
@@ -8,11 +8,13 @@
#define __UCPTRIE_H__
#include "unicode/utypes.h"
-
-#include "unicode/localpointer.h"
#include "unicode/ucpmap.h"
#include "unicode/utf8.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
U_CDECL_BEGIN
/**
@@ -580,11 +582,11 @@ enum {
// Do not conditionalize with #ifndef U_HIDE_INTERNAL_API, needed for public API
/** @internal */
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallIndex(const UCPTrie *trie, UChar32 c);
/** @internal */
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallU8Index(const UCPTrie *trie, int32_t lt1, uint8_t t2, uint8_t t3);
/**
@@ -592,7 +594,7 @@ ucptrie_internalSmallU8Index(const UCPTrie *trie, int32_t lt1, uint8_t t2, uint8
* Do not call directly.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c,
const uint8_t *start, const uint8_t *src);
diff --git a/deps/icu-small/source/common/unicode/ucurr.h b/deps/icu-small/source/common/unicode/ucurr.h
index 7149e7adf13067..4e115cd01e0fb6 100644
--- a/deps/icu-small/source/common/unicode/ucurr.h
+++ b/deps/icu-small/source/common/unicode/ucurr.h
@@ -78,7 +78,7 @@ typedef enum UCurrencyUsage UCurrencyUsage;
* invalid.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_forLocale(const char* locale,
UChar* buff,
int32_t buffCapacity,
@@ -113,7 +113,29 @@ typedef enum UCurrNameStyle {
*
* @stable ICU 61
*/
- UCURR_NARROW_SYMBOL_NAME
+ UCURR_NARROW_SYMBOL_NAME,
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Selector for getName() indicating the formal currency symbol.
+ * The formal currency symbol is similar to the regular currency
+ * symbol, but it always takes the form used in formal settings
+ * such as banking; for example, "NT$" instead of "$" for TWD in zh-TW.
+ *
+ * @draft ICU 68
+ */
+ UCURR_FORMAL_SYMBOL_NAME,
+
+ /**
+ * Selector for getName() indicating the variant currency symbol.
+ * The variant symbol for a currency is an alternative symbol
+ * that is not necessarily as widely used as the regular symbol.
+ *
+ * @draft ICU 68
+ */
+ UCURR_VARIANT_SYMBOL_NAME
+#endif // U_HIDE_DRAFT_API
+
} UCurrNameStyle;
#if !UCONFIG_NO_SERVICE
@@ -133,7 +155,7 @@ typedef const void* UCurrRegistryKey;
* if there was an error.
* @stable ICU 2.6
*/
-U_STABLE UCurrRegistryKey U_EXPORT2
+U_CAPI UCurrRegistryKey U_EXPORT2
ucurr_register(const UChar* isoCode,
const char* locale,
UErrorCode* status);
@@ -145,10 +167,10 @@ ucurr_register(const UChar* isoCode,
* 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
- * @return TRUE if the currency for this key was successfully unregistered
+ * @return true if the currency for this key was successfully unregistered
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
#endif /* UCONFIG_NO_SERVICE */
@@ -159,7 +181,7 @@ 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 always set to FALSE, or can be NULL;
+ * @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
@@ -169,7 +191,7 @@ ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
* returned.
* @stable ICU 2.6
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ucurr_getName(const UChar* currency,
const char* locale,
UCurrNameStyle nameStyle,
@@ -183,7 +205,7 @@ 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 always set to FALSE, or can be NULL;
+ * @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
@@ -194,7 +216,7 @@ ucurr_getName(const UChar* currency,
* returned.
* @stable ICU 4.2
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ucurr_getPluralName(const UChar* currency,
const char* locale,
UBool* isChoiceFormat,
@@ -219,7 +241,7 @@ ucurr_getPluralName(const UChar* currency,
* displayed, or 0 if there is an error
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getDefaultFractionDigits(const UChar* currency,
UErrorCode* ec);
@@ -240,7 +262,7 @@ ucurr_getDefaultFractionDigits(const UChar* currency,
* displayed, or 0 if there is an error
* @stable ICU 54
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getDefaultFractionDigitsForUsage(const UChar* currency,
const UCurrencyUsage usage,
UErrorCode* ec);
@@ -255,7 +277,7 @@ ucurr_getDefaultFractionDigitsForUsage(const UChar* currency,
* or 0.0 if there is an error
* @stable ICU 3.0
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
ucurr_getRoundingIncrement(const UChar* currency,
UErrorCode* ec);
@@ -269,7 +291,7 @@ ucurr_getRoundingIncrement(const UChar* currency,
* or 0.0 if there is an error
* @stable ICU 54
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
ucurr_getRoundingIncrementForUsage(const UChar* currency,
const UCurrencyUsage usage,
UErrorCode* ec);
@@ -326,7 +348,7 @@ typedef enum UCurrCurrencyType {
* @param pErrorCode Error code
* @stable ICU 3.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
/**
@@ -351,11 +373,11 @@ ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
* @param errorCode
* ICU error code
*
- * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range.
+ * @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
+U_CAPI UBool U_EXPORT2
ucurr_isAvailable(const UChar* isoCode,
UDate from,
UDate to,
@@ -375,7 +397,7 @@ ucurr_isAvailable(const UChar* isoCode,
* values are invalid.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_countCurrencies(const char* locale,
UDate date,
UErrorCode* ec);
@@ -399,7 +421,7 @@ ucurr_countCurrencies(const char* locale,
* invalid.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_forLocaleAndDate(const char* locale,
UDate date,
int32_t index,
@@ -423,7 +445,7 @@ ucurr_forLocaleAndDate(const char* locale,
* @return a string enumeration over keyword values for the given key and the locale.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucurr_getKeywordValuesForLocale(const char* key,
const char* locale,
UBool commonlyUsed,
@@ -438,7 +460,7 @@ ucurr_getKeywordValuesForLocale(const char* key,
* @return The ISO 4217 numeric code of the currency
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getNumericCode(const UChar* currency);
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/common/unicode/udata.h b/deps/icu-small/source/common/unicode/udata.h
index 8236877b443d3d..88c0dded118d00 100644
--- a/deps/icu-small/source/common/unicode/udata.h
+++ b/deps/icu-small/source/common/unicode/udata.h
@@ -20,7 +20,10 @@
#define __UDATA_H__
#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
U_CDECL_BEGIN
@@ -166,8 +169,8 @@ typedef struct UDataMemory UDataMemory;
* @param pInfo A pointer to the UDataInfo
structure
* of data that has been loaded and will be returned
* by udata_openChoice()
if this function
- * returns TRUE
.
- * @return TRUE if the current data memory is acceptable
+ * returns true
.
+ * @return true if the current data memory is acceptable
* @stable ICU 2.0
*/
typedef UBool U_CALLCONV
@@ -197,7 +200,7 @@ UDataMemoryIsAcceptable(void *context,
* @see udata_openChoice
* @stable ICU 2.0
*/
-U_STABLE UDataMemory * U_EXPORT2
+U_CAPI UDataMemory * U_EXPORT2
udata_open(const char *path, const char *type, const char *name,
UErrorCode *pErrorCode);
@@ -239,7 +242,7 @@ udata_open(const char *path, const char *type, const char *name,
* This may be NULL
or empty.
* @param name A string that specifies the name of the data.
* @param isAcceptable This function is called to verify that loaded data
- * is useful for the client code. If it returns FALSE
+ * is useful for the client code. If it returns false
* for all data items, then udata_openChoice()
* will return with an error.
* @param context Arbitrary parameter to be passed into isAcceptable.
@@ -249,7 +252,7 @@ udata_open(const char *path, const char *type, const char *name,
* to get a pointer to the actual data.
* @stable ICU 2.0
*/
-U_STABLE UDataMemory * U_EXPORT2
+U_CAPI UDataMemory * U_EXPORT2
udata_openChoice(const char *path, const char *type, const char *name,
UDataMemoryIsAcceptable *isAcceptable, void *context,
UErrorCode *pErrorCode);
@@ -261,7 +264,7 @@ udata_openChoice(const char *path, const char *type, const char *name,
* @param pData The pointer to data memory object
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_close(UDataMemory *pData);
/**
@@ -273,7 +276,7 @@ udata_close(UDataMemory *pData);
* @param pData The pointer to data memory object
* @stable ICU 2.0
*/
-U_STABLE const void * U_EXPORT2
+U_CAPI const void * U_EXPORT2
udata_getMemory(UDataMemory *pData);
/**
@@ -294,7 +297,7 @@ udata_getMemory(UDataMemory *pData);
* adjusted and only part of the structure will be filled.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
/**
@@ -303,7 +306,7 @@ udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
* area in memory.
*
* ICU data must be at least 8-aligned, and should be 16-aligned.
- * See http://userguide.icu-project.org/icudata
+ * See https://unicode-org.github.io/icu/userguide/icudata
*
* The format of this data is that of the icu common data file, as is
* generated by the pkgdata tool with mode=common or mode=dll.
@@ -340,7 +343,7 @@ udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
* @param err outgoing error status U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setCommonData(const void *data, UErrorCode *err);
@@ -350,7 +353,7 @@ udata_setCommonData(const void *data, UErrorCode *err);
* pointer.
*
* ICU data must be at least 8-aligned, and should be 16-aligned.
- * See http://userguide.icu-project.org/icudata
+ * See https://unicode-org.github.io/icu/userguide/icudata
*
* The format of this data is that of the icu common data file, like 'icudt26l.dat'
* or the corresponding shared library (DLL) file.
@@ -371,7 +374,7 @@ udata_setCommonData(const void *data, UErrorCode *err);
* @see udata_setCommonData
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setAppData(const char *packageName, const void *data, UErrorCode *err);
/**
@@ -410,7 +413,7 @@ typedef enum UDataFileAccess {
* @see UDataFileAccess
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setFileAccess(UDataFileAccess access, UErrorCode *status);
U_CDECL_END
diff --git a/deps/icu-small/source/common/unicode/udisplaycontext.h b/deps/icu-small/source/common/unicode/udisplaycontext.h
index 398481c6812247..6e1421798054f6 100644
--- a/deps/icu-small/source/common/unicode/udisplaycontext.h
+++ b/deps/icu-small/source/common/unicode/udisplaycontext.h
@@ -156,7 +156,8 @@ enum UDisplayContext {
UDISPCTX_SUBSTITUTE = (UDISPCTX_TYPE_SUBSTITUTE_HANDLING<<8) + 0,
/**
* A possible setting for SUBSTITUTE_HANDLING:
- * Returns a null value when no data is available.
+ * Returns a null value with error code set to U_ILLEGAL_ARGUMENT_ERROR when no
+ * data is available.
* @stable ICU 58
*/
UDISPCTX_NO_SUBSTITUTE = (UDISPCTX_TYPE_SUBSTITUTE_HANDLING<<8) + 1
diff --git a/deps/icu-small/source/common/unicode/uenum.h b/deps/icu-small/source/common/unicode/uenum.h
index eb8ecdf88b6ec5..f1c506934bec87 100644
--- a/deps/icu-small/source/common/unicode/uenum.h
+++ b/deps/icu-small/source/common/unicode/uenum.h
@@ -20,13 +20,14 @@
#define __UENUM_H
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+
U_NAMESPACE_BEGIN
class StringEnumeration;
U_NAMESPACE_END
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -49,7 +50,7 @@ typedef struct UEnumeration UEnumeration;
* @param en UEnumeration structure pointer
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uenum_close(UEnumeration* en);
#if U_SHOW_CPLUSPLUS_API
@@ -85,7 +86,7 @@ U_NAMESPACE_END
* @return number of elements in the iterator
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uenum_count(UEnumeration* en, UErrorCode* status);
/**
@@ -109,7 +110,7 @@ uenum_count(UEnumeration* en, UErrorCode* status);
* traversed, returns NULL.
* @stable ICU 2.2
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
uenum_unext(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status);
@@ -142,7 +143,7 @@ uenum_unext(UEnumeration* en,
* traversed, returns NULL.
* @stable ICU 2.2
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uenum_next(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status);
@@ -156,7 +157,7 @@ uenum_next(UEnumeration* en,
* the iterator is out of sync with its service.
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uenum_reset(UEnumeration* en, UErrorCode* status);
#if U_SHOW_CPLUSPLUS_API
@@ -170,7 +171,7 @@ uenum_reset(UEnumeration* en, UErrorCode* status);
* @return a UEnumeration wrapping the adopted StringEnumeration.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec);
#endif
@@ -186,7 +187,7 @@ uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec)
* @see uenum_close
* @stable ICU 50
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,
UErrorCode* ec);
@@ -201,7 +202,7 @@ uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,
* @see uenum_close
* @stable ICU 50
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openCharStringsEnumeration(const char* const strings[], int32_t count,
UErrorCode* ec);
diff --git a/deps/icu-small/source/common/unicode/uidna.h b/deps/icu-small/source/common/unicode/uidna.h
index cb79ba8545008e..1f75562555c3c2 100644
--- a/deps/icu-small/source/common/unicode/uidna.h
+++ b/deps/icu-small/source/common/unicode/uidna.h
@@ -23,9 +23,13 @@
#if !UCONFIG_NO_IDNA
-#include "unicode/localpointer.h"
+#include
#include "unicode/parseerr.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Internationalizing Domain Names in Applications (IDNA)
@@ -138,7 +142,7 @@ typedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */
* @return the UTS #46 UIDNA instance, if successful
* @stable ICU 4.6
*/
-U_STABLE UIDNA * U_EXPORT2
+U_CAPI UIDNA * U_EXPORT2
uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
/**
@@ -146,7 +150,7 @@ uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
* @param idna UIDNA instance to be closed
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uidna_close(UIDNA *idna);
#if U_SHOW_CPLUSPLUS_API
@@ -182,7 +186,7 @@ typedef struct UIDNAInfo {
/** sizeof(UIDNAInfo) @stable ICU 4.6 */
int16_t size;
/**
- * Set to TRUE if transitional and nontransitional processing produce different results.
+ * Set to true if transitional and nontransitional processing produce different results.
* For details see C++ IDNAInfo::isTransitionalDifferent().
* @stable ICU 4.6
*/
@@ -204,7 +208,7 @@ typedef struct UIDNAInfo {
*/
#define UIDNA_INFO_INITIALIZER { \
(int16_t)sizeof(UIDNAInfo), \
- FALSE, FALSE, \
+ false, false, \
0, 0, 0 }
/**
@@ -230,7 +234,7 @@ typedef struct UIDNAInfo {
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToASCII(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
@@ -257,7 +261,7 @@ uidna_labelToASCII(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToUnicode(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
@@ -286,7 +290,7 @@ uidna_labelToUnicode(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToASCII(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
@@ -313,7 +317,7 @@ uidna_nameToASCII(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToUnicode(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
@@ -338,7 +342,7 @@ uidna_nameToUnicode(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToASCII_UTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
@@ -361,7 +365,7 @@ uidna_labelToASCII_UTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToUnicodeUTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
@@ -384,7 +388,7 @@ uidna_labelToUnicodeUTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToASCII_UTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
@@ -407,7 +411,7 @@ uidna_nameToASCII_UTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToUnicodeUTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
diff --git a/deps/icu-small/source/common/unicode/uiter.h b/deps/icu-small/source/common/unicode/uiter.h
index 3b8537204cecfa..7dbe1266668f24 100644
--- a/deps/icu-small/source/common/unicode/uiter.h
+++ b/deps/icu-small/source/common/unicode/uiter.h
@@ -492,7 +492,7 @@ struct UCharIterator {
* @see UnicodeString::char32At()
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_current32(UCharIterator *iter);
/**
@@ -509,7 +509,7 @@ uiter_current32(UCharIterator *iter);
* @see U16_NEXT
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_next32(UCharIterator *iter);
/**
@@ -526,7 +526,7 @@ uiter_next32(UCharIterator *iter);
* @see U16_PREV
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_previous32(UCharIterator *iter);
/**
@@ -547,7 +547,7 @@ uiter_previous32(UCharIterator *iter);
* @see UITER_NO_STATE
* @stable ICU 2.6
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
uiter_getState(const UCharIterator *iter);
/**
@@ -565,7 +565,7 @@ uiter_getState(const UCharIterator *iter);
* @see UCharIteratorSetState
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
/**
@@ -590,7 +590,7 @@ uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
/**
@@ -613,7 +613,7 @@ uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
* @see uiter_setString
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
/**
@@ -649,7 +649,7 @@ uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
* @see UCharIterator
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
#if U_SHOW_CPLUSPLUS_API
@@ -674,7 +674,7 @@ uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter);
/**
@@ -699,7 +699,7 @@ uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep);
#endif
diff --git a/deps/icu-small/source/common/unicode/uldnames.h b/deps/icu-small/source/common/unicode/uldnames.h
index 3a3c0a06573c36..10f0e91e5526e4 100644
--- a/deps/icu-small/source/common/unicode/uldnames.h
+++ b/deps/icu-small/source/common/unicode/uldnames.h
@@ -16,10 +16,13 @@
*/
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/uscript.h"
#include "unicode/udisplaycontext.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* Enum used in LocaleDisplayNames::createInstance.
* @stable ICU 4.4
@@ -65,7 +68,7 @@ typedef struct ULocaleDisplayNames ULocaleDisplayNames;
* @param pErrorCode the status code
* @stable ICU 4.4
*/
-U_STABLE ULocaleDisplayNames * U_EXPORT2
+U_CAPI ULocaleDisplayNames * U_EXPORT2
uldn_open(const char * locale,
UDialectHandling dialectHandling,
UErrorCode *pErrorCode);
@@ -75,7 +78,7 @@ uldn_open(const char * locale,
* @param ldn the ULocaleDisplayNames instance to be closed
* @stable ICU 4.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uldn_close(ULocaleDisplayNames *ldn);
#if U_SHOW_CPLUSPLUS_API
@@ -106,7 +109,7 @@ U_NAMESPACE_END
* @return the display locale
* @stable ICU 4.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uldn_getLocale(const ULocaleDisplayNames *ldn);
/**
@@ -115,7 +118,7 @@ uldn_getLocale(const ULocaleDisplayNames *ldn);
* @return the dialect handling enum
* @stable ICU 4.4
*/
-U_STABLE UDialectHandling U_EXPORT2
+U_CAPI UDialectHandling U_EXPORT2
uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
/* names for entire locales */
@@ -131,7 +134,7 @@ uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
const char *locale,
UChar *result,
@@ -151,7 +154,7 @@ uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
const char *lang,
UChar *result,
@@ -169,7 +172,7 @@ uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
const char *script,
UChar *result,
@@ -187,7 +190,7 @@ uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
UScriptCode scriptCode,
UChar *result,
@@ -205,7 +208,7 @@ uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
const char *region,
UChar *result,
@@ -223,7 +226,7 @@ uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
const char *variant,
UChar *result,
@@ -241,7 +244,7 @@ uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
UChar *result,
@@ -260,7 +263,7 @@ uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
const char *value,
@@ -282,7 +285,7 @@ uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
* @return a ULocaleDisplayNames instance
* @stable ICU 51
*/
-U_STABLE ULocaleDisplayNames * U_EXPORT2
+U_CAPI ULocaleDisplayNames * U_EXPORT2
uldn_openForContext(const char * locale, UDisplayContext *contexts,
int32_t length, UErrorCode *pErrorCode);
@@ -296,7 +299,7 @@ uldn_openForContext(const char * locale, UDisplayContext *contexts,
* @return the UDisplayContextValue for the specified type.
* @stable ICU 51
*/
-U_STABLE UDisplayContext U_EXPORT2
+U_CAPI UDisplayContext U_EXPORT2
uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,
UErrorCode *pErrorCode);
diff --git a/deps/icu-small/source/common/unicode/uloc.h b/deps/icu-small/source/common/unicode/uloc.h
index a10ab526cec141..56fb4c9b3769e0 100644
--- a/deps/icu-small/source/common/unicode/uloc.h
+++ b/deps/icu-small/source/common/unicode/uloc.h
@@ -371,7 +371,7 @@ typedef enum {
* @system
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getDefault(void);
/**
@@ -391,7 +391,7 @@ uloc_getDefault(void);
* @system
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uloc_setDefault(const char* localeID,
UErrorCode* status);
#endif /* U_HIDE_SYSTEM_API */
@@ -408,7 +408,7 @@ uloc_setDefault(const char* localeID,
* than languageCapacity, the returned language code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getLanguage(const char* localeID,
char* language,
int32_t languageCapacity,
@@ -426,7 +426,7 @@ uloc_getLanguage(const char* localeID,
* than scriptCapacity, the returned language code will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getScript(const char* localeID,
char* script,
int32_t scriptCapacity,
@@ -444,7 +444,7 @@ uloc_getScript(const char* localeID,
* than countryCapacity, the returned country code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getCountry(const char* localeID,
char* country,
int32_t countryCapacity,
@@ -462,7 +462,7 @@ uloc_getCountry(const char* localeID,
* than variantCapacity, the returned variant code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getVariant(const char* localeID,
char* variant,
int32_t variantCapacity,
@@ -485,7 +485,7 @@ uloc_getVariant(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getName(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -508,7 +508,7 @@ uloc_getName(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_canonicalize(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -521,7 +521,7 @@ uloc_canonicalize(const char* localeID,
* @return language the ISO language code for localeID
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getISO3Language(const char* localeID);
@@ -532,7 +532,7 @@ uloc_getISO3Language(const char* localeID);
* @return country the ISO country code for localeID
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID);
/**
@@ -546,26 +546,31 @@ uloc_getISO3Country(const char* localeID);
* @return country the Win32 LCID for localeID
* @stable ICU 2.0
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
uloc_getLCID(const char* localeID);
/**
* Gets the language name suitable for display for the specified locale.
*
* @param locale the locale to get the ISO language code with
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * inLocale would result in "Anglais", while passing Locale::getGerman()
- * for inLocale would result in "Englisch".
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for 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
- * 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.
+ * displayable language code with.
+ * @param status error information if retrieving the displayable language code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * language code is placed into language as fallback.
+ * @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
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayLanguage(const char* locale,
const char* displayLocale,
UChar* language,
@@ -575,20 +580,26 @@ uloc_getDisplayLanguage(const char* locale,
/**
* Gets the script name suitable for display for the specified locale.
*
- * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * 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
- * 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.
+ * @param locale the locale to get the displayable script code with. NULL may be
+ * used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for 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 displayable
+ * script code with.
+ * @param status error information if retrieving the displayable script code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * script code is placed into script as fallback.
+ * @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
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayScript(const char* locale,
const char* displayLocale,
UChar* script,
@@ -597,23 +608,30 @@ uloc_getDisplayScript(const char* locale,
/**
* Gets the country name suitable for display for the specified locale.
- * Warning: this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
- * To get the display name for a region alone, or for other options, use ULocaleDisplayNames instead.
- *
- * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * 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
+ * Warning: this is for the region part of a valid locale ID; it cannot just be
+ * the region code (like "FR"). To get the display name for a region alone, or
+ * for other options, use ULocaleDisplayNames instead.
+ *
+ * @param locale the locale to get the displayable country code with. NULL may
+ * be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for 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
- * 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.
+ * displayable country code with.
+ * @param status error information if retrieving the displayable country code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * country code is placed into country as fallback.
+ * @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
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayCountry(const char* locale,
const char* displayLocale,
UChar* country,
@@ -624,20 +642,26 @@ uloc_getDisplayCountry(const char* locale,
/**
* Gets the variant name suitable for display for the specified locale.
*
- * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * 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 locale the locale to get the displayable variant code with. NULL may
+ * be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for 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
- * 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.
+ * displayable variant code with.
+ * @param status error information if retrieving the displayable variant code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * variant code is placed into variant as fallback.
+ * @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
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayVariant(const char* locale,
const char* displayLocale,
UChar* variant,
@@ -645,8 +669,8 @@ uloc_getDisplayVariant(const char* locale,
UErrorCode* status);
/**
- * 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
+ * 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.
* Usage:
*
@@ -680,11 +704,13 @@ uloc_getDisplayVariant(const char* locale,
* result without writing any of the result string (pre-flighting).
* @param status error information if retrieving the displayable string failed.
* Should not be NULL and should not indicate failure on entry.
+ * U_USING_DEFAULT_WARNING indicates that no data was found from the locale
+ * resources and the keyword is placed into dest as fallback.
* @return the actual buffer size needed for the displayable variant code.
* @see #uloc_openKeywords
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeyword(const char* keyword,
const char* displayLocale,
UChar* dest,
@@ -707,10 +733,12 @@ uloc_getDisplayKeyword(const char* keyword,
* result without writing any of the result string (pre-flighting).
* @param status error information if retrieving the displayable string failed.
* Should not be NULL and must not indicate failure on entry.
+ * U_USING_DEFAULT_WARNING indicates that no data was found from the locale
+ * resources and the value of the keyword is placed into dest as fallback.
* @return the actual buffer size needed for the displayable variant code.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeywordValue( const char* locale,
const char* keyword,
const char* displayLocale,
@@ -733,7 +761,7 @@ uloc_getDisplayKeywordValue( const char* locale,
* than maxResultSize, the returned displayable name will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayName(const char* localeID,
const char* inLocaleID,
UChar* result,
@@ -757,7 +785,7 @@ uloc_getDisplayName(const char* localeID,
* @return a specified locale name of all available locales
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getAvailable(int32_t n);
/**
@@ -766,21 +794,19 @@ uloc_getAvailable(int32_t n);
* @return the size of the locale list
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
-
-#ifndef U_HIDE_DRAFT_API
+U_CAPI int32_t U_EXPORT2 uloc_countAvailable(void);
/**
* Types for uloc_getAvailableByType and uloc_countAvailableByType.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
typedef enum ULocAvailableType {
/**
* Locales that return data when passed to ICU APIs,
* but not including legacy or alias locales.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_DEFAULT,
@@ -798,7 +824,7 @@ typedef enum ULocAvailableType {
* ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use
* ULOC_AVAILABLE_WITH_LEGACY_ALIASES.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_ONLY_LEGACY_ALIASES,
@@ -806,7 +832,7 @@ typedef enum ULocAvailableType {
* The union of the locales in ULOC_AVAILABLE_DEFAULT and
* ULOC_AVAILABLE_ONLY_LEGACY_ALIAS.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_WITH_LEGACY_ALIASES,
@@ -827,13 +853,11 @@ typedef enum ULocAvailableType {
* @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
+ * @stable ICU 65
*/
-U_DRAFT UEnumeration* U_EXPORT2
+U_CAPI 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,
@@ -845,7 +869,7 @@ uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
* @return a list of all available language codes
* @stable ICU 2.0
*/
-U_STABLE const char* const* U_EXPORT2
+U_CAPI const char* const* U_EXPORT2
uloc_getISOLanguages(void);
/**
@@ -857,7 +881,7 @@ uloc_getISOLanguages(void);
* @return a list of all available country codes
* @stable ICU 2.0
*/
-U_STABLE const char* const* U_EXPORT2
+U_CAPI const char* const* U_EXPORT2
uloc_getISOCountries(void);
/**
@@ -873,7 +897,7 @@ uloc_getISOCountries(void);
* @return The length of the parent locale ID.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getParent(const char* localeID,
char* parent,
int32_t parentCapacity,
@@ -904,7 +928,7 @@ uloc_getParent(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getBaseName(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -919,7 +943,7 @@ uloc_getBaseName(const char* localeID,
* @return enumeration of keywords or NULL if there are no keywords.
* @stable ICU 2.8
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywords(const char* localeID,
UErrorCode* status);
@@ -936,7 +960,7 @@ uloc_openKeywords(const char* localeID,
* @return the length of keyword value
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getKeywordValue(const char* localeID,
const char* keywordName,
char* buffer, int32_t bufferCapacity,
@@ -973,7 +997,7 @@ uloc_getKeywordValue(const char* localeID,
* @see uloc_getKeywordValue
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_setKeywordValue(const char* keywordName,
const char* keywordValue,
char* buffer, int32_t bufferCapacity,
@@ -982,18 +1006,18 @@ uloc_setKeywordValue(const char* keywordName,
/**
* Returns whether the locale's script is written right-to-left.
* If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
- * If no likely script is known, then FALSE is returned.
+ * If no likely script is known, then false is returned.
*
* A script is right-to-left according to the CLDR script metadata
* which corresponds to whether the script's letters have Bidi_Class=R or AL.
*
- * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
+ * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl".
*
* @param locale input locale ID
- * @return TRUE if the locale's script is written right-to-left
+ * @return true if the locale's script is written right-to-left
* @stable ICU 54
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uloc_isRightToLeft(const char *locale);
/**
@@ -1017,7 +1041,7 @@ typedef enum {
* @return an enum indicating the layout orientation for characters.
* @stable ICU 4.0
*/
-U_STABLE ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
uloc_getCharacterOrientation(const char* localeId,
UErrorCode *status);
@@ -1029,7 +1053,7 @@ uloc_getCharacterOrientation(const char* localeId,
* @return an enum indicating the layout orientation for lines.
* @stable ICU 4.0
*/
-U_STABLE ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
uloc_getLineOrientation(const char* localeId,
UErrorCode *status);
@@ -1076,7 +1100,7 @@ typedef enum {
* @return length needed for the locale.
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
UAcceptResult *outResult,
const char *httpAcceptLanguage,
@@ -1101,7 +1125,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
* @return length needed for the locale.
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_acceptLanguage(char *result, int32_t resultAvailable,
UAcceptResult *outResult, const char **acceptList,
int32_t acceptListCount,
@@ -1121,7 +1145,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable,
* @return actual the actual size of the locale ID, not including NUL-termination
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
UErrorCode *status);
@@ -1159,7 +1183,7 @@ uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
* On error, the return value is -1.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_addLikelySubtags(const char* localeID,
char* maximizedLocaleID,
int32_t maximizedLocaleIDCapacity,
@@ -1199,7 +1223,7 @@ uloc_addLikelySubtags(const char* localeID,
* On error, the return value is -1.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_minimizeSubtags(const char* localeID,
char* minimizedLocaleID,
int32_t minimizedLocaleIDCapacity,
@@ -1210,13 +1234,17 @@ uloc_minimizeSubtags(const char* localeID,
* 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',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @param langtag the input BCP47 language tag.
* @param localeID the output buffer receiving a locale ID for the
* specified BCP47 language tag.
@@ -1228,7 +1256,7 @@ uloc_minimizeSubtags(const char* localeID,
* @return the length of the locale ID.
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_forLanguageTag(const char* langtag,
char* localeID,
int32_t localeIDCapacity,
@@ -1238,10 +1266,10 @@ uloc_forLanguageTag(const char* langtag,
/**
* Returns a well-formed language tag for this locale ID.
*
- * Note: When strict
is FALSE, any locale
+ * 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
- * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
+ * true, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
* err
if any locale fields do not satisfy the
* BCP47 syntax requirement.
* @param localeID the input locale ID
@@ -1256,7 +1284,7 @@ uloc_forLanguageTag(const char* langtag,
* @return The length of the BCP47 language tag.
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_toLanguageTag(const char* localeID,
char* langtag,
int32_t langtagCapacity,
@@ -1284,7 +1312,7 @@ uloc_toLanguageTag(const char* localeID,
* @see uloc_toLegacyKey
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleKey(const char* keyword);
/**
@@ -1315,7 +1343,7 @@ uloc_toUnicodeLocaleKey(const char* keyword);
* @see uloc_toLegacyType
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleType(const char* keyword, const char* value);
/**
@@ -1330,7 +1358,7 @@ uloc_toUnicodeLocaleType(const char* keyword, const char* value);
* @see toUnicodeLocaleKey
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toLegacyKey(const char* keyword);
/**
@@ -1359,7 +1387,7 @@ uloc_toLegacyKey(const char* keyword);
* @see toUnicodeLocaleType
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toLegacyType(const char* keyword, const char* value);
#endif /*_ULOC*/
diff --git a/deps/icu-small/source/common/unicode/umachine.h b/deps/icu-small/source/common/unicode/umachine.h
index ff5deb8d01786a..219d1ee1911d02 100644
--- a/deps/icu-small/source/common/unicode/umachine.h
+++ b/deps/icu-small/source/common/unicode/umachine.h
@@ -49,12 +49,13 @@
* ANSI C headers:
* stddef.h defines wchar_t
*/
+#include
#include
/*==========================================================================*/
-/* For C wrappers, we use the symbol U_STABLE. */
+/* For C wrappers, we use the symbol U_CAPI. */
/* This works properly if the includer is C or C++. */
-/* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
+/* Functions are declared U_CAPI return-type U_EXPORT2 function-name()... */
/*==========================================================================*/
/**
@@ -107,15 +108,15 @@
/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
#define U_CAPI U_CFUNC U_EXPORT
-/** This is used to declare a function as a stable public ICU C API*/
+/** Obsolete/same as U_CAPI; was used to declare a function as a stable public ICU C API*/
#define U_STABLE U_CAPI
-/** This is used to declare a function as a draft public ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as a draft public ICU C API */
#define U_DRAFT U_CAPI
/** This is used to declare a function as a deprecated public ICU C API */
#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
-/** This is used to declare a function as an obsolete public ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as an obsolete public ICU C API */
#define U_OBSOLETE U_CAPI
-/** This is used to declare a function as an internal ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as an internal ICU C API */
#define U_INTERNAL U_CAPI
/**
@@ -170,11 +171,11 @@
/**
* \def UPRV_BLOCK_MACRO_END
- * Defined as "while (FALSE)" by default.
+ * Defined as "while (false)" by default.
* @internal
*/
#ifndef UPRV_BLOCK_MACRO_END
-#define UPRV_BLOCK_MACRO_END while (FALSE)
+#define UPRV_BLOCK_MACRO_END while (false)
#endif
/*==========================================================================*/
@@ -257,18 +258,59 @@
/* Boolean data type */
/*==========================================================================*/
-/** The ICU boolean type @stable ICU 2.0 */
+/**
+ * The ICU boolean type, a signed-byte integer.
+ * ICU-specific for historical reasons: The C and C++ standards used to not define type bool.
+ * Also provides a fixed type definition, as opposed to
+ * type bool whose details (e.g., sizeof) may vary by compiler and between C and C++.
+ *
+ * @stable ICU 2.0
+ */
typedef int8_t UBool;
+/**
+ * \def U_DEFINE_FALSE_AND_TRUE
+ * Normally turns off defining macros FALSE=0 & TRUE=1 in public ICU headers.
+ * These obsolete macros sometimes break compilation of other code that
+ * defines enum constants or similar with these names.
+ * C++ has long defined bool/false/true.
+ * C99 also added definitions for these, although as macros; see stdbool.h.
+ *
+ * You may transitionally define U_DEFINE_FALSE_AND_TRUE=1 if you need time to migrate code.
+ *
+ * @internal ICU 68
+ */
+#ifdef U_DEFINE_FALSE_AND_TRUE
+ // Use the predefined value.
+#elif defined(U_COMBINED_IMPLEMENTATION) || \
+ defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || \
+ defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || \
+ defined(U_TOOLUTIL_IMPLEMENTATION)
+ // Inside ICU: Keep FALSE & TRUE available.
+# define U_DEFINE_FALSE_AND_TRUE 1
+#else
+ // Outside ICU: Avoid collision with non-macro definitions of FALSE & TRUE.
+# define U_DEFINE_FALSE_AND_TRUE 0
+#endif
+
+#if U_DEFINE_FALSE_AND_TRUE || defined(U_IN_DOXYGEN)
#ifndef TRUE
-/** The TRUE value of a UBool @stable ICU 2.0 */
+/**
+ * The TRUE value of a UBool.
+ *
+ * @deprecated ICU 68 Use standard "true" instead.
+ */
# define TRUE 1
#endif
#ifndef FALSE
-/** The FALSE value of a UBool @stable ICU 2.0 */
+/**
+ * The FALSE value of a UBool.
+ *
+ * @deprecated ICU 68 Use standard "false" instead.
+ */
# define FALSE 0
#endif
-
+#endif // U_DEFINE_FALSE_AND_TRUE
/*==========================================================================*/
/* Unicode data types */
diff --git a/deps/icu-small/source/common/unicode/umutablecptrie.h b/deps/icu-small/source/common/unicode/umutablecptrie.h
index f2af36477d5300..5325d58147ab1f 100644
--- a/deps/icu-small/source/common/unicode/umutablecptrie.h
+++ b/deps/icu-small/source/common/unicode/umutablecptrie.h
@@ -9,11 +9,14 @@
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/ucpmap.h"
#include "unicode/ucptrie.h"
#include "unicode/utf8.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
U_CDECL_BEGIN
/**
diff --git a/deps/icu-small/source/common/unicode/unimatch.h b/deps/icu-small/source/common/unicode/unimatch.h
index 2d3c5210c38e25..10efd3d007a5ca 100644
--- a/deps/icu-small/source/common/unicode/unimatch.h
+++ b/deps/icu-small/source/common/unicode/unimatch.h
@@ -115,11 +115,11 @@ class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an int
* considered for matching will be text.charAt(limit-1) in the
* forward direction or text.charAt(limit+1) in the backward
* direction.
- * @param incremental if TRUE, then assume further characters may
+ * @param incremental if true, then assume further characters may
* be inserted at limit and check for partial matching. Otherwise
* assume the text as given is complete.
* @return a match degree value indicating a full match, a partial
- * match, or a mismatch. If incremental is FALSE then
+ * match, or a mismatch. If incremental is false then
* U_PARTIAL_MATCH should never be returned.
* @stable ICU 2.4
*/
@@ -134,17 +134,17 @@ class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an int
* will produce another matcher that is equal to this one.
* @param result the string to receive the pattern. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
* @stable ICU 2.4
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const = 0;
+ UBool escapeUnprintable = false) const = 0;
/**
- * Returns TRUE if this matcher will match a character c, where c
+ * Returns true if this matcher will match a character c, where c
* & 0xFF == v, at offset, in the forward direction (with limit >
* offset). This is used by RuleBasedTransliterator for
* indexing.
diff --git a/deps/icu-small/source/common/unicode/uniset.h b/deps/icu-small/source/common/unicode/uniset.h
index 18cc9376442a2f..4179507af18e6f 100644
--- a/deps/icu-small/source/common/unicode/uniset.h
+++ b/deps/icu-small/source/common/unicode/uniset.h
@@ -325,7 +325,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
* A bogus set has no value. It is different from an empty set.
* It can be used to indicate that no set value is available.
*
- * @return TRUE if the set is bogus/invalid, FALSE otherwise
+ * @return true if the set is bogus/invalid, false otherwise
* @see setToBogus()
* @stable ICU 4.0
*/
@@ -333,7 +333,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
/**
* Make this UnicodeSet object invalid.
- * The string will test TRUE with isBogus().
+ * The string will test true with isBogus().
*
* A bogus set has no value. It is different from an empty set.
* It can be used to indicate that no set value is available.
@@ -563,7 +563,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
/**
* Determines whether the set has been frozen (made immutable) or not.
* See the ICU4J Freezable interface for details.
- * @return TRUE/FALSE for whether the set has been frozen
+ * @return true/false for whether the set has been frozen
* @see freeze
* @see cloneAsThawed
* @stable ICU 3.8
@@ -700,14 +700,14 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
* A frozen set will not be modified.
* @param result the string to receive the rules. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
* @stable ICU 2.0
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const;
+ UBool escapeUnprintable = false) const;
/**
* Modifies this set to contain those code points which have the given value
@@ -1636,7 +1636,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);
/**
- * A filter that returns TRUE if the given code point should be
+ * A filter that returns true if the given code point should be
* included in the UnicodeSet being constructed.
*/
typedef UBool (*Filter)(UChar32 codePoint, void* context);
diff --git a/deps/icu-small/source/common/unicode/unistr.h b/deps/icu-small/source/common/unicode/unistr.h
index da79053765acf6..456389f265fea0 100644
--- a/deps/icu-small/source/common/unicode/unistr.h
+++ b/deps/icu-small/source/common/unicode/unistr.h
@@ -45,7 +45,7 @@ struct UConverter; // unicode/ucnv.h
/**
* \ingroup ustring_ustrlen
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strlen(const UChar *s);
#endif
@@ -113,9 +113,9 @@ class UnicodeStringAppendable; // unicode/appendable.h
* @stable ICU 2.0
*/
#if !U_CHAR16_IS_TYPEDEF
-# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, u ## cs, _length)
+# define UNICODE_STRING(cs, _length) icu::UnicodeString(true, u ## cs, _length)
#else
-# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const char16_t*)u ## cs, _length)
+# define UNICODE_STRING(cs, _length) icu::UnicodeString(true, (const char16_t*)u ## cs, _length)
#endif
/**
@@ -227,7 +227,7 @@ class UnicodeStringAppendable; // unicode/appendable.h
* The UnicodeString class is not suitable for subclassing.
*
* For an overview of Unicode strings in C and C++ see the
- * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Strings-in-C-C-).
+ * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#strings-in-cc).
*
* In ICU, a Unicode string consists of 16-bit Unicode *code units*.
* A Unicode character may be stored with either one code unit
@@ -285,7 +285,7 @@ class UnicodeStringAppendable; // unicode/appendable.h
* significant performance improvements.
* Also, the internal buffer is accessible via special functions.
* For details see the
- * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Maximizing-Performance-with-the-UnicodeString-Storage-Model).
+ * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#maximizing-performance-with-the-unicodestring-storage-model).
*
* @see utf.h
* @see CharacterIterator
@@ -320,8 +320,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Equality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if `text` contains the same characters as this one,
- * FALSE otherwise.
+ * @return true if `text` contains the same characters as this one,
+ * false otherwise.
* @stable ICU 2.0
*/
inline UBool operator== (const UnicodeString& text) const;
@@ -329,8 +329,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Inequality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return FALSE if `text` contains the same characters as this one,
- * TRUE otherwise.
+ * @return false if `text` contains the same characters as this one,
+ * true otherwise.
* @stable ICU 2.0
*/
inline UBool operator!= (const UnicodeString& text) const;
@@ -338,8 +338,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Greater than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * greater than the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * greater than the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator> (const UnicodeString& text) const;
@@ -347,8 +347,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Less than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * less than the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * less than the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator< (const UnicodeString& text) const;
@@ -356,8 +356,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Greater than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * greater than or equal to the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * greater than or equal to the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator>= (const UnicodeString& text) const;
@@ -365,8 +365,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Less than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * less than or equal to the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * less than or equal to the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator<= (const UnicodeString& text) const;
@@ -855,8 +855,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Determine if this starts with the characters in `text`
* @param text The text to match.
- * @return TRUE if this starts with the characters in `text`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& text) const;
@@ -867,8 +867,8 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param srcText The text to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcText` to match
- * @return TRUE if this starts with the characters in `text`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& srcText,
@@ -879,8 +879,8 @@ class U_COMMON_API UnicodeString : public Replaceable
* Determine if this starts with the characters in `srcChars`
* @param srcChars The characters to match.
* @param srcLength the number of characters in `srcChars`
- * @return TRUE if this starts with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(ConstChar16Ptr srcChars,
@@ -892,7 +892,7 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param srcChars The characters to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcChars` to match
- * @return TRUE if this ends with the characters in `srcChars`, FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`, false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const char16_t *srcChars,
@@ -902,8 +902,8 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Determine if this ends with the characters in `text`
* @param text The text to match.
- * @return TRUE if this ends with the characters in `text`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& text) const;
@@ -914,8 +914,8 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param srcText The text to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcText` to match
- * @return TRUE if this ends with the characters in `text`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& srcText,
@@ -926,8 +926,8 @@ class U_COMMON_API UnicodeString : public Replaceable
* Determine if this ends with the characters in `srcChars`
* @param srcChars The characters to match.
* @param srcLength the number of characters in `srcChars`
- * @return TRUE if this ends with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(ConstChar16Ptr srcChars,
@@ -939,8 +939,8 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param srcChars The characters to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcChars` to match
- * @return TRUE if this ends with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const char16_t *srcChars,
@@ -1804,7 +1804,7 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Determine if this string is empty.
- * @return TRUE if this string contains 0 characters, FALSE otherwise.
+ * @return true if this string contains 0 characters, false otherwise.
* @stable ICU 2.0
*/
inline UBool isEmpty(void) const;
@@ -1832,12 +1832,12 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Determine if this object contains a valid string.
* A bogus string has no value. It is different from an empty string,
- * although in both cases isEmpty() returns TRUE and length() returns 0.
+ * although in both cases isEmpty() returns true and length() returns 0.
* setToBogus() and isBogus() can be used to indicate that no string value is available.
* For a bogus string, getBuffer() and getTerminatedBuffer() return NULL, and
* length() returns 0.
*
- * @return TRUE if the string is bogus/invalid, FALSE otherwise
+ * @return true if the string is bogus/invalid, false otherwise
* @see setToBogus()
* @stable ICU 2.0
*/
@@ -2067,7 +2067,7 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Make this UnicodeString object invalid.
- * The string will test TRUE with isBogus().
+ * The string will test true with isBogus().
*
* A bogus string has no value. It is different from an empty string.
* It can be used to indicate that no string value is available.
@@ -2459,7 +2459,7 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Replaceable API
- * @return TRUE if it has MetaData
+ * @return true if it has MetaData
* @stable ICU 2.4
*/
virtual UBool hasMetaData() const;
@@ -2590,7 +2590,7 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param targetLength the desired length of the string
* @param padChar the character to use for padding. Defaults to
* space (U+0020)
- * @return TRUE if the text was padded, FALSE otherwise.
+ * @return true if the text was padded, false otherwise.
* @stable ICU 2.0
*/
UBool padLeading(int32_t targetLength,
@@ -2604,7 +2604,7 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param targetLength the desired length of the string
* @param padChar the character to use for padding. Defaults to
* space (U+0020)
- * @return TRUE if the text was padded, FALSE otherwise.
+ * @return true if the text was padded, false otherwise.
* @stable ICU 2.0
*/
UBool padTrailing(int32_t targetLength,
@@ -2613,7 +2613,7 @@ class U_COMMON_API UnicodeString : public Replaceable
/**
* Truncate this UnicodeString to the `targetLength`.
* @param targetLength the desired length of this UnicodeString.
- * @return TRUE if the text was truncated, FALSE otherwise
+ * @return true if the text was truncated, false otherwise
* @stable ICU 2.0
*/
inline UBool truncate(int32_t targetLength);
@@ -3615,7 +3615,7 @@ class U_COMMON_API UnicodeString : public Replaceable
void unBogus();
// implements assigment operator, copy constructor, and fastCopyFrom()
- UnicodeString ©From(const UnicodeString &src, UBool fastCopy=FALSE);
+ UnicodeString ©From(const UnicodeString &src, UBool fastCopy=false);
// Copies just the fields without memory management.
void copyFieldsFrom(UnicodeString &src, UBool setSrcToBogus) U_NOEXCEPT;
@@ -3668,13 +3668,13 @@ class U_COMMON_API UnicodeString : public Replaceable
* the buffer is refCounted (shared), and refCount>1, or
* the buffer is too small.
*
- * Return FALSE if memory could not be allocated.
+ * Return false if memory could not be allocated.
*/
UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
int32_t growCapacity = -1,
- UBool doCopyArray = TRUE,
+ UBool doCopyArray = true,
int32_t **pBufferToDelete = 0,
- UBool forceClone = FALSE);
+ UBool forceClone = false);
/**
* Common function for UnicodeString case mappings.
@@ -4732,12 +4732,12 @@ UnicodeString::truncate(int32_t targetLength)
if(isBogus() && targetLength == 0) {
// truncate(0) of a bogus string makes the string empty and non-bogus
unBogus();
- return FALSE;
+ return false;
} else if((uint32_t)targetLength < (uint32_t)length()) {
setLength(targetLength);
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
diff --git a/deps/icu-small/source/common/unicode/unorm.h b/deps/icu-small/source/common/unicode/unorm.h
index 09dd366a968c1b..c3c57582d449d5 100644
--- a/deps/icu-small/source/common/unicode/unorm.h
+++ b/deps/icu-small/source/common/unicode/unorm.h
@@ -274,7 +274,7 @@ unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength,
* never a "maybe".
* For NFD, NFKD, and FCD, both functions work exactly the same.
* For NFC and NFKC where quickCheck may return "maybe", this function will
- * perform further tests to arrive at a TRUE/FALSE result.
+ * perform further tests to arrive at a true/false result.
*
* @param src String that is to be tested if it is in a normalization format.
* @param srcLength Length of source to test, or -1 if NUL-terminated.
@@ -358,10 +358,10 @@ unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
* It is useful for operations like a normalizing transliterator, where one would
* not want to replace a piece of text if it is not modified.
*
- * If doNormalize==TRUE and pNeededToNormalize!=NULL then *pNeeded... is set TRUE
+ * If doNormalize==true and pNeededToNormalize!=NULL then *pNeeded... is set true
* if the normalization was necessary.
*
- * If doNormalize==FALSE then *pNeededToNormalize will be set to FALSE.
+ * If doNormalize==false then *pNeededToNormalize will be set to false.
*
* If the buffer overflows, then *pNeededToNormalize will be undefined;
* essentially, whenever U_FAILURE is true (like in buffer overflows), this result
@@ -373,11 +373,11 @@ unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
* @param mode The normalization mode.
* @param options The normalization options, ORed together (0 for no options).
* @param doNormalize Indicates if the source text up to the next boundary
- * is to be normalized (TRUE) or just copied (FALSE).
+ * is to be normalized (true) or just copied (false).
* @param pNeededToNormalize Output flag indicating if the normalization resulted in
* different text from the input.
* Not defined if an error occurs including buffer overflow.
- * Always FALSE if !doNormalize.
+ * Always false if !doNormalize.
* @param pErrorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* @return Length of output (number of UChars) when successful or buffer overflow.
@@ -406,11 +406,11 @@ unorm_next(UCharIterator *src,
* @param mode The normalization mode.
* @param options The normalization options, ORed together (0 for no options).
* @param doNormalize Indicates if the source text up to the next boundary
- * is to be normalized (TRUE) or just copied (FALSE).
+ * is to be normalized (true) or just copied (false).
* @param pNeededToNormalize Output flag indicating if the normalization resulted in
* different text from the input.
* Not defined if an error occurs including buffer overflow.
- * Always FALSE if !doNormalize.
+ * Always false if !doNormalize.
* @param pErrorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* @return Length of output (number of UChars) when successful or buffer overflow.
diff --git a/deps/icu-small/source/common/unicode/unorm2.h b/deps/icu-small/source/common/unicode/unorm2.h
index a9bd02f256361f..24417b7103c12e 100644
--- a/deps/icu-small/source/common/unicode/unorm2.h
+++ b/deps/icu-small/source/common/unicode/unorm2.h
@@ -31,10 +31,13 @@
*/
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/stringoptions.h"
#include "unicode/uset.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* Constants for normalization modes.
* For details about standard Unicode normalization forms
@@ -132,7 +135,7 @@ typedef struct UNormalizer2 UNormalizer2; /**< C typedef for struct UNormalizer
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFCInstance(UErrorCode *pErrorCode);
/**
@@ -146,7 +149,7 @@ unorm2_getNFCInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFDInstance(UErrorCode *pErrorCode);
/**
@@ -160,7 +163,7 @@ unorm2_getNFDInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKCInstance(UErrorCode *pErrorCode);
/**
@@ -174,7 +177,7 @@ unorm2_getNFKCInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKDInstance(UErrorCode *pErrorCode);
/**
@@ -188,7 +191,7 @@ unorm2_getNFKDInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
/**
@@ -212,7 +215,7 @@ unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
* @return the requested UNormalizer2, if successful
* @stable ICU 4.4
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getInstance(const char *packageName,
const char *name,
UNormalization2Mode mode,
@@ -233,7 +236,7 @@ unorm2_getInstance(const char *packageName,
* @return the requested UNormalizer2, if successful
* @stable ICU 4.4
*/
-U_STABLE UNormalizer2 * U_EXPORT2
+U_CAPI UNormalizer2 * U_EXPORT2
unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode);
/**
@@ -242,7 +245,7 @@ unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode
* @param norm2 UNormalizer2 instance to be closed
* @stable ICU 4.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unorm2_close(UNormalizer2 *norm2);
#if U_SHOW_CPLUSPLUS_API
@@ -280,7 +283,7 @@ U_NAMESPACE_END
* @return dest
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_normalize(const UNormalizer2 *norm2,
const UChar *src, int32_t length,
UChar *dest, int32_t capacity,
@@ -303,7 +306,7 @@ unorm2_normalize(const UNormalizer2 *norm2,
* @return first
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
@@ -326,7 +329,7 @@ unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
* @return first
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_append(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
@@ -351,7 +354,7 @@ unorm2_append(const UNormalizer2 *norm2,
* @return the non-negative length of c's decomposition, if there is one; otherwise a negative value
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_getDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode);
@@ -385,7 +388,7 @@ unorm2_getDecomposition(const UNormalizer2 *norm2,
* @return the non-negative length of c's raw decomposition, if there is one; otherwise a negative value
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_getRawDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode);
@@ -405,7 +408,7 @@ unorm2_getRawDecomposition(const UNormalizer2 *norm2,
* @return The non-negative composite code point if there is one; otherwise a negative value.
* @stable ICU 49
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
/**
@@ -417,7 +420,7 @@ unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
* @return c's combining class
* @stable ICU 49
*/
-U_STABLE uint8_t U_EXPORT2
+U_CAPI uint8_t U_EXPORT2
unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -433,10 +436,10 @@ unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
* 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 TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_isNormalized(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -458,7 +461,7 @@ unorm2_isNormalized(const UNormalizer2 *norm2,
* @return UNormalizationCheckResult
* @stable ICU 4.4
*/
-U_STABLE UNormalizationCheckResult U_EXPORT2
+U_CAPI UNormalizationCheckResult U_EXPORT2
unorm2_quickCheck(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -487,7 +490,7 @@ unorm2_quickCheck(const UNormalizer2 *norm2,
* @return "yes" span end index
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -498,10 +501,10 @@ unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c has a normalization boundary before it
+ * @return true if c has a normalization boundary before it
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -510,10 +513,10 @@ unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c has a normalization boundary after it
+ * @return true if c has a normalization boundary after it
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -521,10 +524,10 @@ unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c is normalization-inert
+ * @return true if c is normalization-inert
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -593,7 +596,7 @@ unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm_compare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
uint32_t options,
diff --git a/deps/icu-small/source/common/unicode/urename.h b/deps/icu-small/source/common/unicode/urename.h
index 30f4b7af39adc5..fe59fdd893d940 100644
--- a/deps/icu-small/source/common/unicode/urename.h
+++ b/deps/icu-small/source/common/unicode/urename.h
@@ -130,7 +130,6 @@
#define izrule_getStaticClassID U_ICU_ENTRY_POINT_RENAME(izrule_getStaticClassID)
#define izrule_isEquivalentTo U_ICU_ENTRY_POINT_RENAME(izrule_isEquivalentTo)
#define izrule_open U_ICU_ENTRY_POINT_RENAME(izrule_open)
-#define locale_getKeywords U_ICU_ENTRY_POINT_RENAME(locale_getKeywords)
#define locale_getKeywordsStart U_ICU_ENTRY_POINT_RENAME(locale_getKeywordsStart)
#define locale_get_default U_ICU_ENTRY_POINT_RENAME(locale_get_default)
#define locale_set_default U_ICU_ENTRY_POINT_RENAME(locale_set_default)
@@ -918,9 +917,11 @@
#define udtitvfmt_format U_ICU_ENTRY_POINT_RENAME(udtitvfmt_format)
#define udtitvfmt_formatCalendarToResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_formatCalendarToResult)
#define udtitvfmt_formatToResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_formatToResult)
+#define udtitvfmt_getContext U_ICU_ENTRY_POINT_RENAME(udtitvfmt_getContext)
#define udtitvfmt_open U_ICU_ENTRY_POINT_RENAME(udtitvfmt_open)
#define udtitvfmt_openResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_openResult)
#define udtitvfmt_resultAsValue U_ICU_ENTRY_POINT_RENAME(udtitvfmt_resultAsValue)
+#define udtitvfmt_setContext U_ICU_ENTRY_POINT_RENAME(udtitvfmt_setContext)
#define uenum_close U_ICU_ENTRY_POINT_RENAME(uenum_close)
#define uenum_count U_ICU_ENTRY_POINT_RENAME(uenum_count)
#define uenum_next U_ICU_ENTRY_POINT_RENAME(uenum_next)
@@ -1079,7 +1080,6 @@
#define uloc_getDisplayLanguage U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayLanguage)
#define uloc_getDisplayName U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayName)
#define uloc_getDisplayScript U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScript)
-#define uloc_getDisplayScriptInContext U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScriptInContext)
#define uloc_getDisplayVariant U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayVariant)
#define uloc_getISO3Country U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Country)
#define uloc_getISO3Language U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Language)
@@ -1123,16 +1123,21 @@
#define ulocimp_forLanguageTag U_ICU_ENTRY_POINT_RENAME(ulocimp_forLanguageTag)
#define ulocimp_getBaseName U_ICU_ENTRY_POINT_RENAME(ulocimp_getBaseName)
#define ulocimp_getCountry U_ICU_ENTRY_POINT_RENAME(ulocimp_getCountry)
+#define ulocimp_getKeywordValue U_ICU_ENTRY_POINT_RENAME(ulocimp_getKeywordValue)
+#define ulocimp_getKeywords U_ICU_ENTRY_POINT_RENAME(ulocimp_getKeywords)
+#define ulocimp_getKnownCanonicalizedLocaleForTest U_ICU_ENTRY_POINT_RENAME(ulocimp_getKnownCanonicalizedLocaleForTest)
#define ulocimp_getLanguage U_ICU_ENTRY_POINT_RENAME(ulocimp_getLanguage)
#define ulocimp_getName U_ICU_ENTRY_POINT_RENAME(ulocimp_getName)
#define ulocimp_getRegionForSupplementalData U_ICU_ENTRY_POINT_RENAME(ulocimp_getRegionForSupplementalData)
#define ulocimp_getScript U_ICU_ENTRY_POINT_RENAME(ulocimp_getScript)
+#define ulocimp_isCanonicalizedLocaleForTest U_ICU_ENTRY_POINT_RENAME(ulocimp_isCanonicalizedLocaleForTest)
#define ulocimp_minimizeSubtags U_ICU_ENTRY_POINT_RENAME(ulocimp_minimizeSubtags)
#define ulocimp_toBcpKey U_ICU_ENTRY_POINT_RENAME(ulocimp_toBcpKey)
#define ulocimp_toBcpType U_ICU_ENTRY_POINT_RENAME(ulocimp_toBcpType)
#define ulocimp_toLanguageTag U_ICU_ENTRY_POINT_RENAME(ulocimp_toLanguageTag)
#define ulocimp_toLegacyKey U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyKey)
#define ulocimp_toLegacyType U_ICU_ENTRY_POINT_RENAME(ulocimp_toLegacyType)
+#define ultag_getTKeyStart U_ICU_ENTRY_POINT_RENAME(ultag_getTKeyStart)
#define ultag_isExtensionSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isExtensionSubtags)
#define ultag_isLanguageSubtag U_ICU_ENTRY_POINT_RENAME(ultag_isLanguageSubtag)
#define ultag_isPrivateuseValueSubtags U_ICU_ENTRY_POINT_RENAME(ultag_isPrivateuseValueSubtags)
@@ -1245,7 +1250,18 @@
#define unumf_resultAsValue U_ICU_ENTRY_POINT_RENAME(unumf_resultAsValue)
#define unumf_resultGetAllFieldPositions U_ICU_ENTRY_POINT_RENAME(unumf_resultGetAllFieldPositions)
#define unumf_resultNextFieldPosition U_ICU_ENTRY_POINT_RENAME(unumf_resultNextFieldPosition)
+#define unumf_resultToDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumf_resultToDecimalNumber)
#define unumf_resultToString U_ICU_ENTRY_POINT_RENAME(unumf_resultToString)
+#define unumrf_close U_ICU_ENTRY_POINT_RENAME(unumrf_close)
+#define unumrf_closeResult U_ICU_ENTRY_POINT_RENAME(unumrf_closeResult)
+#define unumrf_formatDecimalRange U_ICU_ENTRY_POINT_RENAME(unumrf_formatDecimalRange)
+#define unumrf_formatDoubleRange U_ICU_ENTRY_POINT_RENAME(unumrf_formatDoubleRange)
+#define unumrf_openForSkeletonWithCollapseAndIdentityFallback U_ICU_ENTRY_POINT_RENAME(unumrf_openForSkeletonWithCollapseAndIdentityFallback)
+#define unumrf_openResult U_ICU_ENTRY_POINT_RENAME(unumrf_openResult)
+#define unumrf_resultAsValue U_ICU_ENTRY_POINT_RENAME(unumrf_resultAsValue)
+#define unumrf_resultGetFirstDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetFirstDecimalNumber)
+#define unumrf_resultGetIdentityResult U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetIdentityResult)
+#define unumrf_resultGetSecondDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetSecondDecimalNumber)
#define unumsys_close U_ICU_ENTRY_POINT_RENAME(unumsys_close)
#define unumsys_getDescription U_ICU_ENTRY_POINT_RENAME(unumsys_getDescription)
#define unumsys_getName U_ICU_ENTRY_POINT_RENAME(unumsys_getName)
@@ -1259,6 +1275,7 @@
#define uplrules_open U_ICU_ENTRY_POINT_RENAME(uplrules_open)
#define uplrules_openForType U_ICU_ENTRY_POINT_RENAME(uplrules_openForType)
#define uplrules_select U_ICU_ENTRY_POINT_RENAME(uplrules_select)
+#define uplrules_selectForRange U_ICU_ENTRY_POINT_RENAME(uplrules_selectForRange)
#define uplrules_selectFormatted U_ICU_ENTRY_POINT_RENAME(uplrules_selectFormatted)
#define uplrules_selectWithFormat U_ICU_ENTRY_POINT_RENAME(uplrules_selectWithFormat)
#define uplug_closeLibrary U_ICU_ENTRY_POINT_RENAME(uplug_closeLibrary)
diff --git a/deps/icu-small/source/common/unicode/ures.h b/deps/icu-small/source/common/unicode/ures.h
index 839779fada804d..fff84043e84785 100644
--- a/deps/icu-small/source/common/unicode/ures.h
+++ b/deps/icu-small/source/common/unicode/ures.h
@@ -27,7 +27,10 @@
#include "unicode/utypes.h"
#include "unicode/uloc.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -163,7 +166,7 @@ typedef enum {
* @see ures_close
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_open(const char* packageName,
const char* locale,
UErrorCode* status);
@@ -186,7 +189,7 @@ ures_open(const char* packageName,
* @see ures_close
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_openDirect(const char* packageName,
const char* locale,
UErrorCode* status);
@@ -209,7 +212,7 @@ ures_openDirect(const char* packageName,
* @see ures_open
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_openU(const UChar* packageName,
const char* locale,
UErrorCode* status);
@@ -245,7 +248,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle,
* @see ures_open
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_close(UResourceBundle* resourceBundle);
#if U_SHOW_CPLUSPLUS_API
@@ -291,7 +294,7 @@ ures_getVersionNumber(const UResourceBundle* resourceBundle);
* as specified in the resource bundle or its parent.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_getVersion(const UResourceBundle* resB,
UVersionInfo versionInfo);
@@ -325,7 +328,7 @@ ures_getLocale(const UResourceBundle* resourceBundle,
* @return A Locale name
* @stable ICU 2.8
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getLocaleByType(const UResourceBundle* resourceBundle,
ULocDataLocaleType type,
UErrorCode* status);
@@ -348,7 +351,7 @@ ures_getLocaleByType(const UResourceBundle* resourceBundle,
* @param status The error code.
* @internal
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openFillIn(UResourceBundle *r,
const char* packageName,
const char* localeID,
@@ -372,7 +375,7 @@ ures_openFillIn(UResourceBundle *r,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getString(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -383,10 +386,10 @@ ures_getString(const UResourceBundle* resourceBundle,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -404,10 +407,10 @@ ures_getString(const UResourceBundle* resourceBundle,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -424,7 +427,7 @@ ures_getString(const UResourceBundle* resourceBundle,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8String(const UResourceBundle *resB,
char *dest, int32_t *length,
UBool forceCopy,
@@ -447,7 +450,7 @@ ures_getUTF8String(const UResourceBundle *resB,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const uint8_t* U_EXPORT2
+U_CAPI const uint8_t* U_EXPORT2
ures_getBinary(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -469,7 +472,7 @@ ures_getBinary(const UResourceBundle* resourceBundle,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const int32_t* U_EXPORT2
+U_CAPI const int32_t* U_EXPORT2
ures_getIntVector(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -490,7 +493,7 @@ ures_getIntVector(const UResourceBundle* resourceBundle,
* @see ures_getString
* @stable ICU 2.0
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ures_getUInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
@@ -510,7 +513,7 @@ ures_getUInt(const UResourceBundle* resourceBundle,
* @see ures_getString
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ures_getInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
@@ -524,7 +527,7 @@ ures_getInt(const UResourceBundle* resourceBundle,
* @return number of resources in a given resource.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ures_getSize(const UResourceBundle *resourceBundle);
/**
@@ -535,7 +538,7 @@ ures_getSize(const UResourceBundle *resourceBundle);
* @see UResType
* @stable ICU 2.0
*/
-U_STABLE UResType U_EXPORT2
+U_CAPI UResType U_EXPORT2
ures_getType(const UResourceBundle *resourceBundle);
/**
@@ -546,7 +549,7 @@ ures_getType(const UResourceBundle *resourceBundle);
* @return a key associated to this resource, or NULL if it doesn't have a key
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getKey(const UResourceBundle *resourceBundle);
/* ITERATION API
@@ -559,17 +562,17 @@ ures_getKey(const UResourceBundle *resourceBundle);
* @param resourceBundle a resource
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_resetIterator(UResourceBundle *resourceBundle);
/**
* Checks whether the given resource has another element to iterate over.
*
* @param resourceBundle a resource
- * @return TRUE if there are more elements, FALSE if there is no more elements
+ * @return true if there are more elements, false if there is no more elements
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ures_hasNext(const UResourceBundle *resourceBundle);
/**
@@ -584,7 +587,7 @@ ures_hasNext(const UResourceBundle *resourceBundle);
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getNextResource(UResourceBundle *resourceBundle,
UResourceBundle *fillIn,
UErrorCode *status);
@@ -601,7 +604,7 @@ ures_getNextResource(UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getNextString(UResourceBundle *resourceBundle,
int32_t* len,
const char ** key,
@@ -619,7 +622,7 @@ ures_getNextString(UResourceBundle *resourceBundle,
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getByIndex(const UResourceBundle *resourceBundle,
int32_t indexR,
UResourceBundle *fillIn,
@@ -636,7 +639,7 @@ ures_getByIndex(const UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByIndex(const UResourceBundle *resourceBundle,
int32_t indexS,
int32_t* len,
@@ -648,10 +651,10 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -670,10 +673,10 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -690,7 +693,7 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8StringByIndex(const UResourceBundle *resB,
int32_t stringIndex,
char *dest, int32_t *pLength,
@@ -709,7 +712,7 @@ ures_getUTF8StringByIndex(const UResourceBundle *resB,
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getByKey(const UResourceBundle *resourceBundle,
const char* key,
UResourceBundle *fillIn,
@@ -727,7 +730,7 @@ ures_getByKey(const UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByKey(const UResourceBundle *resB,
const char* key,
int32_t* len,
@@ -741,10 +744,10 @@ ures_getStringByKey(const UResourceBundle *resB,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -763,10 +766,10 @@ ures_getStringByKey(const UResourceBundle *resB,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -783,7 +786,7 @@ ures_getStringByKey(const UResourceBundle *resB,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8StringByKey(const UResourceBundle *resB,
const char *key,
char *dest, int32_t *pLength,
@@ -811,7 +814,7 @@ ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
int32_t len = 0;
const UChar *r = ures_getString(resB, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -836,7 +839,7 @@ ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode*
int32_t len = 0;
const UChar* r = ures_getNextString(resB, &len, key, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -858,7 +861,7 @@ ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UError
int32_t len = 0;
const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -881,7 +884,7 @@ ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorC
int32_t len = 0;
const UChar* r = ures_getStringByKey(resB, key, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -900,7 +903,7 @@ U_NAMESPACE_END
* @param status error code
* @stable ICU 3.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ures_openAvailableLocales(const char *packageName, UErrorCode *status);
diff --git a/deps/icu-small/source/common/unicode/uscript.h b/deps/icu-small/source/common/unicode/uscript.h
index 53d57abed14cd0..8448afda761550 100644
--- a/deps/icu-small/source/common/unicode/uscript.h
+++ b/deps/icu-small/source/common/unicode/uscript.h
@@ -514,7 +514,7 @@ typedef enum UScriptCode {
* @return The number of script codes filled in the buffer passed in
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);
/**
@@ -527,7 +527,7 @@ uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capac
* or NULL if scriptCode is invalid
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uscript_getName(UScriptCode scriptCode);
/**
@@ -539,7 +539,7 @@ uscript_getName(UScriptCode scriptCode);
* @return short script name (4-letter code), or NULL if scriptCode is invalid
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uscript_getShortName(UScriptCode scriptCode);
/**
@@ -550,7 +550,7 @@ uscript_getShortName(UScriptCode scriptCode);
* @return The UScriptCode, or 0 if codepoint is invalid
* @stable ICU 2.4
*/
-U_STABLE UScriptCode U_EXPORT2
+U_CAPI UScriptCode U_EXPORT2
uscript_getScript(UChar32 codepoint, UErrorCode *err);
/**
@@ -562,10 +562,10 @@ uscript_getScript(UChar32 codepoint, UErrorCode *err);
* For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
* @param c code point
* @param sc script code
- * @return TRUE if sc is in Script_Extensions(c)
+ * @return true if sc is in Script_Extensions(c)
* @stable ICU 49
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_hasScript(UChar32 c, UScriptCode sc);
/**
@@ -597,7 +597,7 @@ uscript_hasScript(UChar32 c, UScriptCode sc);
* written to scripts unless U_BUFFER_OVERFLOW_ERROR indicates insufficient capacity
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getScriptExtensions(UChar32 c,
UScriptCode *scripts, int32_t capacity,
UErrorCode *errorCode);
@@ -636,7 +636,7 @@ typedef enum UScriptUsage {
* @return the string length, even if U_BUFFER_OVERFLOW_ERROR
* @stable ICU 51
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getSampleString(UScriptCode script, UChar *dest, int32_t capacity, UErrorCode *pErrorCode);
#if U_SHOW_CPLUSPLUS_API
@@ -668,41 +668,41 @@ uscript_getSampleUnicodeString(UScriptCode script);
* @see UScriptUsage
* @stable ICU 51
*/
-U_STABLE UScriptUsage U_EXPORT2
+U_CAPI UScriptUsage U_EXPORT2
uscript_getUsage(UScriptCode script);
/**
- * Returns TRUE if the script is written right-to-left.
+ * Returns true if the script is written right-to-left.
* For example, Arab and Hebr.
*
* @param script script code
- * @return TRUE if the script is right-to-left
+ * @return true if the script is right-to-left
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_isRightToLeft(UScriptCode script);
/**
- * Returns TRUE if the script allows line breaks between letters (excluding hyphenation).
+ * Returns true if the script allows line breaks between letters (excluding hyphenation).
* Such a script typically requires dictionary-based line breaking.
* For example, Hani and Thai.
*
* @param script script code
- * @return TRUE if the script allows line breaks between letters
+ * @return true if the script allows line breaks between letters
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_breaksBetweenLetters(UScriptCode script);
/**
- * Returns TRUE if in modern (or most recent) usage of the script case distinctions are customary.
+ * Returns true if in modern (or most recent) usage of the script case distinctions are customary.
* For example, Latn and Cyrl.
*
* @param script script code
- * @return TRUE if the script is cased
+ * @return true if the script is cased
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_isCased(UScriptCode script);
#endif
diff --git a/deps/icu-small/source/common/unicode/uset.h b/deps/icu-small/source/common/unicode/uset.h
index ef6bbb5c38f3fb..473cc6fbae4e0d 100644
--- a/deps/icu-small/source/common/unicode/uset.h
+++ b/deps/icu-small/source/common/unicode/uset.h
@@ -31,7 +31,10 @@
#include "unicode/utypes.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
#ifndef USET_DEFINED
@@ -158,7 +161,7 @@ typedef enum USetSpanCondition {
* Continues a span() while there is no set element at the current position.
* Increments by one code point at a time.
* Stops before the first set element (character or string).
- * (For code points only, this is like while contains(current)==FALSE).
+ * (For code points only, this is like while contains(current)==false).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of characters that are not in the set,
@@ -169,7 +172,7 @@ typedef enum USetSpanCondition {
USET_SPAN_NOT_CONTAINED = 0,
/**
* Spans the longest substring that is a concatenation of set elements (characters or strings).
- * (For characters only, this is like while contains(current)==TRUE).
+ * (For characters only, this is like while contains(current)==true).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of set elements (characters or strings) that are in the set.
@@ -185,7 +188,7 @@ typedef enum USetSpanCondition {
/**
* Continues a span() while there is a set element at the current position.
* Increments by the longest matching element at each position.
- * (For characters only, this is like while contains(current)==TRUE).
+ * (For characters only, this is like while contains(current)==true).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of set elements (characters or strings) that are in the set.
@@ -260,7 +263,7 @@ typedef struct USerializedSet {
* it when done.
* @stable ICU 4.2
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openEmpty(void);
/**
@@ -273,7 +276,7 @@ uset_openEmpty(void);
* it when done.
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_open(UChar32 start, UChar32 end);
/**
@@ -285,7 +288,7 @@ uset_open(UChar32 start, UChar32 end);
* @param ec the error code
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openPattern(const UChar* pattern, int32_t patternLength,
UErrorCode* ec);
@@ -300,7 +303,7 @@ uset_openPattern(const UChar* pattern, int32_t patternLength,
* @param ec the error code
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
uint32_t options,
UErrorCode* ec);
@@ -311,7 +314,7 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
* @param set the object to dispose of
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_close(USet* set);
#if U_SHOW_CPLUSPLUS_API
@@ -342,19 +345,19 @@ U_NAMESPACE_END
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE USet * U_EXPORT2
+U_CAPI USet * U_EXPORT2
uset_clone(const USet *set);
/**
* Determines whether the set has been frozen (made immutable) or not.
* See the ICU4J Freezable interface for details.
* @param set the set
- * @return TRUE/FALSE for whether the set has been frozen
+ * @return true/false for whether the set has been frozen
* @see uset_freeze
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_isFrozen(const USet *set);
/**
@@ -371,7 +374,7 @@ uset_isFrozen(const USet *set);
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_freeze(USet *set);
/**
@@ -384,7 +387,7 @@ uset_freeze(USet *set);
* @see uset_clone
* @stable ICU 3.8
*/
-U_STABLE USet * U_EXPORT2
+U_CAPI USet * U_EXPORT2
uset_cloneAsThawed(const USet *set);
/**
@@ -396,7 +399,7 @@ uset_cloneAsThawed(const USet *set);
* @param end last character in the set, inclusive
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_set(USet* set,
UChar32 start, UChar32 end);
@@ -421,7 +424,7 @@ uset_set(USet* set,
*
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_applyPattern(USet *set,
const UChar *pattern, int32_t patternLength,
uint32_t options,
@@ -449,7 +452,7 @@ uset_applyPattern(USet *set,
*
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_applyIntPropertyValue(USet* set,
UProperty prop, int32_t value, UErrorCode* ec);
@@ -488,7 +491,7 @@ uset_applyIntPropertyValue(USet* set,
*
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_applyPropertyAlias(USet* set,
const UChar *prop, int32_t propLength,
const UChar *value, int32_t valueLength,
@@ -503,7 +506,7 @@ uset_applyPropertyAlias(USet* set,
* @param pos the given position
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
int32_t pos);
@@ -514,7 +517,7 @@ uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
* @param set the set
* @param result the string to receive the rules, may be NULL
* @param resultCapacity the capacity of result, may be 0 if result is NULL
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
@@ -522,7 +525,7 @@ uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
* @return length of string, possibly larger than resultCapacity
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_toPattern(const USet* set,
UChar* result, int32_t resultCapacity,
UBool escapeUnprintable,
@@ -530,13 +533,13 @@ uset_toPattern(const USet* set,
/**
* Adds the given character to the given USet. After this call,
- * uset_contains(set, c) will return TRUE.
+ * uset_contains(set, c) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param c the character to add
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_add(USet* set, UChar32 c);
/**
@@ -551,31 +554,31 @@ uset_add(USet* set, UChar32 c);
* @param additionalSet the source set whose elements are to be added to this set.
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addAll(USet* set, const USet *additionalSet);
/**
* Adds the given range of characters to the given USet. After this call,
- * uset_contains(set, start, end) will return TRUE.
+ * uset_contains(set, start, end) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param start the first character of the range to add, inclusive
* @param end the last character of the range to add, inclusive
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addRange(USet* set, UChar32 start, UChar32 end);
/**
* Adds the given string to the given USet. After this call,
- * uset_containsString(set, str, strLen) will return TRUE.
+ * uset_containsString(set, str, strLen) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param str the string to add
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addString(USet* set, const UChar* str, int32_t strLen);
/**
@@ -587,42 +590,42 @@ uset_addString(USet* set, const UChar* str, int32_t strLen);
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
/**
* Removes the given character from the given USet. After this call,
- * uset_contains(set, c) will return FALSE.
+ * uset_contains(set, c) will return false.
* A frozen set will not be modified.
* @param set the object from which to remove the character
* @param c the character to remove
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_remove(USet* set, UChar32 c);
/**
* Removes the given range of characters from the given USet. After this call,
- * uset_contains(set, start, end) will return FALSE.
+ * uset_contains(set, start, end) will return false.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param start the first character of the range to remove, inclusive
* @param end the last character of the range to remove, inclusive
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeRange(USet* set, UChar32 start, UChar32 end);
/**
* Removes the given string to the given USet. After this call,
- * uset_containsString(set, str, strLen) will return FALSE.
+ * uset_containsString(set, str, strLen) will return false.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param str the string to remove
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeString(USet* set, const UChar* str, int32_t strLen);
/**
@@ -636,7 +639,7 @@ uset_removeString(USet* set, const UChar* str, int32_t strLen);
* removed from this set
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeAll(USet* set, const USet* removeSet);
/**
@@ -653,7 +656,7 @@ uset_removeAll(USet* set, const USet* removeSet);
* to this set.
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_retain(USet* set, UChar32 start, UChar32 end);
/**
@@ -668,7 +671,7 @@ uset_retain(USet* set, UChar32 start, UChar32 end);
* @param retain set that defines which elements this set will retain
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_retainAll(USet* set, const USet* retain);
/**
@@ -679,7 +682,7 @@ uset_retainAll(USet* set, const USet* retain);
* @param set the object on which to perfrom the compact
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_compact(USet* set);
/**
@@ -690,7 +693,7 @@ uset_compact(USet* set);
* @param set the set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_complement(USet* set);
/**
@@ -704,7 +707,7 @@ uset_complement(USet* set);
* from this set.
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_complementAll(USet* set, const USet* complement);
/**
@@ -714,7 +717,7 @@ uset_complementAll(USet* set, const USet* complement);
* @param set the set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_clear(USet* set);
/**
@@ -743,7 +746,7 @@ uset_clear(USet* set);
* are ignored.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_closeOver(USet* set, int32_t attributes);
/**
@@ -752,51 +755,51 @@ uset_closeOver(USet* set, int32_t attributes);
* @param set the set
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeAllStrings(USet* set);
/**
- * Returns TRUE if the given USet contains no characters and no
+ * Returns true if the given USet contains no characters and no
* strings.
* @param set the set
* @return true if set is empty
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_isEmpty(const USet* set);
/**
- * Returns TRUE if the given USet contains the given character.
+ * Returns true if the given USet contains the given character.
* This function works faster with a frozen set.
* @param set the set
* @param c The codepoint to check for within the set
* @return true if set contains c
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_contains(const USet* set, UChar32 c);
/**
- * Returns TRUE if the given USet contains all characters c
+ * Returns true if the given USet contains all characters c
* where start <= c && c <= end.
* @param set the set
* @param start the first character of the range to test, inclusive
* @param end the last character of the range to test, inclusive
- * @return TRUE if set contains the range
+ * @return true if set contains the range
* @stable ICU 2.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsRange(const USet* set, UChar32 start, UChar32 end);
/**
- * Returns TRUE if the given USet contains the given string.
+ * Returns true if the given USet contains the given string.
* @param set the set
* @param str the string
* @param strLen the length of the string or -1 if null terminated.
* @return true if set contains str
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsString(const USet* set, const UChar* str, int32_t strLen);
/**
@@ -809,7 +812,7 @@ uset_containsString(const USet* set, const UChar* str, int32_t strLen);
* @return an index from 0..size()-1, or -1
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_indexOf(const USet* set, UChar32 c);
/**
@@ -822,7 +825,7 @@ uset_indexOf(const USet* set, UChar32 c);
* @return the character at the given index, or (UChar32)-1.
* @stable ICU 3.2
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uset_charAt(const USet* set, int32_t charIndex);
/**
@@ -833,7 +836,7 @@ uset_charAt(const USet* set, int32_t charIndex);
* contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_size(const USet* set);
/**
@@ -844,7 +847,7 @@ uset_size(const USet* set);
* and/or strings contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getItemCount(const USet* set);
/**
@@ -865,7 +868,7 @@ uset_getItemCount(const USet* set);
* itemIndex is out of range
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getItem(const USet* set, int32_t itemIndex,
UChar32* start, UChar32* end,
UChar* str, int32_t strCapacity,
@@ -879,7 +882,7 @@ uset_getItem(const USet* set, int32_t itemIndex,
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsAll(const USet* set1, const USet* set2);
/**
@@ -892,7 +895,7 @@ uset_containsAll(const USet* set1, const USet* set2);
* @return true if the test condition is met
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
/**
@@ -903,7 +906,7 @@ uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsNone(const USet* set1, const USet* set2);
/**
@@ -914,7 +917,7 @@ uset_containsNone(const USet* set1, const USet* set2);
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsSome(const USet* set1, const USet* set2);
/**
@@ -936,7 +939,7 @@ uset_containsSome(const USet* set1, const USet* set2);
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -957,7 +960,7 @@ uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spa
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -979,7 +982,7 @@ uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -1000,7 +1003,7 @@ uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -1011,7 +1014,7 @@ uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondit
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_equals(const USet* set1, const USet* set2);
/*********************************************************************
@@ -1067,7 +1070,7 @@ uset_equals(const USet* set1, const USet* set2);
* than U_BUFFER_OVERFLOW_ERROR.
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
/**
@@ -1078,7 +1081,7 @@ uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode
* @return true if the given array is valid, otherwise false
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
/**
@@ -1088,18 +1091,18 @@ uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcL
* @param c The codepoint to set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
/**
- * Returns TRUE if the given USerializedSet contains the given
+ * Returns true if the given USerializedSet contains the given
* character.
* @param set the serialized set
* @param c The codepoint to check for within the set
* @return true if set contains c
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_serializedContains(const USerializedSet* set, UChar32 c);
/**
@@ -1111,7 +1114,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c);
* contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getSerializedRangeCount(const USerializedSet* set);
/**
@@ -1127,7 +1130,7 @@ uset_getSerializedRangeCount(const USerializedSet* set);
* @return true if rangeIndex is valid, otherwise false
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
UChar32* pStart, UChar32* pEnd);
diff --git a/deps/icu-small/source/common/unicode/usetiter.h b/deps/icu-small/source/common/unicode/usetiter.h
index f3f470f95aa5f5..45d268a05c9b90 100644
--- a/deps/icu-small/source/common/unicode/usetiter.h
+++ b/deps/icu-small/source/common/unicode/usetiter.h
@@ -176,7 +176,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
* If there are no more elements in the set, return false.
*
*
- * If isString() == TRUE, the value is a
+ * If isString() == true, the value is a
* string, otherwise the value is a
* single code point. Elements of either type can be retrieved
* with the function getString(), while elements of
@@ -197,7 +197,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
/**
* Returns the next element in the set, either a code point range
* or a string. If there are no more elements in the set, return
- * false. If isString() == TRUE, the value is a
+ * false. If isString() == true, the value is a
* string and can be accessed with getString(). Otherwise the value is a
* range of one or more code points from getCodepoint() to
* getCodepointeEnd() inclusive.
@@ -205,7 +205,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
*
The order of iteration is all code points ranges in sorted
* order, followed by all strings sorted order. Ranges are
* disjoint and non-contiguous. The value returned from getString()
- * is undefined unless isString() == TRUE. Do not mix calls to
+ * is undefined unless isString() == true. Do not mix calls to
* next() and nextRange() without calling
* reset() between them. The results of doing so are
* undefined.
diff --git a/deps/icu-small/source/common/unicode/ushape.h b/deps/icu-small/source/common/unicode/ushape.h
index 3064e0857281c5..9a85b73e4cba80 100644
--- a/deps/icu-small/source/common/unicode/ushape.h
+++ b/deps/icu-small/source/common/unicode/ushape.h
@@ -98,7 +98,7 @@
* the return value indicates the necessary destination buffer size.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_shapeArabic(const UChar *source, int32_t sourceLength,
UChar *dest, int32_t destSize,
uint32_t options,
diff --git a/deps/icu-small/source/common/unicode/usprep.h b/deps/icu-small/source/common/unicode/usprep.h
index 7cdc6cdd18ea6b..be06189e2e9e6d 100644
--- a/deps/icu-small/source/common/unicode/usprep.h
+++ b/deps/icu-small/source/common/unicode/usprep.h
@@ -25,7 +25,10 @@
*/
#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
*
@@ -181,7 +184,7 @@ typedef enum UStringPrepProfileType {
* @see usprep_close()
* @stable ICU 2.8
*/
-U_STABLE UStringPrepProfile* U_EXPORT2
+U_CAPI UStringPrepProfile* U_EXPORT2
usprep_open(const char* path,
const char* fileName,
UErrorCode* status);
@@ -197,7 +200,7 @@ usprep_open(const char* path,
* @see usprep_close()
* @stable ICU 4.2
*/
-U_STABLE UStringPrepProfile* U_EXPORT2
+U_CAPI UStringPrepProfile* U_EXPORT2
usprep_openByType(UStringPrepProfileType type,
UErrorCode* status);
@@ -206,7 +209,7 @@ usprep_openByType(UStringPrepProfileType type,
* @param profile The profile to close
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
usprep_close(UStringPrepProfile* profile);
#if U_SHOW_CPLUSPLUS_API
@@ -257,7 +260,7 @@ U_NAMESPACE_END
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
usprep_prepare( const UStringPrepProfile* prep,
const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
diff --git a/deps/icu-small/source/common/unicode/ustring.h b/deps/icu-small/source/common/unicode/ustring.h
index 0d2274a0cabb51..3243acbb7ebfce 100644
--- a/deps/icu-small/source/common/unicode/ustring.h
+++ b/deps/icu-small/source/common/unicode/ustring.h
@@ -89,7 +89,7 @@
* @return The number of UChars in chars
, minus the terminator.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strlen(const UChar *s);
/*@}*/
@@ -106,7 +106,7 @@ u_strlen(const UChar *s);
* @return The number of code points in the specified code units.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_countChar32(const UChar *s, int32_t length);
/**
@@ -127,7 +127,7 @@ u_countChar32(const UChar *s, int32_t length);
* than 'number'. Same as (u_countChar32(s, length)>number).
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
/**
@@ -140,7 +140,7 @@ u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strcat(UChar *dst,
const UChar *src);
@@ -158,7 +158,7 @@ u_strcat(UChar *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strncat(UChar *dst,
const UChar *src,
int32_t n);
@@ -183,7 +183,7 @@ u_strncat(UChar *dst,
* @see u_strFindFirst
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strstr(const UChar *s, const UChar *substring);
/**
@@ -207,7 +207,7 @@ u_strstr(const UChar *s, const UChar *substring);
* @see u_strstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
/**
@@ -227,7 +227,7 @@ u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t s
* @see u_strstr
* @see u_strFindFirst
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strchr(const UChar *s, UChar c);
/**
@@ -247,7 +247,7 @@ u_strchr(const UChar *s, UChar c);
* @see u_strstr
* @see u_strFindFirst
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strchr32(const UChar *s, UChar32 c);
/**
@@ -270,7 +270,7 @@ u_strchr32(const UChar *s, UChar32 c);
* @see u_strFindFirst
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrstr(const UChar *s, const UChar *substring);
/**
@@ -294,7 +294,7 @@ u_strrstr(const UChar *s, const UChar *substring);
* @see u_strstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
/**
@@ -314,7 +314,7 @@ u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t su
* @see u_strrstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrchr(const UChar *s, UChar c);
/**
@@ -334,7 +334,7 @@ u_strrchr(const UChar *s, UChar c);
* @see u_strrstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrchr32(const UChar *s, UChar32 c);
/**
@@ -349,7 +349,7 @@ u_strrchr32(const UChar *s, UChar32 c);
* characters in matchSet
, or NULL if no such character is found.
* @stable ICU 2.0
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strpbrk(const UChar *string, const UChar *matchSet);
/**
@@ -365,7 +365,7 @@ u_strpbrk(const UChar *string, const UChar *matchSet);
* @see u_strspn
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcspn(const UChar *string, const UChar *matchSet);
/**
@@ -381,7 +381,7 @@ u_strcspn(const UChar *string, const UChar *matchSet);
* @see u_strcspn
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strspn(const UChar *string, const UChar *matchSet);
/**
@@ -409,7 +409,7 @@ u_strspn(const UChar *string, const UChar *matchSet);
* when there are no more tokens.
* @stable ICU 2.0
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strtok_r(UChar *src,
const UChar *delim,
UChar **saveState);
@@ -424,7 +424,7 @@ u_strtok_r(UChar *src,
* value if s1
is bitwise greater than s2
.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcmp(const UChar *s1,
const UChar *s2);
@@ -439,7 +439,7 @@ u_strcmp(const UChar *s1,
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
/**
@@ -462,14 +462,14 @@ u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
* @param s2 Second source string.
* @param length2 Length of second source string, or -1 if NUL-terminated.
*
- * @param codePointOrder Choose between code unit order (FALSE)
- * and code point order (TRUE).
+ * @param codePointOrder Choose between code unit order (false)
+ * and code point order (true).
*
* @return <0 or 0 or >0 as usual for string comparisons
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
UBool codePointOrder);
@@ -485,8 +485,8 @@ u_strCompare(const UChar *s1, int32_t length1,
*
* @param iter1 First source string iterator.
* @param iter2 Second source string iterator.
- * @param codePointOrder Choose between code unit order (FALSE)
- * and code point order (TRUE).
+ * @param codePointOrder Choose between code unit order (false)
+ * and code point order (true).
*
* @return <0 or 0 or >0 as usual for string comparisons
*
@@ -494,7 +494,7 @@ u_strCompare(const UChar *s1, int32_t length1,
*
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);
/**
@@ -537,7 +537,7 @@ u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrde
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCaseCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
uint32_t options,
@@ -555,7 +555,7 @@ u_strCaseCompare(const UChar *s1, int32_t length1,
* value if s1
is bitwise greater than s2
.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncmp(const UChar *ucs1,
const UChar *ucs2,
int32_t n);
@@ -573,7 +573,7 @@ u_strncmp(const UChar *ucs1,
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
/**
@@ -595,7 +595,7 @@ u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
/**
@@ -619,7 +619,7 @@ u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
/**
@@ -643,7 +643,7 @@ u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);
/**
@@ -654,7 +654,7 @@ u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options)
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strcpy(UChar *dst,
const UChar *src);
@@ -669,7 +669,7 @@ u_strcpy(UChar *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strncpy(UChar *dst,
const UChar *src,
int32_t n);
@@ -686,7 +686,7 @@ u_strncpy(UChar *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
+U_CAPI UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
const char *src );
/**
@@ -701,7 +701,7 @@ U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
+U_CAPI UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
const char *src,
int32_t n);
@@ -715,7 +715,7 @@ U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE char* U_EXPORT2 u_austrcpy(char *dst,
+U_CAPI char* U_EXPORT2 u_austrcpy(char *dst,
const UChar *src );
/**
@@ -730,7 +730,7 @@ U_STABLE char* U_EXPORT2 u_austrcpy(char *dst,
* @return A pointer to dst
.
* @stable ICU 2.0
*/
-U_STABLE char* U_EXPORT2 u_austrncpy(char *dst,
+U_CAPI char* U_EXPORT2 u_austrncpy(char *dst,
const UChar *src,
int32_t n );
@@ -744,7 +744,7 @@ U_STABLE char* U_EXPORT2 u_austrncpy(char *dst,
* @return A pointer to dest
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memcpy(UChar *dest, const UChar *src, int32_t count);
/**
@@ -755,7 +755,7 @@ u_memcpy(UChar *dest, const UChar *src, int32_t count);
* @return A pointer to dest
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memmove(UChar *dest, const UChar *src, int32_t count);
/**
@@ -767,7 +767,7 @@ u_memmove(UChar *dest, const UChar *src, int32_t count);
* @return A pointer to dest
.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memset(UChar *dest, UChar c, int32_t count);
/**
@@ -781,7 +781,7 @@ u_memset(UChar *dest, UChar c, int32_t count);
* When buf1 > buf2, a positive number is returned.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
/**
@@ -797,7 +797,7 @@ u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
/**
@@ -817,7 +817,7 @@ u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
* @see u_memchr32
* @see u_strFindFirst
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memchr(const UChar *s, UChar c, int32_t count);
/**
@@ -837,7 +837,7 @@ u_memchr(const UChar *s, UChar c, int32_t count);
* @see u_memchr
* @see u_strFindFirst
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memchr32(const UChar *s, UChar32 c, int32_t count);
/**
@@ -857,7 +857,7 @@ u_memchr32(const UChar *s, UChar32 c, int32_t count);
* @see u_memrchr32
* @see u_strFindLast
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memrchr(const UChar *s, UChar c, int32_t count);
/**
@@ -877,7 +877,7 @@ u_memrchr(const UChar *s, UChar c, int32_t count);
* @see u_memrchr
* @see u_strFindLast
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memrchr32(const UChar *s, UChar32 c, int32_t count);
/**
@@ -903,13 +903,13 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count);
*
* U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11);
* U_STRING_DECL(ustringVar2, "jumps 5%", 8);
- * static UBool didInit=FALSE;
+ * static UBool didInit=false;
*
* int32_t function() {
* if(!didInit) {
* U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11);
* U_STRING_INIT(ustringVar2, "jumps 5%", 8);
- * didInit=TRUE;
+ * didInit=true;
* }
* return u_strcmp(ustringVar1, ustringVar2);
* }
@@ -992,7 +992,7 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count);
* @see UnicodeString#unescapeAt()
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_unescape(const char *src,
UChar *dest, int32_t destCapacity);
@@ -1040,7 +1040,7 @@ U_CDECL_END
* @see UnicodeString#unescapeAt()
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_unescapeAt(UNESCAPE_CHAR_AT charAt,
int32_t *offset,
int32_t length,
@@ -1066,7 +1066,7 @@ u_unescapeAt(UNESCAPE_CHAR_AT charAt,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToUpper(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
@@ -1092,7 +1092,7 @@ u_strToUpper(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToLower(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
@@ -1138,7 +1138,7 @@ u_strToLower(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.1
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToTitle(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UBreakIterator *titleIter,
@@ -1171,7 +1171,7 @@ u_strToTitle(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strFoldCase(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
uint32_t options,
@@ -1200,7 +1200,7 @@ u_strFoldCase(UChar *dest, int32_t destCapacity,
* @return The pointer to destination buffer.
* @stable ICU 2.0
*/
-U_STABLE wchar_t* U_EXPORT2
+U_CAPI wchar_t* U_EXPORT2
u_strToWCS(wchar_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1229,7 +1229,7 @@ u_strToWCS(wchar_t *dest,
* @return The pointer to destination buffer.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromWCS(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1260,7 +1260,7 @@ u_strFromWCS(UChar *dest,
* @see u_strToUTF8WithSub
* @see u_strFromUTF8
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToUTF8(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1290,7 +1290,7 @@ u_strToUTF8(char *dest,
* @see u_strFromUTF8WithSub
* @see u_strFromUTF8Lenient
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF8(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1333,7 +1333,7 @@ u_strFromUTF8(UChar *dest,
* @see u_strFromUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToUTF8WithSub(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1378,7 +1378,7 @@ u_strToUTF8WithSub(char *dest,
* @see u_strToUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF8WithSub(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1438,7 +1438,7 @@ u_strFromUTF8WithSub(UChar *dest,
* @see u_strToUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFromUTF8Lenient(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1468,7 +1468,7 @@ u_strFromUTF8Lenient(UChar *dest,
* @see u_strFromUTF32
* @stable ICU 2.0
*/
-U_STABLE UChar32* U_EXPORT2
+U_CAPI UChar32* U_EXPORT2
u_strToUTF32(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1498,7 +1498,7 @@ u_strToUTF32(UChar32 *dest,
* @see u_strToUTF32
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF32(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1541,7 +1541,7 @@ u_strFromUTF32(UChar *dest,
* @see u_strFromUTF32WithSub
* @stable ICU 4.2
*/
-U_STABLE UChar32* U_EXPORT2
+U_CAPI UChar32* U_EXPORT2
u_strToUTF32WithSub(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1585,7 +1585,7 @@ u_strToUTF32WithSub(UChar32 *dest,
* @see u_strToUTF32WithSub
* @stable ICU 4.2
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF32WithSub(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1626,7 +1626,7 @@ u_strFromUTF32WithSub(UChar *dest,
* @see u_strToUTF8WithSub
* @see u_strFromJavaModifiedUTF8WithSub
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToJavaModifiedUTF8(
char *dest,
int32_t destCapacity,
@@ -1676,7 +1676,7 @@ u_strToJavaModifiedUTF8(
* @see u_strToJavaModifiedUTF8
* @stable ICU 4.4
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromJavaModifiedUTF8WithSub(
UChar *dest,
int32_t destCapacity,
diff --git a/deps/icu-small/source/common/unicode/utext.h b/deps/icu-small/source/common/unicode/utext.h
index d36c1c035e70f1..084362be78fc9d 100644
--- a/deps/icu-small/source/common/unicode/utext.h
+++ b/deps/icu-small/source/common/unicode/utext.h
@@ -180,7 +180,7 @@ typedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */
*
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_close(UText *ut);
/**
@@ -204,7 +204,7 @@ utext_close(UText *ut);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
@@ -222,7 +222,7 @@ utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
@@ -239,7 +239,7 @@ utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
@@ -255,7 +255,7 @@ utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);
@@ -271,7 +271,7 @@ utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode
* @see Replaceable
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
/**
@@ -286,7 +286,7 @@ utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
* @see Replaceable
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);
#endif
@@ -323,7 +323,7 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* shallow clones provide some protection against errors of this type by
* disabling text modification via the cloned UText.
*
- * A shallow clone made with the readOnly parameter == FALSE will preserve the
+ * A shallow clone made with the readOnly parameter == false will preserve the
* utext_isWritable() state of the source object. Note, however, that
* write operations must be avoided while more than one UText exists that refer
* to the same underlying text.
@@ -339,8 +339,8 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* If non-NULL, must refer to an already existing UText, which will then
* be reset to become the clone.
* @param src The UText to be cloned.
- * @param deep TRUE to request a deep clone, FALSE for a shallow clone.
- * @param readOnly TRUE to request that the cloned UText have read only access to the
+ * @param deep true to request a deep clone, false for a shallow clone.
+ * @param readOnly true to request that the cloned UText have read only access to the
* underlying text.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
@@ -349,7 +349,7 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* @return The newly created clone, or NULL if the clone operation failed.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
@@ -357,14 +357,14 @@ utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCod
* Compare two UText objects for equality.
* UTexts are equal if they are iterating over the same text, and
* have the same iteration position within the text.
- * If either or both of the parameters are NULL, the comparison is FALSE.
+ * If either or both of the parameters are NULL, the comparison is false.
*
* @param a The first of the two UTexts to compare.
* @param b The other UText to be compared.
- * @return TRUE if the two UTexts are equal.
+ * @return true if the two UTexts are equal.
* @stable ICU 3.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_equals(const UText *a, const UText *b);
@@ -385,11 +385,11 @@ utext_equals(const UText *a, const UText *b);
*
* @stable ICU 3.4
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_nativeLength(UText *ut);
/**
- * Return TRUE if calculating the length of the text could be expensive.
+ * Return true if calculating the length of the text could be expensive.
* Finding the length of NUL terminated strings is considered to be expensive.
*
* Note that the value of this function may change
@@ -398,10 +398,10 @@ utext_nativeLength(UText *ut);
* be expensive to report it.
*
* @param ut the text to be accessed.
- * @return TRUE if determining the length of the text could be time consuming.
+ * @return true if determining the length of the text could be time consuming.
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_isLengthExpensive(const UText *ut);
/**
@@ -429,7 +429,7 @@ utext_isLengthExpensive(const UText *ut);
* @return the code point at the specified index.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_char32At(UText *ut, int64_t nativeIndex);
@@ -443,7 +443,7 @@ utext_char32At(UText *ut, int64_t nativeIndex);
* @return the Unicode code point at the current iterator position.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_current32(UText *ut);
@@ -465,7 +465,7 @@ utext_current32(UText *ut);
* @see UTEXT_NEXT32
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_next32(UText *ut);
@@ -486,7 +486,7 @@ utext_next32(UText *ut);
* @see UTEXT_PREVIOUS32
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_previous32(UText *ut);
@@ -508,7 +508,7 @@ utext_previous32(UText *ut);
* or U_SENTINEL (-1) if it is out of bounds.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_next32From(UText *ut, int64_t nativeIndex);
@@ -528,7 +528,7 @@ utext_next32From(UText *ut, int64_t nativeIndex);
*
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_previous32From(UText *ut, int64_t nativeIndex);
/**
@@ -543,7 +543,7 @@ utext_previous32From(UText *ut, int64_t nativeIndex);
* @return the current index position, in the native units of the text provider.
* @stable ICU 3.4
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_getNativeIndex(const UText *ut);
/**
@@ -569,7 +569,7 @@ utext_getNativeIndex(const UText *ut);
* @param nativeIndex the native unit index of the new iteration position.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utext_setNativeIndex(UText *ut, int64_t nativeIndex);
/**
@@ -584,11 +584,11 @@ utext_setNativeIndex(UText *ut, int64_t nativeIndex);
*
* @param ut the text to be accessed.
* @param delta the signed number of code points to move the iteration position.
- * @return TRUE if the position could be moved the requested number of positions while
+ * @return true if the position could be moved the requested number of positions while
* staying within the range [0 - text length].
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_moveIndex32(UText *ut, int32_t delta);
/**
@@ -613,7 +613,7 @@ utext_moveIndex32(UText *ut, int32_t delta);
* or zero if the current position is at the start of the text.
* @stable ICU 3.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_getPreviousNativeIndex(UText *ut);
@@ -651,7 +651,7 @@ utext_getPreviousNativeIndex(UText *ut);
*
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utext_extract(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
UChar *dest, int32_t destCapacity,
@@ -768,16 +768,16 @@ utext_extract(UText *ut,
/**
- * Return TRUE if the text can be written (modified) with utext_replace() or
+ * Return true if the text can be written (modified) with utext_replace() or
* utext_copy(). For the text to be writable, the text provider must
* be of a type that supports writing and the UText must not be frozen.
*
- * Attempting to modify text when utext_isWriteable() is FALSE will fail -
+ * Attempting to modify text when utext_isWriteable() is false will fail -
* the text will not be modified, and an error will be returned from the function
* that attempted the modification.
*
* @param ut the UText to be tested.
- * @return TRUE if the text is modifiable.
+ * @return true if the text is modifiable.
*
* @see utext_freeze()
* @see utext_replace()
@@ -785,7 +785,7 @@ utext_extract(UText *ut,
* @stable ICU 3.4
*
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_isWritable(const UText *ut);
@@ -794,10 +794,10 @@ utext_isWritable(const UText *ut);
* @see Replaceable::hasMetaData()
*
* @param ut The UText to be tested
- * @return TRUE if the underlying text includes meta data.
+ * @return true if the underlying text includes meta data.
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_hasMetaData(const UText *ut);
@@ -808,7 +808,7 @@ utext_hasMetaData(const UText *ut);
* newly inserted replacement text.
*
* This function is only available on UText types that support writing,
- * that is, ones where utext_isWritable() returns TRUE.
+ * that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a replace operation
@@ -828,7 +828,7 @@ utext_hasMetaData(const UText *ut);
*
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utext_replace(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
const UChar *replacementText, int32_t replacementLength,
@@ -850,7 +850,7 @@ utext_replace(UText *ut,
* at the destination position.
*
* This function is only available on UText types that support writing,
- * that is, ones where utext_isWritable() returns TRUE.
+ * that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a copy operation
@@ -863,12 +863,12 @@ utext_replace(UText *ut,
* to be copied.
* @param destIndex The native destination index to which the source substring is
* copied or moved.
- * @param move If TRUE, then the substring is moved, not copied/duplicated.
+ * @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
+U_CAPI void U_EXPORT2
utext_copy(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
int64_t destIndex,
@@ -897,7 +897,7 @@ utext_copy(UText *ut,
* @see utext_isWritable()
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utext_freeze(UText *ut);
@@ -972,7 +972,7 @@ enum {
* @param dest A UText struct to be filled in with the result of the clone operation,
* or NULL if the clone function should heap-allocate a new UText struct.
* @param src The UText to be cloned.
- * @param deep TRUE to request a deep clone, FALSE for a shallow clone.
+ * @param deep true to request a deep clone, false for a shallow clone.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
* should be returned if the text provider is unable to clone the
* original text.
@@ -1008,9 +1008,9 @@ UTextNativeLength(UText *ut);
*
* @param ut the UText being accessed.
* @param nativeIndex Requested index of the text to be accessed.
- * @param forward If TRUE, then the returned chunk must contain text
+ * @param forward If true, then the returned chunk must contain text
* starting from the index, so that start<=indexUsage:
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -124,7 +124,7 @@
/**
* Is this code point a Unicode noncharacter?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_UNICODE_NONCHAR(c) \
@@ -145,7 +145,7 @@
* and that boundary is tested first for performance.
*
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_UNICODE_CHAR(c) \
@@ -155,7 +155,7 @@
/**
* Is this code point a BMP code point (U+0000..U+ffff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.8
*/
#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff)
@@ -163,7 +163,7 @@
/**
* Is this code point a supplementary code point (U+10000..U+10ffff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.8
*/
#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff)
@@ -171,7 +171,7 @@
/**
* Is this code point a lead surrogate (U+d800..U+dbff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
@@ -179,7 +179,7 @@
/**
* Is this code point a trail surrogate (U+dc00..U+dfff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
@@ -187,7 +187,7 @@
/**
* Is this code point a surrogate (U+d800..U+dfff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)
@@ -196,7 +196,7 @@
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
* is it a lead surrogate?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
@@ -205,7 +205,7 @@
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
* is it a trail surrogate?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 4.2
*/
#define U_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
diff --git a/deps/icu-small/source/common/unicode/utf16.h b/deps/icu-small/source/common/unicode/utf16.h
index 3315214ae69d86..9d68902d2de0f3 100644
--- a/deps/icu-small/source/common/unicode/utf16.h
+++ b/deps/icu-small/source/common/unicode/utf16.h
@@ -23,7 +23,7 @@
* 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
- * (http://userguide.icu-project.org/strings).
+ * (https://unicode-org.github.io/icu/userguide/strings).
*
* Usage:
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -34,6 +34,7 @@
#ifndef __UTF16_H__
#define __UTF16_H__
+#include
#include "unicode/umachine.h"
#ifndef __UTF_H__
# include "unicode/utf.h"
@@ -44,7 +45,7 @@
/**
* Does this code unit alone encode a code point (BMP, not a surrogate)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)
@@ -52,7 +53,7 @@
/**
* Is this code unit a lead surrogate (U+d800..U+dbff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
@@ -60,7 +61,7 @@
/**
* Is this code unit a trail surrogate (U+dc00..U+dfff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
@@ -68,7 +69,7 @@
/**
* Is this code unit a surrogate (U+d800..U+dfff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)
@@ -77,7 +78,7 @@
* Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
* is it a lead surrogate?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
@@ -86,7 +87,7 @@
* Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
* is it a trail surrogate?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 4.2
*/
#define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
@@ -379,13 +380,13 @@
* "Safe" macro, checks for a valid code point.
* If a surrogate pair is written, checks for sufficient space in the string.
* If the code point is not valid or a trail surrogate does not fit,
- * then isError is set to TRUE.
+ * then isError is set to true.
*
* @param s const UChar * string buffer
* @param i string offset, must be i>10)+0xd7c0); \
(s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
} else /* c>0x10ffff or not enough space */ { \
- (isError)=TRUE; \
+ (isError)=true; \
} \
} UPRV_BLOCK_MACRO_END
diff --git a/deps/icu-small/source/common/unicode/utf8.h b/deps/icu-small/source/common/unicode/utf8.h
index bb001303747efe..58bda2cbe51290 100644
--- a/deps/icu-small/source/common/unicode/utf8.h
+++ b/deps/icu-small/source/common/unicode/utf8.h
@@ -23,7 +23,7 @@
* 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
- * (http://userguide.icu-project.org/strings).
+ * (https://unicode-org.github.io/icu/userguide/strings).
*
* Usage:
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -34,6 +34,7 @@
#ifndef __UTF8_H__
#define __UTF8_H__
+#include
#include "unicode/umachine.h"
#ifndef __UTF_H__
# include "unicode/utf.h"
@@ -117,48 +118,48 @@
* Function for handling "next code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict);
/**
* Function for handling "append code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utf8_appendCharSafeBody(uint8_t *s, int32_t i, int32_t length, UChar32 c, UBool *pIsError);
/**
* Function for handling "previous code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utf8_prevCharSafeBody(const uint8_t *s, int32_t start, int32_t *pi, UChar32 c, UBool strict);
/**
* Function for handling "skip backward one code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/* single-code point definitions -------------------------------------------- */
@@ -166,7 +167,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_SINGLE(c) (((c)&0x80)==0)
@@ -174,7 +175,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Is this code unit (byte) a UTF-8 lead byte? (0xC2..0xF4)
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc2)<=0x32)
@@ -183,7 +184,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Is this code unit (byte) a UTF-8 trail byte? (0x80..0xBF)
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_TRAIL(c) ((int8_t)(c)<-0x40)
@@ -445,13 +446,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
* "Safe" macro, checks for a valid code point.
* If a non-ASCII code point is written, checks for sufficient space in the string.
* If the code point is not valid or trail bytes do not fit,
- * then isError is set to TRUE.
+ * then isError is set to true.
*
* @param s const uint8_t * string buffer
* @param i int32_t string offset, must be i>6)&0x3f)|0x80); \
(s)[(i)++]=(uint8_t)((__uc&0x3f)|0x80); \
} else { \
- (isError)=TRUE; \
+ (isError)=true; \
} \
} UPRV_BLOCK_MACRO_END
diff --git a/deps/icu-small/source/common/unicode/utf_old.h b/deps/icu-small/source/common/unicode/utf_old.h
index b2428e6b31e282..160f5ad0a9f248 100644
--- a/deps/icu-small/source/common/unicode/utf_old.h
+++ b/deps/icu-small/source/common/unicode/utf_old.h
@@ -109,7 +109,7 @@
* Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe"
* ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause
* program failures if the strings are not well-formed. The safe macros have an additional, boolean
- * parameter "strict". If strict is FALSE, then only illegal sequences are detected.
+ * parameter "strict". If strict is false, then only illegal sequences are detected.
* Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).
* Safe macros return special error code points for illegal/irregular sequences:
* Typically, U+ffff, or values that would result in a code unit sequence of the same length
@@ -181,7 +181,7 @@ typedef int32_t UTextOffset;
/**
* The default choice for general Unicode string macros is to use the ..._SAFE macro implementations
- * with strict=FALSE.
+ * with strict=false.
*
* @deprecated ICU 2.4. Obsolete, see utf_old.h.
*/
diff --git a/deps/icu-small/source/common/unicode/utrace.h b/deps/icu-small/source/common/unicode/utrace.h
index c7d51ff44f5bf7..bb8e3e8109cc66 100644
--- a/deps/icu-small/source/common/unicode/utrace.h
+++ b/deps/icu-small/source/common/unicode/utrace.h
@@ -112,11 +112,9 @@ typedef enum UTraceFunctionNumber {
UTRACE_COLLATION_LIMIT,
#endif // U_HIDE_DEPRECATED_API
-#ifndef U_HIDE_DRAFT_API
-
/**
* The lowest resource/data location.
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_START=0x3000,
@@ -133,7 +131,7 @@ typedef enum UTraceFunctionNumber {
* - "get" (a path was loaded, but the value was not accessed)
* - "getalias" (a path was loaded, and an alias was resolved)
*
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START,
@@ -141,7 +139,7 @@ typedef enum UTraceFunctionNumber {
* Indicates that a resource bundle was opened.
*
* Provides one C-style string to UTraceData: file name.
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_BUNDLE,
@@ -150,7 +148,7 @@ typedef enum UTraceFunctionNumber {
*
* Provides one C-style string to UTraceData: file name.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_DATA_FILE,
@@ -163,12 +161,10 @@ typedef enum UTraceFunctionNumber {
*
* Provides one C-style string to UTraceData: file name.
*
- * @draft ICU 65
+ * @stable 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.
@@ -249,7 +245,7 @@ typedef enum UTraceFunctionNumber {
* @param traceLevel A UTraceLevel value.
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_setLevel(int32_t traceLevel);
/**
@@ -257,7 +253,7 @@ utrace_setLevel(int32_t traceLevel);
* @return The UTraceLevel value being used by ICU.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_getLevel(void);
/* Trace function pointers types ----------------------------- */
@@ -331,7 +327,7 @@ UTraceData(const void *context, int32_t fnNumber, int32_t level,
*
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_setFunctions(const void *context,
UTraceEntry *e, UTraceExit *x, UTraceData *d);
@@ -345,7 +341,7 @@ utrace_setFunctions(const void *context,
* @param d The currently installed UTraceData function.
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_getFunctions(const void **context,
UTraceEntry **e, UTraceExit **x, UTraceData **d);
@@ -467,7 +463,7 @@ utrace_getFunctions(const void **context,
* If buffer capacity is insufficient, the required capacity is returned.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_vformat(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, va_list args);
@@ -488,7 +484,7 @@ utrace_vformat(char *outBuf, int32_t capacity,
* If buffer capacity is insufficient, the required capacity is returned.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_format(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, ...);
@@ -505,7 +501,7 @@ utrace_format(char *outBuf, int32_t capacity,
* @see UTraceFunctionNumber
* @stable ICU 2.8
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
utrace_functionName(int32_t fnNumber);
U_CDECL_END
diff --git a/deps/icu-small/source/common/unicode/utypes.h b/deps/icu-small/source/common/unicode/utypes.h
index c98de9e6fc3dad..6c57218db8d477 100644
--- a/deps/icu-small/source/common/unicode/utypes.h
+++ b/deps/icu-small/source/common/unicode/utypes.h
@@ -479,13 +479,23 @@ typedef enum UErrorCode {
U_COLLATOR_VERSION_MISMATCH = 28, /**< Collator version is not compatible with the base version */
U_USELESS_COLLATOR_ERROR = 29, /**< Collator is options only and no base is specified */
U_NO_WRITE_PERMISSION = 30, /**< Attempt to modify read-only or constant data. */
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * The input is impractically long for an operation.
+ * It is rejected because it may lead to problems such as excessive
+ * processing time, stack depth, or heap memory requirements.
+ *
+ * @draft ICU 68
+ */
+ U_INPUT_TOO_LONG_ERROR = 31,
+#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_DEPRECATED_API
/**
* One more than the highest standard error code.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
- U_STANDARD_ERROR_LIMIT,
+ U_STANDARD_ERROR_LIMIT = 32,
#endif // U_HIDE_DEPRECATED_API
/*
@@ -715,7 +725,7 @@ typedef enum UErrorCode {
* in the UErrorCode enum above.
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
u_errorName(UErrorCode code);
diff --git a/deps/icu-small/source/common/unicode/uvernum.h b/deps/icu-small/source/common/unicode/uvernum.h
index c66776d10b5826..a46481a3fe610c 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 67
+#define U_ICU_VERSION_MAJOR_NUM 68
/** 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 1
+#define U_ICU_VERSION_MINOR_NUM 2
/** 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 _67
+#define U_ICU_VERSION_SUFFIX _68
/**
* \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 "67.1"
+#define U_ICU_VERSION "68.2"
/**
* The current ICU library major version number as a string, for library name suffixes.
@@ -148,17 +148,17 @@
* Until ICU 4.8, this was the combination of the single-digit major and minor ICU version numbers
* into one string without dots ("48").
* Since ICU 49, it is the double-digit major ICU version number.
- * See http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU
+ * See https://unicode-org.github.io/icu/userguide/design#version-numbers-in-icu
*
* @stable ICU 2.6
*/
-#define U_ICU_VERSION_SHORT "67"
+#define U_ICU_VERSION_SHORT "68"
#ifndef U_HIDE_INTERNAL_API
/** Data version in ICU4C.
* @internal ICU 4.4 Internal Use Only
**/
-#define U_ICU_DATA_VERSION "67.1"
+#define U_ICU_DATA_VERSION "68.2"
#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 c8c7a374c820b2..dde3059261047c 100644
--- a/deps/icu-small/source/common/unicode/uversion.h
+++ b/deps/icu-small/source/common/unicode/uversion.h
@@ -141,7 +141,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
* values of up to 255 each.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionFromString(UVersionInfo versionArray, const char *versionString);
/**
@@ -155,7 +155,7 @@ u_versionFromString(UVersionInfo versionArray, const char *versionString);
* fields with values of up to 255 each.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionFromUString(UVersionInfo versionArray, const UChar *versionString);
@@ -171,7 +171,7 @@ u_versionFromUString(UVersionInfo versionArray, const UChar *versionString);
* The buffer size must be at least U_MAX_VERSION_STRING_LENGTH.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionToString(const UVersionInfo versionArray, char *versionString);
/**
@@ -182,6 +182,6 @@ u_versionToString(const UVersionInfo versionArray, char *versionString);
* @param versionArray the version # information, the result will be filled in
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_getVersion(UVersionInfo versionArray);
#endif
diff --git a/deps/icu-small/source/common/unifiedcache.cpp b/deps/icu-small/source/common/unifiedcache.cpp
index f2dd916559588c..493ab79f6d9067 100644
--- a/deps/icu-small/source/common/unifiedcache.cpp
+++ b/deps/icu-small/source/common/unifiedcache.cpp
@@ -311,7 +311,7 @@ void UnifiedCache::_putNew(
}
keyToAdopt->fCreationStatus = creationStatus;
if (value->softRefCount == 0) {
- _registerMaster(keyToAdopt, value);
+ _registerPrimary(keyToAdopt, value);
}
void *oldValue = uhash_put(fHashtable, keyToAdopt, (void *) value, &status);
U_ASSERT(oldValue == nullptr);
@@ -338,7 +338,7 @@ void UnifiedCache::_putIfAbsentAndGet(
} else {
_put(element, value, status);
}
- // Run an eviction slice. This will run even if we added a master entry
+ // Run an eviction slice. This will run even if we added a primary entry
// which doesn't increase the unused count, but that is still o.k
_runEvictionSlice();
}
@@ -403,9 +403,9 @@ void UnifiedCache::_get(
}
}
-void UnifiedCache::_registerMaster(
+void UnifiedCache::_registerPrimary(
const CacheKeyBase *theKey, const SharedObject *value) const {
- theKey->fIsMaster = true;
+ theKey->fIsPrimary = true;
value->cachePtr = this;
++fNumValuesTotal;
++fNumValuesInUse;
@@ -420,7 +420,7 @@ void UnifiedCache::_put(
const SharedObject *oldValue = (const SharedObject *) element->value.pointer;
theKey->fCreationStatus = status;
if (value->softRefCount == 0) {
- _registerMaster(theKey, value);
+ _registerPrimary(theKey, value);
}
value->softRefCount++;
UHashElement *ptr = const_cast(element);
@@ -474,9 +474,9 @@ UBool UnifiedCache::_isEvictable(const UHashElement *element) const
return FALSE;
}
- // We can evict entries that are either not a master or have just
+ // We can evict entries that are either not a primary or have just
// one reference (The one reference being from the cache itself).
- return (!theKey->fIsMaster || (theValue->softRefCount == 1 && theValue->noHardReferences()));
+ return (!theKey->fIsPrimary || (theValue->softRefCount == 1 && theValue->noHardReferences()));
}
void UnifiedCache::removeSoftRef(const SharedObject *value) const {
diff --git a/deps/icu-small/source/common/unifiedcache.h b/deps/icu-small/source/common/unifiedcache.h
index 5c0bd76f4a2b94..865f4545105cb6 100644
--- a/deps/icu-small/source/common/unifiedcache.h
+++ b/deps/icu-small/source/common/unifiedcache.h
@@ -34,13 +34,13 @@ class UnifiedCache;
*/
class U_COMMON_API CacheKeyBase : public UObject {
public:
- CacheKeyBase() : fCreationStatus(U_ZERO_ERROR), fIsMaster(FALSE) {}
+ CacheKeyBase() : fCreationStatus(U_ZERO_ERROR), fIsPrimary(false) {}
/**
* Copy constructor. Needed to support cloning.
*/
CacheKeyBase(const CacheKeyBase &other)
- : UObject(other), fCreationStatus(other.fCreationStatus), fIsMaster(FALSE) { }
+ : UObject(other), fCreationStatus(other.fCreationStatus), fIsPrimary(false) { }
virtual ~CacheKeyBase();
/**
@@ -88,7 +88,7 @@ class U_COMMON_API CacheKeyBase : public UObject {
}
private:
mutable UErrorCode fCreationStatus;
- mutable UBool fIsMaster;
+ mutable UBool fIsPrimary;
friend class UnifiedCache;
};
@@ -147,10 +147,10 @@ class LocaleCacheKey : public CacheKey {
virtual UBool operator == (const CacheKeyBase &other) const {
// reflexive
if (this == &other) {
- return TRUE;
+ return true;
}
if (!CacheKey::operator == (other)) {
- return FALSE;
+ return false;
}
// We know this and other are of same class because operator== on
// CacheKey returned true.
@@ -359,7 +359,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
/**
* 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.
+ * 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.
@@ -370,7 +370,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
* hard (external) references are not deleted, but are detached from
* the cache, so that a subsequent removeRefs can delete them.
* _flush is not thread safe when all is true.
- * @return TRUE if any value in cache was flushed or FALSE otherwise.
+ * @return true if any value in cache was flushed or false otherwise.
*/
UBool _flush(UBool all) const;
@@ -395,11 +395,11 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
* Attempts to fetch value and status for key from cache.
* On entry, gCacheMutex must not be held value must be NULL and status must
* be U_ZERO_ERROR.
- * On exit, either returns FALSE (In this
- * case caller should try to create the object) or returns TRUE with value
+ * On exit, either returns false (In this
+ * case caller should try to create the object) or returns true with value
* pointing to the fetched value and status set to fetched status. When
- * FALSE is returned status may be set to failure if an in progress hash
- * entry could not be made but value will remain unchanged. When TRUE is
+ * false is returned status may be set to failure if an in progress hash
+ * entry could not be made but value will remain unchanged. When true is
* returned, caller must call removeRef() on value.
*/
UBool _poll(
@@ -463,17 +463,17 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
void _runEvictionSlice() const;
/**
- * Register a master cache entry. A master key is the first key to create
+ * Register a primary cache entry. A primary 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 -
+ * produce referneces to an already existing SharedObject are not primary -
* 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
+ * On exit, items in use count incremented, entry is marked as a primary
* 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;
+ void _registerPrimary(const CacheKeyBase *theKey, const SharedObject *value) const;
/**
* Store a value and creation error status in given hash entry.
diff --git a/deps/icu-small/source/common/uniquecharstr.h b/deps/icu-small/source/common/uniquecharstr.h
new file mode 100644
index 00000000000000..10cc924f7f9eb2
--- /dev/null
+++ b/deps/icu-small/source/common/uniquecharstr.h
@@ -0,0 +1,98 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+// uniquecharstr.h
+// created: 2020sep01 Frank Yung-Fong Tang
+
+#ifndef __UNIQUECHARSTR_H__
+#define __UNIQUECHARSTR_H__
+
+#include "charstr.h"
+#include "uassert.h"
+#include "uhash.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Stores NUL-terminated strings with duplicate elimination.
+ * Checks for unique UTF-16 string pointers and converts to invariant characters.
+ *
+ * Intended to be stack-allocated. Add strings, get a unique number for each,
+ * freeze the object, get a char * pointer for each string,
+ * call orphanCharStrings() to capture the string storage, and let this object go out of scope.
+ */
+class UniqueCharStrings {
+public:
+ UniqueCharStrings(UErrorCode &errorCode) : strings(nullptr) {
+ // Note: We hash on string contents but store stable char16_t * pointers.
+ // If the strings are stored in resource bundles which should be built with
+ // duplicate elimination, then we should be able to hash on just the pointer values.
+ 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.
+ * The string's buffer contents must not change, nor move around in memory,
+ * while this UniqueCharStrings is in use.
+ * The string contents must be NUL-terminated exactly at s.length().
+ *
+ * Best used with read-only-alias UnicodeString objects that point to
+ * stable storage, such as strings returned by resource bundle functions.
+ */
+ 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;
+};
+
+U_NAMESPACE_END
+
+#endif // __UNIQUECHARSTR_H__
diff --git a/deps/icu-small/source/common/unisetspan.h b/deps/icu-small/source/common/unisetspan.h
index f1e78ff3ee2b00..9a1307a9078aab 100644
--- a/deps/icu-small/source/common/unisetspan.h
+++ b/deps/icu-small/source/common/unisetspan.h
@@ -65,8 +65,8 @@ class UnicodeSetStringSpan : public UMemory {
/*
* Do the strings need to be checked in span() etc.?
- * @return TRUE if strings need to be checked (call span() here),
- * FALSE if not (use a BMPSet for best performance).
+ * @return true if strings need to be checked (call span() here),
+ * false if not (use a BMPSet for best performance).
*/
inline UBool needsStringSpanUTF16();
inline UBool needsStringSpanUTF8();
diff --git a/deps/icu-small/source/common/unormimp.h b/deps/icu-small/source/common/unormimp.h
index 7f280551f7ef8e..e09c5c1c916773 100644
--- a/deps/icu-small/source/common/unormimp.h
+++ b/deps/icu-small/source/common/unormimp.h
@@ -418,7 +418,7 @@ enum {
* The same bit is used for NFC and NFKC; (c) differs for them.
* As usual, we build the "not skippable" flags so that unassigned
* code points get a 0 bit.
- * This bit is only valid after (a)..(e) test FALSE; test NFD_NO before (f) as well.
+ * This bit is only valid after (a)..(e) test false; test NFD_NO before (f) as well.
* Test Hangul LV syllables entirely in code.
*
*
diff --git a/deps/icu-small/source/common/uresbund.cpp b/deps/icu-small/source/common/uresbund.cpp
index f4efb8ccab5a0b..743df1f8c505ce 100644
--- a/deps/icu-small/source/common/uresbund.cpp
+++ b/deps/icu-small/source/common/uresbund.cpp
@@ -1792,7 +1792,7 @@ ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *f
return result;
}
-U_INTERNAL const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByKeyWithFallback(const UResourceBundle *resB,
const char* inKey,
int32_t* len,
@@ -2210,7 +2210,7 @@ ures_getUTF8StringByKey(const UResourceBundle *resB,
* INTERNAL: Get the name of the first real locale (not placeholder)
* that has resource bundle data.
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getLocaleInternal(const UResourceBundle* resourceBundle, UErrorCode* status)
{
if (status==NULL || U_FAILURE(*status)) {
@@ -2357,7 +2357,7 @@ ures_openDirect(const char* path, const char* localeID, UErrorCode* status) {
*
* Same as ures_open(), but uses the fill-in parameter and does not allocate a new bundle.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openFillIn(UResourceBundle *r, const char* path,
const char* localeID, UErrorCode* status) {
if(U_SUCCESS(*status) && r == NULL) {
@@ -2370,7 +2370,7 @@ ures_openFillIn(UResourceBundle *r, const char* path,
/**
* Same as ures_openDirect(), but uses the fill-in parameter and does not allocate a new bundle.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openDirectFillIn(UResourceBundle *r, const char* path, const char* localeID, UErrorCode* status) {
if(U_SUCCESS(*status) && r == NULL) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
@@ -2420,7 +2420,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle,
* @see ures_getVersion
* @internal
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getVersionNumberInternal(const UResourceBundle *resourceBundle)
{
if (!resourceBundle) return NULL;
@@ -3016,7 +3016,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status)
}
#if 0
/* This code isn't needed, and given the documentation warnings the implementation is suspect */
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ures_equal(const UResourceBundle* res1, const UResourceBundle* res2){
if(res1==NULL || res2==NULL){
return res1==res2; /* pointer comparision */
@@ -3052,7 +3052,7 @@ ures_equal(const UResourceBundle* res1, const UResourceBundle* res2){
}
return TRUE;
}
-U_INTERNAL UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_clone(const UResourceBundle* res, UErrorCode* status){
UResourceBundle* bundle = NULL;
UResourceBundle* ret = NULL;
@@ -3068,7 +3068,7 @@ ures_clone(const UResourceBundle* res, UErrorCode* status){
}
return ret;
}
-U_INTERNAL const UResourceBundle* U_EXPORT2
+U_CAPI const UResourceBundle* U_EXPORT2
ures_getParentBundle(const UResourceBundle* res){
if(res==NULL){
return NULL;
@@ -3077,7 +3077,7 @@ ures_getParentBundle(const UResourceBundle* res){
}
#endif
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo ver, UErrorCode *status) {
const UChar *str;
int32_t len;
diff --git a/deps/icu-small/source/common/uresdata.cpp b/deps/icu-small/source/common/uresdata.cpp
index 1bb938be62c35b..4e3309f497522c 100644
--- a/deps/icu-small/source/common/uresdata.cpp
+++ b/deps/icu-small/source/common/uresdata.cpp
@@ -963,7 +963,7 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch
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) {
+ if(indexR >= 0 && *closeIndex == 0 && (*pathP != '0' || closeIndex - pathP == 1)) {
/* if we indeed have an index, try to get the item by index */
t2 = res_getTableItemByIndex(pResData, t1, indexR, key);
} // else t2 is already RES_BOGUS
diff --git a/deps/icu-small/source/common/uresdata.h b/deps/icu-small/source/common/uresdata.h
index d1b67babf29049..7c2152e57b500d 100644
--- a/deps/icu-small/source/common/uresdata.h
+++ b/deps/icu-small/source/common/uresdata.h
@@ -402,7 +402,7 @@ typedef struct ResourceData {
/*
* Read a resource bundle from memory.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
res_read(ResourceData *pResData,
const UDataInfo *pInfo, const void *inBytes, int32_t length,
UErrorCode *errorCode);
@@ -422,7 +422,7 @@ res_load(ResourceData *pResData,
U_CFUNC void
res_unload(ResourceData *pResData);
-U_INTERNAL UResType U_EXPORT2
+U_CAPI UResType U_EXPORT2
res_getPublicType(Resource res);
///////////////////////////////////////////////////////////////////////////
@@ -434,31 +434,31 @@ res_getPublicType(Resource res);
* and set its length in *pLength.
* Returns NULL if not found.
*/
-U_INTERNAL const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const uint8_t * U_EXPORT2
+U_CAPI const uint8_t * U_EXPORT2
res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const int32_t * U_EXPORT2
+U_CAPI const int32_t * U_EXPORT2
res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getResource(const ResourceData *pResData, const char *key);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
res_countArrayItems(const ResourceData *pResData, Resource res);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getArrayItem(const ResourceData *pResData, Resource array, int32_t indexS);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getTableItemByIndex(const ResourceData *pResData, Resource table, int32_t indexS, const char ** key);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getTableItemByKey(const ResourceData *pResData, Resource table, int32_t *indexS, const char* * key);
/**
diff --git a/deps/icu-small/source/common/uresimp.h b/deps/icu-small/source/common/uresimp.h
index 2e477dfad3e98f..12154dcb7c68d4 100644
--- a/deps/icu-small/source/common/uresimp.h
+++ b/deps/icu-small/source/common/uresimp.h
@@ -157,7 +157,7 @@ U_CFUNC const char* ures_getName(const UResourceBundle* resB);
U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
/**
* If anything was in the RB cache, dump it to the screen.
- * @return TRUE if there was anything into the cache
+ * @return true if there was anything into the cache
*/
U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void);
#endif
@@ -218,7 +218,7 @@ ures_findSubResource(const UResourceBundle *resB,
* @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 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
* than resultCapacity, the returned full name will be truncated and an error code will be returned.
diff --git a/deps/icu-small/source/common/ustr_imp.h b/deps/icu-small/source/common/ustr_imp.h
index 85d8e6d8ee6970..5b249ade3d21bb 100644
--- a/deps/icu-small/source/common/ustr_imp.h
+++ b/deps/icu-small/source/common/ustr_imp.h
@@ -29,7 +29,7 @@
/**
* Compare two strings in code point order or code unit order.
* Works in strcmp style (both lengths -1),
- * strncmp style (lengths equal and >=0, flag TRUE),
+ * strncmp style (lengths equal and >=0, flag true),
* and memcmp/UnicodeString style (at least one length >=0).
*/
U_CFUNC int32_t U_EXPORT2
@@ -37,13 +37,13 @@ uprv_strCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
UBool strncmpStyle, UBool codePointOrder);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashUCharsN(const UChar *str, int32_t length);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashCharsN(const char *str, int32_t length);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashICharsN(const char *str, int32_t length);
/**
@@ -53,7 +53,7 @@ ustr_hashICharsN(const char *str, int32_t length);
* @return If UChar is a lowercase ASCII character, returns the uppercase version.
* Otherwise, returns the input character.
*/
-U_INTERNAL UChar U_EXPORT2
+U_CAPI UChar U_EXPORT2
u_asciiToUpper(UChar c);
// TODO: Add u_asciiToLower if/when there is a need for it.
@@ -70,28 +70,28 @@ u_asciiToUpper(UChar c);
* @param pErrorCode ICU error code.
* @return length
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a char * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a UChar32 * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a wchar_t * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
@@ -133,7 +133,7 @@ class UTF8 {
* @param t The i-th byte following the lead byte.
* @param i The index (1..3) of byte t in the byte sequence. 0 length) {
+ tailLimit = length;
+ }
+ c = (UChar) u_unescapeAt(charAt, &ahead, tailLimit,
+ context);
}
if (U16_IS_TRAIL(c)) {
*offset = ahead;
diff --git a/deps/icu-small/source/common/util.h b/deps/icu-small/source/common/util.h
index a2be25056e9acb..2a709e408a2698 100644
--- a/deps/icu-small/source/common/util.h
+++ b/deps/icu-small/source/common/util.h
@@ -64,8 +64,8 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s
/**
* Escape unprintable characters using \uxxxx notation for U+0000 to
* U+FFFF and \Uxxxxxxxx for U+10000 and above. If the character is
- * printable ASCII, then do nothing and return FALSE. Otherwise,
- * append the escaped notation and return TRUE.
+ * printable ASCII, then do nothing and return false. Otherwise,
+ * append the escaped notation and return true.
*/
static UBool escapeUnprintable(UnicodeString& result, UChar32 c);
@@ -95,7 +95,7 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s
* after pos, or str.length(), if there is none.
*/
static int32_t skipWhitespace(const UnicodeString& str, int32_t& pos,
- UBool advance = FALSE);
+ UBool advance = false);
/**
* Skip over Pattern_White_Space in a Replaceable.
diff --git a/deps/icu-small/source/common/utrie.h b/deps/icu-small/source/common/utrie.h
index 532ba778eb6ed1..2fd2c461ffb250 100644
--- a/deps/icu-small/source/common/utrie.h
+++ b/deps/icu-small/source/common/utrie.h
@@ -460,13 +460,13 @@ UTrieEnumValue(const void *context, uint32_t value);
* of code points with the same value as retrieved from the trie and
* transformed by the UTrieEnumValue function.
*
- * The callback function can stop the enumeration by returning FALSE.
+ * The callback function can stop the enumeration by returning false.
*
* @param context an opaque pointer, as passed into utrie_enum()
* @param start the first code point in a contiguous range with value
* @param limit one past the last code point in a contiguous range with value
* @param value the value that is set for all code points in [start..limit[
- * @return FALSE to stop the enumeration
+ * @return false to stop the enumeration
*/
typedef UBool U_CALLCONV
UTrieEnumRange(const void *context, UChar32 start, UChar32 limit, uint32_t value);
@@ -667,7 +667,7 @@ utrie_getData(UNewTrie *trie, int32_t *pLength);
* @param trie the build-time trie
* @param c the code point
* @param value the value
- * @return FALSE if a failure occurred (illegal argument or data array overrun)
+ * @return false if a failure occurred (illegal argument or data array overrun)
*/
U_CAPI UBool U_EXPORT2
utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
@@ -677,7 +677,7 @@ utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
*
* @param trie the build-time trie
* @param c the code point
- * @param pInBlockZero if not NULL, then *pInBlockZero is set to TRUE
+ * @param pInBlockZero if not NULL, then *pInBlockZero is set to true
* iff the value is retrieved from block 0;
* block 0 is the all-initial-value initial block
* @return the value
@@ -688,14 +688,14 @@ utrie_get32(UNewTrie *trie, UChar32 c, UBool *pInBlockZero);
/**
* Set a value in a range of code points [start..limit[.
* All code points c with start<=cswapArray32(ds, &inTrie->signature, 4, &outTrie->signature, pErrorCode);
ds->swapArray16(ds, &inTrie->options, 12, &outTrie->options, pErrorCode);
- /* swap the index and the data */
+ /* swap the index */
+ const uint16_t *inIndex=reinterpret_cast(inTrie+1);
+ uint16_t *outIndex=reinterpret_cast(outTrie+1);
+ ds->swapArray16(ds, inIndex, trie.indexLength*2, outIndex, pErrorCode);
+
+ /* swap the data */
+ const uint16_t *inData=inIndex+trie.indexLength;
+ uint16_t *outData=outIndex+trie.indexLength;
switch(valueWidth) {
case UCPTRIE_VALUE_BITS_16:
- ds->swapArray16(ds, inTrie+1, (trie.indexLength+dataLength)*2, outTrie+1, pErrorCode);
+ ds->swapArray16(ds, inData, dataLength*2, outData, pErrorCode);
break;
case UCPTRIE_VALUE_BITS_32:
- ds->swapArray16(ds, inTrie+1, trie.indexLength*2, outTrie+1, pErrorCode);
- ds->swapArray32(ds, (const uint16_t *)(inTrie+1)+trie.indexLength, dataLength*4,
- (uint16_t *)(outTrie+1)+trie.indexLength, pErrorCode);
+ ds->swapArray32(ds, inData, dataLength*4, outData, pErrorCode);
break;
case UCPTRIE_VALUE_BITS_8:
- ds->swapArray16(ds, inTrie+1, trie.indexLength*2, outTrie+1, pErrorCode);
if(inTrie!=outTrie) {
- uprv_memmove((outTrie+1)+trie.indexLength, (inTrie+1)+trie.indexLength, dataLength);
+ uprv_memmove(outData, inData, dataLength);
}
break;
default:
diff --git a/deps/icu-small/source/common/uts46.cpp b/deps/icu-small/source/common/uts46.cpp
index b9e6cb023bb379..f25b4e12f124ca 100644
--- a/deps/icu-small/source/common/uts46.cpp
+++ b/deps/icu-small/source/common/uts46.cpp
@@ -714,6 +714,16 @@ UTS46::processLabel(UnicodeString &dest,
UBool wasPunycode;
if(labelLength>=4 && label[0]==0x78 && label[1]==0x6e && label[2]==0x2d && label[3]==0x2d) {
// Label starts with "xn--", try to un-Punycode it.
+ // In IDNA2008, labels like "xn--" (decodes to an empty string) and
+ // "xn--ASCII-" (decodes to just "ASCII") fail the round-trip validation from
+ // comparing the ToUnicode input with the back-to-ToASCII output.
+ // They are alternate encodings of the respective ASCII labels.
+ // Ignore "xn---" here: It will fail Punycode.decode() which logically comes before
+ // the round-trip verification.
+ if(labelLength==4 || (labelLength>5 && label[labelLength-1]==u'-')) {
+ info.labelErrors|=UIDNA_ERROR_INVALID_ACE_LABEL;
+ return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode);
+ }
wasPunycode=TRUE;
UChar *unicodeBuffer=fromPunycode.getBuffer(-1); // capacity==-1: most labels should fit
if(unicodeBuffer==NULL) {
@@ -925,10 +935,10 @@ UTS46::markBadACELabel(UnicodeString &dest,
UBool isASCII=TRUE;
UBool onlyLDH=TRUE;
const UChar *label=dest.getBuffer()+labelStart;
- // Ok to cast away const because we own the UnicodeString.
- UChar *s=(UChar *)label+4; // After the initial "xn--".
const UChar *limit=label+labelLength;
- do {
+ // Start after the initial "xn--".
+ // Ok to cast away const because we own the UnicodeString.
+ for(UChar *s=const_cast(label+4); sTo do
*
diff --git a/deps/icu-small/source/common/uvectr32.h b/deps/icu-small/source/common/uvectr32.h
index 91a2dd2009eecb..92746a4f4782d8 100644
--- a/deps/icu-small/source/common/uvectr32.h
+++ b/deps/icu-small/source/common/uvectr32.h
@@ -214,7 +214,7 @@ class U_COMMON_API UVector32 : public UObject {
inline UBool UVector32::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
if ((minimumCapacity >= 0) && (capacity >= minimumCapacity)) {
- return TRUE;
+ return true;
} else {
return expandCapacity(minimumCapacity, status);
}
@@ -233,7 +233,7 @@ inline void UVector32::addElement(int32_t elem, UErrorCode &status) {
}
inline int32_t *UVector32::reserveBlock(int32_t size, UErrorCode &status) {
- if (ensureCapacity(count+size, status) == FALSE) {
+ if (ensureCapacity(count+size, status) == false) {
return NULL;
}
int32_t *rp = elements+count;
diff --git a/deps/icu-small/source/common/uvectr64.h b/deps/icu-small/source/common/uvectr64.h
index 6d26863eabc00d..4dab16396c1d13 100644
--- a/deps/icu-small/source/common/uvectr64.h
+++ b/deps/icu-small/source/common/uvectr64.h
@@ -203,7 +203,7 @@ class U_COMMON_API UVector64 : public UObject {
inline UBool UVector64::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
if ((minimumCapacity >= 0) && (capacity >= minimumCapacity)) {
- return TRUE;
+ return true;
} else {
return expandCapacity(minimumCapacity, status);
}
@@ -222,7 +222,7 @@ inline void UVector64::addElement(int64_t elem, UErrorCode &status) {
}
inline int64_t *UVector64::reserveBlock(int32_t size, UErrorCode &status) {
- if (ensureCapacity(count+size, status) == FALSE) {
+ if (ensureCapacity(count+size, status) == false) {
return NULL;
}
int64_t *rp = elements+count;
diff --git a/deps/icu-small/source/common/wintz.cpp b/deps/icu-small/source/common/wintz.cpp
index 115512e704cced..6805297a38a161 100644
--- a/deps/icu-small/source/common/wintz.cpp
+++ b/deps/icu-small/source/common/wintz.cpp
@@ -16,11 +16,12 @@
#if U_PLATFORM_USES_ONLY_WIN32_API
#include "wintz.h"
+#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/ures.h"
-#include "unicode/ustring.h"
+#include "unicode/unistr.h"
#include "uresimp.h"
#ifndef WIN32_LEAN_AND_MEAN
@@ -35,89 +36,279 @@
U_NAMESPACE_BEGIN
-// The max size of TimeZoneKeyName is 128, defined in DYNAMIC_TIME_ZONE_INFORMATION
-#define MAX_TIMEZONE_ID_LENGTH 128
+// Note these constants and the struct are only used when dealing with the fallback path for RDP sesssions.
+
+// This is the location of the time zones in the registry on Vista+ systems.
+// See: https://docs.microsoft.com/windows/win32/api/timezoneapi/ns-timezoneapi-dynamic_time_zone_information
+#define WINDOWS_TIMEZONES_REG_KEY_PATH L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
+
+// Max length for a registry key is 255. +1 for null.
+// See: https://docs.microsoft.com/windows/win32/sysinfo/registry-element-size-limits
+#define WINDOWS_MAX_REG_KEY_LENGTH 256
+
+#if U_PLATFORM_HAS_WINUWP_API == 0
+
+// This is the layout of the TZI binary value in the registry.
+// See: https://docs.microsoft.com/windows/win32/api/timezoneapi/ns-timezoneapi-time_zone_information
+typedef struct _REG_TZI_FORMAT {
+ LONG Bias;
+ LONG StandardBias;
+ LONG DaylightBias;
+ SYSTEMTIME StandardDate;
+ SYSTEMTIME DaylightDate;
+} REG_TZI_FORMAT;
+
+#endif // U_PLATFORM_HAS_WINUWP_API
/**
-* Main Windows time zone detection function.
-* Returns the Windows time zone converted to an ICU time zone as a heap-allocated buffer, or nullptr upon failure.
-* Note: We use the Win32 API GetDynamicTimeZoneInformation to get the current time zone info.
-* This API returns a non-localized time zone name, which we can then map to an ICU time zone name.
+* This is main Windows time zone detection function.
+*
+* It returns the Windows time zone converted to an ICU time zone as a heap-allocated buffer, or nullptr upon failure.
+*
+* We use the Win32 API GetDynamicTimeZoneInformation (which is available since Vista) to get the current time zone info,
+* as this API returns a non-localized time zone name which can be then mapped to an ICU time zone.
+*
+* However, in some RDP/terminal services situations, this struct isn't always fully complete, and the TimeZoneKeyName
+* field of the struct might be NULL. This can happen with some 3rd party RDP clients, and also when using older versions
+* of the RDP protocol, which don't send the newer TimeZoneKeyNamei information and only send the StandardName and DaylightName.
+*
+* Since these 3rd party clients and older RDP clients only send the pre-Vista time zone information to the server, this means that we
+* need to fallback on using the pre-Vista methods to determine the time zone. This unfortunately requires examining the registry directly
+* in order to try and determine the current time zone.
+*
+* Note that this can however still fail in some cases though if the client and server are using different languages, as the StandardName
+* that is sent by client is localized in the client's language. However, we must compare this to the names that are on the server, which
+* are localized in registry using the server's language. Despite that, this is the best we can do.
+*
+* Note: This fallback method won't work for the UWP version though, as we can't use the registry APIs in UWP.
+*
+* Once we have the current Windows time zone, then we can then map it to an ICU time zone ID (~ Olsen ID).
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uprv_detectWindowsTimeZone()
{
- UErrorCode status = U_ZERO_ERROR;
- char* icuid = nullptr;
- char dynamicTZKeyName[MAX_TIMEZONE_ID_LENGTH];
- char tmpid[MAX_TIMEZONE_ID_LENGTH];
- int32_t len;
- int id = GEOID_NOT_AVAILABLE;
- int errorCode;
- wchar_t ISOcodeW[3] = {}; /* 2 letter ISO code in UTF-16 */
- char ISOcode[3] = {}; /* 2 letter ISO code in UTF-8 */
-
+ // We first try to obtain the time zone directly by using the TimeZoneKeyName field of the DYNAMIC_TIME_ZONE_INFORMATION struct.
DYNAMIC_TIME_ZONE_INFORMATION dynamicTZI;
uprv_memset(&dynamicTZI, 0, sizeof(dynamicTZI));
- uprv_memset(dynamicTZKeyName, 0, sizeof(dynamicTZKeyName));
- uprv_memset(tmpid, 0, sizeof(tmpid));
+ SYSTEMTIME systemTimeAllZero;
+ uprv_memset(&systemTimeAllZero, 0, sizeof(systemTimeAllZero));
- /* Obtain TIME_ZONE_INFORMATION from the API and get the non-localized time zone name. */
- if (TIME_ZONE_ID_INVALID == GetDynamicTimeZoneInformation(&dynamicTZI)) {
+ if (GetDynamicTimeZoneInformation(&dynamicTZI) == TIME_ZONE_ID_INVALID) {
return nullptr;
}
- id = GetUserGeoID(GEOCLASS_NATION);
- errorCode = GetGeoInfoW(id, GEO_ISO2, ISOcodeW, 3, 0);
+ // If the DST setting has been turned off in the Control Panel, then return "Etc/GMT".
+ //
+ // Note: This logic is based on how the Control Panel itself determines if DST is 'off' on Windows.
+ // The code is somewhat convoluted; in a sort of pseudo-code it looks like this:
+ //
+ // IF (GetDynamicTimeZoneInformation != TIME_ZONE_ID_INVALID) && (DynamicDaylightTimeDisabled != 0) &&
+ // (StandardDate == DaylightDate) &&
+ // (
+ // (TimeZoneKeyName != Empty && StandardDate == 0) ||
+ // (TimeZoneKeyName == Empty && StandardDate != 0)
+ // )
+ // THEN
+ // DST setting is "Disabled".
+ //
+ if (dynamicTZI.DynamicDaylightTimeDisabled != 0 &&
+ uprv_memcmp(&dynamicTZI.StandardDate, &dynamicTZI.DaylightDate, sizeof(dynamicTZI.StandardDate)) == 0 &&
+ ((dynamicTZI.TimeZoneKeyName[0] != L'\0' && uprv_memcmp(&dynamicTZI.StandardDate, &systemTimeAllZero, sizeof(systemTimeAllZero)) == 0) ||
+ (dynamicTZI.TimeZoneKeyName[0] == L'\0' && uprv_memcmp(&dynamicTZI.StandardDate, &systemTimeAllZero, sizeof(systemTimeAllZero)) != 0)))
+ {
+ LONG utcOffsetMins = dynamicTZI.Bias;
+ if (utcOffsetMins == 0) {
+ return uprv_strdup("Etc/UTC");
+ }
- // convert from wchar_t* (UTF-16 on Windows) to char* (UTF-8).
- u_strToUTF8(ISOcode, UPRV_LENGTHOF(ISOcode), nullptr,
- reinterpret_cast(ISOcodeW), UPRV_LENGTHOF(ISOcodeW), &status);
+ // No way to support when DST is turned off and the offset in minutes is not a multiple of 60.
+ if (utcOffsetMins % 60 == 0) {
+ char gmtOffsetTz[11] = {}; // "Etc/GMT+dd" is 11-char long with a terminal null.
+ // Note '-' before 'utcOffsetMin'. The timezone ID's sign convention
+ // is that a timezone ahead of UTC is Etc/GMT- and a timezone
+ // behind UTC is Etc/GMT+.
+ int ret = snprintf(gmtOffsetTz, UPRV_LENGTHOF(gmtOffsetTz), "Etc/GMT%+ld", -utcOffsetMins / 60);
+ if (ret > 0 && ret < UPRV_LENGTHOF(gmtOffsetTz)) {
+ return uprv_strdup(gmtOffsetTz);
+ }
+ }
+ }
- LocalUResourceBundlePointer bundle(ures_openDirect(nullptr, "windowsZones", &status));
- ures_getByKey(bundle.getAlias(), "mapTimezones", bundle.getAlias(), &status);
+ // If DST is NOT disabled, but the TimeZoneKeyName field of the struct is NULL, then we may be dealing with a
+ // RDP/terminal services session where the 'Time Zone Redirection' feature is enabled. However, either the RDP
+ // client sent the server incomplete info (some 3rd party RDP clients only send the StandardName and DaylightName,
+ // but do not send the important TimeZoneKeyName), or if the RDP server has not appropriately populated the struct correctly.
+ //
+ // In this case we unfortunately have no choice but to fallback to using the pre-Vista method of determining the
+ // time zone, which requires examining the registry directly.
+ //
+ // Note that this can however still fail though if the client and server are using different languages, as the StandardName
+ // that is sent by client is *localized* in the client's language. However, we must compare this to the names that are
+ // on the server, which are *localized* in registry using the server's language.
+ //
+ // One other note is that this fallback method doesn't work for the UWP version, as we can't use the registry APIs.
- // convert from wchar_t* (UTF-16 on Windows) to char* (UTF-8).
- u_strToUTF8(dynamicTZKeyName, UPRV_LENGTHOF(dynamicTZKeyName), nullptr,
- reinterpret_cast(dynamicTZI.TimeZoneKeyName), -1, &status);
+ // windowsTimeZoneName will point at timezoneSubKeyName if we had to fallback to using the registry, and we found a match.
+ WCHAR timezoneSubKeyName[WINDOWS_MAX_REG_KEY_LENGTH];
+ WCHAR *windowsTimeZoneName = dynamicTZI.TimeZoneKeyName;
- if (U_FAILURE(status)) {
+ if (dynamicTZI.TimeZoneKeyName[0] == 0) {
+
+// We can't use the registry APIs in the UWP version.
+#if U_PLATFORM_HAS_WINUWP_API == 1
+ (void)timezoneSubKeyName; // suppress unused variable warnings.
return nullptr;
- }
+#else
+ // Open the path to the time zones in the Windows registry.
+ LONG ret;
+ HKEY hKeyAllTimeZones = nullptr;
+ ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, WINDOWS_TIMEZONES_REG_KEY_PATH, 0, KEY_READ,
+ reinterpret_cast(&hKeyAllTimeZones));
+
+ if (ret != ERROR_SUCCESS) {
+ // If we can't open the key, then we can't do much, so fail.
+ return nullptr;
+ }
+
+ // Read the number of subkeys under the time zone registry path.
+ DWORD numTimeZoneSubKeys;
+ ret = RegQueryInfoKeyW(hKeyAllTimeZones, nullptr, nullptr, nullptr, &numTimeZoneSubKeys,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
+
+ if (ret != ERROR_SUCCESS) {
+ RegCloseKey(hKeyAllTimeZones);
+ return nullptr;
+ }
+
+ // Examine each of the subkeys to try and find a match for the localized standard name ("Std").
+ //
+ // Note: The name of the time zone subkey itself is not localized, but the "Std" name is localized. This means
+ // that we could fail to find a match if the RDP client and RDP server are using different languages, but unfortunately
+ // there isn't much we can do about it.
+ HKEY hKeyTimeZoneSubKey = nullptr;
+ ULONG registryValueType;
+ WCHAR registryStandardName[WINDOWS_MAX_REG_KEY_LENGTH];
- if (dynamicTZI.TimeZoneKeyName[0] != 0) {
- StackUResourceBundle winTZ;
- ures_getByKey(bundle.getAlias(), dynamicTZKeyName, winTZ.getAlias(), &status);
+ for (DWORD i = 0; i < numTimeZoneSubKeys; i++) {
+ // Note: RegEnumKeyExW wants the size of the buffer in characters.
+ DWORD size = UPRV_LENGTHOF(timezoneSubKeyName);
+ ret = RegEnumKeyExW(hKeyAllTimeZones, i, timezoneSubKeyName, &size, nullptr, nullptr, nullptr, nullptr);
- if (U_SUCCESS(status)) {
- const UChar* icuTZ = nullptr;
- if (errorCode != 0) {
- icuTZ = ures_getStringByKey(winTZ.getAlias(), ISOcode, &len, &status);
+ if (ret != ERROR_SUCCESS) {
+ RegCloseKey(hKeyAllTimeZones);
+ return nullptr;
}
- if (errorCode == 0 || icuTZ == nullptr) {
- /* fallback to default "001" and reset status */
- status = U_ZERO_ERROR;
- icuTZ = ures_getStringByKey(winTZ.getAlias(), "001", &len, &status);
+
+ ret = RegOpenKeyExW(hKeyAllTimeZones, timezoneSubKeyName, 0, KEY_READ,
+ reinterpret_cast(&hKeyTimeZoneSubKey));
+
+ if (ret != ERROR_SUCCESS) {
+ RegCloseKey(hKeyAllTimeZones);
+ return nullptr;
+ }
+
+ // Note: RegQueryValueExW wants the size of the buffer in bytes.
+ size = sizeof(registryStandardName);
+ ret = RegQueryValueExW(hKeyTimeZoneSubKey, L"Std", nullptr, ®istryValueType,
+ reinterpret_cast(registryStandardName), &size);
+
+ if (ret != ERROR_SUCCESS || registryValueType != REG_SZ) {
+ RegCloseKey(hKeyTimeZoneSubKey);
+ RegCloseKey(hKeyAllTimeZones);
+ return nullptr;
}
- if (U_SUCCESS(status)) {
- int index = 0;
+ // Note: wcscmp does an ordinal (byte) comparison.
+ if (wcscmp(reinterpret_cast(registryStandardName), dynamicTZI.StandardName) == 0) {
+ // Since we are comparing the *localized* time zone name, it's possible that some languages might use
+ // the same string for more than one time zone. Thus we need to examine the TZI data in the registry to
+ // compare the GMT offset (the bias), and the DST transition dates, to ensure it's the same time zone
+ // as the currently reported one.
+ REG_TZI_FORMAT registryTziValue;
+ uprv_memset(®istryTziValue, 0, sizeof(registryTziValue));
- while (!(*icuTZ == '\0' || *icuTZ == ' ')) {
- // time zone IDs only contain ASCII invariant characters.
- tmpid[index++] = (char)(*icuTZ++);
+ // Note: RegQueryValueExW wants the size of the buffer in bytes.
+ DWORD timezoneTziValueSize = sizeof(registryTziValue);
+ ret = RegQueryValueExW(hKeyTimeZoneSubKey, L"TZI", nullptr, ®istryValueType,
+ reinterpret_cast(®istryTziValue), &timezoneTziValueSize);
+
+ if (ret == ERROR_SUCCESS) {
+ if ((dynamicTZI.Bias == registryTziValue.Bias) &&
+ (memcmp((const void *)&dynamicTZI.StandardDate, (const void *)®istryTziValue.StandardDate, sizeof(SYSTEMTIME)) == 0) &&
+ (memcmp((const void *)&dynamicTZI.DaylightDate, (const void *)®istryTziValue.DaylightDate, sizeof(SYSTEMTIME)) == 0))
+ {
+ // We found a matching time zone.
+ windowsTimeZoneName = timezoneSubKeyName;
+ break;
+ }
}
- tmpid[index] = '\0';
}
+ RegCloseKey(hKeyTimeZoneSubKey);
+ hKeyTimeZoneSubKey = nullptr;
+ }
+
+ if (hKeyTimeZoneSubKey != nullptr) {
+ RegCloseKey(hKeyTimeZoneSubKey);
}
+ if (hKeyAllTimeZones != nullptr) {
+ RegCloseKey(hKeyAllTimeZones);
+ }
+#endif // U_PLATFORM_HAS_WINUWP_API
}
- // Copy the timezone ID to icuid to be returned.
- if (tmpid[0] != 0) {
- icuid = uprv_strdup(tmpid);
+ CharString winTZ;
+ UErrorCode status = U_ZERO_ERROR;
+ winTZ.appendInvariantChars(UnicodeString(TRUE, windowsTimeZoneName, -1), status);
+
+ // Map Windows Timezone name (non-localized) to ICU timezone ID (~ Olson timezone id).
+ StackUResourceBundle winTZBundle;
+ ures_openDirectFillIn(winTZBundle.getAlias(), nullptr, "windowsZones", &status);
+ ures_getByKey(winTZBundle.getAlias(), "mapTimezones", winTZBundle.getAlias(), &status);
+ ures_getByKey(winTZBundle.getAlias(), winTZ.data(), winTZBundle.getAlias(), &status);
+
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+
+ // Note: Since the ISO 3166 country/region codes are all invariant ASCII chars, we can
+ // directly downcast from wchar_t to do the conversion.
+ // We could call the A version of the GetGeoInfo API, but that would be slightly slower than calling the W API,
+ // as the A version of the API will end up calling MultiByteToWideChar anyways internally.
+ wchar_t regionCodeW[3] = {};
+ char regionCode[3] = {}; // 2 letter ISO 3166 country/region code made entirely of invariant chars.
+ int geoId = GetUserGeoID(GEOCLASS_NATION);
+ int regionCodeLen = GetGeoInfoW(geoId, GEO_ISO2, regionCodeW, UPRV_LENGTHOF(regionCodeW), 0);
+
+ const UChar *icuTZ16 = nullptr;
+ int32_t tzListLen = 0;
+
+ if (regionCodeLen != 0) {
+ for (int i = 0; i < UPRV_LENGTHOF(regionCodeW); i++) {
+ regionCode[i] = static_cast(regionCodeW[i]);
+ }
+ icuTZ16 = ures_getStringByKey(winTZBundle.getAlias(), regionCode, &tzListLen, &status);
+ }
+ if (regionCodeLen == 0 || U_FAILURE(status)) {
+ // fallback to default "001" (world)
+ status = U_ZERO_ERROR;
+ icuTZ16 = ures_getStringByKey(winTZBundle.getAlias(), "001", &tzListLen, &status);
+ }
+
+ // Note: We want the first entry in the string returned by ures_getStringByKey.
+ // However this string can be a space delimited list of timezones:
+ // Ex: "America/New_York America/Detroit America/Indiana/Petersburg ..."
+ // We need to stop at the first space, so we pass tzLen (instead of tzListLen) to appendInvariantChars below.
+ int32_t tzLen = 0;
+ if (tzListLen > 0) {
+ while (!(icuTZ16[tzLen] == u'\0' || icuTZ16[tzLen] == u' ')) {
+ tzLen++;
+ }
}
- return icuid;
+ // Note: cloneData returns nullptr if the status is a failure, so this
+ // will return nullptr if the above look-up fails.
+ CharString icuTZStr;
+ return icuTZStr.appendInvariantChars(icuTZ16, tzLen, status).cloneData(status);
}
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/wintz.h b/deps/icu-small/source/common/wintz.h
index 9140d2729a98f8..b1ac8c07903738 100644
--- a/deps/icu-small/source/common/wintz.h
+++ b/deps/icu-small/source/common/wintz.h
@@ -28,7 +28,7 @@ U_CDECL_BEGIN
typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
U_CDECL_END
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uprv_detectWindowsTimeZone();
#endif /* U_PLATFORM_USES_ONLY_WIN32_API */
diff --git a/deps/icu-small/source/data/in/icudt67l.dat.bz2 b/deps/icu-small/source/data/in/icudt68l.dat.bz2
similarity index 55%
rename from deps/icu-small/source/data/in/icudt67l.dat.bz2
rename to deps/icu-small/source/data/in/icudt68l.dat.bz2
index 60bc3e084f4322..8fd32b7471d648 100644
Binary files a/deps/icu-small/source/data/in/icudt67l.dat.bz2 and b/deps/icu-small/source/data/in/icudt68l.dat.bz2 differ
diff --git a/deps/icu-small/source/i18n/buddhcal.h b/deps/icu-small/source/i18n/buddhcal.h
index c3ffa6a41d3565..e5ce18883ac039 100644
--- a/deps/icu-small/source/i18n/buddhcal.h
+++ b/deps/icu-small/source/i18n/buddhcal.h
@@ -174,7 +174,7 @@ class BuddhistCalendar : public GregorianCalendar {
UBool useMonth) const;
/**
- * Returns TRUE because the Buddhist Calendar does have a default century
+ * Returns true because the Buddhist Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/calendar.cpp b/deps/icu-small/source/i18n/calendar.cpp
index e8b718f3c4619d..df256c154d7a4f 100644
--- a/deps/icu-small/source/i18n/calendar.cpp
+++ b/deps/icu-small/source/i18n/calendar.cpp
@@ -266,7 +266,7 @@ static ECalType getCalendarTypeForLocale(const char *locid) {
//TODO: ULOC_FULL_NAME is out of date and too small..
char canonicalName[256];
- // canonicalize, so grandfathered variant will be transformed to keywords
+ // Canonicalize, so that an old-style 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.
@@ -870,7 +870,7 @@ Calendar::createInstance(const TimeZone& zone, UErrorCode& success)
Calendar* U_EXPORT2
Calendar::createInstance(const Locale& aLocale, UErrorCode& success)
{
- return createInstance(TimeZone::createDefault(), aLocale, success);
+ return createInstance(TimeZone::forLocaleOrDefault(aLocale), aLocale, success);
}
// ------------------------------------- Adopting
diff --git a/deps/icu-small/source/i18n/cecal.cpp b/deps/icu-small/source/i18n/cecal.cpp
index 458fe2f3049b9d..3389b728697db3 100644
--- a/deps/icu-small/source/i18n/cecal.cpp
+++ b/deps/icu-small/source/i18n/cecal.cpp
@@ -49,7 +49,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
//-------------------------------------------------------------------------
CECalendar::CECalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success)
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success);
}
diff --git a/deps/icu-small/source/i18n/cecal.h b/deps/icu-small/source/i18n/cecal.h
index c380f0bea30523..80dab70f6ff0bf 100644
--- a/deps/icu-small/source/i18n/cecal.h
+++ b/deps/icu-small/source/i18n/cecal.h
@@ -88,7 +88,7 @@ class U_I18N_API CECalendar : public Calendar {
virtual UBool inDaylightTime(UErrorCode&) const;
/**
- * Returns TRUE because Coptic/Ethiopic Calendar does have a default century
+ * Returns true because Coptic/Ethiopic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/chnsecal.cpp b/deps/icu-small/source/i18n/chnsecal.cpp
index 2ff9f755afe1f1..2ab08dd33925b2 100644
--- a/deps/icu-small/source/i18n/chnsecal.cpp
+++ b/deps/icu-small/source/i18n/chnsecal.cpp
@@ -123,7 +123,7 @@ ChineseCalendar* ChineseCalendar::clone() const {
}
ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
isLeapYear(FALSE),
fEpochYear(CHINESE_EPOCH_YEAR),
fZoneAstroCalc(getChineseCalZoneAstroCalc())
@@ -133,7 +133,7 @@ ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
ChineseCalendar::ChineseCalendar(const Locale& aLocale, int32_t epochYear,
const TimeZone* zoneAstroCalc, UErrorCode &success)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
isLeapYear(FALSE),
fEpochYear(epochYear),
fZoneAstroCalc(zoneAstroCalc)
diff --git a/deps/icu-small/source/i18n/chnsecal.h b/deps/icu-small/source/i18n/chnsecal.h
index c7c063738145e7..77a68a48929e10 100644
--- a/deps/icu-small/source/i18n/chnsecal.h
+++ b/deps/icu-small/source/i18n/chnsecal.h
@@ -242,7 +242,7 @@ class U_I18N_API ChineseCalendar : public Calendar {
/**
- * Returns TRUE because the Islamic Calendar does have a default century
+ * Returns true because the Islamic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/collation.h b/deps/icu-small/source/i18n/collation.h
index e9256c9c12c5a7..ecbba29057f03a 100644
--- a/deps/icu-small/source/i18n/collation.h
+++ b/deps/icu-small/source/i18n/collation.h
@@ -356,7 +356,7 @@ class U_I18N_API Collation {
}
/**
- * @return TRUE if the ce32 yields one or more CEs without further data lookups
+ * @return true if the ce32 yields one or more CEs without further data lookups
*/
static UBool isSelfContainedCE32(uint32_t ce32) {
return !isSpecialCE32(ce32) ||
diff --git a/deps/icu-small/source/i18n/collationbuilder.h b/deps/icu-small/source/i18n/collationbuilder.h
index 2f20050f93ba1d..82f0459748f051 100644
--- a/deps/icu-small/source/i18n/collationbuilder.h
+++ b/deps/icu-small/source/i18n/collationbuilder.h
@@ -42,7 +42,7 @@ class U_I18N_API CollationBuilder : public CollationRuleParser::Sink {
CollationBuilder(const CollationTailoring *base, UErrorCode &errorCode);
virtual ~CollationBuilder();
- void disableFastLatin() { fastLatinEnabled = FALSE; }
+ void disableFastLatin() { fastLatinEnabled = false; }
CollationTailoring *parseAndBuild(const UnicodeString &ruleString,
const UVersionInfo rulesVersion,
diff --git a/deps/icu-small/source/i18n/collationdatabuilder.h b/deps/icu-small/source/i18n/collationdatabuilder.h
index fee444deee77dc..6ae77772fd5a46 100644
--- a/deps/icu-small/source/i18n/collationdatabuilder.h
+++ b/deps/icu-small/source/i18n/collationdatabuilder.h
@@ -73,12 +73,12 @@ class U_I18N_API CollationDataBuilder : public UObject {
}
/**
- * @return TRUE if this builder has mappings (e.g., add() has been called)
+ * @return true if this builder has mappings (e.g., add() has been called)
*/
UBool hasMappings() const { return modified; }
/**
- * @return TRUE if c has CEs in this builder
+ * @return true if c has CEs in this builder
*/
UBool isAssigned(UChar32 c) const;
@@ -118,7 +118,7 @@ class U_I18N_API CollationDataBuilder : public UObject {
* @param primary primary weight for 'start'
* @param step per-code point primary-weight increment
* @param errorCode ICU in/out error code
- * @return TRUE if an OFFSET_TAG range was used for start..end
+ * @return true if an OFFSET_TAG range was used for start..end
*/
UBool maybeSetPrimaryRange(UChar32 start, UChar32 end,
uint32_t primary, int32_t step,
@@ -150,7 +150,7 @@ class U_I18N_API CollationDataBuilder : public UObject {
void optimize(const UnicodeSet &set, UErrorCode &errorCode);
void suppressContractions(const UnicodeSet &set, UErrorCode &errorCode);
- void enableFastLatin() { fastLatinEnabled = TRUE; }
+ void enableFastLatin() { fastLatinEnabled = true; }
virtual void build(CollationData &data, UErrorCode &errorCode);
/**
diff --git a/deps/icu-small/source/i18n/collationfcd.h b/deps/icu-small/source/i18n/collationfcd.h
index ec7167d76bab75..3a5738efb24a7c 100644
--- a/deps/icu-small/source/i18n/collationfcd.h
+++ b/deps/icu-small/source/i18n/collationfcd.h
@@ -84,7 +84,7 @@ class U_I18N_API CollationFCD {
// Handles all of Unicode 0..10FFFF.
// c can be negative, e.g., U_SENTINEL.
// U+0300 is the first character with lccc!=0.
- if(c < 0x300) { return FALSE; }
+ if(c < 0x300) { return false; }
if(c > 0xffff) { c = U16_LEAD(c); }
int32_t i;
return
@@ -101,7 +101,7 @@ class U_I18N_API CollationFCD {
* This is a fast and imprecise test.
*
* @param c a code point
- * @return TRUE if c is U+0F73, U+0F75 or U+0F81 or one of several other Tibetan characters
+ * @return true if c is U+0F73, U+0F75 or U+0F81 or one of several other Tibetan characters
*/
static inline UBool maybeTibetanCompositeVowel(UChar32 c) {
return (c & 0x1fff01) == 0xf01;
@@ -116,7 +116,7 @@ class U_I18N_API CollationFCD {
* They have distinct lccc/tccc combinations: 129/130 or 129/132.
*
* @param fcd16 the FCD value (lccc/tccc combination) of a code point
- * @return TRUE if fcd16 is from U+0F73, U+0F75 or U+0F81
+ * @return true if fcd16 is from U+0F73, U+0F75 or U+0F81
*/
static inline UBool isFCD16OfTibetanCompositeVowel(uint16_t fcd16) {
return fcd16 == 0x8182 || fcd16 == 0x8184;
diff --git a/deps/icu-small/source/i18n/collationiterator.h b/deps/icu-small/source/i18n/collationiterator.h
index 12e05b4482fab2..869f0956c34d0d 100644
--- a/deps/icu-small/source/i18n/collationiterator.h
+++ b/deps/icu-small/source/i18n/collationiterator.h
@@ -76,9 +76,9 @@ class U_I18N_API CollationIterator : public UObject {
// (Rather than buffer.getCapacity().)
if(length < INITIAL_CAPACITY || ensureAppendCapacity(1, errorCode)) {
++length;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -251,9 +251,9 @@ class U_I18N_API CollationIterator : public UObject {
virtual UBool foundNULTerminator();
/**
- * @return FALSE if surrogate code points U+D800..U+DFFF
+ * @return false if surrogate code points U+D800..U+DFFF
* map to their own implicit primary weights (for UTF-16),
- * or TRUE if they map to CE(U+FFFD) (for UTF-8)
+ * or true if they map to CE(U+FFFD) (for UTF-8)
*/
virtual UBool forbidSurrogateCodePoints() const;
diff --git a/deps/icu-small/source/i18n/collationkeys.h b/deps/icu-small/source/i18n/collationkeys.h
index 60d9e50c0d9106..c526a4f14f2df8 100644
--- a/deps/icu-small/source/i18n/collationkeys.h
+++ b/deps/icu-small/source/i18n/collationkeys.h
@@ -65,7 +65,7 @@ class SortKeyByteSink : public ByteSink {
}
UBool Overflowed() const { return appended_ > capacity_; }
- /** @return FALSE if memory allocation failed */
+ /** @return false if memory allocation failed */
UBool IsOk() const { return buffer_ != NULL; }
protected:
@@ -94,8 +94,8 @@ class U_I18N_API CollationKeys /* not : public UObject because all methods are s
virtual ~LevelCallback();
/**
* @param level The next level about to be written to the ByteSink.
- * @return TRUE if the level is to be written
- * (the base class implementation always returns TRUE)
+ * @return true if the level is to be written
+ * (the base class implementation always returns true)
*/
virtual UBool needToWrite(Collation::Level level);
};
@@ -103,7 +103,7 @@ class U_I18N_API CollationKeys /* not : public UObject because all methods are s
/**
* Writes the sort key bytes for minLevel up to the iterator data's strength.
* Optionally writes the case level.
- * Stops writing levels when callback.needToWrite(level) returns FALSE.
+ * Stops writing levels when callback.needToWrite(level) returns false.
* Separates levels with the LEVEL_SEPARATOR_BYTE
* but does not write a TERMINATOR_BYTE.
*/
diff --git a/deps/icu-small/source/i18n/collationtailoring.h b/deps/icu-small/source/i18n/collationtailoring.h
index e1bc34c7d7683b..5fc2bac2d307fb 100644
--- a/deps/icu-small/source/i18n/collationtailoring.h
+++ b/deps/icu-small/source/i18n/collationtailoring.h
@@ -50,7 +50,7 @@ struct U_I18N_API CollationTailoring : public SharedObject {
virtual ~CollationTailoring();
/**
- * Returns TRUE if the constructor could not initialize properly.
+ * Returns true if the constructor could not initialize properly.
*/
UBool isBogus() { return settings == NULL; }
diff --git a/deps/icu-small/source/i18n/collationweights.h b/deps/icu-small/source/i18n/collationweights.h
index d8cee79e33fd87..bbd88b27e9e3d7 100644
--- a/deps/icu-small/source/i18n/collationweights.h
+++ b/deps/icu-small/source/i18n/collationweights.h
@@ -62,7 +62,7 @@ class U_I18N_API CollationWeights : public UMemory {
* weights less than this one.
* @param n The number of collation element weights w necessary such that
* lowerLimitclone(): nullptr;
fTimePattern = (itvfmt.fTimePattern)? itvfmt.fTimePattern->clone(): nullptr;
fDateTimeFormat = (itvfmt.fDateTimeFormat)? itvfmt.fDateTimeFormat->clone(): nullptr;
+ fCapitalizationContext = itvfmt.fCapitalizationContext;
}
return *this;
}
@@ -239,7 +243,7 @@ DateIntervalFormat::operator==(const Format& other) const {
if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;}
}
// note: fFromCalendar and fToCalendar hold no persistent state, and therefore do not participate in operator ==.
- // fDateFormat has the master calendar for the DateIntervalFormat.
+ // fDateFormat has the primary calendar for the DateIntervalFormat.
if (fSkeleton != fmt->fSkeleton) {return FALSE;}
if (fDatePattern != fmt->fDatePattern && (fDatePattern == nullptr || fmt->fDatePattern == nullptr)) {return FALSE;}
if (fDatePattern && fmt->fDatePattern && (*fDatePattern != *fmt->fDatePattern)) {return FALSE;}
@@ -254,6 +258,7 @@ DateIntervalFormat::operator==(const Format& other) const {
if (fIntervalPatterns[i].secondPart != fmt->fIntervalPatterns[i].secondPart ) {return FALSE;}
if (fIntervalPatterns[i].laterDateFirst != fmt->fIntervalPatterns[i].laterDateFirst) {return FALSE;}
}
+ if (fCapitalizationContext != fmt->fCapitalizationContext) {return FALSE;}
return TRUE;
}
@@ -409,6 +414,7 @@ UnicodeString& DateIntervalFormat::formatIntervalImpl(
}
+// The following is only called from within the gFormatterMutex lock
UnicodeString&
DateIntervalFormat::formatImpl(Calendar& fromCalendar,
Calendar& toCalendar,
@@ -464,6 +470,11 @@ DateIntervalFormat::formatImpl(Calendar& fromCalendar,
if ( U_FAILURE(status) ) {
return appendTo;
}
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
+ // Set up fDateFormat to handle the first or only part of the interval
+ // (override later for any second part). Inside lock, OK to modify fDateFormat.
+ fDateFormat->setContext(fCapitalizationContext, tempStatus);
+
if ( field == UCAL_FIELD_COUNT ) {
/* ignore the millisecond etc. small fields' difference.
* use single date when all the above are the same.
@@ -521,6 +532,9 @@ DateIntervalFormat::formatImpl(Calendar& fromCalendar,
if ( !intervalPattern.secondPart.isEmpty() ) {
fDateFormat->applyPattern(intervalPattern.secondPart);
+ // No capitalization for second part of interval
+ tempStatus = U_ZERO_ERROR;
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(*secondCal, appendTo, fphandler, status);
}
fDateFormat->applyPattern(originalPattern);
@@ -583,7 +597,7 @@ DateIntervalFormat::adoptTimeZone(TimeZone* zone)
if (fDateFormat != nullptr) {
fDateFormat->adoptTimeZone(zone);
}
- // The fDateFormat has the master calendar for the DateIntervalFormat and has
+ // The fDateFormat has the primary calendar for the DateIntervalFormat and has
// ownership of any adopted TimeZone; fFromCalendar and fToCalendar are internal
// work clones of that calendar (and should not also be given ownership of the
// adopted TimeZone).
@@ -601,7 +615,7 @@ DateIntervalFormat::setTimeZone(const TimeZone& zone)
if (fDateFormat != nullptr) {
fDateFormat->setTimeZone(zone);
}
- // The fDateFormat has the master calendar for the DateIntervalFormat;
+ // The fDateFormat has the primary calendar for the DateIntervalFormat;
// fFromCalendar and fToCalendar are internal work clones of that calendar.
if (fFromCalendar) {
fFromCalendar->setTimeZone(zone);
@@ -622,6 +636,30 @@ DateIntervalFormat::getTimeZone() const
return *(TimeZone::createDefault());
}
+void
+DateIntervalFormat::setContext(UDisplayContext value, UErrorCode& status)
+{
+ if (U_FAILURE(status))
+ return;
+ if ( (UDisplayContextType)((uint32_t)value >> 8) == UDISPCTX_TYPE_CAPITALIZATION ) {
+ fCapitalizationContext = value;
+ } else {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+}
+
+UDisplayContext
+DateIntervalFormat::getContext(UDisplayContextType type, UErrorCode& status) const
+{
+ if (U_FAILURE(status))
+ return (UDisplayContext)0;
+ if (type != UDISPCTX_TYPE_CAPITALIZATION) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return (UDisplayContext)0;
+ }
+ return fCapitalizationContext;
+}
+
DateIntervalFormat::DateIntervalFormat(const Locale& locale,
DateIntervalInfo* dtItvInfo,
const UnicodeString* skeleton,
@@ -633,7 +671,8 @@ DateIntervalFormat::DateIntervalFormat(const Locale& locale,
fLocale(locale),
fDatePattern(nullptr),
fTimePattern(nullptr),
- fDateTimeFormat(nullptr)
+ fDateTimeFormat(nullptr),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
LocalPointer info(dtItvInfo, status);
LocalPointer dtfmt(static_cast(
@@ -751,7 +790,7 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
/* the difference between time skeleton and normalizedTimeSkeleton are:
* 1. (Formerly, normalized time skeleton folded 'H' to 'h'; no longer true)
- * 2. 'a' is omitted in normalized time skeleton.
+ * 2. (Formerly, 'a' was omitted in normalized time skeleton; this is now handled elsewhere)
* 3. there is only one appearance for 'h' or 'H', 'm','v', 'z' in normalized
* time skeleton
*
@@ -760,7 +799,8 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
* 2. 'E' and 'EE' are normalized into 'EEE'
* 3. 'MM' is normalized into 'M'
*/
- getDateTimeSkeleton(fSkeleton, dateSkeleton, normalizedDateSkeleton,
+ UnicodeString convertedSkeleton = normalizeHourMetacharacters(fSkeleton);
+ getDateTimeSkeleton(convertedSkeleton, dateSkeleton, normalizedDateSkeleton,
timeSkeleton, normalizedTimeSkeleton);
#ifdef DTITVFMT_DEBUG
@@ -899,6 +939,91 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
+UnicodeString
+DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) const {
+ UnicodeString result = skeleton;
+
+ UChar hourMetachar = u'\0';
+ int32_t metacharStart = 0;
+ int32_t metacharCount = 0;
+ for (int32_t i = 0; i < result.length(); i++) {
+ UChar c = result[i];
+ if (c == LOW_J || c == CAP_J || c == CAP_C) {
+ if (hourMetachar == u'\0') {
+ hourMetachar = c;
+ metacharStart = i;
+ }
+ ++metacharCount;
+ } else {
+ if (hourMetachar != u'\0') {
+ break;
+ }
+ }
+ }
+
+ if (hourMetachar != u'\0') {
+ UErrorCode err = U_ZERO_ERROR;
+ UChar hourChar = CAP_H;
+ UChar dayPeriodChar = LOW_A;
+ UnicodeString convertedPattern = DateFormat::getBestPattern(fLocale, UnicodeString(hourMetachar), err);
+
+ if (U_SUCCESS(err)) {
+ // strip literal text from the pattern (so literal characters don't get mistaken for pattern
+ // characters-- such as the 'h' in 'Uhr' in Germam)
+ int32_t firstQuotePos;
+ while ((firstQuotePos = convertedPattern.indexOf(u'\'')) != -1) {
+ int32_t secondQuotePos = convertedPattern.indexOf(u'\'', firstQuotePos + 1);
+ if (secondQuotePos == -1) {
+ secondQuotePos = firstQuotePos;
+ }
+ convertedPattern.replace(firstQuotePos, (secondQuotePos - firstQuotePos) + 1, UnicodeString());
+ }
+
+ if (convertedPattern.indexOf(LOW_H) != -1) {
+ hourChar = LOW_H;
+ } else if (convertedPattern.indexOf(CAP_K) != -1) {
+ hourChar = CAP_K;
+ } else if (convertedPattern.indexOf(LOW_K) != -1) {
+ hourChar = LOW_K;
+ }
+
+ if (convertedPattern.indexOf(LOW_B) != -1) {
+ dayPeriodChar = LOW_B;
+ } else if (convertedPattern.indexOf(CAP_B) != -1) {
+ dayPeriodChar = CAP_B;
+ }
+ }
+
+ if (hourChar == CAP_H || hourChar == LOW_K) {
+ result.replace(metacharStart, metacharCount, hourChar);
+ } else {
+ UnicodeString hourAndDayPeriod(hourChar);
+ switch (metacharCount) {
+ case 1:
+ case 2:
+ default:
+ hourAndDayPeriod.append(UnicodeString(dayPeriodChar));
+ break;
+ case 3:
+ case 4:
+ for (int32_t i = 0; i < 4; i++) {
+ hourAndDayPeriod.append(dayPeriodChar);
+ }
+ break;
+ case 5:
+ case 6:
+ for (int32_t i = 0; i < 5; i++) {
+ hourAndDayPeriod.append(dayPeriodChar);
+ }
+ break;
+ }
+ result.replace(metacharStart, metacharCount, hourAndDayPeriod);
+ }
+ }
+ return result;
+}
+
+
void U_EXPORT2
DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
UnicodeString& dateSkeleton,
@@ -911,11 +1036,10 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
int32_t dCount = 0;
int32_t MCount = 0;
int32_t yCount = 0;
- int32_t hCount = 0;
- int32_t HCount = 0;
int32_t mCount = 0;
int32_t vCount = 0;
int32_t zCount = 0;
+ UChar hourChar = u'\0';
int32_t i;
for (i = 0; i < skeleton.length(); ++i) {
@@ -956,17 +1080,14 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
normalizedDateSkeleton.append(ch);
dateSkeleton.append(ch);
break;
- case LOW_A:
- // 'a' is implicitly handled
- timeSkeleton.append(ch);
- break;
case LOW_H:
- timeSkeleton.append(ch);
- ++hCount;
- break;
case CAP_H:
+ case LOW_K:
+ case CAP_K:
timeSkeleton.append(ch);
- ++HCount;
+ if (hourChar == u'\0') {
+ hourChar = ch;
+ }
break;
case LOW_M:
timeSkeleton.append(ch);
@@ -980,14 +1101,15 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
++vCount;
timeSkeleton.append(ch);
break;
+ case LOW_A:
case CAP_V:
case CAP_Z:
- case LOW_K:
- case CAP_K:
case LOW_J:
case LOW_S:
case CAP_S:
case CAP_A:
+ case LOW_B:
+ case CAP_B:
timeSkeleton.append(ch);
normalizedTimeSkeleton.append(ch);
break;
@@ -1023,11 +1145,8 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
}
/* generate normalized form for time */
- if ( HCount != 0 ) {
- normalizedTimeSkeleton.append(CAP_H);
- }
- else if ( hCount != 0 ) {
- normalizedTimeSkeleton.append(LOW_H);
+ if ( hourChar != u'\0' ) {
+ normalizedTimeSkeleton.append(hourChar);
}
if ( mCount != 0 ) {
normalizedTimeSkeleton.append(LOW_M);
@@ -1303,7 +1422,11 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
if ( field == UCAL_AM_PM ) {
fInfo->getIntervalPattern(*bestSkeleton, UCAL_HOUR, pattern,status);
if ( !pattern.isEmpty() ) {
- setIntervalPattern(field, pattern);
+ UBool suppressDayPeriodField = fSkeleton.indexOf(CAP_J) != -1;
+ UnicodeString adjustIntervalPattern;
+ adjustFieldWidth(*skeleton, *bestSkeleton, pattern, differenceInfo,
+ suppressDayPeriodField, adjustIntervalPattern);
+ setIntervalPattern(field, adjustIntervalPattern);
}
return false;
}
@@ -1335,10 +1458,11 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
}
}
if ( !pattern.isEmpty() ) {
- if ( differenceInfo != 0 ) {
+ UBool suppressDayPeriodField = fSkeleton.indexOf(CAP_J) != -1;
+ if ( differenceInfo != 0 || suppressDayPeriodField) {
UnicodeString adjustIntervalPattern;
adjustFieldWidth(*skeleton, *bestSkeleton, pattern, differenceInfo,
- adjustIntervalPattern);
+ suppressDayPeriodField, adjustIntervalPattern);
setIntervalPattern(field, adjustIntervalPattern);
} else {
setIntervalPattern(field, pattern);
@@ -1425,6 +1549,7 @@ DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern)
return (i - count);
}
+// The following is only called from fallbackFormat, i.e. within the gFormatterMutex lock
void DateIntervalFormat::fallbackFormatRange(
Calendar& fromCalendar,
Calendar& toCalendar,
@@ -1441,12 +1566,15 @@ void DateIntervalFormat::fallbackFormatRange(
int32_t offsets[2];
UnicodeString patternBody = sf.getTextWithNoArguments(offsets, 2);
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
// TODO(ICU-20406): Use SimpleFormatter Iterator interface when available.
if (offsets[0] < offsets[1]) {
firstIndex = 0;
appendTo.append(patternBody.tempSubStringBetween(0, offsets[0]));
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0], offsets[1]));
+ // No capitalization for second part of interval
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(toCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1]));
} else {
@@ -1454,11 +1582,14 @@ void DateIntervalFormat::fallbackFormatRange(
appendTo.append(patternBody.tempSubStringBetween(0, offsets[1]));
fDateFormat->_format(toCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1], offsets[0]));
+ // No capitalization for second part of interval
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0]));
}
}
+// The following is only called from formatImpl, i.e. within the gFormatterMutex lock
UnicodeString&
DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
Calendar& toCalendar,
@@ -1483,6 +1614,7 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
UnicodeString fullPattern; // for saving the pattern in fDateFormat
fDateFormat->toPattern(fullPattern); // save current pattern, restore later
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
// {0} is time range
// {1} is single date portion
// TODO(ICU-20406): Use SimpleFormatter Iterator interface when available.
@@ -1492,6 +1624,8 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
fallbackFormatRange(fromCalendar, toCalendar, appendTo, firstIndex, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0], offsets[1]));
fDateFormat->applyPattern(*fDatePattern);
+ // No capitalization for second portion
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1]));
} else {
@@ -1500,6 +1634,8 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1], offsets[0]));
fDateFormat->applyPattern(*fTimePattern);
+ // No capitalization for second portion
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fallbackFormatRange(fromCalendar, toCalendar, appendTo, firstIndex, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0]));
}
@@ -1530,6 +1666,7 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
const UnicodeString& bestMatchSkeleton,
const UnicodeString& bestIntervalPattern,
int8_t differenceInfo,
+ UBool suppressDayPeriodField,
UnicodeString& adjustedPtn) {
adjustedPtn = bestIntervalPattern;
int32_t inputSkeletonFieldWidth[] =
@@ -1556,19 +1693,40 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+ const int8_t PATTERN_CHAR_BASE = 0x41;
+
DateIntervalInfo::parseSkeleton(inputSkeleton, inputSkeletonFieldWidth);
DateIntervalInfo::parseSkeleton(bestMatchSkeleton, bestMatchSkeletonFieldWidth);
- if ( differenceInfo == 2 ) {
- adjustedPtn.findAndReplace(UnicodeString((UChar)0x76 /* v */),
- UnicodeString((UChar)0x7a /* z */));
+ if (suppressDayPeriodField) {
+ findReplaceInPattern(adjustedPtn, UnicodeString(LOW_A), UnicodeString());
+ findReplaceInPattern(adjustedPtn, UnicodeString(" "), UnicodeString(" "));
+ adjustedPtn.trim();
}
+ if ( differenceInfo == 2 ) {
+ if (inputSkeleton.indexOf(LOW_Z) != -1) {
+ findReplaceInPattern(adjustedPtn, UnicodeString(LOW_V), UnicodeString(LOW_Z));
+ }
+ if (inputSkeleton.indexOf(CAP_K) != -1) {
+ findReplaceInPattern(adjustedPtn, UnicodeString(LOW_H), UnicodeString(CAP_K));
+ }
+ if (inputSkeleton.indexOf(LOW_K) != -1) {
+ findReplaceInPattern(adjustedPtn, UnicodeString(CAP_H), UnicodeString(LOW_K));
+ }
+ if (inputSkeleton.indexOf(LOW_B) != -1) {
+ findReplaceInPattern(adjustedPtn, UnicodeString(LOW_A), UnicodeString(LOW_B));
+ }
+ }
+ if (adjustedPtn.indexOf(LOW_A) != -1 && bestMatchSkeletonFieldWidth[LOW_A - PATTERN_CHAR_BASE] == 0) {
+ bestMatchSkeletonFieldWidth[LOW_A - PATTERN_CHAR_BASE] = 1;
+ }
+ if (adjustedPtn.indexOf(LOW_B) != -1 && bestMatchSkeletonFieldWidth[LOW_B - PATTERN_CHAR_BASE] == 0) {
+ bestMatchSkeletonFieldWidth[LOW_B - PATTERN_CHAR_BASE] = 1;
+ }
UBool inQuote = false;
UChar prevCh = 0;
int32_t count = 0;
- const int8_t PATTERN_CHAR_BASE = 0x41;
-
// loop through the pattern string character by character
int32_t adjustedPtnLength = adjustedPtn.length();
int32_t i;
@@ -1634,6 +1792,39 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
}
}
+void
+DateIntervalFormat::findReplaceInPattern(UnicodeString& targetString,
+ const UnicodeString& strToReplace,
+ const UnicodeString& strToReplaceWith) {
+ int32_t firstQuoteIndex = targetString.indexOf(u'\'');
+ if (firstQuoteIndex == -1) {
+ targetString.findAndReplace(strToReplace, strToReplaceWith);
+ } else {
+ UnicodeString result;
+ UnicodeString source = targetString;
+
+ while (firstQuoteIndex >= 0) {
+ int32_t secondQuoteIndex = source.indexOf(u'\'', firstQuoteIndex + 1);
+ if (secondQuoteIndex == -1) {
+ secondQuoteIndex = source.length() - 1;
+ }
+
+ UnicodeString unquotedText(source, 0, firstQuoteIndex);
+ UnicodeString quotedText(source, firstQuoteIndex, secondQuoteIndex - firstQuoteIndex + 1);
+
+ unquotedText.findAndReplace(strToReplace, strToReplaceWith);
+ result += unquotedText;
+ result += quotedText;
+
+ source.remove(0, secondQuoteIndex + 1);
+ firstQuoteIndex = source.indexOf(u'\'');
+ }
+ source.findAndReplace(strToReplace, strToReplaceWith);
+ result += source;
+ targetString = result;
+ }
+}
+
void
diff --git a/deps/icu-small/source/i18n/dtitvinf.cpp b/deps/icu-small/source/i18n/dtitvinf.cpp
index 25536346ec74f0..39fd44a392d694 100644
--- a/deps/icu-small/source/i18n/dtitvinf.cpp
+++ b/deps/icu-small/source/i18n/dtitvinf.cpp
@@ -339,6 +339,9 @@ struct DateIntervalInfo::DateIntervalSink : public ResourceSink {
return UCAL_DATE;
} else if (c0 == 'a') {
return UCAL_AM_PM;
+ } else if (c0 == 'B') {
+ // TODO: Using AM/PM as a proxy for flexible day period isn't really correct, but it's close
+ return UCAL_AM_PM;
} else if (c0 == 'h' || c0 == 'H') {
return UCAL_HOUR;
} else if (c0 == 'm') {
@@ -594,20 +597,23 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
const int32_t DIFFERENT_FIELD = 0x1000;
const int32_t STRING_NUMERIC_DIFFERENCE = 0x100;
const int32_t BASE = 0x41;
- const UChar CHAR_V = 0x0076;
- const UChar CHAR_Z = 0x007A;
- // hack for 'v' and 'z'.
- // resource bundle only have time skeletons ending with 'v',
- // but not for time skeletons ending with 'z'.
- UBool replaceZWithV = false;
+ // hack for certain alternate characters
+ // resource bundles only have time skeletons containing 'v', 'h', and 'H'
+ // but not time skeletons containing 'z', 'K', or 'k'
+ // the skeleton may also include 'a' or 'b', which never occur in the resource bundles, so strip them out too
+ UBool replacedAlternateChars = false;
const UnicodeString* inputSkeleton = &skeleton;
UnicodeString copySkeleton;
- if ( skeleton.indexOf(CHAR_Z) != -1 ) {
+ if ( skeleton.indexOf(LOW_Z) != -1 || skeleton.indexOf(LOW_K) != -1 || skeleton.indexOf(CAP_K) != -1 || skeleton.indexOf(LOW_A) != -1 || skeleton.indexOf(LOW_B) != -1 ) {
copySkeleton = skeleton;
- copySkeleton.findAndReplace(UnicodeString(CHAR_Z), UnicodeString(CHAR_V));
+ copySkeleton.findAndReplace(UnicodeString(LOW_Z), UnicodeString(LOW_V));
+ copySkeleton.findAndReplace(UnicodeString(LOW_K), UnicodeString(CAP_H));
+ copySkeleton.findAndReplace(UnicodeString(CAP_K), UnicodeString(LOW_H));
+ copySkeleton.findAndReplace(UnicodeString(LOW_A), UnicodeString());
+ copySkeleton.findAndReplace(UnicodeString(LOW_B), UnicodeString());
inputSkeleton = ©Skeleton;
- replaceZWithV = true;
+ replacedAlternateChars = true;
}
parseSkeleton(*inputSkeleton, inputSkeletonFieldWidth);
@@ -616,7 +622,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
// 0 means exact the same skeletons;
// 1 means having the same field, but with different length,
- // 2 means only z/v differs
+ // 2 means only z/v, h/K, or H/k differs
// -1 means having different field.
bestMatchDistanceInfo = 0;
int8_t fieldLength = UPRV_LENGTHOF(skeletonFieldWidth);
@@ -672,7 +678,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
break;
}
}
- if ( replaceZWithV && bestMatchDistanceInfo != -1 ) {
+ if ( replacedAlternateChars && bestMatchDistanceInfo != -1 ) {
bestMatchDistanceInfo = 2;
}
return bestSkeleton;
diff --git a/deps/icu-small/source/i18n/dtptngen.cpp b/deps/icu-small/source/i18n/dtptngen.cpp
index 279fb49a7aa9b9..78273ef01e2281 100644
--- a/deps/icu-small/source/i18n/dtptngen.cpp
+++ b/deps/icu-small/source/i18n/dtptngen.cpp
@@ -311,6 +311,16 @@ DateTimePatternGenerator::createInstance(const Locale& locale, UErrorCode& statu
return U_SUCCESS(status) ? result.orphan() : nullptr;
}
+DateTimePatternGenerator* U_EXPORT2
+DateTimePatternGenerator::createInstanceNoStdPat(const Locale& locale, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ LocalPointer result(
+ new DateTimePatternGenerator(locale, status, true), status);
+ return U_SUCCESS(status) ? result.orphan() : nullptr;
+}
+
DateTimePatternGenerator* U_EXPORT2
DateTimePatternGenerator::createEmptyInstance(UErrorCode& status) {
if (U_FAILURE(status)) {
@@ -336,7 +346,7 @@ DateTimePatternGenerator::DateTimePatternGenerator(UErrorCode &status) :
}
}
-DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorCode &status) :
+DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorCode &status, UBool skipStdPatterns) :
skipMatcher(nullptr),
fAvailableFormatKeyHash(nullptr),
fDefaultHourFormatChar(0),
@@ -350,7 +360,7 @@ DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorC
internalErrorCode = status = U_MEMORY_ALLOCATION_ERROR;
}
else {
- initData(locale, status);
+ initData(locale, status, skipStdPatterns);
}
}
@@ -489,13 +499,15 @@ enum AllowedHourFormat{
} // namespace
void
-DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status) {
+DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status, UBool skipStdPatterns) {
//const char *baseLangName = locale.getBaseName(); // unused
skipMatcher = nullptr;
fAvailableFormatKeyHash=nullptr;
addCanonicalItems(status);
- addICUPatterns(locale, status);
+ if (!skipStdPatterns) { // skip to prevent circular dependency when called from SimpleDateFormat::construct
+ addICUPatterns(locale, status);
+ }
addCLDRData(locale, status);
setDateTimeFromCalendar(locale, status);
setDecimalSymbols(locale, status);
@@ -893,7 +905,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString&
err = localStatus;
return;
}
- if (calendarTypeLen < ULOC_KEYWORDS_CAPACITY) {
+ if (calendarTypeLen > 0 && calendarTypeLen < ULOC_KEYWORDS_CAPACITY) {
destination.clear().append(calendarType, -1, err);
if (U_FAILURE(err)) { return; }
}
diff --git a/deps/icu-small/source/i18n/dtptngen_impl.h b/deps/icu-small/source/i18n/dtptngen_impl.h
index ade9f57331e769..9b9442d5787142 100644
--- a/deps/icu-small/source/i18n/dtptngen_impl.h
+++ b/deps/icu-small/source/i18n/dtptngen_impl.h
@@ -195,7 +195,7 @@ class FormatParser : public UMemory {
void getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex);
UBool isPatternSeparator(const UnicodeString& field) const;
static UBool isQuoteLiteral(const UnicodeString& s);
- static int32_t getCanonicalIndex(const UnicodeString& s) { return getCanonicalIndex(s, TRUE); }
+ static int32_t getCanonicalIndex(const UnicodeString& s) { return getCanonicalIndex(s, true); }
static int32_t getCanonicalIndex(const UnicodeString& s, UBool strict);
private:
diff --git a/deps/icu-small/source/i18n/fmtable.cpp b/deps/icu-small/source/i18n/fmtable.cpp
index 10a6fdb0ff3441..44c3087fb91aa6 100644
--- a/deps/icu-small/source/i18n/fmtable.cpp
+++ b/deps/icu-small/source/i18n/fmtable.cpp
@@ -895,7 +895,7 @@ U_NAMESPACE_END
U_NAMESPACE_USE
-U_DRAFT UFormattable* U_EXPORT2
+U_CAPI UFormattable* U_EXPORT2
ufmt_open(UErrorCode *status) {
if( U_FAILURE(*status) ) {
return NULL;
@@ -908,14 +908,14 @@ ufmt_open(UErrorCode *status) {
return fmt;
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
ufmt_close(UFormattable *fmt) {
Formattable *obj = Formattable::fromUFormattable(fmt);
delete obj;
}
-U_INTERNAL UFormattableType U_EXPORT2
+U_CAPI UFormattableType U_EXPORT2
ufmt_getType(const UFormattable *fmt, UErrorCode *status) {
if(U_FAILURE(*status)) {
return (UFormattableType)UFMT_COUNT;
@@ -925,27 +925,27 @@ ufmt_getType(const UFormattable *fmt, UErrorCode *status) {
}
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmt_isNumeric(const UFormattable *fmt) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->isNumeric();
}
-U_DRAFT UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ufmt_getDate(const UFormattable *fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getDate(*status);
}
-U_DRAFT double U_EXPORT2
+U_CAPI double U_EXPORT2
ufmt_getDouble(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getDouble(*status);
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getLong(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -953,7 +953,7 @@ ufmt_getLong(UFormattable *fmt, UErrorCode *status) {
}
-U_DRAFT const void *U_EXPORT2
+U_CAPI const void *U_EXPORT2
ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -966,7 +966,7 @@ ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
return ret;
}
-U_DRAFT const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -986,7 +986,7 @@ ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
return str.getTerminatedBuffer();
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -995,7 +995,7 @@ ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status) {
return count;
}
-U_DRAFT UFormattable * U_EXPORT2
+U_CAPI UFormattable * U_EXPORT2
ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
int32_t count;
@@ -1010,7 +1010,7 @@ ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status) {
}
}
-U_DRAFT const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
if(U_FAILURE(*status)) {
return "";
@@ -1031,7 +1031,7 @@ ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
}
}
-U_DRAFT int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
ufmt_getInt64(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getInt64(*status);
diff --git a/deps/icu-small/source/i18n/fmtable_cnv.cpp b/deps/icu-small/source/i18n/fmtable_cnv.cpp
index 9a647927797dbd..bc3847b6963e70 100644
--- a/deps/icu-small/source/i18n/fmtable_cnv.cpp
+++ b/deps/icu-small/source/i18n/fmtable_cnv.cpp
@@ -30,8 +30,6 @@ U_NAMESPACE_BEGIN
// -------------------------------------
// Creates a formattable object with a char* string.
// This API is useless. The API that takes a UnicodeString is actually just as good.
-// This is just a grandfathered API.
-
Formattable::Formattable(const char* stringToCopy)
{
init();
diff --git a/deps/icu-small/source/i18n/format.cpp b/deps/icu-small/source/i18n/format.cpp
index e5abbe9eb0fa7d..a010defff93c40 100644
--- a/deps/icu-small/source/i18n/format.cpp
+++ b/deps/icu-small/source/i18n/format.cpp
@@ -26,7 +26,7 @@
#include "unicode/utypes.h"
#ifndef U_I18N_IMPLEMENTATION
-#error U_I18N_IMPLEMENTATION not set - must be set for all ICU source files in i18n/ - see http://userguide.icu-project.org/howtouseicu
+#error U_I18N_IMPLEMENTATION not set - must be set for all ICU source files in i18n/ - see https://unicode-org.github.io/icu/userguide/howtouseicu
#endif
/*
diff --git a/deps/icu-small/source/i18n/formatted_string_builder.cpp b/deps/icu-small/source/i18n/formatted_string_builder.cpp
index 5aabc31cc4391b..b370f14f2ac4ff 100644
--- a/deps/icu-small/source/i18n/formatted_string_builder.cpp
+++ b/deps/icu-small/source/i18n/formatted_string_builder.cpp
@@ -276,6 +276,11 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
char16_t *oldChars = getCharPtr();
Field *oldFields = getFieldPtr();
if (fLength + count > oldCapacity) {
+ if ((fLength + count) > INT32_MAX / 2) {
+ // If we continue, then newCapacity will overlow int32_t in the next line.
+ status = U_INPUT_TOO_LONG_ERROR;
+ return -1;
+ }
int32_t newCapacity = (fLength + count) * 2;
int32_t newZero = newCapacity / 2 - (fLength + count) / 2;
@@ -330,12 +335,14 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
fZero = newZero;
fLength += count;
}
+ U_ASSERT((fZero + index) >= 0);
return fZero + index;
}
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;
+ U_ASSERT(position >= 0);
uprv_memmove2(getCharPtr() + position,
getCharPtr() + position + count,
sizeof(char16_t) * (fLength - index - count));
diff --git a/deps/icu-small/source/i18n/formatted_string_builder.h b/deps/icu-small/source/i18n/formatted_string_builder.h
index 4567dc1d66b0ce..92bcf07d782cde 100644
--- a/deps/icu-small/source/i18n/formatted_string_builder.h
+++ b/deps/icu-small/source/i18n/formatted_string_builder.h
@@ -25,7 +25,7 @@ class FormattedValueStringBuilderImpl;
*
*
* - Efficient prepend as well as append.
- *
- Keeps tracks of Fields in an efficient manner.
+ *
- Keeps track of Fields in an efficient manner.
*
*
* See also FormattedValueStringBuilderImpl.
@@ -55,7 +55,6 @@ class U_I18N_API FormattedStringBuilder : public UMemory {
// 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.
// Exported as U_I18N_API so it can be used by other exports on Windows.
struct U_I18N_API Field {
uint8_t bits;
diff --git a/deps/icu-small/source/i18n/formattedval_impl.h b/deps/icu-small/source/i18n/formattedval_impl.h
index 73ae9a3ea2ab3a..1e6eb1e639f809 100644
--- a/deps/icu-small/source/i18n/formattedval_impl.h
+++ b/deps/icu-small/source/i18n/formattedval_impl.h
@@ -69,6 +69,9 @@ U_NAMESPACE_BEGIN
/**
* Implementation of FormattedValue using FieldPositionHandler to accept fields.
+ *
+ * TODO(ICU-20897): This class is unused. If it is not needed when fixing ICU-20897,
+ * it should be deleted.
*/
class FormattedValueFieldPositionIteratorImpl : public UMemory, public FormattedValue {
public:
@@ -114,6 +117,24 @@ class FormattedValueFieldPositionIteratorImpl : public UMemory, public Formatted
};
+// Internal struct that must be exported for MSVC
+struct U_I18N_API SpanInfo {
+ int32_t spanValue;
+ int32_t length;
+};
+
+// Export an explicit template instantiation of the MaybeStackArray that
+// is used as a data member of CEBuffer.
+//
+// When building DLLs for Windows this is required even though
+// no direct access to the MaybeStackArray leaks out of the i18n library.
+//
+// See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.
+//
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray;
+#endif
+
/**
* Implementation of FormattedValue based on FormattedStringBuilder.
*
@@ -147,12 +168,23 @@ class U_I18N_API FormattedValueStringBuilderImpl : public UMemory, public Format
return fString;
}
+ /**
+ * Adds additional metadata used for span fields.
+ *
+ * spanValue: the index of the list item, for example.
+ * length: the length of the span, used to split adjacent fields.
+ */
+ void appendSpanInfo(int32_t spanValue, int32_t length, UErrorCode& status);
+ void prependSpanInfo(int32_t spanValue, int32_t length, UErrorCode& status);
+
private:
FormattedStringBuilder fString;
FormattedStringBuilder::Field fNumericField;
+ MaybeStackArray spanIndices;
bool nextPositionImpl(ConstrainedFieldPosition& cfpos, FormattedStringBuilder::Field numericField, UErrorCode& status) const;
static bool isIntOrGroup(FormattedStringBuilder::Field field);
+ static bool isTrimmable(FormattedStringBuilder::Field field);
int32_t trimBack(int32_t limit) const;
int32_t trimFront(int32_t start) const;
};
@@ -211,7 +243,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
return fData->appendTo(appendable, status); \
} \
UBool Name::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { \
- UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) \
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(false) \
return fData->nextPosition(cfpos, status); \
}
@@ -230,7 +262,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
} \
return static_cast(impl)->exportForC(); \
} \
- U_DRAFT const UFormattedValue* U_EXPORT2 \
+ U_CAPI const UFormattedValue* U_EXPORT2 \
Prefix ## _resultAsValue (const CType* uresult, UErrorCode* ec) { \
const ImplType* result = HelperType::validate(uresult, *ec); \
if (U_FAILURE(*ec)) { return nullptr; } \
diff --git a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
index dfe3af6686df2f..84c2d00666c2be 100644
--- a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
+++ b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
@@ -15,6 +15,7 @@
#include "formatted_string_builder.h"
#include "number_utils.h"
#include "static_unicode_sets.h"
+#include "unicode/listformatter.h"
U_NAMESPACE_BEGIN
@@ -45,19 +46,19 @@ Appendable& FormattedValueStringBuilderImpl::appendTo(Appendable& appendable, UE
UBool FormattedValueStringBuilderImpl::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const {
// NOTE: MSVC sometimes complains when implicitly converting between bool and UBool
- return nextPositionImpl(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;
+ return false;
}
if (rawField < 0 || rawField >= UNUM_FIELD_COUNT) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
ConstrainedFieldPosition cfpos;
@@ -66,7 +67,7 @@ UBool FormattedValueStringBuilderImpl::nextFieldPosition(FieldPosition& fp, UErr
if (nextPositionImpl(cfpos, kUndefinedField, status)) {
fp.setBeginIndex(cfpos.getStart());
fp.setEndIndex(cfpos.getLimit());
- return TRUE;
+ return true;
}
// Special case: fraction should start after integer if fraction is not present
@@ -84,7 +85,7 @@ UBool FormattedValueStringBuilderImpl::nextFieldPosition(FieldPosition& fp, UErr
fp.setEndIndex(i - fString.fZero);
}
- return FALSE;
+ return false;
}
void FormattedValueStringBuilderImpl::getAllFieldPositions(FieldPositionIteratorHandler& fpih,
@@ -109,7 +110,7 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
if (currField != _field) {
int32_t end = i - fString.fZero;
// Grouping separators can be whitespace; don't throw them out!
- if (currField != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)) {
+ if (isTrimmable(currField)) {
end = trimBack(i - fString.fZero);
}
if (end <= fieldStart) {
@@ -120,7 +121,7 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
continue;
}
int32_t start = fieldStart;
- if (currField != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)) {
+ if (isTrimmable(currField)) {
start = trimFront(start);
}
cfpos.setState(currField.getCategory(), currField.getField(), start, end);
@@ -154,7 +155,8 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
|| cfpos.getField() != numericField.getField())
&& fString.getFieldPtr()[i - 1].isNumeric()
&& !_field.isNumeric()) {
- int j = i - 1;
+ // Re-wind to the beginning of the field and then emit it
+ int32_t j = i - 1;
for (; j >= fString.fZero && fString.getFieldPtr()[j].isNumeric(); j--) {}
cfpos.setState(
numericField.getCategory(),
@@ -163,6 +165,21 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
i - fString.fZero);
return true;
}
+ // Special case: emit normalField if we are pointing at the end of spanField.
+ if (i > fString.fZero) {
+ auto elementField = fString.getFieldPtr()[i-1];
+ if (elementField == Field(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD)
+ && cfpos.matchesField(elementField.getCategory(), elementField.getField())
+ && (cfpos.getLimit() < i - fString.fZero || cfpos.getCategory() != elementField.getCategory())) {
+ int64_t si = cfpos.getInt64IterationContext() - 1;
+ cfpos.setState(
+ elementField.getCategory(),
+ elementField.getField(),
+ i - fString.fZero - spanIndices[si].length,
+ i - fString.fZero);
+ return true;
+ }
+ }
// Special case: skip over INTEGER; will be coalesced later.
if (_field == Field(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD)) {
_field = kUndefinedField;
@@ -172,6 +189,29 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
continue;
}
// Case 3: check for field starting at this position
+ // Case 3a: Need to add a SpanField
+ if (_field == Field(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD)) {
+ int64_t si = cfpos.getInt64IterationContext();
+ int32_t spanValue = spanIndices[si].spanValue;
+ int32_t length = spanIndices[si].length;
+ cfpos.setInt64IterationContext(si + 1);
+ if (cfpos.matchesField(UFIELD_CATEGORY_LIST_SPAN, spanValue)) {
+ UFieldCategory spanCategory = UFIELD_CATEGORY_LIST_SPAN;
+ fieldStart = i - fString.fZero;
+ int32_t end = fieldStart + length;
+ cfpos.setState(
+ spanCategory,
+ spanValue,
+ fieldStart,
+ end);
+ return true;
+ } else {
+ // Failed to match; jump ahead
+ i += length - 1;
+ continue;
+ }
+ }
+ // Case 3b: No SpanField
if (cfpos.matchesField(_field.getCategory(), _field.getField())) {
fieldStart = i - fString.fZero;
currField = _field;
@@ -179,14 +219,52 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
}
U_ASSERT(currField == kUndefinedField);
+ // Always set the position to the end so that we don't revisit previous sections
+ cfpos.setState(
+ cfpos.getCategory(),
+ cfpos.getField(),
+ fString.fLength,
+ fString.fLength);
return false;
}
+void FormattedValueStringBuilderImpl::appendSpanInfo(int32_t spanValue, int32_t length, UErrorCode& status) {
+ if (U_FAILURE(status)) { return; }
+ U_ASSERT(spanIndices.getCapacity() >= spanValue);
+ if (spanIndices.getCapacity() == spanValue) {
+ if (!spanIndices.resize(spanValue * 2, spanValue)) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
+ spanIndices[spanValue] = {spanValue, length};
+}
+
+void FormattedValueStringBuilderImpl::prependSpanInfo(int32_t spanValue, int32_t length, UErrorCode& status) {
+ if (U_FAILURE(status)) { return; }
+ U_ASSERT(spanIndices.getCapacity() >= spanValue);
+ if (spanIndices.getCapacity() == spanValue) {
+ if (!spanIndices.resize(spanValue * 2, spanValue)) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
+ for (int32_t i = spanValue - 1; i >= 0; i--) {
+ spanIndices[i+1] = spanIndices[i];
+ }
+ spanIndices[0] = {spanValue, length};
+}
+
bool FormattedValueStringBuilderImpl::isIntOrGroup(Field field) {
return field == Field(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD)
|| field == Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD);
}
+bool FormattedValueStringBuilderImpl::isTrimmable(Field field) {
+ return field != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)
+ && field.getCategory() != UFIELD_CATEGORY_LIST;
+}
+
int32_t FormattedValueStringBuilderImpl::trimBack(int32_t limit) const {
return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack(
fString.getCharPtr() + fString.fZero,
diff --git a/deps/icu-small/source/i18n/formattedvalue.cpp b/deps/icu-small/source/i18n/formattedvalue.cpp
index e2c9c42fc88a36..79ecf0a841cf9b 100644
--- a/deps/icu-small/source/i18n/formattedvalue.cpp
+++ b/deps/icu-small/source/i18n/formattedvalue.cpp
@@ -193,7 +193,7 @@ ucfpos_close(UConstrainedFieldPosition* ptr) {
}
-U_DRAFT const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
@@ -213,7 +213,7 @@ ufmtval_getString(
}
-U_DRAFT UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmtval_nextPosition(
const UFormattedValue* ufmtval,
UConstrainedFieldPosition* ucfpos,
diff --git a/deps/icu-small/source/i18n/fphdlimp.h b/deps/icu-small/source/i18n/fphdlimp.h
index b9fa9b218149d4..4fb0c7b6fe686e 100644
--- a/deps/icu-small/source/i18n/fphdlimp.h
+++ b/deps/icu-small/source/i18n/fphdlimp.h
@@ -41,8 +41,8 @@ class U_I18N_API FieldPositionHandler: public UMemory {
class FieldPositionOnlyHandler : public FieldPositionHandler {
FieldPosition& pos;
- UBool acceptFirstOnly = FALSE;
- UBool seenFirst = FALSE;
+ UBool acceptFirstOnly = false;
+ UBool seenFirst = false;
public:
FieldPositionOnlyHandler(FieldPosition& pos);
diff --git a/deps/icu-small/source/i18n/gregocal.cpp b/deps/icu-small/source/i18n/gregocal.cpp
index 028ab05aa9accc..38a20dd93fb704 100644
--- a/deps/icu-small/source/i18n/gregocal.cpp
+++ b/deps/icu-small/source/i18n/gregocal.cpp
@@ -185,7 +185,7 @@ fIsGregorian(TRUE), fInvertGregorian(FALSE)
// -------------------------------------
GregorianCalendar::GregorianCalendar(const Locale& aLocale, UErrorCode& status)
-: Calendar(TimeZone::createDefault(), aLocale, status),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
fIsGregorian(TRUE), fInvertGregorian(FALSE)
diff --git a/deps/icu-small/source/i18n/gregoimp.h b/deps/icu-small/source/i18n/gregoimp.h
index eb3844f8523eeb..edcae9dbcc65ff 100644
--- a/deps/icu-small/source/i18n/gregoimp.h
+++ b/deps/icu-small/source/i18n/gregoimp.h
@@ -148,9 +148,9 @@ class ClockMath {
class Grego {
public:
/**
- * Return TRUE if the given year is a leap year.
+ * Return true if the given year is a leap year.
* @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
- * @return TRUE if the year is a leap year
+ * @return true if the year is a leap year
*/
static inline UBool isLeapYear(int32_t year);
diff --git a/deps/icu-small/source/i18n/hebrwcal.cpp b/deps/icu-small/source/i18n/hebrwcal.cpp
index 085ded784651a6..98cbb4a1050d01 100644
--- a/deps/icu-small/source/i18n/hebrwcal.cpp
+++ b/deps/icu-small/source/i18n/hebrwcal.cpp
@@ -155,7 +155,7 @@ U_NAMESPACE_BEGIN
* @internal
*/
HebrewCalendar::HebrewCalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success)
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
@@ -393,7 +393,8 @@ int32_t HebrewCalendar::startOfYear(int32_t year, UErrorCode &status)
int32_t day = CalendarCache::get(&gCache, year, status);
if (day == 0) {
- int32_t months = (235 * year - 234) / 19; // # of months before year
+ // # of months before year
+ int32_t months = (int32_t)ClockMath::floorDivide((235 * (int64_t)year - 234), (int64_t)19);
int64_t frac = (int64_t)months * MONTH_FRACT + BAHARAD; // Fractional part of day #
day = months * 29 + (int32_t)(frac / DAY_PARTS); // Whole # part of calculation
@@ -566,8 +567,8 @@ void HebrewCalendar::validateField(UCalendarDateFields field, UErrorCode &status
*/
void HebrewCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) {
int32_t d = julianDay - 347997;
- double m = ((d * (double)DAY_PARTS)/ (double) MONTH_PARTS); // Months (approx)
- int32_t year = (int32_t)( ((19. * m + 234.) / 235.) + 1.); // Years (approx)
+ double m = ClockMath::floorDivide((d * (double)DAY_PARTS), (double) MONTH_PARTS); // Months (approx)
+ int32_t year = (int32_t)(ClockMath::floorDivide((19. * m + 234.), 235.) + 1.); // Years (approx)
int32_t ys = startOfYear(year, status); // 1st day of year
int32_t dayOfYear = (d - ys);
diff --git a/deps/icu-small/source/i18n/hebrwcal.h b/deps/icu-small/source/i18n/hebrwcal.h
index 97e8511705e776..34450ffa61855d 100644
--- a/deps/icu-small/source/i18n/hebrwcal.h
+++ b/deps/icu-small/source/i18n/hebrwcal.h
@@ -386,7 +386,7 @@ class U_I18N_API HebrewCalendar : public Calendar {
virtual UBool inDaylightTime(UErrorCode& status) const;
/**
- * Returns TRUE because the Hebrew Calendar does have a default century
+ * Returns true because the Hebrew Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/indiancal.cpp b/deps/icu-small/source/i18n/indiancal.cpp
index f1266bb7757939..42a91c55e2f526 100644
--- a/deps/icu-small/source/i18n/indiancal.cpp
+++ b/deps/icu-small/source/i18n/indiancal.cpp
@@ -40,7 +40,7 @@ IndianCalendar* IndianCalendar::clone() const {
}
IndianCalendar::IndianCalendar(const Locale& aLocale, UErrorCode& success)
- : Calendar(TimeZone::createDefault(), aLocale, success)
+ : Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
@@ -83,7 +83,6 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
};
-static const double JULIAN_EPOCH = 1721425.5;
static const int32_t INDIAN_ERA_START = 78;
static const int32_t INDIAN_YEAR_START = 80;
@@ -96,7 +95,7 @@ int32_t IndianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType lim
*/
static UBool isGregorianLeap(int32_t year)
{
- return ((year % 4) == 0) && (!(((year % 100) == 0) && ((year % 400) != 0)));
+ return Grego::isLeapYear(year);
}
//----------------------------------------------------------------------
@@ -137,56 +136,22 @@ int32_t IndianCalendar::handleGetYearLength(int32_t eyear) const {
* Returns the Julian Day corresponding to gregorian date
*
* @param year The Gregorian year
- * @param month The month in Gregorian Year
+ * @param month The month in Gregorian Year, 0 based.
* @param date The date in Gregorian day in month
*/
static double gregorianToJD(int32_t year, int32_t month, int32_t date) {
- double julianDay = (JULIAN_EPOCH - 1) +
- (365 * (year - 1)) +
- uprv_floor((year - 1) / 4) +
- (-uprv_floor((year - 1) / 100)) +
- uprv_floor((year - 1) / 400) +
- uprv_floor((((367 * month) - 362) / 12) +
- ((month <= 2) ? 0 :
- (isGregorianLeap(year) ? -1 : -2)
- ) +
- date);
-
- return julianDay;
+ return Grego::fieldsToDay(year, month, date) + kEpochStartAsJulianDay - 0.5;
}
/*
* Returns the Gregorian Date corresponding to a given Julian Day
+ * Month is 0 based.
* @param jd The Julian Day
*/
static int32_t* jdToGregorian(double jd, int32_t gregorianDate[3]) {
- double wjd, depoch, quadricent, dqc, cent, dcent, quad, dquad, yindex, yearday, leapadj;
- int32_t year, month, day;
- wjd = uprv_floor(jd - 0.5) + 0.5;
- depoch = wjd - JULIAN_EPOCH;
- quadricent = uprv_floor(depoch / 146097);
- dqc = (int32_t)uprv_floor(depoch) % 146097;
- cent = uprv_floor(dqc / 36524);
- dcent = (int32_t)uprv_floor(dqc) % 36524;
- quad = uprv_floor(dcent / 1461);
- dquad = (int32_t)uprv_floor(dcent) % 1461;
- yindex = uprv_floor(dquad / 365);
- year = (int32_t)((quadricent * 400) + (cent * 100) + (quad * 4) + yindex);
- if (!((cent == 4) || (yindex == 4))) {
- year++;
- }
- yearday = wjd - gregorianToJD(year, 1, 1);
- leapadj = ((wjd < gregorianToJD(year, 3, 1)) ? 0
- :
- (isGregorianLeap(year) ? 1 : 2)
- );
- month = (int32_t)uprv_floor((((yearday + leapadj) * 12) + 373) / 367);
- day = (int32_t)(wjd - gregorianToJD(year, month, 1)) + 1;
-
- gregorianDate[0] = year;
- gregorianDate[1] = month;
- gregorianDate[2] = day;
-
+ int32_t gdow;
+ Grego::dayToFields(jd - kEpochStartAsJulianDay,
+ gregorianDate[0], gregorianDate[1], gregorianDate[2], gdow);
return gregorianDate;
}
@@ -203,11 +168,11 @@ static double IndianToJD(int32_t year, int32_t month, int32_t date) {
if(isGregorianLeap(gyear)) {
leapMonth = 31;
- start = gregorianToJD(gyear, 3, 21);
+ start = gregorianToJD(gyear, 2 /* The third month in 0 based month */, 21);
}
else {
leapMonth = 30;
- start = gregorianToJD(gyear, 3, 22);
+ start = gregorianToJD(gyear, 2 /* The third month in 0 based month */, 22);
}
if (month == 1) {
@@ -297,7 +262,7 @@ void IndianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& /* stat
gregorianYear = jdToGregorian(julianDay, gd)[0]; // Gregorian date for Julian day
IndianYear = gregorianYear - INDIAN_ERA_START; // Year in Saka era
- jdAtStartOfGregYear = gregorianToJD(gregorianYear, 1, 1); // JD at start of Gregorian year
+ jdAtStartOfGregYear = gregorianToJD(gregorianYear, 0, 1); // JD at start of Gregorian year
yday = (int32_t)(julianDay - jdAtStartOfGregYear); // Day number in Gregorian year (starting from 0)
if (yday < INDIAN_YEAR_START) {
diff --git a/deps/icu-small/source/i18n/indiancal.h b/deps/icu-small/source/i18n/indiancal.h
index 142597ce0e6b02..624cec73b53efc 100644
--- a/deps/icu-small/source/i18n/indiancal.h
+++ b/deps/icu-small/source/i18n/indiancal.h
@@ -147,7 +147,7 @@ class U_I18N_API IndianCalendar : public Calendar {
* @param aLocale The given locale.
* @param success Indicates the status of IndianCalendar object construction.
* Returns U_ZERO_ERROR if constructed successfully.
- * @param beCivil Whether the calendar should be civil (default-TRUE) or religious (FALSE)
+ * @param beCivil Whether the calendar should be civil (default-true) or religious (false)
* @internal
*/
IndianCalendar(const Locale& aLocale, UErrorCode &success);
@@ -303,7 +303,7 @@ class U_I18N_API IndianCalendar : public Calendar {
/**
- * Returns TRUE because the Indian Calendar does have a default century
+ * Returns true because the Indian Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/islamcal.cpp b/deps/icu-small/source/i18n/islamcal.cpp
index 4e4a6648048208..6e21e51150ab88 100644
--- a/deps/icu-small/source/i18n/islamcal.cpp
+++ b/deps/icu-small/source/i18n/islamcal.cpp
@@ -232,7 +232,7 @@ IslamicCalendar* IslamicCalendar::clone() const {
}
IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success, ECalculationType type)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
cType(type)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
@@ -368,7 +368,7 @@ int32_t IslamicCalendar::yearStart(int32_t year) const{
if (cType == CIVIL || cType == TBLA ||
(cType == UMALQURA && (year < UMALQURA_YEAR_START || year > UMALQURA_YEAR_END)))
{
- return (year-1)*354 + ClockMath::floorDivide((3+11*year),30);
+ return (year-1)*354 + ClockMath::floorDivide((3+11*(int64_t)year),(int64_t)30);
} else if(cType==ASTRONOMICAL){
return trueMonthStart(12*(year-1));
} else {
@@ -391,7 +391,7 @@ int32_t IslamicCalendar::monthStart(int32_t year, int32_t month) const {
if (cType == CIVIL || cType == TBLA) {
// This does not handle months out of the range 0..11
return (int32_t)uprv_ceil(29.5*month)
- + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*year),30);
+ + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*(int64_t)year),(int64_t)30);
} else if(cType==ASTRONOMICAL){
return trueMonthStart(12*(year-1) + month);
} else {
@@ -447,7 +447,8 @@ int32_t IslamicCalendar::trueMonthStart(int32_t month) const
}
} while (age < 0);
}
- start = (int32_t)ClockMath::floorDivide((origin - HIJRA_MILLIS), (double)kOneDay) + 1;
+ start = (int32_t)(ClockMath::floorDivide(
+ (int64_t)((int64_t)origin - HIJRA_MILLIS), (int64_t)kOneDay) + 1);
CalendarCache::put(&gMonthCache, month, start, status);
}
trueMonthStartEnd :
@@ -639,13 +640,14 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
months--;
}
- year = months / 12 + 1;
- month = months % 12;
+ year = months >= 0 ? ((months / 12) + 1) : ((months + 1 ) / 12);
+ month = ((months % 12) + 12 ) % 12;
} else if(cType == UMALQURA) {
int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ;
if( days < umalquraStartdays){
//Use Civil calculation
- year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 );
+ year = (int32_t)ClockMath::floorDivide(
+ (30 * (int64_t)days + 10646) , (int64_t)10631.0 );
month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
month = month<11?month:11;
startDate = monthStart(year, month);
diff --git a/deps/icu-small/source/i18n/islamcal.h b/deps/icu-small/source/i18n/islamcal.h
index aad8f07be0f984..b4ead411da9e04 100644
--- a/deps/icu-small/source/i18n/islamcal.h
+++ b/deps/icu-small/source/i18n/islamcal.h
@@ -395,7 +395,7 @@ class U_I18N_API IslamicCalendar : public Calendar {
/**
- * Returns TRUE because the Islamic Calendar does have a default century
+ * Returns true because the Islamic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/japancal.h b/deps/icu-small/source/i18n/japancal.h
index ee86c4ed0e3b93..d313fcd99ab508 100644
--- a/deps/icu-small/source/i18n/japancal.h
+++ b/deps/icu-small/source/i18n/japancal.h
@@ -167,7 +167,7 @@ class JapaneseCalendar : public GregorianCalendar {
virtual const char * getType() const;
/**
- * @return FALSE - no default century in Japanese
+ * @return false - no default century in Japanese
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/listformatter.cpp b/deps/icu-small/source/i18n/listformatter.cpp
index 4b27587555219c..be0d16bc7f52b3 100644
--- a/deps/icu-small/source/i18n/listformatter.cpp
+++ b/deps/icu-small/source/i18n/listformatter.cpp
@@ -16,6 +16,10 @@
* created by: Umesh P. Nair
*/
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
#include "cmemory.h"
#include "unicode/fpositer.h" // FieldPositionIterator
#include "unicode/listformatter.h"
@@ -52,10 +56,12 @@ class PatternHandler : public UObject {
virtual PatternHandler* clone() const { return new PatternHandler(twoPattern, endPattern); }
+ /** Argument: final string in the list. */
virtual const SimpleFormatter& getTwoPattern(const UnicodeString&) const {
return twoPattern;
}
+ /** Argument: final string in the list. */
virtual const SimpleFormatter& getEndPattern(const UnicodeString&) const {
return endPattern;
}
@@ -169,21 +175,21 @@ PatternHandler* createPatternHandler(
UErrorCode& status) {
if (uprv_strcmp(lang, "es") == 0) {
// Spanish
- UnicodeString spanishYStr(TRUE, spanishY, -1);
+ UnicodeString spanishYStr(true, spanishY, -1);
bool twoIsY = two == spanishYStr;
bool endIsY = end == spanishYStr;
if (twoIsY || endIsY) {
- UnicodeString replacement(TRUE, spanishE, -1);
+ UnicodeString replacement(true, spanishE, -1);
return new ContextualHandler(
shouldChangeToE,
twoIsY ? replacement : two, two,
endIsY ? replacement : end, end, status);
}
- UnicodeString spanishOStr(TRUE, spanishO, -1);
+ UnicodeString spanishOStr(true, spanishO, -1);
bool twoIsO = two == spanishOStr;
bool endIsO = end == spanishOStr;
if (twoIsO || endIsO) {
- UnicodeString replacement(TRUE, spanishU, -1);
+ UnicodeString replacement(true, spanishU, -1);
return new ContextualHandler(
shouldChangeToU,
twoIsO ? replacement : two, two,
@@ -191,11 +197,11 @@ PatternHandler* createPatternHandler(
}
} else if (uprv_strcmp(lang, "he") == 0 || uprv_strcmp(lang, "iw") == 0) {
// Hebrew
- UnicodeString hebrewVavStr(TRUE, hebrewVav, -1);
+ UnicodeString hebrewVavStr(true, hebrewVav, -1);
bool twoIsVav = two == hebrewVavStr;
bool endIsVav = end == hebrewVavStr;
if (twoIsVav || endIsVav) {
- UnicodeString replacement(TRUE, hebrewVavDash, -1);
+ UnicodeString replacement(true, hebrewVavDash, -1);
return new ContextualHandler(
shouldChangeToVavDash,
twoIsVav ? replacement : two, two,
@@ -236,17 +242,15 @@ ListFormatInternal(const ListFormatInternal &other) :
};
-#if !UCONFIG_NO_FORMATTING
-class FormattedListData : public FormattedValueFieldPositionIteratorImpl {
+class FormattedListData : public FormattedValueStringBuilderImpl {
public:
- FormattedListData(UErrorCode& status) : FormattedValueFieldPositionIteratorImpl(5, status) {}
+ FormattedListData(UErrorCode&) : FormattedValueStringBuilderImpl(kUndefinedField) {}
virtual ~FormattedListData();
};
FormattedListData::~FormattedListData() = default;
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedList)
-#endif
static Hashtable* listPatternHash = nullptr;
@@ -255,7 +259,7 @@ U_CDECL_BEGIN
static UBool U_CALLCONV uprv_listformatter_cleanup() {
delete listPatternHash;
listPatternHash = nullptr;
- return TRUE;
+ return true;
}
static void U_CALLCONV
@@ -348,7 +352,6 @@ const ListFormatInternal* ListFormatter::getListFormatInternal(
return result;
}
-#if !UCONFIG_NO_FORMATTING
static const char* typeWidthToStyleString(UListFormatterType type, UListFormatterWidth width) {
switch (type) {
case ULISTFMT_TYPE_AND:
@@ -392,7 +395,6 @@ static const char* typeWidthToStyleString(UListFormatterType type, UListFormatte
return nullptr;
}
-#endif
static const UChar solidus = 0x2F;
static const UChar aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
@@ -513,14 +515,9 @@ ListFormatter* ListFormatter::createInstance(UErrorCode& errorCode) {
}
ListFormatter* ListFormatter::createInstance(const Locale& locale, UErrorCode& errorCode) {
-#if !UCONFIG_NO_FORMATTING
return createInstance(locale, ULISTFMT_TYPE_AND, ULISTFMT_WIDTH_WIDE, errorCode);
-#else
- return createInstance(locale, "standard", errorCode);
-#endif
}
-#if !UCONFIG_NO_FORMATTING
ListFormatter* ListFormatter::createInstance(
const Locale& locale, UListFormatterType type, UListFormatterWidth width, UErrorCode& errorCode) {
const char* style = typeWidthToStyleString(type, width);
@@ -530,7 +527,6 @@ ListFormatter* ListFormatter::createInstance(
}
return createInstance(locale, style, errorCode);
}
-#endif
ListFormatter* ListFormatter::createInstance(const Locale& locale, const char *style, UErrorCode& errorCode) {
const ListFormatInternal* listFormatInternal = getListFormatInternal(locale, style, errorCode);
@@ -557,50 +553,89 @@ ListFormatter::~ListFormatter() {
delete owned;
}
-/**
- * Joins first and second using the pattern pat.
- * On entry offset is an offset into first or -1 if offset unspecified.
- * On exit offset is offset of second in result if recordOffset was set
- * Otherwise if it was >=0 it is set to point into result where it used
- * to point into first. On exit, result is the join of first and second
- * according to pat. Any previous value of result gets replaced.
- */
-static void joinStringsAndReplace(
- const SimpleFormatter& pat,
- const UnicodeString& first,
- const UnicodeString& second,
- UnicodeString &result,
- UBool recordOffset,
- int32_t &offset,
- int32_t *offsetFirst,
- int32_t *offsetSecond,
- UErrorCode& errorCode) {
- if (U_FAILURE(errorCode)) {
- return;
- }
- const UnicodeString *params[2] = {&first, &second};
- int32_t offsets[2];
- pat.formatAndReplace(
- params,
- UPRV_LENGTHOF(params),
- result,
- offsets,
- UPRV_LENGTHOF(offsets),
- errorCode);
- if (U_FAILURE(errorCode)) {
- return;
+namespace {
+
+class FormattedListBuilder {
+public:
+ LocalPointer data;
+
+ /** For lists of length 1+ */
+ FormattedListBuilder(const UnicodeString& start, UErrorCode& status)
+ : data(new FormattedListData(status), status) {
+ if (U_SUCCESS(status)) {
+ data->getStringRef().append(
+ start,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->appendSpanInfo(0, start.length(), status);
+ }
}
- if (offsets[0] == -1 || offsets[1] == -1) {
- errorCode = U_INVALID_FORMAT_ERROR;
- return;
+
+ /** For lists of length 0 */
+ FormattedListBuilder(UErrorCode& status)
+ : data(new FormattedListData(status), status) {
}
- if (recordOffset) {
- offset = offsets[1];
- } else if (offset >= 0) {
- offset += offsets[0];
+
+ void append(const SimpleFormatter& pattern, const UnicodeString& next, int32_t position, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (pattern.getArgumentLimit() != 2) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
+ }
+ // In the pattern, {0} are the pre-existing elements and {1} is the new element.
+ int32_t offsets[] = {0, 0};
+ UnicodeString temp = pattern.getTextWithNoArguments(offsets, 2);
+ if (offsets[0] <= offsets[1]) {
+ // prefix{0}infix{1}suffix
+ // Prepend prefix, then append infix, element, and suffix
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(0, offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ temp.tempSubStringBetween(offsets[0], offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ next,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->appendSpanInfo(position, next.length(), status);
+ data->getStringRef().append(
+ temp.tempSubString(offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ } else {
+ // prefix{1}infix{0}suffix
+ // Prepend infix, element, and prefix, then append suffix.
+ // (We prepend in reverse order because prepending at index 0 is fast.)
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(offsets[1], offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().insert(
+ 0,
+ next,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->prependSpanInfo(position, next.length(), status);
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(0, offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ temp.tempSubString(offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ }
}
- if (offsetFirst != nullptr) *offsetFirst = offsets[0];
- if (offsetSecond != nullptr) *offsetSecond = offsets[1];
+};
+
}
UnicodeString& ListFormatter::format(
@@ -619,190 +654,86 @@ UnicodeString& ListFormatter::format(
int32_t index,
int32_t &offset,
UErrorCode& errorCode) const {
- return format_(items, nItems, appendTo, index, offset, nullptr, errorCode);
+ int32_t initialOffset = appendTo.length();
+ auto result = formatStringsToValue(items, nItems, errorCode);
+ UnicodeStringAppendable appendable(appendTo);
+ result.appendTo(appendable, errorCode);
+ if (index >= 0) {
+ ConstrainedFieldPosition cfpos;
+ cfpos.constrainField(UFIELD_CATEGORY_LIST_SPAN, index);
+ result.nextPosition(cfpos, errorCode);
+ offset = initialOffset + cfpos.getStart();
+ }
+ return appendTo;
}
-#if !UCONFIG_NO_FORMATTING
FormattedList ListFormatter::formatStringsToValue(
const UnicodeString items[],
int32_t nItems,
UErrorCode& errorCode) const {
- LocalPointer result(new FormattedListData(errorCode), errorCode);
- if (U_FAILURE(errorCode)) {
- return FormattedList(errorCode);
+ if (nItems == 0) {
+ FormattedListBuilder result(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
+ } else if (nItems == 1) {
+ FormattedListBuilder result(items[0], errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
+ } else if (nItems == 2) {
+ FormattedListBuilder result(items[0], errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ }
+ result.append(
+ data->patternHandler->getTwoPattern(items[1]),
+ items[1],
+ 1,
+ errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
}
- UnicodeString string;
- int32_t offset;
- auto handler = result->getHandler(errorCode);
- handler.setCategory(UFIELD_CATEGORY_LIST);
- format_(items, nItems, string, -1, offset, &handler, errorCode);
- handler.getError(errorCode);
- result->appendString(string, errorCode);
+
+ FormattedListBuilder result(items[0], errorCode);
if (U_FAILURE(errorCode)) {
return FormattedList(errorCode);
}
-
- // Add span fields and sort
- ConstrainedFieldPosition cfpos;
- cfpos.constrainField(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD);
- int32_t i = 0;
- handler.setCategory(UFIELD_CATEGORY_LIST_SPAN);
- while (result->nextPosition(cfpos, errorCode)) {
- handler.addAttribute(i++, cfpos.getStart(), cfpos.getLimit());
+ result.append(
+ data->startPattern,
+ items[1],
+ 1,
+ errorCode);
+ for (int32_t i = 2; i < nItems - 1; i++) {
+ result.append(
+ data->middlePattern,
+ items[i],
+ i,
+ errorCode);
}
- handler.getError(errorCode);
+ result.append(
+ data->patternHandler->getEndPattern(items[nItems-1]),
+ items[nItems-1],
+ nItems-1,
+ errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
if (U_FAILURE(errorCode)) {
return FormattedList(errorCode);
- }
- result->sort();
-
- return FormattedList(result.orphan());
-}
-#endif
-
-UnicodeString& ListFormatter::format_(
- const UnicodeString items[],
- int32_t nItems,
- UnicodeString& appendTo,
- int32_t index,
- int32_t &offset,
- FieldPositionHandler* handler,
- UErrorCode& errorCode) const {
-#if !UCONFIG_NO_FORMATTING
- offset = -1;
- if (U_FAILURE(errorCode)) {
- return appendTo;
- }
- if (data == nullptr) {
- errorCode = U_INVALID_STATE_ERROR;
- return appendTo;
- }
-
- if (nItems <= 0) {
- return appendTo;
- }
- if (nItems == 1) {
- if (index == 0) {
- offset = appendTo.length();
- }
- if (handler != nullptr) {
- handler->addAttribute(ULISTFMT_ELEMENT_FIELD,
- appendTo.length(),
- appendTo.length() + items[0].length());
- }
- appendTo.append(items[0]);
- return appendTo;
- }
- UnicodeString result(items[0]);
- if (index == 0) {
- offset = 0;
- }
- 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.
- MaybeStackArray offsets((handler != nullptr) ? 2 * (nItems + 1): 0);
- if (nItems == 2) {
- joinStringsAndReplace(
- data->patternHandler->getTwoPattern(items[1]),
- result,
- items[1],
- result,
- index == 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
} else {
- joinStringsAndReplace(
- data->startPattern,
- result,
- items[1],
- result,
- index == 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- }
- if (handler != nullptr) {
- offsets[0] = 0;
- prefixLength += offsetFirst;
- offsets[1] = offsetSecond - prefixLength;
- }
- if (nItems > 2) {
- for (int32_t i = 2; i < nItems - 1; ++i) {
- joinStringsAndReplace(
- data->middlePattern,
- result,
- items[i],
- result,
- index == i,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- if (handler != nullptr) {
- prefixLength += offsetFirst;
- offsets[i] = offsetSecond - prefixLength;
- }
- }
- joinStringsAndReplace(
- data->patternHandler->getEndPattern(items[nItems - 1]),
- result,
- items[nItems - 1],
- result,
- index == nItems - 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- if (handler != nullptr) {
- prefixLength += offsetFirst;
- offsets[nItems - 1] = offsetSecond - prefixLength;
- }
- }
- if (handler != nullptr) {
- // If there are already some data in appendTo, we need to adjust the index
- // by shifting that lenght while insert into handler.
- int32_t shift = appendTo.length() + prefixLength;
- // Output the ULISTFMT_ELEMENT_FIELD in the order of the input elements
- for (int32_t i = 0; i < nItems; ++i) {
- offsets[i + nItems] = offsets[i] + items[i].length() + shift;
- offsets[i] += shift;
- handler->addAttribute(
- ULISTFMT_ELEMENT_FIELD, // id
- offsets[i], // index
- offsets[i + nItems]); // limit
- }
- // The locale pattern may reorder the items (such as in ur-IN locale),
- // so we cannot assume the array is in accendning order.
- // To handle the edging case, just insert the two ends into the array
- // and sort. Then we output ULISTFMT_LITERAL_FIELD if the indecies
- // between the even and odd position are not the same in the sorted array.
- offsets[2 * nItems] = shift - prefixLength;
- offsets[2 * nItems + 1] = result.length() + shift - prefixLength;
- uprv_sortArray(offsets.getAlias(), 2 * (nItems + 1), sizeof(int32_t),
- uprv_int32Comparator, nullptr,
- false, &errorCode);
- for (int32_t i = 0; i <= nItems; ++i) {
- if (offsets[i * 2] != offsets[i * 2 + 1]) {
- handler->addAttribute(
- ULISTFMT_LITERAL_FIELD, // id
- offsets[i * 2], // index
- offsets[i * 2 + 1]); // limit
- }
- }
- }
- if (U_SUCCESS(errorCode)) {
- if (offset >= 0) {
- offset += appendTo.length();
- }
- appendTo += result;
+ return FormattedList(result.data.orphan());
}
-#endif
- return appendTo;
}
+
U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/measfmt.cpp b/deps/icu-small/source/i18n/measfmt.cpp
index a98a6dda4705b5..3e7f7bae157cf7 100644
--- a/deps/icu-small/source/i18n/measfmt.cpp
+++ b/deps/icu-small/source/i18n/measfmt.cpp
@@ -861,7 +861,7 @@ UnicodeString &MeasureFormat::formatMeasuresSlowTrack(
return appendTo;
}
// Fix up FieldPosition indexes if our field is found.
- if (offset != -1) {
+ if (fieldPositionFoundIndex != -1 && offset != -1) {
pos.setBeginIndex(fpos.getBeginIndex() + offset);
pos.setEndIndex(fpos.getEndIndex() + offset);
}
diff --git a/deps/icu-small/source/i18n/measunit.cpp b/deps/icu-small/source/i18n/measunit.cpp
index 2486ca9b15a05e..ece83177625513 100644
--- a/deps/icu-small/source/i18n/measunit.cpp
+++ b/deps/icu-small/source/i18n/measunit.cpp
@@ -34,8 +34,9 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit)
// http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
//
// Start generated code
+// TODO(ICU-21076): improve how this generated code is produced.
-
+// Maps from Type ID to offset in gSubTypes.
static const int32_t gOffsets[] = {
0,
2,
@@ -50,45 +51,49 @@ static const int32_t gOffsets[] = {
368,
370,
374,
- 381,
- 402,
+ 382,
404,
- 418,
- 421,
- 427,
- 437,
- 441,
- 445,
- 447,
- 474
+ 408,
+ 423,
+ 426,
+ 432,
+ 442,
+ 446,
+ 450,
+ 452,
+ 486
};
-static const int32_t gIndexes[] = {
- 0,
- 2,
- 7,
- 17,
- 25,
- 29,
- 29,
- 40,
- 56,
- 60,
- 69,
- 71,
- 75,
- 82,
- 103,
- 105,
- 119,
- 122,
- 128,
- 138,
- 142,
- 146,
- 148,
- 175
-};
+// TODO: FIX CODE GENERATION - leaving this here but commented-out to make it
+// clear that we no longer want this array. We needed it for only one thing: efficient checking of "currency".
+//
+// static const int32_t gIndexes[] = {
+// 0,
+// 2,
+// 7,
+// 17,
+// 25,
+// 29,
+// 29,
+// 40,
+// 56,
+// 60,
+// 69,
+// 71,
+// 75,
+// 83,
+// 105,
+// 109,
+// 124,
+// 127,
+// 133,
+// 143,
+// 147,
+// 151,
+// 153,
+// 187
+// };
+static const int32_t kCurrencyOffset = 5;
// Must be sorted alphabetically.
static const char * const gTypes[] = {
@@ -493,6 +498,7 @@ static const char * const gSubTypes[] = {
"hertz",
"kilohertz",
"megahertz",
+ "dot",
"dot-per-centimeter",
"dot-per-inch",
"em",
@@ -503,6 +509,7 @@ static const char * const gSubTypes[] = {
"astronomical-unit",
"centimeter",
"decimeter",
+ "earth-radius",
"fathom",
"foot",
"furlong",
@@ -521,11 +528,14 @@ static const char * const gSubTypes[] = {
"point",
"solar-radius",
"yard",
+ "candela",
+ "lumen",
"lux",
"solar-luminosity",
"carat",
"dalton",
"earth-mass",
+ "grain",
"gram",
"kilogram",
"metric-ton",
@@ -580,34 +590,29 @@ static const char * const gSubTypes[] = {
"cup",
"cup-metric",
"deciliter",
+ "dessert-spoon",
+ "dessert-spoon-imperial",
+ "dram",
+ "drop",
"fluid-ounce",
"fluid-ounce-imperial",
"gallon",
"gallon-imperial",
"hectoliter",
+ "jigger",
"liter",
"megaliter",
"milliliter",
+ "pinch",
"pint",
"pint-metric",
"quart",
+ "quart-imperial",
"tablespoon",
"teaspoon"
};
-// Must be sorted by first value and then second value.
-static int32_t unitPerUnitToSingleUnit[][4] = {
- {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}
-};
+// unitPerUnitToSingleUnit no longer in use! TODO: remove from code-generation code.
// Shortcuts to the base unit in order to make the default constructor fast
static const int32_t kBaseTypeIdx = 16;
@@ -781,14 +786,6 @@ MeasureUnit MeasureUnit::getMole() {
return MeasureUnit(3, 3);
}
-MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
- return MeasureUnit::create(3, 6, status);
-}
-
-MeasureUnit MeasureUnit::getPartPerMillion() {
- return MeasureUnit(3, 6);
-}
-
MeasureUnit *MeasureUnit::createPercent(UErrorCode &status) {
return MeasureUnit::create(3, 4, status);
}
@@ -805,6 +802,14 @@ MeasureUnit MeasureUnit::getPermille() {
return MeasureUnit(3, 5);
}
+MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
+ return MeasureUnit::create(3, 6, status);
+}
+
+MeasureUnit MeasureUnit::getPartPerMillion() {
+ return MeasureUnit(3, 6);
+}
+
MeasureUnit *MeasureUnit::createPermyriad(UErrorCode &status) {
return MeasureUnit::create(3, 7, status);
}
@@ -1213,62 +1218,70 @@ MeasureUnit MeasureUnit::getMegahertz() {
return MeasureUnit(11, 3);
}
-MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDot(UErrorCode &status) {
return MeasureUnit::create(12, 0, status);
}
-MeasureUnit MeasureUnit::getDotPerCentimeter() {
+MeasureUnit MeasureUnit::getDot() {
return MeasureUnit(12, 0);
}
-MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) {
return MeasureUnit::create(12, 1, status);
}
-MeasureUnit MeasureUnit::getDotPerInch() {
+MeasureUnit MeasureUnit::getDotPerCentimeter() {
return MeasureUnit(12, 1);
}
-MeasureUnit *MeasureUnit::createEm(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) {
return MeasureUnit::create(12, 2, status);
}
-MeasureUnit MeasureUnit::getEm() {
+MeasureUnit MeasureUnit::getDotPerInch() {
return MeasureUnit(12, 2);
}
-MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createEm(UErrorCode &status) {
return MeasureUnit::create(12, 3, status);
}
-MeasureUnit MeasureUnit::getMegapixel() {
+MeasureUnit MeasureUnit::getEm() {
return MeasureUnit(12, 3);
}
-MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) {
return MeasureUnit::create(12, 4, status);
}
-MeasureUnit MeasureUnit::getPixel() {
+MeasureUnit MeasureUnit::getMegapixel() {
return MeasureUnit(12, 4);
}
-MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) {
return MeasureUnit::create(12, 5, status);
}
-MeasureUnit MeasureUnit::getPixelPerCentimeter() {
+MeasureUnit MeasureUnit::getPixel() {
return MeasureUnit(12, 5);
}
-MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) {
return MeasureUnit::create(12, 6, status);
}
-MeasureUnit MeasureUnit::getPixelPerInch() {
+MeasureUnit MeasureUnit::getPixelPerCentimeter() {
return MeasureUnit(12, 6);
}
+MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) {
+ return MeasureUnit::create(12, 7, status);
+}
+
+MeasureUnit MeasureUnit::getPixelPerInch() {
+ return MeasureUnit(12, 7);
+}
+
MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) {
return MeasureUnit::create(13, 0, status);
}
@@ -1293,166 +1306,190 @@ MeasureUnit MeasureUnit::getDecimeter() {
return MeasureUnit(13, 2);
}
-MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createEarthRadius(UErrorCode &status) {
return MeasureUnit::create(13, 3, status);
}
-MeasureUnit MeasureUnit::getFathom() {
+MeasureUnit MeasureUnit::getEarthRadius() {
return MeasureUnit(13, 3);
}
-MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
return MeasureUnit::create(13, 4, status);
}
-MeasureUnit MeasureUnit::getFoot() {
+MeasureUnit MeasureUnit::getFathom() {
return MeasureUnit(13, 4);
}
-MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
return MeasureUnit::create(13, 5, status);
}
-MeasureUnit MeasureUnit::getFurlong() {
+MeasureUnit MeasureUnit::getFoot() {
return MeasureUnit(13, 5);
}
-MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
return MeasureUnit::create(13, 6, status);
}
-MeasureUnit MeasureUnit::getInch() {
+MeasureUnit MeasureUnit::getFurlong() {
return MeasureUnit(13, 6);
}
-MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
return MeasureUnit::create(13, 7, status);
}
-MeasureUnit MeasureUnit::getKilometer() {
+MeasureUnit MeasureUnit::getInch() {
return MeasureUnit(13, 7);
}
-MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
return MeasureUnit::create(13, 8, status);
}
-MeasureUnit MeasureUnit::getLightYear() {
+MeasureUnit MeasureUnit::getKilometer() {
return MeasureUnit(13, 8);
}
-MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
return MeasureUnit::create(13, 9, status);
}
-MeasureUnit MeasureUnit::getMeter() {
+MeasureUnit MeasureUnit::getLightYear() {
return MeasureUnit(13, 9);
}
-MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
return MeasureUnit::create(13, 10, status);
}
-MeasureUnit MeasureUnit::getMicrometer() {
+MeasureUnit MeasureUnit::getMeter() {
return MeasureUnit(13, 10);
}
-MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
return MeasureUnit::create(13, 11, status);
}
-MeasureUnit MeasureUnit::getMile() {
+MeasureUnit MeasureUnit::getMicrometer() {
return MeasureUnit(13, 11);
}
-MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
return MeasureUnit::create(13, 12, status);
}
-MeasureUnit MeasureUnit::getMileScandinavian() {
+MeasureUnit MeasureUnit::getMile() {
return MeasureUnit(13, 12);
}
-MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
return MeasureUnit::create(13, 13, status);
}
-MeasureUnit MeasureUnit::getMillimeter() {
+MeasureUnit MeasureUnit::getMileScandinavian() {
return MeasureUnit(13, 13);
}
-MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
return MeasureUnit::create(13, 14, status);
}
-MeasureUnit MeasureUnit::getNanometer() {
+MeasureUnit MeasureUnit::getMillimeter() {
return MeasureUnit(13, 14);
}
-MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
return MeasureUnit::create(13, 15, status);
}
-MeasureUnit MeasureUnit::getNauticalMile() {
+MeasureUnit MeasureUnit::getNanometer() {
return MeasureUnit(13, 15);
}
-MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
return MeasureUnit::create(13, 16, status);
}
-MeasureUnit MeasureUnit::getParsec() {
+MeasureUnit MeasureUnit::getNauticalMile() {
return MeasureUnit(13, 16);
}
-MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
return MeasureUnit::create(13, 17, status);
}
-MeasureUnit MeasureUnit::getPicometer() {
+MeasureUnit MeasureUnit::getParsec() {
return MeasureUnit(13, 17);
}
-MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
return MeasureUnit::create(13, 18, status);
}
-MeasureUnit MeasureUnit::getPoint() {
+MeasureUnit MeasureUnit::getPicometer() {
return MeasureUnit(13, 18);
}
-MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
return MeasureUnit::create(13, 19, status);
}
-MeasureUnit MeasureUnit::getSolarRadius() {
+MeasureUnit MeasureUnit::getPoint() {
return MeasureUnit(13, 19);
}
-MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
return MeasureUnit::create(13, 20, status);
}
-MeasureUnit MeasureUnit::getYard() {
+MeasureUnit MeasureUnit::getSolarRadius() {
return MeasureUnit(13, 20);
}
-MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
+ return MeasureUnit::create(13, 21, status);
+}
+
+MeasureUnit MeasureUnit::getYard() {
+ return MeasureUnit(13, 21);
+}
+
+MeasureUnit *MeasureUnit::createCandela(UErrorCode &status) {
return MeasureUnit::create(14, 0, status);
}
-MeasureUnit MeasureUnit::getLux() {
+MeasureUnit MeasureUnit::getCandela() {
return MeasureUnit(14, 0);
}
-MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLumen(UErrorCode &status) {
return MeasureUnit::create(14, 1, status);
}
-MeasureUnit MeasureUnit::getSolarLuminosity() {
+MeasureUnit MeasureUnit::getLumen() {
return MeasureUnit(14, 1);
}
+MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
+ return MeasureUnit::create(14, 2, status);
+}
+
+MeasureUnit MeasureUnit::getLux() {
+ return MeasureUnit(14, 2);
+}
+
+MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
+ return MeasureUnit::create(14, 3, status);
+}
+
+MeasureUnit MeasureUnit::getSolarLuminosity() {
+ return MeasureUnit(14, 3);
+}
+
MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) {
return MeasureUnit::create(15, 0, status);
}
@@ -1477,94 +1514,102 @@ MeasureUnit MeasureUnit::getEarthMass() {
return MeasureUnit(15, 2);
}
-MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGrain(UErrorCode &status) {
return MeasureUnit::create(15, 3, status);
}
-MeasureUnit MeasureUnit::getGram() {
+MeasureUnit MeasureUnit::getGrain() {
return MeasureUnit(15, 3);
}
-MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
return MeasureUnit::create(15, 4, status);
}
-MeasureUnit MeasureUnit::getKilogram() {
+MeasureUnit MeasureUnit::getGram() {
return MeasureUnit(15, 4);
}
-MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
return MeasureUnit::create(15, 5, status);
}
-MeasureUnit MeasureUnit::getMetricTon() {
+MeasureUnit MeasureUnit::getKilogram() {
return MeasureUnit(15, 5);
}
-MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
return MeasureUnit::create(15, 6, status);
}
-MeasureUnit MeasureUnit::getMicrogram() {
+MeasureUnit MeasureUnit::getMetricTon() {
return MeasureUnit(15, 6);
}
-MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
return MeasureUnit::create(15, 7, status);
}
-MeasureUnit MeasureUnit::getMilligram() {
+MeasureUnit MeasureUnit::getMicrogram() {
return MeasureUnit(15, 7);
}
-MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
return MeasureUnit::create(15, 8, status);
}
-MeasureUnit MeasureUnit::getOunce() {
+MeasureUnit MeasureUnit::getMilligram() {
return MeasureUnit(15, 8);
}
-MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
return MeasureUnit::create(15, 9, status);
}
-MeasureUnit MeasureUnit::getOunceTroy() {
+MeasureUnit MeasureUnit::getOunce() {
return MeasureUnit(15, 9);
}
-MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
return MeasureUnit::create(15, 10, status);
}
-MeasureUnit MeasureUnit::getPound() {
+MeasureUnit MeasureUnit::getOunceTroy() {
return MeasureUnit(15, 10);
}
-MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
return MeasureUnit::create(15, 11, status);
}
-MeasureUnit MeasureUnit::getSolarMass() {
+MeasureUnit MeasureUnit::getPound() {
return MeasureUnit(15, 11);
}
-MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
return MeasureUnit::create(15, 12, status);
}
-MeasureUnit MeasureUnit::getStone() {
+MeasureUnit MeasureUnit::getSolarMass() {
return MeasureUnit(15, 12);
}
-MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
return MeasureUnit::create(15, 13, status);
}
-MeasureUnit MeasureUnit::getTon() {
+MeasureUnit MeasureUnit::getStone() {
return MeasureUnit(15, 13);
}
+MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
+ return MeasureUnit::create(15, 14, status);
+}
+
+MeasureUnit MeasureUnit::getTon() {
+ return MeasureUnit(15, 14);
+}
+
MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) {
return MeasureUnit::create(17, 0, status);
}
@@ -1885,110 +1930,166 @@ MeasureUnit MeasureUnit::getDeciliter() {
return MeasureUnit(22, 13);
}
-MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDessertSpoon(UErrorCode &status) {
return MeasureUnit::create(22, 14, status);
}
-MeasureUnit MeasureUnit::getFluidOunce() {
+MeasureUnit MeasureUnit::getDessertSpoon() {
return MeasureUnit(22, 14);
}
-MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDessertSpoonImperial(UErrorCode &status) {
return MeasureUnit::create(22, 15, status);
}
-MeasureUnit MeasureUnit::getFluidOunceImperial() {
+MeasureUnit MeasureUnit::getDessertSpoonImperial() {
return MeasureUnit(22, 15);
}
-MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDram(UErrorCode &status) {
return MeasureUnit::create(22, 16, status);
}
-MeasureUnit MeasureUnit::getGallon() {
+MeasureUnit MeasureUnit::getDram() {
return MeasureUnit(22, 16);
}
-MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDrop(UErrorCode &status) {
return MeasureUnit::create(22, 17, status);
}
-MeasureUnit MeasureUnit::getGallonImperial() {
+MeasureUnit MeasureUnit::getDrop() {
return MeasureUnit(22, 17);
}
-MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
return MeasureUnit::create(22, 18, status);
}
-MeasureUnit MeasureUnit::getHectoliter() {
+MeasureUnit MeasureUnit::getFluidOunce() {
return MeasureUnit(22, 18);
}
-MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
return MeasureUnit::create(22, 19, status);
}
-MeasureUnit MeasureUnit::getLiter() {
+MeasureUnit MeasureUnit::getFluidOunceImperial() {
return MeasureUnit(22, 19);
}
-MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
return MeasureUnit::create(22, 20, status);
}
-MeasureUnit MeasureUnit::getMegaliter() {
+MeasureUnit MeasureUnit::getGallon() {
return MeasureUnit(22, 20);
}
-MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
return MeasureUnit::create(22, 21, status);
}
-MeasureUnit MeasureUnit::getMilliliter() {
+MeasureUnit MeasureUnit::getGallonImperial() {
return MeasureUnit(22, 21);
}
-MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
return MeasureUnit::create(22, 22, status);
}
-MeasureUnit MeasureUnit::getPint() {
+MeasureUnit MeasureUnit::getHectoliter() {
return MeasureUnit(22, 22);
}
-MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createJigger(UErrorCode &status) {
return MeasureUnit::create(22, 23, status);
}
-MeasureUnit MeasureUnit::getPintMetric() {
+MeasureUnit MeasureUnit::getJigger() {
return MeasureUnit(22, 23);
}
-MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
return MeasureUnit::create(22, 24, status);
}
-MeasureUnit MeasureUnit::getQuart() {
+MeasureUnit MeasureUnit::getLiter() {
return MeasureUnit(22, 24);
}
-MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
return MeasureUnit::create(22, 25, status);
}
-MeasureUnit MeasureUnit::getTablespoon() {
+MeasureUnit MeasureUnit::getMegaliter() {
return MeasureUnit(22, 25);
}
-MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
return MeasureUnit::create(22, 26, status);
}
-MeasureUnit MeasureUnit::getTeaspoon() {
+MeasureUnit MeasureUnit::getMilliliter() {
return MeasureUnit(22, 26);
}
+MeasureUnit *MeasureUnit::createPinch(UErrorCode &status) {
+ return MeasureUnit::create(22, 27, status);
+}
+
+MeasureUnit MeasureUnit::getPinch() {
+ return MeasureUnit(22, 27);
+}
+
+MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
+ return MeasureUnit::create(22, 28, status);
+}
+
+MeasureUnit MeasureUnit::getPint() {
+ return MeasureUnit(22, 28);
+}
+
+MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
+ return MeasureUnit::create(22, 29, status);
+}
+
+MeasureUnit MeasureUnit::getPintMetric() {
+ return MeasureUnit(22, 29);
+}
+
+MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
+ return MeasureUnit::create(22, 30, status);
+}
+
+MeasureUnit MeasureUnit::getQuart() {
+ return MeasureUnit(22, 30);
+}
+
+MeasureUnit *MeasureUnit::createQuartImperial(UErrorCode &status) {
+ return MeasureUnit::create(22, 31, status);
+}
+
+MeasureUnit MeasureUnit::getQuartImperial() {
+ return MeasureUnit(22, 31);
+}
+
+MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
+ return MeasureUnit::create(22, 32, status);
+}
+
+MeasureUnit MeasureUnit::getTablespoon() {
+ return MeasureUnit(22, 32);
+}
+
+MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
+ return MeasureUnit::create(22, 33, status);
+}
+
+MeasureUnit MeasureUnit::getTeaspoon() {
+ return MeasureUnit(22, 33);
+}
+
// End generated code
static int32_t binarySearch(
@@ -2038,7 +2139,9 @@ MeasureUnit &MeasureUnit::operator=(const MeasureUnit &other) {
if (this == &other) {
return *this;
}
- delete fImpl;
+ if (fImpl != nullptr) {
+ delete fImpl;
+ }
if (other.fImpl) {
ErrorCode localStatus;
fImpl = new MeasureUnitImpl(other.fImpl->copy(localStatus));
@@ -2059,7 +2162,9 @@ MeasureUnit &MeasureUnit::operator=(MeasureUnit &&other) noexcept {
if (this == &other) {
return *this;
}
- delete fImpl;
+ if (fImpl != nullptr) {
+ delete fImpl;
+ }
fImpl = other.fImpl;
other.fImpl = nullptr;
fTypeId = other.fTypeId;
@@ -2072,8 +2177,10 @@ MeasureUnit *MeasureUnit::clone() const {
}
MeasureUnit::~MeasureUnit() {
- delete fImpl;
- fImpl = nullptr;
+ if (fImpl != nullptr) {
+ delete fImpl;
+ fImpl = nullptr;
+ }
}
const char *MeasureUnit::getType() const {
@@ -2107,10 +2214,6 @@ UBool MeasureUnit::operator==(const UObject& other) const {
return uprv_strcmp(getIdentifier(), rhs.getIdentifier()) == 0;
}
-int32_t MeasureUnit::getIndex() const {
- return gIndexes[fTypeId] + fSubTypeId;
-}
-
int32_t MeasureUnit::getAvailable(
MeasureUnit *dest,
int32_t destCapacity,
@@ -2173,26 +2276,12 @@ StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
return result;
}
-int32_t MeasureUnit::getIndexCount() {
- return gIndexes[UPRV_LENGTHOF(gIndexes) - 1];
-}
-
-int32_t MeasureUnit::internalGetIndexForTypeAndSubtype(const char *type, const char *subtype) {
- int32_t t = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), type);
- if (t < 0) {
- return t;
- }
- int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subtype);
- if (st < 0) {
- return st;
- }
- return gIndexes[t] + st - gOffsets[t];
-}
-
bool MeasureUnit::findBySubType(StringPiece subType, MeasureUnit* output) {
for (int32_t t = 0; t < UPRV_LENGTHOF(gOffsets) - 1; t++) {
+ // Ensure kCurrencyOffset is set correctly
+ U_ASSERT(uprv_strcmp(gTypes[kCurrencyOffset], "currency") == 0);
// Skip currency units
- if (gIndexes[t] == gIndexes[t + 1]) {
+ if (t == kCurrencyOffset) {
continue;
}
int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subType);
@@ -2204,41 +2293,6 @@ bool MeasureUnit::findBySubType(StringPiece subType, MeasureUnit* output) {
return false;
}
-MeasureUnit MeasureUnit::resolveUnitPerUnit(
- const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved) {
- int32_t unitOffset = unit.getOffset();
- int32_t perUnitOffset = perUnit.getOffset();
- if (unitOffset == -1 || perUnitOffset == -1) {
- *isResolved = false;
- return MeasureUnit();
- }
-
- // binary search for (unitOffset, perUnitOffset)
- int32_t start = 0;
- int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit);
- while (start < end) {
- int32_t mid = (start + end) / 2;
- int32_t *midRow = unitPerUnitToSingleUnit[mid];
- if (unitOffset < midRow[0]) {
- end = mid;
- } else if (unitOffset > midRow[0]) {
- start = mid + 1;
- } else if (perUnitOffset < midRow[1]) {
- end = mid;
- } else if (perUnitOffset > midRow[1]) {
- start = mid + 1;
- } else {
- // We found a resolution for our unit / per-unit combo
- // return it.
- *isResolved = true;
- return MeasureUnit(midRow[2], midRow[3]);
- }
- }
-
- *isResolved = false;
- return MeasureUnit();
-}
-
MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
if (U_FAILURE(status)) {
return NULL;
@@ -2279,20 +2333,13 @@ void MeasureUnit::initCurrency(StringPiece isoCurrency) {
fSubTypeId = result - gOffsets[fTypeId];
}
-void MeasureUnit::initNoUnit(const char *subtype) {
- int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "none");
- U_ASSERT(result != -1);
- fTypeId = result;
- result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], subtype);
- U_ASSERT(result != -1);
- fSubTypeId = result - gOffsets[fTypeId];
-}
-
void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
fTypeId = typeId;
fSubTypeId = subTypeId;
- delete fImpl;
- fImpl = nullptr;
+ if (fImpl != nullptr) {
+ delete fImpl;
+ fImpl = nullptr;
+ }
}
int32_t MeasureUnit::getOffset() const {
@@ -2302,6 +2349,20 @@ int32_t MeasureUnit::getOffset() const {
return gOffsets[fTypeId] + fSubTypeId;
}
+MeasureUnitImpl MeasureUnitImpl::copy(UErrorCode &status) const {
+ MeasureUnitImpl result;
+ result.complexity = complexity;
+ result.identifier.append(identifier, status);
+ for (int32_t i = 0; i < units.length(); i++) {
+ SingleUnitImpl *item = result.units.emplaceBack(*units[i]);
+ if (!item) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return result;
+ }
+ }
+ return result;
+}
+
U_NAMESPACE_END
#endif /* !UNCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/measunit_extra.cpp b/deps/icu-small/source/i18n/measunit_extra.cpp
index aeb60017a18fce..2eb3f066142967 100644
--- a/deps/icu-small/source/i18n/measunit_extra.cpp
+++ b/deps/icu-small/source/i18n/measunit_extra.cpp
@@ -12,20 +12,25 @@
// Helpful in toString methods and elsewhere.
#define UNISTR_FROM_STRING_EXPLICIT
-#include
+#include "charstr.h"
+#include "cmemory.h"
#include "cstring.h"
#include "measunit_impl.h"
+#include "resource.h"
#include "uarrsort.h"
#include "uassert.h"
#include "ucln_in.h"
#include "umutex.h"
-#include "unicode/errorcode.h"
+#include "unicode/bytestrie.h"
+#include "unicode/bytestriebuilder.h"
#include "unicode/localpointer.h"
#include "unicode/measunit.h"
-#include "unicode/ucharstrie.h"
-#include "unicode/ucharstriebuilder.h"
-
-#include "cstr.h"
+#include "unicode/stringpiece.h"
+#include "unicode/stringtriebuilder.h"
+#include "unicode/ures.h"
+#include "unicode/ustringtrie.h"
+#include "uresimp.h"
+#include
U_NAMESPACE_BEGIN
@@ -60,7 +65,7 @@ enum InitialCompoundPart {
INITIAL_COMPOUND_PART_PER = kInitialCompoundPartOffset,
};
-// Trie value offset for powers like "square-", "cubic-", "p2-" etc.
+// Trie value offset for powers like "square-", "cubic-", "pow2-" etc.
constexpr int32_t kPowerPartOffset = 256;
enum PowerPart {
@@ -110,119 +115,101 @@ const struct SIPrefixStrings {
{ "yocto", UMEASURE_SI_PREFIX_YOCTO },
};
-// TODO(ICU-21059): Get this list from data
-const char16_t* const gSimpleUnits[] = {
- u"candela",
- u"carat",
- u"gram",
- u"ounce",
- u"ounce-troy",
- u"pound",
- u"kilogram",
- u"stone",
- u"ton",
- u"metric-ton",
- u"earth-mass",
- u"solar-mass",
- u"point",
- u"inch",
- u"foot",
- u"yard",
- u"meter",
- u"fathom",
- u"furlong",
- u"mile",
- u"nautical-mile",
- u"mile-scandinavian",
- u"100-kilometer",
- u"earth-radius",
- u"solar-radius",
- u"astronomical-unit",
- u"light-year",
- u"parsec",
- u"second",
- u"minute",
- u"hour",
- u"day",
- u"day-person",
- u"week",
- u"week-person",
- u"month",
- u"month-person",
- u"year",
- u"year-person",
- u"decade",
- u"century",
- u"ampere",
- u"fahrenheit",
- u"kelvin",
- u"celsius",
- u"arc-second",
- u"arc-minute",
- u"degree",
- u"radian",
- u"revolution",
- u"item",
- u"mole",
- u"permillion",
- u"permyriad",
- u"permille",
- u"percent",
- u"karat",
- u"portion",
- u"bit",
- u"byte",
- u"dot",
- u"pixel",
- u"em",
- u"hertz",
- u"newton",
- u"pound-force",
- u"pascal",
- u"bar",
- u"atmosphere",
- u"ofhg",
- u"electronvolt",
- u"dalton",
- u"joule",
- u"calorie",
- u"british-thermal-unit",
- u"foodcalorie",
- u"therm-us",
- u"watt",
- u"horsepower",
- u"solar-luminosity",
- u"volt",
- u"ohm",
- u"dunam",
- u"acre",
- u"hectare",
- u"teaspoon",
- u"tablespoon",
- u"fluid-ounce-imperial",
- u"fluid-ounce",
- u"cup",
- u"cup-metric",
- u"pint",
- u"pint-metric",
- u"quart",
- u"liter",
- u"gallon",
- u"gallon-imperial",
- u"bushel",
- u"barrel",
- u"knot",
- u"g-force",
- u"lux",
+/**
+ * A ResourceSink that collects simple unit identifiers from the keys of the
+ * convertUnits table into an array, and adds these values to a TrieBuilder,
+ * with associated values being their index into this array plus a specified
+ * offset, to a trie.
+ *
+ * Example code:
+ *
+ * UErrorCode status = U_ZERO_ERROR;
+ * BytesTrieBuilder b(status);
+ * const char *unitIdentifiers[200];
+ * SimpleUnitIdentifiersSink identifierSink(unitIdentifiers, 200, b, kTrieValueOffset);
+ * LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ * ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status);
+ */
+class SimpleUnitIdentifiersSink : public icu::ResourceSink {
+ public:
+ /**
+ * Constructor.
+ * @param out Array of char* to which the simple unit identifiers will be
+ * saved.
+ * @param outSize The size of `out`.
+ * @param trieBuilder The trie builder to which the simple unit identifier
+ * should be added. The trie builder must outlive this resource sink.
+ * @param trieValueOffset This is added to the index of the identifier in
+ * the `out` array, before adding to `trieBuilder` as the value
+ * associated with the identifier.
+ */
+ explicit SimpleUnitIdentifiersSink(const char **out, int32_t outSize, BytesTrieBuilder &trieBuilder,
+ int32_t trieValueOffset)
+ : outArray(out), outSize(outSize), trieBuilder(trieBuilder), trieValueOffset(trieValueOffset),
+ outIndex(0) {
+ }
+
+ /**
+ * Adds the table keys found in value to the output vector.
+ * @param key The key of the resource passed to `value`: the second
+ * parameter of the ures_getAllItemsWithFallback() call.
+ * @param value Should be a ResourceTable value, if
+ * ures_getAllItemsWithFallback() was called correctly for this sink.
+ * @param noFallback Ignored.
+ * @param status The standard ICU error code output parameter.
+ */
+ void put(const char * /*key*/, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
+ ResourceTable table = value.getTable(status);
+ if (U_FAILURE(status)) return;
+
+ if (outIndex + table.getSize() > outSize) {
+ status = U_INDEX_OUTOFBOUNDS_ERROR;
+ return;
+ }
+
+ // Collect keys from the table resource.
+ const char *key;
+ for (int32_t i = 0; table.getKeyAndValue(i, key, value); ++i) {
+ U_ASSERT(i < table.getSize());
+ U_ASSERT(outIndex < outSize);
+ if (uprv_strcmp(key, "kilogram") == 0) {
+ // For parsing, we use "gram", the prefixless metric mass unit. We
+ // thus ignore the SI Base Unit of Mass: it exists due to being the
+ // mass conversion target unit, but not needed for MeasureUnit
+ // parsing.
+ continue;
+ }
+ outArray[outIndex] = key;
+ trieBuilder.add(key, trieValueOffset + outIndex, status);
+ outIndex++;
+ }
+ }
+
+ private:
+ const char **outArray;
+ int32_t outSize;
+ BytesTrieBuilder &trieBuilder;
+ int32_t trieValueOffset;
+
+ int32_t outIndex;
};
icu::UInitOnce gUnitExtrasInitOnce = U_INITONCE_INITIALIZER;
-char16_t* kSerializedUnitExtrasStemTrie = nullptr;
+// Array of simple unit IDs.
+//
+// The array memory itself is owned by this pointer, but the individual char* in
+// that array point at static memory. (Note that these char* are also returned
+// by SingleUnitImpl::getSimpleUnitID().)
+const char **gSimpleUnits = nullptr;
+
+char *gSerializedUnitExtrasStemTrie = nullptr;
UBool U_CALLCONV cleanupUnitExtras() {
- uprv_free(kSerializedUnitExtrasStemTrie);
- kSerializedUnitExtrasStemTrie = nullptr;
+ uprv_free(gSerializedUnitExtrasStemTrie);
+ gSerializedUnitExtrasStemTrie = nullptr;
+ uprv_free(gSimpleUnits);
+ gSimpleUnits = nullptr;
gUnitExtrasInitOnce.reset();
return TRUE;
}
@@ -230,55 +217,75 @@ UBool U_CALLCONV cleanupUnitExtras() {
void U_CALLCONV initUnitExtras(UErrorCode& status) {
ucln_i18n_registerCleanup(UCLN_I18N_UNIT_EXTRAS, cleanupUnitExtras);
- UCharsTrieBuilder b(status);
+ BytesTrieBuilder b(status);
if (U_FAILURE(status)) { return; }
// Add SI prefixes
for (const auto& siPrefixInfo : gSIPrefixStrings) {
- UnicodeString uSIPrefix(siPrefixInfo.string, -1, US_INV);
- b.add(uSIPrefix, siPrefixInfo.value + kSIPrefixOffset, status);
+ b.add(siPrefixInfo.string, siPrefixInfo.value + kSIPrefixOffset, status);
}
if (U_FAILURE(status)) { return; }
// Add syntax parts (compound, power prefixes)
- b.add(u"-per-", COMPOUND_PART_PER, status);
- b.add(u"-", COMPOUND_PART_TIMES, status);
- b.add(u"-and-", COMPOUND_PART_AND, status);
- b.add(u"per-", INITIAL_COMPOUND_PART_PER, status);
- b.add(u"square-", POWER_PART_P2, status);
- b.add(u"cubic-", POWER_PART_P3, status);
- b.add(u"p2-", POWER_PART_P2, status);
- b.add(u"p3-", POWER_PART_P3, status);
- b.add(u"p4-", POWER_PART_P4, status);
- b.add(u"p5-", POWER_PART_P5, status);
- b.add(u"p6-", POWER_PART_P6, status);
- b.add(u"p7-", POWER_PART_P7, status);
- b.add(u"p8-", POWER_PART_P8, status);
- b.add(u"p9-", POWER_PART_P9, status);
- b.add(u"p10-", POWER_PART_P10, status);
- b.add(u"p11-", POWER_PART_P11, status);
- b.add(u"p12-", POWER_PART_P12, status);
- b.add(u"p13-", POWER_PART_P13, status);
- b.add(u"p14-", POWER_PART_P14, status);
- b.add(u"p15-", POWER_PART_P15, status);
+ b.add("-per-", COMPOUND_PART_PER, status);
+ b.add("-", COMPOUND_PART_TIMES, status);
+ b.add("-and-", COMPOUND_PART_AND, status);
+ b.add("per-", INITIAL_COMPOUND_PART_PER, status);
+ b.add("square-", POWER_PART_P2, status);
+ b.add("cubic-", POWER_PART_P3, status);
+ b.add("pow2-", POWER_PART_P2, status);
+ b.add("pow3-", POWER_PART_P3, status);
+ b.add("pow4-", POWER_PART_P4, status);
+ b.add("pow5-", POWER_PART_P5, status);
+ b.add("pow6-", POWER_PART_P6, status);
+ b.add("pow7-", POWER_PART_P7, status);
+ b.add("pow8-", POWER_PART_P8, status);
+ b.add("pow9-", POWER_PART_P9, status);
+ b.add("pow10-", POWER_PART_P10, status);
+ b.add("pow11-", POWER_PART_P11, status);
+ b.add("pow12-", POWER_PART_P12, status);
+ b.add("pow13-", POWER_PART_P13, status);
+ b.add("pow14-", POWER_PART_P14, status);
+ b.add("pow15-", POWER_PART_P15, status);
+ if (U_FAILURE(status)) { return; }
+
+ // Add sanctioned simple units by offset: simple units all have entries in
+ // units/convertUnits resources.
+ // TODO(ICU-21059): confirm whether this is clean enough, or whether we need to
+ // filter units' validity list instead.
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ LocalUResourceBundlePointer convertUnits(
+ ures_getByKey(unitsBundle.getAlias(), "convertUnits", NULL, &status));
if (U_FAILURE(status)) { return; }
- // Add sanctioned simple units by offset
- int32_t simpleUnitOffset = kSimpleUnitOffset;
- for (auto simpleUnit : gSimpleUnits) {
- b.add(simpleUnit, simpleUnitOffset++, status);
+ // Allocate enough space: with identifierSink below skipping kilogram, we're
+ // probably allocating one more than needed.
+ int32_t simpleUnitsCount = convertUnits.getAlias()->fSize;
+ int32_t arrayMallocSize = sizeof(char *) * simpleUnitsCount;
+ gSimpleUnits = static_cast(uprv_malloc(arrayMallocSize));
+ if (gSimpleUnits == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
}
+ uprv_memset(gSimpleUnits, 0, arrayMallocSize);
+
+ // Populate gSimpleUnits and build the associated trie.
+ SimpleUnitIdentifiersSink identifierSink(gSimpleUnits, simpleUnitsCount, b, kSimpleUnitOffset);
+ ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status);
// Build the CharsTrie
// TODO: Use SLOW or FAST here?
- UnicodeString result;
- b.buildUnicodeString(USTRINGTRIE_BUILD_FAST, result, status);
+ StringPiece result = b.buildStringPiece(USTRINGTRIE_BUILD_FAST, status);
if (U_FAILURE(status)) { return; }
// Copy the result into the global constant pointer
- size_t numBytes = result.length() * sizeof(char16_t);
- kSerializedUnitExtrasStemTrie = static_cast(uprv_malloc(numBytes));
- uprv_memcpy(kSerializedUnitExtrasStemTrie, result.getBuffer(), numBytes);
+ size_t numBytes = result.length();
+ gSerializedUnitExtrasStemTrie = static_cast(uprv_malloc(numBytes));
+ if (gSerializedUnitExtrasStemTrie == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ uprv_memcpy(gSerializedUnitExtrasStemTrie, result.data(), numBytes);
}
class Token {
@@ -385,7 +392,7 @@ class Parser {
// should live longer than this Parser - and the parser shouldn't return any
// references to that string.
StringPiece fSource;
- UCharsTrie fTrie;
+ BytesTrie fTrie;
// Set to true when we've seen a "-per-" or a "per-", after which all units
// are in the denominator. Until we find an "-and-", at which point the
@@ -395,7 +402,7 @@ class Parser {
Parser() : fSource(""), fTrie(u"") {}
Parser(StringPiece source)
- : fSource(source), fTrie(kSerializedUnitExtrasStemTrie) {}
+ : fSource(source), fTrie(gSerializedUnitExtrasStemTrie) {}
inline bool hasNext() const {
return fIndex < fSource.length();
@@ -640,11 +647,11 @@ void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& o
} else if (posPower == 3) {
output.append("cubic-", status);
} else if (posPower < 10) {
- output.append('p', status);
+ output.append("pow", status);
output.append(posPower + '0', status);
output.append('-', status);
} else if (posPower <= 15) {
- output.append("p1", status);
+ output.append("pow1", status);
output.append('0' + (posPower % 10), status);
output.append('-', status);
} else {
@@ -666,7 +673,7 @@ void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& o
return;
}
- output.appendInvariantChars(gSimpleUnits[singleUnit.index], status);
+ output.append(singleUnit.getSimpleUnitID(), status);
}
/**
@@ -777,6 +784,17 @@ MeasureUnit SingleUnitImpl::build(UErrorCode& status) const {
return std::move(temp).build(status);
}
+const char *SingleUnitImpl::getSimpleUnitID() const {
+ return gSimpleUnits[index];
+}
+
+MeasureUnitImpl::MeasureUnitImpl(const MeasureUnitImpl &other, UErrorCode &status) {
+ *this = other.copy(status);
+}
+
+MeasureUnitImpl::MeasureUnitImpl(const SingleUnitImpl &singleUnit, UErrorCode &status) {
+ this->append(singleUnit, status);
+}
MeasureUnitImpl MeasureUnitImpl::forIdentifier(StringPiece identifier, UErrorCode& status) {
return Parser::from(identifier, status).parse(status);
@@ -813,12 +831,26 @@ bool MeasureUnitImpl::append(const SingleUnitImpl& singleUnit, UErrorCode& statu
return appendImpl(*this, singleUnit, status);
}
+MaybeStackVector MeasureUnitImpl::extractIndividualUnits(UErrorCode &status) const {
+ MaybeStackVector result;
+
+ if (this->complexity != UMeasureUnitComplexity::UMEASURE_UNIT_MIXED) {
+ result.emplaceBackAndCheckErrorCode(status, *this, status);
+ return result;
+ }
+
+ for (int32_t i = 0; i < units.length(); i++) {
+ result.emplaceBackAndCheckErrorCode(status, *units[i], status);
+ }
+
+ return result;
+}
+
MeasureUnit MeasureUnitImpl::build(UErrorCode& status) && {
serialize(*this, status);
return MeasureUnit(std::move(*this));
}
-
MeasureUnit MeasureUnit::forIdentifier(StringPiece identifier, UErrorCode& status) {
return Parser::from(identifier, status).parse(status).build(status);
}
@@ -876,11 +908,15 @@ MeasureUnit MeasureUnit::product(const MeasureUnit& other, UErrorCode& status) c
return std::move(impl).build(status);
}
-LocalArray MeasureUnit::splitToSingleUnits(int32_t& outCount, UErrorCode& status) const {
+LocalArray MeasureUnit::splitToSingleUnitsImpl(int32_t& outCount, UErrorCode& status) const {
MeasureUnitImpl temp;
const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(*this, temp, status);
outCount = impl.units.length();
MeasureUnit* arr = new MeasureUnit[outCount];
+ if (arr == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return LocalArray();
+ }
for (int32_t i = 0; i < outCount; i++) {
arr[i] = impl.units[i]->build(status);
}
diff --git a/deps/icu-small/source/i18n/measunit_impl.h b/deps/icu-small/source/i18n/measunit_impl.h
index c886d3c29a38b2..1024cd65547ff1 100644
--- a/deps/icu-small/source/i18n/measunit_impl.h
+++ b/deps/icu-small/source/i18n/measunit_impl.h
@@ -22,7 +22,7 @@ static const char kDefaultCurrency8[] = "XXX";
/**
* A struct representing a single unit (optional SI prefix and dimensionality).
*/
-struct SingleUnitImpl : public UMemory {
+struct U_I18N_API SingleUnitImpl : public UMemory {
/**
* Gets a single unit from the MeasureUnit. If there are multiple single units, sets an error
* code and returns the base dimensionless unit. Parses if necessary.
@@ -32,6 +32,16 @@ struct SingleUnitImpl : public UMemory {
/** Transform this SingleUnitImpl into a MeasureUnit, simplifying if possible. */
MeasureUnit build(UErrorCode& status) const;
+ /**
+ * Returns the "simple unit ID", without SI or dimensionality prefix: this
+ * instance may represent a square-kilometer, but only "meter" will be
+ * returned.
+ *
+ * The returned pointer points at memory that exists for the duration of the
+ * program's running.
+ */
+ const char *getSimpleUnitID() const;
+
/**
* Compare this SingleUnitImpl to another SingleUnitImpl for the sake of
* sorting and coalescing.
@@ -110,12 +120,27 @@ struct SingleUnitImpl : public UMemory {
int32_t dimensionality = 1;
};
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray;
+template class U_I18N_API MemoryPool;
+template class U_I18N_API MaybeStackVector;
+#endif
/**
* Internal representation of measurement units. Capable of representing all complexities of units,
* including mixed and compound units.
*/
-struct MeasureUnitImpl : public UMemory {
+struct U_I18N_API MeasureUnitImpl : public UMemory {
+ MeasureUnitImpl() = default;
+ MeasureUnitImpl(MeasureUnitImpl &&other) = default;
+ MeasureUnitImpl(const MeasureUnitImpl &other, UErrorCode &status);
+ MeasureUnitImpl(const SingleUnitImpl &singleUnit, UErrorCode &status);
+
+ MeasureUnitImpl &operator=(MeasureUnitImpl &&other) noexcept = default;
+
/** Extract the MeasureUnitImpl from a MeasureUnit. */
static inline const MeasureUnitImpl* get(const MeasureUnit& measureUnit) {
return measureUnit.fImpl;
@@ -169,13 +194,17 @@ struct MeasureUnitImpl : public UMemory {
/**
* Create a copy of this MeasureUnitImpl. Don't use copy constructor to make this explicit.
*/
- inline MeasureUnitImpl copy(UErrorCode& status) const {
- MeasureUnitImpl result;
- result.complexity = complexity;
- result.units.appendAll(units, status);
- result.identifier.append(identifier, status);
- return result;
- }
+ MeasureUnitImpl copy(UErrorCode& status) const;
+
+ /**
+ * Extracts the list of all the individual units inside the `MeasureUnitImpl`.
+ * For example:
+ * - if the `MeasureUnitImpl` is `foot-per-hour`
+ * it will return a list of 1 {`foot-per-hour`}
+ * - if the `MeasureUnitImpl` is `foot-and-inch`
+ * it will return a list of 2 { `foot`, `inch`}
+ */
+ MaybeStackVector extractIndividualUnits(UErrorCode &status) const;
/** Mutates this MeasureUnitImpl to take the reciprocal. */
void takeReciprocal(UErrorCode& status);
@@ -206,7 +235,6 @@ struct MeasureUnitImpl : public UMemory {
CharString identifier;
};
-
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/measure.cpp b/deps/icu-small/source/i18n/measure.cpp
index bffa44215e3cde..23adba100707aa 100644
--- a/deps/icu-small/source/i18n/measure.cpp
+++ b/deps/icu-small/source/i18n/measure.cpp
@@ -23,7 +23,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Measure)
-Measure::Measure() {}
+Measure::Measure() : unit(nullptr) {}
Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
UErrorCode& ec) :
@@ -35,7 +35,7 @@ Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
}
Measure::Measure(const Measure& other) :
- UObject(other), unit(0) {
+ UObject(other), unit(nullptr) {
*this = other;
}
@@ -43,7 +43,11 @@ Measure& Measure::operator=(const Measure& other) {
if (this != &other) {
delete unit;
number = other.number;
- unit = other.unit->clone();
+ if (other.unit != nullptr) {
+ unit = other.unit->clone();
+ } else {
+ unit = nullptr;
+ }
}
return *this;
}
diff --git a/deps/icu-small/source/i18n/nfrs.cpp b/deps/icu-small/source/i18n/nfrs.cpp
index 659cfcbbf5a857..dd91d7833db111 100644
--- a/deps/icu-small/source/i18n/nfrs.cpp
+++ b/deps/icu-small/source/i18n/nfrs.cpp
@@ -37,7 +37,7 @@ enum {
/** 0.x */
PROPER_FRACTION_RULE_INDEX = 2,
/** x.0 */
- MASTER_RULE_INDEX = 3,
+ DEFAULT_RULE_INDEX = 3,
/** Inf */
INFINITY_RULE_INDEX = 4,
/** NaN */
@@ -278,8 +278,8 @@ void NFRuleSet::setNonNumericalRule(NFRule *rule) {
else if (baseValue == NFRule::kProperFractionRule) {
setBestFractionRule(PROPER_FRACTION_RULE_INDEX, rule, TRUE);
}
- else if (baseValue == NFRule::kMasterRule) {
- setBestFractionRule(MASTER_RULE_INDEX, rule, TRUE);
+ else if (baseValue == NFRule::kDefaultRule) {
+ setBestFractionRule(DEFAULT_RULE_INDEX, rule, TRUE);
}
else if (baseValue == NFRule::kInfinityRule) {
delete nonNumericalRules[INFINITY_RULE_INDEX];
@@ -323,7 +323,7 @@ NFRuleSet::~NFRuleSet()
for (int i = 0; i < NON_NUMERICAL_RULE_LENGTH; i++) {
if (i != IMPROPER_FRACTION_RULE_INDEX
&& i != PROPER_FRACTION_RULE_INDEX
- && i != MASTER_RULE_INDEX)
+ && i != DEFAULT_RULE_INDEX)
{
delete nonNumericalRules[i];
}
@@ -375,7 +375,7 @@ NFRuleSet::setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErro
rules[i]->setDecimalFormatSymbols(newSymbols, status);
}
// Switch the fraction rules to mirror the DecimalFormatSymbols.
- for (int32_t nonNumericalIdx = IMPROPER_FRACTION_RULE_INDEX; nonNumericalIdx <= MASTER_RULE_INDEX; nonNumericalIdx++) {
+ for (int32_t nonNumericalIdx = IMPROPER_FRACTION_RULE_INDEX; nonNumericalIdx <= DEFAULT_RULE_INDEX; nonNumericalIdx++) {
if (nonNumericalRules[nonNumericalIdx]) {
for (uint32_t fIdx = 0; fIdx < fractionRules.size(); fIdx++) {
NFRule *fractionRule = fractionRules[fIdx];
@@ -472,9 +472,9 @@ NFRuleSet::findDoubleRule(double number) const
}
}
- // if there's a master rule, use it to format the number
- if (nonNumericalRules[MASTER_RULE_INDEX]) {
- return nonNumericalRules[MASTER_RULE_INDEX];
+ // if there's a default rule, use it to format the number
+ if (nonNumericalRules[DEFAULT_RULE_INDEX]) {
+ return nonNumericalRules[DEFAULT_RULE_INDEX];
}
// and if we haven't yet returned a rule, use findNormalRule()
@@ -507,13 +507,13 @@ NFRuleSet::findNormalRule(int64_t number) const
// do them in findRule(), because the version of format() that
// takes a long bypasses findRule() and goes straight to this
// function. This function does skip the fraction rules since
- // we know the value is an integer (it also skips the master
+ // we know the value is an integer (it also skips the default
// rule, since it's considered a fraction rule. Skipping the
- // master rule in this function is also how we avoid infinite
+ // default rule in this function is also how we avoid infinite
// recursion)
// {dlf} unfortunately this fails if there are no rules except
- // special rules. If there are no rules, use the master rule.
+ // special rules. If there are no rules, use the default rule.
// binary-search the rule list for the applicable rule
// (a rule is used for all values from its base value to
@@ -553,8 +553,8 @@ NFRuleSet::findNormalRule(int64_t number) const
}
return result;
}
- // else use the master rule
- return nonNumericalRules[MASTER_RULE_INDEX];
+ // else use the default rule
+ return nonNumericalRules[DEFAULT_RULE_INDEX];
}
/**
@@ -792,7 +792,7 @@ NFRuleSet::appendRules(UnicodeString& result) const
if (nonNumericalRules[i]) {
if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule)
+ || rule->getBaseValue() == NFRule::kDefaultRule)
{
for (uint32_t fIdx = 0; fIdx < fractionRules.size(); fIdx++) {
NFRule *fractionRule = fractionRules[fIdx];
diff --git a/deps/icu-small/source/i18n/nfrs.h b/deps/icu-small/source/i18n/nfrs.h
index c56fc0707851a7..e9b955ddff142d 100644
--- a/deps/icu-small/source/i18n/nfrs.h
+++ b/deps/icu-small/source/i18n/nfrs.h
@@ -36,7 +36,7 @@ class NFRuleSet : public UMemory {
void parseRules(UnicodeString& rules, UErrorCode& status);
void setNonNumericalRule(NFRule *rule);
void setBestFractionRule(int32_t originalIndex, NFRule *newRule, UBool rememberRule);
- void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; }
+ void makeIntoFractionRuleSet() { fIsFractionRuleSet = true; }
~NFRuleSet();
@@ -93,11 +93,11 @@ int64_t util64_fromDouble(double d);
uint64_t util64_pow(uint32_t radix, uint16_t exponent);
// convert n to digit string in buffer, return length of string
-uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
+uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
#ifdef RBNF_DEBUG
int64_t util64_utoi(const UChar* str, uint32_t radix = 10);
-uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
+uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
int64_t util64_atoi(const char* str, uint32_t radix);
#endif
diff --git a/deps/icu-small/source/i18n/nfrule.cpp b/deps/icu-small/source/i18n/nfrule.cpp
index b5e7892d5e68cb..cba41d14bb1fa8 100644
--- a/deps/icu-small/source/i18n/nfrule.cpp
+++ b/deps/icu-small/source/i18n/nfrule.cpp
@@ -153,7 +153,7 @@ NFRule::makeRules(UnicodeString& description,
if ((rule1->baseValue > 0
&& (rule1->baseValue % util64_pow(rule1->radix, rule1->exponent)) == 0)
|| rule1->getType() == kImproperFractionRule
- || rule1->getType() == kMasterRule) {
+ || rule1->getType() == kDefaultRule) {
// if it passes that test, new up the second rule. If the
// rule set both rules will belong to is a fraction rule
@@ -181,9 +181,9 @@ NFRule::makeRules(UnicodeString& description,
}
// if the description began with "x.0" and contains bracketed
- // text, it describes both the master rule and the
+ // text, it describes both the default rule and the
// improper fraction rule
- else if (rule1->getType() == kMasterRule) {
+ else if (rule1->getType() == kDefaultRule) {
rule2->baseValue = rule1->baseValue;
rule1->setType(kImproperFractionRule);
}
@@ -376,7 +376,7 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status)
decimalPoint = descriptor.charAt(1);
}
else if (firstChar == gX && lastChar == gZero) {
- setBaseValue(kMasterRule, status);
+ setBaseValue(kDefaultRule, status);
decimalPoint = descriptor.charAt(1);
}
else if (descriptor.compare(gNaN, 3) == 0) {
@@ -663,7 +663,7 @@ NFRule::_appendRuleText(UnicodeString& result) const
case kNegativeNumberRule: result.append(gMinusX, 2); break;
case kImproperFractionRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gX); break;
case kProperFractionRule: result.append(gZero).append(decimalPoint == 0 ? gDot : decimalPoint).append(gX); break;
- case kMasterRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gZero); break;
+ case kDefaultRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gZero); break;
case kInfinityRule: result.append(gInf, 3); break;
case kNaNRule: result.append(gNaN, 3); break;
default:
@@ -1297,6 +1297,10 @@ NFRule::prefixLength(const UnicodeString& str, const UnicodeString& prefix, UErr
#if !UCONFIG_NO_COLLATION
// go through all this grief if we're in lenient-parse mode
if (formatter->isLenient()) {
+ // Check if non-lenient rule finds the text before call lenient parsing
+ if (str.startsWith(prefix)) {
+ return prefix.length();
+ }
// get the formatter's collator and use it to create two
// collation element iterators, one over the target string
// and another over the prefix (right now, we'll throw an
@@ -1505,9 +1509,15 @@ NFRule::findText(const UnicodeString& str,
return str.indexOf(key, startingAt);
}
else {
- // but if lenient parsing is turned ON, we've got some work
- // ahead of us
- return findTextLenient(str, key, startingAt, length);
+ // Check if non-lenient rule finds the text before call lenient parsing
+ *length = key.length();
+ int32_t pos = str.indexOf(key, startingAt);
+ if(pos >= 0) {
+ return pos;
+ } else {
+ // but if lenient parsing is turned ON, we've got some work ahead of us
+ return findTextLenient(str, key, startingAt, length);
+ }
}
}
diff --git a/deps/icu-small/source/i18n/nfrule.h b/deps/icu-small/source/i18n/nfrule.h
index 2b030390ea7dcb..12431c0dba33e8 100644
--- a/deps/icu-small/source/i18n/nfrule.h
+++ b/deps/icu-small/source/i18n/nfrule.h
@@ -38,7 +38,7 @@ class NFRule : public UMemory {
kNegativeNumberRule = -1,
kImproperFractionRule = -2,
kProperFractionRule = -3,
- kMasterRule = -4,
+ kDefaultRule = -4,
kInfinityRule = -5,
kNaNRule = -6,
kOtherRule = -7
diff --git a/deps/icu-small/source/i18n/nfsubs.cpp b/deps/icu-small/source/i18n/nfsubs.cpp
index 3733f0ca74d3e3..e3ea3938835ea3 100644
--- a/deps/icu-small/source/i18n/nfsubs.cpp
+++ b/deps/icu-small/source/i18n/nfsubs.cpp
@@ -342,7 +342,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
// IntegralPartSubstitution
else if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule) {
+ || rule->getBaseValue() == NFRule::kDefaultRule) {
return new IntegralPartSubstitution(pos, ruleSet, description, status);
}
@@ -371,7 +371,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
// FractionalPartSubstitution
else if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule) {
+ || rule->getBaseValue() == NFRule::kDefaultRule) {
return new FractionalPartSubstitution(pos, ruleSet, description, status);
}
diff --git a/deps/icu-small/source/i18n/nounit.cpp b/deps/icu-small/source/i18n/nounit.cpp
deleted file mode 100644
index 1d4aa05506e98d..00000000000000
--- a/deps/icu-small/source/i18n/nounit.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// © 2017 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-#include "unicode/nounit.h"
-#include "uassert.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-U_NAMESPACE_BEGIN
-
-UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NoUnit)
-
-NoUnit U_EXPORT2 NoUnit::base() {
- return NoUnit("");
-}
-
-NoUnit U_EXPORT2 NoUnit::percent() {
- return NoUnit("percent");
-}
-
-NoUnit U_EXPORT2 NoUnit::permille() {
- return NoUnit("permille");
-}
-
-NoUnit::NoUnit(const char* subtype) {
- initNoUnit(subtype);
-}
-
-NoUnit::NoUnit(const NoUnit& other) : MeasureUnit(other) {
-}
-
-NoUnit* NoUnit::clone() const {
- return new NoUnit(*this);
-}
-
-NoUnit::~NoUnit() {
-}
-
-
-U_NAMESPACE_END
-
-#endif
diff --git a/deps/icu-small/source/i18n/number_asformat.h b/deps/icu-small/source/i18n/number_asformat.h
index 7b0a1dee6f438b..3a2fe3185bee1c 100644
--- a/deps/icu-small/source/i18n/number_asformat.h
+++ b/deps/icu-small/source/i18n/number_asformat.h
@@ -25,7 +25,6 @@ namespace impl {
* A wrapper around LocalizedNumberFormatter implementing the Format interface, enabling improved
* compatibility with other APIs.
*
- * @draft ICU 62
* @see NumberFormatter
*/
class U_I18N_API LocalizedNumberFormatterAsFormat : public Format {
diff --git a/deps/icu-small/source/i18n/number_capi.cpp b/deps/icu-small/source/i18n/number_capi.cpp
index d61440d081e9fb..ef5f0a41ff07a4 100644
--- a/deps/icu-small/source/i18n/number_capi.cpp
+++ b/deps/icu-small/source/i18n/number_capi.cpp
@@ -13,6 +13,7 @@
#include "number_utypes.h"
#include "numparse_types.h"
#include "formattedval_impl.h"
+#include "number_decnum.h"
#include "unicode/numberformatter.h"
#include "unicode/unumberformatter.h"
@@ -196,6 +197,23 @@ unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPosition
result->fData.getAllFieldPositions(fpih, *ec);
}
+U_CAPI int32_t U_EXPORT2
+unumf_resultToDecimalNumber(
+ const UFormattedNumber* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec) {
+ const auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return 0;
+ }
+ DecNum decnum;
+ return result->fData.quantity
+ .toDecNum(decnum, *ec)
+ .toCharString(*ec)
+ .extract(dest, destCapacity, *ec);
+}
+
U_CAPI void U_EXPORT2
unumf_close(UNumberFormatter* f) {
UErrorCode localStatus = U_ZERO_ERROR;
diff --git a/deps/icu-small/source/i18n/number_compact.cpp b/deps/icu-small/source/i18n/number_compact.cpp
index e1fef8feb52298..d781b6fada234c 100644
--- a/deps/icu-small/source/i18n/number_compact.cpp
+++ b/deps/icu-small/source/i18n/number_compact.cpp
@@ -167,6 +167,11 @@ void CompactData::CompactDataSink::put(const char *key, ResourceValue &value, UB
if (U_FAILURE(status)) { return; }
for (int i4 = 0; pluralVariantsTable.getKeyAndValue(i4, key, value); ++i4) {
+ if (uprv_strcmp(key, "0") == 0 || uprv_strcmp(key, "1") == 0) {
+ // TODO(ICU-21258): Handle this case. For now, skip.
+ continue;
+ }
+
// Skip this magnitude/plural if we already have it from a child locale.
// Note: This also skips USE_FALLBACK entries.
StandardPlural::Form plural = StandardPlural::fromString(key, status);
diff --git a/deps/icu-small/source/i18n/number_currencysymbols.cpp b/deps/icu-small/source/i18n/number_currencysymbols.cpp
index 4d6fb2cb1d8dec..9208427904cceb 100644
--- a/deps/icu-small/source/i18n/number_currencysymbols.cpp
+++ b/deps/icu-small/source/i18n/number_currencysymbols.cpp
@@ -44,6 +44,16 @@ UnicodeString CurrencySymbols::getNarrowCurrencySymbol(UErrorCode& status) const
return loadSymbol(UCURR_NARROW_SYMBOL_NAME, status);
}
+UnicodeString CurrencySymbols::getFormalCurrencySymbol(UErrorCode& status) const {
+ // Note: currently no override is available for formal currency symbol
+ return loadSymbol(UCURR_FORMAL_SYMBOL_NAME, status);
+}
+
+UnicodeString CurrencySymbols::getVariantCurrencySymbol(UErrorCode& status) const {
+ // Note: currently no override is available for variant currency symbol
+ return loadSymbol(UCURR_VARIANT_SYMBOL_NAME, status);
+}
+
UnicodeString CurrencySymbols::getCurrencySymbol(UErrorCode& status) const {
if (!fCurrencySymbol.isBogus()) {
return fCurrencySymbol;
diff --git a/deps/icu-small/source/i18n/number_currencysymbols.h b/deps/icu-small/source/i18n/number_currencysymbols.h
index 9996bf96ae08a1..7e38fdf8287e14 100644
--- a/deps/icu-small/source/i18n/number_currencysymbols.h
+++ b/deps/icu-small/source/i18n/number_currencysymbols.h
@@ -31,6 +31,10 @@ class U_I18N_API CurrencySymbols : public UMemory {
UnicodeString getNarrowCurrencySymbol(UErrorCode& status) const;
+ UnicodeString getFormalCurrencySymbol(UErrorCode& status) const;
+
+ UnicodeString getVariantCurrencySymbol(UErrorCode& status) const;
+
UnicodeString getCurrencySymbol(UErrorCode& status) const;
UnicodeString getIntlCurrencySymbol(UErrorCode& status) const;
diff --git a/deps/icu-small/source/i18n/number_decimalquantity.cpp b/deps/icu-small/source/i18n/number_decimalquantity.cpp
index 5ce9c27cbf4a76..75af5e9974fc65 100644
--- a/deps/icu-small/source/i18n/number_decimalquantity.cpp
+++ b/deps/icu-small/source/i18n/number_decimalquantity.cpp
@@ -20,6 +20,7 @@
#include "charstr.h"
#include "number_utils.h"
#include "uassert.h"
+#include "util.h"
using namespace icu;
using namespace icu::number;
@@ -626,7 +627,7 @@ double DecimalQuantity::toDouble() const {
&count);
}
-void DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
+DecNum& DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
// Special handling for zero
if (precision == 0) {
output.setTo("0", status);
@@ -634,11 +635,15 @@ void DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
// Use the BCD constructor. We need to do a little bit of work to convert, though.
// The decNumber constructor expects most-significant first, but we store least-significant first.
- MaybeStackArray ubcd(precision);
+ MaybeStackArray ubcd(precision, status);
+ if (U_FAILURE(status)) {
+ return output;
+ }
for (int32_t m = 0; m < precision; m++) {
ubcd[precision - m - 1] = static_cast(getDigitPos(m));
}
output.setTo(ubcd.getAlias(), precision, scale, isNegative(), status);
+ return output;
}
void DecimalQuantity::truncate() {
@@ -1004,13 +1009,8 @@ void DecimalQuantity::shiftLeft(int32_t numDigits) {
}
if (usingBytes) {
ensureCapacity(precision + numDigits);
- int i = precision + numDigits - 1;
- for (; i >= numDigits; i--) {
- fBCD.bcdBytes.ptr[i] = fBCD.bcdBytes.ptr[i - numDigits];
- }
- for (; i >= 0; i--) {
- fBCD.bcdBytes.ptr[i] = 0;
- }
+ uprv_memmove(fBCD.bcdBytes.ptr + numDigits, fBCD.bcdBytes.ptr, precision);
+ uprv_memset(fBCD.bcdBytes.ptr, 0, numDigits);
} else {
fBCD.bcdLong <<= (numDigits * 4);
}
@@ -1324,7 +1324,11 @@ bool DecimalQuantity::operator==(const DecimalQuantity& other) const {
}
UnicodeString DecimalQuantity::toString() const {
- MaybeStackArray digits(precision + 1);
+ UErrorCode localStatus = U_ZERO_ERROR;
+ MaybeStackArray digits(precision + 1, localStatus);
+ if (U_FAILURE(localStatus)) {
+ return ICU_Utility::makeBogusString();
+ }
for (int32_t i = 0; i < precision; i++) {
digits[i] = getDigitPos(precision - i - 1) + '0';
}
diff --git a/deps/icu-small/source/i18n/number_decimalquantity.h b/deps/icu-small/source/i18n/number_decimalquantity.h
index 53a9eb33b26caf..839424775a0d8d 100644
--- a/deps/icu-small/source/i18n/number_decimalquantity.h
+++ b/deps/icu-small/source/i18n/number_decimalquantity.h
@@ -20,7 +20,7 @@ namespace impl {
class DecNum;
/**
- * An class for representing a number to be processed by the decimal formatting pipeline. Includes
+ * A class for representing a number to be processed by the decimal formatting pipeline. Includes
* methods for rounding, plural rules, and decimal digit extraction.
*
* By design, this is NOT IMMUTABLE and NOT THREAD SAFE. It is intended to be an intermediate
@@ -209,7 +209,7 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
double toDouble() const;
/** Computes a DecNum representation of this DecimalQuantity, saving it to the output parameter. */
- void toDecNum(DecNum& output, UErrorCode& status) const;
+ DecNum& toDecNum(DecNum& output, UErrorCode& status) const;
DecimalQuantity &setToInt(int32_t n);
@@ -217,7 +217,13 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
DecimalQuantity &setToDouble(double n);
- /** decNumber is similar to BigDecimal in Java. */
+ /**
+ * Produces a DecimalQuantity that was parsed from a string by the decNumber
+ * C Library.
+ *
+ * decNumber is similar to BigDecimal in Java, and supports parsing strings
+ * such as "123.456621E+40".
+ */
DecimalQuantity &setToDecNumber(StringPiece n, UErrorCode& status);
/** Internal method if the caller already has a DecNum. */
diff --git a/deps/icu-small/source/i18n/number_decnum.h b/deps/icu-small/source/i18n/number_decnum.h
index 0c7399dbddd43b..3bb8d107807967 100644
--- a/deps/icu-small/source/i18n/number_decnum.h
+++ b/deps/icu-small/source/i18n/number_decnum.h
@@ -9,6 +9,7 @@
#include "decNumber.h"
#include "charstr.h"
+#include "bytesinkutil.h"
U_NAMESPACE_BEGIN
@@ -57,6 +58,13 @@ class U_I18N_API DecNum : public UMemory {
void toString(ByteSink& output, UErrorCode& status) const;
+ inline CharString toCharString(UErrorCode& status) const {
+ CharString cstr;
+ CharStringByteSink sink(&cstr);
+ toString(sink, status);
+ return cstr;
+ }
+
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 9cdb8b7156e614..8569a36e5b260b 100644
--- a/deps/icu-small/source/i18n/number_fluent.cpp
+++ b/deps/icu-small/source/i18n/number_fluent.cpp
@@ -13,6 +13,7 @@
#include "number_asformat.h"
#include "number_utils.h"
#include "number_utypes.h"
+#include "number_mapper.h"
#include "util.h"
#include "fphdlimp.h"
@@ -273,6 +274,20 @@ Derived NumberFormatterSettings::scale(const Scale& scale)&& {
return move;
}
+template
+Derived NumberFormatterSettings::usage(const StringPiece usage) const& {
+ Derived copy(*this);
+ copy.fMacros.usage.set(usage);
+ return copy;
+}
+
+template
+Derived NumberFormatterSettings::usage(const StringPiece usage)&& {
+ Derived move(std::move(*this));
+ move.fMacros.usage.set(usage);
+ return move;
+}
+
template
Derived NumberFormatterSettings::padding(const Padder& padder) const& {
Derived copy(*this);
@@ -400,7 +415,8 @@ LocalizedNumberFormatter::LocalizedNumberFormatter(const LNF& other)
LocalizedNumberFormatter::LocalizedNumberFormatter(const NFS& other)
: NFS(other) {
- // No additional fields to assign (let call count and compiled formatter reset to defaults)
+ UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error
+ lnfCopyHelper(static_cast(other), localStatus);
}
LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT
@@ -408,38 +424,25 @@ LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& sr
LocalizedNumberFormatter::LocalizedNumberFormatter(NFS&& src) U_NOEXCEPT
: NFS(std::move(src)) {
- // For the move operators, copy over the compiled formatter.
- // Note: if the formatter is not compiled, call count information is lost.
- if (static_cast(src).fCompiled != nullptr) {
- lnfMoveHelper(static_cast(src));
- }
+ lnfMoveHelper(std::move(static_cast(src)));
}
LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(const LNF& other) {
NFS::operator=(static_cast&>(other));
- // Reset to default values.
- clear();
+ UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error
+ lnfCopyHelper(other, localStatus);
return *this;
}
LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(LNF&& src) U_NOEXCEPT {
NFS::operator=(static_cast&&>(src));
- // For the move operators, copy over the compiled formatter.
- // Note: if the formatter is not compiled, call count information is lost.
- if (static_cast(src).fCompiled != nullptr) {
- // Formatter is compiled
- lnfMoveHelper(static_cast(src));
- } else {
- clear();
- }
+ lnfMoveHelper(std::move(src));
return *this;
}
-void LocalizedNumberFormatter::clear() {
- // Reset to default values.
+void LocalizedNumberFormatter::resetCompiled() {
auto* callCount = reinterpret_cast(fUnsafeCallCount);
umtx_storeRelease(*callCount, 0);
- delete fCompiled;
fCompiled = nullptr;
}
@@ -447,19 +450,56 @@ void LocalizedNumberFormatter::lnfMoveHelper(LNF&& src) {
// Copy over the compiled formatter and set call count to INT32_MIN as in computeCompiled().
// Don't copy the call count directly because doing so requires a loadAcquire/storeRelease.
// The bits themselves appear to be platform-dependent, so copying them might not be safe.
- auto* callCount = reinterpret_cast(fUnsafeCallCount);
- umtx_storeRelease(*callCount, INT32_MIN);
delete fCompiled;
- fCompiled = src.fCompiled;
- // Reset the source object to leave it in a safe state.
- auto* srcCallCount = reinterpret_cast(src.fUnsafeCallCount);
- umtx_storeRelease(*srcCallCount, 0);
- src.fCompiled = nullptr;
+ if (src.fCompiled != nullptr) {
+ auto* callCount = reinterpret_cast(fUnsafeCallCount);
+ umtx_storeRelease(*callCount, INT32_MIN);
+ fCompiled = src.fCompiled;
+ // Reset the source object to leave it in a safe state.
+ src.resetCompiled();
+ } else {
+ resetCompiled();
+ }
+
+ // Unconditionally move the warehouse
+ delete fWarehouse;
+ fWarehouse = src.fWarehouse;
+ src.fWarehouse = nullptr;
+}
+
+void LocalizedNumberFormatter::lnfCopyHelper(const LNF&, UErrorCode& status) {
+ // When copying, always reset the compiled formatter.
+ delete fCompiled;
+ resetCompiled();
+
+ // If MacroProps has a reference to AffixPatternProvider, we need to copy it.
+ // If MacroProps has a reference to PluralRules, copy that one, too.
+ delete fWarehouse;
+ if (fMacros.affixProvider || fMacros.rules) {
+ LocalPointer warehouse(new DecimalFormatWarehouse(), status);
+ if (U_FAILURE(status)) {
+ fWarehouse = nullptr;
+ return;
+ }
+ if (fMacros.affixProvider) {
+ warehouse->affixProvider.setTo(fMacros.affixProvider, status);
+ fMacros.affixProvider = &warehouse->affixProvider.get();
+ }
+ if (fMacros.rules) {
+ warehouse->rules.adoptInsteadAndCheckErrorCode(
+ new PluralRules(*fMacros.rules), status);
+ fMacros.rules = warehouse->rules.getAlias();
+ }
+ fWarehouse = warehouse.orphan();
+ } else {
+ fWarehouse = nullptr;
+ }
}
LocalizedNumberFormatter::~LocalizedNumberFormatter() {
delete fCompiled;
+ delete fWarehouse;
}
LocalizedNumberFormatter::LocalizedNumberFormatter(const MacroProps& macros, const Locale& locale) {
@@ -480,123 +520,6 @@ LocalizedNumberFormatter UnlocalizedNumberFormatter::locale(const Locale& locale
return LocalizedNumberFormatter(std::move(fMacros), locale);
}
-SymbolsWrapper::SymbolsWrapper(const SymbolsWrapper& other) {
- doCopyFrom(other);
-}
-
-SymbolsWrapper::SymbolsWrapper(SymbolsWrapper&& src) U_NOEXCEPT {
- doMoveFrom(std::move(src));
-}
-
-SymbolsWrapper& SymbolsWrapper::operator=(const SymbolsWrapper& other) {
- if (this == &other) {
- return *this;
- }
- doCleanup();
- doCopyFrom(other);
- return *this;
-}
-
-SymbolsWrapper& SymbolsWrapper::operator=(SymbolsWrapper&& src) U_NOEXCEPT {
- if (this == &src) {
- return *this;
- }
- doCleanup();
- doMoveFrom(std::move(src));
- return *this;
-}
-
-SymbolsWrapper::~SymbolsWrapper() {
- doCleanup();
-}
-
-void SymbolsWrapper::setTo(const DecimalFormatSymbols& dfs) {
- doCleanup();
- fType = SYMPTR_DFS;
- fPtr.dfs = new DecimalFormatSymbols(dfs);
-}
-
-void SymbolsWrapper::setTo(const NumberingSystem* ns) {
- doCleanup();
- fType = SYMPTR_NS;
- fPtr.ns = ns;
-}
-
-void SymbolsWrapper::doCopyFrom(const SymbolsWrapper& other) {
- fType = other.fType;
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- // Memory allocation failures are exposed in copyErrorTo()
- if (other.fPtr.dfs != nullptr) {
- fPtr.dfs = new DecimalFormatSymbols(*other.fPtr.dfs);
- } else {
- fPtr.dfs = nullptr;
- }
- break;
- case SYMPTR_NS:
- // Memory allocation failures are exposed in copyErrorTo()
- if (other.fPtr.ns != nullptr) {
- fPtr.ns = new NumberingSystem(*other.fPtr.ns);
- } else {
- fPtr.ns = nullptr;
- }
- break;
- }
-}
-
-void SymbolsWrapper::doMoveFrom(SymbolsWrapper&& src) {
- fType = src.fType;
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- fPtr.dfs = src.fPtr.dfs;
- src.fPtr.dfs = nullptr;
- break;
- case SYMPTR_NS:
- fPtr.ns = src.fPtr.ns;
- src.fPtr.ns = nullptr;
- break;
- }
-}
-
-void SymbolsWrapper::doCleanup() {
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- delete fPtr.dfs;
- break;
- case SYMPTR_NS:
- delete fPtr.ns;
- break;
- }
-}
-
-bool SymbolsWrapper::isDecimalFormatSymbols() const {
- return fType == SYMPTR_DFS;
-}
-
-bool SymbolsWrapper::isNumberingSystem() const {
- return fType == SYMPTR_NS;
-}
-
-const DecimalFormatSymbols* SymbolsWrapper::getDecimalFormatSymbols() const {
- U_ASSERT(fType == SYMPTR_DFS);
- return fPtr.dfs;
-}
-
-const NumberingSystem* SymbolsWrapper::getNumberingSystem() const {
- U_ASSERT(fType == SYMPTR_NS);
- return fPtr.ns;
-}
-
-
FormattedNumber LocalizedNumberFormatter::formatInt(int64_t value, UErrorCode& status) const {
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
auto results = new UFormattedNumberData();
@@ -676,9 +599,9 @@ LocalizedNumberFormatter::formatDecimalQuantity(const DecimalQuantity& dq, UErro
void LocalizedNumberFormatter::formatImpl(impl::UFormattedNumberData* results, UErrorCode& status) const {
if (computeCompiled(status)) {
- fCompiled->format(results->quantity, results->getStringRef(), status);
+ fCompiled->format(results, status);
} else {
- NumberFormatterImpl::formatStatic(fMacros, results->quantity, results->getStringRef(), status);
+ NumberFormatterImpl::formatStatic(fMacros, results, status);
}
if (U_FAILURE(status)) {
return;
diff --git a/deps/icu-small/source/i18n/number_formatimpl.cpp b/deps/icu-small/source/i18n/number_formatimpl.cpp
index 5bba09cfb5293e..9a9f3c8b71e01c 100644
--- a/deps/icu-small/source/i18n/number_formatimpl.cpp
+++ b/deps/icu-small/source/i18n/number_formatimpl.cpp
@@ -25,20 +25,20 @@ using namespace icu::number;
using namespace icu::number::impl;
-MicroPropsGenerator::~MicroPropsGenerator() = default;
-
-
NumberFormatterImpl::NumberFormatterImpl(const MacroProps& macros, UErrorCode& status)
: NumberFormatterImpl(macros, true, status) {
}
-int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuantity& inValue,
- FormattedStringBuilder& outString, UErrorCode& status) {
+int32_t NumberFormatterImpl::formatStatic(const MacroProps ¯os, UFormattedNumberData *results,
+ UErrorCode &status) {
+ DecimalQuantity &inValue = results->quantity;
+ FormattedStringBuilder &outString = results->getStringRef();
NumberFormatterImpl impl(macros, false, status);
MicroProps& micros = impl.preProcessUnsafe(inValue, status);
if (U_FAILURE(status)) { return 0; }
int32_t length = writeNumber(micros, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
+ results->outputUnit = std::move(micros.outputUnit);
return length;
}
@@ -54,13 +54,15 @@ int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, Sig
// The "unsafe" method simply re-uses fMicros, eliminating the extra copy operation.
// See MicroProps::processQuantity() for details.
-int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, FormattedStringBuilder& outString,
- UErrorCode& status) const {
+int32_t NumberFormatterImpl::format(UFormattedNumberData *results, UErrorCode &status) const {
+ DecimalQuantity &inValue = results->quantity;
+ FormattedStringBuilder &outString = results->getStringRef();
MicroProps micros;
preProcess(inValue, micros, status);
if (U_FAILURE(status)) { return 0; }
int32_t length = writeNumber(micros, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
+ results->outputUnit = std::move(micros.outputUnit);
return length;
}
@@ -130,9 +132,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Pre-compute a few values for efficiency.
bool isCurrency = utils::unitIsCurrency(macros.unit);
- bool isNoUnit = utils::unitIsNoUnit(macros.unit);
+ bool isBaseUnit = utils::unitIsBaseUnit(macros.unit);
bool isPercent = utils::unitIsPercent(macros.unit);
bool isPermille = utils::unitIsPermille(macros.unit);
+ bool isCompactNotation = macros.notation.fType == Notation::NTN_COMPACT;
bool isAccounting =
macros.sign == UNUM_SIGN_ACCOUNTING || macros.sign == UNUM_SIGN_ACCOUNTING_ALWAYS ||
macros.sign == UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO;
@@ -144,8 +147,20 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
if (macros.unitWidth != UNUM_UNIT_WIDTH_COUNT) {
unitWidth = macros.unitWidth;
}
- bool isCldrUnit = !isCurrency && !isNoUnit &&
- (unitWidth == UNUM_UNIT_WIDTH_FULL_NAME || !(isPercent || isPermille));
+ // Use CLDR unit data for all MeasureUnits (not currency and not
+ // no-unit), except use the dedicated percent pattern for percent and
+ // permille. However, use the CLDR unit data for percent/permille if a
+ // long name was requested OR if compact notation is being used, since
+ // compact notation overrides the middle modifier (micros.modMiddle)
+ // normally used for the percent pattern.
+ bool isCldrUnit = !isCurrency
+ && !isBaseUnit
+ && (unitWidth == UNUM_UNIT_WIDTH_FULL_NAME
+ || !(isPercent || isPermille)
+ || isCompactNotation
+ );
+ bool isMixedUnit = isCldrUnit && (uprv_strcmp(macros.unit.getType(), "") == 0) &&
+ macros.unit.getComplexity(status) == UMEASURE_UNIT_MIXED;
// Select the numbering system.
LocalPointer nsLocal;
@@ -222,6 +237,27 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
/// START POPULATING THE DEFAULT MICROPROPS AND BUILDING THE MICROPROPS GENERATOR ///
/////////////////////////////////////////////////////////////////////////////////////
+ // Unit Preferences and Conversions as our first step
+ if (macros.usage.isSet()) {
+ if (!isCldrUnit) {
+ // We only support "usage" when the input unit is specified, and is
+ // a CLDR Unit.
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return nullptr;
+ }
+ auto usagePrefsHandler =
+ new UsagePrefsHandler(macros.locale, macros.unit, macros.usage.fUsage, chain, status);
+ fUsagePrefsHandler.adoptInsteadAndCheckErrorCode(usagePrefsHandler, status);
+ chain = fUsagePrefsHandler.getAlias();
+ } else if (isMixedUnit) {
+ MeasureUnitImpl temp;
+ const MeasureUnitImpl &outputUnit = MeasureUnitImpl::forMeasureUnit(macros.unit, temp, status);
+ auto unitConversionHandler =
+ new UnitConversionHandler(outputUnit.units[0]->build(status), macros.unit, chain, status);
+ fUnitConversionHandler.adoptInsteadAndCheckErrorCode(unitConversionHandler, status);
+ chain = fUnitConversionHandler.getAlias();
+ }
+
// Multiplier
if (macros.scale.isValid()) {
fMicros.helpers.multiplier.setAndChain(macros.scale, chain);
@@ -232,20 +268,18 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
Precision precision;
if (!macros.precision.isBogus()) {
precision = macros.precision;
- } else if (macros.notation.fType == Notation::NTN_COMPACT) {
+ } else if (isCompactNotation) {
precision = Precision::integer().withMinDigits(2);
} else if (isCurrency) {
precision = Precision::currency(UCURR_USAGE_STANDARD);
+ } else if (macros.usage.isSet()) {
+ // Bogus Precision - it will get set in the UsagePrefsHandler instead
+ precision = Precision();
} else {
precision = Precision::maxFraction(6);
}
UNumberFormatRoundingMode roundingMode;
- if (macros.roundingMode != kDefaultMode) {
- roundingMode = macros.roundingMode;
- } else {
- // Temporary until ICU 64
- roundingMode = precision.fRoundingMode;
- }
+ roundingMode = macros.roundingMode;
fMicros.rounder = {precision, roundingMode, currency, status};
if (U_FAILURE(status)) {
return nullptr;
@@ -254,7 +288,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Grouping strategy
if (!macros.grouper.isBogus()) {
fMicros.grouping = macros.grouper;
- } else if (macros.notation.fType == Notation::NTN_COMPACT) {
+ } else if (isCompactNotation) {
// Compact notation uses minGrouping by default since ICU 59
fMicros.grouping = Grouper::forStrategy(UNUM_GROUPING_MIN2);
} else {
@@ -330,7 +364,8 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
patternModifier->setSymbols(fMicros.symbols, currency, unitWidth, nullptr, status);
}
if (safe) {
- fImmutablePatternModifier.adoptInstead(patternModifier->createImmutable(status));
+ fImmutablePatternModifier.adoptInsteadAndCheckErrorCode(patternModifier->createImmutable(status),
+ status);
}
if (U_FAILURE(status)) {
return nullptr;
@@ -338,24 +373,34 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Outer modifier (CLDR units and currency long names)
if (isCldrUnit) {
- fLongNameHandler.adoptInstead(
- LongNameHandler::forMeasureUnit(
- macros.locale,
- macros.unit,
- macros.perUnit,
- unitWidth,
- resolvePluralRules(macros.rules, macros.locale, status),
- chain,
- status));
- chain = fLongNameHandler.getAlias();
+ if (macros.usage.isSet()) {
+ fLongNameMultiplexer.adoptInsteadAndCheckErrorCode(
+ LongNameMultiplexer::forMeasureUnits(
+ macros.locale, *fUsagePrefsHandler->getOutputUnits(), unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status), chain, status),
+ status);
+ chain = fLongNameMultiplexer.getAlias();
+ } else if (isMixedUnit) {
+ fMixedUnitLongNameHandler.adoptInsteadAndCheckErrorCode(new MixedUnitLongNameHandler(),
+ status);
+ MixedUnitLongNameHandler::forMeasureUnit(
+ macros.locale, macros.unit, unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status), chain,
+ fMixedUnitLongNameHandler.getAlias(), status);
+ chain = fMixedUnitLongNameHandler.getAlias();
+ } else {
+ fLongNameHandler.adoptInsteadAndCheckErrorCode(new LongNameHandler(), status);
+ LongNameHandler::forMeasureUnit(macros.locale, macros.unit, macros.perUnit, unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status),
+ chain, fLongNameHandler.getAlias(), status);
+ chain = fLongNameHandler.getAlias();
+ }
} else if (isCurrency && unitWidth == UNUM_UNIT_WIDTH_FULL_NAME) {
- fLongNameHandler.adoptInstead(
- LongNameHandler::forCurrencyLongNames(
- macros.locale,
- currency,
- resolvePluralRules(macros.rules, macros.locale, status),
- chain,
- status));
+ fLongNameHandler.adoptInsteadAndCheckErrorCode(
+ LongNameHandler::forCurrencyLongNames(
+ macros.locale, currency, resolvePluralRules(macros.rules, macros.locale, status), chain,
+ status),
+ status);
chain = fLongNameHandler.getAlias();
} else {
// No outer modifier required
@@ -366,7 +411,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
}
// Compact notation
- if (macros.notation.fType == Notation::NTN_COMPACT) {
+ if (isCompactNotation) {
CompactType compactType = (isCurrency && unitWidth != UNUM_UNIT_WIDTH_FULL_NAME)
? CompactType::TYPE_CURRENCY : CompactType::TYPE_DECIMAL;
auto newCompactHandler = new CompactHandler(
@@ -379,6 +424,9 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
safe,
chain,
status);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
if (newCompactHandler == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
@@ -417,6 +465,7 @@ NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Local
int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStringBuilder& string,
int32_t start, int32_t end, UErrorCode& status) {
+ U_ASSERT(micros.modOuter != nullptr);
// Always apply the inner modifier (which is "strong").
int32_t length = micros.modInner->apply(string, start, end, status);
if (micros.padding.isValid()) {
diff --git a/deps/icu-small/source/i18n/number_formatimpl.h b/deps/icu-small/source/i18n/number_formatimpl.h
index 084bc4a9d0b209..5cd549e54a363f 100644
--- a/deps/icu-small/source/i18n/number_formatimpl.h
+++ b/deps/icu-small/source/i18n/number_formatimpl.h
@@ -10,11 +10,13 @@
#include "number_types.h"
#include "formatted_string_builder.h"
#include "number_patternstring.h"
+#include "number_usageprefs.h"
#include "number_utils.h"
#include "number_patternmodifier.h"
#include "number_longnames.h"
#include "number_compact.h"
#include "number_microprops.h"
+#include "number_utypes.h"
U_NAMESPACE_BEGIN namespace number {
namespace impl {
@@ -34,9 +36,8 @@ 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, FormattedStringBuilder &outString,
- UErrorCode &status);
+ static int32_t formatStatic(const MacroProps ¯os, UFormattedNumberData *results,
+ UErrorCode &status);
/**
* Prints only the prefix and suffix; used for DecimalFormat getters.
@@ -51,7 +52,7 @@ class NumberFormatterImpl : public UMemory {
/**
* Evaluates the "safe" MicroPropsGenerator created by "fromMacros".
*/
- int32_t format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const;
+ int32_t format(UFormattedNumberData *results, UErrorCode &status) const;
/**
* Like format(), but saves the result into an output MicroProps without additional processing.
@@ -82,7 +83,9 @@ class NumberFormatterImpl : public UMemory {
int32_t end, UErrorCode& status);
private:
- // Head of the MicroPropsGenerator linked list:
+ // Head of the MicroPropsGenerator linked list. Subclasses' processQuantity
+ // methods process this list in a parent-first order, such that the last
+ // item added, which this points to, typically has its logic executed last.
const MicroPropsGenerator *fMicroPropsGenerator = nullptr;
// Tail of the list:
@@ -90,13 +93,20 @@ class NumberFormatterImpl : public UMemory {
// Other fields possibly used by the number formatting pipeline:
// TODO: Convert more of these LocalPointers to value objects to reduce the number of news?
+ LocalPointer fUsagePrefsHandler;
+ LocalPointer fUnitConversionHandler;
LocalPointer fSymbols;
LocalPointer fRules;
LocalPointer fPatternInfo;
LocalPointer fScientificHandler;
LocalPointer fPatternModifier;
LocalPointer fImmutablePatternModifier;
- LocalPointer fLongNameHandler;
+ LocalPointer fLongNameHandler;
+ // TODO: use a common base class that enables fLongNameHandler,
+ // fLongNameMultiplexer, and fMixedUnitLongNameHandler to be merged into one
+ // member?
+ LocalPointer fMixedUnitLongNameHandler;
+ LocalPointer fLongNameMultiplexer;
LocalPointer fCompactHandler;
// Value objects possibly used by the number formatting pipeline:
diff --git a/deps/icu-small/source/i18n/number_grouping.cpp b/deps/icu-small/source/i18n/number_grouping.cpp
index 41f727a458f943..6b1642cfd34abd 100644
--- a/deps/icu-small/source/i18n/number_grouping.cpp
+++ b/deps/icu-small/source/i18n/number_grouping.cpp
@@ -64,6 +64,13 @@ Grouper Grouper::forProperties(const DecimalFormatProperties& properties) {
}
void Grouper::setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale) {
+ if (fMinGrouping == -2) {
+ fMinGrouping = getMinGroupingForLocale(locale);
+ } else if (fMinGrouping == -3) {
+ fMinGrouping = static_cast(uprv_max(2, getMinGroupingForLocale(locale)));
+ } else {
+ // leave fMinGrouping alone
+ }
if (fGrouping1 != -2 && fGrouping2 != -4) {
return;
}
@@ -76,13 +83,6 @@ void Grouper::setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Lo
if (grouping3 == -1) {
grouping2 = grouping1;
}
- if (fMinGrouping == -2) {
- fMinGrouping = getMinGroupingForLocale(locale);
- } else if (fMinGrouping == -3) {
- fMinGrouping = static_cast(uprv_max(2, getMinGroupingForLocale(locale)));
- } else {
- // leave fMinGrouping alone
- }
fGrouping1 = grouping1;
fGrouping2 = grouping2;
}
diff --git a/deps/icu-small/source/i18n/number_integerwidth.cpp b/deps/icu-small/source/i18n/number_integerwidth.cpp
index d62aef444dca96..10b853423c847a 100644
--- a/deps/icu-small/source/i18n/number_integerwidth.cpp
+++ b/deps/icu-small/source/i18n/number_integerwidth.cpp
@@ -40,6 +40,9 @@ IntegerWidth IntegerWidth::truncateAt(int32_t maxInt) {
}
void IntegerWidth::apply(impl::DecimalQuantity& quantity, UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return;
+ }
if (fHasError) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else if (fUnion.minMaxInt.fMaxInt == -1) {
diff --git a/deps/icu-small/source/i18n/number_longnames.cpp b/deps/icu-small/source/i18n/number_longnames.cpp
index bb32d0381a507e..3891d532dea851 100644
--- a/deps/icu-small/source/i18n/number_longnames.cpp
+++ b/deps/icu-small/source/i18n/number_longnames.cpp
@@ -10,6 +10,7 @@
#include "ureslocs.h"
#include "charstr.h"
#include "uresimp.h"
+#include "measunit_impl.h"
#include "number_longnames.h"
#include "number_microprops.h"
#include
@@ -22,8 +23,23 @@ using namespace icu::number::impl;
namespace {
+/**
+ * Display Name (this format has no placeholder).
+ *
+ * Used as an index into the LongNameHandler::simpleFormats array. Units
+ * resources cover the normal set of PluralRules keys, as well as `dnam` and
+ * `per` forms.
+ */
constexpr int32_t DNAM_INDEX = StandardPlural::Form::COUNT;
+/**
+ * "per" form (e.g. "{0} per day" is day's "per" form).
+ *
+ * Used as an index into the LongNameHandler::simpleFormats array. Units
+ * resources cover the normal set of PluralRules keys, as well as `dnam` and
+ * `per` forms.
+ */
constexpr int32_t PER_INDEX = StandardPlural::Form::COUNT + 1;
+// Number of keys in the array populated by PluralTableSink.
constexpr int32_t ARRAY_LENGTH = StandardPlural::Form::COUNT + 2;
static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
@@ -38,6 +54,11 @@ static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
}
}
+// Selects a string out of the `strings` array which corresponds to the
+// specified plural form, with fallback to the OTHER form.
+//
+// The `strings` array must have ARRAY_LENGTH items: one corresponding to each
+// of the plural forms, plus a display name ("dnam") and a "per" form.
static UnicodeString getWithPlural(
const UnicodeString* strings,
StandardPlural::Form plural,
@@ -87,6 +108,18 @@ class PluralTableSink : public ResourceSink {
// NOTE: outArray MUST have room for all StandardPlural values. No bounds checking is performed.
+/**
+ * Populates outArray with `locale`-specific values for `unit` through use of
+ * PluralTableSink. Only the set of basic units are supported!
+ *
+ * Reading from resources *unitsNarrow* and *unitsShort* (for width
+ * UNUM_UNIT_WIDTH_NARROW), or just *unitsShort* (for width
+ * UNUM_UNIT_WIDTH_SHORT). For other widths, it reads just "units".
+ *
+ * @param unit must have a type and subtype (i.e. it must be a unit listed in
+ * gTypes and gSubTypes in measunit.cpp).
+ * @param outArray must be of fixed length ARRAY_LENGTH.
+ */
void getMeasureData(const Locale &locale, const MeasureUnit &unit, const UNumberUnitWidth &width,
UnicodeString *outArray, UErrorCode &status) {
PluralTableSink sink(outArray);
@@ -184,78 +217,107 @@ UnicodeString getPerUnitFormat(const Locale& locale, const UNumberUnitWidth &wid
} // namespace
-LongNameHandler*
-LongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &unitRef, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status) {
- if (uprv_strlen(unitRef.getType()) == 0 || uprv_strlen(perUnit.getType()) == 0) {
- // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an error code.
- status = U_UNSUPPORTED_ERROR;
- return nullptr;
- }
+void LongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &unitRef,
+ const MeasureUnit &perUnit, const UNumberUnitWidth &width,
+ const PluralRules *rules, const MicroPropsGenerator *parent,
+ LongNameHandler *fillIn, UErrorCode &status) {
+ // Not valid for mixed units that aren't built-in units, and there should
+ // not be any built-in mixed units!
+ U_ASSERT(uprv_strcmp(unitRef.getType(), "") != 0 ||
+ unitRef.getComplexity(status) != UMEASURE_UNIT_MIXED);
+ U_ASSERT(fillIn != nullptr);
MeasureUnit unit = unitRef;
if (uprv_strcmp(perUnit.getType(), "none") != 0) {
// Compound unit: first try to simplify (e.g., meters per second is its own unit).
- bool isResolved = false;
- MeasureUnit resolved = MeasureUnit::resolveUnitPerUnit(unit, perUnit, &isResolved);
- if (isResolved) {
- unit = resolved;
+ MeasureUnit simplified = unit.product(perUnit.reciprocal(status), status);
+ if (uprv_strcmp(simplified.getType(), "") != 0) {
+ unit = simplified;
} else {
// No simplified form is available.
- return forCompoundUnit(loc, unit, perUnit, width, rules, parent, status);
+ forCompoundUnit(loc, unit, perUnit, width, rules, parent, fillIn, status);
+ return;
}
}
- auto* result = new LongNameHandler(rules, parent);
- if (result == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return nullptr;
+ if (uprv_strcmp(unit.getType(), "") == 0) {
+ // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an
+ // error code. Once we support not-built-in units here, unitRef may be
+ // anything, but if not built-in, perUnit has to be "none".
+ status = U_UNSUPPORTED_ERROR;
+ return;
}
+
UnicodeString simpleFormats[ARRAY_LENGTH];
getMeasureData(loc, unit, width, simpleFormats, status);
- if (U_FAILURE(status)) { return result; }
- result->simpleFormatsToModifiers(simpleFormats, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
- return result;
+ if (U_FAILURE(status)) {
+ return;
+ }
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+ fillIn->simpleFormatsToModifiers(simpleFormats, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD},
+ status);
}
-LongNameHandler*
-LongNameHandler::forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status) {
- auto* result = new LongNameHandler(rules, parent);
- if (result == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return nullptr;
+void LongNameHandler::forCompoundUnit(const Locale &loc, const MeasureUnit &unit,
+ const MeasureUnit &perUnit, const UNumberUnitWidth &width,
+ const PluralRules *rules, const MicroPropsGenerator *parent,
+ LongNameHandler *fillIn, UErrorCode &status) {
+ if (uprv_strcmp(unit.getType(), "") == 0 || uprv_strcmp(perUnit.getType(), "") == 0) {
+ // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an
+ // error code. Once we support not-built-in units here, unitRef may be
+ // anything, but if not built-in, perUnit has to be "none".
+ status = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ if (fillIn == nullptr) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
}
UnicodeString primaryData[ARRAY_LENGTH];
getMeasureData(loc, unit, width, primaryData, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryData[ARRAY_LENGTH];
getMeasureData(loc, perUnit, width, secondaryData, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString perUnitFormat;
if (!secondaryData[PER_INDEX].isBogus()) {
perUnitFormat = secondaryData[PER_INDEX];
} else {
UnicodeString rawPerUnitFormat = getPerUnitFormat(loc, width, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
// rawPerUnitFormat is something like "{0}/{1}"; we need to substitute in the secondary unit.
SimpleFormatter compiled(rawPerUnitFormat, 2, 2, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryFormat = getWithPlural(secondaryData, StandardPlural::Form::ONE, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
// Some "one" pattern may not contain "{0}". For example in "ar" or "ne" locale.
SimpleFormatter secondaryCompiled(secondaryFormat, 0, 1, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryString = secondaryCompiled.getTextWithNoArguments().trim();
// TODO: Why does UnicodeString need to be explicit in the following line?
compiled.format(UnicodeString(u"{0}"), secondaryString, perUnitFormat, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
}
- result->multiSimpleFormatsToModifiers(primaryData, perUnitFormat, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
- return result;
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+ fillIn->multiSimpleFormatsToModifiers(primaryData, perUnitFormat,
+ {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
}
UnicodeString LongNameHandler::getUnitDisplayName(
@@ -338,7 +400,9 @@ void LongNameHandler::multiSimpleFormatsToModifiers(const UnicodeString *leadFor
void LongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps µs,
UErrorCode &status) const {
- parent->processQuantity(quantity, micros, status);
+ if (parent != NULL) {
+ parent->processQuantity(quantity, micros, status);
+ }
StandardPlural::Form pluralForm = utils::getPluralSafe(micros.rounder, rules, quantity, status);
micros.modOuter = &fModifiers[pluralForm];
}
@@ -347,4 +411,199 @@ const Modifier* LongNameHandler::getModifier(Signum /*signum*/, StandardPlural::
return &fModifiers[plural];
}
+void MixedUnitLongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &mixedUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent,
+ MixedUnitLongNameHandler *fillIn, UErrorCode &status) {
+ U_ASSERT(mixedUnit.getComplexity(status) == UMEASURE_UNIT_MIXED);
+ U_ASSERT(fillIn != nullptr);
+
+ MeasureUnitImpl temp;
+ const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(mixedUnit, temp, status);
+ fillIn->fMixedUnitCount = impl.units.length();
+ fillIn->fMixedUnitData.adoptInstead(new UnicodeString[fillIn->fMixedUnitCount * ARRAY_LENGTH]);
+ for (int32_t i = 0; i < fillIn->fMixedUnitCount; i++) {
+ // Grab data for each of the components.
+ UnicodeString *unitData = &fillIn->fMixedUnitData[i * ARRAY_LENGTH];
+ getMeasureData(loc, impl.units[i]->build(status), width, unitData, status);
+ }
+
+ UListFormatterWidth listWidth = ULISTFMT_WIDTH_SHORT;
+ if (width == UNUM_UNIT_WIDTH_NARROW) {
+ listWidth = ULISTFMT_WIDTH_NARROW;
+ } else if (width == UNUM_UNIT_WIDTH_FULL_NAME) {
+ // This might be the same as SHORT in most languages:
+ listWidth = ULISTFMT_WIDTH_WIDE;
+ }
+ fillIn->fListFormatter.adoptInsteadAndCheckErrorCode(
+ ListFormatter::createInstance(loc, ULISTFMT_TYPE_UNITS, listWidth, status), status);
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+
+ // We need a localised NumberFormatter for the integers of the bigger units
+ // (providing Arabic numerals, for example).
+ fillIn->fIntegerFormatter = NumberFormatter::withLocale(loc);
+}
+
+void MixedUnitLongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps µs,
+ UErrorCode &status) const {
+ U_ASSERT(fMixedUnitCount > 1);
+ if (parent != nullptr) {
+ parent->processQuantity(quantity, micros, status);
+ }
+ micros.modOuter = getMixedUnitModifier(quantity, micros, status);
+}
+
+const Modifier *MixedUnitLongNameHandler::getMixedUnitModifier(DecimalQuantity &quantity,
+ MicroProps µs,
+ UErrorCode &status) const {
+ if (micros.mixedMeasuresCount == 0) {
+ U_ASSERT(micros.mixedMeasuresCount > 0); // Mixed unit: we must have more than one unit value
+ status = U_UNSUPPORTED_ERROR;
+ return µs.helpers.emptyWeakModifier;
+ }
+ // If we don't have at least one mixedMeasure, the LongNameHandler would be
+ // sufficient and we shouldn't be running MixedUnitLongNameHandler code:
+ U_ASSERT(micros.mixedMeasuresCount > 0);
+ // mixedMeasures does not contain the last value:
+ U_ASSERT(fMixedUnitCount == micros.mixedMeasuresCount + 1);
+ U_ASSERT(fListFormatter.isValid());
+
+ // Algorithm:
+ //
+ // For the mixed-units measurement of: "3 yard, 1 foot, 2.6 inch", we should
+ // find "3 yard" and "1 foot" in micros.mixedMeasures.
+ //
+ // Obtain long-names with plural forms corresponding to measure values:
+ // * {0} yards, {0} foot, {0} inches
+ //
+ // Format the integer values appropriately and modify with the format
+ // strings:
+ // - 3 yards, 1 foot
+ //
+ // Use ListFormatter to combine, with one placeholder:
+ // - 3 yards, 1 foot and {0} inches
+ //
+ // Return a SimpleModifier for this pattern, letting the rest of the
+ // pipeline take care of the remaining inches.
+
+ LocalArray outputMeasuresList(new UnicodeString[fMixedUnitCount], status);
+ if (U_FAILURE(status)) {
+ return µs.helpers.emptyWeakModifier;
+ }
+
+ for (int32_t i = 0; i < micros.mixedMeasuresCount; i++) {
+ DecimalQuantity fdec;
+ fdec.setToLong(micros.mixedMeasures[i]);
+ if (i > 0 && fdec.isNegative()) {
+ // If numbers are negative, only the first number needs to have its
+ // negative sign formatted.
+ fdec.negate();
+ }
+ StandardPlural::Form pluralForm = utils::getStandardPlural(rules, fdec);
+
+ UnicodeString simpleFormat =
+ getWithPlural(&fMixedUnitData[i * ARRAY_LENGTH], pluralForm, status);
+ SimpleFormatter compiledFormatter(simpleFormat, 0, 1, status);
+
+ UnicodeString num;
+ auto appendable = UnicodeStringAppendable(num);
+ fIntegerFormatter.formatDecimalQuantity(fdec, status).appendTo(appendable, status);
+ compiledFormatter.format(num, outputMeasuresList[i], status);
+ // TODO(icu-units#67): fix field positions
+ }
+
+ // Reiterated: we have at least one mixedMeasure:
+ U_ASSERT(micros.mixedMeasuresCount > 0);
+ // Thus if negative, a negative has already been formatted:
+ if (quantity.isNegative()) {
+ quantity.negate();
+ }
+
+ UnicodeString *finalSimpleFormats = &fMixedUnitData[(fMixedUnitCount - 1) * ARRAY_LENGTH];
+ StandardPlural::Form finalPlural = utils::getPluralSafe(micros.rounder, rules, quantity, status);
+ UnicodeString finalSimpleFormat = getWithPlural(finalSimpleFormats, finalPlural, status);
+ SimpleFormatter finalFormatter(finalSimpleFormat, 0, 1, status);
+ finalFormatter.format(UnicodeString(u"{0}"), outputMeasuresList[fMixedUnitCount - 1], status);
+
+ // Combine list into a "premixed" pattern
+ UnicodeString premixedFormatPattern;
+ fListFormatter->format(outputMeasuresList.getAlias(), fMixedUnitCount, premixedFormatPattern,
+ status);
+ SimpleFormatter premixedCompiled(premixedFormatPattern, 0, 1, status);
+ if (U_FAILURE(status)) {
+ return µs.helpers.emptyWeakModifier;
+ }
+
+ // TODO(icu-units#67): fix field positions
+ // Return a SimpleModifier for the "premixed" pattern
+ micros.helpers.mixedUnitModifier =
+ SimpleModifier(premixedCompiled, kUndefinedField, false, {this, SIGNUM_POS_ZERO, finalPlural});
+ return µs.helpers.mixedUnitModifier;
+}
+
+const Modifier *MixedUnitLongNameHandler::getModifier(Signum /*signum*/,
+ StandardPlural::Form /*plural*/) const {
+ // TODO(units): investigate this method when investigating where
+ // LongNameHandler::getModifier() gets used. To be sure it remains
+ // unreachable:
+ UPRV_UNREACHABLE;
+ return nullptr;
+}
+
+LongNameMultiplexer *
+LongNameMultiplexer::forMeasureUnits(const Locale &loc, const MaybeStackVector &units,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, UErrorCode &status) {
+ LocalPointer result(new LongNameMultiplexer(parent), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ U_ASSERT(units.length() > 0);
+ if (result->fHandlers.resize(units.length()) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ result->fMeasureUnits.adoptInstead(new MeasureUnit[units.length()]);
+ for (int32_t i = 0, length = units.length(); i < length; i++) {
+ const MeasureUnit& unit = *units[i];
+ result->fMeasureUnits[i] = unit;
+ if (unit.getComplexity(status) == UMEASURE_UNIT_MIXED) {
+ MixedUnitLongNameHandler *mlnh = result->fMixedUnitHandlers.createAndCheckErrorCode(status);
+ MixedUnitLongNameHandler::forMeasureUnit(loc, unit, width, rules, NULL, mlnh, status);
+ result->fHandlers[i] = mlnh;
+ } else {
+ LongNameHandler *lnh = result->fLongNameHandlers.createAndCheckErrorCode(status);
+ LongNameHandler::forMeasureUnit(loc, unit, MeasureUnit(), width, rules, NULL, lnh, status);
+ result->fHandlers[i] = lnh;
+ }
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ }
+ return result.orphan();
+}
+
+void LongNameMultiplexer::processQuantity(DecimalQuantity &quantity, MicroProps µs,
+ UErrorCode &status) const {
+ // We call parent->processQuantity() from the Multiplexer, instead of
+ // letting LongNameHandler handle it: we don't know which LongNameHandler to
+ // call until we've called the parent!
+ fParent->processQuantity(quantity, micros, status);
+
+ // Call the correct LongNameHandler based on outputUnit
+ for (int i = 0; i < fHandlers.getCapacity(); i++) {
+ if (fMeasureUnits[i] == micros.outputUnit) {
+ fHandlers[i]->processQuantity(quantity, micros, status);
+ return;
+ }
+ }
+ if (U_FAILURE(status)) {
+ return;
+ }
+ // We shouldn't receive any outputUnit for which we haven't already got a
+ // LongNameHandler:
+ status = U_INTERNAL_PROGRAM_ERROR;
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/number_longnames.h b/deps/icu-small/source/i18n/number_longnames.h
index a19425aa268af6..67f2316a9cd4bd 100644
--- a/deps/icu-small/source/i18n/number_longnames.h
+++ b/deps/icu-small/source/i18n/number_longnames.h
@@ -7,6 +7,8 @@
#ifndef __NUMBER_LONGNAMES_H__
#define __NUMBER_LONGNAMES_H__
+#include "cmemory.h"
+#include "unicode/listformatter.h"
#include "unicode/uversion.h"
#include "number_utils.h"
#include "number_modifiers.h"
@@ -33,34 +35,206 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public
forCurrencyLongNames(const Locale &loc, const CurrencyUnit ¤cy, const PluralRules *rules,
const MicroPropsGenerator *parent, UErrorCode &status);
- static LongNameHandler*
- forMeasureUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status);
-
+ /**
+ * Construct a localized LongNameHandler for the specified MeasureUnit.
+ *
+ * Compound units can be constructed via `unit` and `perUnit`. Both of these
+ * must then be built-in units.
+ *
+ * Mixed units are not supported, use MixedUnitLongNameHandler::forMeasureUnit.
+ *
+ * This function uses a fillIn intead of returning a pointer, because we
+ * want to fill in instances in a MemoryPool (which cannot adopt pointers it
+ * didn't create itself).
+ *
+ * @param loc The desired locale.
+ * @param unit The measure unit to construct a LongNameHandler for. If
+ * `perUnit` is also defined, `unit` must not be a mixed unit.
+ * @param perUnit If `unit` is a mixed unit, `perUnit` must be "none".
+ * @param width Specifies the desired unit rendering.
+ * @param rules Does not take ownership.
+ * @param parent Does not take ownership.
+ * @param fillIn Required.
+ */
+ static void forMeasureUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, LongNameHandler *fillIn,
+ UErrorCode &status);
+
+ /**
+ * Selects the plural-appropriate Modifier from the set of fModifiers based
+ * on the plural form.
+ */
void
processQuantity(DecimalQuantity &quantity, MicroProps µs, UErrorCode &status) const U_OVERRIDE;
+ // TODO(units): investigate whether we might run into Mixed Unit trouble
+ // with this. This override for ModifierStore::getModifier does not support
+ // mixed units: investigate under which circumstances it gets called (check
+ // both ImmutablePatternModifier and in NumberRangeFormatterImpl).
const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE;
private:
+ // A set of pre-computed modifiers, one for each plural form.
SimpleModifier fModifiers[StandardPlural::Form::COUNT];
+ // Not owned
const PluralRules *rules;
+ // Not owned
const MicroPropsGenerator *parent;
LongNameHandler(const PluralRules *rules, const MicroPropsGenerator *parent)
- : rules(rules), parent(parent) {}
+ : rules(rules), parent(parent) {
+ }
- static LongNameHandler*
- forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status);
+ LongNameHandler() : rules(nullptr), parent(nullptr) {
+ }
+
+ // Enables MemoryPool::emplaceBack(): requires access to
+ // the private constructors.
+ friend class MemoryPool;
+
+ // Allow macrosToMicroGenerator to call the private default constructor.
+ friend class NumberFormatterImpl;
+ // Fills in LongNameHandler fields for formatting compound units identified
+ // via `unit` and `perUnit`. Both `unit` and `perUnit` need to be built-in
+ // units (for which data exists).
+ static void forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, LongNameHandler *fillIn,
+ UErrorCode &status);
+
+ // Sets fModifiers to use the patterns from `simpleFormats`.
void simpleFormatsToModifiers(const UnicodeString *simpleFormats, Field field, UErrorCode &status);
+
+ // Sets fModifiers to a combination of `leadFormats` (one per plural form)
+ // and `trailFormat` appended to each.
+ //
+ // With a leadFormat of "{0}m" and a trailFormat of "{0}/s", it produces a
+ // pattern of "{0}m/s" by inserting the leadFormat pattern into trailFormat.
void multiSimpleFormatsToModifiers(const UnicodeString *leadFormats, UnicodeString trailFormat,
Field field, UErrorCode &status);
};
+// Similar to LongNameHandler, but only for MIXED units.
+class MixedUnitLongNameHandler : public MicroPropsGenerator, public ModifierStore, public UMemory {
+ public:
+ /**
+ * Construct a localized MixedUnitLongNameHandler for the specified
+ * MeasureUnit. It must be a MIXED unit.
+ *
+ * This function uses a fillIn intead of returning a pointer, because we
+ * want to fill in instances in a MemoryPool (which cannot adopt pointers it
+ * didn't create itself).
+ *
+ * @param loc The desired locale.
+ * @param mixedUnit The mixed measure unit to construct a
+ * MixedUnitLongNameHandler for.
+ * @param width Specifies the desired unit rendering.
+ * @param rules Does not take ownership.
+ * @param parent Does not take ownership.
+ * @param fillIn Required.
+ */
+ static void forMeasureUnit(const Locale &loc, const MeasureUnit &mixedUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, MixedUnitLongNameHandler *fillIn,
+ UErrorCode &status);
+
+ /**
+ * Produces a plural-appropriate Modifier for a mixed unit: `quantity` is
+ * taken as the final smallest unit, while the larger unit values must be
+ * provided via `micros.mixedMeasures`.
+ */
+ void processQuantity(DecimalQuantity &quantity, MicroProps µs,
+ UErrorCode &status) const U_OVERRIDE;
+
+ // Required for ModifierStore. And ModifierStore is required by
+ // SimpleModifier constructor's last parameter. We assert his will never get
+ // called though.
+ const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE;
+
+ private:
+ // Not owned
+ const PluralRules *rules;
+ // Not owned
+ const MicroPropsGenerator *parent;
+
+ // Total number of units in the MeasureUnit this handler was configured for:
+ // for "foot-and-inch", this will be 2.
+ int32_t fMixedUnitCount = 1;
+ // Stores unit data for each of the individual units. For each unit, it
+ // stores ARRAY_LENGTH strings, as returned by getMeasureData. (Each unit
+ // with index `i` has ARRAY_LENGTH strings starting at index
+ // `i*ARRAY_LENGTH` in this array.)
+ LocalArray fMixedUnitData;
+ // A localized NumberFormatter used to format the integer-valued bigger
+ // units of Mixed Unit measurements.
+ LocalizedNumberFormatter fIntegerFormatter;
+ // A localised list formatter for joining mixed units together.
+ LocalPointer fListFormatter;
+
+ MixedUnitLongNameHandler(const PluralRules *rules, const MicroPropsGenerator *parent)
+ : rules(rules), parent(parent) {
+ }
+
+ MixedUnitLongNameHandler() : rules(nullptr), parent(nullptr) {
+ }
+
+ // Allow macrosToMicroGenerator to call the private default constructor.
+ friend class NumberFormatterImpl;
+
+ // Enables MemoryPool::emplaceBack(): requires access to
+ // the private constructors.
+ friend class MemoryPool;
+
+ // For a mixed unit, returns a Modifier that takes only one parameter: the
+ // smallest and final unit of the set. The bigger units' values and labels
+ // get baked into this Modifier, together with the unit label of the final
+ // unit.
+ const Modifier *getMixedUnitModifier(DecimalQuantity &quantity, MicroProps µs,
+ UErrorCode &status) const;
+};
+
+/**
+ * A MicroPropsGenerator that multiplexes between different LongNameHandlers,
+ * depending on the outputUnit.
+ *
+ * See processQuantity() for the input requirements.
+ */
+class LongNameMultiplexer : public MicroPropsGenerator, public UMemory {
+ public:
+ // Produces a multiplexer for LongNameHandlers, one for each unit in
+ // `units`. An individual unit might be a mixed unit.
+ static LongNameMultiplexer *forMeasureUnits(const Locale &loc,
+ const MaybeStackVector &units,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, UErrorCode &status);
+
+ // The output unit must be provided via `micros.outputUnit`, it must match
+ // one of the units provided to the factory function.
+ void processQuantity(DecimalQuantity &quantity, MicroProps µs,
+ UErrorCode &status) const U_OVERRIDE;
+
+ private:
+ /**
+ * Because we only know which LongNameHandler we wish to call after calling
+ * earlier MicroPropsGenerators in the chain, LongNameMultiplexer keeps the
+ * parent link, while the LongNameHandlers are given no parents.
+ */
+ MemoryPool fLongNameHandlers;
+ MemoryPool fMixedUnitHandlers;
+ // Unowned pointers to instances owned by MaybeStackVectors.
+ MaybeStackArray fHandlers;
+ // Each MeasureUnit corresponds to the same-index MicroPropsGenerator
+ // pointed to in fHandlers.
+ LocalArray fMeasureUnits;
+
+ const MicroPropsGenerator *fParent;
+
+ LongNameMultiplexer(const MicroPropsGenerator *parent) : fParent(parent) {
+ }
+};
+
} // namespace impl
} // namespace number
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/number_mapper.cpp b/deps/icu-small/source/i18n/number_mapper.cpp
index ec617438c9a9e3..e2a0d284b7cf5d 100644
--- a/deps/icu-small/source/i18n/number_mapper.cpp
+++ b/deps/icu-small/source/i18n/number_mapper.cpp
@@ -92,6 +92,8 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
int32_t minSig = properties.minimumSignificantDigits;
int32_t maxSig = properties.maximumSignificantDigits;
double roundingIncrement = properties.roundingIncrement;
+ // Not assigning directly to macros.roundingMode here: we change
+ // roundingMode if and when we also change macros.precision.
RoundingMode roundingMode = properties.roundingMode.getOrDefault(UNUM_ROUND_HALFEVEN);
bool explicitMinMaxFrac = minFrac != -1 || maxFrac != -1;
bool explicitMinMaxSig = minSig != -1 || maxSig != -1;
@@ -145,7 +147,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
precision = Precision::constructCurrency(currencyUsage);
}
if (!precision.isBogus()) {
- precision.fRoundingMode = roundingMode;
+ macros.roundingMode = roundingMode;
macros.precision = precision;
}
@@ -239,7 +241,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
// TODO: Reset maxSig_ = 1 + minFrac_ to follow the spec.
macros.precision = Precision::constructSignificant(minSig_, maxSig_);
}
- macros.precision.fRoundingMode = roundingMode;
+ macros.roundingMode = roundingMode;
}
}
diff --git a/deps/icu-small/source/i18n/number_mapper.h b/deps/icu-small/source/i18n/number_mapper.h
index d18b8b3c438cf4..9ecd776b3b4795 100644
--- a/deps/icu-small/source/i18n/number_mapper.h
+++ b/deps/icu-small/source/i18n/number_mapper.h
@@ -136,6 +136,16 @@ class AutoAffixPatternProvider {
}
}
+ inline void setTo(const AffixPatternProvider* provider, UErrorCode& status) {
+ if (auto ptr = dynamic_cast(provider)) {
+ propertiesAPP = *ptr;
+ } else if (auto ptr = dynamic_cast(provider)) {
+ currencyPluralInfoAPP = *ptr;
+ } else {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ }
+ }
+
inline const AffixPatternProvider& get() const {
if (!currencyPluralInfoAPP.isBogus()) {
return currencyPluralInfoAPP;
@@ -153,9 +163,9 @@ class AutoAffixPatternProvider {
/**
* A struct for ownership of a few objects needed for formatting.
*/
-struct DecimalFormatWarehouse {
+struct DecimalFormatWarehouse : public UMemory {
AutoAffixPatternProvider affixProvider;
-
+ LocalPointer rules;
};
diff --git a/deps/icu-small/source/i18n/number_microprops.h b/deps/icu-small/source/i18n/number_microprops.h
index 56512f5e6f94ac..058c5923b4567b 100644
--- a/deps/icu-small/source/i18n/number_microprops.h
+++ b/deps/icu-small/source/i18n/number_microprops.h
@@ -22,6 +22,56 @@
U_NAMESPACE_BEGIN namespace number {
namespace impl {
+/**
+ * A copyable container for the integer values of mixed unit measurements.
+ *
+ * If memory allocation fails during copying, no values are copied and status is
+ * set to U_MEMORY_ALLOCATION_ERROR.
+ */
+class IntMeasures : public MaybeStackArray {
+ public:
+ /**
+ * Default constructor initializes with internal T[stackCapacity] buffer.
+ *
+ * Stack Capacity: most mixed units are expected to consist of two or three
+ * subunits, so one or two integer measures should be enough.
+ */
+ IntMeasures() : MaybeStackArray() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * If memory allocation fails during copying, no values are copied and
+ * status is set to U_MEMORY_ALLOCATION_ERROR.
+ */
+ IntMeasures(const IntMeasures &other) : MaybeStackArray