intl/icu-patches/bug-853706
author Ryan VanderMeulen <ryanvm@gmail.com>
Sun, 19 Jan 2014 23:04:26 -0500
changeset 175883 2f9b15aa2f8b6a4b8e4fd8e8667e4d4a4e36fdfa
parent 156453 9d3fa47e4dcbb8574df60bcc428e5402e5f56228
permissions -rw-r--r--
Backed out changesets ce0ef3278d5f, d9d1983edb5c, and 7e0609e54c24 (bug 914847) for bustage. a=backout

# HG changeset patch
# Parent 7965d384123c42ca0e4e4b18bc3ad73b26369f16
# User Norbert Lindenberg <mozilladev@lindenbergsoftware.com>
Bug 853706 - Backported fix for formatting 0 with significant digits from ICU.

diff --git a/intl/icu/source/i18n/decimfmt.cpp b/intl/icu/source/i18n/decimfmt.cpp
--- a/intl/icu/source/i18n/decimfmt.cpp
+++ b/intl/icu/source/i18n/decimfmt.cpp
@@ -1709,16 +1709,24 @@ DecimalFormat::subformat(UnicodeString& 
             }
 
             // Output grouping separator if necessary.
             if (isGroupingPosition(i)) {
                 currentLength = appendTo.length();
                 appendTo.append(*grouping);
                 handler.addAttribute(kGroupingSeparatorField, currentLength, appendTo.length());
             }
+        } 
+
+        // This handles the special case of formatting 0. For zero only, we count the 
+        // zero to the left of the decimal point as one signficant digit. Ordinarily we 
+        // do not count any leading 0's as significant. If the number we are formatting 
+        // is not zero, then either sigCount or digits.getCount() will be non-zero. 
+        if (sigCount == 0 && digits.getCount() == 0) { 
+          sigCount = 1; 
         }
 
         // TODO(dlf): this looks like it was a bug, we marked the int field as ending
         // before the zero was generated.
         // Record field information for caller.
         // if (fieldPosition.getField() == NumberFormat::kIntegerField)
         //     fieldPosition.setEndIndex(appendTo.length());