cvs: php4 /ext/standard formatted_print.c

From: Date: Mon, 14 Aug 2000 10:02:14 +0000
Subject: cvs: php4 /ext/standard formatted_print.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1170@lists.php.net to get a copy of this message
stas Mon Aug 14 03:02:14 2000 EDT Modified files: /php4/ext/standard formatted_print.c Log: Fix non-numbers printing (#6142) # Please, somebody knowing about floats - check if there's more non-numbers # seems we should check for all of them Index: php4/ext/standard/formatted_print.c diff -u php4/ext/standard/formatted_print.c:1.23 php4/ext/standard/formatted_print.c:1.24 --- php4/ext/standard/formatted_print.c:1.23 Thu Jul 20 20:21:56 2000 +++ php4/ext/standard/formatted_print.c Mon Aug 14 03:02:14 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.23 2000/07/21 03:21:56 coar Exp $ */ +/* $Id: formatted_print.c,v 1.24 2000/08/14 10:02:14 stas Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -252,6 +252,39 @@ } else if (precision > MAX_FLOAT_PRECISION) { precision = MAX_FLOAT_PRECISION; } + + if( +#if defined(HAVE_ISNAN) + isnan(number) +#elif defined(NAN) + number == NAN +#else + 0 +#endif + ) { + sign = (number<0); + php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding, + alignment, precision, sign, 0); + return; + } + + if( +#if defined(HAVE_ISISINF) + isinf(number) +#elif defined(HAVE_ISFINITE) + !isfinite(number) +#elif defined(HAVE_FINITE) + !finite(number) +#else + 0 +#endif + ) { + sign = (number<0); + php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding, + alignment, precision, sign, 0); + return; + } + cvt = php_convert_to_decimal(number, precision, &decpt, &sign, (fmt == 'e')); if (sign) {

« previous php.cvs (#1170) next »