From d7692a7f598839b5331a6611b68fd86acf03f3c0 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 6 Nov 2022 14:45:58 +0100 Subject: [PATCH] libc: Rename fold() to lowercase() in strcasecmp and strncasecmp --- libs/libc/src/strings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/libc/src/strings.cpp b/libs/libc/src/strings.cpp index 7c27a9ba..b8f436e5 100644 --- a/libs/libc/src/strings.cpp +++ b/libs/libc/src/strings.cpp @@ -2,7 +2,7 @@ #include #include -static char fold(char c) +static char lowercase(char c) { if (isalpha(c)) return (char)tolower(c); return c; @@ -22,22 +22,22 @@ extern "C" int strcasecmp(const char* a, const char* b) { - while (*a && (fold(*a) == fold(*b))) + while (*a && (lowercase(*a) == lowercase(*b))) { a++; b++; } - return (unsigned char)fold(*a) - (unsigned char)fold(*b); + return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b); } int strncasecmp(const char* a, const char* b, size_t max) { const char* base = a; - while (*a && (fold(*a) == fold(*b)) && (size_t)(a - base) < (max - 1)) + while (*a && (lowercase(*a) == lowercase(*b)) && (size_t)(a - base) < (max - 1)) { a++; b++; } - return (unsigned char)fold(*a) - (unsigned char)fold(*b); + return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b); } } \ No newline at end of file