# HG changeset patch # User wenzelm # Date 1456669268 -3600 # Node ID 5ec1d01089e355f87b6167028943d98abf7744a8 # Parent 26861a913d6b9e951282abe11e97064d7b539911 obsolete; diff -r 26861a913d6b -r 5ec1d01089e3 lib/Tools/update_sub_sup --- a/lib/Tools/update_sub_sup Sun Feb 28 15:19:30 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# Author: Makarius -# -# DESCRIPTION: update Isabelle symbols involving sub/superscripts - - -## diagnostics - -PRG="$(basename "$0")" - -function usage() -{ - echo - echo "Usage: isabelle $PRG [FILES|DIRS...]" - echo - echo " Recursively find .thy/.ML files and update Isabelle symbols involving" - echo " sub- and superscript." - echo - echo " Old versions of files are preserved by appending \"~~\"." - echo - exit 1 -} - - -## process command line - -[ "$#" -eq 0 -o "$1" = "-?" ] && usage - -SPECS="$@"; shift "$#" - - -## main - -find $SPECS \( -name \*.ML -o -name \*.thy \) -print0 | \ - xargs -0 "$ISABELLE_HOME/lib/scripts/update_sub_sup" diff -r 26861a913d6b -r 5ec1d01089e3 lib/scripts/update_sub_sup --- a/lib/scripts/update_sub_sup Sun Feb 28 15:19:30 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -#!/usr/bin/env perl -# -# Author: Makarius -# -# update_sub_sup - update Isabelle symbols involving sub/superscripts - -use warnings; -use strict; - -sub update_sub_sup { - my ($file) = @_; - - open (FILE, $file) || die $!; - undef $/; my $text = ; $/ = "\n"; # slurp whole file - close FILE || die $!; - - $_ = $text; - - s/\Q\<^isub>\E/\\<^sub>/g; - s/\Q\<^isup>\E/\\<^sup>/g; - s/\Q\\E/\\<^sup>1/g; - s/\Q\\E/\\<^sup>2/g; - s/\Q\\E/\\<^sup>3/g; - - my $result = $_; - - if ($text ne $result) { - print STDERR "changing $file\n"; - if (! -f "$file~~") { - rename $file, "$file~~" || die $!; - } - open (FILE, "> $file") || die $!; - print FILE $result; - close FILE || die $!; - } -} - - -## main - -foreach my $file (@ARGV) { - eval { &update_sub_sup($file); }; - if ($@) { print STDERR "*** update_sub_sup $file: ", $@, "\n"; } -}