From e01b88a1f828d670fa9b2ce086631db0af235d21 Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 30 Jul 2018 12:13:22 +0000 Subject: mdso_output_error_record(): re-implemented with fdctx and pure fdio. --- src/output/mdso_output_error.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/output/mdso_output_error.c b/src/output/mdso_output_error.c index 108d9ff..328c5cf 100644 --- a/src/output/mdso_output_error.c +++ b/src/output/mdso_output_error.c @@ -10,6 +10,9 @@ #include #include +#include "mdso_driver_impl.h" +#include "mdso_dprintf_impl.h" + static const char aclr_reset[] = "\x1b[0m"; static const char aclr_bold[] = "\x1b[1m"; @@ -85,19 +88,24 @@ static int mdso_output_error_record_plain( { const char * epath; const char * errdesc = mdso_output_strerror(erri); + int fderr = mdso_driver_fderr(dctx); epath = erri->euctx ? *erri->euctx->path : erri->eunit; if (epath && !(erri->eflags & MDSO_ERROR_NESTED)) - if (fprintf(stderr,"%s: [%s] '%s':\n", + if (mdso_dprintf( + fderr, + "%s: [%s] '%s':\n", dctx->program, mdso_output_unit_header(erri), epath) < 0) return -1; - if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n", + if (mdso_dprintf( + fderr, + "%s: %s %s(), line %d%s%s.\n", dctx->program, mdso_output_error_header(erri), erri->efunction, @@ -106,7 +114,7 @@ static int mdso_output_error_record_plain( errdesc) < 0) return -1; - return fflush(stderr); + return 0; } static int mdso_output_error_record_annotated( @@ -115,14 +123,15 @@ static int mdso_output_error_record_annotated( { const char * epath; const char * errdesc = mdso_output_strerror(erri); + int fderr = mdso_driver_fderr(dctx); epath = erri->euctx ? *erri->euctx->path : erri->eunit; if (epath && !(erri->eflags & MDSO_ERROR_NESTED)) - if (fprintf( - stderr, + if (mdso_dprintf( + fderr, "%s%s%s:%s %s[%s]%s %s%s'%s'%s:\n", aclr_bold,aclr_magenta, @@ -138,8 +147,8 @@ static int mdso_output_error_record_annotated( aclr_reset) < 0) return -1; - if (fprintf( - stderr, + if (mdso_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, @@ -164,7 +173,7 @@ static int mdso_output_error_record_annotated( aclr_reset) < 0) return -1; - return fflush(stderr); + return 0; } int mdso_output_error_record( -- cgit v1.2.3