1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * This code is derived from software contributed to Berkeley by
13 * Paul Borman at Krystal Technologies.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40 #if defined(LIBC_SCCS) && !defined(lint)
41 static char sccsid[] = "@(#)isctype.c 8.3 (Berkeley) 2/24/94";
42 #endif /* LIBC_SCCS and not lint */
43 #include <sys/cdefs.h>
44 __FBSDID("$FreeBSD: stable/12/lib/libc/locale/isctype.c 326025 2017-11-20 19:49:47Z pfg $");
45
46 #include <ctype.h>
47
48 #undef digittoint
49 int
digittoint(int c)50 digittoint(int c)
51 {
52 return (__sbmaskrune(c, 0xFF));
53 }
54
55 #undef isalnum
56 int
isalnum(int c)57 isalnum(int c)
58 {
59 return (__sbistype(c, _CTYPE_A|_CTYPE_N));
60 }
61
62 #undef isalpha
63 int
isalpha(int c)64 isalpha(int c)
65 {
66 return (__sbistype(c, _CTYPE_A));
67 }
68
69 #undef isascii
70 int
isascii(int c)71 isascii(int c)
72 {
73 return ((c & ~0x7F) == 0);
74 }
75
76 #undef isblank
77 int
isblank(int c)78 isblank(int c)
79 {
80 return (__sbistype(c, _CTYPE_B));
81 }
82
83 #undef iscntrl
84 int
iscntrl(int c)85 iscntrl(int c)
86 {
87 return (__sbistype(c, _CTYPE_C));
88 }
89
90 #undef isdigit
91 int
isdigit(int c)92 isdigit(int c)
93 {
94 return (__isctype(c, _CTYPE_D));
95 }
96
97 #undef isgraph
98 int
isgraph(int c)99 isgraph(int c)
100 {
101 return (__sbistype(c, _CTYPE_G));
102 }
103
104 #undef ishexnumber
105 int
ishexnumber(int c)106 ishexnumber(int c)
107 {
108 return (__sbistype(c, _CTYPE_X));
109 }
110
111 #undef isideogram
112 int
isideogram(int c)113 isideogram(int c)
114 {
115 return (__sbistype(c, _CTYPE_I));
116 }
117
118 #undef islower
119 int
islower(int c)120 islower(int c)
121 {
122 return (__sbistype(c, _CTYPE_L));
123 }
124
125 #undef isnumber
126 int
isnumber(int c)127 isnumber(int c)
128 {
129 return (__sbistype(c, _CTYPE_N));
130 }
131
132 #undef isphonogram
133 int
isphonogram(int c)134 isphonogram(int c)
135 {
136 return (__sbistype(c, _CTYPE_Q));
137 }
138
139 #undef isprint
140 int
isprint(int c)141 isprint(int c)
142 {
143 return (__sbistype(c, _CTYPE_R));
144 }
145
146 #undef ispunct
147 int
ispunct(int c)148 ispunct(int c)
149 {
150 return (__sbistype(c, _CTYPE_P));
151 }
152
153 #undef isrune
154 int
isrune(int c)155 isrune(int c)
156 {
157 return (__sbistype(c, 0xFFFFFF00L));
158 }
159
160 #undef isspace
161 int
isspace(int c)162 isspace(int c)
163 {
164 return (__sbistype(c, _CTYPE_S));
165 }
166
167 #undef isspecial
168 int
isspecial(int c)169 isspecial(int c)
170 {
171 return (__sbistype(c, _CTYPE_T));
172 }
173
174 #undef isupper
175 int
isupper(int c)176 isupper(int c)
177 {
178 return (__sbistype(c, _CTYPE_U));
179 }
180
181 #undef isxdigit
182 int
isxdigit(int c)183 isxdigit(int c)
184 {
185 return (__isctype(c, _CTYPE_X));
186 }
187
188 #undef toascii
189 int
toascii(int c)190 toascii(int c)
191 {
192 return (c & 0x7F);
193 }
194
195 #undef tolower
196 int
tolower(int c)197 tolower(int c)
198 {
199 return (__sbtolower(c));
200 }
201
202 #undef toupper
203 int
toupper(int c)204 toupper(int c)
205 {
206 return (__sbtoupper(c));
207 }
208
209