1 /* $Id: ctype.h,v 1.5 1994/06/24 11:05:10 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
11 Author : Richard A. O'Keefe.
12 Updated: 26 April 1984
13 Purpose: Reimplement the UNIX ctype(3) library.
15 isaneol(c) means that c is a line terminating character.
16 isalnum, ispunct, isspace, and isaneol are defined on the
17 range -1..127, i.e. on ASCII U {EOF}, while all the other
18 macros are defined for any integer.
20 isodigit(c) checks for Octal digits.
21 isxdigit(c) checkx for heXadecimal digits.
24 #define isdigit(c) ((unsigned)((c)-'0') < 10)
25 #define islower(c) ((unsigned)((c)-'a') < 26)
26 #define isupper(c) ((unsigned)((c)-'A') < 26)
27 #define isprint(c) ((unsigned)((c)-' ') < 95)
28 #define iscntrl(c) ((unsigned)((c)-' ') >= 95)
29 #define isascii(c) ((unsigned)(c) < 128)
30 #define isalpha(c) ((unsigned)(((c)|32)-'a') < 26)
32 extern char _c2type[];
34 #define isalnum(c) (_c2type[(c)+1] < 36)
35 #define ispunct(c) (_c2type[(c)+1] == 36)
36 #define isspace(c) (_c2type[(c)+1] > 37)
37 #define isaneol(c) (_c2type[(c)+1] > 38)
39 #define isxdigit(c) (_c2type[(c)+1] < 16)
40 #define isodigit(c) ((unsigned)((c)-'0') < 8)
42 /* The following "conversion" macros have been in some versions of UNIX
43 but are not in all. tocntrl is new. The original motivation for ^?
44 being a name for DEL was that (x)^64 mapped A..Z to ^A..^Z and also
45 ? to DEL. The trouble is that this trick doesn't work for lower case
46 letters. The version given here is not mine. I wish it was. It has
47 the nice property that DEL is mapped to itself (so does EOF).
48 tolower(c) and toupper(c) are only defined when isalpha(c).
50 #define tolower(c) ((c)|32)
51 #define toupper(c) ((c)&~32)
52 #define tocntrl(c) (((((c)+1)&~96)-1)&127)
53 #define toascii(c) ((c)&127)