On Wed, Apr 15, 2009 at 12:40:26AM +0700, Robert Elz wrote: > If EOF is to be a valid parameter to toupper(), then the arg type > cannot be u_char - however much you'd like it to be.
toupper like the rest of ctype.h is defined for EOF and for all values of a unsigned char. unsigned char is by definition either smaller (in which case it gets promoted) or the same size as int (in which case only the signedness is magically changed). In the case of sizeof(char) == sizeof(u_char) == size(int), you cannot distinguish EOF from valid characters. Also note that this code very, very likely does not expect EOF to be magical anyway. Nevertheless, casting to int just to shut up a warning from GCC is almost always the wrong approach here, unless it has been explicitly checked before that isascii() is true and I can't find immediate evidence for that. Joerg