Date: Sat, 06 Dec 2008 13:57:53 +0200 From: Giorgos Keramidas <keramida@freebsd.org> To: "Sheldon Givens" <sheldon@sigsegv.ca> Cc: freebsd-hackers@freebsd.org Subject: Re: Small change to wc Message-ID: <87prk5ms72.fsf@kobe.laptop> In-Reply-To: <f4ecc0930812051846n27308fbdue6ea50a909d8d6ab@mail.gmail.com> (Sheldon Givens's message of "Fri, 5 Dec 2008 18:46:00 -0800") References: <f4ecc0930812051414n17867e1fi80d6ed458e879bde@mail.gmail.com> <871vwmtawz.fsf@kobe.laptop> <f4ecc0930812051846n27308fbdue6ea50a909d8d6ab@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 5 Dec 2008 18:46:00 -0800, "Sheldon Givens" <sheldon@sigsegv.ca> wrote: > On Fri, Dec 5, 2008 at 4:17 PM, Giorgos Keramidas <keramida@ceid.upatras.gr>wrote: >> Adding the option to increase finger-compatibility and make shell >> scripts a bit easier to port over sounds fine by me :) >> >> > My apologies if this is in the wrong format. I don't often post here. >> > ---snip--- >> > [patch] >> > ---unsnip--- >> >> Can you post a `diff -u' or `diff -c' version of the patch? I like the >> idea of the new option but it would be easier to read in -u/-c format. > > New diff -u: Excellent, thanks! Other than a few minor style-bugs, which can be fixed before committing it (see inline comments for details), the patch looks great to me :-) > --- /usr/src/usr.bin/wc/wc.c 2004-12-27 14:27:56.000000000 -0800 > +++ wc/wc.c 2008-12-05 14:33:21.000000000 -0800 > @@ -167,9 +172,13 @@ > return (1); > } > charct += len; > - for (p = buf; len--; ++p) > - if (*p == '\n') > + for (p = buf; len--; ++p) > + if (*p == '\n') { > + if (tmpll > llcnt) > + llcnt = tmpll; > + tmpll = 0; > ++linect; > + } else {tmpll++;} It's probably more 'stylish' to write the else part as: if (*p == '\n') { if (tmpll > llcnt) llcnt = tmpll; tmpll = 0; ++linect; } else tmpll++; > @@ -194,7 +207,7 @@ > (void)printf(" %7lld", (long > long)sb.st_size); > tcharct += sb.st_size; > (void)close(fd); > - return (0); > + return (0); This change only removes indendation from a return statement. We should probably keep it out of the final commit. Thanks for writing & posting the patch :-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87prk5ms72.fsf>