diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2003-09-29 23:44:17 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2003-09-29 23:44:17 +0000 |
commit | b5b29e267e928d090e969685d053ae10ab0455c8 (patch) | |
tree | fc23af067aac41042eb1d5e68441756fa1e440aa | |
parent | d632dba1ef1b6dcc00bd0b3d6ac4d52fa865fc3a (diff) | |
download | php-git-b5b29e267e928d090e969685d053ae10ab0455c8.tar.gz |
MFH: More NaN & INF handling fixes.
-rw-r--r-- | main/snprintf.c | 20 |
1 files changed, 18 insertions, 2 deletions
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) |