[PATCH] msvcrt/math: In _fcvt/_fcvt_s handle locale decimal separator properly

Fabian Maurer dark.shadow4 at web.de
Mon Aug 24 15:01:30 CDT 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49730
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/msvcrt/math.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index a75b5512100..15d8fa4be72 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2518,6 +2518,7 @@ char * CDECL MSVCRT__fcvt( double number, int ndigits, int *decpt, int *sign )
     int stop, dec1, dec2;
     char *ptr1, *ptr2, *first;
     char buf[80]; /* ought to be enough */
+    char decimal_separator = get_locinfo()->lconv->decimal_point[0];

     if (!data->efcvt_buffer)
         data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
@@ -2549,7 +2550,7 @@ char * CDECL MSVCRT__fcvt( double number, int ndigits, int *decpt, int *sign )
     }

     while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
-    while (*ptr1 != '\0' && *ptr1 != '.') {
+    while (*ptr1 != '\0' && *ptr1 != decimal_separator) {
 	if (!first) first = ptr2;
 	if ((ptr1 - buf) < stop) {
 	    *ptr2++ = *ptr1++;
@@ -2598,6 +2599,7 @@ int CDECL MSVCRT__fcvt_s(char* outbuffer, MSVCRT_size_t size, double number, int
     int stop, dec1, dec2;
     char *ptr1, *ptr2, *first;
     char buf[80]; /* ought to be enough */
+    char decimal_separator = get_locinfo()->lconv->decimal_point[0];

     if (!outbuffer || !decpt || !sign || size == 0)
     {
@@ -2632,7 +2634,7 @@ int CDECL MSVCRT__fcvt_s(char* outbuffer, MSVCRT_size_t size, double number, int
     }

     while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
-    while (*ptr1 != '\0' && *ptr1 != '.') {
+    while (*ptr1 != '\0' && *ptr1 != decimal_separator) {
 	if (!first) first = ptr2;
 	if ((ptr1 - buf) < stop) {
 	    if (size > 1) {
--
2.28.0




More information about the wine-devel mailing list