diff options
author | Paul Green <paulg@samba.org> | 2003-04-09 21:10:18 +0000 |
---|---|---|
committer | Paul Green <paulg@samba.org> | 2003-04-09 21:10:18 +0000 |
commit | 990ff150efe782b1f85af0c3b903f4e50e1757be (patch) | |
tree | 209e42ca0ee445318fae9366b589a4dddabc8347 /lib/snprintf.c | |
parent | e72b18a9bd9f89847e49e87c1159c74d7bf0fbf3 (diff) | |
download | rsync-990ff150efe782b1f85af0c3b903f4e50e1757be.tar.gz rsync-990ff150efe782b1f85af0c3b903f4e50e1757be.tar.bz2 rsync-990ff150efe782b1f85af0c3b903f4e50e1757be.zip |
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.
Diffstat (limited to 'lib/snprintf.c')
-rw-r--r-- | lib/snprintf.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/snprintf.c b/lib/snprintf.c index 0a52e176..4f3e4dc7 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -53,6 +53,9 @@ * got rid of fcvt code (twas buggy and made testing harder) * 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 */ @@ -725,15 +728,15 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, if (max > 0) { dopr_outch (buffer, currlen, maxlen, '.'); + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + while (fplace > 0) dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); } - while (zpadlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --zpadlen; - } - while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; |