aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/plurrule.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/plurrule.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/plurrule.cpp')
-rw-r--r--contrib/libs/icu/i18n/plurrule.cpp736
1 files changed, 368 insertions, 368 deletions
diff --git a/contrib/libs/icu/i18n/plurrule.cpp b/contrib/libs/icu/i18n/plurrule.cpp
index f21c622a33..794a3d8c55 100644
--- a/contrib/libs/icu/i18n/plurrule.cpp
+++ b/contrib/libs/icu/i18n/plurrule.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
/*
*******************************************************************************
@@ -17,8 +17,8 @@
#include "unicode/plurrule.h"
#include "unicode/upluralrules.h"
#include "unicode/ures.h"
-#include "unicode/numfmt.h"
-#include "unicode/decimfmt.h"
+#include "unicode/numfmt.h"
+#include "unicode/decimfmt.h"
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
@@ -34,16 +34,16 @@
#include "uvectr32.h"
#include "sharedpluralrules.h"
#include "unifiedcache.h"
-#include "number_decimalquantity.h"
-#include "util.h"
+#include "number_decimalquantity.h"
+#include "util.h"
#if !UCONFIG_NO_FORMATTING
U_NAMESPACE_BEGIN
-using namespace icu::pluralimpl;
-using icu::number::impl::DecimalQuantity;
-
+using namespace icu::pluralimpl;
+using icu::number::impl::DecimalQuantity;
+
static const UChar PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
static const UChar PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SPACE,LOW_N,0};
static const UChar PK_IN[]={LOW_I,LOW_N,0};
@@ -66,15 +66,15 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralKeywordEnumeration)
PluralRules::PluralRules(UErrorCode& /*status*/)
: UObject(),
- mRules(nullptr),
- mInternalStatus(U_ZERO_ERROR)
+ mRules(nullptr),
+ mInternalStatus(U_ZERO_ERROR)
{
}
PluralRules::PluralRules(const PluralRules& other)
: UObject(other),
- mRules(nullptr),
- mInternalStatus(U_ZERO_ERROR)
+ mRules(nullptr),
+ mInternalStatus(U_ZERO_ERROR)
{
*this=other;
}
@@ -89,67 +89,67 @@ SharedPluralRules::~SharedPluralRules() {
PluralRules*
PluralRules::clone() const {
- PluralRules* newObj = new PluralRules(*this);
- // Since clone doesn't have a 'status' parameter, the best we can do is return nullptr if
- // the newly created object was not fully constructed properly (an error occurred).
- if (newObj != nullptr && U_FAILURE(newObj->mInternalStatus)) {
- delete newObj;
- newObj = nullptr;
- }
- return newObj;
+ PluralRules* newObj = new PluralRules(*this);
+ // Since clone doesn't have a 'status' parameter, the best we can do is return nullptr if
+ // the newly created object was not fully constructed properly (an error occurred).
+ if (newObj != nullptr && U_FAILURE(newObj->mInternalStatus)) {
+ delete newObj;
+ newObj = nullptr;
+ }
+ return newObj;
}
PluralRules&
PluralRules::operator=(const PluralRules& other) {
if (this != &other) {
delete mRules;
- mRules = nullptr;
- mInternalStatus = other.mInternalStatus;
- if (U_FAILURE(mInternalStatus)) {
- // bail out early if the object we were copying from was already 'invalid'.
- return *this;
+ mRules = nullptr;
+ mInternalStatus = other.mInternalStatus;
+ if (U_FAILURE(mInternalStatus)) {
+ // bail out early if the object we were copying from was already 'invalid'.
+ return *this;
}
- if (other.mRules != nullptr) {
+ if (other.mRules != nullptr) {
mRules = new RuleChain(*other.mRules);
- if (mRules == nullptr) {
- mInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- }
- else if (U_FAILURE(mRules->fInternalStatus)) {
- // If the RuleChain wasn't fully copied, then set our status to failure as well.
- mInternalStatus = mRules->fInternalStatus;
- }
+ if (mRules == nullptr) {
+ mInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ }
+ else if (U_FAILURE(mRules->fInternalStatus)) {
+ // If the RuleChain wasn't fully copied, then set our status to failure as well.
+ mInternalStatus = mRules->fInternalStatus;
+ }
}
}
return *this;
}
StringEnumeration* PluralRules::getAvailableLocales(UErrorCode &status) {
- if (U_FAILURE(status)) {
- return nullptr;
+ if (U_FAILURE(status)) {
+ return nullptr;
}
- LocalPointer<StringEnumeration> result(new PluralAvailableLocalesEnumeration(status), status);
+ LocalPointer<StringEnumeration> result(new PluralAvailableLocalesEnumeration(status), status);
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
- return result.orphan();
+ return result.orphan();
}
PluralRules* U_EXPORT2
PluralRules::createRules(const UnicodeString& description, UErrorCode& status) {
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
PluralRuleParser parser;
- LocalPointer<PluralRules> newRules(new PluralRules(status), status);
- if (U_FAILURE(status)) {
- return nullptr;
+ LocalPointer<PluralRules> newRules(new PluralRules(status), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
- parser.parse(description, newRules.getAlias(), status);
+ parser.parse(description, newRules.getAlias(), status);
if (U_FAILURE(status)) {
- newRules.adoptInstead(nullptr);
+ newRules.adoptInstead(nullptr);
}
- return newRules.orphan();
+ return newRules.orphan();
}
@@ -165,17 +165,17 @@ template<> U_I18N_API
const SharedPluralRules *LocaleCacheKey<SharedPluralRules>::createObject(
const void * /*unused*/, UErrorCode &status) const {
const char *localeId = fLoc.getName();
- LocalPointer<PluralRules> pr(PluralRules::internalForLocale(localeId, UPLURAL_TYPE_CARDINAL, status), status);
+ LocalPointer<PluralRules> pr(PluralRules::internalForLocale(localeId, UPLURAL_TYPE_CARDINAL, status), status);
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
- LocalPointer<SharedPluralRules> result(new SharedPluralRules(pr.getAlias()), status);
- if (U_FAILURE(status)) {
- return nullptr;
+ LocalPointer<SharedPluralRules> result(new SharedPluralRules(pr.getAlias()), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
- pr.orphan(); // result was successfully created so it nows pr.
+ pr.orphan(); // result was successfully created so it nows pr.
result->addRef();
- return result.orphan();
+ return result.orphan();
}
/* end plural rules cache */
@@ -185,13 +185,13 @@ const SharedPluralRules* U_EXPORT2
PluralRules::createSharedInstance(
const Locale& locale, UPluralType type, UErrorCode& status) {
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
if (type != UPLURAL_TYPE_CARDINAL) {
status = U_UNSUPPORTED_ERROR;
- return nullptr;
+ return nullptr;
}
- const SharedPluralRules *result = nullptr;
+ const SharedPluralRules *result = nullptr;
UnifiedCache::getByLocale(locale, result, status);
return result;
}
@@ -209,11 +209,11 @@ PluralRules::forLocale(const Locale& locale, UPluralType type, UErrorCode& statu
const SharedPluralRules *shared = createSharedInstance(
locale, type, status);
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
PluralRules *result = (*shared)->clone();
shared->removeRef();
- if (result == nullptr) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return result;
@@ -222,23 +222,23 @@ PluralRules::forLocale(const Locale& locale, UPluralType type, UErrorCode& statu
PluralRules* U_EXPORT2
PluralRules::internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status) {
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
if (type >= UPLURAL_TYPE_COUNT) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return nullptr;
+ return nullptr;
}
- LocalPointer<PluralRules> newObj(new PluralRules(status), status);
- if (U_FAILURE(status)) {
- return nullptr;
+ LocalPointer<PluralRules> newObj(new PluralRules(status), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
UnicodeString locRule = newObj->getRuleFromResource(locale, type, status);
- // TODO: which other errors, if any, should be returned?
+ // TODO: which other errors, if any, should be returned?
if (locRule.length() == 0) {
- // If an out-of-memory error occurred, then stop and report the failure.
- if (status == U_MEMORY_ALLOCATION_ERROR) {
- return nullptr;
- }
+ // If an out-of-memory error occurred, then stop and report the failure.
+ if (status == U_MEMORY_ALLOCATION_ERROR) {
+ return nullptr;
+ }
// Locales with no specific rules (all numbers have the "other" category
// will return a U_MISSING_RESOURCE_ERROR at this point. This is not
// an error.
@@ -246,13 +246,13 @@ PluralRules::internalForLocale(const Locale& locale, UPluralType type, UErrorCod
status = U_ZERO_ERROR;
}
PluralRuleParser parser;
- parser.parse(locRule, newObj.getAlias(), status);
+ parser.parse(locRule, newObj.getAlias(), status);
// TODO: should rule parse errors be returned, or
// should we silently use default rules?
// Original impl used default rules.
// Ask the question to ICU Core.
- return newObj.orphan();
+ return newObj.orphan();
}
UnicodeString
@@ -266,23 +266,23 @@ PluralRules::select(double number) const {
}
UnicodeString
-PluralRules::select(const number::FormattedNumber& number, UErrorCode& status) const {
- DecimalQuantity dq;
- number.getDecimalQuantity(dq, status);
- if (U_FAILURE(status)) {
- return ICU_Utility::makeBogusString();
+PluralRules::select(const number::FormattedNumber& number, UErrorCode& status) const {
+ DecimalQuantity dq;
+ number.getDecimalQuantity(dq, status);
+ if (U_FAILURE(status)) {
+ return ICU_Utility::makeBogusString();
}
- return select(dq);
+ return select(dq);
}
UnicodeString
-PluralRules::select(const IFixedDecimal &number) const {
- if (mRules == nullptr) {
+PluralRules::select(const IFixedDecimal &number) const {
+ if (mRules == nullptr) {
return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
}
- else {
- return mRules->select(number);
- }
+ else {
+ return mRules->select(number);
+ }
}
@@ -290,17 +290,17 @@ PluralRules::select(const IFixedDecimal &number) const {
StringEnumeration*
PluralRules::getKeywords(UErrorCode& status) const {
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
+ }
+ if (U_FAILURE(mInternalStatus)) {
+ status = mInternalStatus;
+ return nullptr;
+ }
+ LocalPointer<StringEnumeration> nameEnumerator(new PluralKeywordEnumeration(mRules, status), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
- if (U_FAILURE(mInternalStatus)) {
- status = mInternalStatus;
- return nullptr;
- }
- LocalPointer<StringEnumeration> nameEnumerator(new PluralKeywordEnumeration(mRules, status), status);
- if (U_FAILURE(status)) {
- return nullptr;
- }
- return nameEnumerator.orphan();
+ return nameEnumerator.orphan();
}
double
@@ -316,7 +316,7 @@ PluralRules::getAllKeywordValues(const UnicodeString & /* keyword */, double * /
return 0;
}
-
+
static double scaleForInt(double d) {
double scale = 1.0;
while (d != floor(d)) {
@@ -351,7 +351,7 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
dest[sampleCount++] = sampleValue;
}
} else {
-
+
FixedDecimal fixedLo(sampleRange.tempSubStringBetween(0, tildeIndex), status);
FixedDecimal fixedHi(sampleRange.tempSubStringBetween(tildeIndex+1), status);
double rangeLo = fixedLo.source;
@@ -367,7 +367,7 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
// For ranges of samples with fraction decimal digits, scale the number up so that we
// are adding one in the units place. Avoids roundoffs from repetitive adds of tenths.
- double scale = scaleForInt(rangeLo);
+ double scale = scaleForInt(rangeLo);
double t = scaleForInt(rangeHi);
if (t > scale) {
scale = t;
@@ -398,28 +398,28 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
int32_t
PluralRules::getSamples(const UnicodeString &keyword, double *dest,
int32_t destCapacity, UErrorCode& status) {
- if (destCapacity == 0 || U_FAILURE(status)) {
- return 0;
- }
- if (U_FAILURE(mInternalStatus)) {
- status = mInternalStatus;
- return 0;
- }
+ if (destCapacity == 0 || U_FAILURE(status)) {
+ return 0;
+ }
+ if (U_FAILURE(mInternalStatus)) {
+ status = mInternalStatus;
+ return 0;
+ }
RuleChain *rc = rulesForKeyword(keyword);
- if (rc == nullptr) {
+ if (rc == nullptr) {
return 0;
}
int32_t numSamples = getSamplesFromString(rc->fIntegerSamples, dest, destCapacity, status);
- if (numSamples == 0) {
+ if (numSamples == 0) {
numSamples = getSamplesFromString(rc->fDecimalSamples, dest, destCapacity, status);
}
return numSamples;
}
-
+
RuleChain *PluralRules::rulesForKeyword(const UnicodeString &keyword) const {
RuleChain *rc;
- for (rc = mRules; rc != nullptr; rc = rc->fNext) {
+ for (rc = mRules; rc != nullptr; rc = rc->fNext) {
if (rc->fKeyword == keyword) {
break;
}
@@ -433,7 +433,7 @@ PluralRules::isKeyword(const UnicodeString& keyword) const {
if (0 == keyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
return true;
}
- return rulesForKeyword(keyword) != nullptr;
+ return rulesForKeyword(keyword) != nullptr;
}
UnicodeString
@@ -459,13 +459,13 @@ PluralRules::operator==(const PluralRules& other) const {
return FALSE;
}
myKeywordList->reset(status);
- while ((ptrKeyword=myKeywordList->snext(status))!=nullptr) {
+ while ((ptrKeyword=myKeywordList->snext(status))!=nullptr) {
if (!other.isKeyword(*ptrKeyword)) {
return FALSE;
}
}
otherKeywordList->reset(status);
- while ((ptrKeyword=otherKeywordList->snext(status))!=nullptr) {
+ while ((ptrKeyword=otherKeywordList->snext(status))!=nullptr) {
if (!this->isKeyword(*ptrKeyword)) {
return FALSE;
}
@@ -498,33 +498,33 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
}
switch (type) {
case tAnd:
- U_ASSERT(curAndConstraint != nullptr);
- curAndConstraint = curAndConstraint->add(status);
+ U_ASSERT(curAndConstraint != nullptr);
+ curAndConstraint = curAndConstraint->add(status);
break;
case tOr:
{
- U_ASSERT(currentChain != nullptr);
+ U_ASSERT(currentChain != nullptr);
OrConstraint *orNode=currentChain->ruleHeader;
- while (orNode->next != nullptr) {
+ while (orNode->next != nullptr) {
orNode = orNode->next;
}
orNode->next= new OrConstraint();
- if (orNode->next == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- break;
- }
+ if (orNode->next == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ break;
+ }
orNode=orNode->next;
- orNode->next=nullptr;
- curAndConstraint = orNode->add(status);
+ orNode->next=nullptr;
+ curAndConstraint = orNode->add(status);
}
break;
case tIs:
- U_ASSERT(curAndConstraint != nullptr);
+ U_ASSERT(curAndConstraint != nullptr);
U_ASSERT(curAndConstraint->value == -1);
- U_ASSERT(curAndConstraint->rangeList == nullptr);
+ U_ASSERT(curAndConstraint->rangeList == nullptr);
break;
case tNot:
- U_ASSERT(curAndConstraint != nullptr);
+ U_ASSERT(curAndConstraint != nullptr);
curAndConstraint->negated=TRUE;
break;
@@ -534,29 +534,29 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
case tIn:
case tWithin:
case tEqual:
- {
- U_ASSERT(curAndConstraint != nullptr);
- LocalPointer<UVector32> newRangeList(new UVector32(status), status);
- if (U_FAILURE(status)) {
- break;
- }
- curAndConstraint->rangeList = newRangeList.orphan();
- curAndConstraint->rangeList->addElement(-1, status); // range Low
- curAndConstraint->rangeList->addElement(-1, status); // range Hi
- rangeLowIdx = 0;
- rangeHiIdx = 1;
- curAndConstraint->value=PLURAL_RANGE_HIGH;
- curAndConstraint->integerOnly = (type != tWithin);
- }
+ {
+ U_ASSERT(curAndConstraint != nullptr);
+ LocalPointer<UVector32> newRangeList(new UVector32(status), status);
+ if (U_FAILURE(status)) {
+ break;
+ }
+ curAndConstraint->rangeList = newRangeList.orphan();
+ curAndConstraint->rangeList->addElement(-1, status); // range Low
+ curAndConstraint->rangeList->addElement(-1, status); // range Hi
+ rangeLowIdx = 0;
+ rangeHiIdx = 1;
+ curAndConstraint->value=PLURAL_RANGE_HIGH;
+ curAndConstraint->integerOnly = (type != tWithin);
+ }
break;
case tNumber:
- U_ASSERT(curAndConstraint != nullptr);
+ U_ASSERT(curAndConstraint != nullptr);
if ( (curAndConstraint->op==AndConstraint::MOD)&&
(curAndConstraint->opNum == -1 ) ) {
curAndConstraint->opNum=getNumberValue(token);
}
else {
- if (curAndConstraint->rangeList == nullptr) {
+ if (curAndConstraint->rangeList == nullptr) {
// this is for an 'is' rule
curAndConstraint->value = getNumberValue(token);
} else {
@@ -567,7 +567,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
}
else {
curAndConstraint->rangeList->setElementAt(getNumberValue(token), rangeHiIdx);
- if (curAndConstraint->rangeList->elementAti(rangeLowIdx) >
+ if (curAndConstraint->rangeList->elementAti(rangeLowIdx) >
curAndConstraint->rangeList->elementAti(rangeHiIdx)) {
// Range Lower bound > Range Upper bound.
// U_UNEXPECTED_TOKEN seems a little funny, but it is consistently
@@ -582,7 +582,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
case tComma:
// TODO: rule syntax checking is inadequate, can happen with badly formed rules.
// Catch cases like "n mod 10, is 1" here instead.
- if (curAndConstraint == nullptr || curAndConstraint->rangeList == nullptr) {
+ if (curAndConstraint == nullptr || curAndConstraint->rangeList == nullptr) {
status = U_UNEXPECTED_TOKEN;
break;
}
@@ -593,7 +593,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
curAndConstraint->rangeList->addElement(-1, status); // range Hi
break;
case tMod:
- U_ASSERT(curAndConstraint != nullptr);
+ U_ASSERT(curAndConstraint != nullptr);
curAndConstraint->op=AndConstraint::MOD;
break;
case tVariableN:
@@ -601,24 +601,24 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
case tVariableF:
case tVariableT:
case tVariableV:
- U_ASSERT(curAndConstraint != nullptr);
+ U_ASSERT(curAndConstraint != nullptr);
curAndConstraint->digitsType = type;
break;
case tKeyword:
{
RuleChain *newChain = new RuleChain;
- if (newChain == nullptr) {
+ if (newChain == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
newChain->fKeyword = token;
- if (prules->mRules == nullptr) {
+ if (prules->mRules == nullptr) {
prules->mRules = newChain;
} else {
// The new rule chain goes at the end of the linked list of rule chains,
// unless there is an "other" keyword & chain. "other" must remain last.
RuleChain *insertAfter = prules->mRules;
- while (insertAfter->fNext!=nullptr &&
+ while (insertAfter->fNext!=nullptr &&
insertAfter->fNext->fKeyword.compare(PLURAL_KEYWORD_OTHER, 5) != 0 ){
insertAfter=insertAfter->fNext;
}
@@ -626,12 +626,12 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
insertAfter->fNext = newChain;
}
OrConstraint *orNode = new OrConstraint();
- if (orNode == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- break;
- }
+ if (orNode == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ break;
+ }
newChain->ruleHeader = orNode;
- curAndConstraint = orNode->add(status);
+ curAndConstraint = orNode->add(status);
currentChain = newChain;
}
break;
@@ -663,7 +663,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
currentChain->fDecimalSamples.append(token);
}
break;
-
+
default:
break;
}
@@ -681,7 +681,7 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
if (U_FAILURE(errCode)) {
return emptyStr;
}
- LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "plurals", &errCode));
+ LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "plurals", &errCode));
if(U_FAILURE(errCode)) {
return emptyStr;
}
@@ -698,33 +698,33 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
errCode = U_ILLEGAL_ARGUMENT_ERROR;
return emptyStr;
}
- LocalUResourceBundlePointer locRes(ures_getByKey(rb.getAlias(), typeKey, nullptr, &errCode));
+ LocalUResourceBundlePointer locRes(ures_getByKey(rb.getAlias(), typeKey, nullptr, &errCode));
if(U_FAILURE(errCode)) {
return emptyStr;
}
int32_t resLen=0;
- const char *curLocaleName=locale.getBaseName();
+ const char *curLocaleName=locale.getBaseName();
const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
- if (s == nullptr) {
+ if (s == nullptr) {
// Check parent locales.
UErrorCode status = U_ZERO_ERROR;
char parentLocaleName[ULOC_FULLNAME_CAPACITY];
- const char *curLocaleName2=locale.getBaseName();
- uprv_strcpy(parentLocaleName, curLocaleName2);
+ const char *curLocaleName2=locale.getBaseName();
+ uprv_strcpy(parentLocaleName, curLocaleName2);
while (uloc_getParent(parentLocaleName, parentLocaleName,
ULOC_FULLNAME_CAPACITY, &status) > 0) {
resLen=0;
s = ures_getStringByKey(locRes.getAlias(), parentLocaleName, &resLen, &status);
- if (s != nullptr) {
+ if (s != nullptr) {
errCode = U_ZERO_ERROR;
break;
}
status = U_ZERO_ERROR;
}
}
- if (s==nullptr) {
+ if (s==nullptr) {
return emptyStr;
}
@@ -732,18 +732,18 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
u_UCharsToChars(s, setKey, resLen + 1);
// printf("\n PluralRule: %s\n", setKey);
- LocalUResourceBundlePointer ruleRes(ures_getByKey(rb.getAlias(), "rules", nullptr, &errCode));
+ LocalUResourceBundlePointer ruleRes(ures_getByKey(rb.getAlias(), "rules", nullptr, &errCode));
if(U_FAILURE(errCode)) {
return emptyStr;
}
- LocalUResourceBundlePointer setRes(ures_getByKey(ruleRes.getAlias(), setKey, nullptr, &errCode));
+ LocalUResourceBundlePointer setRes(ures_getByKey(ruleRes.getAlias(), setKey, nullptr, &errCode));
if (U_FAILURE(errCode)) {
return emptyStr;
}
int32_t numberKeys = ures_getSize(setRes.getAlias());
UnicodeString result;
- const char *key=nullptr;
+ const char *key=nullptr;
for(int32_t i=0; i<numberKeys; ++i) { // Keys are zero, one, few, ...
UnicodeString rules = ures_getNextUnicodeString(setRes.getAlias(), &key, &errCode);
UnicodeString uKey(key, -1, US_INV);
@@ -759,58 +759,58 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
UnicodeString
PluralRules::getRules() const {
UnicodeString rules;
- if (mRules != nullptr) {
+ if (mRules != nullptr) {
mRules->dumpRules(rules);
}
return rules;
}
AndConstraint::AndConstraint(const AndConstraint& other) {
- this->fInternalStatus = other.fInternalStatus;
- if (U_FAILURE(fInternalStatus)) {
- return; // stop early if the object we are copying from is invalid.
- }
+ this->fInternalStatus = other.fInternalStatus;
+ if (U_FAILURE(fInternalStatus)) {
+ return; // stop early if the object we are copying from is invalid.
+ }
this->op = other.op;
this->opNum=other.opNum;
this->value=other.value;
- if (other.rangeList != nullptr) {
- LocalPointer<UVector32> newRangeList(new UVector32(fInternalStatus), fInternalStatus);
- if (U_FAILURE(fInternalStatus)) {
- return;
- }
- this->rangeList = newRangeList.orphan();
- this->rangeList->assign(*other.rangeList, fInternalStatus);
+ if (other.rangeList != nullptr) {
+ LocalPointer<UVector32> newRangeList(new UVector32(fInternalStatus), fInternalStatus);
+ if (U_FAILURE(fInternalStatus)) {
+ return;
+ }
+ this->rangeList = newRangeList.orphan();
+ this->rangeList->assign(*other.rangeList, fInternalStatus);
}
this->integerOnly=other.integerOnly;
this->negated=other.negated;
this->digitsType = other.digitsType;
- if (other.next != nullptr) {
+ if (other.next != nullptr) {
this->next = new AndConstraint(*other.next);
- if (this->next == nullptr) {
- fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- }
+ if (this->next == nullptr) {
+ fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ }
}
}
AndConstraint::~AndConstraint() {
delete rangeList;
- rangeList = nullptr;
- delete next;
- next = nullptr;
+ rangeList = nullptr;
+ delete next;
+ next = nullptr;
}
UBool
-AndConstraint::isFulfilled(const IFixedDecimal &number) {
+AndConstraint::isFulfilled(const IFixedDecimal &number) {
UBool result = TRUE;
if (digitsType == none) {
// An empty AndConstraint, created by a rule with a keyword but no following expression.
return TRUE;
}
-
- PluralOperand operand = tokenTypeToPluralOperand(digitsType);
- double n = number.getPluralOperand(operand); // pulls n | i | v | f value for the number.
- // Will always be positive.
- // May be non-integer (n option only)
+
+ PluralOperand operand = tokenTypeToPluralOperand(digitsType);
+ double n = number.getPluralOperand(operand); // pulls n | i | v | f value for the number.
+ // Will always be positive.
+ // May be non-integer (n option only)
do {
if (integerOnly && n != uprv_floor(n)) {
result = FALSE;
@@ -820,7 +820,7 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) {
if (op == MOD) {
n = fmod(n, opNum);
}
- if (rangeList == nullptr) {
+ if (rangeList == nullptr) {
result = value == -1 || // empty rule
n == value; // 'is' rule
break;
@@ -841,79 +841,79 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) {
}
AndConstraint*
-AndConstraint::add(UErrorCode& status) {
- if (U_FAILURE(fInternalStatus)) {
- status = fInternalStatus;
- return nullptr;
- }
+AndConstraint::add(UErrorCode& status) {
+ if (U_FAILURE(fInternalStatus)) {
+ status = fInternalStatus;
+ return nullptr;
+ }
this->next = new AndConstraint();
- if (this->next == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+ if (this->next == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
return this->next;
}
OrConstraint::OrConstraint(const OrConstraint& other) {
- this->fInternalStatus = other.fInternalStatus;
- if (U_FAILURE(fInternalStatus)) {
- return; // stop early if the object we are copying from is invalid.
+ this->fInternalStatus = other.fInternalStatus;
+ if (U_FAILURE(fInternalStatus)) {
+ return; // stop early if the object we are copying from is invalid.
}
- if ( other.childNode != nullptr ) {
+ if ( other.childNode != nullptr ) {
this->childNode = new AndConstraint(*(other.childNode));
- if (this->childNode == nullptr) {
- fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
+ if (this->childNode == nullptr) {
+ fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
}
- if (other.next != nullptr ) {
+ if (other.next != nullptr ) {
this->next = new OrConstraint(*(other.next));
- if (this->next == nullptr) {
- fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- if (U_FAILURE(this->next->fInternalStatus)) {
- this->fInternalStatus = this->next->fInternalStatus;
- }
+ if (this->next == nullptr) {
+ fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ if (U_FAILURE(this->next->fInternalStatus)) {
+ this->fInternalStatus = this->next->fInternalStatus;
+ }
}
}
OrConstraint::~OrConstraint() {
- delete childNode;
- childNode = nullptr;
- delete next;
- next = nullptr;
+ delete childNode;
+ childNode = nullptr;
+ delete next;
+ next = nullptr;
}
AndConstraint*
-OrConstraint::add(UErrorCode& status) {
- if (U_FAILURE(fInternalStatus)) {
- status = fInternalStatus;
- return nullptr;
- }
+OrConstraint::add(UErrorCode& status) {
+ if (U_FAILURE(fInternalStatus)) {
+ status = fInternalStatus;
+ return nullptr;
+ }
OrConstraint *curOrConstraint=this;
{
- while (curOrConstraint->next!=nullptr) {
+ while (curOrConstraint->next!=nullptr) {
curOrConstraint = curOrConstraint->next;
}
- U_ASSERT(curOrConstraint->childNode == nullptr);
+ U_ASSERT(curOrConstraint->childNode == nullptr);
curOrConstraint->childNode = new AndConstraint();
- if (curOrConstraint->childNode == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+ if (curOrConstraint->childNode == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
}
return curOrConstraint->childNode;
}
UBool
-OrConstraint::isFulfilled(const IFixedDecimal &number) {
+OrConstraint::isFulfilled(const IFixedDecimal &number) {
OrConstraint* orRule=this;
UBool result=FALSE;
- while (orRule!=nullptr && !result) {
+ while (orRule!=nullptr && !result) {
result=TRUE;
AndConstraint* andRule = orRule->childNode;
- while (andRule!=nullptr && result) {
+ while (andRule!=nullptr && result) {
result = andRule->isFulfilled(number);
andRule=andRule->next;
}
@@ -924,33 +924,33 @@ OrConstraint::isFulfilled(const IFixedDecimal &number) {
}
-RuleChain::RuleChain(const RuleChain& other) :
- fKeyword(other.fKeyword), fDecimalSamples(other.fDecimalSamples),
- fIntegerSamples(other.fIntegerSamples), fDecimalSamplesUnbounded(other.fDecimalSamplesUnbounded),
- fIntegerSamplesUnbounded(other.fIntegerSamplesUnbounded), fInternalStatus(other.fInternalStatus) {
- if (U_FAILURE(this->fInternalStatus)) {
- return; // stop early if the object we are copying from is invalid.
- }
- if (other.ruleHeader != nullptr) {
+RuleChain::RuleChain(const RuleChain& other) :
+ fKeyword(other.fKeyword), fDecimalSamples(other.fDecimalSamples),
+ fIntegerSamples(other.fIntegerSamples), fDecimalSamplesUnbounded(other.fDecimalSamplesUnbounded),
+ fIntegerSamplesUnbounded(other.fIntegerSamplesUnbounded), fInternalStatus(other.fInternalStatus) {
+ if (U_FAILURE(this->fInternalStatus)) {
+ return; // stop early if the object we are copying from is invalid.
+ }
+ if (other.ruleHeader != nullptr) {
this->ruleHeader = new OrConstraint(*(other.ruleHeader));
- if (this->ruleHeader == nullptr) {
- this->fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- }
- else if (U_FAILURE(this->ruleHeader->fInternalStatus)) {
- // If the OrConstraint wasn't fully copied, then set our status to failure as well.
- this->fInternalStatus = this->ruleHeader->fInternalStatus;
- return; // exit early.
- }
- }
- if (other.fNext != nullptr ) {
+ if (this->ruleHeader == nullptr) {
+ this->fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ }
+ else if (U_FAILURE(this->ruleHeader->fInternalStatus)) {
+ // If the OrConstraint wasn't fully copied, then set our status to failure as well.
+ this->fInternalStatus = this->ruleHeader->fInternalStatus;
+ return; // exit early.
+ }
+ }
+ if (other.fNext != nullptr ) {
this->fNext = new RuleChain(*other.fNext);
- if (this->fNext == nullptr) {
- this->fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
- }
- else if (U_FAILURE(this->fNext->fInternalStatus)) {
- // If the RuleChain wasn't fully copied, then set our status to failure as well.
- this->fInternalStatus = this->fNext->fInternalStatus;
- }
+ if (this->fNext == nullptr) {
+ this->fInternalStatus = U_MEMORY_ALLOCATION_ERROR;
+ }
+ else if (U_FAILURE(this->fNext->fInternalStatus)) {
+ // If the RuleChain wasn't fully copied, then set our status to failure as well.
+ this->fInternalStatus = this->fNext->fInternalStatus;
+ }
}
}
@@ -960,9 +960,9 @@ RuleChain::~RuleChain() {
}
UnicodeString
-RuleChain::select(const IFixedDecimal &number) const {
- if (!number.isNaN() && !number.isInfinite()) {
- for (const RuleChain *rules = this; rules != nullptr; rules = rules->fNext) {
+RuleChain::select(const IFixedDecimal &number) const {
+ if (!number.isNaN() && !number.isInfinite()) {
+ for (const RuleChain *rules = this; rules != nullptr; rules = rules->fNext) {
if (rules->ruleHeader->isFulfilled(number)) {
return rules->fKeyword;
}
@@ -994,17 +994,17 @@ void
RuleChain::dumpRules(UnicodeString& result) {
UChar digitString[16];
- if ( ruleHeader != nullptr ) {
+ if ( ruleHeader != nullptr ) {
result += fKeyword;
result += COLON;
result += SPACE;
OrConstraint* orRule=ruleHeader;
- while ( orRule != nullptr ) {
+ while ( orRule != nullptr ) {
AndConstraint* andRule=orRule->childNode;
- while ( andRule != nullptr ) {
- if ((andRule->op==AndConstraint::NONE) && (andRule->rangeList==nullptr) && (andRule->value == -1)) {
+ while ( andRule != nullptr ) {
+ if ((andRule->op==AndConstraint::NONE) && (andRule->rangeList==nullptr) && (andRule->value == -1)) {
// Empty Rules.
- } else if ( (andRule->op==AndConstraint::NONE) && (andRule->rangeList==nullptr) ) {
+ } else if ( (andRule->op==AndConstraint::NONE) && (andRule->rangeList==nullptr) ) {
result += tokenString(andRule->digitsType);
result += UNICODE_STRING_SIMPLE(" is ");
if (andRule->negated) {
@@ -1021,7 +1021,7 @@ RuleChain::dumpRules(UnicodeString& result) {
uprv_itou(digitString,16, andRule->opNum,10,0);
result += UnicodeString(digitString);
}
- if (andRule->rangeList==nullptr) {
+ if (andRule->rangeList==nullptr) {
if (andRule->negated) {
result += UNICODE_STRING_SIMPLE(" is not ");
uprv_itou(digitString,16, andRule->value,10,0);
@@ -1064,16 +1064,16 @@ RuleChain::dumpRules(UnicodeString& result) {
}
}
}
- if ( (andRule=andRule->next) != nullptr) {
+ if ( (andRule=andRule->next) != nullptr) {
result += UNICODE_STRING_SIMPLE(" and ");
}
}
- if ( (orRule = orRule->next) != nullptr ) {
+ if ( (orRule = orRule->next) != nullptr ) {
result += UNICODE_STRING_SIMPLE(" or ");
}
}
}
- if ( fNext != nullptr ) {
+ if ( fNext != nullptr ) {
result += UNICODE_STRING_SIMPLE("; ");
fNext->dumpRules(result);
}
@@ -1082,9 +1082,9 @@ RuleChain::dumpRules(UnicodeString& result) {
UErrorCode
RuleChain::getKeywords(int32_t capacityOfKeywords, UnicodeString* keywords, int32_t& arraySize) const {
- if (U_FAILURE(fInternalStatus)) {
- return fInternalStatus;
- }
+ if (U_FAILURE(fInternalStatus)) {
+ return fInternalStatus;
+ }
if ( arraySize < capacityOfKeywords-1 ) {
keywords[arraySize++]=fKeyword;
}
@@ -1092,7 +1092,7 @@ RuleChain::getKeywords(int32_t capacityOfKeywords, UnicodeString* keywords, int3
return U_BUFFER_OVERFLOW_ERROR;
}
- if ( fNext != nullptr ) {
+ if ( fNext != nullptr ) {
return fNext->getKeywords(capacityOfKeywords, keywords, arraySize);
}
else {
@@ -1106,7 +1106,7 @@ RuleChain::isKeyword(const UnicodeString& keywordParam) const {
return TRUE;
}
- if ( fNext != nullptr ) {
+ if ( fNext != nullptr ) {
return fNext->isKeyword(keywordParam);
}
else {
@@ -1115,9 +1115,9 @@ RuleChain::isKeyword(const UnicodeString& keywordParam) const {
}
-PluralRuleParser::PluralRuleParser() :
- ruleIndex(0), token(), type(none), prevType(none),
- curAndConstraint(nullptr), currentChain(nullptr), rangeLowIdx(-1), rangeHiIdx(-1)
+PluralRuleParser::PluralRuleParser() :
+ ruleIndex(0), token(), type(none), prevType(none),
+ curAndConstraint(nullptr), currentChain(nullptr), rangeLowIdx(-1), rangeHiIdx(-1)
{
}
@@ -1218,8 +1218,8 @@ PluralRuleParser::checkSyntax(UErrorCode &status)
break;
case tNumber:
if (type != tDot2 && type != tSemiColon && type != tIs && type != tNot &&
- type != tIn && type != tEqual && type != tNotEqual && type != tWithin &&
- type != tAnd && type != tOr && type != tComma && type != tAt &&
+ type != tIn && type != tEqual && type != tNotEqual && type != tWithin &&
+ type != tAnd && type != tOr && type != tComma && type != tAt &&
type != tEOF)
{
status = U_UNEXPECTED_TOKEN;
@@ -1264,7 +1264,7 @@ PluralRuleParser::getNextToken(UErrorCode &status)
return;
}
int32_t curIndex= ruleIndex;
-
+
switch (type) {
case tColon:
case tSemiColon:
@@ -1369,7 +1369,7 @@ PluralRuleParser::charType(UChar ch) {
// Set token type for reserved words in the Plural Rule syntax.
-tokenType
+tokenType
PluralRuleParser::getKeyType(const UnicodeString &token, tokenType keyType)
{
if (keyType != tKeyword) {
@@ -1415,36 +1415,36 @@ PluralKeywordEnumeration::PluralKeywordEnumeration(RuleChain *header, UErrorCode
return;
}
fKeywordNames.setDeleter(uprv_deleteUObject);
- UBool addKeywordOther = TRUE;
- RuleChain *node = header;
- while (node != nullptr) {
- auto newElem = new UnicodeString(node->fKeyword);
- if (newElem == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- fKeywordNames.addElement(newElem, status);
+ UBool addKeywordOther = TRUE;
+ RuleChain *node = header;
+ while (node != nullptr) {
+ auto newElem = new UnicodeString(node->fKeyword);
+ if (newElem == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ fKeywordNames.addElement(newElem, status);
if (U_FAILURE(status)) {
- delete newElem;
+ delete newElem;
return;
}
if (0 == node->fKeyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
- addKeywordOther = FALSE;
+ addKeywordOther = FALSE;
}
- node = node->fNext;
+ node = node->fNext;
}
if (addKeywordOther) {
- auto newElem = new UnicodeString(PLURAL_KEYWORD_OTHER);
- if (newElem == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- fKeywordNames.addElement(newElem, status);
- if (U_FAILURE(status)) {
- delete newElem;
- return;
- }
+ auto newElem = new UnicodeString(PLURAL_KEYWORD_OTHER);
+ if (newElem == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ fKeywordNames.addElement(newElem, status);
+ if (U_FAILURE(status)) {
+ delete newElem;
+ return;
+ }
}
}
@@ -1453,7 +1453,7 @@ PluralKeywordEnumeration::snext(UErrorCode& status) {
if (U_SUCCESS(status) && pos < fKeywordNames.size()) {
return (const UnicodeString*)fKeywordNames.elementAt(pos++);
}
- return nullptr;
+ return nullptr;
}
void
@@ -1463,27 +1463,27 @@ PluralKeywordEnumeration::reset(UErrorCode& /*status*/) {
int32_t
PluralKeywordEnumeration::count(UErrorCode& /*status*/) const {
- return fKeywordNames.size();
+ return fKeywordNames.size();
}
PluralKeywordEnumeration::~PluralKeywordEnumeration() {
}
-PluralOperand tokenTypeToPluralOperand(tokenType tt) {
- switch(tt) {
- case tVariableN:
- return PLURAL_OPERAND_N;
- case tVariableI:
- return PLURAL_OPERAND_I;
- case tVariableF:
- return PLURAL_OPERAND_F;
- case tVariableV:
- return PLURAL_OPERAND_V;
- case tVariableT:
- return PLURAL_OPERAND_T;
- default:
- UPRV_UNREACHABLE; // unexpected.
- }
+PluralOperand tokenTypeToPluralOperand(tokenType tt) {
+ switch(tt) {
+ case tVariableN:
+ return PLURAL_OPERAND_N;
+ case tVariableI:
+ return PLURAL_OPERAND_I;
+ case tVariableF:
+ return PLURAL_OPERAND_F;
+ case tVariableV:
+ return PLURAL_OPERAND_V;
+ case tVariableT:
+ return PLURAL_OPERAND_T;
+ default:
+ UPRV_UNREACHABLE; // unexpected.
+ }
}
FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) {
@@ -1523,14 +1523,14 @@ FixedDecimal::FixedDecimal() {
FixedDecimal::FixedDecimal(const UnicodeString &num, UErrorCode &status) {
CharString cs;
cs.appendInvariantChars(num, status);
- DecimalQuantity dl;
- dl.setToDecNumber(cs.toStringPiece(), status);
+ DecimalQuantity dl;
+ dl.setToDecNumber(cs.toStringPiece(), status);
if (U_FAILURE(status)) {
init(0, 0, 0);
return;
}
int32_t decimalPoint = num.indexOf(DOT);
- double n = dl.toDouble();
+ double n = dl.toDouble();
if (decimalPoint == -1) {
init(n, 0, 0);
} else {
@@ -1546,15 +1546,15 @@ FixedDecimal::FixedDecimal(const FixedDecimal &other) {
decimalDigits = other.decimalDigits;
decimalDigitsWithoutTrailingZeros = other.decimalDigitsWithoutTrailingZeros;
intValue = other.intValue;
- _hasIntegerValue = other._hasIntegerValue;
+ _hasIntegerValue = other._hasIntegerValue;
isNegative = other.isNegative;
- _isNaN = other._isNaN;
- _isInfinite = other._isInfinite;
+ _isNaN = other._isNaN;
+ _isInfinite = other._isInfinite;
}
-FixedDecimal::~FixedDecimal() = default;
+FixedDecimal::~FixedDecimal() = default;
+
-
void FixedDecimal::init(double n) {
int32_t numFractionDigits = decimals(n);
init(n, numFractionDigits, getFractionalDigits(n, numFractionDigits));
@@ -1564,16 +1564,16 @@ void FixedDecimal::init(double n) {
void FixedDecimal::init(double n, int32_t v, int64_t f) {
isNegative = n < 0.0;
source = fabs(n);
- _isNaN = uprv_isNaN(source);
- _isInfinite = uprv_isInfinite(source);
- if (_isNaN || _isInfinite) {
+ _isNaN = uprv_isNaN(source);
+ _isInfinite = uprv_isInfinite(source);
+ if (_isNaN || _isInfinite) {
v = 0;
f = 0;
intValue = 0;
- _hasIntegerValue = FALSE;
+ _hasIntegerValue = FALSE;
} else {
intValue = (int64_t)source;
- _hasIntegerValue = (source == intValue);
+ _hasIntegerValue = (source == intValue);
}
visibleDecimalDigitCount = v;
@@ -1635,7 +1635,7 @@ int32_t FixedDecimal::decimals(double n) {
if (buf[i] != '0') {
break;
}
- --numFractionDigits;
+ --numFractionDigits;
}
numFractionDigits -= exponent; // Fraction part of fixed point representation.
return numFractionDigits;
@@ -1685,36 +1685,36 @@ void FixedDecimal::adjustForMinFractionDigits(int32_t minFractionDigits) {
}
}
-
-double FixedDecimal::getPluralOperand(PluralOperand operand) const {
+
+double FixedDecimal::getPluralOperand(PluralOperand operand) const {
switch(operand) {
- case PLURAL_OPERAND_N: return source;
- case PLURAL_OPERAND_I: return static_cast<double>(intValue);
- case PLURAL_OPERAND_F: return static_cast<double>(decimalDigits);
- case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
- case PLURAL_OPERAND_V: return visibleDecimalDigitCount;
- case PLURAL_OPERAND_E: return 0;
+ case PLURAL_OPERAND_N: return source;
+ case PLURAL_OPERAND_I: return static_cast<double>(intValue);
+ case PLURAL_OPERAND_F: return static_cast<double>(decimalDigits);
+ case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
+ case PLURAL_OPERAND_V: return visibleDecimalDigitCount;
+ case PLURAL_OPERAND_E: return 0;
default:
- UPRV_UNREACHABLE; // unexpected.
- }
-}
-
-bool FixedDecimal::isNaN() const {
- return _isNaN;
-}
-
-bool FixedDecimal::isInfinite() const {
- return _isInfinite;
-}
-
-bool FixedDecimal::hasIntegerValue() const {
- return _hasIntegerValue;
-}
-
-bool FixedDecimal::isNanOrInfinity() const {
- return _isNaN || _isInfinite;
-}
-
+ UPRV_UNREACHABLE; // unexpected.
+ }
+}
+
+bool FixedDecimal::isNaN() const {
+ return _isNaN;
+}
+
+bool FixedDecimal::isInfinite() const {
+ return _isInfinite;
+}
+
+bool FixedDecimal::hasIntegerValue() const {
+ return _hasIntegerValue;
+}
+
+bool FixedDecimal::isNanOrInfinity() const {
+ return _isNaN || _isInfinite;
+}
+
int32_t FixedDecimal::getVisibleFractionDigitCount() const {
return visibleDecimalDigitCount;
}
@@ -1726,36 +1726,36 @@ PluralAvailableLocalesEnumeration::PluralAvailableLocalesEnumeration(UErrorCode
if (U_FAILURE(status)) {
return;
}
- fOpenStatus = U_ZERO_ERROR; // clear any warnings.
- LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "plurals", &fOpenStatus));
- fLocales = ures_getByKey(rb.getAlias(), "locales", nullptr, &fOpenStatus);
+ fOpenStatus = U_ZERO_ERROR; // clear any warnings.
+ LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "plurals", &fOpenStatus));
+ fLocales = ures_getByKey(rb.getAlias(), "locales", nullptr, &fOpenStatus);
}
PluralAvailableLocalesEnumeration::~PluralAvailableLocalesEnumeration() {
ures_close(fLocales);
ures_close(fRes);
- fLocales = nullptr;
- fRes = nullptr;
+ fLocales = nullptr;
+ fRes = nullptr;
}
const char *PluralAvailableLocalesEnumeration::next(int32_t *resultLength, UErrorCode &status) {
if (U_FAILURE(status)) {
- return nullptr;
+ return nullptr;
}
if (U_FAILURE(fOpenStatus)) {
status = fOpenStatus;
- return nullptr;
+ return nullptr;
}
fRes = ures_getNextResource(fLocales, fRes, &status);
- if (fRes == nullptr || U_FAILURE(status)) {
+ if (fRes == nullptr || U_FAILURE(status)) {
if (status == U_INDEX_OUTOFBOUNDS_ERROR) {
status = U_ZERO_ERROR;
}
- return nullptr;
+ return nullptr;
}
const char *result = ures_getKey(fRes);
- if (resultLength != nullptr) {
- *resultLength = static_cast<int32_t>(uprv_strlen(result));
+ if (resultLength != nullptr) {
+ *resultLength = static_cast<int32_t>(uprv_strlen(result));
}
return result;
}