#ifndef _h_sh_char
#define _h_sh_char
#if defined(NeXT) && defined(NLS)
# include <appkit/NXCType.h>
#else
# include <ctype.h>
# ifdef WIDE_STRINGS
# ifdef HAVE_WCTYPE_H
# include <wctype.h>
# else
# include <wchar.h>
# endif
# endif
#endif
typedef unsigned char tcshuc;
#ifdef _MINIX
# undef _SP
#endif
extern unsigned short _cmap[];
#if defined(DSPMBYTE)
# define CHECK_MBYTEVAR STRdspmbyte
#endif
extern unsigned short _cmap_c[];
extern unsigned short _cmap_mbyte[];
extern short _enable_mbdisp;
extern unsigned short _mbmap[];
extern unsigned short _mbmap_euc[];
extern unsigned short _mbmap_sjis[];
extern unsigned short _mbmap_big5[];
extern unsigned short _mbmap_utf8[];
#define _MB1 0x0001
#define _MB2 0x0002
#ifndef NLS
extern tcshuc _cmap_lower[], _cmap_upper[];
#endif
#define _QF 0x0001
#define _QB 0x0002
#define _SP 0x0004
#define _NL 0x0008
#define _META 0x0010
#define _GLOB 0x0020
#define _ESC 0x0040
#define _DOL 0x0080
#define _DIG 0x0100
#define _LET 0x0200
#define _UP 0x0400
#define _DOW 0x0800
#define _XD 0x1000
#define _CMD 0x2000
#define _CTR 0x4000
#define _PUN 0x8000
#ifdef IS_ASCII
# define ASC(ch) (ch)
# define CTL_ESC(ch) (ch)
#else
# ifdef _OSD_POSIX
# include <ascii_ebcdic.h>
# else
# endif
extern unsigned short _toascii[256];
extern unsigned short _toebcdic[256];
# define ASC(ch) _toascii[(tcshuc)(ch)]
# define CTL_ESC(ch) _toebcdic[(tcshuc)(ch)]
#endif
#ifdef WIDE_STRINGS
# define cmap(c, bits) \
(((c) < 0) ? 0 : \
((c) & QUOTE) || (c) >= 0x0080 ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#elif defined(SHORT_STRINGS) && defined(KANJI)
# define cmap(c, bits) \
(((c) < 0) ? 0 : \
(((c) & QUOTE) || ((ASC(c) & 0x80) && adrof(STRnokanji))) ? \
0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#else
# define cmap(c, bits) \
(((c) < 0) ? 0 : \
((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#endif
#define isglob(c) cmap((c), _GLOB)
#define isspc(c) cmap((c), _SP)
#define ismeta(c) cmap((c), _META)
#define iscmdmeta(c) cmap((c), _CMD)
#ifdef WIDE_STRINGS
#define letter(c) (((c) & QUOTE) ? 0 : \
(iswalpha((tcshuc) (c)) || (c) == '_'))
#define alnum(c) (((c) & QUOTE) ? 0 : \
(iswalnum((tcshuc) (c)) || (c) == '_'))
#else
#define letter(c) (((Char)(c) & QUOTE) ? 0 : \
(isalpha((tcshuc) (c)) || (c) == '_'))
#define alnum(c) (((Char)(c) & QUOTE) ? 0 : \
(isalnum((tcshuc) (c)) || (c) == '_'))
#endif
#if defined(DSPMBYTE)
# define IsmbyteU(c) (Ismbyte1((Char)(c))||(Ismbyte2((Char)(c))&&((c)&0200)))
#endif
#ifdef NLS
# ifdef WIDE_STRINGS
# define Isspace(c) (((c) & QUOTE) ? 0 : iswspace(c))
# define Isdigit(c) (((c) & QUOTE) ? 0 : iswdigit(c))
# define Isalpha(c) (((c) & QUOTE) ? 0 : iswalpha(c))
# define Islower(c) (((c) & QUOTE) ? 0 : iswlower(c))
# define Isupper(c) (((c) & QUOTE) ? 0 : iswupper(c))
# define Tolower(c) (((c) & QUOTE) ? 0 : (wchar_t)towlower(c))
# define Toupper(c) (((c) & QUOTE) ? 0 : (wchar_t)towupper(c))
# define Isxdigit(c) (((c) & QUOTE) ? 0 : iswxdigit(c))
# define Isalnum(c) (((c) & QUOTE) ? 0 : iswalnum(c))
# define Iscntrl(c) (((c) & QUOTE) ? 0 : iswcntrl(c))
# define Isprint(c) (((c) & QUOTE) ? 0 : iswprint(c))
# define Ispunct(c) (((c) & QUOTE) ? 0 : iswpunct(c))
# elif defined (NeXT)
# define Isspace(c) (((Char)(c) & QUOTE) ? 0 : NXIsSpace((unsigned) (c)))
# define Isdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsDigit((unsigned) (c)))
# define Isalpha(c) (((Char)(c) & QUOTE) ? 0 : NXIsAlpha((unsigned) (c)))
# define Islower(c) (((Char)(c) & QUOTE) ? 0 : NXIsLower((unsigned) (c)))
# define Isupper(c) (((Char)(c) & QUOTE) ? 0 : NXIsUpper((unsigned) (c)))
# define Tolower(c) (((Char)(c) & QUOTE) ? 0 : NXToLower((unsigned) (c)))
# define Toupper(c) (((Char)(c) & QUOTE) ? 0 : NXToUpper((unsigned) (c)))
# define Isxdigit(c) (((Char)(c) & QUOTE) ? 0 : NXIsXDigit((unsigned) (c)))
#if defined(DSPMBYTE)
# define IscntrlM(c) (((Char)(c) & QUOTE) ? 0 : NXIsCntrl((unsigned) (c)))
# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
# define IsprintM(c) (((Char)(c) & QUOTE) ? 0 : NXIsPrint((unsigned) (c)))
# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
#else
# define Isalnum(c) (((Char)(c) & QUOTE) ? 0 : NXIsAlNum((unsigned) (c)))
# define Iscntrl(c) (((Char)(c) & QUOTE) ? 0 : NXIsCntrl((unsigned) (c)))
# define Isprint(c) (((Char)(c) & QUOTE) ? 0 : NXIsPrint((unsigned) (c)))
#endif
# define Ispunct(c) (((Char)(c) & QUOTE) ? 0 : NXIsPunct((unsigned) (c)))
# else
# ifndef WINNT_NATIVE
# define Isspace(c) (((Char)(c) & QUOTE) ? 0 : isspace((tcshuc) (c)))
# define Isdigit(c) (((Char)(c) & QUOTE) ? 0 : isdigit((tcshuc) (c)))
# define Isalpha(c) (((Char)(c) & QUOTE) ? 0 : isalpha((tcshuc) (c)))
# define Islower(c) (((Char)(c) & QUOTE) ? 0 : islower((tcshuc) (c)))
# define Isupper(c) (((Char)(c) & QUOTE) ? 0 : isupper((tcshuc) (c)))
# define Tolower(c) (((Char)(c) & QUOTE) ? 0 : tolower((tcshuc) (c)))
# define Toupper(c) (((Char)(c) & QUOTE) ? 0 : toupper((tcshuc) (c)))
# define Isxdigit(c) (((Char)(c) & QUOTE) ? 0 : isxdigit((tcshuc) (c)))
# define Isalnum(c) (((Char)(c) & QUOTE) ? 0 : isalnum((tcshuc) (c)))
#if defined(DSPMBYTE)
# define IscntrlM(c) (((Char)(c) & QUOTE) ? 0 : iscntrl((tcshuc) (c)))
# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
#else
# define Iscntrl(c) (((Char)(c) & QUOTE) ? 0 : iscntrl((tcshuc) (c)))
#endif
# if SOLARIS2 == 24
#if defined(DSPMBYTE)
# define IsprintM(c) (((Char)(c) & QUOTE) ? 0 : \
(isprint((tcshuc) (c)) && (c) != '\t'))
#else
# define Isprint(c) (((Char)(c) & QUOTE) ? 0 : \
(isprint((tcshuc) (c)) && (c) != '\t'))
#endif
# else
#if defined(DSPMBYTE)
# define IsprintM(c) (((Char)(c) & QUOTE) ? 0 : isprint((tcshuc) (c)))
#else
# define Isprint(c) (((Char)(c) & QUOTE) ? 0 : isprint((tcshuc) (c)))
#endif
# endif
#if defined(DSPMBYTE)
# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
#endif
# define Ispunct(c) (((Char)(c) & QUOTE) ? 0 : ispunct((tcshuc) (c)))
# else
# define Isspace(c) (((Char)(c) & QUOTE) ? 0 : isspace( oem_it((tcshuc)(c))))
# define Isdigit(c) (((Char)(c) & QUOTE) ? 0 : isdigit( oem_it((tcshuc)(c))))
# define Isalpha(c) (((Char)(c) & QUOTE) ? 0 : isalpha( oem_it((tcshuc)(c))))
# define Islower(c) (((Char)(c) & QUOTE) ? 0 : islower( oem_it((tcshuc)(c))))
# define Isupper(c) (((Char)(c) & QUOTE) ? 0 : isupper( oem_it((tcshuc)(c))))
# define Tolower(c) (((Char)(c) & QUOTE) ? 0 : tolower( oem_it((tcshuc)(c))))
# define Toupper(c) (((Char)(c) & QUOTE) ? 0 : toupper( oem_it((tcshuc)(c))))
# define Isxdigit(c)(((Char)(c) & QUOTE) ? 0 : isxdigit(oem_it((tcshuc)(c))))
# define Isalnum(c) (((Char)(c) & QUOTE) ? 0 : isalnum( oem_it((tcshuc)(c))))
# define Ispunct(c) (((Char)(c) & QUOTE) ? 0 : ispunct( oem_it((tcshuc)(c))))
#if defined(DSPMBYTE)
# define IscntrlM(c) (((Char)(c) & QUOTE) ? 0 : iscntrl( oem_it((tcshuc)(c))))
# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
# define IsprintM(c) (((Char)(c) & QUOTE) ? 0 : isprint( oem_it((tcshuc)(c))))
# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
#else
# define Iscntrl(c) (((Char)(c) & QUOTE) ? 0 : iscntrl( oem_it((tcshuc)(c))))
# define Isprint(c) (((Char)(c) & QUOTE) ? 0 : isprint( oem_it((tcshuc)(c))))
#endif
# endif
# endif
#else
# define Isspace(c) cmap((c), _SP|_NL)
# define Isdigit(c) cmap((c), _DIG)
# define Isalpha(c) (cmap((c),_LET) && !(((c) & META) && AsciiOnly))
# define Islower(c) (cmap((c),_DOW) && !(((c) & META) && AsciiOnly))
# define Isupper(c) (cmap((c), _UP) && !(((c) & META) && AsciiOnly))
# define Tolower(c) (_cmap_lower[ASC(c)])
# define Toupper(c) (_cmap_upper[ASC(c)])
# define Isxdigit(c) cmap((c), _XD)
# define Isalnum(c) (cmap((c), _DIG|_LET) && !(((Char)(c) & META) && AsciiOnly))
#if defined(DSPMBYTE)
# define IscntrlM(c) (cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
# define IsprintM(c) (!cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
#else
# define Iscntrl(c) (cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
# define Isprint(c) (!cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
#endif
# define Ispunct(c) (cmap((c),_PUN) && !(((c) & META) && AsciiOnly))
#endif
#if defined(DSPMBYTE)
# define Ismbyte1(c) ((_mbmap[(c) & 0377] & _MB1) ? 1 : 0)
# define Ismbyte2(c) ((_mbmap[(c) & 0377] & _MB2) ? 1 : 0)
#endif
#endif