From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 6 12:09:06 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DD2E1065675 for ; Sat, 6 Dec 2008 12:09:06 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id D02A88FC1D for ; Sat, 6 Dec 2008 12:09:05 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl153-194.kln.forthnet.gr [62.1.244.194]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id mB6C8pwv009835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 6 Dec 2008 14:08:57 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id mB6C8pNN034796; Sat, 6 Dec 2008 14:08:51 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id mB6C8o8c034795; Sat, 6 Dec 2008 14:08:50 +0200 (EET) (envelope-from keramida@freebsd.org) From: Giorgos Keramidas To: "Sheldon Givens" In-Reply-To: (Sheldon Givens's message of "Fri, 5 Dec 2008 18:46:00 -0800") Date: Sat, 06 Dec 2008 13:57:53 +0200 Message-ID: <87prk5ms72.fsf@kobe.laptop> References: <871vwmtawz.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: mB6C8pwv009835 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.455, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL -0.06, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: freebsd-hackers@freebsd.org Subject: Re: Small change to wc X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2008 12:09:06 -0000 On Fri, 5 Dec 2008 18:46:00 -0800, "Sheldon Givens" wrote: > On Fri, Dec 5, 2008 at 4:17 PM, Giorgos Keramidas 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 :-)