This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: Add TOUPPER/TOLOWER to system.h and clean up ctype stuff
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: Patch: Add TOUPPER/TOLOWER to system.h and clean up ctype stuff
- From: Gavin Romig-Koch <gavin at cygnus dot com>
- Date: Tue, 14 Sep 1999 11:01:36 -0400 (EDT)
- Cc: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, bernds at cygnus dot co dot uk, egcs-patches at egcs dot cygnus dot com
- References: <199909131555.LAA11123@caip.rutgers.edu><19990913150059.A24952@cygnus.com>
Richard Henderson writes:
> On Mon, Sep 13, 1999 at 11:55:14AM -0400, Kaveh R. Ghazi wrote:
> > Because if the parameter is an int you can't distinguish EOF.
> > So the cast is only valid if the parameter is a char.
>
> I thought of an ugly way to do this --
>
> #define DOIT(CH) doit(sizeof(CH) == 1 ? (int)(unsigned char)(CH) : (int)(CH))
Less ugly (my opinion):
#define DOIT(CH) doit((CH) == EOF ? (int)CH : (int)(unsigned char)(CH))
along with a comment explaining what's going.
-gavin...