diff --git a/tty_utils.c b/tty_utils.c index 0615582..5c97530 100644 --- a/tty_utils.c +++ b/tty_utils.c @@ -4,16 +4,12 @@ #include #include "tty_utils.h" -void print_colored_prefix(FILE *stream, const char *color, bool is_tty) { - if (is_tty) { - fprintf(stream, "\033[%sm", color); - } +void print_colored_prefix(FILE *stream, const char *color) { + fprintf(stream, "\033[%sm", color); } -void print_colored_suffix(FILE *stream, bool is_tty) { - if (is_tty) { - fprintf(stream, "\033[0m"); - } +void print_colored_suffix(FILE *stream) { + fprintf(stream, "\033[0m"); } void fprintf_error(const char *format, ...) { @@ -21,9 +17,9 @@ void fprintf_error(const char *format, ...) { va_start(args, format); bool is_tty = isatty(fileno(stderr)); - print_colored_prefix(stderr, "31", is_tty); + if (is_tty) print_colored_prefix(stderr, "31"); vfprintf(stderr, format, args); - print_colored_suffix(stderr, is_tty); + if (is_tty) print_colored_suffix(stderr); va_end(args); } \ No newline at end of file