lib/scripts/update_sub_sup
author wenzelm
Fri Jul 12 14:54:17 2013 +0200 (2013-07-12)
changeset 52618 2077168aa8f7
child 52921 0ea2b657eb42
permissions -rwxr-xr-x
added "isabelle update_sub_sup" tool;
     1 #!/usr/bin/env perl
     2 #
     3 # Author: Makarius
     4 #
     5 # update_sub_sup - update sub/sup control symbols
     6 
     7 use warnings;
     8 use strict;
     9 
    10 sub update_sub_sup {
    11     my ($file) = @_;
    12 
    13     open (FILE, $file) || die $!;
    14     undef $/; my $text = <FILE>; $/ = "\n";         # slurp whole file
    15     close FILE || die $!;
    16 
    17     $_ = $text;
    18 
    19     s/\Q\<^isub>\E/\\<^sub>/g;
    20     s/\Q\<^isup>\E/\\<^sup>/g;
    21 
    22     my $result = $_;
    23 
    24     if ($text ne $result) {
    25         print STDERR "changing $file\n";
    26         if (! -f "$file~~") {
    27             rename $file, "$file~~" || die $!;
    28         }
    29         open (FILE, "> $file") || die $!;
    30         print FILE $result;
    31         close FILE || die $!;
    32     }
    33 }
    34 
    35 
    36 ## main
    37 
    38 foreach my $file (@ARGV) {
    39   eval { &update_sub_sup($file); };
    40   if ($@) { print STDERR "*** update_sub_sup $file: ", $@, "\n"; }
    41 }