1/* $NetBSD: urestubs.c,v 1.1.1.3 2010/12/12 15:22:07 adam Exp $ */ 2 3/* OpenLDAP: pkg/ldap/libraries/liblunicode/ure/urestubs.c,v 1.14.2.5 2010/04/13 20:23:04 kurt Exp */ 4/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 5 * 6 * Copyright 1998-2010 The OpenLDAP Foundation. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted only as authorized by the OpenLDAP 11 * Public License. 12 * 13 * A copy of this license is available in file LICENSE in the 14 * top-level directory of the distribution or, alternatively, at 15 * <http://www.OpenLDAP.org/license.html>. 16 */ 17/* 18 * Copyright 1997, 1998, 1999 Computing Research Labs, 19 * New Mexico State University 20 * 21 * Permission is hereby granted, free of charge, to any person obtaining a 22 * copy of this software and associated documentation files (the "Software"), 23 * to deal in the Software without restriction, including without limitation 24 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 25 * and/or sell copies of the Software, and to permit persons to whom the 26 * Software is furnished to do so, subject to the following conditions: 27 * 28 * The above copyright notice and this permission notice shall be included in 29 * all copies or substantial portions of the Software. 30 * 31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 34 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 35 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 36 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 37 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 */ 39/* Id: urestubs.c,v 1.2 1999/09/21 15:47:44 mleisher Exp" */ 40 41#include "portable.h" 42#include <ac/bytes.h> 43 44#include "ure.h" 45 46#ifdef _MSC_VER 47# include "../ucdata/ucdata.h" 48#else 49# include "ucdata.h" 50#endif 51 52/* 53 * This file contains stub routines needed by the URE package to test 54 * character properties and other Unicode implementation specific details. 55 */ 56 57/* 58 * This routine should return the lower case equivalent for the character or, 59 * if there is no lower case quivalent, the character itself. 60 */ 61ucs4_t _ure_tolower(ucs4_t c) 62{ 63 return uctoupper(c); 64} 65 66static struct ucmaskmap { 67 unsigned long mask1; 68 unsigned long mask2; 69} masks[32] = { 70 { UC_MN, 0 }, /* _URE_NONSPACING */ 71 { UC_MC, 0 }, /* _URE_COMBINING */ 72 { UC_ND, 0 }, /* _URE_NUMDIGIT */ 73 { UC_NL|UC_NO, 0 }, /* _URE_NUMOTHER */ 74 { UC_ZS, 0 }, /* _URE_SPACESEP */ 75 { UC_ZL, 0 }, /* _URE_LINESEP */ 76 { UC_ZP, 0 }, /* _URE_PARASEP */ 77 { UC_CC, 0 }, /* _URE_CNTRL */ 78 { UC_CO, 0 }, /* _URE_PUA */ 79 80 { UC_LU, 0 }, /* _URE_UPPER */ 81 { UC_LL, 0 }, /* _URE_LOWER */ 82 { UC_LT, 0 }, /* _URE_TITLE */ 83 { UC_LM, 0 }, /* _URE_MODIFIER */ 84 { UC_LO, 0 }, /* _URE_OTHERLETTER */ 85 { UC_PD, 0 }, /* _URE_DASHPUNCT */ 86 { UC_PS, 0 }, /* _URE_OPENPUNCT */ 87 { UC_PC, 0 }, /* _URE_CLOSEPUNCT */ 88 { UC_PO, 0 }, /* _URE_OTHERPUNCT */ 89 { UC_SM, 0 }, /* _URE_MATHSYM */ 90 { UC_SC, 0 }, /* _URE_CURRENCYSYM */ 91 { UC_SO, 0 }, /* _URE_OTHERSYM */ 92 93 { UC_L, 0 }, /* _URE_LTR */ 94 { UC_R, 0 }, /* _URE_RTL */ 95 96 { 0, UC_EN }, /* _URE_EURONUM */ 97 { 0, UC_ES }, /* _URE_EURONUMSEP */ 98 { 0, UC_ET }, /* _URE_EURONUMTERM */ 99 { 0, UC_AN }, /* _URE_ARABNUM */ 100 { 0, UC_CS }, /* _URE_COMMONSEP */ 101 102 { 0, UC_B }, /* _URE_BLOCKSEP */ 103 { 0, UC_S }, /* _URE_SEGMENTSEP */ 104 105 { 0, UC_WS }, /* _URE_WHITESPACE */ 106 { 0, UC_ON } /* _URE_OTHERNEUT */ 107}; 108 109 110/* 111 * This routine takes a set of URE character property flags (see ure.h) along 112 * with a character and tests to see if the character has one or more of those 113 * properties. 114 */ 115int 116_ure_matches_properties(unsigned long props, ucs4_t c) 117{ 118 int i; 119 unsigned long mask1=0, mask2=0; 120 121 for( i=0; i<32; i++ ) { 122 if( props & (1 << i) ) { 123 mask1 |= masks[i].mask1; 124 mask2 |= masks[i].mask2; 125 } 126 } 127 128 return ucisprop( mask1, mask2, c ); 129} 130