delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/10/28/03:38:14

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Date: Tue, 28 Oct 2003 11:37:31 +0300 (MSK)
From: "Alexander Aganichev" <aaganichev AT yandex DOT ru>
Sender: aaganichev AT yandex DOT ru
Message-Id: <3F9E2ACB.000003.29694@colgate.yandex.ru>
MIME-Version: 1.0
X-Mailer: Yamail [ http://yandex.ru ]
To: djgpp-workers AT delorie DOT com
Subject: decimal point fixes
X-source-ip: 208.248.82.254
Reply-To: djgpp-workers AT delorie DOT com

Here is fixes for the decimal point handling in libc:

diff -rup djgpp.orig/src/libc/ansi/stdio/doprnt.c djgpp/src/libc/ansi/stdio/doprnt.c
--- djgpp.orig/src/libc/ansi/stdio/doprnt.c	2003-08-20 04:08:40.000000000 +0000
+++ djgpp/src/libc/ansi/stdio/doprnt.c	2003-10-28 09:58:46.000000000 +0000
@@ -807,7 +807,7 @@ roundl(long double fract, int *expv, cha
     if (fract == 0.5L)
     {
       char *e = end;
-      if (*e == '.')
+      if (*e == decimal)
 	e--;
       if (*e == '0' || *e == '2' || *e == '4'
 	  || *e == '6' || *e == '8')
diff -rup djgpp.orig/src/libc/ansi/stdio/doscan.c djgpp/src/libc/ansi/stdio/doscan.c
--- djgpp.orig/src/libc/ansi/stdio/doscan.c	2003-01-25 05:08:38.000000000 +0000
+++ djgpp/src/libc/ansi/stdio/doscan.c	2003-10-28 10:38:28.000000000 +0000
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <locale.h>
 #include <libc/file.h>
 #include <libc/local.h>
 
@@ -43,6 +44,7 @@ static char _sctab[256] = {
 };
 
 static int nchars = 0;
+static char decimal = '.';
 
 int 
 _doscan(FILE *iop, const char *fmt, va_list argp)
@@ -58,6 +60,7 @@ _doscan_low(FILE *iop, int (*scan_getc)(
   int nmatch, len, ch1;
   int *ptr, fileended, size;
 
+  decimal = localeconv()->decimal_point[0];
   nchars = 0;
   nmatch = 0;
   fileended = 0;
@@ -275,7 +278,7 @@ _innum(int *ptr, int type, int len, int 
       lcval += c;
       c = c1;
       continue;
-    } else if (c=='.') {
+    } else if (c==decimal) {
       if (base!=10 || scale==INT)
 	break;
       ndigit++;
diff -rup djgpp.orig/src/libc/ansi/stdlib/strtod.c djgpp/src/libc/ansi/stdlib/strtod.c
--- djgpp.orig/src/libc/ansi/stdlib/strtod.c	2003-06-30 04:08:48.000000000 +0000
+++ djgpp/src/libc/ansi/stdlib/strtod.c	2003-10-28 09:50:32.000000000 +0000
@@ -5,6 +5,7 @@
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <locale.h>
 #include <math.h>
 #include <stdlib.h>
 #include <float.h>
@@ -24,6 +25,7 @@ strtod(const char *s, char **sret)
   int esign;
   int i;
   int flags=0;
+  char decimal = localeconv()->decimal_point[0];
 
   r = 0.0;
   sign = 1;
@@ -123,7 +125,7 @@ strtod(const char *s, char **sret)
     s++;
   }
 
-  if (*s == '.')
+  if (*s == decimal)
   {
     d = 0.1L;
     s++;
diff -rup djgpp.orig/src/libc/ansi/stdlib/strtold.c djgpp/src/libc/ansi/stdlib/strtold.c
--- djgpp.orig/src/libc/ansi/stdlib/strtold.c	2003-10-26 05:09:08.000000000 +0000
+++ djgpp/src/libc/ansi/stdlib/strtold.c	2003-10-28 09:50:24.000000000 +0000
@@ -3,6 +3,7 @@
 /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <locale.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <math.h>
@@ -25,6 +26,7 @@ strtold(const char *s, char **sret)
   int esign;
   int flags=0;
   int l2powm1;
+  char decimal = localeconv()->decimal_point[0];
 
   r = 0.0L;
   sign = 1;
@@ -123,7 +125,7 @@ strtold(const char *s, char **sret)
     s++;
   }
 
-  if (*s == '.')
+  if (*s == decimal)
   {
     s++;
     while ((*s >= '0') && (*s <= '9'))


-- 
Alexander Aganichev

url: http://aaganichev.narod.ru
e-mail: aaganichev AT yandex DOT ru
gsm: +7-095-786-1339

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019