git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30022 a95241bf-73f2-0310-859d-f6bbb57e9c96
30 lines
526 B
C++
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;
|
|
}
|