| 13 | #include <string.h> |
| 14 | |
| 15 | char *strtok_r(char *s, const char *delim, char **save_ptr) |
| 16 | { |
| 17 | char *token; |
| 18 | |
| 19 | if (s == NULL) s = *save_ptr; |
| 20 | |
| 21 | /* Scan leading delimiters. */ |
| 22 | s += strspn(s, delim); |
| 23 | if (*s == '\0') return NULL; |
| 24 | |
| 25 | /* Find the end of the token. */ |
| 26 | token = s; |
| 27 | s = strpbrk(token, delim); |
| 28 | if (s == NULL) |
| 29 | { |
| 30 | /* This token finishes the string. */ |
| 31 | *save_ptr = strchr(token, '\0'); |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | /* Terminate the token and make *save_ptr point past it. */ |
| 36 | *s = '\0'; |
| 37 | *save_ptr = s + 1; |
| 38 | } |
| 39 | |
| 40 | return token; |
| 41 | } |
| 42 | #endif // HB_NEED_STRTOK_R |
| 43 | |
| 44 | #ifndef HAS_STRERROR_R |
no outgoing calls
no test coverage detected