xref: /freebsd-13-stable/lib/libc/locale/isctype.c (revision 3d497e17ebd33fe0f58d773e35ab994d750258d6)
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 #include <ctype.h>
45 
46 #undef digittoint
47 int
digittoint(int c)48 digittoint(int c)
49 {
50 	return (__sbmaskrune(c, 0xFF));
51 }
52 
53 #undef isalnum
54 int
isalnum(int c)55 isalnum(int c)
56 {
57 	return (__sbistype(c, _CTYPE_A|_CTYPE_N));
58 }
59 
60 #undef isalpha
61 int
isalpha(int c)62 isalpha(int c)
63 {
64 	return (__sbistype(c, _CTYPE_A));
65 }
66 
67 #undef isascii
68 int
isascii(int c)69 isascii(int c)
70 {
71 	return ((c & ~0x7F) == 0);
72 }
73 
74 #undef isblank
75 int
isblank(int c)76 isblank(int c)
77 {
78 	return (__sbistype(c, _CTYPE_B));
79 }
80 
81 #undef iscntrl
82 int
iscntrl(int c)83 iscntrl(int c)
84 {
85 	return (__sbistype(c, _CTYPE_C));
86 }
87 
88 #undef isdigit
89 int
isdigit(int c)90 isdigit(int c)
91 {
92 	return (__isctype(c, _CTYPE_D));
93 }
94 
95 #undef isgraph
96 int
isgraph(int c)97 isgraph(int c)
98 {
99 	return (__sbistype(c, _CTYPE_G));
100 }
101 
102 #undef ishexnumber
103 int
ishexnumber(int c)104 ishexnumber(int c)
105 {
106 	return (__sbistype(c, _CTYPE_X));
107 }
108 
109 #undef isideogram
110 int
isideogram(int c)111 isideogram(int c)
112 {
113 	return (__sbistype(c, _CTYPE_I));
114 }
115 
116 #undef islower
117 int
islower(int c)118 islower(int c)
119 {
120 	return (__sbistype(c, _CTYPE_L));
121 }
122 
123 #undef isnumber
124 int
isnumber(int c)125 isnumber(int c)
126 {
127 	return (__sbistype(c, _CTYPE_N));
128 }
129 
130 #undef isphonogram
131 int
isphonogram(int c)132 isphonogram(int c)
133 {
134 	return (__sbistype(c, _CTYPE_Q));
135 }
136 
137 #undef isprint
138 int
isprint(int c)139 isprint(int c)
140 {
141 	return (__sbistype(c, _CTYPE_R));
142 }
143 
144 #undef ispunct
145 int
ispunct(int c)146 ispunct(int c)
147 {
148 	return (__sbistype(c, _CTYPE_P));
149 }
150 
151 #undef isrune
152 int
isrune(int c)153 isrune(int c)
154 {
155 	return (__sbistype(c, 0xFFFFFF00L));
156 }
157 
158 #undef isspace
159 int
isspace(int c)160 isspace(int c)
161 {
162 	return (__sbistype(c, _CTYPE_S));
163 }
164 
165 #undef isspecial
166 int
isspecial(int c)167 isspecial(int c)
168 {
169 	return (__sbistype(c, _CTYPE_T));
170 }
171 
172 #undef isupper
173 int
isupper(int c)174 isupper(int c)
175 {
176 	return (__sbistype(c, _CTYPE_U));
177 }
178 
179 #undef isxdigit
180 int
isxdigit(int c)181 isxdigit(int c)
182 {
183 	return (__isctype(c, _CTYPE_X));
184 }
185 
186 #undef toascii
187 int
toascii(int c)188 toascii(int c)
189 {
190 	return (c & 0x7F);
191 }
192 
193 #undef tolower
194 int
tolower(int c)195 tolower(int c)
196 {
197 	return (__sbtolower(c));
198 }
199 
200 #undef toupper
201 int
toupper(int c)202 toupper(int c)
203 {
204 	return (__sbtoupper(c));
205 }
206 
207