home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / libF77 / s_cmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  400 b   |  33 lines

  1. int s_cmp(a, b, la, lb)    /* compare two strings */
  2. char *a, *b;
  3. long int la, lb;
  4. {
  5. char *aend, *bend;
  6. aend = a + la;
  7.  
  8. if(la <= lb)
  9.     {
  10.     while(a < aend)
  11.         if(*a != *b)
  12.             return( *a - *b );
  13.         else
  14.             { ++a; ++b; }
  15.  
  16.     }
  17.  
  18. else
  19.     {
  20.     bend = b + lb;
  21.     while(b < bend)
  22.         if(*a == *b)
  23.             { ++a; ++b; }
  24.         else
  25.             return( *a - *b );
  26.     while(a < aend)
  27.         if(*a != ' ')
  28.             return(*a - ' ');
  29.         else    ++a;
  30.     }
  31. return(0);
  32. }
  33.