From owner-freebsd-audit Wed Feb 7 18:12: 6 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 44FB037B503 for ; Wed, 7 Feb 2001 18:11:46 -0800 (PST) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f182Biu431207; Wed, 7 Feb 2001 21:11:44 -0500 (EST) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0G8F00NWT23J2Q@gkar.cc.vt.edu>; Wed, 7 Feb 2001 21:11:43 -0500 (EST) Date: Wed, 07 Feb 2001 21:11:43 -0500 (EST) From: Mike Heffner Subject: Re: lam(1) patch In-reply-to: <20010207180825.A85807@spawn.nectar.com> To: "Jacques A. Vidrine" Cc: FreeBSD-audit Cc: FreeBSD-audit , Warner Losh Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 8bit X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Even though our implementation is inlined, I think I'll take Warner's suggestion so that it's clear. As I found out in the following, it wasn't what I would have expected: #define xtolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z'))) int main(int ac, char **av) { char *c, *p = "HELLO"; switch(xtolower(*(c = ++p))) { default: printf("Char: '%c'\n", *c); } printf("String: '%s'\n", p); } [spock@enterprise]:117 $ ./test Char: 'L' String: 'LO' On 08-Feb-2001 Jacques A. Vidrine wrote: | On Wed, Feb 07, 2001 at 04:18:45PM -0700, Warner Losh wrote: |> The tolower function will only evaluate the arguments once, but the |> tolower macro might evaluate them multiple times. Maybe I'm recalling |> things too far back. | | C99 7.1.4.1 says, ``Any invocation of a library function that is | implemented as a macro shall expand to code that evaluates each of its | arguments exactly once, fully protected by parentheses where necessary, | so it is generally safe to use arbitrary expressions as arguments.'' | | Our tolower is implemented as an inline. | | I'd like to know when this was first spelled out -- I don't have a | C89 reference handy. | | Cheers, | -- | Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org | | | To Unsubscribe: send mail to majordomo@FreeBSD.org | with "unsubscribe freebsd-audit" in the body of the message -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message