trunk
Rev | Line | |
---|
[cdcfe90] | 1 | #! /usr/bin/perl -w |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use utf8; |
---|
| 6 | |
---|
[6f4fe5e] | 7 | use Encode; |
---|
[cdcfe90] | 8 | |
---|
| 9 | my $top = shift @ARGV || exit; |
---|
| 10 | if (! -d $top) { exit; } |
---|
| 11 | |
---|
[6f4fe5e] | 12 | my $utf8 = find_encoding("utf8"); |
---|
| 13 | |
---|
[cdcfe90] | 14 | checkdir($top); |
---|
| 15 | |
---|
| 16 | sub match { |
---|
| 17 | my $str = shift @_; |
---|
| 18 | |
---|
[6f4fe5e] | 19 | my $sjis = encode("cp932", $utf8->decode($str), Encode::FB_HTMLCREF); |
---|
[cdcfe90] | 20 | if ($sjis =~ /&#\d{4,};/) { |
---|
| 21 | return 1; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | return ''; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | sub checkdir { |
---|
| 28 | my $target = shift @_; |
---|
| 29 | |
---|
[dfae53c] | 30 | print STDERR "# checking '$target'\n"; |
---|
[cdcfe90] | 31 | opendir(my $dir, $target) || return $target; |
---|
[0e3de64] | 32 | my @entries = sort grep { !m/^(\.|\.\.)$/g } readdir($dir); |
---|
[cdcfe90] | 33 | closedir($dir); |
---|
| 34 | |
---|
| 35 | my @dirs; |
---|
| 36 | while (my $entry = shift @entries) { |
---|
| 37 | if (match($entry)) { |
---|
| 38 | print "'$target/$entry' contains non Shift_JIS character\n"; |
---|
| 39 | next; |
---|
| 40 | } |
---|
| 41 | if (-d "$target/$entry") { |
---|
| 42 | push @dirs, $entry; |
---|
| 43 | next; |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | while (my $entry = pop @dirs) { |
---|
| 48 | checkdir("$target/$entry"); |
---|
| 49 | } |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.