From owner-freebsd-audit Thu Feb 15 19:43:51 2001 Delivered-To: freebsd-audit@freebsd.org Received: from gw.nectar.com (gw.nectar.com [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id 20D6137B503 for ; Thu, 15 Feb 2001 19:43:48 -0800 (PST) Received: by gw.nectar.com (Postfix, from userid 1001) id 2B6FE19380; Thu, 15 Feb 2001 21:43:47 -0600 (CST) Date: Thu, 15 Feb 2001 21:43:47 -0600 From: "Jacques A. Vidrine" To: Mike Heffner Cc: Nathan Ahlstrom , FreeBSD-audit Subject: Re: mail(1) cleanup patch Message-ID: <20010215214346.A28110@spawn.nectar.com> Mail-Followup-To: "Jacques A. Vidrine" , Mike Heffner , Nathan Ahlstrom , FreeBSD-audit References: <20010215185629.A28636@winternet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from mheffner@vt.edu on Thu, Feb 15, 2001 at 08:59:30PM -0500 X-Url: http://www.nectar.com/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Feb 15, 2001 at 08:59:30PM -0500, Mike Heffner wrote: > Well, first because that's what the other BSDs had done =). Second, for the > upcase(), it allows us to do: > > list.c:677: if (upcase(*cp++) != upcase(*cp2++)) { > list.c:728: if (upcase(*cp++) != upcase(*cp2++)) { > > without worrying about whether tolower() is implemented as a macro (but this > isn't a problem since ours is implemented as an inline). Well, actually, it _is_ a macro -- which expands to an inline. But at any rate, C99 specifies that any Standard C library function implemented as a macro evaluates its argument only once [1], and GNU C is conformant in this respect. Using tolower is the right thing to do here. [snip] > Taking another look at the istrncpy(), the while loop could probably > be rewritten as: > > while (--dsize != 0 && *src) { > *dest++ = tolower(*src); > src++; > } I'd recommend just using the library (i.e. strlcpy/tolower) -- that is why it exists. Cheers, -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org [1] ISO/IEC 9899:1999 section 7.1.4 clause 1. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message