1: /* $Header: /home/hyperion/mu/christos/src/sys/tcsh-6.00/RCS/sh.char.h,v 3.0 1991/07/04 21:49:28 christos 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:  *
  10:  * Redistribution and use in source and binary forms, with or without
  11:  * modification, are permitted provided that the following conditions
  12:  * are met:
  13:  * 1. Redistributions of source code must retain the above copyright
  14:  *    notice, this list of conditions and the following disclaimer.
  15:  * 2. Redistributions in binary form must reproduce the above copyright
  16:  *    notice, this list of conditions and the following disclaimer in the
  17:  *    documentation and/or other materials provided with the distribution.
  18:  * 3. All advertising materials mentioning features or use of this software
  19:  *    must display the following acknowledgement:
  20:  *	This product includes software developed by the University of
  21:  *	California, Berkeley and its contributors.
  22:  * 4. Neither the name of the University nor the names of its contributors
  23:  *    may be used to endorse or promote products derived from this software
  24:  *    without specific prior written permission.
  25:  *
  26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36:  * SUCH DAMAGE.
  37:  */
  38: #ifndef _h_sh_char
  39: #define _h_sh_char
  40: #include <ctype.h>
  41: 
  42: extern unsigned short _cmap[];
  43: 
  44: #ifndef NLS
  45: extern unsigned char _cmap_lower[], _cmap_upper[];
  46: 
  47: #endif
  48: 
  49: #define _Q  0x0001      /* '" */
  50: #define _Q1 0x0002      /* ` */
  51: #define _SP 0x0004      /* space and tab */
  52: #define _NL 0x0008      /* \n */
  53: #define _META   0x0010      /* lex meta characters, sp #'`";&<>()|\t\n */
  54: #define _GLOB   0x0020      /* glob characters, *?{[` */
  55: #define _ESC    0x0040      /* \ */
  56: #define _DOL    0x0080      /* $ */
  57: #define _DIG    0x0100      /* 0-9 */
  58: #define _LET    0x0200      /* a-z, A-Z, _ */
  59: #define _UP     0x0400      /* A-Z */
  60: #define _LOW    0x0800      /* a-z */
  61: #define _XD     0x1000      /* 0-9, a-f, A-F */
  62: #define _CMD    0x2000      /* lex end of command chars, ;&(|` */
  63: #define _CTR    0x4000      /* control */
  64: 
  65: #define cmap(c, bits)   \
  66:     (((c) & QUOTE) ? 0 : (_cmap[(unsigned char)(c)] & (bits)))
  67: 
  68: #define isglob(c)   cmap(c, _GLOB)
  69: #define isspc(c)    cmap(c, _SP)
  70: #define ismeta(c)   cmap(c, _META)
  71: #define iscmdmeta(c)    cmap(c, _CMD)
  72: #define letter(c)   (((c) & QUOTE) ? 0 : \
  73:              (isalpha((unsigned char) (c)) || (c) == '_'))
  74: #define alnum(c)    (((c) & QUOTE) ? 0 : \
  75:                  (isalnum((unsigned char) (c)) || (c) == '_'))
  76: #ifdef NLS
  77: # define Isspace(c) (((c) & QUOTE) ? 0 : isspace((unsigned char) (c)))
  78: # define Isdigit(c) (((c) & QUOTE) ? 0 : isdigit((unsigned char) (c)))
  79: # define Isalpha(c) (((c) & QUOTE) ? 0 : isalpha((unsigned char) (c)))
  80: # define Islower(c) (((c) & QUOTE) ? 0 : islower((unsigned char) (c)))
  81: # define Isupper(c) (((c) & QUOTE) ? 0 : isupper((unsigned char) (c)))
  82: # define Tolower(c)     (((c) & QUOTE) ? 0 : tolower((unsigned char) (c)))
  83: # define Toupper(c)     (((c) & QUOTE) ? 0 : toupper((unsigned char) (c)))
  84: # define Isxdigit(c)    (((c) & QUOTE) ? 0 : isxdigit((unsigned char) (c)))
  85: # define Isalnum(c) (((c) & QUOTE) ? 0 : isalnum((unsigned char) (c)))
  86: # define Iscntrl(c)     (((c) & QUOTE) ? 0 : iscntrl((unsigned char) (c)))
  87: # define Isprint(c)     (((c) & QUOTE) ? 0 : isprint((unsigned char) (c)))
  88: #else
  89: # define Isspace(c) cmap(c, _SP|_NL)
  90: # define Isdigit(c) cmap(c, _DIG)
  91: # define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
  92: # define Islower(c) (cmap(c,_LOW) && !(((c) & META) && AsciiOnly))
  93: # define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
  94: # define Tolower(c) (_cmap_lower[(unsigned char)(c)])
  95: # define Toupper(c) (_cmap_upper[(unsigned char)(c)])
  96: # define Isxdigit(c)    cmap(c, _XD)
  97: # define Isalnum(c) (cmap(c, _DIG|_LET) && !(((c) & META) && AsciiOnly))
  98: # define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
  99: # define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
 100: #endif
 101: 
 102: #endif /* _h_sh_char */

Defined macros

Isalnum defined in line 97; never used
Isalpha defined in line 91; used 1 times
Islower defined in line 92; used 4 times
Isxdigit defined in line 96; used 1 times
Toupper defined in line 95; used 4 times
_CMD defined in line 62; used 6 times
_CTR defined in line 63; used 67 times
_DIG defined in line 57; used 12 times
_GLOB defined in line 54; used 7 times
_LET defined in line 58; used 116 times
_LOW defined in line 60; used 59 times
_META defined in line 53; used 17 times
_NL defined in line 52; used 3 times
_Q1 defined in line 50; used 6 times
_SP defined in line 51; used 6 times
_UP defined in line 59; used 57 times
_XD defined in line 61; used 23 times
_h_sh_char defined in line 39; used 1 times
  • in line 38
cmap defined in line 65; used 23 times
iscmdmeta defined in line 71; used 4 times
isglob defined in line 68; used 3 times
isspc defined in line 69; used 2 times
letter defined in line 72; used 9 times

Usage of this include

Last modified: 1991-08-20
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3054
Valid CSS Valid XHTML 1.0 Strict