This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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...



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]