source: buchla-68k/include/ctype.h

Last change on this file was 83a374d, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Fixed ctype.h.

  • Property mode set to 100644
File size: 2.6 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 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#pragma once
42
43#include "stdint.h"
44
45/* Digital Research / Alcyon C table definitions */
46
47#define _C 0x01 /* control 00.1F */
48#define _P 0x02 /* punctuation */
49#define _N 0x04 /* numeric 0..9 */
50#define _U 0x08 /* upper case */
51#define _L 0x10 /* lower case */
52#define _S 0x20 /* whitespace */
53#define _B 0x40 /* blank */
54#define _X 0x80 /* hex digit */
55
56#define isascii(c) (!((c) & ~0x7f))
57
58#define isprint(c) (__atab[(c) & 0xff] & (_P | _U | _L | _N | _B))
59#define isgraph(c) (__atab[(c) & 0xff] & (_P | _U | _L | _N))
60#define iscntrl(c) (__atab[(c) & 0xff] & _C)
61
62#define isalpha(c) (__atab[(c) & 0xff] & (_U | _L))
63#define isupper(c) (__atab[(c) & 0xff] & _U)
64#define islower(c) (__atab[(c) & 0xff] & _L)
65
66#define isdigit(c) (__atab[(c) & 0xff] & _N)
67#define isxdigit(c) (__atab[(c) & 0xff] & _X)
68
69#define isalnum(c) (__atab[(c) & 0xff] & (_U | _L | _N))
70
71#define isspace(c) (__atab[(c) & 0xff] & _S)
72#define ispunct(c) (__atab[(c) & 0xff] & _P)
73
74#define iscsym(c) (isalnum(c) || (((c) & 0x7f) == 0x5f))
75#define iscsymf(c) (isalpha(c) || (((c) & 0x7f) == 0x5f))
76
77#define toascii(c) ((int8_t)((c) & 0x7f))
78
79#define _toupper(c) ((int8_t)((c) - 'a' + 'A'))
80#define _tolower(c) ((int8_t)((c) - 'A' + 'a'))
Note: See TracBrowser for help on using the repository browser.