lib/scripts/fixgreek.pl
author wenzelm
Thu, 15 Sep 2005 17:18:57 +0200
changeset 17419 16df5a5eef68
parent 14981 e73f8140af78
permissions -rw-r--r--
poly -doDisplay;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14171
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     1
#
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     2
# $Id$
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     3
# Author: Sebastian Skalberg, TU Muenchen
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     4
#
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     5
# fixgreek.pl - fix problems with greek and other foreign letters now
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     6
#               being classified as letters instead of symbols.
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     7
#
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     8
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
     9
sub fixgreek {
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    10
    my ($file) = @_;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    11
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    12
    open (FILE, $file) || die $!;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    13
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    14
    close FILE || die $!;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    15
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    16
    $_ = $text;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    17
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    18
    s/(\\<(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z)>)([a-zA-Z0-9])/$1 $3/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    19
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    20
    s/([a-zA-Z][a-zA-Z0-9]*)(\\<(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z)>)/$1 $2/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    21
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    22
    s/(\\<(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz|AA|BB|CC|DD|EE|FF|GG|HH|II|JJ|KK|LL|MM|NN|OO|PP|QQ|RR|SS|TT|UU|VV|WW|XX|YY|ZZ)>)([a-zA-Z0-9])/$1 $3/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    23
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    24
    s/([a-zA-Z][a-zA-Z0-9]*)(\\<(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz|AA|BB|CC|DD|EE|FF|GG|HH|II|JJ|KK|LL|MM|NN|OO|PP|QQ|RR|SS|TT|UU|VV|WW|XX|YY|ZZ)>)/$1 $2/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    25
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    26
    s/(\\<(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|mu|nu|xi|pi|rho|sigma|tau|upsilon|phi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)>)([a-zA-Z0-9])/$1 $3/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    27
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    28
    s/([a-zA-Z][a-zA-Z0-9]*)(\\<(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|mu|nu|xi|pi|rho|sigma|tau|upsilon|phi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)>)/$1 $2/sg;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    29
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    30
    $result = $_;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    31
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    32
    if ($text ne $result) {
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    33
	print STDERR "fixing $file\n";
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    34
        if (! -f "$file~~") {
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    35
	    rename $file, "$file~~" || die $!;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    36
        }
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    37
	open (FILE, "> $file") || die $!;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    38
	print FILE $result;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    39
	close FILE || die $!;
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    40
    }
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    41
}
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    42
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    43
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    44
## main
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    45
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    46
foreach $file (@ARGV) {
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    47
  eval { &fixgreek($file); };
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    48
  if ($@) { print STDERR "*** fixgreek $file: ", $@, "\n"; }
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
diff changeset
    49
}