From 4ef522eeb12c63f4174e4f13eb9be924eab7dd6c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 24 Jan 2005 17:03:54 +0000 Subject: [PATCH] * lib/Automake/FileUtils.pm: Rename filename as file_name to be consistent with the terminology of the GNU coding standards. From Paul Eggert. (update_file): Accept a $force argument, so that --force always updates the time stamps. --- ChangeLog | 8 +++++ lib/Automake/FileUtils.pm | 67 ++++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdeb90fa3..8b4d50725 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-01-24 Akim Demaille + + * lib/Automake/FileUtils.pm: Rename filename as file_name to be + consistent with the terminology of the GNU coding standards. + From Paul Eggert. + (update_file): Accept a $force argument, so that --force always + updates the time stamps. + 2005-01-23 Alexandre Duret-Lutz * doc/automake.texi (How the Linker is Chosen): Explain how the diff --git a/lib/Automake/FileUtils.pm b/lib/Automake/FileUtils.pm index 2c9cba375..f527e6b93 100644 --- a/lib/Automake/FileUtils.pm +++ b/lib/Automake/FileUtils.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005 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 @@ -47,9 +47,9 @@ use vars qw (@ISA @EXPORT); &xsystem &xqx &dir_has_case_matching_file &reset_dir_cache); -=item C +=item C -Return the first path for a C<$filename> in the Cs. +Return the first path for a C<$file_name> in the Cs. We match exactly the behavior of GNU M4: first look in the current directory (which includes the case of absolute file names), and, if @@ -60,36 +60,36 @@ if absent, otherwise exit with error. =cut -# $FILENAME -# find_file ($FILENAME, @INCLUDE) +# $FILE_NAME +# find_file ($FILE_NAME, @INCLUDE) # ------------------------------- sub find_file ($@) { use File::Spec; - my ($filename, @include) = @_; + my ($file_name, @include) = @_; my $optional = 0; $optional = 1 - if $filename =~ s/\?$//; + if $file_name =~ s/\?$//; - return File::Spec->canonpath ($filename) - if -e $filename; + return File::Spec->canonpath ($file_name) + if -e $file_name; - if (File::Spec->file_name_is_absolute ($filename)) + if (File::Spec->file_name_is_absolute ($file_name)) { - fatal "$filename: no such file or directory" + fatal "$file_name: no such file or directory" unless $optional; return undef; } foreach my $path (@include) { - return File::Spec->canonpath (File::Spec->catfile ($path, $filename)) - if -e File::Spec->catfile ($path, $filename) + return File::Spec->canonpath (File::Spec->catfile ($path, $file_name)) + if -e File::Spec->catfile ($path, $file_name) } - fatal "$filename: no such file or directory" + fatal "$file_name: no such file or directory" unless $optional; return undef; @@ -119,19 +119,22 @@ sub mtime ($) } -=item C +=item C Rename C<$from> as C<$to>, preserving C<$to> timestamp if it has not -changed. Recognize C<$to> = C<-> standing for C. C<$from> is -always removed/renamed. +changed, unless C<$force> is true (defaults to false). Recognize +C<$to> = C<-> standing for C. C<$from> is always +removed/renamed. =cut -# &update_file ($FROM, $TO) -# ------------------------- -sub update_file ($$) +# &update_file ($FROM, $TO; $FORCE) +# --------------------------------- +sub update_file ($$;$) { - my ($from, $to) = @_; + my ($from, $to, $force) = @_; + $force = 0 + unless defined $force; my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~'; use File::Compare; use File::Copy; @@ -149,7 +152,7 @@ sub update_file ($$) return; } - if (-f "$to" && compare ("$from", "$to") == 0) + if (!$force && -f "$to" && compare ("$from", "$to") == 0) { # File didn't change, so don't update its mod time. msg 'note', "`$to' is unchanged"; @@ -290,14 +293,14 @@ sub xsystem ($) } -=item C +=item C -Return the contents of c<$filename>. +Return the contents of C<$file_name>. =cut -# contents ($FILENAME) -# -------------------- +# contents ($FILE_NAME) +# --------------------- sub contents ($) { my ($file) = @_; @@ -310,9 +313,9 @@ sub contents ($) } -=item C +=item C -Return true iff $DIR contains a filename that matches $FILENAME case +Return true iff $DIR contains a file name that matches $FILE_NAME case insensitively. We need to be cautious on case-insensitive case-preserving file @@ -321,7 +324,7 @@ systems (e.g. Mac OS X's HFS+). On such systems C<-f 'Foo'> and C<-f F file, but has no F file, automake would still try to distribute F (because it thinks it exists) in addition to F, although it is impossible for these two -files to be in the same directory (the two filenames designate the +files to be in the same directory (the two file names designate the same file). =cut @@ -333,8 +336,8 @@ sub dir_has_case_matching_file ($$) # X (with Perl v5.8.1-RC3 at least), so do not try to shortcut this # function using that. - my ($dirname, $filename) = @_; - return 0 unless -f "$dirname/$filename"; + my ($dirname, $file_name) = @_; + return 0 unless -f "$dirname/$file_name"; # The file appears to exist, however it might be a mirage if the # system is case insensitive. Let's browse the directory and check @@ -348,7 +351,7 @@ sub dir_has_case_matching_file ($$) $_directory_cache{$dirname} = { map { $_ => 1 } readdir (DIR) }; closedir (DIR); } - return exists $_directory_cache{$dirname}{$filename}; + return exists $_directory_cache{$dirname}{$file_name}; } =item C -- 2.47.2