1 #
2 /*
3  *	UNIX shell
4  *
5  *	S. R. Bourne
6  *	Bell Telephone Laboratories
7  *
8  */
9 
10 
11 /* table 1 */
12 #define T_SUB	01
13 #define T_MET	02
14 #define	T_SPC	04
15 #define T_DIP	010
16 #define T_EOF	020
17 #define T_EOR	040
18 #define T_QOT	0100
19 #define T_ESC	0200
20 
21 /* table 2 */
22 #define T_BRC	01
23 #define T_DEF	02
24 #define T_AST	04
25 #define	T_DIG	010
26 #define T_FNG	020
27 #define T_SHN	040
28 #define	T_IDC	0100
29 #define T_SET	0200
30 
31 /* for single chars */
32 #define _TAB	(T_SPC)
33 #define _SPC	(T_SPC)
34 #define _UPC	(T_IDC)
35 #define _LPC	(T_IDC)
36 #define _DIG	(T_DIG)
37 #define _EOF	(T_EOF)
38 #define _EOR	(T_EOR)
39 #define _BAR	(T_DIP)
40 #define _HAT	(T_MET)
41 #define _BRA	(T_MET)
42 #define _KET	(T_MET)
43 #define _SQB	(T_FNG)
44 #define _AMP	(T_DIP)
45 #define _SEM	(T_DIP)
46 #define _LT	(T_DIP)
47 #define _GT	(T_DIP)
48 #define _LQU	(T_QOT|T_ESC)
49 #define _BSL	(T_ESC)
50 #define _DQU	(T_QOT)
51 #define _DOL1	(T_SUB|T_ESC)
52 
53 #define _CBR	T_BRC
54 #define _CKT	T_DEF
55 #define _AST	(T_AST|T_FNG)
56 #define _EQ	(T_DEF)
57 #define _MIN	(T_DEF|T_SHN)
58 #define _PCS	(T_SHN)
59 #define _NUM	(T_SHN)
60 #define _DOL2	(T_SHN)
61 #define _PLS	(T_DEF|T_SET)
62 #define _AT	(T_AST)
63 #define _QU	(T_DEF|T_FNG|T_SHN)
64 
65 /* abbreviations for tests */
66 #define _IDCH	(T_IDC|T_DIG)
67 #define _META	(T_SPC|T_DIP|T_MET|T_EOR)
68 
69 extern char	_ctype1[];
70 
71 /* nb these args are not call by value !!!! */
72 #define	space(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_SPC))
73 #define eofmeta(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(_META|T_EOF))
74 #define qotchar(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_QOT))
75 #define eolchar(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_EOR|T_EOF))
76 #define dipchar(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_DIP))
77 #define subchar(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_SUB|T_QOT))
78 #define escchar(c)	(((c)&QUOTE)==0 ANDF _ctype1[c]&(T_ESC))
79 
80 extern char	_ctype2[];
81 
82 #define	digit(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_DIG))
83 #ifndef SYSIII
84 #define fngchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_FNG))
85 #endif
86 #define dolchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_AST|T_BRC|T_DIG|T_IDC|T_SHN))
87 #define defchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_DEF))
88 #define setchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_SET))
89 #define digchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_AST|T_DIG))
90 #define	letter(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_IDC))
91 #define alphanum(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(_IDCH))
92 #define astchar(c)	(((c)&QUOTE)==0 ANDF _ctype2[c]&(T_AST))
93