summaryrefslogtreecommitdiff
path: root/src/strings/strcasecmp.c
blob: a5955f4e4bbfceb477c899433a83fcfa756119f7 (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
26
#include <strings.h>
#include <ctype.h>

int strcasecmp(const char *s1, const char *s2)
{
	while (*s1 && *s2) {
		char c1 = tolower(*s1);
		char c2 = tolower(*s2);
		if (c1 != c2) {
			return c1 - c2;
		}
	}

	if (*s1) {
		return -1;
	} else if (*s2) {
		return 1;
	}

	return 0;
}

/*
XOPEN(400)
POSIX(200809)
*/