chiark / gitweb /
[PATCH] sync up with the 0.84 version of klibc
[elogind.git] / klibc / klibc / strncasecmp.c
1 /*
2  * strncasecmp.c
3  */
4
5 #include <string.h>
6 #include <ctype.h>
7
8 int strncasecmp(const char *s1, const char *s2, size_t n)
9 {
10         char *n1, *n2;
11         int i, retval;
12
13         n1 = strndup(s1, n);
14         n2 = strndup(s2, n);
15
16         for (i = 0; i < strlen(n1); i++)
17                 n1[i] = toupper(n1[i]);
18         for (i = 0; i < strlen(n2); i++)
19                 n2[i] = toupper(n2[i]);
20         retval = strcmp(n1, n2);
21         free(n1);
22         free(n2);
23         return retval;
24 }