Commit | Line | Data |
---|---|---|
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 | 11 | static char sccsid[] = "@(#)s_cmp.c 5.2 (Berkeley) 4/12/91"; |
82492b51 KB |
12 | #endif /* not lint */ |
13 | ||
13147d7f DW |
14 | int s_cmp(a, b, la, lb) /* compare two strings */ |
15 | register char *a, *b; | |
16 | long int la, lb; | |
17 | { | |
18 | register char *aend, *bend; | |
19 | aend = a + la; | |
20 | bend = b + lb; | |
21 | ||
22 | if(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 | ||
36 | else | |
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 | } | |
48 | return(0); | |
49 | } |