Re: [PATCH] eruby on tiger
Brian Candler <[email protected]> Tue, 19 Jul 2005 20:39:35 +0100
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 19, 2005 at 07:12:14PM +0200, Jb Evain wrote:
> Bonjour !
>
> > if (isspace ( *(unsigned char *)s ) ) { ... }
>
> Yeah, or
>
> if (isspace ((unsigned char) *s)) ...
>
> or ... :)
I'm personally less happy about casting an int to an unsigned char and then
implicitly back to an int again, as I don't trust all compilers to get it
right. If you want to do it that way, then I'd say it's safer to do
if (isspace (*s & 0xff)) ...
But if you cast the pointer to an unsigned char *, then it's not an issue.
> Attached is a patch that respects the isspace desire to handle
> unsigned char
isspace takes an _int_. If isspace were declared to take an unsigned char,
then I think (in ANSI C at least) the problem wouldn't happen. But it's
declared to take an int, because historically that's what it always did.
Blame K&R for allowing compilers to choose whether chars were signed or
unsigned :-(
Regards,
Brian.