Pristine Ack-5.5
[Ack-5.5.git] / lang / fortran / lib / libF77 / s_cmp.c
1 #include "f2c.h"
2
3 integer s_cmp(a, b, la, lb)     /* compare two strings */
4 register char *a, *b;
5 long int la, lb;
6 {
7 register char *aend, *bend;
8 aend = a + la;
9 bend = b + lb;
10
11 if(la <= lb)
12         {
13         while(a < aend)
14                 if(*a != *b)
15                         return( *a - *b );
16                 else
17                         { ++a; ++b; }
18
19         while(b < bend)
20                 if(*b != ' ')
21                         return( ' ' - *b );
22                 else    ++b;
23         }
24
25 else
26         {
27         while(b < bend)
28                 if(*a == *b)
29                         { ++a; ++b; }
30                 else
31                         return( *a - *b );
32         while(a < aend)
33                 if(*a != ' ')
34                         return(*a - ' ');
35                 else    ++a;
36         }
37 return(0);
38 }