1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 #pragma ident "%Z%%M% %I% %E% SMI"
23 /* from UCB 4.2 83/07/08 */
24
25 #include <ctype.h>
26 #include <stdlib.h>
27
28
29 char _ctype_[] = { 0,
30
31 /* 0 1 2 3 4 5 6 7 */
32
33 /* 0*/ _C, _C, _C, _C, _C, _C, _C, _C,
34 /* 10*/ _C, _S|_C, _S|_C, _S|_C, _S|_C, _S|_C, _C, _C,
35 /* 20*/ _C, _C, _C, _C, _C, _C, _C, _C,
36 /* 30*/ _C, _C, _C, _C, _C, _C, _C, _C,
37 /* 40*/ (char)(_S|_B), _P, _P, _P, _P, _P, _P, _P,
38 /* 50*/ _P, _P, _P, _P, _P, _P, _P, _P,
39 /* 60*/ _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X,
40 /* 70*/ _N|_X, _N|_X, _P, _P, _P, _P, _P, _P,
41 /*100*/ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
42 /*110*/ _U, _U, _U, _U, _U, _U, _U, _U,
43 /*120*/ _U, _U, _U, _U, _U, _U, _U, _U,
44 /*130*/ _U, _U, _U, _P, _P, _P, _P, _P,
45 /*140*/ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
46 /*150*/ _L, _L, _L, _L, _L, _L, _L, _L,
47 /*160*/ _L, _L, _L, _L, _L, _L, _L, _L,
48 /*170*/ _L, _L, _L, _P, _P, _P, _P, _C,
49 /*200*/ 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0,
63 0, 0, 0, 0, 0, 0, 0, 0,
64 0, 0, 0, 0, 0, 0, 0, 0
65 };
66
67 unsigned int _mb_cur_max;
68
69 /* Now we also supply the functions in libc as well as the macros in
70 * ctype.h
71 */
72
73 #undef isalpha
74 #undef isupper
75 #undef islower
76 #undef isdigit
77 #undef isxdigit
78 #undef isspace
79 #undef ispunct
80 #undef isalnum
81 #undef isprint
82 #undef isgraph
83 #undef iscntrl
84 #undef isascii
85 #undef toascii
86
87 extern int mbtowc();
88
isalpha(c)89 int isalpha(c)
90 register int c;
91 {
92 return((_ctype_+1)[c]&(_U|_L));
93 }
94
isupper(c)95 int isupper(c)
96 register int c;
97 {
98 return((_ctype_+1)[c]&_U);
99 }
100
islower(c)101 int islower(c)
102 register int c;
103 {
104 return((_ctype_+1)[c]&_L);
105 }
106
isdigit(c)107 int isdigit(c)
108 register int c;
109 {
110 return((_ctype_+1)[c]&_N);
111 }
112
isxdigit(c)113 int isxdigit(c)
114 register int c;
115 {
116 return((_ctype_+1)[c]&_X);
117 }
118
119
isspace(c)120 int isspace(c)
121 register int c;
122 {
123 return((_ctype_+1)[c]&_S);
124 }
125
126
ispunct(c)127 int ispunct(c)
128 register int c;
129 {
130 return((_ctype_+1)[c]&_P);
131 }
132
133
isalnum(c)134 int isalnum(c)
135 register int c;
136 {
137 return((_ctype_+1)[c]&(_U|_L|_N));
138 }
139
140
isprint(c)141 int isprint(c)
142 register int c;
143 {
144 return((_ctype_+1)[c]&(_P|_U|_L|_N|_B));
145 }
146
147
isgraph(c)148 int isgraph(c)
149 register int c;
150 {
151 return((_ctype_+1)[c]&(_P|_U|_L|_N));
152 }
153
154
iscntrl(c)155 int iscntrl(c)
156 register int c;
157 {
158 return((_ctype_+1)[c]&_C);
159 }
160
isascii(c)161 int isascii(c)
162 register int c;
163 {
164 return((unsigned)(c)<=0177);
165 }
166
toascii(c)167 int toascii(c)
168 register int c;
169 {
170 return((c)&0177);
171 }
172
173