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