19 lines
334 B
C
19 lines
334 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);
|
|
if(*s) *s++ = 0;
|
|
|
|
return token;
|
|
}
|