equal
deleted
inserted
replaced
|
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 $thy = ""; |
|
15 ($path, $thy, $ext) = ($file =~ m,^(.*/)?(\w+)(\.\w+)?$,); |
|
16 |
|
17 $_ = $text; |
|
18 |
|
19 s/^\s*goalw\b\s*\bthy\b/Goalw/mg; |
|
20 s/^\s*goalw\b\s*\b$thy\.thy\b/Goalw/mg; |
|
21 s/^\s*goal\b\s*\bthy\b/Goal/mg; |
|
22 s/^\s*goal\b\s*\b$thy\.thy\b/Goal/mg; |
|
23 |
|
24 |
|
25 $result = $_; |
|
26 |
|
27 if ($text ne $result) { |
|
28 print STDERR "fixing $file\n"; |
|
29 if (! -f "$file~~") { |
|
30 rename $file, "$file~~" || die $!; |
|
31 } |
|
32 open (FILE, "> $file") || die $!; |
|
33 print FILE $result; |
|
34 close FILE || die $!; |
|
35 } |
|
36 } |
|
37 |
|
38 |
|
39 ## main |
|
40 |
|
41 foreach $file (@ARGV) { |
|
42 eval { &fixgoal($file); }; |
|
43 if ($@) { print STDERR "*** fixgoal $file: ", $@, "\n"; } |
|
44 } |