Commit | Line | Data |
---|---|---|
dbb879ad C |
1 | // Here's a ctype.h for SunOS-3 and vax 4.3BSD. |
2 | // It will probably work on most BSD derived systems. | |
3 | // Just compare it to the C version to verify. | |
4 | // No big deal, but it will save you some typing. | |
5 | ||
6 | #ifndef _ctype_h | |
7 | #ifdef __GNUG__ | |
8 | #pragma once | |
9 | #pragma interface | |
10 | #endif | |
11 | #define _ctype_h | |
12 | ||
13 | int isalpha(char c); | |
14 | int isupper(char c); | |
15 | int islower(char c); | |
16 | int isdigit(char c); | |
17 | int isxdigit(char c); | |
18 | int isspace(char c); | |
19 | int ispunct(char c); | |
20 | int isalnum(char c); | |
21 | int isprint(char c); | |
22 | int isgraph(char c); | |
23 | int iscntrl(char c); | |
24 | int isascii(char c); | |
25 | int toupper(char c); | |
26 | int tolower(char c); | |
27 | int toascii(char c); | |
28 | ||
29 | #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) | |
30 | ||
31 | #include <stdio.h> /* sorry, but needed for USG stuff */ | |
32 | ||
33 | static const int _U = 01; | |
34 | static const int _L = 02; | |
35 | static const int _N = 04; | |
36 | static const int _S = 010; | |
37 | static const int _P = 020; | |
38 | static const int _C = 040; | |
39 | ||
40 | ||
41 | #if defined(USG) || defined(DGUX) | |
42 | static const int _B = 0100; /* different from BSD */ | |
43 | static const int _X = 0200; /* different from BSD */ | |
44 | #else | |
45 | static const int _X = 0100; | |
46 | static const int _B = 0200; | |
47 | #endif | |
48 | ||
49 | ||
50 | #ifdef DGUX | |
51 | #define CTYPE_TYPE short | |
52 | #else | |
53 | #define CTYPE_TYPE char | |
54 | #endif | |
55 | ||
56 | #if defined(DGUX) || defined(USG) || defined(hpux) | |
57 | #define _ctype_ _ctype | |
58 | #endif | |
59 | ||
60 | extern "C" { | |
61 | extern CTYPE_TYPE _ctype_[]; | |
62 | } | |
63 | ||
64 | /* | |
65 | * The following bit of ugliness is to ensure that the __ctype__[] | |
66 | * initialization is brought in from the VAX-11 "C" runtime library | |
67 | */ | |
68 | #ifdef VMS | |
69 | #define _ctype_ $$PsectAttributes_NOWRT$$_ctype_ | |
70 | extern char _ctype_[]; | |
71 | extern "C" { | |
72 | extern c$v_ctypedefs(); | |
73 | static __ctype__dummy(){c$v_ctypedefs();} | |
74 | } | |
75 | #endif | |
76 | ||
77 | ||
78 | #ifdef VMS | |
79 | inline int isalpha(char c) { return ((_ctype_)[c]&(_U|_L)); } | |
80 | inline int isupper(char c) { return ((_ctype_)[c]&_U); } | |
81 | inline int islower(char c) { return ((_ctype_)[c]&_L); } | |
82 | inline int isdigit(char c) { return ((_ctype_)[c]&_N); } | |
83 | inline int isxdigit(char c) { return ((_ctype_)[c]&_X); } | |
84 | inline int isspace(char c) { return ((_ctype_)[c]&_S); } | |
85 | inline int ispunct(char c) { return ((_ctype_)[c]&_P); } | |
86 | inline int isalnum(char c) { return ((_ctype_)[c]&(_U|_L|_N)); } | |
87 | inline int isprint(char c) { return ((_ctype_)[c]&(_P|_U|_L|_N|_B)); } | |
88 | inline int isgraph(char c) { return ((_ctype_)[c]&(_P|_U|_L|_N)); } | |
89 | inline int iscntrl(char c) { return ((_ctype_)[c]&_C); } | |
90 | inline int isascii(char c) { return ((unsigned)(c)<=0177); } | |
91 | inline int toupper(char c) { return ((c)-'a'+'A'); } | |
92 | inline int tolower(char c) { return ((c)-'A'+'a'); } | |
93 | inline int toascii(char c) { return ((c)&0177); } | |
94 | #else | |
95 | inline int isalpha(char c) { return ((_ctype_+1)[c]&(_U|_L)); } | |
96 | inline int isupper(char c) { return ((_ctype_+1)[c]&_U); } | |
97 | inline int islower(char c) { return ((_ctype_+1)[c]&_L); } | |
98 | inline int isdigit(char c) { return ((_ctype_+1)[c]&_N); } | |
99 | inline int isxdigit(char c) { return ((_ctype_+1)[c]&_X); } | |
100 | inline int isspace(char c) { return ((_ctype_+1)[c]&_S); } | |
101 | inline int ispunct(char c) { return ((_ctype_+1)[c]&_P); } | |
102 | inline int isalnum(char c) { return ((_ctype_+1)[c]&(_U|_L|_N)); } | |
103 | inline int isprint(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N|_B)); } | |
104 | inline int isgraph(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N)); } | |
105 | inline int iscntrl(char c) { return ((_ctype_+1)[c]&_C); } | |
106 | inline int isascii(char c) { return ((unsigned)(c)<=0177); } | |
107 | inline int toupper(char c) { return islower(c)? (c-'a'+'A') : c; } | |
108 | inline int tolower(char c) { return isupper(c)? (c-'A'+'a') : c; } | |
109 | inline int toascii(char c) { return ((c)&0177); } | |
110 | #endif | |
111 | ||
112 | #ifdef _ctype_ | |
113 | #undef _ctype_ | |
114 | #endif | |
115 | ||
116 | #ifdef CTYPE_TYPE | |
117 | #undef CTYPE_TYPE | |
118 | #endif | |
119 | ||
120 | #endif /* __OPTIMIZE__ */ | |
121 | ||
122 | #endif _ctype_h |