[illumos-Developer] webrev: reimplementation of od
Garrett D'Amore
garrett at nexenta.com
Sat Oct 16 22:02:10 PDT 2010
So I couldn't find a suitable "od". GNU is GPL and not POSIX compliant
to boot. (At least from my tests.) And the legacy Solaris one is --
startlingly, amazingly bad. (If anyone can tell me what od -tfD
*thinks* its doing when long doubles are 12-bytes wide, I'd love to hear
an explanation. I think its just generating random garbage somehow.)
Anyway, the new code I wrote is here:
http://pastebin.ca/1964590
Its not in an ON workspace yet.
I've reasonably tested this as best as I can. It performs on par with
legacy Sun od, and for some interesting cases runs even faster. (od -c
in particular.)
As far as I can tell, for the main common cases I generate bit-for-bit
identical output to Sun's legacy od.
The situations where I do not are:
a) any situation involving long doubles. Sun's code was hideously
busted here. I believe my code does the right thing, even when mixing
it with 8-byte wide formats. (The block size then becomes 12 bytes.)
b) spacing differences when outputting multiple formats. I can't
figure out what the logic Sun uses to try to spread the format out via
"justification" or somesuch here, and I'm not really interested in
guessing, as the permutations are large. These whitespace differences
are permitted by POSIX.
c) No support for legacy semantics of "-c". If you want those in your
script, run your script with LANG=C (or LC_CTYPE=C), rather than in a
different locale. (It will go faster, too!) The semantics I followed
are what is required by POSIX.
d) No special interpretation of "-" to mean stdin. That's verboten by
POSIX, and the xpg4 version doesn't do it. So neither does my code. If
someone *really* believes they want to mix stdin on the list of files,
let me know, and I'll craft a version up. I just think its not very
worthwhile, its a semantics that is horribly confusing.
Assuming I get some good reviews of this, I'll probably integrate it on
Monday. It compiles cleanly, so its simple to just d/l and compile if
you want to try it yourself. :-)
- Garrett
More information about the Developer
mailing list