]> git.sur5r.net Git - openldap/blobdiff - libraries/liblunicode/ure/urestubs.c
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / liblunicode / ure / urestubs.c
index 078202491ae21ff64505d3fa07ded066f88fc5c7..93dae71af1a4c613157473c668ea12ecbecb4388 100644 (file)
@@ -1,3 +1,17 @@
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2012 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
 /*
  * Copyright 1997, 1998, 1999 Computing Research Labs,
  * New Mexico State University
  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#ifndef lint
-static char rcsid[] = "$Id: urestubs.c,v 1.2 1999/09/21 15:47:44 mleisher Exp $";
-#endif
+/* $Id: urestubs.c,v 1.2 1999/09/21 15:47:44 mleisher Exp $" */
+
+#include "portable.h"
+#include <ac/bytes.h>
 
 #include "ure.h"
 
+#ifdef _MSC_VER
+#  include "../ucdata/ucdata.h"
+#else
+#  include "ucdata.h"
+#endif
+
 /*
  * This file contains stub routines needed by the URE package to test
  * character properties and other Unicode implementation specific details.
@@ -37,9 +58,53 @@ static char rcsid[] = "$Id: urestubs.c,v 1.2 1999/09/21 15:47:44 mleisher Exp $"
  */
 ucs4_t _ure_tolower(ucs4_t c)
 {
-    return c;
+    return uctoupper(c);
 }
 
+static struct ucmaskmap {
+       unsigned long mask1;
+       unsigned long mask2;
+} masks[32] = {
+       { UC_MN, 0 },   /* _URE_NONSPACING */
+       { UC_MC, 0 },   /* _URE_COMBINING */
+       { UC_ND, 0 },   /* _URE_NUMDIGIT */
+       { UC_NL|UC_NO, 0 },     /* _URE_NUMOTHER */
+       { UC_ZS, 0 },   /* _URE_SPACESEP */
+       { UC_ZL, 0 },   /* _URE_LINESEP */
+       { UC_ZP, 0 },   /* _URE_PARASEP */
+       { UC_CC, 0 },   /* _URE_CNTRL */
+       { UC_CO, 0 },   /* _URE_PUA */
+
+       { UC_LU, 0 },   /* _URE_UPPER */
+       { UC_LL, 0 },   /* _URE_LOWER */
+       { UC_LT, 0 },   /* _URE_TITLE */
+       { UC_LM, 0 },   /* _URE_MODIFIER */
+       { UC_LO, 0 },   /* _URE_OTHERLETTER */
+       { UC_PD, 0 },   /* _URE_DASHPUNCT */
+       { UC_PS, 0 },   /* _URE_OPENPUNCT */
+       { UC_PC, 0 },   /* _URE_CLOSEPUNCT */
+       { UC_PO, 0 },   /* _URE_OTHERPUNCT */
+       { UC_SM, 0 },   /* _URE_MATHSYM */
+       { UC_SC, 0 },   /* _URE_CURRENCYSYM */
+       { UC_SO, 0 },   /* _URE_OTHERSYM */
+
+       { UC_L, 0 },    /* _URE_LTR */
+       { UC_R, 0 },    /* _URE_RTL */
+
+       { 0, UC_EN },   /* _URE_EURONUM */
+       { 0, UC_ES },   /* _URE_EURONUMSEP */
+       { 0, UC_ET },   /* _URE_EURONUMTERM */
+       { 0, UC_AN },   /* _URE_ARABNUM */
+       { 0, UC_CS },   /* _URE_COMMONSEP */
+
+       { 0, UC_B },    /* _URE_BLOCKSEP */
+       { 0, UC_S },    /* _URE_SEGMENTSEP */
+
+       { 0, UC_WS },   /* _URE_WHITESPACE */
+       { 0, UC_ON }    /* _URE_OTHERNEUT */
+};
+
+
 /*
  * This routine takes a set of URE character property flags (see ure.h) along
  * with a character and tests to see if the character has one or more of those
@@ -48,5 +113,15 @@ ucs4_t _ure_tolower(ucs4_t c)
 int
 _ure_matches_properties(unsigned long props, ucs4_t c)
 {
-    return 1;
+       int i;
+       unsigned long mask1=0, mask2=0;
+
+       for( i=0; i<32; i++ ) {
+               if( props & (1 << i) ) {
+                       mask1 |= masks[i].mask1;
+                       mask2 |= masks[i].mask2;
+               }
+       }
+
+       return ucisprop( mask1, mask2, c );
 }