terminfo: simplify a bit.

db4
John Benediktsson 2013-04-25 21:29:05 -07:00
parent 7d27d64f36
commit ca3b7b9d6e
1 changed files with 5 additions and 12 deletions

View File

@ -37,20 +37,14 @@ C: <terminfo-header> terminfo-header
: read-booleans ( header -- booleans ) : read-booleans ( header -- booleans )
boolean-bytes>> read [ 1 = ] { } map-as ; boolean-bytes>> read [ 1 = ] { } map-as ;
: parse-shorts ( seq -- seq' ) : read-shorts ( n -- seq' )
[ le> dup 65535 = [ drop f ] when ] map ; 2 * read 2 <groups> [ le> dup 65535 = [ drop f ] when ] map ;
: read-numbers ( header -- numbers ) : read-numbers ( header -- numbers )
#numbers>> 2 * read 2 <groups> parse-shorts ; #numbers>> read-shorts ;
: read-strings ( header -- strings ) : read-strings ( header -- strings )
#strings>> 2 * read 2 <groups> parse-shorts ; [ #strings>> read-shorts ] [ string-bytes>> read ] bi '[
: read-string-table ( header -- string-table )
string-bytes>> read ;
: parse-strings ( strings string-table -- strings )
'[
[ _ 0 2over index-from swap subseq >string ] [ f ] if* [ _ 0 2over index-from swap subseq >string ] [ f ] if*
] map ; ] map ;
@ -64,8 +58,7 @@ C: <terminfo> terminfo
[ read-booleans ] [ read-booleans ]
[ read-numbers ] [ read-numbers ]
[ read-strings ] [ read-strings ]
[ read-string-table ] } cleave <terminfo> ;
} cleave parse-strings <terminfo> ;
PRIVATE> PRIVATE>