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