123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include <string.h>
- #ifdef __USE_GNU
- # define __rawmemchr rawmemchr
- #else
- # define __rawmemchr strchr
- #endif
- #if 0
- Parse S into tokens separated by characters in DELIM.
- If S is NULL, the saved pointer in SAVE_PTR is used as
- the next starting point. For example:
- char s[] = "-abc-=-def";
- char *sp;
- x = strtok_r(s, "-", &sp);
- x = strtok_r(NULL, "-=", &sp);
- x = strtok_r(NULL, "=", &sp);
-
- #endif
- char *strtok_r (char *s, const char *delim, char **save_ptr)
- {
- char *token;
- if (s == NULL)
- s = *save_ptr;
-
- s += strspn (s, delim);
- if (*s == '\0')
- {
- *save_ptr = s;
- return NULL;
- }
-
- token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
-
- *save_ptr = __rawmemchr (token, '\0');
- else
- {
-
- *s = '\0';
- *save_ptr = s + 1;
- }
- return token;
- }
- libc_hidden_def(strtok_r)
|