_tolower and _toupper macros

Sean Legassick cuuee at warwick.ac.uk
Thu Jul 26 20:07:21 AEST 1990


In article <2891 at dftsrv.gsfc.nasa.gov> John R. Vanderpool writes:
>its  amazing that _toupper and _tolower "misbehave" on the SUN's
>it seems like they do the masking without doing the checking
>
>from VAXC v3.0 ctype.h
>
>#define _toupper(c)	((c) >= 'a' && (c) <= 'z' ? (c) & 0x5F:(c))
>#define _tolower(c)	((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20:(c))
>

	I'm not sure what the ANSI position on these macros is (are
they mentioned at all?) but my Turbo C v1.5 (claiming ANSI compliance :-) )
gives this definition of _toupper : "is a macro that does the same conversion
as toupper except that it should be used only when [the arg] is known
to be lowercase" and similarly for _tolower. This would seem to imply that
in fact it is VAXC v3.0 which has the mistake in ctype.h.
	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?

---------------------------------------------------------------------------
Sean Legassick,       cuuee at uk.ac.warwick.cu	"Man, I'm so hip I find it
  Computing Services	  (the walking 	          difficult to see over
    University of Warwick   C obfuscator!)	    my pelvis" (D Adams)



More information about the Comp.lang.c mailing list