fxlibc/src/libc/string/strtok.c

19 lines
327 B
C

#include <string.h>
char *strtok(char * restrict new_s, char const * restrict separators)
{
static char *s = NULL;
if(new_s) s = new_s;
/* Skip leading delimiters */
s += strspn(s, separators);
if(!*s) return NULL;
/* Skip non-delimiters */
char *token = s;
s += strcspn(s, separators);
*s++ = 0;
return token;
}