1 /****************************************************************
2 Copyright 1990 - 1997 by AT&T, Lucent Technologies and Bellcore.
3 
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both that the copyright notice and this
8 permission notice and warranty disclaimer appear in supporting
9 documentation, and that the names of AT&T, Bell Laboratories,
10 Lucent or Bellcore or any of their entities not be used in
11 advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
13 
14 AT&T, Lucent and Bellcore disclaim all warranties with regard to
15 this software, including all implied warranties of
16 merchantability and fitness.  In no event shall AT&T, Lucent or
17 Bellcore be liable for any special, indirect or consequential
18 damages or any damages whatsoever resulting from loss of use,
19 data or profits, whether in an action of contract, negligence or
20 other tortious action, arising out of or in connection with the
21 use or performance of this software.
22 ****************************************************************/
23 
24 #include "f2c.h"
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29     /* compare two strings */
s_cmp(const char * a0,const char * b0,ftnlen la,ftnlen lb)30     integer s_cmp(const char *a0, const char *b0, ftnlen la, ftnlen lb)
31     {
32         register unsigned char *a, *aend, *b, *bend;
33         a = (unsigned char *)a0;
34         b = (unsigned char *)b0;
35         aend = a + la;
36         bend = b + lb;
37 
38         if(la <= lb)
39         {
40             while(a < aend)
41                 if(*a != *b)
42                     return( *a - *b );
43                 else
44                 {
45                     ++a;
46                     ++b;
47                 }
48 
49             while(b < bend)
50                 if(*b != ' ')
51                     return( ' ' - *b );
52                 else	++b;
53         }
54         else
55         {
56             while(b < bend)
57                 if(*a == *b)
58                 {
59                     ++a;
60                     ++b;
61                 }
62                 else
63                     return( *a - *b );
64             while(a < aend)
65                 if(*a != ' ')
66                     return(*a - ' ');
67                 else	++a;
68         }
69         return(0);
70     }
71 
72 #ifdef __cplusplus
73 }
74 #endif
75