|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1988, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define XK_LATIN1
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <X11/keysymdef.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/CharSet.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/SysUtil.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#include <stdio.h>
|
|
Packit Service |
2b1f13 |
#include <stdarg.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* ISO Latin-1 case conversion routine
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
#define XmuTolower(c) \
|
|
Packit Service |
2b1f13 |
((c) >= XK_a && (c) <= XK_z ? \
|
|
Packit Service |
2b1f13 |
(c) : (c) >= XK_A && (c) <= XK_Z ? \
|
|
Packit Service |
2b1f13 |
(c) + (XK_a - XK_A) : (c) >= XK_Agrave && (c) <= XK_Odiaeresis ? \
|
|
Packit Service |
2b1f13 |
(c) + (XK_agrave - XK_Agrave) : (c) >= XK_Ooblique && (c) <= XK_Thorn ? \
|
|
Packit Service |
2b1f13 |
(c) + (XK_oslash - XK_Ooblique) : \
|
|
Packit Service |
2b1f13 |
(c))
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define XmuToupper(c) \
|
|
Packit Service |
2b1f13 |
((c) >= XK_A && (c) <= XK_Z ? \
|
|
Packit Service |
2b1f13 |
(c) : (c) >= XK_a && (c) <= XK_z ? \
|
|
Packit Service |
2b1f13 |
(c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \
|
|
Packit Service |
2b1f13 |
(c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \
|
|
Packit Service |
2b1f13 |
(c) - (XK_oslash - XK_Ooblique) : \
|
|
Packit Service |
2b1f13 |
(c))
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Implementation
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char *dest;
|
|
Packit Service |
2b1f13 |
_Xconst unsigned char *source;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
|
|
Packit Service |
2b1f13 |
*source;
|
|
Packit Service |
2b1f13 |
source++, dest++)
|
|
Packit Service |
2b1f13 |
*dest = XmuTolower(*source);
|
|
Packit Service |
2b1f13 |
*dest = '\0';
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char *dest;
|
|
Packit Service |
2b1f13 |
_Xconst unsigned char *source;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
|
|
Packit Service |
2b1f13 |
*source;
|
|
Packit Service |
2b1f13 |
source++, dest++)
|
|
Packit Service |
2b1f13 |
*dest = XmuToupper(*source);
|
|
Packit Service |
2b1f13 |
*dest = '\0';
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
int
|
|
Packit Service |
2b1f13 |
XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_Xconst unsigned char *ap, *bp;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (ap = (_Xconst unsigned char *)first, bp = (_Xconst unsigned char *)second;
|
|
Packit Service |
2b1f13 |
*ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
|
|
Packit Service |
2b1f13 |
ap++, bp++)
|
|
Packit Service |
2b1f13 |
;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char *dest;
|
|
Packit Service |
2b1f13 |
_Xconst unsigned char *source;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (size > 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
for (dest = (unsigned char *)dst, source = (_Xconst unsigned char *)src;
|
|
Packit Service |
2b1f13 |
*source && size > 1;
|
|
Packit Service |
2b1f13 |
source++, dest++, size--)
|
|
Packit Service |
2b1f13 |
*dest = XmuTolower(*source);
|
|
Packit Service |
2b1f13 |
*dest = '\0';
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char *dest;
|
|
Packit Service |
2b1f13 |
_Xconst unsigned char *source;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (size > 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
for (dest = (unsigned char *)dst, source = ( _Xconst unsigned char *)src;
|
|
Packit Service |
2b1f13 |
*source && size > 1;
|
|
Packit Service |
2b1f13 |
source++, dest++, size--)
|
|
Packit Service |
2b1f13 |
*dest = XmuToupper(*source);
|
|
Packit Service |
2b1f13 |
*dest = '\0';
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
int
|
|
Packit Service |
2b1f13 |
XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
va_list ap;
|
|
Packit Service |
2b1f13 |
int retval;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (size <= 0)
|
|
Packit Service |
2b1f13 |
return (size);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
va_start(ap, fmt);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#if 0
|
|
Packit Service |
2b1f13 |
retval = vsprintf(str, fmt, ap);
|
|
Packit Service |
2b1f13 |
if (retval >= size)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
fprintf(stderr, "WARNING: buffer overflow detected!\n");
|
|
Packit Service |
2b1f13 |
fflush(stderr);
|
|
Packit Service |
2b1f13 |
abort();
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
#else
|
|
Packit Service |
2b1f13 |
retval = vsnprintf(str, size, fmt, ap);
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
va_end(ap);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (retval);
|
|
Packit Service |
2b1f13 |
}
|