diff options
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/base')
7 files changed, 277 insertions, 72 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/ctx.rb b/Master/texmf-dist/scripts/context/ruby/base/ctx.rb index 0baf5a88b1b..dff9570d837 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/ctx.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/ctx.rb @@ -84,7 +84,7 @@ class CtxRunner end if ! done && defaultname && FileTest.file?(defaultname) then report("using default ctxfile #{defaultname}") - @ctxname = defaultname + @ctxname, done = defaultname, true end if not done then report('no ctx file found') @@ -115,23 +115,34 @@ class CtxRunner if @jobname then variables['job'] = @jobname end - REXML::XPath.each(@xmldata.root,"//ctx:value[@name='job']") do |val| + root = @xmldata.root + begin + REXML::XPath.each(root,"//ctx:block") do |blk| + if @jobname && blk.attributes['pattern'] then + root.delete(blk) unless @jobname =~ /#{blk.attributes['pattern']}/ + else + root.delete(blk) + end + end + rescue + end + REXML::XPath.each(root,"//ctx:value[@name='job']") do |val| substititute(val,variables['job']) end - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:message") do |mes| + REXML::XPath.each(root,"/ctx:job//ctx:message") do |mes| report("preprocessing: #{justtext(mes)}") end - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:process/ctx:resources/ctx:environment") do |sty| + REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:environment") do |sty| @environments << justtext(sty) end - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:process/ctx:resources/ctx:module") do |mod| + REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:module") do |mod| @modules << justtext(mod) end - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:process/ctx:resources/ctx:filter") do |fil| + REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:filter") do |fil| @filters << justtext(fil) end commands = Hash.new - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:preprocess/ctx:processors/ctx:processor") do |pre| + REXML::XPath.each(root,"/ctx:job//ctx:preprocess/ctx:processors/ctx:processor") do |pre| begin commands[pre.attributes['name']] = pre rescue @@ -139,13 +150,13 @@ class CtxRunner end suffix = @@suffix begin - suffix = REXML::XPath.match(@xmldata.root,"/ctx:job/ctx:preprocess/@suffix").to_s + 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 - REXML::XPath.each(@xmldata.root,"/ctx:job/ctx:preprocess/ctx:files") do |files| + REXML::XPath.each(root,"/ctx:job//ctx:preprocess/ctx:files") do |files| REXML::XPath.each(files,"ctx:file") do |pattern| preprocessor = pattern.attributes['processor'] if preprocessor and not preprocessor.empty? then @@ -267,7 +278,7 @@ class CtxRunner if f = File.open(fullname,'r') and i = REXML::Document.new(f) then report("including ctx file #{name}") REXML::XPath.each(i.root,"*") do |ii| - xmldata.root.insert_after(e,ii) + xmldata.root.insert_before(e,ii) more = true end end @@ -275,8 +286,8 @@ class CtxRunner end rescue end + break if done end - break if done end report("no valid ctx inclusion file #{name}") unless done rescue Exception diff --git a/Master/texmf-dist/scripts/context/ruby/base/kpse.rb b/Master/texmf-dist/scripts/context/ruby/base/kpse.rb index b0321672fc1..bff3cc1fae7 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/kpse.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/kpse.rb @@ -28,6 +28,10 @@ class String end end + def sane_path + self.gsub(/\\/,'/') + end + end class Array @@ -36,6 +40,12 @@ class Array self.join(File::PATH_SEPARATOR) end + def non_empty + self.delete_if do |i| + (i == nil || i.empty?) rescue false + end + end + end module Kpse @@ -96,42 +106,57 @@ module Kpse @@scripts.keys.sort.each do |k| puts("scripts : #{k} -> #{@@scripts[k]}\n") end end + def Kpse.used_path(varname) + begin + if @@mswindows then + path = run("--expand-path=\$#{varname}") rescue '' + else + path = run("--expand-path='$#{varname}'") rescue '' + end + rescue + path = '' + end + return path.sane_path + end + def Kpse.found(filename, progname=nil, format=nil) begin tag = Kpse.key(filename) # all if @@located.key?(tag) then - return @@located[tag] + return @@located[tag].sane_path elsif FileTest.file?(filename) then setvariable(tag,filename) return filename elsif FileTest.file?(File.join(@@ownpath,filename)) then setvariable(tag,File.join(@@ownpath,filename)) - return @@located[tag] + return @@located[tag].sane_path else [progname,@@progname].flatten.compact.uniq.each do |prg| [format,@@formats].flatten.compact.uniq.each do |fmt| begin tag = Kpse.key(filename,prg,fmt) if @@located.key?(tag) then - return @@located[tag] + return @@located[tag].sane_path elsif p = Kpse.kpsewhich(filename,prg,fmt) then setvariable(tag,p.chomp) - return @@located[tag] + return @@located[tag].sane_path end rescue end end end setvariable(tag,filename) - return filename + return filename.sane_path end rescue - filename + filename.sane_path end end def Kpse.kpsewhich(filename,progname,format) - Kpse.run("-progname=#{progname} -format=\"#{format}\" #{filename}") + p = if progname && ! progname.empty? then "-progname=#{progname}" else '' end + f = if format && ! format.empty? then "-format=\"#{format}\"" else '' end + Kpse.run("#{p} #{f} #{filename}") end def Kpse.which @@ -160,7 +185,7 @@ module Kpse # maybe we should check for writeability unless @@paths.key?('formatpaths') then begin - setpath('formatpaths',run("--show-path=fmt").gsub(/\\/,'/').split_path) + setpath('formatpaths',run("--show-path=fmt").sane_path.split_path) rescue setpath('formatpaths',[]) end diff --git a/Master/texmf-dist/scripts/context/ruby/base/kpsefast.rb b/Master/texmf-dist/scripts/context/ruby/base/kpsefast.rb index 20c07c70a4e..24ff1a0fa7c 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/kpsefast.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/kpsefast.rb @@ -9,6 +9,8 @@ # www : www.pragma-ade.com # todo: multiple cnf files +# +# todo: cleanup, string or table store (as in lua variant) class String diff --git a/Master/texmf-dist/scripts/context/ruby/base/mp.rb b/Master/texmf-dist/scripts/context/ruby/base/mp.rb index b30be111091..5dd2948cffc 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/mp.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/mp.rb @@ -91,8 +91,8 @@ EOT f.puts("") f.puts(@@start[method]) end - data.gsub!(/[^\\]%.*?$/mo) do - '' + data.gsub!(/([^\\])%.*?$/mo) do + $1 end data.scan(/(verbatim|b)tex\s*(.*?)\s*etex/mo) do tag, text = $1, $2 diff --git a/Master/texmf-dist/scripts/context/ruby/base/tex.rb b/Master/texmf-dist/scripts/context/ruby/base/tex.rb index a6403dcde2b..f6f3dc4ed83 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/tex.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/tex.rb @@ -85,6 +85,9 @@ class TEX @@pdftex = 'pdftex' # new default, pdfetex is gone + @@luafiles = "luafiles.tmp" + @@luatarget = "lua/context" + ENV['PATH'].split(File::PATH_SEPARATOR).each do |p| if System.unix? then pp, pe = "#{p}/pdftex" , "#{p}/pdfetex" @@ -113,7 +116,7 @@ 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 - ['dvips','ps'] .each do |b| @@backends[b] = 'dvips' 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 ['xdv','xdv2pdf'] .each do |b| @@backends[b] = 'xdv2pdf' end @@ -164,7 +167,7 @@ class TEX @@runoptions['xetex'] = ['--8bit -no-pdf'] # from now on we assume (x)dvipdfmx to be used @@runoptions['pdfetex'] = ['--8bit '] @@runoptions['pdftex'] = ['--8bit '] # pdftex is now pdfetex - @@runoptions['luatex'] = ['--8bit '] + @@runoptions['luatex'] = [''] @@runoptions['aleph'] = ['--8bit '] @@booleanvars = [ @@ -225,6 +228,29 @@ class TEX @@extrabooleanvars << vars end + # def jobvariables(names=nil) + # if [names ||[]].flatten.size == 0 then + # names = [allbooleanvars,allstringvars].flatten + # end + # data = Hash.new + # names.each do |name| + # if allbooleanvars.include?(name) then + # data[name] = if getvariable(name) then "yes" else "no" end + # else + # data[name] = getvariable(name) + # end + # end + # data + # end + + # def setjobvariables(names=nil) + # assignments = Array.new + # jobvariables(names).each do |k,v| + # assignments << "#{k}=\{#{v}\}" + # end + # "\setvariables[exe][#{assignments.join(", ")}]" + # end + @@temprunfile = 'texexec' @@temptexfile = 'texexec.tex' @@ -524,6 +550,41 @@ class TEX return version end + def cleanupluafiles + File.delete(@@luafiles) rescue false + end + + def compileluafiles + begin + Dir.glob("lua/context/*.luc").each do |luc| + File.delete(luc) rescue false + end + rescue + end + if data = (IO.readlines(@@luafiles) rescue nil) then + report("compiling lua files (using #{File.expand_path(@@luafiles)})") + begin + Dir.makedirs(@@luatarget) rescue false + data.each do |line| + luafile = line.chomp + lucfile = File.basename(luafile).gsub(/\..*?$/,'') + ".luc" + if runcommand(["luac","-s","-o",quoted(File.join(Dir.getwd,@@luatarget,lucfile)),quoted(luafile)]) then + report("#{File.basename(luafile)} converted to #{File.basename(lucfile)}") + else + report("#{File.basename(luafile)} not converted to #{File.basename(lucfile)}") + end + end + rescue + report("fatal error in compilation") + end + else + report("no lua compilations needed") + end + File.delete(@@luafiles) rescue false + end + + # we need engine methods + def makeformats checktestversion @@ -561,9 +622,18 @@ class TEX makeuserfile makeresponsefile end - texformats.each do |texformat| - report("generating tex format #{texformat}") - runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)]) + if texengine == 'luatex' then + cleanupluafiles + texformats.each do |texformat| + report("generating tex format #{texformat}") +run_luatools("--ini --compile #{texformat}") + end + compileluafiles + else + texformats.each do |texformat| + report("generating tex format #{texformat}") + runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)]) + end end else report("unable to make format due to lack of permissions") @@ -592,8 +662,10 @@ class TEX mpsformatpath = '' end # check for problems + report("") report("tex engine path: #{texformatpath}") unless texformatpath.empty? report("mps engine path: #{mpsformatpath}") unless mpsformatpath.empty? + report("") [['fmt','tex'],['mem','mps']].each do |f| [[texformatpath,'global'],[mpsformatpath,'global'],[savedpath,'current']].each do |p| begin @@ -601,11 +673,20 @@ class TEX rescue else Dir.glob("*.#{f[0]}").each do |file| - report("#{f[1]}format: #{filestate(file)} > #{File.expand_path(file)}") + report("#{f[1]}: #{filestate(file)} > #{File.expand_path(file)} (#{File.size(file)})") end end end end + begin + lucdir = File.join(texformatpath,@@luatarget) + Dir.chdir(lucdir) + rescue + else + Dir.glob("*.luc").each do |file| + report("luc: #{filestate(file)} > #{File.expand_path(file)} (#{File.size(file)})") + end + end # to be sure, go back to current path begin Dir.chdir(savedpath) @@ -613,6 +694,7 @@ class TEX end # finalize cleanup + report("") reportruntime end @@ -853,10 +935,10 @@ class TEX rname = File.unsuffixed(resultname) if ! rname.empty? && (rname != fname) then report("outputfile #{rname}") - ['tuo','log','dvi','pdf'].each do |s| + ['tuo','tuc','log','dvi','pdf'].each do |s| File.silentrename(File.suffixed(fname,s),File.suffixed('texexec',s)) end - ['tuo'].each do |s| + ['tuo','tuc'].each do |s| File.silentrename(File.suffixed(rname,s),File.suffixed(fname,s)) if FileTest.file?(File.suffixed(rname,s)) end end @@ -867,12 +949,12 @@ class TEX rname = File.unsuffixed(resultname) if ! rname.empty? && (rname != fname) then report("renaming #{fname} to #{rname}") - ['tuo','log','dvi','pdf'].each do |s| + ['tuo','tuc','log','dvi','pdf'].each do |s| File.silentrename(File.suffixed(fname,s),File.suffixed(rname,s)) end report("restoring #{fname}") unless $fname == 'texexec' then - ['tuo','log','dvi','pdf'].each do |s| + ['tuo','tuc','log','dvi','pdf'].each do |s| File.silentrename(File.suffixed('texexec',s),File.suffixed(fname,s)) end end @@ -1034,6 +1116,20 @@ class TEX public + 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("lua #{script} #{args}") + end + end + end + return runcommand("texmfstart luatools #{args}") + end + def processmpgraphic getarrayvariable('files').each do |filename| setvariable('filename',filename) @@ -1126,6 +1222,38 @@ class TEX reportruntime end + def processmpstatic + if filename = getvariable('filename') then + filename += ".mp" unless filename =~ /\..+?$/ + if FileTest.file?(filename) then + begin + data = IO.read(filename) + File.open("texexec.tex",'w') do |f| + f << "\\setupoutput[pdftex]\n" + f << "\\setupcolors[state=start]\n" + data.sub!(/^%mpenvironment\:\s*(.*?)$/mois) do + f << $1 + "\n" + end + f << "\\starttext\n" + f << "\\startMPpage\n" + f << data.gsub(/end\.*\s*$/m, '') # a bit of a hack + f << "\\stopMPpage\n" + f << "\\stoptext\n" + end + report("converting static '#{filename}'") + runtex("texexec.tex") + pdffile = File.suffixed(filename,'pdf') + File.silentrename("texexec.pdf",pdffile) + report ("#{filename} converted to #{pdffile}") + rescue + report("error in converting #{filename} (#{$!}") + end + end + end + reportruntime + end + def processmpxtex getarrayvariable('files').each do |filename| setvariable('filename',filename) @@ -1372,7 +1500,11 @@ class TEX report("progname: #{progname}") if texengine && texformat && progname then fixbackendvars(@@mappaths[texengine]) +if texengine == "luatex" then + run_luatools("--fmt=#{texformat} #{filename}") +else runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)]) +end # true else false @@ -1451,7 +1583,25 @@ class TEX end end - # 1=tex 2=mptex 3=mpxtex 4=mpgraphic + def runluacheck(jobname) + if false then + # test-pos.tex / 6 meg tua file: 18.6 runtime + old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc') + if FileTest.file?(old) then + report("converting #{old} into #{new}") + system("luac -s -o #{new} #{old}") + end + else + # test-pos.tex / 6 meg tua file: 17.5 runtime + old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc') + if FileTest.file?(old) then + report("renaming #{old} into #{new}") + File.rename(old,new) rescue false + end + end + end + + # 1=tex 2=mptex 3=mpxtex 4=mpgraphic 5=mpstatic def runtexexec(filename=[], options=[], mode=nil) begin @@ -1470,6 +1620,7 @@ class TEX when 2 then job.processmptex when 3 then job.processmpxtex when 4 then job.processmpgraphic + when 5 then job.processmpstatic end job.inspect && Kpse.inspect if getvariable('verbose') return true @@ -1658,6 +1809,7 @@ class TEX ok = runtex(if dummyfile || forcexml then rawbase else rawname end) if ok then ok = runtexutil(rawbase) if getvariable('texutil') || getvariable('forcetexutil') + runluacheck(rawbase) runbackend(rawbase) popresult(rawbase,result) end @@ -1667,10 +1819,11 @@ class TEX end end else +# goto tmp/jobname when present mprundone, ok, stoprunning = false, true, false texruns, nofruns = 0, getvariable('runs').to_i state = FileState.new - ['tub','tuo'].each do |s| + ['tub','tuo','tuc'].each do |s| state.register(File.suffixed(rawbase,s)) end if getvariable('automprun') then # check this @@ -1690,13 +1843,16 @@ class TEX makeoptionfile(rawbase,jobname,orisuffix,false,false,2,texruns) # unknown end end +# goto . ok = runtex(File.suffixed(if dummyfile || forcexml then rawbase else rawname end,jobsuffix)) +# goto tmp/jobname when present if ok && (nofruns > 1) then unless getvariable('nompmode') then mprundone = runtexmpjob(rawbase, "mpgraph") mprundone = runtexmpjob(rawbase, "mprun") end ok = runtexutil(rawbase) + runluacheck(rawbase) state.update stoprunning = state.stable? end @@ -1704,11 +1860,16 @@ class TEX if not ok then setvariable('error','error in tex file') end - ok = runtexutil(rawbase) if (nofruns == 1) && getvariable('texutil') + if (nofruns == 1) && getvariable('texutil') then + ok = runtexutil(rawbase) + runluacheck(rawbase) + end if ok && finalrun && (nofruns > 1) then makeoptionfile(rawbase,jobname,orisuffix,true,finalrun,4,texruns) unless getvariable('nooptionfile') report("final TeX run #{texruns}") +# goto . ok = runtex(File.suffixed(if dummyfile || forcexml then rawbase else rawname end,jobsuffix)) +# goto tmp/jobname when present end if getvariable('keep') then ['top','log','run'].each do |suffix| @@ -1721,8 +1882,11 @@ class TEX # File.silentdelete(File.suffixed(rawbase,s)) # end if ok then +# goto . runbackend(rawbase) popresult(rawbase,result) +# goto tmp/jobname when present +# skip next end if true then # autopurge begin @@ -1755,14 +1919,14 @@ class TEX end end rescue - report("fatal error #{$!}") + # report("fatal error #{$!}") end end end Kpse.runscript('ctxtools',rawbase,'--purge') if getvariable('purge') Kpse.runscript('ctxtools',rawbase,'--purge --all') if getvariable('purgeall') - +# till here when 'latex' then ok = runtex(rawname) @@ -1913,7 +2077,7 @@ class TEX def purge_mpx_files(mpname) unless getvariable('keep') then - ['tex', 'log', 'tui', 'tuo', 'top'].each do |suffix| + ['tex', 'log', 'tui', 'tuo', 'tuc', 'top'].each do |suffix| File.silentdelete(File.suffixed(mpname,'temp',suffix)) end end diff --git a/Master/texmf-dist/scripts/context/ruby/base/texutil.rb b/Master/texmf-dist/scripts/context/ruby/base/texutil.rb index 2bca831675e..7c402b98f85 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/texutil.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/texutil.rb @@ -235,7 +235,11 @@ class TeXUtil end def tokenize(str) - str.gsub(/\\strchr\{(.*?)\}/o) do "\\#{$1}" end + if str then + str.gsub(/\\strchr\{(.*?)\}/o) do "\\#{$1}" end + else + "" + end end def remap(str) @@ -461,7 +465,6 @@ class TeXUtil class Synonym @@debug = false - @@debug = true def initialize(t, c, k, d) @type, @command, @key, @sortkey, @data = t, c, k, k, d @@ -559,7 +562,6 @@ class TeXUtil @@specialbanner = "" # \\relax" @@debug = false - @@debug = true @@howto = /^(.*?)\:\:(.*)$/o @@split = ' && ' @@ -598,7 +600,8 @@ class TeXUtil # end end else - @entry, @key = cleanupsplit(@entry), cleanupsplit(@key) + # @entry, @key = cleanupsplit(@entry), cleanupsplit(@key) +@entry, @key = cleanupsplit(@entry), xcleanupsplit(@key) end @sortkey = sorter.simplify(@key) # special = @sortkey =~ /^([^a-zA-Z\\])/o @@ -613,7 +616,7 @@ class TeXUtil @entry, @texthowto.ljust(10,' '), # @state, # no, messes up things - (@realpage ||'').rjust(6,' ').gsub(/0/,' '), + (@realpage.to_s || '').rjust(6,' ').gsub(/0/,' '), # (@realpage ||'').rjust(6,' '), @pagehowto ].join(@@split) @@ -628,6 +631,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 <=> (other) @sortkey <=> other.sortkey end @@ -659,11 +679,13 @@ class TeXUtil alphaclass, alpha = '', '' @@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', '' if @@debug then + # if true then list.each do |entry| handle << "% [#{entry.sortkey.gsub(/#{@@split}/o,'] [')}]\n" end end list.each do |entry| +# puts(entry.sortkey.gsub(/\s+/,"")) if entry.sortkey =~ /^(\S+)/o then if sorter.division?($1) then testalpha = sorter.getdivision($1) @@ -738,6 +760,7 @@ class TeXUtil elsif @@savedhowto != entry.pagehowto and ! entry.pagehowto.empty? then @@savedhowto = entry.pagehowto 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}}" savedline = "{#{entry.type}}{#{@@savedhowto},#{entry.texthowto}}{#{entry.location}}{#{entry.page}}{#{entry.realpage}}" @@ -791,7 +814,8 @@ class TeXUtil @@registers[data[1]].push(Register.new(3,data[1],data[2],data[3],data[4],nil,data[5],data[6])) when 's' then @@registers[data[1]] = Array.new unless @@registers.key?(data[1]) - @@registers[data[1]].push(Register.new(4,data[1],data[2],data[3],data[4],data[5],data[6],nil)) + # was this but wrong sort order (4,data[1],data[2],data[3],data[4],data[5],data[6],nil)) + @@registers[data[1]].push(Register.new(4,data[1],data[2],data[3],data[4],data[5],data[6],0)) when 'l' then @@languages[data[1]] = data[2] || '' end @@ -820,6 +844,7 @@ class TeXUtil @@registers[s].each_index do |i| @@registers[s][i].build(@@sorter[s]) end + # @@registers[s].uniq! @@registers[s] = @@registers[s].sort end end diff --git a/Master/texmf-dist/scripts/context/ruby/base/tool.rb b/Master/texmf-dist/scripts/context/ruby/base/tool.rb index 9f120ca117a..77ad947fe1e 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/tool.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/tool.rb @@ -129,7 +129,7 @@ module Tool def Tool.simplefilename(old) - return old unless test(?f,old) + return old if not FileTest.file?(old) new = old.downcase new.gsub!(/[^A-Za-z0-9\_\-\.\\\/]/o) do # funny chars @@ -141,9 +141,10 @@ module Tool $1 + ':' end end - new.gsub!(/(.+?)\.(.+?)(\..+)$/o) do # duplicate . - $1 + '-' + $2 + $3 - end + # fragile for a.b.c.d.bla-bla.e.eps + # new.gsub!(/(.+?)\.(.+?)(\..+)$/o) do # duplicate . + # $1 + '-' + $2 + $3 + # end new.gsub!(/\-+/o) do # duplicate - '-' end @@ -244,7 +245,7 @@ module Tool new.sub!(/\.ai$/io) do '.eps' end - new.sub!(/\.ai(.*?)$/io) do + new.sub!(/\.ai([a-z0-9]*)$/io) do '-' + $1 + '.eps' end new @@ -253,7 +254,7 @@ module Tool def Tool.cleanfilename(old,logging=nil) - return old unless test(?f,old) + return old if not FileTest.file?(old) new = checksuffix(simplefilename(old)) unless new == old @@ -269,29 +270,6 @@ module Tool end - def Tool.preventduplicates(old,logging=nil) - - return false unless test(?f,old) - - if old =~ /\.(tif|jpg|png|tiff)$/io - suffix = $1 - new = old - newn, news = new.split('.') - if test(?e,'newn.eps') - new = newn + '-' + suffix + '.' + suffix - begin - File.rename(old,new) - logging.report("renaming duplicate #{old} to #{new}") unless logging - return true - rescue - logging.report("unable to rename duplicate #{old} to #{new}") unless logging - end - end - end - return false - - end - def Tool.servername host = Socket::gethostname begin |