From: Alexandre Duret-Lutz Date: Fri, 4 Aug 2006 08:42:54 +0000 (+0000) Subject: * aclocal.in (install_file): Cannot use /dev/null while diffing X-Git-Tag: v1.10.2~193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76542b15689ffa5b24587f3ea4d2e3c0fef37586;p=platform%2Fupstream%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 5a73452..922599a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-08-04 Alexandre Duret-Lutz + + * 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 * automake.in (handle_LIBOBJS_or_ALLOCA): With subdir-objects, diff --git a/aclocal.in b/aclocal.in index acb05d2..5cc280f 100644 --- a/aclocal.in +++ b/aclocal.in @@ -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; ################################################################ +# 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) { diff --git a/tests/acloca18.test b/tests/acloca18.test index 42ee8e6..0b6dfe2 100755 --- a/tests/acloca18.test +++ b/tests/acloca18.test @@ -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