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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [strspn.c] - Blame information for rev 207

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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