1
/* $Xorg: Lower.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
5
Copyright 1988, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
29
/* $XFree86: xc/lib/Xmu/Lower.c,v 1.12 2001/12/14 19:55:47 dawes Exp $ */
32
#include <X11/keysymdef.h>
33
#include <X11/Xmu/CharSet.h>
34
#include <X11/Xmu/SysUtil.h>
47
* ISO Latin-1 case conversion routine
49
#define XmuTolower(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_Ooblique && (c) <= XK_Thorn ? \
54
(c) + (XK_oslash - XK_Ooblique) : \
57
#define XmuToupper(c) \
58
((c) >= XK_A && (c) <= XK_Z ? \
59
(c) : (c) >= XK_a && (c) <= XK_z ? \
60
(c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \
61
(c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \
62
(c) - (XK_oslash - XK_Ooblique) : \
69
XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
71
register unsigned char *dest, *source;
73
for (dest = (unsigned char *)dst, source = (unsigned char *)src;
76
*dest = XmuTolower(*source);
81
XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
83
register unsigned char *dest, *source;
85
for (dest = (unsigned char *)dst, source = (unsigned char *)src;
88
*dest = XmuToupper(*source);
93
XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
95
register unsigned char *ap, *bp;
97
for (ap = (unsigned char *)first, bp = (unsigned char *)second;
98
*ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
102
return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
106
XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
108
register unsigned char *dest, *source;
112
for (dest = (unsigned char *)dst, source = (unsigned char *)src;
114
source++, dest++, size--)
115
*dest = XmuTolower(*source);
121
XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
123
register unsigned char *dest, *source;
127
for (dest = (unsigned char *)dst, source = (unsigned char *)src;
129
source++, dest++, size--)
130
*dest = XmuToupper(*source);
136
XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
147
retval = vsprintf(str, fmt, ap);
150
fprintf(stderr, "WARNING: buffer overflow detected!\n");
155
retval = vsnprintf(str, size, fmt, ap);