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:
parent
8a43f5a64a
commit
75307803a2
Notes:
sideshowbarker
2024-07-17 03:35:24 +09:00
Author: https://github.com/sdomi 🔰
Commit: 75307803a2
Pull-request: https://github.com/SerenityOS/serenity/pull/19347
Reviewed-by: https://github.com/linusg ✅
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue