[PATCH] Fix libdecnumber bootstrap on Tru64 (part 2)
Richard Earnshaw
rearnsha@arm.com
Tue Dec 20 18:40:00 GMT 2005
On Tue, 2005-12-20 at 18:01, Roger Sayle wrote:
> 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?
Or just use strcasecmp which is in libiberty :-)
R.
More information about the Gcc-patches
mailing list