xref: /csrg-svn/lib/libc/string/index.c (revision 61193)
142147Sbostic /*-
2*61193Sbostic  * Copyright (c) 1990, 1993
3*61193Sbostic  *	The Regents of the University of California.  All rights reserved.
434617Sbostic  *
542147Sbostic  * %sccs.include.redist.c%
61969Swnj  */
71969Swnj 
834617Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*61193Sbostic static char sccsid[] = "@(#)index.c	8.1 (Berkeley) 06/04/93";
1034617Sbostic #endif /* LIBC_SCCS and not lint */
111969Swnj 
1246613Sbostic #include <sys/cdefs.h>
1342147Sbostic #include <string.h>
1442147Sbostic #include <stddef.h>
1534617Sbostic 
161969Swnj char *
1743488Sbostic #ifdef STRCHR
strchr(p,ch)1843488Sbostic strchr(p, ch)
1943488Sbostic #else
2034617Sbostic index(p, ch)
2143488Sbostic #endif
2246613Sbostic 	register const char *p, ch;
231969Swnj {
2434617Sbostic 	for (;; ++p) {
2534617Sbostic 		if (*p == ch)
2646613Sbostic 			return((char *)p);
2734617Sbostic 		if (!*p)
2834617Sbostic 			return((char *)NULL);
2934617Sbostic 	}
3034617Sbostic 	/* NOTREACHED */
311969Swnj }
32