1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 09:56:07 +03:00

Merge pull request #233 from wader/interp-decode-tobinary-simplier

interp: Simpler and more efficient hexdump
This commit is contained in:
Mattias Wadman 2022-04-19 18:21:39 +02:00 committed by GitHub
commit 8f1b2bceca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
package interp
import (
"bytes"
"errors"
"fmt"
"io"
@ -399,23 +398,11 @@ func dump(v *decode.Value, w io.Writer, opts Options) error {
}
func hexdump(w io.Writer, bv Binary, opts Options) error {
br, err := bv.toReader()
br, err := bitioextra.Range(bv.br, bv.r.Start, bv.r.Len)
if err != nil {
return err
}
cBR, err := bitioextra.Clone(bv.br)
if err != nil {
return err
}
bytesB := &bytes.Buffer{}
if _, err := bitioextra.CopyBits(bytesB, cBR); err != nil {
return err
}
biib := bitio.NewBitReader(bytesB.Bytes(), -1)
// TODO: hack
opts.Verbose = true
return dump(
@ -423,7 +410,7 @@ func hexdump(w io.Writer, bv Binary, opts Options) error {
// TODO: hack
V: &scalar.S{Actual: br},
Range: bv.r,
RootReader: biib,
RootReader: bv.br,
},
w,
opts,