1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:17:44 +00:00

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