summaryrefslogtreecommitdiffhomepage
path: root/src/output/slbt_output_error.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-06-27 03:51:35 +0000
committermidipix <writeonce@midipix.org>2018-06-27 07:30:01 -0400
commita82cc2f34bddae9b79e582a3bcc6b2c9cbb5009b (patch)
tree1d0de0094b350cf323b6ea8ee44f571918048789 /src/output/slbt_output_error.c
parent6088476d902b8bcbf688ce7cb6055a4c47c2d0b7 (diff)
downloadslibtool-a82cc2f34bddae9b79e582a3bcc6b2c9cbb5009b.tar.bz2
slibtool-a82cc2f34bddae9b79e582a3bcc6b2c9cbb5009b.tar.xz
driver, library interfaces: support alternate fd's for input/output/error/log.
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