1 /*
2  *	%W%	(TriChlor) %G% %U%
3  */
4 
5 #ifndef _VNTYPE_H_
6 #define _VNTYPE_H_
7 
8 #ifndef _MSDOS
9 #ifndef _WINDOWS
10 /* Undo the effect of ctype.h to silence compiler warnings */
11 #undef	_U
12 #undef	_L
13 #undef	_N
14 #undef	_S
15 #undef	_P
16 #undef	_C
17 #undef	_X
18 #undef	_B
19 
20 /* Types enumerated in Viet-Std locale */
21 #undef	isupper(c)
22 #undef	islower(c)
23 #undef	isdigit(c)
24 #undef	isspace(c)
25 #undef	ispunct(c)
26 #undef	iscntrl(c)
27 #undef	isxdigit(c)
28 #undef	isblank(c)
29 
30 #undef	toupper(c)
31 #undef	tolower(c)
32 
33 /* Types not enumerated in Viet-Std locale */
34 #undef	isascii(c)
35 #undef	isalpha(c)
36 #undef	isalnum(c)
37 #undef	isprint(c)
38 #undef	isgraph(c)
39 
40 #undef toascii(c)
41 #endif /* _WINDOWS */
42 #endif /* _MSDOS */
43 
44 
45 /* Definitions overriding ctype.h */
46 #ifndef _uchar
47 #define	_uchar	unsigned char
48 #endif
49 
50 #define	_U	0x01	/* Upper case */
51 #define	_L	0x02	/* Lower case */
52 #define	_N	0x04	/* Numeral (digit) */
53 #define	_S	0x08	/* Spacing character */
54 #define _P	0x10	/* Punctuation */
55 #define _C	0x20	/* Control character */
56 #define _X	0x40	/* Hexadecimal */
57 #define _B	0x80	/* Blank */
58 
59 /* Special types */
60 #define	_V	0x100	/* Vowel */
61 #define	_M	0x200	/* Modifier (breve,circumflex,horn) */
62 #define	_A	0x400	/* Accent (acute,grave,hook above,tilde,dot below) */
63 #define	_Med	0x800	/* Modified vowel */
64 #define	_Aed	0x1000	/* Accented vowel */
65 
66 extern	unsigned int	_pvntype[];
67 extern	unsigned char	_vntoupper[];
68 extern	unsigned char	_vntolower[];
69 
70 /* Types enumerated in Viet-Std locale */
71 #define	isupper(c)	(_pvntype[(_uchar)(c)]&_U)
72 #define	islower(c)	(_pvntype[(_uchar)(c)]&_L)
73 #define	isdigit(c)	(_pvntype[(_uchar)(c)]&_N)
74 #define	isspace(c)	(_pvntype[(_uchar)(c)]&_S)
75 #define ispunct(c)	(_pvntype[(_uchar)(c)]&_P)
76 #define iscntrl(c)	(_pvntype[(_uchar)(c)]&_C)
77 #define	isxdigit(c)	(_pvntype[(_uchar)(c)]&_X)
78 #define	isblank(c)	(_pvntype[(_uchar)(c)]&_B)
79 
80 #define	toupper(c)	(_vntoupper[(_uchar)(c)])
81 #define	tolower(c)	(_vntolower[(_uchar)(c)])
82 
83 /* Types not enumerated in Viet-Std locale */
84 #define isascii(c)	((unsigned)(c)<=0177)
85 #define	isalpha(c)	(_pvntype[(_uchar)(c)]&(_U|_L))
86 #define isalnum(c)	(_pvntype[(_uchar)(c)]&(_U|_L|_N))
87 #define isprint(c)	(_pvntype[(_uchar)(c)]&(_P|_U|_L|_N|_B))
88 #define isgraph(c)	(_pvntype[(_uchar)(c)]&(_P|_U|_L|_N))
89 
90 #define toascii(c)	((c)&0177)
91 
92 /* Special types */
93 #define	isvowel(c)	(_pvntype[(_uchar)(c)]&_V)
94 #define	isconsonant(c)	(isalpha(c) && !(_pvntype[(_uchar)(c)]&_V))
95 #define	ismodifier(c)	(_pvntype[(_uchar)(c)]&_M)
96 #define	isaccent(c)	(_pvntype[(_uchar)(c)]&_A)
97 #define	isdiacritic(c)	(ismodifier(c) || isaccent(c))
98 #define	ismodified(c)	(_pvntype[(_uchar)(c)]&_Med)
99 #define	isaccented(c)	(_pvntype[(_uchar)(c)]&_Aed)
100 /* We need a Presidential Pardon for "diacriticized" */
101 #define	isdiacriticized(c)	(ismodified(c) || isaccented(c))
102 
103 #endif /* _VNTYPE_H_ */
104