]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/rbnf.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / rbnf.cpp
index 751070d020e119289bf2646539d87f6d8499df86..f1e9818bdb4e472a3e29087965480e65a0c94fbd 100644 (file)
@@ -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);
 }
@@ -1110,45 +1116,6 @@ RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status
     return NULL;
 }
 
-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,