xref: /original-bsd/usr.bin/f77/libF77/s_cmp.c (revision bdc0a208)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)s_cmp.c	5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
11 
12 int s_cmp(a, b, la, lb)	/* compare two strings */
13 register char *a, *b;
14 long int la, lb;
15 {
16 register char *aend, *bend;
17 aend = a + la;
18 bend = b + lb;
19 
20 if(la <= lb)
21 	{
22 	while(a < aend)
23 		if(*a != *b)
24 			return( *a - *b );
25 		else
26 			{ ++a; ++b; }
27 
28 	while(b < bend)
29 		if(*b != ' ')
30 			return( ' ' - *b );
31 		else	++b;
32 	}
33 
34 else
35 	{
36 	while(b < bend)
37 		if(*a == *b)
38 			{ ++a; ++b; }
39 		else
40 			return( *a - *b );
41 	while(a < aend)
42 		if(*a != ' ')
43 			return(*a - ' ');
44 		else	++a;
45 	}
46 return(0);
47 }
48