R5RS fix adds decimal point for inexact in atom2str (SourceForge bug #3395548)

This commit is contained in:
Kevin Cozens 2011-08-29 17:24:28 -04:00
parent 6af99d4793
commit 7ab6704f78
1 changed files with 7 additions and 0 deletions

View File

@ -2127,6 +2127,13 @@ static void atom2str(scheme *sc, pointer l, int f, char **pp, int *plen) {
snprintf(p, STRBUFFSIZE, "%ld", ivalue_unchecked(l));
} else {
snprintf(p, STRBUFFSIZE, "%.10g", rvalue_unchecked(l));
/* R5RS says there must be a '.' (unless 'e'?) */
f = strcspn(p, ".e");
if (p[f] == 0) {
p[f] = '.'; // not found, so add '.0' at the end
p[f+1] = '0';
p[f+2] = 0;
}
}
} else if (is_string(l)) {
if (!f) {