Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1693 serge 1
/*
2
FUNCTION
3
	<>---count characters 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
	<> returns the length of the substring found.
24
 
25
PORTABILITY
26
<> is ANSI C.
27
 
28
<> requires no supporting OS subroutines.
29
 */
30
 
31
#include 
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
}