summaryrefslogtreecommitdiffstats
path: root/contrib/gdtoa
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-03-19 20:23:29 +0000
committerdas <das@FreeBSD.org>2003-03-19 20:23:29 +0000
commit375d3f8cdbff37bbc427464bd2d61a5b14135acd (patch)
treec887fc22683dd3a2d7e07d6fa0c55f75f1175c7e /contrib/gdtoa
parentdb3a0f1435efcb4461005cb8d8509bff01f9b018 (diff)
downloadFreeBSD-src-375d3f8cdbff37bbc427464bd2d61a5b14135acd.zip
FreeBSD-src-375d3f8cdbff37bbc427464bd2d61a5b14135acd.tar.gz
Import gdtoa sources dated 20030318, which contain several locale fixes.
Reviewed by: mike (mentor)
Diffstat (limited to 'contrib/gdtoa')
-rw-r--r--contrib/gdtoa/README4
-rw-r--r--contrib/gdtoa/g__fmt.c16
-rw-r--r--contrib/gdtoa/strtod.c25
-rw-r--r--contrib/gdtoa/strtodg.c25
-rw-r--r--contrib/gdtoa/xsum0.out10
5 files changed, 29 insertions, 51 deletions
diff --git a/contrib/gdtoa/README b/contrib/gdtoa/README
index f29e1cf..d1dcb26 100644
--- a/contrib/gdtoa/README
+++ b/contrib/gdtoa/README
@@ -313,6 +313,10 @@ bit fpi->nbits in the bits array on. Denormals have it off, with
exponent = fpi->emin. Strtodg provides distinct return values for normals
and denormals; see gdtoa.h.
+Compiling g__fmt.c, strtod.c, and strtodg.c with -DUSE_LOCALE causes
+the decimal-point character to be taken from the current locale; otherwise
+it is '.'.
+
Please send comments to
David M. Gay
diff --git a/contrib/gdtoa/g__fmt.c b/contrib/gdtoa/g__fmt.c
index 6451b25..5edc492 100644
--- a/contrib/gdtoa/g__fmt.c
+++ b/contrib/gdtoa/g__fmt.c
@@ -37,6 +37,10 @@ THIS SOFTWARE.
#include "gdtoaimp.h"
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
char *
#ifdef KR_headers
g__fmt(b, s, se, decpt, sign) char *b; char *s; char *se; int decpt; ULong sign;
@@ -46,13 +50,17 @@ g__fmt(char *b, char *s, char *se, int decpt, ULong sign)
{
int i, j, k;
char *s0 = s;
-
+#ifdef USE_LOCALE
+ char decimalpoint = *localeconv()->decimal_point;
+#else
+#define decimalpoint '.'
+#endif
if (sign)
*b++ = '-';
if (decpt <= -4 || decpt > se - s + 5) {
*b++ = *s++;
if (*s) {
- *b++ = '.';
+ *b++ = decimalpoint;
while((*b = *s++) !=0)
b++;
}
@@ -76,7 +84,7 @@ g__fmt(char *b, char *s, char *se, int decpt, ULong sign)
*b = 0;
}
else if (decpt <= 0) {
- *b++ = '.';
+ *b++ = decimalpoint;
for(; decpt < 0; decpt++)
*b++ = '0';
while((*b = *s++) !=0)
@@ -86,7 +94,7 @@ g__fmt(char *b, char *s, char *se, int decpt, ULong sign)
while((*b = *s++) !=0) {
b++;
if (--decpt == 0 && *s)
- *b++ = '.';
+ *b++ = decimalpoint;
}
for(; decpt > 0; decpt--)
*b++ = '0';
diff --git a/contrib/gdtoa/strtod.c b/contrib/gdtoa/strtod.c
index 3c0e0c4..0a559d5 100644
--- a/contrib/gdtoa/strtod.c
+++ b/contrib/gdtoa/strtod.c
@@ -85,9 +85,6 @@ strtod
#ifdef Honor_FLT_ROUNDS
int rounding;
#endif
-#ifdef USE_LOCALE
- CONST char *s2;
-#endif
sign = nz0 = nz = 0;
dval(rv) = 0.;
@@ -150,25 +147,11 @@ strtod
z = 10*z + c - '0';
nd0 = nd;
#ifdef USE_LOCALE
- s1 = localeconv()->decimal_point;
- if (c == *s1) {
- c = '.';
- if (*++s1) {
- s2 = s;
- for(;;) {
- if (*++s2 != *s1) {
- c = 0;
- break;
- }
- if (!*++s1) {
- s = s2;
- break;
- }
- }
- }
- }
+ if (c == *localeconv()->decimal_point)
+#else
+ if (c == '.')
#endif
- if (c == '.') {
+ {
c = *++s;
if (!nd) {
for(; c == '0'; c = *++s)
diff --git a/contrib/gdtoa/strtodg.c b/contrib/gdtoa/strtodg.c
index ec2cbfd..5b8409b 100644
--- a/contrib/gdtoa/strtodg.c
+++ b/contrib/gdtoa/strtodg.c
@@ -59,9 +59,6 @@ increment(Bigint *b)
{
ULong *x, *xe;
Bigint *b1;
-#ifdef USE_LOCALE
- CONST char *s2;
-#endif
#ifdef Pack_16
ULong carry = 1, y;
#endif
@@ -399,25 +396,11 @@ strtodg
z = 10*z + c - '0';
nd0 = nd;
#ifdef USE_LOCALE
- s1 = localeconv()->decimal_point;
- if (c == *s1) {
- c = '.';
- if (*++s1) {
- s2 = s;
- for(;;) {
- if (*++s2 != *s1) {
- c = 0;
- break;
- }
- if (!*++s1) {
- s = s2;
- break;
- }
- }
- }
- }
+ if (c == *localeconv()->decimal_point)
+#else
+ if (c == '.')
#endif
- if (c == '.') {
+ {
c = *++s;
if (!nd) {
for(; c == '0'; c = *++s)
diff --git a/contrib/gdtoa/xsum0.out b/contrib/gdtoa/xsum0.out
index 85eabe4..f564f91 100644
--- a/contrib/gdtoa/xsum0.out
+++ b/contrib/gdtoa/xsum0.out
@@ -1,9 +1,9 @@
-README 10a65619 13093
+README 7150e50 13249
arithchk.c e37b8a75 4070
dmisc.c e8d262b6 4712
dtoa.c f3c132b3 16905
g_Qfmt.c e5847e9 2870
-g__fmt.c f2d66617 2355
+g__fmt.c e29d67f1 2534
g_ddfmt.c fcf94527 3790
g_dfmt.c f30e55a9 2533
g_ffmt.c 7c4ea96 2459
@@ -12,7 +12,7 @@ g_xfmt.c c20a5e4 2795
gdtoa.c 364a0d2 17017
gdtoa.h 1eb440de 4810
gdtoaimp.h 6a955ba 19106
-gethex.c f56c1968 5041
+gethex.c ff3c434d 4981
gmisc.c e1a268ea 2114
hd_init.c cf9a94e 1827
hexnan.c f53be1da 2988
@@ -26,9 +26,9 @@ strtoIf.c eb75ac99 1905
strtoIg.c ec59c2fa 3484
strtoIx.c 8f8c9d 1990
strtoIxL.c 1313ff7f 1961
-strtod.c 1390a957 20277
+strtod.c 1ad667 20076
strtodI.c e58338e0 4062
-strtodg.c 1cba0060 19769
+strtodg.c 1caf3fa4 19553
strtof.c 1e7a787a 2202
strtopQ.c e232c542 2685
strtopd.c e865dc64 1701
OpenPOWER on IntegriCloud