aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--print.c11
1 files 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);