CString: Support strcpy(), strcat() and strchr()
This commit is contained in:
parent
30555f8e5a
commit
a01b56ed39
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user