File:  [CSRG BSD Unix] / 43BSD / contrib / icon / tran / char.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

/*
 * Macros for determining character type.
 *
 * The table chrtype (in char.c) classifies each character
 *  in one of the categories defined below.
 */

#define _S	 01		/* space */
#define _U	 02		/* upper case */
#define _L	 04		/* lower case */
#define _A	010		/* other alphabetic (e.g. "_") */
#define _N	020		/* digit */

#define _UL	(_U | _L)	/* letter */
#define _ULA	(_UL | _A)	/* alphabetic */
#define _ULAN	(_ULA | _N)	/* alphanumeric */

#define isspace(c)	(chrtype[c] & _S) 
#define isupper(c)	(chrtype[c] & _U) 
#define islower(c)	(chrtype[c] & _L) 
#define isletter(c)	(chrtype[c] & _UL) 
#define isalpha(c)	(chrtype[c] & _ULA) 
#define isdigit(c)	(chrtype[c] & _N) 
#define isalnum(c)	(chrtype[c] & _ULAN) 

#define toupper(c)	(islower(c)? (c - ('a'-'A')) : c) 
#define tolower(c)	(isupper(c)? (c + ('a'-'A')) : c) 
#define tonum(c)	(isdigit(c)? (c - '0') : ((c & 037) + 9)) 

extern char chrtype[];

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.