* mingwex/wcrtomb.c (wcsrtombs): Fix src end-pointer thinko.

* mingwex/math/lgamma.c: (LOGPI) Avoid type punning.
	(LS2PI): Likewise.
        * mingwex/math/sf_erf.c (erff): Initialize z.
        (erfcf): Likewise.
	* mingwex/math/tgamma.c (SQTPI): Avoid type punning.
This commit is contained in:
Danny Smith 2006-06-26 00:53:34 +00:00
parent b4e8ed0098
commit 1dcd64ff55
5 changed files with 55 additions and 28 deletions

View File

@ -1,3 +1,12 @@
2006-06-26 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/wcrtomb.c (wcsrtombs): Fix src end-pointer thinko.
* mingwex/math/lgamma.c: (LOGPI) Avoid type punning.
(LS2PI): Likewise.
* mingwex/math/sf_erf.c (erff): Initialize z.
(erfcf): Likewise.
* mingwex/math/tgamma.c (SQTPI): Avoid type punning.
2006-06-23 Danny Smith <dannysmith@users.sourceforge.net> 2006-06-23 Danny Smith <dannysmith@users.sourceforge.net>
* include/sys/time.h (struct timezone): Define. * include/sys/time.h (struct timezone): Define.

View File

@ -189,15 +189,20 @@ static const unsigned short C[] = {
0xe14a,0x6a11,0xce4b,0xc13e 0xe14a,0x6a11,0xce4b,0xc13e
}; };
/* log( sqrt( 2*pi ) ) */ /* log( sqrt( 2*pi ) ) */
static const unsigned short LS2P[] = { static const union
0xbeb5,0xc864,0x67f1,0x3fed {
}; unsigned short s[4];
#define LS2PI *(double *)LS2P double d;
} ls2p = {{0xbeb5,0xc864,0x67f1,0x3fed}};
#define LS2PI (ls2p.d)
#define MAXLGM 2.556348e305 #define MAXLGM 2.556348e305
static const unsigned short LPI[4] = { /* log (pi) */
0xa1bd,0x48e7,0x50d0,0x3ff2, static const union
}; {
#define LOGPI *(double *)LPI unsigned short s[4];
double d;
} lpi = {{0xa1bd,0x48e7,0x50d0,0x3ff2}};
#define LOGPI (lpi.d)
#endif #endif
#ifdef MIEEE #ifdef MIEEE
@ -225,15 +230,20 @@ static const unsigned short C[] = {
0xc13e,0xce4b,0x6a11,0xe14a 0xc13e,0xce4b,0x6a11,0xe14a
}; };
/* log( sqrt( 2*pi ) ) */ /* log( sqrt( 2*pi ) ) */
static const unsigned short LS2P[] = { static const union
0x3fed,0x67f1,0xc864,0xbeb5 {
}; unsigned short s[4];
#define LS2PI *(double *)LS2P double d;
} ls2p = {{0x3fed,0x67f1,0xc864,0xbeb5}};
#define LS2PI ls2p.d
#define MAXLGM 2.556348e305 #define MAXLGM 2.556348e305
static unsigned short LPI[4] = { /* log (pi) */
0x3ff2,0x50d0,0x48e7,0xa1bd, static const union
}; {
#define LOGPI *(double *)LPI unsigned short s[4];
double d;
} lpi = {{0x3ff2, 0x50d0, 0x48e7, 0xa1bd}};
#define LOGPI (lpi.d)
#endif #endif

View File

@ -190,6 +190,8 @@ sb7 = -2.2440952301e+01; /* 0xc1b38712 */
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
sb5+s*(sb6+s*sb7)))))); sb5+s*(sb6+s*sb7))))));
} }
z = x;
__trunc_float_word (&z); __trunc_float_word (&z);
r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
if(hx>=0) return one-r/x; else return r/x-one; if(hx>=0) return one-r/x; else return r/x-one;
@ -252,6 +254,7 @@ sb7 = -2.2440952301e+01; /* 0xc1b38712 */
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
sb5+s*(sb6+s*sb7)))))); sb5+s*(sb6+s*sb7))))));
} }
z = x;
__trunc_float_word (&z); __trunc_float_word (&z);
r = __ieee754_expf(-z*z-(float)0.5625)* r = __ieee754_expf(-z*z-(float)0.5625)*
__ieee754_expf((z-x)*(z+x)+R/S); __ieee754_expf((z-x)*(z+x)+R/S);

View File

@ -188,10 +188,13 @@ static const unsigned short STIR[20] = {
0x5986,0x5555,0x5555,0x3fb5, 0x5986,0x5555,0x5555,0x3fb5,
}; };
#define MAXSTIR 143.01608 #define MAXSTIR 143.01608
static const unsigned short SQT[4] = {
0x2706,0x1ff6,0x0d93,0x4004, static const union
}; {
#define SQTPI *(double *)SQT unsigned short s[4];
double d;
} sqt = {0x2706,0x1ff6,0x0d93,0x4004};
#define SQTPI (sqt.d)
#endif #endif
#if MIEEE #if MIEEE
static const unsigned short STIR[20] = { static const unsigned short STIR[20] = {

View File

@ -53,40 +53,42 @@ size_t wcsrtombs (char *dst, const wchar_t **src, size_t len,
size_t n = 0; size_t n = 0;
const unsigned int cp = get_cp_from_locale(); const unsigned int cp = get_cp_from_locale();
const unsigned int mb_max = MB_CUR_MAX; const unsigned int mb_max = MB_CUR_MAX;
const wchar_t *pwc = *src;
if (src == NULL || *src == NULL) /* undefined behavior */ if (src == NULL || *src == NULL) /* undefined behavior */
return 0; return 0;
if (dst != NULL) if (dst != NULL)
{ {
const wchar_t ** saved_src = src; while (n < len)
while (n < len)
{ {
if ((ret = __wcrtomb_cp (dst, **src, cp, mb_max)) <= 0) if ((ret = __wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0)
return (size_t) -1; return (size_t) -1;
n += ret; n += ret;
dst += ret; dst += ret;
if (*(dst - 1) == '\0') if (*(dst - 1) == '\0')
{ {
*saved_src = (wchar_t*) NULL;; *src = (wchar_t*) NULL;;
return (n - 1); return (n - 1);
} }
*src++; pwc++;
} }
*src = pwc;
} }
else else
{ {
char byte_bucket [MB_LEN_MAX]; char byte_bucket [MB_LEN_MAX];
while (n < len) while (n < len)
{ {
if ((ret = __wcrtomb_cp (byte_bucket, **src, cp, mb_max)) if ((ret = __wcrtomb_cp (byte_bucket, *pwc, cp, mb_max))
<= 0) <= 0)
return (size_t) -1; return (size_t) -1;
n += ret; n += ret;
if (byte_bucket [ret - 1] == '\0') if (byte_bucket [ret - 1] == '\0')
return (n - 1); return (n - 1);
*src++; pwc++;
} }
} }
return n; return n;
} }