lsame.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* lsame.f -- translated by f2c (version 20061008).
  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. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. logical lsame_(char *ca, char *cb)
  14. {
  15. /* System generated locals */
  16. logical ret_val;
  17. /* Local variables */
  18. integer inta, intb, zcode;
  19. /* -- LAPACK auxiliary routine (version 3.1) -- */
  20. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  21. /* November 2006 */
  22. /* .. Scalar Arguments .. */
  23. /* .. */
  24. /* Purpose */
  25. /* ======= */
  26. /* LSAME returns .TRUE. if CA is the same letter as CB regardless of */
  27. /* case. */
  28. /* Arguments */
  29. /* ========= */
  30. /* CA (input) CHARACTER*1 */
  31. /* CB (input) CHARACTER*1 */
  32. /* CA and CB specify the single characters to be compared. */
  33. /* ===================================================================== */
  34. /* .. Intrinsic Functions .. */
  35. /* .. */
  36. /* .. Local Scalars .. */
  37. /* .. */
  38. /* Test if the characters are equal */
  39. ret_val = *(unsigned char *)ca == *(unsigned char *)cb;
  40. if (ret_val) {
  41. return ret_val;
  42. }
  43. /* Now test for equivalence if both characters are alphabetic. */
  44. zcode = 'Z';
  45. /* Use 'Z' rather than 'A' so that ASCII can be detected on Prime */
  46. /* machines, on which ICHAR returns a value with bit 8 set. */
  47. /* ICHAR('A') on Prime machines returns 193 which is the same as */
  48. /* ICHAR('A') on an EBCDIC machine. */
  49. inta = *(unsigned char *)ca;
  50. intb = *(unsigned char *)cb;
  51. if (zcode == 90 || zcode == 122) {
  52. /* ASCII is assumed - ZCODE is the ASCII code of either lower or */
  53. /* upper case 'Z'. */
  54. if (inta >= 97 && inta <= 122) {
  55. inta += -32;
  56. }
  57. if (intb >= 97 && intb <= 122) {
  58. intb += -32;
  59. }
  60. } else if (zcode == 233 || zcode == 169) {
  61. /* EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or */
  62. /* upper case 'Z'. */
  63. if (inta >= 129 && inta <= 137 || inta >= 145 && inta <= 153 || inta
  64. >= 162 && inta <= 169) {
  65. inta += 64;
  66. }
  67. if (intb >= 129 && intb <= 137 || intb >= 145 && intb <= 153 || intb
  68. >= 162 && intb <= 169) {
  69. intb += 64;
  70. }
  71. } else if (zcode == 218 || zcode == 250) {
  72. /* ASCII is assumed, on Prime machines - ZCODE is the ASCII code */
  73. /* plus 128 of either lower or upper case 'Z'. */
  74. if (inta >= 225 && inta <= 250) {
  75. inta += -32;
  76. }
  77. if (intb >= 225 && intb <= 250) {
  78. intb += -32;
  79. }
  80. }
  81. ret_val = inta == intb;
  82. /* RETURN */
  83. /* End of LSAME */
  84. return ret_val;
  85. } /* lsame_ */