xref: /original-bsd/include/ctype.h (revision 78204ff3)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)ctype.h	5.1 (Berkeley) 05/27/89
18  */
19 
20 #define	_U	0x01
21 #define	_L	0x02
22 #define	_N	0x04
23 #define	_S	0x08
24 #define	_P	0x10
25 #define	_C	0x20
26 #define	_X	0x40
27 #define	_B	0x80
28 
29 extern char	_ctype_[];
30 
31 #define	isdigit(c)	((_ctype_ + 1)[c] & _N)
32 #define	islower(c)	((_ctype_ + 1)[c] & _L)
33 #define	isspace(c)	((_ctype_ + 1)[c] & _S)
34 #define	ispunct(c)	((_ctype_ + 1)[c] & _P)
35 #define	isupper(c)	((_ctype_ + 1)[c] & _U)
36 #define	isalpha(c)	((_ctype_ + 1)[c] & (_U|_L))
37 #define	isxdigit(c)	((_ctype_ + 1)[c] & (_N|_X))
38 #define	isalnum(c)	((_ctype_ + 1)[c] & (_U|_L|_N))
39 #define	isprint(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B))
40 #define	isgraph(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N))
41 #define	iscntrl(c)	((_ctype_ + 1)[c] & _C)
42 #define	isascii(c)	((unsigned)(c) <= 0177)
43 #define	toupper(c)	((c) - 'a' + 'A')
44 #define	tolower(c)	((c) - 'A' + 'a')
45 #define	toascii(c)	((c) & 0177)
46