miscutil.c revision 23a0898a
123a0898aSmrg/* $Xorg: miscutil.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */ 223a0898aSmrg 323a0898aSmrg/* 423a0898aSmrg 523a0898aSmrgCopyright 1991, 1994, 1998 The Open Group 623a0898aSmrg 723a0898aSmrgPermission to use, copy, modify, distribute, and sell this software and its 823a0898aSmrgdocumentation for any purpose is hereby granted without fee, provided that 923a0898aSmrgthe above copyright notice appear in all copies and that both that 1023a0898aSmrgcopyright notice and this permission notice appear in supporting 1123a0898aSmrgdocumentation. 1223a0898aSmrg 1323a0898aSmrgThe above copyright notice and this permission notice shall be included 1423a0898aSmrgin all copies or substantial portions of the Software. 1523a0898aSmrg 1623a0898aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1723a0898aSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1823a0898aSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1923a0898aSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 2023a0898aSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2123a0898aSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2223a0898aSmrgOTHER DEALINGS IN THE SOFTWARE. 2323a0898aSmrg 2423a0898aSmrgExcept as contained in this notice, the name of The Open Group shall 2523a0898aSmrgnot be used in advertising or otherwise to promote the sale, use or 2623a0898aSmrgother dealings in this Software without prior written authorization 2723a0898aSmrgfrom The Open Group. 2823a0898aSmrg 2923a0898aSmrg*/ 3023a0898aSmrg/* $XFree86: xc/lib/font/util/miscutil.c,v 1.7 2001/07/25 15:04:57 dawes Exp $ */ 3123a0898aSmrg 3223a0898aSmrg#ifdef HAVE_CONFIG_H 3323a0898aSmrg#include <config.h> 3423a0898aSmrg#endif 3523a0898aSmrg#include <X11/Xosdefs.h> 3623a0898aSmrg#include <stdlib.h> 3723a0898aSmrg#include <X11/fonts/fontmisc.h> 3823a0898aSmrg#include "stubs.h" 3923a0898aSmrg 4023a0898aSmrg#define XK_LATIN1 4123a0898aSmrg#include <X11/keysymdef.h> 4223a0898aSmrg 4323a0898aSmrg 4423a0898aSmrg#ifdef __SUNPRO_C 4523a0898aSmrg#pragma weak serverGeneration 4623a0898aSmrg#pragma weak Xalloc 4723a0898aSmrg#pragma weak Xrealloc 4823a0898aSmrg#pragma weak Xfree 4923a0898aSmrg#pragma weak Xcalloc 5023a0898aSmrg#pragma weak CopyISOLatin1Lowered 5123a0898aSmrg#pragma weak register_fpe_functions 5223a0898aSmrg#endif 5323a0898aSmrg 5423a0898aSmrg/* make sure everything initializes themselves at least once */ 5523a0898aSmrgweak long serverGeneration = 1; 5623a0898aSmrg 5723a0898aSmrgweak void * 5823a0898aSmrgXalloc (unsigned long m) 5923a0898aSmrg{ 6023a0898aSmrg return malloc (m); 6123a0898aSmrg} 6223a0898aSmrg 6323a0898aSmrgweak void * 6423a0898aSmrgXrealloc (void *n, unsigned long m) 6523a0898aSmrg{ 6623a0898aSmrg if (!n) 6723a0898aSmrg return malloc (m); 6823a0898aSmrg else 6923a0898aSmrg return realloc (n, m); 7023a0898aSmrg} 7123a0898aSmrg 7223a0898aSmrgweak void 7323a0898aSmrgXfree (void *n) 7423a0898aSmrg{ 7523a0898aSmrg if (n) 7623a0898aSmrg free (n); 7723a0898aSmrg} 7823a0898aSmrg 7923a0898aSmrgweak void * 8023a0898aSmrgXcalloc (unsigned long n) 8123a0898aSmrg{ 8223a0898aSmrg return calloc (n, 1); 8323a0898aSmrg} 8423a0898aSmrg 8523a0898aSmrgweak void 8623a0898aSmrgCopyISOLatin1Lowered (char *dst, char *src, int len) 8723a0898aSmrg{ 8823a0898aSmrg register unsigned char *dest, *source; 8923a0898aSmrg 9023a0898aSmrg for (dest = (unsigned char *)dst, source = (unsigned char *)src; 9123a0898aSmrg *source && len > 0; 9223a0898aSmrg source++, dest++, len--) 9323a0898aSmrg { 9423a0898aSmrg if ((*source >= XK_A) && (*source <= XK_Z)) 9523a0898aSmrg *dest = *source + (XK_a - XK_A); 9623a0898aSmrg else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis)) 9723a0898aSmrg *dest = *source + (XK_agrave - XK_Agrave); 9823a0898aSmrg else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn)) 9923a0898aSmrg *dest = *source + (XK_oslash - XK_Ooblique); 10023a0898aSmrg else 10123a0898aSmrg *dest = *source; 10223a0898aSmrg } 10323a0898aSmrg *dest = '\0'; 10423a0898aSmrg} 10523a0898aSmrg 10623a0898aSmrgweak void 10723a0898aSmrgregister_fpe_functions () 10823a0898aSmrg{ 10923a0898aSmrg} 110