~ chicken-core (chicken-5) 31bcafcf3014e128a462e48b0a35915a1180b5f4
commit 31bcafcf3014e128a462e48b0a35915a1180b5f4
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sat Sep 15 11:26:32 2018 +0200
Commit: Evan Hanson <evhan@foldling.org>
CommitDate: Wed Sep 19 06:31:07 2018 +1200
Fix broken string-ci>=?/string-ci<=?
For arguments that have matching prefix but different length.
Reported by Nils Holm.
See also: https://groups.google.com/group/comp.lang.scheme/t/6b8be06b84b39a7
Signed-off-by: Evan Hanson <evhan@foldling.org>
diff --git a/library.scm b/library.scm
index e81648cd..72d32150 100644
--- a/library.scm
+++ b/library.scm
@@ -1470,14 +1470,14 @@ EOF
s1 s2 'string-ci<=?
(lambda (len1 len2 cmp)
(if (eq? cmp 0)
- (fx>= len1 len2)
+ (fx<= len1 len2)
(fx< cmp 0) ) ) ) ) )
(set! scheme#string-ci>=? (lambda (s1 s2)
(compare
s1 s2 'string-ci>=?
(lambda (len1 len2 cmp)
(if (eq? cmp 0)
- (fx<= len1 len2)
+ (fx>= len1 len2)
(fx> cmp 0) ) ) ) ) ) )
(define (##sys#string-append x y)
diff --git a/tests/library-tests.scm b/tests/library-tests.scm
index bf1164e1..f31e17f0 100644
--- a/tests/library-tests.scm
+++ b/tests/library-tests.scm
@@ -498,6 +498,12 @@ A
(assert (string-ci<? "foo\x00a" "foo\x00B"))
(assert (string-ci>? "foo\x00b" "foo\x00A"))
+;; reported by Nils Holm (#1534)
+;; https://groups.google.com/group/comp.lang.scheme/t/6b8be06b84b39a7
+(assert (not (string-ci<=? "test" "tes")))
+(assert (string-ci>=? "test" "tes"))
+
+
;;; getter-with-setter
(define foo
Trap