aboutsummaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-20 13:05:15 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-20 13:05:15 -0700
commit8fcf6261bdb4bee39ce5d197340113ca72967774 (patch)
treee0cb3c3b76e23835911be5330988348dfbcb424c /print.c
parent13e1b20f436927e1550a02e7a90653352f70378a (diff)
Print errors to stderr instead of stdout
Diffstat (limited to 'print.c')
-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);