lib/scripts/fixgoal.pl
author wenzelm
Tue, 13 Feb 2001 16:31:18 +0100
changeset 11109 ce1cefc6c14c
parent 9789 7e5e6c47c0b5
child 14981 e73f8140af78
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5045
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     1
#
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     2
# $Id$
9789
wenzelm
parents: 5051
diff changeset
     3
# Author: Markus Wenzel, TU Muenchen
wenzelm
parents: 5051
diff changeset
     4
# License: GPL (GNU GENERAL PUBLIC LICENSE)
5045
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     5
#
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     6
# fixgoal.pl - replace goal(w) commands by implicit versions Goal(w)
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     7
#
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     8
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
     9
sub fixgoal {
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    10
    my ($file) = @_;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    11
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    12
    open (FILE, $file) || die $!;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    13
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    14
    close FILE || die $!;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    15
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    16
    ($path, $thy, $ext) = ($file =~ m,^(.*/)?(\w+)(\.\w+)?$,);
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    17
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    18
    $_ = $text;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    19
5051
3b45aee5c7ec tuned \s pattern;
wenzelm
parents: 5045
diff changeset
    20
    s/^[ \t]*goalw\b\s*\bthy\b/Goalw/mg;
3b45aee5c7ec tuned \s pattern;
wenzelm
parents: 5045
diff changeset
    21
    s/^[ \t]*goalw\b\s*\b$thy\.thy\b/Goalw/mg;
3b45aee5c7ec tuned \s pattern;
wenzelm
parents: 5045
diff changeset
    22
    s/^[ \t]*goal\b\s*\bthy\b/Goal/mg;
3b45aee5c7ec tuned \s pattern;
wenzelm
parents: 5045
diff changeset
    23
    s/^[ \t]*goal\b\s*\b$thy\.thy\b/Goal/mg;
5045
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    24
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    25
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    26
    $result = $_;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    27
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    28
    if ($text ne $result) {
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    29
	print STDERR "fixing $file\n";
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    30
        if (! -f "$file~~") {
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    31
	    rename $file, "$file~~" || die $!;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    32
        }
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    33
	open (FILE, "> $file") || die $!;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    34
	print FILE $result;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    35
	close FILE || die $!;
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    36
    }
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    37
}
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    38
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    39
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    40
## main
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    41
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    42
foreach $file (@ARGV) {
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    43
  eval { &fixgoal($file); };
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    44
  if ($@) { print STDERR "*** fixgoal $file: ", $@, "\n"; }
a19e5c91a1ab replace goal(w) commands by implicit versions Goal(w);
wenzelm
parents:
diff changeset
    45
}