Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2006-09-18 02:27:56 +0400
committerDanny Smith <dannysmith@users.sourceforge.net>2006-09-18 02:27:56 +0400
commitdad33637073ad09e3268ae1bbc1a0968bd649e48 (patch)
treec9ab6840c68eb188466d6670353e649bf06beff1 /winsup/mingw/mingwex/gdtoa
parent7aa8dc8eb0eaa02b123a50284fdf38c14ffc0050 (diff)
* mingwex/gdtoa/g_xfmt.c (g_xfmt): Fix representation of infinity. Use fpclassify.
* mingwex/gdtoa/strtopx (__strtopx): Avoid cast of long double* to void*. * mingwex/gdtoa/gdtoa.h (__g_fmt): Make declaration consistent with others.
Diffstat (limited to 'winsup/mingw/mingwex/gdtoa')
-rwxr-xr-xwinsup/mingw/mingwex/gdtoa/g_xfmt.c45
-rwxr-xr-xwinsup/mingw/mingwex/gdtoa/gdtoa.h2
-rwxr-xr-xwinsup/mingw/mingwex/gdtoa/strtopx.c6
3 files changed, 32 insertions, 21 deletions
diff --git a/winsup/mingw/mingwex/gdtoa/g_xfmt.c b/winsup/mingw/mingwex/gdtoa/g_xfmt.c
index c92d6bd97..8015403e3 100755
--- a/winsup/mingw/mingwex/gdtoa/g_xfmt.c
+++ b/winsup/mingw/mingwex/gdtoa/g_xfmt.c
@@ -64,6 +64,8 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
UShort *L;
int decpt, ex, i, mode;
+ int fptype = __fpclassifyl (*(long double*) V);
+
if (ndig < 0)
ndig = 0;
if (bufsize < ndig + 10)
@@ -71,28 +73,36 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
L = (UShort *)V;
sign = L[_0] & 0x8000;
+ ex = L[_0] & 0x7fff;
+
bits[1] = (L[_1] << 16) | L[_2];
bits[0] = (L[_3] << 16) | L[_4];
- if ( (ex = L[_0] & 0x7fff) !=0) {
- if (ex == 0x7fff) {
- /* Infinity or NaN */
- if (bits[0] | bits[1])
- b = strcp(buf, "NaN");
- else {
- b = buf;
- if (sign)
- *b++ = '-';
- b = strcp(b, "Infinity");
- }
- return b;
- }
- i = STRTOG_Normal;
- }
- else if (bits[0] | bits[1]) {
+
+ if (fptype & FP_NAN) /* NaN or Inf */
+ {
+ if (fptype & FP_NORMAL)
+ {
+ b = buf;
+ *b++ = sign ? '-': '+';
+ strncpy (b, "Infinity", ndig ? ndig : 8);
+ return (buf + strlen (buf));
+ }
+ strncpy (buf, "NaN", ndig ? ndig : 3);
+ return (buf + strlen (buf));
+ }
+
+ else if (fptype & FP_NORMAL) /* Normal or subnormal */
+ {
+ if (fptype & FP_ZERO)
+ {
i = STRTOG_Denormal;
ex = 1;
- }
+ }
+ else
+ i = STRTOG_Normal;
+ }
else {
+ i = STRTOG_Zero;
b = buf;
#ifndef IGNORE_ZERO_SIGN
if (sign)
@@ -102,6 +112,7 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
*b = 0;
return b;
}
+
ex -= 0x3fff + 63;
mode = 2;
if (ndig <= 0) {
diff --git a/winsup/mingw/mingwex/gdtoa/gdtoa.h b/winsup/mingw/mingwex/gdtoa/gdtoa.h
index 285834b30..88e0e54cd 100755
--- a/winsup/mingw/mingwex/gdtoa/gdtoa.h
+++ b/winsup/mingw/mingwex/gdtoa/gdtoa.h
@@ -116,7 +116,7 @@ extern float __strtof ANSI((CONST char *, char **));
extern double __strtod ANSI((CONST char *, char **));
extern long double strtold ANSI((CONST char *, char **));
-extern char* __g__fmt(char *, char *, char *e, int, ULong);
+extern char* __g__fmt ANSI((char *, char *, char *e, int, ULong));
extern char* __g_dfmt ANSI((char*, double*, int, unsigned));
extern char* __g_ffmt ANSI((char*, float*, int, unsigned));
extern char* __g_xfmt ANSI((char*, void*, int, unsigned));
diff --git a/winsup/mingw/mingwex/gdtoa/strtopx.c b/winsup/mingw/mingwex/gdtoa/strtopx.c
index 14fea435f..59b7c2289 100755
--- a/winsup/mingw/mingwex/gdtoa/strtopx.c
+++ b/winsup/mingw/mingwex/gdtoa/strtopx.c
@@ -53,9 +53,9 @@ THIS SOFTWARE.
static int
#ifdef KR_headers
-__strtopx(s, sp, V) CONST char *s; char **sp; void *V;
+__strtopx(s, sp, V) CONST char *s; char **sp; long double *V;
#else
-__strtopx(CONST char *s, char **sp, void *V)
+__strtopx(CONST char *s, char **sp, long double *V)
#endif
{
static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
@@ -108,7 +108,7 @@ __cdecl
__strtold (const char * __restrict__ src, char ** __restrict__ endptr)
{
long double ret;
- __strtopx(src, endptr, (void*) &ret);
+ __strtopx(src, endptr, &ret);
return ret;
}