From: Norman Walsh Date: Fri, 9 Feb 2007 13:20:02 +0000 (+0000) Subject: Handle no CLASSPATH and improve parameter parsing X-Git-Tag: release/1.79.1~6^2~2276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45ab91a70572d16bba12cfda65300068fd471c26;p=docbook-dsssl Handle no CLASSPATH and improve parameter parsing --- diff --git a/cvstools/saxon b/cvstools/saxon index 80183a1fe..fcfc3a2f6 100755 --- a/cvstools/saxon +++ b/cvstools/saxon @@ -124,8 +124,8 @@ if (!defined($version)) { } my $optsname = "saxon"; -$optsname .= $saxonsa if defined($saxonsa); $optsname .= "-$version"; +$optsname .= "a" if defined($saxonsa); # Inelegantly, these are used as globals by several functions my %seenopts = (); @@ -145,7 +145,8 @@ die "Unexpected root element in configuration file.\n" if !$doc; # Figure out the class path separator before we go any further my $cpseparator = $doc->getAttribute('classpath-separator'); # Default to ';' if it appears in $CLASSPATH, otherwise ':' -$cpseparator = ($ENV{'CLASSPATH'} =~ /;/ ? ";" : ":") +my $CLASSPATH = $ENV{'CLASSPATH'} || ""; +$cpseparator = ($CLASSPATH =~ /\;/ ? ";" : ":") if !defined($cpseparator) or $cpseparator eq ''; foreach my $name (@opts, $optsname) { @@ -154,7 +155,7 @@ foreach my $name (@opts, $optsname) { $java = "java" if $java eq ''; -foreach my $path (reverse split(/$cpseparator/, $ENV{'CLASSPATH'})) { +foreach my $path (reverse split(/$cpseparator/, $CLASSPATH)) { unshift(@classpath, $path); } @@ -166,7 +167,16 @@ my $jopts = join(" ", @javaopts); my $jprops = join(" ", @systemprops); my $jcp = join($cpseparator, @classpath); my $sopts = join(" ", @saxonopts); -my $sparam = join(" ", @params); + +my $sparam = ""; +foreach my $param (@params) { + $sparam .= " " if $sparam ne ''; + if ($param =~ /^(.+?)=(.+)$/) { + $sparam .= "$1=\"$2\""; + } else { + $sparam .= "$param"; + } +} if ($cpseparator eq ';') { # This must be cygwin or some windows flavor, let's try to make it work @@ -179,7 +189,7 @@ if ($cpseparator eq ';') { } } -print "$java $jopts $classname $sopts $input $style $sparam\n" if $debug; +print "$java $jopts -cp $jcp $jprops $classname $sopts $input $style $sparam\n" if $debug; exec("$java $jopts -cp $jcp $jprops $classname $sopts $input $style $sparam"); # ============================================================