1 // Copyright 2016 The Fuchsia Authors 2 // Copyright (c) 2008 Travis Geiselbrecht 3 // 4 // Use of this source code is governed by a MIT-style 5 // license that can be found in the LICENSE file or at 6 // https://opensource.org/licenses/MIT 7 8 #include <string.h> 9 #include <sys/types.h> 10 11 static char *___strtok = NULL; 12 13 char * strtok(char * s,char const * ct)14strtok(char *s, char const *ct) 15 { 16 char *sbegin, *send; 17 18 sbegin = s ? s : ___strtok; 19 if (!sbegin) { 20 return NULL; 21 } 22 sbegin += strspn(sbegin,ct); 23 if (*sbegin == '\0') { 24 ___strtok = NULL; 25 return ( NULL ); 26 } 27 send = strpbrk( sbegin, ct); 28 if (send && *send != '\0') 29 *send++ = '\0'; 30 ___strtok = send; 31 return (sbegin); 32 } 33