Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1exp 11/4/83; site ihnp4.UUCP Path: utzoo!linus!decvax!harpo!floyd!clyde!ihnp4!tsclark From: tsclark@ihnp4.UUCP (Tom Clark) Newsgroups: net.lang.c Subject: Re: Question about toupper and tolower Message-ID: <486@ihnp4.UUCP> Date: Wed, 9-Nov-83 23:54:05 EST Article-I.D.: ihnp4.486 Posted: Wed Nov 9 23:54:05 1983 Date-Received: Fri, 11-Nov-83 09:05:54 EST References: <1764@fortune.UUCP> Organization: AT&T Bell Labs, Naperville, Il Lines: 15 John Rogers (fortune!jr) asked about tolower and toupper, and stated that in System V (and version 7 and system III) tolower/toupper were defined as macros in /usr/include/ctype.h. Well, actually the macros defined in ctype.h are called _tolower(c) and _toupper(c) and do indeed perform no checking. The only purpose of the ctype header file is to define character types (e.g. for running C on a non-ASCII machine). There are routines tolower(c) and toupper(c) in libc which will do what you want (check case before conversion). The source is in /usr/src/lib/libc/gen in tolower.c and toupper.c. I can't speak for version 7 or system III, but suspect they do much the same thing. You should also note that the macros cannot be recoded to say: #define tolower(c) (isupper(c) : _tolower(c) : c) because this will result in c being evaluated more than once, which will *definitely* break a lot of programs! -- Tom Clark, BTL IH, ihnp4!tsclark, (312) 979-2620