LibC: Implement wmemcmp

This commit is contained in:
Daniel Bertalan 2021-10-16 09:52:54 +02:00 committed by Linus Groh
parent 685045176b
commit 57f0c12b9a
Notes: sideshowbarker 2024-07-18 02:15:46 +09:00
2 changed files with 10 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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