summaryrefslogtreecommitdiff
path: root/lib/libc/strings/strcasecmp.c
blob: e96f059a4919bbce6515272a504be3118b30a1a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <libc.h>
#include <ctype.h>

int strcasecmp(const char *s1, const char *s2)
{
	unsigned char c1, c2;

	while (*s1 && *s2) {
		c1 = (unsigned char)tolower((unsigned char)*s1);
		c2 = (unsigned char)tolower((unsigned char)*s2);
		if (c1 != c2)
			return c1 - c2;
		s1++;
		s2++;
	}

	return (unsigned char)tolower((unsigned char)*s1) -
	       (unsigned char)tolower((unsigned char)*s2);
}

__weak int strcasecmp_l(const char *s1, const char *s2,
			locale_t __unused locale)
{
	return strcasecmp(s1, s2);
}