]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/unicode/normalize/normalize.factor
factor: trim some using lists
[factor.git] / basis / unicode / normalize / normalize.factor
index ff59204aefeb9115c546afa355231c20da445ce5..cc22e6d339feaaab058c751e545dc51c3bd06dce 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ascii sequences namespaces make unicode.data kernel math arrays
-locals sorting.insertion accessors assocs math.order combinators
-strings sbufs hints combinators.short-circuit vectors ;
+USING: accessors arrays ascii combinators
+combinators.short-circuit hints kernel make math
+math.order sbufs sequences sorting.insertion strings
+unicode.data vectors ;
 IN: unicode.normalize
 
 <PRIVATE
@@ -88,23 +89,6 @@ HINTS: (nfd) string ;
 
 HINTS: (nfkd) string ;
 
-PRIVATE>
-
-: nfd ( string -- nfd )
-    [ (nfd) ] with-string ;
-
-: nfkd ( string -- nfkd )
-    [ (nfkd) ] with-string ;
-
-: string-append ( s1 s2 -- string )
-    [ append ] keep
-    0 over ?nth non-starter?
-    [ length dupd reorder-back ] [ drop ] if ;
-
-HINTS: string-append string string ;
-
-<PRIVATE
-
 ! Normalization -- Composition
 
 : initial-medial? ( str i -- ? )
@@ -113,17 +97,17 @@ HINTS: string-append string string ;
 : --final? ( str i -- ? )
     2 + swap ?nth final? ;
 
-: imf, ( str i -- str i )
+: imf% ( str i -- str i )
     [ tail-slice first3 jamo>hangul , ]
     [ 3 + ] 2bi ;
 
-: im, ( str i -- str i )
+: im% ( str i -- str i )
     [ tail-slice first2 final-base jamo>hangul , ]
     [ 2 + ] 2bi ;
 
 : compose-jamo ( str i -- str i )
     2dup initial-medial? [
-        2dup --final? [ imf, ] [ im, ] if
+        2dup --final? [ imf% ] [ im% ] if
     ] [ 2dup swap nth , 1 + ] if ;
 
 : pass-combining ( str -- str i )
@@ -153,7 +137,7 @@ DEFER: compose-iter
 
 : try-noncombining ( state char -- state )
     [ drop ] [ [ char>> ] dip combine-chars ] 2bi
-    [ >>char to f >>last-class compose-iter ] when* ; inline
+    [ >>char to f >>last-class compose-iter ] when* ; inline recursive
 
 : compose-iter ( state -- state )
     dup current [
@@ -188,9 +172,3 @@ DEFER: compose-iter
 HINTS: combine string ;
 
 PRIVATE>
-
-: nfc ( string -- nfc )
-    [ (nfd) combine ] with-string ;
-
-: nfkc ( string -- nfkc )
-    [ (nfkd) combine ] with-string ;