]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/wctype.c.patch
Libc-391.2.10.tar.gz
[apple/libc.git] / locale / FreeBSD / wctype.c.patch
1 --- wctype.c.orig 2004-11-25 11:38:21.000000000 -0800
2 +++ wctype.c 2005-02-27 02:15:11.000000000 -0800
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wctype.c,v 1.3 2004/03/27 08:59:21 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <ctype.h>
10 #include <string.h>
11 #include <wctype.h>
12 @@ -36,34 +38,57 @@
13 iswctype(wint_t wc, wctype_t charclass)
14 {
15
16 - return (__istype(wc, charclass));
17 + return (__istype_l(wc, charclass, __current_locale()));
18 +}
19 +
20 +#undef iswctype_l
21 +int
22 +iswctype_l(wint_t wc, wctype_t charclass, locale_t loc)
23 +{
24 + NORMALIZE_LOCALE(loc);
25 + return (__istype_l(wc, charclass, loc));
26 }
27
28 +static struct {
29 + const char *name;
30 + wctype_t mask;
31 +} props[] = {
32 + { "alnum", _CTYPE_A|_CTYPE_D },
33 + { "alpha", _CTYPE_A },
34 + { "blank", _CTYPE_B },
35 + { "cntrl", _CTYPE_C },
36 + { "digit", _CTYPE_D },
37 + { "graph", _CTYPE_G },
38 + { "lower", _CTYPE_L },
39 + { "print", _CTYPE_R },
40 + { "punct", _CTYPE_P },
41 + { "space", _CTYPE_S },
42 + { "upper", _CTYPE_U },
43 + { "xdigit", _CTYPE_X },
44 + { "ideogram", _CTYPE_I }, /* BSD extension */
45 + { "special", _CTYPE_T }, /* BSD extension */
46 + { "phonogram", _CTYPE_Q }, /* BSD extension */
47 + { "rune", 0xFFFFFF00L }, /* BSD extension */
48 + { NULL, 0UL }, /* Default */
49 +};
50 +
51 +/* these don't currently depend on the locale, but they could */
52 +
53 wctype_t
54 wctype(const char *property)
55 {
56 - struct {
57 - const char *name;
58 - wctype_t mask;
59 - } props[] = {
60 - { "alnum", _CTYPE_A|_CTYPE_D },
61 - { "alpha", _CTYPE_A },
62 - { "blank", _CTYPE_B },
63 - { "cntrl", _CTYPE_C },
64 - { "digit", _CTYPE_D },
65 - { "graph", _CTYPE_G },
66 - { "lower", _CTYPE_L },
67 - { "print", _CTYPE_R },
68 - { "punct", _CTYPE_P },
69 - { "space", _CTYPE_S },
70 - { "upper", _CTYPE_U },
71 - { "xdigit", _CTYPE_X },
72 - { "ideogram", _CTYPE_I }, /* BSD extension */
73 - { "special", _CTYPE_T }, /* BSD extension */
74 - { "phonogram", _CTYPE_Q }, /* BSD extension */
75 - { "rune", 0xFFFFFF00L }, /* BSD extension */
76 - { NULL, 0UL }, /* Default */
77 - };
78 + int i;
79 +
80 + i = 0;
81 + while (props[i].name != NULL && strcmp(props[i].name, property) != 0)
82 + i++;
83 +
84 + return (props[i].mask);
85 +}
86 +
87 +wctype_t
88 +wctype_l(const char *property, locale_t loc)
89 +{
90 int i;
91
92 i = 0;