Commit 990ff150 authored by Paul Green's avatar Paul Green

Fix bug reported by engard.ferenc at innomed.hu whereby using the %f format

in sprintf with a value like 0.025 produced 0.250.  We were dropping the
leading zeros before the fractional digits.
parent e72b18a9
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
* got rid of fcvt code (twas buggy and made testing harder) * got rid of fcvt code (twas buggy and made testing harder)
* added C99 semantics * added C99 semantics
* *
* Paul Green (paulg@samba.org) April 9, 2003
* fixed handling of %f when converting fractions with leading zeros.
* (e.g., 0.025).
**************************************************************/ **************************************************************/
#ifndef NO_CONFIG_H /* for some tests */ #ifndef NO_CONFIG_H /* for some tests */
...@@ -725,15 +728,15 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ...@@ -725,15 +728,15 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
if (max > 0) { if (max > 0) {
dopr_outch (buffer, currlen, maxlen, '.'); dopr_outch (buffer, currlen, maxlen, '.');
while (zpadlen > 0) {
dopr_outch (buffer, currlen, maxlen, '0');
--zpadlen;
}
while (fplace > 0) while (fplace > 0)
dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
} }
while (zpadlen > 0) {
dopr_outch (buffer, currlen, maxlen, '0');
--zpadlen;
}
while (padlen < 0) { while (padlen < 0) {
dopr_outch (buffer, currlen, maxlen, ' '); dopr_outch (buffer, currlen, maxlen, ' ');
++padlen; ++padlen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment