Commit | Line | Data |
---|---|---|
b79f4fa9 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
094e80ed | 3 | * All rights reserved. The Berkeley Software License Agreement |
b79f4fa9 DF |
4 | * specifies the terms and conditions for redistribution. |
5 | * | |
c2dc294d | 6 | * @(#)char.h 5.3 (Berkeley) %G% |
b79f4fa9 | 7 | */ |
13a4113c EW |
8 | |
9 | /* | |
10 | * Table for spotting special characters quickly | |
11 | * | |
12 | * Makes for very obscure but efficient coding. | |
13 | */ | |
14 | ||
c2dc294d | 15 | extern unsigned short _cmap[]; |
13a4113c EW |
16 | |
17 | #define _Q 0x01 /* '" */ | |
18 | #define _Q1 0x02 /* ` */ | |
19 | #define _SP 0x04 /* space and tab */ | |
20 | #define _NL 0x08 /* \n */ | |
21 | #define _META 0x10 /* lex meta characters, sp #'`";&<>()|\t\n */ | |
22 | #define _GLOB 0x20 /* glob characters, *?{[` */ | |
23 | #define _ESC 0x40 /* \ */ | |
24 | #define _DOL 0x80 /* $ */ | |
c2dc294d JL |
25 | #define _DIG 0x100 /* 0-9 */ |
26 | #define _LET 0x200 /* a-z, A-Z, _ */ | |
13a4113c EW |
27 | |
28 | #define cmap(c, bits) (_cmap[(unsigned char)(c)] & (bits)) | |
29 | ||
30 | #define isglob(c) cmap(c, _GLOB) | |
31 | #define isspace(c) cmap(c, _SP) | |
32 | #define isspnl(c) cmap(c, _SP|_NL) | |
33 | #define ismeta(c) cmap(c, _META) | |
c2dc294d JL |
34 | #define digit(c) cmap(c, _DIG) |
35 | #define letter(c) cmap(c, _LET) | |
36 | #define alnum(c) (digit(c) || letter(c)) |