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