diff options
Diffstat (limited to 'lib/string/strtok.c')
| -rw-r--r-- | lib/string/strtok.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/string/strtok.c b/lib/string/strtok.c new file mode 100644 index 0000000..86d9c97 --- /dev/null +++ b/lib/string/strtok.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */ + +#include <string.h> + +char *strtok(char *restrict s, const char *restrict sep) +{ + static char *p; + if (!s && !(s = p)) return NULL; + s += strspn(s, sep); + if (!*s) return p = 0; + p = s + strcspn(s, sep); + if (*p) *p++ = 0; + else p = 0; + return s; +} |
