texlive[51167] Master/texmf-dist: lualibs (19may19)

commits+karl at tug.org commits+karl at tug.org
Sun May 19 23:26:37 CEST 2019


Revision: 51167
          http://tug.org/svn/texlive?view=revision&revision=51167
Author:   karl
Date:     2019-05-19 23:26:37 +0200 (Sun, 19 May 2019)
Log Message:
-----------
lualibs (19may19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/lualibs/NEWS
    trunk/Master/texmf-dist/doc/luatex/lualibs/README
    trunk/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
    trunk/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua

Modified: trunk/Master/texmf-dist/doc/luatex/lualibs/NEWS
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/lualibs/NEWS	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/doc/luatex/lualibs/NEWS	2019-05-19 21:26:37 UTC (rev 51167)
@@ -1,4 +1,7 @@
                         History of the lualibs package
+2019/05/18 v2.65/
+    * sync with Context current as of 2019/05/18    
+                            
 2019/02/14 v2.64/
     * sync with Context beta as of 2019/02/14                        
                         

Modified: trunk/Master/texmf-dist/doc/luatex/lualibs/README
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/lualibs/README	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/doc/luatex/lualibs/README	2019-05-19 21:26:37 UTC (rev 51167)
@@ -11,8 +11,8 @@
 This package has been developed by the LuaLaTeX development team on
 <http://github.com/lualatex/lualibs>. 
 
-The current verson 2.64 has been build by Ulrike Fischer on
-<https://github.com/u-fischer/lualibs> from context 2019-02-14. 
+The current verson 2.65 has been build by Ulrike Fischer on
+<https://github.com/u-fischer/lualibs> from context 2019-05-18. 
 
 See the 'NEWS' file for version history.
 

Modified: trunk/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx
===================================================================
--- trunk/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx	2019-05-19 21:26:37 UTC (rev 51167)
@@ -37,7 +37,7 @@
 \input docstrip.tex
 \Msg{************************************************************************}
 \Msg{* Installation}
-\Msg{* Package: lualibs 2019-02-14 v2.64 Lua additional functions.}
+\Msg{* Package: lualibs 2019-05-18 v2.65 Lua additional functions.}
 \Msg{************************************************************************}
 
 \keepsilent
@@ -107,7 +107,7 @@
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{lualibs.drv}
-  [2019/02/14 v2.64 Lua Libraries.]
+  [2019/05/18 v2.65 Lua Libraries.]
 \documentclass{ltxdoc}
 \usepackage{fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -208,7 +208,7 @@
 % \GetFileInfo{lualibs.drv}
 %
 % \title{The \identifier{lualibs} package}
-% \date{2019/02/14 v2.64}
+% \date{2019/05/18 v2.65}
 % \author{Élie Roux      · \email{elie.roux at telecom-bretagne.eu}\\
 %         Philipp Gesang · \email{phg at phi-gamma.net}\\
 %         Ulrike Fischer · \email{fischer at troubleshooting-tex.de}\\
@@ -429,8 +429,8 @@
 
 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",
@@ -584,8 +584,8 @@
 
 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",
@@ -666,8 +666,8 @@
 
 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",

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -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 @@
 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 @@
 }
 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 @@
  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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
  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 @@
  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 @@
  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 @@
  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 @@
   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 @@
  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 @@
  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 @@
  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 @@
 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 @@
 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,18 +3258,9 @@
  unix="xdg-open %s &> /dev/null &",
 }
 function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
 end
-if not os.times then
- function os.times()
-  return {
-   utime=os.gettimeofday(),
-   stime=0,
-   cutime=0,
-   cstime=0,
-  }
- end
-end
 local gettimeofday=os.gettimeofday or os.clock
 os.gettimeofday=gettimeofday
 local startuptime=gettimeofday()
@@ -3696,41 +3711,46 @@
 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
+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
- elseif lfs.isfile(name) then
-  local f=io.open(name,"ab")
-  if f then
-   f:close()
-   return true
+  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
- else
-  local f=io.open(name,"ab")
-  if f then
-   f:close()
-   os.remove(name)
-   return true
-  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
-end
 file.isreadable=file.is_readable 
 file.iswritable=file.is_writable 
 function file.size(name)
@@ -4114,13 +4134,15 @@
   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 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 @@
   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 @@
  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 @@
  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 @@
 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -29,8 +29,8 @@
 
 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",

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-dir.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -91,13 +91,15 @@
         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 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 @@
         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 @@
     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 @@
     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 @@
 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -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 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 @@
  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 @@
 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.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 @@
 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 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 @@
   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
+   local last=#root
+   if last>0 then
+    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
-   if last>0 then
-    first=1
-   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 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 @@
 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 @@
  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 @@
 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 @@
 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 @@
   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 @@
  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 @@
 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,7 +2536,7 @@
 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
@@ -2517,6 +2543,17 @@
   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 @@
  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.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 @@
  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 @@
  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 @@
   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.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 @@
    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 @@
   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 @@
 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 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") 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -30,8 +30,8 @@
 
 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",

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -73,13 +73,9 @@
 
 -- 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 @@
 -- 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
+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
-    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
+        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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -228,10 +228,10 @@
     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 @@
 -- 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -227,25 +227,12 @@
 }
 
 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
 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -8,7 +8,7 @@
 
 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 @@
 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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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
 
 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
 
 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 @@
 -- 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 @@
 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 @@
     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 @@
 -- 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 @@
     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 @@
 
 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 @@
     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 @@
 
 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 @@
 
 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 @@
 
 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -29,7 +29,7 @@
 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 @@
 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 @@
     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 @@
         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.elapsedtime    = elapsedtime
 statistics.elapsedindeed  = elapsedindeed
 statistics.elapsedseconds = elapsedseconds
+statistics.benchmarktimer = benchmarktimer
 
 -- general function .. we might split this module
 
@@ -193,10 +209,17 @@
      -- 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 @@
      -- 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")

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -31,7 +31,7 @@
 -- dump, find, format, gfind, gmatch, gsub, lower, match, rep, reverse, upper
 
 utf     = utf or { }
---unicode = nil
+-- unicode = nil
 
 if not string.utfcharacters then
 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -30,8 +30,16 @@
 
 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
 
 elseif os.type == "windows" then

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-dim.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -397,18 +397,22 @@
 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-lua.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -30,9 +30,9 @@
 
 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",

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -24,8 +24,8 @@
 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 @@
 
 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 @@
 
 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 @@
 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 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 @@
         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 @@
 
 -- 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 @@
     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 @@
     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 @@
 
 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 @@
     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 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 @@
 --     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 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 @@
     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")))

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -14,7 +14,6 @@
 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 @@
     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 @@
 
 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 @@
 -- 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 @@
 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

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -22,7 +22,8 @@
 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 @@
     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 @@
 
     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 @@
         -- 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
+            local last  = #root
+            if last > 0 then
+                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
-            if last > 0 then
-                first = 1
-            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]

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tpl.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -171,6 +171,8 @@
 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))

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua	2019-05-19 21:26:20 UTC (rev 51166)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua	2019-05-19 21:26:37 UTC (rev 51167)
@@ -25,8 +25,8 @@
 
 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",



More information about the tex-live-commits mailing list