Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / string / strspn.c
blobbfa3331cd4590157abc8eb918ddf6cfa387aa1e5
1 /*
2 FUNCTION
3 <<strspn>>---find initial match
5 INDEX
6 strspn
8 SYNOPSIS
9 #include <string.h>
10 size_t strspn(const char *<[s1]>, const char *<[s2]>);
12 DESCRIPTION
13 This function computes the length of the initial segment of
14 the string pointed to by <[s1]> which consists entirely of
15 characters from the string pointed to by <[s2]> (excluding the
16 terminating null character).
18 RETURNS
19 <<strspn>> returns the length of the segment found.
21 PORTABILITY
22 <<strspn>> is ANSI C.
24 <<strspn>> requires no supporting OS subroutines.
26 QUICKREF
27 strspn ansi pure
30 #include <string.h>
32 size_t
33 strspn (const char *s1,
34 const char *s2)
36 const char *s = s1;
37 const char *c;
39 while (*s1)
41 for (c = s2; *c; c++)
43 if (*s1 == *c)
44 goto found;
46 if (*c == '\0')
47 break;
48 found:
49 s1++;
52 return s1 - s;