Mercurial > hg > octave-nkf > gnulib-hg
changeset 9837:8c80e0046993
More strtod touchups.
* tests/test-strtod.c (main): Ignore tests for signbit on NaN, and
sign of negative underflow, for now. Use .5, not .1.
* doc/posix-functions/strtod.texi (strtod): Mention these
limitations.
Reported by Jim Meyering.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Sun, 30 Mar 2008 15:57:54 -0600 |
parents | 69507e40ea4f |
children | c73f27c8e6f0 |
files | ChangeLog doc/posix-functions/strtod.texi tests/test-strtod.c |
diffstat | 3 files changed, 39 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,15 @@ 2008-03-30 Eric Blake <ebb9@byu.net> + More strtod touchups. + * tests/test-strtod.c (main): Ignore tests for signbit on NaN, and + sign of negative underflow, for now. Use .5, not .1. + * doc/posix-functions/strtod.texi (strtod): Mention these + limitations. + Reported by Jim Meyering. + +2008-03-30 Eric Blake <ebb9@byu.net> + strtod touchups. * lib/strtod.c (strtod): Avoid compiler warnings. Reported by Jim Meyering.
--- a/doc/posix-functions/strtod.texi +++ b/doc/posix-functions/strtod.texi @@ -52,7 +52,12 @@ @item This function returns a positive value for negative underflow on some platforms: -glibc 2.4, Mingw, Cygwin. +glibc 2.7, Mingw, Cygwin. + +@item +This function cannot distinguish between ``nan'' and ``-nan'' on some +platforms: +glibc 2.7. @item This function fails to correctly parse very long strings on some
--- a/tests/test-strtod.c +++ b/tests/test-strtod.c @@ -143,10 +143,10 @@ } { errno = 0; - const char input[] = ".1"; + const char input[] = ".5"; char *ptr; double result = strtod (input, &ptr); - ASSERT (result == 0.1); + ASSERT (result == 0.5); ASSERT (ptr == input + 2); ASSERT (errno == 0); } @@ -215,10 +215,10 @@ } { errno = 0; - const char input[] = "1e-1"; + const char input[] = "5e-1"; char *ptr; double result = strtod (input, &ptr); - ASSERT (result == 0.1); + ASSERT (result == 0.5); ASSERT (ptr == input + 4); ASSERT (errno == 0); } @@ -443,7 +443,7 @@ /* Overflow/underflow. */ { errno = 0; - const char input[] = "1E100000"; + const char input[] = "1E1000000"; char *ptr; double result = strtod (input, &ptr); ASSERT (result == HUGE_VAL); @@ -452,7 +452,7 @@ } { errno = 0; - const char input[] = "-1E100000"; + const char input[] = "-1E1000000"; char *ptr; double result = strtod (input, &ptr); ASSERT (result == -HUGE_VAL); @@ -475,7 +475,13 @@ char *ptr; double result = strtod (input, &ptr); ASSERT (-FLT_MIN <= result && result <= 0.0); +#if 0 + /* FIXME - this is glibc bug 5995; POSIX allows returning positive + 0 on negative underflow, even though quality of implementation + demands preserving the sign. Disable this test until fixed + glibc is more prevalent. */ ASSERT (signbit (result) == signbit (-0.0)); +#endif ASSERT (ptr == input + 10); ASSERT (errno == ERANGE); } @@ -539,7 +545,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 4); ASSERT (ptr2 == input + 4); ASSERT (errno == 0); @@ -587,7 +597,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 6); ASSERT (ptr2 == input + 6); ASSERT (errno == 0); @@ -630,7 +644,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 7); ASSERT (ptr2 == input + 7); ASSERT (errno == 0);