On 06/26/2012 04:06 PM, Andre Renaud wrote: > Hi, > I've started to do an implementation of 'od' - it is most of the way > there, but I'm not particularly happy with the method I've used for > determining which 'printf' format string and which data alignment to > use. At the moment I'm essentially reparsing the -t XX parameters each > time you want to print a new character, which has pretty hideous > performance (and currently doesn't support the -to2o4 syntax).
The performance doesn't have to be that hideous if it fits in l1 cache. > 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... > 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... Rob -- GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code. Either it's "mere aggregation", or a license violation. Pick one. _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
