xref: /csrg-svn/games/monop/strcmp.c (revision 32259)
1*32259Sbostic # include	<stdio.h>
2*32259Sbostic # include	<ctype.h>
3*32259Sbostic 
4*32259Sbostic # define	reg	register
5*32259Sbostic 
6*32259Sbostic # define	makelower(c)	(isupper(c) ? tolower(c) : c)
7*32259Sbostic 
8*32259Sbostic /*
9*32259Sbostic  * Compare strings:  s1>s2: >0  s1==s2: 0  s1<s2: <0
10*32259Sbostic  */
11*32259Sbostic 
strcmp(s1,s2)12*32259Sbostic strcmp(s1, s2)
13*32259Sbostic reg char	*s1, *s2; {
14*32259Sbostic 
15*32259Sbostic 	while (makelower(*s1) == makelower(*s2)) {
16*32259Sbostic 		if (*s1 == '\0')
17*32259Sbostic 			return 0;
18*32259Sbostic 		s1++, s2++;
19*32259Sbostic 	}
20*32259Sbostic 	return *s1 - *s2;
21*32259Sbostic }
22