xref: /csrg-svn/lib/libc/string/strpbrk.c (revision 42169)
124191Skre /*
224191Skre  * Copyright (c) 1985 Regents of the University of California.
334479Sbostic  * All rights reserved.
434479Sbostic  *
534479Sbostic  * Redistribution and use in source and binary forms are permitted
634831Sbostic  * provided that the above copyright notice and this paragraph are
734831Sbostic  * duplicated in all such forms and that any documentation,
834831Sbostic  * advertising materials, and other materials related to such
934831Sbostic  * distribution and use acknowledge that the software was developed
1034831Sbostic  * by the University of California, Berkeley.  The name of the
1134831Sbostic  * University may not be used to endorse or promote products derived
1234831Sbostic  * from this software without specific prior written permission.
1334831Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434831Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534831Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1624191Skre  */
1724191Skre 
1826535Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*42169Sbostic static char sccsid[] = "@(#)strpbrk.c	5.6 (Berkeley) 05/17/90";
2034479Sbostic #endif /* LIBC_SCCS and not lint */
2124191Skre 
22*42169Sbostic #include <string.h>
23*42169Sbostic #include <sys/stdc.h>
24*42169Sbostic 
25*42169Sbostic /*
26*42169Sbostic  * Find the first occurrence in s1 of a character in s2 (excluding NUL).
27*42169Sbostic  */
2824191Skre char *
2937776Sbostic strpbrk(s1, s2)
30*42169Sbostic 	register const char *s1, *s2;
3124191Skre {
32*42169Sbostic 	register const char *scanp;
3337776Sbostic 	register int c, sc;
3424191Skre 
35*42169Sbostic 	while ((c = *s1++) != 0) {
36*42169Sbostic 		for (scanp = s2; (sc = *scanp++) != 0;)
3737776Sbostic 			if (sc == c)
38*42169Sbostic 				return ((char *)(s1 - 1));
39*42169Sbostic 	}
40*42169Sbostic 	return (NULL);
4124191Skre }
42