lib/scripts/fixdots.pl
author wenzelm
Thu, 09 Oct 1997 17:45:03 +0200
changeset 3824 9fdde15e3215
child 3826 0caedb36900d
permissions -rw-r--r--
ensure that dots in formulas are followed by non-idents;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3824
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     1
#
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     2
# $Id$
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     3
#
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     4
# fixdots.pl - ensure that dots in formulas are followed by non-idents
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     5
#
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     6
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     7
foreach $file (@ARGV) {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     8
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
     9
    if (open (FILE, $file)) {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    10
	undef $/;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    11
	$text = <FILE>;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    12
	close FILE;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    13
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    14
	$result = "";
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    15
	$rest = $text;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    16
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    17
	while (1) {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    18
	    $_ = $rest;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    19
	    ($pre, $str, $rest) = m/^([^"]*)"((?:[^"\\]|\\.)*)"(.*)$/s;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    20
	    if ($str) {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    21
		$_ = $str;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    22
		if (!m/^[a-zA-Z0-9_\/\.]*$/s && !m/\.ML$/s && !m/\.thy/) {     # Exclude filenames!
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    23
		    s/([a-zA-Z][a-zA-Z0-9_']*)\.([a-zA-Z])/$1\. $2/g;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    24
	        }
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    25
                $result = $result . $pre . '"' . $_ . '"';
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    26
            } else {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    27
 	        $result = $result . $_;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    28
    	        last;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    29
	    }
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    30
        }
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    31
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    32
        if ($text ne $result) {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    33
	    print STDERR "fixing $file\n";
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    34
	    open (FILE, "> $file") || die $!;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    35
	    print FILE $result;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    36
	    close FILE || die $!;
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    37
        }
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    38
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    39
    } else {
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    40
        print STDERR "Can't open file $file: $!\n";
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    41
    }
9fdde15e3215 ensure that dots in formulas are followed by non-idents;
wenzelm
parents:
diff changeset
    42
}