Patch to use more safe-ctype macros

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Mon Oct 22 12:52:00 GMT 2001


 > From: DJ Delorie <dj@redhat.com>
 > 
 > > >  hex_digit_value (c)
 > > >       unsigned int c;
 > > >  {
 > > > +  if (ISDIGIT (c))
 > > > +    return c - '0';
 > > >    if (c >= 'a' && c <= 'f')
 > > >      return c - 'a' + 10;
 > > >    if (c >= 'A' && c <= 'F')
 > > >      return c - 'A' + 10;
 > > > -  if (c >= '0' && c <= '9')
 > > > -    return c - '0';
 > > >    abort ();
 > > 
 > > I would prefer if you left this one alone; I think it's more readable
 > > to have all three conditions take the same general form.
 > 
 > Libiberty exports a table for that purpose.  This is what's in
 > libiberty.h, although nobody in gcc uses it (or calls hex_init) yet.
 > 
 > extern char _hex_value[_hex_array_size];
 > extern void hex_init PARAMS ((void));

Can't we set _hex_value as a const array at compile-time like the ones
in safe-ctype.c?  Then one doesn't have to remember to call hex_init().

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



More information about the Gcc-patches mailing list