diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2002-10-15 12:07:36 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2002-10-15 12:07:36 +0000 |
commit | 95312e994e8e1a5e4cfe3ee3ec837438742279ef (patch) | |
tree | 77bfd7f94a6a9cec456cd65d8098adc35e4ce5ae | |
parent | 1a08e5b622f07893ed3ff2718491ef7847635d73 (diff) | |
download | php-git-95312e994e8e1a5e4cfe3ee3ec837438742279ef.tar.gz |
Fixed bug #4232. (Added support for %e and %E to printf/sprintf)
-rw-r--r-- | ext/standard/formatted_print.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index f2160c9745..8dc3d2f9a8 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -333,6 +333,31 @@ php_sprintf_appenddouble(char **buffer, int *pos, if (precision > 0) numbuf[i++] = decimal_point; } + } else if (fmt == 'e' || fmt == 'E') { + char *exp_p; + int dec2; + + decpt--; + + numbuf[i++] = cvt[j++]; + numbuf[i++] = decimal_point; + + if (precision > 0) { + int k = precision; + + while (k-- && cvt[j]) { + numbuf[i++] = cvt[j++]; + } + } else { + numbuf[i++] = '0'; + } + + numbuf[i++] = fmt; + exp_p = php_convert_to_decimal(decpt, 0, &dec2, &sign, 0); + numbuf[i++] = sign ? '-' : '+'; + while (*exp_p) { + numbuf[i++] = *(exp_p++); + } } else { numbuf[i++] = cvt[j++]; if (precision > 0) |