summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-07-24 03:39:51 -0400
committermidipix <writeonce@midipix.org>2018-07-24 12:05:37 -0400
commit3f9a17455a5ae3c453225684f552d9d2aebec305 (patch)
tree1a7a1a86eedf0156c5b9eb7c216ef9a814768e42 /src
parent67bba74b591b7d000eb68013334ba923ca4f216c (diff)
downloadperk-3f9a17455a5ae3c453225684f552d9d2aebec305.tar.bz2
perk-3f9a17455a5ae3c453225684f552d9d2aebec305.tar.xz
pe_output_error_record(): re-implemented with fdctx and pure fdio.
Diffstat (limited to 'src')
-rw-r--r--src/output/pe_output_error.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/output/pe_output_error.c b/src/output/pe_output_error.c
index 60e8cf6..39d7fd6 100644
--- a/src/output/pe_output_error.c
+++ b/src/output/pe_output_error.c
@@ -10,6 +10,9 @@
#include <unistd.h>
#include <perk/perk.h>
+#include "perk_driver_impl.h"
+#include "perk_dprintf_impl.h"
+
static const char aclr_reset[] = "\x1b[0m";
static const char aclr_bold[] = "\x1b[1m";
@@ -86,19 +89,24 @@ static int pe_output_error_record_plain(
{
const char * epath;
const char * errdesc = pe_output_strerror(erri);
+ int fderr = pe_driver_fderr(dctx);
epath = erri->euctx
? *erri->euctx->path
: erri->eunit;
if (epath && !(erri->eflags & PERK_ERROR_NESTED))
- if (fprintf(stderr,"%s: [%s] '%s':\n",
+ if (pe_dprintf(
+ fderr,
+ "%s: [%s] '%s':\n",
dctx->program,
pe_output_unit_header(erri),
epath) < 0)
return -1;
- if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n",
+ if (pe_dprintf(
+ fderr,
+ "%s: %s %s(), line %d%s%s.\n",
dctx->program,
pe_output_error_header(erri),
erri->efunction,
@@ -107,7 +115,7 @@ static int pe_output_error_record_plain(
errdesc) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
static int pe_output_error_record_annotated(
@@ -116,14 +124,15 @@ static int pe_output_error_record_annotated(
{
const char * epath;
const char * errdesc = pe_output_strerror(erri);
+ int fderr = pe_driver_fderr(dctx);
epath = erri->euctx
? *erri->euctx->path
: erri->eunit;
if (epath && !(erri->eflags & PERK_ERROR_NESTED))
- if (fprintf(
- stderr,
+ if (pe_dprintf(
+ fderr,
"%s%s%s:%s %s[%s]%s %s%s'%s'%s:\n",
aclr_bold,aclr_magenta,
@@ -139,8 +148,8 @@ static int pe_output_error_record_annotated(
aclr_reset) < 0)
return -1;
- if (fprintf(
- stderr,
+ if (pe_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,
@@ -165,7 +174,7 @@ static int pe_output_error_record_annotated(
aclr_reset) < 0)
return -1;
- return fflush(stderr);
+ return 0;
}
int pe_output_error_record(