summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-04-02 16:25:10 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-04-02 16:25:10 +0200
commit15ab7c153a96a9befc4e2c1774e701f3c941cc2d (patch)
tree4262a9085036949283dd3e56d992111a9745c680 /scripts
parent37c561c2f98d84fc02011b7b819ae8cf9bb4b10d (diff)
downloadcontext-15ab7c153a96a9befc4e2c1774e701f3c941cc2d.tar.gz
2018-04-02 15:51:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-update.lua2
-rw-r--r--scripts/context/lua/mtxlibs.lua26
-rw-r--r--scripts/context/lua/mtxrun.lua167
-rw-r--r--scripts/context/stubs/install/first-setup.sh6
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua167
-rw-r--r--scripts/context/stubs/setup/setuptex141
-rw-r--r--scripts/context/stubs/unix/mtxrun167
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua167
8 files changed, 618 insertions, 225 deletions
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index 20ca9ce27..6663be7a2 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -188,6 +188,8 @@ update.platforms = {
["linux-64"] = "linux-64",
["linux64"] = "linux-64",
--
+ ["linuxmusl-64"] = "linuxmusl-64",
+ --
["linux-armhf"] = "linux-armhf",
--
["freebsd"] = "freebsd",
diff --git a/scripts/context/lua/mtxlibs.lua b/scripts/context/lua/mtxlibs.lua
index bb0e03b17..f6839eb9d 100644
--- a/scripts/context/lua/mtxlibs.lua
+++ b/scripts/context/lua/mtxlibs.lua
@@ -68,7 +68,7 @@ local owntree = ownpath
local ownlibs = {
"l-lua.lua",
- "l-macros.lua",
+ "l-macro.lua",
"l-sandbox.lua",
"l-package.lua",
"l-lpeg.lua",
@@ -196,15 +196,13 @@ end
local arguments = environment.arguments
local files = environment.files
-if file.basename(environment.ownname) ~= "mtxlibs.lua" then
- return
-end
+local ownname = file.basename(environment.ownname)
local helpinfo = [[
usage: mtxlibs [options]
---merge
---merge targetfile extralibs
+--selfmerge
+--selfmerge targetfile extralibs
--selfclean
and in a lua file:
@@ -218,7 +216,19 @@ local application = logs.application {
helpinfo = helpinfo,
}
-local report = application.report
+local report = application.report
+
+if ownname == "mtxrun" or ownname == "mtxrun.lua" then
+ -- we're using mtxrun
+ ownname = "mtxlibs.lua"
+elseif ownname == "mtxlibs" or ownname == "mtxlibs.lua" then
+ -- we're using lua
+ ownname = "mtxlibs.lua"
+else
+ report("usage : lua mtxlibs.lua ...")
+ report(" : mtxrun --script mtxlibs.lua ...")
+ return
+end
if arguments.selfmerge then
@@ -247,7 +257,7 @@ elseif arguments.selfclean then
merger.selfclean(ownname)
report("done")
-elseif arguments.help or files[1] == "help" then
+else -- if arguments.help or files[1] == "help" then
application.help()
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 3374a364a..91528360a 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -195,7 +195,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-macro"] = package.loaded["l-macro"] or true
--- original size: 6393, stripped down to: 3659
+-- original size: 8260, stripped down to: 5213
if not modules then modules={} end modules ['l-macros']={
version=1.001,
@@ -207,7 +207,8 @@ if not modules then modules={} end modules ['l-macros']={
local S,P,R,V,C,Cs,Cc,Ct,Carg=lpeg.S,lpeg.P,lpeg.R,lpeg.V,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg
local lpegmatch=lpeg.match
local concat=table.concat
-local next=next
+local format,sub=string.format,string.sub
+local next,load,type=next,load,type
local newline=S("\n\r")^1
local continue=P("\\")*newline
local spaces=S(" \t")+continue
@@ -228,6 +229,14 @@ local patterns={}
local definitions={}
local resolve
local subparser
+local report_lua=function(...)
+ if logs and logs.reporter then
+ report_lua=logs.reporter("system","lua")
+ report_lua(...)
+ else
+ print(format(...))
+ end
+end
resolve=C(C(name)*arguments^-1)/function(raw,s,a)
local d=definitions[s]
if d then
@@ -334,6 +343,61 @@ end
function macros.resolving()
return next(patterns)
end
+local function loaded(name,trace,detail)
+ local f=io.open(name,"rb")
+ if not f then
+ return false,format("file '%s' not found",name)
+ end
+ local c=f:read("*a")
+ if not c then
+ return false,format("file '%s' is invalid",name)
+ end
+ f:close()
+ local n=lpegmatch(parser,c)
+ if trace then
+ if #n~=#c then
+ report_lua("macros expanded in '%s' (%i => %i bytes)",name,#c,#n)
+ if detail then
+ report_lua()
+ report_lua(n)
+ report_lua()
+ end
+ elseif detail then
+ report_lua("no macros expanded in '%s'",name)
+ end
+ end
+ if #name>30 then
+ n="--[["..sub(name,-30).."]] "..n
+ else
+ n="--[["..name.."]] "..n
+ end
+ return load(n)
+end
+macros.loaded=loaded
+function required(name,trace)
+ local filename=file.addsuffix(name,"lua")
+ local fullname=resolvers and resolvers.find_file(filename) or filename
+ if not fullname or fullname=="" then
+ return false
+ end
+ local codeblob=package.loaded[fullname]
+ if codeblob then
+ return codeblob
+ end
+ local code,message=loaded(fullname,macros,trace,trace)
+ if type(code)=="function" then
+ code=code()
+ else
+ report_lua("error when loading '%s'",fullname)
+ return false,message
+ end
+ if code==nil then
+ code=false
+ end
+ package.loaded[fullname]=code
+ return code
+end
+macros.required=required
end -- of closure
@@ -609,7 +673,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-package"] = package.loaded["l-package"] or true
--- original size: 11564, stripped down to: 8625
+-- original size: 11562, stripped down to: 8625
if not modules then modules={} end modules ['l-package']={
version=1.001,
@@ -620,10 +684,10 @@ if not modules then modules={} end modules ['l-package']={
}
local type=type
local gsub,format,find=string.gsub,string.format,string.find
+local insert,remove=table.insert,table.remove
local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local package=package
local searchers=package.searchers or package.loaders
-local insert,remove=table.insert,table.remove
local filejoin=file and file.join or function(path,name) return path.."/"..name end
local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end
local addsuffix=file and file.addsuffix or function(name,suffix) return name.."."..suffix end
@@ -1871,7 +1935,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40161, stripped down to: 23559
+-- original size: 40197, stripped down to: 23561
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2783,10 +2847,10 @@ function table.reversed(t)
return tt
end
end
-function table.reverse(t)
+function table.reverse(t)
if t then
local n=#t
- for i=1,floor(n/2) do
+ for i=1,floor(n/2) do
local j=n-i+1
t[i],t[j]=t[j],t[i]
end
@@ -6037,7 +6101,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 38725, stripped down to: 21726
+-- original size: 38699, stripped down to: 22142
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6051,13 +6115,15 @@ utilities.strings=utilities.strings or {}
local strings=utilities.strings
local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,string.find
local load,dump=load,string.dump
-local tonumber,type,tostring,next=tonumber,type,tostring,next
+local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
+local unpack,concat=table.unpack,table.concat
local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
local loadstripped=nil
-if LUAVERSION<5.2 then
+local oldfashioned=LUAVERSION<5.2
+if oldfashioned then
loadstripped=function(str,shortcuts)
return load(str)
end
@@ -6329,7 +6395,7 @@ local template=[[
return function(%s) return %s end
]]
local preamble,environment="",{}
-if LUAVERSION<5.2 then
+if oldfashioned then
preamble=[[
local lpeg=lpeg
local type=type
@@ -6376,7 +6442,7 @@ else
sequenced=table.sequenced,
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
- formattedfloat=number.formattedfloat
+ formattedfloat=number.formattedfloat,
}
end
local arguments={ "a1" }
@@ -6733,12 +6799,18 @@ local builder=Cs { "start",
["?"]=Cs(((1-P("%"))^1 )^1)/format_rest,
["!"]=Carg(2)*prefix_any*P("!")*C((1-P("!"))^1)*P("!")/format_extension,
}
-local direct=Cs (
- P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
-)
+local xx=setmetatable({},{ __index=function(t,k) local v=format("%02x",k) t[k]=v return v end })
+local XX=setmetatable({},{ __index=function(t,k) local v=format("%02X",k) t[k]=v return v end })
+local preset={
+ ["%02x"]=function(n) return xx[n] end,
+ ["%02X"]=function(n) return XX[n] end,
+}
+local direct=P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
local function make(t,str)
- local f
- local p
+ local f=preset[str]
+ if f then
+ return f
+ end
local p=lpegmatch(direct,str)
if p then
f=loadstripped(p)()
@@ -6759,7 +6831,7 @@ local function use(t,fmt,...)
return t[fmt](...)
end
strings.formatters={}
-if LUAVERSION<5.2 then
+if oldfashioned then
function strings.formatters.new(noconcat)
local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_=preamble,_environment_={} }
setmetatable(t,{ __index=make,__call=use })
@@ -6796,7 +6868,7 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-if LUAVERSION<5.2 then
+if oldfashioned then
add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
@@ -9200,7 +9272,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32737, stripped down to: 22946
+-- original size: 32922, stripped down to: 23011
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -9210,13 +9282,15 @@ if not modules then modules={} end modules ['trac-log']={
license="see context related readme files"
}
local next,type,select,print=next,type,select,print
-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
local topattern=string.topattern
local utfchar=utf.char
local datetime=os.date
local openfile=io.open
+local runningtex=tex and (tex.jobname or tex.formatname)
+local write_nl=runningtex and texio and texio.write_nl or print
+local write=runningtex and texio and texio.write or io.write
local setmetatableindex=table.setmetatableindex
local formatters=string.formatters
local settings_to_hash=utilities.parsers.settings_to_hash
@@ -9243,7 +9317,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if tex and (tex.jobname or tex.formatname) then
+if runningtex then
if texio.setescape then
texio.setescape(0)
end
@@ -10091,7 +10165,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 8284, stripped down to: 5698
+-- original size: 8097, stripped down to: 5534
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -10205,10 +10279,7 @@ function statistics.show()
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)
+ register("callbacks",statistics.callbacks)
if TEXENGINE=="luajittex" and JITSUPPORTED then
local jitstatus=jit.status
if jitstatus then
@@ -10427,7 +10498,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-lua"] = package.loaded["util-lua"] or true
--- original size: 6921, stripped down to: 4998
+-- original size: 6621, stripped down to: 4764
if not modules then modules={} end modules ['util-lua']={
version=1.001,
@@ -10463,7 +10534,7 @@ luautilities.suffixes={
tua="tua",
tuc="tuc",
}
-local function register(name)
+local function register(name)
if tracestripping then
report_lua("stripped bytecode from %a",name or "unknown")
end
@@ -10491,17 +10562,12 @@ local function stupidcompile(luafile,lucfile,strip)
end
function luautilities.loadedluacode(fullname,forcestrip,name,macros)
name=name or fullname
- local code,message
if macros then
macros=lua.macros
end
- if macros and macros.enabled then
- local f=io.open(fullname,"rb") local c=f:read("*a") f:close()
- local n=c and macros.resolvestring("--[["..fullname.."]] "..c)
- if n and #n~=#c then
- report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n)
- end
- code,message=load(n or c)
+ local code,message
+ if macros then
+ code,message=macros.loaded(fullname,true,false)
else
code,message=loadfile(fullname)
end
@@ -15602,7 +15668,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-xml"] = package.loaded["lxml-xml"] or true
--- original size: 10412, stripped down to: 7669
+-- original size: 11096, stripped down to: 8243
if not modules then modules={} end modules ['lxml-xml']={
version=1.001,
@@ -15621,6 +15687,9 @@ local xmltostring=xml.tostring
local xmlserialize=xml.serialize
local xmlcollected=xml.collected
local xmlnewhandlers=xml.newhandlers
+local reparsedentity=xml.reparsedentitylpeg
+local unescapedentity=xml.unescapedentitylpeg
+local parsedentity=reparsedentity
local function first(collected)
return collected and collected[1]
end
@@ -15903,6 +15972,24 @@ function xml.text(id,pattern)
return ""
end
end
+function xml.pure(id,pattern)
+ if pattern then
+ local collected=xmlfilter(id,pattern)
+ if collected and #collected>0 then
+ parsedentity=unescapedentity
+ local s=collected and #collected>0 and xmltotext(collected[1]) or ""
+ parsedentity=reparsedentity
+ return s
+ else
+ return ""
+ end
+ else
+ parsedentity=unescapedentity
+ local s=xmltotext(id) or ""
+ parsedentity=reparsedentity
+ return s
+ end
+end
xml.content=text
function xml.position(id,pattern,n)
return position(xmlfilter(id,pattern),n)
@@ -21234,8 +21321,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 874849
--- stripped bytes : 317531
+-- original bytes : 877106
+-- stripped bytes : 317575
-- end library merge
diff --git a/scripts/context/stubs/install/first-setup.sh b/scripts/context/stubs/install/first-setup.sh
index ea72d55d4..11af49233 100644
--- a/scripts/context/stubs/install/first-setup.sh
+++ b/scripts/context/stubs/install/first-setup.sh
@@ -60,7 +60,6 @@ case "$system" in
FreeBSD|freebsd)
case "$cpu" in
i*86) platform="freebsd" ;;
- x86_64) platform="freebsd" ;; # no special binaries are available yet
amd64) platform="freebsd-amd64" ;;
*) platform="unknown" ;;
esac ;;
@@ -71,15 +70,14 @@ case "$system" in
#x86_64|amd64) platform="kfreebsd-amd64" ;;
*) platform="unknown" ;;
esac ;;
- # cygwin
# OpenBSD
- OpenBSD|freebsd)
+ OpenBSD)
case "$cpu" in
i*86) platform="openbsd" ;;
- x86_64) platform="openbsd" ;; # no special binaries are available yet
amd64) platform="openbsd-amd64" ;;
*) platform="unknown" ;;
esac ;;
+ # cygwin
CYGWIN*)
case "$cpu" in
i*86) platform="cygwin" ;;
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 3374a364a..91528360a 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -195,7 +195,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-macro"] = package.loaded["l-macro"] or true
--- original size: 6393, stripped down to: 3659
+-- original size: 8260, stripped down to: 5213
if not modules then modules={} end modules ['l-macros']={
version=1.001,
@@ -207,7 +207,8 @@ if not modules then modules={} end modules ['l-macros']={
local S,P,R,V,C,Cs,Cc,Ct,Carg=lpeg.S,lpeg.P,lpeg.R,lpeg.V,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg
local lpegmatch=lpeg.match
local concat=table.concat
-local next=next
+local format,sub=string.format,string.sub
+local next,load,type=next,load,type
local newline=S("\n\r")^1
local continue=P("\\")*newline
local spaces=S(" \t")+continue
@@ -228,6 +229,14 @@ local patterns={}
local definitions={}
local resolve
local subparser
+local report_lua=function(...)
+ if logs and logs.reporter then
+ report_lua=logs.reporter("system","lua")
+ report_lua(...)
+ else
+ print(format(...))
+ end
+end
resolve=C(C(name)*arguments^-1)/function(raw,s,a)
local d=definitions[s]
if d then
@@ -334,6 +343,61 @@ end
function macros.resolving()
return next(patterns)
end
+local function loaded(name,trace,detail)
+ local f=io.open(name,"rb")
+ if not f then
+ return false,format("file '%s' not found",name)
+ end
+ local c=f:read("*a")
+ if not c then
+ return false,format("file '%s' is invalid",name)
+ end
+ f:close()
+ local n=lpegmatch(parser,c)
+ if trace then
+ if #n~=#c then
+ report_lua("macros expanded in '%s' (%i => %i bytes)",name,#c,#n)
+ if detail then
+ report_lua()
+ report_lua(n)
+ report_lua()
+ end
+ elseif detail then
+ report_lua("no macros expanded in '%s'",name)
+ end
+ end
+ if #name>30 then
+ n="--[["..sub(name,-30).."]] "..n
+ else
+ n="--[["..name.."]] "..n
+ end
+ return load(n)
+end
+macros.loaded=loaded
+function required(name,trace)
+ local filename=file.addsuffix(name,"lua")
+ local fullname=resolvers and resolvers.find_file(filename) or filename
+ if not fullname or fullname=="" then
+ return false
+ end
+ local codeblob=package.loaded[fullname]
+ if codeblob then
+ return codeblob
+ end
+ local code,message=loaded(fullname,macros,trace,trace)
+ if type(code)=="function" then
+ code=code()
+ else
+ report_lua("error when loading '%s'",fullname)
+ return false,message
+ end
+ if code==nil then
+ code=false
+ end
+ package.loaded[fullname]=code
+ return code
+end
+macros.required=required
end -- of closure
@@ -609,7 +673,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-package"] = package.loaded["l-package"] or true
--- original size: 11564, stripped down to: 8625
+-- original size: 11562, stripped down to: 8625
if not modules then modules={} end modules ['l-package']={
version=1.001,
@@ -620,10 +684,10 @@ if not modules then modules={} end modules ['l-package']={
}
local type=type
local gsub,format,find=string.gsub,string.format,string.find
+local insert,remove=table.insert,table.remove
local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local package=package
local searchers=package.searchers or package.loaders
-local insert,remove=table.insert,table.remove
local filejoin=file and file.join or function(path,name) return path.."/"..name end
local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end
local addsuffix=file and file.addsuffix or function(name,suffix) return name.."."..suffix end
@@ -1871,7 +1935,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40161, stripped down to: 23559
+-- original size: 40197, stripped down to: 23561
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2783,10 +2847,10 @@ function table.reversed(t)
return tt
end
end
-function table.reverse(t)
+function table.reverse(t)
if t then
local n=#t
- for i=1,floor(n/2) do
+ for i=1,floor(n/2) do
local j=n-i+1
t[i],t[j]=t[j],t[i]
end
@@ -6037,7 +6101,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 38725, stripped down to: 21726
+-- original size: 38699, stripped down to: 22142
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6051,13 +6115,15 @@ utilities.strings=utilities.strings or {}
local strings=utilities.strings
local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,string.find
local load,dump=load,string.dump
-local tonumber,type,tostring,next=tonumber,type,tostring,next
+local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
+local unpack,concat=table.unpack,table.concat
local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
local loadstripped=nil
-if LUAVERSION<5.2 then
+local oldfashioned=LUAVERSION<5.2
+if oldfashioned then
loadstripped=function(str,shortcuts)
return load(str)
end
@@ -6329,7 +6395,7 @@ local template=[[
return function(%s) return %s end
]]
local preamble,environment="",{}
-if LUAVERSION<5.2 then
+if oldfashioned then
preamble=[[
local lpeg=lpeg
local type=type
@@ -6376,7 +6442,7 @@ else
sequenced=table.sequenced,
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
- formattedfloat=number.formattedfloat
+ formattedfloat=number.formattedfloat,
}
end
local arguments={ "a1" }
@@ -6733,12 +6799,18 @@ local builder=Cs { "start",
["?"]=Cs(((1-P("%"))^1 )^1)/format_rest,
["!"]=Carg(2)*prefix_any*P("!")*C((1-P("!"))^1)*P("!")/format_extension,
}
-local direct=Cs (
- P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
-)
+local xx=setmetatable({},{ __index=function(t,k) local v=format("%02x",k) t[k]=v return v end })
+local XX=setmetatable({},{ __index=function(t,k) local v=format("%02X",k) t[k]=v return v end })
+local preset={
+ ["%02x"]=function(n) return xx[n] end,
+ ["%02X"]=function(n) return XX[n] end,
+}
+local direct=P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
local function make(t,str)
- local f
- local p
+ local f=preset[str]
+ if f then
+ return f
+ end
local p=lpegmatch(direct,str)
if p then
f=loadstripped(p)()
@@ -6759,7 +6831,7 @@ local function use(t,fmt,...)
return t[fmt](...)
end
strings.formatters={}
-if LUAVERSION<5.2 then
+if oldfashioned then
function strings.formatters.new(noconcat)
local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_=preamble,_environment_={} }
setmetatable(t,{ __index=make,__call=use })
@@ -6796,7 +6868,7 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-if LUAVERSION<5.2 then
+if oldfashioned then
add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
@@ -9200,7 +9272,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32737, stripped down to: 22946
+-- original size: 32922, stripped down to: 23011
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -9210,13 +9282,15 @@ if not modules then modules={} end modules ['trac-log']={
license="see context related readme files"
}
local next,type,select,print=next,type,select,print
-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
local topattern=string.topattern
local utfchar=utf.char
local datetime=os.date
local openfile=io.open
+local runningtex=tex and (tex.jobname or tex.formatname)
+local write_nl=runningtex and texio and texio.write_nl or print
+local write=runningtex and texio and texio.write or io.write
local setmetatableindex=table.setmetatableindex
local formatters=string.formatters
local settings_to_hash=utilities.parsers.settings_to_hash
@@ -9243,7 +9317,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if tex and (tex.jobname or tex.formatname) then
+if runningtex then
if texio.setescape then
texio.setescape(0)
end
@@ -10091,7 +10165,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 8284, stripped down to: 5698
+-- original size: 8097, stripped down to: 5534
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -10205,10 +10279,7 @@ function statistics.show()
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)
+ register("callbacks",statistics.callbacks)
if TEXENGINE=="luajittex" and JITSUPPORTED then
local jitstatus=jit.status
if jitstatus then
@@ -10427,7 +10498,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-lua"] = package.loaded["util-lua"] or true
--- original size: 6921, stripped down to: 4998
+-- original size: 6621, stripped down to: 4764
if not modules then modules={} end modules ['util-lua']={
version=1.001,
@@ -10463,7 +10534,7 @@ luautilities.suffixes={
tua="tua",
tuc="tuc",
}
-local function register(name)
+local function register(name)
if tracestripping then
report_lua("stripped bytecode from %a",name or "unknown")
end
@@ -10491,17 +10562,12 @@ local function stupidcompile(luafile,lucfile,strip)
end
function luautilities.loadedluacode(fullname,forcestrip,name,macros)
name=name or fullname
- local code,message
if macros then
macros=lua.macros
end
- if macros and macros.enabled then
- local f=io.open(fullname,"rb") local c=f:read("*a") f:close()
- local n=c and macros.resolvestring("--[["..fullname.."]] "..c)
- if n and #n~=#c then
- report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n)
- end
- code,message=load(n or c)
+ local code,message
+ if macros then
+ code,message=macros.loaded(fullname,true,false)
else
code,message=loadfile(fullname)
end
@@ -15602,7 +15668,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-xml"] = package.loaded["lxml-xml"] or true
--- original size: 10412, stripped down to: 7669
+-- original size: 11096, stripped down to: 8243
if not modules then modules={} end modules ['lxml-xml']={
version=1.001,
@@ -15621,6 +15687,9 @@ local xmltostring=xml.tostring
local xmlserialize=xml.serialize
local xmlcollected=xml.collected
local xmlnewhandlers=xml.newhandlers
+local reparsedentity=xml.reparsedentitylpeg
+local unescapedentity=xml.unescapedentitylpeg
+local parsedentity=reparsedentity
local function first(collected)
return collected and collected[1]
end
@@ -15903,6 +15972,24 @@ function xml.text(id,pattern)
return ""
end
end
+function xml.pure(id,pattern)
+ if pattern then
+ local collected=xmlfilter(id,pattern)
+ if collected and #collected>0 then
+ parsedentity=unescapedentity
+ local s=collected and #collected>0 and xmltotext(collected[1]) or ""
+ parsedentity=reparsedentity
+ return s
+ else
+ return ""
+ end
+ else
+ parsedentity=unescapedentity
+ local s=xmltotext(id) or ""
+ parsedentity=reparsedentity
+ return s
+ end
+end
xml.content=text
function xml.position(id,pattern,n)
return position(xmlfilter(id,pattern),n)
@@ -21234,8 +21321,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 874849
--- stripped bytes : 317531
+-- original bytes : 877106
+-- stripped bytes : 317575
-- end library merge
diff --git a/scripts/context/stubs/setup/setuptex b/scripts/context/stubs/setup/setuptex
index 78128ee8b..9808140e4 100644
--- a/scripts/context/stubs/setup/setuptex
+++ b/scripts/context/stubs/setup/setuptex
@@ -22,59 +22,91 @@ system=`uname -s`
cpu=`uname -m`
case "$system" in
- # linux
- Linux)
- case "$cpu" in
- i*86) platform="linux" ;;
- x86_64|ia64) platform="linux-64" ;;
- # a little bit of cheating with ppc64 (won't work on Gentoo)
- ppc|ppc64) platform="linux-ppc" ;;
- *) platform="unknown" ;;
- esac ;;
- # Mac OS X
- Darwin)
- case "$cpu" in
- i*86) platform="osx-intel" ;;
- x86_64) platform="osx-64" ;;
- ppc*|powerpc|power*|Power*) platform="osx-ppc" ;;
- *) platform="unknown" ;;
- esac ;;
- # FreeBSD
- FreeBSD|freebsd)
- case "$cpu" in
- i*86) platform="freebsd" ;;
- x86_64) platform="freebsd" ;;
- amd64) platform="freebsd-amd64" ;;
- *) platform="unknown" ;;
- esac ;;
- # kFreeBSD (Debian)
- GNU/kFreeBSD)
- case "$cpu" in
- i*86) platform="kfreebsd-i386" ;;
- x86_64|amd64) platform="kfreebsd-amd64" ;;
- *) platform="unknown" ;;
- esac ;;
- # MSYS2|MSYS_NT-10.0)
- case "$cpu" in
- i*86) platform="win32" ;;
- x86_64) platform="win64" ;;
- *) platform="unknown" ;;
- esac ;;
- # cygwin
- CYGWIN)
- case "$cpu" in
- i*86) platform="cygwin" ;;
- x86_64|ia64) platform="cygwin-64" ;;
- *) platform="unknown" ;;
- esac ;;
- # SunOS/Solaris
- SunOS)
- case "$cpu" in
- sparc) platform="solaris-sparc" ;;
- i86pc) platform="solaris-intel" ;;
- *) platform="unknown" ;;
- esac ;;
- *) platform="unknown"
+ # linux
+ Linux)
+ case "$cpu" in
+ i*86) platform="linux" ;;
+ x86_64|ia64) platform="linux-64" ;;
+
+ # a little bit of cheating with ppc64 (won't work on Gentoo)
+ ppc|ppc64) platform="linux-ppc" ;;
+
+ # we currently support just mipsel, but Debian is lying (reports mips64)
+ # we need more hacks to fix the situation, this is just a temporary solution
+ mips|mips64|mipsel|mips64el) platform="linux-mipsel" ;;
+
+ armv7l) platform="linux-armhf"
+ # machine id output by uname(1) is insufficent to determine whether this
+ # is a soft or hard float system so we check ourselves.
+ # a) binutils, this should work almost everywhere
+ if $(which readelf >/dev/null 2>&1); then
+ readelf -A /proc/self/exe | grep -q '^ \+Tag_ABI_VFP_args'
+ if [ ! $? ]; then
+ platform="linux-armel"
+ fi
+ # b) debian-specific fallback
+ elif $(which dpkg >/dev/null 2>&1); then
+ if [ "$(dpkg --print-architecture)" = armel ]; then
+ platform="linux-armel"
+ fi
+ fi
+ # else go with hard fp
+ ;;
+
+ *) platform="unknown" ;;
+ esac ;;
+ # Mac OS X
+ Darwin)
+ case "$cpu" in
+ i*86) platform="osx-intel" ;;
+ x86_64) platform="osx-64" ;;
+ ppc*|powerpc|power*|Power*) platform="osx-ppc" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # FreeBSD
+ FreeBSD|freebsd)
+ case "$cpu" in
+ i*86) platform="freebsd" ;;
+ x86_64) platform="freebsd" ;;
+ amd64) platform="freebsd-amd64" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # OpenBSD
+ OpenBSD)
+ case "$cpu" in
+ i*86) platform="openbsd" ;;
+ amd64) platform="openbsd-amd64" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # kFreeBSD (Debian)
+ GNU/kFreeBSD)
+ case "$cpu" in
+ i*86) platform="kfreebsd-i386" ;;
+ x86_64|amd64) platform="kfreebsd-amd64" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # MSYS2
+ MSYS_NT-10.0)
+ case "$cpu" in
+ i*86) platform="win32" ;;
+ x86_64) platform="win64" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # cygwin
+ CYGWIN)
+ case "$cpu" in
+ i*86) platform="cygwin" ;;
+ x86_64|ia64) platform="cygwin-64" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ # SunOS/Solaris
+ SunOS)
+ case "$cpu" in
+ sparc) platform="solaris-sparc" ;;
+ i86pc) platform="solaris-intel" ;;
+ *) platform="unknown" ;;
+ esac ;;
+ *) platform="unknown"
esac
# temporary fix for Snow Leopard
@@ -91,6 +123,9 @@ fi
if test "$platform" = "unknown" ; then
echo "Error: your system \"$system $cpu\" is not supported yet."
echo "Please report to the ConTeXt mailing-list (ntg-context@ntg.nl)"
+elif test "$platform" = "linux-ppc" ; then
+ echo "Error: support for your system \"$platform\" has been dropped."
+ echo "Please ask on to the ConTeXt mailing-list if you still need it (ntg-context@ntg.nl)"
fi
#
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 3374a364a..91528360a 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -195,7 +195,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-macro"] = package.loaded["l-macro"] or true
--- original size: 6393, stripped down to: 3659
+-- original size: 8260, stripped down to: 5213
if not modules then modules={} end modules ['l-macros']={
version=1.001,
@@ -207,7 +207,8 @@ if not modules then modules={} end modules ['l-macros']={
local S,P,R,V,C,Cs,Cc,Ct,Carg=lpeg.S,lpeg.P,lpeg.R,lpeg.V,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg
local lpegmatch=lpeg.match
local concat=table.concat
-local next=next
+local format,sub=string.format,string.sub
+local next,load,type=next,load,type
local newline=S("\n\r")^1
local continue=P("\\")*newline
local spaces=S(" \t")+continue
@@ -228,6 +229,14 @@ local patterns={}
local definitions={}
local resolve
local subparser
+local report_lua=function(...)
+ if logs and logs.reporter then
+ report_lua=logs.reporter("system","lua")
+ report_lua(...)
+ else
+ print(format(...))
+ end
+end
resolve=C(C(name)*arguments^-1)/function(raw,s,a)
local d=definitions[s]
if d then
@@ -334,6 +343,61 @@ end
function macros.resolving()
return next(patterns)
end
+local function loaded(name,trace,detail)
+ local f=io.open(name,"rb")
+ if not f then
+ return false,format("file '%s' not found",name)
+ end
+ local c=f:read("*a")
+ if not c then
+ return false,format("file '%s' is invalid",name)
+ end
+ f:close()
+ local n=lpegmatch(parser,c)
+ if trace then
+ if #n~=#c then
+ report_lua("macros expanded in '%s' (%i => %i bytes)",name,#c,#n)
+ if detail then
+ report_lua()
+ report_lua(n)
+ report_lua()
+ end
+ elseif detail then
+ report_lua("no macros expanded in '%s'",name)
+ end
+ end
+ if #name>30 then
+ n="--[["..sub(name,-30).."]] "..n
+ else
+ n="--[["..name.."]] "..n
+ end
+ return load(n)
+end
+macros.loaded=loaded
+function required(name,trace)
+ local filename=file.addsuffix(name,"lua")
+ local fullname=resolvers and resolvers.find_file(filename) or filename
+ if not fullname or fullname=="" then
+ return false
+ end
+ local codeblob=package.loaded[fullname]
+ if codeblob then
+ return codeblob
+ end
+ local code,message=loaded(fullname,macros,trace,trace)
+ if type(code)=="function" then
+ code=code()
+ else
+ report_lua("error when loading '%s'",fullname)
+ return false,message
+ end
+ if code==nil then
+ code=false
+ end
+ package.loaded[fullname]=code
+ return code
+end
+macros.required=required
end -- of closure
@@ -609,7 +673,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-package"] = package.loaded["l-package"] or true
--- original size: 11564, stripped down to: 8625
+-- original size: 11562, stripped down to: 8625
if not modules then modules={} end modules ['l-package']={
version=1.001,
@@ -620,10 +684,10 @@ if not modules then modules={} end modules ['l-package']={
}
local type=type
local gsub,format,find=string.gsub,string.format,string.find
+local insert,remove=table.insert,table.remove
local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local package=package
local searchers=package.searchers or package.loaders
-local insert,remove=table.insert,table.remove
local filejoin=file and file.join or function(path,name) return path.."/"..name end
local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end
local addsuffix=file and file.addsuffix or function(name,suffix) return name.."."..suffix end
@@ -1871,7 +1935,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40161, stripped down to: 23559
+-- original size: 40197, stripped down to: 23561
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2783,10 +2847,10 @@ function table.reversed(t)
return tt
end
end
-function table.reverse(t)
+function table.reverse(t)
if t then
local n=#t
- for i=1,floor(n/2) do
+ for i=1,floor(n/2) do
local j=n-i+1
t[i],t[j]=t[j],t[i]
end
@@ -6037,7 +6101,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 38725, stripped down to: 21726
+-- original size: 38699, stripped down to: 22142
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6051,13 +6115,15 @@ utilities.strings=utilities.strings or {}
local strings=utilities.strings
local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,string.find
local load,dump=load,string.dump
-local tonumber,type,tostring,next=tonumber,type,tostring,next
+local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
+local unpack,concat=table.unpack,table.concat
local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
local loadstripped=nil
-if LUAVERSION<5.2 then
+local oldfashioned=LUAVERSION<5.2
+if oldfashioned then
loadstripped=function(str,shortcuts)
return load(str)
end
@@ -6329,7 +6395,7 @@ local template=[[
return function(%s) return %s end
]]
local preamble,environment="",{}
-if LUAVERSION<5.2 then
+if oldfashioned then
preamble=[[
local lpeg=lpeg
local type=type
@@ -6376,7 +6442,7 @@ else
sequenced=table.sequenced,
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
- formattedfloat=number.formattedfloat
+ formattedfloat=number.formattedfloat,
}
end
local arguments={ "a1" }
@@ -6733,12 +6799,18 @@ local builder=Cs { "start",
["?"]=Cs(((1-P("%"))^1 )^1)/format_rest,
["!"]=Carg(2)*prefix_any*P("!")*C((1-P("!"))^1)*P("!")/format_extension,
}
-local direct=Cs (
- P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
-)
+local xx=setmetatable({},{ __index=function(t,k) local v=format("%02x",k) t[k]=v return v end })
+local XX=setmetatable({},{ __index=function(t,k) local v=format("%02X",k) t[k]=v return v end })
+local preset={
+ ["%02x"]=function(n) return xx[n] end,
+ ["%02X"]=function(n) return XX[n] end,
+}
+local direct=P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
local function make(t,str)
- local f
- local p
+ local f=preset[str]
+ if f then
+ return f
+ end
local p=lpegmatch(direct,str)
if p then
f=loadstripped(p)()
@@ -6759,7 +6831,7 @@ local function use(t,fmt,...)
return t[fmt](...)
end
strings.formatters={}
-if LUAVERSION<5.2 then
+if oldfashioned then
function strings.formatters.new(noconcat)
local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_=preamble,_environment_={} }
setmetatable(t,{ __index=make,__call=use })
@@ -6796,7 +6868,7 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-if LUAVERSION<5.2 then
+if oldfashioned then
add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
@@ -9200,7 +9272,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32737, stripped down to: 22946
+-- original size: 32922, stripped down to: 23011
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -9210,13 +9282,15 @@ if not modules then modules={} end modules ['trac-log']={
license="see context related readme files"
}
local next,type,select,print=next,type,select,print
-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
local topattern=string.topattern
local utfchar=utf.char
local datetime=os.date
local openfile=io.open
+local runningtex=tex and (tex.jobname or tex.formatname)
+local write_nl=runningtex and texio and texio.write_nl or print
+local write=runningtex and texio and texio.write or io.write
local setmetatableindex=table.setmetatableindex
local formatters=string.formatters
local settings_to_hash=utilities.parsers.settings_to_hash
@@ -9243,7 +9317,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if tex and (tex.jobname or tex.formatname) then
+if runningtex then
if texio.setescape then
texio.setescape(0)
end
@@ -10091,7 +10165,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 8284, stripped down to: 5698
+-- original size: 8097, stripped down to: 5534
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -10205,10 +10279,7 @@ function statistics.show()
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)
+ register("callbacks",statistics.callbacks)
if TEXENGINE=="luajittex" and JITSUPPORTED then
local jitstatus=jit.status
if jitstatus then
@@ -10427,7 +10498,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-lua"] = package.loaded["util-lua"] or true
--- original size: 6921, stripped down to: 4998
+-- original size: 6621, stripped down to: 4764
if not modules then modules={} end modules ['util-lua']={
version=1.001,
@@ -10463,7 +10534,7 @@ luautilities.suffixes={
tua="tua",
tuc="tuc",
}
-local function register(name)
+local function register(name)
if tracestripping then
report_lua("stripped bytecode from %a",name or "unknown")
end
@@ -10491,17 +10562,12 @@ local function stupidcompile(luafile,lucfile,strip)
end
function luautilities.loadedluacode(fullname,forcestrip,name,macros)
name=name or fullname
- local code,message
if macros then
macros=lua.macros
end
- if macros and macros.enabled then
- local f=io.open(fullname,"rb") local c=f:read("*a") f:close()
- local n=c and macros.resolvestring("--[["..fullname.."]] "..c)
- if n and #n~=#c then
- report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n)
- end
- code,message=load(n or c)
+ local code,message
+ if macros then
+ code,message=macros.loaded(fullname,true,false)
else
code,message=loadfile(fullname)
end
@@ -15602,7 +15668,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-xml"] = package.loaded["lxml-xml"] or true
--- original size: 10412, stripped down to: 7669
+-- original size: 11096, stripped down to: 8243
if not modules then modules={} end modules ['lxml-xml']={
version=1.001,
@@ -15621,6 +15687,9 @@ local xmltostring=xml.tostring
local xmlserialize=xml.serialize
local xmlcollected=xml.collected
local xmlnewhandlers=xml.newhandlers
+local reparsedentity=xml.reparsedentitylpeg
+local unescapedentity=xml.unescapedentitylpeg
+local parsedentity=reparsedentity
local function first(collected)
return collected and collected[1]
end
@@ -15903,6 +15972,24 @@ function xml.text(id,pattern)
return ""
end
end
+function xml.pure(id,pattern)
+ if pattern then
+ local collected=xmlfilter(id,pattern)
+ if collected and #collected>0 then
+ parsedentity=unescapedentity
+ local s=collected and #collected>0 and xmltotext(collected[1]) or ""
+ parsedentity=reparsedentity
+ return s
+ else
+ return ""
+ end
+ else
+ parsedentity=unescapedentity
+ local s=xmltotext(id) or ""
+ parsedentity=reparsedentity
+ return s
+ end
+end
xml.content=text
function xml.position(id,pattern,n)
return position(xmlfilter(id,pattern),n)
@@ -21234,8 +21321,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 874849
--- stripped bytes : 317531
+-- original bytes : 877106
+-- stripped bytes : 317575
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 3374a364a..91528360a 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -195,7 +195,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-macro"] = package.loaded["l-macro"] or true
--- original size: 6393, stripped down to: 3659
+-- original size: 8260, stripped down to: 5213
if not modules then modules={} end modules ['l-macros']={
version=1.001,
@@ -207,7 +207,8 @@ if not modules then modules={} end modules ['l-macros']={
local S,P,R,V,C,Cs,Cc,Ct,Carg=lpeg.S,lpeg.P,lpeg.R,lpeg.V,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg
local lpegmatch=lpeg.match
local concat=table.concat
-local next=next
+local format,sub=string.format,string.sub
+local next,load,type=next,load,type
local newline=S("\n\r")^1
local continue=P("\\")*newline
local spaces=S(" \t")+continue
@@ -228,6 +229,14 @@ local patterns={}
local definitions={}
local resolve
local subparser
+local report_lua=function(...)
+ if logs and logs.reporter then
+ report_lua=logs.reporter("system","lua")
+ report_lua(...)
+ else
+ print(format(...))
+ end
+end
resolve=C(C(name)*arguments^-1)/function(raw,s,a)
local d=definitions[s]
if d then
@@ -334,6 +343,61 @@ end
function macros.resolving()
return next(patterns)
end
+local function loaded(name,trace,detail)
+ local f=io.open(name,"rb")
+ if not f then
+ return false,format("file '%s' not found",name)
+ end
+ local c=f:read("*a")
+ if not c then
+ return false,format("file '%s' is invalid",name)
+ end
+ f:close()
+ local n=lpegmatch(parser,c)
+ if trace then
+ if #n~=#c then
+ report_lua("macros expanded in '%s' (%i => %i bytes)",name,#c,#n)
+ if detail then
+ report_lua()
+ report_lua(n)
+ report_lua()
+ end
+ elseif detail then
+ report_lua("no macros expanded in '%s'",name)
+ end
+ end
+ if #name>30 then
+ n="--[["..sub(name,-30).."]] "..n
+ else
+ n="--[["..name.."]] "..n
+ end
+ return load(n)
+end
+macros.loaded=loaded
+function required(name,trace)
+ local filename=file.addsuffix(name,"lua")
+ local fullname=resolvers and resolvers.find_file(filename) or filename
+ if not fullname or fullname=="" then
+ return false
+ end
+ local codeblob=package.loaded[fullname]
+ if codeblob then
+ return codeblob
+ end
+ local code,message=loaded(fullname,macros,trace,trace)
+ if type(code)=="function" then
+ code=code()
+ else
+ report_lua("error when loading '%s'",fullname)
+ return false,message
+ end
+ if code==nil then
+ code=false
+ end
+ package.loaded[fullname]=code
+ return code
+end
+macros.required=required
end -- of closure
@@ -609,7 +673,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-package"] = package.loaded["l-package"] or true
--- original size: 11564, stripped down to: 8625
+-- original size: 11562, stripped down to: 8625
if not modules then modules={} end modules ['l-package']={
version=1.001,
@@ -620,10 +684,10 @@ if not modules then modules={} end modules ['l-package']={
}
local type=type
local gsub,format,find=string.gsub,string.format,string.find
+local insert,remove=table.insert,table.remove
local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local package=package
local searchers=package.searchers or package.loaders
-local insert,remove=table.insert,table.remove
local filejoin=file and file.join or function(path,name) return path.."/"..name end
local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end
local addsuffix=file and file.addsuffix or function(name,suffix) return name.."."..suffix end
@@ -1871,7 +1935,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40161, stripped down to: 23559
+-- original size: 40197, stripped down to: 23561
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2783,10 +2847,10 @@ function table.reversed(t)
return tt
end
end
-function table.reverse(t)
+function table.reverse(t)
if t then
local n=#t
- for i=1,floor(n/2) do
+ for i=1,floor(n/2) do
local j=n-i+1
t[i],t[j]=t[j],t[i]
end
@@ -6037,7 +6101,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 38725, stripped down to: 21726
+-- original size: 38699, stripped down to: 22142
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6051,13 +6115,15 @@ utilities.strings=utilities.strings or {}
local strings=utilities.strings
local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,string.find
local load,dump=load,string.dump
-local tonumber,type,tostring,next=tonumber,type,tostring,next
+local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
+local unpack,concat=table.unpack,table.concat
local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
local loadstripped=nil
-if LUAVERSION<5.2 then
+local oldfashioned=LUAVERSION<5.2
+if oldfashioned then
loadstripped=function(str,shortcuts)
return load(str)
end
@@ -6329,7 +6395,7 @@ local template=[[
return function(%s) return %s end
]]
local preamble,environment="",{}
-if LUAVERSION<5.2 then
+if oldfashioned then
preamble=[[
local lpeg=lpeg
local type=type
@@ -6376,7 +6442,7 @@ else
sequenced=table.sequenced,
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
- formattedfloat=number.formattedfloat
+ formattedfloat=number.formattedfloat,
}
end
local arguments={ "a1" }
@@ -6733,12 +6799,18 @@ local builder=Cs { "start",
["?"]=Cs(((1-P("%"))^1 )^1)/format_rest,
["!"]=Carg(2)*prefix_any*P("!")*C((1-P("!"))^1)*P("!")/format_extension,
}
-local direct=Cs (
- P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
-)
+local xx=setmetatable({},{ __index=function(t,k) local v=format("%02x",k) t[k]=v return v end })
+local XX=setmetatable({},{ __index=function(t,k) local v=format("%02X",k) t[k]=v return v end })
+local preset={
+ ["%02x"]=function(n) return xx[n] end,
+ ["%02X"]=function(n) return XX[n] end,
+}
+local direct=P("%")*(S("+- .")+R("09"))^0*S("sqidfgGeExXo")*P(-1)/[[local format = string.format return function(str) return format("%0",str) end]]
local function make(t,str)
- local f
- local p
+ local f=preset[str]
+ if f then
+ return f
+ end
local p=lpegmatch(direct,str)
if p then
f=loadstripped(p)()
@@ -6759,7 +6831,7 @@ local function use(t,fmt,...)
return t[fmt](...)
end
strings.formatters={}
-if LUAVERSION<5.2 then
+if oldfashioned then
function strings.formatters.new(noconcat)
local t={ _type_="formatter",_connector_=noconcat and "," or "..",_extensions_={},_preamble_=preamble,_environment_={} }
setmetatable(t,{ __index=make,__call=use })
@@ -6796,7 +6868,7 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-if LUAVERSION<5.2 then
+if oldfashioned then
add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
@@ -9200,7 +9272,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32737, stripped down to: 22946
+-- original size: 32922, stripped down to: 23011
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -9210,13 +9282,15 @@ if not modules then modules={} end modules ['trac-log']={
license="see context related readme files"
}
local next,type,select,print=next,type,select,print
-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
local topattern=string.topattern
local utfchar=utf.char
local datetime=os.date
local openfile=io.open
+local runningtex=tex and (tex.jobname or tex.formatname)
+local write_nl=runningtex and texio and texio.write_nl or print
+local write=runningtex and texio and texio.write or io.write
local setmetatableindex=table.setmetatableindex
local formatters=string.formatters
local settings_to_hash=utilities.parsers.settings_to_hash
@@ -9243,7 +9317,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if tex and (tex.jobname or tex.formatname) then
+if runningtex then
if texio.setescape then
texio.setescape(0)
end
@@ -10091,7 +10165,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 8284, stripped down to: 5698
+-- original size: 8097, stripped down to: 5534
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -10205,10 +10279,7 @@ function statistics.show()
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)
+ register("callbacks",statistics.callbacks)
if TEXENGINE=="luajittex" and JITSUPPORTED then
local jitstatus=jit.status
if jitstatus then
@@ -10427,7 +10498,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-lua"] = package.loaded["util-lua"] or true
--- original size: 6921, stripped down to: 4998
+-- original size: 6621, stripped down to: 4764
if not modules then modules={} end modules ['util-lua']={
version=1.001,
@@ -10463,7 +10534,7 @@ luautilities.suffixes={
tua="tua",
tuc="tuc",
}
-local function register(name)
+local function register(name)
if tracestripping then
report_lua("stripped bytecode from %a",name or "unknown")
end
@@ -10491,17 +10562,12 @@ local function stupidcompile(luafile,lucfile,strip)
end
function luautilities.loadedluacode(fullname,forcestrip,name,macros)
name=name or fullname
- local code,message
if macros then
macros=lua.macros
end
- if macros and macros.enabled then
- local f=io.open(fullname,"rb") local c=f:read("*a") f:close()
- local n=c and macros.resolvestring("--[["..fullname.."]] "..c)
- if n and #n~=#c then
- report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n)
- end
- code,message=load(n or c)
+ local code,message
+ if macros then
+ code,message=macros.loaded(fullname,true,false)
else
code,message=loadfile(fullname)
end
@@ -15602,7 +15668,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-xml"] = package.loaded["lxml-xml"] or true
--- original size: 10412, stripped down to: 7669
+-- original size: 11096, stripped down to: 8243
if not modules then modules={} end modules ['lxml-xml']={
version=1.001,
@@ -15621,6 +15687,9 @@ local xmltostring=xml.tostring
local xmlserialize=xml.serialize
local xmlcollected=xml.collected
local xmlnewhandlers=xml.newhandlers
+local reparsedentity=xml.reparsedentitylpeg
+local unescapedentity=xml.unescapedentitylpeg
+local parsedentity=reparsedentity
local function first(collected)
return collected and collected[1]
end
@@ -15903,6 +15972,24 @@ function xml.text(id,pattern)
return ""
end
end
+function xml.pure(id,pattern)
+ if pattern then
+ local collected=xmlfilter(id,pattern)
+ if collected and #collected>0 then
+ parsedentity=unescapedentity
+ local s=collected and #collected>0 and xmltotext(collected[1]) or ""
+ parsedentity=reparsedentity
+ return s
+ else
+ return ""
+ end
+ else
+ parsedentity=unescapedentity
+ local s=xmltotext(id) or ""
+ parsedentity=reparsedentity
+ return s
+ end
+end
xml.content=text
function xml.position(id,pattern,n)
return position(xmlfilter(id,pattern),n)
@@ -21234,8 +21321,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 874849
--- stripped bytes : 317531
+-- original bytes : 877106
+-- stripped bytes : 317575
-- end library merge