Only rename source files and directories

Francois Gouget fgouget at free.fr
Sat Feb 19 05:51:30 CST 2005


Changelog:

  * tools/winemaker

    Only 'fix' the names of source files and directories (this way 
documentation files are unharmed).
    Better handle Makefiles generated by Winemaker. In particular, don't 
rename them to makefile.win!


-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                           La terre est une b\xEAta...
-------------- next part --------------
Index: tools/winemaker
===================================================================
RCS file: /var/cvs/wine/tools/winemaker,v
retrieving revision 1.79
diff -u -p -r1.79 winemaker
--- tools/winemaker	11 Jan 2005 10:39:10 -0000	1.79
+++ tools/winemaker	19 Feb 2005 11:38:09 -0000
@@ -992,6 +993,7 @@ sub source_scan()
 # - they have the case desired by the user
 # - their extension is of the appropriate case
 # - they don't contain annoying characters like ' ', '$', '#', ...
+# But only perform these changes for source files and directories.
 sub fix_file_and_directory_names($);
 sub fix_file_and_directory_names($)
 {
@@ -1003,40 +1005,38 @@ sub fix_file_and_directory_names($)
 	next;
       }
       # Set $warn to 1 if the user should be warned of the renaming
-      my $warn=0;
-
-      # autoconf and make don't support these characters well
+      my $warn;
       my $new_name=$dentry;
-      $new_name =~ s/[ \$]/_/g;
 
-      # Only all lowercase extensions are supported (because of the
-      # transformations ':.c=.o') .
-      if (-f "$dirname/$new_name") {
-	if ($new_name =~ /\.C$/) {
-	  $new_name =~ s/\.C$/.c/;
-	}
-	if ($new_name =~ /\.cpp$/i) {
-	  $new_name =~ s/\.cpp$/.cpp/i;
-	}
-	if ($new_name =~ s/\.cxx$/.cpp/i) {
-	  $warn=1;
-	}
-	if ($new_name =~ /\.rc$/i) {
-	  $new_name =~ s/\.rc$/.rc/i;
-	}
+      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
-	if ($new_name =~ s/^makefile$/makefile.win/) {
-	  $warn=1;
-	}
+	$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) {


More information about the wine-patches mailing list