httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: PR 2553 and 2282
Date Tue, 07 Jul 1998 18:01:02 GMT

On Tue, 7 Jul 1998, Roy T. Fielding wrote:

> Shouldn't (unsigned) be (unsigned char), as in

Both work, but (unsigned char)c can introduce an extra (c & 0xff) when c
is actually an int (because the cast to char has to loose the high bits,
and the compiler can't prove that they're already zero in general)...
whereas (unsigned)(c) does nothing for ints (we assume they're already in
0..0xff), and zero extends chars (which is what we want -- rather than
sign extend). 

Dean, performance freak

> #define ap_isalnum(c) (isalnum(((unsigned char)(c)))
> #define ap_isalpha(c) (isalpha(((unsigned char)(c)))
> #define ap_iscntrl(c) (iscntrl(((unsigned char)(c)))
> #define ap_isdigit(c) (isdigit(((unsigned char)(c)))
> #define ap_isgraph(c) (isgraph(((unsigned char)(c)))
> #define ap_islower(c) (islower(((unsigned char)(c)))
> #define ap_isprint(c) (isprint(((unsigned char)(c)))
> #define ap_ispunct(c) (ispunct(((unsigned char)(c)))
> #define ap_isspace(c) (isspace(((unsigned char)(c)))
> #define ap_isupper(c) (isupper(((unsigned char)(c)))
> or is the potential lack of (unsigned char) the problem?
> Color me confused.
> ....Roy [resisting the temptation to comment on casts, almost]

View raw message