Back to index

openldap  2.4.31
urestubs.c
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 /*
00016  * Copyright 1997, 1998, 1999 Computing Research Labs,
00017  * New Mexico State University
00018  *
00019  * Permission is hereby granted, free of charge, to any person obtaining a
00020  * copy of this software and associated documentation files (the "Software"),
00021  * to deal in the Software without restriction, including without limitation
00022  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00023  * and/or sell copies of the Software, and to permit persons to whom the
00024  * Software is furnished to do so, subject to the following conditions:
00025  *
00026  * The above copyright notice and this permission notice shall be included in
00027  * all copies or substantial portions of the Software.
00028  *
00029  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00030  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00031  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00032  * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
00033  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00034  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00035  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00036  */
00037 /* $Id: urestubs.c,v 1.2 1999/09/21 15:47:44 mleisher Exp $" */
00038 
00039 #include "portable.h"
00040 #include <ac/bytes.h>
00041 
00042 #include "ure.h"
00043 
00044 #ifdef _MSC_VER
00045 #  include "../ucdata/ucdata.h"
00046 #else
00047 #  include "ucdata.h"
00048 #endif
00049 
00050 /*
00051  * This file contains stub routines needed by the URE package to test
00052  * character properties and other Unicode implementation specific details.
00053  */
00054 
00055 /*
00056  * This routine should return the lower case equivalent for the character or,
00057  * if there is no lower case quivalent, the character itself.
00058  */
00059 ucs4_t _ure_tolower(ucs4_t c)
00060 {
00061     return uctoupper(c);
00062 }
00063 
00064 static struct ucmaskmap {
00065        unsigned long mask1;
00066        unsigned long mask2;
00067 } masks[32] = {
00068        { UC_MN, 0 }, /* _URE_NONSPACING */
00069        { UC_MC, 0 }, /* _URE_COMBINING */
00070        { UC_ND, 0 }, /* _URE_NUMDIGIT */
00071        { UC_NL|UC_NO, 0 },  /* _URE_NUMOTHER */
00072        { UC_ZS, 0 }, /* _URE_SPACESEP */
00073        { UC_ZL, 0 }, /* _URE_LINESEP */
00074        { UC_ZP, 0 }, /* _URE_PARASEP */
00075        { UC_CC, 0 }, /* _URE_CNTRL */
00076        { UC_CO, 0 }, /* _URE_PUA */
00077 
00078        { UC_LU, 0 }, /* _URE_UPPER */
00079        { UC_LL, 0 }, /* _URE_LOWER */
00080        { UC_LT, 0 }, /* _URE_TITLE */
00081        { UC_LM, 0 }, /* _URE_MODIFIER */
00082        { UC_LO, 0 }, /* _URE_OTHERLETTER */
00083        { UC_PD, 0 }, /* _URE_DASHPUNCT */
00084        { UC_PS, 0 }, /* _URE_OPENPUNCT */
00085        { UC_PC, 0 }, /* _URE_CLOSEPUNCT */
00086        { UC_PO, 0 }, /* _URE_OTHERPUNCT */
00087        { UC_SM, 0 }, /* _URE_MATHSYM */
00088        { UC_SC, 0 }, /* _URE_CURRENCYSYM */
00089        { UC_SO, 0 }, /* _URE_OTHERSYM */
00090 
00091        { UC_L, 0 },  /* _URE_LTR */
00092        { UC_R, 0 },  /* _URE_RTL */
00093 
00094        { 0, UC_EN }, /* _URE_EURONUM */
00095        { 0, UC_ES }, /* _URE_EURONUMSEP */
00096        { 0, UC_ET }, /* _URE_EURONUMTERM */
00097        { 0, UC_AN }, /* _URE_ARABNUM */
00098        { 0, UC_CS }, /* _URE_COMMONSEP */
00099 
00100        { 0, UC_B },  /* _URE_BLOCKSEP */
00101        { 0, UC_S },  /* _URE_SEGMENTSEP */
00102 
00103        { 0, UC_WS }, /* _URE_WHITESPACE */
00104        { 0, UC_ON }  /* _URE_OTHERNEUT */
00105 };
00106 
00107 
00108 /*
00109  * This routine takes a set of URE character property flags (see ure.h) along
00110  * with a character and tests to see if the character has one or more of those
00111  * properties.
00112  */
00113 int
00114 _ure_matches_properties(unsigned long props, ucs4_t c)
00115 {
00116        int i;
00117        unsigned long mask1=0, mask2=0;
00118 
00119        for( i=0; i<32; i++ ) {
00120               if( props & (1 << i) ) {
00121                      mask1 |= masks[i].mask1;
00122                      mask2 |= masks[i].mask2;
00123               }
00124        }
00125 
00126        return ucisprop( mask1, mask2, c );
00127 }