gecko/intl/icu-patches/bug-853706

34 lines
1.5 KiB
Plaintext

# 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());