make hexdump work for byte-vectors

db4
Doug Coleman 2009-02-13 09:55:38 -06:00
parent 237f16b4db
commit f3e8bc1247
1 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,8 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays io io.streams.string kernel math math.parser
namespaces sequences splitting grouping strings ascii byte-arrays ;
namespaces sequences splitting grouping strings ascii
byte-arrays byte-vectors ;
IN: tools.hexdump
<PRIVATE
@ -26,13 +27,17 @@ IN: tools.hexdump
: write-hex-line ( bytes lineno -- )
write-offset [ >hex-digits write ] [ >ascii write ] bi nl ;
: hexdump-bytes
[ length write-header ]
[ 16 <sliced-groups> [ write-hex-line ] each-index ] bi ;
PRIVATE>
GENERIC: hexdump. ( byte-array -- )
M: byte-array hexdump.
[ length write-header ]
[ 16 <sliced-groups> [ write-hex-line ] each-index ] bi ;
M: byte-array hexdump. hexdump-bytes ;
M: byte-vector hexdump. hexdump-bytes ;
: hexdump ( byte-array -- str )
[ hexdump. ] with-string-writer ;