Move the lib/ stuff around a bit
[fio.git] / lib / strsep.c
... / ...
CommitLineData
1#include <stdio.h>
2
3char *strsep(char **stringp, const char *delim)
4{
5 char *s;
6 const char *spanp;
7 int c, sc;
8 char *tok;
9
10 if ((s = *stringp) == NULL)
11 return (NULL);
12 for (tok = s;;) {
13 c = *s++;
14 spanp = delim;
15 do {
16 if ((sc = *spanp++) == c) {
17 if (c == 0)
18 s = NULL;
19 else
20 s[-1] = 0;
21 *stringp = s;
22 return (tok);
23 }
24 } while (sc != 0);
25 }
26}