]> gitweb.factorcode.org Git - factor.git/commitdiff
terminfo: cleanup a little, separate the align-even-bytes.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 26 Apr 2013 15:55:39 +0000 (08:55 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 26 Apr 2013 15:55:39 +0000 (08:55 -0700)
extra/terminfo/terminfo.factor

index a9c453a8e64f5b71c256622116b9b116bcc83533..1c494d082f8be6593e2927184e5b7c5d82873863 100644 (file)
@@ -30,9 +30,7 @@ C: <terminfo-header> terminfo-header
     5 firstn <terminfo-header> ;
 
 : 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> terminfo-header
 : read-shorts ( n -- seq' )
     2 * read 2 <groups> [ 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 '[