Jacek Caban : oleaut32: Use C locale in VARIANT_BstrFromReal.

Alexandre Julliard julliard at winehq.org
Tue Feb 16 16:03:19 CST 2021


Module: wine
Branch: master
Commit: 22a1485c08fb219444f7bb45b37c26af7c203d19
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=22a1485c08fb219444f7bb45b37c26af7c203d19

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Feb 16 19:03:37 2021 +0100

oleaut32: Use C locale in VARIANT_BstrFromReal.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50672
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/oleaut32/vartype.c         |  7 ++++++-
 include/msvcrt/corecrt_wstdio.h | 11 +++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
index 6793de317ac..90b3fcaa1a9 100644
--- a/dlls/oleaut32/vartype.c
+++ b/dlls/oleaut32/vartype.c
@@ -29,6 +29,8 @@
 #include "variant.h"
 #include "resource.h"
 
+#include "locale.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
 extern HMODULE hProxyDll DECLSPEC_HIDDEN;
@@ -6501,12 +6503,15 @@ static BSTR VARIANT_BstrReplaceDecimal(const WCHAR * buff, LCID lcid, ULONG dwFl
 static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
                                     BSTR* pbstrOut, LPCWSTR lpszFormat)
 {
+  _locale_t locale;
   WCHAR buff[256];
 
   if (!pbstrOut)
     return E_INVALIDARG;
 
-  swprintf( buff, ARRAY_SIZE(buff), lpszFormat, dblIn );
+  if (!(locale = _create_locale(LC_ALL, "C"))) return E_OUTOFMEMORY;
+  _swprintf_l(buff, ARRAY_SIZE(buff), lpszFormat, locale, dblIn);
+  _free_locale(locale);
 
   /* Negative zeroes are disallowed (some applications depend on this).
      If buff starts with a minus, and then nothing follows but zeroes
diff --git a/include/msvcrt/corecrt_wstdio.h b/include/msvcrt/corecrt_wstdio.h
index 63f411e02db..81238afafb8 100644
--- a/include/msvcrt/corecrt_wstdio.h
+++ b/include/msvcrt/corecrt_wstdio.h
@@ -181,6 +181,17 @@ static inline int WINAPIV swprintf_s(wchar_t *buffer, size_t size, const wchar_t
     return ret;
 }
 
+static inline int WINAPIV _swprintf_l(wchar_t *buffer, size_t size, const wchar_t* format, _locale_t locale, ...)
+{
+    int ret;
+    __ms_va_list args;
+
+    __ms_va_start(args, locale);
+    ret = __stdio_common_vswprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, format, locale, args);
+    __ms_va_end(args);
+    return ret;
+}
+
 static inline int __cdecl _vscwprintf(const wchar_t *format, __ms_va_list args)
 {
     int ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,




More information about the wine-cvs mailing list