]> gitweb.factorcode.org Git - factor.git/commitdiff
unicode.case: slightly cleaner locale case handling.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Aug 2012 18:32:12 +0000 (11:32 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Aug 2012 18:32:12 +0000 (11:32 -0700)
basis/unicode/case/case.factor

index d14c765f4cf10a937c70320f7f8118bb72b2ce95..e19fd2ba84510b2f85a30863af9a7d94edd5d824 100644 (file)
@@ -17,10 +17,10 @@ SYMBOL: locale ! Just casing locale, or overall?
 : replace ( old new str -- newstr )
     [ split-subseq ] dip join ; inline
 
-: i-dot? ( -- ? )
-    locale get { "tr" "az" } member? ;
+: i-dot? ( locale -- ? )
+    { "tr" "az" } member? ; inline
 
-: lithuanian? ( -- ? ) locale get "lt" = ;
+: lithuanian? ( locale -- ? ) "lt" = ; inline
 
 : lithuanian>upper ( string -- lower )
     "i\u000307" "i" replace
@@ -80,19 +80,26 @@ SYMBOL: locale ! Just casing locale, or overall?
         [ char-quot call out push ] ?if
     ] each out "" like ; inline
 
+: locale>lower ( string -- string' )
+    locale get
+    [ i-dot? [ turk>lower ] when ]
+    [ lithuanian? [ lithuanian>lower ] when ] bi ;
+
+: locale>upper ( string -- string' )
+    locale get
+    [ i-dot? [ turk>upper ] when ]
+    [ lithuanian? [ lithuanian>upper ] when ] bi ;
+
 PRIVATE>
 
 : >lower ( string -- lower )
-    i-dot? [ turk>lower ] when
-    lithuanian? [ lithuanian>lower ] when
-    final-sigma
+    locale>lower final-sigma
     [ lower>> ] [ ch>lower ] map-case ;
 
 HINTS: >lower string ;
 
 : >upper ( string -- upper )
-    i-dot? [ turk>upper ] when
-    lithuanian? [ lithuanian>upper ] when
+    locale>upper
     [ upper>> ] [ ch>upper ] map-case ;
 
 HINTS: >upper string ;
@@ -100,8 +107,7 @@ HINTS: >upper string ;
 <PRIVATE
 
 : (>title) ( string -- title )
-    i-dot? [ turk>upper ] when
-    lithuanian? [ lithuanian>upper ] when
+    locale>upper
     [ title>> ] [ ch>title ] map-case ; inline
 
 PRIVATE>