xref: /csrg-svn/lib/libc/string/strcmp.c (revision 42150)
1*42150Sbostic /*-
2*42150Sbostic  * Copyright (c) 1990 The Regents of the University of California.
335095Sbostic  * All rights reserved.
435095Sbostic  *
5*42150Sbostic  * This code is derived from software contributed to Berkeley by
6*42150Sbostic  * Chris Torek.
7*42150Sbostic  *
8*42150Sbostic  * %sccs.include.redist.c%
91983Swnj  */
101983Swnj 
1135095Sbostic #if defined(LIBC_SCCS) && !defined(lint)
12*42150Sbostic static char sccsid[] = "@(#)strcmp.c	5.4 (Berkeley) 05/16/90";
1335095Sbostic #endif /* LIBC_SCCS and not lint */
1435095Sbostic 
15*42150Sbostic #include <sys/stdc.h>
16*42150Sbostic #include <string.h>
17*42150Sbostic 
18*42150Sbostic /*
19*42150Sbostic  * Compare strings.
20*42150Sbostic  */
21*42150Sbostic int
221983Swnj strcmp(s1, s2)
23*42150Sbostic 	register const char *s1, *s2;
241983Swnj {
25*42150Sbostic 	while (*s1 == *s2++)
26*42150Sbostic 		if (*s1++ == 0)
27*42150Sbostic 			return (0);
28*42150Sbostic 	return (*(unsigned char *)s1 - *(unsigned char *)--s2);
291983Swnj }
30