From ca3b7b9d6e9e001e94563a86521694ef0c32f079 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 25 Apr 2013 21:29:05 -0700 Subject: [PATCH] terminfo: simplify a bit. --- extra/terminfo/terminfo.factor | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/extra/terminfo/terminfo.factor b/extra/terminfo/terminfo.factor index 84cc43d162..4e19c3607c 100644 --- a/extra/terminfo/terminfo.factor +++ b/extra/terminfo/terminfo.factor @@ -37,20 +37,14 @@ C: terminfo-header : read-booleans ( header -- booleans ) boolean-bytes>> read [ 1 = ] { } map-as ; -: parse-shorts ( seq -- seq' ) - [ le> dup 65535 = [ drop f ] when ] map ; +: read-shorts ( n -- seq' ) + 2 * read 2 [ le> dup 65535 = [ drop f ] when ] map ; : read-numbers ( header -- numbers ) - #numbers>> 2 * read 2 parse-shorts ; + #numbers>> read-shorts ; : read-strings ( header -- strings ) - #strings>> 2 * read 2 parse-shorts ; - -: read-string-table ( header -- string-table ) - string-bytes>> read ; - -: parse-strings ( strings string-table -- strings ) - '[ + [ #strings>> read-shorts ] [ string-bytes>> read ] bi '[ [ _ 0 2over index-from swap subseq >string ] [ f ] if* ] map ; @@ -64,8 +58,7 @@ C: terminfo [ read-booleans ] [ read-numbers ] [ read-strings ] - [ read-string-table ] - } cleave parse-strings ; + } cleave ; PRIVATE>