Module: wine Branch: master Commit: d4fddfb4bc1b2537639cb82c8802793ea251414f URL: http://source.winehq.org/git/wine.git/?a=commit;h=d4fddfb4bc1b2537639cb82c88...
Author: Francois Gouget fgouget@free.fr Date: Wed Feb 25 10:32:36 2009 +0100
winemaker: Fix invalid usage of {open,close}dir() in fix_file_and_directory_names(). .
Reuse our caching mechanism (get_directory_contents()), but clear the cache if we have modified a directory's content.
---
tools/winemaker | 75 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 43 insertions(+), 32 deletions(-)
diff --git a/tools/winemaker b/tools/winemaker index 8c78987..078ef44 100755 --- a/tools/winemaker +++ b/tools/winemaker @@ -447,6 +447,14 @@ sub get_directory_contents($) return $directory; }
+## +# Removes a directory from the cache. +# This is needed if one of its files or subdirectory has been renamed. +sub clear_directory_cache($) +{ + my ($dirname)=@_; + delete $directories{$dirname}; +}
##### @@ -604,7 +612,6 @@ sub source_scan_directory($$$$) } } } - closedir(DIRECTORY);
if ($has_headers) { push @{@$project_settings[$T_INCLUDE_PATH]},"-I."; @@ -997,10 +1004,11 @@ sub fix_file_and_directory_names($) { my $dirname=$_[0];
- if (opendir(DIRECTORY, "$dirname")) { - foreach my $dentry (readdir DIRECTORY) { + my $directory=get_directory_contents($dirname); + foreach my $dentry (@$directory) + { if ($dentry =~ /^./ or $dentry eq "CVS") { - next; + next; } # Set $warn to 1 if the user should be warned of the renaming my $warn; @@ -1008,49 +1016,52 @@ sub fix_file_and_directory_names($)
if (-f "$dirname/$dentry") { - # Don't rename Winemaker's makefiles - next if ($dentry eq "Makefile" and - `head -n 1 "$dirname/$dentry"` =~ /Generated by Winemaker/); - - # Leave non-source files alone - next if ($new_name !~ /(^makefile|.(c|cpp|h|rc))$/i); - - # Only all lowercase extensions are supported (because of - # rules like '.c.o:'. - $new_name =~ s/.C$/.c/; - $new_name =~ s/.cpp$/.cpp/i; - $warn=1 if ($new_name =~ s/.cxx$/.cpp/i); - $new_name =~ s/.rc$/.rc/i; - # And this last one is to avoid confusion then running make - $warn=1 if ($new_name =~ s/^makefile$/makefile.win/i); + # Don't rename Winemaker's makefiles + next if ($dentry eq "Makefile" and + `head -n 1 "$dirname/$dentry"` =~ /Generated by Winemaker/); + + # Leave non-source files alone + next if ($new_name !~ /(^makefile|.(c|cpp|h|rc))$/i); + + # Only all lowercase extensions are supported (because of + # rules like '.c.o:'. + $new_name =~ s/.C$/.c/; + $new_name =~ s/.cpp$/.cpp/i; + $warn=1 if ($new_name =~ s/.cxx$/.cpp/i); + $new_name =~ s/.rc$/.rc/i; + # And this last one is to avoid confusion then running make + $warn=1 if ($new_name =~ s/^makefile$/makefile.win/i); }
# Adjust the case to the user's preferences if (($opt_lower == $OPT_LOWER_ALL and $dentry =~ /[A-Z]/) or ($opt_lower == $OPT_LOWER_UPPERCASE and $dentry !~ /[a-z]/) ) { - $new_name=lc $new_name; + $new_name=lc $new_name; }
# autoconf and make don't support these characters well $new_name =~ s/[ $]/_/g;
# And finally, perform the renaming - if ($new_name ne $dentry) { - if ($warn) { - print STDERR "warning: in "$dirname", renaming "$dentry" to "$new_name"\n"; - } - if (!rename("$dirname/$dentry","$dirname/$new_name")) { - print STDERR "error: in "$dirname", unable to rename "$dentry" to "$new_name"\n"; - print STDERR " $!\n"; - $new_name=$dentry; - } + if ($new_name ne $dentry) + { + if ($warn) { + print STDERR "warning: in "$dirname", renaming "$dentry" to "$new_name"\n"; + } + if (!rename("$dirname/$dentry","$dirname/$new_name")) { + print STDERR "error: in "$dirname", unable to rename "$dentry" to "$new_name"\n"; + print STDERR " $!\n"; + $new_name=$dentry; + } + else + { + clear_directory_cache($dirname); + } } if (-d "$dirname/$new_name") { - fix_file_and_directory_names("$dirname/$new_name"); + fix_file_and_directory_names("$dirname/$new_name"); } - } - closedir(DIRECTORY); } }