lsame.cpp 2.6 KB

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