LibC: Add wcsncmp()

Taken from strncmp(), like wcscmp() in ef40ebb. :^)
This commit is contained in:
Linus Groh 2021-01-18 09:57:12 +01:00 committed by Andreas Kling
parent 2cc3d68615
commit ec42f864d4
Notes: sideshowbarker 2024-07-18 23:06:51 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -61,6 +61,19 @@ int wcscmp(const wchar_t* s1, const wchar_t* s2)
return *(const wchar_t*)s1 - *(const wchar_t*)--s2;
}
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n)
{
if (!n)
return 0;
do {
if (*s1 != *s2++)
return *(const wchar_t*)s1 - *(const wchar_t*)--s2;
if (*s1++ == 0)
break;
} while (--n);
return 0;
}
wchar_t* wcschr(const wchar_t* str, int c)
{
wchar_t ch = c;

View file

@ -39,6 +39,7 @@ size_t wcslen(const wchar_t*);
wchar_t* wcscpy(wchar_t*, const wchar_t*);
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
int wcscmp(const wchar_t*, const wchar_t*);
int wcsncmp(const wchar_t*, const wchar_t*, size_t);
wchar_t* wcschr(const wchar_t*, int);
const wchar_t* wcsrchr(const wchar_t*, wchar_t);
wchar_t* wcscat(wchar_t*, const wchar_t*);