]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/Autom4te/General.pm: Use `carp' and `croak', not `warn' and
authorAkim Demaille <akim@epita.fr>
Wed, 1 Aug 2001 15:10:36 +0000 (15:10 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 1 Aug 2001 15:10:36 +0000 (15:10 +0000)
`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'.

ChangeLog
bin/autom4te.in
bin/autoscan.in
bin/autoupdate.in
lib/Autom4te/General.pm

index 5f468c68c8be405d1f29cb3ed06574cb3558fc63..a0f1cd90ad262337a8affa53931635f62e6a9704 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2001-08-01  Akim Demaille  <akim@epita.fr>
+
+       * 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'.
+
 2001-08-01  Akim Demaille  <akim@epita.fr>
 
        * lib/Autom4te/General.pm (&unique): New.
index 64329e75ab036bef335f1d4660c545545aaf0793..891bfd7703aeeedb2b015dc9d47b25f039c29fe5 100644 (file)
@@ -280,39 +280,6 @@ map { s/:.*//;s/\W// } @m4_builtins;
 ## ---------- ##
 
 
-# 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 50d01553341d948a5bb4af8e648eeec4d73cb160..be508aff5efd87ca9ad13639053c76394b72ab3a 100644 (file)
@@ -77,16 +77,6 @@ my $log = new IO::File ">$me.log"
 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 @@ sub check_configure_ac ($)
   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 @@ sub check_configure_ac ($)
     }
 
   $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 a5dbae70fb706d7426ca4d826cfed57c9f0ecfe0..9fd790386063728fb84f2403db8d0b670070154b 100644 (file)
@@ -33,6 +33,8 @@ BEGIN
 
 use Getopt::Long;
 use File::Basename;
+use File::Compare;
+use File::Copy;
 use Autom4te::General;
 use strict;
 
@@ -50,36 +52,6 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
 ## ---------- ##
 
 
-# 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 @@ foreach (@m4_builtins)
     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 @@ while (<MACROS>)
       }
   }
 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 @@ foreach (sort keys %ac_macros)
     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 @@ foreach my $file (@ARGV)
       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 @@ foreach my $file (@ARGV)
       # 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 @@ EOF
         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 4194aab4913335821ac1c51a17e4911c3712a2ea..bcfcdf8c3ead7e3583512ca78f266169c2aea45f 100644 (file)
@@ -41,6 +41,43 @@ $verbose = 0;
 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 @@ sub find_configure_ac ()
     {
       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';
     }
@@ -102,10 +139,6 @@ sub find_peer ($$$)
 }
 
 
-# Our tmp dir.
-use vars qw ($tmp);
-$tmp = undef;
-
 # mktmpdir ($SIGNATURE)
 # ---------------------
 # Create a temporary directory which name is based on $SIGNATURE.