summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-09 23:57:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-09 23:57:04 -0800
commit8817d95ca84e7ce4478a29a82b65632979125980 (patch)
treebe3ef111df0a045d64858ec0ffdf3a50068cf3b8
parentbd673c7e3b84bd36a60bea7a2ece0386d7afbb3c (diff)
downloadtxr-8817d95ca84e7ce4478a29a82b65632979125980.tar.gz
txr-8817d95ca84e7ce4478a29a82b65632979125980.tar.bz2
txr-8817d95ca84e7ce4478a29a82b65632979125980.zip
Fix broken Json parsing test case on MinGW.
* stream.c (vformat): Fix incorrect code for normalizing exponent fields in the output of sprintf's floating-point conversion. For ~e, the logic would let through a leading zero. For ~a/~s conversion, it was comparing to 0 instead of '0', not squashing leading zeros at all.
-rw-r--r--ChangeLog10
-rw-r--r--stream.c11
2 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index dee34c4b..e1954b41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2014-01-09 Kaz Kylheku <kaz@kylheku.com>
+ Fix broken Json parsing test case on MinGW.
+
+ * stream.c (vformat): Fix incorrect code for normalizing
+ exponent fields in the output of sprintf's floating-point
+ conversion. For ~e, the logic would let through a leading zero.
+ For ~a/~s conversion, it was comparing to 0 instead of '0',
+ not squashing leading zeros at all.
+
+2014-01-09 Kaz Kylheku <kaz@kylheku.com>
+
* stream.c: Eliminate useless #else section containing #error
2013-01-09 Kaz Kylheku <kaz@kylheku.com>
diff --git a/stream.c b/stream.c
index bd76e43d..1ad75444 100644
--- a/stream.c
+++ b/stream.c
@@ -1528,11 +1528,14 @@ val vformat(val stream, val fmtstr, va_list vl)
else if (*scan == '+')
scan++;
- while (scan[0] == '0' && scan[1] == '0')
+ while (*scan == '0')
scan++;
- while (*scan)
- *exp++ = *scan++;
+ if (!*scan)
+ *exp++ = '0';
+ else
+ while (*scan)
+ *exp++ = *scan++;
*exp = 0;
}
@@ -1588,7 +1591,7 @@ val vformat(val stream, val fmtstr, va_list vl)
else if (*scan == '+')
scan++;
- while (*scan == 0)
+ while (*scan == '0')
scan++;
while (*scan)