Bug 1422415 - Part 2: Call _sprintf_l with C-locale to ensure result doesn't contain locale-dependent decimal separator. r=Waldo
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 05 Dec 2017 04:24:41 -0800
changeset 401144 8b6bb4335d4bb4e47045921aebe730113e9bd693
parent 401143 68acdee69ce173669fe7435be843924c1d89fdc0
child 401145 2175c053b6ebdf6b1bb0efa7dd2ee6590869b972
push id33332
push userccoroiu@mozilla.com
push dateSun, 28 Jan 2018 10:41:03 +0000
treeherdermozilla-central@094915903938 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1422415
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1422415 - Part 2: Call _sprintf_l with C-locale to ensure result doesn't contain locale-dependent decimal separator. r=Waldo
intl/icu-patches/bug-1422415-numberformat-sprintfl-windows.diff
intl/icu/source/i18n/digitlst.cpp
intl/update-icu.sh
new file mode 100644
--- /dev/null
+++ b/intl/icu-patches/bug-1422415-numberformat-sprintfl-windows.diff
@@ -0,0 +1,30 @@
+Bug 1422415 - NumberFormat returns NaN if RegionalPrefsLocales is fa-IR and value has decimals
+
+https://ssl.icu-project.org/trac/ticket/13497
+
+diff --git a/intl/icu/source/i18n/digitlst.cpp b/intl/icu/source/i18n/digitlst.cpp
+--- a/intl/icu/source/i18n/digitlst.cpp
++++ b/intl/icu/source/i18n/digitlst.cpp
+@@ -846,17 +846,22 @@ DigitList::set(double source)
+     //       That is why infinity is special cased here.
+     if (uprv_isInfinite(source)) {
+         if (uprv_isNegativeInfinity(source)) {
+             uprv_strcpy(rep,"-inf"); // Handle negative infinity
+         } else {
+             uprv_strcpy(rep,"inf");
+         }
+     } else {
++#if U_USE_STRTOD_L && U_PLATFORM_USES_ONLY_WIN32_API
++        umtx_initOnce(gCLocaleInitOnce, &initCLocale);
++        _sprintf_l(rep, "%+1.*e", gCLocale, MAX_DBL_DIGITS - 1, source);
++#else
+         sprintf(rep, "%+1.*e", MAX_DBL_DIGITS - 1, source);
++#endif
+     }
+     U_ASSERT(uprv_strlen(rep) < sizeof(rep));
+ 
+     // uprv_decNumberFromString() will parse the string expecting '.' as a
+     // decimal separator, however sprintf() can use ',' in certain locales.
+     // Overwrite a ',' with '.' here before proceeding.
+     char *decimalSeparator = strchr(rep, ',');
+     if (decimalSeparator != NULL) {
--- a/intl/icu/source/i18n/digitlst.cpp
+++ b/intl/icu/source/i18n/digitlst.cpp
@@ -846,17 +846,22 @@ DigitList::set(double source)
     //       That is why infinity is special cased here.
     if (uprv_isInfinite(source)) {
         if (uprv_isNegativeInfinity(source)) {
             uprv_strcpy(rep,"-inf"); // Handle negative infinity
         } else {
             uprv_strcpy(rep,"inf");
         }
     } else {
+#if U_USE_STRTOD_L && U_PLATFORM_USES_ONLY_WIN32_API
+        umtx_initOnce(gCLocaleInitOnce, &initCLocale);
+        _sprintf_l(rep, "%+1.*e", gCLocale, MAX_DBL_DIGITS - 1, source);
+#else
         sprintf(rep, "%+1.*e", MAX_DBL_DIGITS - 1, source);
+#endif
     }
     U_ASSERT(uprv_strlen(rep) < sizeof(rep));
 
     // uprv_decNumberFromString() will parse the string expecting '.' as a
     // decimal separator, however sprintf() can use ',' in certain locales.
     // Overwrite a ',' with '.' here before proceeding.
     char *decimalSeparator = strchr(rep, ',');
     if (decimalSeparator != NULL) {
--- a/intl/update-icu.sh
+++ b/intl/update-icu.sh
@@ -65,16 +65,17 @@ find ${icu_dir}/source/data/zone \
 # the tree.)
 svn info $1 | grep -v '^Revision: [[:digit:]]\+$' > ${icu_dir}/SVN-INFO
 
 for patch in \
  bug-915735 \
  suppress-warnings.diff \
  bug-1172609-timezone-recreateDefault.diff \
  bug-1198952-workaround-make-3.82-bug.diff \
+ bug-1422415-numberformat-sprintfl-windows.diff \
 ; do
   echo "Applying local patch $patch"
   patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch
 done
 
 topsrcdir=`dirname $0`/../
 python ${topsrcdir}/js/src/tests/ecma_6/String/make-normalize-generateddata-input.py $topsrcdir