summaryrefslogtreecommitdiff
path: root/lib/libc/strings/strcasecmp.c
blob: 90ccc59b7be1603f6d90b3d2d49e6aa704e00ed3 (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
#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);
}