17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley Software License Agreement 127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate /* 167c478bd9Sstevel@tonic-gate * Macros to classify characters. 177c478bd9Sstevel@tonic-gate */ 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate #ifdef MBCHAR 207c478bd9Sstevel@tonic-gate #include <wchar.h> 217c478bd9Sstevel@tonic-gate #include <wctype.h> 227c478bd9Sstevel@tonic-gate #define isauxspZ (!isascii(Z)&&!(Z"E)&&iswspace(Z)) 237c478bd9Sstevel@tonic-gate #define isauxsp(c) (Z=((unsigned)(c)), isauxspZ) 247c478bd9Sstevel@tonic-gate /* Regocnizes non-ASCII space characters. */ 257c478bd9Sstevel@tonic-gate #else 267c478bd9Sstevel@tonic-gate #include <ctype.h> 277c478bd9Sstevel@tonic-gate /* macros of macros to reduce further #ifdef MBCHAR later. Please be patient!*/ 287c478bd9Sstevel@tonic-gate #define iswdigit(c) isdigit(c) 297c478bd9Sstevel@tonic-gate #define iswalpha(c) isalpha(c) 30*55fea89dSDan Cross #define isphonogram(c) 0 317c478bd9Sstevel@tonic-gate #define isideogram(c) 0 327c478bd9Sstevel@tonic-gate #define isauxsp(c) 0 337c478bd9Sstevel@tonic-gate #define isauxspZ 0 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate extern unsigned short _cmap[];/* Defined in sh.char.c */ 36258f91c6SToomas Soome extern unsigned int Z; /* A place to save macro arg to avoid side-effect!*/ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #define _Q 0x01 /* '" */ 397c478bd9Sstevel@tonic-gate #define _Q1 0x02 /* ` */ 407c478bd9Sstevel@tonic-gate #define _SP 0x04 /* space and tab */ 417c478bd9Sstevel@tonic-gate #define _NL 0x08 /* \n */ 427c478bd9Sstevel@tonic-gate #define _META 0x10 /* lex meta characters, sp #'`";&<>()|\t\n */ 437c478bd9Sstevel@tonic-gate #define _GLOB 0x20 /* glob characters, *?{[` */ 447c478bd9Sstevel@tonic-gate #define _ESC 0x40 /* \ */ 457c478bd9Sstevel@tonic-gate #define _DOL 0x80 /* $ */ 467c478bd9Sstevel@tonic-gate #define _DIG 0x100 /* 0-9 */ 477c478bd9Sstevel@tonic-gate #define _LET 0x200 /* a-z, A-Z, _ NO LONGER OF REAL USE. */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #define quoted(c) ((unsigned)(c) & QUOTE) 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #define cmapZ(bits) (isascii(Z)?(_cmap[Z] & (bits)):0) 537c478bd9Sstevel@tonic-gate #define cmap(c, bits) (Z=((unsigned)(c)), cmapZ(bits)) 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #define isglob(c) cmap(c, _GLOB) 567c478bd9Sstevel@tonic-gate #define ismeta(c) cmap(c, _META) 577c478bd9Sstevel@tonic-gate #define digit(c) cmap(c, _DIG) 58*55fea89dSDan Cross #define issp(c) (Z=((unsigned)(c)), cmapZ( _SP)||isauxspZ) 597c478bd9Sstevel@tonic-gate /*WAS isspace(c)*/ 607c478bd9Sstevel@tonic-gate #define isspnl(c) (Z=((unsigned)(c)), cmapZ( _SP|_NL)||isauxspZ) 617c478bd9Sstevel@tonic-gate #define letter(c) \ 627c478bd9Sstevel@tonic-gate (Z=((unsigned)(c)), !quoted(Z)&&(iswalpha(Z)||((Z)=='_')\ 637c478bd9Sstevel@tonic-gate ||isphonogram(Z)||isideogram(Z))) 647c478bd9Sstevel@tonic-gate #define alnum(c) \ 657c478bd9Sstevel@tonic-gate (Z=((unsigned)(c)), !quoted(Z)&&(iswalpha(Z)||((Z)=='_')\ 667c478bd9Sstevel@tonic-gate ||iswdigit(Z)||isphonogram(Z)||isideogram(Z))) 67