xref: /illumos-gate/usr/src/cmd/sh/ctype.h (revision 7c478bd95313f5f23a4c958a745db2134aa0324)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.10.1.1	*/
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  *	UNIX shell
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /* table 1 */
33*7c478bd9Sstevel@tonic-gate #define T_SUB	01
34*7c478bd9Sstevel@tonic-gate #define T_MET	02
35*7c478bd9Sstevel@tonic-gate #define	T_SPC	04
36*7c478bd9Sstevel@tonic-gate #define T_DIP	010
37*7c478bd9Sstevel@tonic-gate #define T_EOF	020
38*7c478bd9Sstevel@tonic-gate #define T_EOR	040
39*7c478bd9Sstevel@tonic-gate #define T_QOT	0100
40*7c478bd9Sstevel@tonic-gate #define T_ESC	0200
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /* table 2 */
43*7c478bd9Sstevel@tonic-gate #define T_BRC	01
44*7c478bd9Sstevel@tonic-gate #define T_DEF	02
45*7c478bd9Sstevel@tonic-gate #define T_AST	04
46*7c478bd9Sstevel@tonic-gate #define	T_DIG	010
47*7c478bd9Sstevel@tonic-gate #define T_SHN	040
48*7c478bd9Sstevel@tonic-gate #define	T_IDC	0100
49*7c478bd9Sstevel@tonic-gate #define T_SET	0200
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /* for single chars */
52*7c478bd9Sstevel@tonic-gate #define _TAB	(T_SPC)
53*7c478bd9Sstevel@tonic-gate #define _SPC	(T_SPC)
54*7c478bd9Sstevel@tonic-gate #define _UPC	(T_IDC)
55*7c478bd9Sstevel@tonic-gate #define _LPC	(T_IDC)
56*7c478bd9Sstevel@tonic-gate #define _DIG	(T_DIG)
57*7c478bd9Sstevel@tonic-gate #define _EOF	(T_EOF)
58*7c478bd9Sstevel@tonic-gate #define _EOR	(T_EOR)
59*7c478bd9Sstevel@tonic-gate #define _BAR	(T_DIP)
60*7c478bd9Sstevel@tonic-gate #define _HAT	(T_MET)
61*7c478bd9Sstevel@tonic-gate #define _BRA	(T_MET)
62*7c478bd9Sstevel@tonic-gate #define _KET	(T_MET)
63*7c478bd9Sstevel@tonic-gate #define _AMP	(T_DIP)
64*7c478bd9Sstevel@tonic-gate #define _SEM	(T_DIP)
65*7c478bd9Sstevel@tonic-gate #define _LT	(T_DIP)
66*7c478bd9Sstevel@tonic-gate #define _GT	(T_DIP)
67*7c478bd9Sstevel@tonic-gate #define _LQU	(T_QOT|T_ESC)
68*7c478bd9Sstevel@tonic-gate #define _BSL	(T_ESC)
69*7c478bd9Sstevel@tonic-gate #define _DQU	(T_QOT|T_ESC)
70*7c478bd9Sstevel@tonic-gate #define _DOL1	(T_SUB|T_ESC)
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #define _CBR	T_BRC
73*7c478bd9Sstevel@tonic-gate #define _CKT	T_DEF
74*7c478bd9Sstevel@tonic-gate #define _AST	(T_AST)
75*7c478bd9Sstevel@tonic-gate #define _EQ	(T_DEF)
76*7c478bd9Sstevel@tonic-gate #define _MIN	(T_DEF|T_SHN)
77*7c478bd9Sstevel@tonic-gate #define _PCS	(T_SHN)
78*7c478bd9Sstevel@tonic-gate #define _NUM	(T_SHN)
79*7c478bd9Sstevel@tonic-gate #define _DOL2	(T_SHN)
80*7c478bd9Sstevel@tonic-gate #define _PLS	(T_DEF|T_SET)
81*7c478bd9Sstevel@tonic-gate #define _AT	(T_AST)
82*7c478bd9Sstevel@tonic-gate #define _QU	(T_DEF|T_SHN)
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* abbreviations for tests */
85*7c478bd9Sstevel@tonic-gate #define _IDCH	(T_IDC|T_DIG)
86*7c478bd9Sstevel@tonic-gate #define _META	(T_SPC|T_DIP|T_MET|T_EOR)
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate extern
89*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
90*7c478bd9Sstevel@tonic-gate const
91*7c478bd9Sstevel@tonic-gate #endif
92*7c478bd9Sstevel@tonic-gate unsigned char	_ctype1[];
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /* nb these args are not call by value !!!! */
95*7c478bd9Sstevel@tonic-gate #define	space(c)	((c<QUOTE) && _ctype1[c]&(T_SPC))
96*7c478bd9Sstevel@tonic-gate #define eofmeta(c)	((c<QUOTE) && _ctype1[c]&(_META|T_EOF))
97*7c478bd9Sstevel@tonic-gate #define qotchar(c)	((c<QUOTE) && _ctype1[c]&(T_QOT))
98*7c478bd9Sstevel@tonic-gate #define eolchar(c)	((c<QUOTE) && _ctype1[c]&(T_EOR|T_EOF))
99*7c478bd9Sstevel@tonic-gate #define dipchar(c)	((c<QUOTE) && _ctype1[c]&(T_DIP))
100*7c478bd9Sstevel@tonic-gate #define subchar(c)	((c<QUOTE) && _ctype1[c]&(T_SUB|T_QOT))
101*7c478bd9Sstevel@tonic-gate #define escchar(c)	((c<QUOTE) && _ctype1[c]&(T_ESC))
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate extern
104*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
105*7c478bd9Sstevel@tonic-gate const
106*7c478bd9Sstevel@tonic-gate #endif
107*7c478bd9Sstevel@tonic-gate unsigned char   _ctype2[];
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #define	digit(c)	((c<QUOTE) && _ctype2[c]&(T_DIG))
110*7c478bd9Sstevel@tonic-gate #define dolchar(c)	((c<QUOTE) && _ctype2[c]&(T_AST|T_BRC|T_DIG|T_IDC|T_SHN))
111*7c478bd9Sstevel@tonic-gate #define defchar(c)	((c<QUOTE) && _ctype2[c]&(T_DEF))
112*7c478bd9Sstevel@tonic-gate #define setchar(c)	((c<QUOTE) && _ctype2[c]&(T_SET))
113*7c478bd9Sstevel@tonic-gate #define digchar(c)	((c<QUOTE) && _ctype2[c]&(T_AST|T_DIG))
114*7c478bd9Sstevel@tonic-gate #define	letter(c)	((c<QUOTE) && _ctype2[c]&(T_IDC))
115*7c478bd9Sstevel@tonic-gate #define alphanum(c)	((c<QUOTE) && _ctype2[c]&(_IDCH))
116*7c478bd9Sstevel@tonic-gate #define astchar(c)	((c<QUOTE) && _ctype2[c]&(T_AST))
117