summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/rbnf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/rbnf.cpp')
-rw-r--r--deps/icu-small/source/i18n/rbnf.cpp53
1 files changed, 10 insertions, 43 deletions
diff --git a/deps/icu-small/source/i18n/rbnf.cpp b/deps/icu-small/source/i18n/rbnf.cpp
index 74707ccd22..c25e61e6b2 100644
--- a/deps/icu-small/source/i18n/rbnf.cpp
+++ b/deps/icu-small/source/i18n/rbnf.cpp
@@ -355,10 +355,16 @@ private:
};
#ifdef RBNF_DEBUG
-#define ERROR(msg) parseError(msg); return NULL;
+#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \
+ parseError(msg); \
+ return NULL; \
+} UPRV_BLOCK_MACRO_END
#define EXPLANATION_ARG explanationArg
#else
-#define ERROR(msg) parseError(NULL); return NULL;
+#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \
+ parseError(NULL); \
+ return NULL; \
+} UPRV_BLOCK_MACRO_END
#define EXPLANATION_ARG
#endif
@@ -924,8 +930,8 @@ RuleBasedNumberFormat::~RuleBasedNumberFormat()
dispose();
}
-Format*
-RuleBasedNumberFormat::clone(void) const
+RuleBasedNumberFormat*
+RuleBasedNumberFormat::clone() const
{
return new RuleBasedNumberFormat(*this);
}
@@ -1112,45 +1118,6 @@ RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status
UnicodeString&
RuleBasedNumberFormat::format(const DecimalQuantity &number,
- UnicodeString &appendTo,
- FieldPositionIterator *posIter,
- UErrorCode &status) const {
- if (U_FAILURE(status)) {
- return appendTo;
- }
- DecimalQuantity copy(number);
- if (copy.fitsInLong()) {
- format(number.toLong(), appendTo, posIter, status);
- }
- else {
- copy.roundToMagnitude(0, number::impl::RoundingMode::UNUM_ROUND_HALFEVEN, status);
- if (copy.fitsInLong()) {
- format(number.toDouble(), appendTo, posIter, status);
- }
- else {
- // We're outside of our normal range that this framework can handle.
- // The DecimalFormat will provide more accurate results.
-
- // TODO this section should probably be optimized. The DecimalFormat is shared in ICU4J.
- LocalPointer<NumberFormat> decimalFormat(NumberFormat::createInstance(locale, UNUM_DECIMAL, status), status);
- if (decimalFormat.isNull()) {
- return appendTo;
- }
- Formattable f;
- LocalPointer<DecimalQuantity> decimalQuantity(new DecimalQuantity(number), status);
- if (decimalQuantity.isNull()) {
- return appendTo;
- }
- f.adoptDecimalQuantity(decimalQuantity.orphan()); // f now owns decimalQuantity.
- decimalFormat->format(f, appendTo, posIter, status);
- }
- }
- return appendTo;
-}
-
-
-UnicodeString&
-RuleBasedNumberFormat::format(const DecimalQuantity &number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const {