xref: /original-bsd/lib/libc/locale/isctype.c (revision 753853ba)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)isctype.c	5.6 (Berkeley) 03/13/92";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #define _ANSI_LIBRARY
13 #include <ctype.h>
14 
15 #undef isalnum
16 isalnum(c)
17 	int c;
18 {
19 	return ((__ctype + 1)[c] & (_U|_L|_N));
20 }
21 
22 #undef isalpha
23 isalpha(c)
24 	int c;
25 {
26 	return ((__ctype + 1)[c] & (_U|_L));
27 }
28 
29 #undef isascii
30 isascii(c)
31 	int c;
32 {
33 	return (c <= 0177);
34 }
35 
36 #undef isblank
37 isblank(c)
38 	int c;
39 {
40 	return (c == '\t' || c == ' ');
41 }
42 
43 #undef iscntrl
44 iscntrl(c)
45 	int c;
46 {
47 	return ((__ctype + 1)[c] & _C);
48 }
49 
50 #undef isdigit
51 isdigit(c)
52 	int c;
53 {
54 	return ((__ctype + 1)[c] & _N);
55 }
56 
57 #undef isgraph
58 isgraph(c)
59 	int c;
60 {
61 	return ((__ctype + 1)[c] & (_P|_U|_L|_N));
62 }
63 
64 #undef islower
65 islower(c)
66 	int c;
67 {
68 	return ((__ctype + 1)[c] & _L);
69 }
70 
71 #undef isprint
72 isprint(c)
73 	int c;
74 {
75 	return ((__ctype + 1)[c] & (_P|_U|_L|_N|_B));
76 }
77 
78 #undef ispunct
79 ispunct(c)
80 	int c;
81 {
82 	return ((__ctype + 1)[c] & _P);
83 }
84 
85 #undef isspace
86 isspace(c)
87 	int c;
88 {
89 	return ((__ctype + 1)[c] & _S);
90 }
91 
92 #undef isupper
93 isupper(c)
94 	int c;
95 {
96 	return ((__ctype + 1)[c] & _U);
97 }
98 
99 #undef isxdigit
100 isxdigit(c)
101 	int c;
102 {
103 	return ((__ctype + 1)[c] & (_N|_X));
104 }
105 
106 #undef toascii
107 toascii(c)
108 	int c;
109 {
110 	return (c & 0177);
111 }
112 
113 #undef tolower
114 tolower(c)
115 	int c;
116 {
117 	return (isupper(c) ? c - 'A' + 'a' : c);
118 }
119 
120 #undef toupper
121 toupper(c)
122 	int c;
123 {
124 	return (islower(c) ? c - 'a' + 'A' : c);
125 }
126