1#include <string.h> 2 3char* strtok_r(char* restrict s, const char* restrict sep, char** restrict p) { 4 if (!s && !(s = *p)) 5 return NULL; 6 s += strspn(s, sep); 7 if (!*s) 8 return *p = 0; 9 *p = s + strcspn(s, sep); 10 if (**p) 11 *(*p)++ = 0; 12 else 13 *p = 0; 14 return s; 15} 16