From 25520aab6144927a20d501c0396e9597f36fc871 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 24 Oct 2013 22:03:09 +0300 Subject: Improve handling of writes to dead pipes. --- msg.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'msg.c') diff --git a/msg.c b/msg.c index edacdd1c..16fef73a 100644 --- a/msg.c +++ b/msg.c @@ -44,15 +44,22 @@ err(bool isfatal, const char *s, const char *emsg, va_list argp) char *file; const char *me; + static bool first = true; + static bool add_src_info = false; + + if (first) { + first = false; + add_src_info = (getenv("GAWK_MSG_SRC") != NULL); + } + (void) fflush(output_fp); me = myname; (void) fprintf(stderr, "%s: ", me); -#ifdef GAWKDEBUG - if (srcfile != NULL) { + + if (srcfile != NULL && add_src_info) { fprintf(stderr, "%s:%d:", srcfile, srcline); srcfile = NULL; } -#endif /* GAWKDEBUG */ if (sourceline > 0) { if (source != NULL) @@ -109,10 +116,10 @@ msg(const char *mesg, ...) va_end(args); } -/* warning --- print a warning message */ +/* r_warning --- print a warning message */ void -warning(const char *mesg, ...) +r_warning(const char *mesg, ...) { va_list args; va_start(args, mesg); -- cgit v1.2.3