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)
63 register unsigned char *dest, *source;
65 for (dest = (unsigned char *)dst, source = (unsigned char *)src;
68 *dest = XmuTolower(*source);
73 XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
75 register unsigned char *dest, *source;
77 for (dest = (unsigned char *)dst, source = (unsigned char *)src;
80 *dest = XmuToupper(*source);
85 XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
87 register unsigned char *ap, *bp;
89 for (ap = (unsigned char *)first, bp = (unsigned char *)second;
90 *ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
94 return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
98 XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
100 register unsigned char *dest, *source;
104 for (dest = (unsigned char *)dst, source = (unsigned char *)src;
106 source++, dest++, size--)
107 *dest = XmuTolower(*source);
113 XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
115 register unsigned char *dest, *source;
119 for (dest = (unsigned char *)dst, source = (unsigned char *)src;
121 source++, dest++, size--)
122 *dest = XmuToupper(*source);
128 XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
139 retval = vsprintf(str, fmt, ap);
142 fprintf(stderr, "WARNING: buffer overflow detected!\n");
147 retval = vsnprintf(str, size, fmt, ap);