Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1693 | serge | 1 | /* |
2 | FUNCTION |
||
3 | < |
||
4 | |||
5 | INDEX |
||
6 | strspn |
||
7 | |||
8 | ANSI_SYNOPSIS |
||
9 | #include |
||
10 | size_t strspn(const char *<[s1]>, const char *<[s2]>); |
||
11 | |||
12 | TRAD_SYNOPSIS |
||
13 | #include |
||
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 | < |
||
26 | |||
27 | PORTABILITY |
||
28 | < |
||
29 | |||
30 | < |
||
31 | |||
32 | QUICKREF |
||
33 | strspn ansi pure |
||
34 | */ |
||
35 | |||
36 | #include |
||
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 | } |