Deleted Added
full compact
sh.char.h (100616) sh.char.h (145479)
1/* $Header: /src/pub/tcsh/sh.char.h,v 3.20 2002/07/01 20:50:21 christos Exp $ */
1/* $Header: /src/pub/tcsh/sh.char.h,v 3.26 2005/03/03 16:49:15 kim Exp $ */
2/*
3 * sh.char.h: Table for spotting special characters quickly
4 * Makes for very obscure but efficient coding.
5 */
6/*-
7 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * All rights reserved.
9 *

--- 22 unchanged lines hidden (view full) ---

32 * SUCH DAMAGE.
33 */
34#ifndef _h_sh_char
35#define _h_sh_char
36#if defined(NeXT) && defined(NLS)
37# include <appkit/NXCType.h>
38#else
39# include <ctype.h>
2/*
3 * sh.char.h: Table for spotting special characters quickly
4 * Makes for very obscure but efficient coding.
5 */
6/*-
7 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * All rights reserved.
9 *

--- 22 unchanged lines hidden (view full) ---

32 * SUCH DAMAGE.
33 */
34#ifndef _h_sh_char
35#define _h_sh_char
36#if defined(NeXT) && defined(NLS)
37# include <appkit/NXCType.h>
38#else
39# include <ctype.h>
40# ifdef SHORT_STRINGS
41# ifdef HAVE_WCTYPE_H
42# include <wctype.h>
43# else
44# include <wchar.h>
45# endif
46# endif
40#endif
41
42typedef unsigned char tcshuc;
43#ifdef _MINIX
44# undef _SP
45#endif /* _MINIX */
46extern unsigned short _cmap[];
47#if defined(DSPMBYTE)
47#endif
48
49typedef unsigned char tcshuc;
50#ifdef _MINIX
51# undef _SP
52#endif /* _MINIX */
53extern unsigned short _cmap[];
54#if defined(DSPMBYTE)
48extern unsigned short _mbmap[];
49# define CHECK_MBYTEVAR STRdspmbyte
50#endif
51extern unsigned short _cmap_c[];
52extern unsigned short _cmap_mbyte[];
53extern short _enable_mbdisp;
54extern unsigned short _mbmap[];
55extern unsigned short _mbmap_euc[];
56extern unsigned short _mbmap_sjis[];

--- 13 unchanged lines hidden (view full) ---

70#define _QB 0x0002 /* ` (Backquote) */
71#define _SP 0x0004 /* space and tab */
72#define _NL 0x0008 /* \n */
73#define _META 0x0010 /* lex meta characters, sp #'`";&<>()|\t\n */
74#define _GLOB 0x0020 /* glob characters, *?{[` */
75#define _ESC 0x0040 /* \ */
76#define _DOL 0x0080 /* $ */
77#define _DIG 0x0100 /* 0-9 */
55# define CHECK_MBYTEVAR STRdspmbyte
56#endif
57extern unsigned short _cmap_c[];
58extern unsigned short _cmap_mbyte[];
59extern short _enable_mbdisp;
60extern unsigned short _mbmap[];
61extern unsigned short _mbmap_euc[];
62extern unsigned short _mbmap_sjis[];

--- 13 unchanged lines hidden (view full) ---

76#define _QB 0x0002 /* ` (Backquote) */
77#define _SP 0x0004 /* space and tab */
78#define _NL 0x0008 /* \n */
79#define _META 0x0010 /* lex meta characters, sp #'`";&<>()|\t\n */
80#define _GLOB 0x0020 /* glob characters, *?{[` */
81#define _ESC 0x0040 /* \ */
82#define _DOL 0x0080 /* $ */
83#define _DIG 0x0100 /* 0-9 */
78#define _LET 0x0200 /* a-z, A-Z, _ */
79#define _UP 0x0400 /* A-Z */
80#define _DOW 0x0800 /* a-z */
84#define _LET 0x0200 /* a-z, A-Z, _, or locale-specific */
85#define _UP 0x0400 /* A-Z, or locale-specific */
86#define _DOW 0x0800 /* a-z, or locale-specific */
81#define _XD 0x1000 /* 0-9, a-f, A-F */
82#define _CMD 0x2000 /* lex end of command chars, ;&(|` */
83#define _CTR 0x4000 /* control */
84#define _PUN 0x8000 /* punctuation */
85
87#define _XD 0x1000 /* 0-9, a-f, A-F */
88#define _CMD 0x2000 /* lex end of command chars, ;&(|` */
89#define _CTR 0x4000 /* control */
90#define _PUN 0x8000 /* punctuation */
91
86#if defined(SHORT_STRINGS) && defined(KANJI)
92#ifdef IS_ASCII
87# define ASC(ch) ch
88# define CTL_ESC(ch) ch
93# define ASC(ch) ch
94# define CTL_ESC(ch) ch
89# define cmap(c, bits) \
90 ((((c) & QUOTE) || ((c & 0x80) && adrof(STRnokanji))) ? \
91 0 : (_cmap[(tcshuc)(c)] & (bits)))
92#else /* SHORT_STRINGS && KANJI */
93# ifdef IS_ASCII
94# define ASC(ch) ch
95# define CTL_ESC(ch) ch
96# define cmap(c, bits) \
97 (((c) & QUOTE) ? 0 : (_cmap[(tcshuc)(c)] & (bits)))
98# else /* IS_ASCII */
95#else
96# ifdef _OSD_POSIX
99/* "BS2000 OSD" is a POSIX on a main frame using a EBCDIC char set */
97/* "BS2000 OSD" is a POSIX on a main frame using a EBCDIC char set */
98# include <ascii_ebcdic.h>
99# else
100/* "OS/390 USS" is a POSIX on a main frame using an IBM1047 char set */
100/* "OS/390 USS" is a POSIX on a main frame using an IBM1047 char set */
101extern unsigned short _toascii[256];
102extern unsigned short _toebcdic[256];
101# endif
102 extern unsigned short _toascii[256];
103 extern unsigned short _toebcdic[256];
103
104/* mainly for comparisons if (ASC(ch)=='\177')... */
105# define ASC(ch) _toascii[(tcshuc)ch]
106
107/* Literal escapes ('\010') must be mapped to EBCDIC,
108 * for C-Escapes ('\b'), the compiler already does it.
109 */
110# define CTL_ESC(ch) _toebcdic[(tcshuc)ch]
104
105/* mainly for comparisons if (ASC(ch)=='\177')... */
106# define ASC(ch) _toascii[(tcshuc)ch]
107
108/* Literal escapes ('\010') must be mapped to EBCDIC,
109 * for C-Escapes ('\b'), the compiler already does it.
110 */
111# define CTL_ESC(ch) _toebcdic[(tcshuc)ch]
112#endif /*IS_ASCII*/
111
113
114#ifdef WIDE_STRINGS
115# define cmap(c, bits) \
116 (((c) & QUOTE) || (c) >= 0x0080 ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
117#elif defined(SHORT_STRINGS) && defined(KANJI)
112# define cmap(c, bits) \
118# define cmap(c, bits) \
113 (((c) & QUOTE) ? 0 : (_cmap[_toascii[(tcshuc)(c)]] & (bits)))
114# endif /* IS_ASCII */
119 ((((c) & QUOTE) || ((ASC(c) & 0x80) && adrof(STRnokanji))) ? \
120 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
121#else /* SHORT_STRINGS && KANJI */
122# define cmap(c, bits) \
123 (((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
115#endif /* SHORT_STRINGS && KANJI */
116
117#define isglob(c) cmap(c, _GLOB)
118#define isspc(c) cmap(c, _SP)
119#define ismeta(c) cmap(c, _META)
120#define iscmdmeta(c) cmap(c, _CMD)
124#endif /* SHORT_STRINGS && KANJI */
125
126#define isglob(c) cmap(c, _GLOB)
127#define isspc(c) cmap(c, _SP)
128#define ismeta(c) cmap(c, _META)
129#define iscmdmeta(c) cmap(c, _CMD)
121#define letter(c) (((Char)(c) & QUOTE) ? 0 : \
130#ifdef WIDE_STRINGS
131#define letter(c) (((c) & QUOTE) ? 0 : \
132 (iswalpha((tcshuc) (c)) || (c) == '_'))
133#define alnum(c) (((c) & QUOTE) ? 0 : \
134 (iswalnum((tcshuc) (c)) || (c) == '_'))
135#else
136#define letter(c) (((Char)(c) & QUOTE) ? 0 : \
122 (isalpha((tcshuc) (c)) || (c) == '_'))
137 (isalpha((tcshuc) (c)) || (c) == '_'))
123#define alnum(c) (((Char)(c) & QUOTE) ? 0 : \
138#define alnum(c) (((Char)(c) & QUOTE) ? 0 : \
124 (isalnum((tcshuc) (c)) || (c) == '_'))
139 (isalnum((tcshuc) (c)) || (c) == '_'))
140#endif
125
126#if defined(DSPMBYTE)
127# define IsmbyteU(c) (Ismbyte1((Char)(c))||(Ismbyte2((Char)(c))&&((c)&0200)))
128#endif
129
130#ifdef NLS
141
142#if defined(DSPMBYTE)
143# define IsmbyteU(c) (Ismbyte1((Char)(c))||(Ismbyte2((Char)(c))&&((c)&0200)))
144#endif
145
146#ifdef NLS
131# ifdef NeXT
147# ifdef WIDE_STRINGS
148# define Isspace(c) (((c) & QUOTE) ? 0 : iswspace(c))
149# define Isdigit(c) (((c) & QUOTE) ? 0 : iswdigit(c))
150# define Isalpha(c) (((c) & QUOTE) ? 0 : iswalpha(c))
151# define Islower(c) (((c) & QUOTE) ? 0 : iswlower(c))
152# define Isupper(c) (((c) & QUOTE) ? 0 : iswupper(c))
153# define Tolower(c) (((c) & QUOTE) ? 0 : (wchar_t)towlower(c))
154# define Toupper(c) (((c) & QUOTE) ? 0 : (wchar_t)towupper(c))
155# define Isxdigit(c) (((c) & QUOTE) ? 0 : iswxdigit(c))
156# define Isalnum(c) (((c) & QUOTE) ? 0 : iswalnum(c))
157# define Iscntrl(c) (((c) & QUOTE) ? 0 : iswcntrl(c))
158# define Isprint(c) (((c) & QUOTE) ? 0 : iswprint(c))
159# define Ispunct(c) (((c) & QUOTE) ? 0 : iswpunct(c))
160# elif defined (NeXT)
132# define Isspace(c) (((Char)(c) & QUOTE) ? 0 : NXIsSpace((unsigned) (c)))
133# define Isdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsDigit((unsigned) (c)))
134# define Isalpha(c) (((Char)(c) & QUOTE) ? 0 : NXIsAlpha((unsigned) (c)))
135# define Islower(c) (((Char)(c) & QUOTE) ? 0 : NXIsLower((unsigned) (c)))
136# define Isupper(c) (((Char)(c) & QUOTE) ? 0 : NXIsUpper((unsigned) (c)))
137# define Tolower(c) (((Char)(c) & QUOTE) ? 0 : NXToLower((unsigned) (c)))
138# define Toupper(c) (((Char)(c) & QUOTE) ? 0 : NXToUpper((unsigned) (c)))
139# define Isxdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsXDigit((unsigned) (c)))

--- 73 unchanged lines hidden (view full) ---

213# endif /* WINNT_NATIVE */
214# endif /* !NeXT */
215#else /* !NLS */
216# define Isspace(c) cmap(c, _SP|_NL)
217# define Isdigit(c) cmap(c, _DIG)
218# define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
219# define Islower(c) (cmap(c,_DOW) && !(((c) & META) && AsciiOnly))
220# define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
161# define Isspace(c) (((Char)(c) & QUOTE) ? 0 : NXIsSpace((unsigned) (c)))
162# define Isdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsDigit((unsigned) (c)))
163# define Isalpha(c) (((Char)(c) & QUOTE) ? 0 : NXIsAlpha((unsigned) (c)))
164# define Islower(c) (((Char)(c) & QUOTE) ? 0 : NXIsLower((unsigned) (c)))
165# define Isupper(c) (((Char)(c) & QUOTE) ? 0 : NXIsUpper((unsigned) (c)))
166# define Tolower(c) (((Char)(c) & QUOTE) ? 0 : NXToLower((unsigned) (c)))
167# define Toupper(c) (((Char)(c) & QUOTE) ? 0 : NXToUpper((unsigned) (c)))
168# define Isxdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsXDigit((unsigned) (c)))

--- 73 unchanged lines hidden (view full) ---

242# endif /* WINNT_NATIVE */
243# endif /* !NeXT */
244#else /* !NLS */
245# define Isspace(c) cmap(c, _SP|_NL)
246# define Isdigit(c) cmap(c, _DIG)
247# define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
248# define Islower(c) (cmap(c,_DOW) && !(((c) & META) && AsciiOnly))
249# define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
221# ifdef IS_ASCII
222# define Tolower(c) (_cmap_lower[(tcshuc)(c)])
223# define Toupper(c) (_cmap_upper[(tcshuc)(c)])
224# else
225/* "BS2000 OSD" is a POSIX on a main frame using a EBCDIC char set */
226# define Tolower(c) (_cmap_lower[_toascii[(tcshuc)(c)]])
227# define Toupper(c) (_cmap_upper[_toascii[(tcshuc)(c)]])
228# endif
250# define Tolower(c) (_cmap_lower[ASC(c)])
251# define Toupper(c) (_cmap_upper[ASC(c)])
229# define Isxdigit(c) cmap(c, _XD)
230# define Isalnum(c) (cmap(c, _DIG|_LET) && !(((Char)(c) & META) && AsciiOnly))
231#if defined(DSPMBYTE)
232# define IscntrlM(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
233# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
234# define IsprintM(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
235# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
236#else
237# define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
238# define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
239#endif /* !defined(DSPMBYTE) */
240# define Ispunct(c) (cmap(c,_PUN) && !(((c) & META) && AsciiOnly))
241
242#endif /* !NLS */
243
252# define Isxdigit(c) cmap(c, _XD)
253# define Isalnum(c) (cmap(c, _DIG|_LET) && !(((Char)(c) & META) && AsciiOnly))
254#if defined(DSPMBYTE)
255# define IscntrlM(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
256# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
257# define IsprintM(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
258# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
259#else
260# define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
261# define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
262#endif /* !defined(DSPMBYTE) */
263# define Ispunct(c) (cmap(c,_PUN) && !(((c) & META) && AsciiOnly))
264
265#endif /* !NLS */
266
267#if defined (SHORT_STRINGS) && defined (NLS)
268# define Iswcntrl(c) (((c) & QUOTE) ? 0 : iswcntrl(c))
269# define Iswprint(c) (((c) & QUOTE) ? 0 : iswprint(c))
270#else
271# define Iswcntrl(c) Iscntrl(c)
272# define Iswprint(c) Isprint(c)
273#endif
274
244#if defined(DSPMBYTE)
245# define Ismbyte1(c) ((_mbmap[(c) & 0377] & _MB1) ? 1 : 0)
246# define Ismbyte2(c) ((_mbmap[(c) & 0377] & _MB2) ? 1 : 0)
247#endif
248
249#endif /* _h_sh_char */
275#if defined(DSPMBYTE)
276# define Ismbyte1(c) ((_mbmap[(c) & 0377] & _MB1) ? 1 : 0)
277# define Ismbyte2(c) ((_mbmap[(c) & 0377] & _MB2) ? 1 : 0)
278#endif
279
280#endif /* _h_sh_char */