CString: Support strcpy(), strcat() and strchr()

This commit is contained in:
apio 2023-01-06 16:20:35 +01:00
parent 30555f8e5a
commit a01b56ed39
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 29 additions and 0 deletions

View File

@ -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);
}

View File

@ -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<char*>(str);
return NULL;
}
}