summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/mptopdf.pl153
-rw-r--r--scripts/context/ruby/base/tex.rb41
2 files changed, 131 insertions, 63 deletions
diff --git a/scripts/context/perl/mptopdf.pl b/scripts/context/perl/mptopdf.pl
index 767d2d260..b5d4bc15d 100644
--- a/scripts/context/perl/mptopdf.pl
+++ b/scripts/context/perl/mptopdf.pl
@@ -37,91 +37,118 @@ my $PassOn = '' ;
"passon" => \$PassOn,
"latex" => \$Latex ) ;
-my $program = "MPtoPDF 1.3" ;
+my $program = "MPtoPDF 1.3.2" ;
my $pattern = "@ARGV" ; # was $ARGV[0]
+my $miktex = 0 ;
my $done = 0 ;
my $report = '' ;
my $texlatexswitch = " --tex=latex --format=latex " ;
my $mplatexswitch = " --tex=latex " ;
my $dosish = ($Config{'osname'} =~/^(ms)?dos|^os\/2|^mswin/i) ;
-my $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io);
-my $escapeshell = ( ($ENV{'SHELL'}) && ($ENV{'SHELL'} =~ m/sh/i ));
+my $escapeshell = (($ENV{'SHELL'}) && ($ENV{'SHELL'} =~ m/sh/i ));
+
+if ($ENV{"TEXSYSTEM"}) {
+ $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io) ;
+}
my @files ;
my $command = my $mpbin = '' ;
-sub CopyFile # agressive copy, works for open files like in gs
- { my ($From,$To) = @_ ;
- return unless open(INP,"<$From") ; binmode INP ;
- return unless open(OUT,">$To") ; binmode OUT ;
- while (<INP>) { print OUT $_ }
+# agressive copy, works for open files like in gs
+
+sub CopyFile {
+ my ($From,$To) = @_ ;
+ return unless open(INP,"<$From") ;
+ return unless open(OUT,">$To") ;
+ binmode INP ;
+ binmode OUT ;
+ while (<INP>) {
+ print OUT $_ ;
+ }
close (INP) ;
- close (OUT) }
-
-if (($pattern eq '')||($Help))
- { print "\n$program : provide MP output file (or pattern)\n" ;
- exit }
-elsif ($pattern =~ /\.mp$/io)
- { shift @ARGV ; my $rest = join(" ", @ARGV) ;
- if (open(INP,$pattern))
- { while (<INP>)
- { if (/(documentstyle|documentclass|begin\{document\})/io)
- { $Latex = 1 ; last } }
- close (INP) }
- if ($RawMP)
- { if ($Latex)
- { $rest .= " $mplatexswitch" }
+ close (OUT) ;
+}
+
+if (($pattern eq '')||($Help)) {
+ print "\n$program : provide MP output file (or pattern)\n" ;
+ exit ;
+} elsif ($pattern =~ /\.mp$/io) {
+ shift @ARGV ; my $rest = join(" ", @ARGV) ;
+ if (open(INP,$pattern)) {
+ while (<INP>) {
+ if (/(documentstyle|documentclass|begin\{document\})/io) {
+ $Latex = 1 ; last ;
+ }
+ }
+ close (INP) ;
+ }
+ if ($RawMP) {
+ if ($Latex) {
+ $rest .= " $mplatexswitch" ;
+ }
if ($MetaFun) {
$mpbin = 'mpost --progname=mpost --mem=metafun' ;
} else {
$mpbin = 'mpost --mem=mpost' ;
}
+ } else {
+ if ($Latex) {
+ $rest .= " $texlatexswitch" ;
+ }
+ $mpbin = 'texexec --mptex $PassOn' ;
}
- else
- { if ($Latex)
- { $rest .= " $texlatexswitch" }
- $mpbin = 'texexec --mptex $PassOn' }
+ print "\n$program : running '$command'" ;
my $error = system ("$mpbin $rest $pattern") ;
- if ($error)
- { print "\n$program : error while processing mp file\n" ; exit }
- else
- { $pattern =~ s/\.mp$//io ;
- @files = glob "$pattern.*" } }
-elsif (-e $pattern)
- { @files = ($pattern) }
-elsif ($pattern =~ /.\../o)
- { @files = glob "$pattern" }
-else
- { $pattern .= '.*' ;
- @files = glob "$pattern" }
-
-foreach my $file (@files)
- { $_ = $file ;
- if (s/\.(\d+|mps)$// && -e $file)
- { if ($miktex)
- { $command = "pdfetex -undump=mptopdf" }
- else
- { $command = "pdfetex -fmt=mptopdf -progname=context" }
- if ($dosish)
- { $command = "$command \\relax $file" }
- else
- { $command = "$command \\\\relax $file" }
+ if ($error) {
+ print "\n$program : error while processing mp file\n" ;
+ exit ;
+ } else {
+ $pattern =~ s/\.mp$//io ;
+ @files = glob "$pattern.*" ;
+ }
+} elsif (-e $pattern) {
+ @files = ($pattern) ;
+} elsif ($pattern =~ /.\../o) {
+ @files = glob "$pattern" ;
+} else {
+ $pattern .= '.*' ;
+ @files = glob "$pattern" ;
+}
+
+foreach my $file (@files) {
+ $_ = $file ;
+ if (s/\.(\d+|mps)$// && -e $file) {
+ if ($miktex) {
+ $command = "pdfetex -undump=mptopdf" ;
+ } else {
+ $command = "pdfetex -fmt=mptopdf -progname=context" ;
+ }
+ if ($dosish) {
+ $command = "$command \\relax $file" ;
+ } else {
+ $command = "$command \\\\relax $file" ;
+ }
system($command) ;
- # rename ("$_.pdf", "$_-$1.pdf") ;
- # if (-e "$_.pdf") { CopyFile ("$_.pdf", "$_-$1.pdf") }
my $pdfsrc = basename($_).".pdf";
rename ($pdfsrc, "$_-$1.pdf") ;
- if (-e $pdfsrc) { CopyFile ($pdfsrc, "$_-$1.pdf") }
- # end of patch
- if ($done) { $report .= " +" }
+ if (-e $pdfsrc) {
+ CopyFile ($pdfsrc, "$_-$1.pdf") ;
+ }
+ if ($done) {
+ $report .= " +" ;
+ }
$report .= " $_-$1.pdf" ;
- ++$done } }
+ ++$done ;
+ }
+}
-if ($report eq '')
- { $report = '*' }
+if ($report eq '') {
+ $report = '*' ;
+}
-if ($done)
- { print "\n$program : $pattern is converted to$report\n" }
-else
- { print "\n$program : no filename matches $pattern\n" }
+if ($done) {
+ print "\n$program : $pattern is converted to$report\n" ;
+} else {
+ print "\n$program : no filename matches $pattern\n" ;
+}
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 700150055..0d1e01b95 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -125,6 +125,7 @@ class TEX
'nomapfiles', 'local',
'arrange', 'noarrange',
'forcexml', 'foxet',
+'alpha', 'beta',
'mpyforce', 'forcempy',
'forcetexutil', 'texutil',
'globalfile', 'autopath',
@@ -447,6 +448,9 @@ class TEX
end
def makeformats
+
+ checktestversion
+
report("using search method '#{Kpse.searchmethod}'")
if getvariable('fast') then
report('using existing database')
@@ -1036,7 +1040,40 @@ class TEX
end
end
+ def checktestversion
+ #
+ # one can set TEXMFALPHA and TEXMFBETA for test versions
+ # but keep in mind that the format as well as the test files
+ # then need the --alpha or --beta flag
+ #
+ done, tree = false, ''
+ ['alpha', 'beta'].each do |what|
+ if getvariable(what) then
+ if ENV["TEXMF#{what.upcase}"] then
+ done, tree = true, ENV["TEXMF#{what.upcase}"]
+ elsif ENV["TEXMFLOCAL"] then
+ done, tree = true, File.join(File.dirname(ENV['TEXMFLOCAL']), "texmf-#{what}")
+ end
+ end
+ break if done
+ end
+ if done then
+ tree = tree.strip
+ ENV['TEXMFPROJECT'] = tree
+ report("using test tree '#{tree}'")
+ ['MP', 'MF', 'TX'].each do |ctx|
+ ENV['CTXDEV#{ctx}PATH'] = ''
+ end
+ unless (FileTest.file?(File.join(tree,'ls-r')) || FileTest.file?(File.join(tree,'ls-R'))) then
+ report("no ls-r/ls-R file for tree '#{tree}' (run: mktexlsr #{tree})")
+ end
+ end
+ # puts `kpsewhich --expand-path=$TEXMF`
+ # exit
+ end
+
def runtex(filename)
+checktestversion
texengine = validtexengine(getvariable('texengine'))
texformat = validtexformat(getarrayvariable('texformats').first)
progname = validprogname(getvariable('progname'))
@@ -1054,6 +1091,7 @@ class TEX
end
def runmp(filename,mpx=false)
+checktestversion
mpsengine = validmpsengine(getvariable('mpsengine'))
mpsformat = validmpsformat(getarrayvariable('mpsformats').first)
progname = validprogname(getvariable('progname'))
@@ -1070,6 +1108,7 @@ class TEX
end
def runtexmp(filename,filetype='')
+checktestversion
mpfile = File.suffixed(filename,filetype,'mp')
if File.atleast?(mpfile,25) then
# first run needed
@@ -1087,6 +1126,7 @@ class TEX
end
def runtexmpjob(filename,filetype='')
+checktestversion
mpfile = File.suffixed(filename,filetype,'mp')
if File.atleast?(mpfile,25) && (data = File.silentread(mpfile)) then
textranslation = if data =~ /^\%\s+translate.*?\=([\w\d\-]+)/io then $1 else '' end
@@ -1191,6 +1231,7 @@ class TEX
def processfile
takeprecautions
+ # checktestversion
report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose')