libluna+libc: Add strpbrk()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-04-12 18:42:25 +02:00
parent 3618a41bcd
commit 193d63c81b
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 16 additions and 0 deletions

View File

@ -65,6 +65,9 @@ extern "C"
/* Return the length of the initial segment of str which consists only of bytes not in reject. */
size_t strcspn(const char* str, const char* reject);
/* Return a pointer to the first occurrence of any of the characters in accept in s. */
char* strpbrk(const char* s, const char* delim);
/* Separate a string into several tokens. */
char* strtok(char* str, const char* delim);

View File

@ -34,4 +34,6 @@ extern "C"
char* strchr(const char* str, int c);
char* strrchr(const char* str, int c);
char* strpbrk(const char* s, const char* accept);
}

View File

@ -237,4 +237,15 @@ extern "C"
return nullptr;
}
char* strpbrk(const char* s, const char* accept)
{
usize index = strcspn(s, accept);
const char* ptr = s + index;
if (*ptr) return const_cast<char*>(ptr);
return nullptr;
}
}