summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-03-13 19:31:00 +0100
committerHans Hagen <pragma@wxs.nl>2013-03-13 19:31:00 +0100
commitb7b5b5a42f937eeccc519e61f015343d6e95b01b (patch)
tree7f0ed16e09a6280326610d89e455cd4ec3786c7c
parent5626463eac244d7c6a934c18667de121bd8944fe (diff)
downloadcontext-b7b5b5a42f937eeccc519e61f015343d6e95b01b.tar.gz
beta 2013.03.13 19:31
-rw-r--r--scripts/context/lua/mtxrun.lua702
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua702
-rwxr-xr-xscripts/context/stubs/unix/mtxrun702
-rw-r--r--tex/context/base/context-version.pdfbin4147 -> 4144 bytes
-rw-r--r--tex/context/base/context-version.pngbin40467 -> 40426 bytes
-rw-r--r--tex/context/base/core-ctx.mkiv1
-rw-r--r--tex/context/base/core-def.mkiv4
-rw-r--r--tex/context/base/data-lst.lua13
-rw-r--r--tex/context/base/file-job.lua147
-rw-r--r--tex/context/base/font-age.lua2
-rw-r--r--tex/context/base/font-syn.lua4
-rw-r--r--tex/context/base/l-lpeg.lua34
-rw-r--r--tex/context/base/l-os.lua2
-rw-r--r--tex/context/base/lpdf-xmp.lua11
-rw-r--r--tex/context/base/luat-cod.lua8
-rw-r--r--tex/context/base/luat-fio.lua7
-rw-r--r--tex/context/base/luat-lib.mkiv5
-rw-r--r--tex/context/base/luat-run.lua19
-rw-r--r--tex/context/base/luat-sto.lua31
-rw-r--r--tex/context/base/lxml-tex.lua10
-rw-r--r--tex/context/base/node-ext.lua4
-rw-r--r--tex/context/base/node-fin.lua2
-rw-r--r--tex/context/base/node-ini.lua16
-rw-r--r--tex/context/base/node-ser.lua2
-rw-r--r--tex/context/base/node-tra.lua5
-rw-r--r--tex/context/base/status-files.pdfbin24740 -> 24755 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin210149 -> 209945 bytes
-rw-r--r--tex/context/base/toks-ini.lua2
-rw-r--r--tex/context/base/trac-inf.lua39
-rw-r--r--tex/context/base/trac-log.lua80
-rw-r--r--tex/context/base/trac-set.lua60
-rw-r--r--tex/context/base/util-deb.lua12
-rw-r--r--tex/context/base/util-sto.lua12
-rw-r--r--tex/context/base/x-calcmath.lua81
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua3
35 files changed, 1460 insertions, 1262 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 53c299283..6e8a36d18 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -275,7 +275,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true
--- original size: 26334, stripped down to: 14439
+-- original size: 26269, stripped down to: 14392
if not modules then modules={} end modules ['l-lpeg']={
version=1.001,
@@ -285,7 +285,6 @@ if not modules then modules={} end modules ['l-lpeg']={
license="see context related readme files"
}
lpeg=require("lpeg")
-local report=texio and texio.write_nl or print
local type,next,tostring=type,next,tostring
local byte,char,gmatch,format=string.byte,string.char,string.gmatch,string.format
local floor=math.floor
@@ -2378,7 +2377,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 13687, stripped down to: 8406
+-- original size: 13692, stripped down to: 8406
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -5140,7 +5139,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4270, stripped down to: 2989
+-- original size: 4237, stripped down to: 2975
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5153,11 +5152,11 @@ local setmetatable,getmetatable=setmetatable,getmetatable
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
-local report=texio and texio.write_nl or print
function storage.mark(t)
if not t then
- report("fatal error: storage cannot be marked")
- return
+ print("\nfatal error: storage cannot be marked\n")
+ os.exit()
+ return
end
local m=getmetatable(t)
if not m then
@@ -5183,8 +5182,9 @@ function storage.marked(t)
end
function storage.checked(t)
if not t then
- report("fatal error: storage has not been allocated")
- return
+ report("\nfatal error: storage has not been allocated\n")
+ os.exit()
+ return
end
return t
end
@@ -5757,294 +5757,9 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-deb"] = package.loaded["util-deb"] or true
-
--- original size: 3676, stripped down to: 2553
-
-if not modules then modules={} end modules ['util-deb']={
- version=1.001,
- comment="companion to luat-lib.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local debug=require "debug"
-local getinfo=debug.getinfo
-local type,next,tostring=type,next,tostring
-local format,find=string.format,string.find
-local is_boolean=string.is_boolean
-utilities=utilities or {}
-utilities.debugger=utilities.debugger or {}
-local debugger=utilities.debugger
-local counters={}
-local names={}
-local function hook()
- local f=getinfo(2)
- if f then
- local n="unknown"
- if f.what=="C" then
- n=f.name or '<anonymous>'
- if not names[n] then
- names[n]=format("%42s",n)
- end
- else
- n=f.name or f.namewhat or f.what
- if not n or n=="" then
- n="?"
- end
- if not names[n] then
- names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
- end
- end
- counters[n]=(counters[n] or 0)+1
- end
-end
-function debugger.showstats(printer,threshold)
- printer=printer or texio.write or print
- threshold=threshold or 0
- local total,grandtotal,functions=0,0,0
- local dataset={}
- for name,count in next,counters do
- dataset[#dataset+1]={ name,count }
- end
- table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
- for i=1,#dataset do
- local d=dataset[i]
- local name=d[1]
- local count=d[2]
- if count>threshold and not find(name,"for generator") then
- printer(format("%8i %s\n",count,names[name]))
- total=total+count
- end
- grandtotal=grandtotal+count
- functions=functions+1
- end
- printer("\n")
- printer(format("functions : % 10i\n",functions))
- printer(format("total : % 10i\n",total))
- printer(format("grand total: % 10i\n",grandtotal))
- printer(format("threshold : % 10i\n",threshold))
-end
-function debugger.savestats(filename,threshold)
- local f=io.open(filename,'w')
- if f then
- debugger.showstats(function(str) f:write(str) end,threshold)
- f:close()
- end
-end
-function debugger.enable()
- debug.sethook(hook,"c")
-end
-function debugger.disable()
- debug.sethook()
-end
-function traceback()
- local level=1
- while true do
- local info=debug.getinfo(level,"Sl")
- if not info then
- break
- elseif info.what=="C" then
- print(format("%3i : C function",level))
- else
- print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
- end
- level=level+1
- end
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
-package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
-
--- original size: 6380, stripped down to: 5101
-
-if not modules then modules={} end modules ['trac-inf']={
- version=1.001,
- comment="companion to trac-inf.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local type,tonumber=type,tonumber
-local format,lower=string.format,string.lower
-local concat=table.concat
-local clock=os.gettimeofday or os.clock
-local write_nl=texio and texio.write_nl or print
-statistics=statistics or {}
-local statistics=statistics
-statistics.enable=true
-statistics.threshold=0.01
-local statusinfo,n,registered,timers={},0,{},{}
-table.setmetatableindex(timers,function(t,k)
- local v={ timing=0,loadtime=0 }
- t[k]=v
- return v
-end)
-local function hastiming(instance)
- return instance and timers[instance]
-end
-local function resettiming(instance)
- timers[instance or "notimer"]={ timing=0,loadtime=0 }
-end
-local function starttiming(instance)
- local timer=timers[instance or "notimer"]
- local it=timer.timing or 0
- if it==0 then
- timer.starttime=clock()
- if not timer.loadtime then
- timer.loadtime=0
- end
- end
- timer.timing=it+1
-end
-local function stoptiming(instance,report)
- local timer=timers[instance or "notimer"]
- local it=timer.timing
- if it>1 then
- timer.timing=it-1
- else
- local starttime=timer.starttime
- if starttime then
- local stoptime=clock()
- local loadtime=stoptime-starttime
- timer.stoptime=stoptime
- timer.loadtime=timer.loadtime+loadtime
- if report then
- statistics.report("load time %0.3f",loadtime)
- end
- timer.timing=0
- return loadtime
- end
- end
- return 0
-end
-local function elapsed(instance)
- if type(instance)=="number" then
- return instance or 0
- else
- local timer=timers[instance or "notimer"]
- return timer and timer.loadtime or 0
- end
-end
-local function elapsedtime(instance)
- return format("%0.3f",elapsed(instance))
-end
-local function elapsedindeed(instance)
- return elapsed(instance)>statistics.threshold
-end
-local function elapsedseconds(instance,rest)
- if elapsedindeed(instance) then
- return format("%0.3f seconds %s",elapsed(instance),rest or "")
- end
-end
-statistics.hastiming=hastiming
-statistics.resettiming=resettiming
-statistics.starttiming=starttiming
-statistics.stoptiming=stoptiming
-statistics.elapsed=elapsed
-statistics.elapsedtime=elapsedtime
-statistics.elapsedindeed=elapsedindeed
-statistics.elapsedseconds=elapsedseconds
-function statistics.register(tag,fnc)
- if statistics.enable and type(fnc)=="function" then
- local rt=registered[tag] or (#statusinfo+1)
- statusinfo[rt]={ tag,fnc }
- registered[tag]=rt
- if #tag>n then n=#tag end
- end
-end
-function statistics.show(reporter)
- if statistics.enable then
- if not reporter then reporter=function(tag,data,n) write_nl(tag.." "..data) end end
- local register=statistics.register
- register("luatex banner",function()
- return lower(status.banner)
- end)
- register("control sequences",function()
- return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
- end)
- register("callbacks",function()
- local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
- return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
- end)
- if jit then
- local status={ jit.status() }
- if status[1] then
- register("luajit status",function()
- return concat(status," ",2)
- end)
- end
- end
- collectgarbage("collect")
- register("current memory usage",statistics.memused)
- register("runtime",statistics.runtime)
- for i=1,#statusinfo do
- local s=statusinfo[i]
- local r=s[2]()
- if r then
- reporter(s[1],r,n)
- end
- end
- write_nl("")
- statistics.enable=false
- end
-end
-local template,report_statistics,nn=nil,nil,0
-function statistics.showjobstat(tag,data,n)
- if not logs then
- elseif type(data)=="table" then
- for i=1,#data do
- statistics.showjobstat(tag,data[i],n)
- end
- else
- if not template or n>nn then
- template,n=format("%%-%ss - %%s",n),nn
- report_statistics=logs.reporter("mkiv lua stats")
- end
- report_statistics(format(template,tag,data))
- end
-end
-function statistics.memused()
- local round=math.round or math.floor
- return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
-end
-starttiming(statistics)
-function statistics.formatruntime(runtime)
- return format("%s seconds",runtime)
-end
-function statistics.runtime()
- stoptiming(statistics)
- return statistics.formatruntime(elapsedtime(statistics))
-end
-function statistics.timed(action,report)
- report=report or logs.reporter("system")
- starttiming("run")
- action()
- stoptiming("run")
- report("total runtime: %s",elapsedtime("run"))
-end
-commands=commands or {}
-function commands.resettimer(name)
- resettiming(name or "whatever")
- starttiming(name or "whatever")
-end
-function commands.elapsedtime(name)
- stoptiming(name or "whatever")
- context(elapsedtime(name or "whatever"))
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12501, stripped down to: 8920
+-- original size: 12360, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6061,8 +5776,8 @@ local settings_to_hash=utilities.parsers.settings_to_hash
local allocate=utilities.storage.allocate
utilities=utilities or {}
local utilities=utilities
-utilities.setters=utilities.setters or {}
-local setters=utilities.setters
+local setters=utilities.setters or {}
+utilities.setters=setters
local data={}
local trace_initialize=false
function setters.initialize(filename,name,values)
@@ -6246,14 +5961,8 @@ function setters.show(t)
t.report()
end
local enable,disable,register,list,show=setters.enable,setters.disable,setters.register,setters.list,setters.show
-local write_nl=texio and texio.write_nl or print
-local function report(setter,...)
- local report=logs and logs.report
- if report then
- report(setter.name,...)
- else
- write_nl(format("%-15s : %s\n",setter.name,format(...)))
- end
+function setters.report(setter,...)
+ print(format("%-15s : %s\n",setter.name,format(...)))
end
local function default(setter,name)
local d=setter.data[name]
@@ -6268,12 +5977,12 @@ function setters.new(name)
setter={
data=allocate(),
name=name,
- report=function(...) report (setter,...) end,
- enable=function(...) enable (setter,...) end,
- disable=function(...) disable (setter,...) end,
- register=function(...) register(setter,...) end,
- list=function(...) list (setter,...) end,
- show=function(...) show (setter,...) end,
+ report=function(...) setters.report (setter,...) end,
+ enable=function(...) enable (setter,...) end,
+ disable=function(...) disable (setter,...) end,
+ register=function(...) register(setter,...) end,
+ list=function(...) list (setter,...) end,
+ show=function(...) show (setter,...) end,
default=function(...) return default (setter,...) end,
value=function(...) return value (setter,...) end,
}
@@ -6283,40 +5992,46 @@ end
trackers=setters.new("trackers")
directives=setters.new("directives")
experiments=setters.new("experiments")
-local t_enable,t_disable,t_report=trackers .enable,trackers .disable,trackers .report
-local d_enable,d_disable,d_report=directives .enable,directives .disable,directives .report
-local e_enable,e_disable,e_report=experiments.enable,experiments.disable,experiments.report
+local t_enable,t_disable=trackers .enable,trackers .disable
+local d_enable,d_disable=directives .enable,directives .disable
+local e_enable,e_disable=experiments.enable,experiments.disable
local trace_directives=false local trace_directives=false trackers.register("system.directives",function(v) trace_directives=v end)
local trace_experiments=false local trace_experiments=false trackers.register("system.experiments",function(v) trace_experiments=v end)
function directives.enable(...)
if trace_directives then
- d_report("enabling: % t",{...})
+ directives.report("enabling: % t",{...})
end
d_enable(...)
end
function directives.disable(...)
if trace_directives then
- d_report("disabling: % t",{...})
+ directives.report("disabling: % t",{...})
end
d_disable(...)
end
function experiments.enable(...)
if trace_experiments then
- e_report("enabling: % t",{...})
+ experiments.report("enabling: % t",{...})
end
e_enable(...)
end
function experiments.disable(...)
if trace_experiments then
- e_report("disabling: % t",{...})
+ experiments.report("disabling: % t",{...})
end
e_disable(...)
end
directives.register("system.nostatistics",function(v)
- statistics.enable=not v
+ if statistics then
+ statistics.enable=not v
+ else
+ end
end)
directives.register("system.nolibraries",function(v)
- libraries=nil
+ if libraries then
+ libraries=nil
+ else
+ end
end)
if environment then
local engineflags=environment.engineflags
@@ -6356,7 +6071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 19098, stripped down to: 13439
+-- original size: 20646, stripped down to: 14629
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6365,6 +6080,49 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
+if tex and (tex.jobname or tex.formatname) then
+ local texio_write_nl=texio.write_nl
+ local texio_write=texio.write
+ local io_write=io.write
+ local write_nl=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(...)
+ elseif target=="log" then
+ texio_write_nl("log",...)
+ elseif target=="term" then
+ texio_write_nl("term","")
+ io_write(...)
+ else
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(target,...)
+ end
+ end
+ local write=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write("log",...)
+ io_write(...)
+ elseif target=="log" then
+ texio_write("log",...)
+ elseif target=="term" then
+ io_write(...)
+ else
+ texio_write("log",...)
+ io_write(target,...)
+ end
+ end
+ texio.write=write
+ texio.write_nl=write_nl
+else
+end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6696,6 +6454,14 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
+local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k)
+ t[k]=v
+ return v
+end)
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
directives.register("logs.blocked",function(v)
setblocked(v,true)
end)
@@ -6749,7 +6515,6 @@ function logs.stop_page_number()
end
logs.flush()
end
-logs.report_job_stat=statistics and statistics.showjobstat
local report_files=logs.reporter("files")
local nesting=0
local verbose=false
@@ -6877,6 +6642,173 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
+
+-- original size: 5791, stripped down to: 4540
+
+if not modules then modules={} end modules ['trac-inf']={
+ version=1.001,
+ comment="companion to trac-inf.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tonumber=type,tonumber
+local format,lower=string.format,string.lower
+local concat=table.concat
+local clock=os.gettimeofday or os.clock
+statistics=statistics or {}
+local statistics=statistics
+statistics.enable=true
+statistics.threshold=0.01
+local statusinfo,n,registered,timers={},0,{},{}
+table.setmetatableindex(timers,function(t,k)
+ local v={ timing=0,loadtime=0 }
+ t[k]=v
+ return v
+end)
+local function hastiming(instance)
+ return instance and timers[instance]
+end
+local function resettiming(instance)
+ timers[instance or "notimer"]={ timing=0,loadtime=0 }
+end
+local function starttiming(instance)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing or 0
+ if it==0 then
+ timer.starttime=clock()
+ if not timer.loadtime then
+ timer.loadtime=0
+ end
+ end
+ timer.timing=it+1
+end
+local function stoptiming(instance,report)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing
+ if it>1 then
+ timer.timing=it-1
+ else
+ local starttime=timer.starttime
+ if starttime then
+ local stoptime=clock()
+ local loadtime=stoptime-starttime
+ timer.stoptime=stoptime
+ timer.loadtime=timer.loadtime+loadtime
+ if report then
+ statistics.report("load time %0.3f",loadtime)
+ end
+ timer.timing=0
+ return loadtime
+ end
+ end
+ return 0
+end
+local function elapsed(instance)
+ if type(instance)=="number" then
+ return instance or 0
+ else
+ local timer=timers[instance or "notimer"]
+ return timer and timer.loadtime or 0
+ end
+end
+local function elapsedtime(instance)
+ return format("%0.3f",elapsed(instance))
+end
+local function elapsedindeed(instance)
+ return elapsed(instance)>statistics.threshold
+end
+local function elapsedseconds(instance,rest)
+ if elapsedindeed(instance) then
+ return format("%0.3f seconds %s",elapsed(instance),rest or "")
+ end
+end
+statistics.hastiming=hastiming
+statistics.resettiming=resettiming
+statistics.starttiming=starttiming
+statistics.stoptiming=stoptiming
+statistics.elapsed=elapsed
+statistics.elapsedtime=elapsedtime
+statistics.elapsedindeed=elapsedindeed
+statistics.elapsedseconds=elapsedseconds
+function statistics.register(tag,fnc)
+ if statistics.enable and type(fnc)=="function" then
+ local rt=registered[tag] or (#statusinfo+1)
+ statusinfo[rt]={ tag,fnc }
+ registered[tag]=rt
+ if #tag>n then n=#tag end
+ end
+end
+local report=logs.reporter("mkiv lua stats")
+function statistics.show()
+ if statistics.enable then
+ local register=statistics.register
+ register("luatex banner",function()
+ return lower(status.banner)
+ end)
+ register("control sequences",function()
+ return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
+ end)
+ register("callbacks",function()
+ local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
+ return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
+ end)
+ if jit then
+ local status={ jit.status() }
+ if status[1] then
+ register("luajit status",function()
+ return concat(status," ",2)
+ end)
+ end
+ end
+ register("current memory usage",statistics.memused)
+ register("runtime",statistics.runtime)
+ logs.newline()
+ for i=1,#statusinfo do
+ local s=statusinfo[i]
+ local r=s[2]()
+ if r then
+ report("%s: %s",s[1],r)
+ end
+ end
+ statistics.enable=false
+ end
+end
+function statistics.memused()
+ local round=math.round or math.floor
+ return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
+end
+starttiming(statistics)
+function statistics.formatruntime(runtime)
+ return format("%s seconds",runtime)
+end
+function statistics.runtime()
+ stoptiming(statistics)
+ return statistics.formatruntime(elapsedtime(statistics))
+end
+local report=logs.reporter("system")
+function statistics.timed(action)
+ starttiming("run")
+ action()
+ stoptiming("run")
+ report("total runtime: %s",elapsedtime("run"))
+end
+commands=commands or {}
+function commands.resettimer(name)
+ resettiming(name or "whatever")
+ starttiming(name or "whatever")
+end
+function commands.elapsedtime(name)
+ stoptiming(name or "whatever")
+ context(elapsedtime(name or "whatever"))
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["trac-pro"] = package.loaded["trac-pro"] or true
-- original size: 5773, stripped down to: 3453
@@ -7311,6 +7243,108 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-deb"] = package.loaded["util-deb"] or true
+
+-- original size: 3708, stripped down to: 2568
+
+if not modules then modules={} end modules ['util-deb']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local debug=require "debug"
+local getinfo=debug.getinfo
+local type,next,tostring=type,next,tostring
+local format,find=string.format,string.find
+local is_boolean=string.is_boolean
+utilities=utilities or {}
+local debugger=utilities.debugger or {}
+utilities.debugger=debugger
+local counters={}
+local names={}
+local report=logs.reporter("debugger")
+local function hook()
+ local f=getinfo(2)
+ if f then
+ local n="unknown"
+ if f.what=="C" then
+ n=f.name or '<anonymous>'
+ if not names[n] then
+ names[n]=format("%42s",n)
+ end
+ else
+ n=f.name or f.namewhat or f.what
+ if not n or n=="" then
+ n="?"
+ end
+ if not names[n] then
+ names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
+ end
+ end
+ counters[n]=(counters[n] or 0)+1
+ end
+end
+function debugger.showstats(printer,threshold)
+ printer=printer or report
+ threshold=threshold or 0
+ local total,grandtotal,functions=0,0,0
+ local dataset={}
+ for name,count in next,counters do
+ dataset[#dataset+1]={ name,count }
+ end
+ table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
+ for i=1,#dataset do
+ local d=dataset[i]
+ local name=d[1]
+ local count=d[2]
+ if count>threshold and not find(name,"for generator") then
+ printer(format("%8i %s\n",count,names[name]))
+ total=total+count
+ end
+ grandtotal=grandtotal+count
+ functions=functions+1
+ end
+ printer("\n")
+ printer(format("functions : % 10i\n",functions))
+ printer(format("total : % 10i\n",total))
+ printer(format("grand total: % 10i\n",grandtotal))
+ printer(format("threshold : % 10i\n",threshold))
+end
+function debugger.savestats(filename,threshold)
+ local f=io.open(filename,'w')
+ if f then
+ debugger.showstats(function(str) f:write(str) end,threshold)
+ f:close()
+ end
+end
+function debugger.enable()
+ debug.sethook(hook,"c")
+end
+function debugger.disable()
+ debug.sethook()
+end
+function traceback()
+ local level=1
+ while true do
+ local info=debug.getinfo(level,"Sl")
+ if not info then
+ break
+ elseif info.what=="C" then
+ print(format("%3i : C function",level))
+ else
+ print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
+ end
+ level=level+1
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["util-mrg"] = package.loaded["util-mrg"] or true
-- original size: 7255, stripped down to: 5798
@@ -15037,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lst"] = package.loaded["data-lst"] or true
--- original size: 2632, stripped down to: 2278
+-- original size: 2652, stripped down to: 2299
if not modules then modules={} end modules ['data-lst']={
version=1.001,
@@ -15089,20 +15123,20 @@ function resolvers.listers.variables(pattern)
instance.variables=fastcopy(var)
instance.expansions=fastcopy(exp)
end
-function resolvers.listers.configurations(report)
+local report_resolved=logs.report("system","resolved")
+function resolvers.listers.configurations()
local configurations=resolvers.instance.specification
- local report=report or texio.write_nl
for i=1,#configurations do
- report(format("file : %s",resolvers.resolve(configurations[i])))
+ report_resolved("file : %s",resolvers.resolve(configurations[i]))
end
- report("")
+ report_resolved("")
local list=resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
for i=1,#list do
local li=resolvers.resolve(list[i])
if lfs.isdir(li) then
- report(format("path - %s",li))
+ report_resolved("path - %s",li)
else
- report(format("path + %s",li))
+ report_resolved("path + %s",li)
end
end
end
@@ -15349,10 +15383,10 @@ end
end -- of closure
--- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua util-deb.lua trac-inf.lua trac-set.lua trac-log.lua trac-pro.lua util-lua.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 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 luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.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 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 luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 635238
--- stripped bytes : 230016
+-- original bytes : 636015
+-- stripped bytes : 230310
-- end library merge
@@ -15397,13 +15431,13 @@ local ownlibs = { -- order can be made better
'util-sto.lua',
'util-prs.lua',
'util-fmt.lua',
- 'util-deb.lua',
- 'trac-inf.lua',
'trac-set.lua',
'trac-log.lua',
+ 'trac-inf.lua', -- was before trac-set
'trac-pro.lua', -- not really needed
'util-lua.lua', -- indeed here?
+ 'util-deb.lua',
'util-mrg.lua',
'util-tpl.lua',
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 53c299283..6e8a36d18 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -275,7 +275,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true
--- original size: 26334, stripped down to: 14439
+-- original size: 26269, stripped down to: 14392
if not modules then modules={} end modules ['l-lpeg']={
version=1.001,
@@ -285,7 +285,6 @@ if not modules then modules={} end modules ['l-lpeg']={
license="see context related readme files"
}
lpeg=require("lpeg")
-local report=texio and texio.write_nl or print
local type,next,tostring=type,next,tostring
local byte,char,gmatch,format=string.byte,string.char,string.gmatch,string.format
local floor=math.floor
@@ -2378,7 +2377,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 13687, stripped down to: 8406
+-- original size: 13692, stripped down to: 8406
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -5140,7 +5139,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4270, stripped down to: 2989
+-- original size: 4237, stripped down to: 2975
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5153,11 +5152,11 @@ local setmetatable,getmetatable=setmetatable,getmetatable
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
-local report=texio and texio.write_nl or print
function storage.mark(t)
if not t then
- report("fatal error: storage cannot be marked")
- return
+ print("\nfatal error: storage cannot be marked\n")
+ os.exit()
+ return
end
local m=getmetatable(t)
if not m then
@@ -5183,8 +5182,9 @@ function storage.marked(t)
end
function storage.checked(t)
if not t then
- report("fatal error: storage has not been allocated")
- return
+ report("\nfatal error: storage has not been allocated\n")
+ os.exit()
+ return
end
return t
end
@@ -5757,294 +5757,9 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-deb"] = package.loaded["util-deb"] or true
-
--- original size: 3676, stripped down to: 2553
-
-if not modules then modules={} end modules ['util-deb']={
- version=1.001,
- comment="companion to luat-lib.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local debug=require "debug"
-local getinfo=debug.getinfo
-local type,next,tostring=type,next,tostring
-local format,find=string.format,string.find
-local is_boolean=string.is_boolean
-utilities=utilities or {}
-utilities.debugger=utilities.debugger or {}
-local debugger=utilities.debugger
-local counters={}
-local names={}
-local function hook()
- local f=getinfo(2)
- if f then
- local n="unknown"
- if f.what=="C" then
- n=f.name or '<anonymous>'
- if not names[n] then
- names[n]=format("%42s",n)
- end
- else
- n=f.name or f.namewhat or f.what
- if not n or n=="" then
- n="?"
- end
- if not names[n] then
- names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
- end
- end
- counters[n]=(counters[n] or 0)+1
- end
-end
-function debugger.showstats(printer,threshold)
- printer=printer or texio.write or print
- threshold=threshold or 0
- local total,grandtotal,functions=0,0,0
- local dataset={}
- for name,count in next,counters do
- dataset[#dataset+1]={ name,count }
- end
- table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
- for i=1,#dataset do
- local d=dataset[i]
- local name=d[1]
- local count=d[2]
- if count>threshold and not find(name,"for generator") then
- printer(format("%8i %s\n",count,names[name]))
- total=total+count
- end
- grandtotal=grandtotal+count
- functions=functions+1
- end
- printer("\n")
- printer(format("functions : % 10i\n",functions))
- printer(format("total : % 10i\n",total))
- printer(format("grand total: % 10i\n",grandtotal))
- printer(format("threshold : % 10i\n",threshold))
-end
-function debugger.savestats(filename,threshold)
- local f=io.open(filename,'w')
- if f then
- debugger.showstats(function(str) f:write(str) end,threshold)
- f:close()
- end
-end
-function debugger.enable()
- debug.sethook(hook,"c")
-end
-function debugger.disable()
- debug.sethook()
-end
-function traceback()
- local level=1
- while true do
- local info=debug.getinfo(level,"Sl")
- if not info then
- break
- elseif info.what=="C" then
- print(format("%3i : C function",level))
- else
- print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
- end
- level=level+1
- end
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
-package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
-
--- original size: 6380, stripped down to: 5101
-
-if not modules then modules={} end modules ['trac-inf']={
- version=1.001,
- comment="companion to trac-inf.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local type,tonumber=type,tonumber
-local format,lower=string.format,string.lower
-local concat=table.concat
-local clock=os.gettimeofday or os.clock
-local write_nl=texio and texio.write_nl or print
-statistics=statistics or {}
-local statistics=statistics
-statistics.enable=true
-statistics.threshold=0.01
-local statusinfo,n,registered,timers={},0,{},{}
-table.setmetatableindex(timers,function(t,k)
- local v={ timing=0,loadtime=0 }
- t[k]=v
- return v
-end)
-local function hastiming(instance)
- return instance and timers[instance]
-end
-local function resettiming(instance)
- timers[instance or "notimer"]={ timing=0,loadtime=0 }
-end
-local function starttiming(instance)
- local timer=timers[instance or "notimer"]
- local it=timer.timing or 0
- if it==0 then
- timer.starttime=clock()
- if not timer.loadtime then
- timer.loadtime=0
- end
- end
- timer.timing=it+1
-end
-local function stoptiming(instance,report)
- local timer=timers[instance or "notimer"]
- local it=timer.timing
- if it>1 then
- timer.timing=it-1
- else
- local starttime=timer.starttime
- if starttime then
- local stoptime=clock()
- local loadtime=stoptime-starttime
- timer.stoptime=stoptime
- timer.loadtime=timer.loadtime+loadtime
- if report then
- statistics.report("load time %0.3f",loadtime)
- end
- timer.timing=0
- return loadtime
- end
- end
- return 0
-end
-local function elapsed(instance)
- if type(instance)=="number" then
- return instance or 0
- else
- local timer=timers[instance or "notimer"]
- return timer and timer.loadtime or 0
- end
-end
-local function elapsedtime(instance)
- return format("%0.3f",elapsed(instance))
-end
-local function elapsedindeed(instance)
- return elapsed(instance)>statistics.threshold
-end
-local function elapsedseconds(instance,rest)
- if elapsedindeed(instance) then
- return format("%0.3f seconds %s",elapsed(instance),rest or "")
- end
-end
-statistics.hastiming=hastiming
-statistics.resettiming=resettiming
-statistics.starttiming=starttiming
-statistics.stoptiming=stoptiming
-statistics.elapsed=elapsed
-statistics.elapsedtime=elapsedtime
-statistics.elapsedindeed=elapsedindeed
-statistics.elapsedseconds=elapsedseconds
-function statistics.register(tag,fnc)
- if statistics.enable and type(fnc)=="function" then
- local rt=registered[tag] or (#statusinfo+1)
- statusinfo[rt]={ tag,fnc }
- registered[tag]=rt
- if #tag>n then n=#tag end
- end
-end
-function statistics.show(reporter)
- if statistics.enable then
- if not reporter then reporter=function(tag,data,n) write_nl(tag.." "..data) end end
- local register=statistics.register
- register("luatex banner",function()
- return lower(status.banner)
- end)
- register("control sequences",function()
- return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
- end)
- register("callbacks",function()
- local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
- return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
- end)
- if jit then
- local status={ jit.status() }
- if status[1] then
- register("luajit status",function()
- return concat(status," ",2)
- end)
- end
- end
- collectgarbage("collect")
- register("current memory usage",statistics.memused)
- register("runtime",statistics.runtime)
- for i=1,#statusinfo do
- local s=statusinfo[i]
- local r=s[2]()
- if r then
- reporter(s[1],r,n)
- end
- end
- write_nl("")
- statistics.enable=false
- end
-end
-local template,report_statistics,nn=nil,nil,0
-function statistics.showjobstat(tag,data,n)
- if not logs then
- elseif type(data)=="table" then
- for i=1,#data do
- statistics.showjobstat(tag,data[i],n)
- end
- else
- if not template or n>nn then
- template,n=format("%%-%ss - %%s",n),nn
- report_statistics=logs.reporter("mkiv lua stats")
- end
- report_statistics(format(template,tag,data))
- end
-end
-function statistics.memused()
- local round=math.round or math.floor
- return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
-end
-starttiming(statistics)
-function statistics.formatruntime(runtime)
- return format("%s seconds",runtime)
-end
-function statistics.runtime()
- stoptiming(statistics)
- return statistics.formatruntime(elapsedtime(statistics))
-end
-function statistics.timed(action,report)
- report=report or logs.reporter("system")
- starttiming("run")
- action()
- stoptiming("run")
- report("total runtime: %s",elapsedtime("run"))
-end
-commands=commands or {}
-function commands.resettimer(name)
- resettiming(name or "whatever")
- starttiming(name or "whatever")
-end
-function commands.elapsedtime(name)
- stoptiming(name or "whatever")
- context(elapsedtime(name or "whatever"))
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12501, stripped down to: 8920
+-- original size: 12360, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6061,8 +5776,8 @@ local settings_to_hash=utilities.parsers.settings_to_hash
local allocate=utilities.storage.allocate
utilities=utilities or {}
local utilities=utilities
-utilities.setters=utilities.setters or {}
-local setters=utilities.setters
+local setters=utilities.setters or {}
+utilities.setters=setters
local data={}
local trace_initialize=false
function setters.initialize(filename,name,values)
@@ -6246,14 +5961,8 @@ function setters.show(t)
t.report()
end
local enable,disable,register,list,show=setters.enable,setters.disable,setters.register,setters.list,setters.show
-local write_nl=texio and texio.write_nl or print
-local function report(setter,...)
- local report=logs and logs.report
- if report then
- report(setter.name,...)
- else
- write_nl(format("%-15s : %s\n",setter.name,format(...)))
- end
+function setters.report(setter,...)
+ print(format("%-15s : %s\n",setter.name,format(...)))
end
local function default(setter,name)
local d=setter.data[name]
@@ -6268,12 +5977,12 @@ function setters.new(name)
setter={
data=allocate(),
name=name,
- report=function(...) report (setter,...) end,
- enable=function(...) enable (setter,...) end,
- disable=function(...) disable (setter,...) end,
- register=function(...) register(setter,...) end,
- list=function(...) list (setter,...) end,
- show=function(...) show (setter,...) end,
+ report=function(...) setters.report (setter,...) end,
+ enable=function(...) enable (setter,...) end,
+ disable=function(...) disable (setter,...) end,
+ register=function(...) register(setter,...) end,
+ list=function(...) list (setter,...) end,
+ show=function(...) show (setter,...) end,
default=function(...) return default (setter,...) end,
value=function(...) return value (setter,...) end,
}
@@ -6283,40 +5992,46 @@ end
trackers=setters.new("trackers")
directives=setters.new("directives")
experiments=setters.new("experiments")
-local t_enable,t_disable,t_report=trackers .enable,trackers .disable,trackers .report
-local d_enable,d_disable,d_report=directives .enable,directives .disable,directives .report
-local e_enable,e_disable,e_report=experiments.enable,experiments.disable,experiments.report
+local t_enable,t_disable=trackers .enable,trackers .disable
+local d_enable,d_disable=directives .enable,directives .disable
+local e_enable,e_disable=experiments.enable,experiments.disable
local trace_directives=false local trace_directives=false trackers.register("system.directives",function(v) trace_directives=v end)
local trace_experiments=false local trace_experiments=false trackers.register("system.experiments",function(v) trace_experiments=v end)
function directives.enable(...)
if trace_directives then
- d_report("enabling: % t",{...})
+ directives.report("enabling: % t",{...})
end
d_enable(...)
end
function directives.disable(...)
if trace_directives then
- d_report("disabling: % t",{...})
+ directives.report("disabling: % t",{...})
end
d_disable(...)
end
function experiments.enable(...)
if trace_experiments then
- e_report("enabling: % t",{...})
+ experiments.report("enabling: % t",{...})
end
e_enable(...)
end
function experiments.disable(...)
if trace_experiments then
- e_report("disabling: % t",{...})
+ experiments.report("disabling: % t",{...})
end
e_disable(...)
end
directives.register("system.nostatistics",function(v)
- statistics.enable=not v
+ if statistics then
+ statistics.enable=not v
+ else
+ end
end)
directives.register("system.nolibraries",function(v)
- libraries=nil
+ if libraries then
+ libraries=nil
+ else
+ end
end)
if environment then
local engineflags=environment.engineflags
@@ -6356,7 +6071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 19098, stripped down to: 13439
+-- original size: 20646, stripped down to: 14629
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6365,6 +6080,49 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
+if tex and (tex.jobname or tex.formatname) then
+ local texio_write_nl=texio.write_nl
+ local texio_write=texio.write
+ local io_write=io.write
+ local write_nl=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(...)
+ elseif target=="log" then
+ texio_write_nl("log",...)
+ elseif target=="term" then
+ texio_write_nl("term","")
+ io_write(...)
+ else
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(target,...)
+ end
+ end
+ local write=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write("log",...)
+ io_write(...)
+ elseif target=="log" then
+ texio_write("log",...)
+ elseif target=="term" then
+ io_write(...)
+ else
+ texio_write("log",...)
+ io_write(target,...)
+ end
+ end
+ texio.write=write
+ texio.write_nl=write_nl
+else
+end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6696,6 +6454,14 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
+local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k)
+ t[k]=v
+ return v
+end)
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
directives.register("logs.blocked",function(v)
setblocked(v,true)
end)
@@ -6749,7 +6515,6 @@ function logs.stop_page_number()
end
logs.flush()
end
-logs.report_job_stat=statistics and statistics.showjobstat
local report_files=logs.reporter("files")
local nesting=0
local verbose=false
@@ -6877,6 +6642,173 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
+
+-- original size: 5791, stripped down to: 4540
+
+if not modules then modules={} end modules ['trac-inf']={
+ version=1.001,
+ comment="companion to trac-inf.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tonumber=type,tonumber
+local format,lower=string.format,string.lower
+local concat=table.concat
+local clock=os.gettimeofday or os.clock
+statistics=statistics or {}
+local statistics=statistics
+statistics.enable=true
+statistics.threshold=0.01
+local statusinfo,n,registered,timers={},0,{},{}
+table.setmetatableindex(timers,function(t,k)
+ local v={ timing=0,loadtime=0 }
+ t[k]=v
+ return v
+end)
+local function hastiming(instance)
+ return instance and timers[instance]
+end
+local function resettiming(instance)
+ timers[instance or "notimer"]={ timing=0,loadtime=0 }
+end
+local function starttiming(instance)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing or 0
+ if it==0 then
+ timer.starttime=clock()
+ if not timer.loadtime then
+ timer.loadtime=0
+ end
+ end
+ timer.timing=it+1
+end
+local function stoptiming(instance,report)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing
+ if it>1 then
+ timer.timing=it-1
+ else
+ local starttime=timer.starttime
+ if starttime then
+ local stoptime=clock()
+ local loadtime=stoptime-starttime
+ timer.stoptime=stoptime
+ timer.loadtime=timer.loadtime+loadtime
+ if report then
+ statistics.report("load time %0.3f",loadtime)
+ end
+ timer.timing=0
+ return loadtime
+ end
+ end
+ return 0
+end
+local function elapsed(instance)
+ if type(instance)=="number" then
+ return instance or 0
+ else
+ local timer=timers[instance or "notimer"]
+ return timer and timer.loadtime or 0
+ end
+end
+local function elapsedtime(instance)
+ return format("%0.3f",elapsed(instance))
+end
+local function elapsedindeed(instance)
+ return elapsed(instance)>statistics.threshold
+end
+local function elapsedseconds(instance,rest)
+ if elapsedindeed(instance) then
+ return format("%0.3f seconds %s",elapsed(instance),rest or "")
+ end
+end
+statistics.hastiming=hastiming
+statistics.resettiming=resettiming
+statistics.starttiming=starttiming
+statistics.stoptiming=stoptiming
+statistics.elapsed=elapsed
+statistics.elapsedtime=elapsedtime
+statistics.elapsedindeed=elapsedindeed
+statistics.elapsedseconds=elapsedseconds
+function statistics.register(tag,fnc)
+ if statistics.enable and type(fnc)=="function" then
+ local rt=registered[tag] or (#statusinfo+1)
+ statusinfo[rt]={ tag,fnc }
+ registered[tag]=rt
+ if #tag>n then n=#tag end
+ end
+end
+local report=logs.reporter("mkiv lua stats")
+function statistics.show()
+ if statistics.enable then
+ local register=statistics.register
+ register("luatex banner",function()
+ return lower(status.banner)
+ end)
+ register("control sequences",function()
+ return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
+ end)
+ register("callbacks",function()
+ local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
+ return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
+ end)
+ if jit then
+ local status={ jit.status() }
+ if status[1] then
+ register("luajit status",function()
+ return concat(status," ",2)
+ end)
+ end
+ end
+ register("current memory usage",statistics.memused)
+ register("runtime",statistics.runtime)
+ logs.newline()
+ for i=1,#statusinfo do
+ local s=statusinfo[i]
+ local r=s[2]()
+ if r then
+ report("%s: %s",s[1],r)
+ end
+ end
+ statistics.enable=false
+ end
+end
+function statistics.memused()
+ local round=math.round or math.floor
+ return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
+end
+starttiming(statistics)
+function statistics.formatruntime(runtime)
+ return format("%s seconds",runtime)
+end
+function statistics.runtime()
+ stoptiming(statistics)
+ return statistics.formatruntime(elapsedtime(statistics))
+end
+local report=logs.reporter("system")
+function statistics.timed(action)
+ starttiming("run")
+ action()
+ stoptiming("run")
+ report("total runtime: %s",elapsedtime("run"))
+end
+commands=commands or {}
+function commands.resettimer(name)
+ resettiming(name or "whatever")
+ starttiming(name or "whatever")
+end
+function commands.elapsedtime(name)
+ stoptiming(name or "whatever")
+ context(elapsedtime(name or "whatever"))
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["trac-pro"] = package.loaded["trac-pro"] or true
-- original size: 5773, stripped down to: 3453
@@ -7311,6 +7243,108 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-deb"] = package.loaded["util-deb"] or true
+
+-- original size: 3708, stripped down to: 2568
+
+if not modules then modules={} end modules ['util-deb']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local debug=require "debug"
+local getinfo=debug.getinfo
+local type,next,tostring=type,next,tostring
+local format,find=string.format,string.find
+local is_boolean=string.is_boolean
+utilities=utilities or {}
+local debugger=utilities.debugger or {}
+utilities.debugger=debugger
+local counters={}
+local names={}
+local report=logs.reporter("debugger")
+local function hook()
+ local f=getinfo(2)
+ if f then
+ local n="unknown"
+ if f.what=="C" then
+ n=f.name or '<anonymous>'
+ if not names[n] then
+ names[n]=format("%42s",n)
+ end
+ else
+ n=f.name or f.namewhat or f.what
+ if not n or n=="" then
+ n="?"
+ end
+ if not names[n] then
+ names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
+ end
+ end
+ counters[n]=(counters[n] or 0)+1
+ end
+end
+function debugger.showstats(printer,threshold)
+ printer=printer or report
+ threshold=threshold or 0
+ local total,grandtotal,functions=0,0,0
+ local dataset={}
+ for name,count in next,counters do
+ dataset[#dataset+1]={ name,count }
+ end
+ table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
+ for i=1,#dataset do
+ local d=dataset[i]
+ local name=d[1]
+ local count=d[2]
+ if count>threshold and not find(name,"for generator") then
+ printer(format("%8i %s\n",count,names[name]))
+ total=total+count
+ end
+ grandtotal=grandtotal+count
+ functions=functions+1
+ end
+ printer("\n")
+ printer(format("functions : % 10i\n",functions))
+ printer(format("total : % 10i\n",total))
+ printer(format("grand total: % 10i\n",grandtotal))
+ printer(format("threshold : % 10i\n",threshold))
+end
+function debugger.savestats(filename,threshold)
+ local f=io.open(filename,'w')
+ if f then
+ debugger.showstats(function(str) f:write(str) end,threshold)
+ f:close()
+ end
+end
+function debugger.enable()
+ debug.sethook(hook,"c")
+end
+function debugger.disable()
+ debug.sethook()
+end
+function traceback()
+ local level=1
+ while true do
+ local info=debug.getinfo(level,"Sl")
+ if not info then
+ break
+ elseif info.what=="C" then
+ print(format("%3i : C function",level))
+ else
+ print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
+ end
+ level=level+1
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["util-mrg"] = package.loaded["util-mrg"] or true
-- original size: 7255, stripped down to: 5798
@@ -15037,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lst"] = package.loaded["data-lst"] or true
--- original size: 2632, stripped down to: 2278
+-- original size: 2652, stripped down to: 2299
if not modules then modules={} end modules ['data-lst']={
version=1.001,
@@ -15089,20 +15123,20 @@ function resolvers.listers.variables(pattern)
instance.variables=fastcopy(var)
instance.expansions=fastcopy(exp)
end
-function resolvers.listers.configurations(report)
+local report_resolved=logs.report("system","resolved")
+function resolvers.listers.configurations()
local configurations=resolvers.instance.specification
- local report=report or texio.write_nl
for i=1,#configurations do
- report(format("file : %s",resolvers.resolve(configurations[i])))
+ report_resolved("file : %s",resolvers.resolve(configurations[i]))
end
- report("")
+ report_resolved("")
local list=resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
for i=1,#list do
local li=resolvers.resolve(list[i])
if lfs.isdir(li) then
- report(format("path - %s",li))
+ report_resolved("path - %s",li)
else
- report(format("path + %s",li))
+ report_resolved("path + %s",li)
end
end
end
@@ -15349,10 +15383,10 @@ end
end -- of closure
--- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua util-deb.lua trac-inf.lua trac-set.lua trac-log.lua trac-pro.lua util-lua.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 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 luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.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 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 luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 635238
--- stripped bytes : 230016
+-- original bytes : 636015
+-- stripped bytes : 230310
-- end library merge
@@ -15397,13 +15431,13 @@ local ownlibs = { -- order can be made better
'util-sto.lua',
'util-prs.lua',
'util-fmt.lua',
- 'util-deb.lua',
- 'trac-inf.lua',
'trac-set.lua',
'trac-log.lua',
+ 'trac-inf.lua', -- was before trac-set
'trac-pro.lua', -- not really needed
'util-lua.lua', -- indeed here?
+ 'util-deb.lua',
'util-mrg.lua',
'util-tpl.lua',
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 53c299283..6e8a36d18 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -275,7 +275,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true
--- original size: 26334, stripped down to: 14439
+-- original size: 26269, stripped down to: 14392
if not modules then modules={} end modules ['l-lpeg']={
version=1.001,
@@ -285,7 +285,6 @@ if not modules then modules={} end modules ['l-lpeg']={
license="see context related readme files"
}
lpeg=require("lpeg")
-local report=texio and texio.write_nl or print
local type,next,tostring=type,next,tostring
local byte,char,gmatch,format=string.byte,string.char,string.gmatch,string.format
local floor=math.floor
@@ -2378,7 +2377,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 13687, stripped down to: 8406
+-- original size: 13692, stripped down to: 8406
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -5140,7 +5139,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4270, stripped down to: 2989
+-- original size: 4237, stripped down to: 2975
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5153,11 +5152,11 @@ local setmetatable,getmetatable=setmetatable,getmetatable
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
-local report=texio and texio.write_nl or print
function storage.mark(t)
if not t then
- report("fatal error: storage cannot be marked")
- return
+ print("\nfatal error: storage cannot be marked\n")
+ os.exit()
+ return
end
local m=getmetatable(t)
if not m then
@@ -5183,8 +5182,9 @@ function storage.marked(t)
end
function storage.checked(t)
if not t then
- report("fatal error: storage has not been allocated")
- return
+ report("\nfatal error: storage has not been allocated\n")
+ os.exit()
+ return
end
return t
end
@@ -5757,294 +5757,9 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-deb"] = package.loaded["util-deb"] or true
-
--- original size: 3676, stripped down to: 2553
-
-if not modules then modules={} end modules ['util-deb']={
- version=1.001,
- comment="companion to luat-lib.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local debug=require "debug"
-local getinfo=debug.getinfo
-local type,next,tostring=type,next,tostring
-local format,find=string.format,string.find
-local is_boolean=string.is_boolean
-utilities=utilities or {}
-utilities.debugger=utilities.debugger or {}
-local debugger=utilities.debugger
-local counters={}
-local names={}
-local function hook()
- local f=getinfo(2)
- if f then
- local n="unknown"
- if f.what=="C" then
- n=f.name or '<anonymous>'
- if not names[n] then
- names[n]=format("%42s",n)
- end
- else
- n=f.name or f.namewhat or f.what
- if not n or n=="" then
- n="?"
- end
- if not names[n] then
- names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
- end
- end
- counters[n]=(counters[n] or 0)+1
- end
-end
-function debugger.showstats(printer,threshold)
- printer=printer or texio.write or print
- threshold=threshold or 0
- local total,grandtotal,functions=0,0,0
- local dataset={}
- for name,count in next,counters do
- dataset[#dataset+1]={ name,count }
- end
- table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
- for i=1,#dataset do
- local d=dataset[i]
- local name=d[1]
- local count=d[2]
- if count>threshold and not find(name,"for generator") then
- printer(format("%8i %s\n",count,names[name]))
- total=total+count
- end
- grandtotal=grandtotal+count
- functions=functions+1
- end
- printer("\n")
- printer(format("functions : % 10i\n",functions))
- printer(format("total : % 10i\n",total))
- printer(format("grand total: % 10i\n",grandtotal))
- printer(format("threshold : % 10i\n",threshold))
-end
-function debugger.savestats(filename,threshold)
- local f=io.open(filename,'w')
- if f then
- debugger.showstats(function(str) f:write(str) end,threshold)
- f:close()
- end
-end
-function debugger.enable()
- debug.sethook(hook,"c")
-end
-function debugger.disable()
- debug.sethook()
-end
-function traceback()
- local level=1
- while true do
- local info=debug.getinfo(level,"Sl")
- if not info then
- break
- elseif info.what=="C" then
- print(format("%3i : C function",level))
- else
- print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
- end
- level=level+1
- end
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
-package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
-
--- original size: 6380, stripped down to: 5101
-
-if not modules then modules={} end modules ['trac-inf']={
- version=1.001,
- comment="companion to trac-inf.mkiv",
- author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright="PRAGMA ADE / ConTeXt Development Team",
- license="see context related readme files"
-}
-local type,tonumber=type,tonumber
-local format,lower=string.format,string.lower
-local concat=table.concat
-local clock=os.gettimeofday or os.clock
-local write_nl=texio and texio.write_nl or print
-statistics=statistics or {}
-local statistics=statistics
-statistics.enable=true
-statistics.threshold=0.01
-local statusinfo,n,registered,timers={},0,{},{}
-table.setmetatableindex(timers,function(t,k)
- local v={ timing=0,loadtime=0 }
- t[k]=v
- return v
-end)
-local function hastiming(instance)
- return instance and timers[instance]
-end
-local function resettiming(instance)
- timers[instance or "notimer"]={ timing=0,loadtime=0 }
-end
-local function starttiming(instance)
- local timer=timers[instance or "notimer"]
- local it=timer.timing or 0
- if it==0 then
- timer.starttime=clock()
- if not timer.loadtime then
- timer.loadtime=0
- end
- end
- timer.timing=it+1
-end
-local function stoptiming(instance,report)
- local timer=timers[instance or "notimer"]
- local it=timer.timing
- if it>1 then
- timer.timing=it-1
- else
- local starttime=timer.starttime
- if starttime then
- local stoptime=clock()
- local loadtime=stoptime-starttime
- timer.stoptime=stoptime
- timer.loadtime=timer.loadtime+loadtime
- if report then
- statistics.report("load time %0.3f",loadtime)
- end
- timer.timing=0
- return loadtime
- end
- end
- return 0
-end
-local function elapsed(instance)
- if type(instance)=="number" then
- return instance or 0
- else
- local timer=timers[instance or "notimer"]
- return timer and timer.loadtime or 0
- end
-end
-local function elapsedtime(instance)
- return format("%0.3f",elapsed(instance))
-end
-local function elapsedindeed(instance)
- return elapsed(instance)>statistics.threshold
-end
-local function elapsedseconds(instance,rest)
- if elapsedindeed(instance) then
- return format("%0.3f seconds %s",elapsed(instance),rest or "")
- end
-end
-statistics.hastiming=hastiming
-statistics.resettiming=resettiming
-statistics.starttiming=starttiming
-statistics.stoptiming=stoptiming
-statistics.elapsed=elapsed
-statistics.elapsedtime=elapsedtime
-statistics.elapsedindeed=elapsedindeed
-statistics.elapsedseconds=elapsedseconds
-function statistics.register(tag,fnc)
- if statistics.enable and type(fnc)=="function" then
- local rt=registered[tag] or (#statusinfo+1)
- statusinfo[rt]={ tag,fnc }
- registered[tag]=rt
- if #tag>n then n=#tag end
- end
-end
-function statistics.show(reporter)
- if statistics.enable then
- if not reporter then reporter=function(tag,data,n) write_nl(tag.." "..data) end end
- local register=statistics.register
- register("luatex banner",function()
- return lower(status.banner)
- end)
- register("control sequences",function()
- return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
- end)
- register("callbacks",function()
- local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
- return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
- end)
- if jit then
- local status={ jit.status() }
- if status[1] then
- register("luajit status",function()
- return concat(status," ",2)
- end)
- end
- end
- collectgarbage("collect")
- register("current memory usage",statistics.memused)
- register("runtime",statistics.runtime)
- for i=1,#statusinfo do
- local s=statusinfo[i]
- local r=s[2]()
- if r then
- reporter(s[1],r,n)
- end
- end
- write_nl("")
- statistics.enable=false
- end
-end
-local template,report_statistics,nn=nil,nil,0
-function statistics.showjobstat(tag,data,n)
- if not logs then
- elseif type(data)=="table" then
- for i=1,#data do
- statistics.showjobstat(tag,data[i],n)
- end
- else
- if not template or n>nn then
- template,n=format("%%-%ss - %%s",n),nn
- report_statistics=logs.reporter("mkiv lua stats")
- end
- report_statistics(format(template,tag,data))
- end
-end
-function statistics.memused()
- local round=math.round or math.floor
- return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
-end
-starttiming(statistics)
-function statistics.formatruntime(runtime)
- return format("%s seconds",runtime)
-end
-function statistics.runtime()
- stoptiming(statistics)
- return statistics.formatruntime(elapsedtime(statistics))
-end
-function statistics.timed(action,report)
- report=report or logs.reporter("system")
- starttiming("run")
- action()
- stoptiming("run")
- report("total runtime: %s",elapsedtime("run"))
-end
-commands=commands or {}
-function commands.resettimer(name)
- resettiming(name or "whatever")
- starttiming(name or "whatever")
-end
-function commands.elapsedtime(name)
- stoptiming(name or "whatever")
- context(elapsedtime(name or "whatever"))
-end
-
-
-end -- of closure
-
-do -- create closure to overcome 200 locals limit
-
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12501, stripped down to: 8920
+-- original size: 12360, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6061,8 +5776,8 @@ local settings_to_hash=utilities.parsers.settings_to_hash
local allocate=utilities.storage.allocate
utilities=utilities or {}
local utilities=utilities
-utilities.setters=utilities.setters or {}
-local setters=utilities.setters
+local setters=utilities.setters or {}
+utilities.setters=setters
local data={}
local trace_initialize=false
function setters.initialize(filename,name,values)
@@ -6246,14 +5961,8 @@ function setters.show(t)
t.report()
end
local enable,disable,register,list,show=setters.enable,setters.disable,setters.register,setters.list,setters.show
-local write_nl=texio and texio.write_nl or print
-local function report(setter,...)
- local report=logs and logs.report
- if report then
- report(setter.name,...)
- else
- write_nl(format("%-15s : %s\n",setter.name,format(...)))
- end
+function setters.report(setter,...)
+ print(format("%-15s : %s\n",setter.name,format(...)))
end
local function default(setter,name)
local d=setter.data[name]
@@ -6268,12 +5977,12 @@ function setters.new(name)
setter={
data=allocate(),
name=name,
- report=function(...) report (setter,...) end,
- enable=function(...) enable (setter,...) end,
- disable=function(...) disable (setter,...) end,
- register=function(...) register(setter,...) end,
- list=function(...) list (setter,...) end,
- show=function(...) show (setter,...) end,
+ report=function(...) setters.report (setter,...) end,
+ enable=function(...) enable (setter,...) end,
+ disable=function(...) disable (setter,...) end,
+ register=function(...) register(setter,...) end,
+ list=function(...) list (setter,...) end,
+ show=function(...) show (setter,...) end,
default=function(...) return default (setter,...) end,
value=function(...) return value (setter,...) end,
}
@@ -6283,40 +5992,46 @@ end
trackers=setters.new("trackers")
directives=setters.new("directives")
experiments=setters.new("experiments")
-local t_enable,t_disable,t_report=trackers .enable,trackers .disable,trackers .report
-local d_enable,d_disable,d_report=directives .enable,directives .disable,directives .report
-local e_enable,e_disable,e_report=experiments.enable,experiments.disable,experiments.report
+local t_enable,t_disable=trackers .enable,trackers .disable
+local d_enable,d_disable=directives .enable,directives .disable
+local e_enable,e_disable=experiments.enable,experiments.disable
local trace_directives=false local trace_directives=false trackers.register("system.directives",function(v) trace_directives=v end)
local trace_experiments=false local trace_experiments=false trackers.register("system.experiments",function(v) trace_experiments=v end)
function directives.enable(...)
if trace_directives then
- d_report("enabling: % t",{...})
+ directives.report("enabling: % t",{...})
end
d_enable(...)
end
function directives.disable(...)
if trace_directives then
- d_report("disabling: % t",{...})
+ directives.report("disabling: % t",{...})
end
d_disable(...)
end
function experiments.enable(...)
if trace_experiments then
- e_report("enabling: % t",{...})
+ experiments.report("enabling: % t",{...})
end
e_enable(...)
end
function experiments.disable(...)
if trace_experiments then
- e_report("disabling: % t",{...})
+ experiments.report("disabling: % t",{...})
end
e_disable(...)
end
directives.register("system.nostatistics",function(v)
- statistics.enable=not v
+ if statistics then
+ statistics.enable=not v
+ else
+ end
end)
directives.register("system.nolibraries",function(v)
- libraries=nil
+ if libraries then
+ libraries=nil
+ else
+ end
end)
if environment then
local engineflags=environment.engineflags
@@ -6356,7 +6071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 19098, stripped down to: 13439
+-- original size: 20646, stripped down to: 14629
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6365,6 +6080,49 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
+if tex and (tex.jobname or tex.formatname) then
+ local texio_write_nl=texio.write_nl
+ local texio_write=texio.write
+ local io_write=io.write
+ local write_nl=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(...)
+ elseif target=="log" then
+ texio_write_nl("log",...)
+ elseif target=="term" then
+ texio_write_nl("term","")
+ io_write(...)
+ else
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(target,...)
+ end
+ end
+ local write=function(target,...)
+ if not io_write then
+ io_write=io.write
+ end
+ if target=="term and log" then
+ texio_write("log",...)
+ io_write(...)
+ elseif target=="log" then
+ texio_write("log",...)
+ elseif target=="term" then
+ io_write(...)
+ else
+ texio_write("log",...)
+ io_write(target,...)
+ end
+ end
+ texio.write=write
+ texio.write_nl=write_nl
+else
+end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6696,6 +6454,14 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
+local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k)
+ t[k]=v
+ return v
+end)
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
directives.register("logs.blocked",function(v)
setblocked(v,true)
end)
@@ -6749,7 +6515,6 @@ function logs.stop_page_number()
end
logs.flush()
end
-logs.report_job_stat=statistics and statistics.showjobstat
local report_files=logs.reporter("files")
local nesting=0
local verbose=false
@@ -6877,6 +6642,173 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
+
+-- original size: 5791, stripped down to: 4540
+
+if not modules then modules={} end modules ['trac-inf']={
+ version=1.001,
+ comment="companion to trac-inf.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tonumber=type,tonumber
+local format,lower=string.format,string.lower
+local concat=table.concat
+local clock=os.gettimeofday or os.clock
+statistics=statistics or {}
+local statistics=statistics
+statistics.enable=true
+statistics.threshold=0.01
+local statusinfo,n,registered,timers={},0,{},{}
+table.setmetatableindex(timers,function(t,k)
+ local v={ timing=0,loadtime=0 }
+ t[k]=v
+ return v
+end)
+local function hastiming(instance)
+ return instance and timers[instance]
+end
+local function resettiming(instance)
+ timers[instance or "notimer"]={ timing=0,loadtime=0 }
+end
+local function starttiming(instance)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing or 0
+ if it==0 then
+ timer.starttime=clock()
+ if not timer.loadtime then
+ timer.loadtime=0
+ end
+ end
+ timer.timing=it+1
+end
+local function stoptiming(instance,report)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing
+ if it>1 then
+ timer.timing=it-1
+ else
+ local starttime=timer.starttime
+ if starttime then
+ local stoptime=clock()
+ local loadtime=stoptime-starttime
+ timer.stoptime=stoptime
+ timer.loadtime=timer.loadtime+loadtime
+ if report then
+ statistics.report("load time %0.3f",loadtime)
+ end
+ timer.timing=0
+ return loadtime
+ end
+ end
+ return 0
+end
+local function elapsed(instance)
+ if type(instance)=="number" then
+ return instance or 0
+ else
+ local timer=timers[instance or "notimer"]
+ return timer and timer.loadtime or 0
+ end
+end
+local function elapsedtime(instance)
+ return format("%0.3f",elapsed(instance))
+end
+local function elapsedindeed(instance)
+ return elapsed(instance)>statistics.threshold
+end
+local function elapsedseconds(instance,rest)
+ if elapsedindeed(instance) then
+ return format("%0.3f seconds %s",elapsed(instance),rest or "")
+ end
+end
+statistics.hastiming=hastiming
+statistics.resettiming=resettiming
+statistics.starttiming=starttiming
+statistics.stoptiming=stoptiming
+statistics.elapsed=elapsed
+statistics.elapsedtime=elapsedtime
+statistics.elapsedindeed=elapsedindeed
+statistics.elapsedseconds=elapsedseconds
+function statistics.register(tag,fnc)
+ if statistics.enable and type(fnc)=="function" then
+ local rt=registered[tag] or (#statusinfo+1)
+ statusinfo[rt]={ tag,fnc }
+ registered[tag]=rt
+ if #tag>n then n=#tag end
+ end
+end
+local report=logs.reporter("mkiv lua stats")
+function statistics.show()
+ if statistics.enable then
+ local register=statistics.register
+ register("luatex banner",function()
+ return lower(status.banner)
+ end)
+ register("control sequences",function()
+ return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
+ end)
+ register("callbacks",function()
+ local total,indirect=status.callbacks or 0,status.indirect_callbacks or 0
+ return format("%s direct, %s indirect, %s total",total-indirect,indirect,total)
+ end)
+ if jit then
+ local status={ jit.status() }
+ if status[1] then
+ register("luajit status",function()
+ return concat(status," ",2)
+ end)
+ end
+ end
+ register("current memory usage",statistics.memused)
+ register("runtime",statistics.runtime)
+ logs.newline()
+ for i=1,#statusinfo do
+ local s=statusinfo[i]
+ local r=s[2]()
+ if r then
+ report("%s: %s",s[1],r)
+ end
+ end
+ statistics.enable=false
+ end
+end
+function statistics.memused()
+ local round=math.round or math.floor
+ return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000))
+end
+starttiming(statistics)
+function statistics.formatruntime(runtime)
+ return format("%s seconds",runtime)
+end
+function statistics.runtime()
+ stoptiming(statistics)
+ return statistics.formatruntime(elapsedtime(statistics))
+end
+local report=logs.reporter("system")
+function statistics.timed(action)
+ starttiming("run")
+ action()
+ stoptiming("run")
+ report("total runtime: %s",elapsedtime("run"))
+end
+commands=commands or {}
+function commands.resettimer(name)
+ resettiming(name or "whatever")
+ starttiming(name or "whatever")
+end
+function commands.elapsedtime(name)
+ stoptiming(name or "whatever")
+ context(elapsedtime(name or "whatever"))
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["trac-pro"] = package.loaded["trac-pro"] or true
-- original size: 5773, stripped down to: 3453
@@ -7311,6 +7243,108 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-deb"] = package.loaded["util-deb"] or true
+
+-- original size: 3708, stripped down to: 2568
+
+if not modules then modules={} end modules ['util-deb']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local debug=require "debug"
+local getinfo=debug.getinfo
+local type,next,tostring=type,next,tostring
+local format,find=string.format,string.find
+local is_boolean=string.is_boolean
+utilities=utilities or {}
+local debugger=utilities.debugger or {}
+utilities.debugger=debugger
+local counters={}
+local names={}
+local report=logs.reporter("debugger")
+local function hook()
+ local f=getinfo(2)
+ if f then
+ local n="unknown"
+ if f.what=="C" then
+ n=f.name or '<anonymous>'
+ if not names[n] then
+ names[n]=format("%42s",n)
+ end
+ else
+ n=f.name or f.namewhat or f.what
+ if not n or n=="" then
+ n="?"
+ end
+ if not names[n] then
+ names[n]=format("%42s : % 5i : %s",n,f.linedefined or 0,f.short_src or "unknown source")
+ end
+ end
+ counters[n]=(counters[n] or 0)+1
+ end
+end
+function debugger.showstats(printer,threshold)
+ printer=printer or report
+ threshold=threshold or 0
+ local total,grandtotal,functions=0,0,0
+ local dataset={}
+ for name,count in next,counters do
+ dataset[#dataset+1]={ name,count }
+ end
+ table.sort(dataset,function(a,b) return a[2]==b[2] and b[1]>a[1] or a[2]>b[2] end)
+ for i=1,#dataset do
+ local d=dataset[i]
+ local name=d[1]
+ local count=d[2]
+ if count>threshold and not find(name,"for generator") then
+ printer(format("%8i %s\n",count,names[name]))
+ total=total+count
+ end
+ grandtotal=grandtotal+count
+ functions=functions+1
+ end
+ printer("\n")
+ printer(format("functions : % 10i\n",functions))
+ printer(format("total : % 10i\n",total))
+ printer(format("grand total: % 10i\n",grandtotal))
+ printer(format("threshold : % 10i\n",threshold))
+end
+function debugger.savestats(filename,threshold)
+ local f=io.open(filename,'w')
+ if f then
+ debugger.showstats(function(str) f:write(str) end,threshold)
+ f:close()
+ end
+end
+function debugger.enable()
+ debug.sethook(hook,"c")
+end
+function debugger.disable()
+ debug.sethook()
+end
+function traceback()
+ local level=1
+ while true do
+ local info=debug.getinfo(level,"Sl")
+ if not info then
+ break
+ elseif info.what=="C" then
+ print(format("%3i : C function",level))
+ else
+ print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
+ end
+ level=level+1
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["util-mrg"] = package.loaded["util-mrg"] or true
-- original size: 7255, stripped down to: 5798
@@ -15037,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lst"] = package.loaded["data-lst"] or true
--- original size: 2632, stripped down to: 2278
+-- original size: 2652, stripped down to: 2299
if not modules then modules={} end modules ['data-lst']={
version=1.001,
@@ -15089,20 +15123,20 @@ function resolvers.listers.variables(pattern)
instance.variables=fastcopy(var)
instance.expansions=fastcopy(exp)
end
-function resolvers.listers.configurations(report)
+local report_resolved=logs.report("system","resolved")
+function resolvers.listers.configurations()
local configurations=resolvers.instance.specification
- local report=report or texio.write_nl
for i=1,#configurations do
- report(format("file : %s",resolvers.resolve(configurations[i])))
+ report_resolved("file : %s",resolvers.resolve(configurations[i]))
end
- report("")
+ report_resolved("")
local list=resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
for i=1,#list do
local li=resolvers.resolve(list[i])
if lfs.isdir(li) then
- report(format("path - %s",li))
+ report_resolved("path - %s",li)
else
- report(format("path + %s",li))
+ report_resolved("path + %s",li)
end
end
end
@@ -15349,10 +15383,10 @@ end
end -- of closure
--- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua util-deb.lua trac-inf.lua trac-set.lua trac-log.lua trac-pro.lua util-lua.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 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 luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.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-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.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 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 luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 635238
--- stripped bytes : 230016
+-- original bytes : 636015
+-- stripped bytes : 230310
-- end library merge
@@ -15397,13 +15431,13 @@ local ownlibs = { -- order can be made better
'util-sto.lua',
'util-prs.lua',
'util-fmt.lua',
- 'util-deb.lua',
- 'trac-inf.lua',
'trac-set.lua',
'trac-log.lua',
+ 'trac-inf.lua', -- was before trac-set
'trac-pro.lua', -- not really needed
'util-lua.lua', -- indeed here?
+ 'util-deb.lua',
'util-mrg.lua',
'util-tpl.lua',
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index ad7781917..39c395435 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 232ef41d6..9f10e90ad 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/core-ctx.mkiv b/tex/context/base/core-ctx.mkiv
index 50b3ae4a2..59115621a 100644
--- a/tex/context/base/core-ctx.mkiv
+++ b/tex/context/base/core-ctx.mkiv
@@ -19,7 +19,6 @@
\unexpanded\def\job_options_get_commandline {\ctxcommand{getcommandline()}}
\unexpanded\def\job_options_get_ctxfile {\ctxcommand{getctxfile()}}
-\unexpanded\def\job_options_log {\ctxcommand{logoptions()}}
\unexpanded\def\job_options_set_modes {\ctxcommand{setdocumentmodes()}}
\unexpanded\def\job_options_set_modules {\ctxcommand{setdocumentmodules()}}
\unexpanded\def\job_options_set_environments{\ctxcommand{setdocumentenvironments()}}
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index d1c774f40..cf1049e58 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -112,10 +112,6 @@
\to \everyjob
\appendtoks
- \job_options_log
-\to \everystarttext
-
-\appendtoks
\ifarrangingpages\poparrangedpages\fi
\to \everybye
diff --git a/tex/context/base/data-lst.lua b/tex/context/base/data-lst.lua
index c86e58fd8..64d891514 100644
--- a/tex/context/base/data-lst.lua
+++ b/tex/context/base/data-lst.lua
@@ -57,20 +57,21 @@ function resolvers.listers.variables(pattern)
instance.expansions = fastcopy(exp)
end
-function resolvers.listers.configurations(report)
+local report_resolved = logs.report("system","resolved")
+
+function resolvers.listers.configurations()
local configurations = resolvers.instance.specification
- local report = report or texio.write_nl
for i=1,#configurations do
- report(format("file : %s",resolvers.resolve(configurations[i])))
+ report_resolved("file : %s",resolvers.resolve(configurations[i]))
end
- report("")
+ report_resolved("")
local list = resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
for i=1,#list do
local li = resolvers.resolve(list[i])
if lfs.isdir(li) then
- report(format("path - %s",li))
+ report_resolved("path - %s",li)
else
- report(format("path + %s",li))
+ report_resolved("path + %s",li)
end
end
end
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 780438dc8..9e5912bc7 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -12,6 +12,7 @@ if not modules then modules = { } end modules ['file-job'] = {
local format, gsub, match, find = string.format, string.gsub, string.match, string.find
local insert, remove, concat = table.insert, table.remove, table.concat
local validstring = string.valid
+local sortedhash = table.sortedhash
local commands, resolvers, context = commands, resolvers, context
@@ -27,7 +28,6 @@ local logsnewline = logs.newline
local logspushtarget = logs.pushtarget
local logspoptarget = logs.poptarget
local settings_to_array = utilities.parsers.settings_to_array
-local write_nl = texio.write_nl
local allocate = utilities.storage.allocate
local nameonly = file.nameonly
@@ -103,26 +103,7 @@ function commands.usezipfile(name,tree)
end
end
-local report_system = logs.reporter("system","options")
-local report_options = logs.reporter("used options")
-
-function commands.copyfiletolog(name)
- local f = io.open(name)
- if f then
- logspushtarget("logfile")
- logsnewline()
- report_system("start used options")
- logsnewline()
- for line in f:lines() do
- report_options(line)
- end
- logsnewline()
- report_system("stop used options")
- logsnewline()
- logspoptarget()
- f:close()
- end
-end
+local report_system = logs.reporter("system")
-- moved from tex to lua:
@@ -271,8 +252,6 @@ end
-- document structure
-local report_system = logs.reporter("system")
-
local textlevel = 0 -- inaccessible for user, we need to define counter textlevel at the tex end
local function dummyfunction() end
@@ -382,8 +361,8 @@ local stacks = {
--
-local report_system = logs.reporter("system","structure")
-local report_structure = logs.reporter("used structure")
+local report_structures = logs.reporter("system","structure")
+local report_structure = logs.reporter("used structure")
local function pushtree(what,name)
local t = { }
@@ -408,20 +387,18 @@ local function log_tree(top,depth)
end
end
-local function logtree()
+luatex.registerstopactions(function()
logspushtarget("logfile")
logsnewline()
- report_system("start used structure")
+ report_structures("start used structure")
logsnewline()
root.name = environment.jobname
log_tree(root,"")
logsnewline()
- report_system("stop used structure")
+ report_structures("stop used structure")
logsnewline()
logspoptarget()
-end
-
-luatex.registerstopactions(logtree)
+end)
job.structure = job.structure or { }
job.structure.collected = job.structure.collected or { }
@@ -906,19 +883,107 @@ function commands.setdocumentenvironments() -- was setup: *runtime:environments
apply(document.options.commandline.environments,context.environment)
end
-function commands.logoptions()
- local arguments = document.arguments
- local files = document.files
- write_nl("log","\n% begin of command line arguments\n%\n")
- for k, v in next, arguments do
- write_nl("log",format("%% %-20s = %s",k,tostring(v)))
+local report_files = logs.reporter("system","files")
+local report_options = logs.reporter("system","options")
+local report_file = logs.reporter("used file")
+local report_option = logs.reporter("used option")
+
+luatex.registerstopactions(function()
+ local foundintrees = resolvers.instance.foundintrees
+ if #foundintrees > 0 then
+ logspushtarget("logfile")
+ logsnewline()
+ report_files("start used files")
+ logsnewline()
+ for i=1,#foundintrees do
+ report_file("%4i: % T",i,foundintrees[i])
+ end
+ logsnewline()
+ report_files("stop used files")
+ logsnewline()
+ logspoptarget()
end
- write_nl("log","%\n% end of command line arguments\n")
- write_nl("log","\n% begin of command line files\n%\n")
+end)
+
+luatex.registerstopactions(function()
+ local files = document.files -- or environment.files
+ local arguments = document.arguments -- or environment.arguments
+ --
+ logspushtarget("logfile")
+ logsnewline()
+ report_options("start commandline options")
+ logsnewline()
+ for argument, value in sortedhash(arguments) do
+ report_option("%s=%A",argument,value)
+ end
+ logsnewline()
+ report_options("stop commandline options")
+ logsnewline()
+ report_options("start commandline files")
+ logsnewline()
for i=1,#files do
- write_nl("log",format("%% %i %s",i,files[i]))
+ report_file("% 4i: %s",i,files[i])
end
- write_nl("log","%\n% end of command line files\n\n")
+ logsnewline()
+ report_options("stop commandline files")
+ logsnewline()
+ logspoptarget()
+end)
+
+if environment.initex then
+
+ local report_storage = logs.reporter("system","storage")
+ local report_table = logs.reporter("stored table")
+ local report_module = logs.reporter("stored module")
+ local report_attribute = logs.reporter("stored attribute")
+ local report_catcodetable = logs.reporter("stored catcodetable")
+ local report_corenamespace = logs.reporter("stored corenamespace")
+
+ luatex.registerstopactions(function()
+ logspushtarget("logfile")
+ logsnewline()
+ report_storage("start stored tables")
+ logsnewline()
+ for k,v in sortedhash(storage.data) do
+ report_table("%03i %s",k,v[1])
+ end
+ logsnewline()
+ report_storage("stop stored tables")
+ logsnewline()
+ report_storage("start stored modules")
+ logsnewline()
+ for k,v in sortedhash(lua.bytedata) do
+ report_module("%03i %s %s",k,v[2],v[1])
+ end
+ logsnewline()
+ report_storage("stop stored modules")
+ logsnewline()
+ report_storage("start stored attributes")
+ logsnewline()
+ for k,v in sortedhash(attributes.names) do
+ report_attribute("%03i %s",k,v)
+ end
+ logsnewline()
+ report_storage("stop stored attributes")
+ logsnewline()
+ report_storage("start stored catcodetables")
+ logsnewline()
+ for k,v in sortedhash(catcodes.names) do
+ report_catcodetable("%03i % t",k,v)
+ end
+ logsnewline()
+ report_storage("stop stored catcodetables")
+ logsnewline()
+ report_storage("start stored corenamespaces")
+ for k,v in sortedhash(interfaces.corenamespaces) do
+ report_corenamespace("%03i %s",k,v)
+ end
+ logsnewline()
+ report_storage("stop stored corenamespaces")
+ logsnewline()
+ logspoptarget()
+ end)
+
end
function commands.doifelsecontinuewithfile(inpname)
diff --git a/tex/context/base/font-age.lua b/tex/context/base/font-age.lua
index 36647c3a6..ba8f0bb0b 100644
--- a/tex/context/base/font-age.lua
+++ b/tex/context/base/font-age.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-age'] = {
}
if context then
- texio.write_nl("fatal error: this module is not for context")
+ logs.report("fatal error","this module is not for context")
os.exit()
end
diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua
index 3436465f5..6b3af4dee 100644
--- a/tex/context/base/font-syn.lua
+++ b/tex/context/base/font-syn.lua
@@ -1518,10 +1518,6 @@ function names.exists(name)
return ((resolvers.findfile(name,"tfm") or "") ~= "") or ((names.resolve(name) or "") ~= "")
end
--- for i=1,fonts.names.lookup(pattern) do
--- texio.write_nl(fonts.names.getkey("filename",i))
--- end
-
local lastlookups, lastpattern = { }, ""
function names.lookup(pattern,name,reload) -- todo: find
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index cfc26a5a5..9f51c644f 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -17,8 +17,6 @@ lpeg = require("lpeg")
-- some code will move to unicode and string
-local report = texio and texio.write_nl or print
-
-- local lpmatch = lpeg.match
-- local lpprint = lpeg.print
-- local lpp = lpeg.P
@@ -36,22 +34,22 @@ local report = texio and texio.write_nl or print
-- local lpcmt = lpeg.Cmt
-- local lpcarg = lpeg.Carg
--- function lpeg.match(l,...) report("LPEG MATCH") lpprint(l) return lpmatch(l,...) end
-
--- function lpeg.P (l) local p = lpp (l) report("LPEG P =") lpprint(l) return p end
--- function lpeg.R (l) local p = lpr (l) report("LPEG R =") lpprint(l) return p end
--- function lpeg.S (l) local p = lps (l) report("LPEG S =") lpprint(l) return p end
--- function lpeg.C (l) local p = lpc (l) report("LPEG C =") lpprint(l) return p end
--- function lpeg.B (l) local p = lpb (l) report("LPEG B =") lpprint(l) return p end
--- function lpeg.V (l) local p = lpv (l) report("LPEG V =") lpprint(l) return p end
--- function lpeg.Cf (l) local p = lpcf (l) report("LPEG Cf =") lpprint(l) return p end
--- function lpeg.Cb (l) local p = lpcb (l) report("LPEG Cb =") lpprint(l) return p end
--- function lpeg.Cg (l) local p = lpcg (l) report("LPEG Cg =") lpprint(l) return p end
--- function lpeg.Ct (l) local p = lpct (l) report("LPEG Ct =") lpprint(l) return p end
--- function lpeg.Cs (l) local p = lpcs (l) report("LPEG Cs =") lpprint(l) return p end
--- function lpeg.Cc (l) local p = lpcc (l) report("LPEG Cc =") lpprint(l) return p end
--- function lpeg.Cmt (l) local p = lpcmt (l) report("LPEG Cmt =") lpprint(l) return p end
--- function lpeg.Carg (l) local p = lpcarg(l) report("LPEG Carg =") lpprint(l) return p end
+-- function lpeg.match(l,...) print("LPEG MATCH") lpprint(l) return lpmatch(l,...) end
+
+-- function lpeg.P (l) local p = lpp (l) print("LPEG P =") lpprint(l) return p end
+-- function lpeg.R (l) local p = lpr (l) print("LPEG R =") lpprint(l) return p end
+-- function lpeg.S (l) local p = lps (l) print("LPEG S =") lpprint(l) return p end
+-- function lpeg.C (l) local p = lpc (l) print("LPEG C =") lpprint(l) return p end
+-- function lpeg.B (l) local p = lpb (l) print("LPEG B =") lpprint(l) return p end
+-- function lpeg.V (l) local p = lpv (l) print("LPEG V =") lpprint(l) return p end
+-- function lpeg.Cf (l) local p = lpcf (l) print("LPEG Cf =") lpprint(l) return p end
+-- function lpeg.Cb (l) local p = lpcb (l) print("LPEG Cb =") lpprint(l) return p end
+-- function lpeg.Cg (l) local p = lpcg (l) print("LPEG Cg =") lpprint(l) return p end
+-- function lpeg.Ct (l) local p = lpct (l) print("LPEG Ct =") lpprint(l) return p end
+-- function lpeg.Cs (l) local p = lpcs (l) print("LPEG Cs =") lpprint(l) return p end
+-- function lpeg.Cc (l) local p = lpcc (l) print("LPEG Cc =") lpprint(l) return p end
+-- function lpeg.Cmt (l) local p = lpcmt (l) print("LPEG Cmt =") lpprint(l) return p end
+-- function lpeg.Carg (l) local p = lpcarg(l) print("LPEG Carg =") lpprint(l) return p end
local type, next, tostring = type, next, tostring
local byte, char, gmatch, format = string.byte, string.char, string.gmatch, string.format
diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua
index 08d0473bc..42f3e4862 100644
--- a/tex/context/base/l-os.lua
+++ b/tex/context/base/l-os.lua
@@ -157,7 +157,7 @@ function os.launch(str)
os.execute(format(launchers[os.name] or launchers.unix,str))
end
-if not os.times then
+if not os.times then -- ?
-- utime = user time
-- stime = system time
-- cutime = children user time
diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua
index fbdea8815..061ed0757 100644
--- a/tex/context/base/lpdf-xmp.lua
+++ b/tex/context/base/lpdf-xmp.lua
@@ -180,9 +180,14 @@ local function flushxmpinfo()
Type = pdfconstant("Metadata"),
}
if trace_xmp then
- report_xmp("data flushed (see log file)")
- texio.write_nl("log","")
- texio.write("log","\n% ",(gsub(blob,"[\r\n]","\n%% ")),"\n")
+ report_xmp("data flushed, see log file")
+ logs.pushtarget("logfile")
+ report_xmp("start xmp blob")
+ logs.newline()
+ logs.writer(blob)
+ logs.newline()
+ report_xmp("stop xmp blob")
+ logs.poptarget()
end
blob = format(xpacket,packetid,blob)
if not verbose and tex.pdfcompresslevel > 0 then
diff --git a/tex/context/base/luat-cod.lua b/tex/context/base/luat-cod.lua
index 87b2c0059..8b015477f 100644
--- a/tex/context/base/luat-cod.lua
+++ b/tex/context/base/luat-cod.lua
@@ -62,7 +62,7 @@ function lua.registerfinalizer(f,comment)
if type(f) == "function" then
finalizers[#finalizers+1] = { action = f, comment = comment }
else
- texio.write_nl(format("fatal error: invalid finalizer, action: %s",comment))
+ print(format("\nfatal error: invalid finalizer, action: %s\n",comment))
os.exit()
end
end
@@ -72,7 +72,7 @@ function lua.finalize(logger)
local finalizer = finalizers[i]
finalizer.action()
if logger then
- logger("finalizing lua", "action: %s",finalizer.comment)
+ logger("finalize action: %s",finalizer.comment)
end
end
end
@@ -112,7 +112,9 @@ if not environment.luafilechunk then
end
if not environment.engineflags then -- raw flags
+
local engineflags = { }
+
for i=-10,#arg do
local a = arg[i]
if a then
@@ -122,7 +124,9 @@ if not environment.engineflags then -- raw flags
end
end
end
+
environment.engineflags = engineflags
+
end
-- We need a few premature callbacks in the format generator. We
diff --git a/tex/context/base/luat-fio.lua b/tex/context/base/luat-fio.lua
index 2f00914d3..d61c6f142 100644
--- a/tex/context/base/luat-fio.lua
+++ b/tex/context/base/luat-fio.lua
@@ -6,9 +6,6 @@ if not modules then modules = { } end modules ['luat-fio'] = {
license = "see context related readme files"
}
-local texiowrite_nl = (texio and texio.write_nl) or print
-local texiowrite = (texio and texio.write) or print
-
local format = string.format
local concat = table.concat
local sequenced = table.sequenced
@@ -98,7 +95,7 @@ luatex.registerstopactions(function()
report_system("start used files")
logs.newline()
for i=1,#foundintrees do
- report_files("%4i: % t",i,foundintrees[i])
+ report_files("%4i: % T",i,foundintrees[i])
end
logs.newline()
report_system("stop used files")
@@ -115,6 +112,6 @@ statistics.register("resource resolver", function()
scandata.time,
scandata.shared,
#resolvers.instance.foundintrees,
- concat(scandata.paths," ")
+ #scandata.paths > 0 and concat(scandata.paths," ") or "<none>"
)
end)
diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv
index 948a9bc8d..26596c157 100644
--- a/tex/context/base/luat-lib.mkiv
+++ b/tex/context/base/luat-lib.mkiv
@@ -22,14 +22,15 @@
%registerctxluafile{util-lua}{1.001} % moved
\registerctxluafile{util-prs}{1.001}
\registerctxluafile{util-fmt}{1.001}
-\registerctxluafile{util-deb}{1.001} % could also be done in trac-deb.mkiv
\registerctxluafile{util-dim}{1.001}
-\registerctxluafile{trac-inf}{1.001}
+%registerctxluafile{trac-inf}{1.001}
\registerctxluafile{trac-set}{1.001}
\registerctxluafile{trac-log}{1.001}
+\registerctxluafile{trac-inf}{1.001}
%registerctxluafile{trac-pro}{1.001}
\registerctxluafile{util-lua}{1.001}
+\registerctxluafile{util-deb}{1.001} % could also be done in trac-deb.mkiv
\registerctxluafile{util-tpl}{1.001} % needs tracker
diff --git a/tex/context/base/luat-run.lua b/tex/context/base/luat-run.lua
index 4f65370bb..34d45d096 100644
--- a/tex/context/base/luat-run.lua
+++ b/tex/context/base/luat-run.lua
@@ -9,10 +9,15 @@ if not modules then modules = { } end modules ['luat-run'] = {
local format = string.format
local insert = table.insert
+-- trace_job_status is also controlled by statistics.enable that is set via the directive system.nostatistics
+
local trace_lua_dump = false trackers.register("system.dump", function(v) trace_lua_dump = v end)
local trace_temp_files = false trackers.register("system.tempfiles", function(v) trace_temp_files = v end)
+local trace_job_status = true trackers.register("system.jobstatus", function(v) trace_job_status = v end)
+local trace_tex_status = false trackers.register("system.texstatus", function(v) trace_tex_status = v end)
local report_lua = logs.reporter("system","lua")
+local report_tex = logs.reporter("system","status")
local report_tempfiles = logs.reporter("resolvers","tempfiles")
luatex = luatex or { }
@@ -24,9 +29,6 @@ local stopactions = { }
function luatex.registerstartactions(...) insert(startactions, ...) end
function luatex.registerstopactions (...) insert(stopactions, ...) end
-luatex.showtexstat = luatex.showtexstat or function() end
-luatex.showjobstat = luatex.showjobstat or statistics.showjobstat
-
local function start_run()
if logs.start_run then
logs.start_run()
@@ -40,12 +42,12 @@ local function stop_run()
for i=1,#stopactions do
stopactions[i]()
end
- if luatex.showjobstat then
- statistics.show(logs.report_job_stat)
+ if trace_job_status then
+ statistics.show()
end
- if luatex.showtexstat then
- for k,v in next, status.list() do
- logs.report_tex_stat(k,v)
+ if trace_tex_status then
+ for k, v in table.sortedhash(status.list()) do
+ report_tex("%S=%S",k,v)
end
end
if logs.stop_run then
@@ -75,7 +77,6 @@ end
local function pre_dump_actions()
lua.finalize(trace_lua_dump and report_lua or nil)
- statistics.reportstorage("log")
-- statistics.savefmtstatus("\jobname","\contextversion","context.tex")
end
diff --git a/tex/context/base/luat-sto.lua b/tex/context/base/luat-sto.lua
index 67653da6a..c2c89004f 100644
--- a/tex/context/base/luat-sto.lua
+++ b/tex/context/base/luat-sto.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['luat-sto'] = {
-- we could nil some function in the productionrun
local type, next, setmetatable, getmetatable, collectgarbage = type, next, setmetatable, getmetatable, collectgarbage
-local gmatch, format, write_nl = string.gmatch, string.format, texio.write_nl
+local gmatch, format = string.gmatch, string.format
local serialize, concat, sortedhash = table.serialize, table.concat, table.sortedhash
local bytecode = lua.bytecode
local strippedloadstring = utilities.lua.strippedloadstring
@@ -155,36 +155,11 @@ if lua.bytedata then
storage.register("lua/bytedata",lua.bytedata,"lua.bytedata")
end
-function statistics.reportstorage(whereto)
- whereto = whereto or "term and log"
- write_nl(whereto," ","stored tables:"," ")
- for k,v in sortedhash(storage.data) do
- write_nl(whereto,format("%03i %s",k,v[1]))
- end
- write_nl(whereto," ","stored modules:"," ")
- for k,v in sortedhash(lua.bytedata) do
- write_nl(whereto,format("%03i %s %s",k,v[2],v[1]))
- end
- write_nl(whereto," ","stored attributes:"," ")
- for k,v in sortedhash(attributes.names) do
- write_nl(whereto,format("%03i %s",k,v))
- end
- write_nl(whereto," ","stored catcodetables:"," ")
- for k,v in sortedhash(catcodes.names) do
- write_nl(whereto,format("%03i %s",k,concat(v," ")))
- end
- write_nl(whereto," ","used corenamespaces:"," ")
- for k,v in sortedhash(interfaces.corenamespaces) do
- write_nl(whereto,format("%03i %s",k,v))
- end
- write_nl(whereto," ")
-end
-
-storage.shared = storage.shared or { }
-
-- Because the storage mechanism assumes tables, we define a table for storing
-- (non table) values.
+storage.shared = storage.shared or { }
+
storage.register("storage/shared", storage.shared, "storage.shared")
local mark = storage.mark
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 30d264c4e..f7de100b2 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -1588,16 +1588,18 @@ statistics.register("lxml lpath profile", function()
if p and next(p) then
local s = table.sortedkeys(p)
local tested, matched, finalized = 0, 0, 0
- texio.write_nl("log","\nbegin of lxml profile\n")
- texio.write_nl("log","\n tested matched finalized pattern\n\n")
+ logs.pushtarget("logfile")
+ logs.writer("\nbegin of lxml profile\n")
+ logs.writer("\n tested matched finalized pattern\n\n")
for i=1,#s do
local pattern = s[i]
local pp = p[pattern]
local t, m, f = pp.tested, pp.matched, pp.finalized
tested, matched, finalized = tested + t, matched + m, finalized + f
- texio.write_nl("log",format("%9i %9i %9i %s",t,m,f,pattern))
+ logs.writer(format("%9i %9i %9i %s",t,m,f,pattern))
end
- texio.write_nl("log","\nend of lxml profile\n")
+ logs.writer("\nend of lxml profile\n")
+ logs.poptarget()
return format("%s patterns, %s tested, %s matched, %s finalized (see log for details)",#s,tested,matched,finalized)
else
return nil
diff --git a/tex/context/base/node-ext.lua b/tex/context/base/node-ext.lua
index 5c4eec8de..82ec04ee5 100644
--- a/tex/context/base/node-ext.lua
+++ b/tex/context/base/node-ext.lua
@@ -13,14 +13,14 @@ use external applications to process node lists.</p>
--ldx]]--
function nodes.show(stack)
--- texio.write_nl(table.serialize(stack))
+-- logs.writer(table.serialize(stack))
end
function nodes.save(stack,name) -- *.ltn : luatex node file
-- if name then
-- file.savedata(name,table.serialize(stack))
-- else
--- texio.write_nl('log',table.serialize(stack))
+-- logs.writer(table.serialize(stack))
-- end
end
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index cad45c6a2..9367badd3 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -72,7 +72,7 @@ end
-- end
--
-- function states.check()
--- texio.write_nl(concat(collected,"\n"))
+-- logs.report("states",concat(collected,"\n"))
-- end
-- we used to do the main processor loop here and call processor for each node
diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua
index 3caeb69dd..be1eb77bf 100644
--- a/tex/context/base/node-ini.lua
+++ b/tex/context/base/node-ini.lua
@@ -213,18 +213,24 @@ listcodes.column = listcodes.alignment
kerncodes.italiccorrection = kerncodes.userkern
kerncodes.kerning = kerncodes.fontkern
-nodes.codes = allocate {
+nodes.codes = allocate { -- mostly for listing
+ glue = skipcodes,
+ noad = noadcodes,
+ node = nodecodes,
hlist = listcodes,
vlist = listcodes,
glyph = glyphcodes,
- glue = skipcodes,
kern = kerncodes,
- whatsit = whatcodes,
+ penalty = penaltycodes,
math = mathnodes,
- noad = noadcodes,
+ fill = fillcodes,
margin = margincodes,
+ disc = disccodes,
+ whatsit = whatcodes,
}
+local report_codes = logs.reporter("nodes","codes")
+
function nodes.showcodes()
local t = { }
for name, codes in sortedhash(nodes.codes) do
@@ -238,7 +244,7 @@ function nodes.showcodes()
end
formatcolumns(t)
for k=1,#t do
- texio.write_nl(t[k])
+ report_codes (t[k])
end
end
diff --git a/tex/context/base/node-ser.lua b/tex/context/base/node-ser.lua
index 2c3e7fefb..b0a6e9952 100644
--- a/tex/context/base/node-ser.lua
+++ b/tex/context/base/node-ser.lua
@@ -277,7 +277,7 @@ end
function nodes.print(head,n)
while head do
local id = head.id
- texio.write_nl(rep(" ",n or 0) .. tostring(head))
+ logs.writer(string.formatters["%w%S"],n or 0,head)
if id == hlist_code or id == vlist_code then
nodes.print(head.list,(n or 0)+1)
end
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index c7f50b1aa..48d6310b0 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -15,7 +15,6 @@ local utfchar = utf.char
local concat = table.concat
local format, match, gmatch, concat, rep = string.format, string.match, string.gmatch, table.concat, string.rep
local lpegmatch = lpeg.match
-local write_nl = texio.write_nl
local clock = os.gettimeofday or os.clock -- should go in environment
local report_nodes = logs.reporter("nodes","tracing")
@@ -353,10 +352,10 @@ end
function nodes.showlist(head, message)
if message then
- write_nl(message)
+ report_nodes(message)
end
for n in traverse_nodes(head) do
- write_nl(tostring(n))
+ report_nodes(tostring(n))
end
end
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index db91fd850..1c266bb28 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index fb42b1ac2..8860757b1 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/toks-ini.lua b/tex/context/base/toks-ini.lua
index f88e0fcb5..ef4b5406b 100644
--- a/tex/context/base/toks-ini.lua
+++ b/tex/context/base/toks-ini.lua
@@ -197,7 +197,7 @@ collectors.showtoken = showtoken
function collectors.trace()
local t = get_next()
- texio.write_nl(showtoken(t))
+ logs.report("tokenlist",showtoken(t))
return t
end
diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua
index 1d39f24a6..fdc07d97d 100644
--- a/tex/context/base/trac-inf.lua
+++ b/tex/context/base/trac-inf.lua
@@ -15,7 +15,6 @@ local type, tonumber = type, tonumber
local format, lower = string.format, string.lower
local concat = table.concat
local clock = os.gettimeofday or os.clock -- should go in environment
-local write_nl = texio and texio.write_nl or print
statistics = statistics or { }
local statistics = statistics
@@ -116,9 +115,10 @@ function statistics.register(tag,fnc)
end
end
-function statistics.show(reporter)
+local report = logs.reporter("mkiv lua stats")
+
+function statistics.show()
if statistics.enable then
- if not reporter then reporter = function(tag,data,n) write_nl(tag .. " " .. data) end end
-- this code will move
local register = statistics.register
register("luatex banner", function()
@@ -139,39 +139,23 @@ function statistics.show(reporter)
end)
end
end
- collectgarbage("collect")
- register("current memory usage", statistics.memused)
+ -- so far
+ -- collectgarbage("collect")
+ register("current memory usage",statistics.memused)
register("runtime",statistics.runtime)
+ logs.newline() -- initial newline
for i=1,#statusinfo do
local s = statusinfo[i]
local r = s[2]()
if r then
- reporter(s[1],r,n)
+ report("%s: %s",s[1],r)
end
end
- write_nl("") -- final newline
+ -- logs.newline() -- final newline
statistics.enable = false
end
end
-local template, report_statistics, nn = nil, nil, 0 -- we only calcute it once
-
-function statistics.showjobstat(tag,data,n)
- if not logs then
- -- sorry
- elseif type(data) == "table" then
- for i=1,#data do
- statistics.showjobstat(tag,data[i],n)
- end
- else
- if not template or n > nn then
- template, n = format("%%-%ss - %%s",n), nn
- report_statistics = logs.reporter("mkiv lua stats")
- end
- report_statistics(format(template,tag,data))
- end
-end
-
function statistics.memused() -- no math.round yet -)
local round = math.round or math.floor
return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000), round(status.luastate_bytes/1000000))
@@ -188,8 +172,9 @@ function statistics.runtime()
return statistics.formatruntime(elapsedtime(statistics))
end
-function statistics.timed(action,report)
- report = report or logs.reporter("system")
+local report = logs.reporter("system")
+
+function statistics.timed(action)
starttiming("run")
action()
stoptiming("run")
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index 2b84ba487..6a6bd39cb 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -6,6 +6,60 @@ if not modules then modules = { } end modules ['trac-log'] = {
license = "see context related readme files"
}
+if tex and (tex.jobname or tex.formatname) then
+
+ -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2)
+
+ local texio_write_nl = texio.write_nl
+ local texio_write = texio.write
+ local io_write = io.write
+
+ local write_nl = function(target,...)
+ if not io_write then
+ io_write = io.write
+ end
+ if target == "term and log" then
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(...)
+ elseif target == "log" then
+ texio_write_nl("log",...)
+ elseif target == "term" then
+ texio_write_nl("term","")
+ io_write(...)
+ else
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(target,...)
+ end
+ end
+
+ local write = function(target,...)
+ if not io_write then
+ io_write = io.write
+ end
+ if target == "term and log" then
+ texio_write("log",...)
+ io_write(...)
+ elseif target == "log" then
+ texio_write("log",...)
+ elseif target == "term" then
+ io_write(...)
+ else
+ texio_write("log",...)
+ io_write(target,...)
+ end
+ end
+
+ texio.write = write
+ texio.write_nl = write_nl
+
+else
+
+ -- texlua
+
+end
+
-- todo: less categories, more subcategories (e.g. nodes)
-- todo: split into basics and ctx specific
@@ -217,8 +271,6 @@ if tex and (tex.jobname or tex.formatname) then
else
--- local format = string.formatter
-
logs.flush = ignore
writer = write_nl
@@ -449,6 +501,16 @@ function logs.show()
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
+local delayed_reporters = { } setmetatableindex(delayed_reporters,function(t,k)
+ local v = logs.reporter(k)
+ t[k] = v
+ return v
+end)
+
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
+
directives.register("logs.blocked", function(v)
setblocked(v,true)
end)
@@ -513,15 +575,12 @@ function logs.stop_page_number() -- the first page can includes the initializati
logs.flush()
end
-logs.report_job_stat = statistics and statistics.showjobstat
+-- we don't have show_open and show_close callbacks yet
local report_files = logs.reporter("files")
-
-local nesting = 0
-local verbose = false
-local hasscheme = url.hasscheme
-
--- we don't have show_open and show_close callbacks yet
+local nesting = 0
+local verbose = false
+local hasscheme = url.hasscheme
function logs.show_open(name)
-- if hasscheme(name) ~= "virtual" then
@@ -699,3 +758,6 @@ end
io.stdout:setvbuf('no')
io.stderr:setvbuf('no')
+
+-- windows: > nul 2>&1
+-- unix : > null 2>&1
diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua
index 9dc5dd9da..6f91e25f7 100644
--- a/tex/context/base/trac-set.lua
+++ b/tex/context/base/trac-set.lua
@@ -17,10 +17,11 @@ local allocate = utilities.storage.allocate
utilities = utilities or { }
local utilities = utilities
-utilities.setters = utilities.setters or { }
-local setters = utilities.setters
-local data = { } -- maybe just local
+local setters = utilities.setters or { }
+utilities.setters = setters
+
+local data = { }
-- We can initialize from the cnf file. This is sort of tricky as
-- later defined setters also need to be initialized then. If set
@@ -235,15 +236,8 @@ end
local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show
-local write_nl = texio and texio.write_nl or print
-
-local function report(setter,...)
- local report = logs and logs.report
- if report then
- report(setter.name,...)
- else -- fallback, as this module is loaded before the logger
- write_nl(format("%-15s : %s\n",setter.name,format(...)))
- end
+function setters.report(setter,...)
+ print(format("%-15s : %s\n",setter.name,format(...)))
end
local function default(setter,name)
@@ -261,14 +255,14 @@ function setters.new(name) -- we could use foo:bar syntax (but not used that oft
setter = {
data = allocate(), -- indexed, but also default and value fields
name = name,
- report = function(...) report (setter,...) end,
- enable = function(...) enable (setter,...) end,
- disable = function(...) disable (setter,...) end,
- register = function(...) register(setter,...) end,
- list = function(...) list (setter,...) end,
- show = function(...) show (setter,...) end,
- default = function(...) return default (setter,...) end,
- value = function(...) return value (setter,...) end,
+ report = function(...) setters.report (setter,...) end,
+ enable = function(...) enable (setter,...) end,
+ disable = function(...) disable (setter,...) end,
+ register = function(...) register(setter,...) end,
+ list = function(...) list (setter,...) end,
+ show = function(...) show (setter,...) end,
+ default = function(...) return default (setter,...) end,
+ value = function(...) return value (setter,...) end,
}
data[name] = setter
return setter
@@ -278,9 +272,9 @@ trackers = setters.new("trackers")
directives = setters.new("directives")
experiments = setters.new("experiments")
-local t_enable, t_disable, t_report = trackers .enable, trackers .disable, trackers .report
-local d_enable, d_disable, d_report = directives .enable, directives .disable, directives .report
-local e_enable, e_disable, e_report = experiments.enable, experiments.disable, experiments.report
+local t_enable, t_disable = trackers .enable, trackers .disable
+local d_enable, d_disable = directives .enable, directives .disable
+local e_enable, e_disable = experiments.enable, experiments.disable
-- nice trick: we overload two of the directives related functions with variants that
-- do tracing (itself using a tracker) .. proof of concept
@@ -290,28 +284,28 @@ local trace_experiments = false local trace_experiments = false trackers.regist
function directives.enable(...)
if trace_directives then
- d_report("enabling: % t",{...})
+ directives.report("enabling: % t",{...})
end
d_enable(...)
end
function directives.disable(...)
if trace_directives then
- d_report("disabling: % t",{...})
+ directives.report("disabling: % t",{...})
end
d_disable(...)
end
function experiments.enable(...)
if trace_experiments then
- e_report("enabling: % t",{...})
+ experiments.report("enabling: % t",{...})
end
e_enable(...)
end
function experiments.disable(...)
if trace_experiments then
- e_report("disabling: % t",{...})
+ experiments.report("disabling: % t",{...})
end
e_disable(...)
end
@@ -319,11 +313,19 @@ end
-- a useful example
directives.register("system.nostatistics", function(v)
- statistics.enable = not v
+ if statistics then
+ statistics.enable = not v
+ else
+ -- forget about it
+ end
end)
directives.register("system.nolibraries", function(v)
- libraries = nil -- we discard this tracing for security
+ if libraries then
+ libraries = nil -- we discard this tracing for security
+ else
+ -- no libraries defined
+ end
end)
-- experiment
diff --git a/tex/context/base/util-deb.lua b/tex/context/base/util-deb.lua
index d4b0831f2..785373f86 100644
--- a/tex/context/base/util-deb.lua
+++ b/tex/context/base/util-deb.lua
@@ -18,11 +18,13 @@ local format, find = string.format, string.find
local is_boolean = string.is_boolean
utilities = utilities or { }
-utilities.debugger = utilities.debugger or { }
-local debugger = utilities.debugger
+local debugger = utilities.debugger or { }
+utilities.debugger = debugger
-local counters = { }
-local names = { }
+local counters = { }
+local names = { }
+
+local report = logs.reporter("debugger")
-- one
@@ -50,7 +52,7 @@ local function hook()
end
function debugger.showstats(printer,threshold) -- hm, something has changed, rubish now
- printer = printer or texio.write or print
+ printer = printer or report
threshold = threshold or 0
local total, grandtotal, functions = 0, 0, 0
local dataset = { }
diff --git a/tex/context/base/util-sto.lua b/tex/context/base/util-sto.lua
index 147f17ea9..ddf699bca 100644
--- a/tex/context/base/util-sto.lua
+++ b/tex/context/base/util-sto.lua
@@ -12,12 +12,11 @@ utilities = utilities or { }
utilities.storage = utilities.storage or { }
local storage = utilities.storage
-local report = texio and texio.write_nl or print
-
function storage.mark(t)
if not t then
- report("fatal error: storage cannot be marked")
- return -- os.exit()
+ print("\nfatal error: storage cannot be marked\n")
+ os.exit()
+ return
end
local m = getmetatable(t)
if not m then
@@ -46,8 +45,9 @@ end
function storage.checked(t)
if not t then
- report("fatal error: storage has not been allocated")
- return -- os.exit()
+ report("\nfatal error: storage has not been allocated\n")
+ os.exit()
+ return
end
return t
end
diff --git a/tex/context/base/x-calcmath.lua b/tex/context/base/x-calcmath.lua
index e8656c78e..1394f3450 100644
--- a/tex/context/base/x-calcmath.lua
+++ b/tex/context/base/x-calcmath.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['x-calcmath'] = {
license = "see context related readme files"
}
+-- this really needs to be redone
+
local format, lower, upper, gsub, sub = string.format, string.lower, string.upper, string.gsub, string.sub
local concat = table.concat
local lpegmatch = lpeg.match
@@ -223,11 +225,8 @@ if false then
),
}
-
local parser = space * grammar * -1
- local texprint = function(...) texio.write(concat{ ... }) end
-
local function has_factor(t)
for i=1,#t do
if t[i] == "factor" then
@@ -236,112 +235,114 @@ if false then
end
end
+ -- can be sped up if needed ...
+
function totex(t)
if t then
local one = t[1]
if type(one) == "string" then
local two, three = t[2], t[3]
if one == "number" then
- texprint(two)
+ context(two)
elseif one == "real" then
- texprint(two)
+ context(two)
elseif one == "float" then
- texprint("\\scinot{",two,"}{",three,"}")
+ context("\\scinot{",two,"}{",three,"}")
elseif one == "identifier" then
- texprint(two)
+ context(two)
elseif one == "constant" then
- texprint("\\"..two)
+ context("\\"..two)
elseif one == "function" then
if two == "sqrt" then
- texprint("\\sqrt{")
+ context("\\sqrt{")
totex(three)
- texprint("}")
+ context("}")
elseif two == "exp" then
- texprint(" e^{")
+ context(" e^{")
totex(three)
- texprint("}")
+ context("}")
elseif two == "abs" then
- texprint("\\left|")
+ context("\\left|")
totex(three)
- texprint("\\right|")
+ context("\\right|")
elseif two == "mean" then
- texprint("\\overline{")
+ context("\\overline{")
totex(three)
- texprint("}")
+ context("}")
elseif two == "int" or two == "prod" or two == "sum" then
local four, five = t[4], t[5]
if five then
- texprint("\\"..two.."^{")
+ context("\\"..two.."^{") -- context[two]("{")
totex(three)
- texprint("}_{")
+ context("}_{")
totex(four)
- texprint("}")
+ context("}")
totex(five)
elseif four then
- texprint("\\"..two.."^{")
+ context("\\"..two.."^{")
totex(three)
- texprint("}")
+ context("}")
totex(four)
elseif three then
- texprint("\\"..two.." ") -- " " not needed
+ context("\\"..two.." ") -- " " not needed
totex(three)
else
- texprint("\\"..two)
+ context("\\"..two)
end
else
- texprint("\\"..two.."(")
+ context("\\"..two.."(")
totex(three)
- texprint(")")
+ context(")")
end
end
else
local nt = #t
local hasfactor = has_factor(t)
if hasfactor then
- texprint("\\left(")
+ context("\\left(")
end
totex(one)
for i=2,nt,3 do
local what, how, rest = t[i], t[i+1], t[i+2]
if what == "factor" then
if how == '^' or how == "_" then
- texprint(how)
- texprint("{")
+ context(how)
+ context("{")
totex(rest)
- texprint("}")
+ context("}")
else
- texprint(how)
+ context(how)
totex(rest)
end
elseif what == "term" then
if how == '/' then
- texprint("\\frac{")
+ context("\\frac{")
totex(rest)
- texprint("}{")
+ context("}{")
totex(t[i+3] or "")
- texprint("}")
+ context("}")
elseif how == '*' then
- texprint("\\times")
+ context("\\times")
totex(rest)
else
- texprint(how)
+ context(how)
totex(three)
end
elseif what == "compare" then
if two == ">=" then
- texprint("\\ge")
+ context("\\ge")
elseif two == "<=" then
- texprint("\\le")
+ context("\\le")
elseif two == "&gt;" then
- texprint(">")
+ context(">")
elseif two == "&lt;" then
- texprint("<")
+ context("<")
end
totex(three)
end
end
if hasfactor then
- texprint("\\right)")
+ context("\\right)")
end
end
end
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index e1e12bb43..0cbe0f2d5 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 03/13/13 12:53:56
+-- merge date : 03/13/13 19:31:38
do -- begin closure to overcome local limits and interference
@@ -226,7 +226,6 @@ if not modules then modules={} end modules ['l-lpeg']={
license="see context related readme files"
}
lpeg=require("lpeg")
-local report=texio and texio.write_nl or print
local type,next,tostring=type,next,tostring
local byte,char,gmatch,format=string.byte,string.char,string.gmatch,string.format
local floor=math.floor