toupper() side effects (was Re: evaluation order)

Henry Spencer henry at utzoo.uucp
Sun Sep 17 08:18:21 AEST 1989


In article <2511ADAD.6056 at marob.masa.com> daveh at marob.masa.com (Dave Hammond) writes:
>Note that some implementations of toupper() (SunOS comes to mind)
>will return the wrong result if passed a non-lowercase argument.
>You'd probably want to expand this line and run an islower()
>test on the argument to toupper...

It's worse than that.  Some implementations of islower() (e.g. the original
V7 one, still found in many Unixes) cannot safely be applied to any char
value -- you have to precede them with an isascii() test.  This is an awful
nuisance if you're trying to write maximally-portable code, because ANSI C
requires islower() to work on any char and hence does not have isascii()...
-- 
V7 /bin/mail source: 554 lines.|     Henry Spencer at U of Toronto Zoology
1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list