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]
Other format: [Raw text]

Re: [PATCH] Fix libdecnumber bootstrap on Tru64 (part 2)


On 20 Dec 2005, Gabriel Dos Reis wrote:
> | Many thanks.  Here's the cast to int solution that I committed:
>
> I think this solution is wrong.

Doh!

There's also a third possibility, an alternative implementation that
avoids the use of <ctype.h> functions completely, by observing that
this function has two calls, both of which test against a constant
reference string, one being a prefix of the other.

static Flag
decStrEqInf (const char *str)
{
  if ((str[0] != 'I' && str[0] != 'i')
      || (str[1] != 'N' && str[1] != 'n')
      || (str[2] != 'F' && str[2] != 'f'))
    return 0;

  if (str[3] == '\0')
    return 1;

  return (str[3] == 'I' || str[3] == 'i')
         && (str[4] == 'N' || str[4] == 'n')
         && (str[5] == 'I' || str[5] == 'i')
         && (str[6] == 'T' || str[6] == 't')
         && (str[7] == 'Y' || str[7] == 'y')
         && str[8] == '\0';
}


Which has the benefit of being both faster and more portable?

Roger
--


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