Fixing string-foldcase to always use non-final small sigma.

Fixes issue #217.
This commit is contained in:
Alex Shinn 2014-05-06 10:04:48 +09:00
parent 09addf0920
commit a1ab36c667
2 changed files with 5 additions and 4 deletions

View file

@ -77,7 +77,7 @@
(proc out)
(get-output-string out)))
(define (string-downcase str)
(define (string-down-or-fold-case str fold?)
(call-with-output-string
(lambda (out)
(let ((in (open-input-string str)))
@ -86,7 +86,7 @@
(cond
((not (eof-object? ch))
(display
(if (eqv? ch #\x03A3)
(if (and (not fold?) (eqv? ch #\x03A3))
(let ((ch2 (peek-char in)))
(if (or (eof-object? ch2)
(not (char-set-contains? char-set:letter ch2)))
@ -96,7 +96,8 @@
out)
(lp)))))))))
(define string-foldcase string-downcase)
(define (string-downcase str) (string-down-or-fold-case str #f))
(define (string-foldcase str) (string-down-or-fold-case str #t))
(define (string-upcase str)
(call-with-output-string

View file

@ -1194,7 +1194,7 @@
(test "γλώσσα" (string-foldcase "ΓΛΏΣΣΑ"))
(test "ΜΈΛΟΣ" (string-upcase "μέλος"))
(test "μέλος" (string-downcase "ΜΈΛΟΣ"))
(test "μέλος" (string-foldcase "ΜΈΛΟΣ"))
(test "μέλοσ" (string-foldcase "ΜΈΛΟΣ"))
(test "μέλος ενός" (string-downcase "ΜΈΛΟΣ ΕΝΌΣ"))
(test "" (substring "" 0 0))