summaryrefslogtreecommitdiff
path: root/src/util/snprintf.c
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-12-20 21:00:13 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-12-20 21:00:13 +0000
commit6420adb9c6c5300e563dd8aa12455e39ee388944 (patch)
tree7f068443b18590686c6743b75f20608b8ca6e26f /src/util/snprintf.c
parent2c6407b498e6b52dfc2677c9827995ee1c8c206b (diff)
Fix bug which ate zeros after decimal places for output.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@3939 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/snprintf.c')
-rw-r--r--src/util/snprintf.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/snprintf.c b/src/util/snprintf.c
index 458338fd..10c7f48f 100644
--- a/src/util/snprintf.c
+++ b/src/util/snprintf.c
@@ -60,6 +60,10 @@
* Short ints get promoted to ints by compiler, so changed args to va_arg
* to reflect this.
*
+ * Tom Goodale <goodale@cct.lsu.edu> 2004-12-20
+ * Fixes formatting of floating point numbers with zeros
+ * immediately after the decimal point.
+ *
**************************************************************/
@@ -663,6 +667,12 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
(caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while(fracpart && (fplace < 20));
+ /* Make sure we replace any leading zeros. */
+ while(fplace < max)
+ {
+ fconvert[fplace++] = '0';
+ }
+
if (fplace == 20) fplace--;
fconvert[fplace] = 0;