xref: /titanic_41/usr/src/cmd/csh/sh.char.h (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley Software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*
18  * Macros to classify characters.
19  */
20 
21 #ifdef MBCHAR
22 #include <wchar.h>
23 #include <wctype.h>
24 #define	isauxspZ	(!isascii(Z)&&!(Z&QUOTE)&&iswspace(Z))
25 #define	isauxsp(c) 	(Z=((unsigned)(c)), isauxspZ)
26 /* Regocnizes non-ASCII space characters. */
27 #else
28 #include <ctype.h>
29 /* macros of macros to reduce further #ifdef MBCHAR later. Please be patient!*/
30 #define	iswdigit(c)	isdigit(c)
31 #define	iswalpha(c)	isalpha(c)
32 #define	isphonogram(c)	0
33 #define	isideogram(c)	0
34 #define	isauxsp(c) 	0
35 #define	isauxspZ 	0
36 #endif
37 extern unsigned short _cmap[];/* Defined in sh.char.c */
38 unsigned int	Z; 	/* A place to save macro arg to avoid side-effect!*/
39 
40 #define _Q	0x01		/* '" */
41 #define _Q1	0x02		/* ` */
42 #define _SP	0x04		/* space and tab */
43 #define _NL	0x08		/* \n */
44 #define _META	0x10		/* lex meta characters, sp #'`";&<>()|\t\n */
45 #define _GLOB	0x20		/* glob characters, *?{[` */
46 #define _ESC	0x40		/* \ */
47 #define _DOL	0x80		/* $ */
48 #define _DIG    0x100		/* 0-9 */
49 #define _LET    0x200		/* a-z, A-Z, _ 	NO LONGER OF REAL USE. */
50 
51 
52 #define quoted(c)     ((unsigned)(c) & QUOTE)
53 
54 #define	cmapZ(bits)	(isascii(Z)?(_cmap[Z] & (bits)):0)
55 #define cmap(c, bits)	(Z=((unsigned)(c)), cmapZ(bits))
56 
57 #define isglob(c)	cmap(c, _GLOB)
58 #define ismeta(c)	cmap(c, _META)
59 #define digit(c)	cmap(c, _DIG)
60 #define issp(c)		(Z=((unsigned)(c)), cmapZ( _SP)||isauxspZ)
61 /*WAS isspace(c)*/
62 #define isspnl(c)	(Z=((unsigned)(c)), cmapZ( _SP|_NL)||isauxspZ)
63 #define letter(c)	\
64 	(Z=((unsigned)(c)), !quoted(Z)&&(iswalpha(Z)||((Z)=='_')\
65 	||isphonogram(Z)||isideogram(Z)))
66 #define alnum(c)	\
67 	(Z=((unsigned)(c)), !quoted(Z)&&(iswalpha(Z)||((Z)=='_')\
68 	||iswdigit(Z)||isphonogram(Z)||isideogram(Z)))
69