Messages in this thread | | | Subject | Re: 2.1.120pre2: Bug in strnicmp() noted in 2.1.119pre1 is still there! | Date | 1 Sep 1998 00:20:49 GMT | From | (Ton Hospel) |
| |
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
| |