From afa87ec5f311ccb7823423d20969f5f8a44c4fcc Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 14 Feb 2025 02:18:40 +0200 Subject: [PATCH] userspace/libc: implement strcoll() Signed-off-by: EnderIce2 --- Userspace/libc/include/string.h | 2 +- Userspace/libc/src/std/string.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Userspace/libc/include/string.h b/Userspace/libc/include/string.h index 9c289379..72e05dfe 100644 --- a/Userspace/libc/include/string.h +++ b/Userspace/libc/include/string.h @@ -38,7 +38,7 @@ extern "C" char *strcat(char *restrict, const char *restrict); char *strchr(const char *s, int c); int strcmp(const char *s1, const char *s2); - int strcoll(const char *, const char *); + int strcoll(const char *s1, const char *s2); int strcoll_l(const char *, const char *, locale_t); char *strcpy(char *restrict, const char *restrict); size_t strcspn(const char *s1, const char *s2); diff --git a/Userspace/libc/src/std/string.c b/Userspace/libc/src/std/string.c index 9b64149f..e90bd788 100644 --- a/Userspace/libc/src/std/string.c +++ b/Userspace/libc/src/std/string.c @@ -72,7 +72,17 @@ export int strcmp(const char *s1, const char *s2) return *(unsigned char *)s1 - *(unsigned char *)s2; } -export int strcoll(const char *, const char *); +export int strcoll(const char *s1, const char *s2) +{ + while (*s1 && (*s1 == *s2)) + { + s1++; + s2++; + } + + return *(unsigned char *)s1 - *(unsigned char *)s2; +} + export int strcoll_l(const char *, const char *, locale_t); export char *strcpy(char *restrict, const char *restrict);