2 # *******************************************************************************
\r
3 # * Copyright (C) 2001-2004, International Business Machines Corporation and *
\r
4 # * others. All Rights Reserved. *
\r
5 # *******************************************************************************
\r
10 if "%OS%" == "Windows_NT" goto WinNT
\r
11 perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
\r
15 if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
\r
16 if %errorlevel% == 9009 echo You do not have Perl in your PATH.
\r
22 # Usage: perl varsub.bat [-n|-nr] <infile> <outfile>
\r
24 # Substitutes variables into rules and deletes variable definition
\r
25 # statements. Variables that expand to UnicodeSets are NOT
\r
28 # -n Afterwards, run native2ascii -encoding UTF8
\r
29 # -nr Afterwards, run native2ascii -encoding UTF8 -reverse
\r
36 $N2Aoption = ($IN eq '-nr') ? " -reverse " : "";
\r
41 if (!($IN && $OUT)) {
\r
42 die "Usage: $0 [-n|-nr] <infile> <outfile>";
\r
45 open(IN) or die "Can't open $IN: $!";
\r
46 open(OUT, ">$OUT") or die "Can't open $OUT: $!";
\r
49 if (/^\s*\$([a-zA-Z0-9_]+)\s*=\s*([^;\#]+)\s*;\s*(\#.*)?$/) {
\r
50 # This looks like a variable definition
\r
51 my ($var, $def) = ($1, $2);
\r
52 # Don't substitute UnicodeSet vars
\r
53 if ($def !~ /^\[/) {
\r
54 if (exists $VAR{$var}) {
\r
55 print STDERR "Error: Duplicate definition of $var\n";
\r
63 # Do variable substitutions, and output line
\r
64 foreach my $var (keys %VAR) {
\r
65 my $def = $VAR{$var};
\r
75 `native2ascii -encoding UTF8 $N2Aoption $OUT $OUT.native2ascii`;
\r
77 rename "$OUT.native2ascii", $OUT;
\r