Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / libs / bsd / string.cpp
blobe51e8ac2b1688b56d499907ce40d8d427c443528
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include <string.h>
9 char*
10 strsep(char** string, const char* delimiters)
12 if (*string == NULL)
13 return NULL;
15 // find the end of the token
16 char* token = *string;
17 char* end = token;
18 while (*end != '\0' && strchr(delimiters, *end) == NULL)
19 end++;
21 // terminate the token and update the string pointer
22 if (*end != '\0') {
23 *end = '\0';
24 *string = end + 1;
25 } else
26 *string = NULL;
28 return token;