runetype.c revision 11695
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{ 443050Sache int x; 453050Sache _RuneRange *rr = &_CurrentRuneLocale->runetype_ext; 463050Sache _RuneEntry *re = rr->ranges; 473050Sache 483050Sache if (c == EOF) 493050Sache return(0); 503050Sache for (x = 0; x < rr->nranges; ++x, ++re) { 513050Sache if (c < re->min) 523050Sache return(0L); 533050Sache if (c <= re->max) { 543050Sache if (re->types) 553050Sache return(re->types[c - re->min]); 563050Sache else 573050Sache return(re->map); 583050Sache } 593050Sache } 603050Sache return(0L); 613050Sache} 623050Sache 63