[Toybox] [PATCH] xxd: -d Decimal Lables flag, Don't cap at one file

enh enh at google.com
Mon Apr 22 14:14:23 PDT 2024


On Sat, Apr 20, 2024 at 7:38 PM Oliver Webb via Toybox
<toybox at lists.landley.net> wrote:
>
> Looking at xxd, I noticed that the -b[inary] flag wasn't there,
> Having some facility to print binary is nice, but since printf
> doesn't have anything in built for it implementing it isn't hard,
> but it looks _ugly_. Which is why I decided not to do that in this
> patch.
>
> xxd also runs on average about 5 times slower than vim xxd, this is
> because of read reading 16 bytes at a time, also not hard to fix, but
> very hard to fix cleanly.

really? a quick glance suggests it reads blocks of sizeof(toybuf)? (or
"whatever stdio is using for its buffer" in the -r case.)

> xxd has a -d flag to do decimal address lables that I added in this patch.

do you have a _use_ for that? i saw it and ignored it when
implementing toybox xxd because i couldn't even imagine a use for
decimal addresses...

> Toybox xxd intentionally caps itself at 1 file per invocation, "Why?": Vim xxd is
> a bloated pile of garbage with things like EBCDIC support. They added a
> "improvement" where if you gave 2 files to it, it would rewrite the contents
> of the second with the output of the first because it was made for operating
> systems where file redirection wasn't a built in thing. As someone who's lost
> data because of this, I'm glad there isn't support for this in toybox xxd.
>
> But even though we do loopfiles() over the arguments, There isn't any actual way
> to take advantage of that code since we cap it at one file. Removing the cap doesn't
> break anything that wouldn't already be broken, so I removed the ">1" in the option
> string in this patch.
>
> -   Oliver Webb <aquahobbyist at proton.me>
>
> P.S. As someone who once did a cleanup pass on a vim xxd fork a while back,
> a reason to not do colorized output is that you are outputting ANSI codes
> for _every byte, twice_. And unless you have code to optimize that down, your
> files can take 3/4 times longer to print out via colorized xxd since every
> line goes from 68 bytes to 420:
>
> Colored xxd:
> 0001d590: 306d 201b 5b31 3b33 376d 3030 1b5b 306d  0m .[1;37m00.[0m
> 0001d5a0: 1b5b 313b 3337 6d30 301b 5b30 6d20 1b5b  .[1;37m00.[0m .[
> 0001d5b0: 313b 3337 6d30 301b 5b30 6d1b 5b31 3b33  1;37m00.[0m.[1;3
> Normal xxd:
> 000159a0: 3030 2030 3030 3020 3030 3030 2030 3030  00 0000 0000 000
> 000159b0: 3020 3030 3030 2030 3030 3020 3030 3030  0 0000 0000 0000
> 000159c0: 2030 3030 3020 202e 2e2e 2e2e 2e2e 2e2e   0000  .........
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net


More information about the Toybox mailing list