summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-05-15 12:15:04 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-05-15 12:15:04 +0200
commitd0d9c0224d42b024edfc81eaf8e6d9e82b204804 (patch)
treec7f09fbb4b089eea5885981c0f376869eced8b5d
parent35af43666d4d33ac9a492dd106c466e30c166ed2 (diff)
downloadcontext-d0d9c0224d42b024edfc81eaf8e6d9e82b204804.tar.gz
2015-05-15 11:44:00
-rw-r--r--scripts/context/lua/mtxrun.lua244
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua244
-rw-r--r--scripts/context/stubs/unix/mtxrun244
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua244
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4176 -> 4182 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/data-tmp.lua13
-rw-r--r--tex/context/base/font-otn.lua24
-rw-r--r--tex/context/base/font-otp.lua2
-rw-r--r--tex/context/base/font-sty.mkvi2
-rw-r--r--tex/context/base/l-table.lua280
-rw-r--r--tex/context/base/status-files.pdfbin24457 -> 24470 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin251171 -> 251173 bytes
-rw-r--r--tex/context/base/typo-itc.lua1
-rw-r--r--tex/context/base/util-prs.lua46
-rw-r--r--tex/context/base/util-tab.lua60
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua169
-rw-r--r--tex/generic/context/luatex/luatex-fonts-otn.lua20
19 files changed, 831 insertions, 766 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 6afe0fab5..edfeba8dd 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1372,7 +1372,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 33830, stripped down to: 21894
+-- original size: 35724, stripped down to: 21525
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1405,7 +1405,7 @@ end
function table.keys(t)
if t then
local keys,k={},0
- for key,_ in next,t do
+ for key in next,t do
k=k+1
keys[k]=key
end
@@ -1416,32 +1416,51 @@ function table.keys(t)
end
local function compare(a,b)
local ta=type(a)
- local tb=type(b)
- if ta==tb and ta=="number" then
- return a<b
- else
- return tostring(a)<tostring(b)
+ if ta=="number" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ elseif tb=="string" then
+ return tostring(a)<b
+ end
+ elseif ta=="string" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ else
+ return a<tostring(b)
+ end
end
+ return tostring(a)<tostring(b)
end
local function sortedkeys(tab)
if tab then
local srt,category,s={},0,0
- for key,_ in next,tab do
+ for key in next,tab do
s=s+1
srt[s]=key
if category==3 then
+ elseif category==1 then
+ if type(key)~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if type(key)~="number" then
+ category=3
+ end
else
local tkey=type(key)
if tkey=="string" then
- category=(category==2 and 3) or 1
+ category=1
elseif tkey=="number" then
- category=(category==1 and 3) or 2
+ category=2
else
category=3
end
end
end
- if category==0 or category==3 then
+ if s<2 then
+ elseif category==3 then
sort(srt,compare)
else
sort(srt)
@@ -1454,13 +1473,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="string" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1469,13 +1490,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="number" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1484,13 +1507,15 @@ end
local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if key then
s=s+1
srt[s]=key
end
end
- sort(srt,cmp)
+ if s>1 then
+ sort(srt,cmp)
+ end
return srt
else
return {}
@@ -1499,7 +1524,7 @@ end
function table.allkeys(t)
local keys={}
for k,v in next,t do
- for k,v in next,v do
+ for k in next,v do
keys[k]=true
end
end
@@ -1518,19 +1543,21 @@ local function sortedhash(t,cmp)
else
s=sortedkeys(t)
end
- local n=0
local m=#s
- local function kv()
- if n<m then
- n=n+1
- local k=s[n]
- return k,t[k]
+ if m==1 then
+ return next,t
+ elseif m>0 then
+ local n=0
+ return function()
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
end
- return kv
- else
- return nothing
end
+ return nothing
end
table.sortedhash=sortedhash
table.sortedpairs=sortedhash
@@ -1672,39 +1699,36 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,reduce,compact,inline,functions
+local noquotes,hexify,handle,compact,inline,functions
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',
}
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
end
- if n==#t then
- local tt,nt={},0
- for i=1,#t do
+ if n==nt then
+ local tt={}
+ for i=1,nt do
local v=t[i]
local tv=type(v)
if tv=="number" then
- nt=nt+1
if hexify then
- tt[nt]=format("0x%X",v)
+ tt[i]=format("0x%X",v)
else
- tt[nt]=tostring(v)
+ tt[i]=tostring(v)
end
elseif tv=="string" then
- nt=nt+1
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- nt=nt+1
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
- tt=nil
- break
+ return nil
end
end
return tt
@@ -1758,7 +1782,8 @@ local function do_serialize(root,name,depth,level,indexed)
for i=1,#sk do
local k=sk[i]
local v=root[k]
- local tv,tk=type(v),type(k)
+ local tv=type(v)
+ local tk=type(k)
if compact and first and tk=="number" and k>=first and k<=last then
if tv=="number" then
if hexify then
@@ -1767,11 +1792,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v))
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv=="table" then
if next(v)==nil then
handle(format("%s {},",depth))
@@ -1827,34 +1848,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk=="number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk=="boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv=="table" then
if next(v)==nil then
@@ -1951,7 +1956,6 @@ local function serialize(_handle,root,name,specification)
noquotes=specification.noquotes
hexify=specification.hexify
handle=_handle or specification.handle or print
- reduce=specification.reduce or false
functions=specification.functions
compact=specification.compact
inline=specification.inline and compact
@@ -1968,7 +1972,6 @@ local function serialize(_handle,root,name,specification)
noquotes=false
hexify=false
handle=_handle or print
- reduce=false
compact=true
inline=true
functions=true
@@ -5882,7 +5885,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 24267, stripped down to: 16260
+-- original size: 25338, stripped down to: 16247
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -5895,7 +5898,7 @@ utilities=utilities or {}
utilities.tables=utilities.tables or {}
local tables=utilities.tables
local format,gmatch,gsub,sub=string.format,string.gmatch,string.gsub,string.sub
-local concat,insert,remove=table.concat,table.insert,table.remove
+local concat,insert,remove,sort=table.concat,table.insert,table.remove,table.sort
local setmetatable,getmetatable,tonumber,tostring=setmetatable,getmetatable,tonumber,tostring
local type,next,rawset,tonumber,tostring,load,select=type,next,rawset,tonumber,tostring,load,select
local lpegmatch,P,Cs,Cc=lpeg.match,lpeg.P,lpeg.Cs,lpeg.Cc
@@ -6325,7 +6328,8 @@ function table.serialize(root,name,specification)
local t
local n=1
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
@@ -6333,19 +6337,17 @@ function table.serialize(root,name,specification)
return nil
end
end
- if n==#t then
+ if n==nt then
local tt={}
- local nt=0
- for i=1,#t do
+ for i=1,nt do
local v=t[i]
local tv=type(v)
- nt=nt+1
if tv=="number" then
- tt[nt]=v
+ tt[i]=v
elseif tv=="string" then
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
return nil
end
@@ -6393,7 +6395,7 @@ function table.serialize(root,name,specification)
local v=root[k]
local tv=type(v)
local tk=type(k)
- if first and tk=="number" and k>=first and k<=last then
+ if first and tk=="number" and k<=last and k>=first then
if tv=="number" then
n=n+1 t[n]=f_val_num(depth,v)
elseif tv=="string" then
@@ -6431,11 +6433,11 @@ function table.serialize(root,name,specification)
elseif tv=="table" then
if next(v)==nil then
if tk=="number" then
- n=n+1 t[n]=f_key_num_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_num_value_not(depth,k)
elseif tk=="string" then
- n=n+1 t[n]=f_key_str_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_str_value_not(depth,k)
elseif tk=="boolean" then
- n=n+1 t[n]=f_key_boo_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_boo_value_not(depth,k)
end
else
local st=simple_table(v)
@@ -6650,7 +6652,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 21751, stripped down to: 15108
+-- original size: 21780, stripped down to: 15121
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6672,6 +6674,8 @@ local patterns=parsers.patterns or {}
parsers.patterns=patterns
local setmetatableindex=table.setmetatableindex
local sortedhash=table.sortedhash
+local sortedkeys=table.sortedkeys
+local tohash=table.tohash
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -6721,9 +6725,7 @@ patterns.settings_to_hash_a=pattern_a_s
patterns.settings_to_hash_b=pattern_b_s
patterns.settings_to_hash_c=pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if type(str)=="table" then
- return set
- elseif how=="strict" then
+ if how=="strict" then
return (pattern_c/set)^1
elseif how=="tolerant" then
return (pattern_b/set)^1
@@ -6732,7 +6734,9 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
end
function parsers.settings_to_hash(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6741,16 +6745,16 @@ function parsers.settings_to_hash(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_a_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6759,16 +6763,16 @@ function parsers.settings_to_hash_tolerant(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_b_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_strict(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return nil
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6781,8 +6785,6 @@ function parsers.settings_to_hash_strict(str,existing)
hash=existing or {}
lpegmatch(pattern_c_s,str)
return next(hash) and hash
- else
- return nil
end
end
local separator=comma*space^0
@@ -6790,10 +6792,10 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm
local pattern=spaces*Ct(value*(separator*value)^0)
patterns.settings_to_array=pattern
function parsers.settings_to_array(str,strict)
- if type(str)=="table" then
- return str
- elseif not str or str=="" then
+ if not str or str=="" then
return {}
+ elseif type(str)=="table" then
+ return str
elseif strict then
if find(str,"{",1,true) then
return lpegmatch(pattern,str)
@@ -6854,8 +6856,8 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,table.sortedkeys(h)
- omit=omit and table.tohash(omit)
+ local t,tn,s={},0,sortedkeys(h)
+ omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
if not omit or not omit[key] then
@@ -7001,7 +7003,7 @@ function parsers.keq_to_hash(str)
end
local defaultspecification={ separator=",",quote='"' }
function parsers.csvsplitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=specification.quote
local separator=S(separator~="" and separator or ",")
@@ -7025,7 +7027,7 @@ function parsers.csvsplitter(specification)
end
end
function parsers.rfc4180splitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=P(specification.quote)
local dquotechar=quotechar*quotechar
@@ -7084,9 +7086,9 @@ function parsers.unittoxml(str)
return lpegmatch(pattern,str)
end
local cache={}
-local spaces=lpeg.patterns.space^0
+local spaces=lpegpatterns.space^0
local dummy=function() end
-table.setmetatableindex(cache,function(t,k)
+setmetatableindex(cache,function(t,k)
local separator=P(k)
local value=(1-separator)^0
local pattern=spaces*C(value)*separator^0*Cp()
@@ -14060,7 +14062,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 15681, stripped down to: 11761
+-- original size: 15618, stripped down to: 11629
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -14070,7 +14072,7 @@ if not modules then modules={} end modules ['data-tmp']={
license="see context related readme files"
}
local format,lower,gsub,concat=string.format,string.lower,string.gsub,table.concat
-local concat,serialize,serializetofile=table.concat,table.serialize,table.tofile
+local concat=table.concat
local mkdirs,isdir,isfile=dir.mkdirs,lfs.isdir,lfs.isfile
local addsuffix,is_writable,is_readable=file.addsuffix,file.is_writable,file.is_readable
local formatters=string.formatters
@@ -14339,15 +14341,11 @@ end
local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
- local reduce,simplify=true,true
- if raw then
- reduce,simplify=false,false
- end
data.cache_uuid=os.uuid()
if caches.direct then
- file.savedata(tmaname,serialize(data,true,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- serializetofile(tmaname,data,true,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
@@ -14412,7 +14410,7 @@ function caches.savecontent(cachename,dataname,content,filename)
content=content,
uuid=os.uuid(),
}
- local ok=io.savedata(luaname,serialize(data,true))
+ local ok=io.savedata(luaname,table.serialize(data,true))
if ok then
if trace_locating then
report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
@@ -17938,8 +17936,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 742687
--- stripped bytes : 265759
+-- original bytes : 745618
+-- stripped bytes : 269191
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 6afe0fab5..edfeba8dd 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -1372,7 +1372,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 33830, stripped down to: 21894
+-- original size: 35724, stripped down to: 21525
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1405,7 +1405,7 @@ end
function table.keys(t)
if t then
local keys,k={},0
- for key,_ in next,t do
+ for key in next,t do
k=k+1
keys[k]=key
end
@@ -1416,32 +1416,51 @@ function table.keys(t)
end
local function compare(a,b)
local ta=type(a)
- local tb=type(b)
- if ta==tb and ta=="number" then
- return a<b
- else
- return tostring(a)<tostring(b)
+ if ta=="number" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ elseif tb=="string" then
+ return tostring(a)<b
+ end
+ elseif ta=="string" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ else
+ return a<tostring(b)
+ end
end
+ return tostring(a)<tostring(b)
end
local function sortedkeys(tab)
if tab then
local srt,category,s={},0,0
- for key,_ in next,tab do
+ for key in next,tab do
s=s+1
srt[s]=key
if category==3 then
+ elseif category==1 then
+ if type(key)~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if type(key)~="number" then
+ category=3
+ end
else
local tkey=type(key)
if tkey=="string" then
- category=(category==2 and 3) or 1
+ category=1
elseif tkey=="number" then
- category=(category==1 and 3) or 2
+ category=2
else
category=3
end
end
end
- if category==0 or category==3 then
+ if s<2 then
+ elseif category==3 then
sort(srt,compare)
else
sort(srt)
@@ -1454,13 +1473,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="string" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1469,13 +1490,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="number" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1484,13 +1507,15 @@ end
local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if key then
s=s+1
srt[s]=key
end
end
- sort(srt,cmp)
+ if s>1 then
+ sort(srt,cmp)
+ end
return srt
else
return {}
@@ -1499,7 +1524,7 @@ end
function table.allkeys(t)
local keys={}
for k,v in next,t do
- for k,v in next,v do
+ for k in next,v do
keys[k]=true
end
end
@@ -1518,19 +1543,21 @@ local function sortedhash(t,cmp)
else
s=sortedkeys(t)
end
- local n=0
local m=#s
- local function kv()
- if n<m then
- n=n+1
- local k=s[n]
- return k,t[k]
+ if m==1 then
+ return next,t
+ elseif m>0 then
+ local n=0
+ return function()
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
end
- return kv
- else
- return nothing
end
+ return nothing
end
table.sortedhash=sortedhash
table.sortedpairs=sortedhash
@@ -1672,39 +1699,36 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,reduce,compact,inline,functions
+local noquotes,hexify,handle,compact,inline,functions
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',
}
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
end
- if n==#t then
- local tt,nt={},0
- for i=1,#t do
+ if n==nt then
+ local tt={}
+ for i=1,nt do
local v=t[i]
local tv=type(v)
if tv=="number" then
- nt=nt+1
if hexify then
- tt[nt]=format("0x%X",v)
+ tt[i]=format("0x%X",v)
else
- tt[nt]=tostring(v)
+ tt[i]=tostring(v)
end
elseif tv=="string" then
- nt=nt+1
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- nt=nt+1
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
- tt=nil
- break
+ return nil
end
end
return tt
@@ -1758,7 +1782,8 @@ local function do_serialize(root,name,depth,level,indexed)
for i=1,#sk do
local k=sk[i]
local v=root[k]
- local tv,tk=type(v),type(k)
+ local tv=type(v)
+ local tk=type(k)
if compact and first and tk=="number" and k>=first and k<=last then
if tv=="number" then
if hexify then
@@ -1767,11 +1792,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v))
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv=="table" then
if next(v)==nil then
handle(format("%s {},",depth))
@@ -1827,34 +1848,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk=="number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk=="boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv=="table" then
if next(v)==nil then
@@ -1951,7 +1956,6 @@ local function serialize(_handle,root,name,specification)
noquotes=specification.noquotes
hexify=specification.hexify
handle=_handle or specification.handle or print
- reduce=specification.reduce or false
functions=specification.functions
compact=specification.compact
inline=specification.inline and compact
@@ -1968,7 +1972,6 @@ local function serialize(_handle,root,name,specification)
noquotes=false
hexify=false
handle=_handle or print
- reduce=false
compact=true
inline=true
functions=true
@@ -5882,7 +5885,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 24267, stripped down to: 16260
+-- original size: 25338, stripped down to: 16247
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -5895,7 +5898,7 @@ utilities=utilities or {}
utilities.tables=utilities.tables or {}
local tables=utilities.tables
local format,gmatch,gsub,sub=string.format,string.gmatch,string.gsub,string.sub
-local concat,insert,remove=table.concat,table.insert,table.remove
+local concat,insert,remove,sort=table.concat,table.insert,table.remove,table.sort
local setmetatable,getmetatable,tonumber,tostring=setmetatable,getmetatable,tonumber,tostring
local type,next,rawset,tonumber,tostring,load,select=type,next,rawset,tonumber,tostring,load,select
local lpegmatch,P,Cs,Cc=lpeg.match,lpeg.P,lpeg.Cs,lpeg.Cc
@@ -6325,7 +6328,8 @@ function table.serialize(root,name,specification)
local t
local n=1
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
@@ -6333,19 +6337,17 @@ function table.serialize(root,name,specification)
return nil
end
end
- if n==#t then
+ if n==nt then
local tt={}
- local nt=0
- for i=1,#t do
+ for i=1,nt do
local v=t[i]
local tv=type(v)
- nt=nt+1
if tv=="number" then
- tt[nt]=v
+ tt[i]=v
elseif tv=="string" then
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
return nil
end
@@ -6393,7 +6395,7 @@ function table.serialize(root,name,specification)
local v=root[k]
local tv=type(v)
local tk=type(k)
- if first and tk=="number" and k>=first and k<=last then
+ if first and tk=="number" and k<=last and k>=first then
if tv=="number" then
n=n+1 t[n]=f_val_num(depth,v)
elseif tv=="string" then
@@ -6431,11 +6433,11 @@ function table.serialize(root,name,specification)
elseif tv=="table" then
if next(v)==nil then
if tk=="number" then
- n=n+1 t[n]=f_key_num_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_num_value_not(depth,k)
elseif tk=="string" then
- n=n+1 t[n]=f_key_str_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_str_value_not(depth,k)
elseif tk=="boolean" then
- n=n+1 t[n]=f_key_boo_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_boo_value_not(depth,k)
end
else
local st=simple_table(v)
@@ -6650,7 +6652,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 21751, stripped down to: 15108
+-- original size: 21780, stripped down to: 15121
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6672,6 +6674,8 @@ local patterns=parsers.patterns or {}
parsers.patterns=patterns
local setmetatableindex=table.setmetatableindex
local sortedhash=table.sortedhash
+local sortedkeys=table.sortedkeys
+local tohash=table.tohash
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -6721,9 +6725,7 @@ patterns.settings_to_hash_a=pattern_a_s
patterns.settings_to_hash_b=pattern_b_s
patterns.settings_to_hash_c=pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if type(str)=="table" then
- return set
- elseif how=="strict" then
+ if how=="strict" then
return (pattern_c/set)^1
elseif how=="tolerant" then
return (pattern_b/set)^1
@@ -6732,7 +6734,9 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
end
function parsers.settings_to_hash(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6741,16 +6745,16 @@ function parsers.settings_to_hash(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_a_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6759,16 +6763,16 @@ function parsers.settings_to_hash_tolerant(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_b_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_strict(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return nil
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6781,8 +6785,6 @@ function parsers.settings_to_hash_strict(str,existing)
hash=existing or {}
lpegmatch(pattern_c_s,str)
return next(hash) and hash
- else
- return nil
end
end
local separator=comma*space^0
@@ -6790,10 +6792,10 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm
local pattern=spaces*Ct(value*(separator*value)^0)
patterns.settings_to_array=pattern
function parsers.settings_to_array(str,strict)
- if type(str)=="table" then
- return str
- elseif not str or str=="" then
+ if not str or str=="" then
return {}
+ elseif type(str)=="table" then
+ return str
elseif strict then
if find(str,"{",1,true) then
return lpegmatch(pattern,str)
@@ -6854,8 +6856,8 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,table.sortedkeys(h)
- omit=omit and table.tohash(omit)
+ local t,tn,s={},0,sortedkeys(h)
+ omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
if not omit or not omit[key] then
@@ -7001,7 +7003,7 @@ function parsers.keq_to_hash(str)
end
local defaultspecification={ separator=",",quote='"' }
function parsers.csvsplitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=specification.quote
local separator=S(separator~="" and separator or ",")
@@ -7025,7 +7027,7 @@ function parsers.csvsplitter(specification)
end
end
function parsers.rfc4180splitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=P(specification.quote)
local dquotechar=quotechar*quotechar
@@ -7084,9 +7086,9 @@ function parsers.unittoxml(str)
return lpegmatch(pattern,str)
end
local cache={}
-local spaces=lpeg.patterns.space^0
+local spaces=lpegpatterns.space^0
local dummy=function() end
-table.setmetatableindex(cache,function(t,k)
+setmetatableindex(cache,function(t,k)
local separator=P(k)
local value=(1-separator)^0
local pattern=spaces*C(value)*separator^0*Cp()
@@ -14060,7 +14062,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 15681, stripped down to: 11761
+-- original size: 15618, stripped down to: 11629
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -14070,7 +14072,7 @@ if not modules then modules={} end modules ['data-tmp']={
license="see context related readme files"
}
local format,lower,gsub,concat=string.format,string.lower,string.gsub,table.concat
-local concat,serialize,serializetofile=table.concat,table.serialize,table.tofile
+local concat=table.concat
local mkdirs,isdir,isfile=dir.mkdirs,lfs.isdir,lfs.isfile
local addsuffix,is_writable,is_readable=file.addsuffix,file.is_writable,file.is_readable
local formatters=string.formatters
@@ -14339,15 +14341,11 @@ end
local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
- local reduce,simplify=true,true
- if raw then
- reduce,simplify=false,false
- end
data.cache_uuid=os.uuid()
if caches.direct then
- file.savedata(tmaname,serialize(data,true,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- serializetofile(tmaname,data,true,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
@@ -14412,7 +14410,7 @@ function caches.savecontent(cachename,dataname,content,filename)
content=content,
uuid=os.uuid(),
}
- local ok=io.savedata(luaname,serialize(data,true))
+ local ok=io.savedata(luaname,table.serialize(data,true))
if ok then
if trace_locating then
report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
@@ -17938,8 +17936,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 742687
--- stripped bytes : 265759
+-- original bytes : 745618
+-- stripped bytes : 269191
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 6afe0fab5..edfeba8dd 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -1372,7 +1372,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 33830, stripped down to: 21894
+-- original size: 35724, stripped down to: 21525
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1405,7 +1405,7 @@ end
function table.keys(t)
if t then
local keys,k={},0
- for key,_ in next,t do
+ for key in next,t do
k=k+1
keys[k]=key
end
@@ -1416,32 +1416,51 @@ function table.keys(t)
end
local function compare(a,b)
local ta=type(a)
- local tb=type(b)
- if ta==tb and ta=="number" then
- return a<b
- else
- return tostring(a)<tostring(b)
+ if ta=="number" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ elseif tb=="string" then
+ return tostring(a)<b
+ end
+ elseif ta=="string" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ else
+ return a<tostring(b)
+ end
end
+ return tostring(a)<tostring(b)
end
local function sortedkeys(tab)
if tab then
local srt,category,s={},0,0
- for key,_ in next,tab do
+ for key in next,tab do
s=s+1
srt[s]=key
if category==3 then
+ elseif category==1 then
+ if type(key)~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if type(key)~="number" then
+ category=3
+ end
else
local tkey=type(key)
if tkey=="string" then
- category=(category==2 and 3) or 1
+ category=1
elseif tkey=="number" then
- category=(category==1 and 3) or 2
+ category=2
else
category=3
end
end
end
- if category==0 or category==3 then
+ if s<2 then
+ elseif category==3 then
sort(srt,compare)
else
sort(srt)
@@ -1454,13 +1473,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="string" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1469,13 +1490,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="number" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1484,13 +1507,15 @@ end
local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if key then
s=s+1
srt[s]=key
end
end
- sort(srt,cmp)
+ if s>1 then
+ sort(srt,cmp)
+ end
return srt
else
return {}
@@ -1499,7 +1524,7 @@ end
function table.allkeys(t)
local keys={}
for k,v in next,t do
- for k,v in next,v do
+ for k in next,v do
keys[k]=true
end
end
@@ -1518,19 +1543,21 @@ local function sortedhash(t,cmp)
else
s=sortedkeys(t)
end
- local n=0
local m=#s
- local function kv()
- if n<m then
- n=n+1
- local k=s[n]
- return k,t[k]
+ if m==1 then
+ return next,t
+ elseif m>0 then
+ local n=0
+ return function()
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
end
- return kv
- else
- return nothing
end
+ return nothing
end
table.sortedhash=sortedhash
table.sortedpairs=sortedhash
@@ -1672,39 +1699,36 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,reduce,compact,inline,functions
+local noquotes,hexify,handle,compact,inline,functions
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',
}
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
end
- if n==#t then
- local tt,nt={},0
- for i=1,#t do
+ if n==nt then
+ local tt={}
+ for i=1,nt do
local v=t[i]
local tv=type(v)
if tv=="number" then
- nt=nt+1
if hexify then
- tt[nt]=format("0x%X",v)
+ tt[i]=format("0x%X",v)
else
- tt[nt]=tostring(v)
+ tt[i]=tostring(v)
end
elseif tv=="string" then
- nt=nt+1
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- nt=nt+1
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
- tt=nil
- break
+ return nil
end
end
return tt
@@ -1758,7 +1782,8 @@ local function do_serialize(root,name,depth,level,indexed)
for i=1,#sk do
local k=sk[i]
local v=root[k]
- local tv,tk=type(v),type(k)
+ local tv=type(v)
+ local tk=type(k)
if compact and first and tk=="number" and k>=first and k<=last then
if tv=="number" then
if hexify then
@@ -1767,11 +1792,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v))
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv=="table" then
if next(v)==nil then
handle(format("%s {},",depth))
@@ -1827,34 +1848,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk=="number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk=="boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv=="table" then
if next(v)==nil then
@@ -1951,7 +1956,6 @@ local function serialize(_handle,root,name,specification)
noquotes=specification.noquotes
hexify=specification.hexify
handle=_handle or specification.handle or print
- reduce=specification.reduce or false
functions=specification.functions
compact=specification.compact
inline=specification.inline and compact
@@ -1968,7 +1972,6 @@ local function serialize(_handle,root,name,specification)
noquotes=false
hexify=false
handle=_handle or print
- reduce=false
compact=true
inline=true
functions=true
@@ -5882,7 +5885,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 24267, stripped down to: 16260
+-- original size: 25338, stripped down to: 16247
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -5895,7 +5898,7 @@ utilities=utilities or {}
utilities.tables=utilities.tables or {}
local tables=utilities.tables
local format,gmatch,gsub,sub=string.format,string.gmatch,string.gsub,string.sub
-local concat,insert,remove=table.concat,table.insert,table.remove
+local concat,insert,remove,sort=table.concat,table.insert,table.remove,table.sort
local setmetatable,getmetatable,tonumber,tostring=setmetatable,getmetatable,tonumber,tostring
local type,next,rawset,tonumber,tostring,load,select=type,next,rawset,tonumber,tostring,load,select
local lpegmatch,P,Cs,Cc=lpeg.match,lpeg.P,lpeg.Cs,lpeg.Cc
@@ -6325,7 +6328,8 @@ function table.serialize(root,name,specification)
local t
local n=1
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
@@ -6333,19 +6337,17 @@ function table.serialize(root,name,specification)
return nil
end
end
- if n==#t then
+ if n==nt then
local tt={}
- local nt=0
- for i=1,#t do
+ for i=1,nt do
local v=t[i]
local tv=type(v)
- nt=nt+1
if tv=="number" then
- tt[nt]=v
+ tt[i]=v
elseif tv=="string" then
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
return nil
end
@@ -6393,7 +6395,7 @@ function table.serialize(root,name,specification)
local v=root[k]
local tv=type(v)
local tk=type(k)
- if first and tk=="number" and k>=first and k<=last then
+ if first and tk=="number" and k<=last and k>=first then
if tv=="number" then
n=n+1 t[n]=f_val_num(depth,v)
elseif tv=="string" then
@@ -6431,11 +6433,11 @@ function table.serialize(root,name,specification)
elseif tv=="table" then
if next(v)==nil then
if tk=="number" then
- n=n+1 t[n]=f_key_num_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_num_value_not(depth,k)
elseif tk=="string" then
- n=n+1 t[n]=f_key_str_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_str_value_not(depth,k)
elseif tk=="boolean" then
- n=n+1 t[n]=f_key_boo_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_boo_value_not(depth,k)
end
else
local st=simple_table(v)
@@ -6650,7 +6652,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 21751, stripped down to: 15108
+-- original size: 21780, stripped down to: 15121
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6672,6 +6674,8 @@ local patterns=parsers.patterns or {}
parsers.patterns=patterns
local setmetatableindex=table.setmetatableindex
local sortedhash=table.sortedhash
+local sortedkeys=table.sortedkeys
+local tohash=table.tohash
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -6721,9 +6725,7 @@ patterns.settings_to_hash_a=pattern_a_s
patterns.settings_to_hash_b=pattern_b_s
patterns.settings_to_hash_c=pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if type(str)=="table" then
- return set
- elseif how=="strict" then
+ if how=="strict" then
return (pattern_c/set)^1
elseif how=="tolerant" then
return (pattern_b/set)^1
@@ -6732,7 +6734,9 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
end
function parsers.settings_to_hash(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6741,16 +6745,16 @@ function parsers.settings_to_hash(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_a_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6759,16 +6763,16 @@ function parsers.settings_to_hash_tolerant(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_b_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_strict(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return nil
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6781,8 +6785,6 @@ function parsers.settings_to_hash_strict(str,existing)
hash=existing or {}
lpegmatch(pattern_c_s,str)
return next(hash) and hash
- else
- return nil
end
end
local separator=comma*space^0
@@ -6790,10 +6792,10 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm
local pattern=spaces*Ct(value*(separator*value)^0)
patterns.settings_to_array=pattern
function parsers.settings_to_array(str,strict)
- if type(str)=="table" then
- return str
- elseif not str or str=="" then
+ if not str or str=="" then
return {}
+ elseif type(str)=="table" then
+ return str
elseif strict then
if find(str,"{",1,true) then
return lpegmatch(pattern,str)
@@ -6854,8 +6856,8 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,table.sortedkeys(h)
- omit=omit and table.tohash(omit)
+ local t,tn,s={},0,sortedkeys(h)
+ omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
if not omit or not omit[key] then
@@ -7001,7 +7003,7 @@ function parsers.keq_to_hash(str)
end
local defaultspecification={ separator=",",quote='"' }
function parsers.csvsplitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=specification.quote
local separator=S(separator~="" and separator or ",")
@@ -7025,7 +7027,7 @@ function parsers.csvsplitter(specification)
end
end
function parsers.rfc4180splitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=P(specification.quote)
local dquotechar=quotechar*quotechar
@@ -7084,9 +7086,9 @@ function parsers.unittoxml(str)
return lpegmatch(pattern,str)
end
local cache={}
-local spaces=lpeg.patterns.space^0
+local spaces=lpegpatterns.space^0
local dummy=function() end
-table.setmetatableindex(cache,function(t,k)
+setmetatableindex(cache,function(t,k)
local separator=P(k)
local value=(1-separator)^0
local pattern=spaces*C(value)*separator^0*Cp()
@@ -14060,7 +14062,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 15681, stripped down to: 11761
+-- original size: 15618, stripped down to: 11629
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -14070,7 +14072,7 @@ if not modules then modules={} end modules ['data-tmp']={
license="see context related readme files"
}
local format,lower,gsub,concat=string.format,string.lower,string.gsub,table.concat
-local concat,serialize,serializetofile=table.concat,table.serialize,table.tofile
+local concat=table.concat
local mkdirs,isdir,isfile=dir.mkdirs,lfs.isdir,lfs.isfile
local addsuffix,is_writable,is_readable=file.addsuffix,file.is_writable,file.is_readable
local formatters=string.formatters
@@ -14339,15 +14341,11 @@ end
local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
- local reduce,simplify=true,true
- if raw then
- reduce,simplify=false,false
- end
data.cache_uuid=os.uuid()
if caches.direct then
- file.savedata(tmaname,serialize(data,true,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- serializetofile(tmaname,data,true,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
@@ -14412,7 +14410,7 @@ function caches.savecontent(cachename,dataname,content,filename)
content=content,
uuid=os.uuid(),
}
- local ok=io.savedata(luaname,serialize(data,true))
+ local ok=io.savedata(luaname,table.serialize(data,true))
if ok then
if trace_locating then
report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
@@ -17938,8 +17936,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 742687
--- stripped bytes : 265759
+-- original bytes : 745618
+-- stripped bytes : 269191
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 6afe0fab5..edfeba8dd 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -1372,7 +1372,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 33830, stripped down to: 21894
+-- original size: 35724, stripped down to: 21525
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1405,7 +1405,7 @@ end
function table.keys(t)
if t then
local keys,k={},0
- for key,_ in next,t do
+ for key in next,t do
k=k+1
keys[k]=key
end
@@ -1416,32 +1416,51 @@ function table.keys(t)
end
local function compare(a,b)
local ta=type(a)
- local tb=type(b)
- if ta==tb and ta=="number" then
- return a<b
- else
- return tostring(a)<tostring(b)
+ if ta=="number" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ elseif tb=="string" then
+ return tostring(a)<b
+ end
+ elseif ta=="string" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ else
+ return a<tostring(b)
+ end
end
+ return tostring(a)<tostring(b)
end
local function sortedkeys(tab)
if tab then
local srt,category,s={},0,0
- for key,_ in next,tab do
+ for key in next,tab do
s=s+1
srt[s]=key
if category==3 then
+ elseif category==1 then
+ if type(key)~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if type(key)~="number" then
+ category=3
+ end
else
local tkey=type(key)
if tkey=="string" then
- category=(category==2 and 3) or 1
+ category=1
elseif tkey=="number" then
- category=(category==1 and 3) or 2
+ category=2
else
category=3
end
end
end
- if category==0 or category==3 then
+ if s<2 then
+ elseif category==3 then
sort(srt,compare)
else
sort(srt)
@@ -1454,13 +1473,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="string" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1469,13 +1490,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="number" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1484,13 +1507,15 @@ end
local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if key then
s=s+1
srt[s]=key
end
end
- sort(srt,cmp)
+ if s>1 then
+ sort(srt,cmp)
+ end
return srt
else
return {}
@@ -1499,7 +1524,7 @@ end
function table.allkeys(t)
local keys={}
for k,v in next,t do
- for k,v in next,v do
+ for k in next,v do
keys[k]=true
end
end
@@ -1518,19 +1543,21 @@ local function sortedhash(t,cmp)
else
s=sortedkeys(t)
end
- local n=0
local m=#s
- local function kv()
- if n<m then
- n=n+1
- local k=s[n]
- return k,t[k]
+ if m==1 then
+ return next,t
+ elseif m>0 then
+ local n=0
+ return function()
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
end
- return kv
- else
- return nothing
end
+ return nothing
end
table.sortedhash=sortedhash
table.sortedpairs=sortedhash
@@ -1672,39 +1699,36 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,reduce,compact,inline,functions
+local noquotes,hexify,handle,compact,inline,functions
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',
}
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
end
- if n==#t then
- local tt,nt={},0
- for i=1,#t do
+ if n==nt then
+ local tt={}
+ for i=1,nt do
local v=t[i]
local tv=type(v)
if tv=="number" then
- nt=nt+1
if hexify then
- tt[nt]=format("0x%X",v)
+ tt[i]=format("0x%X",v)
else
- tt[nt]=tostring(v)
+ tt[i]=tostring(v)
end
elseif tv=="string" then
- nt=nt+1
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- nt=nt+1
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
- tt=nil
- break
+ return nil
end
end
return tt
@@ -1758,7 +1782,8 @@ local function do_serialize(root,name,depth,level,indexed)
for i=1,#sk do
local k=sk[i]
local v=root[k]
- local tv,tk=type(v),type(k)
+ local tv=type(v)
+ local tk=type(k)
if compact and first and tk=="number" and k>=first and k<=last then
if tv=="number" then
if hexify then
@@ -1767,11 +1792,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v))
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv=="table" then
if next(v)==nil then
handle(format("%s {},",depth))
@@ -1827,34 +1848,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk=="number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk=="boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv=="table" then
if next(v)==nil then
@@ -1951,7 +1956,6 @@ local function serialize(_handle,root,name,specification)
noquotes=specification.noquotes
hexify=specification.hexify
handle=_handle or specification.handle or print
- reduce=specification.reduce or false
functions=specification.functions
compact=specification.compact
inline=specification.inline and compact
@@ -1968,7 +1972,6 @@ local function serialize(_handle,root,name,specification)
noquotes=false
hexify=false
handle=_handle or print
- reduce=false
compact=true
inline=true
functions=true
@@ -5882,7 +5885,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 24267, stripped down to: 16260
+-- original size: 25338, stripped down to: 16247
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -5895,7 +5898,7 @@ utilities=utilities or {}
utilities.tables=utilities.tables or {}
local tables=utilities.tables
local format,gmatch,gsub,sub=string.format,string.gmatch,string.gsub,string.sub
-local concat,insert,remove=table.concat,table.insert,table.remove
+local concat,insert,remove,sort=table.concat,table.insert,table.remove,table.sort
local setmetatable,getmetatable,tonumber,tostring=setmetatable,getmetatable,tonumber,tostring
local type,next,rawset,tonumber,tostring,load,select=type,next,rawset,tonumber,tostring,load,select
local lpegmatch,P,Cs,Cc=lpeg.match,lpeg.P,lpeg.Cs,lpeg.Cc
@@ -6325,7 +6328,8 @@ function table.serialize(root,name,specification)
local t
local n=1
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
@@ -6333,19 +6337,17 @@ function table.serialize(root,name,specification)
return nil
end
end
- if n==#t then
+ if n==nt then
local tt={}
- local nt=0
- for i=1,#t do
+ for i=1,nt do
local v=t[i]
local tv=type(v)
- nt=nt+1
if tv=="number" then
- tt[nt]=v
+ tt[i]=v
elseif tv=="string" then
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
return nil
end
@@ -6393,7 +6395,7 @@ function table.serialize(root,name,specification)
local v=root[k]
local tv=type(v)
local tk=type(k)
- if first and tk=="number" and k>=first and k<=last then
+ if first and tk=="number" and k<=last and k>=first then
if tv=="number" then
n=n+1 t[n]=f_val_num(depth,v)
elseif tv=="string" then
@@ -6431,11 +6433,11 @@ function table.serialize(root,name,specification)
elseif tv=="table" then
if next(v)==nil then
if tk=="number" then
- n=n+1 t[n]=f_key_num_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_num_value_not(depth,k)
elseif tk=="string" then
- n=n+1 t[n]=f_key_str_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_str_value_not(depth,k)
elseif tk=="boolean" then
- n=n+1 t[n]=f_key_boo_value_not(depth,k,v)
+ n=n+1 t[n]=f_key_boo_value_not(depth,k)
end
else
local st=simple_table(v)
@@ -6650,7 +6652,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 21751, stripped down to: 15108
+-- original size: 21780, stripped down to: 15121
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6672,6 +6674,8 @@ local patterns=parsers.patterns or {}
parsers.patterns=patterns
local setmetatableindex=table.setmetatableindex
local sortedhash=table.sortedhash
+local sortedkeys=table.sortedkeys
+local tohash=table.tohash
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -6721,9 +6725,7 @@ patterns.settings_to_hash_a=pattern_a_s
patterns.settings_to_hash_b=pattern_b_s
patterns.settings_to_hash_c=pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if type(str)=="table" then
- return set
- elseif how=="strict" then
+ if how=="strict" then
return (pattern_c/set)^1
elseif how=="tolerant" then
return (pattern_b/set)^1
@@ -6732,7 +6734,9 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
end
function parsers.settings_to_hash(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6741,16 +6745,16 @@ function parsers.settings_to_hash(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_a_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return {}
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6759,16 +6763,16 @@ function parsers.settings_to_hash_tolerant(str,existing)
else
return str
end
- elseif str and str~="" then
+ else
hash=existing or {}
lpegmatch(pattern_b_s,str)
return hash
- else
- return {}
end
end
function parsers.settings_to_hash_strict(str,existing)
- if type(str)=="table" then
+ if not str or str=="" then
+ return nil
+ elseif type(str)=="table" then
if existing then
for k,v in next,str do
existing[k]=v
@@ -6781,8 +6785,6 @@ function parsers.settings_to_hash_strict(str,existing)
hash=existing or {}
lpegmatch(pattern_c_s,str)
return next(hash) and hash
- else
- return nil
end
end
local separator=comma*space^0
@@ -6790,10 +6792,10 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm
local pattern=spaces*Ct(value*(separator*value)^0)
patterns.settings_to_array=pattern
function parsers.settings_to_array(str,strict)
- if type(str)=="table" then
- return str
- elseif not str or str=="" then
+ if not str or str=="" then
return {}
+ elseif type(str)=="table" then
+ return str
elseif strict then
if find(str,"{",1,true) then
return lpegmatch(pattern,str)
@@ -6854,8 +6856,8 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,table.sortedkeys(h)
- omit=omit and table.tohash(omit)
+ local t,tn,s={},0,sortedkeys(h)
+ omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
if not omit or not omit[key] then
@@ -7001,7 +7003,7 @@ function parsers.keq_to_hash(str)
end
local defaultspecification={ separator=",",quote='"' }
function parsers.csvsplitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=specification.quote
local separator=S(separator~="" and separator or ",")
@@ -7025,7 +7027,7 @@ function parsers.csvsplitter(specification)
end
end
function parsers.rfc4180splitter(specification)
- specification=specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification=specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator=specification.separator
local quotechar=P(specification.quote)
local dquotechar=quotechar*quotechar
@@ -7084,9 +7086,9 @@ function parsers.unittoxml(str)
return lpegmatch(pattern,str)
end
local cache={}
-local spaces=lpeg.patterns.space^0
+local spaces=lpegpatterns.space^0
local dummy=function() end
-table.setmetatableindex(cache,function(t,k)
+setmetatableindex(cache,function(t,k)
local separator=P(k)
local value=(1-separator)^0
local pattern=spaces*C(value)*separator^0*Cp()
@@ -14060,7 +14062,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 15681, stripped down to: 11761
+-- original size: 15618, stripped down to: 11629
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -14070,7 +14072,7 @@ if not modules then modules={} end modules ['data-tmp']={
license="see context related readme files"
}
local format,lower,gsub,concat=string.format,string.lower,string.gsub,table.concat
-local concat,serialize,serializetofile=table.concat,table.serialize,table.tofile
+local concat=table.concat
local mkdirs,isdir,isfile=dir.mkdirs,lfs.isdir,lfs.isfile
local addsuffix,is_writable,is_readable=file.addsuffix,file.is_writable,file.is_readable
local formatters=string.formatters
@@ -14339,15 +14341,11 @@ end
local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
- local reduce,simplify=true,true
- if raw then
- reduce,simplify=false,false
- end
data.cache_uuid=os.uuid()
if caches.direct then
- file.savedata(tmaname,serialize(data,true,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- serializetofile(tmaname,data,true,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
@@ -14412,7 +14410,7 @@ function caches.savecontent(cachename,dataname,content,filename)
content=content,
uuid=os.uuid(),
}
- local ok=io.savedata(luaname,serialize(data,true))
+ local ok=io.savedata(luaname,table.serialize(data,true))
if ok then
if trace_locating then
report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
@@ -17938,8 +17936,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 742687
--- stripped bytes : 265759
+-- original bytes : 745618
+-- stripped bytes : 269191
-- end library merge
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index cf38042b6..6cf0725e6 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2015.05.13 23:52}
+\newcontextversion{2015.05.15 11:42}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index cd9ca783d..2c40d33ca 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a775cfa02..da357ca9a 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2015.05.13 23:52}
+\edef\contextversion{2015.05.15 11:42}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua
index 8ee5792cc..9e1515a26 100644
--- a/tex/context/base/data-tmp.lua
+++ b/tex/context/base/data-tmp.lua
@@ -23,7 +23,8 @@ luatools with a recache feature.</p>
--ldx]]--
local format, lower, gsub, concat = string.format, string.lower, string.gsub, table.concat
-local concat, serialize, serializetofile = table.concat, table.serialize, table.tofile
+----- serialize, serializetofile = table.serialize, table.tofile -- overloaded so no local
+local concat = table.concat
local mkdirs, isdir, isfile = dir.mkdirs, lfs.isdir, lfs.isfile
local addsuffix, is_writable, is_readable = file.addsuffix, file.is_writable, file.is_readable
local formatters = string.formatters
@@ -349,15 +350,11 @@ local saveoptions = { compact = true }
function caches.savedata(filepath,filename,data,raw)
local tmaname, tmcname = caches.setluanames(filepath,filename)
- local reduce, simplify = true, true
- if raw then
- reduce, simplify = false, false
- end
data.cache_uuid = os.uuid()
if caches.direct then
- file.savedata(tmaname,serialize(data,true,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- serializetofile(tmaname,data,true,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
@@ -429,7 +426,7 @@ function caches.savecontent(cachename,dataname,content,filename)
content = content,
uuid = os.uuid(),
}
- local ok = io.savedata(luaname,serialize(data,true))
+ local ok = io.savedata(luaname,table.serialize(data,true))
if ok then
if trace_locating then
report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index 440eb34ec..b1bd45304 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -2085,7 +2085,7 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
if not replace then
break
elseif n > l then
--- match = false
+ -- match = false
break
end
else
@@ -2163,7 +2163,7 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
if not replace or replace == finish then
break
elseif n < 1 then
--- match = false
+ -- match = false
break
end
else
@@ -2196,17 +2196,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif f == 2 then
- match = seq[1][32]
--- elseif f > 2 then
--- match = false -- KE ?
else
- for n=f-1,1 do
- if not seq[n][32] then
- match = false
- break
- end
- end
+ match = false
end
end
-- after
@@ -2287,15 +2278,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif s-l == 1 then
- match = seq[s][32]
else
- for n=l+1,s do
- if not seq[n][32] then
- match = false
- break
- end
- end
+ match = false
end
end
end
diff --git a/tex/context/base/font-otp.lua b/tex/context/base/font-otp.lua
index 63e4184c1..ebf36ed45 100644
--- a/tex/context/base/font-otp.lua
+++ b/tex/context/base/font-otp.lua
@@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['font-otp'] = {
-- todo: pack math (but not that much to share)
--
-- pitfall 5.2: hashed tables can suddenly become indexed with nil slots
+--
+-- unless we sort all hashes we can get a different pack order (no big deal but size can differ)
local next, type = next, type
local sort, concat = table.sort, table.concat
diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi
index 673cf25ae..5924a3033 100644
--- a/tex/context/base/font-sty.mkvi
+++ b/tex/context/base/font-sty.mkvi
@@ -352,7 +352,7 @@
\def\font_styles_define_style_instance[#instance][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever]
{\iffirstargument
- \ifcsname#1\endcsname\else\font_styles_define_style_collection[#instance]\fi
+ \ifcsname#instance\endcsname\else\font_styles_define_style_collection[#instance]\fi
\fi
\iffourthargument
\setvalue{\??stylecollection#instance:#2:#3}{#4}%
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 97e0441eb..b02f210cb 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -39,7 +39,7 @@ end
function table.keys(t)
if t then
local keys, k = { }, 0
- for key, _ in next, t do
+ for key in next, t do
k = k + 1
keys[k] = key
end
@@ -50,44 +50,126 @@ function table.keys(t)
end
-- local function compare(a,b)
--- local ta, tb = type(a), type(b) -- needed, else 11 < 2
--- if ta == tb then
+-- local ta = type(a) -- needed, else 11 < 2
+-- local tb = type(b) -- needed, else 11 < 2
+-- if ta == tb and ta == "number" then
-- return a < b
-- else
-- return tostring(a) < tostring(b) -- not that efficient
-- end
-- end
+-- local function compare(a,b)
+-- local ta = type(a) -- needed, else 11 < 2
+-- local tb = type(b) -- needed, else 11 < 2
+-- if ta == tb and (ta == "number" or ta == "string") then
+-- return a < b
+-- else
+-- return tostring(a) < tostring(b) -- not that efficient
+-- end
+-- end
+
+-- local function sortedkeys(tab)
+-- if tab then
+-- local srt, category, s = { }, 0, 0 -- 0=unknown 1=string, 2=number 3=mixed
+-- for key in next, tab do
+-- s = s + 1
+-- srt[s] = key
+-- if category == 3 then
+-- -- no further check
+-- else
+-- local tkey = type(key)
+-- if tkey == "string" then
+-- category = (category == 2 and 3) or 1
+-- elseif tkey == "number" then
+-- category = (category == 1 and 3) or 2
+-- else
+-- category = 3
+-- end
+-- end
+-- end
+-- if category == 0 or category == 3 then
+-- sort(srt,compare)
+-- else
+-- sort(srt)
+-- end
+-- return srt
+-- else
+-- return { }
+-- end
+-- end
+
+-- local function compare(a,b)
+-- local ta = type(a) -- needed, else 11 < 2
+-- local tb = type(b) -- needed, else 11 < 2
+-- if ta == tb and (ta == "number" or ta == "string") then
+-- return a < b
+-- else
+-- return tostring(a) < tostring(b) -- not that efficient
+-- end
+-- end
+
+-- local function compare(a,b)
+-- local ta = type(a) -- needed, else 11 < 2
+-- if ta == "number" or ta == "string" then
+-- local tb = type(b) -- needed, else 11 < 2
+-- if ta == tb then
+-- return a < b
+-- end
+-- end
+-- return tostring(a) < tostring(b) -- not that efficient
+-- end
+
local function compare(a,b)
local ta = type(a) -- needed, else 11 < 2
- local tb = type(b) -- needed, else 11 < 2
- if ta == tb and ta == "number" then
- return a < b
- else
- return tostring(a) < tostring(b) -- not that efficient
+ if ta == "number" then
+ local tb = type(b) -- needed, else 11 < 2
+ if ta == tb then
+ return a < b
+ elseif tb == "string" then
+ return tostring(a) < b
+ end
+ elseif ta == "string" then
+ local tb = type(b) -- needed, else 11 < 2
+ if ta == tb then
+ return a < b
+ else
+ return a < tostring(b)
+ end
end
+ return tostring(a) < tostring(b) -- not that efficient
end
local function sortedkeys(tab)
if tab then
local srt, category, s = { }, 0, 0 -- 0=unknown 1=string, 2=number 3=mixed
- for key,_ in next, tab do
+ for key in next, tab do
s = s + 1
srt[s] = key
if category == 3 then
-- no further check
+ elseif category == 1 then
+ if type(key) ~= "string" then
+ category = 3
+ end
+ elseif category == 2 then
+ if type(key) ~= "number" then
+ category = 3
+ end
else
local tkey = type(key)
if tkey == "string" then
- category = (category == 2 and 3) or 1
+ category = 1
elseif tkey == "number" then
- category = (category == 1 and 3) or 2
+ category = 2
else
category = 3
end
end
end
- if category == 0 or category == 3 then
+ if s < 2 then
+ -- nothing to sort
+ elseif category == 3 then
sort(srt,compare)
else
sort(srt)
@@ -101,13 +183,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt, s = { }, 0
- for key,_ in next, tab do
+ for key in next, tab do
if type(key) == "string" then
s = s + 1
srt[s] = key
end
end
- sort(srt)
+ if s > 1 then
+ sort(srt)
+ end
return srt
else
return { }
@@ -117,13 +201,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt, s = { }, 0
- for key,_ in next, tab do
+ for key in next, tab do
if type(key) == "number" then
s = s + 1
srt[s] = key
end
end
- sort(srt)
+ if s > 1 then
+ sort(srt)
+ end
return srt
else
return { }
@@ -133,13 +219,15 @@ end
local function sortedhashkeys(tab,cmp) -- fast one
if tab then
local srt, s = { }, 0
- for key,_ in next, tab do
+ for key in next, tab do
if key then
s= s + 1
srt[s] = key
end
end
- sort(srt,cmp)
+ if s > 1 then
+ sort(srt,cmp)
+ end
return srt
else
return { }
@@ -149,7 +237,7 @@ end
function table.allkeys(t)
local keys = { }
for k, v in next, t do
- for k, v in next, v do
+ for k in next, v do
keys[k] = true
end
end
@@ -172,19 +260,21 @@ local function sortedhash(t,cmp)
else
s = sortedkeys(t) -- the robust one
end
- local n = 0
local m = #s
- local function kv() -- (s)
- if n < m then
- n = n + 1
- local k = s[n]
- return k, t[k]
+ if m == 1 then
+ return next, t
+ elseif m > 0 then
+ local n = 0
+ return function()
+ if n < m then
+ n = n + 1
+ local k = s[n]
+ return k, t[k]
+ end
end
end
- return kv -- , s
- else
- return nothing
end
+ return nothing
end
table.sortedhash = sortedhash
@@ -328,7 +418,7 @@ end
local function copy(t, tables) -- taken from lua wiki, slightly adapted
tables = tables or { }
- local tcopy = {}
+ local tcopy = { }
if not tables[t] then
tables[t] = tcopy
end
@@ -388,7 +478,7 @@ function table.fromhash(t)
return hsh
end
-local noquotes, hexify, handle, reduce, compact, inline, functions
+local noquotes, hexify, handle, compact, inline, functions
local reserved = table.tohash { -- intercept a language inconvenience: no reserved words as key
'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'if',
@@ -396,33 +486,67 @@ local reserved = table.tohash { -- intercept a language inconvenience: no reserv
'NaN', 'goto',
}
+-- local function simple_table(t)
+-- if #t > 0 then
+-- local n = 0
+-- for _,v in next, t do
+-- n = n + 1
+-- end
+-- if n == #t then
+-- local tt, nt = { }, 0
+-- for i=1,#t do
+-- local v = t[i]
+-- local tv = type(v)
+-- if tv == "number" then
+-- nt = nt + 1
+-- if hexify then
+-- tt[nt] = format("0x%X",v)
+-- else
+-- tt[nt] = tostring(v) -- tostring not needed
+-- end
+-- elseif tv == "string" then
+-- nt = nt + 1
+-- tt[nt] = format("%q",v)
+-- elseif tv == "boolean" then
+-- nt = nt + 1
+-- tt[nt] = v and "true" or "false"
+-- else
+-- return nil
+-- end
+-- end
+-- return tt
+-- end
+-- end
+-- return nil
+-- end
+
local function simple_table(t)
- if #t > 0 then
+ local nt = #t
+ if nt > 0 then
local n = 0
for _,v in next, t do
n = n + 1
+ -- if type(v) == "table" then
+ -- return nil
+ -- end
end
- if n == #t then
- local tt, nt = { }, 0
- for i=1,#t do
+ if n == nt then
+ local tt = { }
+ for i=1,nt do
local v = t[i]
local tv = type(v)
if tv == "number" then
- nt = nt + 1
if hexify then
- tt[nt] = format("0x%X",v)
+ tt[i] = format("0x%X",v)
else
- tt[nt] = tostring(v) -- tostring not needed
+ tt[i] = tostring(v) -- tostring not needed
end
elseif tv == "string" then
- nt = nt + 1
- tt[nt] = format("%q",v)
+ tt[i] = format("%q",v)
elseif tv == "boolean" then
- nt = nt + 1
- tt[nt] = v and "true" or "false"
+ tt[i] = v and "true" or "false"
else
- tt = nil
- break
+ return nil
end
end
return tt
@@ -480,14 +604,6 @@ local function do_serialize(root,name,depth,level,indexed)
end
-- we could check for k (index) being number (cardinal)
if root and next(root) ~= nil then
- -- local first, last = nil, 0 -- #root cannot be trusted here (will be ok in 5.2 when ipairs is gone)
- -- if compact then
- -- -- NOT: for k=1,#root do (we need to quit at nil)
- -- for k,v in ipairs(root) do -- can we use next?
- -- if not first then first = k end
- -- last = last + 1
- -- end
- -- end
local first, last = nil, 0
if compact then
last = #root
@@ -503,12 +619,10 @@ local function do_serialize(root,name,depth,level,indexed)
end
local sk = sortedkeys(root)
for i=1,#sk do
- local k = sk[i]
- local v = root[k]
- --~ if v == root then
- -- circular
- --~ else
- local tv, tk = type(v), type(k)
+ local k = sk[i]
+ local v = root[k]
+ local tv = type(v)
+ local tk = type(k)
if compact and first and tk == "number" and k >= first and k <= last then
if tv == "number" then
if hexify then
@@ -517,11 +631,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v)) -- %.99g
end
elseif tv == "string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv == "table" then
if next(v) == nil then
handle(format("%s {},",depth))
@@ -577,34 +687,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv == "string" then
- if reduce and tonumber(v) then
- if tk == "number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk == "boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk == "number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk == "number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk == "boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv == "table" then
if next(v) == nil then
@@ -690,7 +784,6 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%q]=%q,",depth,k,tostring(v)))
end
end
- --~ end
end
end
if level > 0 then
@@ -707,7 +800,6 @@ local function serialize(_handle,root,name,specification) -- handle wins
noquotes = specification.noquotes
hexify = specification.hexify
handle = _handle or specification.handle or print
- reduce = specification.reduce or false
functions = specification.functions
compact = specification.compact
inline = specification.inline and compact
@@ -724,7 +816,6 @@ local function serialize(_handle,root,name,specification) -- handle wins
noquotes = false
hexify = false
handle = _handle or print
- reduce = false
compact = true
inline = true
functions = true
@@ -798,15 +889,6 @@ end
table.tohandle = serialize
--- sometimes tables are real use (zapfino extra pro is some 85M) in which
--- case a stepwise serialization is nice; actually, we could consider:
---
--- for line in table.serializer(root,name,reduce,noquotes) do
--- ...(line)
--- end
---
--- so this is on the todo list
-
local maxtab = 2*1024
function table.tofile(filename,root,name,specification)
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 78e8b3da7..0444f2f91 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 2db0c3406..96ab490b7 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/typo-itc.lua b/tex/context/base/typo-itc.lua
index c6528eee8..e4873f606 100644
--- a/tex/context/base/typo-itc.lua
+++ b/tex/context/base/typo-itc.lua
@@ -39,6 +39,7 @@ local getfont = nuts.getfont
local getchar = nuts.getchar
local getattr = nuts.getattr
local setattr = nuts.setattr
+local setfield = nuts.setfield
local insert_node_after = nuts.insert_after
local delete_node = nuts.delete
diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua
index ea34c2c27..a3c1c6f8f 100644
--- a/tex/context/base/util-prs.lua
+++ b/tex/context/base/util-prs.lua
@@ -21,6 +21,8 @@ parsers.patterns = patterns
local setmetatableindex = table.setmetatableindex
local sortedhash = table.sortedhash
+local sortedkeys = table.sortedkeys
+local tohash = table.tohash
-- we share some patterns
@@ -94,9 +96,7 @@ patterns.settings_to_hash_b = pattern_b_s
patterns.settings_to_hash_c = pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if type(str) == "table" then
- return set
- elseif how == "strict" then
+ if how == "strict" then
return (pattern_c/set)^1
elseif how == "tolerant" then
return (pattern_b/set)^1
@@ -106,7 +106,9 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
function parsers.settings_to_hash(str,existing)
- if type(str) == "table" then
+ if not str or str == "" then
+ return { }
+ elseif type(str) == "table" then
if existing then
for k, v in next, str do
existing[k] = v
@@ -115,17 +117,17 @@ function parsers.settings_to_hash(str,existing)
else
return str
end
- elseif str and str ~= "" then
+ else
hash = existing or { }
lpegmatch(pattern_a_s,str)
return hash
- else
- return { }
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if type(str) == "table" then
+ if not str or str == "" then
+ return { }
+ elseif type(str) == "table" then
if existing then
for k, v in next, str do
existing[k] = v
@@ -134,17 +136,17 @@ function parsers.settings_to_hash_tolerant(str,existing)
else
return str
end
- elseif str and str ~= "" then
+ else
hash = existing or { }
lpegmatch(pattern_b_s,str)
return hash
- else
- return { }
end
end
function parsers.settings_to_hash_strict(str,existing)
- if type(str) == "table" then
+ if not str or str == "" then
+ return nil
+ elseif type(str) == "table" then
if existing then
for k, v in next, str do
existing[k] = v
@@ -157,8 +159,6 @@ function parsers.settings_to_hash_strict(str,existing)
hash = existing or { }
lpegmatch(pattern_c_s,str)
return next(hash) and hash
- else
- return nil
end
end
@@ -174,10 +174,10 @@ patterns.settings_to_array = pattern
-- we could use a weak table as cache
function parsers.settings_to_array(str,strict)
- if type(str) == "table" then
- return str
- elseif not str or str == "" then
+ if not str or str == "" then
return { }
+ elseif type(str) == "table" then
+ return str
elseif strict then
if find(str,"{",1,true) then
return lpegmatch(pattern,str)
@@ -262,8 +262,8 @@ end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t, tn, s = { }, 0, table.sortedkeys(h)
- omit = omit and table.tohash(omit)
+ local t, tn, s = { }, 0, sortedkeys(h)
+ omit = omit and tohash(omit)
for i=1,#s do
local key = s[i]
if not omit or not omit[key] then
@@ -478,7 +478,7 @@ local defaultspecification = { separator = ",", quote = '"' }
-- database module
function parsers.csvsplitter(specification)
- specification = specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification = specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator = specification.separator
local quotechar = specification.quote
local separator = S(separator ~= "" and separator or ",")
@@ -517,7 +517,7 @@ end
-- local list, names = mycsvsplitter(crap) inspect(list) inspect(names)
function parsers.rfc4180splitter(specification)
- specification = specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification = specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator = specification.separator --> rfc: COMMA
local quotechar = P(specification.quote) --> DQUOTE
local dquotechar = quotechar * quotechar --> 2DQUOTE
@@ -602,10 +602,10 @@ end
-- print(utilities.parsers.unittotex("10^-32 %"),utilities.parsers.unittoxml("10^32 %"))
local cache = { }
-local spaces = lpeg.patterns.space^0
+local spaces = lpegpatterns.space^0
local dummy = function() end
-table.setmetatableindex(cache,function(t,k)
+setmetatableindex(cache,function(t,k)
local separator = P(k)
local value = (1-separator)^0
local pattern = spaces * C(value) * separator^0 * Cp()
diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua
index 5eae0d5f6..618f34cee 100644
--- a/tex/context/base/util-tab.lua
+++ b/tex/context/base/util-tab.lua
@@ -11,7 +11,7 @@ utilities.tables = utilities.tables or { }
local tables = utilities.tables
local format, gmatch, gsub, sub = string.format, string.gmatch, string.gsub, string.sub
-local concat, insert, remove = table.concat, table.insert, table.remove
+local concat, insert, remove, sort = table.concat, table.insert, table.remove, table.sort
local setmetatable, getmetatable, tonumber, tostring = setmetatable, getmetatable, tonumber, tostring
local type, next, rawset, tonumber, tostring, load, select = type, next, rawset, tonumber, tostring, load, select
local lpegmatch, P, Cs, Cc = lpeg.match, lpeg.P, lpeg.Cs, lpeg.Cc
@@ -571,8 +571,42 @@ function table.serialize(root,name,specification)
local t -- = { }
local n = 1
+-- local function simple_table(t)
+-- local ts = #t
+-- if ts > 0 then
+-- local n = 0
+-- for _, v in next, t do
+-- n = n + 1
+-- if type(v) == "table" then
+-- return nil
+-- end
+-- end
+-- if n == ts then
+-- local tt = { }
+-- local nt = 0
+-- for i=1,ts do
+-- local v = t[i]
+-- local tv = type(v)
+-- nt = nt + 1
+-- if tv == "number" then
+-- tt[nt] = v
+-- elseif tv == "string" then
+-- tt[nt] = format("%q",v) -- f_string(v)
+-- elseif tv == "boolean" then
+-- tt[nt] = v and "true" or "false"
+-- else
+-- return nil
+-- end
+-- end
+-- return tt
+-- end
+-- end
+-- return nil
+-- end
+
local function simple_table(t)
- if #t > 0 then
+ local nt = #t
+ if nt > 0 then
local n = 0
for _, v in next, t do
n = n + 1
@@ -580,19 +614,17 @@ function table.serialize(root,name,specification)
return nil
end
end
- if n == #t then
+ if n == nt then
local tt = { }
- local nt = 0
- for i=1,#t do
+ for i=1,nt do
local v = t[i]
local tv = type(v)
- nt = nt + 1
if tv == "number" then
- tt[nt] = v
+ tt[i] = v -- not needed tostring(v)
elseif tv == "string" then
- tt[nt] = format("%q",v) -- f_string(v)
+ tt[i] = format("%q",v) -- f_string(v)
elseif tv == "boolean" then
- tt[nt] = v and "true" or "false"
+ tt[i] = v and "true" or "false"
else
return nil
end
@@ -636,13 +668,13 @@ function table.serialize(root,name,specification)
if last > 0 then
first = 1
end
- local sk = sortedkeys(root) -- inline fast version?
+ local sk = sortedkeys(root) -- inline fast version?\
for i=1,#sk do
local k = sk[i]
local v = root[k]
local tv = type(v)
local tk = type(k)
- if first and tk == "number" and k >= first and k <= last then
+ if first and tk == "number" and k <= last and k >= first then
if tv == "number" then
n = n + 1 t[n] = f_val_num(depth,v)
elseif tv == "string" then
@@ -680,11 +712,11 @@ function table.serialize(root,name,specification)
elseif tv == "table" then
if next(v) == nil then
if tk == "number" then
- n = n + 1 t[n] = f_key_num_value_not(depth,k,v)
+ n = n + 1 t[n] = f_key_num_value_not(depth,k)
elseif tk == "string" then
- n = n + 1 t[n] = f_key_str_value_not(depth,k,v)
+ n = n + 1 t[n] = f_key_str_value_not(depth,k)
elseif tk == "boolean" then
- n = n + 1 t[n] = f_key_boo_value_not(depth,k,v)
+ n = n + 1 t[n] = f_key_boo_value_not(depth,k)
end
else
local st = simple_table(v)
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 0e0e5ebba..afd01aae2 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 05/13/15 23:52:22
+-- merge date : 05/15/15 11:42:33
do -- begin closure to overcome local limits and interference
@@ -1041,7 +1041,7 @@ end
function table.keys(t)
if t then
local keys,k={},0
- for key,_ in next,t do
+ for key in next,t do
k=k+1
keys[k]=key
end
@@ -1052,32 +1052,51 @@ function table.keys(t)
end
local function compare(a,b)
local ta=type(a)
- local tb=type(b)
- if ta==tb and ta=="number" then
- return a<b
- else
- return tostring(a)<tostring(b)
+ if ta=="number" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ elseif tb=="string" then
+ return tostring(a)<b
+ end
+ elseif ta=="string" then
+ local tb=type(b)
+ if ta==tb then
+ return a<b
+ else
+ return a<tostring(b)
+ end
end
+ return tostring(a)<tostring(b)
end
local function sortedkeys(tab)
if tab then
local srt,category,s={},0,0
- for key,_ in next,tab do
+ for key in next,tab do
s=s+1
srt[s]=key
if category==3 then
+ elseif category==1 then
+ if type(key)~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if type(key)~="number" then
+ category=3
+ end
else
local tkey=type(key)
if tkey=="string" then
- category=(category==2 and 3) or 1
+ category=1
elseif tkey=="number" then
- category=(category==1 and 3) or 2
+ category=2
else
category=3
end
end
end
- if category==0 or category==3 then
+ if s<2 then
+ elseif category==3 then
sort(srt,compare)
else
sort(srt)
@@ -1090,13 +1109,15 @@ end
local function sortedhashonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="string" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1105,13 +1126,15 @@ end
local function sortedindexonly(tab)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if type(key)=="number" then
s=s+1
srt[s]=key
end
end
- sort(srt)
+ if s>1 then
+ sort(srt)
+ end
return srt
else
return {}
@@ -1120,13 +1143,15 @@ end
local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
- for key,_ in next,tab do
+ for key in next,tab do
if key then
s=s+1
srt[s]=key
end
end
- sort(srt,cmp)
+ if s>1 then
+ sort(srt,cmp)
+ end
return srt
else
return {}
@@ -1135,7 +1160,7 @@ end
function table.allkeys(t)
local keys={}
for k,v in next,t do
- for k,v in next,v do
+ for k in next,v do
keys[k]=true
end
end
@@ -1154,19 +1179,21 @@ local function sortedhash(t,cmp)
else
s=sortedkeys(t)
end
- local n=0
local m=#s
- local function kv()
- if n<m then
- n=n+1
- local k=s[n]
- return k,t[k]
+ if m==1 then
+ return next,t
+ elseif m>0 then
+ local n=0
+ return function()
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
end
- return kv
- else
- return nothing
end
+ return nothing
end
table.sortedhash=sortedhash
table.sortedpairs=sortedhash
@@ -1308,39 +1335,36 @@ function table.fromhash(t)
end
return hsh
end
-local noquotes,hexify,handle,reduce,compact,inline,functions
+local noquotes,hexify,handle,compact,inline,functions
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',
}
local function simple_table(t)
- if #t>0 then
+ local nt=#t
+ if nt>0 then
local n=0
for _,v in next,t do
n=n+1
end
- if n==#t then
- local tt,nt={},0
- for i=1,#t do
+ if n==nt then
+ local tt={}
+ for i=1,nt do
local v=t[i]
local tv=type(v)
if tv=="number" then
- nt=nt+1
if hexify then
- tt[nt]=format("0x%X",v)
+ tt[i]=format("0x%X",v)
else
- tt[nt]=tostring(v)
+ tt[i]=tostring(v)
end
elseif tv=="string" then
- nt=nt+1
- tt[nt]=format("%q",v)
+ tt[i]=format("%q",v)
elseif tv=="boolean" then
- nt=nt+1
- tt[nt]=v and "true" or "false"
+ tt[i]=v and "true" or "false"
else
- tt=nil
- break
+ return nil
end
end
return tt
@@ -1394,7 +1418,8 @@ local function do_serialize(root,name,depth,level,indexed)
for i=1,#sk do
local k=sk[i]
local v=root[k]
- local tv,tk=type(v),type(k)
+ local tv=type(v)
+ local tk=type(k)
if compact and first and tk=="number" and k>=first and k<=last then
if tv=="number" then
if hexify then
@@ -1403,11 +1428,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %s,",depth,v))
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- handle(format("%s %s,",depth,v))
- else
- handle(format("%s %q,",depth,v))
- end
+ handle(format("%s %q,",depth,v))
elseif tv=="table" then
if next(v)==nil then
handle(format("%s {},",depth))
@@ -1463,34 +1484,18 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="string" then
- if reduce and tonumber(v) then
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%s,",depth,k,v))
- else
- handle(format("%s [%s]=%s,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v))
+ if tk=="number" then
+ if hexify then
+ handle(format("%s [0x%X]=%q,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk=="boolean" then
+ handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+ handle(format("%s %s=%q,",depth,k,v))
else
- if tk=="number" then
- if hexify then
- handle(format("%s [0x%X]=%q,",depth,k,v))
- else
- handle(format("%s [%s]=%q,",depth,k,v))
- end
- elseif tk=="boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%q,",depth,k,v))
- else
- handle(format("%s [%q]=%q,",depth,k,v))
- end
+ handle(format("%s [%q]=%q,",depth,k,v))
end
elseif tv=="table" then
if next(v)==nil then
@@ -1587,7 +1592,6 @@ local function serialize(_handle,root,name,specification)
noquotes=specification.noquotes
hexify=specification.hexify
handle=_handle or specification.handle or print
- reduce=specification.reduce or false
functions=specification.functions
compact=specification.compact
inline=specification.inline and compact
@@ -1604,7 +1608,6 @@ local function serialize(_handle,root,name,specification)
noquotes=false
hexify=false
handle=_handle or print
- reduce=false
compact=true
inline=true
functions=true
@@ -12719,15 +12722,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif f==2 then
- match=seq[1][32]
else
- for n=f-1,1 do
- if not seq[n][32] then
- match=false
- break
- end
- end
+ match=false
end
end
if match and s>l then
@@ -12777,15 +12773,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif s-l==1 then
- match=seq[s][32]
else
- for n=l+1,s do
- if not seq[n][32] then
- match=false
- break
- end
- end
+ match=false
end
end
end
diff --git a/tex/generic/context/luatex/luatex-fonts-otn.lua b/tex/generic/context/luatex/luatex-fonts-otn.lua
index 343e1826e..dd3aa6153 100644
--- a/tex/generic/context/luatex/luatex-fonts-otn.lua
+++ b/tex/generic/context/luatex/luatex-fonts-otn.lua
@@ -376,7 +376,7 @@ local function copy_glyph(g) -- next and prev are untouched !
end
end
---
+--
-- start is a mark and we need to keep that one
@@ -1834,15 +1834,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif f == 2 then
- match = seq[1][32]
else
- for n=f-1,1 do
- if not seq[n][32] then
- match = false
- break
- end
- end
+ match = false
end
end
-- after
@@ -1895,15 +1888,8 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
break
end
end
- elseif s-l == 1 then
- match = seq[s][32]
else
- for n=l+1,s do
- if not seq[n][32] then
- match = false
- break
- end
- end
+ match = false
end
end
end