1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:17:34 +00:00

LibC: Implement wcslcpy

This commit is contained in:
Daniel Bertalan 2021-10-16 10:31:04 +02:00 committed by Linus Groh
parent e6164d35fa
commit 13e6d9d71a
3 changed files with 38 additions and 0 deletions

View file

@ -69,6 +69,18 @@ wchar_t* wcsncpy(wchar_t* dest, const wchar_t* src, size_t num)
return original_dest;
}
size_t wcslcpy(wchar_t* dest, const wchar_t* src, size_t n)
{
size_t i;
for (i = 0; i + 1 < n && src[i] != L'\0'; ++i)
dest[i] = src[i];
if (n)
dest[i] = L'\0';
for (; src[i] != L'\0'; ++i)
; // Determine the length of src, don't copy.
return i;
}
int wcscmp(const wchar_t* s1, const wchar_t* s2)
{
while (*s1 == *s2++)

View file

@ -29,6 +29,7 @@ struct tm;
size_t wcslen(const wchar_t*);
wchar_t* wcscpy(wchar_t*, const wchar_t*);
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
__attribute__((warn_unused_result)) size_t wcslcpy(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);