diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-25 13:27:05 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-25 13:27:05 -0400 |
| commit | f5ddf6983da99c52806687220fcf60079011b285 (patch) | |
| tree | 54c97c36b5c8c8c4d33bc5437bca40379c0c2832 /src/parse.c | |
| parent | 7994a4835b2340e12301f6897ae62e7447915f5b (diff) | |
Parser errors should use USE_COLOR as well
Diffstat (limited to 'src/parse.c')
| -rw-r--r-- | src/parse.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parse.c b/src/parse.c index 6c47dd38..9ad0db34 100644 --- a/src/parse.c +++ b/src/parse.c @@ -149,16 +149,16 @@ static PARSER(parse_deserialize); // __attribute__((noreturn, format(printf, 4, 0))) static _Noreturn void vparser_err(parse_ctx_t *ctx, const char *start, const char *end, const char *fmt, va_list args) { - if (isatty(STDERR_FILENO) && !getenv("NO_COLOR")) + if (USE_COLOR) fputs("\x1b[31;1;7m", stderr); fprintf(stderr, "%s:%ld.%ld: ", ctx->file->relative_filename, get_line_number(ctx->file, start), get_line_column(ctx->file, start)); vfprintf(stderr, fmt, args); - if (isatty(STDERR_FILENO) && !getenv("NO_COLOR")) + if (USE_COLOR) fputs(" \x1b[m", stderr); fputs("\n\n", stderr); - highlight_error(ctx->file, start, end, "\x1b[31;1;7m", 2, isatty(STDERR_FILENO) && !getenv("NO_COLOR")); + highlight_error(ctx->file, start, end, "\x1b[31;1;7m", 2, USE_COLOR); fputs("\n", stderr); if (getenv("TOMO_STACKTRACE")) @@ -321,7 +321,7 @@ static void expect_str( return; } - if (isatty(STDERR_FILENO) && !getenv("NO_COLOR")) + if (USE_COLOR) fputs("\x1b[31;1;7m", stderr); va_list args; va_start(args, fmt); @@ -345,7 +345,7 @@ static void expect_closing( const char *end = eol < next ? eol : next; - if (isatty(STDERR_FILENO) && !getenv("NO_COLOR")) + if (USE_COLOR) fputs("\x1b[31;1;7m", stderr); va_list args; va_start(args, fmt); @@ -358,7 +358,7 @@ static void expect_closing( spaces(_pos); \ auto _result = parser(ctx, *_pos); \ if (!_result) { \ - if (isatty(STDERR_FILENO) && !getenv("NO_COLOR")) \ + if (USE_COLOR) \ fputs("\x1b[31;1;7m", stderr); \ parser_err(ctx, start, *_pos, __VA_ARGS__); \ } \ |
