strtok.c (351B)
1 #include <string.h> 2 #undef strtok 3 4 char * 5 strtok(char * restrict s, const char * restrict delim) 6 { 7 static char *line; 8 9 if (s) 10 line = s; 11 if (!s && !line) 12 return NULL; 13 14 s = line + strspn(line, delim); 15 if (*s == '\0') 16 return line = NULL; 17 18 line = s + strcspn(s, delim); 19 if (*line != '\0') 20 *line++ = '\0'; 21 else 22 line = NULL; 23 24 return s; 25 }