source: trunk/libs/newlib/src/newlib/libc/string/strcspn.c @ 471

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

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

File size: 788 bytes
Line 
1/*
2FUNCTION
3        <<strcspn>>---count characters not in string
4
5INDEX
6        strcspn
7
8SYNOPSIS
9        size_t strcspn(const char *<[s1]>, const char *<[s2]>);
10
11DESCRIPTION
12        This function computes the length of the initial part of
13        the string pointed to by <[s1]> which consists entirely of
14        characters <[NOT]> from the string pointed to by <[s2]>
15        (excluding the terminating null character).
16
17RETURNS
18        <<strcspn>> returns the length of the substring found.
19
20PORTABILITY
21<<strcspn>> is ANSI C.
22
23<<strcspn>> requires no supporting OS subroutines.
24 */
25
26#include <string.h>
27
28size_t
29strcspn (const char *s1,
30        const char *s2)
31{
32  const char *s = s1;
33  const char *c;
34
35  while (*s1)
36    {
37      for (c = s2; *c; c++)
38        {
39          if (*s1 == *c)
40            break;
41        }
42      if (*c)
43        break;
44      s1++;
45    }
46
47  return s1 - s;
48}
Note: See TracBrowser for help on using the repository browser.