summaryrefslogtreecommitdiff
path: root/lib/stdlib/strcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/strcmp.c')
-rw-r--r--lib/stdlib/strcmp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/stdlib/strcmp.c b/lib/stdlib/strcmp.c
index 1d26f2bd..bb86e0f2 100644
--- a/lib/stdlib/strcmp.c
+++ b/lib/stdlib/strcmp.c
@@ -36,6 +36,7 @@
*/
#include <sys/cdefs.h>
+#include <sys/ctype.h>
#include <string.h>
/*
@@ -49,3 +50,17 @@ strcmp(const char *s1, const char *s2)
return 0;
return *(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1);
}
+
+int
+strcasecmp(const char *s1, const char *s2)
+{
+ const unsigned char *us1 = (const unsigned char *)s1;
+ const unsigned char *us2 = (const unsigned char *)s2;
+
+ while (tolower(*us1) == tolower(*us2)) {
+ if (*us1++ == '\0')
+ return 0;
+ us2++;
+ }
+ return tolower(*us1) - tolower(*us2);
+}