diff --git a/src/acconfig.h b/src/acconfig.h index dba3f89b126c86e19cba0b979537d9e2f351523c..e69b20ec4eeaeb21c2b43aa22361ec212b50bbfd 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -247,6 +247,9 @@ /* Define if you have _isnan */ #undef HAVE__ISNAN +/* Define if you have isfinite */ +#undef HAVE_ISFINITE + /* Define if you have fork */ #undef HAVE_FORK diff --git a/src/configure.in b/src/configure.in index 125fddf55707fa8c97fc065de7dd6d3cff3eaeab..023342a0805f14dec5022f0e2e31499e2da174b6 100644 --- a/src/configure.in +++ b/src/configure.in @@ -4719,6 +4719,16 @@ MY_CHECK_FUNCTION(_isnan, exit(_isnan(0.0)); ]) ############################################################################# +# isfinite() is a macro on at least OS X and Linux which doesn't play well +# with AC_CHECK_FUNCS(). +MY_CHECK_FUNCTION(isfinite, +[ +#include <math.h> +], [ + int t = isfinite(0.0); + exit(0); +]) +############################################################################# # FreeBSD 3.0 has broken F_SETFD when running with threads. diff --git a/src/encode.c b/src/encode.c index 8215406e89583bbf348f428244ec3070729317b3..6d99fa9dc98d73f6895071b272afdd3739e74dc2 100644 --- a/src/encode.c +++ b/src/encode.c @@ -675,7 +675,10 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc pike_ftype=Pike_FP_PZERO; else #endif -#ifdef HAVE_FINITE +#ifdef HAVE_ISFINITE + if(!isfinite(d)) + pike_ftype=Pike_FP_PINF; +#elif HAVE_FINITE if(!finite(d)) pike_ftype=Pike_FP_PINF; #endif diff --git a/src/sprintf.c b/src/sprintf.c index 2b06c31621431e532d46b26363ca9562faee81ec..5a75db7259235e2223d4bea81b883251e0aa56c0 100644 --- a/src/sprintf.c +++ b/src/sprintf.c @@ -476,7 +476,10 @@ static void low_write_IEEE_float(char *b, double d, int sz) e = 0; else #endif -#ifdef HAVE_FINITE +#ifdef HAVE_ISFINITE + if(!isfinite(d)) + e = maxexp; +#elif HAVE_FINITE if(!finite(d)) e = maxexp; #endif