Commit | Line | Data |
---|---|---|
ecc449eb KB |
1 | /*- |
2 | * Copyright (c) 1980, 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
b79f4fa9 | 4 | * |
ecc449eb KB |
5 | * %sccs.include.redist.c% |
6 | * | |
6e37afca | 7 | * @(#)char.h 5.6 (Berkeley) %G% |
13a4113c EW |
8 | */ |
9 | ||
6e37afca KB |
10 | #include <ctype.h> |
11 | ||
c2dc294d | 12 | extern unsigned short _cmap[]; |
13a4113c | 13 | |
6e37afca KB |
14 | #ifndef NLS |
15 | extern unsigned char _cmap_lower[], _cmap_upper[]; | |
ff4a8f19 | 16 | |
6e37afca | 17 | #endif |
ff4a8f19 | 18 | |
6e37afca KB |
19 | #define _Q 0x0001 /* '" */ |
20 | #define _Q1 0x0002 /* ` */ | |
21 | #define _SP 0x0004 /* space and tab */ | |
22 | #define _NL 0x0008 /* \n */ | |
23 | #define _META 0x0010 /* lex meta characters, sp #'`";&<>()|\t\n */ | |
24 | #define _GLOB 0x0020 /* glob characters, *?{[` */ | |
25 | #define _ESC 0x0040 /* \ */ | |
26 | #define _DOL 0x0080 /* $ */ | |
27 | #define _DIG 0x0100 /* 0-9 */ | |
28 | #define _LET 0x0200 /* a-z, A-Z, _ */ | |
29 | #define _UP 0x0400 /* A-Z */ | |
30 | #define _LOW 0x0800 /* a-z */ | |
31 | #define _XD 0x1000 /* 0-9, a-f, A-F */ | |
32 | #define _CMD 0x2000 /* lex end of command chars, ;&(|` */ | |
33 | #define _CTR 0x4000 /* control */ | |
13a4113c | 34 | |
6e37afca KB |
35 | #define cmap(c, bits) \ |
36 | (((c) & QUOTE) ? 0 : (_cmap[(unsigned char)(c)] & (bits))) | |
13a4113c | 37 | |
6e37afca KB |
38 | #define isglob(c) cmap(c, _GLOB) |
39 | #define isspc(c) cmap(c, _SP) | |
40 | #define ismeta(c) cmap(c, _META) | |
41 | #define iscmdmeta(c) cmap(c, _CMD) | |
42 | #define letter(c) (((c) & QUOTE) ? 0 : \ | |
43 | (isalpha((unsigned char) (c)) || (c) == '_')) | |
44 | #define alnum(c) (((c) & QUOTE) ? 0 : \ | |
45 | (isalnum((unsigned char) (c)) || (c) == '_')) | |
46 | #ifdef NLS | |
47 | #define Isspace(c) (((c) & QUOTE) ? 0 : isspace((unsigned char) (c))) | |
48 | #define Isdigit(c) (((c) & QUOTE) ? 0 : isdigit((unsigned char) (c))) | |
49 | #define Isalpha(c) (((c) & QUOTE) ? 0 : isalpha((unsigned char) (c))) | |
50 | #define Islower(c) (((c) & QUOTE) ? 0 : islower((unsigned char) (c))) | |
51 | #define Isupper(c) (((c) & QUOTE) ? 0 : isupper((unsigned char) (c))) | |
52 | #define Tolower(c) (((c) & QUOTE) ? 0 : tolower((unsigned char) (c))) | |
53 | #define Toupper(c) (((c) & QUOTE) ? 0 : toupper((unsigned char) (c))) | |
54 | #define Isxdigit(c) (((c) & QUOTE) ? 0 : isxdigit((unsigned char) (c))) | |
55 | #define Isalnum(c) (((c) & QUOTE) ? 0 : isalnum((unsigned char) (c))) | |
56 | #define Iscntrl(c) (((c) & QUOTE) ? 0 : iscntrl((unsigned char) (c))) | |
57 | #define Isprint(c) (((c) & QUOTE) ? 0 : isprint((unsigned char) (c))) | |
58 | #else | |
59 | #define Isspace(c) cmap(c, _SP|_NL) | |
60 | #define Isdigit(c) cmap(c, _DIG) | |
61 | #define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly)) | |
62 | #define Islower(c) (cmap(c,_LOW) && !(((c) & META) && AsciiOnly)) | |
63 | #define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly)) | |
64 | #define Tolower(c) (_cmap_lower[(unsigned char)(c)]) | |
65 | #define Toupper(c) (_cmap_upper[(unsigned char)(c)]) | |
66 | #define Isxdigit(c) cmap(c, _XD) | |
67 | #define Isalnum(c) (cmap(c, _DIG|_LET) && !(((c) & META) && AsciiOnly)) | |
68 | #define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly)) | |
69 | #define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly)) | |
70 | #endif |