LWN.net Logo

Linus Torvalds on SCO's latest claims

Linus Torvalds on SCO's latest claims

Posted Dec 23, 2003 2:26 UTC (Tue) by jimm007 (guest, #18055)
Parent article: Linus Torvalds on SCO's latest claims

#define toupper(c) (char)(c & ~32)
#define tolower(c) (char)(c | 32)


(Log in to post comments)

Linus Torvalds on SCO's latest claims

Posted Dec 23, 2003 3:08 UTC (Tue) by tres (guest, #352) [Link]

This fails to take into account the possibility of some SCO programmer doing:

char new_char = toupper( '5' );

It also fails to work on non ASCII codes which Linus' might or might not depending on whether or not lower case letters have a larger numerical representation.

Linus Torvalds on SCO's latest claims

Posted Dec 23, 2003 6:38 UTC (Tue) by proski (subscriber, #104) [Link]

Try this with your definition:

#include <stdio.h>
int main() {
  printf("Should be A, actually %c\n", toupper(1 ? 'a' : 'b'));
}

$ ./test
Should be A, actually a

Linus Torvalds on SCO's latest claims

Posted Dec 23, 2003 9:42 UTC (Tue) by dvrabel (subscriber, #9500) [Link]

You're missing brackets around the argument in the body of the macro. This is why I always use inline functions in preference to macros.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds