summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/plurrule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/plurrule.cpp')
-rw-r--r--deps/icu-small/source/i18n/plurrule.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/deps/icu-small/source/i18n/plurrule.cpp b/deps/icu-small/source/i18n/plurrule.cpp
index 3caa48a57b..aa950a51f0 100644
--- a/deps/icu-small/source/i18n/plurrule.cpp
+++ b/deps/icu-small/source/i18n/plurrule.cpp
@@ -35,6 +35,7 @@
#include "sharedpluralrules.h"
#include "unifiedcache.h"
#include "number_decimalquantity.h"
+#include "util.h"
#if !UCONFIG_NO_FORMATTING
@@ -265,6 +266,16 @@ 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();
+ }
+ return select(dq);
+}
+
+UnicodeString
PluralRules::select(const IFixedDecimal &number) const {
if (mRules == nullptr) {
return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
@@ -692,14 +703,14 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
return emptyStr;
}
int32_t resLen=0;
- const char *curLocaleName=locale.getName();
+ const char *curLocaleName=locale.getBaseName();
const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
if (s == nullptr) {
// Check parent locales.
UErrorCode status = U_ZERO_ERROR;
char parentLocaleName[ULOC_FULLNAME_CAPACITY];
- const char *curLocaleName2=locale.getName();
+ const char *curLocaleName2=locale.getBaseName();
uprv_strcpy(parentLocaleName, curLocaleName2);
while (uloc_getParent(parentLocaleName, parentLocaleName,
@@ -1471,8 +1482,7 @@ PluralOperand tokenTypeToPluralOperand(tokenType tt) {
case tVariableT:
return PLURAL_OPERAND_T;
default:
- U_ASSERT(FALSE); // unexpected.
- return PLURAL_OPERAND_N;
+ UPRV_UNREACHABLE; // unexpected.
}
}
@@ -1684,8 +1694,7 @@ double FixedDecimal::getPluralOperand(PluralOperand operand) const {
case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
case PLURAL_OPERAND_V: return visibleDecimalDigitCount;
default:
- U_ASSERT(FALSE); // unexpected.
- return source;
+ UPRV_UNREACHABLE; // unexpected.
}
}