BSD 4_4 release
[unix-history] / usr / src / usr.bin / f77 / libF77 / s_cmp.c
CommitLineData
82492b51
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
20af3163 4 *
ad787160
C
5 * This module is believed to contain source code proprietary to AT&T.
6 * Use and redistribution is subject to the Berkeley Software License
7 * Agreement and your Software Agreement with AT&T (Western Electric).
13147d7f
DW
8 */
9
82492b51 10#ifndef lint
ad787160 11static char sccsid[] = "@(#)s_cmp.c 5.2 (Berkeley) 4/12/91";
82492b51
KB
12#endif /* not lint */
13
13147d7f
DW
14int s_cmp(a, b, la, lb) /* compare two strings */
15register char *a, *b;
16long int la, lb;
17{
18register char *aend, *bend;
19aend = a + la;
20bend = b + lb;
21
22if(la <= lb)
23 {
24 while(a < aend)
25 if(*a != *b)
26 return( *a - *b );
27 else
28 { ++a; ++b; }
29
30 while(b < bend)
31 if(*b != ' ')
32 return( ' ' - *b );
33 else ++b;
34 }
35
36else
37 {
38 while(b < bend)
39 if(*a == *b)
40 { ++a; ++b; }
41 else
42 return( *a - *b );
43 while(a < aend)
44 if(*a != ' ')
45 return(*a - ' ');
46 else ++a;
47 }
48return(0);
49}