diff --git a/src/terminal.c b/src/terminal.c index ba88597..bea27ba 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -12,7 +12,7 @@ #include #include -static bool color_mode(FILE *file) +static bool color_mode(void) { static int mode = -1; const char *var; @@ -25,17 +25,17 @@ static bool color_mode(FILE *file) else if (var && !strcmp(var, "never")) mode = false; else - return isatty(fileno(file)); + mode = isatty(fileno(stdout)); return mode; } -static void filter_ansi(FILE *file, const char *fmt, va_list args) +static void filter_ansi(const char *fmt, va_list args) { char *str = NULL; size_t len, i, j; - if (color_mode(file)) { - vfprintf(file, fmt, args); + if (color_mode()) { + vfprintf(stdout, fmt, args); return; } @@ -55,7 +55,7 @@ static void filter_ansi(FILE *file, const char *fmt, va_list args) } } for (i = 0; i < len; i = j) { - fputs(&str[i], file); + fputs(&str[i], stdout); for (j = i + strlen(&str[i]); j < len; ++j) { if (str[j] != '\0') break; @@ -70,15 +70,6 @@ void terminal_printf(const char *fmt, ...) va_list args; va_start(args, fmt); - filter_ansi(stdout, fmt, args); - va_end(args); -} - -void terminal_fprintf(FILE *file, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - filter_ansi(file, fmt, args); + filter_ansi(fmt, args); va_end(args); } diff --git a/src/terminal.h b/src/terminal.h index e8cb570..58697fa 100644 --- a/src/terminal.h +++ b/src/terminal.h @@ -47,6 +47,5 @@ #define TERMINAL_CLEAR_ALL "\x1b[2J" void terminal_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -void terminal_fprintf(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); #endif