cvs: php4 /main snprintf.c
| From: | Andi Gutmans | Date: | Tue, 01 May 2001 16:29:52 +0000 |
| Subject: | cvs: php4 /main snprintf.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5430@lists.php.net to get a copy of this message | ||
andi Tue May 1 09:29:52 2001 EDT
Modified files:
/php4/main snprintf.c
Log:
- Fix snprintf() to work with nan and inf properly
Index: php4/main/snprintf.c
diff -u php4/main/snprintf.c:1.4 php4/main/snprintf.c:1.5
--- php4/main/snprintf.c:1.4 Thu Feb 10 11:41:18 2000
+++ php4/main/snprintf.c Tue May 1 09:29:52 2001
@@ -112,7 +112,8 @@
*/
if (fi != 0) {
p1 = &buf[NDIG];
- while (fi != 0) {
+// while (fi != 0) {
+ while (p1 > &buf[0] && fi != 0) {
fj = modf(fi / 10, &fi);
*--p1 = (int) ((fj + .03) * 10) + '0';
r2++;
@@ -743,15 +744,23 @@
case 'E':
fp_num = va_arg(ap, double);
- s = conv_fp(*fmt, fp_num, alternate_form,
- (adjust_precision == NO) ? FLOAT_DIGITS : precision,
- &is_negative, &num_buf[1], &s_len);
- if (is_negative)
- prefix_char = '-';
- else if (print_sign)
- prefix_char = '+';
- else if (print_blank)
- prefix_char = ' ';
+ if (zend_isnan(fp_num)) {
+ s = "nan";
+ s_len = 3;
+ } else if (zend_isinf(fp_num)) {
+ s = "inf";
+ s_len = 3;
+ } else {
+ s = conv_fp(*fmt, fp_num, alternate_form,
+ (adjust_precision == NO) ? FLOAT_DIGITS : precision,
+ &is_negative, &num_buf[1], &s_len);
+ if (is_negative)
+ prefix_char = '-';
+ else if (print_sign)
+ prefix_char = '+';
+ else if (print_blank)
+ prefix_char = ' ';
+ }
break;