2021-05-24 10:25:32 +02:00
|
|
|
#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);
|
2021-08-17 17:30:21 +02:00
|
|
|
if(*s) *s++ = 0;
|
2021-05-24 10:25:32 +02:00
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|