summaryrefslogtreecommitdiff
path: root/src/wctype/wctype.c
blob: 5c3acbfa054e0d6f2b1c3693743bfc8058917dc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <wctype.h>
#include <string.h>
#include "_assert.h"
#include "_wctype.h"

/** lookup character class **/
wctype_t wctype(const char * property)
{
	ASSERT_NONNULL(property);

	if (!strcmp(property, "alnum")) {
		return CT_ALPHA | CT_DIGIT;
	} else if (!strcmp(property, "alpha")) {
		return CT_ALPHA;
	} else if (!strcmp(property, "blank")) {
		return CT_BLANK;
	} else if (!strcmp(property, "cntrl")) {
		return CT_CNTRL;
	} else if (!strcmp(property, "digit")) {
		return CT_DIGIT;
	} else if (!strcmp(property, "graph")) {
		return CT_GRAPH;
	} else if (!strcmp(property, "lower")) {
		return CT_LOWER;
	} else if (!strcmp(property, "print")) {
		return CT_PRINT;
	} else if (!strcmp(property, "punct")) {
		return CT_PUNCT;
	} else if (!strcmp(property, "space")) {
		return CT_SPACE;
	} else if (!strcmp(property, "upper")) {
		return CT_UPPER;
	} else if (!strcmp(property, "xdigit")) {
		return CT_XDIGIT;
	}

	return 0;
}

/***
The fn(wctype) function looks up the character class specified by the string
arg(property). If arg(property) is a recognized character class, a value is
returned that can be used as the arg(desc) parameter to fn(iswctype).

At least the following character classes are recognized: cclass(alnum),
cclass(alpha), cclass(cntrl), cclass(digit), cclass(graph), cclass(lower),
cclass(print), cclass(punct), cclass(space), cclass(upper), and cclass(xdigit).
***/

/* RETURN(0): the requested character class is not recognized */
/* RETURN(NZ): a value usable as the arg(desc) parameter to fn(iswctype) */

/* UNSPECIFIED: - */
/* IMPLEMENTATION: - */
/* LOCALE: LC_CTYPE */

/*
STDC(199409)
*/