shithub: scc

ref: 0eaa0e21ca1c958ca2ea372e2e785e7392a0818c
dir: /libc/src/strtok.c/

View raw version
/* See LICENSE file for copyright and license details. */

#include <string.h>

char *
strtok(const char *s, const char *delim)
{
	static char *line;

	if (s) 
		line = s;
	if (!s && !line)
		return NULL;

	s = line + strspn(line, delim);
	if (*s == '\0')
		return line = NULL;

	line = s + strcspn(s, delim);
	if (*line != '\0')
		*line++ = '\0';
	else
		line = NULL;

	return s;
}