chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATCH] Add trailing zero to incomplete gcvt(3) output


From: Felix
Subject: [Chicken-hackers] [PATCH] Add trailing zero to incomplete gcvt(3) output on mingw32"
Date: Thu, 11 Jul 2013 12:16:25 +0200 (CEST)

On mingw32 gcvt(3) doesn't add a trailing zero to it's output when the
argument has a zero fractional part. This change adds '\0' explicitly
in that case. Reported by Michele La Monaca, who also tested the fix.


cheers,
felix
>From 0982bce46de8ce4f09db5a2e941c1a20f89b89cd Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Thu, 11 Jul 2013 12:14:50 +0200
Subject: [PATCH] On mingw32 gcvt(3) doesn't add a trailing zero to it's
 output when the argument has a zero fractional part. This
 change adds '\0' explicitly in that case. Reported by
 Michele La Monaca, who also tested the fix.

---
 runtime.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/runtime.c b/runtime.c
index d7d79f2..33e4d11 100644
--- a/runtime.c
+++ b/runtime.c
@@ -7832,6 +7832,11 @@ void C_ccall C_number_to_string(C_word c, C_word 
closure, C_word k, C_word num,
       }
       else if(buffer[ 1 ] != 'i') C_strcat(buffer, C_text(".0")); /* negative 
infinity? */
     }
+#ifdef __MINGW32__
+    /* On mingw32, gcvt(3) does not add a trailing '\0' */
+    else if(buffer[ C_strlen(buffer) - 1 ] == '.')
+      C_strcat(buffer, C_text("0"));
+#endif
 
     p = buffer;
   }
-- 
1.7.9.5


reply via email to

[Prev in Thread] Current Thread [Next in Thread]