summaryrefslogtreecommitdiff
path: root/src/string/strtok_r.c
blob: c763897afa5f385bcc642506fd5bb84c14d509d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#include <string.h>

char *strtok_r(char *s, const char *sep, char **p)
{
	if (!s && !(s = *p)) return NULL;
	s += strspn(s, sep);
	if (!*s) return *p = 0;
	*p = s + strcspn(s, sep);
	if (**p) *(*p)++ = 0;
	else *p = 0;
	return s;
}