• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl -w
2
3# Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# 1.  Redistributions of source code must retain the above copyright
10#     notice, this list of conditions and the following disclaimer.
11# 2.  Redistributions in binary form must reproduce the above copyright
12#     notice, this list of conditions and the following disclaimer in the
13#     documentation and/or other materials provided with the distribution.
14# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15#     its contributors may be used to endorse or promote products derived
16#     from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29# Script to do file renaming.
30
31use strict;
32use FindBin;
33use lib $FindBin::Bin;
34use webkitdirs;
35use File::Find;
36
37setConfiguration();
38chdirWebKit();
39
40my %words;
41
42# find all files we want to process
43
44my @paths;
45find(\&wanted, "JavaScriptCore");
46find(\&wanted, "JavaScriptGlue");
47find(\&wanted, "WebCore");
48find(\&wanted, "WebKit");
49
50sub wanted
51{
52    my $file = $_;
53
54    if ($file eq "icu") {
55        $File::Find::prune = 1;
56        return;
57    }
58
59    if ($file =~ /^\../) {
60        $File::Find::prune = 1;
61        return;
62    }
63
64    return if $file =~ /^ChangeLog/;
65    return if -d $file;
66
67    push @paths, $File::Find::name;
68}
69
70my %renames = (
71);
72
73my %renamesContemplatedForTheFuture = (
74);
75
76# rename files
77
78my %newFile;
79for my $file (sort @paths) {
80    my $f = $file;
81    $f = "$1$renames{$2}" if $f =~ /^(.*\/)(\w+\.\w+)$/ && $renames{$2};
82    $newFile{$file} = $f if $f ne $file;
83}
84
85for my $file (sort @paths) {
86    if ($newFile{$file}) {
87        my $newFile = $newFile{$file};
88        print "Renaming $file to $newFile\n";
89        system "svn move $file $newFile";
90    }
91}
92
93# change all file contents
94
95for my $file (sort @paths) {
96    $file = $newFile{$file} if $newFile{$file};
97    my $contents;
98    {
99        local $/;
100        open FILE, $file or die;
101        $contents = <FILE>;
102        close FILE;
103    }
104    my $newContents = $contents;
105
106    for my $from (keys %renames) {
107        $newContents =~ s/\b\Q$from\E(?!\w)/$renames{$from}/g; # this " unconfuses Xcode syntax highlighting
108    }
109
110    if ($newContents ne $contents) {
111        open FILE, ">", $file or die;
112        print FILE $newContents;
113        close FILE;
114    }
115}
116