Sender: bill AT taniwha DOT tssc DOT co DOT nz Message-ID: <34D7FD21.36B4842A@taniwha.tssc.co.nz> Date: Wed, 04 Feb 1998 18:31:14 +1300 From: Bill Currie MIME-Version: 1.0 To: Vik Heyndrickx CC: DJ Delorie , eliz AT is DOT elta DOT co DOT il, djgpp-workers AT delorie DOT com Subject: Re: char != unsigned char... sometimes, sigh References: <199802031335 DOT IAA27878 AT delorie DOT com> <34D72299 DOT 3037 AT rug DOT ac DOT be> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk IMHO, this discussion is both too long and pointless. Even though they tend to be implemented as macros, the is* functions DO have the following prototypes (Linux man patge for isupper): int isalnum (int c); int isalpha (int c); int isascii (int c); int isblank (int c); int iscntrl (int c); int isdigit (int c); int isgraph (int c); int islower (int c); int isprint (int c); int ispunct (int c); int isspace (int c); int isupper (int c); int isxdigit (int c); Even if these functions were implemented as functions rather than macros, it wouldn't one bit of difference, passing a char (signed, unsigned or ambiguous) would ALWAYS cause `unexpected' results, the compiler will always do something funny when it extends the bits. Basicly, anybody uses a char between fgetc and is* /DESERVES/ to have their program break, seeing as how fgetc is declared as: int fgetc(FILE *stream); which is guaranteed to return a value between -1 and 255 (assuming EOF==-1). char c; /* or signed char or unsigned char */ c=fgetc(file); if (isupper(c)) {} Will, no matter what, give undefined results for EOF, but int c; c=fgetc(file); if (isupper(c)) {} is guaranteed to work. So really, the djgpp ctype.h header file should just make sure c is in the right range (don't want array bounds checking to fail) and be done with it. Forget about coping with `char's of any flavour, they're irrellevant. If anybody disagrees with this, please tell me why. Bill -- Leave others their otherness.