1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <msvcrt/string.h>
3 #include <msvcrt/internal/tls.h>
5 char* strtok(char* s
, const char* delim
)
10 PTHREADDATA ThreadData
= GetThreadData();
12 if (s
== NULL
&& (s
= ThreadData
->lasttoken
) == NULL
)
16 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
20 for (spanp
= delim
; (sc
= *spanp
++) != 0;) {
25 if (c
== 0) { /* no non-delimiter characters */
26 ThreadData
->lasttoken
= NULL
;
32 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
33 * Note that delim must have one NUL; we stop if we see that, too.
39 if ((sc
= *spanp
++) == c
) {
44 ThreadData
->lasttoken
= s
;