From 8fcf6261bdb4bee39ce5d197340113ca72967774 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 20 May 2021 13:05:15 -0700 Subject: [PATCH] Print errors to stderr instead of stdout --- print.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/print.c b/print.c index 8c2fe5f..3dd8d6c 100644 --- a/print.c +++ b/print.c @@ -408,17 +408,18 @@ void print_match(FILE *out, printer_t *pr, match_t *m) } // -// Print any errors that are present in the given match object. +// Print any errors that are present in the given match object to stderr and +// return the number of errors found. // int print_errors(printer_t *pr, match_t *m) { int ret = 0; if (m->pat->type == BP_ERROR) { - printf("\033[31;1m"); + fprintf(stderr, "\033[31;1m"); printer_t tmp = {.file = pr->file}; // No bells and whistles - print_match(stdout, &tmp, m); // Error message - printf("\033[0m\n"); - fprint_line(stdout, pr->file, m->start, m->end, " "); + print_match(stderr, &tmp, m); // Error message + fprintf(stderr, "\033[0m\n"); + fprint_line(stderr, pr->file, m->start, m->end, " "); return 1; } if (m->child) ret += print_errors(pr, m->child);