libluna+libc: Add strtok_r()
This commit is contained in:
parent
47d505dcbb
commit
9bb5371e8c
@ -71,6 +71,9 @@ extern "C"
|
|||||||
/* Separate a string into several tokens. */
|
/* Separate a string into several tokens. */
|
||||||
char* strtok(char* str, const char* delim);
|
char* strtok(char* str, const char* delim);
|
||||||
|
|
||||||
|
/* Separate a string into several tokens. */
|
||||||
|
char* strtok_r(char* str, const char* delim, char** savep);
|
||||||
|
|
||||||
/* Return a heap-allocated copy of a fixed-size string. */
|
/* Return a heap-allocated copy of a fixed-size string. */
|
||||||
char* strndup(const char* str, size_t max);
|
char* strndup(const char* str, size_t max);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ extern "C"
|
|||||||
usize strcspn(const char* str, const char* reject);
|
usize strcspn(const char* str, const char* reject);
|
||||||
|
|
||||||
char* strtok(char* str, const char* delim);
|
char* strtok(char* str, const char* delim);
|
||||||
|
char* strtok_r(char* str, const char* delim, char** savep);
|
||||||
|
|
||||||
usize wcslen(const wchar_t* str);
|
usize wcslen(const wchar_t* str);
|
||||||
int wcscmp(const wchar_t* a, const wchar_t* b);
|
int wcscmp(const wchar_t* a, const wchar_t* b);
|
||||||
|
@ -219,9 +219,9 @@ extern "C"
|
|||||||
return (usize)(s - str);
|
return (usize)(s - str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strtok(char* str, const char* delim)
|
char* strtok_r(char* str, const char* delim, char** savep)
|
||||||
{
|
{
|
||||||
static char* s = nullptr;
|
auto& s = *savep;
|
||||||
if (str) s = str;
|
if (str) s = str;
|
||||||
if (!s) return nullptr;
|
if (!s) return nullptr;
|
||||||
|
|
||||||
@ -248,6 +248,12 @@ extern "C"
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* strtok(char* str, const char* delim)
|
||||||
|
{
|
||||||
|
static char* s;
|
||||||
|
return strtok_r(str, delim, &s);
|
||||||
|
}
|
||||||
|
|
||||||
char* strpbrk(const char* s, const char* accept)
|
char* strpbrk(const char* s, const char* accept)
|
||||||
{
|
{
|
||||||
usize index = strcspn(s, accept);
|
usize index = strcspn(s, accept);
|
||||||
|
Loading…
Reference in New Issue
Block a user