BSD 4_3_Tahoe release
[unix-history] / usr / src / bin / csh / sh.char.h
CommitLineData
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 *
ca67e7b4 6 * @(#)sh.char.h 5.4 (Berkeley) 6/6/88
13a4113c
EW
7 */
8
c2dc294d 9extern unsigned short _cmap[];
13a4113c 10
ff4a8f19
KB
11#define _Q 0x001 /* '" */
12#define _Q1 0x002 /* ` */
13#define _SP 0x004 /* space and tab */
14#define _NL 0x008 /* \n */
15#define _META 0x010 /* lex meta characters, sp #'`";&<>()|\t\n */
16#define _GLOB 0x020 /* glob characters, *?{[` */
17#define _ESC 0x040 /* \ */
18#define _DOL 0x080 /* $ */
19#define _DIG 0x100 /* 0-9 */
20#define _LET 0x200 /* a-z, A-Z, _ */
21
22#define cmap(c, bits) (_cmap[(unsigned char)(c)] & (bits))
23
24#define isglob(c) cmap(c, _GLOB)
25#define isspace(c) cmap(c, _SP)
26#define isspnl(c) cmap(c, _SP|_NL)
27#define ismeta(c) cmap(c, _META)
28#define digit(c) cmap(c, _DIG)
29#define letter(c) cmap(c, _LET)
30#define alnum(c) (digit(c) || letter(c))
13a4113c 31
ff4a8f19
KB
32#define LINELEN 128
33extern char *linp, linbuf[LINELEN];
13a4113c 34
ff4a8f19
KB
35#define CSHPUTCHAR { \
36 if (!(ch&QUOTE) && (ch == 0177 || ch < ' ' && ch != '\t' && \
37 ch != '\n')) { \
38 *linp++ = '^'; \
39 if (ch == 0177) \
40 ch = '?'; \
41 else \
42 ch |= 'A' - 1; \
43 if (linp >= &linbuf[sizeof linbuf - 2]) \
44 flush(); \
45 } \
46 ch &= TRIM; \
47 *linp++ = ch; \
48 if (ch == '\n' || linp >= &linbuf[sizeof(linbuf) - 2]) \
49 flush(); \
50}