Add missing #include, fixes the warning:
[mplayer/greg.git] / osdep / strsep.c
blob85bb8b5749ac7264afe60cc06c5d816448e59531
1 /* strsep implementation for systems that do not have it in libc */
3 #include <stdio.h>
4 #include <string.h>
6 #include "config.h"
8 char *strsep(char **stringp, const char *delim) {
9 char *begin, *end;
11 begin = *stringp;
12 if(begin == NULL)
13 return NULL;
15 if(delim[0] == '\0' || delim[1] == '\0') {
16 char ch = delim[0];
18 if(ch == '\0')
19 end = NULL;
20 else {
21 if(*begin == ch)
22 end = begin;
23 else if(*begin == '\0')
24 end = NULL;
25 else
26 end = strchr(begin + 1, ch);
29 else
30 end = strpbrk(begin, delim);
32 if(end) {
33 *end++ = '\0';
34 *stringp = end;
36 else
37 *stringp = NULL;
39 return begin;