xref: /csrg-svn/lib/libc/string/index.c (revision 43488)
142147Sbostic /*-
242147Sbostic  * Copyright (c) 1990 The Regents of the University of California.
334617Sbostic  * All rights reserved.
434617Sbostic  *
542147Sbostic  * %sccs.include.redist.c%
61969Swnj  */
71969Swnj 
834617Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*43488Sbostic static char sccsid[] = "@(#)index.c	5.6 (Berkeley) 06/23/90";
1034617Sbostic #endif /* LIBC_SCCS and not lint */
111969Swnj 
1242147Sbostic #include <string.h>
1342147Sbostic #include <stddef.h>
1434617Sbostic 
151969Swnj char *
16*43488Sbostic #ifdef STRCHR
17*43488Sbostic strchr(p, ch)
18*43488Sbostic #else
1934617Sbostic index(p, ch)
20*43488Sbostic #endif
2134617Sbostic 	register char *p, ch;
221969Swnj {
2334617Sbostic 	for (;; ++p) {
2434617Sbostic 		if (*p == ch)
2534617Sbostic 			return(p);
2634617Sbostic 		if (!*p)
2734617Sbostic 			return((char *)NULL);
2834617Sbostic 	}
2934617Sbostic 	/* NOTREACHED */
301969Swnj }
31