Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 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
}