5045
|
1 |
#
|
|
2 |
# $Id$
|
|
3 |
#
|
|
4 |
# fixgoal.pl - replace goal(w) commands by implicit versions Goal(w)
|
|
5 |
#
|
|
6 |
|
|
7 |
sub fixgoal {
|
|
8 |
my ($file) = @_;
|
|
9 |
|
|
10 |
open (FILE, $file) || die $!;
|
|
11 |
undef $/; $text = <FILE>; $/ = "\n"; # slurp whole file
|
|
12 |
close FILE || die $!;
|
|
13 |
|
|
14 |
($path, $thy, $ext) = ($file =~ m,^(.*/)?(\w+)(\.\w+)?$,);
|
|
15 |
|
|
16 |
$_ = $text;
|
|
17 |
|
5051
|
18 |
s/^[ \t]*goalw\b\s*\bthy\b/Goalw/mg;
|
|
19 |
s/^[ \t]*goalw\b\s*\b$thy\.thy\b/Goalw/mg;
|
|
20 |
s/^[ \t]*goal\b\s*\bthy\b/Goal/mg;
|
|
21 |
s/^[ \t]*goal\b\s*\b$thy\.thy\b/Goal/mg;
|
5045
|
22 |
|
|
23 |
|
|
24 |
$result = $_;
|
|
25 |
|
|
26 |
if ($text ne $result) {
|
|
27 |
print STDERR "fixing $file\n";
|
|
28 |
if (! -f "$file~~") {
|
|
29 |
rename $file, "$file~~" || die $!;
|
|
30 |
}
|
|
31 |
open (FILE, "> $file") || die $!;
|
|
32 |
print FILE $result;
|
|
33 |
close FILE || die $!;
|
|
34 |
}
|
|
35 |
}
|
|
36 |
|
|
37 |
|
|
38 |
## main
|
|
39 |
|
|
40 |
foreach $file (@ARGV) {
|
|
41 |
eval { &fixgoal($file); };
|
|
42 |
if ($@) { print STDERR "*** fixgoal $file: ", $@, "\n"; }
|
|
43 |
}
|