summaryrefslogtreecommitdiff
path: root/scripts/context/stubs
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-02-16 10:59:14 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-02-16 10:59:14 +0100
commit8e11d447440b44990432ac838953a8cde4ef914f (patch)
treef30b2ff2d8a10f1aff50e1522d968618a97f067c /scripts/context/stubs
parent43fc66771a0c9d27cc0b7fe7a69392ea313bd0ca (diff)
downloadcontext-8e11d447440b44990432ac838953a8cde4ef914f.tar.gz
2020-02-11 16:39:00
Diffstat (limited to 'scripts/context/stubs')
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua708
-rw-r--r--scripts/context/stubs/unix/mtxrun708
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua708
3 files changed, 894 insertions, 1230 deletions
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index bcc3bb243..15e99eb91 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -2102,7 +2102,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 42339, stripped down to: 21588
+-- original size: 41758, stripped down to: 22643
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2445,13 +2445,13 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,compact,inline,functions,metacheck
+local noquotes,hexify,handle,compact,inline,functions,metacheck,accurate
local reserved=table.tohash {
'and','break','do','else','elseif','end','false','for','function','if',
'in','local','nil','not','or','repeat','return','then','true','until','while',
- 'NaN','goto',
+ 'NaN','goto','const',
}
-local function is_simple_table(t,hexify)
+local function is_simple_table(t,hexify,accurate)
local nt=#t
if nt>0 then
local n=0
@@ -2470,6 +2470,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i]=format("0x%X",v)
+ elseif accurate then
+ tt[i]=format("%q",v)
else
tt[i]=v
end
@@ -2490,6 +2492,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i+1]=format("0x%X",v)
+ elseif accurate then
+ tt[i+1]=format("%q",v)
else
tt[i+1]=v
end
@@ -2561,6 +2565,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tv=="number" then
if hexify then
handle(format("%s 0x%X,",depth,v))
+ elseif accurate then
+ handle(format("%s %q,",depth,v))
else
handle(format("%s %s,",depth,v))
end
@@ -2570,7 +2576,7 @@ local function do_serialize(root,name,depth,level,indexed)
if next(v)==nil then
handle(format("%s {},",depth))
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
handle(format("%s { %s },",depth,concat(st,", ")))
else
@@ -2598,12 +2604,16 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v))
end
elseif tk=="boolean" then
if hexify then
handle(format("%s [%s]=0x%X,",depth,k and "true" or "false",v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
else
handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
end
@@ -2611,12 +2621,16 @@ local function do_serialize(root,name,depth,level,indexed)
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
if hexify then
handle(format("%s %s=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s %s=%q,",depth,k,v))
else
handle(format("%s %s=%s,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%q]=%s,",depth,k,v))
end
@@ -2625,6 +2639,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%s]=%q,",depth,k,v))
end
@@ -2641,6 +2657,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={},",depth,k))
+ elseif accurate then
+ handle(format("%s [%q]={},",depth,k))
else
handle(format("%s [%s]={},",depth,k))
end
@@ -2653,11 +2671,13 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%q]={},",depth,k))
end
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={ %s },",depth,k,concat(st,", ")))
+ elseif accurate then
+ handle(format("%s [%q]={ %s },",depth,k,concat(st,", ")))
else
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
@@ -2679,6 +2699,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%s,",depth,k,v and "true" or "false"))
+ elseif accurate then
+ handle(format("%s [%q]=%s,",depth,k,v and "true" or "false"))
else
handle(format("%s [%s]=%s,",depth,k,v and "true" or "false"))
end
@@ -2698,6 +2720,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=load(%q),",depth,k,f))
+ elseif accurate then
+ handle(format("%s [%q]=load(%q),",depth,k,f))
else
handle(format("%s [%s]=load(%q),",depth,k,f))
end
@@ -2715,6 +2739,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,tostring(v)))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
@@ -2738,6 +2764,7 @@ local function serialize(_handle,root,name,specification)
if type(specification)=="table" then
noquotes=specification.noquotes
hexify=specification.hexify
+ accurate=specification.accurate
handle=_handle or specification.handle or print
functions=specification.functions
compact=specification.compact
@@ -3779,7 +3806,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 18925, stripped down to: 10095
+-- original size: 19102, stripped down to: 10192
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -4200,6 +4227,12 @@ function os.validdate(year,month,day)
end
return year,month,day
end
+function os.date(fmt,...)
+ if not fmt then
+ fmt="%Y-%m-%d %H:%M"
+ end
+ return date(fmt,...)
+end
local osexit=os.exit
local exitcode=nil
function os.setexitcode(code)
@@ -6530,7 +6563,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 45072, stripped down to: 22629
+-- original size: 45188, stripped down to: 22734
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6945,9 +6978,12 @@ local format_left=function(f)
return format("a%s..utfpadding(a%s,%i)",n,n,-f)
end
end
-local format_q=function()
+local format_q=JITSUPPORTED and function()
n=n+1
return format("(a%s ~= nil and format('%%q',tostring(a%s)) or '')",n,n)
+end or function()
+ n=n+1
+ return format("(a%s ~= nil and format('%%q',a%s) or '')",n,n)
end
local format_Q=function()
n=n+1
@@ -7412,7 +7448,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 29567, stripped down to: 16483
+-- original size: 32649, stripped down to: 18257
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7649,92 +7685,160 @@ function tables.encapsulate(core,capsule,protect)
} )
end
end
-local f_hashed_string=formatters["[%Q]=%Q,"]
-local f_hashed_number=formatters["[%Q]=%s,"]
-local f_hashed_boolean=formatters["[%Q]=%l,"]
-local f_hashed_table=formatters["[%Q]="]
-local f_indexed_string=formatters["[%s]=%Q,"]
-local f_indexed_number=formatters["[%s]=%s,"]
-local f_indexed_boolean=formatters["[%s]=%l,"]
-local f_indexed_table=formatters["[%s]="]
-local f_ordered_string=formatters["%Q,"]
-local f_ordered_number=formatters["%s,"]
-local f_ordered_boolean=formatters["%l,"]
-function table.fastserialize(t,prefix)
- local r={ type(prefix)=="string" and prefix or "return" }
- local m=1
- local function fastserialize(t,outer)
- local n=#t
- m=m+1
- r[m]="{"
- if n>0 then
- local v=t[0]
- if v then
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_indexed_string(0,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(0,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(0)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(0,v)
+if JITSUPPORTED then
+ local f_hashed_string=formatters["[%Q]=%Q,"]
+ local f_hashed_number=formatters["[%Q]=%s,"]
+ local f_hashed_boolean=formatters["[%Q]=%l,"]
+ local f_hashed_table=formatters["[%Q]="]
+ local f_indexed_string=formatters["[%s]=%Q,"]
+ local f_indexed_number=formatters["[%s]=%s,"]
+ local f_indexed_boolean=formatters["[%s]=%l,"]
+ local f_indexed_table=formatters["[%s]="]
+ local f_ordered_string=formatters["%Q,"]
+ local f_ordered_number=formatters["%s,"]
+ local f_ordered_boolean=formatters["%l,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(0,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(0,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(0)
+ fastserialize(v)
+ m=m+1 r[m]=f_indexed_table(0)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(0,v)
+ end
end
- end
- for i=1,n do
- local v=t[i]
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_ordered_string(v)
- elseif tv=="number" then
- m=m+1 r[m]=f_ordered_number(v)
- elseif tv=="table" then
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_ordered_boolean(v)
+ for i=1,n do
+ local v=t[i]
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_ordered_string(v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_ordered_number(v)
+ elseif tv=="table" then
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_ordered_boolean(v)
+ end
end
end
- end
- for k,v in next,t do
- local tk=type(k)
- if tk=="number" then
- if k>n or k<0 then
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(k,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(k,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(k)
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(k,v)
+ end
+ end
+ else
local tv=type(v)
if tv=="string" then
- m=m+1 r[m]=f_indexed_string(k,v)
+ m=m+1 r[m]=f_hashed_string(k,v)
elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(k,v)
+ m=m+1 r[m]=f_hashed_number(k,v)
elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(k)
+ m=m+1 r[m]=f_hashed_table(k)
fastserialize(v)
elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(k,v)
+ m=m+1 r[m]=f_hashed_boolean(k,v)
end
end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
else
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_hashed_string(k,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_hashed_number(k,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_hashed_table(k)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_hashed_boolean(k,v)
- end
+ r[m]="},"
end
+ return r
end
- m=m+1
- if outer then
- r[m]="}"
- else
- r[m]="},"
+ return concat(fastserialize(t,true))
+ end
+else
+ local f_v=formatters["[%q]=%q,"]
+ local f_t=formatters["[%q]="]
+ local f_q=formatters["%q,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ m=m+1
+ r[m]="[0]='"
+ if type(v)=="table" then
+ fastserialize(v)
+ else
+ r[m]=format("%q,",v)
+ end
+ end
+ for i=1,n do
+ local v=t[i]
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",i)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",i,v)
+ end
+ end
+ end
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",k,v)
+ end
+ end
+ else
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%q]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%q]=%q,",k,v)
+ end
+ end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
+ else
+ r[m]="},"
+ end
+ return r
end
- return r
+ return concat(fastserialize(t,true))
end
- return concat(fastserialize(t,true))
end
function table.deserialize(str)
if not str or str=="" then
@@ -7828,27 +7932,27 @@ function table.twowaymapper(t)
return t
end
local f_start_key_idx=formatters["%w{"]
-local f_start_key_num=formatters["%w[%s]={"]
+local f_start_key_num=JITSUPPORTED and formatters["%w[%s]={"] or formatters["%w[%q]={"]
local f_start_key_str=formatters["%w[%q]={"]
local f_start_key_boo=formatters["%w[%l]={"]
local f_start_key_nop=formatters["%w{"]
local f_stop=formatters["%w},"]
-local f_key_num_value_num=formatters["%w[%s]=%s,"]
-local f_key_str_value_num=formatters["%w[%Q]=%s,"]
-local f_key_boo_value_num=formatters["%w[%l]=%s,"]
-local f_key_num_value_str=formatters["%w[%s]=%Q,"]
+local f_key_num_value_num=JITSUPPORTED and formatters["%w[%s]=%s,"] or formatters["%w[%s]=%q,"]
+local f_key_str_value_num=JITSUPPORTED and formatters["%w[%Q]=%s,"] or formatters["%w[%Q]=%q,"]
+local f_key_boo_value_num=JITSUPPORTED and formatters["%w[%l]=%s,"] or formatters["%w[%l]=%q,"]
+local f_key_num_value_str=JITSUPPORTED and formatters["%w[%s]=%Q,"] or formatters["%w[%q]=%Q,"]
local f_key_str_value_str=formatters["%w[%Q]=%Q,"]
local f_key_boo_value_str=formatters["%w[%l]=%Q,"]
-local f_key_num_value_boo=formatters["%w[%s]=%l,"]
+local f_key_num_value_boo=JITSUPPORTED and formatters["%w[%s]=%l,"] or formatters["%w[%q]=%l,"]
local f_key_str_value_boo=formatters["%w[%Q]=%l,"]
local f_key_boo_value_boo=formatters["%w[%l]=%l,"]
-local f_key_num_value_not=formatters["%w[%s]={},"]
+local f_key_num_value_not=JITSUPPORTED and formatters["%w[%s]={},"] or formatters["%w[%q]={},"]
local f_key_str_value_not=formatters["%w[%Q]={},"]
local f_key_boo_value_not=formatters["%w[%l]={},"]
-local f_key_num_value_seq=formatters["%w[%s]={ %, t },"]
+local f_key_num_value_seq=JITSUPPORTED and formatters["%w[%s]={ %, t },"] or formatters["%w[%q]={ %, t },"]
local f_key_str_value_seq=formatters["%w[%Q]={ %, t },"]
local f_key_boo_value_seq=formatters["%w[%l]={ %, t },"]
-local f_val_num=formatters["%w%s,"]
+local f_val_num=JITSUPPORTED and formatters["%w%s,"] or formatters["%w%q,"]
local f_val_str=formatters["%w%Q,"]
local f_val_boo=formatters["%w%l,"]
local f_val_not=formatters["%w{},"]
@@ -21589,7 +21693,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16070, stripped down to: 11353
+-- original size: 16099, stripped down to: 11379
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -21876,7 +21980,7 @@ function caches.is_writable(filepath,filename)
local tmaname,tmcname=setluanames(filepath,filename)
return is_writable(tmaname)
end
-local saveoptions={ compact=true }
+local saveoptions={ compact=true,accurate=not JITSUPPORTED }
function caches.savedata(filepath,filename,data,fast)
local tmaname,tmcname=setluanames(filepath,filename)
data.cache_uuid=osuuid()
@@ -25385,363 +25489,147 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-lib"] = package.loaded["util-lib"] or true
+package.loaded["libs-ini"] = package.loaded["libs-ini"] or true
--- original size: 17659, stripped down to: 9560
+-- original size: 5822, stripped down to: 3629
-if not modules then modules={} end modules ['util-lib']={
+if not modules then modules={} end modules ['libs-ini']={
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",
+ license="see context related readme files"
}
+local type,unpack=type,unpack
local type=type
-local next=next
-local pcall=pcall
-local gsub=string.gsub
-local find=string.find
-local sort=table.sort
-local pathpart=file.pathpart
local nameonly=file.nameonly
local joinfile=file.join
-local removesuffix=file.removesuffix
local addsuffix=file.addsuffix
-local findfile=resolvers.findfile
-local findfiles=resolvers.findfiles
-local expandpaths=resolvers.expandedpathlistfromvariable
local qualifiedpath=file.is_qualified_path
local isfile=lfs.isfile
-local done=false
-local function locate(required,version,trace,report,action)
- if type(required)~="string" then
- report("provide a proper library name")
- return
- end
- if trace then
- report("requiring library %a with version %a",required,version or "any")
- end
- local found_library=nil
- local required_full=gsub(required,"%.","/")
- local required_path=pathpart(required_full)
- local required_base=nameonly(required_full)
- if qualifiedpath(required) then
- if isfile(addsuffix(required,os.libsuffix)) then
- if trace then
- report("qualified name %a found",required)
+local findfile=resolvers.findfile
+local expandpaths=resolvers.expandedpathlistfromvariable
+local report=logs.reporter("resolvers","libraries")
+local trace=false
+trackers.register("resolvers.lib",function(v) trace=v end)
+local function findlib(required)
+ local suffix=os.libsuffix or "so"
+ if not qualifiedpath(required) then
+ local list=directives.value("system.librarynames" )
+ local only=nameonly(required)
+ if type(list)=="table" then
+ list=list[only]
+ if type(list)~="table" then
+ list={ only }
end
- found_library=required
else
- if trace then
- report("qualified name %a not found",required)
- end
- end
- else
- local required_name=required_base.."."..os.libsuffix
- local version=type(version)=="string" and version~="" and version or false
- local engine=environment.ownmain or false
- if trace and not done then
- local list=expandpaths("lib")
- for i=1,#list do
- report("tds path %i: %s",i,list[i])
- end
+ list={ only }
end
- local function found(locate,asked_library,how,...)
- if trace then
- report("checking %s: %a",how,asked_library)
- end
- return locate(asked_library,...)
+ if trace then
+ report("using lookup list for library %a: % | t",only,list)
end
- local function check(locate,...)
- local found=nil
- if version then
- local asked_library=joinfile(required_path,version,required_name)
- if trace then
- report("checking %s: %a","with version",asked_library)
- end
- found=locate(asked_library,...)
+ for i=1,#list do
+ local name=list[i]
+ local found=findfile(name,"lib")
+ if not found then
+ found=findfile(addsuffix(name,suffix),"lib")
end
- if not found or found=="" then
- local asked_library=joinfile(required_path,required_name)
+ if found then
if trace then
- report("checking %s: %a","with version",asked_library)
+ report("library %a resolved via %a path to %a",name,"tds lib",found)
end
- found=locate(asked_library,...)
- end
- return found and found~="" and found or false
- end
- local function attempt(checkpattern)
- if trace then
- report("checking tds lib paths strictly")
- end
- local found=findfile and check(findfile,"lib")
- if found and (not checkpattern or find(found,checkpattern)) then
return found
end
- if trace then
- report("checking tds lib paths with wildcard")
- end
- local asked_library=joinfile(required_path,".*",required_name)
- if trace then
- report("checking %s: %a","latest version",asked_library)
- end
- local list=findfiles(asked_library,"lib",true)
- if list and #list>0 then
- sort(list)
- local found=list[#list]
- if found and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- if trace then
- report("checking lib paths")
- end
- package.extralibpath(environment.ownpath)
- local paths=package.libpaths()
- local pattern="/[^/]+%."..os.libsuffix.."$"
- for i=1,#paths do
- required_path=gsub(paths[i],pattern,"")
- local found=check(lfs.isfound)
- if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- return false
end
- if engine then
- if trace then
- report("attemp 1, engine %a",engine)
- end
- found_library=attempt("/"..engine.."/")
- if not found_library then
- if trace then
- report("attemp 2, no engine",asked_library)
+ if expandpaths then
+ local list=expandpaths("PATH")
+ local base=addsuffix(only,suffix)
+ for i=1,#list do
+ local full=joinfile(list[i],base)
+ local found=isfile(full) and full
+ if found then
+ if trace then
+ report("library %a resolved via %a path to %a",name,"system",found)
+ end
+ return found
end
- found_library=attempt()
end
- else
- found_library=attempt()
end
- end
- if not found_library then
+ elseif isfile(addsuffix(required,suffix)) then
if trace then
- report("not found: %a",required)
+ report("library with qualified name %a %sfound",required,"")
end
- library=false
+ return required
else
if trace then
- report("found: %a",found_library)
- end
- local result,message=action(found_library,required_base)
- if result then
- library=result
- else
- library=false
- report("load error: message %a, library %a",tostring(message or "unknown"),found_library or "no library")
+ report("library with qualified name %a %sfound",required,"not ")
end
end
- if trace then
- if not library then
- report("unknown library: %a",required)
- else
- report("stored library: %a",required)
- end
- end
- return library or nil
+ return false
end
-resolvers.locatelib=locate
-do
- local report_swiglib=logs.reporter("swiglib")
- local trace_swiglib=false
- local savedrequire=require
- local loadedlibs={}
- local loadlib=package.loadlib
- local pushdir=dir.push
- local popdir=dir.pop
- trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
- function requireswiglib(required,version)
- local library=loadedlibs[library]
- if library==nil then
- local trace_swiglib=trace_swiglib or package.helpers.trace
- library=locate(required,version,trace_swiglib,report_swiglib,function(name,base)
- pushdir(pathpart(name))
- local opener="luaopen_"..base
- if trace_swiglib then
- report_swiglib("opening: %a with %a",name,opener)
- end
- local library,message=loadlib(name,opener)
- local libtype=type(library)
- if libtype=="function" then
- library=library()
+local foundlibraries=table.setmetatableindex(function(t,k)
+ local v=findlib(k)
+ t[k]=v
+ return v
+end)
+function resolvers.findlib(required)
+ return foundlibraries[required]
+end
+local libraries={}
+resolvers.libraries=libraries
+local report=logs.reporter("optional")
+if optional then optional.loaded={} end
+function libraries.validoptional(name)
+ local thelib=optional and optional[name]
+ if not thelib then
+ elseif thelib.initialize then
+ return thelib
+ else
+ report("invalid optional library %a",libname)
+ end
+end
+function libraries.optionalloaded(name,libnames)
+ local thelib=optional and optional[name]
+ if not thelib then
+ report("no optional %a library found",name)
+ else
+ local thelib_initialize=thelib.initialize
+ if not thelib_initialize then
+ report("invalid optional library %a",name)
+ else
+ if type(libnames)=="string" then
+ libnames={ libnames }
+ end
+ if type(libnames)=="table" then
+ for i=1,#libnames do
+ local libname=libnames[i]
+ local filename=foundlibraries[libname]
+ if filename then
+ libnames[i]=filename
+ else
+ report("unable to locate library %a",libname)
+ return
+ end
+ end
+ local initialized=thelib_initialize(unpack(libnames))
+ if initialized then
+ report("using library '% + t'",libnames)
else
- report_swiglib("load error: %a returns %a, message %a, library %a",opener,libtype,(string.gsub(message or "no message","[%s]+$","")),found_library or "no library")
- library=false
+ report("unable to initialize library '% + t'",libnames)
end
- popdir()
- return library
- end)
- loadedlibs[required]=library or false
- end
- return library
- end
- function require(name,version)
- if find(name,"^swiglib%.") then
- return requireswiglib(name,version)
- else
- return savedrequire(name)
- end
- end
- local swiglibs={}
- local initializer="core"
- function swiglib(name,version)
- local library=swiglibs[name]
- if not library then
- statistics.starttiming(swiglibs)
- if trace_swiglib then
- report_swiglib("loading %a",name)
- end
- if not find(name,"%."..initializer.."$") then
- fullname="swiglib."..name.."."..initializer
- else
- fullname="swiglib."..name
+ return initialized
end
- library=requireswiglib(fullname,version)
- swiglibs[name]=library
- statistics.stoptiming(swiglibs)
end
- return library
end
- statistics.register("used swiglibs",function()
- if next(swiglibs) then
- return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
- end
- end)
end
if FFISUPPORTED and ffi and ffi.load then
- local report_ffilib=logs.reporter("ffilib")
- local trace_ffilib=false
- local savedffiload=ffi.load
- trackers.register("resolvers.ffilib",function(v) trace_ffilib=v end)
- local loaded={}
- local function locateindeed(name)
- name=removesuffix(name)
- local l=loaded[name]
- if l==nil then
- local state,library=pcall(savedffiload,name)
- if type(library)=="userdata" then
- l=library
- elseif type(state)=="userdata" then
- l=state
- else
- l=false
- end
- loaded[name]=l
- elseif trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local function getlist(required)
- local list=directives.value("system.librarynames" )
- if type(list)=="table" then
- list=list[required]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",required,list)
- end
- return list
- end
- end
- return { required }
- end
- function ffilib(name,version)
- name=removesuffix(name)
- local l=loaded[name]
- if l~=nil then
- if trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local list=getlist(name)
- if version=="system" then
- for i=1,#list do
- local library=locateindeed(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- else
- for i=1,#list do
- local library=locate(list[i],version,trace_ffilib,report_ffilib,locateindeed)
- if type(library)=="userdata" then
- return library
- end
- end
- end
- end
+ local ffiload=ffi.load
function ffi.load(name)
- local list=getlist(name)
- for i=1,#list do
- local library=ffilib(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- if trace_ffilib then
- report_ffilib("trying to load %a using normal loader",name)
- end
- for i=1,#list do
- local state,library=pcall(savedffiload,list[i])
- if type(library)=="userdata" then
- return library
- elseif type(state)=="userdata" then
- return library
- end
- end
- end
-end
-do
- local isfile=lfs.isfile
- local report=logs.reporter("resolvers","lib")
- local trace=false
- trackers.register("resolvers.lib",function(v) trace=v end)
- local function action(filename)
- return isfile(filename) and filename or false
- end
- function resolvers.findlib(required)
- local list=directives.value("system.librarynames" )
- local only=nameonly(required)
- if type(list)=="table" then
- list=list[only]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",only,list)
- end
- else
- list={ only }
- end
+ local full=name and foundlibraries[name]
+ if full then
+ return ffiload(full)
else
- list={ only }
- end
- for i=1,#list do
- local name=list[i]
- local found=locate(name,false,trace,report,action)
- if found then
- return found
- end
- end
- local getpaths=resolvers.expandedpathlistfromvariable
- if getpaths then
- local list=getpaths("PATH")
- local base=addsuffix(only,os.libsuffix)
- for i=1,#list do
- local full=joinfile(list[i],base)
- local found=locate(full,false,trace,report,action)
- if found then
- return found
- end
- end
+ return ffiload(name)
end
end
end
@@ -26187,10 +26075,10 @@ end
end -- of closure
--- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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
+-- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1047142
--- stripped bytes : 416876
+-- original bytes : 1038128
+-- stripped bytes : 410736
-- end library merge
@@ -26304,7 +26192,7 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
- 'util-lib.lua', -- swiglib
+ 'libs-ini.lua',
'luat-sta.lua',
'luat-fmt.lua',
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index bcc3bb243..15e99eb91 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -2102,7 +2102,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 42339, stripped down to: 21588
+-- original size: 41758, stripped down to: 22643
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2445,13 +2445,13 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,compact,inline,functions,metacheck
+local noquotes,hexify,handle,compact,inline,functions,metacheck,accurate
local reserved=table.tohash {
'and','break','do','else','elseif','end','false','for','function','if',
'in','local','nil','not','or','repeat','return','then','true','until','while',
- 'NaN','goto',
+ 'NaN','goto','const',
}
-local function is_simple_table(t,hexify)
+local function is_simple_table(t,hexify,accurate)
local nt=#t
if nt>0 then
local n=0
@@ -2470,6 +2470,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i]=format("0x%X",v)
+ elseif accurate then
+ tt[i]=format("%q",v)
else
tt[i]=v
end
@@ -2490,6 +2492,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i+1]=format("0x%X",v)
+ elseif accurate then
+ tt[i+1]=format("%q",v)
else
tt[i+1]=v
end
@@ -2561,6 +2565,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tv=="number" then
if hexify then
handle(format("%s 0x%X,",depth,v))
+ elseif accurate then
+ handle(format("%s %q,",depth,v))
else
handle(format("%s %s,",depth,v))
end
@@ -2570,7 +2576,7 @@ local function do_serialize(root,name,depth,level,indexed)
if next(v)==nil then
handle(format("%s {},",depth))
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
handle(format("%s { %s },",depth,concat(st,", ")))
else
@@ -2598,12 +2604,16 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v))
end
elseif tk=="boolean" then
if hexify then
handle(format("%s [%s]=0x%X,",depth,k and "true" or "false",v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
else
handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
end
@@ -2611,12 +2621,16 @@ local function do_serialize(root,name,depth,level,indexed)
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
if hexify then
handle(format("%s %s=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s %s=%q,",depth,k,v))
else
handle(format("%s %s=%s,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%q]=%s,",depth,k,v))
end
@@ -2625,6 +2639,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%s]=%q,",depth,k,v))
end
@@ -2641,6 +2657,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={},",depth,k))
+ elseif accurate then
+ handle(format("%s [%q]={},",depth,k))
else
handle(format("%s [%s]={},",depth,k))
end
@@ -2653,11 +2671,13 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%q]={},",depth,k))
end
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={ %s },",depth,k,concat(st,", ")))
+ elseif accurate then
+ handle(format("%s [%q]={ %s },",depth,k,concat(st,", ")))
else
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
@@ -2679,6 +2699,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%s,",depth,k,v and "true" or "false"))
+ elseif accurate then
+ handle(format("%s [%q]=%s,",depth,k,v and "true" or "false"))
else
handle(format("%s [%s]=%s,",depth,k,v and "true" or "false"))
end
@@ -2698,6 +2720,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=load(%q),",depth,k,f))
+ elseif accurate then
+ handle(format("%s [%q]=load(%q),",depth,k,f))
else
handle(format("%s [%s]=load(%q),",depth,k,f))
end
@@ -2715,6 +2739,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,tostring(v)))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
@@ -2738,6 +2764,7 @@ local function serialize(_handle,root,name,specification)
if type(specification)=="table" then
noquotes=specification.noquotes
hexify=specification.hexify
+ accurate=specification.accurate
handle=_handle or specification.handle or print
functions=specification.functions
compact=specification.compact
@@ -3779,7 +3806,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 18925, stripped down to: 10095
+-- original size: 19102, stripped down to: 10192
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -4200,6 +4227,12 @@ function os.validdate(year,month,day)
end
return year,month,day
end
+function os.date(fmt,...)
+ if not fmt then
+ fmt="%Y-%m-%d %H:%M"
+ end
+ return date(fmt,...)
+end
local osexit=os.exit
local exitcode=nil
function os.setexitcode(code)
@@ -6530,7 +6563,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 45072, stripped down to: 22629
+-- original size: 45188, stripped down to: 22734
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6945,9 +6978,12 @@ local format_left=function(f)
return format("a%s..utfpadding(a%s,%i)",n,n,-f)
end
end
-local format_q=function()
+local format_q=JITSUPPORTED and function()
n=n+1
return format("(a%s ~= nil and format('%%q',tostring(a%s)) or '')",n,n)
+end or function()
+ n=n+1
+ return format("(a%s ~= nil and format('%%q',a%s) or '')",n,n)
end
local format_Q=function()
n=n+1
@@ -7412,7 +7448,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 29567, stripped down to: 16483
+-- original size: 32649, stripped down to: 18257
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7649,92 +7685,160 @@ function tables.encapsulate(core,capsule,protect)
} )
end
end
-local f_hashed_string=formatters["[%Q]=%Q,"]
-local f_hashed_number=formatters["[%Q]=%s,"]
-local f_hashed_boolean=formatters["[%Q]=%l,"]
-local f_hashed_table=formatters["[%Q]="]
-local f_indexed_string=formatters["[%s]=%Q,"]
-local f_indexed_number=formatters["[%s]=%s,"]
-local f_indexed_boolean=formatters["[%s]=%l,"]
-local f_indexed_table=formatters["[%s]="]
-local f_ordered_string=formatters["%Q,"]
-local f_ordered_number=formatters["%s,"]
-local f_ordered_boolean=formatters["%l,"]
-function table.fastserialize(t,prefix)
- local r={ type(prefix)=="string" and prefix or "return" }
- local m=1
- local function fastserialize(t,outer)
- local n=#t
- m=m+1
- r[m]="{"
- if n>0 then
- local v=t[0]
- if v then
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_indexed_string(0,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(0,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(0)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(0,v)
+if JITSUPPORTED then
+ local f_hashed_string=formatters["[%Q]=%Q,"]
+ local f_hashed_number=formatters["[%Q]=%s,"]
+ local f_hashed_boolean=formatters["[%Q]=%l,"]
+ local f_hashed_table=formatters["[%Q]="]
+ local f_indexed_string=formatters["[%s]=%Q,"]
+ local f_indexed_number=formatters["[%s]=%s,"]
+ local f_indexed_boolean=formatters["[%s]=%l,"]
+ local f_indexed_table=formatters["[%s]="]
+ local f_ordered_string=formatters["%Q,"]
+ local f_ordered_number=formatters["%s,"]
+ local f_ordered_boolean=formatters["%l,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(0,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(0,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(0)
+ fastserialize(v)
+ m=m+1 r[m]=f_indexed_table(0)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(0,v)
+ end
end
- end
- for i=1,n do
- local v=t[i]
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_ordered_string(v)
- elseif tv=="number" then
- m=m+1 r[m]=f_ordered_number(v)
- elseif tv=="table" then
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_ordered_boolean(v)
+ for i=1,n do
+ local v=t[i]
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_ordered_string(v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_ordered_number(v)
+ elseif tv=="table" then
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_ordered_boolean(v)
+ end
end
end
- end
- for k,v in next,t do
- local tk=type(k)
- if tk=="number" then
- if k>n or k<0 then
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(k,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(k,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(k)
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(k,v)
+ end
+ end
+ else
local tv=type(v)
if tv=="string" then
- m=m+1 r[m]=f_indexed_string(k,v)
+ m=m+1 r[m]=f_hashed_string(k,v)
elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(k,v)
+ m=m+1 r[m]=f_hashed_number(k,v)
elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(k)
+ m=m+1 r[m]=f_hashed_table(k)
fastserialize(v)
elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(k,v)
+ m=m+1 r[m]=f_hashed_boolean(k,v)
end
end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
else
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_hashed_string(k,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_hashed_number(k,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_hashed_table(k)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_hashed_boolean(k,v)
- end
+ r[m]="},"
end
+ return r
end
- m=m+1
- if outer then
- r[m]="}"
- else
- r[m]="},"
+ return concat(fastserialize(t,true))
+ end
+else
+ local f_v=formatters["[%q]=%q,"]
+ local f_t=formatters["[%q]="]
+ local f_q=formatters["%q,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ m=m+1
+ r[m]="[0]='"
+ if type(v)=="table" then
+ fastserialize(v)
+ else
+ r[m]=format("%q,",v)
+ end
+ end
+ for i=1,n do
+ local v=t[i]
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",i)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",i,v)
+ end
+ end
+ end
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",k,v)
+ end
+ end
+ else
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%q]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%q]=%q,",k,v)
+ end
+ end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
+ else
+ r[m]="},"
+ end
+ return r
end
- return r
+ return concat(fastserialize(t,true))
end
- return concat(fastserialize(t,true))
end
function table.deserialize(str)
if not str or str=="" then
@@ -7828,27 +7932,27 @@ function table.twowaymapper(t)
return t
end
local f_start_key_idx=formatters["%w{"]
-local f_start_key_num=formatters["%w[%s]={"]
+local f_start_key_num=JITSUPPORTED and formatters["%w[%s]={"] or formatters["%w[%q]={"]
local f_start_key_str=formatters["%w[%q]={"]
local f_start_key_boo=formatters["%w[%l]={"]
local f_start_key_nop=formatters["%w{"]
local f_stop=formatters["%w},"]
-local f_key_num_value_num=formatters["%w[%s]=%s,"]
-local f_key_str_value_num=formatters["%w[%Q]=%s,"]
-local f_key_boo_value_num=formatters["%w[%l]=%s,"]
-local f_key_num_value_str=formatters["%w[%s]=%Q,"]
+local f_key_num_value_num=JITSUPPORTED and formatters["%w[%s]=%s,"] or formatters["%w[%s]=%q,"]
+local f_key_str_value_num=JITSUPPORTED and formatters["%w[%Q]=%s,"] or formatters["%w[%Q]=%q,"]
+local f_key_boo_value_num=JITSUPPORTED and formatters["%w[%l]=%s,"] or formatters["%w[%l]=%q,"]
+local f_key_num_value_str=JITSUPPORTED and formatters["%w[%s]=%Q,"] or formatters["%w[%q]=%Q,"]
local f_key_str_value_str=formatters["%w[%Q]=%Q,"]
local f_key_boo_value_str=formatters["%w[%l]=%Q,"]
-local f_key_num_value_boo=formatters["%w[%s]=%l,"]
+local f_key_num_value_boo=JITSUPPORTED and formatters["%w[%s]=%l,"] or formatters["%w[%q]=%l,"]
local f_key_str_value_boo=formatters["%w[%Q]=%l,"]
local f_key_boo_value_boo=formatters["%w[%l]=%l,"]
-local f_key_num_value_not=formatters["%w[%s]={},"]
+local f_key_num_value_not=JITSUPPORTED and formatters["%w[%s]={},"] or formatters["%w[%q]={},"]
local f_key_str_value_not=formatters["%w[%Q]={},"]
local f_key_boo_value_not=formatters["%w[%l]={},"]
-local f_key_num_value_seq=formatters["%w[%s]={ %, t },"]
+local f_key_num_value_seq=JITSUPPORTED and formatters["%w[%s]={ %, t },"] or formatters["%w[%q]={ %, t },"]
local f_key_str_value_seq=formatters["%w[%Q]={ %, t },"]
local f_key_boo_value_seq=formatters["%w[%l]={ %, t },"]
-local f_val_num=formatters["%w%s,"]
+local f_val_num=JITSUPPORTED and formatters["%w%s,"] or formatters["%w%q,"]
local f_val_str=formatters["%w%Q,"]
local f_val_boo=formatters["%w%l,"]
local f_val_not=formatters["%w{},"]
@@ -21589,7 +21693,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16070, stripped down to: 11353
+-- original size: 16099, stripped down to: 11379
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -21876,7 +21980,7 @@ function caches.is_writable(filepath,filename)
local tmaname,tmcname=setluanames(filepath,filename)
return is_writable(tmaname)
end
-local saveoptions={ compact=true }
+local saveoptions={ compact=true,accurate=not JITSUPPORTED }
function caches.savedata(filepath,filename,data,fast)
local tmaname,tmcname=setluanames(filepath,filename)
data.cache_uuid=osuuid()
@@ -25385,363 +25489,147 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-lib"] = package.loaded["util-lib"] or true
+package.loaded["libs-ini"] = package.loaded["libs-ini"] or true
--- original size: 17659, stripped down to: 9560
+-- original size: 5822, stripped down to: 3629
-if not modules then modules={} end modules ['util-lib']={
+if not modules then modules={} end modules ['libs-ini']={
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",
+ license="see context related readme files"
}
+local type,unpack=type,unpack
local type=type
-local next=next
-local pcall=pcall
-local gsub=string.gsub
-local find=string.find
-local sort=table.sort
-local pathpart=file.pathpart
local nameonly=file.nameonly
local joinfile=file.join
-local removesuffix=file.removesuffix
local addsuffix=file.addsuffix
-local findfile=resolvers.findfile
-local findfiles=resolvers.findfiles
-local expandpaths=resolvers.expandedpathlistfromvariable
local qualifiedpath=file.is_qualified_path
local isfile=lfs.isfile
-local done=false
-local function locate(required,version,trace,report,action)
- if type(required)~="string" then
- report("provide a proper library name")
- return
- end
- if trace then
- report("requiring library %a with version %a",required,version or "any")
- end
- local found_library=nil
- local required_full=gsub(required,"%.","/")
- local required_path=pathpart(required_full)
- local required_base=nameonly(required_full)
- if qualifiedpath(required) then
- if isfile(addsuffix(required,os.libsuffix)) then
- if trace then
- report("qualified name %a found",required)
+local findfile=resolvers.findfile
+local expandpaths=resolvers.expandedpathlistfromvariable
+local report=logs.reporter("resolvers","libraries")
+local trace=false
+trackers.register("resolvers.lib",function(v) trace=v end)
+local function findlib(required)
+ local suffix=os.libsuffix or "so"
+ if not qualifiedpath(required) then
+ local list=directives.value("system.librarynames" )
+ local only=nameonly(required)
+ if type(list)=="table" then
+ list=list[only]
+ if type(list)~="table" then
+ list={ only }
end
- found_library=required
else
- if trace then
- report("qualified name %a not found",required)
- end
- end
- else
- local required_name=required_base.."."..os.libsuffix
- local version=type(version)=="string" and version~="" and version or false
- local engine=environment.ownmain or false
- if trace and not done then
- local list=expandpaths("lib")
- for i=1,#list do
- report("tds path %i: %s",i,list[i])
- end
+ list={ only }
end
- local function found(locate,asked_library,how,...)
- if trace then
- report("checking %s: %a",how,asked_library)
- end
- return locate(asked_library,...)
+ if trace then
+ report("using lookup list for library %a: % | t",only,list)
end
- local function check(locate,...)
- local found=nil
- if version then
- local asked_library=joinfile(required_path,version,required_name)
- if trace then
- report("checking %s: %a","with version",asked_library)
- end
- found=locate(asked_library,...)
+ for i=1,#list do
+ local name=list[i]
+ local found=findfile(name,"lib")
+ if not found then
+ found=findfile(addsuffix(name,suffix),"lib")
end
- if not found or found=="" then
- local asked_library=joinfile(required_path,required_name)
+ if found then
if trace then
- report("checking %s: %a","with version",asked_library)
+ report("library %a resolved via %a path to %a",name,"tds lib",found)
end
- found=locate(asked_library,...)
- end
- return found and found~="" and found or false
- end
- local function attempt(checkpattern)
- if trace then
- report("checking tds lib paths strictly")
- end
- local found=findfile and check(findfile,"lib")
- if found and (not checkpattern or find(found,checkpattern)) then
return found
end
- if trace then
- report("checking tds lib paths with wildcard")
- end
- local asked_library=joinfile(required_path,".*",required_name)
- if trace then
- report("checking %s: %a","latest version",asked_library)
- end
- local list=findfiles(asked_library,"lib",true)
- if list and #list>0 then
- sort(list)
- local found=list[#list]
- if found and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- if trace then
- report("checking lib paths")
- end
- package.extralibpath(environment.ownpath)
- local paths=package.libpaths()
- local pattern="/[^/]+%."..os.libsuffix.."$"
- for i=1,#paths do
- required_path=gsub(paths[i],pattern,"")
- local found=check(lfs.isfound)
- if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- return false
end
- if engine then
- if trace then
- report("attemp 1, engine %a",engine)
- end
- found_library=attempt("/"..engine.."/")
- if not found_library then
- if trace then
- report("attemp 2, no engine",asked_library)
+ if expandpaths then
+ local list=expandpaths("PATH")
+ local base=addsuffix(only,suffix)
+ for i=1,#list do
+ local full=joinfile(list[i],base)
+ local found=isfile(full) and full
+ if found then
+ if trace then
+ report("library %a resolved via %a path to %a",name,"system",found)
+ end
+ return found
end
- found_library=attempt()
end
- else
- found_library=attempt()
end
- end
- if not found_library then
+ elseif isfile(addsuffix(required,suffix)) then
if trace then
- report("not found: %a",required)
+ report("library with qualified name %a %sfound",required,"")
end
- library=false
+ return required
else
if trace then
- report("found: %a",found_library)
- end
- local result,message=action(found_library,required_base)
- if result then
- library=result
- else
- library=false
- report("load error: message %a, library %a",tostring(message or "unknown"),found_library or "no library")
+ report("library with qualified name %a %sfound",required,"not ")
end
end
- if trace then
- if not library then
- report("unknown library: %a",required)
- else
- report("stored library: %a",required)
- end
- end
- return library or nil
+ return false
end
-resolvers.locatelib=locate
-do
- local report_swiglib=logs.reporter("swiglib")
- local trace_swiglib=false
- local savedrequire=require
- local loadedlibs={}
- local loadlib=package.loadlib
- local pushdir=dir.push
- local popdir=dir.pop
- trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
- function requireswiglib(required,version)
- local library=loadedlibs[library]
- if library==nil then
- local trace_swiglib=trace_swiglib or package.helpers.trace
- library=locate(required,version,trace_swiglib,report_swiglib,function(name,base)
- pushdir(pathpart(name))
- local opener="luaopen_"..base
- if trace_swiglib then
- report_swiglib("opening: %a with %a",name,opener)
- end
- local library,message=loadlib(name,opener)
- local libtype=type(library)
- if libtype=="function" then
- library=library()
+local foundlibraries=table.setmetatableindex(function(t,k)
+ local v=findlib(k)
+ t[k]=v
+ return v
+end)
+function resolvers.findlib(required)
+ return foundlibraries[required]
+end
+local libraries={}
+resolvers.libraries=libraries
+local report=logs.reporter("optional")
+if optional then optional.loaded={} end
+function libraries.validoptional(name)
+ local thelib=optional and optional[name]
+ if not thelib then
+ elseif thelib.initialize then
+ return thelib
+ else
+ report("invalid optional library %a",libname)
+ end
+end
+function libraries.optionalloaded(name,libnames)
+ local thelib=optional and optional[name]
+ if not thelib then
+ report("no optional %a library found",name)
+ else
+ local thelib_initialize=thelib.initialize
+ if not thelib_initialize then
+ report("invalid optional library %a",name)
+ else
+ if type(libnames)=="string" then
+ libnames={ libnames }
+ end
+ if type(libnames)=="table" then
+ for i=1,#libnames do
+ local libname=libnames[i]
+ local filename=foundlibraries[libname]
+ if filename then
+ libnames[i]=filename
+ else
+ report("unable to locate library %a",libname)
+ return
+ end
+ end
+ local initialized=thelib_initialize(unpack(libnames))
+ if initialized then
+ report("using library '% + t'",libnames)
else
- report_swiglib("load error: %a returns %a, message %a, library %a",opener,libtype,(string.gsub(message or "no message","[%s]+$","")),found_library or "no library")
- library=false
+ report("unable to initialize library '% + t'",libnames)
end
- popdir()
- return library
- end)
- loadedlibs[required]=library or false
- end
- return library
- end
- function require(name,version)
- if find(name,"^swiglib%.") then
- return requireswiglib(name,version)
- else
- return savedrequire(name)
- end
- end
- local swiglibs={}
- local initializer="core"
- function swiglib(name,version)
- local library=swiglibs[name]
- if not library then
- statistics.starttiming(swiglibs)
- if trace_swiglib then
- report_swiglib("loading %a",name)
- end
- if not find(name,"%."..initializer.."$") then
- fullname="swiglib."..name.."."..initializer
- else
- fullname="swiglib."..name
+ return initialized
end
- library=requireswiglib(fullname,version)
- swiglibs[name]=library
- statistics.stoptiming(swiglibs)
end
- return library
end
- statistics.register("used swiglibs",function()
- if next(swiglibs) then
- return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
- end
- end)
end
if FFISUPPORTED and ffi and ffi.load then
- local report_ffilib=logs.reporter("ffilib")
- local trace_ffilib=false
- local savedffiload=ffi.load
- trackers.register("resolvers.ffilib",function(v) trace_ffilib=v end)
- local loaded={}
- local function locateindeed(name)
- name=removesuffix(name)
- local l=loaded[name]
- if l==nil then
- local state,library=pcall(savedffiload,name)
- if type(library)=="userdata" then
- l=library
- elseif type(state)=="userdata" then
- l=state
- else
- l=false
- end
- loaded[name]=l
- elseif trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local function getlist(required)
- local list=directives.value("system.librarynames" )
- if type(list)=="table" then
- list=list[required]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",required,list)
- end
- return list
- end
- end
- return { required }
- end
- function ffilib(name,version)
- name=removesuffix(name)
- local l=loaded[name]
- if l~=nil then
- if trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local list=getlist(name)
- if version=="system" then
- for i=1,#list do
- local library=locateindeed(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- else
- for i=1,#list do
- local library=locate(list[i],version,trace_ffilib,report_ffilib,locateindeed)
- if type(library)=="userdata" then
- return library
- end
- end
- end
- end
+ local ffiload=ffi.load
function ffi.load(name)
- local list=getlist(name)
- for i=1,#list do
- local library=ffilib(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- if trace_ffilib then
- report_ffilib("trying to load %a using normal loader",name)
- end
- for i=1,#list do
- local state,library=pcall(savedffiload,list[i])
- if type(library)=="userdata" then
- return library
- elseif type(state)=="userdata" then
- return library
- end
- end
- end
-end
-do
- local isfile=lfs.isfile
- local report=logs.reporter("resolvers","lib")
- local trace=false
- trackers.register("resolvers.lib",function(v) trace=v end)
- local function action(filename)
- return isfile(filename) and filename or false
- end
- function resolvers.findlib(required)
- local list=directives.value("system.librarynames" )
- local only=nameonly(required)
- if type(list)=="table" then
- list=list[only]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",only,list)
- end
- else
- list={ only }
- end
+ local full=name and foundlibraries[name]
+ if full then
+ return ffiload(full)
else
- list={ only }
- end
- for i=1,#list do
- local name=list[i]
- local found=locate(name,false,trace,report,action)
- if found then
- return found
- end
- end
- local getpaths=resolvers.expandedpathlistfromvariable
- if getpaths then
- local list=getpaths("PATH")
- local base=addsuffix(only,os.libsuffix)
- for i=1,#list do
- local full=joinfile(list[i],base)
- local found=locate(full,false,trace,report,action)
- if found then
- return found
- end
- end
+ return ffiload(name)
end
end
end
@@ -26187,10 +26075,10 @@ end
end -- of closure
--- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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
+-- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1047142
--- stripped bytes : 416876
+-- original bytes : 1038128
+-- stripped bytes : 410736
-- end library merge
@@ -26304,7 +26192,7 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
- 'util-lib.lua', -- swiglib
+ 'libs-ini.lua',
'luat-sta.lua',
'luat-fmt.lua',
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index bcc3bb243..15e99eb91 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -2102,7 +2102,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 42339, stripped down to: 21588
+-- original size: 41758, stripped down to: 22643
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2445,13 +2445,13 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,compact,inline,functions,metacheck
+local noquotes,hexify,handle,compact,inline,functions,metacheck,accurate
local reserved=table.tohash {
'and','break','do','else','elseif','end','false','for','function','if',
'in','local','nil','not','or','repeat','return','then','true','until','while',
- 'NaN','goto',
+ 'NaN','goto','const',
}
-local function is_simple_table(t,hexify)
+local function is_simple_table(t,hexify,accurate)
local nt=#t
if nt>0 then
local n=0
@@ -2470,6 +2470,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i]=format("0x%X",v)
+ elseif accurate then
+ tt[i]=format("%q",v)
else
tt[i]=v
end
@@ -2490,6 +2492,8 @@ local function is_simple_table(t,hexify)
if tv=="number" then
if hexify then
tt[i+1]=format("0x%X",v)
+ elseif accurate then
+ tt[i+1]=format("%q",v)
else
tt[i+1]=v
end
@@ -2561,6 +2565,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tv=="number" then
if hexify then
handle(format("%s 0x%X,",depth,v))
+ elseif accurate then
+ handle(format("%s %q,",depth,v))
else
handle(format("%s %s,",depth,v))
end
@@ -2570,7 +2576,7 @@ local function do_serialize(root,name,depth,level,indexed)
if next(v)==nil then
handle(format("%s {},",depth))
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
handle(format("%s { %s },",depth,concat(st,", ")))
else
@@ -2598,12 +2604,16 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v))
end
elseif tk=="boolean" then
if hexify then
handle(format("%s [%s]=0x%X,",depth,k and "true" or "false",v))
+ elseif accurate then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
else
handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
end
@@ -2611,12 +2621,16 @@ local function do_serialize(root,name,depth,level,indexed)
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
if hexify then
handle(format("%s %s=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s %s=%q,",depth,k,v))
else
handle(format("%s %s=%s,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%X,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%q]=%s,",depth,k,v))
end
@@ -2625,6 +2639,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,v))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,v))
else
handle(format("%s [%s]=%q,",depth,k,v))
end
@@ -2641,6 +2657,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={},",depth,k))
+ elseif accurate then
+ handle(format("%s [%q]={},",depth,k))
else
handle(format("%s [%s]={},",depth,k))
end
@@ -2653,11 +2671,13 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%q]={},",depth,k))
end
elseif inline then
- local st=is_simple_table(v,hexify)
+ local st=is_simple_table(v,hexify,accurate)
if st then
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={ %s },",depth,k,concat(st,", ")))
+ elseif accurate then
+ handle(format("%s [%q]={ %s },",depth,k,concat(st,", ")))
else
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
@@ -2679,6 +2699,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%s,",depth,k,v and "true" or "false"))
+ elseif accurate then
+ handle(format("%s [%q]=%s,",depth,k,v and "true" or "false"))
else
handle(format("%s [%s]=%s,",depth,k,v and "true" or "false"))
end
@@ -2698,6 +2720,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=load(%q),",depth,k,f))
+ elseif accurate then
+ handle(format("%s [%q]=load(%q),",depth,k,f))
else
handle(format("%s [%s]=load(%q),",depth,k,f))
end
@@ -2715,6 +2739,8 @@ local function do_serialize(root,name,depth,level,indexed)
if tk=="number" then
if hexify then
handle(format("%s [0x%X]=%q,",depth,k,tostring(v)))
+ elseif accurate then
+ handle(format("%s [%q]=%q,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
@@ -2738,6 +2764,7 @@ local function serialize(_handle,root,name,specification)
if type(specification)=="table" then
noquotes=specification.noquotes
hexify=specification.hexify
+ accurate=specification.accurate
handle=_handle or specification.handle or print
functions=specification.functions
compact=specification.compact
@@ -3779,7 +3806,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 18925, stripped down to: 10095
+-- original size: 19102, stripped down to: 10192
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -4200,6 +4227,12 @@ function os.validdate(year,month,day)
end
return year,month,day
end
+function os.date(fmt,...)
+ if not fmt then
+ fmt="%Y-%m-%d %H:%M"
+ end
+ return date(fmt,...)
+end
local osexit=os.exit
local exitcode=nil
function os.setexitcode(code)
@@ -6530,7 +6563,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 45072, stripped down to: 22629
+-- original size: 45188, stripped down to: 22734
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6945,9 +6978,12 @@ local format_left=function(f)
return format("a%s..utfpadding(a%s,%i)",n,n,-f)
end
end
-local format_q=function()
+local format_q=JITSUPPORTED and function()
n=n+1
return format("(a%s ~= nil and format('%%q',tostring(a%s)) or '')",n,n)
+end or function()
+ n=n+1
+ return format("(a%s ~= nil and format('%%q',a%s) or '')",n,n)
end
local format_Q=function()
n=n+1
@@ -7412,7 +7448,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 29567, stripped down to: 16483
+-- original size: 32649, stripped down to: 18257
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7649,92 +7685,160 @@ function tables.encapsulate(core,capsule,protect)
} )
end
end
-local f_hashed_string=formatters["[%Q]=%Q,"]
-local f_hashed_number=formatters["[%Q]=%s,"]
-local f_hashed_boolean=formatters["[%Q]=%l,"]
-local f_hashed_table=formatters["[%Q]="]
-local f_indexed_string=formatters["[%s]=%Q,"]
-local f_indexed_number=formatters["[%s]=%s,"]
-local f_indexed_boolean=formatters["[%s]=%l,"]
-local f_indexed_table=formatters["[%s]="]
-local f_ordered_string=formatters["%Q,"]
-local f_ordered_number=formatters["%s,"]
-local f_ordered_boolean=formatters["%l,"]
-function table.fastserialize(t,prefix)
- local r={ type(prefix)=="string" and prefix or "return" }
- local m=1
- local function fastserialize(t,outer)
- local n=#t
- m=m+1
- r[m]="{"
- if n>0 then
- local v=t[0]
- if v then
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_indexed_string(0,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(0,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(0)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(0,v)
+if JITSUPPORTED then
+ local f_hashed_string=formatters["[%Q]=%Q,"]
+ local f_hashed_number=formatters["[%Q]=%s,"]
+ local f_hashed_boolean=formatters["[%Q]=%l,"]
+ local f_hashed_table=formatters["[%Q]="]
+ local f_indexed_string=formatters["[%s]=%Q,"]
+ local f_indexed_number=formatters["[%s]=%s,"]
+ local f_indexed_boolean=formatters["[%s]=%l,"]
+ local f_indexed_table=formatters["[%s]="]
+ local f_ordered_string=formatters["%Q,"]
+ local f_ordered_number=formatters["%s,"]
+ local f_ordered_boolean=formatters["%l,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(0,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(0,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(0)
+ fastserialize(v)
+ m=m+1 r[m]=f_indexed_table(0)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(0,v)
+ end
end
- end
- for i=1,n do
- local v=t[i]
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_ordered_string(v)
- elseif tv=="number" then
- m=m+1 r[m]=f_ordered_number(v)
- elseif tv=="table" then
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_ordered_boolean(v)
+ for i=1,n do
+ local v=t[i]
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_ordered_string(v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_ordered_number(v)
+ elseif tv=="table" then
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_ordered_boolean(v)
+ end
end
end
- end
- for k,v in next,t do
- local tk=type(k)
- if tk=="number" then
- if k>n or k<0 then
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ local tv=type(v)
+ if tv=="string" then
+ m=m+1 r[m]=f_indexed_string(k,v)
+ elseif tv=="number" then
+ m=m+1 r[m]=f_indexed_number(k,v)
+ elseif tv=="table" then
+ m=m+1 r[m]=f_indexed_table(k)
+ fastserialize(v)
+ elseif tv=="boolean" then
+ m=m+1 r[m]=f_indexed_boolean(k,v)
+ end
+ end
+ else
local tv=type(v)
if tv=="string" then
- m=m+1 r[m]=f_indexed_string(k,v)
+ m=m+1 r[m]=f_hashed_string(k,v)
elseif tv=="number" then
- m=m+1 r[m]=f_indexed_number(k,v)
+ m=m+1 r[m]=f_hashed_number(k,v)
elseif tv=="table" then
- m=m+1 r[m]=f_indexed_table(k)
+ m=m+1 r[m]=f_hashed_table(k)
fastserialize(v)
elseif tv=="boolean" then
- m=m+1 r[m]=f_indexed_boolean(k,v)
+ m=m+1 r[m]=f_hashed_boolean(k,v)
end
end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
else
- local tv=type(v)
- if tv=="string" then
- m=m+1 r[m]=f_hashed_string(k,v)
- elseif tv=="number" then
- m=m+1 r[m]=f_hashed_number(k,v)
- elseif tv=="table" then
- m=m+1 r[m]=f_hashed_table(k)
- fastserialize(v)
- elseif tv=="boolean" then
- m=m+1 r[m]=f_hashed_boolean(k,v)
- end
+ r[m]="},"
end
+ return r
end
- m=m+1
- if outer then
- r[m]="}"
- else
- r[m]="},"
+ return concat(fastserialize(t,true))
+ end
+else
+ local f_v=formatters["[%q]=%q,"]
+ local f_t=formatters["[%q]="]
+ local f_q=formatters["%q,"]
+ function table.fastserialize(t,prefix)
+ local r={ type(prefix)=="string" and prefix or "return" }
+ local m=1
+ local function fastserialize(t,outer)
+ local n=#t
+ m=m+1
+ r[m]="{"
+ if n>0 then
+ local v=t[0]
+ if v then
+ m=m+1
+ r[m]="[0]='"
+ if type(v)=="table" then
+ fastserialize(v)
+ else
+ r[m]=format("%q,",v)
+ end
+ end
+ for i=1,n do
+ local v=t[i]
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",i)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",i,v)
+ end
+ end
+ end
+ for k,v in next,t do
+ local tk=type(k)
+ if tk=="number" then
+ if k>n or k<0 then
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%i]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%i]=%q,",k,v)
+ end
+ end
+ else
+ m=m+1
+ if type(v)=="table" then
+ r[m]=format("[%q]=",k)
+ fastserialize(v)
+ else
+ r[m]=format("[%q]=%q,",k,v)
+ end
+ end
+ end
+ m=m+1
+ if outer then
+ r[m]="}"
+ else
+ r[m]="},"
+ end
+ return r
end
- return r
+ return concat(fastserialize(t,true))
end
- return concat(fastserialize(t,true))
end
function table.deserialize(str)
if not str or str=="" then
@@ -7828,27 +7932,27 @@ function table.twowaymapper(t)
return t
end
local f_start_key_idx=formatters["%w{"]
-local f_start_key_num=formatters["%w[%s]={"]
+local f_start_key_num=JITSUPPORTED and formatters["%w[%s]={"] or formatters["%w[%q]={"]
local f_start_key_str=formatters["%w[%q]={"]
local f_start_key_boo=formatters["%w[%l]={"]
local f_start_key_nop=formatters["%w{"]
local f_stop=formatters["%w},"]
-local f_key_num_value_num=formatters["%w[%s]=%s,"]
-local f_key_str_value_num=formatters["%w[%Q]=%s,"]
-local f_key_boo_value_num=formatters["%w[%l]=%s,"]
-local f_key_num_value_str=formatters["%w[%s]=%Q,"]
+local f_key_num_value_num=JITSUPPORTED and formatters["%w[%s]=%s,"] or formatters["%w[%s]=%q,"]
+local f_key_str_value_num=JITSUPPORTED and formatters["%w[%Q]=%s,"] or formatters["%w[%Q]=%q,"]
+local f_key_boo_value_num=JITSUPPORTED and formatters["%w[%l]=%s,"] or formatters["%w[%l]=%q,"]
+local f_key_num_value_str=JITSUPPORTED and formatters["%w[%s]=%Q,"] or formatters["%w[%q]=%Q,"]
local f_key_str_value_str=formatters["%w[%Q]=%Q,"]
local f_key_boo_value_str=formatters["%w[%l]=%Q,"]
-local f_key_num_value_boo=formatters["%w[%s]=%l,"]
+local f_key_num_value_boo=JITSUPPORTED and formatters["%w[%s]=%l,"] or formatters["%w[%q]=%l,"]
local f_key_str_value_boo=formatters["%w[%Q]=%l,"]
local f_key_boo_value_boo=formatters["%w[%l]=%l,"]
-local f_key_num_value_not=formatters["%w[%s]={},"]
+local f_key_num_value_not=JITSUPPORTED and formatters["%w[%s]={},"] or formatters["%w[%q]={},"]
local f_key_str_value_not=formatters["%w[%Q]={},"]
local f_key_boo_value_not=formatters["%w[%l]={},"]
-local f_key_num_value_seq=formatters["%w[%s]={ %, t },"]
+local f_key_num_value_seq=JITSUPPORTED and formatters["%w[%s]={ %, t },"] or formatters["%w[%q]={ %, t },"]
local f_key_str_value_seq=formatters["%w[%Q]={ %, t },"]
local f_key_boo_value_seq=formatters["%w[%l]={ %, t },"]
-local f_val_num=formatters["%w%s,"]
+local f_val_num=JITSUPPORTED and formatters["%w%s,"] or formatters["%w%q,"]
local f_val_str=formatters["%w%Q,"]
local f_val_boo=formatters["%w%l,"]
local f_val_not=formatters["%w{},"]
@@ -21589,7 +21693,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16070, stripped down to: 11353
+-- original size: 16099, stripped down to: 11379
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -21876,7 +21980,7 @@ function caches.is_writable(filepath,filename)
local tmaname,tmcname=setluanames(filepath,filename)
return is_writable(tmaname)
end
-local saveoptions={ compact=true }
+local saveoptions={ compact=true,accurate=not JITSUPPORTED }
function caches.savedata(filepath,filename,data,fast)
local tmaname,tmcname=setluanames(filepath,filename)
data.cache_uuid=osuuid()
@@ -25385,363 +25489,147 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-package.loaded["util-lib"] = package.loaded["util-lib"] or true
+package.loaded["libs-ini"] = package.loaded["libs-ini"] or true
--- original size: 17659, stripped down to: 9560
+-- original size: 5822, stripped down to: 3629
-if not modules then modules={} end modules ['util-lib']={
+if not modules then modules={} end modules ['libs-ini']={
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",
+ license="see context related readme files"
}
+local type,unpack=type,unpack
local type=type
-local next=next
-local pcall=pcall
-local gsub=string.gsub
-local find=string.find
-local sort=table.sort
-local pathpart=file.pathpart
local nameonly=file.nameonly
local joinfile=file.join
-local removesuffix=file.removesuffix
local addsuffix=file.addsuffix
-local findfile=resolvers.findfile
-local findfiles=resolvers.findfiles
-local expandpaths=resolvers.expandedpathlistfromvariable
local qualifiedpath=file.is_qualified_path
local isfile=lfs.isfile
-local done=false
-local function locate(required,version,trace,report,action)
- if type(required)~="string" then
- report("provide a proper library name")
- return
- end
- if trace then
- report("requiring library %a with version %a",required,version or "any")
- end
- local found_library=nil
- local required_full=gsub(required,"%.","/")
- local required_path=pathpart(required_full)
- local required_base=nameonly(required_full)
- if qualifiedpath(required) then
- if isfile(addsuffix(required,os.libsuffix)) then
- if trace then
- report("qualified name %a found",required)
+local findfile=resolvers.findfile
+local expandpaths=resolvers.expandedpathlistfromvariable
+local report=logs.reporter("resolvers","libraries")
+local trace=false
+trackers.register("resolvers.lib",function(v) trace=v end)
+local function findlib(required)
+ local suffix=os.libsuffix or "so"
+ if not qualifiedpath(required) then
+ local list=directives.value("system.librarynames" )
+ local only=nameonly(required)
+ if type(list)=="table" then
+ list=list[only]
+ if type(list)~="table" then
+ list={ only }
end
- found_library=required
else
- if trace then
- report("qualified name %a not found",required)
- end
- end
- else
- local required_name=required_base.."."..os.libsuffix
- local version=type(version)=="string" and version~="" and version or false
- local engine=environment.ownmain or false
- if trace and not done then
- local list=expandpaths("lib")
- for i=1,#list do
- report("tds path %i: %s",i,list[i])
- end
+ list={ only }
end
- local function found(locate,asked_library,how,...)
- if trace then
- report("checking %s: %a",how,asked_library)
- end
- return locate(asked_library,...)
+ if trace then
+ report("using lookup list for library %a: % | t",only,list)
end
- local function check(locate,...)
- local found=nil
- if version then
- local asked_library=joinfile(required_path,version,required_name)
- if trace then
- report("checking %s: %a","with version",asked_library)
- end
- found=locate(asked_library,...)
+ for i=1,#list do
+ local name=list[i]
+ local found=findfile(name,"lib")
+ if not found then
+ found=findfile(addsuffix(name,suffix),"lib")
end
- if not found or found=="" then
- local asked_library=joinfile(required_path,required_name)
+ if found then
if trace then
- report("checking %s: %a","with version",asked_library)
+ report("library %a resolved via %a path to %a",name,"tds lib",found)
end
- found=locate(asked_library,...)
- end
- return found and found~="" and found or false
- end
- local function attempt(checkpattern)
- if trace then
- report("checking tds lib paths strictly")
- end
- local found=findfile and check(findfile,"lib")
- if found and (not checkpattern or find(found,checkpattern)) then
return found
end
- if trace then
- report("checking tds lib paths with wildcard")
- end
- local asked_library=joinfile(required_path,".*",required_name)
- if trace then
- report("checking %s: %a","latest version",asked_library)
- end
- local list=findfiles(asked_library,"lib",true)
- if list and #list>0 then
- sort(list)
- local found=list[#list]
- if found and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- if trace then
- report("checking lib paths")
- end
- package.extralibpath(environment.ownpath)
- local paths=package.libpaths()
- local pattern="/[^/]+%."..os.libsuffix.."$"
- for i=1,#paths do
- required_path=gsub(paths[i],pattern,"")
- local found=check(lfs.isfound)
- if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then
- return found
- end
- end
- return false
end
- if engine then
- if trace then
- report("attemp 1, engine %a",engine)
- end
- found_library=attempt("/"..engine.."/")
- if not found_library then
- if trace then
- report("attemp 2, no engine",asked_library)
+ if expandpaths then
+ local list=expandpaths("PATH")
+ local base=addsuffix(only,suffix)
+ for i=1,#list do
+ local full=joinfile(list[i],base)
+ local found=isfile(full) and full
+ if found then
+ if trace then
+ report("library %a resolved via %a path to %a",name,"system",found)
+ end
+ return found
end
- found_library=attempt()
end
- else
- found_library=attempt()
end
- end
- if not found_library then
+ elseif isfile(addsuffix(required,suffix)) then
if trace then
- report("not found: %a",required)
+ report("library with qualified name %a %sfound",required,"")
end
- library=false
+ return required
else
if trace then
- report("found: %a",found_library)
- end
- local result,message=action(found_library,required_base)
- if result then
- library=result
- else
- library=false
- report("load error: message %a, library %a",tostring(message or "unknown"),found_library or "no library")
+ report("library with qualified name %a %sfound",required,"not ")
end
end
- if trace then
- if not library then
- report("unknown library: %a",required)
- else
- report("stored library: %a",required)
- end
- end
- return library or nil
+ return false
end
-resolvers.locatelib=locate
-do
- local report_swiglib=logs.reporter("swiglib")
- local trace_swiglib=false
- local savedrequire=require
- local loadedlibs={}
- local loadlib=package.loadlib
- local pushdir=dir.push
- local popdir=dir.pop
- trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
- function requireswiglib(required,version)
- local library=loadedlibs[library]
- if library==nil then
- local trace_swiglib=trace_swiglib or package.helpers.trace
- library=locate(required,version,trace_swiglib,report_swiglib,function(name,base)
- pushdir(pathpart(name))
- local opener="luaopen_"..base
- if trace_swiglib then
- report_swiglib("opening: %a with %a",name,opener)
- end
- local library,message=loadlib(name,opener)
- local libtype=type(library)
- if libtype=="function" then
- library=library()
+local foundlibraries=table.setmetatableindex(function(t,k)
+ local v=findlib(k)
+ t[k]=v
+ return v
+end)
+function resolvers.findlib(required)
+ return foundlibraries[required]
+end
+local libraries={}
+resolvers.libraries=libraries
+local report=logs.reporter("optional")
+if optional then optional.loaded={} end
+function libraries.validoptional(name)
+ local thelib=optional and optional[name]
+ if not thelib then
+ elseif thelib.initialize then
+ return thelib
+ else
+ report("invalid optional library %a",libname)
+ end
+end
+function libraries.optionalloaded(name,libnames)
+ local thelib=optional and optional[name]
+ if not thelib then
+ report("no optional %a library found",name)
+ else
+ local thelib_initialize=thelib.initialize
+ if not thelib_initialize then
+ report("invalid optional library %a",name)
+ else
+ if type(libnames)=="string" then
+ libnames={ libnames }
+ end
+ if type(libnames)=="table" then
+ for i=1,#libnames do
+ local libname=libnames[i]
+ local filename=foundlibraries[libname]
+ if filename then
+ libnames[i]=filename
+ else
+ report("unable to locate library %a",libname)
+ return
+ end
+ end
+ local initialized=thelib_initialize(unpack(libnames))
+ if initialized then
+ report("using library '% + t'",libnames)
else
- report_swiglib("load error: %a returns %a, message %a, library %a",opener,libtype,(string.gsub(message or "no message","[%s]+$","")),found_library or "no library")
- library=false
+ report("unable to initialize library '% + t'",libnames)
end
- popdir()
- return library
- end)
- loadedlibs[required]=library or false
- end
- return library
- end
- function require(name,version)
- if find(name,"^swiglib%.") then
- return requireswiglib(name,version)
- else
- return savedrequire(name)
- end
- end
- local swiglibs={}
- local initializer="core"
- function swiglib(name,version)
- local library=swiglibs[name]
- if not library then
- statistics.starttiming(swiglibs)
- if trace_swiglib then
- report_swiglib("loading %a",name)
- end
- if not find(name,"%."..initializer.."$") then
- fullname="swiglib."..name.."."..initializer
- else
- fullname="swiglib."..name
+ return initialized
end
- library=requireswiglib(fullname,version)
- swiglibs[name]=library
- statistics.stoptiming(swiglibs)
end
- return library
end
- statistics.register("used swiglibs",function()
- if next(swiglibs) then
- return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
- end
- end)
end
if FFISUPPORTED and ffi and ffi.load then
- local report_ffilib=logs.reporter("ffilib")
- local trace_ffilib=false
- local savedffiload=ffi.load
- trackers.register("resolvers.ffilib",function(v) trace_ffilib=v end)
- local loaded={}
- local function locateindeed(name)
- name=removesuffix(name)
- local l=loaded[name]
- if l==nil then
- local state,library=pcall(savedffiload,name)
- if type(library)=="userdata" then
- l=library
- elseif type(state)=="userdata" then
- l=state
- else
- l=false
- end
- loaded[name]=l
- elseif trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local function getlist(required)
- local list=directives.value("system.librarynames" )
- if type(list)=="table" then
- list=list[required]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",required,list)
- end
- return list
- end
- end
- return { required }
- end
- function ffilib(name,version)
- name=removesuffix(name)
- local l=loaded[name]
- if l~=nil then
- if trace_ffilib then
- report_ffilib("reusing already loaded %a",name)
- end
- return l
- end
- local list=getlist(name)
- if version=="system" then
- for i=1,#list do
- local library=locateindeed(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- else
- for i=1,#list do
- local library=locate(list[i],version,trace_ffilib,report_ffilib,locateindeed)
- if type(library)=="userdata" then
- return library
- end
- end
- end
- end
+ local ffiload=ffi.load
function ffi.load(name)
- local list=getlist(name)
- for i=1,#list do
- local library=ffilib(list[i])
- if type(library)=="userdata" then
- return library
- end
- end
- if trace_ffilib then
- report_ffilib("trying to load %a using normal loader",name)
- end
- for i=1,#list do
- local state,library=pcall(savedffiload,list[i])
- if type(library)=="userdata" then
- return library
- elseif type(state)=="userdata" then
- return library
- end
- end
- end
-end
-do
- local isfile=lfs.isfile
- local report=logs.reporter("resolvers","lib")
- local trace=false
- trackers.register("resolvers.lib",function(v) trace=v end)
- local function action(filename)
- return isfile(filename) and filename or false
- end
- function resolvers.findlib(required)
- local list=directives.value("system.librarynames" )
- local only=nameonly(required)
- if type(list)=="table" then
- list=list[only]
- if type(list)=="table" then
- if trace then
- report("using lookup list for library %a: % | t",only,list)
- end
- else
- list={ only }
- end
+ local full=name and foundlibraries[name]
+ if full then
+ return ffiload(full)
else
- list={ only }
- end
- for i=1,#list do
- local name=list[i]
- local found=locate(name,false,trace,report,action)
- if found then
- return found
- end
- end
- local getpaths=resolvers.expandedpathlistfromvariable
- if getpaths then
- local list=getpaths("PATH")
- local base=addsuffix(only,os.libsuffix)
- for i=1,#list do
- local full=joinfile(list[i],base)
- local found=locate(full,false,trace,report,action)
- if found then
- return found
- end
- end
+ return ffiload(name)
end
end
end
@@ -26187,10 +26075,10 @@ end
end -- of closure
--- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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
+-- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1047142
--- stripped bytes : 416876
+-- original bytes : 1038128
+-- stripped bytes : 410736
-- end library merge
@@ -26304,7 +26192,7 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
- 'util-lib.lua', -- swiglib
+ 'libs-ini.lua',
'luat-sta.lua',
'luat-fmt.lua',