Make the zlib compile against the tinycrt library.
[git-build-vc9.git] / tcrt / src / ctype.cpp
blobe70a6a0e4474e5ff11ef25c30cfd1ba3a27159db
1 /*=============================================================================
2 ctype.cpp :
4 Copyright © 2008 Bruno Santos <nayart3@gmail.com>
5 =============================================================================*/
7 ///////////////////////////////////////////////////////////////////////////////
8 #include <ctype.h>
9 #include <errno.h>
11 ///////////////////////////////////////////////////////////////////////////////
12 enum {
13 UP = tcrt_ctype_flag_upper,
14 LO = tcrt_ctype_flag_lower,
15 CT = tcrt_ctype_flag_cntrl,
16 DG = tcrt_ctype_flag_digit,
17 PT = tcrt_ctype_flag_punct,
18 HX = tcrt_ctype_flag_xdigit,
19 SP = tcrt_ctype_flag_space
22 ///////////////////////////////////////////////////////////////////////////////
23 namespace {
24 const unsigned char TypeLookup[128] = {
25 CT, CT, CT, CT, CT, CT, CT, CT, CT, //0 - 31
26 CT|SP, CT|SP, CT|SP, CT|SP, CT|SP,
27 CT, CT, CT, CT, CT, CT, CT, CT, CT,
28 CT, CT, CT, CT, CT, CT, CT, CT, CT,
30 SP, //32
32 PT, PT, PT, PT, PT, PT, PT, PT, //33 - 47
33 PT, PT, PT, PT, PT, PT, PT,
35 DG, DG, DG, DG, DG, DG, DG, DG, //48 - 57
36 DG, DG,
38 PT, PT, PT, PT, PT, PT, PT, //58 - 64
40 UP|HX, UP|HX, UP|HX, UP|HX, UP|HX, UP|HX, //65 - 90
41 UP, UP, UP, UP, UP, UP, UP, UP, UP, UP,
42 UP, UP, UP, UP, UP, UP, UP, UP, UP, UP,
44 PT, PT, PT, PT, PT, PT, //91 - 96
46 LO|HX, LO|HX, LO|HX, LO|HX, LO|HX, LO|HX, //97 - 122
47 LO, LO, LO, LO, LO, LO, LO, LO, LO, LO,
48 LO, LO, LO, LO, LO, LO, LO, LO, LO, LO,
50 PT, PT, PT, PT, //123 - 126
52 CT //127
56 ///////////////////////////////////////////////////////////////////////////////
57 int tolower(int c)
59 if (isupper(c))
60 return c - 'A' + 'a';
61 return c;
64 int toupper(int c)
66 if (islower(c))
67 return c - 'a' + 'A';
68 return c;
71 int tcrt_ctype(int c)
73 if (c < 128)
74 return TypeLookup[c];
76 __debugbreak();
77 return 0;
80 // EOF ////////////////////////////////////////////////////////////////////////