On 04/04/14 01:59, Samuel Holland wrote: > This version of fold fixes major bugs (infinite loop, overflow) and adds an > option for un/refolding text.
Poking at cleanup, and I was wondering if you could suggest some good tests for this? I built fold with scripts/single.sh and then did: diff -u <(fold -w 60 README) <(./fold -w 60 README) And it just had an extra newline on the end, which is probably within tolerances? (I'm rereading the spec, it's been a while...) But that was the current version, and all teh changes I've made to it so far were whitespace and curly brackets and shuffling variable declarations around and such. I admit I tend to turn switch/case statements into if/else staircases because the end result almost always winds up smaller code both in source and in binary. (Needing both the label and the break lines is a strike against switch/case, and nobody can ever quite agree on how to indent case statements either. It can come out ahead if you make a lot of use of fallthrough, either having multiple labels for the same funcitonality or just doing the clever fallthrough thing ala tab and space in your code. But it usually doesn't.) (I'm not sure if this is an unreasonable bias on my part, but it _does_ shrink the code. It's one of those things I feel slightly guilty about and then do anyway. In theory the switch/case version can do a jump table that winds up faster, but I've never actually caught it making a difference in anything I've benched. If anything, fitting in fewer cache lines and more intelligent branch prediction can make the if/else code win on speed too...) But with a change that intrusive, I really want to test the result well, so... Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
