From: Ilia Alshanetsky Date: Thu, 13 Feb 2003 17:25:31 +0000 (+0000) Subject: Fixed bug #22207 (e notation in *printf would be missing a 0 when there is X-Git-Tag: RELEASE_0_5~1040 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fffe4338a9379807b16c12aa551cb1b01889519;p=php Fixed bug #22207 (e notation in *printf would be missing a 0 when there is no exponent). Added a test case for the bug. --- diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index d5bd95c4b7..b53d5e3072 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -359,8 +359,12 @@ php_sprintf_appenddouble(char **buffer, int *pos, numbuf[i++] = fmt; exp_p = php_convert_to_decimal(decpt, 0, &dec2, &sign, 0); numbuf[i++] = sign ? '-' : '+'; - while (*exp_p) { - numbuf[i++] = *(exp_p++); + if (*exp_p) { + while (*exp_p) { + numbuf[i++] = *(exp_p++); + } + } else { + numbuf[i++] = '0'; } } else { numbuf[i++] = cvt[j++]; diff --git a/ext/standard/tests/strings/bug22207.phpt b/ext/standard/tests/strings/bug22207.phpt new file mode 100644 index 0000000000..1623fb8e41 --- /dev/null +++ b/ext/standard/tests/strings/bug22207.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #22207 (missing 0 when using the e notation in *printf functions) +--FILE-- + +--EXPECT-- +1.1000e+0 +string(17) " 1.1000e+0 +"