blob: f8ec1eba3fdde5c081cbfa042a2b2a96cec843aa [file] [log] [blame]
Linus Torvalds3cbb90a2006-03-25 09:41:40 -08001#include <linux/types.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10002#include <linux/ctype.h>
Linus Torvalds3cbb90a2006-03-25 09:41:40 -08003#include <linux/string.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10004
5int strcasecmp(const char *s1, const char *s2)
6{
7 int c1, c2;
8
9 do {
10 c1 = tolower(*s1++);
11 c2 = tolower(*s2++);
12 } while (c1 == c2 && c1 != 0);
13 return c1 - c2;
14}
15
Linus Torvalds3cbb90a2006-03-25 09:41:40 -080016int strncasecmp(const char *s1, const char *s2, size_t n)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100017{
18 int c1, c2;
19
20 do {
21 c1 = tolower(*s1++);
22 c2 = tolower(*s2++);
23 } while ((--n > 0) && c1 == c2 && c1 != 0);
24 return c1 - c2;
25}