summaryrefslogtreecommitdiff
path: root/lib/snprintf.c
diff options
context:
space:
mode:
authorPaul Green <paulg@samba.org>2003-04-09 21:10:18 +0000
committerPaul Green <paulg@samba.org>2003-04-09 21:10:18 +0000
commit990ff150efe782b1f85af0c3b903f4e50e1757be (patch)
tree209e42ca0ee445318fae9366b589a4dddabc8347 /lib/snprintf.c
parente72b18a9bd9f89847e49e87c1159c74d7bf0fbf3 (diff)
downloadrsync-990ff150efe782b1f85af0c3b903f4e50e1757be.tar.gz
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.c13
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;