1 /*
2  * ztype.h - character classification macros
3  *
4  * This file is part of zsh, the Z shell.
5  *
6  * Copyright (c) 1992-1997 Paul Falstad
7  * All rights reserved.
8  *
9  * Permission is hereby granted, without written agreement and without
10  * license or royalty fees, to use, copy, modify, and distribute this
11  * software and to distribute modified versions of this software for any
12  * purpose, provided that the above copyright notice and the following
13  * two paragraphs appear in all copies of this software.
14  *
15  * In no event shall Paul Falstad or the Zsh Development Group be liable
16  * to any party for direct, indirect, special, incidental, or consequential
17  * damages arising out of the use of this software and its documentation,
18  * even if Paul Falstad and the Zsh Development Group have been advised of
19  * the possibility of such damage.
20  *
21  * Paul Falstad and the Zsh Development Group specifically disclaim any
22  * warranties, including, but not limited to, the implied warranties of
23  * merchantability and fitness for a particular purpose.  The software
24  * provided hereunder is on an "as is" basis, and Paul Falstad and the
25  * Zsh Development Group have no obligation to provide maintenance,
26  * support, updates, enhancements, or modifications.
27  *
28  */
29 
30 #define IDIGIT   (1 <<  0)
31 #define IALNUM   (1 <<  1)
32 #define IBLANK   (1 <<  2)
33 #define INBLANK  (1 <<  3)
34 #define ITOK     (1 <<  4)
35 #define ISEP     (1 <<  5)
36 #define IALPHA   (1 <<  6)
37 #define IIDENT   (1 <<  7)
38 #define IUSER    (1 <<  8)
39 #define ICNTRL   (1 <<  9)
40 #define IWORD    (1 << 10)
41 #define ISPECIAL (1 << 11)
42 #define IMETA    (1 << 12)
43 #define IWSEP    (1 << 13)
44 #define INULL    (1 << 14)
45 #define IPATTERN (1 << 15)
46 #define zistype(X,Y) (typtab[STOUC(X)] & Y)
47 #define idigit(X) zistype(X,IDIGIT)
48 #define ialnum(X) zistype(X,IALNUM)
49 #define iblank(X) zistype(X,IBLANK)	/* blank, not including \n */
50 #define inblank(X) zistype(X,INBLANK)	/* blank or \n */
51 #define itok(X) zistype(X,ITOK)
52 #define isep(X) zistype(X,ISEP)
53 #define ialpha(X) zistype(X,IALPHA)
54 #define iident(X) zistype(X,IIDENT)
55 #define iuser(X) zistype(X,IUSER)	/* username char */
56 #define icntrl(X) zistype(X,ICNTRL)
57 #define iword(X) zistype(X,IWORD)
58 #define ispecial(X) zistype(X,ISPECIAL)
59 #define imeta(X) zistype(X,IMETA)
60 #define iwsep(X) zistype(X,IWSEP)
61 #define inull(X) zistype(X,INULL)
62 #define ipattern(X) zistype(X,IPATTERN)
63 
64 /*
65  * Bit flags for typtab_flags --- preserved after
66  * shell initialisation.
67  */
68 #define ZTF_INIT     (0x0001) /* One-off initialisation done */
69 #define ZTF_INTERACT (0x0002) /* Shell interactive and reading from stdin */
70 #define ZTF_SP_COMMA (0x0004) /* Treat comma as a special characters */
71 #define ZTF_BANGCHAR (0x0008) /* Treat bangchar as a special character */
72 
73 #ifdef MULTIBYTE_SUPPORT
74 #define WC_ZISTYPE(X,Y) wcsitype((X),(Y))
75 # ifdef ENABLE_UNICODE9
76 #  define WC_ISPRINT(X)	u9_iswprint(X)
77 # else
78 #  define WC_ISPRINT(X)	iswprint(X)
79 # endif
80 #else
81 #define WC_ZISTYPE(X,Y)	zistype((X),(Y))
82 #define WC_ISPRINT(X)	isprint(X)
83 #endif
84 
85 #if defined(__APPLE__) && defined(BROKEN_ISPRINT)
86 #define ZISPRINT(c)  isprint_ascii(c)
87 #else
88 #define ZISPRINT(c)  isprint(c)
89 #endif
90