使っている処理系にstrtok_rがなかったので自作

こんな感じかな。strspnとstrcspnを使います。

#include <string.h>

char *strtok_r(char *str, const char *delim, char **saveptr)
{
	size_t width;
	char* head;

	head  = (NULL != str)? str: *saveptr;
	width = strcspn(head, delim);
	if(0 == width){
		head += strspn(head, delim);
		width = strcspn(head, delim);
	}
	if('\0' == *head){
		return NULL;
	}

	*saveptr = head + width + strspn(head + width, delim);
	*(head + width) = '\0';

	return head;
}