]> sourceware.org Git - automake.git/commitdiff
* aclocal.in (install_file): Cannot use /dev/null while diffing
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 4 Aug 2006 08:42:54 +0000 (08:42 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 4 Aug 2006 08:42:54 +0000 (08:42 +0000)
new files, because Tru64's diff do not handle /dev/null.  So
create an empty destination file before running diff on a new
file, and erase it afterward.  Fall back to using /dev/null only
if we cannot create this file.
Report and initial patch from Ralf Wildenhues.
(unlink_tmp): New function.
* test/acloca18.test: Make sure the empty file has been erased.

ChangeLog
aclocal.in
tests/acloca18.test

index 5a73452ea50fe59f4fe77f7f46f5bdb694bfcf73..922599abf8f78e02f96db94f0b48e948b95c39a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-08-04  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * aclocal.in (install_file): Cannot use /dev/null while diffing
+       new files, because Tru64's diff do not handle /dev/null.  So
+       create an empty destination file before running diff on a new
+       file, and erase it afterward.  Fall back to using /dev/null only
+       if we cannot create this file.
+       Report and initial patch from Ralf Wildenhues.
+       (unlink_tmp): New function.
+       * test/acloca18.test: Make sure the empty file has been erased.
+
 2006-08-04  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * automake.in (handle_LIBOBJS_or_ALLOCA): With subdir-objects,
index acb05d2533c5331123c850e5c3094cab3ae8d25b..5cc280f9fe57ca8867793fddfd5ef81a46aee9e2 100644 (file)
@@ -144,9 +144,25 @@ my $serial_number_rx = '^\d+(?:\.\d+)*$';
 # Autoconf version
 # Set by trace_used_macros.
 my $ac_version;
+
+# If set, names a temporary file that must be erased on abnormal exit.
+my $erase_me;
 \f
 ################################################################
 
+# Erase temporary file ERASE_ME.
+sub unlink_tmp
+{
+  if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
+    {
+      fatal "could not remove `$erase_me': $!";
+    }
+  undef $erase_me;
+}
+
+$SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
+END { unlink_tmp }
+
 # Check macros in acinclude.m4.  If one is not used, warn.
 sub check_acinclude ()
 {
@@ -180,7 +196,7 @@ sub reset_maps ()
 sub install_file ($$)
 {
   my ($src, $dest) = @_;
-  my $diff_dest = $dest;
+  my $diff_dest;
 
   if ($force_output
       || !exists $file_contents{$dest}
@@ -189,21 +205,48 @@ sub install_file ($$)
       if (-e $dest)
        {
          msg 'note', "overwriting `$dest' with `$src'";
+         $diff_dest = $dest;
        }
       else
        {
          msg 'note', "installing `$dest' from `$src'";
-         $diff_dest = '/dev/null';
        }
 
       if (@diff_command)
        {
+         if (! defined $diff_dest)
+           {
+             # $dest does not exist.  We create an empty one just to
+             # run diff, and we erase it afterward.  Using the real
+             # the destination file (rather than a temporary file) is
+             # good when diff is run with options that display the
+             # file name.
+             #
+             # If creating $dest fails, fall back to /dev/null.  At
+             # least one diff implementation (Tru64's) cannot deal
+             # with /dev/null.  However working around this is not
+             # worth the trouble since nobody run aclocal on a
+             # read-only tree anyway.
+             $erase_me = $dest;
+             my $f = new IO::File "> $dest";
+             if (! defined $f)
+               {
+                 undef $erase_me;
+                 $diff_dest = '/dev/null';
+               }
+             else
+               {
+                 $diff_dest = $dest;
+                 $f->close;
+               }
+           }
          my @cmd = (@diff_command, $diff_dest, $src);
          $! = 0;
          verb "running: @cmd";
          my $res = system (@cmd);
          Automake::FileUtils::handle_exec_errors "@cmd", 1
            if $res;
+         unlink_tmp;
        }
       elsif (!$dry_run)
        {
index 42ee8e6ccfb587688b2c9f62a8f7bd4b650aa7db..0b6dfe28a160f0cdd73d50c413617fdaed5aaae0 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2005  Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -109,6 +109,9 @@ AC_DEFUN([AM_MACRO1], [echo macro1d >> foo])
 AC_DEFUN([AM_MACRO2], [echo macro2d >> foo])
 EOF
 rm -f foo
-$ACLOCAL --diff=diff >output
+$ACLOCAL --diff=diff >output 2>stderr
+cat stderr
 cat output
 grep '#serial 456' output
+test ! -f 4/m1.m4
+grep 'installing.*4/m1.m4' stderr
This page took 0.032026 seconds and 5 git commands to generate.