source: trunk/libs/newlib/src/newlib/libc/string/strspn.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 818 bytes
Line 
1/*
2FUNCTION
3        <<strspn>>---find initial match
4
5INDEX
6        strspn
7
8SYNOPSIS
9        #include <string.h>
10        size_t strspn(const char *<[s1]>, const char *<[s2]>);
11
12DESCRIPTION
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).
17
18RETURNS
19        <<strspn>> returns the length of the segment found.
20
21PORTABILITY
22<<strspn>> is ANSI C.
23
24<<strspn>> requires no supporting OS subroutines.
25
26QUICKREF
27        strspn ansi pure
28*/
29
30#include <string.h>
31
32size_t
33strspn (const char *s1,
34        const char *s2)
35{
36  const char *s = s1;
37  const char *c;
38
39  while (*s1)
40    {
41      for (c = s2; *c; c++)
42        {
43          if (*s1 == *c)
44            break;
45        }
46      if (*c == '\0')
47        break;
48      s1++;
49    }
50
51  return s1 - s;
52}
Note: See TracBrowser for help on using the repository browser.