kolibrios-fun/programs/develop/ktcc/trunk/libc/string/strtok.c
turbocat e08c6968ef ktcc: rollback to r9529
git-svn-id: svn://kolibrios.org@9558 a494cfbc-eb01-0410-851d-a64ba20cac60
2022-01-02 12:16:17 +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;
}