9 if(c == NULL || c[0] ==
'\0')
11 const unsigned int length = strlen(c);
12 static const unsigned int MAX_INT_DIGITS = 10;
13 if(length > MAX_INT_DIGITS)
15 for(
int i = 0; i < length; ++i) {
16 if(c[i] <
'0' || c[i] >
'9')
23# include <VersionHelpers.h>
24bool priv_support_color() {
25 HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
26 if(handle == INVALID_HANDLE_VALUE) {
30 if(!GetConsoleMode(handle, &mode)) {
33 mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
34 const bool succeed = SetConsoleMode(handle, mode);
37#elif defined(__linux__)
39bool priv_support_color() {
40 const char *term = getenv(
"TERM");
44 const char *color_terms[] = {
45 "xterm",
"xterm-color",
"xterm-256color",
"screen",
"screen-256color",
46 "tmux",
"tmux-256color",
"linux",
"cygwin",
"rxvt-unicode-256color",
48 const unsigned int len =
sizeof(color_terms) /
sizeof(color_terms[0]);
49 for(
size_t i = 0; i < len; i++) {
50 if(strcmp(term, color_terms[i]) == 0) {
59 static bool res =
false;
60 static bool checked =
false;
63 res = priv_support_color();
bool is_number(const char *c)