* 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.
This commit is contained in:
		| @@ -1,3 +1,12 @@ | ||||
| 2006-09-18  Danny Smith  <dannysmith@users.sourceforge.net> | ||||
|  | ||||
| 	* 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. | ||||
|  | ||||
| 2006-09-16  Danny Smith  <dannysmith@users.sourceforge.net> | ||||
|  | ||||
| 	* mingwex/gdtoa/strtopx.c (strtopx): Fix long double representation | ||||
|   | ||||
| @@ -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 { | ||||
|  | ||||
| 	if (fptype & FP_NAN) /* NaN or Inf */ | ||||
| 	  { | ||||
|  	    if (fptype & FP_NORMAL) | ||||
| 	      { | ||||
| 		b = buf; | ||||
| 				if (sign) | ||||
| 					*b++ = '-'; | ||||
| 				b = strcp(b, "Infinity"); | ||||
| 		*b++ = sign ? '-': '+'; | ||||
| 		strncpy (b, "Infinity", ndig ? ndig : 8); | ||||
| 		return (buf + strlen (buf)); | ||||
| 	      } | ||||
| 			return b; | ||||
| 	    strncpy (buf, "NaN", ndig ? ndig : 3); | ||||
| 	    return (buf + strlen (buf)); | ||||
| 	  } | ||||
| 		i = STRTOG_Normal; | ||||
| 		} | ||||
| 	else if (bits[0] | bits[1]) { | ||||
| 			 | ||||
| 	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) { | ||||
|   | ||||
| @@ -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)); | ||||
|   | ||||
| @@ -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; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user