xref: /csrg-svn/lib/libc/string/strncmp.c (revision 35096)
11988Swnj /*
2*35096Sbostic  * Copyright (c) 1988 Regents of the University of California.
3*35096Sbostic  * All rights reserved.
4*35096Sbostic  *
5*35096Sbostic  * Redistribution and use in source and binary forms are permitted
6*35096Sbostic  * provided that the above copyright notice and this paragraph are
7*35096Sbostic  * duplicated in all such forms and that any documentation,
8*35096Sbostic  * advertising materials, and other materials related to such
9*35096Sbostic  * distribution and use acknowledge that the software was developed
10*35096Sbostic  * by the University of California, Berkeley.  The name of the
11*35096Sbostic  * University may not be used to endorse or promote products derived
12*35096Sbostic  * from this software without specific prior written permission.
13*35096Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35096Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35096Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
161988Swnj  */
171988Swnj 
18*35096Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*35096Sbostic static char sccsid[] = "@(#)strncmp.c	5.3 (Berkeley) 07/18/88";
20*35096Sbostic #endif /* LIBC_SCCS and not lint */
21*35096Sbostic 
22*35096Sbostic strncmp(s1, s2, cnt)
23*35096Sbostic 	register char *s1, *s2;
24*35096Sbostic 	register int cnt;
251988Swnj {
26*35096Sbostic 	for (; cnt && *s1 == *s2; --cnt, ++s1, ++s2)
27*35096Sbostic 		if (!*s1)
281988Swnj 			return(0);
29*35096Sbostic 	return(cnt ? *s1 - *s2 : 0);
301988Swnj }
31