[Toybox] toybox - added cmp
Rob Landley
rob at landley.net
Tue Feb 7 18:09:45 PST 2012
On 02/06/2012 07:44 PM, Tim Elliott wrote:
> On Mon, Feb 6, 2012 at 2:11 AM, Tim Elliott <tle at holymonkey.com> wrote:
>> I implemented cmp. I want to get better at C and the best way to learn
>> is to get feedback on my code. I welcome even nitpicky feedback and I
>> am eager to learn.
>
> I'm attaching an implementation of head. The patch also removes a
> comment in toys/nice.c.
>
> Notes:
> * The spec states "The application shall ensure that the number
> option-argument is a positive decimal integer." and this doesn't do
> that. GNU coreutils has some kind of special behavior when n < 0
The optargs stuff recently grew "i#<0" where the <0 reads "at least 0",
I.E. error out if this argument is less than 0.
Commit 415, I think:
http://landley.net/hg/toybox/rev/415
> * I noticed get_line() in lib/lib.c. Should I be using that instead?
Probably. get_line() and get_rawline() read input a line at a time.
I note that they do so with one syscall per character, but since I dunno
how to push input back into a filehandle...
(This was back when I was still resisting FILE * as unnecessary
overhead. I got over it.)
> Cheers,
> Tim
Rob
1328666985.0
More information about the Toybox
mailing list