summaryrefslogtreecommitdiff
path: root/src/output/slbt_output_error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/output/slbt_output_error.c')
-rw-r--r--src/output/slbt_output_error.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/output/slbt_output_error.c b/src/output/slbt_output_error.c
index 49a27b8..0ccabb2 100644
--- a/src/output/slbt_output_error.c
+++ b/src/output/slbt_output_error.c
@@ -10,6 +10,9 @@
#include <unistd.h>
#include <slibtool/slibtool.h>
+#include "slibtool_driver_impl.h"
+#include "slibtool_dprintf_impl.h"
+
static const char aclr_reset[] = "\x1b[0m";
static const char aclr_bold[] = "\x1b[1m";
@@ -56,7 +59,8 @@ static int slbt_output_error_record_plain(
{
const char * errdesc = slbt_output_strerror(erri);
- if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n",
+ if (slbt_dprintf(slbt_driver_fderr(dctx),
+ "%s: %s %s(), line %d%s%s.\n",
dctx->program,
slbt_output_error_header(erri),
erri->efunction,
@@ -65,7 +69,7 @@ static int slbt_output_error_record_plain(
errdesc) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
static int slbt_output_error_record_annotated(
@@ -74,8 +78,8 @@ static int slbt_output_error_record_annotated(
{
const char * errdesc = slbt_output_strerror(erri);
- if (fprintf(
- stderr,
+ if (slbt_dprintf(
+ slbt_driver_fderr(dctx),
"%s%s%s:%s %s%s%s %s%s%s()%s, %s%sline %d%s%s%s%s%s.\n",
aclr_bold,aclr_magenta,
@@ -100,20 +104,22 @@ static int slbt_output_error_record_annotated(
aclr_reset) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
int slbt_output_error_record(
const struct slbt_driver_ctx * dctx,
const struct slbt_error_info * erri)
{
+ int fderr = slbt_driver_fderr(dctx);
+
if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_NEVER)
return slbt_output_error_record_plain(dctx,erri);
else if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_ALWAYS)
return slbt_output_error_record_annotated(dctx,erri);
- else if (isatty(STDERR_FILENO))
+ else if (isatty(fderr))
return slbt_output_error_record_annotated(dctx,erri);
else
@@ -144,13 +150,15 @@ static int slbt_output_error_vector_annotated(const struct slbt_driver_ctx * dct
int slbt_output_error_vector(const struct slbt_driver_ctx * dctx)
{
+ int fderr = slbt_driver_fderr(dctx);
+
if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_NEVER)
return slbt_output_error_vector_plain(dctx);
else if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_ALWAYS)
return slbt_output_error_vector_annotated(dctx);
- else if (isatty(STDERR_FILENO))
+ else if (isatty(fderr))
return slbt_output_error_vector_annotated(dctx);
else