summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2005-06-03 00:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2005-06-03 00:00:00 +0200
commitaf0834c7d9f8d76f86b00ff31fc2d469684637f0 (patch)
tree42baad8db57775bf5edd59ba01ad93da5412ac61 /scripts
parent12ca3d1c438f47608d47907a0f3ba453d9e401bb (diff)
downloadcontext-af0834c7d9f8d76f86b00ff31fc2d469684637f0.tar.gz
stable 2005.06.03
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/texexec.pl244
-rw-r--r--scripts/context/ruby/base/tex.rb41
-rw-r--r--scripts/context/ruby/ctxtools.rb154
-rw-r--r--scripts/context/ruby/texmfstart.rb31
-rw-r--r--scripts/context/ruby/textools.rb79
5 files changed, 401 insertions, 148 deletions
diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl
index 3f11a83cc..263388a4c 100644
--- a/scripts/context/perl/texexec.pl
+++ b/scripts/context/perl/texexec.pl
@@ -52,7 +52,7 @@ use FindBin;
use File::Compare;
use File::Temp;
-use IO::Handle; autoflush STDOUT 1;
+#~ use IO::Handle; autoflush STDOUT 1;
my %ConTeXtInterfaces; # otherwise problems with strict
my %ResponseInterface; # since i dunno how to allocate else
@@ -199,6 +199,7 @@ my $TheEnginePath = 0 ;
my $Paranoid = 0 ;
my $NotParanoid = 0 ;
my $BoxType = '' ;
+my $Local = '' ;
my $TempDir = '' ;
@@ -258,7 +259,9 @@ my $MakeMpy = '';
"autopath" => \$AutoPath,
"pdf" => \$ProducePdfT,
"pdm" => \$ProducePdfM,
+ "dpm" => \$ProducePdfM,
"pdx" => \$ProducePdfX,
+ "dpx" => \$ProducePdfX,
"xtx" => \$ProducePdfXTX,
"pdfarrange" => \$PdfArrange,
"pdfselect" => \$PdfSelect,
@@ -312,6 +315,7 @@ my $MakeMpy = '';
"paranoid" => \$Paranoid,
"notparanoid" => \$NotParanoid,
"boxtype=s" => \$BoxType, # media art crop bleed trim
+ "local" => \$Local,
#### unix is unsafe (symlink viruses)
"tempdir=s" => \$TempDir,
#### experiment
@@ -420,7 +424,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) {
*STDERR = *LOGFILE;
}
-my $Program = " TeXExec 5.4.1 - ConTeXt / PRAGMA ADE 1997-2005";
+my $Program = " TeXExec 5.4.2 - ConTeXt / PRAGMA ADE 1997-2005";
print "\n$Program\n\n";
@@ -775,7 +779,7 @@ $SetFile = IniValue( 'SetFile', $SetFile );
if ( ($Verbose) && ( $kpsewhich ne '' ) ) {
print "\n";
my $CnfFile = `$kpsewhich -progname=context texmf.cnf`;
- chomp $CnfFile;
+ chomp($CnfFile);
print " applications will use : $CnfFile\n";
}
@@ -866,16 +870,29 @@ $SetupPath =~ s/\\/\//go;
my %OutputFormats;
-$OutputFormats{pdf} = "pdftex";
-$OutputFormats{pdftex} = "pdftex";
+# the mother of all drivers
+
$OutputFormats{dvips} = "dvips";
-$OutputFormats{dvipsone} = "dvipsone";
+
+# needs an update
+
$OutputFormats{acrobat} = "acrobat";
+
+# the core drivers
+
+$OutputFormats{pdftex} = "pdftex"; $OutputFormats{pdf} = "pdftex";
+$OutputFormats{dvipdfm} = "dvipdfm"; $OutputFormats{dpm} = "dvipdfm";
+$OutputFormats{dvipdfmx} = "dvipdfmx"; $OutputFormats{dpx} = "dvipdfmx";
+$OutputFormats{xetex} = "xetex"; $OutputFormats{xtx} = "xetex";
+
+# kind of obsolete now that yandy is gone
+
+$OutputFormats{dvipsone} = "dvipsone";
$OutputFormats{dviwindo} = "dviwindo";
+
+# it was never finished
+
$OutputFormats{dviview} = "dviview";
-$OutputFormats{dvipdfm} = "dvipdfm";
-$OutputFormats{dvipdfmx} = "dvipdfmx";
-$OutputFormats{xetex} = "xetex";
my @ConTeXtFormats = ( "nl", "en", "de", "cz", "uk", "it", "ro", "xx");
@@ -1075,6 +1092,18 @@ sub System {
system($cmd)
}
+sub Pipe {
+ my $cmd = shift ;
+ unless ( $dosish && ! $escapeshell ) {
+ $cmd =~ s/([^\\])\&/$1\\\&/io ;
+ }
+ if ($Verbose) {
+ print "\n$cmd\n\n" ;
+ }
+ return `$cmd`
+}
+
+
sub RunPerlScript {
my ( $ScriptName, $Options ) = @_;
my $cmd = '';
@@ -1117,9 +1146,7 @@ sub CheckOutputFormat {
}
}
if ( !$Ok ) {
- print $Help{'output'};
- } elsif ($FullFormat) {
- # print OPT "\\setupoutput[$FullFormat]\n";
+ print(" unknown output format : $OutputFormat\n");
}
}
unless ($FullFormat) { $FullFormat = $OutputFormat }
@@ -1656,23 +1683,23 @@ sub isXMLfile {
sub RunConTeXtFile {
my ( $JobName, $JobSuffix ) = @_;
-if ($AutoPath) {
- if ($JobName =~ /^(.*)[\/\\](.*?)$/o) {
- $InpPath = $1 ;
- $JobName = $2 ;
+ if ($AutoPath) {
+ if ($JobName =~ /^(.*)[\/\\](.*?)$/o) {
+ $InpPath = $1 ;
+ $JobName = $2 ;
+ }
}
-}
$JobName =~ s/\\/\//goi;
$InpPath =~ s/\\/\//goi;
my $OriSuffix = $JobSuffix;
-if ($JobSuffix =~ /\_fo$/i) {
- if (! -f $JobName) {
- print "stripping funny suffix : _fo\n";
- $JobName =~ s/\_fo$//io ;
- $JobSuffix =~ s/\_fo$//io ;
- $OriSuffix =~ s/\_fo$//io ;
+ if ($JobSuffix =~ /\_fo$/i) {
+ if (! -f $JobName) {
+ print "stripping funny suffix : _fo\n";
+ $JobName =~ s/\_fo$//io ;
+ $JobSuffix =~ s/\_fo$//io ;
+ $OriSuffix =~ s/\_fo$//io ;
+ }
}
-}
if (($dosish) && ($PdfClose)) {
my $ok = System("pdfclose --file $JobName.pdf") if -e "$JobName.pdf" ;
if (($Result ne '') && (-e "$Result.pdf")) {
@@ -1841,10 +1868,16 @@ 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") ;
+ $ENV{'backend'} = $ENV{'progname'} = 'dvipdfm' ;
+ $ENV{'TEXFONTMAPS'} = '.;$TEXMF/fonts/map/{dvipdfm,dvips,}//' ;
+ System("dvipdfmx -d 4 $JobName") ;
} elsif ($ProducePdfM) {
+ $ENV{'backend'} = $ENV{'progname'} = 'dvipdfm' ;
+ $ENV{'TEXFONTMAPS'} = '.;$TEXMF/fonts/map/{dvipdfm,dvips,}//' ;
System("dvipdfm $JobName") ;
} elsif ($ProducePdfXTX) {
+ $ENV{'backend'} = $ENV{'progname'} = 'xetex' ;
+ $ENV{'TEXFONTMAPS'} = '.;$TEXMF/fonts/map/{xetex,pdftex,dvips,}//' ;
System("xdv2pdf $JobName.xdv") ;
}
PopResult($JobName);
@@ -2205,86 +2238,92 @@ 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 ;
- $ENV{"TEXFORMATS"} = $str ;
- }
- # expanded paths
- print " assuming engine : $EnginePath\n";
- if (($UseEnginePath)&&($EngineDone)) {
- $FormatPath = `$kpsewhich --engine=$EnginePath --show-path=fmt` ;
- } else {
- $FormatPath = `$kpsewhich --show-path=fmt` ;
- }
- chomp $FormatPath ;
- if ( ( $FormatPath ne '' ) && $Verbose ) {
- print "located formatpath (1) : $FormatPath\n";
- }
- # fall back
- if ($FormatPath eq '') {
+ if ($Local) {
+ $FormatPath = '.' ; # for patrick
+ } else {
+ if ( ( $FormatPath eq '' ) && ( $kpsewhich ne '' ) ) {
+ unless ($EngineDone) {
+ my $str = $ENV{"TEXFORMATS"} ;
+ $str =~ s/\$engine//io ;
+ $ENV{"TEXFORMATS"} = $str ;
+ }
+ # expanded paths
+ print " assuming engine : $EnginePath\n";
if (($UseEnginePath)&&($EngineDone)) {
- if ($dosish) {
- $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\$TEXFORMATS` ;
- } else {
- $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\\\$TEXFORMATS` ;
- }
+ $FormatPath = `$kpsewhich --engine=$EnginePath --show-path=fmt` ;
+ } else {
+ $FormatPath = `$kpsewhich --show-path=fmt` ;
+ }
+ chomp($FormatPath) ;
+ if ( ( $FormatPath ne '' ) && $Verbose ) {
+ print "located formatpath (1) : $FormatPath\n";
}
- # either no enginepath or failed run
+ # fall back
if ($FormatPath eq '') {
- if ($dosish) {
- $FormatPath = `$kpsewhich --expand-path=\$TEXFORMATS` ;
- } else {
- $FormatPath = `$kpsewhich --expand-path=\\\$TEXFORMATS` ;
+ if (($UseEnginePath)&&($EngineDone)) {
+ if ($dosish) {
+ $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\$TEXFORMATS` ;
+ } else {
+ $FormatPath = `$kpsewhich --engine=$EnginePath --expand-path=\\\$TEXFORMATS` ;
+ }
+ }
+ chomp($FormatPath) ;
+ # either no enginepath or failed run
+ if ($FormatPath eq '') {
+ if ($dosish) {
+ $FormatPath = `$kpsewhich --expand-path=\$TEXFORMATS` ;
+ } else {
+ $FormatPath = `$kpsewhich --expand-path=\\\$TEXFORMATS` ;
+ }
}
+ chomp $FormatPath ;
}
- }
- chomp $FormatPath ;
- if ( ( $FormatPath ne '' ) && $Verbose ) {
- print "located formatpath (2) : $FormatPath\n";
- }
- $FormatPath =~ s/\\/\//g ;
- if ($FormatPath ne '') {
- my @fpaths ;
- if ($dosish) {
- @fpaths = split(';', $FormatPath) ;
- } else {
- @fpaths = split(':', $FormatPath) ;
+ chomp($FormatPath) ;
+ if ( ( $FormatPath ne '' ) && $Verbose ) {
+ print "located formatpath (2) : $FormatPath\n";
}
- # 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 ;
+ $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 ;
+ }
}
}
}
+ $FormatPath = '.' if (($FormatPath eq '') || (! -w $FormatPath)) ;
+ if ( ( $FormatPath ne '' ) && $Verbose ) {
+ print "located formatpath (3) : $FormatPath\n";
+ }
+ $FormatPath .= '/';
}
- $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) {
- mkdir $FormatPath ;
+ if ($UseEnginePath && $EngineDone && ($FormatPath ne '') && ($FormatPath !~ /$EnginePath\/$/)) {
+ $FormatPath .= $EnginePath ;
+ unless (-d $FormatPath) {
+ mkdir $FormatPath ;
+ }
+ $FormatPath .= '/' ;
}
- $FormatPath .= '/' ;
}
print " using formatpath : $FormatPath\n" if $Verbose ;
return $FormatPath;
@@ -2405,17 +2444,18 @@ sub checktexformatpath {
if ($texformats eq '') {
if ($UseEnginePath) {
if ($dosish) {
- $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\$TEXFORMATS`.chomp ;
+ $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\$TEXFORMATS` ;
} else {
- $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\\\$TEXFORMATS`.chomp ;
+ $texformats = `kpsewhich --engine=$TeXExecutable --expand-var=\\\$TEXFORMATS` ;
}
} else {
if ($dosish) {
- $texformats = `kpsewhich --expand-var=\$TEXFORMATS`.chomp ;
+ $texformats = `kpsewhich --expand-var=\$TEXFORMATS` ;
} else {
- $texformats = `kpsewhich --expand-var=\\\$TEXFORMATS`.chomp ;
+ $texformats = `kpsewhich --expand-var=\\\$TEXFORMATS` ;
}
}
+ chomp($texformats) ;
}
if (($texformats !~ /web2c\/.*$TeXExecutable/) && ($texformats !~ /web2c[\/\\].*\$engine/i)) {
$texformats =~ s/(web2c\/\{)(\,\})/$1\$engine$2/ ; # needed for empty engine flags
@@ -2839,7 +2879,7 @@ sub AnalyzeVersion
my ($texengine,$type) = ('unknown', 'unknown');
open (LOG, "<texvers.log") ;
while (<LOG>)
- { /^\s*This is (.*pdf(|e|x)TeX.*?)$/o and $texengine = $1 ;
+ { /^\s*This is (.*(pdf)?(|e|x)TeX.*?)$/o and $texengine = $1 ;
/^\s*ConTeXt (.*int: ([a-z]+).*?)\s*$/o and $type = $1; }
$type =~ s/ int: ([a-z]+)//;
$texengine =~ s/ Version//;
@@ -2870,16 +2910,16 @@ sub show_version_info {
$EnterBatchMode = 1;
$Format = 'cont-en';
my $cmd = PrepRunTeX("texvers","tex",'') ;
- ($texengine,$type) = AnalyzeVersion(`$cmd`) ;
+ ($texengine,$type) = AnalyzeVersion(Pipe($cmd)) ;
print " tex : $texengine\n" ;
print " context : ver: $contextversion\n" ;
print " cont-en : $type\n" ;
foreach my $a (qw(cz de it nl ro uk xx)) {
- my $test = `$kpsewhich -format='fmt' cont-$a`;
+ my $test = Pipe("$kpsewhich -format='fmt' cont-$a") ;
if (defined $test && $test) {
$Format = 'cont-' . $a;
$cmd = PrepRunTeX("texvers","tex",'');
- ($texengine,$type) = AnalyzeVersion(`$cmd`) ;
+ ($texengine,$type) = AnalyzeVersion(Pipe($cmd)) ;
print " cont-$a : $type\n" ;
}
}
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index e9f66ea8d..cea6662ae 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -71,7 +71,7 @@ class TEX
'batchmode', 'nonstopmode', 'fastmode', 'fastdisabled', 'silentmode', 'final',
'paranoid', 'notparanoid', 'nobanner', 'once', 'allpatterrns',
'nompmode', 'nomprun', 'automprun',
- 'nomapfiles',
+ 'nomapfiles', 'local',
'arrange', 'noarrange',
'forcexml', 'foxet',
'mpyforce', 'forcempy',
@@ -236,8 +236,15 @@ class TEX
end
def openedfile(name)
- cleanuplater(name) if f = File.open(name, 'w')
- return f
+ begin
+ f = File.open(name,'w')
+ rescue
+ report("file '#{File.expand_path(name)}' cannot be opened for writing")
+ return nil
+ else
+ cleanuplater(name) if f
+ return f
+ end
end
def prefixed(format,engine)
@@ -395,7 +402,7 @@ class TEX
# generate tex formats
if texformats && texengine && (progname = validprogname(getvariable('progname'),texengine)) then
report("using tex engine #{texengine}")
- texformatpath = Kpse.formatpath(texengine,true)
+ texformatpath = if getvariable('local') then '.' else Kpse.formatpath(texengine,true) end
# can be empty, to do
report("using tex format path #{texformatpath}")
begin
@@ -421,7 +428,7 @@ class TEX
# generate mps formats
if mpsformats && mpsengine && (progname = validprogname(getvariable('progname'),mpsengine)) then
report("using mp engine #{mpsengine}")
- mpsformatpath = Kpse.formatpath(mpsengine,false)
+ mpsformatpath = if getvariable('local') then '.' else Kpse.formatpath(mpsengine,false) end
report("using mps format path #{mpsformatpath}")
begin
Dir.chdir(mpsformatpath)
@@ -998,6 +1005,12 @@ class TEX
Kpse.runscript('texexec',filename,options)
end
+ def fixbackendvars(backend)
+ ENV['backend'] = backend ;
+ ENV['progname'] = backend unless validtexengine(backend)
+ ENV['TEXFONTMAPS'] = ".;\$TEXMF/fonts/map/{#{backend},pdftex,dvips,}//"
+ end
+
def processcontextfile
takeprecautions
@@ -1098,10 +1111,20 @@ class TEX
['tup','top'].each do |s| # previous tuo file / runtime option file
File.silentdelete(File.suffixed(jobname,s))
end
- case validbackend(getvariable('driver'))
- when 'dvipdfmx' then system("dvipdfmx -f dvipdfmx.map -d 4 #{File.unsuffixed(jobname)}")
- when 'xetex' then system("xdv2pdf #{File.suffixed(jobname,'xdv')}")
- when 'dvips' then system("dvips #{File.unsuffixed(jobname)}")
+ case validbackend(getvariable('backend'))
+ when 'dvipdfmx' then
+ fixbackendvars('dvipdfm')
+ system("dvipdfmx -d 4 #{File.unsuffixed(jobname)}")
+ when 'xetex' then
+ fixbackendvars('xetex')
+ system("xdv2pdf #{File.suffixed(jobname,'xdv')}")
+ when 'dvips' then
+ fixbackendvars('dvips')
+ system("dvips #{File.unsuffixed(jobname)}")
+ when 'pdftex' then
+ # no need for postprocessing
+ else
+ report("no postprocessing needed")
end
popresult(jobname,result)
end
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index 1a87e298e..4e69d9534 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -767,26 +767,51 @@ class Language
@remapping.push([from,to])
end
+ # def load(filenames=@filenames)
+ # begin
+ # if filenames then
+ # @filenames = [filenames].flatten
+ # @filenames.each do |filename|
+ # begin
+ # if filename = located(filename) then
+ # data = IO.read(filename)
+ # @data += data.gsub(/\%.*$/, '')
+ # data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end
+ # @read += "\n% preamble of file #{filename}\n\n#{data}\n"
+ # else
+ # report("file #{filename} is not found")
+ # end
+ # rescue
+ # report("file #{filename} is not readable")
+ # else
+ # report("file #{filename} is loaded")
+ # end
+ # end
+ # end
+ # rescue
+ # end
+ # end
+
def load(filenames=@filenames)
begin
if filenames then
- @filenames = [filenames].flatten
- @filenames.each do |filename|
- begin
- if filename = located(filename) then
- data = IO.read(filename)
- @data += data.gsub(/\%.*$/, '')
- data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end
- @read += "\n% preamble of file #{filename}\n\n#{data}\n"
- else
- report("file #{filename} is not found")
+ @filenames.each do |fileset|
+ [fileset].flatten.each do |filename|
+ begin
+ if filename = located(filename) then
+ data = IO.read(filename)
+ @data += data.gsub(/\%.*$/, '')
+ data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end
+ @read += "\n% preamble of file #{filename}\n\n#{data}\n"
+ report("file #{filename} is loaded")
+ break # next fileset
+ else
+ report("file #{filename} is not found")
+ end
+ rescue
+ report("file #{filename} is not readable")
end
- rescue
- report("file #{filename} is not readable")
- else
- report("file #{filename} is loaded")
end
- # @data.gsub!(/\s\\[nc]\{(.*?)\}\s/o) do $1 end
end
end
rescue
@@ -1146,7 +1171,8 @@ class Commands
# ghyphen.readme ghyph31.readme grphyph
@@languagedata['hr' ] = [['hrhyph.tex'], 'ec']
@@languagedata['hu' ] = [['huhyphn.tex'], 'ec']
- @@languagedata['en' ] = [['hyphen.tex'], 'default']
+ @@languagedata['en' ] = [[['ushyph','hyphen.tex']], 'default']
+ @@languagedata['en' ] = [['ushyph.tex'], 'default']
# inhyph.tex
@@languagedata['is' ] = [['ishyph.tex'], 'ec']
@@languagedata['it' ] = [['ithyph.tex'], 'ec']
@@ -1164,7 +1190,95 @@ class Commands
# srhyphc.tex / cyrillic
@@languagedata['sv' ] = [['svhyph.tex'], 'ec']
@@languagedata['tr' ] = [['tkhyph.tex'], 'ec']
- @@languagedata['uk' ] = [['ukhyphen.tex'], 'default']
+ @@languagedata['uk' ] = [[['ukhyph','ukhyphen.tex']], 'default']
+
+end
+
+class Commands
+
+ include CommandBase
+
+ def dpxmapfiles
+
+ force = @commandline.option("force")
+
+ texmfroot = @commandline.argument('first')
+ texmfroot = '.' if texmfroot.empty?
+ maproot = "#{texmfroot}/fonts/map/pdftex/context"
+
+ if File.directory?(maproot) then
+ if files = Dir.glob("#{maproot}/*.map") and files.size > 0 then
+ files.each do |pdffile|
+ next if File.basename(pdffile) == 'pdftex.map'
+ pdffile = File.expand_path(pdffile)
+ dpxfile = File.expand_path(pdffile.sub(/pdftex/i,'dvipdfm'))
+ unless pdffile == dpxfile then
+ begin
+ if data = File.read(pdffile) then
+ report("< #{File.basename(pdffile)} - pdf(e)tex")
+ n = 0
+ data = data.collect do |line|
+ if line =~ /^[\%\#]+/mo then
+ ''
+ else
+ encoding = if line =~ /([a-z0-9\-]+)\.enc/io then $1 else '' end
+ fontfile = if line =~ /([a-z0-9\-]+)\.(pfb|ttf)/io then $1 else nil end
+ metrics = if line =~ /^([a-z0-9\-]+)[\s\<]+/io then $1 else nil end
+ if metrics && encoding && fontfile then
+ n += 1
+ "#{metrics} #{encoding} #{fontfile}"
+ else
+ ''
+ end
+ end
+ end
+ data.delete_if do |line|
+ line.gsub(/\s+/,'').empty?
+ end
+ begin
+ if force then
+ if n > 0 then
+ File.makedirs(File.dirname(dpxfile))
+ if f = File.open(dpxfile,'w') then
+ report("> #{File.basename(dpxfile)} - dvipdfm(x) - #{n}")
+ f.puts(data)
+ f.close
+ else
+ report("? #{File.basename(dpxfile)} - dvipdfm(x)")
+ end
+ else
+ report("- #{File.basename(dpxfile)} - dvipdfm(x)")
+ begin File.delete(dpxname) ; rescue ; end
+ end
+ else
+ report(". #{File.basename(dpxfile)} - dvipdfm(x) - #{n}")
+ end
+ rescue
+ report("error in saving dvipdfm file")
+ end
+ else
+ report("error in loading pdftex file")
+ end
+ rescue
+ report("error in processing pdftex file")
+ end
+ end
+ end
+ if force then
+ begin
+ report("regenerating database for #{texmfroot}")
+ system("mktexlsr #{texmfroot}")
+ rescue
+ end
+ end
+ else
+ report("no mapfiles found in #{maproot}")
+ end
+ else
+ report("provide proper texmfroot")
+ end
+
+ end
end
@@ -1182,12 +1296,14 @@ commandline.registeraction('rawinterface', 'generate raw syntax files [--pipe]')
commandline.registeraction('translateinterface', 'generate interface files (xml) [nl de ..]')
commandline.registeraction('purgefiles', 'remove temporary files [--all] [basename]')
-commandline.registeraction('documentation', 'generate documentation file [--type=] [filename]')
+commandline.registeraction('documentation', 'generate documentation [--type=] [filename]')
commandline.registeraction('filterpages') # no help, hidden temporary feature
commandline.registeraction('purgeallfiles') # no help, compatibility feature
-commandline.registeraction('patternfiles', 'generate pattern files [languagecode|all]')
+commandline.registeraction('patternfiles', 'generate pattern files [--all] [languagecode]')
+
+commandline.registeraction('dpxmapfiles', 'convert pdftex mapfiles to dvipdfmx [--force] [texmfroot]')
commandline.registervalue('type','')
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 82b87a7e9..c082b623d 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -26,6 +26,8 @@
#
# file: path: bin:
+# texmfstart --exec bin:scite *.tex
+
# we don't depend on other libs
$ownpath = File.expand_path(File.dirname($0)) unless defined? $ownpath
@@ -375,35 +377,30 @@ def usage
print(" texmfstart --page=2 --file=showcase.pdf\n")
print(" texmfstart --program=yourtex yourscript.pl arg-1 arg-2\n")
print(" texmfstart --direct xsltproc kpse:somefile.xsl somefile.xml\n")
- print(" texmfstart bin:xsltproc env:somepreset kpse:somefile.xsl somefile.xml\n")
+ print(" texmfstart bin:xsltproc env:somepreset path:somefile.xsl somefile.xml\n")
print(" texmfstart --iftouched=normal,lowres downsample.rb normal lowres\n")
+ print(" texmfstart texmfstart bin:scite kpse:texmf.cnf\n")
+ print(" texmfstart texmfstart --exec bin:scite *.tex\n")
end
# somehow registration does not work out (at least not under windows)
+def tag(name)
+ if $crossover then "_CTX_K_S_#{name}_" else "TEXMFSTART.#{name}" end
+end
+
def registered?(filename)
- if $crossover then
- return ENV["_CTX_K_S_#{filename}_"] != nil
- else
- return ENV["TEXMFSTART.#{filename}"] != nil
- end
+ return ENV[tag(filename)] != nil
end
def registered(filename)
- if $crossover then
- return ENV["_CTX_K_S_#{filename}_"]
- else
- return ENV["TEXMFSTART.#{filename}"]
- end
+ return ENV[tag(filename)]
end
def register(filename,fullname)
if fullname && ! fullname.empty? then # && FileTest.file?(fullname)
- if $crossover then
- ENV["_CTX_K_S_#{filename}_"] = fullname
- else
- ENV["TEXMFSTART.#{filename}"] = fullname
- end
+ ENV[tag(filename)] = fullname
+ report("registering '#{filename}' as '#{fullname}'")
return true
else
return false
@@ -760,7 +757,7 @@ def execute(arguments)
direct($filename)
else # script: or no prefix
command = find(shortpathname($filename),$program)
- register("THREAD",File.dirname(command))
+ register("THREAD",File.dirname(File.expand_path(command)))
run(command)
end
end
diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb
index 7d23c7dbc..9057e318c 100644
--- a/scripts/context/ruby/textools.rb
+++ b/scripts/context/ruby/textools.rb
@@ -13,7 +13,7 @@
# This script will harbor some handy manipulations on tex
# related files.
-banner = ['TeXTools', 'version 1.2.1', '2002/2005', 'PRAGMA ADE/POD']
+banner = ['TeXTools', 'version 1.2.2', '2002/2005', 'PRAGMA ADE/POD']
unless defined? ownpath
ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
@@ -721,6 +721,81 @@ class Commands
end
+ public
+
+ def merge
+
+ nocheck = @commandline.option('nocheck')
+ force = @commandline.option('force')
+ root = @commandline.argument('first')
+ path = @commandline.argument('second')
+
+ if FileTest.directory?(root) then
+ report("scanning #{root}")
+ rootfiles = Dir.glob("#{root}/**/*")
+ else
+ report("provide sourse root")
+ return
+ end
+ if rootfiles.size > 0 then
+ report("#{rootfiles.size} files")
+ else
+ report("no files")
+ return
+ end
+
+ if FileTest.directory?(path) then
+ report("scanning #{path}")
+ pathfiles = Dir.glob("#{path}/**/*")
+ else
+ report("provide destination root")
+ return
+ end
+ if pathfiles.size > 0 then
+ report("#{pathfiles.size} files")
+ else
+ report("no files")
+ return
+ end
+
+ roothash = Hash.new
+ pathhash = Hash.new
+
+ rootfiles.each do |f|
+ if File.file?(f) then
+ fd, fb = File.dirname(f), File.basename(f)
+ roothash[fb] = if roothash.key?(fb) then nil else fd end
+ end
+ end
+
+ pathfiles.each do |f|
+ if File.file?(f) then
+ fd, fb = File.dirname(f), File.basename(f)
+ pathhash[fb] = if pathhash.key?(fb) then nil else fd end
+ end
+ end
+
+ pathhash.keys.each do |f|
+ if pathhash[f] && roothash[f] then
+ p = File.expand_path(File.join(pathhash[f],f))
+ r = File.expand_path(File.join(roothash[f],f))
+ if p != r then
+ if nocheck or File.mtime(p) < File.mtime(r) then
+ report("copying '#{r}' to '#{p}'")
+ begin
+ File.copy(r,p) if force
+ rescue
+ report("copying failed")
+ end
+ else
+ report("skipping '#{r}' to '#{p}'")
+ end
+ end
+ end
+ end
+
+ end
+
end
logger = Logger.new(banner.shift)
@@ -736,6 +811,7 @@ commandline.registeraction('fixafmfiles' , '[pattern] [--recurse]')
commandline.registeraction('mactodos' , '[pattern] [--recurse]')
commandline.registeraction('fixtexmftrees' , '[texmfroot] [--force]')
commandline.registeraction('replace' , 'filename [--force]')
+commandline.registeraction('merge' , 'fromroot toroot [--force --nocheck]')
commandline.registeraction('downcasefilenames', '[--recurse] [--force]') # not yet documented
commandline.registeraction('stripformfeeds' , '[--recurse] [--force]') # not yet documented
commandline.registeraction('showfont' , 'filename')
@@ -745,6 +821,7 @@ commandline.registeraction('version')
commandline.registerflag('recurse')
commandline.registerflag('force')
+commandline.registerflag('nocheck')
commandline.expand