source: buchla-68k/orig/LATTICE/CTYPE.H@ 4b63bf3

Last change on this file since 4b63bf3 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.1 KB
Line 
1/**
2*
3* This header file defines various ASCII character manipulation macros,
4* as follows:
5*
6* isalpha(c) non-zero if c is alpha
7* isupper(c) non-zero if c is upper case
8* islower(c) non-zero if c is lower case
9* isdigit(c) non-zero if c is a digit (0 to 9)
10* isxdigit(c) non-zero if c is a hexadecimal digit (0 to 9, A to F,
11* a to f)
12* isspace(c) non-zero if c is white space
13* ispunct(c) non-zero if c is punctuation
14* isalnum(c) non-zero if c is alpha or digit
15* isprint(c) non-zero if c is printable (including blank)
16* isgraph(c) non-zero if c is graphic (excluding blank)
17* iscntrl(c) non-zero if c is control character
18* isascii(c) non-zero if c is ASCII
19* iscsym(c) non-zero if valid character for C symbols
20* iscsymf(c) non-zero if valid first character for C symbols
21*
22**/
23
24#define _U 1 /* upper case flag */
25#define _L 2 /* lower case flag */
26#define _N 4 /* number flag */
27#define _S 8 /* space flag */
28#define _P 16 /* punctuation flag */
29#define _C 32 /* control character flag */
30#define _B 64 /* blank flag */
31#define _X 128 /* hexadecimal flag */
32
33extern char _ctype[]; /* character type table */
34
35#define isalpha(c) (_ctype[(c)+1]&(_U|_L))
36#define isupper(c) (_ctype[(c)+1]&_U)
37#define islower(c) (_ctype[(c)+1]&_L)
38#define isdigit(c) (_ctype[(c)+1]&_N)
39#define isxdigit(c) (_ctype[(c)+1]&_X)
40#define isspace(c) (_ctype[(c)+1]&_S)
41#define ispunct(c) (_ctype[(c)+1]&_P)
42#define isalnum(c) (_ctype[(c)+1]&(_U|_L|_N))
43#define isprint(c) (_ctype[(c)+1]&(_P|_U|_L|_N|_B))
44#define isgraph(c) (_ctype[(c)+1]&(_P|_U|_L|_N))
45#define iscntrl(c) (_ctype[(c)+1]&_C)
46#define isascii(c) ((unsigned)(c)<=127)
47#define iscsym(c) (isalnum(c)||(((c)&127)==0x5f))
48#define iscsymf(c) (isalpha(c)||(((c)&127)==0x5f))
49
50#define toupper(c) (islower(c)?((c)-('a'-'A')):(c))
51#define tolower(c) (isupper(c)?((c)+('a'-'A')):(c))
52#define toascii(c) ((c)&127)
Note: See TracBrowser for help on using the repository browser.