aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/dcfmtsym.cpp
diff options
context:
space:
mode:
authormcheshkov <mcheshkov@yandex-team.ru>2022-02-10 16:46:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:16 +0300
commit1312621288956f199a5bd5342b0133d4395fa725 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/icu/i18n/dcfmtsym.cpp
parente9d19cec64684c9c1e6b0c98297e5b895cf904fe (diff)
downloadydb-1312621288956f199a5bd5342b0133d4395fa725.tar.gz
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/icu/i18n/dcfmtsym.cpp')
-rw-r--r--contrib/libs/icu/i18n/dcfmtsym.cpp188
1 files changed, 94 insertions, 94 deletions
diff --git a/contrib/libs/icu/i18n/dcfmtsym.cpp b/contrib/libs/icu/i18n/dcfmtsym.cpp
index e203a0549b..15418bfe65 100644
--- a/contrib/libs/icu/i18n/dcfmtsym.cpp
+++ b/contrib/libs/icu/i18n/dcfmtsym.cpp
@@ -1,4 +1,4 @@
-// © 2016 and later: Unicode, Inc. and others.
+// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@@ -38,7 +38,7 @@
#include "uresimp.h"
#include "ureslocs.h"
#include "charstr.h"
-#include "uassert.h"
+#include "uassert.h"
// *****************************************************************************
// class DecimalFormatSymbols
@@ -66,7 +66,7 @@ static const UChar INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount] = {
"decimal",
"group",
- NULL, /* #11897: the <list> symbol is NOT the pattern separator symbol */
+ NULL, /* #11897: the <list> symbol is NOT the pattern separator symbol */
"percentSign",
NULL, /* Native zero digit is deprecated from CLDR - get it from the numbering system */
NULL, /* Pattern digit character is deprecated from CLDR - use # by default always */
@@ -98,7 +98,7 @@ static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount]
// Initializes this with the decimal format symbols in the default locale.
DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
- : UObject(), locale(), currPattern(NULL) {
+ : UObject(), locale(), currPattern(NULL) {
initialize(locale, status, TRUE);
}
@@ -106,17 +106,17 @@ DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
// Initializes this with the decimal format symbols in the desired locale.
DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, UErrorCode& status)
- : UObject(), locale(loc), currPattern(NULL) {
+ : UObject(), locale(loc), currPattern(NULL) {
initialize(locale, status);
}
-DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, const NumberingSystem& ns, UErrorCode& status)
- : UObject(), locale(loc), currPattern(NULL) {
- initialize(locale, status, FALSE, &ns);
-}
-
+DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, const NumberingSystem& ns, UErrorCode& status)
+ : UObject(), locale(loc), currPattern(NULL) {
+ initialize(locale, status, FALSE, &ns);
+}
+
DecimalFormatSymbols::DecimalFormatSymbols()
- : UObject(), locale(Locale::getRoot()), currPattern(NULL) {
+ : UObject(), locale(Locale::getRoot()), currPattern(NULL) {
*validLocale = *actualLocale = 0;
initialize();
}
@@ -166,8 +166,8 @@ DecimalFormatSymbols::operator=(const DecimalFormatSymbols& rhs)
uprv_strcpy(actualLocale, rhs.actualLocale);
fIsCustomCurrencySymbol = rhs.fIsCustomCurrencySymbol;
fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol;
- fCodePointZero = rhs.fCodePointZero;
- currPattern = rhs.currPattern;
+ fCodePointZero = rhs.fCodePointZero;
+ currPattern = rhs.currPattern;
}
return *this;
}
@@ -199,7 +199,7 @@ DecimalFormatSymbols::operator==(const DecimalFormatSymbols& that) const
return FALSE;
}
}
- // No need to check fCodePointZero since it is based on fSymbols
+ // No need to check fCodePointZero since it is based on fSymbols
return locale == that.locale &&
uprv_strcmp(validLocale, that.validLocale) == 0 &&
uprv_strcmp(actualLocale, that.actualLocale) == 0;
@@ -345,8 +345,8 @@ CurrencySpacingSink::~CurrencySpacingSink() {}
} // namespace
void
-DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
- UBool useLastResortData, const NumberingSystem* ns)
+DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
+ UBool useLastResortData, const NumberingSystem* ns)
{
if (U_FAILURE(status)) { return; }
*validLocale = *actualLocale = 0;
@@ -358,13 +358,13 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
// Next get the numbering system for this locale and set zero digit
// and the digit string based on the numbering system for the locale
//
- LocalPointer<NumberingSystem> nsLocal;
- if (ns == nullptr) {
- // Use the numbering system according to the locale.
- // Save it into a LocalPointer so it gets cleaned up.
- nsLocal.adoptInstead(NumberingSystem::createInstance(loc, status));
- ns = nsLocal.getAlias();
- }
+ LocalPointer<NumberingSystem> nsLocal;
+ if (ns == nullptr) {
+ // Use the numbering system according to the locale.
+ // Save it into a LocalPointer so it gets cleaned up.
+ nsLocal.adoptInstead(NumberingSystem::createInstance(loc, status));
+ ns = nsLocal.getAlias();
+ }
const char *nsName;
if (U_SUCCESS(status) && ns->getRadix() == 10 && !ns->isAlgorithmic()) {
nsName = ns->getName();
@@ -436,33 +436,33 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
// Let the monetary number separators equal the default number separators if necessary.
sink.resolveMissingMonetarySeparators(fSymbols);
- // Resolve codePointZero
- UChar32 tempCodePointZero = -1;
- for (int32_t i=0; i<=9; i++) {
- const UnicodeString& stringDigit = getConstDigitSymbol(i);
- if (stringDigit.countChar32() != 1) {
- tempCodePointZero = -1;
- break;
- }
- UChar32 cp = stringDigit.char32At(0);
- if (i == 0) {
- tempCodePointZero = cp;
- } else if (cp != tempCodePointZero + i) {
- tempCodePointZero = -1;
- break;
- }
- }
- fCodePointZero = tempCodePointZero;
-
- // Get the default currency from the currency API.
+ // Resolve codePointZero
+ UChar32 tempCodePointZero = -1;
+ for (int32_t i=0; i<=9; i++) {
+ const UnicodeString& stringDigit = getConstDigitSymbol(i);
+ if (stringDigit.countChar32() != 1) {
+ tempCodePointZero = -1;
+ break;
+ }
+ UChar32 cp = stringDigit.char32At(0);
+ if (i == 0) {
+ tempCodePointZero = cp;
+ } else if (cp != tempCodePointZero + i) {
+ tempCodePointZero = -1;
+ break;
+ }
+ }
+ fCodePointZero = tempCodePointZero;
+
+ // Get the default currency from the currency API.
UErrorCode internalStatus = U_ZERO_ERROR; // don't propagate failures out
UChar curriso[4];
UnicodeString tempStr;
- int32_t currisoLength = ucurr_forLocale(locStr, curriso, UPRV_LENGTHOF(curriso), &internalStatus);
- if (U_SUCCESS(internalStatus) && currisoLength == 3) {
- setCurrency(curriso, status);
- } else {
- setCurrency(nullptr, status);
+ int32_t currisoLength = ucurr_forLocale(locStr, curriso, UPRV_LENGTHOF(curriso), &internalStatus);
+ if (U_SUCCESS(internalStatus) && currisoLength == 3) {
+ setCurrency(curriso, status);
+ } else {
+ setCurrency(nullptr, status);
}
// Currency Spacing.
@@ -510,56 +510,56 @@ DecimalFormatSymbols::initialize() {
fSymbols[kExponentMultiplicationSymbol] = (UChar)0xd7; // 'x' multiplication symbol for exponents
fIsCustomCurrencySymbol = FALSE;
fIsCustomIntlCurrencySymbol = FALSE;
- fCodePointZero = 0x30;
- U_ASSERT(fCodePointZero == fSymbols[kZeroDigitSymbol].char32At(0));
- currPattern = nullptr;
+ fCodePointZero = 0x30;
+ U_ASSERT(fCodePointZero == fSymbols[kZeroDigitSymbol].char32At(0));
+ currPattern = nullptr;
}
-void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status) {
- // TODO: If this method is made public:
- // - Adopt ICU4J behavior of not allowing currency to be null.
- // - Also verify that the length of currency is 3.
- if (!currency) {
- return;
- }
-
- UnicodeString tempStr;
- uprv_getStaticCurrencyName(currency, locale.getName(), tempStr, status);
- if (U_SUCCESS(status)) {
- fSymbols[kIntlCurrencySymbol].setTo(currency, 3);
- fSymbols[kCurrencySymbol] = tempStr;
- }
-
- char cc[4]={0};
- u_UCharsToChars(currency, cc, 3);
-
- /* An explicit currency was requested */
- // TODO(ICU-13297): Move this data loading logic into a centralized place
- UErrorCode localStatus = U_ZERO_ERROR;
- LocalUResourceBundlePointer rbTop(ures_open(U_ICUDATA_CURR, locale.getName(), &localStatus));
- LocalUResourceBundlePointer rb(
- ures_getByKeyWithFallback(rbTop.getAlias(), "Currencies", NULL, &localStatus));
- ures_getByKeyWithFallback(rb.getAlias(), cc, rb.getAlias(), &localStatus);
- if(U_SUCCESS(localStatus) && ures_getSize(rb.getAlias())>2) { // the length is 3 if more data is present
- ures_getByIndex(rb.getAlias(), 2, rb.getAlias(), &localStatus);
- int32_t currPatternLen = 0;
- currPattern =
- ures_getStringByIndex(rb.getAlias(), (int32_t)0, &currPatternLen, &localStatus);
- UnicodeString decimalSep =
- ures_getUnicodeStringByIndex(rb.getAlias(), (int32_t)1, &localStatus);
- UnicodeString groupingSep =
- ures_getUnicodeStringByIndex(rb.getAlias(), (int32_t)2, &localStatus);
- if(U_SUCCESS(localStatus)){
- fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
- fSymbols[kMonetarySeparatorSymbol] = decimalSep;
- //pattern.setTo(TRUE, currPattern, currPatternLen);
- }
- }
- /* else An explicit currency was requested and is unknown or locale data is malformed. */
- /* ucurr_* API will get the correct value later on. */
-}
-
+void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status) {
+ // TODO: If this method is made public:
+ // - Adopt ICU4J behavior of not allowing currency to be null.
+ // - Also verify that the length of currency is 3.
+ if (!currency) {
+ return;
+ }
+
+ UnicodeString tempStr;
+ uprv_getStaticCurrencyName(currency, locale.getName(), tempStr, status);
+ if (U_SUCCESS(status)) {
+ fSymbols[kIntlCurrencySymbol].setTo(currency, 3);
+ fSymbols[kCurrencySymbol] = tempStr;
+ }
+
+ char cc[4]={0};
+ u_UCharsToChars(currency, cc, 3);
+
+ /* An explicit currency was requested */
+ // TODO(ICU-13297): Move this data loading logic into a centralized place
+ UErrorCode localStatus = U_ZERO_ERROR;
+ LocalUResourceBundlePointer rbTop(ures_open(U_ICUDATA_CURR, locale.getName(), &localStatus));
+ LocalUResourceBundlePointer rb(
+ ures_getByKeyWithFallback(rbTop.getAlias(), "Currencies", NULL, &localStatus));
+ ures_getByKeyWithFallback(rb.getAlias(), cc, rb.getAlias(), &localStatus);
+ if(U_SUCCESS(localStatus) && ures_getSize(rb.getAlias())>2) { // the length is 3 if more data is present
+ ures_getByIndex(rb.getAlias(), 2, rb.getAlias(), &localStatus);
+ int32_t currPatternLen = 0;
+ currPattern =
+ ures_getStringByIndex(rb.getAlias(), (int32_t)0, &currPatternLen, &localStatus);
+ UnicodeString decimalSep =
+ ures_getUnicodeStringByIndex(rb.getAlias(), (int32_t)1, &localStatus);
+ UnicodeString groupingSep =
+ ures_getUnicodeStringByIndex(rb.getAlias(), (int32_t)2, &localStatus);
+ if(U_SUCCESS(localStatus)){
+ fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
+ fSymbols[kMonetarySeparatorSymbol] = decimalSep;
+ //pattern.setTo(TRUE, currPattern, currPatternLen);
+ }
+ }
+ /* else An explicit currency was requested and is unknown or locale data is malformed. */
+ /* ucurr_* API will get the correct value later on. */
+}
+
Locale
DecimalFormatSymbols::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
U_LOCALE_BASED(locBased, *this);