diff --git a/libs/libc/include/string.h b/libs/libc/include/string.h index 7ce34c14..cdfb4dee 100644 --- a/libs/libc/include/string.h +++ b/libs/libc/include/string.h @@ -91,6 +91,11 @@ extern "C" __lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest, const char* src); +#ifdef _GNU_SOURCE + /* Copies the string src into dest, returning a pointer to the end of dest. */ + __lc_is_deprecated char* stpcpy(char* dest, const char* src); +#endif + char* strtok(char* str, const char* delim); // Not implemented. #ifdef __cplusplus diff --git a/libs/libc/src/string.cpp b/libs/libc/src/string.cpp index 974bc5cd..39f1d352 100644 --- a/libs/libc/src/string.cpp +++ b/libs/libc/src/string.cpp @@ -111,6 +111,13 @@ extern "C" return len; } + char* stpcpy(char* dest, const char* src) + { + size_t len = strlen(src); + size_t rc = strlcpy(dest, src, len + 1); + return dest + rc; + } + int strcmp(const char* a, const char* b) { while (*a && (*a == *b))