Newsgroups: comp.lang.c
Path: utzoo!censor!geac!sq!msb
From: msb@sq.sq.com (Mark Brader)
Subject: Re: Is there a good example of how toupper() works?
Message-ID: <1990Oct22.170646.22055@sq.sq.com>
Summary: Correction
Organization: SoftQuad Inc., Toronto, Canada
References: <15857@csli.Stanford.EDU<859@agcsun.UUCP> <1990Oct21.060952.191@sq.sq.com>
Date: Mon, 22 Oct 90 17:06:46 GMT
Lines: 23

My previous posting misspelled CHAR_MAX and UCHAR_MAX.  What I meant
to say was, of course, this:

	#ifdef __STDC__			/* ANSI C */
	# if (CHAR_MAX < UCHAR_MAX)	/* chars are signed */
	#   define TOUPP(c) ((c) < 0? (c): toupper((c)))
	# else
	#   define TOUPP(c) toupper((c))
	# endif
	#else
	# define TOUPP(c) ((isascii((c)) && islower((c))? toupper((c)): ((c)))
	#endif

	for (p = duh; *p != '\0'; ++p)
		*p = TOUPP(*p);

-- 
Mark Brader		   "I don't care HOW you format   char c; while ((c =
SoftQuad Inc., Toronto	    getchar()) != EOF) putchar(c);   ... this code is a
utzoo!sq!msb, msb@sq.com    bug waiting to happen from the outset." --Doug Gwyn

This article is in the public domain.
