Minor io.encodings.8-bit cleanup

db4
Daniel Ehrenberg 2008-04-06 19:03:00 -05:00
parent b369ed600d
commit d81a4aa914
1 changed files with 7 additions and 6 deletions

View File

@ -29,9 +29,10 @@ IN: io.encodings.8-bit
{ "mac-roman" "ROMAN" } { "mac-roman" "ROMAN" }
} ; } ;
: full-path ( file-name -- path ) : encoding-file ( file-name -- stream )
"extra/io/encodings/8-bit/" ".TXT" "extra/io/encodings/8-bit/" ".TXT"
swapd 3append resource-path ; swapd 3append resource-path
ascii <file-reader> ;
: tail-if ( seq n -- newseq ) : tail-if ( seq n -- newseq )
2dup swap length <= [ tail ] [ drop ] if ; 2dup swap length <= [ tail ] [ drop ] if ;
@ -48,8 +49,8 @@ IN: io.encodings.8-bit
: ch>byte ( assoc -- newassoc ) : ch>byte ( assoc -- newassoc )
[ swap ] assoc-map >hashtable ; [ swap ] assoc-map >hashtable ;
: parse-file ( file-name -- byte>ch ch>byte ) : parse-file ( path -- byte>ch ch>byte )
ascii file-lines process-contents lines process-contents
[ byte>ch ] [ ch>byte ] bi ; [ byte>ch ] [ ch>byte ] bi ;
TUPLE: 8-bit name decode encode ; TUPLE: 8-bit name decode encode ;
@ -71,13 +72,13 @@ M: 8-bit decode-char
: make-8-bit ( word byte>ch ch>byte -- ) : make-8-bit ( word byte>ch ch>byte -- )
[ 8-bit construct-boa ] 2curry dupd curry define ; [ 8-bit construct-boa ] 2curry dupd curry define ;
: define-8-bit-encoding ( name path -- ) : define-8-bit-encoding ( name stream -- )
>r in get create r> parse-file make-8-bit ; >r in get create r> parse-file make-8-bit ;
PRIVATE> PRIVATE>
[ [
"io.encodings.8-bit" in [ "io.encodings.8-bit" in [
mappings [ full-path define-8-bit-encoding ] assoc-each mappings [ encoding-file define-8-bit-encoding ] assoc-each
] with-variable ] with-variable
] with-compilation-unit ] with-compilation-unit