Quoting Thorsten Haude <[EMAIL PROTECTED]>: > Hi, > > * Tony Balinski wrote (2007-09-07 18:04): > >Another thing is the expression isalnum((int)*name). If char is > >signed (I think it is/was(?) with Sun's compiler), this can cause > >problems, especially with the old-fashioned macro implementation of > >ctype.h. Better to use isalnum((unsigned char)*name) instead to be > >explicit. > > Interesting, my book clearly calls for an int for ISO C. Why would the > cast be a problem in this case?
isalnum etc is defined for all "characters" and EOF IIRC. Characters are all supposed to be positive values (I think this is stated somewhere in the standard; it is definitely the case for wchar_t), and EOF is usually represented as -1. Now if char has range -128 to 127, half of that range is unusable for characters! I also remember the headers in question defining isalnum et al as lookups into a ctype table, offset by 1 to allow for entries for EOF (as -1). Very efficient, but broken if char is signed! Tony -- NEdit Develop mailing list - [email protected] http://www.nedit.org/mailman/listinfo/develop
