mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibC: Implement strlcpy
This commit is contained in:
parent
3fc2c4866f
commit
41b70ae8ba
1 changed files with 9 additions and 4 deletions
|
@ -216,10 +216,15 @@ char* strncpy(char* dest, const char* src, size_t n)
|
||||||
|
|
||||||
size_t strlcpy(char* dest, const char* src, size_t n)
|
size_t strlcpy(char* dest, const char* src, size_t n)
|
||||||
{
|
{
|
||||||
(void)dest;
|
size_t i;
|
||||||
(void)src;
|
// Would like to test i < n - 1 here, but n might be 0.
|
||||||
(void)n;
|
for (i = 0; i + 1 < n && src[i] != '\0'; ++i)
|
||||||
return 42; // TODO
|
dest[i] = src[i];
|
||||||
|
if (n)
|
||||||
|
dest[i] = '\0';
|
||||||
|
for (; src[i] != '\0'; ++i)
|
||||||
|
; // Determine the length of src, don't copy.
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strchr(const char* str, int c)
|
char* strchr(const char* str, int c)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue