From d4a8005fd2d5adddabf537d26f932192b226806f Mon Sep 17 00:00:00 2001 From: Matthias Paulmier Date: Wed, 1 Aug 2018 13:08:22 +0200 Subject: Move the END sub to another module This fixes the warning we had in bcbc407fb where the STDOUT handle was closed and reopened. --- bin/aclocal.in | 1 + bin/automake.in | 1 + lib/Automake/End.pm | 41 +++++++++++++++++++++++++++++++++++++++++ lib/Automake/General.pm | 25 +------------------------ lib/Automake/local.mk | 1 + 5 files changed, 45 insertions(+), 24 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 c0cfd1e6f..06c09f978 100755 --- a/bin/automake.in +++ b/bin/automake.in @@ -59,6 +59,7 @@ use Automake::ConfVars; use Automake::Configure_ac; use Automake::DisjConditions; use Automake::Errors; +use Automake::End; use Automake::File; use Automake::FileUtils; use Automake::General; diff --git a/lib/Automake/End.pm b/lib/Automake/End.pm new file mode 100644 index 000000000..9de7b1388 --- /dev/null +++ b/lib/Automake/End.pm @@ -0,0 +1,41 @@ +# 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 File::Basename; + +# 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 3a3eda255..d194bea12 100644 --- a/lib/Automake/General.pm +++ b/lib/Automake/General.pm @@ -19,33 +19,10 @@ use 5.006; use strict; use Exporter 'import'; -use File::Basename; use vars qw (@EXPORT); -@EXPORT = 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; - } -} - +@EXPORT = qw (&uniq &none); # @RES # uniq (@LIST) diff --git a/lib/Automake/local.mk b/lib/Automake/local.mk index 6a5a7101d..6a40a1839 100644 --- a/lib/Automake/local.mk +++ b/lib/Automake/local.mk @@ -29,6 +29,7 @@ dist_perllib_DATA = \ %D%/Configure_ac.pm \ %D%/ConfVars.pm \ %D%/DisjConditions.pm \ + %D%/End.pm \ %D%/Errors.pm \ %D%/File.pm \ %D%/FileUtils.pm \ -- cgit v1.2.1