Path: utzoo!attcan!uunet!mcsun!ukc!warwick!cuuee From: cuuee@warwick.ac.uk (Sean Legassick) Newsgroups: comp.lang.c Subject: Re: _tolower and _toupper macros Message-ID: <1990Jul26.100721.14628@warwick.ac.uk> Date: 26 Jul 90 10:07:21 GMT References: <2891@dftsrv.gsfc.nasa.gov> Sender: news@warwick.ac.uk (Network news) Organization: Computing Services, University of Warwick, UK Lines: 25 In article <2891@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@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)