diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2008-06-12 10:42:53 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2008-06-12 10:42:53 +0000 |
commit | 0d01365d53c456d246da0ca1f0b3cd9868f02b35 (patch) | |
tree | 01a655c8028e17cfb371456b299c1848fe08c05b /Master/texmf-dist/scripts/context/ruby | |
parent | 44f3714442da07fdfc36a7f2a8dcd5d4294c5d26 (diff) |
ConTeXt release 2008.05.21
git-svn-id: svn://tug.org/texlive/trunk@8691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby')
27 files changed, 1202 insertions, 1022 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/ctx.rb b/Master/texmf-dist/scripts/context/ruby/base/ctx.rb index f86e92d18c0..a077297f243 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/ctx.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/ctx.rb @@ -21,7 +21,7 @@ require 'rexml/document' class CtxRunner - attr_reader :environments, :modules, :filters, :flags + attr_reader :environments, :modules, :filters, :flags, :modes @@suffix = 'prep' @@ -43,7 +43,13 @@ class CtxRunner @modules = Array.new @filters = Array.new @flags = Array.new + @modes = Array.new @local = false + @paths = Array.new + end + + def register_path(str) + @paths << str end def manipulate(ctxname=nil,defaultname=nil) @@ -60,6 +66,10 @@ class CtxRunner return end + if @ctxname !~ /\.[a-z]+$/ then + @ctxname += ".ctx" + end + # name can be kpse:res-make.ctx if not FileTest.file?(@ctxname) then fullname, done = '', false @@ -83,6 +93,12 @@ class CtxRunner end break if done end + if ! done then + fullname = Kpse.found(@ctxname) + if FileTest.file?(fullname) then + @ctxname, done = fullname, true + end + end end if ! done && defaultname && FileTest.file?(defaultname) then report("using default ctxfile #{defaultname}") @@ -94,7 +110,12 @@ class CtxRunner end end - @xmldata = IO.read(@ctxname) + if FileTest.file?(@ctxname) then + @xmldata = IO.read(@ctxname) + else + report('no ctx file found') + return false + end unless @xmldata =~ /^.*<\?xml.*?\?>/moi then report("ctx file #{@ctxname} is no xml file, skipping") @@ -130,6 +151,9 @@ class CtxRunner REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:filter") do |fil| @filters << justtext(fil) end + REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:mode") do |fil| + @modes << justtext(fil) + end begin REXML::XPath.each(root,"//ctx:block") do |blk| if @jobname && blk.attributes['pattern'] then @@ -155,6 +179,9 @@ class CtxRunner REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:filter") do |fil| @filters << justtext(fil) end + REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:mode") do |fil| + @modes << justtext(fil) + end REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:flags/ctx:flag") do |flg| @flags << justtext(flg) end @@ -180,6 +207,14 @@ class CtxRunner end REXML::XPath.each(root,"/ctx:job//ctx:preprocess/ctx:files") do |files| REXML::XPath.each(files,"ctx:file") do |pattern| + suffix = @@suffix + begin + suffix = REXML::XPath.match(root,"/ctx:job//ctx:preprocess/@suffix").to_s + rescue + suffix = @@suffix + else + if suffix && suffix.empty? then suffix = @@suffix end + end preprocessor = pattern.attributes['processor'] if preprocessor and not preprocessor.empty? then begin @@ -196,12 +231,25 @@ class CtxRunner end pattern = justtext(pattern) oldfiles = Dir.glob(pattern) + pluspath = false if oldfiles.length == 0 then report("no files match #{pattern}") + if @paths.length > 0 then + @paths.each do |p| + oldfiles = Dir.glob("#{p}/#{pattern}") + if oldfiles.length > 0 then + pluspath = true + break + end + end + if oldfiles.length == 0 then + report("no files match #{pattern} on path") + end + end end oldfiles.each do |oldfile| newfile = "#{oldfile}.#{suffix}" - newfile = File.basename(newfile) if @local + newfile = File.basename(newfile) if @local # or pluspath if File.expand_path(oldfile) != File.expand_path(newfile) && File.needsupdate(oldfile,newfile) then report("#{oldfile} needs preprocessing") begin @@ -214,10 +262,10 @@ class CtxRunner if command = commands[pp] then # a lie: no <?xml ...?> command = REXML::Document.new(command.to_s) # don't infect original + # command = command.deep_clone() # don't infect original command = command.elements["ctx:processor"] - begin - newfile = "#{oldfile}.#{suf}" if suf = command.attributes['suffix'] - rescue + if suf = command.attributes['suffix'] then + newfile = "#{oldfile}.#{suf}" end begin newfile = File.basename(newfile) if @local @@ -398,6 +446,7 @@ class CtxRunner when 'suffix' then if str =~ /^.*\.(.*?)$/o then $1 else '' end when 'nosuffix' then if str =~ /^(.*)\..*?$/o then $1 else str end when 'nopath' then if str =~ /^.*[\\\/](.*?)$/o then $1 else str end + when 'base' then if str =~ /^.*[\\\/](.*?)$/o then $1 else str end when 'full' then str when 'complete' then str when 'expand' then File.expand_path(str).gsub(/\\/,"/") diff --git a/Master/texmf-dist/scripts/context/ruby/base/exa.rb b/Master/texmf-dist/scripts/context/ruby/base/exa.rb index fdc5b5093e1..5a094351ec5 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/exa.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/exa.rb @@ -45,7 +45,7 @@ module ExaEncrypt "#{pre}#{password}#{post}" end else - data.gsub!(/<exa:password([^>]*?)>(.*?)<\/exa:password>/mois) do + data.gsub!(/<exa:password([^>]*?)>(.*?)<\/exa:password>/moi) do attributes, password = $1, $2 unless password =~ /^([0-9A-F][0-9A-F])+$/ then done = true @@ -238,11 +238,11 @@ module ExaModes binln, einln = "<inlinetexmath>" , "</inlinetexmath>" egraf = "<p/>" end - str.gsub!(/\n\s*\n+/mois, "\\ENDGRAF ") + str.gsub!(/\n\s*\n+/moi, "\\ENDGRAF ") str.gsub!(/(\[\[)\s*(.*?)\s*(\]\])/mos) do $1 + docalculatortexmath($2) + $3 end - str.gsub!(/(\\ENDGRAF)+\s*(\[\[)\s*(.*?)\s*(\]\])/mois) do + str.gsub!(/(\\ENDGRAF)+\s*(\[\[)\s*(.*?)\s*(\]\])/moi) do $1 + bdisp + $3 + edisp end str.gsub!(/(\[\[)\s*(.*?)\s*(\]\])/o) do diff --git a/Master/texmf-dist/scripts/context/ruby/base/kpse.rb b/Master/texmf-dist/scripts/context/ruby/base/kpse.rb index a4babae5505..0e185b5b8d7 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/kpse.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/kpse.rb @@ -64,8 +64,12 @@ module Kpse # @@distribution = 'miktex' if ENV['PATH'] =~ /miktex[\\\/]bin/o - if ENV['PATH'] =~ /(.*?)miktex[\\\/]bin/i then - @@distribution = 'miktex' unless $1 =~ /(texmf\-mswin[\/\\]bin|bin[\/\\]win32)/i + # if ENV['PATH'] =~ /(.*?)miktex[\\\/]bin/i then + # @@distribution = 'miktex' unless $1 =~ /(texmf\-mswin[\/\\]bin|bin[\/\\]win32)/i + # end + + if @@mswindows && (ENV['PATH'] =~ /(.*?)miktex[\\\/]bin/i) then + @@distribution = 'miktex' unless $1 =~ /(texmf\-mswin[\/\\]bin|bin[\/\\]win32)/i end @@re_true = /yes|on|true|1/i diff --git a/Master/texmf-dist/scripts/context/ruby/base/merge.rb b/Master/texmf-dist/scripts/context/ruby/base/merge.rb index c6ea6c09e66..a66b97e916b 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/merge.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/merge.rb @@ -38,7 +38,7 @@ module SelfMerge @@modules = $".collect do |file| File.expand_path(file) end @@modules.delete_if do |file| - file !~ /^#{@@ownpath}\/#{@@modroot}.*$/ + file !~ /^#{@@ownpath}\/#{@@modroot}.*$/i end def SelfMerge::ok? @@ -65,7 +65,7 @@ module SelfMerge end inserts << "#{@@kpsemergestop}\n\n" # no gsub! else we end up in SelfMerge - rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/mois) do + rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/moi) do inserts end rbfile.gsub!(/^(.*)(require [\"\'].*?#{@@modroot}.*)$/) do @@ -99,7 +99,7 @@ module SelfMerge begin if rbfile = IO.read(@@filename) then begin - rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/mois) do + rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/moi) do "#{@@kpsemergestart}\n\n#{@@kpsemergestop}\n\n" end rbfile.gsub!(/^(.*#{@@kpsemergedone}.*)$/) do diff --git a/Master/texmf-dist/scripts/context/ruby/base/mp.rb b/Master/texmf-dist/scripts/context/ruby/base/mp.rb index 5dd2948cffc..d168bde1d43 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/mp.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/mp.rb @@ -144,7 +144,7 @@ EOT result.gsub!(/(.{80,})(\-\-\-|\-\-|\.\.\.|\.\.)/) do "#{$1}#{$2}\n" end - result.gsub!(/\n[\s\n]+/mois) do + result.gsub!(/\n[\s\n]+/moi) do "\n" end result.gsub!(/btex\((\d+)\)/) do diff --git a/Master/texmf-dist/scripts/context/ruby/base/pdf.rb b/Master/texmf-dist/scripts/context/ruby/base/pdf.rb index 9f4e9a6c3f6..5aec06fc50c 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/pdf.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/pdf.rb @@ -7,7 +7,7 @@ module PDFview @method = 'default' # 'xpdf' - @opencalls['default'] = "pdfopen --file" + @opencalls['default'] = "pdfopen --file" # "pdfopen --back --file" @opencalls['xpdf'] = "xpdfopen" @closecalls['default'] = "pdfclose --file" diff --git a/Master/texmf-dist/scripts/context/ruby/base/system.rb b/Master/texmf-dist/scripts/context/ruby/base/system.rb index 267a22cb98f..c3fb08645a7 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/system.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/system.rb @@ -30,7 +30,7 @@ module System def System.null - if @@mswindows then 'nul' else '/dev/null/' end + if @@mswindows then 'nul' else '/dev/null' end end def System.unix? diff --git a/Master/texmf-dist/scripts/context/ruby/base/tex.rb b/Master/texmf-dist/scripts/context/ruby/base/tex.rb index 8c5cc63ef53..582ff640c6e 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/tex.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/tex.rb @@ -72,6 +72,7 @@ class TEX @@backends = Hash.new @@mappaths = Hash.new @@runoptions = Hash.new + @@tcxflag = Hash.new @@draftoptions = Hash.new @@texformats = Hash.new @@mpsformats = Hash.new @@ -89,29 +90,12 @@ class TEX @@luafiles = "luafiles.tmp" @@luatarget = "lua/context" - # we now drop pdfetex definitely - - # ENV['PATH'].split(File::PATH_SEPARATOR).each do |p| - # if System.unix? then - # pp, pe = "#{p}/pdftex" , "#{p}/pdfetex" - # else - # pp, pe = "#{p}/pdftex.exe", "#{p}/pdfetex.exe" - # end - # if FileTest.file?(pe) then # we assume no update - # @@pdftex = 'pdfetex' - # break - # elsif FileTest.file?(pp) then # we assume an update - # @@pdftex = 'pdftex' - # break - # end - # end - - # ['etex','pdfetex','standard'] .each do |e| @@texengines[e] = @@pdftex end - # ['tex','pdftex'] .each do |e| @@texengines[e] = 'pdftex' end + @@platformslash = if System.unix? then "\\\\" else "\\" end ['tex','etex','pdftex','pdfetex','standard'] .each do |e| @@texengines[e] = 'pdftex' end ['aleph','omega'] .each do |e| @@texengines[e] = 'aleph' end ['xetex'] .each do |e| @@texengines[e] = 'xetex' end + ['petex'] .each do |e| @@texengines[e] = 'petex' end ['luatex'] .each do |e| @@texengines[e] = 'luatex' end ['metapost','mpost', 'standard'] .each do |e| @@mpsengines[e] = 'mpost' end @@ -119,6 +103,8 @@ class TEX ['pdfetex','pdftex','pdf','pdftex','standard'] .each do |b| @@backends[b] = 'pdftex' end ['dvipdfmx','dvipdfm','dpx','dpm'] .each do |b| @@backends[b] = 'dvipdfmx' end ['xetex','xtx'] .each do |b| @@backends[b] = 'xetex' end + ['petex'] .each do |b| @@backends[b] = 'dvipdfmx' end + ['aleph'] .each do |b| @@backends[b] = 'dvipdfmx' end ['dvips','ps','dvi'] .each do |b| @@backends[b] = 'dvips' end ['dvipsone'] .each do |b| @@backends[b] = 'dvipsone' end ['acrobat','adobe','distiller'] .each do |b| @@backends[b] = 'acrobat' end @@ -126,7 +112,7 @@ class TEX ['tex','standard'] .each do |b| @@mappaths[b] = 'dvips' end ['pdftex','pdfetex'] .each do |b| @@mappaths[b] = 'pdftex' end - ['aleph','omega','xetex'] .each do |b| @@mappaths[b] = 'dvipdfm' end + ['aleph','omega','xetex','petex'] .each do |b| @@mappaths[b] = 'dvipdfm' end ['dvipdfm', 'dvipdfmx', 'xdvipdfmx'] .each do |b| @@mappaths[b] = 'dvipdfm' end ['xdv','xdv2pdf'] .each do |b| @@mappaths[b] = 'dvips' end @@ -148,34 +134,40 @@ class TEX ['plain','mpost'] .each do |f| @@mpsformats[f] = 'plain' end ['metafun','context','standard'] .each do |f| @@mpsformats[f] = 'metafun' end - # no 'standard' progname ! / beware, when using texexec we always use the context/metafun values - - ['pdftex','pdfetex','aleph','omega', + ['pdftex','pdfetex','aleph','omega','petex', 'xetex','luatex'] .each do |p| @@prognames[p] = 'context' end ['mpost'] .each do |p| @@prognames[p] = 'metafun' end + ['latex','pdflatex'] .each do |p| @@prognames[p] = 'latex' end ['plain','default','standard','mptopdf'] .each do |f| @@texmethods[f] = 'plain' end ['cont-en','cont-nl','cont-de','cont-it', 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texmethods[f] = 'context' end - ['latex'] .each do |f| @@texmethods[f] = 'latex' end + ['latex','pdflatex'] .each do |f| @@texmethods[f] = 'latex' end ['plain','default','standard'] .each do |f| @@mpsmethods[f] = 'plain' end ['metafun'] .each do |f| @@mpsmethods[f] = 'metafun' end - @@texmakestr['plain'] = "\\dump" - @@mpsmakestr['plain'] = "\\dump" + @@texmakestr['plain'] = @@platformslash + "dump" + @@mpsmakestr['plain'] = @@platformslash + "dump" ['cont-en','cont-nl','cont-de','cont-it', - 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = "\\emergencyend" end + 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = @@platformslash + "emergencyend" end - # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass - # @@runoptions['xetex'] = ['--8bit','-no-pdf'] # from now on we assume (x)dvipdfmx to be used - @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"'] - @@runoptions['pdfetex'] = ['--8bit'] # obsolete - @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex - @@runoptions['luatex'] = ['--file-line-error'] @@runoptions['aleph'] = ['--8bit'] + @@runoptions['luatex'] = ['--file-line-error'] @@runoptions['mpost'] = ['--8bit'] + @@runoptions['pdfetex'] = ['--8bit'] # obsolete + @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex + # @@runoptions['petex'] = [] + @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"'] + + @@tcxflag['aleph'] = true + @@tcxflag['luatex'] = false + @@tcxflag['mpost'] = true + @@tcxflag['pdfetex'] = true + @@tcxflag['pdftex'] = true + @@tcxflag['petex'] = false + @@tcxflag['xetex'] = false @@draftoptions['pdftex'] = ['--draftmode'] @@ -480,8 +472,10 @@ class TEX def validprogname(str) if str then [str].flatten.each do |s| + s = s.sub(/\.\S*/,"") return @@prognames[s] if @@prognames.key?(s) end + return str[0].sub(/\.\S*/,"") else return nil end @@ -497,11 +491,7 @@ class TEX else return "" end if format then - # if engine then - # "#{prefix}=#{engine}/#{format}" - # else - "#{prefix}=#{format}" - # end + "#{prefix}=#{format.sub(/\.\S+$/,"")}" else prefix end @@ -542,11 +532,16 @@ class TEX "--ini" end end - def tcxflag(file="natural.tcx") - if Kpse.miktex? then - "-tcx=#{file}" + def tcxflag(engine) + if @@tcxflag[engine] then + file = "natural.tcx" + if Kpse.miktex? then + "-tcx=#{file}" + else + "-translate-file=#{file}" + end else - "-translate-file=#{file}" + "" end end @@ -582,7 +577,7 @@ class TEX if data = (IO.readlines(@@luafiles) rescue nil) then report("compiling lua files (using #{File.expand_path(@@luafiles)})") begin - Dir.makedirs(@@luatarget) rescue false + File.makedirs(@@luatarget) rescue false data.each do |line| luafile = line.chomp lucfile = File.basename(luafile).gsub(/\..*?$/,'') + ".luc" @@ -612,15 +607,12 @@ class TEX report('using existing database') else report('updating file database') - Kpse.update + Kpse.update # obsolete here if getvariable('luatex') then begin - luatools = `texmfstart luatools --format=texmfscripts luatools.lua`.chomp.strip - unless luatools.empty? then - runcommand(["luatex","--luaonly #{luatools}","--generate","--verbose"]) - end + runcommand(["luatools","--generate","--verbose"]) rescue - report("run 'luatex --luaonly pathto/luatools.lua --generate' manually") + report("run 'luatools --generate' manualy") exit end end @@ -666,12 +658,13 @@ class TEX texformats.each do |texformat| report("generating tex format #{texformat}") progname = validprogname([getvariable('progname'),texformat,texengine]) - runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)]) + runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)]) end end else report("unable to make format due to lack of permissions") texformatpath = '' + setvariable('error','no permissions to write') end else texformatpath = '' @@ -686,7 +679,7 @@ class TEX mpsformats.each do |mpsformat| report("generating mps format #{mpsformat}") progname = validprogname([getvariable('progname'),mpsformat,mpsengine]) - if not runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) then + if not runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag(mpsengine),runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) then setvariable('error','no format made') end end @@ -783,12 +776,12 @@ class TEX result = runtexexec([tempfilename], flags, 1) if FileTest.file?("#{@@temprunfile}.log") then logdata = IO.read("#{@@temprunfile}.log") - if logdata =~ /^\s*This is (.*?)[\s\,]+(.*?)$/mois then + if logdata =~ /^\s*This is (.*?)[\s\,]+(.*?)$/moi then if validtexengine($1.downcase) then results.push("#{$1} #{$2.gsub(/\(format.*$/,'')}".strip) end end - if logdata =~ /^\s*(ConTeXt)\s+(.*int:\s+[a-z]+.*?)\s*$/mois then + if logdata =~ /^\s*(ConTeXt)\s+(.*int:\s+[a-z]+.*?)\s*$/moi then results.push("#{$1} #{$2}".gsub(/\s+/,' ').strip) end else @@ -817,12 +810,12 @@ class TEX private - def makeuserfile + def makeuserfile # not used in luatex (yet) language = getvariable('language') mainlanguage = getvariable('mainlanguage') bodyfont = getvariable('bodyfont') if f = openedfile("cont-fmt.tex") then - f << "\\unprotect" + f << "\\unprotect\n" case language when 'all' then f << "\\preloadallpatterns\n" @@ -910,9 +903,14 @@ class TEX end if ok then # we have a valid line + @@preamblekeys.each do |v| setvariable(v[1],vars[v[0]]) if vars.key?(v[0]) && vars[v[0]] end + +if getvariable('given.backend') == "standard" or getvariable('given.backend') == "" then + setvariable('backend',@@backends[getvariable('texengine')] || 'standard') +end break end else @@ -932,7 +930,8 @@ class TEX case str.chomp when /^\%/o then # next - when /\\(starttekst|stoptekst|startonderdeel|startdocument|startoverzicht)/o then + # when /\\(starttekst|stoptekst|startonderdeel|startdocument|startoverzicht)/o then + when /\\(starttekst|stoptekst|startonderdeel|startoverzicht)/o then setvariable('texformats','nl') ; break when /\\(stelle|verwende|umgebung|benutze)/o then setvariable('texformats','de') ; break @@ -1104,8 +1103,10 @@ class TEX end rescue TimeoutError report("job aborted due to timeout '#{delay}'") + setvariable('error','timeout') rescue report("job aborted due to error") + setvariable('error','fatal error') else report("job finished within timeout '#{delay}'") end @@ -1153,18 +1154,22 @@ class TEX public - def run_luatools(args) + # def run_luatools(args) # dirty trick: we know that the lua path is relative to the ruby path; of course this # will not work well when stubs are used - [(ENV["_CTX_K_S_texexec_"] or ENV["_CTX_K_S_THREAD_"] or ENV["TEXMFSTART.THREAD"]), File.dirname($0)].each do |path| - if path then - script = "#{path}/../lua/luatools.lua" - if FileTest.file?(script) then - return runcommand("luatex --luaonly #{script} #{args}") - end - end - end - return runcommand("texmfstart luatools #{args}") + # [(ENV["_CTX_K_S_texexec_"] or ENV["_CTX_K_S_THREAD_"] or ENV["TEXMFSTART.THREAD"]), File.dirname($0)].each do |path| + # if path then + # script = "#{path}/../lua/luatools.lua" + # if FileTest.file?(script) then + # return runcommand("luatex --luaonly #{script} #{args}") + # end + # end + # end + # return runcommand("texmfstart luatools #{args}") + # end + + def run_luatools(args) + return runcommand("luatools #{args}") end def processmpgraphic @@ -1182,7 +1187,7 @@ class TEX begin data = IO.read(File.suffixed(filename,'log')) basename = filename.sub(/\.mp$/, '') - if data =~ /output files* written\:\s*(.*)$/mois then + if data =~ /output files* written\:\s*(.*)$/moi then files, number, range, list = $1.split(/\s+/), 0, false, [] files.each do |fname| if fname =~ /^.*\.(\d+)$/ then @@ -1268,7 +1273,7 @@ class TEX File.open("texexec.tex",'w') do |f| f << "\\setupoutput[pdftex]\n" f << "\\setupcolors[state=start]\n" - data.sub!(/^%mpenvironment\:\s*(.*?)$/mois) do + data.sub!(/^%mpenvironment\:\s*(.*?)$/moi) do f << $1 "\n" end @@ -1448,9 +1453,10 @@ class TEX end end opt << "\\protect\n"; - begin getvariable('filters' ).split(',').uniq.each do |f| opt << "\\useXMLfilter[#{f}]\n" end ; rescue ; end - begin getvariable('usemodules' ).split(',').uniq.each do |m| opt << "\\usemodule[#{m}]\n" end ; rescue ; end - begin getvariable('environments').split(',').uniq.each do |e| opt << "\\environment #{e}\n" end ; rescue ; end + # begin getvariable('modes' ).split(',').uniq.each do |e| opt << "\\enablemode [#{e}]\n" end ; rescue ; end + begin getvariable('filters' ).split(',').uniq.each do |f| opt << "\\useXMLfilter[#{f}]\n" end ; rescue ; end + begin getvariable('usemodules' ).split(',').uniq.each do |m| opt << "\\usemodule [#{m}]\n" end ; rescue ; end + begin getvariable('environments').split(',').uniq.each do |e| opt << "\\environment #{e} \n" end ; rescue ; end # this will become: # begin getvariable('environments').split(',').uniq.each do |e| opt << "\\useenvironment[#{e}]\n" end ; rescue ; end opt << "\\endinput\n" @@ -1485,7 +1491,14 @@ class TEX [getvariable('runpath'),getvariable('path')].each do |pat| unless pat.empty? then if ENV.key?(res) then - ENV[res] = if ENV[res].empty? then pat else pat + ":" + ENV[res] end + # ENV[res] = if ENV[res].empty? then pat else pat + ":" + ENV[res] end +if ENV[res].empty? then + ENV[res] = pat +elsif ENV[res] == pat || ENV[res] =~ /^#{pat}\:/ || ENV[res] =~ /\:#{pat}\:/ then + # skip +else + ENV[res] = pat + ":" + ENV[res] +end else ENV[res] = pat end @@ -1544,7 +1557,7 @@ class TEX run_luatools("--fmt=#{texformat} #{filename}") else progname = validprogname([getvariable('progname'),texformat,texengine]) - runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)]) + runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)]) end # true else @@ -1559,8 +1572,7 @@ class TEX if mpsengine && mpsformat then ENV["MPXCOMMAND"] = "0" unless mpx progname = validprogname([getvariable('progname'),mpsformat,mpsengine]) - runcommand([quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) - # runcommand([quoted(mpsengine),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) + runcommand([quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag(mpsengine),runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) true else false @@ -1728,14 +1740,9 @@ class TEX takeprecautions report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose') + rawname = getvariable('filename') jobname = getvariable('filename') - suffix = getvariable('suffix') - result = getvariable('result') - forcexml = getvariable('forcexml') - runonce = getvariable('once') - finalrun = getvariable('final') || (getvariable('arrange') && ! getvariable('noarrange')) - globalfile = getvariable('globalfile') if getvariable('autopath') then jobname = File.basename(jobname) @@ -1748,18 +1755,11 @@ class TEX jobname = File.unixfied(jobname) inppath = File.unixfied(inppath) - result = File.unixfied(result) orisuffix = jobsuffix # still needed ? - setvariable('nomprun',true) if orisuffix == 'mpx' # else cylic run - - PDFview.setmethod('xpdf') if getvariable('xpdf') - - PDFview.closeall if getvariable('autopdf') - if jobsuffix =~ /^(htm|html|xhtml|xml|fo|fox|rlg|exa)$/io then - forcexml = true + setvariable('forcexml',true) end dummyfile = false @@ -1776,7 +1776,6 @@ class TEX # we can have funny names, like 2005.10.10 (given without suffix) rawname = jobname + '.' + jobsuffix - rawpath = File.dirname(rawname) rawbase = File.basename(rawname) @@ -1786,16 +1785,22 @@ class TEX end end - if dummyfile || forcexml then + forcexml = getvariable('forcexml') + + if dummyfile || forcexml then # after ctx? jobsuffix = makestubfile(rawname,rawbase,forcexml) checkxmlfile(rawname) end - # preprocess files unless getvariable('noctx') then ctx = CtxRunner.new(rawname,@logger) + if pth = getvariable('path') then + pth.split(',').each do |p| + ctx.register_path(p) + end + end if getvariable('ctxfile').empty? then if rawname == rawbase then ctx.manipulate(File.suffixed(rawname,'ctx'),'jobname.ctx') @@ -1810,6 +1815,7 @@ class TEX envs = ctx.environments mods = ctx.modules flags = ctx.flags + mdes = ctx.modes flags.each do |f| f.sub!(/^\-+/,'') @@ -1825,24 +1831,47 @@ class TEX # merge environment and module specs envs << getvariable('environments') unless getvariable('environments').empty? - mods << getvariable('modules') unless getvariable('modules') .empty? + mods << getvariable('usemodules') unless getvariable('usemodules') .empty? + mdes << getvariable('modes') unless getvariable('modes') .empty? envs = envs.uniq.join(',') mods = mods.uniq.join(',') + mdes = mdes.uniq.join(',') report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose') + report("using environments #{envs}") if envs.length > 0 report("using modules #{mods}") if mods.length > 0 + report("using modes #{mdes}") if mdes.length > 0 setvariable('environments', envs) - setvariable('modules', mods) + setvariable('usemodules', mods) + setvariable('modes', mdes) end # end of preprocessing and merging + setvariable('nomprun',true) if orisuffix == 'mpx' # else cylic run + PDFview.setmethod('xpdf') if getvariable('xpdf') + PDFview.closeall if getvariable('autopdf') + + runonce = getvariable('once') + finalrun = getvariable('final') || (getvariable('arrange') && ! getvariable('noarrange')) + suffix = getvariable('suffix') + result = getvariable('result') + globalfile = getvariable('globalfile') + forcexml = getvariable('forcexml') # can be set in ctx file + +if dummyfile || forcexml then # after ctx? + jobsuffix = makestubfile(rawname,rawbase,forcexml) + checkxmlfile(rawname) +end + + result = File.unixfied(result) + if globalfile || FileTest.file?(rawname) then - if not dummyfile and not globalfile then + if not dummyfile and not globalfile and not forcexml then scantexpreamble(rawname) scantexcontent(rawname) if getvariable('texformats').standard? end @@ -1897,7 +1926,15 @@ class TEX end end # goto . + ok = runtex(File.suffixed(if dummyfile || forcexml then rawbase else rawname end,jobsuffix)) + +if getvariable('texengine') == "xetex" then + ok = true +end + +############################ + # goto tmp/jobname when present if ok && (nofruns > 1) then unless getvariable('nompmode') then @@ -1951,7 +1988,7 @@ class TEX # next line is empty ok = 2 when 2 then - if line =~ /^\%\s+\>\s+(.*?)\s+(\d+)/mois then + if line =~ /^\%\s+\>\s+(.*?)\s+(\d+)/moi then filename, n = $1, $2 done = File.delete(filename) rescue false if done && getvariable('verbose') then @@ -1961,7 +1998,7 @@ class TEX break end else - if line =~ /^\%\s+temporary files\:\s+(\d+)/mois then + if line =~ /^\%\s+temporary files\:\s+(\d+)/moi then if $1.to_i == 0 then break else @@ -2021,7 +2058,7 @@ class TEX setvariable('mp.line','') setvariable('mp.error','') if mpdata = File.silentread(mpname) then - mpdata.gsub!(/^\#.*\n/o,'') + mpdata.gsub!(/^\%.*\n/o,'') File.silentrename(mpname,mpcopy) texfound = mergebe || (mpdata =~ /btex .*? etex/mo) if mp = openedfile(mpname) then diff --git a/Master/texmf-dist/scripts/context/ruby/base/texutil.rb b/Master/texmf-dist/scripts/context/ruby/base/texutil.rb index 7c402b98f85..063f67f2d38 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/texutil.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/texutil.rb @@ -187,7 +187,14 @@ class TeXUtil # shortcut("\\\"e", 'ediaeresis') # shortcut("\\\'o", 'oacute') + def hextoutf(str) + str.gsub(/^(0x[A-F\d]+)$/) do + [$1.hex()].pack("U") + end + end + def shortcut(from,to) + from = hextoutf(from) replacer(from,to) expander(to) end @@ -400,7 +407,7 @@ class TeXUtil def MyCommands::writer(logger,handle) handle << logger.banner("commands: #{@@commands.size}") @@commands.each do |c| - handle << "#{c}\n" + handle << "#{c}%\n" end end @@ -433,8 +440,8 @@ class TeXUtil def MyExtras::writer(logger,handle) handle << logger.banner("programs: #{@@programs.size}") - @@programs.each do |p| - handle << "% #{p} (#{@@programs[p.to_i]})\n" + @@programs.each_with_index do |cmd, p| + handle << "% #{p+1} (#{cmd})\n" end end @@ -447,10 +454,11 @@ class TeXUtil end def MyExtras::finalizer(logger) - @@programs.each do |p| - cmd = @@programs[p.to_i] - logger.report("running #{cmd}") - system(cmd) + unless (ENV["CTX.TEXUTIL.EXTRAS"] =~ /^(no|off|false|0)$/io) || (ENV["CTX_TEXUTIL_EXTRAS"] =~ /^(no|off|false|0)$/io) then + @@programs.each do |cmd| + logger.report("running #{cmd}") + system(cmd) + end end end @@ -493,7 +501,7 @@ class TeXUtil end end list.each do |entry| - handle << "\\synonymentry{#{entry.type}}{#{entry.command}}{#{entry.key}}{#{entry.data}}\n" + handle << "\\synonymentry{#{entry.type}}{#{entry.command}}{#{entry.key}}{#{entry.data}}%\n" end end @@ -601,7 +609,7 @@ class TeXUtil end else # @entry, @key = cleanupsplit(@entry), cleanupsplit(@key) -@entry, @key = cleanupsplit(@entry), xcleanupsplit(@key) + @entry, @key = cleanupsplit(@entry), xcleanupsplit(@key) end @sortkey = sorter.simplify(@key) # special = @sortkey =~ /^([^a-zA-Z\\])/o @@ -631,23 +639,23 @@ class TeXUtil end end -def xcleanupsplit(target) # +a+b+c &a&b&c a+b+c a&b&c - t = Array.new - case target[0,1] - when '&' then - t = target.sub(/^./o,'').split(/([^\\])\&/o) - when '+' then - t = target.sub(/^./o,'').split(/([^\\])\+/o) - else - # t = target.split(/([^\\])[\&\+]/o) - # t = target.split(/[\&\+]/o) - t = target.split(/(?!\\)[\&\+]/o) # lookahead - end - if not t[1] then t[1] = " " end # we need some entry else we get subentries first - if not t[2] then t[2] = " " end # we need some entry else we get subentries first - return t.join(@@split) -end - + def xcleanupsplit(target) # +a+b+c &a&b&c a+b+c a&b&c + t = Array.new + case target[0,1] + when '&' then + t = target.sub(/^./o,'').split(/([^\\])\&/o) + when '+' then + t = target.sub(/^./o,'').split(/([^\\])\+/o) + else + # t = target.split(/([^\\])[\&\+]/o) + # t = target.split(/[\&\+]/o) + t = target.split(/(?!\\)[\&\+]/o) # lookahead + end + if not t[1] then t[1] = " " end # we need some entry else we get subentries first + if not t[2] then t[2] = " " end # we need some entry else we get subentries first + if not t[3] then t[3] = " " end # we need some entry else we get subentries first + return t.join(@@split) + end def <=> (other) @sortkey <=> other.sortkey end @@ -660,10 +668,10 @@ end def Register.flushsavedline(handle) if @@collapse && ! @@savedfrom.empty? then if ! @@savedto.empty? then - handle << "\\registerfrom#{@@savedfrom}" - handle << "\\registerto#{@@savedto}" + handle << "\\registerfrom#{@@savedfrom}%" + handle << "\\registerto#{@@savedto}%" else - handle << "\\registerpage#{@@savedfrom}" + handle << "\\registerpage#{@@savedfrom}%" end end @@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', '' @@ -710,10 +718,10 @@ end else character = "\\unknown" end - handle << "\\registerentry{#{entry.type}}{#{character}}\n" + handle << "\\registerentry{#{entry.type}}{#{character}}%\n" end end - current = [entry.entry.split(@@split),'','',''].flatten + current = [entry.entry.split(@@split),'','','',''].flatten howto = current.collect do |e| e + '::' + entry.texthowto end @@ -723,38 +731,51 @@ end previous[0] = howto[0].dup previous[1] = '' previous[2] = '' + previous[3] = '' end if howto[1] == previous[1] then current[1] = '' else previous[1] = howto[1].dup previous[2] = '' + previous[3] = '' end if howto[2] == previous[2] then current[2] = '' else previous[2] = howto[2].dup + previous[3] = '' + end + if howto[3] == previous[3] then + current[3] = '' + else + previous[3] = howto[3].dup end copied = false unless current[0].empty? then Register.flushsavedline(handle) - handle << "\\registerentrya{#{entry.type}}{#{current[0]}}\n" + handle << "\\registerentrya{#{entry.type}}{#{current[0]}}%\n" copied = true end unless current[1].empty? then Register.flushsavedline(handle) - handle << "\\registerentryb{#{entry.type}}{#{current[1]}}\n" + handle << "\\registerentryb{#{entry.type}}{#{current[1]}}%\n" copied = true end unless current[2].empty? then Register.flushsavedline(handle) - handle << "\\registerentryc{#{entry.type}}{#{current[2]}}\n" + handle << "\\registerentryc{#{entry.type}}{#{current[2]}}%\n" + copied = true + end + unless current[3].empty? then + Register.flushsavedline(handle) + handle << "\\registerentryd{#{entry.type}}{#{current[3]}}%\n" copied = true end @nofentries += 1 if copied if entry.realpage.to_i == 0 then Register.flushsavedline(handle) - handle << "\\registersee{#{entry.type}}{#{entry.pagehowto},#{entry.texthowto}}{#{entry.seetoo}}{#{entry.page}}\n" ; + handle << "\\registersee{#{entry.type}}{#{entry.pagehowto},#{entry.texthowto}}{#{entry.seetoo}}{#{entry.page}}%\n" ; lastpage, lastrealpage = entry.page, entry.realpage copied = false # no page ! elsif @@savedhowto != entry.pagehowto and ! entry.pagehowto.empty? then @@ -762,14 +783,14 @@ end end # beware, we keep multiple page entries per realpage because of possible prefix usage if copied || ! ((lastpage == entry.page) && (lastrealpage == entry.realpage)) then - nextentry = "{#{entry.type}}{#{previous[0]}}{#{previous[1]}}{#{previous[2]}}{#{entry.pagehowto},#{entry.texthowto}}" + nextentry = "{#{entry.type}}{#{previous[0]}}{#{previous[1]}}{#{previous[2]}}{#{previous[3]}}{#{entry.pagehowto},#{entry.texthowto}}" savedline = "{#{entry.type}}{#{@@savedhowto},#{entry.texthowto}}{#{entry.location}}{#{entry.page}}{#{entry.realpage}}" if entry.state == 1 then # from Register.flushsavedline(handle) - handle << "\\registerfrom#{savedline}\n" + handle << "\\registerfrom#{savedline}%\n" elsif entry.state == 3 then # to Register.flushsavedline(handle) - handle << "\\registerto#{savedline}\n" + handle << "\\registerto#{savedline}%\n" @@savedhowto = '' # test elsif @@collapse then if savedentry != nextentry then @@ -778,7 +799,7 @@ end savedTo, savedentry = savedline, nextentry end else - handle << "\\registerpage#{savedline}\n" + handle << "\\registerpage#{savedline}%\n" @@savedhowto = '' # test end @nofpages += 1 @@ -1026,6 +1047,7 @@ end begin if f = File.open(File.suffixed(filename,'tuo'),'w') then @plugins.writers(f) + f << "\\endinput\n" f.close end rescue diff --git a/Master/texmf-dist/scripts/context/ruby/base/tool.rb b/Master/texmf-dist/scripts/context/ruby/base/tool.rb index 77ad947fe1e..5ccedfec1c1 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/tool.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/tool.rb @@ -129,6 +129,8 @@ module Tool def Tool.simplefilename(old) + return old # too fragile + return old if not FileTest.file?(old) new = old.downcase @@ -258,7 +260,7 @@ module Tool new = checksuffix(simplefilename(old)) unless new == old - begin + begin # bugged, should only be name, not path File.rename(old,new) logging.report("renaming fuzzy name #{old} to #{new}") unless logging return old diff --git a/Master/texmf-dist/scripts/context/ruby/concheck.rb b/Master/texmf-dist/scripts/context/ruby/concheck.rb index 6c7512bff8f..3db3e5148bf 100644 --- a/Master/texmf-dist/scripts/context/ruby/concheck.rb +++ b/Master/texmf-dist/scripts/context/ruby/concheck.rb @@ -308,7 +308,7 @@ def some_wrd_error(data, filename, start, stop, ignore) end end -def some_sym_error (data, filename, symbol,template=false) +def some_sym_error (data, filename, symbol, template=false) saved = Array.new inside = false level = 0 diff --git a/Master/texmf-dist/scripts/context/ruby/ctxtools.rb b/Master/texmf-dist/scripts/context/ruby/ctxtools.rb index b306ee5dc43..00d2b494bb0 100644 --- a/Master/texmf-dist/scripts/context/ruby/ctxtools.rb +++ b/Master/texmf-dist/scripts/context/ruby/ctxtools.rb @@ -44,7 +44,7 @@ # it cannot do that (it tries to hyphenate as if the "ffi" was a # character), and the result is wrong hyphenation. -banner = ['CtxTools', 'version 1.3.3', '2004/2006', 'PRAGMA ADE/POD'] +banner = ['CtxTools', 'version 1.3.5', '2004/2008', 'PRAGMA ADE'] $: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq! @@ -334,7 +334,7 @@ class Commands report("generating #{keyfile}") begin - one = "texexec --make --alone --all #{interface}" + one = "texexec --make --all #{interface}" two = "texexec --batch --silent --interface=#{interface} x-set-01" if @commandline.option("force") then system(one) @@ -534,7 +534,7 @@ class Commands ] $dontasksuffixes = [ "mp(graph|run)\\.mp", "mp(graph|run)\\.mpd", "mp(graph|run)\\.mpo", "mp(graph|run)\\.mpy", - "mp(graph|run)\\.\\d+", + "mp(graph|run)\\.\\d+", "mp(graph|run)\\.mp.keep", "xlscript\\.xsl" ] $forsuresuffixes = [ @@ -866,6 +866,7 @@ class Language @filenames = filenames @remapping = Array.new @demapping = Array.new + @cloning = Array.new @unicode = Hash.new @encoding = encoding @data = '' @@ -895,6 +896,9 @@ class Language def demap(from, to) @demapping.push([from,to]) end + def clone(from, to) + @cloning.push([from,to]) + end def load(filenames=@filenames) found = false @@ -908,7 +912,7 @@ class Language @data += data.gsub(/\%.*$/, '').gsub(/\\message\{.*?\}/, '') data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end @read += "\n% preamble of file #{fname}\n\n#{data}\n" - @data.gsub!(/^[\s\n]+$/mois, '') + @data.gsub!(/^[\s\n]+$/moi, '') report("file #{fname} is loaded") found = true break # next fileset @@ -957,6 +961,22 @@ class Language @remapping[$1.to_i][1] end report(" nothing remapped") unless done + @cloning.each_index do |i| + c = 0 + f, s = @cloning[i][0], @cloning[i][1] + str = "#{f}|#{s}" + str.gsub!(/([\[\]])/) do "\\" + "#{$1}" end + reg = /(#{str})/ + content.gsub!(/(\S*(#{str})\S*)/) do + a, b = $1, $1 + a.gsub!(reg, f) + b.gsub!(reg, s) + c = c + 1 + "#{a} #{b}" + end + report("#{c.to_s.rjust(5)} times #{f} cloned to #{s}") + n += c + end report("") content.to_s end @@ -1300,6 +1320,14 @@ class Language remap(/\\a\s*/, "[aeligature]") remap(/\\o\s*/, "[oeligature]") when 'agr' then + # bug fix + remap("a2|", "[greekalphaiotasub]") + remap("h2|", "[greeketaiotasub]") + remap("w2|", "[greekomegaiotasub]") + remap(">2r1<2r", "[2ῤ1ῥ]") + remap(">a2n1wdu'", "[ἀ2ν1ωδύ]") + remap(">e3s2ou'", "[ἐ3σ2ού]") + # main conversion remap(/\<\'a\|/, "[greekalphaiotasubdasiatonos]") # remap(/\<\'a\|/, "[greekdasiatonos][greekAlpha][greekiota]") remap(/\>\'a\|/, "[greekalphaiotasubpsilitonos]") @@ -1399,7 +1427,7 @@ class Language remap(/\<\'u/, "[greekupsilondasiatonos]") remap(/\>\'u/, "[greekupsilonpsilitonos]") remap(/\<\`u/, "[greekupsilondasiavaria]") - remap(/\>\'u/, "[greekupsilonpsilivaria]") + remap(/\>\`u/, "[greekupsilonpsilivaria]") remap(/\<\~u/, "[greekupsilondasiaperispomeni]") remap(/\>\~u/, "[greekupsilonpsiliperispomeni]") remap(/\"\'u/, "[greekupsilondialytikatonos]") @@ -1433,14 +1461,15 @@ class Language remap(/\"\'/, "[greekdialytikatonos]") remap(/\"\`/, "[greekdialytikavaria]") remap(/\"\~/, "[greekdialytikaperispomeni]") - remap(/\</, "[dasia]") - remap(/\>/, "[psili]") - remap(/\'/, "[oxia]") + remap(/\</, "[greekdasia]") + remap(/\>/, "[greekpsili]") + remap(/\d.{0,2}''/, "") + remap(/\'/, "[greekoxia]") remap(/\`/, "[greekvaria]") remap(/\~/, "[perispomeni]") - remap(/\"/, "[dialytika]") + remap(/\"/, "[greekdialytika]") # unknown - remap(/\|/, "[greekIotadialytika]") + # remap(/\|/, "[greekIotadialytika]") # next remap(/A/, "[greekAlpha]") remap(/B/, "[greekBeta]") @@ -1491,6 +1520,13 @@ class Language remap(/x/, "[greekxi]") remap(/y/, "[greekpsi]") remap(/z/, "[greekzeta]") + clone("[greekalphatonos]", "[greekalphaoxia]") + clone("[greekepsilontonos]", "[greekepsilonoxia]") + clone("[greeketatonos]", "[greeketaoxia]") + clone("[greekiotatonos]", "[greekiotaoxia]") + clone("[greekomicrontonos]", "[greekomicronoxia]") + clone("[greekupsilontonos]", "[greekupsilonoxia]") + clone("[greekomegatonos]", "[greekomegaoxia]") when 'ru' then remap(/\xC1/, "[cyrillica]") remap(/\xC2/, "[cyrillicb]") @@ -1602,14 +1638,14 @@ class Commands @@languagedata['da' ] = [ 'ec' , ['dkspecial.tex','dkcommon.tex'] ] # elhyph.tex @@languagedata['es' ] = [ 'ec' , ['eshyph.tex'] ] - @@languagedata['fi' ] = [ 'ec' , ['ethyph.tex'] ] + @@languagedata['et' ] = [ 'ec' , ['ethyph.tex'] ] @@languagedata['fi' ] = [ 'ec' , ['fihyph.tex'] ] @@languagedata['fr' ] = [ 'ec' , ['frhyph.tex'] ] # ghyphen.readme ghyph31.readme grphyph @@languagedata['hr' ] = [ 'ec' , ['hrhyph.tex'] ] @@languagedata['hu' ] = [ 'ec' , ['huhyphn.tex'] ] - @@languagedata['en' ] = [ 'default' , ['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex'] ] - @@languagedata['us' ] = [ 'default' , ['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex'] ] + @@languagedata['en' ] = [ 'default' , [['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex']] ] + @@languagedata['us' ] = [ 'default' , [['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex']] ] # inhyph.tex @@languagedata['is' ] = [ 'ec' , ['ishyph.tex'] ] @@languagedata['it' ] = [ 'ec' , ['ithyph.tex'] ] @@ -1617,12 +1653,12 @@ class Commands # mnhyph @@languagedata['nl' ] = [ 'ec' , ['nehyph96.tex'] ] # @@languagedata['no' ] = [ 'ec' , ['nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex'] ] - @@languagedata['no' ] = [ 'ec' , ['asxsx.tex','nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex'] ] - @@languagedata['agr'] = [ 'agr' , [['grahyph4.tex','oldgrhyph.tex']] ] # new, todo + @@languagedata['no' ] = [ 'ec' , [['asxsx.tex','nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex']] ] + @@languagedata['agr'] = [ 'agr' , [['grahyph4.tex'], ['oldgrhyph.tex']] ] # new, todo @@languagedata['pl' ] = [ 'ec' , ['plhyph.tex'] ] @@languagedata['pt' ] = [ 'ec' , ['pthyph.tex'] ] @@languagedata['ro' ] = [ 'ec' , ['rohyph.tex'] ] - @@languagedata['sl' ] = [ 'ec' , ['sihyph.tex'] ] + @@languagedata['sl' ] = [ 'ec' , [['slhyph.tex'], ['sihyph.tex']] ] @@languagedata['sk' ] = [ 'ec' , ['skhyphen.tex','skhyphen.ex'] ] # sorhyph.tex / upper sorbian # srhyphc.tex / cyrillic @@ -1639,19 +1675,22 @@ class Commands def dpxmapfiles - force = @commandline.option("force") + force = @commandline.option("force") texmfroot = @commandline.argument('first') texmfroot = '.' if texmfroot.empty? - maproot = "#{texmfroot.gsub(/\\/,'/')}/fonts/map/pdftex/context" - + if @commandline.option('maproot') != "" then + maproot = @commandline.option('maproot') + else + maproot = "#{texmfroot.gsub(/\\/,'/')}/fonts/map/pdftex/context" + end if File.directory?(maproot) then files = Dir.glob("#{maproot}/*.map") if 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')) + dpxfile = File.expand_path(pdffile.sub(/(dvips|pdftex)/i,'dvipdfm')) unless pdffile == dpxfile then begin if data = File.read(pdffile) then @@ -1737,7 +1776,7 @@ class Array def add_shebang(filename,program) unless self[0] =~ /^\#/ then - self.insert(0,"\#!/usr/env #{program}") + self.insert(0,"\#!/usr/bin/env #{program}") end unless self[2] =~ /^\#.*?copyright\=/ then self.insert(1,"\#") @@ -2238,7 +2277,7 @@ class TexDeps report('') n = 0 @files.each do |filename| - if f = File.open(filename) then + if File.file?(filename) and f = File.open(filename) then defs, uses, l = 0, 0, 0 n += 1 report("#{n.to_s.rjust(5,' ')} #{filename}") @@ -2592,7 +2631,17 @@ class Commands def fetchfile(site, name, target=nil) begin - http = Net::HTTP.new(site) + proxy = @commandline.option('proxy') + if proxy && ! proxy.empty? then + address, port = proxy.split(":") + if address && port then + http = Net::HTTP::Proxy(address, port).new(site) + else + http = Net::HTTP::Proxy(proxy, 80).new(site) + end + else + http = Net::HTTP.new(site) + end resp, data = http.get(name.gsub(/^\/*/, '/')) rescue return false @@ -2640,7 +2689,14 @@ class Commands end def remakeformats - return system("texmfstart texexec --make --all") + system("mktexlsr") + system("luatools --selfupdate") + system("mtxrun --selfupdate") + system("luatools --generate") + system("texmfstart texexec --make --all --fast --pdftex") + system("texmfstart texexec --make --all --fast --luatex") + system("texmfstart texexec --make --all --fast --xetex") + return true end if localtree = locatedlocaltree then @@ -2693,11 +2749,13 @@ commandline.registeraction('listentities' , 'create doctype entity definiti commandline.registeraction('brandfiles' , 'add context copyright notice [--force]') commandline.registeraction('platformize' , 'replace line-endings [--recurse --force] [pattern]') commandline.registeraction('dependencies' , 'analyze depedencies within context [--save --compact --filter=[macros|filenames]] [filename]') -commandline.registeraction('updatecontext' , 'download latest version and remake formats') +commandline.registeraction('updatecontext' , 'download latest version and remake formats [--proxy]') commandline.registeraction('disarmutfbom' , 'remove utf bom [--force]') commandline.registervalue('type','') commandline.registervalue('filter','') +commandline.registervalue('maproot','') +commandline.registervalue('proxy','') commandline.registerflag('recurse') commandline.registerflag('force') diff --git a/Master/texmf-dist/scripts/context/ruby/graphics/gs.rb b/Master/texmf-dist/scripts/context/ruby/graphics/gs.rb index 070fd1be85a..cb3d016f4cb 100644 --- a/Master/texmf-dist/scripts/context/ruby/graphics/gs.rb +++ b/Master/texmf-dist/scripts/context/ruby/graphics/gs.rb @@ -296,9 +296,9 @@ class GhostScript def gscolorswitch case getvariable('colormodel') - when 'cmyk' then '-dProcessColorModel=/DeviceCMYK ' - when 'rgb' then '-dProcessColorModel=/DeviceRGB ' - when 'gray' then '-dProcessColorModel=/DeviceGRAY ' + when 'cmyk' then '-dProcessColorModel=/DeviceCMYK -dColorConversionStrategy=/CMYK ' + when 'rgb' then '-dProcessColorModel=/DeviceRGB -dColorConversionStrategy=/RGB ' + when 'gray' then '-dProcessColorModel=/DeviceGRAY -dColorConversionStrategy=/GRAY ' else '' end @@ -452,10 +452,10 @@ class GhostScript debug('bbox spec', bbox) - if bbox =~ /(Exact|HiRes)BoundingBox:#{@@bboxspec}/mois then + if bbox =~ /(Exact|HiRes)BoundingBox:#{@@bboxspec}/moi then debug("high res bbox #{$2} #{$3} #{$4} #{$5}") setdimensions($2,$3,$4,$5) - elsif bbox =~ /BoundingBox:#{@@bboxspec}/mois + elsif bbox =~ /BoundingBox:#{@@bboxspec}/moi debug("low res bbox #{$1} #{$2} #{$3} #{$4}") setdimensions($1,$2,$3,$4) end @@ -570,7 +570,12 @@ end if ! epsbbox && str =~ /^%%(Page:|EndProlog)/io then out.puts(str) if $1 == "EndProlog" debug('faking papersize') - out.puts("<< /PageSize [#{@width} #{@height}] >> setpagedevice\n") + # out.puts("<< /PageSize [#{@width} #{@height}] >> setpagedevice\n") + if ! dimensions? then + out.puts("<< /PageSize [1 1] >> setpagedevice\n") + else + out.puts("<< /PageSize [#{@width} #{@height}] >> setpagedevice\n") + end out.puts("gsave #{@xoffset} #{@yoffset} translate\n") epsbbox = true elsif str =~ /^%%BeginBinary\:\s*\d+\s*$/o then diff --git a/Master/texmf-dist/scripts/context/ruby/graphics/inkscape.rb b/Master/texmf-dist/scripts/context/ruby/graphics/inkscape.rb index 4495c3070f4..8d3b2646826 100644 --- a/Master/texmf-dist/scripts/context/ruby/graphics/inkscape.rb +++ b/Master/texmf-dist/scripts/context/ruby/graphics/inkscape.rb @@ -43,6 +43,10 @@ class InkScape def convert(logfile=System.null) + directpdf = false + + logfile = logfile.gsub(/\/+$/,"") + inpfilename = getvariable('inputfile').dup outfilename = getvariable('outputfile').dup outfilename = inpfilename.dup if outfilename.empty? @@ -62,11 +66,15 @@ class InkScape return false end - report("converting #{inpfilename} to #{tmpfilename}") - # we need to redirect the error info else we get a pop up console - resultpipe = "--without-gui --print=\">#{tmpfilename}\" 2>#{logfile}" + if directpdf then + report("converting #{inpfilename} to #{outfilename}") + resultpipe = "--without-gui --export-pdf=\"#{outfilename}\" 2>#{logfile}" + else + report("converting #{inpfilename} to #{tmpfilename}") + resultpipe = "--without-gui --print=\">#{tmpfilename}\" 2>#{logfile}" + end arguments = [resultpipe,inpfilename].join(' ').gsub(/\s+/,' ') @@ -76,8 +84,11 @@ class InkScape # should work # ok = System.run('inkscape',arguments) # does not work here # but 0.40 only works with this: - ok = system("inkscape #{arguments}") + command = "inkscape #{arguments}" + report(command) + ok = system(command) # and 0.41 fails with everything + # and 0.45 is better rescue report("aborted due to error") return false @@ -85,18 +96,16 @@ class InkScape return false unless ok end - ghostscript = GhostScript.new(@logger) - - ghostscript.setvariable('inputfile',tmpfilename) - ghostscript.setvariable('outputfile',outfilename) - - report("converting #{tmpfilename} to #{outfilename}") - - ghostscript.convert - - begin - File.delete(tmpfilename) - rescue + if not directpdf then + ghostscript = GhostScript.new(@logger) + ghostscript.setvariable('inputfile',tmpfilename) + ghostscript.setvariable('outputfile',outfilename) + report("converting #{tmpfilename} to #{outfilename}") + ghostscript.convert + begin + File.delete(tmpfilename) + rescue + end end end diff --git a/Master/texmf-dist/scripts/context/ruby/mtxtools.rb b/Master/texmf-dist/scripts/context/ruby/mtxtools.rb index 7cbe68c0d4c..41d0f7085b1 100644 --- a/Master/texmf-dist/scripts/context/ruby/mtxtools.rb +++ b/Master/texmf-dist/scripts/context/ruby/mtxtools.rb @@ -1,426 +1,475 @@ -#!/usr/bin/env ruby
-
-# program : mtxtools
-# copyright : PRAGMA Advanced Document Engineering
-# version : 2004-2005
-# author : Hans Hagen
-#
-# info : j.hagen@xs4all.nl
-# www : www.pragma-ade.com
-
-# This script hosts MetaTeX related features.
-
-banner = ['MtxTools', 'version 1.0.0', '2006', 'PRAGMA ADE/POD']
-
-$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
-
-require 'base/switch'
-require 'base/logger'
-require 'base/system'
-require 'base/kpse'
-
-class Reporter
- def report(str)
- puts(str)
- end
-end
-
-module ConTeXt
-
- def ConTeXt::banner(filename,companionname,compact=false)
- "-- filename : #{File.basename(filename)}\n" +
- "-- comment : companion to #{File.basename(companionname)} (in ConTeXt)\n" +
- "-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL\n" +
- "-- copyright: PRAGMA ADE / ConTeXt Development Team\n" +
- "-- license : see context related readme files\n" +
- if compact then "\n-- remark : compact version\n" else "" end
- end
-
-end
-
-class UnicodeTables
-
- @@version = "1.001"
-
- @@shape_a = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)$/
- @@shape_b = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)\s*(.+)$/
-
- @@shape_a = /^(.*\s*LETTER\s*[A-Z]+)$/
- @@shape_b = /^(.*\s*LETTER\s*[A-Z]+)\s+WITH\s+(.+)$/
-
- attr_accessor :context, :comment
-
- def initialize(logger=Reporter.new)
- @data = Array.new
- @logger = logger
- @error = false
- @context = true
- @comment = true
- @shapes = Hash.new
- end
-
- def load_unicode_data(filename='unicodedata.txt')
- # beware, the unicodedata table is bugged, sometimes ending
- @logger.report("reading base data from #{filename}") if @logger
- begin
- IO.readlines(filename).each do |line|
- if line =~ /^[0-9A-F]{4,4}/ then
- d = line.chomp.sub(/\;$/, '').split(';')
- if d then
- while d.size < 15 do d << '' end
- n = d[0].hex
- @data[n] = d
- if d[1] =~ @@shape_a then
- @shapes[$1] = d[0]
- end
- end
- end
- end
- rescue
- @error = true
- @logger.report("error while reading base data from #{filename}") if @logger
- end
- end
-
- def load_context_data(filename='contextnames.txt')
- @logger.report("reading data from #{filename}") if @logger
- begin
- IO.readlines(filename).each do |line|
- if line =~ /^[0-9A-F]{4,4}/ then
- d = line.chomp.split(';')
- if d then
- n = d[0].hex
- if @data[n] then
- @data[d[0].hex] << d[1] # adobename == 15
- @data[d[0].hex] << d[2] # contextname == 16
- else
- @logger.report("missing information about #{d} in #{filename}") if @logger
- end
- end
- end
- end
- rescue
- @error = true
- @logger.report("error while reading context data from #{filename}") if @logger
- end
- end
-
- def save_metatex_data(filename='char-def.lua',compact=false)
- if not @error then
- begin
- File.open(filename,'w') do |f|
- @logger.report("saving data in #{filename}") if @logger
- f << ConTeXt::banner(filename,'char-def.tex',compact)
- f << "\n"
- f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n"
- f << "\n"
- f << "if not characters then characters = { } end\n"
- f << "if not characters.data then characters.data = { } end\n"
- f << "\n"
- f << "characters.data = {\n" if compact
- @data.each do |d|
- if d then
- r = metatex_data(d)
- if compact then
- f << "\t" << "[0x#{d[0]}]".rjust(8,' ') << " = { #{r.join(", ").gsub(/\t/,'')} }, \n"
- else
- f << "characters.define { -- #{d[0].hex}" << "\n"
- f << r.join(",\n") << "\n"
- f << "}" << "\n"
- end
- end
- end
- f << "}\n" if compact
- end
- rescue
- @logger.report("error while saving data in #{filename}") if @logger
- else
- @logger.report("#{@data.size} (#{sprintf('%X',@data.size)}) entries saved in #{filename}") if @logger
- end
- else
- @logger.report("not saving data in #{filename} due to previous error") if @logger
- end
- end
-
- def metatex_data(d)
- r = Array.new
- r << "\tunicodeslot=0x#{d[0]}"
- if d[2] && ! d[2].empty? then
- r << "\tcategory='#{d[2].downcase}'"
- end
- if @context then
- if d[15] && ! d[15].empty? then
- r << "\tadobename='#{d[15]}'"
- end
- if d[16] && ! d[16].empty? then
- r << "\tcontextname='#{d[16]}'"
- end
- end
- if @comment then
- if d[1] == "<control>" then
- r << "\tdescription='#{d[10]}'" unless d[10].empty?
- else
- r << "\tdescription='#{d[1]}'" unless d[1].empty?
- end
- end
- if d[1] =~ @@shape_b then
- r << "\tshcode=0x#{@shapes[$1]}" if @shapes[$1]
- end
- if d[12] && ! d[12].empty? then
- r << "\tuccode=0x#{d[12]}"
- elsif d[14] && ! d[14].empty? then
- r << "\tuccode=0x#{d[14]}"
- end
- if d[13] && ! d[13].empty? then
- r << "\tlccode=0x#{d[13]}"
- end
- if d[5] && ! d[5].empty? then
- special, specials = '', Array.new
- c = d[5].split(/\s+/).collect do |cc|
- if cc =~ /^\<(.*)\>$/io then
- special = $1.downcase
- else
- specials << "0x#{cc}"
- end
- end
- if specials.size > 0 then
- special = 'char' if special.empty?
- r << "\tspecials={'#{special}',#{specials.join(',')}}"
- end
- end
- return r
- end
-
- def save_xetex_data(filename='enco-xtx.tex')
- if not @error then
- begin
- minnumber, maxnumber, n = 0x001F, 0xFFFF, 0
- File.open(filename,'w') do |f|
- @logger.report("saving data in #{filename}") if @logger
- f << "% filename : #{filename}\n"
- f << "% comment : poor man's alternative for a proper enco file\n"
- f << "% author : Hans Hagen, PRAGMA-ADE, Hasselt NL\n"
- f << "% copyright: PRAGMA ADE / ConTeXt Development Team\n"
- f << "% license : see context related readme files\n"
- f << "\n"
- f << "\\ifx\\setcclcuc\\undefined\n"
- f << "\n"
- f << " \\def\\setcclcuc #1 #2 #3 %\n"
- f << " {\\global\\catcode\"#1=11 \n"
- f << " \\global\\lccode \"#1=\"#2 \n"
- f << " \\global\\uccode \"#1=\"#3 }\n"
- f << "\n"
- f << "\\fi\n"
- f << "\n"
- @data.each do |d|
- if d then
- number, type = d[0], d[2].downcase
- if number.hex >= minnumber && number.hex <= maxnumber && type =~ /^l(l|u|t)$/o then
- if d[13] && ! d[13].empty? then
- lc = d[13]
- else
- lc = number
- end
- if d[12] && ! d[12].empty? then
- uc = d[12]
- elsif d[14] && ! d[14].empty? then
- uc = d[14]
- else
- uc = number
- end
- if @comment then
- f << "\\setcclcuc #{number} #{lc} #{uc} % #{d[1]}\n"
- else
- f << "\\setcclcuc #{number} #{lc} #{uc} \n"
- end
- n += 1
- end
- end
- end
- f << "\n"
- f << "\\endinput\n"
- end
- rescue
- @logger.report("error while saving data in #{filename}") if @logger
- else
- @logger.report("#{n} entries saved in #{filename}") if @logger
- end
- else
- @logger.report("not saving data in #{filename} due to previous error") if @logger
- end
- end
-
-end
-
-class RegimeTables
-
- @@version = "1.001"
-
- def initialize(logger=Reporter.new)
- @logger = logger
- reset
- end
-
- def reset
- @code, @regime, @filename, @loaded = Array.new(256), '', '', false
- (32..127).each do |i|
- @code[i] = [sprintf('%04X',i), i.chr]
- end
- end
-
- def load(filename)
- begin
- reset
- if filename =~ /regi\-(ini|run|uni|utf|syn)/ then
- report("skipping #{filename}")
- else
- report("loading file #{filename}")
- @regime, unicodeset = File.basename(filename).sub(/\..*?$/,''), false
- IO.readlines(filename).each do |line|
- case line
- when /^\#/ then
- # skip
- when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+\#\s+(.*)$/ then
- @code[$1.hex], unicodeset = [$2, $3], true
- when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+/ then
- @code[$1.hex], unicodeset = [$2, ''], true
- end
- end
- reset if not unicodeset
- end
- rescue
- report("problem in loading file #{filename}")
- reset
- else
- if ! @regime.empty? then
- @loaded = true
- else
- reset
- end
- end
- end
-
- def save(filename,compact=false)
- begin
- if @loaded && ! @regime.empty? then
- if File.expand_path(filename) == File.expand_path(@filename) then
- report("saving in #{filename} is blocked")
- else
- report("saving file #{filename}")
- File.open(filename,'w') do |f|
- f << ConTeXt::banner(filename,'regi-ini.tex',compact)
- f << "\n"
- f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n"
- f << "\n"
- f << "if not regimes then regimes = { } end\n"
- f << "if not regimes.data then regimes.data = { } end\n"
- f << "\n"
- if compact then
- f << "regimes.data[\"#{@regime}\"] = { [0] = \n\t"
- i = 17
- @code.each_index do |c|
- if (i-=1) == 0 then
- i = 16
- f << "\n\t"
- end
- if @code[c] then
- f << @code[c][0].rjust(6,' ')
- else
- f << "0x0000".rjust(6,' ')
- end
- f << ', ' if c<@code.length-1
- end
- f << "\n}\n"
- else
- @code.each_index do |c|
- if @code[c] then
- f << someregimeslot(@regime,c,@code[c][0],@code[c][1])
- else
- f << someregimeslot(@regime,c,'','')
- end
- end
- end
- end
- end
- end
- rescue
- report("problem in saving file #{filename} #{$!}")
- end
- end
-
- def report(str)
- @logger.report(str)
- end
-
- private
-
- def someregimeslot(regime,slot,unicodeslot,comment)
- "regimes.define { #{if comment.empty? then '' else '-- ' end} #{comment}\n" +
- "\tregime='#{regime}',\n" +
- "\tslot='#{sprintf('0x%02X',slot)}',\n" +
- "\tunicodeslot='#{if unicodeslot.empty? then '0x0000' else unicodeslot end}'\n" +
- "}\n"
- end
-
- public
-
- def RegimeTables::convert(filenames,compact=false)
- filenames.each do |filename|
- txtfile = File.expand_path(filename)
- luafile = File.join(File.dirname(txtfile),'regi-'+File.basename(txtfile.sub(/\..*?$/, '.lua')))
- unless txtfile == luafile then
- regime = RegimeTables.new
- regime.load(txtfile)
- regime.save(luafile,compact)
- end
- end
- end
-
-end
-
-class Commands
-
- include CommandBase
-
- def unicodetable
- unicode = UnicodeTables.new(logger)
- unicode.load_unicode_data
- unicode.load_context_data
- unicode.save_metatex_data('char-def.lua',@commandline.option('compact'))
- end
-
- def xetextable
- unicode = UnicodeTables.new(logger)
- unicode.load_unicode_data
- unicode.load_context_data
- # unicode.comment = false
- unicode.save_xetex_data
- end
-
- def regimetable
- if @commandline.arguments.length > 0 then
- RegimeTables::convert(@commandline.arguments, @commandline.option('compact'))
- else
- RegimeTables::convert(Dir.glob("cp*.txt") , @commandline.option('compact'))
- RegimeTables::convert(Dir.glob("8859*.txt") , @commandline.option('compact'))
- end
- end
-
-end
-
-logger = Logger.new(banner.shift)
-commandline = CommandLine.new
-
-commandline.registeraction('unicodetable', 'create unicode table for metatex/luatex')
-commandline.registeraction('regimetable', 'create regime table(s) for metatex/luatex [--compact]')
-commandline.registeraction('xetextable' , 'create unicode table for xetex')
-
-# general
-
-commandline.registeraction('help')
-commandline.registeraction('version')
-commandline.registerflag('compact')
-
-commandline.expand
-
-Commands.new(commandline,logger,banner).send(commandline.action || 'help')
+#!/usr/bin/env ruby + +# program : mtxtools +# copyright : PRAGMA Advanced Document Engineering +# version : 2004-2005 +# author : Hans Hagen +# +# info : j.hagen@xs4all.nl +# www : www.pragma-ade.com + +# This script hosts MetaTeX related features. + +banner = ['MtxTools', 'version 1.0.0', '2006', 'PRAGMA ADE/POD'] + +$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq! + +require 'base/switch' +require 'base/logger' +require 'base/system' +require 'base/kpse' + +class Reporter + def report(str) + puts(str) + end +end + +module ConTeXt + + def ConTeXt::banner(filename,companionname,compact=false) + "-- filename : #{File.basename(filename)}\n" + + "-- comment : companion to #{File.basename(companionname)} (in ConTeXt)\n" + + "-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL\n" + + "-- copyright: PRAGMA ADE / ConTeXt Development Team\n" + + "-- license : see context related readme files\n" + + if compact then "\n-- remark : compact version\n" else "" end + end + +end + +class UnicodeTables + + @@version = "1.001" + + @@shape_a = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)$/ + @@shape_b = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)\s*(.+)$/ + + @@shape_a = /^(.*\s*LETTER\s*[A-Z]+)$/ + @@shape_b = /^(.*\s*LETTER\s*[A-Z]+)\s+WITH\s+(.+)$/ + + attr_accessor :context, :comment + + def initialize(logger=Reporter.new) + @data = Array.new + @logger = logger + @error = false + @context = true + @comment = true + @shapes = Hash.new + end + + def load_unicode_data(filename='unicodedata.txt') + # beware, the unicodedata table is bugged, sometimes ending + @logger.report("reading base data from #{filename}") if @logger + begin + IO.readlines(filename).each do |line| + if line =~ /^[0-9A-F]{4,4}/ then + d = line.chomp.sub(/\;$/, '').split(';') + if d then + while d.size < 15 do d << '' end + n = d[0].hex + @data[n] = d + if d[1] =~ @@shape_a then + @shapes[$1] = d[0] + end + end + end + end + rescue + @error = true + @logger.report("error while reading base data from #{filename}") if @logger + end + end + + def load_context_data(filename='contextnames.txt') + @logger.report("reading data from #{filename}") if @logger + begin + IO.readlines(filename).each do |line| + if line =~ /^[0-9A-F]{4,4}/ then + d = line.chomp.split(';') + if d then + n = d[0].hex + if @data[n] then + @data[d[0].hex] << d[1] # adobename == 15 + @data[d[0].hex] << d[2] # contextname == 16 + else + @logger.report("missing information about #{d} in #{filename}") if @logger + end + end + end + end + rescue + @error = true + @logger.report("error while reading context data from #{filename}") if @logger + end + end + + def save_metatex_data(filename='char-def.lua',compact=false) + if not @error then + begin + File.open(filename,'w') do |f| + @logger.report("saving data in #{filename}") if @logger + f << ConTeXt::banner(filename,'char-def.tex',compact) + f << "\n" + f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n" + f << "\n" + f << "if not characters then characters = { } end\n" + f << "if not characters.data then characters.data = { } end\n" + f << "\n" + f << "characters.data = {\n" if compact + @data.each do |d| + if d then + r = metatex_data(d) + if compact then + f << "\t" << "[0x#{d[0]}]".rjust(8,' ') << " = { #{r.join(", ").gsub(/\t/,'')} }, \n" + else + f << "characters.define { -- #{d[0].hex}" << "\n" + f << r.join(",\n") << "\n" + f << "}" << "\n" + end + end + end + f << "}\n" if compact + end + rescue + @logger.report("error while saving data in #{filename}") if @logger + else + @logger.report("#{@data.size} (#{sprintf('%X',@data.size)}) entries saved in #{filename}") if @logger + end + else + @logger.report("not saving data in #{filename} due to previous error") if @logger + end + end + + def metatex_data(d) + r = Array.new + r << "\tunicodeslot=0x#{d[0]}" + if d[2] && ! d[2].empty? then + r << "\tcategory='#{d[2].downcase}'" + end + if @context then + if d[15] && ! d[15].empty? then + r << "\tadobename='#{d[15]}'" + end + if d[16] && ! d[16].empty? then + r << "\tcontextname='#{d[16]}'" + end + end + if @comment then + if d[1] == "<control>" then + r << "\tdescription='#{d[10]}'" unless d[10].empty? + else + r << "\tdescription='#{d[1]}'" unless d[1].empty? + end + end + if d[1] =~ @@shape_b then + r << "\tshcode=0x#{@shapes[$1]}" if @shapes[$1] + end + if d[12] && ! d[12].empty? then + r << "\tuccode=0x#{d[12]}" + elsif d[14] && ! d[14].empty? then + r << "\tuccode=0x#{d[14]}" + end + if d[13] && ! d[13].empty? then + r << "\tlccode=0x#{d[13]}" + end + if d[5] && ! d[5].empty? then + special, specials = '', Array.new + c = d[5].split(/\s+/).collect do |cc| + if cc =~ /^\<(.*)\>$/io then + special = $1.downcase + else + specials << "0x#{cc}" + end + end + if specials.size > 0 then + special = 'char' if special.empty? + r << "\tspecials={'#{special}',#{specials.join(',')}}" + end + end + return r + end + + def save_xetex_data(filename='enco-utf.tex') + if not @error then + begin + minnumber, maxnumber, n = 0x001F, 0xFFFF, 0 + File.open(filename,'w') do |f| + @logger.report("saving data in #{filename}") if @logger + f << "% filename : #{filename}\n" + f << "% comment : poor man's alternative for a proper enco file\n" + f << "% this file is generated by mtxtools and can be\n" + f << "% used in xetex and luatex mkii mode\n" + f << "% author : Hans Hagen, PRAGMA-ADE, Hasselt NL\n" + f << "% copyright: PRAGMA ADE / ConTeXt Development Team\n" + f << "% license : see context related readme files\n" + f << "\n" + f << "\\ifx\\setcclcucx\\undefined\n" + f << "\n" + f << " \\def\\setcclcucx #1 #2 #3 %\n" + f << " {\\global\\catcode\"#1=11 \n" + f << " \\global\\lccode \"#1=\"#2 \n" + f << " \\global\\uccode \"#1=\"#3 }\n" + f << "\n" + f << "\\fi\n" + f << "\n" + @data.each do |d| + if d then + number, type = d[0], d[2].downcase + if number.hex >= minnumber && number.hex <= maxnumber && type =~ /^l(l|u|t)$/o then + if d[13] && ! d[13].empty? then + lc = d[13] + else + lc = number + end + if d[12] && ! d[12].empty? then + uc = d[12] + elsif d[14] && ! d[14].empty? then + uc = d[14] + else + uc = number + end + if @comment then + f << "\\setcclcuc #{number} #{lc} #{uc} % #{d[1]}\n" + else + f << "\\setcclcuc #{number} #{lc} #{uc} \n" + end + n += 1 + end + end + end + f << "\n" + f << "\\endinput\n" + end + rescue + @logger.report("error while saving data in #{filename}") if @logger + else + @logger.report("#{n} entries saved in #{filename}") if @logger + end + else + @logger.report("not saving data in #{filename} due to previous error") if @logger + end + end + +end + +class RegimeTables + + @@version = "1.001" + + def initialize(logger=Reporter.new) + @logger = logger + reset + end + + def reset + @code, @regime, @filename, @loaded = Array.new(256), '', '', false + (32..127).each do |i| + @code[i] = [sprintf('%04X',i), i.chr] + end + end + + def load(filename) + begin + reset + if filename =~ /regi\-(ini|run|uni|utf|syn)/ then + report("skipping #{filename}") + else + report("loading file #{filename}") + @regime, unicodeset = File.basename(filename).sub(/\..*?$/,''), false + IO.readlines(filename).each do |line| + case line + when /^\#/ then + # skip + when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+\#\s+(.*)$/ then + @code[$1.hex], unicodeset = [$2, $3], true + when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+/ then + @code[$1.hex], unicodeset = [$2, ''], true + end + end + reset if not unicodeset + end + rescue + report("problem in loading file #{filename}") + reset + else + if ! @regime.empty? then + @loaded = true + else + reset + end + end + end + + def save(filename,compact=false) + begin + if @loaded && ! @regime.empty? then + if File.expand_path(filename) == File.expand_path(@filename) then + report("saving in #{filename} is blocked") + else + report("saving file #{filename}") + File.open(filename,'w') do |f| + f << ConTeXt::banner(filename,'regi-ini.tex',compact) + f << "\n" + f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n" + f << "\n" + f << "if not regimes then regimes = { } end\n" + f << "if not regimes.data then regimes.data = { } end\n" + f << "\n" + if compact then + f << "regimes.data[\"#{@regime}\"] = { [0] = \n\t" + i = 17 + @code.each_index do |c| + if (i-=1) == 0 then + i = 16 + f << "\n\t" + end + if @code[c] then + f << @code[c][0].rjust(6,' ') + else + f << "0x0000".rjust(6,' ') + end + f << ', ' if c<@code.length-1 + end + f << "\n}\n" + else + @code.each_index do |c| + if @code[c] then + f << someregimeslot(@regime,c,@code[c][0],@code[c][1]) + else + f << someregimeslot(@regime,c,'','') + end + end + end + end + end + end + rescue + report("problem in saving file #{filename} #{$!}") + end + end + + def report(str) + @logger.report(str) + end + + private + + def someregimeslot(regime,slot,unicodeslot,comment) + "regimes.define { #{if comment.empty? then '' else '-- ' end} #{comment}\n" + + "\tregime='#{regime}',\n" + + "\tslot='#{sprintf('0x%02X',slot)}',\n" + + "\tunicodeslot='#{if unicodeslot.empty? then '0x0000' else unicodeslot end}'\n" + + "}\n" + end + + public + + def RegimeTables::convert(filenames,compact=false) + filenames.each do |filename| + txtfile = File.expand_path(filename) + luafile = File.join(File.dirname(txtfile),'regi-'+File.basename(txtfile.sub(/\..*?$/, '.lua'))) + unless txtfile == luafile then + regime = RegimeTables.new + regime.load(txtfile) + regime.save(luafile,compact) + end + end + end + +end + +class Commands + + include CommandBase + + def unicodetable + unicode = UnicodeTables.new(logger) + unicode.load_unicode_data + unicode.load_context_data + unicode.save_metatex_data('char-def.lua',@commandline.option('compact')) + end + + def xetextable + unicode = UnicodeTables.new(logger) + unicode.load_unicode_data + unicode.load_context_data + # unicode.comment = false + unicode.save_xetex_data + end + + def regimetable + if @commandline.arguments.length > 0 then + RegimeTables::convert(@commandline.arguments, @commandline.option('compact')) + else + RegimeTables::convert(Dir.glob("cp*.txt") , @commandline.option('compact')) + RegimeTables::convert(Dir.glob("8859*.txt") , @commandline.option('compact')) + end + end + + def pdftextable + # instead of directly saving the data, we use luatex (kind of test) + pdfrdef = 'pdfr-def.tex' + tmpfile = 'mtxtools.tmp' + File.delete(pdfrdef) rescue false + if f = File.open(tmpfile,'w') then + f << "\\starttext\n" + f << "\\ctxlua{characters.pdftex.make_pdf_to_unicodetable('#{pdfrdef}')}\n" + f << "\\stoptext\n" + f.close() + system("texmfstart texexec --luatex --once --purge mtxtools.tmp") + report("vecor saved in #{pdfrdef}") + end + File.delete(tmpfile) rescue false + end + + def xmlmapfile + # instead of directly saving the data, we use luatex (kind of test) + tmpfile = 'mtxtools.tmp' + xmlsuffix = 'frx' + @commandline.arguments.each do |mapname| + if f = File.open(tmpfile,'w') then + xmlname = mapname.gsub(/\.map$/,".#{xmlsuffix}") + File.delete(xmlname) rescue false + f << "\\starttext\n" + f << "\\ctxlua{\n" + f << " mapname = input.find_file(texmf.instance,'#{mapname}') or ''\n" + f << " xmlname = '#{xmlname}'\n" + f << " if mapname and not mapname:is_empty() then\n" + f << " ctx.fonts.map.convert_file(mapname,xmlname)\n" + f << " end\n" + f << "}\n" + f << "\\stoptext\n" + f.close() + system("texmfstart texexec --luatex --once --purge mtxtools.tmp") + if FileTest.file?(xmlname) then + report("map file #{mapname} converted to #{xmlname}") + else + report("no valid map file #{mapname}") + end + end + end + File.delete(tmpfile) rescue false + end + +end + +logger = Logger.new(banner.shift) +commandline = CommandLine.new + +commandline.registeraction('unicodetable', 'create unicode table for metatex/luatex') +commandline.registeraction('regimetable' , 'create regime table(s) for metatex/luatex [--compact]') +commandline.registeraction('xetextable' , 'create unicode table for xetex') +commandline.registeraction('pdftextable' , 'create unicode table for xetex') +commandline.registeraction('xmlmapfile' , 'convert traditional mapfile to xml font resourse') + +# general + +commandline.registeraction('help') +commandline.registeraction('version') +commandline.registerflag('compact') + +commandline.expand + +Commands.new(commandline,logger,banner).send(commandline.action || 'help') diff --git a/Master/texmf-dist/scripts/context/ruby/pdftools.rb b/Master/texmf-dist/scripts/context/ruby/pdftools.rb index 25e7250b67f..23edfeca226 100644 --- a/Master/texmf-dist/scripts/context/ruby/pdftools.rb +++ b/Master/texmf-dist/scripts/context/ruby/pdftools.rb @@ -397,20 +397,20 @@ class SpotColorImage if data =~ /(\d+)\s+0\s+obj\s+\[\/Separation\s+\/#{@colorname}/mos then @command.report("replacing separation color") object = $1 - data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do + data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do $1 + "/ColorSpace #{object} 0 R".ljust($2.length) end elsif data =~ /(\d+)\s+0\s+obj\s+\[\/Indexed\s*\[/mos then @command.report("replacing indexed color") # todo: more precise check on color object = $1 - data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do + data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do $1 + "/ColorSpace #{object} 0 R".ljust($2.length) end elsif data =~ /(\d+)\s+0\s+obj\s+\[\/Separation/mos then @command.report("replacing separation color") object = $1 - data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do + data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do $1 + "/ColorSpace #{object} 0 R".ljust($2.length) end end @@ -663,7 +663,7 @@ class Commands pairs = Hash.new data.each do |d| - if (d =~ /^\s*(.*?)\s*\:\s*(.*?)\s*$/mois) then + if (d =~ /^\s*(.*?)\s*\:\s*(.*?)\s*$/moi) then key, val = $1, $2 pairs[key.downcase.sub(/ /,'')] = val end @@ -780,7 +780,7 @@ class Commands end threshold = @commandline.option('threshold').to_i rescue 0 filenames.each do |filename| - if `pdfinfo #{filename}`.chomp =~ /^pages\s*\:\s*(\d+)/mois then + if `pdfinfo #{filename}`.chomp =~ /^pages\s*\:\s*(\d+)/moi then p = $1 m = p.to_i rescue 0 if threshold == 0 or m > threshold then diff --git a/Master/texmf-dist/scripts/context/ruby/pstopdf.rb b/Master/texmf-dist/scripts/context/ruby/pstopdf.rb index 3625f4d83dc..73e628df23b 100644 --- a/Master/texmf-dist/scripts/context/ruby/pstopdf.rb +++ b/Master/texmf-dist/scripts/context/ruby/pstopdf.rb @@ -76,7 +76,7 @@ class Commands @commandline.arguments.each do |filename| - filename = Tool.cleanfilename(filename,@commandline) + filename = Tool.cleanfilename(filename,@commandline) # brrrr inppath = @commandline.option('inputpath') if inppath.empty? then inppath = '.' diff --git a/Master/texmf-dist/scripts/context/ruby/rlxtools.rb b/Master/texmf-dist/scripts/context/ruby/rlxtools.rb index ea065612f0a..1617fcad4ae 100644 --- a/Master/texmf-dist/scripts/context/ruby/rlxtools.rb +++ b/Master/texmf-dist/scripts/context/ruby/rlxtools.rb @@ -300,6 +300,7 @@ class Commands begin str = nil if FileTest.file?(filename) then + # todo: use pdfinto for pdf files, identify is bugged if centimeters then result = `identify -units PixelsPerCentimeter -format \"x=%x,y=%y,w=%w,h=%h,b=%b\" #{filename}`.chomp.split(',') else diff --git a/Master/texmf-dist/scripts/context/ruby/texexec.rb b/Master/texmf-dist/scripts/context/ruby/texexec.rb index f37cfd8c2b0..a09572c6caa 100644 --- a/Master/texmf-dist/scripts/context/ruby/texexec.rb +++ b/Master/texmf-dist/scripts/context/ruby/texexec.rb @@ -111,7 +111,7 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then backspace = @commandline.checkedoption('backspace', '1.5cm') @@ -156,7 +156,7 @@ class Commands prepare(job) job.cleanuptemprunfiles fast = @commandline.option('fast') - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if fast or (files.length > 0) then if f = File.open(job.tempfilename('tex'),'w') then files.delete("texexec.pdf") @@ -202,7 +202,7 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end msuffixes = ['tex','mkii','mkiv','mp','pl','pm','rb'] if files.length > 0 then files.each do |fname| @@ -242,7 +242,7 @@ class Commands mod << "\\stoptext\n" mod.close job.setvariable('interface','english') # redundant - job.setvariable('simplerun',true) + # job.setvariable('simplerun',true) # job.setvariable('nooptionfile',true) job.setvariable('files',[job.tempfilename]) result = File.unsuffixed(File.basename(ffname)) @@ -302,7 +302,7 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then emptypages = @commandline.checkedoption('addempty', '') @@ -355,7 +355,7 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then selection = @commandline.checkedoption('selection', '') @@ -425,15 +425,16 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then scale = @commandline.checkedoption('scale') begin - scale = (scale.to_i * 1000).to_i if scale.to_i < 10 + scale = (scale.to_f * 1000.0).to_i if scale.to_i < 10 rescue scale = 1000 end + scale = scale.to_i paperoffset = @commandline.checkedoption('paperoffset', '0cm') f << "\\starttext\n" files.each do |filename| @@ -491,7 +492,7 @@ class Commands if job = TEX.new(logger) then prepare(job) job.cleanuptemprunfiles - files = @commandline.arguments.sort + files = if @commandline.option('sort') then @commandline.arguments.sort else @commandline.arguments end if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then paperoffset = @commandline.checkedoption('paperoffset', '0cm') @@ -570,16 +571,20 @@ class Commands job.setvariable(k,@commandline.option(k)) unless @commandline.option(k).empty? end +job.setvariable('given.backend',job.getvariable('backend')) + if (str = @commandline.option('engine')) && ! str.standard? && ! str.empty? then job.setvariable('texengine',str) + elsif @commandline.oneof('luatex') then + job.setvariable('texengine','luatex') elsif @commandline.oneof('pdfetex','pdftex','pdf') then job.setvariable('texengine','pdftex') elsif @commandline.oneof('xetex','xtx') then job.setvariable('texengine','xetex') elsif @commandline.oneof('aleph') then job.setvariable('texengine','aleph') - elsif @commandline.oneof('luatex') then - job.setvariable('texengine','luatex') + elsif @commandline.oneof('petex') then + job.setvariable('texengine','petex') else job.setvariable('texengine','standard') end @@ -594,6 +599,8 @@ class Commands job.setvariable('backend','xetex') elsif @commandline.oneof('aleph') then job.setvariable('backend','dvipdfmx') + elsif @commandline.oneof('petex') then + job.setvariable('backend','dvipdfmx') elsif @commandline.oneof('dvips','ps') then job.setvariable('backend','dvips') elsif @commandline.oneof('xdv') then @@ -604,6 +611,7 @@ class Commands when 'pdftex' then job.setvariable('backend','pdftex') when 'luatex' then job.setvariable('backend','pdftex') when 'xetex' then job.setvariable('backend','xetex') + when 'petex' then job.setvariable('backend','dvipdfmx') when 'aleph' then job.setvariable('backend','dvipdfmx') else job.setvariable('backend','standard') @@ -757,8 +765,11 @@ commandline.registerflag('xdv') commandline.registerflag('aleph') +commandline.registerflag('petex') + commandline.registerflag('all') commandline.registerflag('fast') +commandline.registerflag('sort') # generic diff --git a/Master/texmf-dist/scripts/context/ruby/texmfstart.rb b/Master/texmf-dist/scripts/context/ruby/texmfstart.rb index 4d1e2976145..e43929213f5 100644 --- a/Master/texmf-dist/scripts/context/ruby/texmfstart.rb +++ b/Master/texmf-dist/scripts/context/ruby/texmfstart.rb @@ -36,6 +36,8 @@ $: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.u require "rbconfig" require "md5" +# funny, selfmergs was suddenly broken to case problems + # kpse_merge_done: require 'base/kpseremote' # kpse_merge_done: require 'base/kpsedirect' # kpse_merge_done: require 'base/kpsefast' @@ -43,127 +45,7 @@ require "md5" # kpse_merge_start -# kpse_merge_file: 'C:/data/develop/context/ruby/base/kpseremote.rb' - -# kpse_merge_done: require 'base/kpsefast' - -case ENV['KPSEMETHOD'] - when /soap/o then # kpse_merge_done: require 'base/kpse/soap' - when /drb/o then # kpse_merge_done: require 'base/kpse/drb' - else # kpse_merge_done: require 'base/kpse/drb' -end - -class KpseRemote - - @@port = ENV['KPSEPORT'] || 7000 - @@method = ENV['KPSEMETHOD'] || 'drb' - - def KpseRemote::available? - @@method && @@port - end - - def KpseRemote::start_server(port=nil) - kpse = KpseServer.new(port || @@port) - kpse.start - end - - def KpseRemote::start_client(port=nil) # keeps object in server - kpseclient = KpseClient.new(port || @@port) - kpseclient.start - kpse = kpseclient.object - tree = kpse.choose(KpseUtil::identify, KpseUtil::environment) - [kpse, tree] - end - - def KpseRemote::fetch(port=nil) # no need for defining methods but slower, send whole object - kpseclient = KpseClient.new(port || @@port) - kpseclient.start - kpseclient.object.fetch(KpseUtil::identify, KpseUtil::environment) rescue nil - end - - def initialize(port=nil) - if KpseRemote::available? then - begin - @kpse, @tree = KpseRemote::start_client(port) - rescue - @kpse, @tree = nil, nil - end - else - @kpse, @tree = nil, nil - end - end - - def progname=(value) - @kpse.set(@tree,'progname',value) - end - def format=(value) - @kpse.set(@tree,'format',value) - end - def engine=(value) - @kpse.set(@tree,'engine',value) - end - - def progname - @kpse.get(@tree,'progname') - end - def format - @kpse.get(@tree,'format') - end - def engine - @kpse.get(@tree,'engine') - end - - def load - @kpse.load(KpseUtil::identify, KpseUtil::environment) - end - def okay? - @kpse && @tree - end - def set(key,value) - @kpse.set(@tree,key,value) - end - def load_cnf - @kpse.load_cnf(@tree) - end - def load_lsr - @kpse.load_lsr(@tree) - end - def expand_variables - @kpse.expand_variables(@tree) - end - def expand_braces(str) - clean_name(@kpse.expand_braces(@tree,str)) - end - def expand_path(str) - clean_name(@kpse.expand_path(@tree,str)) - end - def expand_var(str) - clean_name(@kpse.expand_var(@tree,str)) - end - def show_path(str) - clean_name(@kpse.show_path(@tree,str)) - end - def var_value(str) - clean_name(@kpse.var_value(@tree,str)) - end - def find_file(filename) - clean_name(@kpse.find_file(@tree,filename)) - end - def find_files(filename,first=false) - # dodo: each filename - @kpse.find_files(@tree,filename,first) - end - - private - - def clean_name(str) - str.gsub(/\\/,'/') - end - -end - - -# kpse_merge_file: 'C:/data/develop/context/ruby/base/kpsefast.rb' +# kpse_merge_file: 't:/ruby/base/kpsefast.rb' # module : base/kpsefast # copyright : PRAGMA Advanced Document Engineering @@ -1097,67 +979,7 @@ end -# kpse_merge_file: 'C:/data/develop/context/ruby/base/kpse/drb.rb' - -require 'drb' -# kpse_merge_done: require 'base/kpse/trees' - -class KpseServer - - attr_accessor :port - - def initialize(port=7000) - @port = port - end - - def start - puts "starting drb service at port #{@port}" - DRb.start_service("druby://localhost:#{@port}", KpseTrees.new) - trap(:INT) do - DRb.stop_service - end - DRb.thread.join - end - - def stop - # todo - end - -end - -class KpseClient - - attr_accessor :port - - def initialize(port=7000) - @port = port - @kpse = nil - end - - def start - # only needed when callbacks are used / slow, due to Socket::getaddrinfo - # DRb.start_service - end - - def object - @kpse = DRbObject.new(nil,"druby://localhost:#{@port}") - end - -end - - -# SERVER_URI="druby://localhost:8787" -# -# # Start a local DRbServer to handle callbacks. -# # -# # Not necessary for this small example, but will be required -# # as soon as we pass a non-marshallable object as an argument -# # to a dRuby call. -# DRb.start_service -# - - -# kpse_merge_file: 'C:/data/develop/context/ruby/base/kpse/trees.rb' +# kpse_merge_file: 't:/ruby/base/kpse/trees.rb' require 'monitor' # kpse_merge_done: require 'base/kpsefast' @@ -1245,179 +1067,219 @@ class KpseTrees < Monitor end -# kpse_merge_file: 'C:/data/develop/context/ruby/base/kpsedirect.rb' +# kpse_merge_file: 't:/ruby/base/kpse/drb.rb' -class KpseDirect +require 'drb' +# kpse_merge_done: require 'base/kpse/trees' - attr_accessor :progname, :format, :engine +class KpseServer - def initialize - @progname, @format, @engine = '', '', '' - end + attr_accessor :port - def expand_path(str) - clean_name(`kpsewhich -expand-path=#{str}`.chomp) + def initialize(port=7000) + @port = port end - def expand_var(str) - clean_name(`kpsewhich -expand-var=#{str}`.chomp) + def start + puts "starting drb service at port #{@port}" + DRb.start_service("druby://localhost:#{@port}", KpseTrees.new) + trap(:INT) do + DRb.stop_service + end + DRb.thread.join end - def find_file(str) - clean_name(`kpsewhich #{_progname_} #{_format_} #{str}`.chomp) + def stop + # todo end - def _progname_ - if @progname.empty? then '' else "-progname=#{@progname}" end - end - def _format_ - if @format.empty? then '' else "-format=\"#{@format}\"" end +end + +class KpseClient + + attr_accessor :port + + def initialize(port=7000) + @port = port + @kpse = nil end - private + def start + # only needed when callbacks are used / slow, due to Socket::getaddrinfo + # DRb.start_service + end - def clean_name(str) - str.gsub(/\\/,'/') + def object + @kpse = DRbObject.new(nil,"druby://localhost:#{@port}") end end -# kpse_merge_file: 'C:/data/develop/context/ruby/base/merge.rb' - -# module : base/merge -# copyright : PRAGMA Advanced Document Engineering -# version : 2006 -# author : Hans Hagen +# SERVER_URI="druby://localhost:8787" +# +# # Start a local DRbServer to handle callbacks. +# # +# # Not necessary for this small example, but will be required +# # as soon as we pass a non-marshallable object as an argument +# # to a dRuby call. +# DRb.start_service # -# project : ConTeXt / eXaMpLe -# concept : Hans Hagen -# info : j.hagen@xs4all.nl -# this module will package all the used modules in the file itself -# so that we can relocate the file at wish, usage: -# -# merge: -# -# unless SelfMerge::ok? && SelfMerge::merge then -# puts("merging should happen on the path were the base inserts reside") -# end -# -# cleanup: -# -# unless SelfMerge::cleanup then -# puts("merging should happen on the path were the base inserts reside") +# kpse_merge_file: 't:/ruby/base/kpseremote.rb' -module SelfMerge +# kpse_merge_done: require 'base/kpsefast' - @@kpsemergestart = "\# kpse_merge_start" - @@kpsemergestop = "\# kpse_merge_stop" - @@kpsemergefile = "\# kpse_merge_file: " - @@kpsemergedone = "\# kpse_merge_done: " +case ENV['KPSEMETHOD'] + when /soap/o then # kpse_merge_done: require 'base/kpse/soap' + when /drb/o then # kpse_merge_done: require 'base/kpse/drb' + else # kpse_merge_done: require 'base/kpse/drb' +end - @@filename = File.basename($0) - @@ownpath = File.expand_path(File.dirname($0)) - @@modroot = '(base|graphics|rslb|www)' # needed in regex in order not to mess up SelfMerge - @@modules = $".collect do |file| File.expand_path(file) end +class KpseRemote - @@modules.delete_if do |file| - file !~ /^#{@@ownpath}\/#{@@modroot}.*$/ + @@port = ENV['KPSEPORT'] || 7000 + @@method = ENV['KPSEMETHOD'] || 'drb' + + def KpseRemote::available? + @@method && @@port end - def SelfMerge::ok? - begin - @@modules.each do |file| - return false unless FileTest.file?(file) - end - rescue - return false - else - return true - end + def KpseRemote::start_server(port=nil) + kpse = KpseServer.new(port || @@port) + kpse.start end - def SelfMerge::merge - begin - if SelfMerge::ok? && rbfile = IO.read(@@filename) then - begin - inserts = "#{@@kpsemergestart}\n\n" - @@modules.each do |file| - inserts << "#{@@kpsemergefile}'#{file}'\n\n" - inserts << IO.read(file).gsub(/^#.*?\n$/,'') - inserts << "\n\n" - end - inserts << "#{@@kpsemergestop}\n\n" - # no gsub! else we end up in SelfMerge - rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/mois) do - inserts - end - rbfile.gsub!(/^(.*)(require [\"\'].*?#{@@modroot}.*)$/) do - pre, post = $1, $2 - if pre =~ /#{@@kpsemergedone}/ then - "#{pre}#{post}" - else - "#{pre}#{@@kpsemergedone}#{post}" - end - end - rescue - return false - else - begin - File.open(@@filename,'w') do |f| - f << rbfile - end - rescue - return false - end - end - end - rescue - return false - else - return true - end + def KpseRemote::start_client(port=nil) # keeps object in server + kpseclient = KpseClient.new(port || @@port) + kpseclient.start + kpse = kpseclient.object + tree = kpse.choose(KpseUtil::identify, KpseUtil::environment) + [kpse, tree] end - def SelfMerge::cleanup - begin - if rbfile = IO.read(@@filename) then - begin - rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/mois) do - "#{@@kpsemergestart}\n\n#{@@kpsemergestop}\n\n" - end - rbfile.gsub!(/^(.*#{@@kpsemergedone}.*)$/) do - str = $1 - if str =~ /require [\"\']/ then - str.gsub(/#{@@kpsemergedone}/, '') - else - str - end - end - rescue - return false - else - begin - File.open(@@filename,'w') do |f| - f << rbfile - end - rescue - return false - end - end + def KpseRemote::fetch(port=nil) # no need for defining methods but slower, send whole object + kpseclient = KpseClient.new(port || @@port) + kpseclient.start + kpseclient.object.fetch(KpseUtil::identify, KpseUtil::environment) rescue nil + end + + def initialize(port=nil) + if KpseRemote::available? then + begin + @kpse, @tree = KpseRemote::start_client(port) + rescue + @kpse, @tree = nil, nil end - rescue - return false else - return true + @kpse, @tree = nil, nil end end - def SelfMerge::replace - if SelfMerge::ok? then - SelfMerge::cleanup - SelfMerge::merge - end + def progname=(value) + @kpse.set(@tree,'progname',value) + end + def format=(value) + @kpse.set(@tree,'format',value) + end + def engine=(value) + @kpse.set(@tree,'engine',value) + end + + def progname + @kpse.get(@tree,'progname') + end + def format + @kpse.get(@tree,'format') + end + def engine + @kpse.get(@tree,'engine') + end + + def load + @kpse.load(KpseUtil::identify, KpseUtil::environment) + end + def okay? + @kpse && @tree + end + def set(key,value) + @kpse.set(@tree,key,value) + end + def load_cnf + @kpse.load_cnf(@tree) + end + def load_lsr + @kpse.load_lsr(@tree) + end + def expand_variables + @kpse.expand_variables(@tree) + end + def expand_braces(str) + clean_name(@kpse.expand_braces(@tree,str)) + end + def expand_path(str) + clean_name(@kpse.expand_path(@tree,str)) + end + def expand_var(str) + clean_name(@kpse.expand_var(@tree,str)) + end + def show_path(str) + clean_name(@kpse.show_path(@tree,str)) + end + def var_value(str) + clean_name(@kpse.var_value(@tree,str)) + end + def find_file(filename) + clean_name(@kpse.find_file(@tree,filename)) + end + def find_files(filename,first=false) + # dodo: each filename + @kpse.find_files(@tree,filename,first) + end + + private + + def clean_name(str) + str.gsub(/\\/,'/') + end + +end + + +# kpse_merge_file: 't:/ruby/base/kpsedirect.rb' + +class KpseDirect + + attr_accessor :progname, :format, :engine + + def initialize + @progname, @format, @engine = '', '', '' + end + + def expand_path(str) + clean_name(`kpsewhich -expand-path=#{str}`.chomp) + end + + def expand_var(str) + clean_name(`kpsewhich -expand-var=#{str}`.chomp) + end + + def find_file(str) + clean_name(`kpsewhich #{_progname_} #{_format_} #{str}`.chomp) + end + + def _progname_ + if @progname.empty? then '' else "-progname=#{@progname}" end + end + def _format_ + if @format.empty? then '' else "-format=\"#{@format}\"" end + end + + private + + def clean_name(str) + str.gsub(/\\/,'/') end end @@ -1445,6 +1307,7 @@ $stderr.sync = true $applications = Hash.new $suffixinputs = Hash.new $predefined = Hash.new +$runners = Hash.new $suffixinputs['pl'] = 'PERLINPUTS' $suffixinputs['rb'] = 'RUBYINPUTS' @@ -1474,8 +1337,8 @@ $predefined['pdftools'] = 'pdftools.rb' $predefined['mpstools'] = 'mpstools.rb' $predefined['exatools'] = 'exatools.rb' $predefined['xmltools'] = 'xmltools.rb' -$predefined['luatools'] = 'luatools.lua' -$predefined['mtxtools'] = 'mtxtools.rb' +# $predefined['luatools'] = 'luatools.lua' +# $predefined['mtxtools'] = 'mtxtools.rb' $predefined['newpstopdf'] = 'pstopdf.rb' $predefined['newtexexec'] = 'texexec.rb' @@ -1500,9 +1363,12 @@ $makelist = [ 'exatools', 'runtools', 'rlxtools', - 'luatools', - 'mtxtools', + 'pdftrimwhite', + 'texfind', + 'texshow' # + # no 'luatools', + # no 'mtxtools', # no, 'texmfstart' ] @@ -1517,10 +1383,10 @@ $kpse = nil def set_applications(page=1) $applications['unknown'] = '' - $applications['perl'] = $applications['pl'] = 'perl' $applications['ruby'] = $applications['rb'] = 'ruby' + $applications['lua'] = $applications['lua'] = 'lua' + $applications['perl'] = $applications['pl'] = 'perl' $applications['python'] = $applications['py'] = 'python' - $applications['lua'] = $applications['lua'] = 'luatex --luaonly' $applications['java'] = $applications['jar'] = 'java' if $mswindows then @@ -1536,6 +1402,8 @@ def set_applications(page=1) $applications['htm'] = $applications['html'] $applications['eps'] = $applications['ps'] + $runners['lua'] = "texlua" + end set_applications() @@ -1675,6 +1543,33 @@ class File end +# def hashed (arr=[]) + # arg = if arr.class == String then arr.split(' ') else arr.dup end + # hsh = Hash.new + # if arg.length > 0 + # hsh['arguments'] = '' + # done = false + # arg.each do |s| + # if done then + # if s =~ / / then + # hsh['arguments'] += " \"#{s}\"" # maybe split on = + # else + # hsh['arguments'] += " #{s}" + # end + # else + # kvl = s.split('=') + # if kvl[0].sub!(/^\-+/,'') then + # hsh[kvl[0]] = if kvl.length > 1 then kvl[1] else true end + # else + # hsh['file'] = s + # done = true + # end + # end + # end + # end + # return hsh +# end + def hashed (arr=[]) arg = if arr.class == String then arr.split(' ') else arr.dup end hsh = Hash.new @@ -1683,7 +1578,18 @@ def hashed (arr=[]) done = false arg.each do |s| if done then - hsh['arguments'] += ' ' + s + if s =~ /\s/ then + kvl = s.split('=') + if kvl[1] and kvl[1] !~ /^[\"\']/ then + hsh['arguments'] += ' ' + kvl[0] + "=" + '"' + kvl[1] + '"' + elsif s =~ /\s/ then + hsh['arguments'] += ' "' + s + '"' + else + hsh['arguments'] += ' ' + s + end + else + hsh['arguments'] += ' ' + s + end else kvl = s.split('=') if kvl[0].sub!(/^\-+/,'') then @@ -1698,6 +1604,7 @@ def hashed (arr=[]) return hsh end + def launch(filename) if $browser && $mswindows then filename = filename.gsub(/\.[\/\\]/) do @@ -1717,15 +1624,25 @@ end # rel|relative # loc|locate|kpse|path|file +def quoted(str) + if str =~ /^\"/ then + return str + elsif str =~ / / then + return "\"#{str}\"" + else + return str + end +end + def expanded(arg) # no "other text files", too restricted 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 - resolved + quoted(resolved) else report("environment variable #{original} cannot be resolved") unless $report - original + quoted(original) end end . gsub(/(rel|relative)\:([a-zA-Z\-\_\.0-9]+)/o) do method, original, resolved = $1, $2, '' @@ -1736,9 +1653,9 @@ def expanded(arg) # no "other text files", too restricted end end if resolved.empty? then - original + quoted(original) else - resolved + quoted(resolved) end end . gsub(/(kpse|loc|locate|file|path)\:([a-zA-Z\-\_\.0-9]+)/o) do method, original, resolved = $1, $2, '' @@ -1753,7 +1670,7 @@ def expanded(arg) # no "other text files", too restricted if ENV["_CTX_K_V_#{original}_"] then resolved = ENV["_CTX_K_V_#{original}_"] report("environment provides #{original} as #{resolved}") unless $report - resolved + quoted(resolved) else check_kpse pstrings.each do |pstr| @@ -1789,12 +1706,12 @@ def expanded(arg) # no "other text files", too restricted original = File.dirname(original) if method =~ /path/ report("#{original} is not resolved") unless $report ENV["_CTX_K_V_#{original}_"] = original if $crossover - original + quoted(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 + quoted(resolved) end end end @@ -1839,10 +1756,16 @@ def runcommand(command) end end +def join_command(args) + args[0] = $runners[args[0]] || args[0] + [args].join(' ') +end + def runoneof(application,fullname,browserpermitted) if browserpermitted && launch(fullname) then return true else + fullname = quoted(fullname) # added because MM ran into problems report("starting #{$filename}") unless $report output("\n") if $report && $verbose applications = $applications[application.downcase] @@ -1851,26 +1774,26 @@ def runoneof(application,fullname,browserpermitted) return true elsif applications.class == Array then if $report then - output([fullname,expanded($arguments)].join(' ')) + output(join_command([fullname,expanded($arguments)])) return true else applications.each do |a| - return true if runcommand([a,fullname,expanded($arguments)].join(' ')) + return true if runcommand(join_command([a,fullname,expanded($arguments)])) end end elsif applications.empty? then if $report then - output([fullname,expanded($arguments)].join(' ')) + output(join_command([fullname,expanded($arguments)])) return true else - return runcommand([fullname,expanded($arguments)].join(' ')) + return runcommand(join_command([fullname,expanded($arguments)])) end else if $report then - output([applications,fullname,expanded($arguments)].join(' ')) + output(join_command([applications,fullname,expanded($arguments)])) return true else - return runcommand([applications,fullname,expanded($arguments)].join(' ')) + return runcommand(join_command([applications,fullname,expanded($arguments)])) end end return false @@ -1920,6 +1843,7 @@ def usage end # somehow registration does not work out (at least not under windows) +# the . is also not accepted by unix as seperator def tag(name) if $crossover then "_CTX_K_S_#{name}_" else "TEXMFSTART.#{name}" end @@ -2410,10 +2334,9 @@ def show_environment end end -def execute(arguments) +def execute(arguments) # br global arguments = arguments.split(/\s+/) if arguments.class == String - $directives = hashed(arguments) $help = $directives['help'] || false @@ -2576,5 +2499,3 @@ else report("\nexecution failed") if $verbose exit(1) end - -# exit (if ($?.to_i rescue 0) > 0 then 1 else 0 end) diff --git a/Master/texmf-dist/scripts/context/ruby/texsync.rb b/Master/texmf-dist/scripts/context/ruby/texsync.rb index ade307d8ef2..00461039982 100644 --- a/Master/texmf-dist/scripts/context/ruby/texsync.rb +++ b/Master/texmf-dist/scripts/context/ruby/texsync.rb @@ -14,6 +14,8 @@ # distribution. In due time I will add a few more options, like # synchronization of the iso image. +# taco's sync: rsync -au -v rsync://www.pragma-ade.com/all ./htdocs + banner = ['TeXSync', 'version 1.1.1', '2002/2004', 'PRAGMA ADE/POD'] $: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq! @@ -28,7 +30,7 @@ class Commands include CommandBase - @@formats = ['en','nl','de','cz','it','ro'] + @@formats = ['en','nl','de','cz','it','ro', 'fr'] @@always = ['metafun','mptopdf','en','nl'] @@rsync = 'rsync -r -z -c --progress --stats "--exclude=*.fmt" "--exclude=*.efmt" "--exclude=*.mem"' diff --git a/Master/texmf-dist/scripts/context/ruby/textools.rb b/Master/texmf-dist/scripts/context/ruby/textools.rb index b6300215e78..442dc19240e 100644 --- a/Master/texmf-dist/scripts/context/ruby/textools.rb +++ b/Master/texmf-dist/scripts/context/ruby/textools.rb @@ -713,7 +713,7 @@ class Commands f << "\n" f << "/#{encoding.gsub(/[^a-zA-Z]/,'')}encoding [\n" 256.times do |i| - f << " /#{chars[i] || '.notdef'}\n" + f << " /#{chars[i] || '.notdef'} % #{i}\n" end f << "] def\n" f.close @@ -974,6 +974,8 @@ class Commands donepaths.keys.sort.each do |d| pathfiles = Dir.glob("#{path}/#{d}/**/*") pathfiles.each do |p| +# puts(File.dirname(p)) +# if donepaths[File.dirname(p)] then r = File.join(root,d,File.basename(p)) if FileTest.file?(p) and not FileTest.file?(r) and not copiedfiles.key?(File.expand_path(p)) then if delete then @@ -988,6 +990,7 @@ class Commands end end end +# end end end diff --git a/Master/texmf-dist/scripts/context/ruby/www/dir.rb b/Master/texmf-dist/scripts/context/ruby/www/dir.rb index 09e088d772d..115fd8911d9 100644 --- a/Master/texmf-dist/scripts/context/ruby/www/dir.rb +++ b/Master/texmf-dist/scripts/context/ruby/www/dir.rb @@ -62,9 +62,9 @@ class WWW end u = dir_uri(@variables.get('path') || '.') str << "<div class='dir-view'>\n<pre>\n" - str << "<a href=\"#{u}&n=#{d1}\">name</A>".ljust(49+u.length) - str << "<a href=\"#{u}&m=#{d1}\">last modified</A>".ljust(41+u.length) - str << "<a href=\"#{u}&s=#{d1}\">size</A>".rjust(31+u.length) << "\n" << "\n" + str << "<a href=\"#{u}&n=#{d1}\">name</a>".ljust(49+u.length) + str << "<a href=\"#{u}&m=#{d1}\">last modified</a>".ljust(41+u.length) + str << "<a href=\"#{u}&s=#{d1}\">size</a>".rjust(31+u.length) << "\n" << "\n" # parent path if showdirs && ! hidden.include?('..') then dname = "parent directory" diff --git a/Master/texmf-dist/scripts/context/ruby/www/exa.rb b/Master/texmf-dist/scripts/context/ruby/www/exa.rb index 5e9b3fd82e3..20a40fc7b66 100644 --- a/Master/texmf-dist/scripts/context/ruby/www/exa.rb +++ b/Master/texmf-dist/scripts/context/ruby/www/exa.rb @@ -156,32 +156,32 @@ class WWW req << "</exa:request>\n" else # better use rexml but slower - if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/mois then + if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/moi then threshold = $1 unless threshold.empty? then @interface.set('process:threshold', threshold) @session.set('threshold', threshold) end end - req.sub!(/(<exa:request[^>]*>.*?)\s*<exa:option>\s*\-\-action\=(.*?)\s*<\/exa:option>\s*(.*?<\/exa:request>)/mois) do + req.sub!(/(<exa:request[^>]*>.*?)\s*<exa:option>\s*\-\-action\=(.*?)\s*<\/exa:option>\s*(.*?<\/exa:request>)/moi) do pre, act, pos = $1, $2, $3 action = act.sub(/\.exa$/,'') if action.empty? str = "#{pre}<exa:action>#{action}</exa:action>#{pos}" - str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/mois ,'') + str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/moi ,'') end - req.sub!(/(<exa:request[^>]*>.*?)<exa:action>\s*(.*?)\s*<\/exa:action>(.*?<\/exa:request>)/mois) do + req.sub!(/(<exa:request[^>]*>.*?)<exa:action>\s*(.*?)\s*<\/exa:action>(.*?<\/exa:request>)/moi) do pre, act, pos = $1, $2, $3 action = act.sub(/\.exa$/,'') if action.empty? str = "#{pre}<exa:action>#{action}</exa:action>#{pos}" - str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/mois ,'') + str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/moi ,'') end - unless req =~ /<exa:data>(.*?)<\/exa:data>/mois then + unless req =~ /<exa:data>(.*?)<\/exa:data>/moi then req.sub!(/(<\/exa:request>)/) do dat + $1 end end end - req.sub!(/<exa:filename>.*?<\/exa:filename>/mois, '') + req.sub!(/<exa:filename>.*?<\/exa:filename>/moi, '') unless @variables.empty?('exa:filename') then - req.sub!(/(<\/exa:application>)/mois) do + req.sub!(/(<\/exa:application>)/moi) do "<exa:filename>#{@variables.get('exa:filename')}<\/exa:filename>" + $1 end end @@ -312,13 +312,13 @@ class WWW end unless req.empty? then # better use rexml but slower / reuse these : command = filter_from_request('exa:command') - if req =~ /<exa:request[^>]*>.*?\s*<exa:command>\s*(.*?)\s*<\/exa:command>\s*.*?<\/exa:request>/mois then + if req =~ /<exa:request[^>]*>.*?\s*<exa:command>\s*(.*?)\s*<\/exa:command>\s*.*?<\/exa:request>/moi then command = $1 end - if req =~ /<exa:request[^>]*>.*?\s*<exa:url>\s*(.*?)\s*<\/exa:url>\s*.*?<\/exa:request>/mois then + if req =~ /<exa:request[^>]*>.*?\s*<exa:url>\s*(.*?)\s*<\/exa:url>\s*.*?<\/exa:request>/moi then url = $1 end - if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/mois then + if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/moi then threshold = $1 unless threshold.empty? then @interface.set('process:threshold', threshold) @@ -368,6 +368,7 @@ class WWW end def handle_exastatus + get_cfg() # weird, needed for apache, but not for wwwserver if request_variable('id').empty? then if id = valid_session() then send_result() diff --git a/Master/texmf-dist/scripts/context/ruby/www/lib.rb b/Master/texmf-dist/scripts/context/ruby/www/lib.rb index f5f362b12d0..b9a44c9f61c 100644 --- a/Master/texmf-dist/scripts/context/ruby/www/lib.rb +++ b/Master/texmf-dist/scripts/context/ruby/www/lib.rb @@ -163,7 +163,7 @@ class WWW @interface.set('template:login' , 'exalogin.htm') @interface.set('process:timeout' , @@session_max_age) @interface.set('process:threshold' , @@send_threshold) - @interface.set('process:background', 'yes') # this demands a watchdog being active + @interface.set('process:background', 'yes') # this demands a watchdog being active @interface.set('process:indirect' , 'no') # indirect download, no direct feed @interface.set('process:autologin' , 'yes') # provide default interface when applicable @interface.set('process:exaurl' , '') # this one will be used as replacement in templates @@ -1226,6 +1226,12 @@ class WWW return ! (@session.nothing?('gui') && @session.nothing?('path') && @session.nothing?('process')) end + def get_cfg() + if data = load_interface_file() then + fetch_session_interface_variables(data) + end + end + end class WWW diff --git a/Master/texmf-dist/scripts/context/ruby/wwwserver.rb b/Master/texmf-dist/scripts/context/ruby/wwwserver.rb index 53e1cdc518e..13d5d13125c 100644 --- a/Master/texmf-dist/scripts/context/ruby/wwwserver.rb +++ b/Master/texmf-dist/scripts/context/ruby/wwwserver.rb @@ -1,4 +1,4 @@ -#!/usr/env ruby +#!/usr/bin/env ruby banner = ['WWWServer', 'version 1.0.0', '2003-2006', 'PRAGMA ADE/POD'] diff --git a/Master/texmf-dist/scripts/context/ruby/xmltools.rb b/Master/texmf-dist/scripts/context/ruby/xmltools.rb index 5b4a112b8b5..c28df200dd6 100644 --- a/Master/texmf-dist/scripts/context/ruby/xmltools.rb +++ b/Master/texmf-dist/scripts/context/ruby/xmltools.rb @@ -15,7 +15,7 @@ # This script will harbor some handy manipulations on tex # related files. -banner = ['XMLTools', 'version 1.2.1', '2002/2006', 'PRAGMA ADE/POD'] +banner = ['XMLTools', 'version 1.2.2', '2002/2007', 'PRAGMA ADE/POD'] $: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq! @@ -466,35 +466,35 @@ class Commands elements = Array.new preamble = "" done = false - data.sub!(/^(.*?)\s*(<[a-z])/mois) do + data.sub!(/^(.*?)\s*(<[a-z])/moi) do preamble = $1 $2 end # hide elements - data.gsub!(/<(.*?)>/mois) do + data.gsub!(/<([^>]*?)>/moi) do elements << $1 "<#{elements.length}>" end # abc[-/]def - data.gsub!(/([a-z]{3,})([\/\-])([a-z]{3,})/mois) do + data.gsub!(/([a-z]{3,})([\/\-\(\)]+)([a-z]{3,})/moi) do done = true report("compound: #{$1}#{$2}#{$3}") if verbose "#{$1}<compound token='#{$2}'/>#{$3}" end # (abcd - data.gsub!(/(\()([a-z]{4,})/mois) do - done = true - report("compound: #{$1}#{$2}") if verbose - "<compound token='#{$1}'/>#{$2}" - end + # data.gsub!(/(\()([a-z]{4,})/moi) do + # done = true + # report("compound: #{$1}#{$2}") if verbose + # "<compound token='#{$1}'/>#{$2}" + # end # abcd) - data.gsub!(/(\()([a-z]{4,})/mois) do - done = true - report("compound: #{$1}#{$2}") if verbose - "#{$2}<compound token='#{$2}'/>" - end + # data.gsub!(/(\()([a-z]{4,})/moi) do + # done = true + # report("compound: #{$1}#{$2}") if verbose + # "#{$2}<compound token='#{$2}'/>" + # end # roll back elements - data.gsub!(/<(\d+)>/mois) do + data.gsub!(/<(\d+)>/moi) do "<#{elements.shift}>" end File.open(newname,'wb') do |f| |