Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: source/i18n/plurfmt.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/pluralaffix.cpp ('k') | source/i18n/plurrule.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/plurfmt.cpp
diff --git a/source/i18n/plurfmt.cpp b/source/i18n/plurfmt.cpp
index 7f6cd86e4c8babb4c0ff03250baebe2988624d91..9ff2bffc9d99cae2984adcde81bb7473ae5e332e 100644
--- a/source/i18n/plurfmt.cpp
+++ b/source/i18n/plurfmt.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2009-2014, International Business Machines Corporation and
+* Copyright (C) 2009-2015, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
@@ -19,6 +19,8 @@
#include "plurrule_impl.h"
#include "uassert.h"
#include "uhash.h"
+#include "precision.h"
+#include "visibledigits.h"
#if !UCONFIG_NO_FORMATTING
@@ -259,18 +261,37 @@ PluralFormat::format(const Formattable& numberObject, double number,
double numberMinusOffset = number - offset;
UnicodeString numberString;
FieldPosition ignorePos;
- FixedDecimal dec(numberMinusOffset);
+ FixedPrecision fp;
+ VisibleDigitsWithExponent dec;
+ fp.initVisibleDigitsWithExponent(numberMinusOffset, dec, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
if (offset == 0) {
- numberFormat->format(numberObject, numberString, ignorePos, status); // could be BigDecimal etc.
DecimalFormat *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
if(decFmt != NULL) {
- dec = decFmt->getFixedDecimal(numberObject, status);
+ decFmt->initVisibleDigitsWithExponent(
+ numberObject, dec, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ decFmt->format(dec, numberString, ignorePos, status);
+ } else {
+ numberFormat->format(
+ numberObject, numberString, ignorePos, status); // could be BigDecimal etc.
}
} else {
- numberFormat->format(numberMinusOffset, numberString, ignorePos, status);
DecimalFormat *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
if(decFmt != NULL) {
- dec = decFmt->getFixedDecimal(numberMinusOffset, status);
+ decFmt->initVisibleDigitsWithExponent(
+ numberMinusOffset, dec, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ decFmt->format(dec, numberString, ignorePos, status);
+ } else {
+ numberFormat->format(
+ numberMinusOffset, numberString, ignorePos, status);
}
}
int32_t partIndex = findSubMessage(msgPattern, 0, pluralRulesWrapper, &dec, number, status);
@@ -533,7 +554,7 @@ void PluralFormat::parseType(const UnicodeString& source, const NFRule *rbnfLeni
currMatchIndex = rbnfLenientScanner->findTextLenient(source, currArg, startingAt, &length);
}
else {
- currMatchIndex = source.indexOf(currArg);
+ currMatchIndex = source.indexOf(currArg, startingAt);
}
if (currMatchIndex >= 0 && currMatchIndex >= matchedIndex && currArg.length() > matchedWord.length()) {
matchedIndex = currMatchIndex;
@@ -562,8 +583,7 @@ PluralFormat::PluralSelectorAdapter::~PluralSelectorAdapter() {
UnicodeString PluralFormat::PluralSelectorAdapter::select(void *context, double number,
UErrorCode& /*ec*/) const {
(void)number; // unused except in the assertion
- FixedDecimal *dec=static_cast<FixedDecimal *>(context);
- U_ASSERT(dec->source==number);
+ VisibleDigitsWithExponent *dec=static_cast<VisibleDigitsWithExponent *>(context);
return pluralRules->select(*dec);
}
« no previous file with comments | « source/i18n/pluralaffix.cpp ('k') | source/i18n/plurrule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698