Files
haiku-beta6/src/libs/bsd/string.cpp
T
Ingo Weinhold a3c74fcd8c Added a strsep() to our BSD compatibility library.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30022 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-08 10:57:46 +00:00

30 lines
526 B
C++

/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <string.h>
char*
strsep(char** string, const char* delimiters)
{
if (*string == NULL)
return NULL;
// find the end of the token
char* token = *string;
char* end = token;
while (*end != '\0' && strchr(delimiters, *end) == NULL)
end++;
// terminate the token and update the string pointer
if (*end != '\0') {
*end = '\0';
*string = end + 1;
} else
*string = NULL;
return token;
}