aboutsummaryrefslogtreecommitdiff
path: root/ic-reals-6.3/base/strsep.c
blob: 1191f339f1ea17efd7deeab00d6b4204e288b244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Some UNIX distributions don't come with strsep.
 */
#include <stdio.h>
#include <string.h>

char *
strsep(char **str_p, char *delim)
{
	char *start, *end;

	start = *str_p;
	if (start == NULL)
		return NULL;

	end = strpbrk(start, delim);
	if (end) {
		*end++ = '\0';
		*str_p = end;
    }
	else
		*str_p = NULL;

	return start;
}