diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-10-16 09:52:54 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-17 17:09:58 +0100 |
commit | 57f0c12b9a7a2ff812e712ea8ef1cc9aff3bedfa (patch) | |
tree | 5a3accc6f5c62f5a49d9c514036bea89ed4a5dec /Userland/Libraries | |
parent | 685045176b565740275e24b522bf03ad145ca854 (diff) | |
download | serenity-57f0c12b9a7a2ff812e712ea8ef1cc9aff3bedfa.zip |
LibC: Implement wmemcmp
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibC/wchar.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibC/wchar.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/wchar.cpp b/Userland/Libraries/LibC/wchar.cpp index d12d224e90..2b843a4ace 100644 --- a/Userland/Libraries/LibC/wchar.cpp +++ b/Userland/Libraries/LibC/wchar.cpp @@ -541,4 +541,13 @@ size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* ps) // If we are here, we have written `len` wchars, but not reached the null byte. return written; } + +int wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n) +{ + while (n-- > 0) { + if (*s1++ != *s2++) + return s1[-1] < s2[-1] ? -1 : 1; + } + return 0; +} } diff --git a/Userland/Libraries/LibC/wchar.h b/Userland/Libraries/LibC/wchar.h index a1ed5476c0..52c632c6a8 100644 --- a/Userland/Libraries/LibC/wchar.h +++ b/Userland/Libraries/LibC/wchar.h @@ -60,5 +60,6 @@ int swprintf(wchar_t*, size_t, const wchar_t*, ...); int wcwidth(wchar_t); size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*); size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*); +int wmemcmp(const wchar_t*, const wchar_t*, size_t); __END_DECLS |