From de21951d79339ac64af6ef089e8f8e577730a887 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 26 Apr 2013 08:55:39 -0700 Subject: [PATCH] terminfo: cleanup a little, separate the align-even-bytes. --- extra/terminfo/terminfo.factor | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extra/terminfo/terminfo.factor b/extra/terminfo/terminfo.factor index a9c453a8e6..1c494d082f 100644 --- a/extra/terminfo/terminfo.factor +++ b/extra/terminfo/terminfo.factor @@ -30,9 +30,7 @@ C: terminfo-header 5 firstn ; : read-names ( header -- names ) - names-bytes>> - [ read 1 head* "|" split [ >string ] map ] - [ odd? [ read1 drop ] when ] bi ; + names-bytes>> read 1 head* "|" split [ >string ] map ; : read-booleans ( header -- booleans ) boolean-bytes>> read [ 1 = ] { } map-as ; @@ -40,8 +38,12 @@ C: terminfo-header : read-shorts ( n -- seq' ) 2 * read 2 [ le> dup 65535 = [ drop f ] when ] map ; +: align-even-bytes ( header -- ) + [ names-bytes>> ] [ boolean-bytes>> ] bi + odd? + [ read1 drop ] when ; + : read-numbers ( header -- numbers ) - #numbers>> read-shorts ; + [ align-even-bytes ] [ #numbers>> read-shorts ] bi ; : read-strings ( header -- strings ) [ #strings>> read-shorts ] [ string-bytes>> read ] bi '[