summaryrefslogtreecommitdiffstats
path: root/contrib/gdtoa/gethex.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2007-01-03 04:58:54 +0000
committerdas <das@FreeBSD.org>2007-01-03 04:58:54 +0000
commit5bc737f35262327ca86ef96a7cbc6680c8eeb2ea (patch)
tree5f657cd7247cc76d6a32a0ea1f51ec09f8b25661 /contrib/gdtoa/gethex.c
parent2b54587e529691da13ad420858ce167f84023ce5 (diff)
downloadFreeBSD-src-5bc737f35262327ca86ef96a7cbc6680c8eeb2ea.zip
FreeBSD-src-5bc737f35262327ca86ef96a7cbc6680c8eeb2ea.tar.gz
Import of the latest gdtoa sources, which include fixes for minor
problems relating to NaNs and rounding.
Diffstat (limited to 'contrib/gdtoa/gethex.c')
-rw-r--r--contrib/gdtoa/gethex.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/contrib/gdtoa/gethex.c b/contrib/gdtoa/gethex.c
index fadb5de..610f747 100644
--- a/contrib/gdtoa/gethex.c
+++ b/contrib/gdtoa/gethex.c
@@ -26,10 +26,8 @@ THIS SOFTWARE.
****************************************************************/
-/* Please send bug reports to
- David M. Gay
- dmg@acm.org
- */
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to "."). */
#include "gdtoaimp.h"
@@ -47,7 +45,7 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
{
Bigint *b;
CONST unsigned char *decpt, *s0, *s, *s1;
- int esign, havedig, irv, k, n, nbits, up;
+ int esign, havedig, irv, k, n, nbits, up, zret;
ULong L, lostbits, *x;
Long e, e1;
#ifdef USE_LOCALE
@@ -65,22 +63,20 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
s0 += havedig;
s = s0;
decpt = 0;
+ zret = 0;
+ e = 0;
if (!hexdig[*s]) {
- if (*s == decimalpoint) {
- decpt = ++s;
- if (!hexdig[*s])
- goto ret0;
- }
- else {
- ret0:
- *sp = (char*)s;
- return havedig ? STRTOG_Zero : STRTOG_NoNumber;
- }
+ zret = 1;
+ if (*s != decimalpoint)
+ goto pcheck;
+ decpt = ++s;
+ if (!hexdig[*s])
+ goto pcheck;
while(*s == '0')
s++;
+ if (hexdig[*s])
+ zret = 0;
havedig = 1;
- if (!hexdig[*s])
- goto ret0;
s0 = s;
}
while(hexdig[*s])
@@ -90,9 +86,9 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
while(hexdig[*s])
s++;
}
- e = 0;
if (decpt)
e = -(((Long)(s-decpt)) << 2);
+ pcheck:
s1 = s;
switch(*s) {
case 'p':
@@ -117,6 +113,8 @@ gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
e += e1;
}
*sp = (char*)s;
+ if (zret)
+ return havedig ? STRTOG_Zero : STRTOG_NoNumber;
n = s1 - s0 - 1;
for(k = 0; n > 7; n >>= 1)
k++;
OpenPOWER on IntegriCloud