Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
CTYPE_BITS.cpp
Go to the documentation of this file.
1// checking for ctype constants
2
3
25#include <ctype.h>
26#include <stdio.h>
27
28
29int main ()
30{
31 struct {
32 const char* name;
33 int val;
34 } bits[] = {
35
36 {
37 "UPPER",
38#if defined (_ISUPPER)
39 _ISUPPER
40#elif defined (_ISupper)
41 _ISupper
42#elif defined (_U)
43 _U
44#elif defined (__GLIBC__)
45 _ISupper,
46#else
47 -1
48#endif
49 },
50
51 {
52 "LOWER",
53#if defined (_ISLOWER)
54 _ISLOWER
55#elif defined (_ISlower)
56 _ISlower
57#elif defined (_L)
58 _L
59#elif defined (__GLIBC__)
60 _ISlower,
61#else
62 -1
63#endif
64 },
65
66 {
67 "DIGIT",
68#if defined (_ISDIGIT)
69 _ISDIGIT
70#elif defined (_ISdigit)
71 _ISdigit
72#elif defined (_D)
73 _D
74#elif defined (__GLIBC__)
75 _ISdigit,
76#else
77 -1
78#endif
79 },
80
81 {
82 "SPACE",
83#if defined (_ISSPACE)
84 _ISSPACE
85#elif defined (_ISspace)
86 _ISspace
87#elif defined (_S)
88 _S
89#elif defined (__GLIBC__)
90 _ISspace,
91#else
92 -1
93#endif
94 },
95
96 {
97 "PUNCT",
98#if defined (_ISPUNCT)
99 _ISPUNCT
100#elif defined (_ISpunct)
101 _ISpunct
102#elif defined (_P)
103 _P
104#elif defined (__GLIBC__)
105 _ISpunct,
106#else
107 -1
108#endif
109 },
110
111 {
112 "CNTRL",
113#if defined (_ISCNTRL)
114 _ISCNTRL
115#elif defined (_IScntrl)
116 _IScntrl
117#elif defined (_C)
118 _C
119#elif defined (__GLIBC__)
120 _IScntrl,
121#else
122 -1
123#endif
124 },
125
126 {
127 "BLANK",
128#if defined (_ISBLANK)
129 _ISBLANK
130#elif defined (_ISblank)
131 _ISblank
132#elif defined (_B)
133 _B
134#elif defined (__GLIBC__)
135 _ISblank,
136#else
137 -1
138#endif
139 },
140
141 {
142 "XDIGIT",
143#if defined (_ISXDIGIT)
144 _ISXDIGIT
145#elif defined (_ISxdigit)
146 _ISxdigit
147#elif defined (_X)
148 _X
149#elif defined (__GLIBC__)
150 _ISxdigit,
151#else
152 -1
153#endif
154 },
155
156 {
157 "GRAPH",
158#if defined (_ISGRAPH)
159 _ISGRAPH
160#elif defined (_ISgraph)
161 _ISgraph
162#elif defined (__GLIBC__)
163 _ISgraph,
164#else
165 -1
166#endif
167 },
168
169 {
170 "ALPHA",
171#if defined (_ISALPHA)
172 _ISALPHA
173#elif defined (_ISalpha)
174 _ISalpha
175#elif defined (__GLIBC__)
176 _ISalpha,
177#else
178 -1
179#endif
180 },
181
182 {
183 "PRINT",
184#if defined (_ISPRINT)
185 _ISPRINT
186#elif defined (_ISprint)
187 _ISprint
188#elif defined (__GLIBC__)
189 _ISprint,
190#else
191 -1
192#endif
193 },
194
195 {
196 "ALNUM",
197#if defined (_ISALNUM)
198 _ISALNUM
199#elif defined (_ISalnum)
200 _ISalnum
201#elif defined (__GLIBC__)
202 _ISalnum,
203#else
204 -1
205#endif
206 }
207 };
208
209 int used = 0;
210
211 for (unsigned i = 0; i != sizeof bits / sizeof *bits; ++i) {
212
213 if (-1 != bits [i].val) {
214 used |= bits [i].val;
215
216 printf ("#define _RWSTD_CTYPE_%s %#010x"
217 " /* libc value */\n",
218 bits [i].name, bits [i].val);
219 }
220 }
221
222 for (unsigned j = 0; j != sizeof bits / sizeof *bits; ++j) {
223 if (-1 == bits [j].val) {
224 for (unsigned i = 0; i != sizeof used * 8; ++i) {
225 if (!(used & (1 << i))) {
226
227 used |= 1 << i;
228
229 printf ("#define _RWSTD_CTYPE_%s %#010x"
230 " /* computed */\n",
231 bits [j].name, 1 << i);
232
233 break;
234 }
235 }
236 }
237 }
238
239 return 0;
240}
#define i
Definition 17.names.cpp:126
#define j
Definition 17.names.cpp:127
#define val
Definition 17.names.cpp:570
int main()
IMPORT_C SInt32 printf(const Char *,...)
const char * name
Definition codecvt1.cpp:72