[f40a309] | 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 | isascii(c) non-zero if c is ASCII
|
---|
| 14 |
|
---|
| 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 |
|
---|
| 19 | isalpha(c) non-zero if c is alpha
|
---|
| 20 | isupper(c) non-zero if c is upper case
|
---|
| 21 | islower(c) non-zero if c is lower case
|
---|
| 22 |
|
---|
| 23 | isdigit(c) non-zero if c is a digit (0 to 9)
|
---|
| 24 | isxdigit(c) non-zero if c is a hexadecimal digit (0 to 9, A to F, a to f)
|
---|
| 25 |
|
---|
| 26 | isalnum(c) non-zero if c is alpha or digit
|
---|
| 27 |
|
---|
| 28 | isspace(c) non-zero if c is white space
|
---|
| 29 | ispunct(c) non-zero if c is punctuation
|
---|
| 30 |
|
---|
| 31 | iscsym(c) non-zero if valid character for C symbols
|
---|
| 32 | iscsymf(c) non-zero if valid first character for C symbols
|
---|
| 33 |
|
---|
| 34 | toascii(c) returns c masked to 7 bits
|
---|
| 35 |
|
---|
| 36 | _tolower(c) returns the lower case version of c
|
---|
| 37 | _toupper(c) returns the upper case version of c
|
---|
| 38 | ============================================================================
|
---|
| 39 | */
|
---|
| 40 |
|
---|
| 41 | /* |
---|
| 42 |
|
---|
| 43 | */
|
---|
[f7428b1] | 44 |
|
---|
[f40a309] | 45 | #pragma once
|
---|
| 46 |
|
---|
| 47 | /* Digital Research / Alcyon C table definitions */
|
---|
| 48 |
|
---|
| 49 | #define _C 0x01 /* control 00.1F */
|
---|
| 50 | #define _P 0x02 /* punctuation */
|
---|
| 51 | #define _N 0x04 /* numeric 0..9 */
|
---|
| 52 | #define _U 0x08 /* upper case */
|
---|
| 53 | #define _L 0x10 /* lower case */
|
---|
| 54 | #define _S 0x20 /* whitespace */
|
---|
| 55 | #define _B 0x40 /* blank */
|
---|
| 56 | #define _X 0x80 /* hex digit */
|
---|
| 57 |
|
---|
| 58 | /* |
---|
| 59 |
|
---|
[f7428b1] | 60 | */
|
---|
[f40a309] | 61 |
|
---|
[f7428b1] | 62 | #define isascii(c) (!((c) & ~0x7f))
|
---|
| 63 |
|
---|
| 64 | #define isprint(c) (__atab[(c) & 0xff] & (_P | _U | _L | _N | _B))
|
---|
[f40a309] | 65 | #define isgraph(c) (__atab[(c) & 0xff] & (_P | _U | _L | _N))
|
---|
[f7428b1] | 66 | #define iscntrl(c) (__atab[(c) & 0xff] & _C)
|
---|
| 67 |
|
---|
| 68 | #define isalpha(c) (__atab[(c) & 0xff] & (_U | _L))
|
---|
[f40a309] | 69 | #define isupper(c) (__atab[(c) & 0xff] & _U)
|
---|
[f7428b1] | 70 | #define islower(c) (__atab[(c) & 0xff] & _L)
|
---|
| 71 |
|
---|
[f40a309] | 72 | #define isdigit(c) (__atab[(c) & 0xff] & _N)
|
---|
[f7428b1] | 73 | #define isxdigit(c) (__atab[(c) & 0xff] & _X)
|
---|
[f40a309] | 74 |
|
---|
[f7428b1] | 75 | #define isalnum(c) (__atab[(c) & 0xff] & (_U | _L | _N))
|
---|
| 76 |
|
---|
[f40a309] | 77 | #define isspace(c) (__atab[(c) & 0xff] & _S)
|
---|
[f7428b1] | 78 | #define ispunct(c) (__atab[(c) & 0xff] & _P)
|
---|
| 79 |
|
---|
[f40a309] | 80 | #define iscsym(c) (isalnum(c) || (((c) & 0x7f) == 0x5f))
|
---|
[f7428b1] | 81 | #define iscsymf(c) (isalpha(c) || (((c) & 0x7f) == 0x5f))
|
---|
[f40a309] | 82 |
|
---|
[f7428b1] | 83 | #define toascii(c) ((c) & 0x7f)
|
---|
| 84 |
|
---|
| 85 | #define _toupper(c) ((c) - 'a' + 'A')
|
---|
| 86 | #define _tolower(c) ((c) - 'A' + 'a')
|
---|