Patch: Add TOUPPER/TOLOWER to system.h and clean up ctype stuff

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Thu Sep 30 23:58:00 GMT 1999


 > From: Horst von Brand <vonbrand@inf.utfsm.cl>
 >  
 > > 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...
 > > 
 > >       I think the above will do the wrong thing if CH is a char and
 > > is equal to 255 (-1 when signed, == EOF.)  That is a printable
 > > character and depending on the locale, may or may not be alphabetic.
 > > (Right?)
 >  
 > A signed char, cast to unsigned char and then to int can't give you
 > -1.  Unless you have _real_ weird characters, i.e. char == int.


	This is the case on c4x, if xm-c4x.h is to be believed.

Besides, the bad promotion will occur in the == comparison, where
there is no cast anyway.



 > > Since sizeof char might not be one (e.g. c4x), maybe the following
 >   is
 > > best:
 >  
 > According to ANSI C, sizeof(char) == 1, by definition. Or am I missing
 > something here?
 > Dr. Horst H. von Brand


	No, you are correct.  My bad.

--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions



More information about the Gcc-patches mailing list