bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] make check: 2 TESTS FAILED


From: Aharon Robbins
Subject: Re: [bug-gawk] make check: 2 TESTS FAILED
Date: Tue, 22 Oct 2013 22:27:38 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi.

> The warning message continues to occur sometimes and accordingly, make 
> check fails (sometimes), see below.

Third time's the charm.  Please try the following patch, after a
git reset --hard.

Thanks,

Arnold
------------------------------------
diff --git a/ChangeLog b/ChangeLog
index f7f40fd..3798a5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-10-22         Arnold D. Robbins     <address@hidden>
+
+       Revise error messages when writing to standard output or standard
+       error to ignore EPIPE.  Add the ability based on an environment
+       variable to get the source file and line number.
+
+       * awk.h (r_warning): Renamed from warning.
+       (warning): New macro to set location and call warning.
+       * io.c (flush_io): Print errors only if not EPIPE.
+       (close_io): Ditto.
+       * main.c (lintfunc): Init to r_warning.
+       (main): Enhance explanatory comment.
+       (usage): Print errors only if not EPIPE.
+       (copyleft): Ditto.
+       * msg.c (err): Make printing srcfile and srcline depend upon
+       GAWK_MSG_SRC environment variable.
+       (r_warning): Renamed from warning.
+
 2013-10-17         Arnold D. Robbins     <address@hidden>
 
        * main.c (main): Ignore SIGPIPE. See the comment in the code.
diff --git a/awk.h b/awk.h
index e2744e5..6c6e840 100644
--- a/awk.h
+++ b/awk.h
@@ -213,6 +213,8 @@ typedef void *stackoverflow_context_t;
 /* use this as lintwarn("...")
    this is a hack but it gives us the right semantics */
 #define lintwarn (*(set_loc(__FILE__, __LINE__),lintfunc))
+/* same thing for warning */
+#define warning (*(set_loc(__FILE__, __LINE__),r_warning))
 
 #ifdef HAVE_MPFR
 #include <gmp.h>
@@ -1577,7 +1579,7 @@ extern void final_exit(int status) ATTRIBUTE_NORETURN;
 extern void err(bool isfatal, const char *s, const char *emsg, va_list argp) 
ATTRIBUTE_PRINTF(3, 0);
 extern void msg (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
 extern void error (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
-extern void warning (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
+extern void r_warning (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
 extern void set_loc (const char *file, int line);
 extern void r_fatal (const char *mesg, ...) ATTRIBUTE_PRINTF_1;
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 2ee9450..5cef459 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-22         Arnold D. Robbins     <address@hidden>
+
+       * gawktexi.in (Other Environment Variables): Document GAWK_MSG_SRC
+       variable and fix documentation of *_CHAIN_MAX variables.
+
 2013-10-11         Arnold D. Robbins     <address@hidden>
 
        * gawktexi.in (Conversion, Printf Ordering): Better wording for
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index e1b86c7..f5e0fc0 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -3884,10 +3884,6 @@ for use by the @command{gawk} developers for testing and 
tuning.
 They are subject to change. The variables are:
 
 @table @env
address@hidden AVG_CHAIN_MAX
-The average number of items @command{gawk} will maintain on a
-hash chain for managing arrays.
-
 @item AWK_HASH
 If this variable exists with a value of @samp{gst}, @command{gawk}
 will switch to using the hash function from GNU Smalltalk for
@@ -3900,6 +3896,13 @@ files one line at a time, instead of reading in blocks. 
This exists
 for debugging problems on filesystems on non-POSIX operating systems
 where I/O is performed in records, not in blocks.
 
address@hidden GAWK_MSG_SRC
+If this variable exists, @command{gawk} includes the source file
+name and line number from which warning and/or fatal messages
+are generated.  Its purpose is to help isolate the source of a
+message, since there can be multiple places which produce the
+same warning or error message.
+
 @item GAWK_NO_DFA
 If this variable exists, @command{gawk} does not use the DFA regexp matcher
 for ``does it match'' kinds of tests. This can cause @command{gawk}
@@ -3912,6 +3915,14 @@ coordinate with each other.)
 This specifies the amount by which @command{gawk} should grow its
 internal evaluation stack, when needed.
 
address@hidden INT_CHAIN_MAX
+The average number of items @command{gawk} will maintain on a
+hash chain for managing arrays indexed by integers.
+
address@hidden STR_CHAIN_MAX
+The average number of items @command{gawk} will maintain on a
+hash chain for managing arrays indexed by strings.
+
 @item TIDYMEM
 If this variable exists, @command{gawk} uses the @code{mtrace()} library
 calls from GNU LIBC to help track down possible memory leaks.
diff --git a/io.c b/io.c
index e0632d8..a24ac82 100644
--- a/io.c
+++ b/io.c
@@ -1261,11 +1261,11 @@ flush_io()
        int status = 0;
 
        errno = 0;
-       if (fflush(stdout)) {
+       if (fflush(stdout) && errno != EPIPE) {
                warning(_("error writing standard output (%s)"), 
strerror(errno));
                status++;
        }
-       if (fflush(stderr)) {
+       if (fflush(stderr) && errno != EPIPE) {
                warning(_("error writing standard error (%s)"), 
strerror(errno));
                status++;
        }
@@ -1316,12 +1316,12 @@ close_io(bool *stdio_problem)
         * them, we just flush them, and do that across the board.
         */
        *stdio_problem = false;
-       if (fflush(stdout)) {
+       if (fflush(stdout) != 0 && errno != EPIPE) {
                warning(_("error writing standard output (%s)"), 
strerror(errno));
                status++;
                *stdio_problem = true;
        }
-       if (fflush(stderr)) {
+       if (fflush(stderr) != 0 && errno != EPIPE) {
                warning(_("error writing standard error (%s)"), 
strerror(errno));
                status++;
                *stdio_problem = true;
diff --git a/main.c b/main.c
index d765a43..6c916f7 100644
--- a/main.c
+++ b/main.c
@@ -157,7 +157,7 @@ GETGROUPS_T *groupset;              /* current group set */
 int ngroups;                   /* size of said set */
 #endif
 
-void (*lintfunc)(const char *mesg, ...) = warning;
+void (*lintfunc)(const char *mesg, ...) = r_warning;
 
 static const struct option optab[] = {
        { "traditional",        no_argument,            NULL,   'c' },
@@ -289,6 +289,14 @@ main(int argc, char **argv)
         * Ignore SIGPIPE so that writes to pipes that fail don't
         * kill the process but instead return -1 and set errno.
         * That lets us print a fatal message instead of dieing suddenly.
+        *
+        * Note that this requires ignoring EPIPE when writing and
+        * flushing stdout/stderr in other parts of the program. E.g.,
+        *
+        *      gawk 'BEGIN { print "hi" }' | exit
+        *
+        * should not give us "broken pipe" messages --- mainly because
+        * it did not do so in the past and people would complain.
         */
        signal(SIGPIPE, SIG_IGN);
 #endif
@@ -849,7 +857,7 @@ By default it reads standard input and writes standard 
output.\n\n"), fp);
        fflush(fp);
 
        if (ferror(fp)) {
-               if (fp == stdout)
+               if (fp == stdout && errno != EPIPE)
                        warning(_("error writing standard output (%s)"), 
strerror(errno));
                exit(EXIT_FAILURE);
        }
@@ -886,7 +894,7 @@ along with this program. If not, see 
http://www.gnu.org/licenses/.\n";);
        fputs(_(blurb_part3), stdout);
        fflush(stdout);
 
-       if (ferror(stdout)) {
+       if (ferror(stdout) && errno != EPIPE) {
                warning(_("error writing standard output (%s)"), 
strerror(errno));
                exit(EXIT_FAILURE);
        }
diff --git a/msg.c b/msg.c
index edacdd1..16fef73 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);
diff --git a/test/ChangeLog b/test/ChangeLog
index 4de3d14..beabad0 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,14 @@
+2013-10-22         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (pipeio3): Enhance test to be more resilient to variations
+       in error messages produced by different Bourne shells when a command
+       is not found.
+
+2013-10-17         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (pipeio3): New test.
+       * pipeio3.awk, pipeio3.ok: New files.
+
 2013-10-10         Arnold D. Robbins     <address@hidden>
 
        * Makefile.am (backbigs1, backsmalls1): New tests.
diff --git a/test/Makefile.am b/test/Makefile.am
index abb3fb9..ff3db19 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1882,6 +1882,12 @@ backsmalls1:
        AWKPATH="$(srcdir)" $(AWK) -f address@hidden "$(srcdir)"/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 
+pipeio3:
+       @echo $@
+       @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
+       @sed 's/sh.*cart:.*not found/sh: 1: cart: not found/' < _$@ >_x$@ ; mv 
_x$@ _$@
+       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
 # Targets generated for other tests:
 include Maketests
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 9676494..2ab56a5 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -2275,6 +2275,12 @@ backsmalls1:
        @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
        AWKPATH="$(srcdir)" $(AWK) -f address@hidden "$(srcdir)"/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
+pipeio3:
+       @echo $@
+       @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
+       @sed 's/sh.*cart:.*not found/sh: 1: cart: not found/' < _$@ >_x$@ ; mv 
_x$@ _$@
+       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 Gt-dummy:
 # file Maketests, generated from Makefile.am by the Gentests program
 addcomma:
@@ -3184,11 +3190,6 @@ getlnhd:
        @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 
-pipeio3:
-       @echo $@
-       @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
-       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
-
 aadelete1:
        @echo $@
        @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 29f9a17..df272ce 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -907,11 +907,6 @@ getlnhd:
        @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 
-pipeio3:
-       @echo $@
-       @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
-       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
-
 aadelete1:
        @echo $@
        @AWKPATH="$(srcdir)" $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@



reply via email to

[Prev in Thread] Current Thread [Next in Thread]