| 1 | /* @(#)char.h 4.1 (Berkeley) %G% */ |
| 2 | |
| 3 | /* |
| 4 | * Table for spotting special characters quickly |
| 5 | * |
| 6 | * Makes for very obscure but efficient coding. |
| 7 | */ |
| 8 | |
| 9 | extern char _cmap[]; |
| 10 | |
| 11 | #define _Q 0x01 /* '" */ |
| 12 | #define _Q1 0x02 /* ` */ |
| 13 | #define _SP 0x04 /* space and tab */ |
| 14 | #define _NL 0x08 /* \n */ |
| 15 | #define _META 0x10 /* lex meta characters, sp #'`";&<>()|\t\n */ |
| 16 | #define _GLOB 0x20 /* glob characters, *?{[` */ |
| 17 | #define _ESC 0x40 /* \ */ |
| 18 | #define _DOL 0x80 /* $ */ |
| 19 | |
| 20 | #define cmap(c, bits) (_cmap[(unsigned char)(c)] & (bits)) |
| 21 | |
| 22 | #define isglob(c) cmap(c, _GLOB) |
| 23 | #define isspace(c) cmap(c, _SP) |
| 24 | #define isspnl(c) cmap(c, _SP|_NL) |
| 25 | #define ismeta(c) cmap(c, _META) |