summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/luatex/lualibs/NEWS3
-rw-r--r--Master/texmf-dist/doc/luatex/lualibs/README8
-rw-r--r--Master/texmf-dist/doc/luatex/lualibs/lualibs.pdfbin80496 -> 80641 bytes
-rw-r--r--Master/texmf-dist/source/luatex/lualibs/lualibs.dtx18
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua294
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua60
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua77
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua19
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua66
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua32
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua228
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua59
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua8
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs.lua4
16 files changed, 515 insertions, 369 deletions
diff --git a/Master/texmf-dist/doc/luatex/lualibs/NEWS b/Master/texmf-dist/doc/luatex/lualibs/NEWS
index f930695f28f..376ce105b7c 100644
--- a/Master/texmf-dist/doc/luatex/lualibs/NEWS
+++ b/Master/texmf-dist/doc/luatex/lualibs/NEWS
@@ -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
diff --git a/Master/texmf-dist/doc/luatex/lualibs/README b/Master/texmf-dist/doc/luatex/lualibs/README
index e6d08535f1d..20351af8f2f 100644
--- a/Master/texmf-dist/doc/luatex/lualibs/README
+++ b/Master/texmf-dist/doc/luatex/lualibs/README
@@ -11,8 +11,8 @@ for use independent of ConTeXt.
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 @@ Source files:
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 @@ Source files:
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
diff --git a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
index 70cb2e2cc31..beedbe0ff9f 100644
--- a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
+++ b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx
index fcfe0b02243..607b51338f6 100644
--- a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx
+++ b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx
@@ -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 @@ and lualibs-extended.lua.
%<*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 @@ and lualibs-extended.lua.
% \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@telecom-bretagne.eu}\\
% Philipp Gesang · \email{phg@phi-gamma.net}\\
% Ulrike Fischer · \email{fischer@troubleshooting-tex.de}\\
@@ -429,8 +429,8 @@ lualibs = lualibs or { }
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 loadmodule = lualibs.loadmodule
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 @@ lualibs = lualibs or { }
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",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
index db130567123..d94b696b3d9 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-basic-merged.lua
-- parent file : lualibs-basic.lua
--- merge date : 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 @@ function lpeg.counter(pattern,action)
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 table,string=table,string
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 @@ local function do_serialize(root,name,depth,level,indexed)
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 @@ if bit32 then
"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 @@ if bit32 then
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 find,format,gsub,upper,gmatch=string.find,string.format,string.gsub,string
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 @@ if not modules then modules={} end modules ['l-unicode']={
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 tabletopattern=lpeg.utfchartabletopattern
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 @@ end
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 @@ if not utf.sub then
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 @@ function utf.remapper(mapping,option,action)
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 @@ function utf.remapper(mapping,option,action)
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 @@ function utf.subtituter(t)
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 more=0
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 @@ end
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 @@ function utf.toeight(str)
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 @@ else
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 @@ if not utf.values then
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 @@ end
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 @@ function string.utfpadd(s,n)
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
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
index 3ddb39f7ccf..32024f47147 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua
@@ -29,8 +29,8 @@ local loadmodule = lualibs.loadmodule
local lualibs_basic_module = {
name = "lualibs-basic",
- version = 2.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",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
index c2a5fc242af..2d973be3b95 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-extended-merged.lua
-- parent file : lualibs-extended.lua
--- merge date : 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 @@ function strings.newcollector()
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 @@ if not modules then modules={} end modules ['util-deb']={
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 @@ setmetatableindex(names,function(t,name)
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 @@ function debugger.showstats(printer,threshold)
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 @@ function debugger.savestats(filename,threshold)
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 @@ function debugger.disable()
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
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
index 6a46d6c1cf9..fda759cc1df 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua
@@ -30,8 +30,8 @@ lualibs = lualibs or { }
local lualibs_extended_module = {
name = "lualibs-extended",
- version = 2.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",
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua
index 589fa2b0b22..51bc1d3df30 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua
@@ -657,82 +657,6 @@ function lpeg.counter(pattern,action)
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 @@ function lpeg.utfreplacer(list,insensitive)
end
end
-
-- local t = { "start", "stoep", "staart", "paard" }
-- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/string.upper + 1)^1)
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua
index dc4a93b0ec0..9fd2f82f785 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-number.lua
@@ -81,13 +81,14 @@ if bit32 then
"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 @@ if bit32 then
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
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
index c2a903f5c3f..cf469f79d32 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua
@@ -32,6 +32,72 @@ 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
+-- 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.
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
index 69f45d9b4cd..eae13513990 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
@@ -11,7 +11,6 @@ local table, string = table, string
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 @@ local function do_serialize(root,name,depth,level,indexed)
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
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
index b5f52d3127c..73d1eb7660c 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua
@@ -21,13 +21,33 @@ if not modules then modules = { } end modules ['l-unicode'] = {
-- 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 { }
+
+-- 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
-utf.characters = utf.characters or string.utfcharacters
-utf.values = utf.values or string.utfvalues
+
+end
+
+utf.characters = string.utfcharacters
-- string.utfvalues
-- string.utfcharacters
@@ -53,23 +73,19 @@ local bytepairs = string.bytepairs
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
-
- unicode = { utf = utf } -- for a while
-
-end
+-- if not unicode then
+-- unicode = { utf = utf } -- for a while
+-- end
if not utf.char then
@@ -164,10 +180,8 @@ if not utf.byte then
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 @@ if not utf.len then
-- -- 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 @@ if not utf.len then
--
-- 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 @@ if not utf.sub then
-- 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 @@ if not utf.sub then
-- 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 @@ if not utf.sub then
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 @@ end
-- 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 @@ function utf.remapper(mapping,option,action) -- static also returns a pattern
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 @@ function utf.remapper(mapping,option,action) -- static also returns a pattern
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 @@ end
-- 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 @@ local utf_32_le_linesplitter = utf_32_le_getbom * lpeg.tsplitat(patterns.utf_32_
-- 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 @@ local utf_32_le_linesplitter = utf_32_le_getbom * lpeg.tsplitat(patterns.utf_32_
-- 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 @@ local utf_32_le_linesplitter = utf_32_le_getbom * lpeg.tsplitat(patterns.utf_32_
-- 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 more = 0
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 @@ end
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 @@ function utf.utf8_to_utf16(str,littleendian,nobom)
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,25 +1168,10 @@ 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 -- 4 times slower but still faster than / function
- return #lpegmatch(Cs((P(what)/" " + p_nany)^0),str)
- end
- end
-
-else
+do
- local cache = { }
+ local p_nany = p_utf8character / ""
+ local cache = { }
function utf.count(str,what)
if type(what) == "string" then
@@ -1198,23 +1188,7 @@ else
end
--- maybe also register as string.utf*
-
-
-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
+if not string.utfvalues 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 @@ if not utf.values then
-- 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 @@ if not utf.values then
--
-- faster:
- function utf.values(str)
+ function string.utfvalues(str)
local n = #str
if n == 0 then
return dummy
@@ -1264,11 +1238,11 @@ if not utf.values then
-- 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 @@ if not utf.values then
-- 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 @@ 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) ..
@@ -1359,3 +1333,73 @@ function string.utfpadd(s,n)
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
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
index 9488a728b61..6932e8804d3 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-deb.lua
@@ -10,9 +10,6 @@ if not modules then modules = { } end modules ['util-deb'] = {
-- 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 @@ setmetatableindex(names,function(t,name)
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 @@ function debugger.showstats(printer,threshold)
-- 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 @@ function debugger.savestats(filename,threshold)
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 @@ function debugger.disable()
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 @@ end
-- 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()
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
index f090bce55cc..508d32d71cf 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua
@@ -1415,3 +1415,11 @@ function strings.newcollector()
end
end
end
+
+--
+
+local f_16_16 = formatters["%0.5N"]
+
+function number.to16dot16(n)
+ return f_16_16(n/65536.0)
+end
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
index e375e8481cc..21d2a122c81 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
@@ -25,8 +25,8 @@ lualibs = lualibs or { }
lualibs.module_info = {
name = "lualibs",
- version = 2.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",