libc: Add strchrnul()
Another GNU extension, it's ok.
This commit is contained in:
parent
bfbe8e847b
commit
8908faf6e2
@ -49,6 +49,10 @@ extern "C"
|
|||||||
/* Returns a pointer to the last occurrence of the character c in str, or NULL if it is not found. */
|
/* Returns a pointer to the last occurrence of the character c in str, or NULL if it is not found. */
|
||||||
char* strrchr(const char* str, int c);
|
char* strrchr(const char* str, int c);
|
||||||
|
|
||||||
|
/* Returns a pointer to the first occurrence of the character c in str, or a pointer to the terminating null byte of
|
||||||
|
* str if it is not found. */
|
||||||
|
char* strchrnul(const char* str, int c);
|
||||||
|
|
||||||
/* Concatenates at most max bytes of the string src into dest. */
|
/* Concatenates at most max bytes of the string src into dest. */
|
||||||
char* strncat(char* dest, const char* src, size_t max);
|
char* strncat(char* dest, const char* src, size_t max);
|
||||||
|
|
||||||
|
@ -208,6 +208,12 @@ extern "C"
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* strchrnul(const char* str, int c)
|
||||||
|
{
|
||||||
|
while (*str && *str != (char)c) str++;
|
||||||
|
return const_cast<char*>(str);
|
||||||
|
}
|
||||||
|
|
||||||
char* strrchr(const char* str, int c)
|
char* strrchr(const char* str, int c)
|
||||||
{
|
{
|
||||||
const char* s = str + strlen(str);
|
const char* s = str + strlen(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user