Subject: Re: bin/21645: Localized comments and indent(1)
To: Mishka <mishka@batraq.anything3d.com>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 06/25/2003 09:16:16
On Wed, Jun 18, 2003 at 05:52:52PM +0300, Mishka wrote:
> David Laight <david@l8s.co.uk> wrote:
> > 
> > The (int) cast only gets rid of a warning genberated by some compilers.
> > 
> > The problem is that if 'c' is a signed char, then it is promoted to
> > a signed integer using by preserving the sign.  This does not DTRT
> > for any of the isXXX() functions.
> 
> 
> I'll see now. IYSS, how about (int)((unsigned char)c)?
> So, the ctype convertion inside isXXXX() functions will looks like:
> 
>     #define isXXXX(c)  ((int)((_ctype_ + 1)[(int)((unsigned char)(c))] & (CTYPE_FLAGS)))
> 
> This causes the index [(int)((unsigned char)(c))] will always return
> a positive value, even in signed int.

No, you can't do that either (I think someone else said so in another
thread), the domain of the isxxx() functions includes EOF (-1).
So isupper(-1) is valid and, in this implementation, indexes the first
item of the _ctype_ array.

	David

-- 
David Laight: david@l8s.co.uk