Merge branch 'titlecase' of github.com:mflatt/ChezScheme

original commit: 244185f858a01b4679d2add4f0f6dc90c9f92c3d
This commit is contained in:
Matthew Flatt 2019-01-20 16:35:27 -07:00
commit c647fd031d
3 changed files with 12 additions and 3 deletions

3
LOG
View File

@ -1067,3 +1067,6 @@
inspect.ss, prin.ss, mkheader.ss, misc.ms,
alloc.c, prim5.c, gc.c, fasl.c, externs.h,
smgmt.stex, system.stex, release_notes.stex
- 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.