summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-19 21:26:37 +0000
committerKarl Berry <karl@freefriends.org>2019-05-19 21:26:37 +0000
commit5653ce727bbbbd072f5c4e6a2d8b16a3fb4ba86f (patch)
tree82c8175883c03586d73d382ba4c2883405f60613 /Master/texmf-dist/tex/luatex
parent556dfa7ef108ed2946da8b8f32106f881d064ce9 (diff)
lualibs (19may19)
git-svn-id: svn://tug.org/texlive/trunk@51167 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua209
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua31
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua164
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua77
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua13
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua21
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua104
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua43
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua2
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua10
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua14
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua87
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua41
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua30
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua2
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs.lua4
19 files changed, 542 insertions, 322 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
index 2c5215eb362..bc4e3290873 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-basic-merged.lua
-- parent file : lualibs-basic.lua
--- merge date : Fri Feb 22 23:27:00 2019
+-- merge date : Sat May 18 17:39:21 2019
do -- begin closure to overcome local limits and interference
@@ -119,8 +119,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
end -- closure
@@ -1362,7 +1361,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1372,7 +1371,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1385,7 +1385,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -1416,27 +1417,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
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
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -1453,7 +1457,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -1470,7 +1475,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -1487,7 +1493,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -1563,7 +1570,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -1592,7 +1601,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -1624,7 +1634,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -1671,7 +1683,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -1772,7 +1785,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -2031,7 +2045,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -2045,13 +2060,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -2153,8 +2170,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -2254,7 +2275,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2367,7 +2389,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -3234,17 +3258,8 @@ local launchers={
unix="xdg-open %s &> /dev/null &",
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
-end
-if not os.times then
- function os.times()
- return {
- utime=os.gettimeofday(),
- stime=0,
- cutime=0,
- cstime=0,
- }
- end
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
end
local gettimeofday=os.gettimeofday or os.clock
os.gettimeofday=gettimeofday
@@ -3696,40 +3711,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -4114,13 +4134,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs=0
- for name in walkdir(usedpath) do
+ for name,mode,size,time in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode=="directory" then
if dirs then
@@ -4156,10 +4178,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs=0
local noffiles=#result
- for name,a in walkdir(usedpath) do
+ for name,mode in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
noffiles=noffiles+1
@@ -4210,7 +4234,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path=path..'/'
end
- for name in scanner,first do
+ for name in scanner,first do
if name=="." then
elseif name==".." then
else
@@ -4301,10 +4325,12 @@ local function globfiles(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if recurse then
globfiles(path.."/"..name,recurse,func,files)
@@ -4327,10 +4353,12 @@ local function globdirs(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if not func or func(name) then
noffiles=noffiles+1
@@ -4511,8 +4539,7 @@ local stack={}
function dir.push(newdir)
local curdir=currentdir()
insert(stack,curdir)
- if newdir and newdir~="" then
- chdir(newdir)
+ if newdir and newdir~="" and chdir(newdir) then
return newdir
else
return curdir
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
index 19cbe26bf2d..40431c79e84 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
@@ -29,8 +29,8 @@ local loadmodule = lualibs.loadmodule
local lualibs_basic_module = {
name = "lualibs-basic",
- version = 2.64,
- date = "2019-02-14",
+ version = 2.65,
+ date = "2019-05-18",
description = "ConTeXt Lua libraries -- basic collection.",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua
index b0b2c52836a..325039cb1e6 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua
@@ -91,13 +91,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs = 0
- for name in walkdir(usedpath) do
+ for name, mode, size, time in walkdir(usedpath) do
if name ~= "." and name ~= ".." then
local full = path .. name
- local mode = attributes(full,'mode')
+ if mode == nil then
+ mode = attributes(full,'mode')
+ end
if mode == 'file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode == "directory" then
if dirs then
@@ -134,10 +136,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs = 0
local noffiles = #result
- for name, a in walkdir(usedpath) do
+ for name, mode in walkdir(usedpath) do
if name ~= "." and name ~= ".." then
local full = path .. name
- local mode = attributes(full,'mode')
+ if mode == nil then
+ mode = attributes(full,'mode')
+ end
if mode == 'file' then
if not patt or find(full,patt) then
noffiles = noffiles + 1
@@ -193,7 +197,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path = path .. '/'
end
- for name in scanner, first do
+ for name in scanner, first do -- cna be optimized
if name == "." then
-- skip
elseif name == ".." then
@@ -321,11 +325,13 @@ local function globfiles(path,recurse,func,files) -- func == pattern or function
end
files = files or { }
local noffiles = #files
- for name in walkdir(path) do
+ for name, mode in walkdir(path) do
if find(name,"^%.") then
--- skip
else
- local mode = attributes(name,'mode')
+ if mode == nil then
+ mode = attributes(name,'mode')
+ end
if mode == "directory" then
if recurse then
globfiles(path .. "/" .. name,recurse,func,files)
@@ -350,11 +356,13 @@ local function globdirs(path,recurse,func,files) -- func == pattern or function
end
files = files or { }
local noffiles = #files
- for name in walkdir(path) do
+ for name, mode in walkdir(path) do
if find(name,"^%.") then
--- skip
else
- local mode = attributes(name,'mode')
+ if mode == nil then
+ mode = attributes(name,'mode')
+ end
if mode == "directory" then
if not func or func(name) then
noffiles = noffiles + 1
@@ -597,8 +605,7 @@ local stack = { }
function dir.push(newdir)
local curdir = currentdir()
insert(stack,curdir)
- if newdir and newdir ~= "" then
- chdir(newdir)
+ if newdir and newdir ~= "" and chdir(newdir) then
return newdir
else
return curdir
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
index 229a713c401..afd99067725 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-extended-merged.lua
-- parent file : lualibs-extended.lua
--- merge date : Fri Feb 22 23:26:50 2019
+-- merge date : Sat May 18 17:39:12 2019
do -- begin closure to overcome local limits and interference
@@ -18,7 +18,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -357,8 +356,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -445,7 +444,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -801,9 +800,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -835,6 +834,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- closure
@@ -1154,7 +1174,8 @@ local formatters=string.formatters
local utftoeight=utf.toeight
local splitter=lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast)
- local composed,t=nil,{}
+ local composed=nil
+ local t={}
local snippets=lpegmatch(splitter,target)
for i=1,#snippets-(nolast and 1 or 0) do
local name=snippets[i]
@@ -1595,18 +1616,19 @@ local function serialize(root,name,specification)
end
if root and next(root)~=nil then
local first=nil
- local last=0
- last=#root
- for k=1,last do
- if rawget(root,k)==nil then
- last=k-1
- break
- end
- end
+ local last=#root
if last>0 then
- first=1
+ for k=1,last do
+ if rawget(root,k)==nil then
+ last=k-1
+ break
+ end
+ end
+ if last>0 then
+ first=1
+ end
end
- local sk=sortedkeys(root)
+ local sk=sortedkeys(root)
for i=1,#sk do
local k=sk[i]
local v=root[k]
@@ -1980,7 +2002,7 @@ local sortedhash=table.sortedhash
local sortedkeys=table.sortedkeys
local tohash=table.tohash
local hashes={}
-utilities.parsers.hashes=hashes
+parsers.hashes=hashes
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -2200,7 +2222,9 @@ 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,sortedkeys(h)
+ local t={}
+ local tn=0
+ local s=sortedkeys(h)
omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
@@ -2238,7 +2262,7 @@ function parsers.array_to_string(a,separator)
end
end
local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or {}
end
hashes.settings_to_set=table.setmetatableindex(function(t,k)
@@ -2248,7 +2272,8 @@ hashes.settings_to_set=table.setmetatableindex(function(t,k)
end)
getmetatable(hashes.settings_to_set).__mode="kv"
function parsers.simple_hash_to_string(h,separator)
- local t,tn={},0
+ local t={}
+ local tn=0
for k,v in sortedhash(h) do
if v then
tn=tn+1
@@ -2260,11 +2285,11 @@ end
local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1)
local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
local splitter=setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or {}) or {}
end
local splitter=lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or {}
end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
@@ -2277,7 +2302,8 @@ local function repeater(n,str)
if n==1 then
return unpack(s)
else
- local t,tn={},0
+ local t={}
+ local tn=0
for i=1,n do
for j=1,#s do
tn=tn+1
@@ -2448,7 +2474,7 @@ setmetatableindex(cache,function(t,k)
return pattern
end)
local commalistiterator=cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n=#str
if n==0 then
return dummy
@@ -2490,10 +2516,10 @@ end
local name=C((1-S(", "))^1)
local parser=(Carg(1)*name/initialize)*(S(", ")^1*(Carg(1)*name/fetch))^0
local merge=Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time=os.runtime()
end
@@ -2510,13 +2536,24 @@ local apply=P("->")
local method=C((1-apply)^1)
local token=lbrace*C((1-rbrace)^1)*rbrace+C(anything^1)
local pattern=spacing*(method*spacing*apply+Carg(1))*spacing*token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
return default or false,""
end
end
+local p_year=lpegpatterns.digit^4/tonumber
+local pattern=Cf(Ct("")*(
+ (Cg(Cc("year")*p_year)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("day")*cardinal)
+ )+(Cg(Cc("day")*cardinal)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("year")*p_year)
+ )
+ )*P(" ")*Cg(Cc("hour")*cardinal)*P(":")*Cg(Cc("min")*cardinal)*(P(":")*Cg(Cc("sec")*cardinal))^-1
+,rawset)
+lpegpatterns.splittime=pattern
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
end -- closure
@@ -2677,14 +2714,19 @@ function dimen(a)
end
end
function string.todimen(str)
- if type(str)=="number" then
+ local t=type(str)
+ if t=="number" then
return str
else
local k=known[str]
if not k then
- local value,unit=lpegmatch(dimenpair,str)
- if value and unit then
- k=value/unit
+ if t=="string" then
+ local value,unit=lpegmatch(dimenpair,str)
+ if value and unit then
+ k=value/unit
+ else
+ k=0
+ end
else
k=0
end
@@ -2863,7 +2905,7 @@ statistics.enable=true
statistics.threshold=0.01
local statusinfo,n,registered,timers={},0,{},{}
setmetatableindex(timers,function(t,k)
- local v={ timing=0,loadtime=0 }
+ local v={ timing=0,loadtime=0,offset=0 }
t[k]=v
return v
end)
@@ -2871,7 +2913,7 @@ local function hastiming(instance)
return instance and timers[instance]
end
local function resettiming(instance)
- timers[instance or "notimer"]={ timing=0,loadtime=0 }
+ timers[instance or "notimer"]={ timing=0,loadtime=0,offset=0 }
end
local ticks=clock
local seconds=function(n) return n or 0 end
@@ -2909,12 +2951,26 @@ local function stoptiming(instance)
end
return 0
end
+local function benchmarktimer(instance)
+ local timer=timers[instance or "notimer"]
+ local it=timer.timing
+ if it>1 then
+ timer.timing=it-1
+ else
+ local starttime=timer.starttime
+ if starttime and starttime>0 then
+ timer.offset=ticks()-starttime
+ else
+ timer.offset=0
+ end
+ end
+end
local function elapsed(instance)
if type(instance)=="number" then
return instance
else
local timer=timers[instance or "notimer"]
- return timer and seconds(timer.loadtime) or 0
+ return timer and seconds(timer.loadtime-2*(timer.offset or 0)) or 0
end
end
local function currenttime(instance)
@@ -2927,7 +2983,7 @@ local function currenttime(instance)
else
local starttime=timer.starttime
if starttime and starttime>0 then
- return seconds(timer.loadtime+ticks()-starttime)
+ return seconds(timer.loadtime+ticks()-starttime-2*(timer.offset or 0))
end
end
return 0
@@ -2953,6 +3009,7 @@ statistics.elapsed=elapsed
statistics.elapsedtime=elapsedtime
statistics.elapsedindeed=elapsedindeed
statistics.elapsedseconds=elapsedseconds
+statistics.benchmarktimer=benchmarktimer
function statistics.register(tag,fnc)
if statistics.enable and type(fnc)=="function" then
local rt=registered[tag] or (#statusinfo+1)
@@ -2969,10 +3026,17 @@ function statistics.show()
return format("%s, type: %s, binary subtree: %s",
os.platform or "unknown",os.type or "unknown",environment.texos or "unknown")
end)
- register("used engine",function()
- return format("%s version %s with functionality level %s, banner: %s",
- LUATEXENGINE,LUATEXVERSION,LUATEXFUNCTIONALITY,lower(status.banner))
- end)
+ if LUATEXENGINE=="luametatex" then
+ register("used engine",function()
+ return format("%s version %s, functionality level %s, format id %s",
+ LUATEXENGINE,LUATEXVERSION,LUATEXFUNCTIONALITY,LUATEXFORMATID)
+ end)
+ else
+ register("used engine",function()
+ return format("%s version %s with functionality level %s, banner: %s",
+ LUATEXENGINE,LUATEXVERSION,LUATEXFUNCTIONALITY,lower(status.banner))
+ end)
+ end
register("control sequences",function()
return format("%s of %s + %s",status.cs_count,status.hash_size,status.hash_extra)
end)
@@ -2988,13 +3052,11 @@ function statistics.show()
end
register("lua properties",function()
local hashchar=tonumber(status.luatex_hashchars)
- local hashtype=status.luatex_hashtype
local mask=lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask=="utf" and "τεχ" or "tex")
@@ -3079,9 +3141,9 @@ local strippedchunks={}
luautilities.strippedchunks=strippedchunks
luautilities.suffixes={
tma="tma",
- tmc=jit and "tmb" or "tmc",
+ tmc=(CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 and "tmd") or (jit and "tmb") or "tmc",
lua="lua",
- luc=jit and "lub" or "luc",
+ luc=(CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 and "lud") or (jit and "lub") or "luc",
lui="lui",
luv="luv",
luj="luj",
@@ -3244,7 +3306,13 @@ local dummycalls=10*1000
local nesting=0
local names={}
local initialize=false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+ initialize=function()
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+ initialize=false
+ end
+elseif not (FFISUPPORTED and ffi) then
elseif os.type=="windows" then
initialize=function()
local kernel=ffilib("kernel32","system")
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
index 4d9e29591ed..1f5fcc5a9d7 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
@@ -30,8 +30,8 @@ lualibs = lualibs or { }
local lualibs_extended_module = {
name = "lualibs-extended",
- version = 2.64,
- date = "2019-02-14",
+ version = 2.65,
+ date = "2019-05-18",
description = "ConTeXt Lua libraries -- extended collection.",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
index 46b6847d331..1b039a43866 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
@@ -73,13 +73,9 @@ local P, R, S, C, Cs, Cp, Cc, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg
-- better this way:
------ tricky = S("/\\") * P(-1)
local attributes = lfs.attributes
function lfs.isdir(name)
- -- if not lpegmatch(tricky,name) then
- -- name = name .. "/."
- -- end
return attributes(name,"mode") == "directory"
end
@@ -336,43 +332,52 @@ end
-- But after some testing Taco and I came up with the more robust
-- variant:
-function file.is_writable(name)
- if not name then
- -- error
- elseif lfs.isdir(name) then
- name = name .. "/m_t_x_t_e_s_t.tmp"
- local f = io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f = io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f = io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+
+ file.is_readable = lfs.isreadablefile
+ file.is_writable = lfs.iswritablefile
+
+else
+
+ function file.is_writable(name)
+ if not name then
+ -- error
+ elseif lfs.isdir(name) then
+ name = name .. "/m_t_x_t_e_s_t.tmp"
+ local f = io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f = io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f = io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
+ return false
end
- return false
-end
-local readable = P("r") * Cc(true)
+ local readable = P("r") * Cc(true)
-function file.is_readable(name)
- if name then
- local a = attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
- return false
+ function file.is_readable(name)
+ if name then
+ local a = attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
end
+
end
file.isreadable = file.is_readable -- depricated
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua
index ddd499022fa..5570e83dc8d 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua
@@ -228,10 +228,10 @@ elseif not ffi.number then
ffi.number = tonumber
end
-if not bit32 then -- and utf8 then
- -- bit32 = load ( [[ -- replacement code with 5.3 syntax so that 5.2 doesn't bark on it ]] )
- bit32 = require("l-bit32")
-end
+-- if not bit32 then -- and utf8 then
+-- -- bit32 = load ( [[ -- replacement code with 5.3 syntax so that 5.2 doesn't bark on it ]] )
+-- bit32 = require("l-bit32")
+-- end
-- We need this due a bug in luatex socket loading:
@@ -248,3 +248,8 @@ end
-- if not loaded["socket.smtp"] then loaded["socket.smtp"] = socket.smtp end
-- if not loaded["socket.tp"] then loaded["socket.tp"] = socket.tp end
-- if not loaded["socket.url"] then loaded["socket.url"] = socket.url end
+
+if LUAVERSION > 5.3 then
+ -- collectgarbage("collect")
+ -- collectgarbage("generational") -- crashes on unix
+end
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
index cf469f79d32..aa04e254df8 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
@@ -227,25 +227,12 @@ local launchers = {
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
+ local command = format(launchers[os.name] or launchers.unix,str)
+ -- todo: pcall
+-- print(command)
+ execute(command)
end
-if not os.times then -- ?
- -- utime = user time
- -- stime = system time
- -- cutime = children user time
- -- cstime = children system time
- function os.times()
- return {
- utime = os.gettimeofday(), -- user
- stime = 0, -- system
- cutime = 0, -- children user
- cstime = 0, -- children system
- }
- end
-end
-
-
local gettimeofday = os.gettimeofday or os.clock
os.gettimeofday = gettimeofday
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
index eae13513990..192347b0619 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['l-table'] = {
local type, next, tostring, tonumber, select = type, next, tostring, tonumber, select
local table, string = table, string
-local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove
+local concat, sort = table.concat, table.sort
local format, lower, dump = string.format, string.lower, string.dump
local getmetatable, setmetatable = getmetatable, setmetatable
local lpegmatch, patterns = lpeg.match, lpeg.patterns
@@ -26,7 +26,8 @@ function table.getn(t)
end
function table.strip(tab)
- local lst, l = { }, 0
+ local lst = { }
+ local l = 0
for i=1,#tab do
local s = lpegmatch(stripper,tab[i]) or ""
if s == "" then
@@ -41,7 +42,8 @@ end
function table.keys(t)
if t then
- local keys, k = { }, 0
+ local keys = { }
+ local k = 0
for key in next, t do
k = k + 1
keys[k] = key
@@ -145,28 +147,30 @@ end
local function sortedkeys(tab)
if tab then
- local srt, category, s = { }, 0, 0 -- 0=unknown 1=string, 2=number 3=mixed
+ local srt = { }
+ local category = 0 -- 0=unknown 1=string, 2=number 3=mixed
+ local s = 0
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
+ if category ~= 3 then
local tkey = type(key)
- if tkey == "string" then
- category = 1
- elseif tkey == "number" then
- category = 2
+ if category == 1 then
+ if tkey ~= "string" then
+ category = 3
+ end
+ elseif category == 2 then
+ if tkey ~= "number" then
+ category = 3
+ end
else
- category = 3
+ if tkey == "string" then
+ category = 1
+ elseif tkey == "number" then
+ category = 2
+ else
+ category = 3
+ end
end
end
end
@@ -185,7 +189,8 @@ end
local function sortedhashonly(tab)
if tab then
- local srt, s = { }, 0
+ local srt = { }
+ local s = 0
for key in next, tab do
if type(key) == "string" then
s = s + 1
@@ -203,7 +208,8 @@ end
local function sortedindexonly(tab)
if tab then
- local srt, s = { }, 0
+ local srt = { }
+ local s = 0
for key in next, tab do
if type(key) == "number" then
s = s + 1
@@ -221,7 +227,8 @@ end
local function sortedhashkeys(tab,cmp) -- fast one
if tab then
- local srt, s = { }, 0
+ local srt = { }
+ local s = 0
for key in next, tab do
if key then
s= s + 1
@@ -317,7 +324,9 @@ end
-- end
function table.merge(t, ...) -- first one is target
- t = t or { }
+ if not t then
+ t = { }
+ end
for i=1,select("#",...) do
for k, v in next, (select(i,...)) do
t[k] = v
@@ -383,7 +392,8 @@ end
-- end
function table.imerged(...)
- local tmp, ntmp = { }, 0
+ local tmp = { }
+ local ntmp = 0
for i=1,select("#",...) do
local nst = select(i,...)
for j=1,#nst do
@@ -420,7 +430,9 @@ end
-- todo : copy without metatable
local function copy(t,tables) -- taken from lua wiki, slightly adapted
- tables = tables or { }
+ if not tables then
+ tables = { }
+ end
local tcopy = { }
if not tables[t] then
tables[t] = tcopy
@@ -471,7 +483,8 @@ function table.tohash(t,value)
end
function table.fromhash(t)
- local hsh, h = { }, 0
+ local hsh = { }
+ local h = 0
for k, v in next, t do
if v then
h = h + 1
@@ -669,7 +682,8 @@ 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
+ local first = nil
+ local last = 0
if compact then
last = #root
for k=1,last do
@@ -960,7 +974,8 @@ end
-- number : [number] = { }
function table.serialize(root,name,specification)
- local t, n = { }, 0
+ local t = { }
+ local n = 0
local function flush(s)
n = n + 1
t[n] = s
@@ -984,13 +999,15 @@ function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
- local t, n = { }, 0
+ local t = { }
+ local n = 0
local function flush(s)
n = n + 1
t[n] = s
if n > maxtab then
f:write(concat(t,"\n"),"\n") -- hm, write(sometable) should be nice
- t, n = { }, 0 -- we could recycle t if needed
+ t = { } -- we could recycle t if needed
+ n = 0
end
end
serialize(flush,root,name,specification)
@@ -1008,12 +1025,12 @@ end
local function flattened(t,f,depth) -- also handles { nil, 1, nil, 2 }
if f == nil then
- f = { }
+ f = { }
depth = 0xFFFF
elseif tonumber(f) then
-- assume that only two arguments are given
depth = f
- f = { }
+ f = { }
elseif not depth then
depth = 0xFFFF
end
@@ -1101,8 +1118,12 @@ local function are_equal(a,b,n,m) -- indexed
if a == b then
return true
elseif a and b and #a == #b then
- n = n or 1
- m = m or #a
+ if not n then
+ n = 1
+ end
+ if not m then
+ m = #a
+ end
for i=n,m do
local ai, bi = a[i], b[i]
if ai==bi then
@@ -1215,7 +1236,8 @@ end
function table.reversed(t)
if t then
- local tt, tn = { }, #t
+ local tt = { }
+ local tn = #t
if tn > 0 then
local ttn = 0
for i=tn,1,-1 do
@@ -1332,8 +1354,8 @@ end
function table.unique(old)
local hash = { }
- local new = { }
- local n = 0
+ local new = { }
+ local n = 0
for i=1,#old do
local oi = old[i]
if not hash[oi] then
@@ -1354,12 +1376,14 @@ end
function table.values(t,s) -- optional sort flag
if t then
- local values, keys, v = { }, { }, 0
+ local values = { }
+ local keys = { }
+ local v = 0
for key, value in next, t do
if not keys[value] then
v = v + 1
values[v] = value
- keys[k] = key
+ keys[k] = key
end
end
if s then
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
index 7a5c35fd5fa..0a4537e3177 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
@@ -29,7 +29,7 @@ statistics.threshold = 0.01
local statusinfo, n, registered, timers = { }, 0, { }, { }
setmetatableindex(timers,function(t,k)
- local v = { timing = 0, loadtime = 0 }
+ local v = { timing = 0, loadtime = 0, offset = 0 }
t[k] = v
return v
end)
@@ -39,7 +39,7 @@ local function hastiming(instance)
end
local function resettiming(instance)
- timers[instance or "notimer"] = { timing = 0, loadtime = 0 }
+ timers[instance or "notimer"] = { timing = 0, loadtime = 0, offset = 0 }
end
local ticks = clock
@@ -118,12 +118,27 @@ local function stoptiming(instance)
return 0
end
+local function benchmarktimer(instance)
+ local timer = timers[instance or "notimer"]
+ local it = timer.timing
+ if it > 1 then
+ timer.timing = it - 1
+ else
+ local starttime = timer.starttime
+ if starttime and starttime > 0 then
+ timer.offset = ticks() - starttime
+ else
+ timer.offset = 0
+ end
+ end
+end
+
local function elapsed(instance)
if type(instance) == "number" then
return instance
else
local timer = timers[instance or "notimer"]
- return timer and seconds(timer.loadtime) or 0
+ return timer and seconds(timer.loadtime - 2*(timer.offset or 0)) or 0
end
end
@@ -138,7 +153,7 @@ local function currenttime(instance)
else
local starttime = timer.starttime
if starttime and starttime > 0 then
- return seconds(timer.loadtime + ticks() - starttime)
+ return seconds(timer.loadtime + ticks() - starttime - 2*(timer.offset or 0))
end
end
return 0
@@ -168,6 +183,7 @@ statistics.elapsed = elapsed
statistics.elapsedtime = elapsedtime
statistics.elapsedindeed = elapsedindeed
statistics.elapsedseconds = elapsedseconds
+statistics.benchmarktimer = benchmarktimer
-- general function .. we might split this module
@@ -193,10 +209,17 @@ function statistics.show()
-- register("luatex banner", function()
-- return lower(status.banner)
-- end)
- register("used engine", function()
- return format("%s version %s with functionality level %s, banner: %s",
- LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner))
- end)
+ if LUATEXENGINE == "luametatex" then
+ register("used engine", function()
+ return format("%s version %s, functionality level %s, format id %s",
+ LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, LUATEXFORMATID)
+ end)
+ else
+ register("used engine", function()
+ return format("%s version %s with functionality level %s, banner: %s",
+ LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner))
+ end)
+ end
register("control sequences", function()
return format("%s of %s + %s", status.cs_count, status.hash_size,status.hash_extra)
end)
@@ -214,13 +237,11 @@ function statistics.show()
-- collectgarbage("collect")
register("lua properties",function()
local hashchar = tonumber(status.luatex_hashchars)
- local hashtype = status.luatex_hashtype
local mask = lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask == "utf" and "τεχ" or "tex")
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
index b03b49f0048..73d1eb7660c 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
@@ -31,7 +31,7 @@ if not modules then modules = { } end modules ['l-unicode'] = {
-- dump, find, format, gfind, gmatch, gsub, lower, match, rep, reverse, upper
utf = utf or { }
---unicode = nil
+-- unicode = nil
if not string.utfcharacters then
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
index 6932e8804d3..bd94b6d01ed 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
@@ -30,7 +30,15 @@ local names = { }
local initialize = false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+
+ initialize = function()
+ ticks = lua.getpreciseticks
+ seconds = lua.getpreciseseconds
+ initialize = false
+ end
+
+elseif not (FFISUPPORTED and ffi) then
-- we have no precise timer
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua
index fd9351a28fb..76b5fd20bb3 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua
@@ -397,18 +397,22 @@ function dimen(a)
end
function string.todimen(str) -- maybe use tex.sp when available
- if type(str) == "number" then
+ local t = type(str)
+ if t == "number" then
return str
else
local k = known[str]
if not k then
- local value, unit = lpegmatch(dimenpair,str)
- if value and unit then
- k = value/unit -- to be considered: round
+ if t == "string" then
+ local value, unit = lpegmatch(dimenpair,str)
+ if value and unit then
+ k = value/unit -- to be considered: round
+ else
+ k = 0
+ end
else
k = 0
end
- -- print(str,value,unit)
known[str] = k
end
return k
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua
index 1199301f42f..f7e6e4f3130 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua
@@ -30,9 +30,9 @@ luautilities.strippedchunks = strippedchunks
luautilities.suffixes = {
tma = "tma",
- tmc = jit and "tmb" or "tmc",
+ tmc = (CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 and "tmd") or (jit and "tmb") or "tmc",
lua = "lua",
- luc = jit and "lub" or "luc",
+ luc = (CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 and "lud") or (jit and "lub") or "luc",
lui = "lui",
luv = "luv",
luj = "luj",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
index 891f1096ac9..3154bf6c28d 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
@@ -24,8 +24,8 @@ local sortedhash = table.sortedhash
local sortedkeys = table.sortedkeys
local tohash = table.tohash
-local hashes = { }
-utilities.parsers.hashes = hashes
+local hashes = { }
+parsers.hashes = hashes
-- we share some patterns
local digit = R("09")
@@ -308,7 +308,9 @@ end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t, tn, s = { }, 0, sortedkeys(h)
+ local t = { }
+ local tn = 0
+ local s = sortedkeys(h)
omit = omit and tohash(omit)
for i=1,#s do
local key = s[i]
@@ -361,7 +363,7 @@ end
local pattern = Cf(Ct("") * Cg(C((1-S(", "))^1) * S(", ")^0 * Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or { }
end
@@ -374,7 +376,8 @@ end)
getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense)
function parsers.simple_hash_to_string(h, separator)
- local t, tn = { }, 0
+ local t = { }
+ local tn = 0
for k, v in sortedhash(h) do
if v then
tn = tn + 1
@@ -390,13 +393,13 @@ local str = Cs(lpegpatterns.unquoted) + C((1-whitespace-equal)^1)
local setting = Cf( Carg(1) * (whitespace^0 * Cg(str * whitespace^0 * (equal * whitespace^0 * str + Cc(""))))^1,rawset)
local splitter = setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or { }) or { }
end
local splitter = lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or { }
end
@@ -415,7 +418,8 @@ local function repeater(n,str)
if n == 1 then
return unpack(s)
else
- local t, tn = { }, 0
+ local t = { }
+ local tn = 0
for i=1,n do
for j=1,#s do
tn = tn + 1
@@ -557,7 +561,7 @@ end
-- and this is a slightly patched version of a version posted by Philipp Gesang
--- local mycsvsplitter = utilities.parsers.rfc4180splitter()
+-- local mycsvsplitter = parsers.rfc4180splitter()
-- local crap = [[
-- first,second,third,fourth
@@ -597,11 +601,11 @@ function parsers.rfc4180splitter(specification)
end
end
--- utilities.parsers.stepper("1,7-",9,function(i) print(">>>",i) end)
--- utilities.parsers.stepper("1-3,7,8,9")
--- utilities.parsers.stepper("1-3,6,7",function(i) print(">>>",i) end)
--- utilities.parsers.stepper(" 1 : 3, ,7 ")
--- utilities.parsers.stepper("1:4,9:13,24:*",30)
+-- parsers.stepper("1,7-",9,function(i) print(">>>",i) end)
+-- parsers.stepper("1-3,7,8,9")
+-- parsers.stepper("1-3,6,7",function(i) print(">>>",i) end)
+-- parsers.stepper(" 1 : 3, ,7 ")
+-- parsers.stepper("1:4,9:13,24:*",30)
local function ranger(first,last,n,action)
if not first then
@@ -654,7 +658,7 @@ function parsers.unittoxml(str)
return lpegmatch(pattern,str)
end
--- print(utilities.parsers.unittotex("10^-32 %"),utilities.parsers.unittoxml("10^32 %"))
+-- print(parsers.unittotex("10^-32 %"),utilities.parsers.unittoxml("10^32 %"))
local cache = { }
local spaces = lpegpatterns.space^0
@@ -670,7 +674,7 @@ end)
local commalistiterator = cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n = #str
if n == 0 then
return dummy
@@ -689,7 +693,7 @@ function utilities.parsers.iterator(str,separator)
end
end
--- for s in utilities.parsers.iterator("a b c,b,c") do
+-- for s in parsers.iterator("a b c,b,c") do
-- print(s)
-- end
@@ -721,7 +725,7 @@ local name = C((1-S(", "))^1)
local parser = (Carg(1) * name / initialize) * (S(", ")^1 * (Carg(1) * name / fetch))^0
local merge = Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
@@ -731,9 +735,9 @@ end
-- cc = { epsilon = 3 },
-- }
--
--- inspect(utilities.parsers.mergehashes(t,"aa, bb, cc"))
+-- inspect(parsers.mergehashes(t,"aa, bb, cc"))
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time = os.runtime()
end
@@ -755,7 +759,7 @@ local token = lbrace * C((1-rbrace)^1) * rbrace + C(anything^1)
local pattern = spacing * (method * spacing * apply + Carg(1)) * spacing * token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
@@ -763,9 +767,38 @@ function utilities.parsers.splitmethod(str,default)
end
end
--- print(utilities.parsers.splitmethod(" foo -> {bar} "))
--- print(utilities.parsers.splitmethod("foo->{bar}"))
--- print(utilities.parsers.splitmethod("foo->bar"))
--- print(utilities.parsers.splitmethod("foo"))
--- print(utilities.parsers.splitmethod("{foo}"))
--- print(utilities.parsers.splitmethod())
+-- print(parsers.splitmethod(" foo -> {bar} "))
+-- print(parsers.splitmethod("foo->{bar}"))
+-- print(parsers.splitmethod("foo->bar"))
+-- print(parsers.splitmethod("foo"))
+-- print(parsers.splitmethod("{foo}"))
+-- print(parsers.splitmethod())
+
+local p_year = lpegpatterns.digit^4 / tonumber
+
+local pattern = Cf( Ct("") *
+ (
+ ( Cg(Cc("year") * p_year)
+ * S("-/") * Cg(Cc("month") * cardinal)
+ * S("-/") * Cg(Cc("day") * cardinal)
+ ) +
+ ( Cg(Cc("day") * cardinal)
+ * S("-/") * Cg(Cc("month") * cardinal)
+ * S("-/") * Cg(Cc("year") * p_year)
+ )
+ )
+ * P(" ") * Cg(Cc("hour") * cardinal)
+ * P(":") * Cg(Cc("min") * cardinal)
+ * (P(":") * Cg(Cc("sec") * cardinal))^-1
+, rawset)
+
+lpegpatterns.splittime = pattern
+
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
+
+-- print(os.time(parsers.totime("2019-03-05 12:12:12")))
+-- print(os.time(parsers.totime("2019/03/05 12:12:12")))
+-- print(os.time(parsers.totime("05-03-2019 12:12:12")))
+-- print(os.time(parsers.totime("05/03/2019 12:12:12")))
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
index 713c294ebe7..5470c2fd698 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
@@ -14,7 +14,6 @@ local format, gsub, rep, sub, find = string.format, string.gsub, string.rep, str
local load, dump = load, string.dump
local tonumber, type, tostring, next, setmetatable = tonumber, type, tostring, next, setmetatable
local unpack, concat = table.unpack, table.concat
-local unpack, concat = table.unpack, table.concat
local P, V, C, S, R, Ct, Cs, Cp, Carg, Cc = lpeg.P, lpeg.V, lpeg.C, lpeg.S, lpeg.R, lpeg.Ct, lpeg.Cs, lpeg.Cp, lpeg.Carg, lpeg.Cc
local patterns, lpegmatch = lpeg.patterns, lpeg.match
local utfchar, utfbyte, utflen = utf.char, utf.byte, utf.len
@@ -610,8 +609,8 @@ local environment = {
formattednumber = number.formatted,
sparseexponent = number.sparseexponent,
formattedfloat = number.formattedfloat,
- stripzero = lpeg.patterns.stripzero,
- stripzeros = lpeg.patterns.stripzeros,
+ stripzero = patterns.stripzero,
+ stripzeros = patterns.stripzeros,
FORMAT = string.f9,
}
@@ -745,7 +744,7 @@ end
local format_k = function(b,a) -- slow
n = n + 1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0, a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g = function(f)
@@ -1329,9 +1328,9 @@ patterns.luaquoted = Cs(Cc('"') * ((1-S('"\n'))^1 + P('"')/'\\"' + P('\n')/'\\n"
-- escaping by lpeg is faster for strings without quotes, slower on a string with quotes, but
-- faster again when other q-escapables are found (the ones we don't need to escape)
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape = lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape = lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape = lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape = patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape = patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape = patterns.luaescape })
-- -- yes or no:
--
@@ -1409,3 +1408,31 @@ local f_16_16 = formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+
+--
+
+if not string.explode then
+
+ local tsplitat = lpeg.tsplitat
+
+ local p_utf = patterns.utf8character
+ local p_check = C(p_utf) * (P("+") * Cc(true))^0
+ local p_split = Ct(C(p_utf)^0)
+ local p_space = Ct((C(1-P(" ")^1) + P(" ")^1)^0)
+
+ function string.explode(str,symbol)
+ if symbol == "" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a, b = lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+
+end
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
index ed4cef9967c..2f425cca384 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
@@ -22,7 +22,8 @@ local utftoeight = utf.toeight
local splitter = lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast) -- defines undefined tables
- local composed, t = nil, { }
+ local composed = nil
+ local t = { }
local snippets = lpegmatch(splitter,target)
for i=1,#snippets - (nolast and 1 or 0) do
local name = snippets[i]
@@ -310,7 +311,8 @@ function tables.encapsulate(core,capsule,protect)
end
end
--- best keep [%q] keys (as we have some in older applications i.e. saving user data
+-- best keep [%q] keys (as we have some in older applications i.e. saving user data (otherwise
+-- we also need to check for reserved words)
local f_hashed_string = formatters["[%q]=%q,"]
local f_hashed_number = formatters["[%q]=%s,"]
@@ -334,7 +336,6 @@ function table.fastserialize(t,prefix)
local r = { type(prefix) == "string" and prefix or "return" }
local m = 1
-
local function fastserialize(t,outer) -- no mixes
local n = #t
m = m + 1
@@ -654,19 +655,20 @@ local function serialize(root,name,specification)
-- we could check for k (index) being number (cardinal)
if root and next(root) ~= nil then
local first = nil
- local last = 0
- last = #root
- for k=1,last do
- if rawget(root,k) == nil then
- -- if root[k] == nil then
- last = k - 1
- break
- end
- end
+ local last = #root
if last > 0 then
- first = 1
+ for k=1,last do
+ if rawget(root,k) == nil then
+ -- if root[k] == nil then
+ last = k - 1
+ break
+ end
+ end
+ if last > 0 then
+ first = 1
+ end
end
- local sk = sortedkeys(root) -- inline fast version?\
+ local sk = sortedkeys(root)
for i=1,#sk do
local k = sk[i]
local v = root[k]
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua
index 5e75a151b92..57d7df3a91d 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua
@@ -171,6 +171,8 @@ local function replace(str,mapping,how,recurse)
end
-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]] }))
+-- print(replace("test '%x%' test",{ x = [[a "x"  a]] }))
+-- print(replace([[test "%[x]%" test]],{ x = [[a "x"  a]] }))
-- print(replace("test '%[x]%' test",{ x = true }))
-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]], y = "oeps" },'sql'))
-- print(replace("test '%[x]%' test",{ x = [[a '%y%'  a]], y = "oeps" },'sql',true))
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
index 92a9168d4ee..089a7441dd2 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
@@ -25,8 +25,8 @@ lualibs = lualibs or { }
lualibs.module_info = {
name = "lualibs",
- version = 2.64,
- date = "2019-02-14",
+ version = 2.65,
+ date = "2019-05-18",
description = "ConTeXt Lua standard libraries.",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",