Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Feb 2001 21:43:47 -0600
From:      "Jacques A. Vidrine" <n@nectar.com>
To:        Mike Heffner <mheffner@vt.edu>
Cc:        Nathan Ahlstrom <nrahlstr@winternet.com>, FreeBSD-audit <FreeBSD-audit@FreeBSD.ORG>
Subject:   Re: mail(1) cleanup patch
Message-ID:  <20010215214346.A28110@spawn.nectar.com>
In-Reply-To: <XFMail.20010215205930.mheffner@vt.edu>; from mheffner@vt.edu on Thu, Feb 15, 2001 at 08:59:30PM -0500
References:  <20010215185629.A28636@winternet.com> <XFMail.20010215205930.mheffner@vt.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010215214346.A28110>