xref: /netbsd-src/lib/libc/gen/isctype.c (revision 725ed31e82183584230a67cb514922b4de02c9ac)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  * (c) UNIX System Laboratories, Inc.
5  * All or some portions of this file are derived from material licensed
6  * to the University of California by American Telephone and Telegraph
7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8  * the permission of UNIX System Laboratories, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 
39 #if defined(LIBC_SCCS) && !defined(lint)
40 /*static char *sccsid = "from: @(#)isctype.c	5.2 (Berkeley) 6/1/90";*/
41 static char *rcsid = "$Id: isctype.c,v 1.12 1994/05/17 04:13:51 cgd Exp $";
42 #endif /* LIBC_SCCS and not lint */
43 
44 #define _ANSI_LIBRARY
45 #include <ctype.h>
46 
47 #undef isalnum
48 int
49 isalnum(c)
50 	int c;
51 {
52 	return((_ctype_ + 1)[c] & (_U|_L|_N));
53 }
54 
55 #undef isalpha
56 int
57 isalpha(c)
58 	int c;
59 {
60 	return((_ctype_ + 1)[c] & (_U|_L));
61 }
62 
63 #undef isblank
64 int
65 isblank(c)
66 	int c;
67 {
68 	return(c == ' ' || c == '\t');
69 }
70 
71 #undef iscntrl
72 int
73 iscntrl(c)
74 	int c;
75 {
76 	return((_ctype_ + 1)[c] & _C);
77 }
78 
79 #undef isdigit
80 int
81 isdigit(c)
82 	int c;
83 {
84 	return((_ctype_ + 1)[c] & _N);
85 }
86 
87 #undef isgraph
88 int
89 isgraph(c)
90 	int c;
91 {
92 	return((_ctype_ + 1)[c] & (_P|_U|_L|_N));
93 }
94 
95 #undef islower
96 int
97 islower(c)
98 	int c;
99 {
100 	return((_ctype_ + 1)[c] & _L);
101 }
102 
103 #undef isprint
104 int
105 isprint(c)
106 	int c;
107 {
108 	return((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B));
109 }
110 
111 #undef ispunct
112 int
113 ispunct(c)
114 	int c;
115 {
116 	return((_ctype_ + 1)[c] & _P);
117 }
118 
119 #undef isspace
120 int
121 isspace(c)
122 	int c;
123 {
124 	return((_ctype_ + 1)[c] & _S);
125 }
126 
127 #undef isupper
128 int
129 isupper(c)
130 	int c;
131 {
132 	return((_ctype_ + 1)[c] & _U);
133 }
134 
135 #undef isxdigit
136 int
137 isxdigit(c)
138 	int c;
139 {
140 	return((_ctype_ + 1)[c] & (_N|_X));
141 }
142 
143 #undef isascii
144 int
145 isascii(c)
146 	int c;
147 {
148 	return ((unsigned)(c) <= 0177);
149 }
150 
151 #undef toascii
152 int
153 toascii(c)
154 	int c;
155 {
156 	return ((c) & 0177);
157 }
158 
159 #undef _toupper
160 int
161 _toupper(c)
162 	int c;
163 {
164 	return (c - 'a' + 'A');
165 }
166 
167 #undef _tolower
168 int
169 _tolower(c)
170 	int c;
171 {
172 	return (c - 'A' + 'a');
173 }
174