LibC: add strchrnul()

this is a gnu libc extension
This commit is contained in:
Bananymous 2023-06-11 20:18:03 +03:00
parent c62e820bcf
commit 071da18fa3
2 changed files with 12 additions and 0 deletions

View File

@ -20,6 +20,7 @@ char* stpcpy(char* __restrict s1, const char* __restrict s2);
char* stpncpy(char* __restrict s1, const char* __restrict s2, size_t n);
char* strcat(char* __restrict s1, const char* __restrict s2);
char* strchr(const char* s, int c);
char* strchrnul(const char* s, int c);
int strcmp(const char* s1, const char* s2);
int strcoll(const char* s1, const char* s2);
int strcoll_l(const char* s1, const char* s2, locale_t locale);

View File

@ -303,6 +303,17 @@ char* strchr(const char* str, int c)
return (*str == c) ? (char*)str : nullptr;
}
char* strchrnul(const char* str, int c)
{
while (*str)
{
if (*str == c)
return (char*)str;
str++;
}
return (char*)str;
}
char* strncpy(char* __restrict__ dest, const char* __restrict__ src, size_t n)
{
size_t i;