_fallcUtil.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* lcUtil.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:42 */
  24. /* $XConsortium: _fallcUtil.c /main/1 1996/04/08 15:19:43 cde-fuj $ */
  25. /*
  26. * Copyright 1992, 1993 by TOSHIBA Corp.
  27. *
  28. * Permission to use, copy, modify, and distribute this software and its
  29. * documentation for any purpose and without fee is hereby granted, provided
  30. * that the above copyright notice appear in all copies and that both that
  31. * copyright notice and this permission notice appear in supporting
  32. * documentation, and that the name of TOSHIBA not be used in advertising
  33. * or publicity pertaining to distribution of the software without specific,
  34. * written prior permission. TOSHIBA make no representations about the
  35. * suitability of this software for any purpose. It is provided "as is"
  36. * without express or implied warranty.
  37. *
  38. * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  39. * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  40. * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  41. * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  42. * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  43. * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  44. * SOFTWARE.
  45. *
  46. * Author: Katsuhisa Yano TOSHIBA Corp.
  47. * mopi@osa.ilab.toshiba.co.jp
  48. */
  49. #include <stdio.h>
  50. #include <ctype.h>
  51. #include <X11/Xos.h>
  52. #include "_fallibint.h"
  53. #ifdef X_NOT_STDC_ENV
  54. #ifndef toupper
  55. #define toupper(c) ((int)(c) - 'a' + 'A')
  56. #endif
  57. #endif
  58. int
  59. _fallcCompareISOLatin1(char *str1, char *str2)
  60. {
  61. char ch1, ch2;
  62. for ( ; (ch1 = *str1) && (ch2 = *str2); str1++, str2++) {
  63. if (islower(ch1))
  64. ch1 = toupper(ch1);
  65. if (islower(ch2))
  66. ch2 = toupper(ch2);
  67. if (ch1 != ch2)
  68. break;
  69. }
  70. return *str1 - *str2;
  71. }
  72. int
  73. _fallcNCompareISOLatin1(char *str1, char *str2, int len)
  74. {
  75. char ch1, ch2;
  76. for ( ; (ch1 = *str1) && (ch2 = *str2) && len; str1++, str2++, len--) {
  77. if (islower(ch1))
  78. ch1 = toupper(ch1);
  79. if (islower(ch2))
  80. ch2 = toupper(ch2);
  81. if (ch1 != ch2)
  82. break;
  83. }
  84. if (len == 0)
  85. return 0;
  86. return *str1 - *str2;
  87. }