source: buchla-68k/orig/GP/CTYPE.H@ 6d3de83

Last change on this file since 6d3de83 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 3.8 KB
Line 
1/*
2 ============================================================================
3 ctype.h -- extended character macros, ala' Unix(tm)
4 Version 8 -- 1987-06-16 -- D.N. Lynx Crowe
5
6 These macros are a superset of those provided for System 5 Unix(tm).
7
8 This set of macros will return status for characters 0x80..0xFF as
9 though they were in the range 0x00..0x7F for compatibility with
10 the equivalent Lattice C macros. This means that isascii(c) should
11 be used if it is necessary to restrict the results to true ASCII.
12
13 If SYS5CODE is TRUE these macros will use the same table definitions
14 as System 5 Unix(tm). In this case these behave well even when fed
15 an EOF. The EOF character value, -1, is not defined as being in any
16 of the classes tested for. If SYS5CODE is FALSE, the Alcyon table
17 will be used, and EOF will not work properly.
18
19 Define _CTYPE_C for compiling the ctype.c file, undefine otherwise.
20
21 The symbol _ii_ is defined to be the base of the table used.
22
23 isascii(c) non-zero if c is ASCII
24
25 isprint(c) non-zero if c is printable (including blank)
26 isgraph(c) non-zero if c is graphic (excluding blank)
27 iscntrl(c) non-zero if c is control character
28
29 isalpha(c) non-zero if c is alpha
30 isupper(c) non-zero if c is upper case
31 islower(c) non-zero if c is lower case
32
33 isdigit(c) non-zero if c is a digit (0 to 9)
34 isxdigit(c) non-zero if c is a hexadecimal digit (0 to 9, A to F, a to f)
35
36 isalnum(c) non-zero if c is alpha or digit
37
38 isspace(c) non-zero if c is white space
39 ispunct(c) non-zero if c is punctuation
40
41 iscsym(c) non-zero if valid character for C symbols
42 iscsymf(c) non-zero if valid first character for C symbols
43
44 toascii(c) returns c masked to 7 bits
45
46 _tolower(c) returns the lower case version of c
47 _toupper(c) returns the upper case version of c
48
49 tonumber(c) converts c from ASCII to integer
50 ============================================================================
51*/
52
53/*
54
55*/
56
57#define SYS5CODE 0 /* define non-zero for System 5 / Aztec C */
58
59#if SYS5CODE
60
61#define _ii_ _ctype+1
62
63/* System 5 Unix(tm) / Aztec C table definitions */
64
65#define _U 0x01 /* upper case */
66#define _L 0x02 /* lower case */
67#define _N 0x04 /* numeric 0..9 */
68#define _S 0x08 /* whitespace */
69#define _P 0x10 /* punctuation */
70#define _C 0x20 /* control 00..1F */
71#define _B 0x40 /* blank */
72#define _X 0x80 /* hex digit */
73
74#else
75
76#define _ii_ __atab
77
78/* Digital Research / Alcyon C table definitions */
79
80#define _C 0x01 /* control 00.1F */
81#define _P 0x02 /* punctuation */
82#define _N 0x04 /* numeric 0..9 */
83#define _U 0x08 /* upper case */
84#define _L 0x10 /* lower case */
85#define _S 0x20 /* whitespace */
86#define _B 0x40 /* blank */
87#define _X 0x80 /* hex digit */
88
89#endif
90
91#ifndef _CTYPE_C
92
93#if SYS5CODE
94
95extern char _ctype[]; /* character type table */
96
97#else /* SYS5CODE */
98
99extern char ___atab(); /* so the loader sees us ... */
100extern char __atab[]; /* character type table */
101
102#endif /* SYS5CODE */
103
104#endif /* _CTYPE_C */
105
106/*
107
108*/
109
110#define isascii(c) (!((c)&~0x7F))
111
112#define isprint(c) ((_ii_)[c]&(_P|_U|_L|_N|_B))
113#define isgraph(c) ((_ii_)[c]&(_P|_U|_L|_N))
114#define iscntrl(c) ((_ii_)[c]&_C)
115
116#define isalpha(c) ((_ii_)[c]&(_U|_L))
117#define isupper(c) ((_ii_)[c]&_U)
118#define islower(c) ((_ii_)[c]&_L)
119
120#define isdigit(c) ((_ii_)[c]&_N)
121#define isxdigit(c) ((_ii_)[c]&_X)
122
123#define isalnum(c) ((_ii_)[c]&(_U|_L|_N))
124
125#define isspace(c) ((_ii_)[c]&_S)
126#define ispunct(c) ((_ii_)[c]&_P)
127
128#define iscsym(c) (isalnum(c)||(((c)&127)==0x5F))
129#define iscsymf(c) (isalpha(c)||(((c)&127)==0x5F))
130
131#define toascii(c) ((c)&0x7F)
132
133#define _toupper(c) ((c)-'a'+'A')
134#define _tolower(c) ((c)-'A'+'a')
135
136#define tonumber(c) ((((c)&0x7F)>'9')?((islower(c)?_toupper(c):c)-'A'+10):(c&0x0F))
137
Note: See TracBrowser for help on using the repository browser.