forked from FDOS/freecom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindstrg.pl
57 lines (50 loc) · 946 Bytes
/
findstrg.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
47
48
49
50
51
52
53
54
55
56
57
#!perl
# Searches for string codes in sources
$lng = shift;
die "Useage: $0 lng-file {source-files}\n"
unless $lng;
foreach $pattern (@ARGV) {
if(substr($pattern, 0, 1) eq '-') {
$pattern = substr($pattern ,1);
$negate = 1;
} else {
$negate = 0;
}
foreach $file (glob($pattern)) {
if(-f $file) {
$ofile = lc($file);
if($negate) {
delete $files{$ofile};
} else {
$files{$ofile} = $file;
}
}
}
}
foreach $ofile (sort keys %files) {
$file = $files{$ofile};
warn "Cannot open file $file: $!\n"
unless open(IN, $file);
while(<IN>) {
while(/\b(TEXT|PROMPT)_[A-Z_]+\b/) {
$string{$&} = 1;
$_ = $';
}
}
close IN;
}
die "Cannot open lng file: $!\n"
unless open(IN, $lng);
while(<IN>) {
next unless /^:/;
$name = $';
$name = $` if $name =~ /\#/;
$name =~ s/\s+//g;
$body = '';
while(<IN>) {
$body .= $_;
last if /^[\.\,]\s*$/;
}
print $name . "\n" unless $string{$name};
}
close IN;