Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <string.h>
2
 
3
#define	N	256
4
 
5
char*
6
strtok_r(char *s, const char *b, char **last)
7
{
8
	char map[N], *os;
9
 
10
	memset(map, 0, N);
11
	while(*b)
12
		map[*(unsigned char*)b++] = 1;
13
	if(s == 0)
14
		s = *last;
15
	while(map[*(unsigned char*)s++])
16
		;
17
	if(*--s == 0)
18
		return 0;
19
	os = s;
20
	while(map[*(unsigned char*)s] == 0)
21
		if(*s++ == 0) {
22
			*last = s-1;
23
			return os;
24
		}
25
	*s++ = 0;
26
	*last = s;
27
	return os;
28
}
29
 
30
char*
31
strtok(char *s, const char *b)
32
{
33
	static char *under_rock;
34
 
35
	return strtok_r(s, b, &under_rock);
36
}