1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley Software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)char.h 5.3 (Berkeley) 03/29/86 7 */ 8 9 /* 10 * Table for spotting special characters quickly 11 * 12 * Makes for very obscure but efficient coding. 13 */ 14 15 extern unsigned short _cmap[]; 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 /* $ */ 25 #define _DIG 0x100 /* 0-9 */ 26 #define _LET 0x200 /* a-z, A-Z, _ */ 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) 34 #define digit(c) cmap(c, _DIG) 35 #define letter(c) cmap(c, _LET) 36 #define alnum(c) (digit(c) || letter(c)) 37