-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-ctype-data.cc
54 lines (49 loc) · 1.13 KB
/
gen-ctype-data.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
#include <iostream>
#include <ctype.h>
namespace {
void do_ctype(std::ostream& os, int i, int (*f)(int), std::string name)
{
if (f(i)) {
os << " | " << name;
}
}
}
#define DO(x) do_ctype(std::cout, i, is##x, "_IS" #x)
int main(int ac, char **av)
{
std::cout << "static unsigned short c_locale_array[384] = {\n";
for (int i = -128; i < 256; ++i) {
std::cout << "0";
DO(alnum);
DO(alpha);
/* DO(ascii); */
DO(blank);
DO(cntrl);
DO(digit);
DO(graph);
DO(lower);
DO(print);
DO(punct);
DO(space);
DO(upper);
DO(xdigit);
std::cout << ",\n";
}
std::cout << "};\n";
std::cout << "static int c_toupper_array[384] = {\n";
for (int i = -128; i < 256; ++i) {
std::cout << toupper(i) << ",\n";
}
std::cout << "};\n";
std::cout << "static int c_tolower_array[384] = {\n";
for (int i = -128; i < 256; ++i) {
std::cout << tolower(i) << ",\n";
}
std::cout << "};\n";
}