texlive[49741] Master/texmf-dist: lualibs (17jan19)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 17 22:28:52 CET 2019


Revision: 49741
          http://tug.org/svn/texlive?view=revision&revision=49741
Author:   karl
Date:     2019-01-17 22:28:52 +0100 (Thu, 17 Jan 2019)
Log Message:
-----------
lualibs (17jan19)

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-extended-merged.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.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-unicode.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
    trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.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-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/doc/luatex/lualibs/NEWS	2019-01-17 21:28:52 UTC (rev 49741)
@@ -1,4 +1,7 @@
                         History of the lualibs package
+2018-12-19 v2.62/ (upload 2019-01-16)
+    * sync with Context beta as of 2018-12-19
+                        
 2018/10/18 v2.61/
     * sync with Context beta as of 2018-10-18
 

Modified: trunk/Master/texmf-dist/doc/luatex/lualibs/README
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/lualibs/README	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/doc/luatex/lualibs/README	2019-01-17 21:28:52 UTC (rev 49741)
@@ -11,8 +11,8 @@
 This package has been developed by the LuaLaTeX development team on
 <http://github.com/lualatex/lualibs>. 
 
-The current verson 2.61 has been build by Ulrike Fischer on
-<https://github.com/u-fischer/lualibs>. 
+The current verson 2.62 has been build by Ulrike Fischer on
+<https://github.com/u-fischer/lualibs> from context 2018-12-19. 
 
 See the 'NEWS' file for version history.
 
@@ -57,7 +57,7 @@
     lualibs-string.lua              tex/luatex/lualibs/lualibs-string.lua
     lualibs-table.lua               tex/luatex/lualibs/lualibs-table.lua
     lualibs-trac-inf.lua            tex/luatex/lualibs/lualibs-trac-inf.lua
-    lualibs-unicode.lua             tex/luatex/lualibs/lualibs-unicode.lua
+    lualibs-unicode.lua*            tex/luatex/lualibs/lualibs-unicode.lua
     lualibs-url.lua                 tex/luatex/lualibs/lualibs-url.lua
     lualibs-util-deb.lua            tex/luatex/lualibs/lualibs-util-deb.lua
     lualibs-util-dim.lua            tex/luatex/lualibs/lualibs-util-dim.lua
@@ -72,6 +72,8 @@
     LICENSE                         doc/luatex/lualibs/LICENSE
     NEWS                            doc/luatex/lualibs/NEWS
     README                          doc/luatex/lualibs/README
+    
+* the file has been modified to enable the unicode library again    
 
 Derived files:
     lualibs.lua                     tex/luatex/lualibs/lualibs.lua

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-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx	2019-01-17 21:28:52 UTC (rev 49741)
@@ -37,7 +37,7 @@
 \input docstrip.tex
 \Msg{************************************************************************}
 \Msg{* Installation}
-\Msg{* Package: lualibs 2018-10-18 v2.61 Lua additional functions.}
+\Msg{* Package: lualibs 2018-12-19 v2.62 Lua additional functions.}
 \Msg{************************************************************************}
 
 \keepsilent
@@ -107,7 +107,7 @@
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{lualibs.drv}
-  [2018/10/18 v2.61 Lua Libraries.]
+  [2018/12/07 v2.62 Lua Libraries.]
 \documentclass{ltxdoc}
 \usepackage{fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -208,7 +208,7 @@
 % \GetFileInfo{lualibs.drv}
 %
 % \title{The \identifier{lualibs} package}
-% \date{2018/10/18 v2.61}
+% \date{2018/12/07 v2.62}
 % \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.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -1,6 +1,6 @@
 -- merged file : lualibs-basic-merged.lua
 -- parent file : lualibs-basic.lua
--- merge date  : Thu Oct 18 23:57:42 2018
+-- merge date  : Tue Dec 25 16:21:45 2018
 
 do -- begin closure to overcome local limits and interference
 
@@ -871,64 +871,6 @@
     return function(str) n=0;lpegmatch(pattern,str);return n end
   end
 end
-utf=utf or (unicode and unicode.utf8) or {}
-local utfcharacters=utf and utf.characters or string.utfcharacters
-local utfgmatch=utf and utf.gmatch
-local utfchar=utf and utf.char
-lpeg.UP=lpeg.P
-if utfcharacters then
-  function lpeg.US(str)
-    local p=P(false)
-    for uc in utfcharacters(str) do
-      p=p+P(uc)
-    end
-    return p
-  end
-elseif utfgmatch then
-  function lpeg.US(str)
-    local p=P(false)
-    for uc in utfgmatch(str,".") do
-      p=p+P(uc)
-    end
-    return p
-  end
-else
-  function lpeg.US(str)
-    local p=P(false)
-    local f=function(uc)
-      p=p+P(uc)
-    end
-    lpegmatch((utf8char/f)^0,str)
-    return p
-  end
-end
-local range=utf8byte*utf8byte+Cc(false) 
-function lpeg.UR(str,more)
-  local first,last
-  if type(str)=="number" then
-    first=str
-    last=more or first
-  else
-    first,last=lpegmatch(range,str)
-    if not last then
-      return P(str)
-    end
-  end
-  if first==last then
-    return P(str)
-  elseif utfchar and (last-first<8) then 
-    local p=P(false)
-    for i=first,last do
-      p=p+P(utfchar(i))
-    end
-    return p 
-  else
-    local f=function(b)
-      return b>=first and b<=last
-    end
-    return utf8byte/f 
-  end
-end
 function lpeg.is_lpeg(p)
   return p and lpegtype(p)=="pattern"
 end
@@ -1424,7 +1366,6 @@
 local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
 local format,lower,dump=string.format,string.lower,string.dump
 local getmetatable,setmetatable=getmetatable,setmetatable
-local getinfo=debug.getinfo
 local lpegmatch,patterns=lpeg.match,lpeg.patterns
 local floor=math.floor
 local stripper=patterns.stripper
@@ -1986,20 +1927,23 @@
         end
       elseif tv=="function" then
         if functions then
-          local f=getinfo(v).what=="C" and dump(dummy) or dump(v)
-          if tk=="number" then
-            if hexify then
-              handle(format("%s [0x%X]=load(%q),",depth,k,f))
+          local getinfo=debug and debug.getinfo
+          if getinfo then
+            local f=getinfo(v).what=="C" and dump(dummy) or dump(v)
+            if tk=="number" then
+              if hexify then
+                handle(format("%s [0x%X]=load(%q),",depth,k,f))
+              else
+                handle(format("%s [%s]=load(%q),",depth,k,f))
+              end
+            elseif tk=="boolean" then
+              handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f))
+            elseif tk~="string" then
+            elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+              handle(format("%s %s=load(%q),",depth,k,f))
             else
-              handle(format("%s [%s]=load(%q),",depth,k,f))
+              handle(format("%s [%q]=load(%q),",depth,k,f))
             end
-          elseif tk=="boolean" then
-            handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f))
-          elseif tk~="string" then
-          elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
-            handle(format("%s %s=load(%q),",depth,k,f))
-          else
-            handle(format("%s [%q]=load(%q),",depth,k,f))
           end
         end
       else
@@ -2590,11 +2534,14 @@
     "0","0","0","0","0","0","0","0",
     "0","0","0","0","0","0","0","0",
   }
-  function number.tobitstring(b,m)
-    local n=32
-    for i=0,31 do
+  function number.tobitstring(b,m,w)
+    if not w then
+      w=32
+    end
+    local n=w
+    for i=0,w-1 do
       local v=bextract(b,i)
-      local k=32-i
+      local k=w-i
       if v==1 then
         n=k
         t[k]="1"
@@ -2602,12 +2549,14 @@
         t[k]="0"
       end
     end
-    if m then
+    if w then
+      return concat(t,"",1,w)
+    elseif m then
       m=33-m*8
       if m<1 then
         m=1
       end
-      return concat(t,"",m)
+      return concat(t,"",1,m)
     elseif n<8 then
       return concat(t)
     elseif n<16 then
@@ -3136,6 +3085,61 @@
 local concat=table.concat
 local random,ceil,randomseed=math.random,math.ceil,math.randomseed
 local rawget,rawset,type,getmetatable,setmetatable,tonumber,tostring=rawget,rawset,type,getmetatable,setmetatable,tonumber,tostring
+do
+  local selfdir=os.selfdir
+  if selfdir=="" then
+    selfdir=nil
+  end
+  if not selfdir then
+    if arg then
+      for i=1,#arg do
+        local a=arg[i]
+        if find(a,"^%-%-[c:]*texmfbinpath=") then
+          selfdir=gsub(a,"^.-=","")
+          break
+        end
+      end
+    end
+    if not selfdir then
+      selfdir=os.selfbin or "luatex"
+      if find(selfdir,"[/\\]") then
+        selfdir=gsub(selfdir,"[/\\][^/\\]*$","")
+      elseif os.getenv then
+        local path=os.getenv("PATH")
+        local name=gsub(selfdir,"^.*[/\\][^/\\]","")
+        local patt="[^:]+"
+        if os.type=="windows" then
+          patt="[^;]+"
+          name=name..".exe"
+        end
+        local isfile
+        if lfs then
+          local attributes=lfs.attributes
+          isfile=function(name)
+            local a=attributes(name,"mode")
+            return a=="file" or a=="link" or nil
+          end
+        else
+          local open=io.open
+          isfile=function(name)
+            local f=open(name)
+            if f then
+              f:close()
+              return true
+            end
+          end
+        end
+        for p in gmatch(path,patt) do
+          if isfile(p.."/"..name) then
+            selfdir=p
+            break
+          end
+        end
+      end
+    end
+    os.selfdir=selfdir or "."
+  end
+end
 math.initialseed=tonumber(string.sub(string.reverse(tostring(ceil(socket and socket.gettime()*10000 or time()))),1,6))
 randomseed(math.initialseed)
 if not os.__getenv__ then
@@ -4551,9 +4555,14 @@
   copyright="PRAGMA ADE / ConTeXt Development Team",
   license="see context related readme files"
 }
-utf=utf or (unicode and unicode.utf8) or {}
-utf.characters=utf.characters or string.utfcharacters
-utf.values=utf.values   or string.utfvalues
+utf=utf or {}
+if not string.utfcharacters then
+  local gmatch=string.gmatch
+  function string.characters(str)
+    return gmatch(str,".[\128-\191]*")
+  end
+end
+utf.characters=string.utfcharacters
 local type=type
 local char,byte,format,sub,gmatch=string.char,string.byte,string.format,string.sub,string.gmatch
 local concat=table.concat
@@ -4564,19 +4573,15 @@
 local bytepairs=string.bytepairs
 local finder=lpeg.finder
 local replacer=lpeg.replacer
-local utfvalues=utf.values
-local utfgmatch=utf.gmatch 
 local p_utftype=patterns.utftype
 local p_utfstricttype=patterns.utfstricttype
 local p_utfoffset=patterns.utfoffset
-local p_utf8char=patterns.utf8character
+local p_utf8character=patterns.utf8character
+local p_utf8char=patterns.utf8char
 local p_utf8byte=patterns.utf8byte
 local p_utfbom=patterns.utfbom
 local p_newline=patterns.newline
 local p_whitespace=patterns.whitespace
-if not unicode then
-  unicode={ utf=utf } 
-end
 if not utf.char then
   utf.char=string.utfcharacter or (utf8 and utf8.char)
   if not utf.char then
@@ -4641,9 +4646,8 @@
 if not utf.byte then
   utf.byte=string.utfvalue or (utf8 and utf8.codepoint)
   if not utf.byte then
-    local utf8byte=patterns.utf8byte
     function utf.byte(c)
-      return lpegmatch(utf8byte,c)
+      return lpegmatch(p_utf8byte,c)
     end
   end
 end
@@ -4744,10 +4748,10 @@
       return true
     end
   end
-  local pattern_zero=Cmt(p_utf8char,slide_zero)^0
-  local pattern_one=Cmt(p_utf8char,slide_one )^0
-  local pattern_two=Cmt(p_utf8char,slide_two )^0
-  local pattern_first=C(patterns.utf8character)
+  local pattern_zero=Cmt(p_utf8character,slide_zero)^0
+  local pattern_one=Cmt(p_utf8character,slide_one )^0
+  local pattern_two=Cmt(p_utf8character,slide_two )^0
+  local pattern_first=C(p_utf8character)
   function utf.sub(str,start,stop)
     if not start then
       return str
@@ -4822,15 +4826,15 @@
           return ""
         else
           if not pattern then
-            pattern=Cs((tabletopattern(mapping)/action+p_utf8char)^0)
+            pattern=Cs((tabletopattern(mapping)/action+p_utf8character)^0)
           end
           return lpegmatch(pattern,str)
         end
       end
     elseif option=="pattern" then
-      return Cs((tabletopattern(mapping)/action+p_utf8char)^0)
+      return Cs((tabletopattern(mapping)/action+p_utf8character)^0)
     else
-      local pattern=Cs((tabletopattern(mapping)/action+p_utf8char)^0)
+      local pattern=Cs((tabletopattern(mapping)/action+p_utf8character)^0)
       return function(str)
         if not str or str=="" then
           return ""
@@ -4841,9 +4845,9 @@
     end
   elseif variant=="function" then
     if option=="pattern" then
-      return Cs((p_utf8char/mapping+p_utf8char)^0)
+      return Cs((p_utf8character/mapping+p_utf8character)^0)
     else
-      local pattern=Cs((p_utf8char/mapping+p_utf8char)^0)
+      local pattern=Cs((p_utf8character/mapping+p_utf8character)^0)
       return function(str)
         if not str or str=="" then
           return ""
@@ -4879,9 +4883,9 @@
   end
 end
 local utflinesplitter=p_utfbom^-1*lpeg.tsplitat(p_newline)
-local utfcharsplitter_ows=p_utfbom^-1*Ct(C(p_utf8char)^0)
-local utfcharsplitter_iws=p_utfbom^-1*Ct((p_whitespace^1+C(p_utf8char))^0)
-local utfcharsplitter_raw=Ct(C(p_utf8char)^0)
+local utfcharsplitter_ows=p_utfbom^-1*Ct(C(p_utf8character)^0)
+local utfcharsplitter_iws=p_utfbom^-1*Ct((p_whitespace^1+C(p_utf8character))^0)
+local utfcharsplitter_raw=Ct(C(p_utf8character)^0)
 patterns.utflinesplitter=utflinesplitter
 function utf.splitlines(str)
   return lpegmatch(utflinesplitter,str or "")
@@ -4918,7 +4922,7 @@
 local p_utf16_to_utf8_be=C(1)*C(1)/function(left,right)
   local now=256*byte(left)+byte(right)
   if more>0 then
-    now=(more-0xD800)*0x400+(now-0xDC00)+0x10000 
+    now=(more-0xD800)*0x400+(now-0xDC00)+0x10000
     more=0
     return utfchar(now)
   elseif now>=0xD800 and now<=0xDBFF then
@@ -4931,7 +4935,7 @@
 local p_utf16_to_utf8_le=C(1)*C(1)/function(right,left)
   local now=256*byte(left)+byte(right)
   if more>0 then
-    now=(more-0xD800)*0x400+(now-0xDC00)+0x10000 
+    now=(more-0xD800)*0x400+(now-0xDC00)+0x10000
     more=0
     return utfchar(now)
   elseif now>=0xD800 and now<=0xDBFF then
@@ -5128,20 +5132,8 @@
     return str
   end
 end
-local p_nany=p_utf8char/""
-if utfgmatch then
-  function utf.count(str,what)
-    if type(what)=="string" then
-      local n=0
-      for _ in utfgmatch(str,what) do
-        n=n+1
-      end
-      return n
-    else 
-      return #lpegmatch(Cs((P(what)/" "+p_nany)^0),str)
-    end
-  end
-else
+do
+  local p_nany=p_utf8character/""
   local cache={}
   function utf.count(str,what)
     if type(what)=="string" then
@@ -5156,17 +5148,11 @@
     end
   end
 end
-if not utf.characters then
-  function utf.characters(str)
-    return gmatch(str,".[\128-\191]*")
-  end
-  string.utfcharacters=utf.characters
-end
-if not utf.values then
+if not string.utfvalues then
   local find=string.find
   local dummy=function()
   end
-  function utf.values(str)
+  function string.utfvalues(str)
     local n=#str
     if n==0 then
       return dummy
@@ -5183,8 +5169,8 @@
       end
     end
   end
-  string.utfvalues=utf.values
 end
+utf.values=string.utfvalues
 function utf.chrlen(u) 
   return
     (u<0x80 and 1) or
@@ -5197,7 +5183,7 @@
 if bit32 then
   local extract=bit32.extract
   local char=string.char
-  function unicode.toutf32string(n)
+  function utf.toutf32string(n)
     if n<=0xFF then
       return
         char(n).."\000\000\000"
@@ -5232,6 +5218,60 @@
   end
   return s
 end
+do
+  local utfcharacters=utf.characters or string.utfcharacters
+  local utfchar=utf.char    or string.utfcharacter
+  lpeg.UP=P
+  if utfcharacters then
+    function lpeg.US(str)
+      local p=P(false)
+      for uc in utfcharacters(str) do
+        p=p+P(uc)
+      end
+      return p
+    end
+  else
+    function lpeg.US(str)
+      local p=P(false)
+      local f=function(uc)
+        p=p+P(uc)
+      end
+      lpegmatch((p_utf8char/f)^0,str)
+      return p
+    end
+  end
+  local range=p_utf8byte*p_utf8byte+Cc(false) 
+  function lpeg.UR(str,more)
+    local first,last
+    if type(str)=="number" then
+      first=str
+      last=more or first
+    else
+      first,last=lpegmatch(range,str)
+      if not last then
+        return P(str)
+      end
+    end
+    if first==last then
+      return P(str)
+    end
+    if not utfchar then
+      utfchar=utf.char 
+    end
+    if utfchar and (last-first<8) then 
+      local p=P(false)
+      for i=first,last do
+        p=p+P(utfchar(i))
+      end
+      return p 
+    else
+      local f=function(b)
+        return b>=first and b<=last
+      end
+      return p_utf8byte/f 
+    end
+  end
+end
 
 end -- closure
 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -29,8 +29,8 @@
 
 local lualibs_basic_module = {
   name          = "lualibs-basic",
-  version       = 2.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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-extended-merged.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -1,6 +1,6 @@
 -- merged file : lualibs-extended-merged.lua
 -- parent file : lualibs-extended.lua
--- merge date  : Thu Oct 18 23:57:30 2018
+-- merge date  : Tue Dec 25 16:21:26 2018
 
 do -- begin closure to overcome local limits and interference
 
@@ -872,6 +872,10 @@
       end
     end
 end
+local f_16_16=formatters["%0.5N"]
+function number.to16dot16(n)
+  return f_16_16(n/65536.0)
+end
 
 end -- closure
 
@@ -3203,8 +3207,6 @@
   copyright="PRAGMA ADE / ConTeXt Development Team",
   license="see context related readme files"
 }
-local debug=require "debug"
-local getinfo,sethook=debug.getinfo,debug.sethook
 local type,next,tostring,tonumber=type,next,tostring,tonumber
 local format,find,sub,gsub=string.format,string.find,string.sub,string.gsub
 local insert,remove,sort=table.insert,table.remove,table.sort
@@ -3285,6 +3287,8 @@
   t[name]=v
   return v
 end)
+local getinfo=nil
+local sethook=nil
 local function hook(where)
   local f=getinfo(2,"nSl")
   if f then
@@ -3409,6 +3413,26 @@
   printer(format("calls     : %i",calls))
   printer(format("overhead  : %f",seconds(overhead/1000)))
 end
+local function getdebug()
+  if sethook and getinfo then
+    return
+  end
+  if not debug then
+    local okay
+    okay,debug=pcall(require,"debug")
+  end
+  if type(debug)~="table" then
+    return
+  end
+  getinfo=debug.getinfo
+  sethook=debug.sethook
+  if type(getinfo)~="function" then
+    getinfo=nil
+  end
+  if type(sethook)~="function" then
+    sethook=nil
+  end
+end
 function debugger.savestats(filename,threshold)
   local f=io.open(filename,'w')
   if f then
@@ -3417,7 +3441,8 @@
   end
 end
 function debugger.enable()
-  if nesting==0 then
+  getdebug()
+  if sethook and getinfo and nesting==0 then
     running=true
     if initialize then
       initialize()
@@ -3438,23 +3463,26 @@
   if nesting>0 then
     nesting=nesting-1
   end
-  if nesting==0 then
+  if sethook and getinfo and nesting==0 then
     sethook()
   end
 end
 local function showtraceback(rep) 
-  local level=2 
-  local reporter=rep or report
-  while true do
-    local info=getinfo(level,"Sl")
-    if not info then
-      break
-    elseif info.what=="C" then
-      reporter("%2i : %s",level-1,"C function")
-    else
-      reporter("%2i : %s : %s",level-1,info.short_src,info.currentline)
+  getdebug()
+  if getinfo then
+    local level=2 
+    local reporter=rep or report
+    while true do
+      local info=getinfo(level,"Sl")
+      if not info then
+        break
+      elseif info.what=="C" then
+        reporter("%2i : %s",level-1,"C function")
+      else
+        reporter("%2i : %s : %s",level-1,info.short_src,info.currentline)
+      end
+      level=level+1
     end
-    level=level+1
   end
 end
 debugger.showtraceback=showtraceback

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -30,8 +30,8 @@
 
 local lualibs_extended_module = {
   name          = "lualibs-extended",
-  version       = 2.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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-lpeg.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -657,82 +657,6 @@
     end
 end
 
--- utf extensies
-
-utf = utf or (unicode and unicode.utf8) or { }
-
-local utfcharacters = utf and utf.characters or string.utfcharacters
-local utfgmatch     = utf and utf.gmatch
-local utfchar       = utf and utf.char
-
-lpeg.UP = lpeg.P
-
-if utfcharacters then
-
-    function lpeg.US(str)
-        local p = P(false)
-        for uc in utfcharacters(str) do
-            p = p + P(uc)
-        end
-        return p
-    end
-
-
-elseif utfgmatch then
-
-    function lpeg.US(str)
-        local p = P(false)
-        for uc in utfgmatch(str,".") do
-            p = p + P(uc)
-        end
-        return p
-    end
-
-else
-
-    function lpeg.US(str)
-        local p = P(false)
-        local f = function(uc)
-            p = p + P(uc)
-        end
-        lpegmatch((utf8char/f)^0,str)
-        return p
-    end
-
-end
-
-local range = utf8byte * utf8byte + Cc(false) -- utf8byte is already a capture
-
-function lpeg.UR(str,more)
-    local first, last
-    if type(str) == "number" then
-        first = str
-        last = more or first
-    else
-        first, last = lpegmatch(range,str)
-        if not last then
-            return P(str)
-        end
-    end
-    if first == last then
-        return P(str)
-    elseif utfchar and (last - first < 8) then -- a somewhat arbitrary criterium
-        local p = P(false)
-        for i=first,last do
-            p = p + P(utfchar(i))
-        end
-        return p -- nil when invalid range
-    else
-        local f = function(b)
-            return b >= first and b <= last
-        end
-        -- tricky, these nested captures
-        return utf8byte / f -- nil when invalid range
-    end
-end
-
--- print(lpeg.match(lpeg.Cs((C(lpeg.UR("αω"))/{ ["χ"] = "OEPS" })^0),"αωχαω"))
-
 -- lpeg.print(lpeg.R("ab","cd","gh"))
 -- lpeg.print(lpeg.P("a","b","c"))
 -- lpeg.print(lpeg.S("a","b","c"))
@@ -1051,7 +975,6 @@
     end
 end
 
-
 -- local t = { "start", "stoep", "staart", "paard" }
 -- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/string.upper + 1)^1)
 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -81,13 +81,14 @@
         "0", "0", "0", "0", "0", "0", "0", "0",
     }
 
-    function number.tobitstring(b,m)
-        -- if really needed we can speed this one up
-        -- because small numbers need less extraction
-        local n = 32
-        for i=0,31 do
+    function number.tobitstring(b,m,w)
+        if not w then
+            w = 32
+        end
+        local n = w
+        for i=0,w-1 do
             local v = bextract(b,i)
-            local k = 32 - i
+            local k = w - i
             if v == 1 then
                 n = k
                 t[k] = "1"
@@ -95,12 +96,14 @@
                 t[k] = "0"
             end
         end
-        if m then
+        if w then
+            return concat(t,"",1,w)
+        elseif m then
             m = 33 - m * 8
             if m < 1 then
                 m = 1
             end
-            return concat(t,"",m)
+            return concat(t,"",1,m)
         elseif n < 8 then
             return concat(t)
         elseif n < 16 then

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -32,6 +32,72 @@
 local random, ceil, randomseed = math.random, math.ceil, math.randomseed
 local rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring = rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring
 
+-- This check needs to happen real early on. Todo: we can pick it up from the commandline
+-- if we pass --binpath= (which is useful anyway)
+
+do
+    local selfdir = os.selfdir
+    if selfdir == "" then
+        selfdir = nil
+    end
+    if not selfdir then
+        -- We need a fallback plan so let's see what we get.
+        if arg then
+            -- passed by mtx-context ... saves network access
+            for i=1,#arg do
+                local a = arg[i]
+                if find(a,"^%-%-[c:]*texmfbinpath=") then
+                    selfdir = gsub(a,"^.-=","")
+                    break
+                end
+            end
+        end
+        if not selfdir then
+            selfdir = os.selfbin or "luatex"
+            if find(selfdir,"[/\\]") then
+                selfdir = gsub(selfdir,"[/\\][^/\\]*$","")
+            elseif os.getenv then
+                local path = os.getenv("PATH")
+                local name = gsub(selfdir,"^.*[/\\][^/\\]","")
+                local patt = "[^:]+"
+                if os.type == "windows" then
+                    patt = "[^;]+"
+                    name = name .. ".exe"
+                end
+                local isfile
+                if lfs then
+                    -- we're okay as lfs is assumed present
+                    local attributes = lfs.attributes
+                    isfile = function(name)
+                        local a = attributes(name,"mode")
+                        return a == "file" or a == "link" or nil
+                    end
+                else
+                    -- we're not okay and much will not work as we miss lfs
+                    local open = io.open
+                    isfile = function(name)
+                        local f = open(name)
+                        if f then
+                            f:close()
+                            return true
+                        end
+                    end
+                end
+                for p in gmatch(path,patt) do
+                    -- possible speedup: there must be tex in 'p'
+                    if isfile(p .. "/" .. name) then
+                        selfdir = p
+                        break
+                    end
+                end
+            end
+        end
+        -- let's hope we're okay now
+        os.selfdir = selfdir or "."
+    end
+end
+-- print(os.selfdir) os.exit()
+
 -- The following code permits traversing the environment table, at least in luatex. Internally all
 -- environment names are uppercase.
 

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -11,7 +11,6 @@
 local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove
 local format, lower, dump = string.format, string.lower, string.dump
 local getmetatable, setmetatable = getmetatable, setmetatable
-local getinfo = debug.getinfo
 local lpegmatch, patterns = lpeg.match, lpeg.patterns
 local floor = math.floor
 
@@ -830,22 +829,25 @@
                 end
             elseif tv == "function" then
                 if functions then
-                    local f = getinfo(v).what == "C" and dump(dummy) or dump(v) -- maybe strip
-                 -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v) -- maybe strip
-                    if tk == "number" then
-                        if hexify then
-                            handle(format("%s [0x%X]=load(%q),",depth,k,f))
+                    local getinfo = debug and debug.getinfo
+                    if getinfo then
+                        local f = getinfo(v).what == "C" and dump(dummy) or dump(v) -- maybe strip
+                     -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v) -- maybe strip
+                        if tk == "number" then
+                            if hexify then
+                                handle(format("%s [0x%X]=load(%q),",depth,k,f))
+                            else
+                                handle(format("%s [%s]=load(%q),",depth,k,f))
+                            end
+                        elseif tk == "boolean" then
+                            handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f))
+                        elseif tk ~= "string" then
+                            -- ignore
+                        elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+                            handle(format("%s %s=load(%q),",depth,k,f))
                         else
-                            handle(format("%s [%s]=load(%q),",depth,k,f))
+                            handle(format("%s [%q]=load(%q),",depth,k,f))
                         end
-                    elseif tk == "boolean" then
-                        handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f))
-                    elseif tk ~= "string" then
-                        -- ignore
-                    elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
-                        handle(format("%s %s=load(%q),",depth,k,f))
-                    else
-                        handle(format("%s [%q]=load(%q),",depth,k,f))
                     end
                 end
             else

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -21,14 +21,34 @@
 -- todo: utf.sub replacement (used in syst-aux)
 -- we put these in the utf namespace:
 
--- used     : byte char gmatch len lower sub upper
--- not used : dump find format gfind gsub match rep reverse
+-- used     : byte char len lower sub upper
+-- not used : dump find format gmatch gfind gsub match rep reverse
 
-utf = utf or (unicode and unicode.utf8) or { }
+-- utf  = utf or (unicode and unicode.utf8) or { }
 
-utf.characters = utf.characters or string.utfcharacters
-utf.values     = utf.values     or string.utfvalues
+-- not supported:
+--
+-- dump, find, format, gfind, gmatch, gsub, lower, match, rep, reverse, upper
 
+utf     = utf or { }
+-- unicode = nil
+
+if not string.utfcharacters then
+
+    -- New: this gmatch hack is taken from the Lua 5.2 book. It's about two times slower
+    -- than the built-in string.utfcharacters.
+
+    local gmatch = string.gmatch
+
+    function string.characters(str)
+        return gmatch(str,".[\128-\191]*")
+    end
+
+
+end
+
+utf.characters = string.utfcharacters
+
 -- string.utfvalues
 -- string.utfcharacters
 -- string.characters
@@ -53,24 +73,20 @@
 local finder          = lpeg.finder
 local replacer        = lpeg.replacer
 
-local utfvalues       = utf.values
-local utfgmatch       = utf.gmatch -- not always present
-
 local p_utftype       = patterns.utftype
 local p_utfstricttype = patterns.utfstricttype
 local p_utfoffset     = patterns.utfoffset
-local p_utf8char      = patterns.utf8character
+local p_utf8character = patterns.utf8character
+local p_utf8char      = patterns.utf8char
 local p_utf8byte      = patterns.utf8byte
 local p_utfbom        = patterns.utfbom
 local p_newline       = patterns.newline
 local p_whitespace    = patterns.whitespace
 
-if not unicode then
+-- if not unicode then
+--     unicode = { utf = utf } -- for a while
+-- end
 
-    unicode = { utf = utf } -- for a while
-
-end
-
 if not utf.char then
 
     utf.char = string.utfcharacter or (utf8 and utf8.char)
@@ -164,10 +180,8 @@
 
     if not utf.byte then
 
-        local utf8byte = patterns.utf8byte
-
         function utf.byte(c)
-            return lpegmatch(utf8byte,c)
+            return lpegmatch(p_utf8byte,c)
         end
 
     end
@@ -281,7 +295,7 @@
 
         -- -- alternative 1: 0.77
         --
-        -- local utfcharcounter = utfbom^-1 * Cs((p_utf8char/'!')^0)
+        -- local utfcharcounter = utfbom^-1 * Cs((p_utf8character/'!')^0)
         --
         -- function utf.len(str)
         --     return #lpegmatch(utfcharcounter,str or "")
@@ -291,7 +305,7 @@
         --
         -- local n = 0
         --
-        -- local utfcharcounter = utfbom^-1 * (p_utf8char/function() n = n + 1 end)^0 -- slow
+        -- local utfcharcounter = utfbom^-1 * (p_utf8character/function() n = n + 1 end)^0 -- slow
         --
         -- function utf.length(str)
         --     n = 0
@@ -368,7 +382,7 @@
     -- inefficient as lpeg just copies ^n
 
     -- local function sub(str,start,stop)
-    --     local pattern = p_utf8char^-(start-1) * C(p_utf8char^-(stop-start+1))
+    --     local pattern = p_utf8character^-(start-1) * C(p_utf8character^-(stop-start+1))
     --     inspect(pattern)
     --     return lpegmatch(pattern,str) or ""
     -- end
@@ -391,7 +405,7 @@
     --     end
     -- end
     --
-    -- local pattern = Cmt(p_utf8char,slide)^0
+    -- local pattern = Cmt(p_utf8character,slide)^0
     --
     -- function utf.sub(str,start,stop) -- todo: from the end
     --     if not start then
@@ -446,11 +460,11 @@
         end
     end
 
-    local pattern_zero  = Cmt(p_utf8char,slide_zero)^0
-    local pattern_one   = Cmt(p_utf8char,slide_one )^0
-    local pattern_two   = Cmt(p_utf8char,slide_two )^0
+    local pattern_zero  = Cmt(p_utf8character,slide_zero)^0
+    local pattern_one   = Cmt(p_utf8character,slide_one )^0
+    local pattern_two   = Cmt(p_utf8character,slide_two )^0
 
-    local pattern_first = C(patterns.utf8character)
+    local pattern_first = C(p_utf8character)
 
     function utf.sub(str,start,stop)
         if not start then
@@ -546,7 +560,7 @@
 -- a replacement for simple gsubs:
 
 -- function utf.remapper(mapping)
---     local pattern = Cs((p_utf8char/mapping)^0)
+--     local pattern = Cs((p_utf8character/mapping)^0)
 --     return function(str)
 --         if not str or str == "" then
 --             return ""
@@ -568,16 +582,16 @@
                     return ""
                 else
                     if not pattern then
-                        pattern = Cs((tabletopattern(mapping)/action + p_utf8char)^0)
+                        pattern = Cs((tabletopattern(mapping)/action + p_utf8character)^0)
                     end
                     return lpegmatch(pattern,str)
                 end
             end
         elseif option == "pattern" then
-            return Cs((tabletopattern(mapping)/action + p_utf8char)^0)
+            return Cs((tabletopattern(mapping)/action + p_utf8character)^0)
      -- elseif option == "static" then
         else
-            local pattern = Cs((tabletopattern(mapping)/action + p_utf8char)^0)
+            local pattern = Cs((tabletopattern(mapping)/action + p_utf8character)^0)
             return function(str)
                 if not str or str == "" then
                     return ""
@@ -588,9 +602,9 @@
         end
     elseif variant == "function" then
         if option == "pattern" then
-            return Cs((p_utf8char/mapping + p_utf8char)^0)
+            return Cs((p_utf8character/mapping + p_utf8character)^0)
         else
-            local pattern = Cs((p_utf8char/mapping + p_utf8char)^0)
+            local pattern = Cs((p_utf8character/mapping + p_utf8character)^0)
             return function(str)
                 if not str or str == "" then
                     return ""
@@ -637,9 +651,9 @@
 -- inspect(utf.split("a b c d",true))
 
 local utflinesplitter     = p_utfbom^-1 * lpeg.tsplitat(p_newline)
-local utfcharsplitter_ows = p_utfbom^-1 * Ct(C(p_utf8char)^0)
-local utfcharsplitter_iws = p_utfbom^-1 * Ct((p_whitespace^1 + C(p_utf8char))^0)
-local utfcharsplitter_raw = Ct(C(p_utf8char)^0)
+local utfcharsplitter_ows = p_utfbom^-1 * Ct(C(p_utf8character)^0)
+local utfcharsplitter_iws = p_utfbom^-1 * Ct((p_whitespace^1 + C(p_utf8character))^0)
+local utfcharsplitter_raw = Ct(C(p_utf8character)^0)
 
 patterns.utflinesplitter  = utflinesplitter
 
@@ -775,7 +789,7 @@
 --                 if right then
 --                     local now = 256*left + right
 --                     if more > 0 then
---                         now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+--                         now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
 --                         more = 0
 --                         r = r + 1
 --                         result[r] = utfchar(now)
@@ -804,7 +818,7 @@
 --         if right then
 --             local now = 256*right + left
 --             if more > 0 then
---                 now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+--                 now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
 --                 more = 0
 --                 r = r + 1
 --                 result[r] = utfchar(now)
@@ -834,7 +848,7 @@
 --                 if right then
 --                     local now = 256*right + left
 --                     if more > 0 then
---                         now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+--                         now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
 --                         more = 0
 --                         r = r + 1
 --                         result[r] = utfchar(now)
@@ -911,7 +925,7 @@
 local p_utf16_to_utf8_be = C(1) * C(1) /function(left,right)
     local now = 256*byte(left) + byte(right)
     if more > 0 then
-        now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+        now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
         more = 0
         return utfchar(now)
     elseif now >= 0xD800 and now <= 0xDBFF then
@@ -925,7 +939,7 @@
 local p_utf16_to_utf8_le = C(1) * C(1) /function(right,left)
     local now = 256*byte(left) + byte(right)
     if more > 0 then
-        now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+        now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
         more = 0
         return utfchar(now)
     elseif now >= 0xD800 and now <= 0xDBFF then
@@ -1119,15 +1133,6 @@
     end
 end
 
--- function utf.tocodes(str,separator) -- can be sped up with an lpeg
---     local t, n = { }, 0
---     for u in utfvalues(str) do
---         n = n + 1
---         t[n] = format("0x%04X",u)
---     end
---     return concat(t,separator or " ")
--- end
-
 local pattern = Cs (
     (p_utf8byte           / function(unicode          ) return format(  "0x%04X",          unicode) end) *
     (p_utf8byte * Carg(1) / function(unicode,separator) return format("%s0x%04X",separator,unicode) end)^0
@@ -1163,28 +1168,13 @@
 
 --
 
-local p_nany = p_utf8char / ""
+do
 
-if utfgmatch then
+    local p_nany = p_utf8character / ""
+    local cache  = { }
 
     function utf.count(str,what)
         if type(what) == "string" then
-            local n = 0
-            for _ in utfgmatch(str,what) do
-                n = n + 1
-            end
-            return n
-        else -- 4 times slower but still faster than / function
-            return #lpegmatch(Cs((P(what)/" " + p_nany)^0),str)
-        end
-    end
-
-else
-
-    local cache = { }
-
-    function utf.count(str,what)
-        if type(what) == "string" then
             local p = cache[what]
             if not p then
                 p = Cs((P(what)/" " + p_nany)^0)
@@ -1198,24 +1188,8 @@
 
 end
 
--- maybe also register as string.utf*
+if not string.utfvalues then
 
-
-if not utf.characters then
-
-    -- New: this gmatch hack is taken from the Lua 5.2 book. It's about two times slower
-    -- than the built-in string.utfcharacters.
-
-    function utf.characters(str)
-        return gmatch(str,".[\128-\191]*")
-    end
-
-    string.utfcharacters = utf.characters
-
-end
-
-if not utf.values then
-
     -- So, a logical next step is to check for the values variant. It over five times
     -- slower than the built-in string.utfvalues. I optimized it a bit for n=0,1.
 
@@ -1226,7 +1200,7 @@
         -- we share this one
     end
 
-    -- function utf.values(str)
+    -- function string.utfvalues(str)
     --     local n = #str
     --     if n == 0 then
     --         return wrap(dummy)
@@ -1241,7 +1215,7 @@
     --
     -- faster:
 
-    function utf.values(str)
+    function string.utfvalues(str)
         local n = #str
         if n == 0 then
             return dummy
@@ -1264,11 +1238,11 @@
 
     -- slower:
     --
-    -- local pattern = C(patterns.utf8character) * Cp()
-    -- ----- pattern = patterns.utf8character/utfbyte * Cp()
-    -- ----- pattern = patterns.utf8byte * Cp()
+    -- local pattern = C(p_utf8character) * Cp()
+    -- ----- pattern = p_utf8character/utfbyte * Cp()
+    -- ----- pattern = p_utf8byte * Cp()
     --
-    -- function utf.values(str) -- one of the cases where a find is faster than an lpeg
+    -- function string.utfvalues(str) -- one of the cases where a find is faster than an lpeg
     --     local n = #str
     --     if n == 0 then
     --         return dummy
@@ -1287,10 +1261,10 @@
     --     end
     -- end
 
-    string.utfvalues = utf.values
-
 end
 
+utf.values = string.utfvalues
+
 function utf.chrlen(u) -- u is number
     return
         (u < 0x80 and 1) or
@@ -1310,7 +1284,7 @@
     local extract = bit32.extract
     local char    = string.char
 
-    function unicode.toutf32string(n)
+    function utf.toutf32string(n)
         if n <= 0xFF then
             return
                 char(n) ..
@@ -1359,3 +1333,73 @@
     end
     return s
 end
+
+-- goodies
+
+do
+
+    local utfcharacters = utf.characters or string.utfcharacters
+    local utfchar       = utf.char       or string.utfcharacter
+
+    lpeg.UP = P
+
+    if utfcharacters then
+
+        function lpeg.US(str)
+            local p = P(false)
+            for uc in utfcharacters(str) do
+                p = p + P(uc)
+            end
+            return p
+        end
+
+    else
+
+        function lpeg.US(str)
+            local p = P(false)
+            local f = function(uc)
+                p = p + P(uc)
+            end
+            lpegmatch((p_utf8char/f)^0,str)
+            return p
+        end
+
+    end
+
+    local range = p_utf8byte * p_utf8byte + Cc(false) -- utf8byte is already a capture
+
+    function lpeg.UR(str,more)
+        local first, last
+        if type(str) == "number" then
+            first = str
+            last = more or first
+        else
+            first, last = lpegmatch(range,str)
+            if not last then
+                return P(str)
+            end
+        end
+        if first == last then
+            return P(str)
+        end
+        if not utfchar then
+            utfchar = utf.char -- maybe delayed
+        end
+        if utfchar and (last - first < 8) then -- a somewhat arbitrary criterium
+            local p = P(false)
+            for i=first,last do
+                p = p + P(utfchar(i))
+            end
+            return p -- nil when invalid range
+        else
+            local f = function(b)
+                return b >= first and b <= last
+            end
+            -- tricky, these nested captures
+            return p_utf8byte / f -- nil when invalid range
+        end
+    end
+
+    -- print(lpeg.match(lpeg.Cs((C(lpeg.UR("αω"))/{ ["χ"] = "OEPS" })^0),"αωχαω"))
+
+end

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -10,9 +10,6 @@
 -- bound to a variable, like node.new, node.copy etc (contrary to for instance
 -- node.has_attribute which is bound to a has_attribute local variable in mkiv)
 
-local debug = require "debug"
-
-local getinfo, sethook = debug.getinfo, debug.sethook
 local type, next, tostring, tonumber = type, next, tostring, tonumber
 local format, find, sub, gsub = string.format, string.find, string.sub, string.gsub
 local insert, remove, sort = table.insert, table.remove, table.sort
@@ -109,6 +106,9 @@
     return v
 end)
 
+local getinfo = nil
+local sethook = nil
+
 local function hook(where)
     local f = getinfo(2,"nSl")
     if f then
@@ -240,6 +240,27 @@
  -- table.save("luatex-profile.lua",names)
 end
 
+local function getdebug()
+    if sethook and getinfo then
+        return
+    end
+    if not debug then
+        local okay
+        okay, debug = pcall(require,"debug")
+    end
+    if type(debug) ~= "table" then
+        return
+    end
+    getinfo = debug.getinfo
+    sethook = debug.sethook
+    if type(getinfo) ~= "function" then
+        getinfo = nil
+    end
+    if type(sethook) ~= "function" then
+        sethook = nil
+    end
+end
+
 function debugger.savestats(filename,threshold)
     local f = io.open(filename,'w')
     if f then
@@ -249,7 +270,8 @@
 end
 
 function debugger.enable()
-    if nesting == 0 then
+    getdebug()
+    if sethook and getinfo and nesting == 0 then
         running = true
         if initialize then
             initialize()
@@ -271,7 +293,7 @@
     if nesting > 0 then
         nesting = nesting - 1
     end
-    if nesting == 0 then
+    if sethook and getinfo and nesting == 0 then
         sethook()
     end
 end
@@ -294,20 +316,25 @@
 -- from the lua book:
 
 local function showtraceback(rep) -- from lua site / adapted
-    local level = 2 -- we don't want this function to be reported
-    local reporter = rep or report
-    while true do
-        local info = getinfo(level, "Sl")
-        if not info then
-            break
-        elseif info.what == "C" then
-            reporter("%2i : %s",level-1,"C function")
-        else
-            reporter("%2i : %s : %s",level-1,info.short_src,info.currentline)
+    getdebug()
+    if getinfo then
+        local level = 2 -- we don't want this function to be reported
+        local reporter = rep or report
+        while true do
+            local info = getinfo(level, "Sl")
+            if not info then
+                break
+            elseif info.what == "C" then
+                reporter("%2i : %s",level-1,"C function")
+            else
+                reporter("%2i : %s : %s",level-1,info.short_src,info.currentline)
+            end
+            level = level + 1
         end
-        level = level + 1
     end
 end
 
 debugger.showtraceback = showtraceback
 -- debug.showtraceback = showtraceback
+
+-- showtraceback()

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -1415,3 +1415,11 @@
             end
         end
 end
+
+--
+
+local f_16_16 = formatters["%0.5N"]
+
+function number.to16dot16(n)
+    return f_16_16(n/65536.0)
+end

Modified: trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua	2019-01-17 21:28:35 UTC (rev 49740)
+++ trunk/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua	2019-01-17 21:28:52 UTC (rev 49741)
@@ -25,8 +25,8 @@
 
 lualibs.module_info = {
   name          = "lualibs",
-  version       = 2.61,
-  date          = "2018-10-18",
+  version       = 2.62,
+  date          = "2018-12-19",
   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