Re: 2.1.120pre2: Bug in strnicmp() noted in 2.1.119pre1 is still there!

Linus Torvalds (torvalds@transmeta.com)
Mon, 31 Aug 1998 10:29:28 -0700 (PDT)


On Mon, 31 Aug 1998, Linus Torvalds wrote:
>
> The isofs strnicmp() implementation is so broken anyway that this doesn't
> really matter. Look at signedness issues etc, and you'll see that this is
> just a small thing..
>
> I'll rewrite it completely,

Ok, shoot holes in this one instead.

Linus

-----
static int strnicmp(const char *s1, const char *s2, int len)
{
/* Yes, Virginia, it had better be unsigned */
unsigned char c1, c2;

while (len) {
c1 = *s1; c2 = *s2;
s1++; s2++;
if (!c1)
goto end_of_string1;
if (!c2)
goto end_of_string2;
if (c1 != c2) {
c1 = tolower(c1);
c2 = tolower(c2);
if (c1 != c2)
goto different;
}
len--;
}
return 0;

end_of_string1:
return c2 ? -1 : 0;

end_of_string2:
return 1;

different:
return c1 < c2 ? -1 : 1;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html