[Toybox] RFC: od toy

Andre Renaud andre at bluewatersys.com
Tue Jun 26 19:25:06 PDT 2012


Hi Rob,
> The performance doesn't have to be that hideous if it fits in l1 cache.

True, but the idea of doing some form of string manipulation for every
character of input is pretty horrid.

>> I'm debating about pre-parsing these, and then a list of function
>> pointers. This would also require me to have ~20 tiny stub functions,
>> which basically just do a printf with a different format string & data
>> type, and return the length of data that they've consumed (or possibly
>> iterate over an entire line, I haven't decided).
>
> You can take advantage of the data all being the same sizes (char is
> promoted to int, long and pointer are the same size), and set up a more
> generic call to printf.  Lemme see what I can do...

There might be some benefit to integer promotion, but as you have to
specify the width for printf anyway, you essentially have to know the
type at that point. Having said that, there probably is a more cunning
way of doing this.

>> Does anyone have any comments about an alternative method to do this?
>
> Well, "toybox od -t a filename" doesn't work. And the number in the
> front has one more digit of zero padding than the ubuntu one. I'll have
> to read the spec to see what's expected...

The parsing of the -t parameter is currently very crude - so you have
to specify both the type and the width. I didn't go any further
because I wasn't happy with the other bits.

Regards,
Andre

-- 
Bluewater Systems - An Aiotec Company

Andre Renaud
andre at bluewatersys.com          5 Amuri Park, 404 Barbadoes St
www.bluewatersys.com            PO Box 13 889, Christchurch 8013
www.aiotec.co.nz                New Zealand
Phone: +64 3 3779127            Freecall: Australia 1800 148 751
Fax:   +64 3 3779135            USA 1800 261 2934

 1340763906.0


More information about the Toybox mailing list