1 /*
2  *  Copyright (C) 1991, 1992  Linus Torvalds
3  */
4 
5 #include <xen/string.h>
6 
7 /**
8  * strsep - Split a string into tokens
9  * @s: The string to be searched
10  * @ct: The characters to search for
11  *
12  * strsep() updates @s to point after the token, ready for the next call.
13  *
14  * It returns empty tokens, too, behaving exactly like the libc function
15  * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
16  * Same semantics, slimmer shape. ;)
17  */
strsep(char ** s,const char * ct)18 char *strsep(char **s, const char *ct)
19 {
20 	char *sbegin = *s, *end;
21 
22 	if (sbegin == NULL)
23 		return NULL;
24 
25 	end = strpbrk(sbegin, ct);
26 	if (end)
27 		*end++ = '\0';
28 	*s = end;
29 
30 	return sbegin;
31 }
32 
33 /*
34  * Local variables:
35  * mode: C
36  * c-file-style: "BSD"
37  * c-basic-offset: 8
38  * tab-width: 8
39  * indent-tabs-mode: t
40  * End:
41  */
42