Re: Usage of isspace and friends
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Oct 13, 2005, 15:56 UTC
- Message-ID
- <Pine.LNX.4.64.0510130847190.15297@g5.osdl.org>
- In-Reply-To
- <434E8117.3090102@zytor.com>
On Thu, 13 Oct 2005, H. Peter Anvin wrote:
> > Because of the special case of 255 which looks indistinguishable from EOF, > therefore making it required?
Yeah, and I agree, that was a mistake. It could have been fixed by making EOF be MIN_INT (or any other value outside the range of either "unsigned char" or "signed char" - preferably still negative), but there are probably programs that depend on it being -1.
The stupid thing I just posted doesn't care. It happens to return 0 for EOF for all cases, but that's a side effect of (a) not doing locales (so 255 is never printable or alpha) and (b) not even implementing iscntrl().
In general, the rule for ctype and EOF _should_ have been that it's part of an acceptable input range, but that the return value is undefined ;)
(Which would allow you to test EOF later, and not worry about any faults).
Linus