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