]> git.saurik.com Git - apple/libc.git/blobdiff - locale/FreeBSD/wctype.c
Libc-1082.20.4.tar.gz
[apple/libc.git] / locale / FreeBSD / wctype.c
index c28015e95f1e8d395f337e3e459144fc6074f23b..f94c1334f6606f3ada6cd0cab5a1f1250491df8a 100644 (file)
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/locale/wctype.c,v 1.2 2002/08/04 12:43:53 tjr Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/locale/wctype.c,v 1.4 2008/03/17 18:22:23 antoine Exp $");
+
+#include "xlocale_private.h"
 
 #include <ctype.h>
 #include <string.h>
 #include <wctype.h>
-
-#undef iswctype
-int
-iswctype(wint_t wc, wctype_t charclass)
-{
-
-       return (__istype(wc, charclass));
-}
+#include <limits.h>
 
 wctype_t
-wctype(const char *property)
+wctype_l(const char *property, locale_t loc)
 {
-       struct {
+       _RuneLocale *rl;
+       static const struct {
                const char      *name;
                wctype_t         mask;
        } props[] = {
@@ -61,6 +57,7 @@ wctype(const char *property)
                { "ideogram",   _CTYPE_I },     /* BSD extension */
                { "special",    _CTYPE_T },     /* BSD extension */
                { "phonogram",  _CTYPE_Q },     /* BSD extension */
+               { "rune",       0xFFFFFF00L },  /* BSD extension */
                { NULL,         0UL },          /* Default */
        };
        int i;
@@ -69,5 +66,23 @@ wctype(const char *property)
        while (props[i].name != NULL && strcmp(props[i].name, property) != 0)
                i++;
 
-       return (props[i].mask);
+       if (props[i].mask)
+               return (props[i].mask);
+
+       NORMALIZE_LOCALE(loc);
+       rl = &loc->__lc_ctype->_CurrentRuneLocale;
+       if ((i = rl->__ncharclasses) > 0) {
+               _RuneCharClass *rp;
+               for (rp = rl->__charclasses; i-- > 0; rp++) {
+                       if (strncmp(rp->__name, property, CHARCLASS_NAME_MAX) == 0)
+                               return (rp->__mask);
+               }
+       }
+       return 0;
+}
+
+wctype_t
+wctype(const char *property)
+{
+       return wctype_l(property, __current_locale());
 }