1 #include <u.h> 2 #include <libc.h> 3 4 #define N 256 5 6 char* strtok(char * s,char * b)7strtok(char *s, char *b) 8 { 9 static char *under_rock; 10 char map[N], *os; 11 12 memset(map, 0, N); 13 while(*b) 14 map[*(uchar*)b++] = 1; 15 if(s == 0) 16 s = under_rock; 17 while(map[*(uchar*)s++]) 18 ; 19 if(*--s == 0) 20 return 0; 21 os = s; 22 while(map[*(uchar*)s] == 0) 23 if(*s++ == 0) { 24 under_rock = s-1; 25 return os; 26 } 27 *s++ = 0; 28 under_rock = s; 29 return os; 30 } 31