Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | |||
4 | char * |
||
5 | strsep(char **stringp, const char *delim) |
||
6 | { |
||
7 | char *s; |
||
8 | const char *spanp; |
||
9 | int c, sc; |
||
10 | char *tok; |
||
11 | |||
12 | if ((s = *stringp) == 0) |
||
13 | return 0; |
||
14 | |||
15 | tok = s; |
||
16 | while (1) |
||
17 | { |
||
18 | c = *s++; |
||
19 | spanp = delim; |
||
20 | do { |
||
21 | if ((sc = *spanp++) == c) |
||
22 | { |
||
23 | if (c == 0) |
||
24 | s = 0; |
||
25 | else |
||
26 | s[-1] = 0; |
||
27 | *stringp = s; |
||
28 | return tok; |
||
29 | } |
||
30 | } while (sc != 0); |
||
31 | } |
||
32 | } |