OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [string/] [strcspn.c] - Blame information for rev 1010

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
        <<strcspn>>---count chars not in string
4
 
5
INDEX
6
        strcspn
7
 
8
ANSI_SYNOPSIS
9
        size_t strcspn(const char *<[s1]>, const char *<[s2]>);
10
 
11
TRAD_SYNOPSIS
12
        size_t strcspn(<[s1]>, <[s2]>)
13
        char *<[s1]>;
14
        char *<[s2]>;
15
 
16
DESCRIPTION
17
        This function computes the length of the initial part of
18
        the string pointed to by <[s1]> which consists entirely of
19
        characters <[NOT]> from the string pointed to by <[s2]>
20
        (excluding the terminating null character).
21
 
22
RETURNS
23
        <<strcspn>> returns the length of the substring found.
24
 
25
PORTABILITY
26
<<strcspn>> is ANSI C.
27
 
28
<<strcspn>> requires no supporting OS subroutines.
29
 */
30
 
31
#include <string.h>
32
 
33
size_t
34
_DEFUN (strcspn, (s1, s2),
35
        _CONST char *s1 _AND
36
        _CONST char *s2)
37
{
38
  _CONST char *s = s1;
39
  _CONST char *c;
40
 
41
  while (*s1)
42
    {
43
      for (c = s2; *c; c++)
44
        {
45
          if (*s1 == *c)
46
            break;
47
        }
48
      if (*c)
49
        break;
50
      s1++;
51
    }
52
 
53
  return s1 - s;
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.