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