summaryrefslogtreecommitdiffstats
path: root/contrib/gdtoa/gethex.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-03-25 17:55:07 +0000
committerdas <das@FreeBSD.org>2003-03-25 17:55:07 +0000
commitac4cce98d01fbe19f88ac1e217e7895ec38fdbac (patch)
treecd193b11cc426b2df4cb276c23214cfa9b598050 /contrib/gdtoa/gethex.c
parent375d3f8cdbff37bbc427464bd2d61a5b14135acd (diff)
downloadFreeBSD-src-ac4cce98d01fbe19f88ac1e217e7895ec38fdbac.zip
FreeBSD-src-ac4cce98d01fbe19f88ac1e217e7895ec38fdbac.tar.gz
Import new sources. The only material change in this update is to
add locale support for hexadecimal floating point conversions. Noticed by: ache Reviewed by: mike (mentor)
Diffstat (limited to 'contrib/gdtoa/gethex.c')
-rw-r--r--contrib/gdtoa/gethex.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/contrib/gdtoa/gethex.c b/contrib/gdtoa/gethex.c
index 333f075..0f9ae33 100644
--- a/contrib/gdtoa/gethex.c
+++ b/contrib/gdtoa/gethex.c
@@ -28,15 +28,15 @@ THIS SOFTWARE.
/* Please send bug reports to
David M. Gay
- Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-0636
- U.S.A.
- dmg@bell-labs.com
+ dmg@acm.org
*/
#include "gdtoaimp.h"
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
int
#ifdef KR_headers
gethex(sp, fpi, exp, bp, sign)
@@ -50,6 +50,11 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
int esign, havedig, irv, k, n, nbits, up;
ULong L, lostbits, *x;
Long e, e1;
+#ifdef USE_LOCALE
+ char decimalpoint = *localeconv()->decimal_point;
+#else
+#define decimalpoint '.'
+#endif
if (!hexdig['0'])
hexdig_init_D2A();
@@ -61,7 +66,7 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
s = s0;
decpt = 0;
if (!hexdig[*s]) {
- if (*s == '.') {
+ if (*s == decimalpoint) {
decpt = ++s;
if (!hexdig[*s])
goto ret0;
@@ -80,7 +85,7 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
}
while(hexdig[*s])
s++;
- if (*s == '.' && !decpt) {
+ if (*s == decimalpoint && !decpt) {
decpt = ++s;
while(hexdig[*s])
s++;
@@ -120,7 +125,7 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
n = 0;
L = 0;
while(s1 > s0) {
- if (*--s1 == '.')
+ if (*--s1 == decimalpoint)
continue;
if (n == 32) {
*x++ = L;
OpenPOWER on IntegriCloud