From 2eeef9581f08b972c2ae9ef37bebca032f56f07f Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 6 Nov 2022 19:56:36 +0100 Subject: [PATCH] libc: Add strxfrm() --- libs/libc/include/string.h | 3 +++ libs/libc/src/string.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/libs/libc/include/string.h b/libs/libc/include/string.h index 854c2eab..6e45ff9a 100644 --- a/libs/libc/include/string.h +++ b/libs/libc/include/string.h @@ -74,6 +74,9 @@ extern "C" /* Compares a and b based on the current locale. */ int strcoll(const char* a, const char* b); + /* Transforms src based on the current locale and stores n bytes of it in dest. */ + size_t strxfrm(char* dest, const char* src, size_t n); + /* Searches for the needle string in the haystack string. */ char* strstr(const char* haystack, const char* needle); diff --git a/libs/libc/src/string.cpp b/libs/libc/src/string.cpp index 092123c2..1d431623 100644 --- a/libs/libc/src/string.cpp +++ b/libs/libc/src/string.cpp @@ -136,6 +136,12 @@ extern "C" return strcmp(a, b); } + size_t strxfrm(char* dest, const char* src, size_t n) + { + strncpy(dest, src, n); + return n; + } + size_t strcspn(const char* str, const char* reject) { const char* s = str;