kolibrios-gitea/programs/develop/ktcc/trunk/libc/string/strtok.c
siemargl ace23ebbe2 libc testsuite + fixes
git-svn-id: svn://kolibrios.org@6433 a494cfbc-eb01-0410-851d-a64ba20cac60
2016-05-19 12:15:22 +00:00

26 lines
382 B
C

#include <string.h>
char* strtok(char* s,const char* delim)
// non reentrant
{
static char* savep;
char* res;
if(s)
savep = NULL;
else
s = savep;
if (*s == '\0')
return NULL;
s += strspn(s, delim);
if (*s == '\0')
return NULL;
res = s;
s += strcspn(s, delim);
savep = s + 1;
*s = '\0';
return res;
}