Browse Subversion Repository
Contents of /trunk/installer/check_sjis_code.pl
Parent Directory
| Revision Log
Revision 3430 -
( show annotations)
( download)
( as text)
Sun May 31 13:59:54 2009 UTC
(3 years, 11 months ago)
by yutakapon
File MIME type: text/x-perl
File size: 1465 byte(s)
ActivePerl で動作するように改修した。
| 1 |
#! /usr/bin/perl
|
| 2 |
|
| 3 |
#
|
| 4 |
# 英語版ドキュメントに日本語が含まれていないかを調べる。
|
| 5 |
#
|
| 6 |
# Usage(ActivePerl):
|
| 7 |
# perl check_sjis_code.pl > result.txt
|
| 8 |
#
|
| 9 |
|
| 10 |
get_file_paths('../doc/en/html');
|
| 11 |
exit(0);
|
| 12 |
|
| 13 |
sub get_file_paths {
|
| 14 |
my ($top_dir)= @_;
|
| 15 |
my @paths=();
|
| 16 |
my @temp = ();
|
| 17 |
|
| 18 |
#-- カレントの一覧を取得 --#
|
| 19 |
opendir(DIR, $top_dir);
|
| 20 |
@temp = readdir(DIR);
|
| 21 |
closedir(DIR);
|
| 22 |
foreach my $path (sort @temp) {
|
| 23 |
next if( $path =~ /^\.{1,2}$/ ); # '.' と '..' はスキップ
|
| 24 |
next if( $path =~ /^\.svn$/ ); # '.svn' はスキップ
|
| 25 |
|
| 26 |
my $full_path = "$top_dir" . '/' . "$path";
|
| 27 |
next if (-B $full_path); # バイナリファイルはスキップ
|
| 28 |
|
| 29 |
# print "$full_path\r\n"; # 表示だけなら全てを表示してくれる-------
|
| 30 |
push(@paths, $full_path); # データとして取り込んでも前の取り込みが初期化される
|
| 31 |
if( -d "$top_dir/$path" ){ #-- ディレクトリの場合は自分自身を呼び出す
|
| 32 |
&get_file_paths("$full_path");
|
| 33 |
|
| 34 |
} else {
|
| 35 |
check_sjis_code($full_path);
|
| 36 |
|
| 37 |
}
|
| 38 |
}
|
| 39 |
return \@paths;
|
| 40 |
}
|
| 41 |
|
| 42 |
|
| 43 |
# cf. http://charset.7jp.net/sjis.html
|
| 44 |
# ShiftJIS 文字
|
| 45 |
|
| 46 |
sub check_sjis_code {
|
| 47 |
my($filename) = shift;
|
| 48 |
local(*FP);
|
| 49 |
my($line, $no);
|
| 50 |
|
| 51 |
open(FP, "<$filename") || return;
|
| 52 |
$no = 1;
|
| 53 |
while ($line = <FP>) {
|
| 54 |
# $line = chomp($line);
|
| 55 |
# print "$line\n";
|
| 56 |
if ($line =~ /([\xA1-\xDF]|[\x81-\x9F\xE0-\xEF][\x40-\x7E\x80-\xFC])/) {
|
| 57 |
print "$filename:$no: $1\n";
|
| 58 |
print "$line\n";
|
| 59 |
}
|
| 60 |
$no++;
|
| 61 |
}
|
| 62 |
close(FP);
|
| 63 |
}
|
| 64 |
|
|