make hexdump work for byte-vectors
parent
237f16b4db
commit
f3e8bc1247
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays io io.streams.string kernel math math.parser
|
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
|
IN: tools.hexdump
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -26,13 +27,17 @@ IN: tools.hexdump
|
||||||
: write-hex-line ( bytes lineno -- )
|
: write-hex-line ( bytes lineno -- )
|
||||||
write-offset [ >hex-digits write ] [ >ascii write ] bi nl ;
|
write-offset [ >hex-digits write ] [ >ascii write ] bi nl ;
|
||||||
|
|
||||||
|
: hexdump-bytes
|
||||||
|
[ length write-header ]
|
||||||
|
[ 16 <sliced-groups> [ write-hex-line ] each-index ] bi ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
GENERIC: hexdump. ( byte-array -- )
|
GENERIC: hexdump. ( byte-array -- )
|
||||||
|
|
||||||
M: byte-array hexdump.
|
M: byte-array hexdump. hexdump-bytes ;
|
||||||
[ length write-header ]
|
|
||||||
[ 16 <sliced-groups> [ write-hex-line ] each-index ] bi ;
|
M: byte-vector hexdump. hexdump-bytes ;
|
||||||
|
|
||||||
: hexdump ( byte-array -- str )
|
: hexdump ( byte-array -- str )
|
||||||
[ hexdump. ] with-string-writer ;
|
[ hexdump. ] with-string-writer ;
|
||||||
|
|
Loading…
Reference in New Issue