fix string-titlecase on special-casing characters

original commit: 0ae58f75bcf76fb41e571579a81ab2080379455c
This commit is contained in:
Matthew Flatt 2019-01-20 16:32:47 -07:00
parent 03a33fb4fc
commit 4752199578
3 changed files with 12 additions and 3 deletions

3
LOG
View File

@ -1027,3 +1027,6 @@
cpnanopass.ss, x86_64.ss, x86.ss, foreign2.c, foreign.ms
- added initialization of seginfo sorted and trigger_ephemerons fields.
segment.c
- fix `string-titlecase` on special-casing characters like #\xDF and
#\xFB00
5_4.ss, 5_4.ms

View File

@ -1162,6 +1162,10 @@
(test (string-titlecase "r6rs") "R6rs") ; this example appears to be wrong in R6RS (Sept 2007 version)
(test (string-titlecase "R6RS") "R6rs") ; this one, too
(test (string-titlecase "stra \xDF;e") "Stra Sse")
(test (string-titlecase "one \xFB00;e") "One Ffe")
(test (string-titlecase "one\xFB00;e") "One\xFB00;e")
(test (string-downcase "A\x3A3;'x") "a\x3C3;'x") ; ' is a MidLetter
(test (string-ci<? "a" "Z") #t)

View File

@ -403,9 +403,11 @@
(define (trans s i c seen-cased? ac)
(if seen-cased?
(trans1 s i ($str-downcase c) #t ac)
(if ($char-cased? c)
(trans1 s i ($str-titlecase c) #t ac)
(trans1 s i c #f ac))))
(let ([tc ($str-titlecase c)])
(if (or ($char-cased? c)
(not (eqv? c tc)))
(trans1 s i tc #t ac)
(trans1 s i c #f ac)))))
; NB: if used as a pattern for word breaking, take care not to break between CR & LF (WB3)
; NB: and between regional-indicators (WB13c). also take care not to let handling of WB6 and
; NB: WB7 here prevent breaks in, e.g., "a." when not followed by, e.g., another letter.