Debian Codegraph @

mingw-w64-crt/ctype/wctype.c

raw
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6 /*
7 wctype.c
8 7.25.2.2.2 The wctype function
9
10 Contributed by: Danny Smith <[email protected]>
11 2005-02-24
12
13 This source code is placed in the PUBLIC DOMAIN. It is modified
14 from the Q8 package created by Doug Gwyn <[email protected]>
15
16 The wctype function constructs a value with type wctype_t that
17 describes a class of wide characters identified by the string
18 argument property.
19
20 In particular, we map the property strings so that:
21
22 iswctype(wc, wctype("alnum")) == iswalnum(wc)
23 iswctype(wc, wctype("alpha")) == iswalpha(wc)
24 iswctype(wc, wctype("blank")) == iswblank(wc)
25 iswctype(wc, wctype("cntrl")) == iswcntrl(wc)
26 iswctype(wc, wctype("digit")) == iswdigit(wc)
27 iswctype(wc, wctype("graph")) == iswgraph(wc)
28 iswctype(wc, wctype("lower")) == iswlower(wc)
29 iswctype(wc, wctype("print")) == iswprint(wc)
30 iswctype(wc, wctype("punct")) == iswpunct(wc)
31 iswctype(wc, wctype("space")) == iswspace(wc)
32 iswctype(wc, wctype("upper")) == iswupper(wc)
33 iswctype(wc, wctype("xdigit")) == iswxdigit(wc)
34 */
35
36 #include <stdlib.h>
37 #include <string.h>
38 #include <wctype.h>
39
40 /* Using the bit-OR'd ctype character classification flags as return
41 values achieves compatibility with MS iswctype(). */
42 static const struct {
43 const char *name;
44 wctype_t flags;
45 } cmap[] = {
46 {"alnum", _ALPHA|_DIGIT},
47 {"alpha", _ALPHA},
48 {"blank", _BLANK},
49 {"cntrl", _CONTROL},
50 {"digit", _DIGIT},
51 {"graph", _ALPHA|_DIGIT|_PUNCT},
52 {"lower", _LOWER},
53 {"print", _ALPHA|_BLANK|_DIGIT|_PUNCT},
54 {"punct", _PUNCT},
55 {"space", _SPACE},
56 {"upper", _UPPER},
57 {"xdigit", _HEX}
58 };
59
60 wctype_t wctype (const char *property)
61 {
62 int i;
63 for (i = 0; i < (int) _countof (cmap); ++i)
64 if (strcmp (property, cmap[i].name) == 0)
65 return cmap[i].flags;
66 return 0;
67 }
68
69 wctype_t (__cdecl *__MINGW_IMP_SYMBOL (wctype)) (const char *) = wctype;