summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2005-05-30 00:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2005-05-30 00:00:00 +0200
commit12ca3d1c438f47608d47907a0f3ba453d9e401bb (patch)
treef4d34d4aa95c042c2c16ee65fa442bce8dac2ee7 /scripts
parent7791a6c6b224e5ec3c1a40489e231c887a8864fa (diff)
downloadcontext-12ca3d1c438f47608d47907a0f3ba453d9e401bb.tar.gz
stable 2005.05.30
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/texexec.pl318
-rw-r--r--scripts/context/ruby/base/kpse.rb124
-rw-r--r--scripts/context/ruby/newpstopdf.rb3
-rw-r--r--scripts/context/ruby/newtexexec.rb6
-rw-r--r--scripts/context/ruby/texmfstart.rb68
5 files changed, 258 insertions, 261 deletions
diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl
index 0e6e5d098..3f11a83cc 100644
--- a/scripts/context/perl/texexec.pl
+++ b/scripts/context/perl/texexec.pl
@@ -420,7 +420,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) {
*STDERR = *LOGFILE;
}
-my $Program = " TeXExec 5.3.2 - ConTeXt / PRAGMA ADE 1997-2005";
+my $Program = " TeXExec 5.4.1 - ConTeXt / PRAGMA ADE 1997-2005";
print "\n$Program\n\n";
@@ -757,6 +757,13 @@ my $UseEnginePath = IniValue( 'UseEnginePath', '');
if ($TheEnginePath) { $UseEnginePath = 1 }
+# ok, let's force the engine; let's also forget about
+# fmtutil, since it does not support $engine subpaths
+# we will replace texexec anyway
+
+$UseEnginePath = 1 ;
+$Alone = 1 ;
+
my $FmtLanguage = IniValue( 'FmtLanguage', '' );
my $FmtBodyFont = IniValue( 'FmtBodyFont', '' );
my $FmtResponse = IniValue( 'FmtResponse', '' );
@@ -800,48 +807,31 @@ if ( $MpFormatFlag eq "" ) {
$MpFormatFlag = "-mem=" ;
}
-#~ if ($UseEnginePath && (! $MakeFormats)) {
- #~ if ($MpEngineSupport) {
- #~ $MpFormatFlag .= $MpExecutable . '/' ;
- #~ } ;
- #~ $TeXFormatFlag .= $TeXExecutable . '/' ;
-#~ }
-
-#~ if ( $TeXFormatFlag eq "" ) { $TeXFormatFlag = "&" }
-#~ if ( $MpFormatFlag eq "" ) { $MpFormatFlag = "&" }
-
-#~ unless ( $dosish && !$escapeshell ) {
- #~ if ( $TeXFormatFlag eq "&" ) { $TeXFormatFlag = "\\&" }
- #~ if ( $MpFormatFlag eq "&" ) { $MpFormatFlag = "\\&" }
-#~ }
-
if ($TeXProgram) { $TeXExecutable = $TeXProgram }
my $fmtutil = '';
-# for the moment forget about fmtutil, since it does not support $engine subpaths
-
-$Alone = 1 ;
-
-if ( $MakeFormats || $Verbose ) {
- if ($Alone || $UseEnginePath) {
- if ($Verbose) { print " generating format : not using fmtutil\n" }
- } elsif ( $TeXShell =~ /tetex|fptex/i ) {
- foreach (@paths) {
- my $p = checked_path($_) . 'fmtutil';
- if ( -e $p ) { $fmtutil = $p; last }
- elsif ( -e $p . '.exe' ) { $fmtutil = $p . '.exe'; last }
- }
- $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ;
- if ($Verbose) {
- if ( $fmtutil eq '' ) {
- print " locating fmtutil : not found in path\n";
- } else {
- print " locating fmtutil : $fmtutil\n";
- }
- }
- }
-}
+# obsolete
+#
+# if ( $MakeFormats || $Verbose ) {
+# if ($Alone || $UseEnginePath) {
+# if ($Verbose) { print " generating format : not using fmtutil\n" }
+# } elsif ( $TeXShell =~ /tetex|fptex/i ) {
+# foreach (@paths) {
+# my $p = checked_path($_) . 'fmtutil';
+# if ( -e $p ) { $fmtutil = $p; last }
+# elsif ( -e $p . '.exe' ) { $fmtutil = $p . '.exe'; last }
+# }
+# $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ;
+# if ($Verbose) {
+# if ( $fmtutil eq '' ) {
+# print " locating fmtutil : not found in path\n";
+# } else {
+# print " locating fmtutil : $fmtutil\n";
+# }
+# }
+# }
+# }
if ($Verbose) { print "\n" }
@@ -1074,10 +1064,24 @@ sub MPJobName {
return $MPJobName;
}
+sub System {
+ my $cmd = shift ;
+ unless ( $dosish && ! $escapeshell ) {
+ $cmd =~ s/([^\\])\&/$1\\\&/io ;
+ }
+ if ($Verbose) {
+ print "\n$cmd\n\n" ;
+ }
+ system($cmd)
+}
+
sub RunPerlScript {
my ( $ScriptName, $Options ) = @_;
my $cmd = '';
$own_quote = ($own_path =~ m/^[^\"].* / ? "\"" : "") ;
+ if ($Verbose) {
+ $Options .= ' --verbose' ;
+ }
if ($dosish) {
if ( -e "own_path$ScriptName$own_type" ) {
$cmd =
@@ -1092,8 +1096,7 @@ sub RunPerlScript {
$cmd = "$ScriptName $Options";
}
unless ( $cmd eq "" ) {
- print $cmd if ($Verbose) ;
- system($cmd) ;
+ System($cmd) ;
}
}
@@ -1424,63 +1427,6 @@ if ( $ConTeXtInterfaces{$ConTeXtInterface} ) {
my $Problems = my $Ok = 0;
-#~ sub RunTeX {
- #~ my ( $JobName, $JobSuffix ) = @_;
- #~ my $StartTime = time;
- #~ my $cmd;
- #~ my $TeXProgNameFlag = '';
- #~ if ( !$dosish ) # we assume tetex on linux
- #~ {
- #~ $TeXProgramPath = '';
- #~ $TeXFormatPath = '';
- #~ if ( !$TeXProgNameFlag
- #~ && ( $Format =~ /^cont/ )
- #~ && ( $TeXPassString !~ /progname/io ) )
- #~ {
- #~ $TeXProgNameFlag = "-progname=context";
- #~ }
- #~ }
- #~ $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ;
- #~ $cmd = join( ' ',
- #~ "$own_quote$TeXProgramPath$TeXExecutable$own_quote",
- #~ $TeXProgNameFlag, $TeXPassString, $PassOn, "" );
- #~ if ($EnterBatchMode) { $cmd .= "$TeXBatchFlag " }
- #~ if ($EnterNonStopMode) { $cmd .= "$TeXNonStopFlag " }
- #~ if ( $TeXTranslation ne '' ) { $cmd .= "-translate-file=$TeXTranslation " }
- #~ $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix";
- #~ if ($Verbose) { print "\n$cmd\n\n" }
- #~ if ($EnterBatchMode) {
- #~ $Problems = system("$cmd");
- #~ } else {
- #~ $Problems = system("$cmd");
- #~ }
- #~ # generate formats if needed and retry
- #~ #
- #~ # well, this used to work ok, until a engines started to use the same suffix
- #~ # and no robust check was possible any more
- #~ #
- #~ # if ($Problems) {
- #~ # my $efmt = `$kpsewhich cont-en.efmt` ;
- #~ # chomp $efmt ;
- #~ # if ($efmt eq "") {
- #~ # print "\n";
- #~ # print " emergency action : generate all formats\n";
- #~ # system("texexec --make --alone --all") ;
- #~ # print "\n";
- #~ # print " emergency action : retry processing file\n";
- #~ # if ($EnterBatchMode) {
- #~ # $Problems = system("$cmd");
- #~ # } else {
- #~ # $Problems = system("$cmd");
- #~ # }
- #~ # }
- #~ # }
- #~ my $StopTime = time - $StartTime;
- #~ print "\n return code : $Problems";
- #~ print "\n run time : $StopTime seconds\n";
- #~ return $Problems;
-#~ }
-
sub PrepRunTeX {
my ( $JobName, $JobSuffix, $PipeString ) = @_;
my $cmd;
@@ -1504,11 +1450,6 @@ sub PrepRunTeX {
if ($EnterNonStopMode) { $cmd .= "$TeXNonStopFlag " }
if ( $TeXTranslation ne '' ) { $cmd .= "-translate-file=$TeXTranslation " }
$cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix $PipeString";
- if ($Verbose) { print "\n$cmd\n\n" }
-unless ( $dosish && ! $escapeshell ) {
- #~ $cmd =~ s/[^\\]\&/\\\&/io ;
- $cmd =~ s/([^\\])\&/$1\\\&/io ;
-}
return $cmd;
}
@@ -1516,34 +1457,11 @@ sub RunTeX {
my ( $JobName, $JobSuffix ) = @_;
my $StartTime = time;
my $cmd = PrepRunTeX($JobName, $JobSuffix, '');
- print $cmd if ($Verbose) ;
if ($EnterBatchMode) {
- $Problems = system("$cmd");
+ $Problems = System("$cmd");
} else {
- $Problems = system("$cmd");
+ $Problems = System("$cmd");
}
- # generate formats if needed and retry
- #
- # well, this used to work ok, until a engines started to use the same suffix
- # and no robust check was possible any more
- #
- # if ($Problems) {
- # my $efmt = `$kpsewhich cont-en.efmt` ;
- # chomp $efmt ;
- # if ($efmt eq "") {
- # print "\n";
- # print " emergency action : generate all formats\n";
- # system("texexec --make --alone --all") ;
- # print "\n";
- # print " emergency action : retry processing file\n";
- # if ($EnterBatchMode) {
- # $Problems = system("$cmd");
- # } else {
- # $Problems = system("$cmd");
- # }
- # }
- # }
-
my $StopTime = time - $StartTime;
print "\n return code : $Problems";
print "\n run time : $StopTime seconds\n";
@@ -1756,11 +1674,11 @@ if ($JobSuffix =~ /\_fo$/i) {
}
}
if (($dosish) && ($PdfClose)) {
- my $ok = system("pdfclose --file $JobName.pdf") if -e "$JobName.pdf" ;
+ my $ok = System("pdfclose --file $JobName.pdf") if -e "$JobName.pdf" ;
if (($Result ne '') && (-e "$Result.pdf")) {
- $ok = system("pdfclose --file $Result.pdf") ;
+ $ok = System("pdfclose --file $Result.pdf") ;
}
- system("pdfclose --all") unless $ok ;
+ System("pdfclose --all") unless $ok ;
}
if ( -e "$JobName.$JobSuffix" ) {
$DummyFile = ( ($ForceXML) || ( $JobSuffix =~ /(xml|fo|fox)/io ) );
@@ -1923,11 +1841,11 @@ if ($JobSuffix =~ /\_fo$/i) {
unlink "$JobName.tup"; # previous tuo file
unlink "$JobName.top"; # runtime option file
if ($ProducePdfX) {
- system("dvipdfmx -f dvipdfmx.map -d 4 $JobName") ;
+ System("dvipdfmx -f dvipdfmx.map -d 4 $JobName") ;
} elsif ($ProducePdfM) {
- system("dvipdfm $JobName") ;
+ System("dvipdfm $JobName") ;
} elsif ($ProducePdfXTX) {
- system("xdv2pdf $JobName.xdv") ;
+ System("xdv2pdf $JobName.xdv") ;
}
PopResult($JobName);
}
@@ -1938,9 +1856,9 @@ if ($JobSuffix =~ /\_fo$/i) {
}
if ((!$Problems) && ($PdfOpen)) {
if ($Result ne '') {
- system("pdfopen --file $Result.pdf") if -f "$Result.pdf"
+ System("pdfopen --file $Result.pdf") if -f "$Result.pdf"
} else {
- system("pdfopen --file $JobName.pdf") if -f "$JobName.pdf"
+ System("pdfopen --file $JobName.pdf") if -f "$JobName.pdf"
}
}
}
@@ -2283,14 +2201,14 @@ sub RunCombine {
RunConTeXtFile( $CombineFile, "tex" );
}
-sub LocatedFormatPath {
+sub LocatedFormatPath { # watch out $engine is lowercase in kpse
my $FormatPath = shift;
my $EnginePath = shift;
my $EngineDone = shift;
if ( ( $FormatPath eq '' ) && ( $kpsewhich ne '' ) ) {
unless ($EngineDone) {
my $str = $ENV{"TEXFORMATS"} ;
- $str =~ s/\$ENGINE//io ;
+ $str =~ s/\$engine//io ;
$ENV{"TEXFORMATS"} = $str ;
}
# expanded paths
@@ -2308,15 +2226,17 @@ sub LocatedFormatPath {
if ($FormatPath eq '') {
if (($UseEnginePath)&&($EngineDone)) {
if ($dosish) {
- $FormatPath = `$kpsewhich --engine=$EnginePath --expand-var=\$TEXFORMATS` ;
+ $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\$TEXFORMATS` ;
} else {
- $FormatPath = `$kpsewhich --engine=$EnginePath --expand-var=\\\$TEXFORMATS` ;
+ $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\\\$TEXFORMATS` ;
}
- } else {
+ }
+ # either no enginepath or failed run
+ if ($FormatPath eq '') {
if ($dosish) {
- $FormatPath = `$kpsewhich --expand-var=\$TEXFORMATS` ;
+ $FormatPath = `$kpsewhich --expand-path=\$TEXFORMATS` ;
} else {
- $FormatPath = `$kpsewhich --expand-var=\\\$TEXFORMATS` ;
+ $FormatPath = `$kpsewhich --expand-path=\\\$TEXFORMATS` ;
}
}
}
@@ -2324,30 +2244,41 @@ sub LocatedFormatPath {
if ( ( $FormatPath ne '' ) && $Verbose ) {
print "located formatpath (2) : $FormatPath\n";
}
- #
- if ( ( $FormatPath ne '' ) && ($FormatPath =~ /unsetengine/) ) {
- $FormatPath =~ s/unsetengine/$EnginePath/;
- if ( ( $FormatPath ne '' ) && $Verbose ) {
- print "located formatpath (!) : $FormatPath (unbugged)\n";
+ $FormatPath =~ s/\\/\//g ;
+ if ($FormatPath ne '') {
+ my @fpaths ;
+ if ($dosish) {
+ @fpaths = split(';', $FormatPath) ;
+ } else {
+ @fpaths = split(':', $FormatPath) ;
+ }
+ # take first writable unless current
+ foreach my $fp (@fpaths) {
+ # remove funny patterns
+ $fp =~ s/\/+$// ;
+ $fp =~ s/^!!// ;
+ $fp =~ s/unsetengine/$EnginePath/ ;
+ if (($fp ne '') && ($fp ne '.')) {
+ # correct if needed
+ # append engine unless engine is already there
+ $fp =~ "$fp/$EnginePath" if ($fp =~ /[\\\/]$EnginePath[\\\/]*$/) ;
+ # path may not yet be present
+ # check if usable format path
+ my $fpp = $fp ;
+ $fpp =~ s/\/*$EnginePath\/*// ;
+ if ((-d $fpp) && (-w $fpp)) {
+ $FormatPath = $fpp ;
+ last ;
+ }
+ }
}
}
- # take first one
- if ($dosish) {
- $FormatPath =~ s/\;.*//o;
- } else {
- $FormatPath =~ s/\:.*//o;
- }
- # remove clever things
- $FormatPath =~ s/[\!\{\}\,]//go;
- $FormatPath =~ s/\\/\//go;
- $FormatPath =~ s/\/\//\//go;
- $FormatPath =~ s/[\/\\]$//;
+ $FormatPath = '.' if (($FormatPath eq '') || (! -w $FormatPath)) ;
if ( ( $FormatPath ne '' ) && $Verbose ) {
print "located formatpath (3) : $FormatPath\n";
}
$FormatPath .= '/';
}
-
if ($UseEnginePath && $EngineDone && ($FormatPath ne '') && ($FormatPath !~ /$EnginePath\/$/)) {
$FormatPath .= $EnginePath ;
unless (-d $FormatPath) {
@@ -2366,10 +2297,9 @@ sub RunOneFormat {
if ( ( $fmtutil ne "" ) && ( $FormatName !~ /metafun|mptopdf/io ) ) {
# could not happen, not supported any more
my $cmd = "$fmtutil --byfmt $FormatName";
- if ($Verbose) { print "\n$cmd\n\n" }
MakeUserFile; # this works only when the path is kept
MakeResponseFile;
- $Problems = system("$cmd");
+ $Problems = System("$cmd");
RemoveResponseFile;
RestoreUserFile;
} else {
@@ -2389,8 +2319,7 @@ sub RunOneFormat {
my $cmd =
"$own_quote$TeXProgramPath$TeXExecutable$own_quote $TeXVirginFlag "
. "$TeXPassString $PassOn ${TeXPrefix}$FormatName";
- if ($Verbose) { print "\n$cmd\n\n" }
- $Problems = system($cmd) ;
+ $Problems = System($cmd) ;
RemoveResponseFile;
RestoreUserFile;
@@ -2401,6 +2330,7 @@ sub RunOneFormat {
} else {
print " used formatpath : $TheTeXFormatPath\n";
}
+ print "\n";
chdir $CurrentPath;
}
}
@@ -2422,8 +2352,7 @@ sub RunFormats {
print "\n";
print " TeX hash binary : $TeXProgramPath$TeXHashExecutable\n";
print " comment : hashing may take a while ...\n";
- if ($Verbose) { print "\n$cmd\n\n" }
- system($cmd);
+ System($cmd);
}
}
foreach my $Interface (@ConTeXtFormats) {
@@ -2451,21 +2380,11 @@ sub RunMpFormat {
$own_quote = ($MpExecutable =~ m/^[^\"].* / ? "\"" : "") ;
my $cmd =
"$own_quote$MpExecutable$own_quote $MpVirginFlag $MpPassString $MpFormat";
-
-unless ( $dosish && !$escapeshell ) {
- $cmd =~ s/[^\\]\&/\\\&/io ;
-}
-
- if ($Verbose) { print "\n$cmd\n\n" }
- system($cmd ) ;
-
+ System($cmd ) ;
if ( ( $TheMpFormatPath ne '' ) && ( $CurrentPath ne '' ) ) {
print "\n";
- #~ if ($UseEnginePath) {
- #~ print " used engineformatpath : $TheMpFormatPath\n";
- #~ } else {
- print " used formatpath : $TheMpFormatPath\n";
- #~ }
+ print " used formatpath : $TheMpFormatPath\n";
+ print "\n";
chdir $CurrentPath;
}
}
@@ -2480,26 +2399,40 @@ sub checktexformatpath {
my $texformats ;
if (defined($ENV{'TEXFORMATS'})) {
$texformats = $ENV{'TEXFORMATS'} ;
- } else{
+ } else {
$texformats = '' ;
}
if ($texformats eq '') {
- if ($dosish) {
- $texformats = `kpsewhich --expand-var=\$TEXFORMATS`.chomp ;
+ if ($UseEnginePath) {
+ if ($dosish) {
+ $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\$TEXFORMATS`.chomp ;
+ } else {
+ $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\\\$TEXFORMATS`.chomp ;
+ }
} else {
- $texformats = `kpsewhich --expand-var=\\\$TEXFORMATS`.chomp ;
+ if ($dosish) {
+ $texformats = `kpsewhich --expand-var=\$TEXFORMATS`.chomp ;
+ } else {
+ $texformats = `kpsewhich --expand-var=\\\$TEXFORMATS`.chomp ;
+ }
}
}
- if ($texformats !~ /web2c[\/\\].*\$ENGINE/) {
- $texformats =~ s/web2c/web2c\/{\$ENGINE,}/ ;
+ if (($texformats !~ /web2c\/.*$TeXExecutable/) && ($texformats !~ /web2c[\/\\].*\$engine/i)) {
+ $texformats =~ s/(web2c\/\{)(\,\})/$1\$engine$2/ ; # needed for empty engine flags
+ if ($texformats !~ /web2c[\/\\].*\$ENGINE/) {
+ $texformats =~ s/web2c/web2c\/{\$engine,}/ ; # needed for me
+ }
$ENV{'TEXFORMATS'} = $texformats ;
print " fixing texformat path : $ENV{'TEXFORMATS'}\n";
+ } else {
+ print " using texformat path : $ENV{'TEXFORMATS'}\n" if ($Verbose) ;
}
if (! defined($ENV{'ENGINE'})) {
if ($MpEngineSupport) {
$ENV{'ENGINE'} .= $MpExecutable ;
} ;
$ENV{'ENGINE'} = $TeXExecutable ;
+ print "fixing engine variable : $ENV{'ENGINE'}\n";
}
}
@@ -2774,7 +2707,7 @@ sub doRunMP { ###########
print " metapost to tex : $MpName\n";
$own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ;
$Problems =
- system("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex");
+ System("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex");
if ( -e $MpTex && !$Problems ) {
open( TMP, ">>$MpTex" );
print TMP "\\end\{document\}\n"; # to be sure
@@ -2788,7 +2721,7 @@ sub doRunMP { ###########
if ( -e $MpDvi && !$Problems ) {
print " dvi to metapost : $MpName\n";
$own_quote = ($DviToMpExecutable =~ m/^[^\"].* / ? "\"" : "") ;
- $Problems = system("$own_quote$DviToMpExecutable$own_quote $MpDvi $MpName.mpx");
+ $Problems = System("$own_quote$DviToMpExecutable$own_quote $MpDvi $MpName.mpx");
}
unlink $MpBck;
rename $MpTex, $MpBck;
@@ -2806,8 +2739,7 @@ sub doRunMP { ###########
}
# prevent nameclash, experimental
my $MpMpName = "$MpName";
- print "$cmd $MpMpName" if ($Verbose) ;
- $Problems = system("$cmd $MpMpName");
+ $Problems = System("$cmd $MpMpName");
open( MPL, "$MpName.log" );
while (<MPL>) # can be one big line unix under win
{
@@ -2842,7 +2774,7 @@ sub RunMPX {
print " generating mpx file : $MpName\n";
$own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ;
$Problems =
- system("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex");
+ System("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex");
if ( -e $MpTex && !$Problems ) {
open( TMP, ">>$MpTex" );
print TMP "\\end\n"; # to be sure
@@ -2855,7 +2787,7 @@ sub RunMPX {
if ( -e $MpDvi && !$Problems ) {
$own_quote = ($DviToMpExecutable =~ m/^[^\"].* / ? "\"" : "") ;
$Problems =
- system("$own_quote$DviToMpExecutable$own_quote $MpDvi $MpName.mpx");
+ System("$own_quote$DviToMpExecutable$own_quote $MpDvi $MpName.mpx");
}
unlink $MpTex;
unlink $MpDvi;
@@ -2938,7 +2870,6 @@ sub show_version_info {
$EnterBatchMode = 1;
$Format = 'cont-en';
my $cmd = PrepRunTeX("texvers","tex",'') ;
- #~ my $ok = system("$cmd");
($texengine,$type) = AnalyzeVersion(`$cmd`) ;
print " tex : $texengine\n" ;
print " context : ver: $contextversion\n" ;
@@ -2948,7 +2879,6 @@ sub show_version_info {
if (defined $test && $test) {
$Format = 'cont-' . $a;
$cmd = PrepRunTeX("texvers","tex",'');
- #~ my $ok = system("$cmd");
($texengine,$type) = AnalyzeVersion(`$cmd`) ;
print " cont-$a : $type\n" ;
}
@@ -2962,7 +2892,6 @@ if ($HelpAsked) {
show_help_info
} elsif ($Version) {
show_version_info
- #~ system("texmfstart ctxtools --check $OriginalArgs") ;
} elsif ($TypesetListing) {
check_texmf_root;
check_texmf_tree;
@@ -2988,7 +2917,6 @@ if ($HelpAsked) {
else {
RunFormats ;
}
- #~ system("texmfstart ctxtools $OriginalArgs") ;
} elsif (@ARGV) {
check_texmf_root;
check_texmf_tree;
diff --git a/scripts/context/ruby/base/kpse.rb b/scripts/context/ruby/base/kpse.rb
index 6dbd6e6cf..7073ad017 100644
--- a/scripts/context/ruby/base/kpse.rb
+++ b/scripts/context/ruby/base/kpse.rb
@@ -10,6 +10,10 @@
# rename this one to environment
+require 'rbconfig'
+
+# beware $engine is lowercase in kpse
+
module Kpse
@@located = Hash.new
@@ -119,6 +123,7 @@ module Kpse
end
def Kpse.formatpaths
+ # maybe we should check for writeability
unless @@paths.key?('formatpaths') then
begin
setpath('formatpaths',run("--show-path=fmt").gsub(/\\/,'/').split(File::PATH_SEPARATOR))
@@ -135,61 +140,72 @@ module Kpse
def Kpse.formatpath(engine='pdfetex',enginepath=true)
+ # because engine support in distributions is not always
+ # as we expect, we need to check for it;
+
+ # todo: miktex
+
unless @@paths.key?(engine) then
- # overcome a bug/error in web2c/distributions/kpse
- if ENV['TEXFORMATS'] then
- ENV['TEXFORMATS'] = ENV['TEXFORMATS'].sub(/\$ENGINE/io,'')
+ # savedengine = ENV['engine']
+ if ENV['TEXFORMATS'] && ! ENV['TEXFORMATS'].empty? then
+ # make sure that we have a lowercase entry
+ ENV['TEXFORMATS'] = ENV['TEXFORMATS'].sub(/\$engine/io,"\$engine")
+ # well, we will append anyway, so we could also strip it
+ # ENV['TEXFORMATS'] = ENV['TEXFORMATS'].sub(/\$engine/io,"")
end
# use modern method
if enginepath then
formatpath = run("--engine=#{engine} --show-path=fmt")
else
+ # ENV['engine'] = engine if engine
formatpath = run("--show-path=fmt")
end
# use ancient method
if formatpath.empty? then
if enginepath then
if @@mswindows then
- formatpath = run("--engine=#{engine} --expand-var=\$TEXFORMATS")
+ formatpath = run("--engine=#{engine} --expand-path=\$TEXFORMATS")
else
- formatpath = run("--engine=#{engine} --expand-var=\\\$TEXFORMATS")
+ formatpath = run("--engine=#{engine} --expand-path=\\\$TEXFORMATS")
end
- else
- if enginepath then
- formatpath = run("--expand-var=\$TEXFORMATS")
+ end
+ # either no enginepath or failed run
+ if formatpath.empty? then
+ if @@mswindows then
+ formatpath = run("--expand-path=\$TEXFORMATS")
else
- formatpath = run("--expand-var=\\\$TEXFORMATS")
+ formatpath = run("--expand-path=\\\$TEXFORMATS")
end
end
end
- # overcome a bug/error in web2c/distributions/kpse
- formatpath.sub!(/unsetengine/, engine)
- # take first one
+ # locate writable path
if ! formatpath.empty? then
- formatpath = formatpath.split(File::PATH_SEPARATOR).first
- # remove clever things
- formatpath.gsub!(/[\!\{\}\,]/, '')
- unless formatpath.empty? then
- if enginepath then
- newformatpath = File.join(formatpath,engine).gsub(/[\/\\]+/, '/')
- if FileTest.directory?(newformatpath) then
- formatpath = newformatpath
- else
- begin
- File.makedirs(newformatpath)
- rescue
- else
- formatpath = newformatpath if FileTest.directory?(newformatpath)
- end
+ formatpath.split(File::PATH_SEPARATOR).each do |fp|
+ fp.gsub!(/\\/,'/')
+ # remove funny patterns
+ fp.sub!(/^!!/,'')
+ fp.sub!(/\/+$/,'')
+ fp.sub!(/unsetengine/,if enginepath then engine else '' end)
+ if ! fp.empty? && (fp != '.') then
+ # strip (possible engine) and test for writeability
+ fpp = fp.sub(/#{engine}\/*$/,'')
+ if FileTest.directory?(fpp) && FileTest.writable?(fpp) then
+ # use this path
+ formatpath = fp.dup
+ break
end
- else
- formatpath = formatpath.gsub(/[\/\\]+/, '/').gsub(/\/$/, '')
end
end
end
+ # fall back to current path
+ formatpath = '.' if formatpath.empty? || ! FileTest.writable?(formatpath)
+ # append engine but prevent duplicates
+ formatpath = File.join(formatpath.sub(/\/*#{engine}\/*$/,''), engine) if enginepath
+ begin File.makedirs(formatpath) ; rescue ; end ;
setpath(engine,formatpath)
+ # ENV['engine'] = savedengine
end
- return @@paths[engine]
+ return @@paths[engine].first
end
def Kpse.update
@@ -221,23 +237,49 @@ module Kpse
end
# engine support is either broken of not implemented in some
- # distributions, so we need to take care of it ourselves
+ # distributions, so we need to take care of it ourselves (without
+ # delays due to kpse calls); there can be many paths in the string
+ #
+ # in a year or so, i will drop this check
def Kpse.fixtexmfvars(engine=nil)
ENV['ENGINE'] = engine if engine
texformats = if ENV['TEXFORMATS'] then ENV['TEXFORMATS'].dup else '' end
- if @@mswindows then
- texformats = `kpsewhich --expand-var=\$TEXFORMATS`.chomp if texformats.empty?
- else
- texformats = `kpsewhich --expand-var=\\\$TEXFORMATS`.chomp if texformats.empty?
+ if texformats.empty? then
+ if engine then
+ if @@mswindows then
+ texformats = `kpsewhich --engine=#{engine} --expand-var=\$TEXFORMATS`.chomp
+ else
+ texformats = `kpsewhich --engine=#{engine} --expand-var=\\\$TEXFORMATS`.chomp
+ end
+ else
+ if @@mswindows then
+ texformats = `kpsewhich --expand-var=\$TEXFORMATS`.chomp
+ else
+ texformats = `kpsewhich --expand-var=\\\$TEXFORMATS`.chomp
+ end
+ end
end
- if texformats !~ /web2c[\/\\].*\$ENGINE/ then
- ENV['TEXFORMATS'] = texformats.gsub(/web2c/, "web2c/{\$ENGINE,}")
- return true
+ if engine then
+ texformats.sub!(/unsetengine/,engine)
else
+ texformats.sub!(/unsetengine/,"\$engine")
+ end
+ if engine && (texformats =~ /web2c[\/\\].*#{engine}/o) then
+ # ok, engine is seen
+ return false
+ elsif texformats =~ /web2c[\/\\].*\$engine/io then
+ # shouldn't happen
return false
+ else
+ ENV['TEXFORMATS'] = texformats.gsub(/(web2c\/\{)(,\})/o) do
+ "#{$1}\$engine#{$2}"
+ end
+ if texformats !~ /web2c[\/\\].*\$engine/io then
+ ENV['TEXFORMATS'] = texformats.gsub(/web2c\/*/, "web2c/{\$engine,}")
+ end
+ return true
end
-
end
def Kpse.runscript(name,filename=[],options=[])
@@ -263,7 +305,9 @@ module Kpse
end
def Kpse.setpath(key,value)
- @@paths[key] = [value].flatten.uniq
+ @@paths[key] = [value].flatten.uniq.collect do |p|
+ p.sub(/^!!/,'').sub(/\/*$/,'')
+ end
ENV["_CTX_K_P_#{key}_"] = @@paths[key].join(';') if @@crossover
end
diff --git a/scripts/context/ruby/newpstopdf.rb b/scripts/context/ruby/newpstopdf.rb
index aa3a14fef..898f987cb 100644
--- a/scripts/context/ruby/newpstopdf.rb
+++ b/scripts/context/ruby/newpstopdf.rb
@@ -19,6 +19,9 @@ end
# todo: paden/prefix in magick and inkscape
# todo: clean up method handling (pass strings, no numbers)
+# --method=crop|bounded|raw|...
+# --resolution=low|normal|medium|high|printer|print|screen|ebook|default
+# + downward compatible flag handling
require 'base/switch'
require 'base/tool'
diff --git a/scripts/context/ruby/newtexexec.rb b/scripts/context/ruby/newtexexec.rb
index 38c9675ca..758a42d89 100644
--- a/scripts/context/ruby/newtexexec.rb
+++ b/scripts/context/ruby/newtexexec.rb
@@ -495,7 +495,11 @@ class Commands
job.setvariable('backend','standard')
end
- job.setvariable('mpsengine',@commandline.option('engine'))
+ if (str = @commandline.option('engine')) && ! str.standard? && ! str.empty? then
+ job.setvariable('mpsengine',@commandline.option('engine'))
+ else
+ job.setvariable('mpsengine','standard')
+ end
end
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 120c73e80..82b87a7e9 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -23,14 +23,18 @@
# --locate => provides location
# --exec => exec instead of system
# --iftouched=a,b => only if timestamp a<>b
+#
+# file: path: bin:
# we don't depend on other libs
+$ownpath = File.expand_path(File.dirname($0)) unless defined? $ownpath
+
require "rbconfig"
$mswindows = Config::CONFIG['host_os'] =~ /mswin/
$separator = File::PATH_SEPARATOR
-$version = "1.6.0"
+$version = "1.6.2"
if $mswindows then
@@ -221,7 +225,7 @@ def launch(filename)
end
def expanded(arg) # no "other text files", too restricted
- arg.gsub(/(env)\:([a-zA-Z\-\_\.0-9]+)/o) do
+ arg.gsub(/(env|environment)\:([a-zA-Z\-\_\.0-9]+)/o) do
method, original, resolved = $1, $2, ''
if resolved = ENV[original] then
report("environment variable #{original} expands to #{resolved}") unless $report
@@ -230,7 +234,7 @@ def expanded(arg) # no "other text files", too restricted
report("environment variable #{original} cannot be resolved") unless $report
original
end
- end . gsub(/(kpse|loc)\:([a-zA-Z\-\_\.0-9]+)/o) do # was: \S
+ end . gsub(/(kpse|loc|file|path)\:([a-zA-Z\-\_\.0-9]+)/o) do # was: \S
method, original, resolved = $1, $2, ''
if $program && ! $program.empty? then
pstrings = ["-progname=#{$program}"]
@@ -265,10 +269,12 @@ def expanded(arg) # no "other text files", too restricted
end
end
if resolved.empty? then
+ original = File.dirname(original) if method =~ /path/
report("#{original} is not resolved") unless $report
ENV["_CTX_K_V_#{original}_"] = original if $crossover
original
else
+ resolved = File.dirname(resolved) if method =~ /path/
report("#{original} is resolved to #{resolved}") unless $report
ENV["_CTX_K_V_#{original}_"] = resolved if $crossover
resolved
@@ -314,7 +320,7 @@ def runoneof(application,fullname,browserpermitted)
return true
else
report("starting #{$filename}") unless $report
- ouput("\n") if $report && $verbose
+ output("\n") if $report && $verbose
applications = $applications[application]
if applications.class == Array then
if $report then
@@ -379,7 +385,7 @@ def registered?(filename)
if $crossover then
return ENV["_CTX_K_S_#{filename}_"] != nil
else
- return ENV["texmfstart.#{filename}"] != nil
+ return ENV["TEXMFSTART.#{filename}"] != nil
end
end
@@ -387,7 +393,7 @@ def registered(filename)
if $crossover then
return ENV["_CTX_K_S_#{filename}_"]
else
- return ENV["texmfstart.#{filename}"]
+ return ENV["TEXMFSTART.#{filename}"]
end
end
@@ -396,7 +402,7 @@ def register(filename,fullname)
if $crossover then
ENV["_CTX_K_S_#{filename}_"] = fullname
else
- ENV["texmfstart.#{filename}"] = fullname
+ ENV["TEXMFSTART.#{filename}"] = fullname
end
return true
else
@@ -433,15 +439,16 @@ def find(filename,program)
end
filename.sub!(/^.*[\\\/]/, '')
# next we look at the current path and the callerpath
- ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
- [['.','current'],[ownpath,'caller']].each do |p|
- suffixlist.each do |suffix|
- fname = "#{filename}.#{suffix}"
- fullname = File.join(p[0],fname)
- report("locating '#{fname}' in #{p[1]} path")
- if FileTest.file?(fullname) && register(filename,fullname) then
- report("'#{fname}' located in #{p[1]} path")
- return shortpathname(fullname)
+ [['.','current'],[$ownpath,'caller'],[registered("THREAD"),'thread']].each do |p|
+ if p && ! p.empty? then
+ suffixlist.each do |suffix|
+ fname = "#{filename}.#{suffix}"
+ fullname = File.expand_path(File.join(p[0],fname))
+ report("locating '#{fname}' in #{p[1]} path '#{p[0]}'")
+ if FileTest.file?(fullname) && register(filename,fullname) then
+ report("'#{fname}' located in #{p[1]} path")
+ return shortpathname(fullname)
+ end
end
end
end
@@ -611,7 +618,7 @@ end
def direct(fullname)
begin
- return runcommand([fullname.sub(/^bin\:/, ''),expanded($arguments)].join(' '))
+ return runcommand([fullname.sub(/^(bin|binary)\:/, ''),expanded($arguments)].join(' '))
rescue
return false
end
@@ -674,9 +681,11 @@ def process(&block)
end
-def main
+def execute(arguments)
- $directives = hashed(ARGV)
+ arguments = arguments.split(/\s+/) if arguments.class == String
+
+ $directives = hashed(arguments)
$help = $directives['help'] || false
$batch = $directives['batch'] || false
@@ -699,6 +708,9 @@ def main
$stubpath = $directives['stubpath'] || ''
$indirect = $directives['indirect'] || false
+ $before = $directives['before'] || ''
+ $after = $directives['after'] || ''
+
$iftouched = $directives['iftouched'] || false
$openoffice = $directives['oo'] || false
@@ -742,16 +754,22 @@ def main
elsif $browser && $filename =~ /^http\:\/\// then
launch($filename)
else
- process do
- if $direct || $filename =~ /^bin\:/ then
- direct($filename)
- else # script: or no prefix
- run(find(shortpathname($filename),$program))
+ begin
+ process do
+ if $direct || $filename =~ /^bin\:/ then
+ direct($filename)
+ else # script: or no prefix
+ command = find(shortpathname($filename),$program)
+ register("THREAD",File.dirname(command))
+ run(command)
+ end
end
+ rescue
+ report('fatal error in starting process')
end
end
end
end
-main
+execute(ARGV)