1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibC: Implement stpcpy

For better code clarity, also reformatted how strcpy increments
pointers.
This commit is contained in:
Dominika Liberda 2023-06-11 06:00:11 +02:00 committed by Linus Groh
parent 8a43f5a64a
commit 75307803a2
Notes: sideshowbarker 2024-07-17 03:35:24 +09:00
2 changed files with 15 additions and 2 deletions

View file

@ -187,11 +187,23 @@ void* memmem(void const* haystack, size_t haystack_length, void const* needle, s
char* strcpy(char* dest, char const* src)
{
char* original_dest = dest;
while ((*dest++ = *src++) != '\0')
;
while ((*dest = *src) != '\0') {
dest++;
src++;
}
return original_dest;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpcpy.html
char* stpcpy(char* dest, char const* src)
{
while ((*dest = *src) != '\0') {
dest++;
src++;
}
return dest;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncpy.html
char* strncpy(char* dest, char const* src, size_t n)
{