Bug 853706 - Backported fix for formatting 0 with significant digits from ICU, and add a warning about this backported fix to update-icu.sh. r=jwalden
--- 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());
--- a/intl/update-icu.sh
+++ b/intl/update-icu.sh
@@ -9,16 +9,25 @@
# build with the Mozilla build tools for Windows. Check
# http://bugs.icu-project.org/trac/ticket/9985
# whether this has been addressed in the version you're updating to.
# If not, obtain the patch "Make ICU build with Mozilla build for Windows" from
# https://bugzilla.mozilla.org/show_bug.cgi?id=724533
# and reapply it after running update-icu.sh (additional updates may be needed).
# If the bug has been addressed, please delete this warning.
+# Warning
+# =======
+# The fix for ICU bug 10045 has been individually backported into this tree.
+# If you update ICU to a version that does not have this fix yet, obtain the
+# patch "Backported fix for formatting 0 with significant digits from ICU" from
+# https://bugzilla.mozilla.org/show_bug.cgi?id=853706
+# and reapply it after running update-icu.sh.
+# If you update ICU to a version that has the fix, please delete this warning.
+
# Usage: update-icu.sh <URL of ICU SVN with release>
# E.g., for ICU 50.1.1: update-icu.sh http://source.icu-project.org/repos/icu/icu/tags/release-50-1-1/
if [ $# -lt 1 ]; then
echo "Usage: update-icu.sh <URL of ICU SVN with release>"
exit 1
fi