_tolower and _toupper macros

Arnold Robbins arnold at audiofax.com
Sat Jul 28 00:01:59 AEST 1990


In article <1990Jul26.100721.14628 at warwick.ac.uk> cuuee at warwick.ac.uk (Sean Legassick) writes:
>	Does anyone know what ANSI has to say about these conversion
>routines? It would seem that using them on any other character except
>for capitals with _tolower and lowercase with _toupper is pretty
>non-portable code writing. Comments?

The standard says that tolower() and toupper() return the corresponding
lower- or upper-case letter if their argument is an upper- or lower-case
letter respectively.  Otherwise the argument is returned unchanged.
_toupper() and _tolower() are not specified in the standard.

To set things straight history wise:

	V7 -	tolower() and toupper() blindly converted the case on
		their arguments.  Handing a nonuppercase letter to tolower()
		or a nonlowercase letter to toupper() could produce suprises.

	BSD -	Inherited the above behavior from V7.  (Expect this to be
		fixed [probably] in 4.4 BSD, which is aiming at ANSI and
		POSIX compliance.)

	System III - Made toupper() and tolower() into functions that behave
		as the ANSI spec says; return the translated letter or the
		original argument if there is no corresponding upper/lower
		case letter.  The old behavior was still available in
		macros named _tolower() and _toupper() which blindly
		converted.  Note that tolower() and toupper() became real
		functions, with the attendant performance loss.

	System V Release 1-? - inherited the above behavior from System III.

	System V Release 3.2 - on my 386 V.3.2 box, _tolower() and _toupper()
		are macros that behave like toupper() and tolower(). It
		looks like someone finally got smart.  I don't know when
		this first appeared in System V.

I guess tolower() and toupper() remain real functions in V.3.2 in case
anyone takes their address; I can't see any other reason to not have them
be macros identical to their _to* counterparts.
-- 
Arnold Robbins				AudioFAX, Inc. | Laundry increases
2000 Powers Ferry Road, #220 / Marietta, GA. 30067     | exponentially in the
INTERNET: arnold at audiofax.com	Phone: +1 404 933 7600 | number of children.
UUCP:	  emory!audfax!arnold	Fax:   +1 404 933 7606 |   -- Miriam Robbins



More information about the Comp.lang.c mailing list