summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-04 05:07:29 -0400
committermidipix <writeonce@midipix.org>2018-08-04 05:21:03 -0400
commit816f06559aa185c484f4615ae13430f52d55b084 (patch)
treed90c48d0287787160186181e7661e9f736a4ad17 /src/output
parent2dfa014f328f366d1f78481d9f91c76df5b5007a (diff)
downloadsofort-816f06559aa185c484f4615ae13430f52d55b084.tar.bz2
sofort-816f06559aa185c484f4615ae13430f52d55b084.tar.xz
sfrt_output_error_record(): re-implemented with fdctx and pure fdio.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/sfrt_output_error.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/output/sfrt_output_error.c b/src/output/sfrt_output_error.c
index 9e26f21..46b637b 100644
--- a/src/output/sfrt_output_error.c
+++ b/src/output/sfrt_output_error.c
@@ -2,7 +2,10 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+
#include <sofort/sofort.h>
+#include "sofort_driver_impl.h"
+#include "sofort_dprintf_impl.h"
static const char aclr_reset[] = "\x1b[0m";
static const char aclr_bold[] = "\x1b[1m";
@@ -75,19 +78,24 @@ static int sfrt_output_error_record_plain(
{
const char * epath;
const char * errdesc = sfrt_output_strerror(erri);
+ int fderr = sfrt_driver_fderr(dctx);
epath = erri->euctx
? *erri->euctx->path
: erri->eunit;
if (epath && !(erri->eflags & SFRT_ERROR_NESTED))
- if (fprintf(stderr,"%s: [%s] '%s':\n",
+ if (sfrt_dprintf(
+ fderr,
+ "%s: [%s] '%s':\n",
dctx->program,
sfrt_output_unit_header(erri),
epath) < 0)
return -1;
- if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n",
+ if (sfrt_dprintf(
+ fderr,
+ "%s: %s %s(), line %d%s%s.\n",
dctx->program,
sfrt_output_error_header(erri),
erri->efunction,
@@ -96,7 +104,7 @@ static int sfrt_output_error_record_plain(
errdesc) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
static int sfrt_output_error_record_annotated(
@@ -105,14 +113,15 @@ static int sfrt_output_error_record_annotated(
{
const char * epath;
const char * errdesc = sfrt_output_strerror(erri);
+ int fderr = sfrt_driver_fderr(dctx);
epath = erri->euctx
? *erri->euctx->path
: erri->eunit;
if (epath && !(erri->eflags & SFRT_ERROR_NESTED))
- if (fprintf(
- stderr,
+ if (sfrt_dprintf(
+ fderr,
"%s%s%s:%s %s[%s]%s %s%s'%s'%s:\n",
aclr_bold,aclr_magenta,
@@ -128,8 +137,8 @@ static int sfrt_output_error_record_annotated(
aclr_reset) < 0)
return -1;
- if (fprintf(
- stderr,
+ if (sfrt_dprintf(
+ fderr,
"%s%s%s:%s %s%s%s %s%s%s()%s, %s%sline %d%s%s%s%s%s.\n",
aclr_bold,aclr_magenta,
@@ -154,7 +163,7 @@ static int sfrt_output_error_record_annotated(
aclr_reset) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
int sfrt_output_error_record(
@@ -167,7 +176,7 @@ int sfrt_output_error_record(
else if (dctx->cctx->drvflags & SFRT_DRIVER_ANNOTATE_ALWAYS)
return sfrt_output_error_record_annotated(dctx,erri);
- else if (isatty(STDERR_FILENO))
+ else if (isatty(sfrt_driver_fderr(dctx)))
return sfrt_output_error_record_annotated(dctx,erri);
else
@@ -204,7 +213,7 @@ int sfrt_output_error_vector(const struct sfrt_driver_ctx * dctx)
else if (dctx->cctx->drvflags & SFRT_DRIVER_ANNOTATE_ALWAYS)
return sfrt_output_error_vector_annotated(dctx);
- else if (isatty(STDERR_FILENO))
+ else if (isatty(sfrt_driver_fderr(dctx)))
return sfrt_output_error_vector_annotated(dctx);
else