Commit 53a024a9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set data type of stdXX_is_tty to bool.

parent fa07d9db
......@@ -345,15 +345,15 @@ cdo_init_is_tty()
{
struct stat statbuf;
fstat(0, &statbuf);
if (S_ISCHR(statbuf.st_mode)) stdin_is_tty = 1;
if (S_ISCHR(statbuf.st_mode)) stdin_is_tty = true;
fstat(1, &statbuf);
if (S_ISCHR(statbuf.st_mode))
{
stdout_is_tty = 1;
Progress::stdout_is_tty = 1;
stdout_is_tty = true;
Progress::stdout_is_tty = true;
}
fstat(2, &statbuf);
if (S_ISCHR(statbuf.st_mode)) stderr_is_tty = 1;
if (S_ISCHR(statbuf.st_mode)) stderr_is_tty = true;
}
static void
......
......@@ -18,9 +18,9 @@
#include <functional>
#include "mpmo_color.h"
int stdin_is_tty = 0;
int stdout_is_tty = 0;
int stderr_is_tty = 0;
bool stdin_is_tty = false;
bool stdout_is_tty = false;
bool stderr_is_tty = false;
int CDO_Color = 1;
......@@ -56,21 +56,20 @@ set_text_color(FILE *fp, TextColor fg)
void
reset_text_color(FILE *fp)
{
int attr = MODELESS;
if (fp == stdout && !COLOR_STDOUT) return;
if (fp == stderr && !COLOR_STDERR) return;
fprintf(fp, "%c[%dm", 0x1B, attr);
fprintf(fp, "%c[%dm", 0x1B, MODELESS);
}
void colorize(FILE *fp, TextColor fg, TextMode mode, std::function<void()> func)
{
set_text_color(fp, mode, fg);
func();
reset_text_color(fp);
set_text_color(fp, mode, fg);
func();
reset_text_color(fp);
}
void colorize(FILE *fp, TextColor fg, std::function<void()> func)
{
colorize(fp,fg,MODELESS,func);
colorize(fp,fg,MODELESS,func);
}
......@@ -46,9 +46,9 @@ enum TextColor
WHITE = 37
};
extern int stdin_is_tty;
extern int stdout_is_tty;
extern int stderr_is_tty;
extern bool stdin_is_tty;
extern bool stdout_is_tty;
extern bool stderr_is_tty;
extern int CDO_Color;
......
......@@ -5,7 +5,7 @@
namespace Progress
{
bool stdout_is_tty = 0;
bool stdout_is_tty = false;
bool silentMode = false;
bool ps_lhead = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment