Subject: Re: lib/34632
To: None <,,>
From: David Laight <>
List: netbsd-bugs
Date: 09/28/2006 20:55:02
The following reply was made to PR lib/34632; it has been noted by GNATS.

From: David Laight <>
Subject: Re: lib/34632
Date: Thu, 28 Sep 2006 21:49:06 +0100

 On Wed, Sep 27, 2006 at 10:00:33PM +0200, Alan Barrett wrote:
 > See section ISO 9899:1999 section 7.4:
 >     The header <ctype.h> declares several functions useful for
 >     classifying and mapping characters.  In all cases the argument is an
 >     int, the value of which shall be representable as an unsigned char
 >     or shall equal the value of the macro EOF. If the argument has any
 >     other value, the behavior is undefined.
 It is worth noting here that EOF is allowed to be distinct from all the
 values that are representable as an unsigned char.
 In most systems with 8-bit chars EOF has the value -1.
 Now suppose I have a character string that contains a byte that is the
 all-ones bit pattern, and I test isalpha(*(signed char *)p).
 This is equivalent to isalpha(-1) and hence isapha(EOF) so is false.
 However in some european locales it is an alphabetic character
 (I've forgotten whether it is an i-j ligature or y double dot),
 so should return non-zero.
 There is nothing the implementation can do to get you out of that hole.
 On linux you will probably find that the isxxx() functions return an
 incorrect answer for values between -128 and -2.  Again you need to test
 with a locale where some of the values need to return non-zero.
 David Laight: