diff --git a/luna/include/luna/CString.h b/luna/include/luna/CString.h index df46497c..b4ac3029 100644 --- a/luna/include/luna/CString.h +++ b/luna/include/luna/CString.h @@ -16,4 +16,9 @@ extern "C" // Copies len bytes from src into dest and adds a null terminator. void nullcpy(char* dest, const char* src, usize len); + + [[deprecated]] char* strcpy(char* dst, const char* src); + [[deprecated]] char* strcat(char* dst, const char* src); + + char* strchr(const char* str, int c); } diff --git a/luna/src/CString.cpp b/luna/src/CString.cpp index ac048c3c..06f129f6 100644 --- a/luna/src/CString.cpp +++ b/luna/src/CString.cpp @@ -81,4 +81,28 @@ extern "C" memcpy(dest, src, len); dest[len] = 0; } + + char* strcpy(char* dest, const char* src) + { + char* s = dest; + for (; *src; dest++, src++) *dest = *src; + *dest = 0; + return s; + } + + char* strcat(char* dest, const char* src) + { + char* s = dest; + while (*dest) dest++; + for (; *src; dest++, src++) *dest = *src; + *dest = 0; + return s; + } + + char* strchr(const char* str, int c) + { + while (*str && *str != c) str++; + if (*str) return const_cast(str); + return NULL; + } }