Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Casting ctype lookups



On Mon, 12 Nov 2012 13:47:59 -0500
"D'Arcy J.M. Cain" <darcy%NetBSD.org@localhost> wrote:
> Should the inline macro cast the args for these table lookups?  I
> would like to modify sys/ctype_inline.h to change lookup lines like;
> 
> #define toupper(c)  ((int)((_toupper_tab_ + 1)[(c)]))     
> to
> #define toupper(c)  ((int)((_toupper_tab_ + 1)[(int)(c)]))
> 
> or else add a comment why they should not be cast.  Which should it
> be?
> 

Would this be safer?

#define toupper(c)\
  ((int)((_toupper_tab_ + 1)[(int)(unsigned char)(c)]))

-- 
D'Arcy J.M. Cain <darcy%NetBSD.org@localhost>
http://www.NetBSD.org/ IM:darcy%Vex.Net@localhost


Home | Main Index | Thread Index | Old Index