Mercurial > hg > qm-dsp
comparison ext/clapack/src/s_cmp.c @ 430:335af74a25b6
Merge from branch clapack-included
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 30 Sep 2016 16:24:24 +0100 |
parents | 905e45637745 |
children |
comparison
equal
deleted
inserted
replaced
426:a23b9f8b4a59 | 430:335af74a25b6 |
---|---|
1 #include "f2c.h" | |
2 #ifdef __cplusplus | |
3 extern "C" { | |
4 #endif | |
5 | |
6 /* compare two strings */ | |
7 | |
8 #ifdef KR_headers | |
9 integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb; | |
10 #else | |
11 integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb) | |
12 #endif | |
13 { | |
14 register unsigned char *a, *aend, *b, *bend; | |
15 a = (unsigned char *)a0; | |
16 b = (unsigned char *)b0; | |
17 aend = a + la; | |
18 bend = b + lb; | |
19 | |
20 if(la <= lb) | |
21 { | |
22 while(a < aend) | |
23 if(*a != *b) | |
24 return( *a - *b ); | |
25 else | |
26 { ++a; ++b; } | |
27 | |
28 while(b < bend) | |
29 if(*b != ' ') | |
30 return( ' ' - *b ); | |
31 else ++b; | |
32 } | |
33 | |
34 else | |
35 { | |
36 while(b < bend) | |
37 if(*a == *b) | |
38 { ++a; ++b; } | |
39 else | |
40 return( *a - *b ); | |
41 while(a < aend) | |
42 if(*a != ' ') | |
43 return(*a - ' '); | |
44 else ++a; | |
45 } | |
46 return(0); | |
47 } | |
48 #ifdef __cplusplus | |
49 } | |
50 #endif |