2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is libxul build automation.
17 # The Initial Developer of the Original Code is
18 # Benjamin Smedberg <benjamin@smedbergs.us>
19 # Portions created by the Initial Developer are Copyright (C) 2004
20 # the Initial Developer. All Rights Reserved.
23 # Soeren Munk Skroeder (sskroeder) @ 2005-08-24 -
24 # added support for inc files (defines)
25 # added to-do description with "add/remove these keys from your locale"
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
45 my ($file, $dir) = @_;
47 -d
$dir && system("rm -rf $dir");
48 system("unzip -q -d $dir $file") && die("Could not unZIP $file");
55 open DTD
, "<$file" || die ("Couldn't open file $file");
61 $contents =~ s/<!--.*?-->//gs; # strip SGML comments
63 return $contents =~ /<!ENTITY\s+([\w\.]+)\s+(?:\"[^\"]*\"|\'[^\']*\')\s*>/g;
70 my @entities1 = readDTD
("$gSourceDir1/$path");
71 my %entities2 = map { $_ => 1 } readDTD
("$gSourceDir2/$path");
75 foreach my $entity (@entities1) {
76 if (exists $entities2{$entity}) {
77 delete $entities2{$entity};
79 push @extra1, $entity;
83 if (@extra1 or keys %entities2) {
85 print "Entities in $path don't match:\n";
87 print " In $gSource1: (add these keys to your localization)\n";
88 map { print " $_\n"; } @extra1;
91 if (keys %entities2) {
92 print " In $gSource2: (remove these keys from your localization)\n";
93 map {print " $_\n"; } keys %entities2;
103 open PROPS
, "<$file" || die ("Couldn't open file $file");
106 my $contents = <PROPS
>;
109 $contents =~ s/\\$$//gm;
111 return $contents =~ /^\s*([^#!\s\r\n][^=:\r\n]*?)\s*[=:]/gm;
114 sub compareProperties
118 my @entities1 = readProperties
("$gSourceDir1/$path");
119 my %entities2 = map { $_ => 1 } readProperties
("$gSourceDir2/$path");
123 foreach my $entity (@entities1) {
124 if (exists $entities2{$entity}) {
125 delete $entities2{$entity};
127 # hack to ignore non-fatal region.properties differences
128 if ($path !~ /chrome\/browser
-region\
/region\.properties$/ or
129 ($entity !~ /browser\.search\.order\.[1-9]/ and
130 $entity !~ /browser\.contentHandlers\.types\.[0-5]/ and
131 $entity !~ /gecko\.handlerService\.schemes\./ and
132 $entity !~ /gecko\.handlerService\.defaultHandlersVersion/)) {
133 push @extra1, $entity;
137 # hack to ignore non-fatal region.properties differences
138 if ($path =~ /chrome\/browser
-region\
/region\.properties$/) {
139 foreach $entity (keys(%entities2)) {
140 if ($entity =~ /browser\.search\.order\.[1-9]/ ||
141 $entity =~ /browser\.contentHandlers\.types\.[0-5]/ ||
142 $entity =~ /gecko\.handlerService\.schemes\./ ||
143 $entity =~ /gecko\.handlerService\.defaultHandlersVersion/) {
144 delete $entities2{$entity};
149 if (@extra1 or keys %entities2) {
151 print "Properties in $path don't match:\n";
153 print " In $gSource1: (add these to your localization)\n";
154 map { print " $_\n"; } @extra1;
157 if (keys %entities2) {
158 print " In $gSource2: (remove these from your localization)\n";
159 map {print " $_\n"; } keys %entities2;
169 open DEFS
, "<$file" || die ("Couldn't open file $file");
172 my $contents = <DEFS
>;
175 return $contents =~ /#define\s+(\w+)/gm;
182 my @entities1 = readDefines
("$gSourceDir1/$path");
183 my %entities2 = map { $_ => 1 } readDefines
("$gSourceDir2/$path");
187 foreach my $entity (@entities1) {
188 if (exists $entities2{$entity}) {
189 delete $entities2{$entity};
191 push @extra1, $entity;
195 if (@extra1 or keys %entities2) {
197 print "Defines in $path don't match:\n";
199 print " In $gSource1: (add these to your localization)\n";
200 map { print " $_\n"; } @extra1;
203 if (keys %entities2) {
204 print " In $gSource2: (remove these from your localization)\n";
205 map {print " $_\n"; } keys %entities2;
215 my (@entries1, %entries2);
217 opendir(DIR1
, "$gSourceDir1/$path") ||
218 die ("Couldn't list $gSourceDir1/$path");
219 @entries1 = grep(!(/^(\.|CVS)/ || /~$/), readdir(DIR1
));
222 opendir(DIR2
, "$gSourceDir2/$path") ||
223 die ("Couldn't list $gSourceDir2/$path");
224 %entries2 = map { $_ => 1 } grep(!(/^(\.|CVS)/ || /~$/), readdir(DIR2
));
227 foreach my $file (@entries1) {
228 if (exists($entries2{$file})) {
229 delete $entries2{$file};
231 if (-d
"$gSourceDir1/$path/$file") {
232 compareDir
("$path/$file");
234 if ($file =~ /\.dtd$/) {
235 compareDTD
("$path/$file");
236 } elsif ($file =~ /\.inc$/) {
237 compareDefines
("$path/$file");
238 } elsif ($file =~ /\.properties$/) {
239 compareProperties
("$path/$file");
241 print "no comparison for $path/$file\n";
245 push @gSource1Extra, "$path/$file";
249 foreach my $file (keys %entries2) {
250 push @gSource2Extra, "$path/$file";
254 local ($gSource1, $gSource2) = @ARGV;
255 ($gSource1 && $gSource2) || die("Specify two directories or ZIP files");
257 my ($gSource1IsZIP, $gSource2IsZIP);
258 local ($gSourceDir1, $gSourceDir2);
259 local (@gSource1Extra, @gSource2Extra);
263 $gSourceDir1 = $gSource1;
266 $gSourceDir1 = "temp1";
267 unJAR
($gSource1, $gSourceDir1);
272 $gSourceDir2 = $gSource2;
275 $gSourceDir2 = "temp2";
276 unJAR
($gSource2, $gSourceDir2);
281 if (@gSource1Extra) {
282 print "Files in $gSource1 not in $gSource2:\n";
283 map { print " $_\n"; } @gSource1Extra;
287 if (@gSource2Extra) {
288 print "Files in $gSource2 not in $gSource1:\n";
289 map { print " $_\n"; } @gSource2Extra;
293 $gSource1IsZIP && system("rm -rf $gSourceDir1");
294 $gSource2IsZIP && system("rm -rf $gSourceDir2");