2016-05-19 14:15:22 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2006-09-07 16:14:53 +02:00
|
|
|
char* strtok(char* s,const char* delim)
|
2016-05-19 14:15:22 +02:00
|
|
|
// non reentrant
|
2006-09-07 16:14:53 +02:00
|
|
|
{
|
2016-05-19 14:15:22 +02:00
|
|
|
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';
|
2006-09-07 16:14:53 +02:00
|
|
|
return res;
|
|
|
|
}
|
2016-05-19 14:15:22 +02:00
|
|
|
|