From 9cc21920261849bdc212c290bd6c922ce3e24fcc Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 10 Dec 2017 15:51:18 +0900 Subject: [PATCH] additional format fixes --- lib/chibi/show-test.sld | 5 ++++- lib/chibi/show/write.scm | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/chibi/show-test.sld b/lib/chibi/show-test.sld index 09c930a0..a9ae25cb 100644 --- a/lib/chibi/show-test.sld +++ b/lib/chibi/show-test.sld @@ -29,6 +29,9 @@ (test "abc def" (show #f "abc" (tab-to) "def")) (test "abc def" (show #f "abc" (tab-to 5) "def")) (test "abcdef" (show #f "abc" (tab-to 3) "def")) + (test "abc\ndef\n" (show #f "abc" nl "def" nl)) + (test "abc\ndef\n" (show #f "abc" fl "def" nl fl)) + (test "abc\ndef\n" (show #f "abc" fl "def" fl fl)) ;; numbers @@ -70,7 +73,7 @@ (test "1.00" (show #f (with ((precision 2)) .99755))) (test "1.00" (show #f (with ((precision 2)) .997))) (test "0.99" (show #f (with ((precision 2)) .99))) - (test "-15." (show #f (with ((precision 0)) -14.99995999999362))) + (test "-15" (show #f (with ((precision 0)) -14.99995999999362))) (test " 3.14159" (show #f (with ((decimal-align 5)) (numeric 3.14159)))) (test " 31.4159" (show #f (with ((decimal-align 5)) (numeric 31.4159)))) diff --git a/lib/chibi/show/write.scm b/lib/chibi/show/write.scm index 3c9f8709..6c455500 100644 --- a/lib/chibi/show/write.scm +++ b/lib/chibi/show/write.scm @@ -134,7 +134,7 @@ (let ((res (- (char->integer ch) (char->integer #\0)))) (if (<= 0 res 9) res - 0))) + ch))) (define (round-up ls) (let lp ((ls ls) (res '())) (cond @@ -224,9 +224,10 @@ (or (> next 5) (and (= next 5) (string-cursor>? last (string-cursor-start s)) - (odd? (digit-value + (memv (digit-value (string-cursor-ref - s (string-cursor-prev s last)))))))) + s (string-cursor-prev s last))) + '(1 3 5 7 9)))))) (list->string (reverse (map char-digit