lib/scripts/fixseq.pl
changeset 4268 90779455c9a7
child 9789 7e5e6c47c0b5
equal deleted inserted replaced
4267:cdc193e38925 4268:90779455c9a7
       
     1 #
       
     2 # $Id$
       
     3 #
       
     4 # fixseq.pl - fix references to obsolete Pure/Sequence structure
       
     5 #
       
     6 
       
     7 sub fixseq {
       
     8     my ($file) = @_;
       
     9 
       
    10     open (FILE, $file) || die $!;
       
    11     undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
       
    12     close FILE || die $!;
       
    13 
       
    14     $_ = $text;
       
    15 
       
    16 
       
    17     s/Sequence\.tl/Seq.tl/sg;
       
    18     s/Sequence\.single/Seq.single/sg;
       
    19     s/Sequence\.seqof/Seq.make/sg;
       
    20     s/Sequence\.seq/Seq.seq/sg;
       
    21     s/Sequence\.s_of_list/Seq.of_list/sg;
       
    22     s/Sequence\.pull/Seq.pull/sg;
       
    23     s/Sequence\.prints/Seq.print/sg;
       
    24     s/Sequence\.null/Seq.empty/sg;
       
    25     s/Sequence\.maps/Seq.map/sg;
       
    26     s/Sequence\.mapp/Seq.mapp/sg;
       
    27     s/Sequence\.list_of_s/Seq.list_of/sg;
       
    28     s/Sequence\.its_right/Seq.it_right/sg;
       
    29     s/Sequence\.interleave/Seq.interleave/sg;
       
    30     s/Sequence\.hd/Seq.hd/sg;
       
    31     s/Sequence\.flats/Seq.flat/sg;
       
    32     s/Sequence\.filters/Seq.filter/sg;
       
    33     s/Sequence\.cons/Seq.cons/sg;
       
    34     s/Sequence\.chop/Seq.chop/sg;
       
    35     s/Sequence\.append/Seq.append/sg;
       
    36 
       
    37 
       
    38     $result = $_;
       
    39 
       
    40     if ($text ne $result) {
       
    41 	print STDERR "fixing $file\n";
       
    42         if (! -f "$file~~") {
       
    43 	    rename $file, "$file~~" || die $!;
       
    44         }
       
    45 	open (FILE, "> $file") || die $!;
       
    46 	print FILE $result;
       
    47 	close FILE || die $!;
       
    48     }
       
    49 }
       
    50 
       
    51 
       
    52 ## main
       
    53 
       
    54 foreach $file (@ARGV) {
       
    55   eval { &fixseq($file); };
       
    56   if ($@) { print STDERR "*** fixseq $file: ", $@, "\n"; }
       
    57 }