]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/strtok_r.c
Implement the IRC command "SERVLIST"
[ngircd-alex.git] / src / portab / strtok_r.c
1 #include "portab.h"
2 #include <string.h>
3
4 #ifndef HAVE_STRTOK_R
5
6 char *
7 strtok_r(char *str, const char *delim, char **saveptr)
8 {
9         char *tmp;
10
11         if (!str)
12                 str = *saveptr;
13         str += strspn(str, delim);
14         if (*str == 0)
15                 return NULL;
16
17         tmp = str + strcspn(str, delim); /* get end of token */
18         if (*tmp) { /* another delimiter */
19                 *tmp = 0;
20                 tmp++;
21         }
22         *saveptr = tmp;
23         return str;
24 }
25
26 #endif
27