static char sccsid
[] = "@(#)strtok.c 1.1 (Berkeley/CCI) 7/5/86";
* uses strpbrk and strspn to break string into tokens on
* sequentially subsequent calls. returns NULL when no
* non-separator characters remain.
* `subsequent' calls are calls with first argument NULL.
register char *p
, *q
, *r
;
/*first or subsequent call*/
p
= (string
== NULL
)? savept
: string
;
if(p
== 0) /* return if no tokens remaining */
q
= p
+ strspn(p
, sepset
); /* skip leading separators */
if(*q
== '\0') /* return if no tokens remaining */
if((r
= strpbrk(q
, sepset
)) == NULL
) /* move past token */
savept
= 0; /* indicate this is last token */