summaryrefslogtreecommitdiff
path: root/libc/string/strcspn.c
blob: 619c8be6b63a08e15f524389586af5896f9bec33 (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
26
27
28
29
30
31
32
/* strcspn.c */

/* from Schumacher's Atari library, improved */

#include <string.h>

size_t strcspn(string, set)
register char *string;
char *set;
/*
 *	Return the length of the sub-string of <string> that consists
 *	entirely of characters not found in <set>.  The terminating '\0'
 *	in <set> is not considered part of the match set.  If the first
 *	character if <string> is in <set>, 0 is returned.
 */
{
    register char *setptr;
    char *start;

    start = string;
    while (*string)
    {
	setptr = set;
	do
	    if (*setptr == *string)
		goto break2;
	while (*setptr++);
	++string;
    }
break2:
    return string - start;
}