| 1 |
# |
| 2 |
# マクロコマンドのドキュメント類のチェックを行う |
| 3 |
# |
| 4 |
# [実行方法] |
| 5 |
# すべて(ttmparse.h より読み込み)のマクロを検証する |
| 6 |
# >perl macrotemplate.pl |
| 7 |
# |
| 8 |
# 指定したマクロを検証する |
| 9 |
# >perl macrotemplate.pl scpsend |
| 10 |
# |
| 11 |
# [改版履歴] |
| 12 |
# 1.0 (2008.02.16 Yutaka Hirata) |
| 13 |
# 1.1 (2008.02.23 Yutaka Hirata) |
| 14 |
# 1.2 (2009.03.03 Yutaka Hirata) |
| 15 |
# 1.3 (2009.03.04 NAGATA Shinya) |
| 16 |
# |
| 17 |
|
| 18 |
$macroidfile = '..\teraterm\ttpmacro\ttmparse.h'; |
| 19 |
$helpidfile = '..\teraterm\common\helpid.h'; |
| 20 |
$encmdfile = '..\doc\en\html\macro\command'; |
| 21 |
$jacmdfile = '..\doc\ja\html\macro\command'; |
| 22 |
$enhhcfile = '..\doc\en\teraterm.hhc'; |
| 23 |
$jahhcfile = '..\doc\ja\teraterm.hhc'; |
| 24 |
$enhhpfile = '..\doc\en\teraterm.hhp'; |
| 25 |
$jahhpfile = '..\doc\ja\teraterm.hhp'; |
| 26 |
$keyfile = 'release\keyfile.ini'; |
| 27 |
|
| 28 |
if ($#ARGV != -1) { |
| 29 |
print "==== " . $ARGV[0] . "マクロを検証中...\n"; |
| 30 |
do_main(lc($ARGV[0])); |
| 31 |
|
| 32 |
} else { |
| 33 |
@FULL_COMMAND = (); |
| 34 |
open(FP, "$macroidfile") || die "Can't open $file."; |
| 35 |
while (<FP>) { |
| 36 |
if (/^#define Rsv(\w+)\s+(\d+)/) { |
| 37 |
if ($1 eq 'Operator') { |
| 38 |
last; |
| 39 |
} |
| 40 |
push(@FULL_COMMAND, "$1 $2"); |
| 41 |
} |
| 42 |
} |
| 43 |
close(FP); |
| 44 |
|
| 45 |
foreach (@FULL_COMMAND) { |
| 46 |
if (/(\w+)\s+.*/) { |
| 47 |
$key = lc($1); |
| 48 |
|
| 49 |
print "==== $key マクロを検証中...\n"; |
| 50 |
do_main($key); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
exit(0); |
| 55 |
|
| 56 |
|
| 57 |
#; TODO |
| 58 |
#; en/teraterm.hhcにリンク挿入 |
| 59 |
#; en/teraterm.hhpにalias追加 |
| 60 |
#; ja/teraterm.hhcにリンク挿入 |
| 61 |
#; ja/teraterm.hhpにalias追加 |
| 62 |
|
| 63 |
sub do_main { |
| 64 |
my($macro) = @_; |
| 65 |
my($ret, $id, $s, $pat); |
| 66 |
my($idline, $helpline); |
| 67 |
# print "$macro\n"; |
| 68 |
|
| 69 |
$s = "Rsv$macro\\b"; |
| 70 |
$ret = read_keyword($macroidfile, $s); |
| 71 |
$idline = $ret; |
| 72 |
# print "$ret\n"; |
| 73 |
if ($ret =~ /$macro\s+(\d+)/i) { |
| 74 |
$id = $1; |
| 75 |
} else { |
| 76 |
print "IDファイル($macroidfile)からマクロ定義が見つかりません\n"; |
| 77 |
print "$idline\n"; |
| 78 |
return; |
| 79 |
} |
| 80 |
# print "$id\n"; |
| 81 |
|
| 82 |
# 置換 |
| 83 |
# ttmparse.h と helpid.h で名前が一致していないため |
| 84 |
if ($macro eq 'if' || |
| 85 |
$macro eq 'then' || |
| 86 |
$macro eq 'else' || |
| 87 |
$macro eq 'elseif' || |
| 88 |
$macro eq 'endif' |
| 89 |
) { |
| 90 |
$macro = 'Ifthenelseif'; |
| 91 |
} |
| 92 |
if ($macro eq 'for' || |
| 93 |
$macro eq 'next' |
| 94 |
) { |
| 95 |
$macro = 'fornext'; |
| 96 |
} |
| 97 |
if ($macro eq 'endwhile' |
| 98 |
) { |
| 99 |
$macro = 'while'; |
| 100 |
} |
| 101 |
if ($macro eq 'findfirst' || |
| 102 |
$macro eq 'findnext' || |
| 103 |
$macro eq 'findclose' |
| 104 |
) { |
| 105 |
$macro = 'Findoperations'; |
| 106 |
} |
| 107 |
if ($macro eq 'millipause' |
| 108 |
) { |
| 109 |
$macro = 'mpause'; |
| 110 |
} |
| 111 |
if ($macro eq 'rotatel' |
| 112 |
) { |
| 113 |
$macro = 'rotateleft'; |
| 114 |
} |
| 115 |
if ($macro eq 'rotater' |
| 116 |
) { |
| 117 |
$macro = 'rotateright'; |
| 118 |
} |
| 119 |
|
| 120 |
$s = "Command$macro\\b"; |
| 121 |
$ret = read_keyword($helpidfile, $s); |
| 122 |
$helpline = $ret; |
| 123 |
# print "$ret\n"; |
| 124 |
if ($ret =~ /$macro\s+(\d+)/i) { |
| 125 |
$n = 92000 + $id; |
| 126 |
if ($n != $1) { |
| 127 |
print "$helpidfile のIDが一致していません ($n != $1)\n"; |
| 128 |
print "$idline\n"; |
| 129 |
print "$ret\n"; |
| 130 |
return; |
| 131 |
} |
| 132 |
} else { |
| 133 |
print "HELPIDファイル($helpidfile)からマクロ定義が見つかりません\n"; |
| 134 |
print "$idline\n"; |
| 135 |
print "$ret\n"; |
| 136 |
return; |
| 137 |
} |
| 138 |
|
| 139 |
$pat = "\\b$macro\\b"; |
| 140 |
$ret = read_keyword($keyfile, $pat); |
| 141 |
if ($ret eq '') { |
| 142 |
print "$keyfile ファイルに $pat コマンドがありません\n"; |
| 143 |
} |
| 144 |
|
| 145 |
# 置換 |
| 146 |
# helpid.h とコマンドのヘルプファイルで名前が一致していないため |
| 147 |
if ($macro eq 'do' || |
| 148 |
$macro eq 'loop' |
| 149 |
) { |
| 150 |
$macro = 'doloop'; |
| 151 |
} |
| 152 |
if ($macro eq 'enduntil' |
| 153 |
) { |
| 154 |
$macro = 'until'; |
| 155 |
} |
| 156 |
if ($macro eq 'crc32file' |
| 157 |
) { |
| 158 |
$macro = 'crc32'; |
| 159 |
} |
| 160 |
|
| 161 |
$s = "$encmdfile\\$macro.html"; |
| 162 |
if (!(-e $s)) { |
| 163 |
print "マクロコマンドの英語版説明文($s)がありません\n"; |
| 164 |
} |
| 165 |
|
| 166 |
$s = "$jacmdfile\\$macro.html"; |
| 167 |
if (!(-e $s)) { |
| 168 |
print "マクロコマンドの日本語版説明文($s)がありません\n"; |
| 169 |
} |
| 170 |
|
| 171 |
$s = "$encmdfile\\index.html"; |
| 172 |
$pat = "$macro.html"; |
| 173 |
$ret = read_keyword($s, $pat); |
| 174 |
if ($ret eq '') { |
| 175 |
print "$s ファイルに $pat へのリンクがありません\n"; |
| 176 |
} |
| 177 |
|
| 178 |
$s = "$jacmdfile\\index.html"; |
| 179 |
$pat = "$macro.html"; |
| 180 |
$ret = read_keyword($s, $pat); |
| 181 |
if ($ret eq '') { |
| 182 |
print "$s ファイルに $pat へのリンクがありません\n"; |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
$pat = "$macro.html"; |
| 187 |
$ret = read_keyword($enhhcfile, $pat); |
| 188 |
if ($ret eq '') { |
| 189 |
print "$enhhcfile ファイルに $pat へのリンクがありません\n"; |
| 190 |
} |
| 191 |
|
| 192 |
$pat = "$macro.html"; |
| 193 |
$ret = read_keyword($jahhcfile, $pat); |
| 194 |
if ($ret eq '') { |
| 195 |
print "$jahhcfile ファイルに $pat へのリンクがありません\n"; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
$pat = "$macro.html"; |
| 200 |
$ret = read_keyword($enhhpfile, $pat); |
| 201 |
if ($ret eq '') { |
| 202 |
print "$enhhpfile ファイルに $pat へのALIASリンクがありません\n"; |
| 203 |
} |
| 204 |
|
| 205 |
$pat = "$macro.html"; |
| 206 |
$ret = read_keyword($jahhpfile, $pat); |
| 207 |
if ($ret eq '') { |
| 208 |
print "$jahhpfile ファイルに $pat へのALIASリンクがありません\n"; |
| 209 |
} |
| 210 |
|
| 211 |
} |
| 212 |
|
| 213 |
sub read_keyword { |
| 214 |
my($file, $keyword) = @_; |
| 215 |
my($line) = ''; |
| 216 |
my($found) = 0; |
| 217 |
|
| 218 |
open(FP, "$file") || die "Can't open $file."; |
| 219 |
while (<FP>) { |
| 220 |
chomp; |
| 221 |
$line = $_; |
| 222 |
if (/$keyword/i) { |
| 223 |
$found = 1; |
| 224 |
last; |
| 225 |
} |
| 226 |
} |
| 227 |
close(FP); |
| 228 |
|
| 229 |
if ($found == 0) { |
| 230 |
$line = ''; |
| 231 |
} |
| 232 |
return ($line); |
| 233 |
} |