summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-10-16 09:52:54 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-17 17:09:58 +0100
commit57f0c12b9a7a2ff812e712ea8ef1cc9aff3bedfa (patch)
tree5a3accc6f5c62f5a49d9c514036bea89ed4a5dec /Userland/Libraries
parent685045176b565740275e24b522bf03ad145ca854 (diff)
downloadserenity-57f0c12b9a7a2ff812e712ea8ef1cc9aff3bedfa.zip
LibC: Implement wmemcmp
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibC/wchar.cpp9
-rw-r--r--Userland/Libraries/LibC/wchar.h1
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