1 /* lsame.f -- translated by f2c (version 20100827). 2 You must link the resulting object file with libf2c: 3 on Microsoft Windows system, link with libf2c.lib; 4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 5 or, if you install libf2c.a in a standard place, with -lf2c -lm 6 -- in that order, at the end of the command line, as in 7 cc *.o -lf2c -lm 8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 9 10 http://www.netlib.org/f2c/libf2c.zip 11 */ 12 13 #include "datatypes.h" 14 15 logical lsame_(char *ca, char *cb, ftnlen ca_len, ftnlen cb_len) 16 { 17 /* System generated locals */ 18 logical ret_val; 19 20 /* Local variables */ 21 integer inta, intb, zcode; 22 23 24 /* -- LAPACK auxiliary routine (version 3.1) -- */ 25 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 26 /* November 2006 */ 27 28 /* .. Scalar Arguments .. */ 29 /* .. */ 30 31 /* Purpose */ 32 /* ======= */ 33 34 /* LSAME returns .TRUE. if CA is the same letter as CB regardless of */ 35 /* case. */ 36 37 /* Arguments */ 38 /* ========= */ 39 40 /* CA (input) CHARACTER*1 */ 41 42 /* CB (input) CHARACTER*1 */ 43 /* CA and CB specify the single characters to be compared. */ 44 45 /* ===================================================================== */ 46 47 /* .. Intrinsic Functions .. */ 48 /* .. */ 49 /* .. Local Scalars .. */ 50 /* .. */ 51 52 /* Test if the characters are equal */ 53 54 ret_val = *(unsigned char *)ca == *(unsigned char *)cb; 55 if (ret_val) { 56 return ret_val; 57 } 58 59 /* Now test for equivalence if both characters are alphabetic. */ 60 61 zcode = 'Z'; 62 63 /* Use 'Z' rather than 'A' so that ASCII can be detected on Prime */ 64 /* machines, on which ICHAR returns a value with bit 8 set. */ 65 /* ICHAR('A') on Prime machines returns 193 which is the same as */ 66 /* ICHAR('A') on an EBCDIC machine. */ 67 68 inta = *(unsigned char *)ca; 69 intb = *(unsigned char *)cb; 70 71 if (zcode == 90 || zcode == 122) { 72 73 /* ASCII is assumed - ZCODE is the ASCII code of either lower or */ 74 /* upper case 'Z'. */ 75 76 if (inta >= 97 && inta <= 122) { 77 inta += -32; 78 } 79 if (intb >= 97 && intb <= 122) { 80 intb += -32; 81 } 82 83 } else if (zcode == 233 || zcode == 169) { 84 85 /* EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or */ 86 /* upper case 'Z'. */ 87 88 if ((inta >= 129 && inta <= 137) || (inta >= 145 && inta <= 153) || 89 (inta >= 162 && inta <= 169)) { 90 inta += 64; 91 } 92 if ((intb >= 129 && intb <= 137) || (intb >= 145 && intb <= 153) || 93 (intb >= 162 && intb <= 169)) { 94 intb += 64; 95 } 96 97 } else if (zcode == 218 || zcode == 250) { 98 99 /* ASCII is assumed, on Prime machines - ZCODE is the ASCII code */ 100 /* plus 128 of either lower or upper case 'Z'. */ 101 102 if (inta >= 225 && inta <= 250) { 103 inta += -32; 104 } 105 if (intb >= 225 && intb <= 250) { 106 intb += -32; 107 } 108 } 109 ret_val = inta == intb; 110 111 /* RETURN */ 112 113 /* End of LSAME */ 114 115 return ret_val; 116 } /* lsame_ */ 117 118