strtok_r.c 233 B

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