>From 5b397a953f5ed897bc5f6861b05599063ac80b37 Mon Sep 17 00:00:00 2001 From: Matthias Paulmier Date: Fri, 7 Sep 2018 18:17:40 +0200 Subject: [PATCH 3/4] Fix termination error for .plt test files We had an error where the STDOUT handler would be closed and then reopened because of the redefinition of END in the Automake::General library. Isolating this redefinition in its own file and including it only where it is needed (in bin/* scripts) fixes this error. - lib/Automake/End.pm: Add it and move END from General.pm to here. Fixes a termination bug where the STDOUT handler was closed and reopened --- bin/aclocal.in | 1 + bin/automake.in | 1 + lib/Automake/End.pm | 47 +++++++++++++++++++++++++++++++++++++++++ lib/Automake/General.pm | 24 +-------------------- lib/Automake/local.mk | 1 + 5 files changed, 51 insertions(+), 23 deletions(-) mode change 100644 => 100755 bin/aclocal.in create mode 100644 lib/Automake/End.pm diff --git a/bin/aclocal.in b/bin/aclocal.in old mode 100644 new mode 100755 index 722affa55..09d8b89de --- a/bin/aclocal.in +++ b/bin/aclocal.in @@ -34,6 +34,7 @@ use Automake::Channels; use Automake::ChannelDefs; use Automake::XFile; use Automake::FileUtils; +use Automake::End; use File::Basename; use File::Path (); diff --git a/bin/automake.in b/bin/automake.in index b4ae8f43f..8c783074b 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -55,6 +55,7 @@ use Automake::XFile; use Automake::Channels; use Automake::ChannelDefs; use Automake::Configure_ac; +use Automake::End; use Automake::FileUtils; use Automake::Location; use Automake::Condition qw/TRUE FALSE/; diff --git a/lib/Automake/End.pm b/lib/Automake/End.pm new file mode 100644 index 000000000..7946d814b --- /dev/null +++ b/lib/Automake/End.pm @@ -0,0 +1,47 @@ +# Copyright (C) 2018 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Automake::End; + +use Exporter; +use File::Basename; + +use vars (@ISA, @EXPORT); + address@hidden = qw (Exporter); address@hidden = qw ($me); + +# Variable we share with the main package. Be sure to have a single +# copy of them: using 'my' together with multiple inclusion of this +# package would introduce several copies. +use vars qw ($me); +$me = basename ($0); + +# END +# --- +# Exit nonzero whenever closing STDOUT fails. +sub END +{ + # This is required if the code might send any output to stdout + # E.g., even --version or --help. So it's best to do it unconditionally. + if (! close STDOUT) + { + print STDERR "$me: closing standard output: $!\n"; + $? = 74; # EX_IOERR + return; + } +} + +1; diff --git a/lib/Automake/General.pm b/lib/Automake/General.pm index aa2de38b8..646608552 100644 --- a/lib/Automake/General.pm +++ b/lib/Automake/General.pm @@ -23,29 +23,7 @@ use File::Basename; use vars qw (@ISA @EXPORT); @ISA = qw (Exporter); address@hidden = qw (&uniq &none $me); - -# Variable we share with the main package. Be sure to have a single -# copy of them: using 'my' together with multiple inclusion of this -# package would introduce several copies. -use vars qw ($me); -$me = basename ($0); - -# END -# --- -# Exit nonzero whenever closing STDOUT fails. -sub END -{ - # This is required if the code might send any output to stdout - # E.g., even --version or --help. So it's best to do it unconditionally. - if (! close STDOUT) - { - print STDERR "$me: closing standard output: $!\n"; - $? = 74; # EX_IOERR - return; - } -} - address@hidden = qw (uniq none); # @RES # uniq (@LIST) diff --git a/lib/Automake/local.mk b/lib/Automake/local.mk index fbb21f3f1..75cfda75c 100644 --- a/lib/Automake/local.mk +++ b/lib/Automake/local.mk @@ -26,6 +26,7 @@ dist_perllib_DATA = \ %D%/Condition.pm \ %D%/Configure_ac.pm \ %D%/DisjConditions.pm \ + %D%/End.pm \ %D%/FileUtils.pm \ %D%/General.pm \ %D%/Getopt.pm \ -- 2.18.0