2001-03-06 11:17:54 +03:00
|
|
|
/* public domain rewrite of strncasecmp(3) */
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
#include <ctype.h>
|
2005-10-22 05:28:00 +04:00
|
|
|
#include <stddef.h>
|
1999-08-13 09:45:20 +04:00
|
|
|
|
|
|
|
int
|
2005-10-22 05:28:00 +04:00
|
|
|
strncasecmp(const char *p1, const char *p2, size_t len)
|
1999-08-13 09:45:20 +04:00
|
|
|
{
|
2001-03-06 11:17:54 +03:00
|
|
|
while (len != 0) {
|
1999-08-13 09:45:20 +04:00
|
|
|
if (toupper(*p1) != toupper(*p2)) {
|
|
|
|
return toupper(*p1) - toupper(*p2);
|
|
|
|
}
|
|
|
|
if (*p1 == '\0') {
|
|
|
|
return 0;
|
|
|
|
}
|
2001-03-06 11:17:54 +03:00
|
|
|
len--; p1++; p2++;
|
1999-08-13 09:45:20 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|