lib/scripts/fixcpure.pl
author haftmann
Tue, 24 Jul 2007 15:20:49 +0200
changeset 23951 b188cac107ad
parent 15821 ac7ea72c463b
permissions -rw-r--r--
renamed lcm_lowest to lcm_least

#
# $Id$
# Author: Makarius
#
# fixcpure.pl - adapt theories and ML files to new CPure/Pure arrangement
#

sub fixcpure {
    my ($file) = @_;

    open (FILE, $file) || die $!;
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
    close FILE || die $!;

    $_ = $text;

    s/\bCPure\.thy\b/-THE-CPURE-THEORY-/sg;
    s/\bCPure\.([A-Za-z_\-])/Pure.$1/sg;
    s/-THE-CPURE-THEORY-/CPure.thy/sg;

    $result = $_;

    if ($text ne $result) {
        print STDERR "fixing $file\n";
        if (! -f "$file~~") {
            rename $file, "$file~~" || die $!;
        }
        open (FILE, "> $file") || die $!;
        print FILE $result;
        close FILE || die $!;
    }
}


## main

foreach $file (@ARGV) {
  eval { &fixcpure($file); };
  if ($@) { print STDERR "*** fixcpure $file: ", $@, "\n"; }
}