Date: Wed, 07 Feb 2001 21:11:43 -0500 (EST) From: Mike Heffner <mheffner@vt.edu> To: "Jacques A. Vidrine" <n@nectar.com> Cc: FreeBSD-audit <FreeBSD-audit@FreeBSD.ORG>, Warner Losh <imp@harmony.village.org> Subject: Re: lam(1) patch Message-ID: <XFMail.20010207211143.mheffner@vt.edu> In-Reply-To: <20010207180825.A85807@spawn.nectar.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <mheffner@vt.edu> Blacksburg, VA <mikeh@FreeBSD.org> http://filebox.vt.edu/users/mheffner 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?XFMail.20010207211143.mheffner>