]> gitweb.factorcode.org Git - factor.git/commitdiff
io.encodings.ascii: make sure encode-string gets a string.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 05:18:12 +0000 (22:18 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 05:18:12 +0000 (22:18 -0700)
basis/hints/hints.factor
core/io/encodings/ascii/ascii.factor

index d1272b45d8023c4ec6076d108a0445c899467f52..3dc8dff936880a1a282788345bff9ffd31901d84 100644 (file)
@@ -141,5 +141,3 @@ set-specializer
 M\ hashtable set-at
 { { object fixnum object } { object word object } }
 set-specializer
-
-\ encode-string { string object object } set-specializer
index 45217748a4be2f13c462552fcae40343a9a10d3a..2c7a475217c1b2c9d7e15b4b30e1cc11a653cf34 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors byte-arrays io io.encodings
-io.encodings.private kernel math sequences ;
+io.encodings.private kernel math sequences strings ;
 IN: io.encodings.ascii
 
 SINGLETON: ascii
@@ -10,15 +10,20 @@ M: ascii encode-char
     drop
     over 127 <= [ stream-write1 ] [ encode-error ] if ; inline
 
+<PRIVATE
+
+GENERIC: ascii> ( string -- byte-array )
+
+M: string ascii>
+    dup aux>>
+    [ [ dup 127 <= [ encode-error ] unless ] B{ } map-as ]
+    [ string>byte-array-fast ] if ; inline
+
+PRIVATE>
+
 M: ascii encode-string
     drop
-    [
-        dup aux>>
-        [ [ dup 127 <= [ encode-error ] unless ] B{ } map-as ]
-        [ string>byte-array-fast ]
-        if
-    ] dip
-    stream-write ;
+    [ ascii> ] dip stream-write ;
 
 M: ascii decode-char
     drop