]> granicus.if.org Git - php/commitdiff
MFH: More NaN & INF handling fixes.
authorIlia Alshanetsky <iliaa@php.net>
Mon, 29 Sep 2003 23:44:17 +0000 (23:44 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 29 Sep 2003 23:44:17 +0000 (23:44 +0000)
main/snprintf.c

index 8aa2d0188159a324e3b63ee953f9124c0ef27180..b9383c57da318cce1f33dd1f8adfe8c52b11f091 100644 (file)
@@ -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)