You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.9 KiB

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