xref: /csrg-svn/lib/libc/string/memccpy.c (revision 61193)
141958Sbostic /*-
2*61193Sbostic  * Copyright (c) 1990, 1993
3*61193Sbostic  *	The Regents of the University of California.  All rights reserved.
434479Sbostic  *
541958Sbostic  * %sccs.include.redist.c%
624194Skre  */
724194Skre 
826525Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61193Sbostic static char sccsid[] = "@(#)memccpy.c	8.1 (Berkeley) 06/04/93";
1034479Sbostic #endif /* LIBC_SCCS and not lint */
1124194Skre 
1246144Sbostic #include <sys/cdefs.h>
1341958Sbostic #include <string.h>
1424194Skre 
1541958Sbostic void *
memccpy(t,f,c,n)1624194Skre memccpy(t, f, c, n)
1742447Sbostic 	void *t;
1842447Sbostic 	const void *f;
1942447Sbostic 	int c;
2041958Sbostic 	register size_t n;
2124194Skre {
2242447Sbostic 
2342447Sbostic 	if (n) {
2449952Sbostic 		register unsigned char *tp = t;
2549952Sbostic 		register const unsigned char *fp = f;
2642447Sbostic 		do {
2749952Sbostic 			if ((*tp++ = *fp++) == c)
2842447Sbostic 				return (t);
2942447Sbostic 		} while (--n != 0);
3042447Sbostic 	}
3124194Skre 	return (0);
3224194Skre }
33