lkml.org 
[lkml]   [1998]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: 2.1.120pre2: Bug in strnicmp() noted in 2.1.119pre1 is still there!
Date
From
This one is somewhat faster (one less test in the main loop) and
(I think) cleaner. (It does assume tolower(n)==0 iff n==0)

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;
s1++;
c2 = *s2;
s2++;
if (c1 != c2) {
c1 = tolower(c1);
c2 = tolower(c2);
if (c1 != c2)
return c1 < c2 ? -1 : 1;
}
if (!c1) return 0;
len--;
}
return 0;
}

-
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

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.224 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site