Question about toupper and tolower

jr at fortune.UUCP jr at fortune.UUCP
Thu Nov 10 08:35:42 AEST 1983


I have a question about the macros "tolower" and "toupper" (which are usually
defined in /usr/include/ctype.h, although they usually don't appear in the
manual page (ctype(3)).  The UNIX versions of these (including Version 7,
System III, and System V) will screw-up the character if it's already the
correct case.  For instance, in the expression "toupper('A')", 'A' (0x41)
becomes '!' (0x21).  Now, I realize that it is possible to use:
	if (islower(c))
		c = toupper(c);
However, I'm not thrilled by doing that.  There are other versions of C which
handle this more gracefully (I'm thinking of Aztec C II and BDS C, both for the
CP/M operating system).  They return the character unchanged if it is already
in the correct case.

My question is this: other than portability reasons, is there any reason to
keep things this way?  Wouldn't it make more sense to have toupper and tolower
leave the characters alone if they're already right? Does anyone know of any
software that would break if the macros were changed?

				Thanks...
-- 
				John Rogers
				CompuServe: 70140,213
				Usenet: ...decvax!decwrl!amd70!fortune!jr



More information about the Comp.lang.c mailing list