From 6d2cf313cb8d162defb541b6c116aba09943f46c Mon Sep 17 00:00:00 2001
From: Simon Brooke <simon@journeyman.cc>
Date: Mon, 31 Dec 2018 16:24:38 +0000
Subject: [PATCH] Very small fix to formatting integers.

---
 src/arith/integer.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/arith/integer.c b/src/arith/integer.c
index d916c99..ec242bd 100644
--- a/src/arith/integer.c
+++ b/src/arith/integer.c
@@ -251,6 +251,14 @@ struct cons_pointer integer_to_string( struct cons_pointer int_pointer,
                 accumulator += ( base * ( i / base ) );
             }
         }
+        
+        if (stringp(result) && pointer2cell(result).payload.string.character == L',') {
+          /* if the number of digits in the string is divisible by 3, there will be
+           * an unwanted comma on the front. */
+          struct cons_pointer tmp = result;
+          result = pointer2cell(result).payload.string.cdr;
+          dec_ref(tmp);
+        }
 
         if ( is_negative ) {
             result = make_string( L'-', result );