Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcsstat.UUCP Path: utzoo!utcsstat!geoff From: geoff@utcsstat.UUCP (Geoffrey Collyer) Newsgroups: net.lang.c Subject: Re: toupper -- a lesson for programmers Message-ID: <1426@utcsstat.UUCP> Date: Sat, 12-Nov-83 23:36:09 EST Article-I.D.: utcsstat.1426 Posted: Sat Nov 12 23:36:09 1983 Date-Received: Sun, 13-Nov-83 21:17:19 EST References: <277@decvax.UUCP> Organization: U. of Toronto, Canada Lines: 26 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 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 functions are in range. Geoff Collyer, U. of Toronto