File: strsep.c

package info (click to toggle)
fio 1.38-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,108 kB
  • ctags: 2,240
  • sloc: ansic: 17,668; makefile: 98; sh: 55
file content (29 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (4)
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
26
27
28
29
#include <stdio.h>

char *strsep(char **stringp, const char *delim)
{
	char *s, *tok;
	const char *spanp;
	int c, sc;

	s = *stringp;
	if (!s)
		return NULL;

	tok = s;
	do {
		c = *s++;
		spanp = delim;
		do {
			sc = *spanp++;
			if (sc == c) {
				if (c == 0)
					s = NULL;
				else
					s[-1] = 0;
				*stringp = s;
				return tok;
			}
		} while (sc != 0);
	} while (1);
}