3 Copyright 1988, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
31 #include <X11/keysymdef.h>
32 #include <X11/Xmu/CharSet.h>
33 #include <X11/Xmu/SysUtil.h>
39 * ISO Latin-1 case conversion routine
41 #define XmuTolower(c) \
42 ((c) >= XK_a && (c) <= XK_z ? \
43 (c) : (c) >= XK_A && (c) <= XK_Z ? \
44 (c) + (XK_a - XK_A) : (c) >= XK_Agrave && (c) <= XK_Odiaeresis ? \
45 (c) + (XK_agrave - XK_Agrave) : (c) >= XK_Ooblique && (c) <= XK_Thorn ? \
46 (c) + (XK_oslash - XK_Ooblique) : \
49 #define XmuToupper(c) \
50 ((c) >= XK_A && (c) <= XK_Z ? \
51 (c) : (c) >= XK_a && (c) <= XK_z ? \
52 (c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \
53 (c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \
54 (c) - (XK_oslash - XK_Ooblique) : \
61 XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
64 _Xconst unsigned char *source;
66 for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
69 *dest = XmuTolower(*source);
74 XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
77 _Xconst unsigned char *source;
79 for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
82 *dest = XmuToupper(*source);
87 XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
89 _Xconst unsigned char *ap, *bp;
91 for (ap = (_Xconst unsigned char *)first, bp = (_Xconst unsigned char *)second;
92 *ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
96 return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
100 XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
103 _Xconst unsigned char *source;
107 for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
109 source++, dest++, size--)
110 *dest = XmuTolower(*source);
116 XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
119 _Xconst unsigned char *source;
123 for (dest = (unsigned char *)dst, source = ( _Xconst unsigned char *)src;
125 source++, dest++, size--)
126 *dest = XmuToupper(*source);
132 XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
143 retval = vsprintf(str, fmt, ap);
146 fprintf(stderr, "WARNING: buffer overflow detected!\n");
151 retval = vsnprintf(str, size, fmt, ap);