| 1 |
/* |
| 2 |
* Copyright 1992, 1993 by TOSHIBA Corp. |
| 3 |
* |
| 4 |
* Permission to use, copy, modify, and distribute this software and its |
| 5 |
* documentation for any purpose and without fee is hereby granted, provided |
| 6 |
* that the above copyright notice appear in all copies and that both that |
| 7 |
* copyright notice and this permission notice appear in supporting |
| 8 |
* documentation, and that the name of TOSHIBA not be used in advertising |
| 9 |
* or publicity pertaining to distribution of the software without specific, |
| 10 |
* written prior permission. TOSHIBA make no representations about the |
| 11 |
* suitability of this software for any purpose. It is provided "as is" |
| 12 |
* without express or implied warranty. |
| 13 |
* |
| 14 |
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
| 15 |
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL |
| 16 |
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR |
| 17 |
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 18 |
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 19 |
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 20 |
* SOFTWARE. |
| 21 |
* |
| 22 |
* Author: Katsuhisa Yano TOSHIBA Corp. |
| 23 |
* [email protected] |
| 24 |
* Bug fixes: Bruno Haible XFree86 Inc. |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifdef HAVE_CONFIG_H |
| 28 |
#include <config.h> |
| 29 |
#endif |
| 30 |
#include <nx-X11/Xlib.h> |
| 31 |
#include "XlcPublic.h" |
| 32 |
|
| 33 |
/* Don't use <ctype.h> here because it is locale dependent. */ |
| 34 |
|
| 35 |
#define set_toupper(ch) \ |
| 36 |
if (ch >= 'a' && ch <= 'z') \ |
| 37 |
ch = (unsigned char) (ch - 'a' + 'A'); |
| 38 |
|
| 39 |
/* Compares two ISO 8859-1 strings, ignoring case of ASCII letters. |
| 40 |
Like strcasecmp in an ASCII locale. */ |
| 41 |
int |
| 42 |
_XlcCompareISOLatin1( |
| 43 |
const char *str1, |
| 44 |
const char *str2) |
| 45 |
{ |
| 46 |
unsigned char ch1, ch2; |
| 47 |
|
| 48 |
for ( ; ; str1++, str2++) { |
| 49 |
ch1 = (unsigned char) *str1; |
| 50 |
ch2 = (unsigned char) *str2; |
| 51 |
if (ch1 == '\0' || ch2 == '\0') |
| 52 |
break; |
| 53 |
set_toupper(ch1); |
| 54 |
set_toupper(ch2); |
| 55 |
if (ch1 != ch2) |
| 56 |
break; |
| 57 |
} |
| 58 |
|
| 59 |
return ch1 - ch2; |
| 60 |
} |
| 61 |
|
| 62 |
/* Compares two ISO 8859-1 strings, at most len bytes of each, ignoring |
| 63 |
case of ASCII letters. Like strncasecmp in an ASCII locale. */ |
| 64 |
int |
| 65 |
_XlcNCompareISOLatin1( |
| 66 |
const char *str1, |
| 67 |
const char *str2, |
| 68 |
int len) |
| 69 |
{ |
| 70 |
unsigned char ch1, ch2; |
| 71 |
|
| 72 |
for ( ; ; str1++, str2++, len--) { |
| 73 |
if (len == 0) |
| 74 |
return 0; |
| 75 |
ch1 = (unsigned char) *str1; |
| 76 |
ch2 = (unsigned char) *str2; |
| 77 |
if (ch1 == '\0' || ch2 == '\0') |
| 78 |
break; |
| 79 |
set_toupper(ch1); |
| 80 |
set_toupper(ch2); |
| 81 |
if (ch1 != ch2) |
| 82 |
break; |
| 83 |
} |
| 84 |
|
| 85 |
return ch1 - ch2; |
| 86 |
} |