autoconf-patches
[Top][All Lists]
Advanced

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

FYI: `END' in Autom4te::General


From: Akim Demaille
Subject: FYI: `END' in Autom4te::General
Date: 01 Aug 2001 17:09:57 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/Autom4te/General.pm: Use `carp' and `croak', not `warn' and
        `die'.
        (&END): New.
        * bin/autoconf.in, bin/autom4te.in, bin/autoupdate.in: Remove your
        `END', as `Autom4te::General::END' will be triggered.
        * bin/autoupdate.in, bin/autoscan.in: Improve error messages accuracy.
        * bin/autoupdate.in (File::Compare, File::Copy): Use them instead of
        system to run `mv', `rm', and `cmp'.

Index: bin/autom4te.in
===================================================================
RCS file: /cvs/autoconf/bin/autom4te.in,v
retrieving revision 1.13
diff -u -u -r1.13 autom4te.in
--- bin/autom4te.in 2001/08/01 15:02:36 1.13
+++ bin/autom4te.in 2001/08/01 15:05:57
@@ -280,39 +280,6 @@
 ## ---------- ##
 
 
-# END
-# ---
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
-  use POSIX qw (_exit);
-
-  my ($q) = ($?);
-
-  # FIXME: Heelp!  Can't find a means to properly catch system's
-  # exit status (without hair I mean).
-  # my $status = $? >> 8;
-
-  if (!$debug && defined $tmp && -d $tmp)
-    {
-      if (<$tmp/*>)
-       {
-         unlink <$tmp/*>
-           or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
-       }
-      rmdir $tmp
-       or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
-    }
-
-  # 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.
-  close STDOUT
-    or (warn "$me: closing standard output: $!\n"), _exit (1);
-
-  ($!, $?) = (0, $q);
-}
-
-
 # $FILENAME
 # find_file ($FILENAME)
 # ---------------------
Index: bin/autoscan.in
===================================================================
RCS file: /cvs/autoconf/bin/autoscan.in,v
retrieving revision 1.61
diff -u -u -r1.61 autoscan.in
--- bin/autoscan.in 2001/08/01 15:02:36 1.61
+++ bin/autoscan.in 2001/08/01 15:05:57
@@ -77,16 +77,6 @@
 my $autoconf = find_peer ('autoconf', "@bindir@", 'autoconf-name');
 my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@";
 
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
-  use POSIX qw (_exit);
-  # 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.
-  close STDOUT
-    or (warn "$me: closing standard output: $!\n"), _exit (1);
-}
-
 
 ## ------------------------ ##
 ## Command line interface.  ##
@@ -555,7 +545,7 @@
   verbose "running: $autoconf -A $datadir $trace_option $configure_ac";
   my $traces =
     new IO::File "$autoconf -A $datadir $trace_option $configure_ac|"
-      or die "$me: cannot create read traces: $!\n";
+      or die "$me: cannot open traces reading pipe: $!\n";
 
   while ($_ = $traces->getline)
     {
@@ -583,7 +573,7 @@
     }
 
   $traces->close
-    or die "$me: cannot close: $!\n";
+    or die "$me: cannot close traces reading pipe: $!\n";
 
   # Report the missing macros.
   foreach my $macro (sort keys %needed_macros)
Index: bin/autoupdate.in
===================================================================
RCS file: /cvs/autoconf/bin/autoupdate.in,v
retrieving revision 1.15
diff -u -u -r1.15 autoupdate.in
--- bin/autoupdate.in 2001/08/01 15:01:16 1.15
+++ bin/autoupdate.in 2001/08/01 15:05:57
@@ -33,6 +33,8 @@
 
 use Getopt::Long;
 use File::Basename;
+use File::Compare;
+use File::Copy;
 use Autom4te::General;
 use strict;
 
@@ -50,36 +52,6 @@
 ## ---------- ##
 
 
-# END
-# ---
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
-  use POSIX qw (_exit);
-
-  my ($q) = ($?);
-
-  # FIXME: Heelp!  Can't find a means to properly catch system's
-  # exit status (without hair I mean).
-  # my $status = $? >> 8;
-
-  if (!$debug && -d $tmp)
-    {
-      unlink <$tmp/*>
-       or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
-      rmdir $tmp
-       or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
-    }
-
-  # 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.
-  close STDOUT
-    or (warn "$me: closing standard output: $!\n"), _exit (1);
-
-  ($!, $?) = (0, $q);
-}
-
-
 # print_usage ()
 # --------------
 # Display usage (--help).
@@ -191,18 +163,18 @@
     print M4SAVE_M4 "define([_au_$_], defn([$_]))\n";
   }
 close M4SAVE_M4
-  or die "$me: cannot close: $!\n";
+  or die "$me: cannot close $tmp/m4save.m4: $!\n";
 close UNM4_M4
-  or die "$me: cannot close: $!\n";
+  or die "$me: cannot close $tmp/unm4.m4: $!\n";
 close M4_M4
-  or die "$me: cannot close: $!\n";
+  or die "$me: cannot close $tmp/m4.m4: $!\n";
 
 
 # @AU_MACROS & AC_MACROS -- AU and AC macros and yet another useful comment.
 open MACROS, ("$autoconf "
              . "--trace AU_DEFUN:'AU:\$f:\$1' --trace define:'AC:\$f:\$1' "
              . "-i /dev/null |")
-  or die "$me: cannot open: $!\n";
+  or die "$me: cannot open definitions reading pipe: $!\n";
 my (%ac_macros, %au_macros);
 while (<MACROS>)
   {
@@ -219,7 +191,8 @@
       }
   }
 close MACROS
-  or die "$me: cannot close: $!\n";
+  or die ($! ? "$me: cannot close definitions reading pipe: $!\n"
+         : "$me: definitions reading pipe failed with exit status: $?\n");
 # Don't keep AU macros in @AC_MACROS.
 delete $ac_macros{$_}
   foreach (keys %au_macros);
@@ -253,9 +226,9 @@
     print DISABLE_M4 "_au_undefine([$_])\n";
   }
 close DISABLE_M4
-  or die "$me: cannot close: $!\n";
+  or die "$me: cannot close $tmp/disable.m4: $!\n";
 close AC_M4
-  or die "$me: cannot close: $!\n";
+  or die "$me: cannot close $tmp/ac.m4: $!\n";
 
 
 
@@ -284,7 +257,7 @@
       divert(-1)                                            -*- Autoconf -*-
       changequote([, ])
 
-      # Move all the builtins into the \`_au_' pseudo namespace
+      # Move all the builtins into the `_au_' pseudo namespace
       include([$tmp/m4save.m4])
 
       # _au_defun(NAME, BODY)
@@ -309,7 +282,7 @@
       # above).  But since AU macros might use AU macros, which should
       # enable/disable only for the outter AU macros.
       #
-      # \`_au_enabled' is used to this end, condionning whether we really
+      # `_au_enabled' is used to this end, condionning whether we really
       # enable/disable.
 
 
@@ -385,43 +358,34 @@
         print INPUT_M4;
        }
     close FILE
-       or die "$me: cannot close: $!\n";
+       or die "$me: cannot close $file: $!\n";
     close INPUT_M4
-       or die "$me: cannot close: $!\n";
+       or die "$me: cannot close $tmp/input.m4: $!\n";
 
     # Now ask m4 to perform the update.
-    print STDERR "$me: running $m4 $tmp/input.m4\n"
-       if $verbose;
-    if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
-       {
-        # Exit status of system() is in the upper byte.
-        $! >>= 8;
-        die "$me: cannot update \`$filename'\n";
-       };
-
     if ("$file" eq "$tmp/stdin")
-       {
-        system ("cat $tmp/updated");
-       }
-    elsif (! system ("cmp -s $tmp/updated $file"))
        {
-        # File didn't change, so don't update its mod time.
-        print STDERR "$me: \`$file' is unchanged\n"
+        xsystem ("$m4 $tmp/input.m4");
        }
     else
        {
-        # Back up and install the new one.
-        if (system ("mv $file $file${SIMPLE_BACKUP_SUFFIX} && "
-                    . "mv $tmp/updated $file") == 0)
+        xsystem ("$m4 $tmp/input.m4 >$tmp/updated");
+        if (compare ("$tmp/updated", "$file") == 0)
           {
-            print STDERR "$me: \`$file' is updated\n";
+            # File didn't change, so don't update its mod time.
+            print STDERR "$me: `$file' is unchanged\n"
           }
         else
           {
-            die "$me: cannot update \`$file'\n";
+            # Back up and install the new one.
+            move ("$file",  "$file$SIMPLE_BACKUP_SUFFIX")
+              or die "$me: cannot not backup $file: $!\n";
+            move ("$tmp/updated", "$file")
+              or die "$me: cannot not update $file: $!\n";
+            print STDERR "$me: `$file' is updated\n";
           }
        }
-  }
+     }
 
 exit 0;
 
Index: lib/Autom4te/General.pm
===================================================================
RCS file: /cvs/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.2
diff -u -u -r1.2 General.pm
--- lib/Autom4te/General.pm 2001/08/01 15:02:36 1.2
+++ lib/Autom4te/General.pm 2001/08/01 15:05:58
@@ -41,7 +41,44 @@
 use vars qw ($debug);
 $debug = 0;
 
+# Our tmp dir.
+use vars qw ($tmp);
+$tmp = undef;
+
+
+# END
+# ---
+# Exit nonzero whenever closing STDOUT fails.
+# Ideally we should `exit ($? >> 8)', unfortunately, for some reason
+# I don't understand, whenever we `exit (1)' somewhere in the code,
+# we arrive here with `$? = 29'.  I suspect some low level END routine
+# might be responsible.  In this case, be sure to exit 1, not 29.
+sub END
+{
+  my $exit_status = $? ? 1 : 0;
+
+  use POSIX qw (_exit);
+
+  if (!$debug && defined $tmp && -d $tmp)
+    {
+      if (<$tmp/*>)
+       {
+         unlink <$tmp/*>
+           or carp ("$me: cannot empty $tmp: $!\n"), _exit (1);
+       }
+      rmdir $tmp
+       or carp ("$me: cannot remove $tmp: $!\n"), _exit (1);
+    }
+
+  # 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.
+  close STDOUT
+    or (carp "$me: closing standard output: $!\n"), _exit (1);
+
+  _exit ($exit_status);
+}
 
+
 # $CONFIGURE_AC
 # &find_configure_ac ()
 # ---------------------
@@ -51,8 +88,8 @@
     {
       if (-f 'configure.in')
        {
-         warn "warning: `configure.ac' and `configure.in' both present.\n";
-         warn "warning: proceeding with `configure.ac'.\n";
+         carp "warning: `configure.ac' and `configure.in' both present.\n";
+         carp "warning: proceeding with `configure.ac'.\n";
        }
       return 'configure.ac';
     }
@@ -101,10 +138,6 @@
   return $res;
 }
 
-
-# Our tmp dir.
-use vars qw ($tmp);
-$tmp = undef;
 
 # mktmpdir ($SIGNATURE)
 # ---------------------



reply via email to

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