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