From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- lib/libc/strings/strncasecmp.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/libc/strings/strncasecmp.c (limited to 'lib/libc/strings/strncasecmp.c') diff --git a/lib/libc/strings/strncasecmp.c b/lib/libc/strings/strncasecmp.c new file mode 100644 index 00000000..679cf245 --- /dev/null +++ b/lib/libc/strings/strncasecmp.c @@ -0,0 +1,32 @@ +#include +#include +#include + +int strncasecmp(const char *s1, const char *s2, size_t n) +{ + unsigned char c1, c2; + + if (n == 0) + return 0; + + while (n-- > 0 && *s1 && *s2) { + c1 = (unsigned char)tolower((unsigned char)*s1); + c2 = (unsigned char)tolower((unsigned char)*s2); + if (c1 != c2) + return c1 - c2; + s1++; + s2++; + } + + if (n == (size_t)-1) + return 0; + + return (unsigned char)tolower((unsigned char)*s1) - + (unsigned char)tolower((unsigned char)*s2); +} + +weak int strncasecmp_l(const char *s1, const char *s2, size_t n, + locale_t unused locale) +{ + return strncasecmp(s1, s2, n); +} -- cgit v1.2.3