minow@decvax.UUCP (Martin Minow) (11/12/83)
The behavior of toupper() and tolower() varies across the many implementations of the C library. The following strategies are known to work: 1. if (isupper(c)) c = tolower(c); 2. #ifdef tolower #undef tolower #define tolower(c) (whatever you feel is right) Moral: if you do something wrong, half the people will adapt to it and the other half will "do it right." Martin Minow decvax!minow
geoff@utcsstat.UUCP (Geoffrey Collyer) (11/13/83)
Martin Minow recently claimed The behavior of toupper() and tolower() varies across the many implementations of the C library. The following strategies are known to work: 1. if (isupper(c)) c = tolower(c); 2. #ifdef tolower #undef tolower #define tolower(c) (whatever you feel is right) *Neither* of these is correct. The first strategy should read #include <ctype.h> if (isascii(c) && isupper(c)) c = tolower(c); The second needs an #endif after #undef tolower. I don't mean to pick nits, but far too much code exists right now that doesn't use isascii to check that arguments to the other <ctype.h> functions are in range. Geoff Collyer, U. of Toronto