automake-patches
[Top][All Lists]
Advanced

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

Re: case sensitive file checks


From: Alexandre Duret-Lutz
Subject: Re: case sensitive file checks
Date: Wed, 08 Dec 2004 01:27:02 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Peter" == Peter O'Gorman <address@hidden> writes:

 Peter> Hi,
 Peter> Okay, my copyright assignment is complete.

Thanks.  Here is how I adapted your patch.  Let me now if
something looks wrong.

 Peter> By the way, did you know it takes 12 hours to run make check in
 Peter> automake on my machine!!

Good score!  If that's anything you bought recently, maybe you
should consider another store next time :) It takes about 45
minutes these days on my not-so-new 2GHz Athlon.  

Presently HEAD should be a bit faster than branch-1-9 as far as
the Perl part of Automake is concerned.  (But a significant part
of the runtime of the test suite is spent in m4 (run by aclocal
and autoconf), and in shell scripts, so I'm not sure if the
difference will be very sensible.)

Anyway, that's no reason for not adding test cases.

2004-12-08  Peter O'Gorman  <address@hidden>
            Alexandre Duret-Lutz  <address@hidden>

        * lib/Automake/FileUtils.pm (dir_has_case_matching_file): New function.
        * automake.in (handle_dist, require_file_internal): Use it, so
        that CHANGELOG is not confused with ChangeLog on case-insensitive
        case-preserving file systems.
        * tests/hfs.test: New file.
        * tests/Makefile.am (TESTS): Add hfs.test.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1569.2.6
diff -u -r1.1569.2.6 automake.in
--- automake.in 21 Oct 2004 21:37:52 -0000      1.1569.2.6
+++ automake.in 7 Dec 2004 23:56:32 -0000
@@ -3468,7 +3468,7 @@
     }
   foreach my $cfile (@common_files)
     {
-      if (-f ($relative_dir . "/" . $cfile)
+      if (dir_has_case_matching_file ($relative_dir, $cfile)
          # The file might be absent, but if it can be built it's ok.
          || rule $cfile)
        {
@@ -3477,7 +3477,7 @@
 
       # Don't use `elsif' here because a file might meaningfully
       # appear in both directories.
-      if ($check_aux && -f "$config_aux_dir/$cfile")
+      if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile))
        {
          &push_dist_common ("$config_aux_dir/$cfile")
        }
@@ -6842,7 +6842,7 @@
        {
          $dangling_sym = 1;
        }
-      elsif (-f $fullfile)
+      elsif (dir_has_case_matching_file ($dir, $file))
        {
          $found_it = 1;
          maybe_push_required_file ($dir, $file, $fullfile);
Index: lib/Automake/FileUtils.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/FileUtils.pm,v
retrieving revision 1.4
diff -u -r1.4 FileUtils.pm
--- lib/Automake/FileUtils.pm   12 Sep 2003 08:37:57 -0000      1.4
+++ lib/Automake/FileUtils.pm   7 Dec 2004 23:56:32 -0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2003  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004  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
@@ -44,7 +44,7 @@
 @EXPORT = qw (&contents
              &find_file &mtime
              &update_file &up_to_date_p
-             &xsystem &xqx);
+             &xsystem &xqx &dir_has_case_matching_file);
 
 
 =item C<find_file ($filename, @include)>
@@ -310,6 +310,48 @@
 }
 
 
+=item C<dir_has_case_matching_file ($DIRNAME, $FILENAME)>
+
+Return true iff $DIR contains a filename that matches $FILENAME case
+insensitively.
+
+We need to be cautious on case-insensitive case-preserving file
+systems (e.g. Mac OS X's HFS+).  On such systems C<-f 'Foo'> and C<-f
+'foO'> answer the same thing.  Hence if a package distributes its own
+F<CHANGELOG> file, but has no F<ChangeLog> file, automake would still
+try to distribute F<ChangeLog> (because it thinks it exists) in
+addition to F<CHANGELOG>, although it is impossible for these two
+files to be in the same directory (the two filenames designate the
+same file).
+
+=cut
+
+use vars '%_directory_cache';
+sub dir_has_case_matching_file ($$)
+{
+  # Note that print File::Spec->case_tolerant returns 0 even on MacOS
+  # 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";
+
+  # The file appears to exist, however it might be a mirage if the
+  # system is case insensitive.  Let's browse the directory and check
+  # whether the file is really in.  We maintain a cache of directories
+  # so Automake doesn't spend all its time reading the same directory
+  # again and again.
+  if (!exists $_directory_cache{$dirname})
+    {
+      error "failed to open directory `$dirname'"
+       unless opendir (DIR, $dirname);
+      $_directory_cache{$dirname} = { map { $_ => 1 } readdir (DIR) };
+      closedir (DIR);
+    }
+  return exists $_directory_cache{$dirname}{$filename};
+}
+
+
 1; # for require
 
 ### Setup "GNU" style for perl-mode and cperl-mode.
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.565.2.7
diff -u -r1.565.2.7 Makefile.am
--- tests/Makefile.am   5 Dec 2004 16:12:43 -0000       1.565.2.7
+++ tests/Makefile.am   7 Dec 2004 23:56:32 -0000
@@ -247,6 +247,7 @@
 gnits3.test \
 header.test \
 help.test \
+hfs.test \
 hosts.test \
 implicit.test \
 include.test \
Index: tests/hfs.test
===================================================================
RCS file: tests/hfs.test
diff -N tests/hfs.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/hfs.test      8 Dec 2004 00:04:22 -0000
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2004  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+
+# Automake should not think that ChangeLog == CHANGELOG on
+# case-preserving case-insensitive file systems (such as HFS+, on
+# Darwin).
+# Report from Peter O'Gorman.
+
+. ./defs
+set -e
+
+echo AC_OUTPUT >>configure.in
+
+: >CHANGELOG
+echo 'EXTRA_DIST = CHANGELOG' >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
-- 
Alexandre Duret-Lutz





reply via email to

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