1 /*
2 **  This file has been modified to get it to compile more easily
3 **  on pre-4.4BSD systems.  Rich $alz, June 1991.
4 */
5 
6 #include "portable/system.h"
7 
8 /*
9  * Copyright (c) 1989 The Regents of the University of California.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms are permitted
13  * provided that: (1) source distributions retain this entire copyright
14  * notice and comment, and (2) distributions including binaries display
15  * the following acknowledgement: ``This product includes software
16  * developed by the University of California, Berkeley and its contributors''
17  * in the documentation or other materials provided with the distribution
18  * and in all advertising materials mentioning features or use of this
19  * software. Neither the name of the University nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25  */
26 
27 
28 /*
29  * Span the string s2 (skip characters that are in s2).
30  */
31 size_t
strspn(const char * s1,const char * s2)32 strspn(const char *s1, const char *s2)
33 {
34     const char *p = s1, *spanp;
35     char c, sc;
36 
37     /*
38      * Skip any characters in s2, excluding the terminating \0.
39      */
40 cont:
41     c = *p++;
42     for (spanp = s2; (sc = *spanp++) != 0;)
43         if (sc == c)
44             goto cont;
45     return (p - 1 - s1);
46 }
47