runetype.c revision 14811
111695Sache/*- 211695Sache * Copyright (c) 1993 311695Sache * The Regents of the University of California. All rights reserved. 411695Sache * 511695Sache * This code is derived from software contributed to Berkeley by 611695Sache * Paul Borman at Krystal Technologies. 711695Sache * 811695Sache * Redistribution and use in source and binary forms, with or without 911695Sache * modification, are permitted provided that the following conditions 1011695Sache * are met: 1111695Sache * 1. Redistributions of source code must retain the above copyright 1211695Sache * notice, this list of conditions and the following disclaimer. 1311695Sache * 2. Redistributions in binary form must reproduce the above copyright 1411695Sache * notice, this list of conditions and the following disclaimer in the 1511695Sache * documentation and/or other materials provided with the distribution. 1611695Sache * 3. All advertising materials mentioning features or use of this software 1711695Sache * must display the following acknowledgement: 1811695Sache * This product includes software developed by the University of 1911695Sache * California, Berkeley and its contributors. 2011695Sache * 4. Neither the name of the University nor the names of its contributors 2111695Sache * may be used to endorse or promote products derived from this software 2211695Sache * without specific prior written permission. 2311695Sache * 2411695Sache * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2511695Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2611695Sache * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2711695Sache * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2811695Sache * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2911695Sache * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3011695Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3111695Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3211695Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3311695Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3411695Sache * SUCH DAMAGE. 3511695Sache */ 3611695Sache 373050Sache#include <stdio.h> 383050Sache#include <rune.h> 393050Sache 403050Sacheunsigned long 413050Sache___runetype(c) 423050Sache _BSD_RUNE_T_ c; 433050Sache{ 4412022Sache#ifdef XPG4 453050Sache int x; 463050Sache _RuneRange *rr = &_CurrentRuneLocale->runetype_ext; 473050Sache _RuneEntry *re = rr->ranges; 483050Sache 4914811Sache if (c < 0 || c == EOF) 5014811Sache return(0L); 5112022Sache 523050Sache for (x = 0; x < rr->nranges; ++x, ++re) { 533050Sache if (c < re->min) 543050Sache return(0L); 553050Sache if (c <= re->max) { 563050Sache if (re->types) 573050Sache return(re->types[c - re->min]); 583050Sache else 593050Sache return(re->map); 603050Sache } 613050Sache } 6212022Sache#endif 633050Sache return(0L); 643050Sache} 653050Sache 66