]> pd.if.org Git - pdclib/blob - functions/string/strspn.c
Added search functions.
[pdclib] / functions / string / strspn.c
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* strspn( const char *, const char * )
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #include <string.h>
12
13 size_t strspn( const char * s1, const char * s2 )
14 {
15     size_t len = 0;
16     const char * p;
17     while ( s1[ len ] )
18     {
19         p = s2;
20         while ( *p )
21         {
22             if ( s1[len] == *p )
23             {
24                 break;
25             }
26             ++p;
27         }
28         if ( ! *p )
29         {
30             return len;
31         }
32         ++len;
33     }
34     return len;
35 }