diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-23 11:04:57 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-23 11:04:57 +0200 |
commit | 9858ddd23d54c56b2ce9e1f5580190d3210d18ed (patch) | |
tree | a73afdfc043fae5b69367c89ec2d7f3fa56a870f /scripts | |
parent | e713d5aa882024dc438506c2f75eae6c5021a237 (diff) | |
download | context-9858ddd23d54c56b2ce9e1f5580190d3210d18ed.tar.gz |
2016-09-23 10:19:00
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-cache.lua | 2 | ||||
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 26 | ||||
-rw-r--r-- | scripts/context/lua/mtx-mtxworks.lua | 14 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 178 | ||||
-rw-r--r-- | scripts/context/ruby/rslb/base.rb | 270 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 178 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxworks.exe | bin | 4608 -> 0 bytes | |||
-rw-r--r-- | scripts/context/stubs/unix/ctxtools | 2 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mptopdf | 2 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 178 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxworks | 2 | ||||
-rw-r--r-- | scripts/context/stubs/unix/pstopdf | 2 | ||||
-rw-r--r-- | scripts/context/stubs/win64/mtxrun.lua | 178 | ||||
-rw-r--r-- | scripts/context/stubs/win64/mtxworks.exe | bin | 15360 -> 0 bytes |
14 files changed, 822 insertions, 210 deletions
diff --git a/scripts/context/lua/mtx-cache.lua b/scripts/context/lua/mtx-cache.lua index f0c0ae0ed..56d3df188 100644 --- a/scripts/context/lua/mtx-cache.lua +++ b/scripts/context/lua/mtx-cache.lua @@ -11,7 +11,7 @@ local helpinfo = [[ <application> <metadata> <entry name="name">mtx-cache</entry> - <entry name="detail">ConTeXt & MetaTeX Cache Management</entry> + <entry name="detail">ConTeXt & MetaTeX Cache Management</entry> <entry name="version">0.10</entry> </metadata> <flags> diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 84254d570..c65828622 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -12,7 +12,7 @@ if not modules then modules = { } end modules ['mtx-context'] = { local type, next, tostring, tonumber = type, next, tostring, tonumber local format, gmatch, match, gsub, find = string.format, string.gmatch, string.match, string.gsub, string.find local quote, validstring = string.quote, string.valid -local concat = table.concat +local sort, concat, insert, sortedhash = table.sort, table.concat, table.insert, table.sortedhash local settings_to_array = utilities.parsers.settings_to_array local appendtable = table.append local lpegpatterns, lpegmatch, Cs, P = lpeg.patterns, lpeg.match, lpeg.Cs, lpeg.P @@ -975,7 +975,7 @@ function scripts.context.pipe() -- still used? end local function make_mkiv_format(name,engine) - environment.make_format(name,environment.arguments.silent) -- jit is picked up later + environment.make_format(name) -- jit is picked up later end local make_mkii_format @@ -1438,6 +1438,7 @@ function scripts.context.modules(pattern) dir.glob(filejoinname(filepathpart(found,pattern)),list) end local done = { } -- todo : sort + local none = { x = { }, m = { }, s = { }, t = { } } for i=1,#list do local v = list[i] local base = filebasename(v) @@ -1445,7 +1446,7 @@ function scripts.context.modules(pattern) done[base] = true local suffix = filesuffix(base) if suffix == "tex" or suffix == "mkiv" or suffix == "mkvi" or suffix == "mkix" or suffix == "mkxi" then - local prefix = match(base,"^([xmst])%-") + local prefix, rest = match(base,"^([xmst])%-(.*)") if prefix then v = resolvers.findfile(base) -- so that files on my dev path are seen local data = io.loaddata(v) or "" @@ -1465,11 +1466,26 @@ function scripts.context.modules(pattern) end end report() + else + insert(none[prefix],rest) end end end end end + + local function show(k,v) + sort(v) + if #v > 0 then + report() + for i=1,#v do + report("%s : %s",k,v[i]) + end + end + end + for k, v in sortedhash(none) do + show(k,v) + end end -- extras @@ -1747,9 +1763,9 @@ elseif getargument("update") then scripts.context.update() elseif getargument("expert") then application.help("expert", "special") -elseif getargument("modules") then +elseif getargument("showmodules") or getargument("modules") then scripts.context.modules() -elseif getargument("extras") then +elseif getargument("showextras") or getargument("extras") then scripts.context.extras(environment.files[1] or getargument("extras")) elseif getargument("extra") then scripts.context.extra() diff --git a/scripts/context/lua/mtx-mtxworks.lua b/scripts/context/lua/mtx-mtxworks.lua deleted file mode 100644 index 1239ae4c5..000000000 --- a/scripts/context/lua/mtx-mtxworks.lua +++ /dev/null @@ -1,14 +0,0 @@ -if not modules then modules = { } end modules ['mtx-mtxworks'] = { - version = 1.002, - comment = "companion to mtxrun.lua", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - --- this is a shortcut to "mtxrun --script texworks --start" - -environment.setargument("start",true) - -require "mtx-texworks" - diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 818cabf26..da185dfd4 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -2377,7 +2377,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-io"] = package.loaded["l-io"] or true --- original size: 9001, stripped down to: 6512 +-- original size: 10421, stripped down to: 7499 if not modules then modules={} end modules ['l-io']={ version=1.001, @@ -2387,6 +2387,7 @@ if not modules then modules={} end modules ['l-io']={ license="see context related readme files" } local io=io +local open,flush,write,read=io.open,io.flush,io.write,io.read local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local floor=math.floor @@ -2403,15 +2404,13 @@ local function readall(f) local size=f:seek("end") if size==0 then return "" - elseif size<1024*1024 then - f:seek("set",0) + end + f:seek("set",0) + if size<1024*1024 then return f:read('*all') else - local done=f:seek("set",0) local step - if size<1024*1024 then - step=1024*1024 - elseif size>16*1024*1024 then + if size>16*1024*1024 then step=16*1024*1024 else step=floor(size/(1024*1024))*1024*1024/8 @@ -2429,7 +2428,7 @@ local function readall(f) end io.readall=readall function io.loaddata(filename,textmode) - local f=io.open(filename,(textmode and 'r') or 'rb') + local f=open(filename,(textmode and 'r') or 'rb') if f then local data=readall(f) f:close() @@ -2438,8 +2437,53 @@ function io.loaddata(filename,textmode) end end end +function io.copydata(source,target,action) + local f=open(source,"rb") + if f then + local g=open(target,"wb") + if g then + local size=f:seek("end") + if size==0 then + else + f:seek("set",0) + if size<1024*1024 then + local data=f:read('*all') + if action then + data=action(data) + end + if data then + g:write(data) + end + else + local step + if size>16*1024*1024 then + step=16*1024*1024 + else + step=floor(size/(1024*1024))*1024*1024/8 + end + while true do + local data=f:read(step) + if data then + if action then + data=action(data) + end + if data then + g:write(data) + end + else + break + end + end + end + end + g:close() + end + f:close() + flush() + end +end function io.savedata(filename,data,joiner) - local f=io.open(filename,"wb") + local f=open(filename,"wb") if f then if type(data)=="table" then f:write(concat(data,joiner or "")) @@ -2449,14 +2493,14 @@ function io.savedata(filename,data,joiner) f:write(data or "") end f:close() - io.flush() + flush() return true else return false end end function io.loadlines(filename,n) - local f=io.open(filename,'r') + local f=open(filename,'r') if not f then elseif n then local lines={} @@ -2482,7 +2526,7 @@ function io.loadlines(filename,n) end end function io.loadchunk(filename,n) - local f=io.open(filename,'rb') + local f=open(filename,'rb') if f then local data=f:read(n or 1024) f:close() @@ -2492,7 +2536,7 @@ function io.loadchunk(filename,n) end end function io.exists(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return false else @@ -2501,7 +2545,7 @@ function io.exists(filename) end end function io.size(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return 0 else @@ -2510,11 +2554,11 @@ function io.size(filename) return s end end -function io.noflines(f) +local function noflines(f) if type(f)=="string" then - local f=io.open(filename) + local f=open(filename) if f then - local n=f and io.noflines(f) or 0 + local n=f and noflines(f) or 0 f:close() return n else @@ -2529,6 +2573,7 @@ function io.noflines(f) return n end end +io.noflines=noflines local nextchar={ [ 4]=function(f) return f:read(1,1,1,1) @@ -2606,16 +2651,16 @@ function io.bytes(f,n) end function io.ask(question,default,options) while true do - io.write(question) + write(question) if options then - io.write(format(" [%s]",concat(options,"|"))) + write(format(" [%s]",concat(options,"|"))) end if default then - io.write(format(" [%s]",default)) + write(format(" [%s]",default)) end - io.write(format(" ")) - io.flush() - local answer=io.read() + write(format(" ")) + flush() + local answer=read() answer=gsub(answer,"^%s*(.*)%s*$","%1") if answer=="" and default then return default @@ -3292,7 +3337,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 21648, stripped down to: 10238 +-- original size: 21698, stripped down to: 10279 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3629,13 +3674,15 @@ function file.robustname(str,strict) end end end -file.readdata=io.loaddata -file.savedata=io.savedata +local loaddata=io.loaddata +local savedata=io.savedata +file.readdata=loaddata +file.savedata=savedata function file.copy(oldname,newname) if oldname and newname then - local data=io.loaddata(oldname) + local data=loaddata(oldname) if data and data~="" then - file.savedata(newname,data) + savedata(newname,data) end end end @@ -4031,7 +4078,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-dir"] = package.loaded["l-dir"] or true --- original size: 18247, stripped down to: 12022 +-- original size: 18330, stripped down to: 12091 if not modules then modules={} end modules ['l-dir']={ version=1.001, @@ -4484,9 +4531,13 @@ end file.expandname=dir.expandname local stack={} function dir.push(newdir) - insert(stack,currentdir()) + local curdir=currentdir() + insert(stack,curdir) if newdir and newdir~="" then chdir(newdir) + return newdir + else + return curdir end end function dir.pop() @@ -8082,7 +8133,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30767, stripped down to: 21312 +-- original size: 31048, stripped down to: 21463 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8128,6 +8179,14 @@ if tex and (tex.jobname or tex.formatname) then if texio.setescape then texio.setescape(0) end + if arg then + for k,v in next,arg do + if v=="--ansi" or v=="--c:ansi" then + variant="ansi" + break + end + end + end local function useluawrites() local texio_write_nl=texio.write_nl local texio_write=texio.write @@ -13891,7 +13950,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-xml"] = package.loaded["trac-xml"] or true --- original size: 6534, stripped down to: 5072 +-- original size: 6591, stripped down to: 5119 if not modules then modules={} end modules ['trac-xml']={ version=1.001, @@ -14041,6 +14100,7 @@ function reporters.export(t,methods,filename) if filename then local fullname=file.replacesuffix(filename,method) t.report("saving export in %a",fullname) + dir.mkdirs(file.pathpart(fullname)) io.savedata(fullname,result) else reporters.lines(t,result) @@ -17428,7 +17488,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-use"] = package.loaded["data-use"] or true --- original size: 4000, stripped down to: 3052 +-- original size: 4150, stripped down to: 3182 if not modules then modules={} end modules ['data-use']={ version=1.001, @@ -17473,7 +17533,7 @@ function resolvers.automount(usecache) end statistics.register("used config file",function() return caches.configfiles() end) statistics.register("used cache path",function() return caches.usedpaths() end) -function statistics.savefmtstatus(texname,formatbanner,sourcefile) +function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) local enginebanner=status.banner if formatbanner and enginebanner and sourcefile then local luvname=file.replacesuffix(texname,"luv") @@ -17484,6 +17544,10 @@ function statistics.savefmtstatus(texname,formatbanner,sourcefile) sourcefile=sourcefile, } io.savedata(luvname,table.serialize(luvdata,true)) + lua.registerfinalizer(function() + logs.report("format banner","%s",banner) + logs.newline() + end) end end function statistics.checkfmtstatus(texname) @@ -18725,7 +18789,7 @@ do -- create closure to overcome 200 locals limit package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true --- original size: 6967, stripped down to: 5631 +-- original size: 7413, stripped down to: 6012 if not modules then modules={} end modules ['luat-fmt']={ version=1.001, @@ -18739,23 +18803,42 @@ local concat=table.concat local quoted=string.quoted local luasuffixes=utilities.lua.suffixes local report_format=logs.reporter("resolvers","formats") -local function primaryflags() - local trackers=environment.argument("trackers") - local directives=environment.argument("directives") +local function primaryflags() + local arguments=environment.arguments + local flags={} + if arguments.silent then + flags[#flags+1]="--interaction=batchmode" + end + if arguments.jit then + flags[#flags+1]="--jiton" + end + return concat(flags," ") +end +local function secondaryflags() + local arguments=environment.arguments + local trackers=arguments.trackers + local directives=arguments.directives local flags={} if trackers and trackers~="" then - flags={ "--trackers="..quoted(trackers) } + flags[#flags+1]="--c:trackers="..quoted(trackers) end if directives and directives~="" then - flags={ "--directives="..quoted(directives) } + flags[#flags+1]="--c:directives="..quoted(directives) + end + if arguments.silent then + flags[#flags+1]="--c:silent" + end + if arguments.jit then + flags[#flags+1]="--c:jiton" end - if environment.argument("jit") then - flags={ "--jiton" } + if arguments.ansi then + flags[#flags+1]="--c:ansi" end return concat(flags," ") end -function environment.make_format(name,silent) +function environment.make_format(name,arguments) local engine=environment.ownmain or "luatex" + local silent=environment.arguments.silent local olddir=dir.current() local path=caches.getwritablepath("formats",engine) or "" if path~="" then @@ -18812,9 +18895,11 @@ function environment.make_format(name,silent) return end local dump=os.platform=="unix" and "\\\\dump" or "\\dump" + local command=format("%s --ini %s --lua=%s %s %s %s", + engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),secondaryflags(),dump) if silent then statistics.starttiming() - local command=format("%s --ini --interaction=batchmode %s --lua=%s %s %s > temp.log",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) + local command=format("%s > temp.log",command) local result=os.execute(command) local runtime=statistics.stoptiming() if result~=0 then @@ -18824,7 +18909,6 @@ function environment.make_format(name,silent) end os.remove("temp.log") else - local command=format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) report_format("running command: %s\n",command) os.execute(command) end @@ -18873,8 +18957,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 803046 --- stripped bytes : 291979 +-- original bytes : 805533 +-- stripped bytes : 292660 -- end library merge diff --git a/scripts/context/ruby/rslb/base.rb b/scripts/context/ruby/rslb/base.rb new file mode 100644 index 000000000..66ce3a19e --- /dev/null +++ b/scripts/context/ruby/rslb/base.rb @@ -0,0 +1,270 @@ +# hans hagen, pragma-ade, hasselt nl +# experimental code, don't touch it + +require 'rexml/document.rb' + +class Array + + def downcase + self.collect do |l| + l.to_s.downcase + end + end + +end + +class Resource + + @@rslburl = 'http://www.pragma-ade.com/rng/rslb.rng' + @@rslbns = 'rl' + @@rslbtmp = 'rslbtool-tmp.xml' + + def initialize (filename='',namespace=@@rslbns) + @ns = if namespace then @@rslbns + ':' else '' end + set_filename(filename) + @library = REXML::Document.new(skeleton, + {:ignore_whitespace_nodes => :all, + :compress_whitespace => :all}) + @lastindex = 0 + @texexec = 'texexec' + @downcaselabels = true + @downcasefilenames = true + end + + def keeplabelcase + @downcaselabels = false + end + + def keepfilenamecase + @downcasefilenames = false + end + + def outer_skeleton (str) + tmp = if @ns.empty? then '' else " xmlns:#{@ns.sub(':','')}='#{@@rslburl}'" end + "<?xml version='1.0'?>\n" + "<#{@ns}library#{tmp}>\n" + str + "\n</#{@ns}library>" + end + + def skeleton + outer_skeleton("<#{@ns}description>" + + "<#{@ns}organization>unknown</#{@ns}organization>" + + "<#{@ns}project>unknown</#{@ns}project>" + + "<#{@ns}product>unknown</#{@ns}product>" + + "<#{@ns}comment>unknown</#{@ns}comment>" + + "</#{@ns}description>") + end + + def set_filename (filename) + @filename = if filename.empty? then 'unknown' else filename end + @fullname = @filename + @filename = File.basename(@filename).sub(/\..*$/,'') + end + + def set_texexec (filename) + print "setting texexec binary to: #{filename}\n" + @texexec = filename + end + + def load (filename='') + set_filename(filename) + if not filename.empty? and FileTest.file?(filename) # todo: test op valide fig base + @library = REXML::Document.new(File.new(filename), + {:ignore_whitespace_nodes => :all, + :compress_whitespace => :all}) + unless @library.root.prefix.empty? + @ns = @library.root.prefix + ':' + end + else + initialize(filename,!@ns.empty?) + end + end + + def save (filename) + filename += '.xml' unless filename =~ /\..*?$/ + if not filename.empty? and f = open(filename,'w') + @library.write(f,0) + f.close + end + end + + def figure_labels + REXML::XPath.match(@library.root,"/#{@ns}library/#{@ns}figure/#{@ns}label/text()") + end + + def figure_records + @library.elements.to_a("/#{@ns}library/#{@ns}figure") + end + + def figure_files + REXML::XPath.match(@library.root,"/#{@ns}library/#{@ns}figure/#{@ns}file/text()") + end + + def delete_figure (label='') + return if label.empty? + labels = figure_labels + labels.each_index do |i| + if labels[i].to_s.downcase == label.downcase + @library.elements.delete_all("/#{@ns}library/#{@ns}figure[#{i+1}]") + end + end + end + + def add_figure (file='',label='',prefix='') + return if file.empty? or file.match(/^#{@filename}\..*$/i) + labels = figure_labels + prefix = @filename if prefix.empty? + if label.empty? + i = @lastindex + loop do + i += 1 + label = prefix + ' ' + i.to_s + break unless labels.include?(label) + end + else + delete_figure(label) unless label.empty? + end + e = REXML::Element.new("#{@ns}figure") + l = REXML::Element.new("#{@ns}label") + f = REXML::Element.new("#{@ns}file") + l.text, f.text = label, file + e.add_element(l) + e.add_element(f) + @library.root.add_element(e) + end + + def add_figures (list='',prefix='') + if @downcasefilenames then + files = figure_files.downcase + [list].flatten.downcase.each do |f| + next unless FileTest.file?(f) + add_figure(f,'',prefix) unless files.include?(f) + end + else + files = figure_files + [list].flatten.each do |f| + next unless FileTest.file?(f) + add_figure(f,'',prefix) unless files.include?(f) + end + end + end + + def delete_figures (list='') + [list].flatten.downcase.each do |l| + delete_figure(l) + end + end + + def sort_figures + if @downcaselabels then + labels = figure_labels.downcase + else + labels = figure_labels + end + return unless labels + figures = figure_records + @library.elements.delete_all("/#{@ns}library/#{@ns}figure") + labels = labels.collect do |l| # prepare numbers + l.gsub(/(\d+)/) do |d| sprintf('%05d', d) end + end + labels.sort.each do |s| + @library.root.add_element(figures[labels.index(s)]) + end + end + + def purge_figures + REXML::XPath.each(@library.root,"/#{@ns}library/#{@ns}figure") do |e| + filename = REXML::XPath.match(e,"#{@ns}file/text()").to_s + e.parent.delete(e) unless FileTest.file?(filename) + end + end + + def run_command(command) + print "calling #{command}\n" + print "\n" + begin + system(command) + rescue + # sorry again + end + print "\n" + end + + def create_dummies(process=false,result='',zipalso='') + result = @filename if result.empty? + list = REXML::XPath.match(@library.root,"/#{@ns}library/#{@ns}usage") + begin + File.delete(result+'.pdf') + rescue + # no way + end + return unless list && list.length>0 + done = Array.new + list.each do |e| + t = REXML::XPath.match(e,"#{@ns}type/text()") + s = REXML::XPath.match(e,"#{@ns}state/text()") + if t && (t.to_s == 'figure') && s && (s.to_s == 'missing') + begin + f = REXML::XPath.match(e,"#{@ns}file/text()").to_s + if done.index(f) + print "skipping dummy figure: " + f + "\n" + elsif f =~ /\s/o + print "skipping crappy fname: " + f + "\n" + elsif f == 'dummy' + print "skipping dummy figure: " + f + "\n" + else + print "creating dummy figure: " + f + "\n" + if process && (x = open(@@rslbtmp,'w')) + x.puts(outer_skeleton(e.to_s)) + x.close + run_command ("#{@texexec} --pdf --once --batch --silent --random --use=res-10 --xml --result=#{f} #{@@rslbtmp}") + end + done.push(f+'.pdf') + begin + File.delete(@@rslbtmp) + rescue + # sorry once more + end + end + rescue + # sorry, skip 'm + end + end + end + if process && (done.length>0) + begin + File.delete(result + '.zip') + rescue + # ok + end + run_command("zip #{result+'.zip'} #{@fullname}") + unless zipalso.empty? + begin + zipalso.split(',').each do |name| + run_command("zip #{result+'.zip'} #{name}") + end + end + end + done.each do |name| + run_command("zip #{result+'.zip'} #{name}") + end + run_command("#{@texexec} --pdf --batch --silent --use=res-11 --xml --result=#{result} #{@fullname}") + done.each do |name| + begin + File.delete(name) + rescue + # sorry + end + end + end + end + +end + +# reslib = Resource.new +# reslib.load('f.xml') # reslib.load('figbase.xml') +# reslib.delete_figure('figbase 5') +# reslib.delete_figure('figbase 5') +# reslib.add_figure('a.pdf') +# reslib.add_figure('b.pdf','something') +# reslib.add_figure('c.pdf') +# reslib.add_files('x.pdf') +# reslib.save('figbase.tmp') diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 818cabf26..da185dfd4 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -2377,7 +2377,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-io"] = package.loaded["l-io"] or true --- original size: 9001, stripped down to: 6512 +-- original size: 10421, stripped down to: 7499 if not modules then modules={} end modules ['l-io']={ version=1.001, @@ -2387,6 +2387,7 @@ if not modules then modules={} end modules ['l-io']={ license="see context related readme files" } local io=io +local open,flush,write,read=io.open,io.flush,io.write,io.read local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local floor=math.floor @@ -2403,15 +2404,13 @@ local function readall(f) local size=f:seek("end") if size==0 then return "" - elseif size<1024*1024 then - f:seek("set",0) + end + f:seek("set",0) + if size<1024*1024 then return f:read('*all') else - local done=f:seek("set",0) local step - if size<1024*1024 then - step=1024*1024 - elseif size>16*1024*1024 then + if size>16*1024*1024 then step=16*1024*1024 else step=floor(size/(1024*1024))*1024*1024/8 @@ -2429,7 +2428,7 @@ local function readall(f) end io.readall=readall function io.loaddata(filename,textmode) - local f=io.open(filename,(textmode and 'r') or 'rb') + local f=open(filename,(textmode and 'r') or 'rb') if f then local data=readall(f) f:close() @@ -2438,8 +2437,53 @@ function io.loaddata(filename,textmode) end end end +function io.copydata(source,target,action) + local f=open(source,"rb") + if f then + local g=open(target,"wb") + if g then + local size=f:seek("end") + if size==0 then + else + f:seek("set",0) + if size<1024*1024 then + local data=f:read('*all') + if action then + data=action(data) + end + if data then + g:write(data) + end + else + local step + if size>16*1024*1024 then + step=16*1024*1024 + else + step=floor(size/(1024*1024))*1024*1024/8 + end + while true do + local data=f:read(step) + if data then + if action then + data=action(data) + end + if data then + g:write(data) + end + else + break + end + end + end + end + g:close() + end + f:close() + flush() + end +end function io.savedata(filename,data,joiner) - local f=io.open(filename,"wb") + local f=open(filename,"wb") if f then if type(data)=="table" then f:write(concat(data,joiner or "")) @@ -2449,14 +2493,14 @@ function io.savedata(filename,data,joiner) f:write(data or "") end f:close() - io.flush() + flush() return true else return false end end function io.loadlines(filename,n) - local f=io.open(filename,'r') + local f=open(filename,'r') if not f then elseif n then local lines={} @@ -2482,7 +2526,7 @@ function io.loadlines(filename,n) end end function io.loadchunk(filename,n) - local f=io.open(filename,'rb') + local f=open(filename,'rb') if f then local data=f:read(n or 1024) f:close() @@ -2492,7 +2536,7 @@ function io.loadchunk(filename,n) end end function io.exists(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return false else @@ -2501,7 +2545,7 @@ function io.exists(filename) end end function io.size(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return 0 else @@ -2510,11 +2554,11 @@ function io.size(filename) return s end end -function io.noflines(f) +local function noflines(f) if type(f)=="string" then - local f=io.open(filename) + local f=open(filename) if f then - local n=f and io.noflines(f) or 0 + local n=f and noflines(f) or 0 f:close() return n else @@ -2529,6 +2573,7 @@ function io.noflines(f) return n end end +io.noflines=noflines local nextchar={ [ 4]=function(f) return f:read(1,1,1,1) @@ -2606,16 +2651,16 @@ function io.bytes(f,n) end function io.ask(question,default,options) while true do - io.write(question) + write(question) if options then - io.write(format(" [%s]",concat(options,"|"))) + write(format(" [%s]",concat(options,"|"))) end if default then - io.write(format(" [%s]",default)) + write(format(" [%s]",default)) end - io.write(format(" ")) - io.flush() - local answer=io.read() + write(format(" ")) + flush() + local answer=read() answer=gsub(answer,"^%s*(.*)%s*$","%1") if answer=="" and default then return default @@ -3292,7 +3337,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 21648, stripped down to: 10238 +-- original size: 21698, stripped down to: 10279 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3629,13 +3674,15 @@ function file.robustname(str,strict) end end end -file.readdata=io.loaddata -file.savedata=io.savedata +local loaddata=io.loaddata +local savedata=io.savedata +file.readdata=loaddata +file.savedata=savedata function file.copy(oldname,newname) if oldname and newname then - local data=io.loaddata(oldname) + local data=loaddata(oldname) if data and data~="" then - file.savedata(newname,data) + savedata(newname,data) end end end @@ -4031,7 +4078,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-dir"] = package.loaded["l-dir"] or true --- original size: 18247, stripped down to: 12022 +-- original size: 18330, stripped down to: 12091 if not modules then modules={} end modules ['l-dir']={ version=1.001, @@ -4484,9 +4531,13 @@ end file.expandname=dir.expandname local stack={} function dir.push(newdir) - insert(stack,currentdir()) + local curdir=currentdir() + insert(stack,curdir) if newdir and newdir~="" then chdir(newdir) + return newdir + else + return curdir end end function dir.pop() @@ -8082,7 +8133,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30767, stripped down to: 21312 +-- original size: 31048, stripped down to: 21463 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8128,6 +8179,14 @@ if tex and (tex.jobname or tex.formatname) then if texio.setescape then texio.setescape(0) end + if arg then + for k,v in next,arg do + if v=="--ansi" or v=="--c:ansi" then + variant="ansi" + break + end + end + end local function useluawrites() local texio_write_nl=texio.write_nl local texio_write=texio.write @@ -13891,7 +13950,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-xml"] = package.loaded["trac-xml"] or true --- original size: 6534, stripped down to: 5072 +-- original size: 6591, stripped down to: 5119 if not modules then modules={} end modules ['trac-xml']={ version=1.001, @@ -14041,6 +14100,7 @@ function reporters.export(t,methods,filename) if filename then local fullname=file.replacesuffix(filename,method) t.report("saving export in %a",fullname) + dir.mkdirs(file.pathpart(fullname)) io.savedata(fullname,result) else reporters.lines(t,result) @@ -17428,7 +17488,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-use"] = package.loaded["data-use"] or true --- original size: 4000, stripped down to: 3052 +-- original size: 4150, stripped down to: 3182 if not modules then modules={} end modules ['data-use']={ version=1.001, @@ -17473,7 +17533,7 @@ function resolvers.automount(usecache) end statistics.register("used config file",function() return caches.configfiles() end) statistics.register("used cache path",function() return caches.usedpaths() end) -function statistics.savefmtstatus(texname,formatbanner,sourcefile) +function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) local enginebanner=status.banner if formatbanner and enginebanner and sourcefile then local luvname=file.replacesuffix(texname,"luv") @@ -17484,6 +17544,10 @@ function statistics.savefmtstatus(texname,formatbanner,sourcefile) sourcefile=sourcefile, } io.savedata(luvname,table.serialize(luvdata,true)) + lua.registerfinalizer(function() + logs.report("format banner","%s",banner) + logs.newline() + end) end end function statistics.checkfmtstatus(texname) @@ -18725,7 +18789,7 @@ do -- create closure to overcome 200 locals limit package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true --- original size: 6967, stripped down to: 5631 +-- original size: 7413, stripped down to: 6012 if not modules then modules={} end modules ['luat-fmt']={ version=1.001, @@ -18739,23 +18803,42 @@ local concat=table.concat local quoted=string.quoted local luasuffixes=utilities.lua.suffixes local report_format=logs.reporter("resolvers","formats") -local function primaryflags() - local trackers=environment.argument("trackers") - local directives=environment.argument("directives") +local function primaryflags() + local arguments=environment.arguments + local flags={} + if arguments.silent then + flags[#flags+1]="--interaction=batchmode" + end + if arguments.jit then + flags[#flags+1]="--jiton" + end + return concat(flags," ") +end +local function secondaryflags() + local arguments=environment.arguments + local trackers=arguments.trackers + local directives=arguments.directives local flags={} if trackers and trackers~="" then - flags={ "--trackers="..quoted(trackers) } + flags[#flags+1]="--c:trackers="..quoted(trackers) end if directives and directives~="" then - flags={ "--directives="..quoted(directives) } + flags[#flags+1]="--c:directives="..quoted(directives) + end + if arguments.silent then + flags[#flags+1]="--c:silent" + end + if arguments.jit then + flags[#flags+1]="--c:jiton" end - if environment.argument("jit") then - flags={ "--jiton" } + if arguments.ansi then + flags[#flags+1]="--c:ansi" end return concat(flags," ") end -function environment.make_format(name,silent) +function environment.make_format(name,arguments) local engine=environment.ownmain or "luatex" + local silent=environment.arguments.silent local olddir=dir.current() local path=caches.getwritablepath("formats",engine) or "" if path~="" then @@ -18812,9 +18895,11 @@ function environment.make_format(name,silent) return end local dump=os.platform=="unix" and "\\\\dump" or "\\dump" + local command=format("%s --ini %s --lua=%s %s %s %s", + engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),secondaryflags(),dump) if silent then statistics.starttiming() - local command=format("%s --ini --interaction=batchmode %s --lua=%s %s %s > temp.log",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) + local command=format("%s > temp.log",command) local result=os.execute(command) local runtime=statistics.stoptiming() if result~=0 then @@ -18824,7 +18909,6 @@ function environment.make_format(name,silent) end os.remove("temp.log") else - local command=format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) report_format("running command: %s\n",command) os.execute(command) end @@ -18873,8 +18957,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 803046 --- stripped bytes : 291979 +-- original bytes : 805533 +-- stripped bytes : 292660 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxworks.exe b/scripts/context/stubs/mswin/mtxworks.exe Binary files differdeleted file mode 100644 index 0e7882cf9..000000000 --- a/scripts/context/stubs/mswin/mtxworks.exe +++ /dev/null diff --git a/scripts/context/stubs/unix/ctxtools b/scripts/context/stubs/unix/ctxtools new file mode 100644 index 000000000..2e6bd4afa --- /dev/null +++ b/scripts/context/stubs/unix/ctxtools @@ -0,0 +1,2 @@ +#!/bin/sh +mtxrun --script ctxtools "$@" diff --git a/scripts/context/stubs/unix/mptopdf b/scripts/context/stubs/unix/mptopdf new file mode 100644 index 000000000..147333740 --- /dev/null +++ b/scripts/context/stubs/unix/mptopdf @@ -0,0 +1,2 @@ +#!/bin/sh +mtxrun --script mptopdf "$@" diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 818cabf26..da185dfd4 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -2377,7 +2377,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-io"] = package.loaded["l-io"] or true --- original size: 9001, stripped down to: 6512 +-- original size: 10421, stripped down to: 7499 if not modules then modules={} end modules ['l-io']={ version=1.001, @@ -2387,6 +2387,7 @@ if not modules then modules={} end modules ['l-io']={ license="see context related readme files" } local io=io +local open,flush,write,read=io.open,io.flush,io.write,io.read local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local floor=math.floor @@ -2403,15 +2404,13 @@ local function readall(f) local size=f:seek("end") if size==0 then return "" - elseif size<1024*1024 then - f:seek("set",0) + end + f:seek("set",0) + if size<1024*1024 then return f:read('*all') else - local done=f:seek("set",0) local step - if size<1024*1024 then - step=1024*1024 - elseif size>16*1024*1024 then + if size>16*1024*1024 then step=16*1024*1024 else step=floor(size/(1024*1024))*1024*1024/8 @@ -2429,7 +2428,7 @@ local function readall(f) end io.readall=readall function io.loaddata(filename,textmode) - local f=io.open(filename,(textmode and 'r') or 'rb') + local f=open(filename,(textmode and 'r') or 'rb') if f then local data=readall(f) f:close() @@ -2438,8 +2437,53 @@ function io.loaddata(filename,textmode) end end end +function io.copydata(source,target,action) + local f=open(source,"rb") + if f then + local g=open(target,"wb") + if g then + local size=f:seek("end") + if size==0 then + else + f:seek("set",0) + if size<1024*1024 then + local data=f:read('*all') + if action then + data=action(data) + end + if data then + g:write(data) + end + else + local step + if size>16*1024*1024 then + step=16*1024*1024 + else + step=floor(size/(1024*1024))*1024*1024/8 + end + while true do + local data=f:read(step) + if data then + if action then + data=action(data) + end + if data then + g:write(data) + end + else + break + end + end + end + end + g:close() + end + f:close() + flush() + end +end function io.savedata(filename,data,joiner) - local f=io.open(filename,"wb") + local f=open(filename,"wb") if f then if type(data)=="table" then f:write(concat(data,joiner or "")) @@ -2449,14 +2493,14 @@ function io.savedata(filename,data,joiner) f:write(data or "") end f:close() - io.flush() + flush() return true else return false end end function io.loadlines(filename,n) - local f=io.open(filename,'r') + local f=open(filename,'r') if not f then elseif n then local lines={} @@ -2482,7 +2526,7 @@ function io.loadlines(filename,n) end end function io.loadchunk(filename,n) - local f=io.open(filename,'rb') + local f=open(filename,'rb') if f then local data=f:read(n or 1024) f:close() @@ -2492,7 +2536,7 @@ function io.loadchunk(filename,n) end end function io.exists(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return false else @@ -2501,7 +2545,7 @@ function io.exists(filename) end end function io.size(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return 0 else @@ -2510,11 +2554,11 @@ function io.size(filename) return s end end -function io.noflines(f) +local function noflines(f) if type(f)=="string" then - local f=io.open(filename) + local f=open(filename) if f then - local n=f and io.noflines(f) or 0 + local n=f and noflines(f) or 0 f:close() return n else @@ -2529,6 +2573,7 @@ function io.noflines(f) return n end end +io.noflines=noflines local nextchar={ [ 4]=function(f) return f:read(1,1,1,1) @@ -2606,16 +2651,16 @@ function io.bytes(f,n) end function io.ask(question,default,options) while true do - io.write(question) + write(question) if options then - io.write(format(" [%s]",concat(options,"|"))) + write(format(" [%s]",concat(options,"|"))) end if default then - io.write(format(" [%s]",default)) + write(format(" [%s]",default)) end - io.write(format(" ")) - io.flush() - local answer=io.read() + write(format(" ")) + flush() + local answer=read() answer=gsub(answer,"^%s*(.*)%s*$","%1") if answer=="" and default then return default @@ -3292,7 +3337,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 21648, stripped down to: 10238 +-- original size: 21698, stripped down to: 10279 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3629,13 +3674,15 @@ function file.robustname(str,strict) end end end -file.readdata=io.loaddata -file.savedata=io.savedata +local loaddata=io.loaddata +local savedata=io.savedata +file.readdata=loaddata +file.savedata=savedata function file.copy(oldname,newname) if oldname and newname then - local data=io.loaddata(oldname) + local data=loaddata(oldname) if data and data~="" then - file.savedata(newname,data) + savedata(newname,data) end end end @@ -4031,7 +4078,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-dir"] = package.loaded["l-dir"] or true --- original size: 18247, stripped down to: 12022 +-- original size: 18330, stripped down to: 12091 if not modules then modules={} end modules ['l-dir']={ version=1.001, @@ -4484,9 +4531,13 @@ end file.expandname=dir.expandname local stack={} function dir.push(newdir) - insert(stack,currentdir()) + local curdir=currentdir() + insert(stack,curdir) if newdir and newdir~="" then chdir(newdir) + return newdir + else + return curdir end end function dir.pop() @@ -8082,7 +8133,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30767, stripped down to: 21312 +-- original size: 31048, stripped down to: 21463 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8128,6 +8179,14 @@ if tex and (tex.jobname or tex.formatname) then if texio.setescape then texio.setescape(0) end + if arg then + for k,v in next,arg do + if v=="--ansi" or v=="--c:ansi" then + variant="ansi" + break + end + end + end local function useluawrites() local texio_write_nl=texio.write_nl local texio_write=texio.write @@ -13891,7 +13950,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-xml"] = package.loaded["trac-xml"] or true --- original size: 6534, stripped down to: 5072 +-- original size: 6591, stripped down to: 5119 if not modules then modules={} end modules ['trac-xml']={ version=1.001, @@ -14041,6 +14100,7 @@ function reporters.export(t,methods,filename) if filename then local fullname=file.replacesuffix(filename,method) t.report("saving export in %a",fullname) + dir.mkdirs(file.pathpart(fullname)) io.savedata(fullname,result) else reporters.lines(t,result) @@ -17428,7 +17488,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-use"] = package.loaded["data-use"] or true --- original size: 4000, stripped down to: 3052 +-- original size: 4150, stripped down to: 3182 if not modules then modules={} end modules ['data-use']={ version=1.001, @@ -17473,7 +17533,7 @@ function resolvers.automount(usecache) end statistics.register("used config file",function() return caches.configfiles() end) statistics.register("used cache path",function() return caches.usedpaths() end) -function statistics.savefmtstatus(texname,formatbanner,sourcefile) +function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) local enginebanner=status.banner if formatbanner and enginebanner and sourcefile then local luvname=file.replacesuffix(texname,"luv") @@ -17484,6 +17544,10 @@ function statistics.savefmtstatus(texname,formatbanner,sourcefile) sourcefile=sourcefile, } io.savedata(luvname,table.serialize(luvdata,true)) + lua.registerfinalizer(function() + logs.report("format banner","%s",banner) + logs.newline() + end) end end function statistics.checkfmtstatus(texname) @@ -18725,7 +18789,7 @@ do -- create closure to overcome 200 locals limit package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true --- original size: 6967, stripped down to: 5631 +-- original size: 7413, stripped down to: 6012 if not modules then modules={} end modules ['luat-fmt']={ version=1.001, @@ -18739,23 +18803,42 @@ local concat=table.concat local quoted=string.quoted local luasuffixes=utilities.lua.suffixes local report_format=logs.reporter("resolvers","formats") -local function primaryflags() - local trackers=environment.argument("trackers") - local directives=environment.argument("directives") +local function primaryflags() + local arguments=environment.arguments + local flags={} + if arguments.silent then + flags[#flags+1]="--interaction=batchmode" + end + if arguments.jit then + flags[#flags+1]="--jiton" + end + return concat(flags," ") +end +local function secondaryflags() + local arguments=environment.arguments + local trackers=arguments.trackers + local directives=arguments.directives local flags={} if trackers and trackers~="" then - flags={ "--trackers="..quoted(trackers) } + flags[#flags+1]="--c:trackers="..quoted(trackers) end if directives and directives~="" then - flags={ "--directives="..quoted(directives) } + flags[#flags+1]="--c:directives="..quoted(directives) + end + if arguments.silent then + flags[#flags+1]="--c:silent" + end + if arguments.jit then + flags[#flags+1]="--c:jiton" end - if environment.argument("jit") then - flags={ "--jiton" } + if arguments.ansi then + flags[#flags+1]="--c:ansi" end return concat(flags," ") end -function environment.make_format(name,silent) +function environment.make_format(name,arguments) local engine=environment.ownmain or "luatex" + local silent=environment.arguments.silent local olddir=dir.current() local path=caches.getwritablepath("formats",engine) or "" if path~="" then @@ -18812,9 +18895,11 @@ function environment.make_format(name,silent) return end local dump=os.platform=="unix" and "\\\\dump" or "\\dump" + local command=format("%s --ini %s --lua=%s %s %s %s", + engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),secondaryflags(),dump) if silent then statistics.starttiming() - local command=format("%s --ini --interaction=batchmode %s --lua=%s %s %s > temp.log",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) + local command=format("%s > temp.log",command) local result=os.execute(command) local runtime=statistics.stoptiming() if result~=0 then @@ -18824,7 +18909,6 @@ function environment.make_format(name,silent) end os.remove("temp.log") else - local command=format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) report_format("running command: %s\n",command) os.execute(command) end @@ -18873,8 +18957,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 803046 --- stripped bytes : 291979 +-- original bytes : 805533 +-- stripped bytes : 292660 -- end library merge diff --git a/scripts/context/stubs/unix/mtxworks b/scripts/context/stubs/unix/mtxworks deleted file mode 100644 index ef8f230c3..000000000 --- a/scripts/context/stubs/unix/mtxworks +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --script texworks --start diff --git a/scripts/context/stubs/unix/pstopdf b/scripts/context/stubs/unix/pstopdf new file mode 100644 index 000000000..116f5f4a3 --- /dev/null +++ b/scripts/context/stubs/unix/pstopdf @@ -0,0 +1,2 @@ +#!/bin/sh +mtxrun --script pstopdf "$@" diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 818cabf26..da185dfd4 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -2377,7 +2377,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-io"] = package.loaded["l-io"] or true --- original size: 9001, stripped down to: 6512 +-- original size: 10421, stripped down to: 7499 if not modules then modules={} end modules ['l-io']={ version=1.001, @@ -2387,6 +2387,7 @@ if not modules then modules={} end modules ['l-io']={ license="see context related readme files" } local io=io +local open,flush,write,read=io.open,io.flush,io.write,io.read local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local floor=math.floor @@ -2403,15 +2404,13 @@ local function readall(f) local size=f:seek("end") if size==0 then return "" - elseif size<1024*1024 then - f:seek("set",0) + end + f:seek("set",0) + if size<1024*1024 then return f:read('*all') else - local done=f:seek("set",0) local step - if size<1024*1024 then - step=1024*1024 - elseif size>16*1024*1024 then + if size>16*1024*1024 then step=16*1024*1024 else step=floor(size/(1024*1024))*1024*1024/8 @@ -2429,7 +2428,7 @@ local function readall(f) end io.readall=readall function io.loaddata(filename,textmode) - local f=io.open(filename,(textmode and 'r') or 'rb') + local f=open(filename,(textmode and 'r') or 'rb') if f then local data=readall(f) f:close() @@ -2438,8 +2437,53 @@ function io.loaddata(filename,textmode) end end end +function io.copydata(source,target,action) + local f=open(source,"rb") + if f then + local g=open(target,"wb") + if g then + local size=f:seek("end") + if size==0 then + else + f:seek("set",0) + if size<1024*1024 then + local data=f:read('*all') + if action then + data=action(data) + end + if data then + g:write(data) + end + else + local step + if size>16*1024*1024 then + step=16*1024*1024 + else + step=floor(size/(1024*1024))*1024*1024/8 + end + while true do + local data=f:read(step) + if data then + if action then + data=action(data) + end + if data then + g:write(data) + end + else + break + end + end + end + end + g:close() + end + f:close() + flush() + end +end function io.savedata(filename,data,joiner) - local f=io.open(filename,"wb") + local f=open(filename,"wb") if f then if type(data)=="table" then f:write(concat(data,joiner or "")) @@ -2449,14 +2493,14 @@ function io.savedata(filename,data,joiner) f:write(data or "") end f:close() - io.flush() + flush() return true else return false end end function io.loadlines(filename,n) - local f=io.open(filename,'r') + local f=open(filename,'r') if not f then elseif n then local lines={} @@ -2482,7 +2526,7 @@ function io.loadlines(filename,n) end end function io.loadchunk(filename,n) - local f=io.open(filename,'rb') + local f=open(filename,'rb') if f then local data=f:read(n or 1024) f:close() @@ -2492,7 +2536,7 @@ function io.loadchunk(filename,n) end end function io.exists(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return false else @@ -2501,7 +2545,7 @@ function io.exists(filename) end end function io.size(filename) - local f=io.open(filename) + local f=open(filename) if f==nil then return 0 else @@ -2510,11 +2554,11 @@ function io.size(filename) return s end end -function io.noflines(f) +local function noflines(f) if type(f)=="string" then - local f=io.open(filename) + local f=open(filename) if f then - local n=f and io.noflines(f) or 0 + local n=f and noflines(f) or 0 f:close() return n else @@ -2529,6 +2573,7 @@ function io.noflines(f) return n end end +io.noflines=noflines local nextchar={ [ 4]=function(f) return f:read(1,1,1,1) @@ -2606,16 +2651,16 @@ function io.bytes(f,n) end function io.ask(question,default,options) while true do - io.write(question) + write(question) if options then - io.write(format(" [%s]",concat(options,"|"))) + write(format(" [%s]",concat(options,"|"))) end if default then - io.write(format(" [%s]",default)) + write(format(" [%s]",default)) end - io.write(format(" ")) - io.flush() - local answer=io.read() + write(format(" ")) + flush() + local answer=read() answer=gsub(answer,"^%s*(.*)%s*$","%1") if answer=="" and default then return default @@ -3292,7 +3337,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 21648, stripped down to: 10238 +-- original size: 21698, stripped down to: 10279 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3629,13 +3674,15 @@ function file.robustname(str,strict) end end end -file.readdata=io.loaddata -file.savedata=io.savedata +local loaddata=io.loaddata +local savedata=io.savedata +file.readdata=loaddata +file.savedata=savedata function file.copy(oldname,newname) if oldname and newname then - local data=io.loaddata(oldname) + local data=loaddata(oldname) if data and data~="" then - file.savedata(newname,data) + savedata(newname,data) end end end @@ -4031,7 +4078,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-dir"] = package.loaded["l-dir"] or true --- original size: 18247, stripped down to: 12022 +-- original size: 18330, stripped down to: 12091 if not modules then modules={} end modules ['l-dir']={ version=1.001, @@ -4484,9 +4531,13 @@ end file.expandname=dir.expandname local stack={} function dir.push(newdir) - insert(stack,currentdir()) + local curdir=currentdir() + insert(stack,curdir) if newdir and newdir~="" then chdir(newdir) + return newdir + else + return curdir end end function dir.pop() @@ -8082,7 +8133,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30767, stripped down to: 21312 +-- original size: 31048, stripped down to: 21463 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8128,6 +8179,14 @@ if tex and (tex.jobname or tex.formatname) then if texio.setescape then texio.setescape(0) end + if arg then + for k,v in next,arg do + if v=="--ansi" or v=="--c:ansi" then + variant="ansi" + break + end + end + end local function useluawrites() local texio_write_nl=texio.write_nl local texio_write=texio.write @@ -13891,7 +13950,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-xml"] = package.loaded["trac-xml"] or true --- original size: 6534, stripped down to: 5072 +-- original size: 6591, stripped down to: 5119 if not modules then modules={} end modules ['trac-xml']={ version=1.001, @@ -14041,6 +14100,7 @@ function reporters.export(t,methods,filename) if filename then local fullname=file.replacesuffix(filename,method) t.report("saving export in %a",fullname) + dir.mkdirs(file.pathpart(fullname)) io.savedata(fullname,result) else reporters.lines(t,result) @@ -17428,7 +17488,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-use"] = package.loaded["data-use"] or true --- original size: 4000, stripped down to: 3052 +-- original size: 4150, stripped down to: 3182 if not modules then modules={} end modules ['data-use']={ version=1.001, @@ -17473,7 +17533,7 @@ function resolvers.automount(usecache) end statistics.register("used config file",function() return caches.configfiles() end) statistics.register("used cache path",function() return caches.usedpaths() end) -function statistics.savefmtstatus(texname,formatbanner,sourcefile) +function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) local enginebanner=status.banner if formatbanner and enginebanner and sourcefile then local luvname=file.replacesuffix(texname,"luv") @@ -17484,6 +17544,10 @@ function statistics.savefmtstatus(texname,formatbanner,sourcefile) sourcefile=sourcefile, } io.savedata(luvname,table.serialize(luvdata,true)) + lua.registerfinalizer(function() + logs.report("format banner","%s",banner) + logs.newline() + end) end end function statistics.checkfmtstatus(texname) @@ -18725,7 +18789,7 @@ do -- create closure to overcome 200 locals limit package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true --- original size: 6967, stripped down to: 5631 +-- original size: 7413, stripped down to: 6012 if not modules then modules={} end modules ['luat-fmt']={ version=1.001, @@ -18739,23 +18803,42 @@ local concat=table.concat local quoted=string.quoted local luasuffixes=utilities.lua.suffixes local report_format=logs.reporter("resolvers","formats") -local function primaryflags() - local trackers=environment.argument("trackers") - local directives=environment.argument("directives") +local function primaryflags() + local arguments=environment.arguments + local flags={} + if arguments.silent then + flags[#flags+1]="--interaction=batchmode" + end + if arguments.jit then + flags[#flags+1]="--jiton" + end + return concat(flags," ") +end +local function secondaryflags() + local arguments=environment.arguments + local trackers=arguments.trackers + local directives=arguments.directives local flags={} if trackers and trackers~="" then - flags={ "--trackers="..quoted(trackers) } + flags[#flags+1]="--c:trackers="..quoted(trackers) end if directives and directives~="" then - flags={ "--directives="..quoted(directives) } + flags[#flags+1]="--c:directives="..quoted(directives) + end + if arguments.silent then + flags[#flags+1]="--c:silent" + end + if arguments.jit then + flags[#flags+1]="--c:jiton" end - if environment.argument("jit") then - flags={ "--jiton" } + if arguments.ansi then + flags[#flags+1]="--c:ansi" end return concat(flags," ") end -function environment.make_format(name,silent) +function environment.make_format(name,arguments) local engine=environment.ownmain or "luatex" + local silent=environment.arguments.silent local olddir=dir.current() local path=caches.getwritablepath("formats",engine) or "" if path~="" then @@ -18812,9 +18895,11 @@ function environment.make_format(name,silent) return end local dump=os.platform=="unix" and "\\\\dump" or "\\dump" + local command=format("%s --ini %s --lua=%s %s %s %s", + engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),secondaryflags(),dump) if silent then statistics.starttiming() - local command=format("%s --ini --interaction=batchmode %s --lua=%s %s %s > temp.log",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) + local command=format("%s > temp.log",command) local result=os.execute(command) local runtime=statistics.stoptiming() if result~=0 then @@ -18824,7 +18909,6 @@ function environment.make_format(name,silent) end os.remove("temp.log") else - local command=format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump) report_format("running command: %s\n",command) os.execute(command) end @@ -18873,8 +18957,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 803046 --- stripped bytes : 291979 +-- original bytes : 805533 +-- stripped bytes : 292660 -- end library merge diff --git a/scripts/context/stubs/win64/mtxworks.exe b/scripts/context/stubs/win64/mtxworks.exe Binary files differdeleted file mode 100644 index 93290a6e0..000000000 --- a/scripts/context/stubs/win64/mtxworks.exe +++ /dev/null |