2001-08-03 Daniel Berlin <dan@cgsoftware.com>
[official-gcc.git] / libf2c / libF77 / s_cmp.c
blob1e052f28642612703ce669a92dbf28fa922c3115
1 #include "f2c.h"
3 /* compare two strings */
5 #ifdef KR_headers
6 integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb;
7 #else
8 integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb)
9 #endif
11 register unsigned char *a, *aend, *b, *bend;
12 a = (unsigned char *)a0;
13 b = (unsigned char *)b0;
14 aend = a + la;
15 bend = b + lb;
17 if(la <= lb)
19 while(a < aend)
20 if(*a != *b)
21 return( *a - *b );
22 else
23 { ++a; ++b; }
25 while(b < bend)
26 if(*b != ' ')
27 return( ' ' - *b );
28 else ++b;
31 else
33 while(b < bend)
34 if(*a == *b)
35 { ++a; ++b; }
36 else
37 return( *a - *b );
38 while(a < aend)
39 if(*a != ' ')
40 return(*a - ' ');
41 else ++a;
43 return(0);