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



commit 7ab6704f78667970fec18344c094e2ef2a055f96
Author: Kevin Cozens <kcozens svn gnome org>
Date:   Mon Aug 29 17:24:28 2011 -0400

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

 plug-ins/script-fu/tinyscheme/scheme.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/script-fu/tinyscheme/scheme.c b/plug-ins/script-fu/tinyscheme/scheme.c
index 4a85f6d..5633ec6 100644
--- a/plug-ins/script-fu/tinyscheme/scheme.c
+++ b/plug-ins/script-fu/tinyscheme/scheme.c
@@ -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) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]