-
Notifications
You must be signed in to change notification settings - Fork 7
/
check_value_resource.pl
46 lines (44 loc) · 1.03 KB
/
check_value_resource.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!usr/bin/perl -w
use strict;
use warnings;
use utf8;
use Encode;
use File::Glob::Windows;
use Text::Diff;
sub getText{
my($fname) = @_;
open(my $fh,"<",$fname) or die "$fname $!\n";
local $/ = undef;
my $bytes = <$fh>;
close($fh) or die "$fname $!\n";
return Encode::decode("utf8",$bytes);
}
my @dirlist = map{ s|\\|/|g;$_} glob( "res/values*/");
my @flist = map{ s|\\|/|g;$_} glob( "res/values/*.xml");
my $count;
for my $file (@flist){
my $text = getText($file);
my @a;
while( $text =~ /<(\S+)\s+name="([^"]+)"/g ){
push @a,"$1 name=$2\n";
}
@a = sort @a;
$file =~ m|([^/]+)$|;
my $name = $1;
for my $dir (@dirlist){
my $file_b = "$dir/$name";
next if $file_b eq $file;
my $text = getText($file_b);
my @b;
while( $text =~ /<(\S+)\s+name="([^"]+)"/g ){
push @b,"$1 name=$2\n";
}
@b = sort @b;
++$count;
my $diff = diff \@a,\@b,{ CONTEXT=>0,STYLE=>"Unified"};
next if not $diff;
print "$file vs $file_b\n";
print "$diff";
}
}
warn "compare $count files\n";