From: Ilia Alshanetsky Date: Mon, 29 Sep 2003 23:44:17 +0000 (+0000) Subject: MFH: More NaN & INF handling fixes. X-Git-Tag: php-4.3.4RC1~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5b29e267e928d090e969685d053ae10ab0455c8;p=php MFH: More NaN & INF handling fixes. --- diff --git a/main/snprintf.c b/main/snprintf.c index 8aa2d01881..b9383c57da 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -794,6 +794,23 @@ static int format_converter(register buffy * odp, const char *fmt, case 'g': case 'G': + fp_num = va_arg(ap, double); + + if (zend_isnan(fp_num)) { + s = "NAN"; + s_len = 3; + break; + } else if (zend_isinf(fp_num)) { + if (fp_num > 0) { + s = "INF"; + s_len = 3; + } else { + s = "-INF"; + s_len = 4; + } + break; + } + if (adjust_precision == NO) precision = FLOAT_DIGITS; else if (precision == 0) @@ -801,8 +818,7 @@ static int format_converter(register buffy * odp, const char *fmt, /* * * We use &num_buf[ 1 ], so that we have room for the sign */ - s = ap_php_gcvt(va_arg(ap, double), precision, &num_buf[1], - alternate_form); + s = ap_php_gcvt(fp_num, precision, &num_buf[1], alternate_form); if (*s == '-') prefix_char = *s++; else if (print_sign)