intl/icu-patches/bug-1422415-numberformat-sprintfl-windows.diff
author André Bargull <andre.bargull@gmail.com>
Tue, 05 Dec 2017 04:24:41 -0800
changeset 401117 8b6bb4335d4bb4e47045921aebe730113e9bd693
permissions -rw-r--r--
Bug 1422415 - Part 2: Call _sprintf_l with C-locale to ensure result doesn't contain locale-dependent decimal separator. r=Waldo

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) {