libc: Add strpbrk()

This commit is contained in:
apio 2022-10-22 17:54:33 +02:00
parent 4d71c0ef04
commit 503a04f0e9
2 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,9 @@ extern "C"
/* Returns the length of the initial segment of str which consists entirely of bytes in accept. */ /* Returns the length of the initial segment of str which consists entirely of bytes in accept. */
size_t strspn(const char* str, const char* accept); size_t strspn(const char* str, const char* accept);
/* Returns a pointer to the first occurrence of any character of b in a. */
char* strpbrk(const char* a, const char* b);
/* Compares strings a and b. You might prefer to use the safer strncmp function. */ /* Compares strings a and b. You might prefer to use the safer strncmp function. */
int strcmp(const char* a, const char* b); int strcmp(const char* a, const char* b);

View File

@ -167,6 +167,16 @@ extern "C"
return s - str; return s - str;
} }
char* strpbrk(const char* a, const char* b)
{
while (*a)
{
if (strchr(b, *a)) return const_cast<char*>(a);
a++;
}
return NULL;
}
char* strcat(char* dest, const char* src) char* strcat(char* dest, const char* src)
{ {
size_t dest_len = strlen(dest); size_t dest_len = strlen(dest);