]> git.lizzy.rs Git - plan9front.git/blob - sys/src/ape/lib/bsd/strncasecmp.c
Import sources from 2011-03-30 iso image
[plan9front.git] / sys / src / ape / lib / bsd / strncasecmp.c
1 #include <string.h>
2
3 typedef unsigned char uchar;
4
5 int
6 strncasecmp(char *s1, char *s2, int n)
7 {
8         int c1, c2;
9
10         while(*s1 && n-- > 0){
11                 c1 = *(uchar*)s1++;
12                 c2 = *(uchar*)s2++;
13
14                 if(c1 == c2)
15                         continue;
16
17                 if(c1 >= 'A' && c1 <= 'Z')
18                         c1 -= 'A' - 'a';
19
20                 if(c2 >= 'A' && c2 <= 'Z')
21                         c2 -= 'A' - 'a';
22
23                 if(c1 != c2)
24                         return c1 - c2;
25         }
26         if(n <= 0)
27                 return 0;
28         return -*s2;
29 }