summaryrefslogtreecommitdiff
path: root/tex/context/base
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-07-22 22:33:21 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-07-22 22:33:21 +0200
commitdd7c4b1a54bfc5e358eb9f766c0b865fc47cbe46 (patch)
tree2e8888da6188eb742a98c3c05a26e2b75b198e62 /tex/context/base
parent50928735daee408de73737b055b2535d96424824 (diff)
downloadcontext-dd7c4b1a54bfc5e358eb9f766c0b865fc47cbe46.tar.gz
2016-07-22 20:13:00
Diffstat (limited to 'tex/context/base')
-rw-r--r--tex/context/base/context-version.pdfbin4267 -> 4256 bytes
-rw-r--r--tex/context/base/mkiv/anch-pos.lua39
-rw-r--r--tex/context/base/mkiv/buff-ini.lua31
-rw-r--r--tex/context/base/mkiv/chem-str.lua2
-rw-r--r--tex/context/base/mkiv/cldf-bas.lua80
-rw-r--r--tex/context/base/mkiv/cldf-com.lua36
-rw-r--r--tex/context/base/mkiv/cldf-ini.lua900
-rw-r--r--tex/context/base/mkiv/cldf-int.lua96
-rw-r--r--tex/context/base/mkiv/cldf-stp.lua20
-rw-r--r--tex/context/base/mkiv/colo-ini.lua56
-rw-r--r--tex/context/base/mkiv/colo-run.lua9
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/core-uti.lua4
-rw-r--r--tex/context/base/mkiv/file-job.lua12
-rw-r--r--tex/context/base/mkiv/font-ctx.lua10
-rw-r--r--tex/context/base/mkiv/font-gbn.lua4
-rw-r--r--tex/context/base/mkiv/font-nod.lua4
-rw-r--r--tex/context/base/mkiv/font-odv.lua12
-rw-r--r--tex/context/base/mkiv/font-osd.lua12
-rw-r--r--tex/context/base/mkiv/font-otn.lua4
-rw-r--r--tex/context/base/mkiv/font-ots.lua6
-rw-r--r--tex/context/base/mkiv/font-sol.lua24
-rw-r--r--tex/context/base/mkiv/font-syn.lua9
-rw-r--r--tex/context/base/mkiv/grph-inc.lua45
-rw-r--r--tex/context/base/mkiv/math-acc.mkvi31
-rw-r--r--tex/context/base/mkiv/math-ini.lua142
-rw-r--r--tex/context/base/mkiv/math-ini.mkiv1
-rw-r--r--tex/context/base/mkiv/math-noa.lua12
-rw-r--r--tex/context/base/mkiv/node-acc.lua74
-rw-r--r--tex/context/base/mkiv/node-aux.lua8
-rw-r--r--tex/context/base/mkiv/node-fnt.lua4
-rw-r--r--tex/context/base/mkiv/node-ltp.lua36
-rw-r--r--tex/context/base/mkiv/node-met.lua122
-rw-r--r--tex/context/base/mkiv/node-nut.lua174
-rw-r--r--tex/context/base/mkiv/node-ppt.lua1
-rw-r--r--tex/context/base/mkiv/node-ref.lua4
-rw-r--r--tex/context/base/mkiv/node-res.lua53
-rw-r--r--tex/context/base/mkiv/pack-rul.lua4
-rw-r--r--tex/context/base/mkiv/pack-rul.mkiv2
-rw-r--r--tex/context/base/mkiv/page-mix.lua4
-rw-r--r--tex/context/base/mkiv/page-str.lua28
-rw-r--r--tex/context/base/mkiv/publ-imp-aps.mkvi7
-rw-r--r--tex/context/base/mkiv/scrn-hlp.lua30
-rw-r--r--tex/context/base/mkiv/spac-ver.lua18
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9228 -> 9095 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin367430 -> 367592 bytes
-rw-r--r--tex/context/base/mkiv/strc-lev.lua13
-rw-r--r--tex/context/base/mkiv/supp-box.lua8
-rw-r--r--tex/context/base/mkiv/supp-box.mkiv13
-rw-r--r--tex/context/base/mkiv/syst-lua.lua42
-rw-r--r--tex/context/base/mkiv/tabl-tbl.mkiv30
-rw-r--r--tex/context/base/mkiv/tabl-xtb.lua206
-rw-r--r--tex/context/base/mkiv/trac-inf.lua1
-rw-r--r--tex/context/base/mkiv/trac-vis.lua5
-rw-r--r--tex/context/base/mkiv/typo-brk.lua10
-rw-r--r--tex/context/base/mkiv/typo-chr.lua4
-rw-r--r--tex/context/base/mkiv/typo-drp.lua2
-rw-r--r--tex/context/base/mkiv/typo-fln.lua8
-rw-r--r--tex/context/base/mkiv/typo-krn.lua4
-rw-r--r--tex/context/base/mkiv/typo-mar.lua6
61 files changed, 1269 insertions, 1257 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index a8a372180..c828f467a 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua
index 7d814677a..3042ea4a0 100644
--- a/tex/context/base/mkiv/anch-pos.lua
+++ b/tex/context/base/mkiv/anch-pos.lua
@@ -35,6 +35,7 @@ local scanners = interfaces.scanners
local commands = commands
local context = context
+local ctxnode = context.flushnode
local tex = tex
local texgetcount = tex.getcount
@@ -380,8 +381,8 @@ scanners.bposcolumnregistered = function() -- tag
local tag = scanstring()
insert(columns,tag)
column = tag
- -- context(new_latelua_node(f_b_column(tag)))
- context(new_latelua_node(function() b_column(tag) end))
+ -- ctxnode(new_latelua_node(f_b_column(tag)))
+ ctxnode(new_latelua_node(function() b_column(tag) end))
end
scanners.eposcolumn = function()
@@ -390,8 +391,8 @@ scanners.eposcolumn = function()
end
scanners.eposcolumnregistered = function()
- -- context(new_latelua_node(f_e_column()))
- context(new_latelua_node(e_column))
+ -- ctxnode(new_latelua_node(f_e_column()))
+ ctxnode(new_latelua_node(e_column))
remove(columns)
column = columns[#columns]
end
@@ -479,12 +480,6 @@ function jobpositions.gettobesaved(name,tag)
end
end
--- scanners.pos = function(name,t) -- name t
--- local name = scanstring()
--- tobesaved[name] = scanstring()
--- context(new_latelua_node(f_enhance(name)))
--- end
-
local nofparagraphs = 0
scanners.parpos = function() -- todo: relate to localpar (so this is an intermediate variant)
@@ -527,8 +522,8 @@ scanners.parpos = function() -- todo: relate to localpar (so this is an intermed
end
local tag = f_p_tag(nofparagraphs)
tobesaved[tag] = t
- -- context(new_latelua_node(f_enhance(tag)))
- context(new_latelua_node(function() enhance(tobesaved[tag]) end))
+ -- ctxnode(new_latelua_node(f_enhance(tag)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[tag]) end))
end
scanners.dosetposition = function() -- name
@@ -542,8 +537,8 @@ scanners.dosetposition = function() -- name
n = nofparagraphs > 0 and nofparagraphs or nil,
r2l = texgetcount("inlinelefttoright") == 1 or nil,
}
- -- context(new_latelua_node(f_enhance(name)))
- context(new_latelua_node(function() enhance(tobesaved[name]) end))
+ -- ctxnode(new_latelua_node(f_enhance(name)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionwhd = function() -- name w h d extra
@@ -563,8 +558,8 @@ scanners.dosetpositionwhd = function() -- name w h d extra
n = nofparagraphs > 0 and nofparagraphs or nil,
r2l = texgetcount("inlinelefttoright") == 1 or nil,
}
- -- context(new_latelua_node(f_enhance(name)))
- context(new_latelua_node(function() enhance(tobesaved[name]) end))
+ -- ctxnode(new_latelua_node(f_enhance(name)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionbox = function() -- name box
@@ -585,8 +580,8 @@ scanners.dosetpositionbox = function() -- name box
n = nofparagraphs > 0 and nofparagraphs or nil,
r2l = texgetcount("inlinelefttoright") == 1 or nil,
}
- -- context(new_latelua_node(f_enhance(name)))
- context(new_latelua_node(function() enhance(tobesaved[name]) end))
+ -- ctxnode(new_latelua_node(f_enhance(name)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionplus = function() -- name w h d extra
@@ -607,8 +602,8 @@ scanners.dosetpositionplus = function() -- name w h d extra
e = scanstring(),
r2l = texgetcount("inlinelefttoright") == 1 or nil,
}
- -- context(new_latelua_node(f_enhance(name)))
- context(new_latelua_node(function() enhance(tobesaved[name]) end))
+ -- ctxnode(new_latelua_node(f_enhance(name)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionstrut = function() -- name
@@ -627,8 +622,8 @@ scanners.dosetpositionstrut = function() -- name
n = nofparagraphs > 0 and nofparagraphs or nil,
r2l = texgetcount("inlinelefttoright") == 1 or nil,
}
- -- context(new_latelua_node(f_enhance(name)))
- context(new_latelua_node(function() enhance(tobesaved[name]) end))
+ -- ctxnode(new_latelua_node(f_enhance(name)))
+ ctxnode(new_latelua_node(function() enhance(tobesaved[name]) end))
end
function jobpositions.getreserved(tag,n)
diff --git a/tex/context/base/mkiv/buff-ini.lua b/tex/context/base/mkiv/buff-ini.lua
index 80272c1bf..876a6944e 100644
--- a/tex/context/base/mkiv/buff-ini.lua
+++ b/tex/context/base/mkiv/buff-ini.lua
@@ -591,18 +591,25 @@ implement {
arguments = "string"
}
-local startbuffer = context.startbuffer
-local stopbuffer = context.stopbuffer
+do
-local startcollecting = context.startcollecting
-local stopcollecting = context.stopcollecting
+ local context = context
+ local ctxcore = context.core
-function context.startbuffer(...)
- startcollecting()
- startbuffer(...)
-end
+ local startbuffer = ctxcore.startbuffer
+ local stopbuffer = ctxcore.stopbuffer
-function context.stopbuffer()
- stopbuffer()
- stopcollecting()
-end
+ local startcollecting = context.startcollecting
+ local stopcollecting = context.stopcollecting
+
+ function ctxcore.startbuffer(...)
+ startcollecting()
+ startbuffer(...)
+ end
+
+ function ctxcore.stopbuffer()
+ stopbuffer()
+ stopcollecting()
+ end
+
+ end
diff --git a/tex/context/base/mkiv/chem-str.lua b/tex/context/base/mkiv/chem-str.lua
index 13e121493..445b779a1 100644
--- a/tex/context/base/mkiv/chem-str.lua
+++ b/tex/context/base/mkiv/chem-str.lua
@@ -732,7 +732,7 @@ function chemistry.start(settings)
if trace_structure then
report_chemistry("skipping trial run")
end
- context.hrule(sp_width,sp_height,0) -- maybe depth
+ context.rule(sp_width,sp_height,0) -- maybe depth
return
end
--
diff --git a/tex/context/base/mkiv/cldf-bas.lua b/tex/context/base/mkiv/cldf-bas.lua
index 1067a17d5..dffeefeb7 100644
--- a/tex/context/base/mkiv/cldf-bas.lua
+++ b/tex/context/base/mkiv/cldf-bas.lua
@@ -22,15 +22,13 @@ if not modules then modules = { } end modules ['cldf-bas'] = {
-- flush(ctxcatcodes,"}")
-- end
--- maybe use context.generics
-
local type = type
local format = string.format
local utfchar = utf.char
local concat = table.concat
local context = context
-local generics = context.generics
+local ctxcore = context.core
local variables = interfaces.variables
local nodepool = nodes.pool
@@ -41,6 +39,8 @@ local current_font = font.current
local texgetcount = tex.getcount
local texsetcount = tex.setcount
+-- a set of basic fast ones
+
function context.char(k) -- used as escape too, so don't change to utf
if type(k) == "table" then
local n = #k
@@ -68,12 +68,6 @@ function context.utfchar(k)
end
end
--- plain variants
-
-function context.chardef(cs,u)
- context([[\chardef\%s=%s\relax]],k)
-end
-
function context.par()
context([[\par]]) -- no need to add {} there
end
@@ -90,7 +84,7 @@ function context.space()
context("\\space") -- no " " as that gets intercepted
end
-function context.hrule(w,h,d,dir)
+function context.rule(w,h,d,dir)
if type(w) == "table" then
context(new_rule(w.width,w.height,w.depth,w.dir))
else
@@ -107,34 +101,19 @@ function context.glyph(id,k)
end
end
-context.vrule = context.hrule
-
---~ local hbox, bgroup, egroup = context.hbox, context.bgroup, context.egroup
-
---~ function context.hbox(a,...)
---~ if type(a) == "table" then
---~ local s = { }
---~ if a.width then
---~ s[#s+1] = "to " .. a.width -- todo: check for number
---~ elseif a.spread then
---~ s[#s+1] = "spread " .. a.spread -- todo: check for number
---~ end
---~ -- todo: dir, attr etc
---~ hbox(false,table.concat(s," "))
---~ bgroup()
---~ context(string.format(...))
---~ egroup()
---~ else
---~ hbox(a,...)
---~ end
---~ end
+-- we also register these in core:
+
+ctxcore.par = context.par
+ctxcore.space = context.space
+ctxcore.bgroup = context.bgroup
+ctxcore.egroup = context.egroup
-- not yet used ... but will get variant at the tex end as well
-function context.sethboxregister(n) context([[\setbox %s\hbox]],n) end
-function context.setvboxregister(n) context([[\setbox %s\vbox]],n) end
+function ctxcore.sethboxregister(n) context([[\setbox %s\hbox]],n) end
+function ctxcore.setvboxregister(n) context([[\setbox %s\vbox]],n) end
-function context.starthboxregister(n)
+function ctxcore.starthboxregister(n)
if type(n) == "number" then
context([[\setbox%s\hbox{]],n)
else
@@ -142,7 +121,7 @@ function context.starthboxregister(n)
end
end
-function context.startvboxregister(n)
+function ctxcore.startvboxregister(n)
if type(n) == "number" then
context([[\setbox%s\vbox{]],n)
else
@@ -150,10 +129,10 @@ function context.startvboxregister(n)
end
end
-context.stophboxregister = context.egroup
-context.stopvboxregister = context.egroup
+ctxcore.stophboxregister = ctxcore.egroup
+ctxcore.stopvboxregister = ctxcore.egroup
-function context.flushboxregister(n)
+function ctxcore.flushboxregister(n)
if type(n) == "number" then
context([[\box%s ]],n)
else
@@ -161,16 +140,16 @@ function context.flushboxregister(n)
end
end
-function context.beginvbox()
+function ctxcore.beginvbox()
context([[\vbox{]]) -- we can do \bvbox ... \evbox (less tokens)
end
-function context.beginhbox()
+function ctxcore.beginhbox()
context([[\hbox{]]) -- todo: use fast one
end
-context.endvbox = context.egroup
-context.endhbox = context.egroup
+ctxcore.endvbox = ctxcore.egroup
+ctxcore.endhbox = ctxcore.egroup
local function allocate(name,what,cmd)
local a = format("c_syst_last_allocated_%s",what)
@@ -182,9 +161,14 @@ local function allocate(name,what,cmd)
return n
end
-function context.newdimen (name) return allocate(name,"dimen") end
-function context.newskip (name) return allocate(name,"skip") end
-function context.newcount (name) return allocate(name,"count") end
-function context.newmuskip(name) return allocate(name,"muskip") end
-function context.newtoks (name) return allocate(name,"toks") end
-function context.newbox (name) return allocate(name,"box","mathchar") end
+context.registers = {
+ -- the number is available directly, the csname after the lua call
+ newdimen = function(name) return allocate(name,"dimen") end,
+ newskip = function(name) return allocate(name,"skip") end,
+ newcount = function(name) return allocate(name,"count") end,
+ newmuskip = function(name) return allocate(name,"muskip") end,
+ newtoks = function(name) return allocate(name,"toks") end,
+ newbox = function(name) return allocate(name,"box","mathchar") end,
+ -- not really a register but kind of belongs here
+ chardef = function(name,u) context([[\chardef\%s=%s\relax]],name,u) end,
+}
diff --git a/tex/context/base/mkiv/cldf-com.lua b/tex/context/base/mkiv/cldf-com.lua
index bd357b712..f9bf5b41a 100644
--- a/tex/context/base/mkiv/cldf-com.lua
+++ b/tex/context/base/mkiv/cldf-com.lua
@@ -6,33 +6,27 @@ if not modules then modules = { } end modules ['cldf-com'] = {
license = "see context related readme files"
}
--- todo ... needs more thinking ... a special table toolkit
+-- Some day I'll make a table toolkit ...
-local tostring = tostring
-local context = context
-local generics = context.generics -- needs documentation
-local variables = interfaces.variables
+local tostring, select = tostring, select
-generics.starttabulate = "starttabulate" -- "start" .. variables.tabulate -- todo: e!start
-generics.stoptabulate = "stoptabulate" -- "stop" .. variables.tabulate -- todo: e!stop
+local context = context
+local ctxcore = context.core
-local NC, NR = context.NC, context.NR
+local ctx_NC = ctxcore.NC
+local ctx_NR = ctxcore.NR
local function tabulaterow(how,...)
+ local ctx_flush = how and context[how] or context
for i=1,select("#",...) do
- local ti = tostring(select(i,...))
- NC()
- if how then
- context[how](ti)
- else
- context(ti)
- end
+ ctx_NC()
+ ctx_flush(tostring(select(i,...)))
end
- NC()
- NR()
+ ctx_NC()
+ ctx_NR()
end
-function context.tabulaterow (...) tabulaterow(false, ...) end
-function context.tabulaterowbold(...) tabulaterow("bold",...) end
-function context.tabulaterowtype(...) tabulaterow("type",...) end
-function context.tabulaterowtyp (...) tabulaterow("typ", ...) end
+function ctxcore.tabulaterow (...) tabulaterow(false, ...) end
+function ctxcore.tabulaterowbold(...) tabulaterow("bold",...) end
+function ctxcore.tabulaterowtype(...) tabulaterow("type",...) end
+function ctxcore.tabulaterowtyp (...) tabulaterow("typ", ...) end
diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua
index f868975e5..a77f25f41 100644
--- a/tex/context/base/mkiv/cldf-ini.lua
+++ b/tex/context/base/mkiv/cldf-ini.lua
@@ -15,6 +15,8 @@ if not modules then modules = { } end modules ['cldf-ini'] = {
-- 0.651 local foo = getcount("ctxcatcodes")
-- 0.408 local foo = getcount(ctxcatcodes) -- local ctxcatcodes = tex.iscount("ctxcatcodes")
+-- maybe  (escape) or 0x2061 (apply function) or 0x2394 (software function ⎔)
+
-- This started as an experiment: generating context code at the lua end. After all
-- it is surprisingly simple to implement due to metatables. I was wondering if
-- there was a more natural way to deal with commands at the lua end. Of course it's
@@ -25,7 +27,6 @@ if not modules then modules = { } end modules ['cldf-ini'] = {
-- currently no coroutine trickery
-- we could always use prtcatcodes (context.a_b_c) but then we loose protection
-- tflush needs checking ... sort of weird that it's not a table
--- __flushlines is an experiment and rather ugly so it will go away
--
-- tex.print == line with endlinechar appended
@@ -41,6 +42,16 @@ if not modules then modules = { } end modules ['cldf-ini'] = {
-- context(string.formatters["%!tex!"]("${}"))
-- context("%!tex!","${}")
+-- We try not to polute the context namespace too much. For that reason the commands are
+-- registered in the context.core namespace. You can call all context commands using
+-- context.foo etc. and pipe to context with context("foo"). Defining a local command
+-- foo being context.foo is okay, as is context.core.foo. We will have some definitions
+-- that are plugged into the core namespace (mostly for speedup) but otherwise specialized
+-- writers are in the context namespace only. In your documents you can best use the
+-- context.foo(...) and context(...) variant but in some core modules we use the faster
+-- ones in critical places (no one will notice of course). The standard syntax highlighter
+-- that I use knows how to visualize ctx related code.
+
local format, stripstring = string.format, string.strip
local next, type, tostring, tonumber, setmetatable, unpack, select, rawset = next, type, tostring, tonumber, setmetatable, unpack, select, rawset
local insert, remove, concat = table.insert, table.remove, table.concat
@@ -274,14 +285,6 @@ local registerfunction, unregisterfunction, reservefunction, knownfunctions, cal
return slot
end
- -- do
- -- commands.test = function(str) report_cld("test function: %s", str) end
- -- if initex then
- -- registerfunction("commands.test") -- number 1
- -- end
- -- luafunctions[1]("okay")
- -- end
-
unregisterfunction = function(slot)
if luafunctions[slot] then
noffreed = noffreed + 1
@@ -430,12 +433,15 @@ local registerfunction, unregisterfunction, reservefunction, knownfunctions, cal
--
-- end
-context.registerfunction = registerfunction
-context.unregisterfunction = unregisterfunction
-context.reservefunction = reservefunction
-context.knownfunctions = knownfunctions
-context.callfunctiononce = callfunctiononce _cldo_ = callfunctiononce
-context.storenode = storenode -- private helper
+context.functions = {
+ register = registerfunction,
+ unregister = unregisterfunction,
+ reserve = reservefunction,
+ known = knownfunctions,
+ callonce = callfunctiononce,
+}
+
+context.storenode = storenode -- private helper
function commands.ctxfunction(code,namespace)
context(registerfunction(code,namespace))
@@ -670,10 +676,6 @@ local flushlines = context.newtexthandler {
simpleline = n_simpleline,
}
-context.__flushlines = flushlines -- maybe context.helpers.flushtexlines
-context.__flush = flush
-context.__flushdirect = flushdirect
-
-- The next variant is only used in rare cases (buffer to mp):
local printlines_ctx = (
@@ -698,302 +700,311 @@ end
local containseol = patterns.containseol
-local writer = nil
-local prtwriter = nil
-
--- if luafunctions then
-
- writer = function (parent,command,...) -- already optimized before call
- flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes
- local direct = false
- -- local t = { ... }
- -- for i=1,#t do
- -- local ti = t[i]
- for i=1,select("#",...) do
- local ti = (select(i,...))
- if direct then
- local typ = type(ti)
- if typ == "string" or typ == "number" then
- flush(currentcatcodes,ti)
- else -- node.write
- report_context("error: invalid use of direct in %a, only strings and numbers can be flushed directly, not %a",command,typ)
- end
- direct = false
- elseif ti == nil then
- -- nothing
- elseif ti == "" then
- flush(currentcatcodes,"{}")
- else
- local typ = type(ti)
- if typ == "string" then
- -- is processlines seen ?
- if processlines and lpegmatch(containseol,ti) then
- flush(currentcatcodes,"{")
- local flushlines = parent.__flushlines or flushlines
- flushlines(ti)
- flush(currentcatcodes,"}")
- elseif currentcatcodes == contentcatcodes then
- flush(currentcatcodes,"{",ti,"}")
- else
- flush(currentcatcodes,"{")
- flush(contentcatcodes,ti)
- flush(currentcatcodes,"}")
- end
- elseif typ == "number" then
- -- numbers never have funny catcodes
+local function writer(parent,command,...) -- already optimized before call
+ flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes
+ local direct = false
+ -- local t = { ... }
+ -- for i=1,#t do
+ -- local ti = t[i]
+ for i=1,select("#",...) do
+ local ti = (select(i,...))
+ if direct then
+ local typ = type(ti)
+ if typ == "string" or typ == "number" then
+ flush(currentcatcodes,ti)
+ else -- node.write
+ report_context("error: invalid use of direct in %a, only strings and numbers can be flushed directly, not %a",command,typ)
+ end
+ direct = false
+ elseif ti == nil then
+ -- nothing
+ elseif ti == "" then
+ flush(currentcatcodes,"{}")
+ else
+ local typ = type(ti)
+ if typ == "string" then
+ -- is processlines seen ?
+ if processlines and lpegmatch(containseol,ti) then
+ flush(currentcatcodes,"{")
+ flushlines(ti)
+ flush(currentcatcodes,"}")
+ elseif currentcatcodes == contentcatcodes then
flush(currentcatcodes,"{",ti,"}")
- elseif typ == "table" then
- local tn = #ti
- if tn == 0 then
- local done = false
- for k, v in next, ti do
- if done then
- if v == "" then
- flush(currentcatcodes,",",k,'=')
- else
- flush(currentcatcodes,",",k,"={",v,"}")
- end
+ else
+ flush(currentcatcodes,"{")
+ flush(contentcatcodes,ti)
+ flush(currentcatcodes,"}")
+ end
+ elseif typ == "number" then
+ -- numbers never have funny catcodes
+ flush(currentcatcodes,"{",ti,"}")
+ elseif typ == "table" then
+ local tn = #ti
+ if tn == 0 then
+ local done = false
+ for k, v in next, ti do
+ if done then
+ if v == "" then
+ flush(currentcatcodes,",",k,'=')
else
- if v == "" then
- flush(currentcatcodes,"[",k,"=")
- else
- flush(currentcatcodes,"[",k,"={",v,"}")
- end
- done = true
+ flush(currentcatcodes,",",k,"={",v,"}")
end
- end
- if done then
- flush(currentcatcodes,"]")
else
- flush(currentcatcodes,"[]")
+ if v == "" then
+ flush(currentcatcodes,"[",k,"=")
+ else
+ flush(currentcatcodes,"[",k,"={",v,"}")
+ end
+ done = true
end
- elseif tn == 1 then -- some 20% faster than the next loop
- local tj = ti[1]
+ end
+ if done then
+ flush(currentcatcodes,"]")
+ else
+ flush(currentcatcodes,"[]")
+ end
+ elseif tn == 1 then -- some 20% faster than the next loop
+ local tj = ti[1]
+ if type(tj) == "function" then
+ flush(currentcatcodes,"[\\cldl",storefunction(tj),"]")
+ -- flush(currentcatcodes,"[",storefunction(tj),"]")
+ else
+ flush(currentcatcodes,"[",tj,"]")
+ end
+ else -- is concat really faster than flushes here? probably needed anyway (print artifacts)
+ flush(currentcatcodes,"[")
+ for j=1,tn do
+ local tj = ti[j]
if type(tj) == "function" then
- flush(currentcatcodes,"[\\cldl",storefunction(tj),"]")
- -- flush(currentcatcodes,"[",storefunction(tj),"]")
+ if j == tn then
+ flush(currentcatcodes,"\\cldl",storefunction(tj),"]")
+ -- flush(currentcatcodes,"",storefunction(tj),"]")
+ else
+ flush(currentcatcodes,"\\cldl",storefunction(tj),",")
+ -- flush(currentcatcodes,"",storefunction(tj),",")
+ end
else
- flush(currentcatcodes,"[",tj,"]")
- end
- else -- is concat really faster than flushes here? probably needed anyway (print artifacts)
- flush(currentcatcodes,"[")
- for j=1,tn do
- local tj = ti[j]
- if type(tj) == "function" then
- if j == tn then
- flush(currentcatcodes,"\\cldl",storefunction(tj),"]")
- -- flush(currentcatcodes,"",storefunction(tj),"]")
- else
- flush(currentcatcodes,"\\cldl",storefunction(tj),",")
- -- flush(currentcatcodes,"",storefunction(tj),",")
- end
+ if j == tn then
+ flush(currentcatcodes,tj,"]")
else
- if j == tn then
- flush(currentcatcodes,tj,"]")
- else
- flush(currentcatcodes,tj,",")
- end
+ flush(currentcatcodes,tj,",")
end
end
end
- elseif typ == "function" then
- flush(currentcatcodes,"{\\cldl ",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
- -- flush(currentcatcodes,"{",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
- elseif typ == "boolean" then
- if ti then
- flushdirect(currentcatcodes,"\r")
- else
- direct = true
- end
- elseif typ == "thread" then
- report_context("coroutines not supported as we cannot yield across boundaries")
- elseif isnode(ti) then -- slow
- flush(currentcatcodes,"{\\cldl",storenode(ti),"}")
- -- flush(currentcatcodes,"{",storenode(ti),"}")
+ end
+ elseif typ == "function" then
+ flush(currentcatcodes,"{\\cldl ",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
+ -- flush(currentcatcodes,"{",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
+ elseif typ == "boolean" then
+ if ti then
+ flushdirect(currentcatcodes,"\r")
else
- report_context("error: %a gets a weird argument %a",command,ti)
+ direct = true
end
+ elseif typ == "thread" then
+ report_context("coroutines not supported as we cannot yield across boundaries")
+ elseif isnode(ti) then -- slow
+ flush(currentcatcodes,"{\\cldl",storenode(ti),"}")
+ -- flush(currentcatcodes,"{",storenode(ti),"}")
+ else
+ report_context("error: %a gets a weird argument %a",command,ti)
end
end
end
+end
- -- if performance really matters we can consider a compiler but it will never
- -- pay off
-
- prtwriter = function (command,...) -- already optimized before call
- flush(prtcatcodes,command)
- for i=1,select("#",...) do
- local ti = (select(i,...))
- if ti == nil then
- -- nothing
- elseif ti == "" then
- flush(prtcatcodes,"{}")
+-- if performance really matters we can consider a compiler but it will never
+-- pay off
+
+local function prtwriter(command,...) -- already optimized before call
+ flush(prtcatcodes,command)
+ for i=1,select("#",...) do
+ local ti = (select(i,...))
+ if ti == nil then
+ -- nothing
+ elseif ti == "" then
+ flush(prtcatcodes,"{}")
+ else
+ local tp = type(ti)
+ if tp == "string" or tp == "number"then
+ flush(prtcatcodes,"{",ti,"}")
+ elseif tp == "function" then
+ flush(prtcatcodes,"{\\cldl ",storefunction(ti),"}")
+ -- flush(currentcatcodes,"{",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
+ elseif isnode(ti) then
+ flush(prtcatcodes,"{\\cldl",storenode(ti),"}")
+ -- flush(currentcatcodes,"{",storenode(ti),"}")
else
- local tp = type(ti)
- if tp == "string" or tp == "number"then
- flush(prtcatcodes,"{",ti,"}")
- elseif tp == "function" then
- flush(prtcatcodes,"{\\cldl ",storefunction(ti),"}")
- -- flush(currentcatcodes,"{",storefunction(ti),"}") -- todo: ctx|prt|texcatcodes
- elseif isnode(ti) then
- flush(prtcatcodes,"{\\cldl",storenode(ti),"}")
- -- flush(currentcatcodes,"{",storenode(ti),"}")
- else
- report_context("fatal error: prt %a gets a weird argument %a",command,ti)
- end
+ report_context("fatal error: prt %a gets a weird argument %a",command,ti)
end
end
end
+end
--- else
+-- Originally we used this:
--
--- writer = function (parent,command,first,...) -- already optimized before call
--- local t = { first, ... }
--- flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes
--- local direct = false
--- for i=1,#t do
--- local ti = t[i]
--- local typ = type(ti)
--- if direct then
--- if typ == "string" or typ == "number" then
--- flush(currentcatcodes,ti)
--- else -- node.write
--- report_context("error: invalid use of direct in %a, only strings and numbers can be flushed directly, not %a",command,typ)
--- end
--- direct = false
--- elseif ti == nil then
--- -- nothing
--- elseif ti == "" then
--- flush(currentcatcodes,"{}")
--- elseif typ == "string" then
--- -- is processelines seen ?
--- if processlines and lpegmatch(containseol,ti) then
--- flush(currentcatcodes,"{")
--- local flushlines = parent.__flushlines or flushlines
--- flushlines(ti)
--- flush(currentcatcodes,"}")
--- elseif currentcatcodes == contentcatcodes then
--- flush(currentcatcodes,"{",ti,"}")
--- else
--- flush(currentcatcodes,"{")
--- flush(contentcatcodes,ti)
--- flush(currentcatcodes,"}")
--- end
--- elseif typ == "number" then
--- -- numbers never have funny catcodes
--- flush(currentcatcodes,"{",ti,"}")
--- elseif typ == "table" then
--- local tn = #ti
--- if tn == 0 then
--- local done = false
--- for k, v in next, ti do
--- if done then
--- if v == "" then
--- flush(currentcatcodes,",",k,'=')
--- else
--- flush(currentcatcodes,",",k,"={",v,"}")
--- end
--- else
--- if v == "" then
--- flush(currentcatcodes,"[",k,"=")
--- else
--- flush(currentcatcodes,"[",k,"={",v,"}")
--- end
--- done = true
--- end
--- end
--- if done then
--- flush(currentcatcodes,"]")
--- else
--- flush(currentcatcodes,"[]")
--- end
--- elseif tn == 1 then -- some 20% faster than the next loop
--- local tj = ti[1]
--- if type(tj) == "function" then
--- flush(currentcatcodes,"[\\cldf{",storefunction(tj),"}]")
--- else
--- flush(currentcatcodes,"[",tj,"]")
--- end
--- else -- is concat really faster than flushes here? probably needed anyway (print artifacts)
--- for j=1,tn do
--- local tj = ti[j]
--- if type(tj) == "function" then
--- ti[j] = "\\cldf{" .. storefunction(tj) .. "}"
--- end
--- end
--- flush(currentcatcodes,"[",concat(ti,","),"]")
--- end
--- elseif typ == "function" then
--- flush(currentcatcodes,"{\\cldf{",storefunction(ti),"}}") -- todo: ctx|prt|texcatcodes
--- elseif typ == "boolean" then
--- if ti then
--- flushdirect(currentcatcodes,"\r")
--- else
--- direct = true
--- end
--- elseif typ == "thread" then
--- report_context("coroutines not supported as we cannot yield across boundaries")
--- elseif isnode(ti) then -- slow
--- flush(currentcatcodes,"{\\cldn{",storenode(ti),"}}")
+-- writer = function (parent,command,first,...) -- already optimized before call
+-- local t = { first, ... }
+-- flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes
+-- local direct = false
+-- for i=1,#t do
+-- local ti = t[i]
+-- local typ = type(ti)
+-- if direct then
+-- if typ == "string" or typ == "number" then
+-- flush(currentcatcodes,ti)
+-- else -- node.write
+-- report_context("error: invalid use of direct in %a, only strings and numbers can be flushed directly, not %a",command,typ)
+-- end
+-- direct = false
+-- elseif ti == nil then
+-- -- nothing
+-- elseif ti == "" then
+-- flush(currentcatcodes,"{}")
+-- elseif typ == "string" then
+-- -- is processelines seen ?
+-- if processlines and lpegmatch(containseol,ti) then
+-- flush(currentcatcodes,"{")
+-- flushlines(ti)
+-- flush(currentcatcodes,"}")
+-- elseif currentcatcodes == contentcatcodes then
+-- flush(currentcatcodes,"{",ti,"}")
+-- else
+-- flush(currentcatcodes,"{")
+-- flush(contentcatcodes,ti)
+-- flush(currentcatcodes,"}")
+-- end
+-- elseif typ == "number" then
+-- -- numbers never have funny catcodes
+-- flush(currentcatcodes,"{",ti,"}")
+-- elseif typ == "table" then
+-- local tn = #ti
+-- if tn == 0 then
+-- local done = false
+-- for k, v in next, ti do
+-- if done then
+-- if v == "" then
+-- flush(currentcatcodes,",",k,'=')
+-- else
+-- flush(currentcatcodes,",",k,"={",v,"}")
+-- end
+-- else
+-- if v == "" then
+-- flush(currentcatcodes,"[",k,"=")
+-- else
+-- flush(currentcatcodes,"[",k,"={",v,"}")
+-- end
+-- done = true
+-- end
+-- end
+-- if done then
+-- flush(currentcatcodes,"]")
+-- else
+-- flush(currentcatcodes,"[]")
+-- end
+-- elseif tn == 1 then -- some 20% faster than the next loop
+-- local tj = ti[1]
+-- if type(tj) == "function" then
+-- flush(currentcatcodes,"[\\cldf{",storefunction(tj),"}]")
+-- else
+-- flush(currentcatcodes,"[",tj,"]")
+-- end
+-- else -- is concat really faster than flushes here? probably needed anyway (print artifacts)
+-- for j=1,tn do
+-- local tj = ti[j]
+-- if type(tj) == "function" then
+-- ti[j] = "\\cldf{" .. storefunction(tj) .. "}"
+-- end
+-- end
+-- flush(currentcatcodes,"[",concat(ti,","),"]")
+-- end
+-- elseif typ == "function" then
+-- flush(currentcatcodes,"{\\cldf{",storefunction(ti),"}}") -- todo: ctx|prt|texcatcodes
+-- elseif typ == "boolean" then
+-- if ti then
+-- flushdirect(currentcatcodes,"\r")
+-- else
+-- direct = true
+-- end
+-- elseif typ == "thread" then
+-- report_context("coroutines not supported as we cannot yield across boundaries")
+-- elseif isnode(ti) then -- slow
+-- flush(currentcatcodes,"{\\cldn{",storenode(ti),"}}")
+-- else
+-- report_context("error: %a gets a weird argument %a",command,ti)
+-- end
+-- end
+-- end
+
+local generics = { } context.generics = generics
+
+-- local indexer = function(parent,k)
+-- if type(k) == "string" then
+-- local c = "\\" .. tostring(generics[k] or k)
+-- local f = function(first,...)
+-- if first == nil then
+-- flush(currentcatcodes,c)
-- else
--- report_context("error: %a gets a weird argument %a",command,ti)
+-- return writer(parent,c,first,...)
-- end
-- end
+-- parent[k] = f
+-- return f
+-- else
+-- return context -- catch
-- end
---
-- end
-local generics = { } context.generics = generics
-local indexer = nil
-local prtindexer = nil
-
--- if environment.initex then
-
- indexer = function(parent,k)
- if type(k) == "string" then
- local c = "\\" .. tostring(generics[k] or k)
- local f = function(first,...)
- if first == nil then
- flush(currentcatcodes,c)
- else
- return writer(parent,c,first,...)
- end
- end
- parent[k] = f
- return f
+local core = table.setmetatableindex(function(parent,k)
+ local c = "\\" .. tostring(generics[k] or k)
+ local f = function(first,...)
+ if first == nil then
+ flush(currentcatcodes,c)
else
- return context -- catch
+ return writer(context,c,first,...)
end
end
+ parent[k] = f
+ return f
+end)
+
+local indexer = function(parent,k)
+ if type(k) == "string" then
+ return core[k]
+ else
+ return context -- catch
+ end
+end
+
+context.core = core
--- else
+-- can only be done in non-ini mode so we'd have a bad mix and tracing
+-- is bad too, so we just keep it as commented
--
--- local create = token.create
--- local twrite = token.write
+-- local create = token.create
+-- local twrite = token.write
--
--- indexer = function(parent,k)
--- if type(k) == "string" then
--- local s = tostring(generics[k] or k)
--- local t = create(s)
--- if t.cmdname == "undefined_cs" then
--- report_cld("macro \\%s is not yet defined",s)
--- token.set_macro(s,"")
--- t = create(s)
--- end
--- local i = t.id
--- local f = function(first,...)
--- twrite(t.tok) --= we need to keep t uncollected
--- if first ~= nil then
--- return writer(parent,first,...)
--- end
+-- indexer = function(parent,k)
+-- if type(k) == "string" then
+-- local s = tostring(generics[k] or k)
+-- local t = create(s)
+-- if t.cmdname == "undefined_cs" then
+-- report_cld("macro \\%s is not yet defined",s)
+-- token.set_macro(s,"")
+-- t = create(s)
+-- end
+-- local i = t.id
+-- local f = function(first,...)
+-- twrite(t.tok) --= we need to keep t uncollected
+-- if first ~= nil then
+-- return writer(parent,first,...)
-- end
--- parent[k] = f
--- return f
--- else
--- return context -- catch
-- end
+-- parent[k] = f
+-- return f
+-- else
+-- return context -- catch
-- end
---
-- end
-- Potential optimization: after the first call we know if there will be an
@@ -1029,18 +1040,19 @@ local prtindexer = nil
-- only for internal usage:
+local prtindexer = nil
+
do
- function context.constructcsonly(k) -- not much faster than the next but more mem efficient
- local c = "\\" .. tostring(generics[k] or k)
- local v = function()
- flush(prtcatcodes,c)
- end
- rawset(context,k,v) -- context namespace
- return v
- end
+ -- the only variant is not much faster than the full but it's more
+ -- memory efficient
+
+ local protected = { }
+ local protectedcs = { }
+ context.protected = protected
+ context.protectedcs = protectedcs
- function context.constructcs(k)
+ local function fullindexer(t,k)
local c = "\\" .. tostring(generics[k] or k)
local v = function(first,...)
if first == nil then
@@ -1049,160 +1061,146 @@ do
return prtwriter(c,first,...)
end
end
- rawset(context,k,v) -- context namespace
+ rawset(t,k,v) -- protected namespace
return v
end
- local function prtindexer(t,k)
+ local function onlyindexer(t,k)
local c = "\\" .. tostring(generics[k] or k)
- local v = function(first,...)
- if first == nil then
- flush(prtcatcodes,c)
- else
- return prtwriter(c,first,...)
- end
+ local v = function()
+ flush(prtcatcodes,c)
end
- rawset(t,k,v) -- protected namespace
+ rawset(protected,k,v)
+ rawset(t,k,v)
return v
end
- context.protected = { } -- we could check for _ in the context namespace
-
- setmetatable(context.protected, { __index = prtindexer, __call = prtwriter } )
+ setmetatable(protected, { __index = fullindexer, __call = prtwriter } )
+ setmetatable(protectedcs, { __index = onlyindexer, __call = prtwriter } )
end
-- local splitformatters = utilities.strings.formatters.new(true) -- not faster (yet)
-local caller
-
--- if luafunctions then
-
- caller = function(parent,f,a,...)
- if not parent then
- -- so we don't need to test in the calling (slower but often no issue)
- elseif f ~= nil then
- local typ = type(f)
- if typ == "string" then
- if f == "" then
- -- new, can save a bit sometimes
- -- if trace_context then
- -- report_context("empty argument to context()")
- -- end
- elseif a then
- flush(contentcatcodes,formatters[f](a,...)) -- was currentcatcodes
- -- flush(contentcatcodes,splitformatters[f](a,...)) -- was currentcatcodes
- elseif processlines and lpegmatch(containseol,f) then
- local flushlines = parent.__flushlines or flushlines
- flushlines(f)
+local caller = function(parent,f,a,...)
+ if not parent then
+ -- so we don't need to test in the calling (slower but often no issue)
+ elseif f ~= nil then
+ local typ = type(f)
+ if typ == "string" then
+ if f == "" then
+ -- new, can save a bit sometimes
+ -- if trace_context then
+ -- report_context("empty argument to context()")
+ -- end
+ elseif a then
+ flush(contentcatcodes,formatters[f](a,...)) -- was currentcatcodes
+ -- flush(contentcatcodes,splitformatters[f](a,...)) -- was currentcatcodes
+ elseif processlines and lpegmatch(containseol,f) then
+ flushlines(f)
+ else
+ flush(contentcatcodes,f)
+ end
+ elseif typ == "number" then
+ if a then
+ flush(currentcatcodes,f,a,...)
+ else
+ flush(currentcatcodes,f)
+ end
+ elseif typ == "function" then
+ -- ignored: a ...
+ flush(currentcatcodes,"{\\cldl",storefunction(f),"}") -- todo: ctx|prt|texcatcodes
+ -- flush(currentcatcodes,"{",storefunction(f),"}") -- todo: ctx|prt|texcatcodes
+ elseif typ == "boolean" then
+ if f then
+ if a ~= nil then
+ flushlines(a)
else
- flush(contentcatcodes,f)
+ flushdirect(currentcatcodes,"\n") -- no \r, else issues with \startlines ... use context.par() otherwise
end
- elseif typ == "number" then
- if a then
- flush(currentcatcodes,f,a,...)
+ else
+ if a ~= nil then
+ -- no command, same as context(a,...)
+ writer(parent,"",a,...)
else
- flush(currentcatcodes,f)
+ -- ignored
end
- elseif typ == "function" then
- -- ignored: a ...
- flush(currentcatcodes,"{\\cldl",storefunction(f),"}") -- todo: ctx|prt|texcatcodes
- -- flush(currentcatcodes,"{",storefunction(f),"}") -- todo: ctx|prt|texcatcodes
- elseif typ == "boolean" then
- if f then
- if a ~= nil then
- local flushlines = parent.__flushlines or flushlines
- flushlines(a)
- else
- flushdirect(currentcatcodes,"\n") -- no \r, else issues with \startlines ... use context.par() otherwise
- end
- else
- if a ~= nil then
- -- no command, same as context(a,...)
- writer(parent,"",a,...)
- else
- -- ignored
- end
- end
- elseif typ == "thread" then
- report_context("coroutines not supported as we cannot yield across boundaries")
- elseif isnode(f) then -- slow
- -- writenode(f)
- flush(currentcatcodes,"\\cldl",storenode(f)," ")
- -- flush(currentcatcodes,"",storenode(f)," ")
- else
- report_context("error: %a gets a weird argument %a","context",f)
end
+ elseif typ == "thread" then
+ report_context("coroutines not supported as we cannot yield across boundaries")
+ elseif isnode(f) then -- slow
+ -- writenode(f)
+ flush(currentcatcodes,"\\cldl",storenode(f)," ")
+ -- flush(currentcatcodes,"",storenode(f)," ")
+ else
+ report_context("error: %a gets a weird argument %a","context",f)
end
end
+end
- function context.flushnode(n)
- flush(currentcatcodes,"\\cldl",storenode(n)," ")
- -- flush(currentcatcodes,"",storenode(n)," ")
- end
+function context.flushnode(n)
+ flush(currentcatcodes,"\\cldl",storenode(n)," ")
+ -- flush(currentcatcodes,"",storenode(n)," ")
+end
--- else
+-- old code, from the early days:
--
--- caller = function(parent,f,a,...)
--- if not parent then
--- -- so we don't need to test in the calling (slower but often no issue)
--- elseif f ~= nil then
--- local typ = type(f)
--- if typ == "string" then
--- if f == "" then
--- -- new, can save a bit sometimes
--- -- if trace_context then
--- -- report_context("empty argument to context()")
--- -- end
--- elseif a then
--- flush(contentcatcodes,formatters[f](a,...)) -- was currentcatcodes
--- -- flush(contentcatcodes,splitformatters[f](a,...)) -- was currentcatcodes
--- elseif processlines and lpegmatch(containseol,f) then
--- local flushlines = parent.__flushlines or flushlines
--- flushlines(f)
--- else
--- flush(contentcatcodes,f)
--- end
--- elseif typ == "number" then
--- if a then
--- flush(currentcatcodes,f,a,...)
+-- caller = function(parent,f,a,...)
+-- if not parent then
+-- -- so we don't need to test in the calling (slower but often no issue)
+-- elseif f ~= nil then
+-- local typ = type(f)
+-- if typ == "string" then
+-- if f == "" then
+-- -- new, can save a bit sometimes
+-- -- if trace_context then
+-- -- report_context("empty argument to context()")
+-- -- end
+-- elseif a then
+-- flush(contentcatcodes,formatters[f](a,...)) -- was currentcatcodes
+-- -- flush(contentcatcodes,splitformatters[f](a,...)) -- was currentcatcodes
+-- elseif processlines and lpegmatch(containseol,f) then
+-- flushlines(f)
+-- else
+-- flush(contentcatcodes,f)
+-- end
+-- elseif typ == "number" then
+-- if a then
+-- flush(currentcatcodes,f,a,...)
+-- else
+-- flush(currentcatcodes,f)
+-- end
+-- elseif typ == "function" then
+-- -- ignored: a ...
+-- flush(currentcatcodes,"{\\cldf{",storefunction(f),"}}") -- todo: ctx|prt|texcatcodes
+-- elseif typ == "boolean" then
+-- if f then
+-- if a ~= nil then
+-- flushlines(a)
-- else
--- flush(currentcatcodes,f)
+-- flushdirect(currentcatcodes,"\n") -- no \r, else issues with \startlines ... use context.par() otherwise
-- end
--- elseif typ == "function" then
--- -- ignored: a ...
--- flush(currentcatcodes,"{\\cldf{",storefunction(f),"}}") -- todo: ctx|prt|texcatcodes
--- elseif typ == "boolean" then
--- if f then
--- if a ~= nil then
--- local flushlines = parent.__flushlines or flushlines
--- flushlines(a)
--- else
--- flushdirect(currentcatcodes,"\n") -- no \r, else issues with \startlines ... use context.par() otherwise
--- end
+-- else
+-- if a ~= nil then
+-- -- no command, same as context(a,...)
+-- writer(parent,"",a,...)
-- else
--- if a ~= nil then
--- -- no command, same as context(a,...)
--- writer(parent,"",a,...)
--- else
--- -- ignored
--- end
+-- -- ignored
-- end
--- elseif typ == "thread" then
--- report_context("coroutines not supported as we cannot yield across boundaries")
--- elseif isnode(f) then -- slow
--- -- writenode(f)
--- flush(currentcatcodes,"\\cldn{",storenode(f),"}")
--- else
--- report_context("error: %a gets a weird argument %a","context",f)
-- end
+-- elseif typ == "thread" then
+-- report_context("coroutines not supported as we cannot yield across boundaries")
+-- elseif isnode(f) then -- slow
+-- -- writenode(f)
+-- flush(currentcatcodes,"\\cldn{",storenode(f),"}")
+-- else
+-- report_context("error: %a gets a weird argument %a","context",f)
-- end
-- end
+-- end
--
--- function context.flushnode(n)
--- flush(currentcatcodes,"\\cldn{",storenode(n),"}")
--- end
---
+-- function context.flushnode(n)
+-- flush(currentcatcodes,"\\cldn{",storenode(n),"}")
-- end
local defaultcaller = caller
@@ -1211,6 +1209,8 @@ setmetatable(context, { __index = indexer, __call = caller } )
-- now we tweak unprotect and protect
+-- context.call = caller -- somehow fails
+
function context.unprotect()
-- at the lua end
insert(catcodestack,currentcatcodes)
@@ -1376,14 +1376,9 @@ local function pushlogger(trace)
trace = trace or report_context
insert(trace_stack,currenttrace)
currenttrace = trace
- --
- flush = tracedflush
- flushdirect = tracedflushdirect
- writer = tracedwriter
- --
- context.__flush = flush
- context.__flushdirect = flushdirect
- --
+ flush = tracedflush
+ flushdirect = tracedflushdirect
+ writer = tracedwriter
return flush, writer, flushdirect
end
@@ -1393,9 +1388,6 @@ local function poplogger()
flush = normalflush
flushdirect = normalflushdirect
writer = normalwriter
- --
- context.__flush = flush
- context.__flushdirect = flushdirect
end
return flush, writer, flushdirect
end
@@ -1499,13 +1491,9 @@ do
if level == 0 then
collected = { }
nofcollected = 0
- --
flush = collect
flushdirect = collectdirect
permitted = tracingpermitted
- --
- context.__flush = flush
- context.__flushdirect = flushdirect
end
level = level + 1
end
@@ -1516,15 +1504,10 @@ do
flush = normalflush
flushdirect = normalflushdirect
tracingpermitted = permitted
- --
- context.__flush = flush
- context.__flushdirect = flushdirect
- --
viafile(concat(collected,sentinel))
- --
- collected = nil
- nofcollected = 0
- level = 0
+ collected = nil
+ nofcollected = 0
+ level = 0
end
end
@@ -1574,7 +1557,8 @@ local function indexer(parent,k)
local f = function(...)
local a = { ... }
return function()
- return context[k](unpack(a))
+ -- return context[k](unpack(a))
+ return core[k](unpack(a))
end
end
parent[k] = f
@@ -1584,48 +1568,11 @@ end
local function caller(parent,...) -- todo: nodes
local a = { ... }
return function()
- return context(unpack(a))
+ -- return context(unpack(a))
+ return defaultcaller(context,unpack(a))
end
end
--- local function indexer(parent,k)
--- local f = function(a,...)
--- if not a then
--- return function()
--- return context[k]()
--- end
--- elseif select("#",...) == 0 then
--- return function()
--- return context[k](a)
--- end
--- elseif a then
--- local t = { ... }
--- return function()
--- return context[k](a,unpack(t))
--- end
--- end
--- end
--- parent[k] = f
--- return f
--- end
---
--- local function caller(parent,a,...) -- todo: nodes
--- if not a then
--- return function()
--- return context()
--- end
--- elseif select("#",...) == 0 then
--- return function()
--- return context(a)
--- end
--- elseif a then
--- local t = { ... }
--- return function()
--- return context(a,unpack(t))
--- end
--- end
--- end
-
setmetatable(delayed, { __index = indexer, __call = caller } )
-- context.nested (todo: lines)
@@ -1639,7 +1586,8 @@ local function indexer(parent,k) -- not ok when traced
n = n + 1
t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
end
- context[k](...)
+ -- context[k](...)
+ core[k](...)
flush = savedflush
return concat(t)
end
@@ -1653,7 +1601,8 @@ local function caller(parent,...)
n = n + 1
t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
end
- context(...)
+ -- context(...)
+ defaultcaller(context,...)
flush = savedflush
return concat(t)
end
@@ -1666,7 +1615,8 @@ function context.newindexer(catcodes)
local handler = { }
local function indexer(parent,k)
- local command = context[k]
+ -- local command = context[k]
+ local command = core[k]
local f = function(...)
local savedcatcodes = contentcatcodes
contentcatcodes = catcodes
diff --git a/tex/context/base/mkiv/cldf-int.lua b/tex/context/base/mkiv/cldf-int.lua
index 2743e4924..cd4db2e90 100644
--- a/tex/context/base/mkiv/cldf-int.lua
+++ b/tex/context/base/mkiv/cldf-int.lua
@@ -172,51 +172,51 @@ function interfaces.tolist(t)
return concat(r,", ")
end
---~ \startluacode
---~ function test(opt_1, opt_2, arg_1)
---~ context.startnarrower()
---~ context("options 1: %s",interfaces.tolist(opt_1))
---~ context.par()
---~ context("options 2: %s",interfaces.tolist(opt_2))
---~ context.par()
---~ context("argument 1: %s",arg_1)
---~ context.stopnarrower()
---~ end
-
---~ interfaces.definecommand {
---~ name = "test",
---~ arguments = {
---~ { "option", "list" },
---~ { "option", "hash" },
---~ { "content", "string" },
---~ },
---~ macro = test,
---~ }
---~ \stopluacode
-
---~ test: \test[1][a=3]{whatever}
-
---~ \startluacode
---~ local function startmore(opt_1)
---~ context.startnarrower()
---~ context("start more, options: %s",interfaces.tolist(opt_1))
---~ context.startnarrower()
---~ end
-
---~ local function stopmore(opt_1)
---~ context.stopnarrower()
---~ context("stop more, options: %s",interfaces.tolist(opt_1))
---~ context.stopnarrower()
---~ end
-
---~ interfaces.definecommand ( "more", {
---~ environment = true,
---~ arguments = {
---~ { "option", "list" },
---~ },
---~ starter = startmore,
---~ stopper = stopmore,
---~ } )
---~ \stopluacode
-
---~ more: \startmore[1] one \startmore[2] two \stopmore one \stopmore
+-- \startluacode
+-- function test(opt_1, opt_2, arg_1)
+-- context.startnarrower()
+-- context("options 1: %s",interfaces.tolist(opt_1))
+-- context.par()
+-- context("options 2: %s",interfaces.tolist(opt_2))
+-- context.par()
+-- context("argument 1: %s",arg_1)
+-- context.stopnarrower()
+-- end
+--
+-- interfaces.definecommand {
+-- name = "test",
+-- arguments = {
+-- { "option", "list" },
+-- { "option", "hash" },
+-- { "content", "string" },
+-- },
+-- macro = test,
+-- }
+-- \stopluacode
+--
+-- test: \test[1][a=3]{whatever}
+--
+-- \startluacode
+-- local function startmore(opt_1)
+-- context.startnarrower()
+-- context("start more, options: %s",interfaces.tolist(opt_1))
+-- context.startnarrower()
+-- end
+--
+-- local function stopmore(opt_1)
+-- context.stopnarrower()
+-- context("stop more, options: %s",interfaces.tolist(opt_1))
+-- context.stopnarrower()
+-- end
+--
+-- interfaces.definecommand ( "more", {
+-- environment = true,
+-- arguments = {
+-- { "option", "list" },
+-- },
+-- starter = startmore,
+-- stopper = stopmore,
+-- } )
+-- \stopluacode
+--
+-- more: \startmore[1] one \startmore[2] two \stopmore one \stopmore
diff --git a/tex/context/base/mkiv/cldf-stp.lua b/tex/context/base/mkiv/cldf-stp.lua
index 7b5225dd3..bd5b084ca 100644
--- a/tex/context/base/mkiv/cldf-stp.lua
+++ b/tex/context/base/mkiv/cldf-stp.lua
@@ -28,14 +28,14 @@ if not modules then modules = { } end modules ['cldf-stp'] = {
-- ...
-- end)
-local create = coroutine.create
-local yield = coroutine.yield
-local resume = coroutine.resume
-local status = coroutine.status
+local create = coroutine.create
+local yield = coroutine.yield
+local resume = coroutine.resume
+local status = coroutine.status
-local stepper = nil
-local stack = { } -- will never be deep so no gc needed
-local depth = 0
+local stepper = nil
+local stack = { } -- will never be deep so no gc needed
+local depth = 0
local nextstep = function()
if status(stepper) == "dead" then
@@ -51,13 +51,13 @@ interfaces.implement {
actions = nextstep,
}
-local cldresume = context.constructcsonly("clf_step")
+local ctx_resume = context.protectedcs.clf_step
function context.step(first,...)
if first ~= nil then
context(first,...)
end
- cldresume()
+ ctx_resume()
yield()
end
@@ -65,5 +65,5 @@ function context.stepwise(f)
depth = depth + 1
stack[depth] = stepper
stepper = create(f)
- resume(stepper)
+ ctx_resume(stepper)
end
diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua
index 31db0a691..c074d3407 100644
--- a/tex/context/base/mkiv/colo-ini.lua
+++ b/tex/context/base/mkiv/colo-ini.lua
@@ -108,18 +108,18 @@ colors.pushset = pushset
colors.popset = popset
colors.setlist = setlist
-local context_colordefagc = context.colordefagc
-local context_colordefagt = context.colordefagt
-local context_colordefalc = context.colordefalc
-local context_colordefalt = context.colordefalt
-local context_colordeffgc = context.colordeffgc
-local context_colordeffgt = context.colordeffgt
-local context_colordefflc = context.colordefflc
-local context_colordefflt = context.colordefflt
-local context_colordefrgc = context.colordefrgc
-local context_colordefrgt = context.colordefrgt
-local context_colordefrlc = context.colordefrlc
-local context_colordefrlt = context.colordefrlt
+local ctx_colordefagc = context.colordefagc
+local ctx_colordefagt = context.colordefagt
+local ctx_colordefalc = context.colordefalc
+local ctx_colordefalt = context.colordefalt
+local ctx_colordeffgc = context.colordeffgc
+local ctx_colordeffgt = context.colordeffgt
+local ctx_colordefflc = context.colordefflc
+local ctx_colordefflt = context.colordefflt
+local ctx_colordefrgc = context.colordefrgc
+local ctx_colordefrgt = context.colordefrgt
+local ctx_colordefrlc = context.colordefrlc
+local ctx_colordefrlt = context.colordefrlt
local function definecolor(name, ca, global)
if ca and ca > 0 then
@@ -127,18 +127,18 @@ local function definecolor(name, ca, global)
if trace_define then
report_colors("define global color %a with attribute %a",name,ca)
end
- context_colordefagc(name,ca)
+ ctx_colordefagc(name,ca)
else
if trace_define then
report_colors("define local color %a with attribute %a",name,ca)
end
- context_colordefalc(name,ca)
+ ctx_colordefalc(name,ca)
end
else
if global then
- context_colordefrgc(name)
+ ctx_colordefrgc(name)
else
- context_colordefrlc(name)
+ ctx_colordefrlc(name)
end
end
colorset[name] = true-- maybe we can store more
@@ -150,18 +150,18 @@ local function inheritcolor(name, ca, global)
if trace_define then
report_colors("inherit global color %a with attribute %a",name,ca)
end
- context_colordeffgc(name,ca) -- some day we will set the macro directly
+ ctx_colordeffgc(name,ca) -- some day we will set the macro directly
else
if trace_define then
report_colors("inherit local color %a with attribute %a",name,ca)
end
- context_colordefflc(name,ca)
+ ctx_colordefflc(name,ca)
end
else
if global then
- context_colordefrgc(name)
+ ctx_colordefrgc(name)
else
- context_colordefrlc(name)
+ ctx_colordefrlc(name)
end
end
colorset[name] = true-- maybe we can store more
@@ -173,18 +173,18 @@ local function definetransparent(name, ta, global)
if trace_define then
report_colors("define global transparency %a with attribute %a",name,ta)
end
- context_colordefagt(name,ta)
+ ctx_colordefagt(name,ta)
else
if trace_define then
report_colors("define local transparency %a with attribute %a",name,ta)
end
- context_colordefalt(name,ta)
+ ctx_colordefalt(name,ta)
end
else
if global then
- context_colordefrgt(name)
+ ctx_colordefrgt(name)
else
- context_colordefrlt(name)
+ ctx_colordefrlt(name)
end
end
end
@@ -195,18 +195,18 @@ local function inherittransparent(name, ta, global)
if trace_define then
report_colors("inherit global transparency %a with attribute %a",name,ta)
end
- context_colordeffgt(name,ta)
+ ctx_colordeffgt(name,ta)
else
if trace_define then
report_colors("inherit local transparency %a with attribute %a",name,ta)
end
- context_colordefflt(name,ta)
+ ctx_colordefflt(name,ta)
end
else
if global then
- context_colordefrgt(name)
+ ctx_colordefrgt(name)
else
- context_colordefrlt(name)
+ ctx_colordefrlt(name)
end
end
end
diff --git a/tex/context/base/mkiv/colo-run.lua b/tex/context/base/mkiv/colo-run.lua
index 6368b3307..2e4cca5ab 100644
--- a/tex/context/base/mkiv/colo-run.lua
+++ b/tex/context/base/mkiv/colo-run.lua
@@ -9,11 +9,12 @@ if not modules then modules = { } end modules ['colo-run'] = {
-- For historic reasons the core has a couple of tracing features. Nowadays
-- these would end up in modules.
-local colors, commands, context, utilities = colors, commands, context, utilities
+local utilities = utilities
+local commands = commands
+local context = context
+local colors = attributes.colors
-local colors = attributes.colors
-
-local private = table.tohash { "d_u_m_m_y", "maintextcolor", "themaintextcolor" }
+local private = table.tohash { "d_u_m_m_y", "maintextcolor", "themaintextcolor" }
function commands.showcolorset(name)
local set = colors.setlist(name)
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 8e28247cd..a85a6175d 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2016.07.18 16:46}
+\newcontextversion{2016.07.22 20:08}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 7259b70ad..e1007750d 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2016.07.18 16:46}
+\edef\contextversion{2016.07.22 20:08}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/core-uti.lua b/tex/context/base/mkiv/core-uti.lua
index 23057872f..1ddfffaf2 100644
--- a/tex/context/base/mkiv/core-uti.lua
+++ b/tex/context/base/mkiv/core-uti.lua
@@ -394,13 +394,15 @@ local used_wood_factor = (50 / 15000000) / 1.2
function statistics.formatruntime(runtime)
if not environment.initex then -- else error when testing as not counters yet
+-- stoptiming(statistics) -- to be sure
local shipped = texgetcount('nofshipouts')
local pages = texgetcount('realpageno')
if pages > shipped then
pages = shipped
end
if shipped > 0 or pages > 0 then
- local persecond = shipped / runtime
+ runtime = tonumber(runtime)
+ local persecond = (runtime > 0) and (shipped/runtime) or pages
if pages == 0 then pages = shipped end
-- if jit then
-- local saved = watts_per_core * runtime * kg_per_watt_per_second / speedup_by_other_engine
diff --git a/tex/context/base/mkiv/file-job.lua b/tex/context/base/mkiv/file-job.lua
index d8509eff1..c7c36a03f 100644
--- a/tex/context/base/mkiv/file-job.lua
+++ b/tex/context/base/mkiv/file-job.lua
@@ -538,9 +538,9 @@ job.register('job.structure.collected',root,initialize)
-- component: small unit, either or not components itself
-- product : combination of components
-local context_processfilemany = context.processfilemany
-local context_processfileonce = context.processfileonce
-local context_processfilenone = context.processfilenone
+local ctx_processfilemany = context.processfilemany
+local ctx_processfileonce = context.processfileonce
+local ctx_processfilenone = context.processfilenone
-- we need a plug in the nested loaded, push pop pseudo current dir
@@ -557,9 +557,9 @@ local function processfilecommon(name,action)
action(name)
end
-local function processfilemany(name) processfilecommon(name,context_processfilemany) end
-local function processfileonce(name) processfilecommon(name,context_processfileonce) end
-local function processfilenone(name) processfilecommon(name,context_processfilenone) end
+local function processfilemany(name) processfilecommon(name,ctx_processfilemany) end
+local function processfileonce(name) processfilecommon(name,ctx_processfileonce) end
+local function processfilenone(name) processfilecommon(name,ctx_processfilenone) end
local processors = utilities.storage.allocate {
-- [v_outer] = {
diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua
index 6b9434d7b..0342ee0ac 100644
--- a/tex/context/base/mkiv/font-ctx.lua
+++ b/tex/context/base/mkiv/font-ctx.lua
@@ -102,8 +102,8 @@ local parameters = hashes.parameters
local designsizefilename = fontgoodies.designsizes.filename
-local context_char = context.char
-local context_getvalue = context.getvalue
+local ctx_char = context.char
+local ctx_getvalue = context.getvalue
local otffeatures = otf.features
local otftables = otf.tables
@@ -1676,13 +1676,13 @@ do -- else too many locals
implement {
name = "fontchar",
- actions = { nametoslot, context_char },
+ actions = { nametoslot, ctx_char },
arguments = "string",
}
implement {
name = "fontcharbyindex",
- actions = { indextoslot, context_char },
+ actions = { indextoslot, ctx_char },
arguments = "integer",
}
@@ -2084,7 +2084,7 @@ do
name = "setfontofid",
arguments = "integer",
actions = function(id)
- context_getvalue(csnames[id])
+ ctx_getvalue(csnames[id])
end
}
diff --git a/tex/context/base/mkiv/font-gbn.lua b/tex/context/base/mkiv/font-gbn.lua
index 1ae817ddb..1f8df642c 100644
--- a/tex/context/base/mkiv/font-gbn.lua
+++ b/tex/context/base/mkiv/font-gbn.lua
@@ -19,7 +19,7 @@ local nodes = nodes
local nuts = nodes.nuts -- context abstraction of direct nodes
local traverse_id = nuts.traverse_id
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local glyph_code = nodes.nodecodes.glyph
local disc_code = nodes.nodecodes.disc
@@ -159,7 +159,7 @@ function nodes.handlers.nodepass(head)
end
end
end
- free_node(r)
+ flush_node(r)
end
end
for d in traverse_id(disc_code,nuthead) do
diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua
index bfc8967dd..519a5c478 100644
--- a/tex/context/base/mkiv/font-nod.lua
+++ b/tex/context/base/mkiv/font-nod.lua
@@ -72,7 +72,7 @@ local setsubtype = nuts.setsubtype
local copy_node_list = nuts.copy_list
local hpack_node_list = nuts.hpack
-local free_node_list = nuts.flush_list
+local flush_node_list = nuts.flush_list
local traverse_nodes = nuts.traverse
local traverse_id = nuts.traverse_id
local protect_glyphs = nuts.protect_glyphs
@@ -270,7 +270,7 @@ function step_tracers.reset()
for i=1,#collection do
local c = collection[i]
if c then
- free_node_list(c)
+ flush_node_list(c)
end
end
collection, messages = { }, { }
diff --git a/tex/context/base/mkiv/font-odv.lua b/tex/context/base/mkiv/font-odv.lua
index a5d2e5882..2e27fefbc 100644
--- a/tex/context/base/mkiv/font-odv.lua
+++ b/tex/context/base/mkiv/font-odv.lua
@@ -126,9 +126,9 @@ local setprop = nuts.setprop
local insert_node_after = nuts.insert_after
local copy_node = nuts.copy
-local free_node = nuts.free
local remove_node = nuts.remove
local flush_list = nuts.flush_list
+local flush_node = nuts.flush_node
local copyinjection = nodes.injections.copy -- KE: is this necessary? HH: probably not as positioning comes later and we rawget/set
@@ -693,7 +693,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if current == stop then
stop = getprev(stop)
head = remove_node(head,current)
- free_node(current)
+ flush_node(current)
return head, stop, nbspaces
else
nbspaces = nbspaces + 1
@@ -735,7 +735,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if tmp then
setprev(tmp,current)
end
- free_node(freenode)
+ flush_node(freenode)
flush_list(tempcurrent)
if changestop then
stop = current
@@ -1018,7 +1018,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if getchar(base) == c_nbsp then
nbspaces = nbspaces - 1
head = remove_node(head,base)
- free_node(base)
+ flush_node(base)
end
return head, stop, nbspaces
@@ -1548,7 +1548,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
if current == stop then
stop = getprev(stop)
head = remove_node(head,current)
- free_node(current)
+ flush_node(current)
return head, stop, nbspaces
else
nbspaces = nbspaces + 1
@@ -1767,7 +1767,7 @@ end
if getchar(base) == c_nbsp then
nbspaces = nbspaces - 1
head = remove_node(head, base)
- free_node(base)
+ flush_node(base)
end
return head, stop, nbspaces
diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua
index a3dda6734..26af69187 100644
--- a/tex/context/base/mkiv/font-osd.lua
+++ b/tex/context/base/mkiv/font-osd.lua
@@ -107,9 +107,9 @@ local ischar = nuts.is_char
local insert_node_after = nuts.insert_after
local copy_node = nuts.copy
-local free_node = nuts.free
local remove_node = nuts.remove
local flush_list = nuts.flush_list
+local flush_node = nuts.flush_node
local copyinjection = nodes.injections.copy -- KE: is this necessary? HH: probably not as positioning comes later and we rawget/set
@@ -792,7 +792,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if current == stop then
stop = getprev(stop)
head = remove_node(head,current)
- free_node(current)
+ flush_node(current)
return head, stop, nbspaces
else
nbspaces = nbspaces + 1
@@ -830,7 +830,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
setchar(current,getchar(tempcurrent)) -- we assumes that the result of blwf consists of one node
local freenode = getnext(current)
setlink(current,tmp)
- free_node(freenode)
+ flush_node(freenode)
flush_list(tempcurrent)
if changestop then
stop = current
@@ -1093,7 +1093,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if getchar(base) == c_nbsp then
nbspaces = nbspaces - 1
head = remove_node(head,base)
- free_node(base)
+ flush_node(base)
end
return head, stop, nbspaces
@@ -1571,7 +1571,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
if current == stop then
stop = getprev(stop)
head = remove_node(head,current)
- free_node(current)
+ flush_node(current)
return head, stop, nbspaces
else
nbspaces = nbspaces + 1
@@ -1768,7 +1768,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
if getchar(base) == c_nbsp then
nbspaces = nbspaces - 1
head = remove_node(head, base)
- free_node(base)
+ flush_node(base)
end
return head, stop, nbspaces
diff --git a/tex/context/base/mkiv/font-otn.lua b/tex/context/base/mkiv/font-otn.lua
index 8c08d2c9a..edd933b0d 100644
--- a/tex/context/base/mkiv/font-otn.lua
+++ b/tex/context/base/mkiv/font-otn.lua
@@ -230,7 +230,7 @@ local copy_node = nuts.copy
local copy_node_list = nuts.copy_list
local find_node_tail = nuts.tail
local flush_node_list = nuts.flush_list
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local end_of_math = nuts.end_of_math
local traverse_nodes = nuts.traverse
local traverse_id = nuts.traverse_id
@@ -404,7 +404,7 @@ end
local function flattendisk(head,disc)
local replace = getfield(disc,"replace")
setfield(disc,"replace",nil)
- free_node(disc)
+ flush_node(disc)
if head == disc then
local next = getnext(disc)
if replace then
diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua
index 0f385088a..10f0518a8 100644
--- a/tex/context/base/mkiv/font-ots.lua
+++ b/tex/context/base/mkiv/font-ots.lua
@@ -184,7 +184,7 @@ local copy_node = nuts.copy
local copy_node_list = nuts.copy_list
local find_node_tail = nuts.tail
local flush_node_list = nuts.flush_list
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local end_of_math = nuts.end_of_math
local traverse_nodes = nuts.traverse
local traverse_id = nuts.traverse_id
@@ -366,7 +366,7 @@ end
local function flattendisk(head,disc)
local _, _, replace, _, _, replacetail = getdisc(disc,true)
setfield(disc,"replace",nil)
- free_node(disc)
+ flush_node(disc)
if head == disc then
local next = getnext(disc)
if replace then
@@ -2744,6 +2744,7 @@ local function kernrun(disc,k_run,font,attr,...)
done = true
end
setprev(pre,nest)
+-- setprev(pre,nil)
setnext(prev,disc)
end
end
@@ -2773,6 +2774,7 @@ local function kernrun(disc,k_run,font,attr,...)
done = true
end
setprev(replace,nest)
+-- setprev(replace,nil)
setnext(prev,disc)
end
if next then
diff --git a/tex/context/base/mkiv/font-sol.lua b/tex/context/base/mkiv/font-sol.lua
index c1cac4fcf..cc36ea5aa 100644
--- a/tex/context/base/mkiv/font-sol.lua
+++ b/tex/context/base/mkiv/font-sol.lua
@@ -73,9 +73,9 @@ local setnext = nuts.setnext
local setlist = nuts.setlist
local find_node_tail = nuts.tail
-local free_node = nuts.free
-local free_nodelist = nuts.flush_list
-local copy_nodelist = nuts.copy_list
+local flush_node = nuts.flush_node
+local flush_node_list = nuts.flush_list
+local copy_node_list = nuts.copy_list
local traverse_nodes = nuts.traverse
local traverse_ids = nuts.traverse_id
local hpack_nodes = nuts.hpack
@@ -351,7 +351,7 @@ function splitters.split(head)
local function flush() -- we can move this
local font = getfont(start)
local last = getnext(stop)
- local list = last and copy_nodelist(start,last) or copy_nodelist(start)
+ local list = last and copy_node_list(start,last) or copy_node_list(start)
local n = #cache + 1
if encapsulate then
local user_one = new_usernumber(splitter_one,n)
@@ -577,7 +577,7 @@ local function doit(word,list,best,width,badness,line,set,listdir)
local featurenumber = features[best] -- not ok probably
if featurenumber then
noftries = noftries + 1
- local first = copy_nodelist(original)
+ local first = copy_node_list(original)
if not trace_colors then
for n in traverse_nodes(first) do -- maybe fast force so no attr needed
setattr(n,0,featurenumber) -- this forces dynamics
@@ -609,7 +609,7 @@ first = tonut(first)
if getid(first) == whatsit_code then
local temp = first
first = getnext(first)
- free_node(temp)
+ flush_node(temp)
end
local last = find_node_tail(first)
-- replace [u]h->t by [u]first->last
@@ -633,14 +633,14 @@ first = tonut(first)
setnext(t)
end
setnext(last)
- free_nodelist(first)
+ flush_node_list(first)
else
if trace_optimize then
report_optimizers("line %a, set %a, badness before: %a, after %a, criterium %a, verdict %a",line,set or "?",badness,b,criterium,"continue")
end
-- free old h->t
setnext(t)
- free_nodelist(h) -- somehow fails
+ flush_node_list(h) -- somehow fails
if not encapsulate then
word[2] = first
word[3] = last
@@ -787,9 +787,9 @@ function splitters.optimize(head)
local bb, base
for i=1,max do
if base then
- free_nodelist(base)
+ flush_node_list(base)
end
- base = copy_nodelist(list)
+ base = copy_node_list(list)
local words = collect_words(base) -- beware: words is adapted
for j=i,max do
local temp, done, changes, b = optimize(words,base,j,width,badness,line,set,dir)
@@ -815,7 +815,7 @@ function splitters.optimize(head)
break
end
end
- free_nodelist(base)
+ flush_node_list(base)
end
local words = collect_words(list)
for best=lastbest or 1,max do
@@ -843,7 +843,7 @@ function splitters.optimize(head)
end
for i=1,nc do
local ci = cache[i]
- free_nodelist(ci.original)
+ flush_node_list(ci.original)
end
cache = { }
tex.hbadness = tex_hbadness
diff --git a/tex/context/base/mkiv/font-syn.lua b/tex/context/base/mkiv/font-syn.lua
index 2f39639fd..372a16ca1 100644
--- a/tex/context/base/mkiv/font-syn.lua
+++ b/tex/context/base/mkiv/font-syn.lua
@@ -517,9 +517,11 @@ local function cleanfilename(fullname,defaultsuffix)
end
local sorter = function(a,b)
- return a > b -- to be checked
+ return a > b -- longest first
end
+-- local sorter = nil
+
names.cleanname = cleanname
names.cleanfilename = cleanfilename
@@ -938,8 +940,9 @@ local function sorthashes()
sort(sorted_mappings [l],sorter)
sort(sorted_fallbacks[l],sorter)
end
- data.sorted_families = table.keys(data.families)
- sort(data.sorted_families,sorter)
+ local sorted_families = table.keys(data.families)
+ data.sorted_families = sorted_families
+ sort(sorted_families,sorter)
end
local function unpackreferences()
diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua
index d4bb4755b..5fd0c07d8 100644
--- a/tex/context/base/mkiv/grph-inc.lua
+++ b/tex/context/base/mkiv/grph-inc.lua
@@ -105,13 +105,19 @@ local v_auto = variables.auto
local maxdimen = 2^30-1
+local ctx_doscalefigure = context.doscalefigure
+local ctx_relocateexternalfigure = context.relocateexternalfigure
+local ctx_startfoundexternalfigure = context.startfoundexternalfigure
+local ctx_stopfoundexternalfigure = context.stopfoundexternalfigure
+local ctx_dosetfigureobject = context.dosetfigureobject
+local ctx_doboxfigureobject = context.doboxfigureobject
+
function images.check(figure)
if figure then
local width = figure.width
local height = figure.height
if width <= 0 or height <= 0 then
- report_inclusion("image %a has bad dimensions (%p,%p), discarding",
- figure.filename,width,height)
+ report_inclusion("image %a has bad dimensions (%p,%p), discarding",figure.filename,width,height)
return false, "bad dimensions"
end
local xres = figure.xres
@@ -1227,7 +1233,7 @@ end
function figures.scale(data) -- will become lua code
data = data or callstack[#callstack] or lastfiguredata
- context.doscalefigure()
+ ctx_doscalefigure()
return data
end
@@ -1402,7 +1408,7 @@ function includers.generic(data)
box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet)
texsetbox(nr,box)
ds.objectnumber = figure.objnum
- context.relocateexternalfigure()
+ ctx_relocateexternalfigure()
end
return data
end
@@ -1419,9 +1425,9 @@ local function checkers_nongeneric(data,command) -- todo: macros and context.*
if type(command) == "function" then
command()
end
- context.dosetfigureobject("FIG",hash)
+ ctx_dosetfigureobject("FIG",hash)
end
- context.doboxfigureobject("FIG",hash)
+ ctx_doboxfigureobject("FIG",hash)
elseif type(command) == "function" then
command()
end
@@ -1448,7 +1454,7 @@ function checkers.mov(data)
report_inclusion("including movie %a, width %p, height %p",foundname,width,height)
end
-- we need to push the node.write in between ... we could make a shared helper for this
- context.startfoundexternalfigure(width .. "sp",height .. "sp")
+ ctx_startfoundexternalfigure(width .. "sp",height .. "sp")
context(function()
nodeinjections.insertmovie {
width = width,
@@ -1461,7 +1467,7 @@ function checkers.mov(data)
foundname = foundname,
}
end)
- context.stopfoundexternalfigure()
+ ctx_stopfoundexternalfigure()
return data
end
@@ -1473,6 +1479,9 @@ internalschemes.mprun = true
-- mprun.foo.1 mprun.6 mprun:foo.2
+local ctx_docheckfiguremprun = context.docheckfiguremprun
+local ctx_docheckfiguremps = context.docheckfiguremps
+
local function internal(askedname)
local spec, mprun, mpnum = match(lower(askedname),"mprun([:%.]?)(.-)%.(%d+)")
if spec ~= "" then
@@ -1494,9 +1503,9 @@ end
function checkers.mps(data)
local mprun, mpnum = internal(data.used.fullname)
if mpnum then
- return checkers_nongeneric(data,function() context.docheckfiguremprun(mprun,mpnum) end)
+ return checkers_nongeneric(data,function() ctx_docheckfiguremprun(mprun,mpnum) end)
else
- return checkers_nongeneric(data,function() context.docheckfiguremps(data.used.fullname) end)
+ return checkers_nongeneric(data,function() ctx_docheckfiguremps(data.used.fullname) end)
end
end
@@ -1504,19 +1513,23 @@ includers.mps = includers.nongeneric
-- -- -- tex -- -- --
+local ctx_docheckfiguretex = context.docheckfiguretex
+
function existers.tex(askedname)
askedname = resolvers.findfile(askedname)
return askedname ~= "" and askedname or false, true, "tex", true
end
function checkers.tex(data)
- return checkers_nongeneric(data,function() context.docheckfiguretex(data.used.fullname) end)
+ return checkers_nongeneric(data,function() ctx_docheckfiguretex(data.used.fullname) end)
end
includers.tex = includers.nongeneric
-- -- -- buffer -- -- --
+local ctx_docheckfigurebuffer = context.docheckfigurebuffer
+
function existers.buffer(askedname)
local name = file.nameonly(askedname)
local okay = buffers.exists(name)
@@ -1524,7 +1537,7 @@ function existers.buffer(askedname)
end
function checkers.buffer(data)
- return checkers_nongeneric(data,function() context.docheckfigurebuffer(file.nameonly(data.used.fullname)) end)
+ return checkers_nongeneric(data,function() ctx_docheckfigurebuffer(file.nameonly(data.used.fullname)) end)
end
includers.buffers = includers.nongeneric
@@ -1547,13 +1560,15 @@ includers.auto = includers.generic
-- -- -- cld -- -- --
+local ctx_docheckfigurecld = context.docheckfigurecld
+
function existers.cld(askedname)
askedname = resolvers.findfile(askedname)
return askedname ~= "" and askedname or false, true, "cld", true
end
function checkers.cld(data)
- return checkers_nongeneric(data,function() context.docheckfigurecld(data.used.fullname) end)
+ return checkers_nongeneric(data,function() ctx_docheckfigurecld(data.used.fullname) end)
end
includers.cld = includers.nongeneric
@@ -1876,6 +1891,8 @@ implement {
local registered = { }
+local ctx_doexternalfigurerepeat = context.doexternalfigurerepeat
+
interfaces.implement {
name = "figure_register_page",
arguments = { "string", "string", "string" },
@@ -1898,7 +1915,7 @@ interfaces.implement {
actions = function(n)
local f = registered[tonumber(n)]
if f then
- context.doexternalfigurerepeat(f[1],f[2],f[3],n)
+ ctx_doexternalfigurerepeat(f[1],f[2],f[3],n)
end
end
}
diff --git a/tex/context/base/mkiv/math-acc.mkvi b/tex/context/base/mkiv/math-acc.mkvi
index 415f2b91f..c3f8bad40 100644
--- a/tex/context/base/mkiv/math-acc.mkvi
+++ b/tex/context/base/mkiv/math-acc.mkvi
@@ -178,4 +178,35 @@
\stopusemathstyleparameter
\endgroup}
+%D Relative new:
+
+\newconditional\c_math_accents_auto_dotless \settrue\c_math_accents_auto_dotless % cf opentype math
+
+\let\normalgrave \grave \unexpanded\def\dotlessgrave #1{\normalgrave {\mathdotless#1}}
+\let\normalddot \ddot \unexpanded\def\dotlessddot #1{\normalddot {\mathdotless#1}}
+\let\normalbar \bar \unexpanded\def\dotlessbar #1{\normalbar {\mathdotless#1}}
+\let\normalacute \acute \unexpanded\def\dotlessacute #1{\normalacute {\mathdotless#1}}
+\let\normalhat \hat \unexpanded\def\dotlesshat #1{\normalhat {\mathdotless#1}}
+\let\normalcheck \check \unexpanded\def\dotlesscheck #1{\normalcheck {\mathdotless#1}}
+\let\normalbreve \breve \unexpanded\def\dotlessbreve #1{\normalbreve {\mathdotless#1}}
+\let\normaldot \dot \unexpanded\def\dotlessdot #1{\normaldot {\mathdotless#1}}
+\let\normalmathring\mathring \unexpanded\def\dotlessmathring#1{\normalmathring{\mathdotless#1}}
+\let\normaltilde \tilde \unexpanded\def\dotlesstilde #1{\normaltilde {\mathdotless#1}}
+\let\normaldddot \dddot \unexpanded\def\dotlessdddot #1{\normaldddot {\mathdotless#1}}
+
+\def\math_accents_auto_dotless#1#2%
+ {\ifconditional\c_math_accents_auto_dotless\expandafter#2\else\expandafter#1\fi}
+
+\unexpanded\def\grave {\math_accents_auto_dotless\normalgrave \dotlessgrave }
+\unexpanded\def\ddot {\math_accents_auto_dotless\normalddot \dotlessddot }
+\unexpanded\def\bar {\math_accents_auto_dotless\normalbar \dotlessbar }
+\unexpanded\def\acute {\math_accents_auto_dotless\normalacute \dotlessacute }
+\unexpanded\def\hat {\math_accents_auto_dotless\normalhat \dotlesshat }
+\unexpanded\def\check {\math_accents_auto_dotless\normalcheck \dotlesscheck }
+\unexpanded\def\breve {\math_accents_auto_dotless\normalbreve \dotlessbreve }
+\unexpanded\def\dot {\math_accents_auto_dotless\normaldot \dotlessdot }
+\unexpanded\def\mathring{\math_accents_auto_dotless\normalmathring\dotlessmathring}
+\unexpanded\def\tilde {\math_accents_auto_dotless\normaltilde \dotlesstilde }
+\unexpanded\def\dddot {\math_accents_auto_dotless\normaldddot \dotlessdddot }
+
\protect \endinput
diff --git a/tex/context/base/mkiv/math-ini.lua b/tex/context/base/mkiv/math-ini.lua
index e6a35c39e..c11199178 100644
--- a/tex/context/base/mkiv/math-ini.lua
+++ b/tex/context/base/mkiv/math-ini.lua
@@ -24,8 +24,8 @@ local context = context
local commands = commands
local implement = interfaces.implement
-local context_sprint = context.sprint
------ context_fprint = context.fprint -- a bit inefficient
+local ctx_sprint = context.sprint
+----- ctx_fprint = context.fprint -- a bit inefficient
local ctx_doifelsesomething = commands.doifelsesomething
local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
@@ -142,64 +142,80 @@ mathematics.families = families
-- there will be proper functions soon (and we will move this code in-line)
-- no need for " in class and family (saves space)
-local function mathchar(class,family,slot)
- return formatters['\\Umathchar "%X "%X "%X '](class,family,slot)
-end
-
-local function mathaccent(class,family,slot)
- return formatters['\\Umathaccent "%X "%X "%X '](0,family,slot) -- no class
-end
-
-local function delimiter(class,family,slot)
- return formatters['\\Udelimiter "%X "%X "%X '](class,family,slot)
-end
-
-local function radical(family,slot)
- return formatters['\\Uradical "%X "%X '](family,slot)
-end
-
-local function root(family,slot)
- return formatters['\\Uroot "%X "%X '](family,slot)
-end
-
-local function mathchardef(name,class,family,slot)
- return formatters['\\Umathchardef\\%s "%X "%X "%X '](name,class,family,slot)
-end
-
-local function mathcode(target,class,family,slot)
- return formatters['\\Umathcode%s="%X "%X "%X '](target,class,family,slot)
-end
-
-local function mathtopaccent(class,family,slot)
- return formatters['\\Umathaccent "%X "%X "%X '](0,family,slot) -- no class
-end
-
-local function mathbotaccent(class,family,slot)
- return formatters['\\Umathaccent bottom "%X "%X "%X '](0,family,slot) -- no class
-end
-
-local function mathtopdelimiter(class,family,slot)
- return formatters['\\Udelimiterover "%X "%X '](family,slot) -- no class
-end
-
-local function mathbotdelimiter(class,family,slot)
- return formatters['\\Udelimiterunder "%X "%X '](family,slot) -- no class
-end
+-- local function mathchar(class,family,slot)
+-- return formatters['\\Umathchar "%X "%X "%X '](class,family,slot)
+-- end
+--
+-- local function mathaccent(class,family,slot)
+-- return formatters['\\Umathaccent "%X "%X "%X '](0,family,slot) -- no class
+-- end
+--
+-- local function delimiter(class,family,slot)
+-- return formatters['\\Udelimiter "%X "%X "%X '](class,family,slot)
+-- end
+--
+-- local function radical(family,slot)
+-- return formatters['\\Uradical "%X "%X '](family,slot)
+-- end
+--
+-- local function root(family,slot)
+-- return formatters['\\Uroot "%X "%X '](family,slot)
+-- end
+--
+-- local function mathchardef(name,class,family,slot)
+-- return formatters['\\Umathchardef\\%s "%X "%X "%X '](name,class,family,slot)
+-- end
+--
+-- local function mathcode(target,class,family,slot)
+-- return formatters['\\Umathcode%s="%X "%X "%X '](target,class,family,slot)
+-- end
+--
+-- local function mathtopaccent(class,family,slot)
+-- return formatters['\\Umathaccent "%X "%X "%X '](0,family,slot) -- no class
+-- end
+--
+-- local function mathbotaccent(class,family,slot)
+-- return formatters['\\Umathaccent bottom "%X "%X "%X '](0,family,slot) -- no class
+-- end
+--
+-- local function mathtopdelimiter(class,family,slot)
+-- return formatters['\\Udelimiterover "%X "%X '](family,slot) -- no class
+-- end
+--
+-- local function mathbotdelimiter(class,family,slot)
+-- return formatters['\\Udelimiterunder "%X "%X '](family,slot) -- no class
+-- end
local escapes = characters.filters.utf.private.escapes
-- not that many so no need to reuse tables
-local setmathcharacter = function(class,family,slot,unicode,mset,dset)
- if mset and codes[class] then -- regular codes < 7
- setmathcode("global",slot,{class,family,unicode})
- mset = false
+local setmathcharacter
+
+if LUATEXVERSION > 0.98 then
+ setmathcharacter = function(class,family,slot,unicode,mset,dset)
+ if mset and codes[class] then -- regular codes < 7
+ setmathcode("global",slot,class,family,unicode)
+ mset = false
+ end
+ if dset and class == open_class or class == close_class or class == middle_class then
+ setdelcode("global",slot,family,unicode,0,0)
+ dset = false
+ end
+ return mset, dset
end
- if dset and class == open_class or class == close_class or class == middle_class then
- setdelcode("global",slot,{family,unicode,0,0})
- dset = false
+else
+ setmathcharacter = function(class,family,slot,unicode,mset,dset)
+ if mset and codes[class] then -- regular codes < 7
+ setmathcode("global",slot,{class,family,unicode})
+ mset = false
+ end
+ if dset and class == open_class or class == close_class or class == middle_class then
+ setdelcode("global",slot,{family,unicode,0,0})
+ dset = false
+ end
+ return mset, dset
end
- return mset, dset
end
local f_accent = formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ]
@@ -216,28 +232,28 @@ local f_char = formatters[ [[\Umathchardef\%s "%X "%X "%X ]] ]
local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing
if class == classes.accent then
- context_sprint(f_accent(name,family,slot))
+ ctx_sprint(f_accent(name,family,slot))
elseif class == classes.topaccent then
- context_sprint(f_topaccent(name,family,slot))
+ ctx_sprint(f_topaccent(name,family,slot))
elseif class == classes.botaccent then
- context_sprint(f_botaccent(name,family,slot))
+ ctx_sprint(f_botaccent(name,family,slot))
elseif class == classes.over then
- context_sprint(f_over(name,family,slot))
+ ctx_sprint(f_over(name,family,slot))
elseif class == classes.under then
- context_sprint(f_under(name,family,slot))
+ ctx_sprint(f_under(name,family,slot))
elseif class == open_class or class == close_class or class == middle_class then
setdelcode("global",slot,{family,slot,0,0})
- context_sprint(f_fence(name,class,family,slot))
+ ctx_sprint(f_fence(name,class,family,slot))
elseif class == classes.delimiter then
setdelcode("global",slot,{family,slot,0,0})
- context_sprint(f_delimiter(name,family,slot))
+ ctx_sprint(f_delimiter(name,family,slot))
elseif class == classes.radical then
- context_sprint(f_radical(name,family,slot))
+ ctx_sprint(f_radical(name,family,slot))
elseif class == classes.root then
- context_sprint(f_root(name,family,slot))
+ ctx_sprint(f_root(name,family,slot))
else
-- beware, open/close and other specials should not end up here
- context_sprint(f_char(name,class,family,slot))
+ ctx_sprint(f_char(name,class,family,slot))
end
end
diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv
index d1e5d6a68..f9963b9b3 100644
--- a/tex/context/base/mkiv/math-ini.mkiv
+++ b/tex/context/base/mkiv/math-ini.mkiv
@@ -76,6 +76,7 @@
%D A few compatibility helpers:
\def\Umathbotaccent{\Umathaccent \s!bottom }
+\def\Umathtopaccent{\Umathaccent \s!top }
\def\Umathaccents {\Umathaccent \s!both }
\ifdefined\Umathcharclass \else
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua
index a291b3a59..2fee1ecc0 100644
--- a/tex/context/base/mkiv/math-noa.lua
+++ b/tex/context/base/mkiv/math-noa.lua
@@ -102,7 +102,7 @@ local getchar = nuts.getchar
local getfont = nuts.getfont
local getattr = nuts.getattr
-local free_node = nuts.free
+local flush_node = nuts.flush
local new_node = nuts.new -- todo: pool: math_noad math_sub
local copy_node = nuts.copy
local slide_nodes = nuts.slide
@@ -711,7 +711,7 @@ local function makefence(what,char)
end
setfield(d,"small_char",chr)
setfield(d,"small_fam", fam)
- free_node(sym)
+ flush_node(sym)
end
setsubtype(f,what)
setfield(f,"delim",d)
@@ -734,7 +734,7 @@ local function makelist(noad,f_o,o_next,c_prev,f_c,middle)
local next = getnext(current)
local fence = makefence(middle_fence_code,current)
setfield(current,"nucleus",nil)
- free_node(current)
+ flush_node(current)
middle[current] = nil
-- replace_node
setlink(prev,fence)
@@ -759,7 +759,7 @@ local function convert_both(open,close,middle)
local f_c = makefence(right_fence_code,close)
makelist(open,f_o,o_next,c_prev,f_c,middle)
setfield(close,"nucleus",nil)
- free_node(close)
+ flush_node(close)
if c_next then
setprev(c_next,open)
end
@@ -1502,7 +1502,7 @@ local function collapsepair(pointer,what,n,parent,nested) -- todo: switch to tur
setfield(parent,"sub",getfield(next_noad,"sub"))
setfield(next_noad,"sup",nil)
setfield(next_noad,"sub",nil)
- free_node(next_noad)
+ flush_node(next_noad)
collapsepair(pointer,what,n,parent,true)
-- if not nested and movesub[current_char] then
-- movesubscript(parent,current_nucleus,current_char)
@@ -1584,7 +1584,7 @@ variants[math_char] = function(pointer,what,n,parent) -- also set export value
end
setprev(next,pointer)
setnext(parent,getnext(next))
- free_node(next)
+ flush_node(next)
end
end
end
diff --git a/tex/context/base/mkiv/node-acc.lua b/tex/context/base/mkiv/node-acc.lua
index 4727fd6a4..a63aef646 100644
--- a/tex/context/base/mkiv/node-acc.lua
+++ b/tex/context/base/mkiv/node-acc.lua
@@ -8,42 +8,42 @@ if not modules then modules = { } end modules ['node-acc'] = {
local nodes, node = nodes, node
-local nodecodes = nodes.nodecodes
-local tasks = nodes.tasks
-
-local nuts = nodes.nuts
-local tonut = nodes.tonut
-local tonode = nodes.tonode
-
-local getid = nuts.getid
-local getfield = nuts.getfield
-local getattr = nuts.getattr
-local getlist = nuts.getlist
-local getchar = nuts.getchar
-local getnext = nuts.getnext
-
-local setfield = nuts.setfield
-local setattr = nuts.setattr
-local setlink = nuts.setlink
-local setchar = nuts.setchar
-local setsubtype = nuts.setsubtype
-
------ traverse_nodes = nuts.traverse
-local traverse_id = nuts.traverse_id
-local copy_node = nuts.copy
-local free_nodelist = nuts.flush_list
-local insert_after = nuts.insert_after
-
-local glue_code = nodecodes.glue
------ kern_code = nodecodes.kern
-local glyph_code = nodecodes.glyph
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-
-local a_characters = attributes.private("characters")
-
-local threshold = 65536 -- not used
-local nofreplaced = 0
+local nodecodes = nodes.nodecodes
+local tasks = nodes.tasks
+
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+local tonode = nodes.tonode
+
+local getid = nuts.getid
+local getfield = nuts.getfield
+local getattr = nuts.getattr
+local getlist = nuts.getlist
+local getchar = nuts.getchar
+local getnext = nuts.getnext
+
+local setfield = nuts.setfield
+local setattr = nuts.setattr
+local setlink = nuts.setlink
+local setchar = nuts.setchar
+local setsubtype = nuts.setsubtype
+
+----- traverse_nodes = nuts.traverse
+local traverse_id = nuts.traverse_id
+local copy_node = nuts.copy
+local flush_node_list = nuts.flush_list
+local insert_after = nuts.insert_after
+
+local glue_code = nodecodes.glue
+----- kern_code = nodecodes.kern
+local glyph_code = nodecodes.glyph
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+
+local a_characters = attributes.private("characters")
+
+local threshold = 65536 -- not used
+local nofreplaced = 0
-- todo: nbsp etc
-- todo: collapse kerns
@@ -62,7 +62,7 @@ local function injectspaces(head)
local g = copy_node(p)
local c = getfield(g,"components")
if c then -- it happens that we copied a ligature
- free_nodelist(c)
+ flush_node_list(c)
setfield(g,"components",nil)
setsubtype(g,256)
end
diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua
index 4115530d4..f965128f9 100644
--- a/tex/context/base/mkiv/node-aux.lua
+++ b/tex/context/base/mkiv/node-aux.lua
@@ -45,7 +45,7 @@ local setprev = nuts.setprev
local traverse_nodes = nuts.traverse
local traverse_id = nuts.traverse_id
-local free_node = nuts.free
+local flush_node = nuts.flush
local hpack_nodes = nuts.hpack
local unset_attribute = nuts.unset_attribute
local first_glyph = nuts.first_glyph
@@ -120,7 +120,7 @@ end
function nuts.takelist(n)
local l = getlist(n)
setlist(n)
- free_node(n)
+ flush_node(n)
return l
end
@@ -133,7 +133,7 @@ local function repackhlist(list,...)
local temp, b = hpack_nodes(list,...)
list = getlist(temp)
setlist(temp)
- free_node(temp)
+ flush_node(temp)
return list, b
end
@@ -454,7 +454,7 @@ local function rehpack(n,width)
setfield(n,"glue_sign", getfield(temp,"glue_sign"))
setfield(n,"glue_order",getfield(temp,"glue_order"))
setlist(temp)
- free_node(temp)
+ flush_node(temp)
return n
end
diff --git a/tex/context/base/mkiv/node-fnt.lua b/tex/context/base/mkiv/node-fnt.lua
index 84c45d4b0..0fb8821e8 100644
--- a/tex/context/base/mkiv/node-fnt.lua
+++ b/tex/context/base/mkiv/node-fnt.lua
@@ -65,7 +65,7 @@ local ischar = nuts.ischar -- checked
local traverse_id = nuts.traverse_id
local traverse_char = nuts.traverse_char
local protect_glyph = nuts.protect_glyph
-local free_node = nuts.free
+local flush_node = nuts.flush
local disc_code = nodecodes.disc
local boundary_code = nodecodes.boundary
@@ -329,7 +329,7 @@ function handlers.characters(head)
end
end
end
- free_node(r)
+ flush_node(r)
end
end
diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua
index fc64bf6e5..0803c949d 100644
--- a/tex/context/base/mkiv/node-ltp.lua
+++ b/tex/context/base/mkiv/node-ltp.lua
@@ -217,12 +217,12 @@ local setprev = nuts.setprev
local setdisc = nuts.setdisc
local setsubtype = nuts.setsubtype
-local slide_nodelist = nuts.slide -- get rid of this, probably ok > 78.2
+local slide_node_list = nuts.slide -- get rid of this, probably ok > 78.2
local find_tail = nuts.tail
local new_node = nuts.new
local copy_node = nuts.copy
-local flush_node = nuts.free
-local flush_nodelist = nuts.flush_list
+local flush_node = nuts.flush
+local flush_node_list = nuts.flush_list
----- hpack_nodes = nuts.hpack
local xpack_nodes = nuts.hpack
local replace_node = nuts.replace
@@ -845,7 +845,7 @@ local function append_to_vlist(par, b)
local s = d < par.line_skip_limit and new_lineskip(par.lineskip) or new_baselineskip(d)
local head_field = par.head_field
if head_field then
- local n = slide_nodelist(head_field) -- todo: find_tail
+ local n = slide_node_list(head_field) -- todo: find_tail
setlink(n,s)
else
par.head_field = s
@@ -854,7 +854,7 @@ local function append_to_vlist(par, b)
end
local head_field = par.head_field
if head_field then
- local n = slide_nodelist(head_field) -- todo: find_tail
+ local n = slide_node_list(head_field) -- todo: find_tail
setlink(n,b)
else
par.head_field = b
@@ -869,7 +869,7 @@ end
local function append_list(par, b)
local head_field = par.head_field
if head_field then
- local n = slide_nodelist(head_field) -- todo: find_tail
+ local n = slide_node_list(head_field) -- todo: find_tail
setlink(n,b)
else
par.head_field = b
@@ -975,7 +975,7 @@ local function initialize_line_break(head,display)
prev_depth = texnest[texnest.ptr].prevdepth,
- final_par_glue = slide_nodelist(head), -- todo: we know tail already, slow
+ final_par_glue = slide_node_list(head), -- todo: we know tail already, slow
par_break_dir = tex.pardir,
line_break_dir = tex.pardir,
@@ -1210,7 +1210,7 @@ local function post_line_break(par)
if not lastnode then
-- only at the end
- lastnode = slide_nodelist(head) -- todo: find_tail
+ lastnode = slide_node_list(head) -- todo: find_tail
if lastnode == par.final_par_glue then
lineend = lastnode
lastnode = getprev(lastnode)
@@ -1233,7 +1233,7 @@ local function post_line_break(par)
report_parbuilders('unsupported disc at location %a',3)
end
if pre then
- flush_nodelist(pre)
+ flush_node_list(pre)
pre = nil -- signal
end
if replace then
@@ -1244,13 +1244,13 @@ local function post_line_break(par)
setdisc(lastnode,pre,post,replace)
local pre, post, replace = getdisc(prevlast)
if pre then
- flush_nodelist(pre)
+ flush_node_list(pre)
end
if replace then
- flush_nodelist(replace)
+ flush_node_list(replace)
end
if post then
- flush_nodelist(post)
+ flush_node_list(post)
end
setdisc(prevlast) -- nil,nil,nil
elseif subtype == first_disc_code then
@@ -1263,7 +1263,7 @@ local function post_line_break(par)
setfield(lastnode,"post") -- nil
end
if replace then
- flush_nodelist(replace)
+ flush_node_list(replace)
end
if pre then
setlink(prevlast,pre)
@@ -1454,7 +1454,7 @@ local function post_line_break(par)
end
if current ~= head then
setnext(current)
- flush_nodelist(getnext(head))
+ flush_node_list(getnext(head))
setlink(head,next)
end
end
@@ -2826,8 +2826,8 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
local adjust_head = texlists.adjust_head
local pre_adjust_head = texlists.pre_adjust_head
- local adjust_tail = adjust_head and slide_nodelist(adjust_head) -- todo: find_tail
- local pre_adjust_tail = pre_adjust_head and slide_nodelist(pre_adjust_head) -- todo: find_tail
+ local adjust_tail = adjust_head and slide_node_list(adjust_head) -- todo: find_tail
+ local pre_adjust_tail = pre_adjust_head and slide_node_list(pre_adjust_head) -- todo: find_tail
new_dir_stack(hpack_dir)
@@ -2971,7 +2971,7 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
else
adjust_head = list
end
- adjust_tail = slide_nodelist(list) -- find_tail(list)
+ adjust_tail = slide_node_list(list) -- find_tail(list)
elseif id == dir_code then
hpack_dir = checked_line_dir(stack,current) or hpack_dir
elseif id == marginkern_code then
@@ -3126,7 +3126,7 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
local overfullrule = tex.overfullrule
if fuzz > hfuzz and overfullrule > 0 then
-- weird, is always called and no rules shows up
- setfield(slide_nodelist(list),"next",new_rule(overfullrule,nil,nil,hlist.dir)) -- todo: find_tail
+ setfield(slide_node_list(list),"next",new_rule(overfullrule,nil,nil,hlist.dir)) -- todo: find_tail
end
diagnostics.overfull_hbox(hlist,line,-delta)
end
diff --git a/tex/context/base/mkiv/node-met.lua b/tex/context/base/mkiv/node-met.lua
index 885bbf45a..2402a9fd5 100644
--- a/tex/context/base/mkiv/node-met.lua
+++ b/tex/context/base/mkiv/node-met.lua
@@ -60,60 +60,62 @@ end
-- We start with some helpers and provide all relevant basic functions in the
-- node namespace as well.
-nodes = nodes or { }
-local nodes = nodes
-
------ gonuts = type(node.direct) == "table"
------.gonuts = gonuts
-
-local nodecodes = nodes.nodecodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-
-nodes.tostring = node.tostring or tostring
-nodes.copy = node.copy
-nodes.copy_list = node.copy_list
-nodes.delete = node.delete
-nodes.dimensions = node.dimensions
-nodes.end_of_math = node.end_of_math
-nodes.flush_list = node.flush_list
-nodes.flush_node = node.flush_node
-nodes.free = node.free
-nodes.insert_after = node.insert_after
-nodes.insert_before = node.insert_before
-nodes.hpack = node.hpack
-nodes.new = node.new
-nodes.tail = node.tail
-nodes.traverse = node.traverse
-nodes.traverse_id = node.traverse_id
-nodes.traverse_char = node.traverse_char
-nodes.slide = node.slide
-nodes.vpack = node.vpack
-nodes.fields = node.fields
-nodes.is_node = node.is_node
-nodes.setglue = node.setglue
-
-nodes.first_glyph = node.first_glyph
-nodes.has_glyph = node.has_glyph or node.first_glyph
-
-nodes.current_attr = node.current_attr
-nodes.do_ligature_n = node.do_ligature_n
-nodes.has_field = node.has_field
-nodes.last_node = node.last_node
-nodes.usedlist = node.usedlist
-nodes.protrusion_skippable = node.protrusion_skippable
-nodes.write = node.write
-
-nodes.has_attribute = node.has_attribute
-nodes.set_attribute = node.set_attribute
-nodes.unset_attribute = node.unset_attribute
-
-nodes.protect_glyphs = node.protect_glyphs
-nodes.protect_glyph = node.protect_glyph
-nodes.unprotect_glyphs = node.unprotect_glyphs
-nodes.kerning = node.kerning
-nodes.ligaturing = node.ligaturing
-nodes.mlist_to_hlist = node.mlist_to_hlist
+nodes = nodes or { }
+local nodes = nodes
+
+----- gonuts = type(node.direct) == "table"
+-----.gonuts = gonuts
+
+local nodecodes = nodes.nodecodes
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+
+nodes.tostring = node.tostring or tostring
+nodes.copy = node.copy
+nodes.copy_node = node.copy
+nodes.copy_list = node.copy_list
+nodes.delete = node.delete
+nodes.dimensions = node.dimensions
+nodes.end_of_math = node.end_of_math
+nodes.flush = node.flush_node
+nodes.flush_node = node.flush_node
+nodes.flush_list = node.flush_list
+nodes.free = node.free
+nodes.insert_after = node.insert_after
+nodes.insert_before = node.insert_before
+nodes.hpack = node.hpack
+nodes.new = node.new
+nodes.tail = node.tail
+nodes.traverse = node.traverse
+nodes.traverse_id = node.traverse_id
+nodes.traverse_char = node.traverse_char
+nodes.slide = node.slide
+nodes.vpack = node.vpack
+nodes.fields = node.fields
+nodes.is_node = node.is_node
+nodes.setglue = node.setglue
+
+nodes.first_glyph = node.first_glyph
+nodes.has_glyph = node.has_glyph or node.first_glyph
+
+nodes.current_attr = node.current_attr
+nodes.has_field = node.has_field
+nodes.last_node = node.last_node
+nodes.usedlist = node.usedlist
+nodes.protrusion_skippable = node.protrusion_skippable
+nodes.check_discretionaries = node.check_discretionaries
+nodes.write = node.write
+
+nodes.has_attribute = node.has_attribute
+nodes.set_attribute = node.set_attribute
+nodes.unset_attribute = node.unset_attribute
+
+nodes.protect_glyphs = node.protect_glyphs
+nodes.protect_glyph = node.protect_glyph
+nodes.unprotect_glyphs = node.unprotect_glyphs
+nodes.kerning = node.kerning
+nodes.ligaturing = node.ligaturing
+nodes.mlist_to_hlist = node.mlist_to_hlist
if LUATEXVERSION < 0.97 then
@@ -211,7 +213,7 @@ nodes.getbox = node.getbox or tex.getbox
nodes.setbox = node.setbox or tex.setbox
nodes.getskip = node.getskip or tex.get
-local n_free_node = nodes.free
+local n_flush_node = nodes.flush
local n_copy_node = nodes.copy
local n_copy_list = nodes.copy_list
local n_find_tail = nodes.tail
@@ -227,7 +229,7 @@ local function remove(head,current,free_too)
if not t then
-- forget about it
elseif free_too then
- n_free_node(t)
+ n_flush_node(t)
t = nil
else
n_setboth(t)
@@ -264,10 +266,10 @@ function nodes.replace(head,current,new) -- no head returned if false
if head == current then
head = new
end
- n_free_node(current)
+ n_flush_node(current)
return head, new
else
- n_free_node(current)
+ n_flush_node(current)
return new
end
end
@@ -464,7 +466,7 @@ metatable.__sub = function(first,second)
local tail = n_find_tail(first)
for i=1,second do
local prev = n_getprev(tail)
- n_free_node(tail) -- can become flushlist/flushnode
+ n_flush_node(tail) -- can become flushlist/flushnode
if prev then
tail = prev
else
@@ -499,7 +501,7 @@ metatable.__add = function(first,second)
local head = second
for i=1,first do
local second = n_getnext(head)
- n_free_node(head) -- can become flushlist/flushnode
+ n_flush_node(head) -- can become flushlist/flushnode
if second then
head = second
else
diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua
index 245367c0a..3bd63bd58 100644
--- a/tex/context/base/mkiv/node-nut.lua
+++ b/tex/context/base/mkiv/node-nut.lua
@@ -158,49 +158,51 @@ end
-- helpers
-nuts.tostring = direct.tostring
-nuts.copy = direct.copy
-nuts.copy_list = direct.copy_list
-nuts.delete = direct.delete
-nuts.dimensions = direct.dimensions
-nuts.end_of_math = direct.end_of_math
-nuts.flush_list = direct.flush_list
-nuts.flush_node = direct.flush_node
-nuts.free = direct.free
-nuts.insert_after = direct.insert_after
-nuts.insert_before = direct.insert_before
-nuts.hpack = direct.hpack
-nuts.new = direct.new
-nuts.tail = direct.tail
-nuts.traverse = direct.traverse
-nuts.traverse_id = direct.traverse_id
-nuts.traverse_char = direct.traverse_char
-nuts.slide = direct.slide
-nuts.writable_spec = direct.writable_spec
-nuts.vpack = direct.vpack
-nuts.is_node = direct.is_node
-nuts.is_direct = direct.is_direct
-nuts.is_nut = direct.is_direct
-nuts.first_glyph = direct.first_glyph
-nuts.has_glyph = direct.has_glyph or direct.first_glyph
-
-nuts.current_attr = direct.current_attr
-nuts.do_ligature_n = direct.do_ligature_n
-nuts.has_field = direct.has_field
-nuts.last_node = direct.last_node
-nuts.usedlist = direct.usedlist
-nuts.protrusion_skippable = direct.protrusion_skippable
-nuts.write = direct.write
-
-nuts.has_attribute = direct.has_attribute
-nuts.set_attribute = direct.set_attribute
-nuts.unset_attribute = direct.unset_attribute
-
-nuts.protect_glyphs = direct.protect_glyphs
-nuts.protect_glyph = direct.protect_glyph
-nuts.unprotect_glyphs = direct.unprotect_glyphs
-nuts.ligaturing = direct.ligaturing
-nuts.kerning = direct.kerning
+nuts.tostring = direct.tostring
+nuts.copy = direct.copy
+nuts.copy_node = direct.copy
+nuts.copy_list = direct.copy_list
+nuts.delete = direct.delete
+nuts.dimensions = direct.dimensions
+nuts.end_of_math = direct.end_of_math
+nuts.flush = direct.flush_node
+nuts.flush_node = direct.flush_node
+nuts.flush_list = direct.flush_list
+nuts.free = direct.free
+nuts.insert_after = direct.insert_after
+nuts.insert_before = direct.insert_before
+nuts.hpack = direct.hpack
+nuts.new = direct.new
+nuts.tail = direct.tail
+nuts.traverse = direct.traverse
+nuts.traverse_id = direct.traverse_id
+nuts.traverse_char = direct.traverse_char
+nuts.slide = direct.slide
+nuts.writable_spec = direct.writable_spec
+nuts.vpack = direct.vpack
+nuts.is_node = direct.is_node
+nuts.is_direct = direct.is_direct
+nuts.is_nut = direct.is_direct
+nuts.first_glyph = direct.first_glyph
+nuts.has_glyph = direct.has_glyph or direct.first_glyph
+
+nuts.current_attr = direct.current_attr
+nuts.has_field = direct.has_field
+nuts.last_node = direct.last_node
+nuts.usedlist = direct.usedlist
+nuts.protrusion_skippable = direct.protrusion_skippable
+nuts.check_discretionaries = direct.check_discretionaries
+nuts.write = direct.write
+
+nuts.has_attribute = direct.has_attribute
+nuts.set_attribute = direct.set_attribute
+nuts.unset_attribute = direct.unset_attribute
+
+nuts.protect_glyphs = direct.protect_glyphs
+nuts.protect_glyph = direct.protect_glyph
+nuts.unprotect_glyphs = direct.unprotect_glyphs
+nuts.ligaturing = direct.ligaturing
+nuts.kerning = direct.kerning
if not direct.mlist_to_hlist then -- needed
@@ -223,46 +225,46 @@ if LUATEXVERSION < 0.97 then
end
-local getglue = direct.getglue
-local setglue = direct.setglue
-local is_zero_glue = direct.is_zero_glue
-
-nuts.effective_glue = direct.effective_glue
-nuts.getglue = getglue
-nuts.setglue = setglue
-nuts.is_zero_glue = is_zero_glue
-
-nuts.getdisc = direct.getdisc
-nuts.setdisc = direct.setdisc
-nuts.setchar = direct.setchar
-nuts.setnext = direct.setnext
-nuts.setprev = direct.setprev
-nuts.setboth = direct.setboth
-nuts.getboth = direct.getboth
-nuts.setlink = direct.setlink
-nuts.setlist = direct.setlist
-nuts.setleader = direct.setleader
-nuts.setsubtype = direct.setsubtype
-
-nuts.is_char = direct.is_char
-nuts.ischar = direct.is_char
-nuts.is_glyph = direct.is_glyph
-nuts.isglyph = direct.is_glyph
-
-local d_remove_node = direct.remove
-local d_free_node = direct.free
-local d_getnext = direct.getnext
-local d_getprev = direct.getprev
-local d_getid = direct.getid
-local d_getlist = direct.getlist
-local d_find_tail = direct.tail
-local d_insert_after = direct.insert_after
-local d_insert_before = direct.insert_before
-local d_slide = direct.slide
------ d_copy_node = direct.copy
-local d_traverse = direct.traverse
-local d_setlink = direct.setlink
-local d_setboth = direct.setboth
+local getglue = direct.getglue
+local setglue = direct.setglue
+local is_zero_glue = direct.is_zero_glue
+
+nuts.effective_glue = direct.effective_glue
+nuts.getglue = getglue
+nuts.setglue = setglue
+nuts.is_zero_glue = is_zero_glue
+
+nuts.getdisc = direct.getdisc
+nuts.setdisc = direct.setdisc
+nuts.setchar = direct.setchar
+nuts.setnext = direct.setnext
+nuts.setprev = direct.setprev
+nuts.setboth = direct.setboth
+nuts.getboth = direct.getboth
+nuts.setlink = direct.setlink
+nuts.setlist = direct.setlist
+nuts.setleader = direct.setleader
+nuts.setsubtype = direct.setsubtype
+
+nuts.is_char = direct.is_char
+nuts.ischar = direct.is_char
+nuts.is_glyph = direct.is_glyph
+nuts.isglyph = direct.is_glyph
+
+local d_remove_node = direct.remove
+local d_flush_node = direct.flush_node
+local d_getnext = direct.getnext
+local d_getprev = direct.getprev
+local d_getid = direct.getid
+local d_getlist = direct.getlist
+local d_find_tail = direct.tail
+local d_insert_after = direct.insert_after
+local d_insert_before = direct.insert_before
+local d_slide = direct.slide
+----- d_copy_node = direct.copy
+local d_traverse = direct.traverse
+local d_setlink = direct.setlink
+local d_setboth = direct.setboth
local function remove(head,current,free_too)
local t = current
@@ -270,7 +272,7 @@ local function remove(head,current,free_too)
if not t then
-- forget about it
elseif free_too then
- d_free_node(t)
+ d_flush_node(t)
t = nil
else
d_setboth(t) -- (t,nil,nil)
@@ -301,10 +303,10 @@ function nuts.replace(head,current,new) -- no head returned if false
if head == current then
head = new
end
- d_free_node(current)
+ d_flush_node(current)
return head, new
else
- d_free_node(current)
+ d_flush_node(current)
return new
end
end
diff --git a/tex/context/base/mkiv/node-ppt.lua b/tex/context/base/mkiv/node-ppt.lua
index cbdae27ce..0f7df2b6e 100644
--- a/tex/context/base/mkiv/node-ppt.lua
+++ b/tex/context/base/mkiv/node-ppt.lua
@@ -30,7 +30,6 @@ local getfield = nuts.getfield
local setfield = nuts.setfield
local getlist = nuts.getlist
local setlist = nuts.setlist
-local flushnode = nuts.flush
local removenode = nuts.remove
local traverse = nuts.traverse
local traverse_id = nuts.traverse_id
diff --git a/tex/context/base/mkiv/node-ref.lua b/tex/context/base/mkiv/node-ref.lua
index bce554beb..7bdd5b8d8 100644
--- a/tex/context/base/mkiv/node-ref.lua
+++ b/tex/context/base/mkiv/node-ref.lua
@@ -91,7 +91,7 @@ local line_code = listcodes.line
local new_rule = nodepool.rule
local new_kern = nodepool.kern
-local free_node = nuts.free
+local flush_node = nuts.flush
local tosequence = nodes.tosequence
@@ -121,7 +121,7 @@ local function vlist_dimensions(start,stop) -- also needs the stretch and so
local h = getfield(v,"height")
local d = getfield(v,"depth")
setlist(v) -- not needed
- free_node(v)
+ flush_node(v)
if temp then
setnext(stop,temp)
end
diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua
index 4876a862f..e4cba8ef1 100644
--- a/tex/context/base/mkiv/node-res.lua
+++ b/tex/context/base/mkiv/node-res.lua
@@ -79,7 +79,7 @@ local setlist = nuts.setlist
local copy_nut = nuts.copy
local new_nut = nuts.new
-local free_nut = nuts.free
+local flush_nut = nuts.flush
local copy_node = nodes.copy
local new_node = nodes.new
@@ -418,43 +418,22 @@ function nutpool.latelua(code)
return n
end
-if context and _cldo_ then
+----- latelua_node = register_node(new_node("whatsit",whatsitcodes.latelua))
+local latelua_nut = register_nut (new_nut ("whatsit",whatsitcodes.latelua))
- -- a typical case where we have more nodes than nuts
+-- local setfield_node = nodes.setfield
+-- local setfield_nut = nuts .setfield
- local context = context
- local register = context.registerfunction
-
- local latelua_node = register_node(new_node("whatsit",whatsitcodes.latelua))
- local latelua_nut = register_nut (new_nut ("whatsit",whatsitcodes.latelua))
-
- local setfield_node = nodes.setfield
- local setfield_nut = nuts .setfield
-
- function nodepool.lateluafunction(f)
- local n = copy_node(latelua_node)
- setfield_node(n,"string",f)
- return n
- end
-
- function nutpool.lateluafunction(f)
- local n = copy_nut(latelua_nut)
- setfield_nut(n,"string",f)
- return n
- end
-
- -- function context.lateluafunction(f)
- -- local n = copy_node(latelua_node)
- -- setfield_node(n,"string",f)
- -- contextsprint(ctxcatcodes,"\\cldl",storenode(n)," ")
- -- end
-
- local new_latelua_node = nodes.pool.latelua
-
- function context.lateluafunction(f) -- not used anyway
- context(new_latelua_node(f))
- end
+-- function nodepool.lateluafunction(f)
+-- local n = copy_node(latelua_node)
+-- setfield_node(n,"string",f)
+-- return n
+-- end
+function nutpool.lateluafunction(f)
+ local n = copy_nut(latelua_nut)
+ setfield(n,"string",f)
+ return n
end
function nutpool.leftmarginkern(glyph,width)
@@ -631,13 +610,13 @@ local function cleanup(nofboxes) -- todo
local nr = nofreserved
for i=1,nofreserved do
local ri = reserved[i]
- free_nut(reserved[i])
+ flush_nut(reserved[i])
end
if nofboxes then
for i=0,nofboxes do
local l = getbox(i)
if l then
- free_nut(l) -- also list ?
+ flush_nut(l) -- also list ?
nl = nl + 1
end
end
diff --git a/tex/context/base/mkiv/pack-rul.lua b/tex/context/base/mkiv/pack-rul.lua
index e85e42200..eb15111b8 100644
--- a/tex/context/base/mkiv/pack-rul.lua
+++ b/tex/context/base/mkiv/pack-rul.lua
@@ -48,7 +48,7 @@ local getbox = nuts.getbox
local hpack = nuts.hpack
local traverse_id = nuts.traverse_id
local node_dimensions = nuts.dimensions
-local free_node = nuts.free
+local flush_node = nuts.flush
local checkformath = false
@@ -125,7 +125,7 @@ local function doreshapeframedbox(n)
setfield(h,"glue_order",getfield(p,"glue_order"))
setfield(h,"glue_sign",getfield(p,"glue_sign"))
setlist(p)
- free_node(p)
+ flush_node(p)
elseif checkformath and subtype == equation_code then
-- display formulas use a shift
if nofnonzero == 1 then
diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv
index d5b1c4234..5c45ddc18 100644
--- a/tex/context/base/mkiv/pack-rul.mkiv
+++ b/tex/context/base/mkiv/pack-rul.mkiv
@@ -2903,7 +2903,7 @@
\iffirstargument
\setupcurrentframedtext[#1]%
\fi
- \edef\p_framed_text_strut{\letframedtextparameter\c!strut}%
+ \edef\p_framed_text_strut{\framedtextparameter\c!strut}%
\letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
\blank[\v!disable]%
diff --git a/tex/context/base/mkiv/page-mix.lua b/tex/context/base/mkiv/page-mix.lua
index bafd6d234..2df762b5b 100644
--- a/tex/context/base/mkiv/page-mix.lua
+++ b/tex/context/base/mkiv/page-mix.lua
@@ -41,7 +41,7 @@ local listtoutf = nodes.listtoutf
local hpack = nuts.hpack
local vpack = nuts.vpack
-local freenode = nuts.free
+local flushnode = nuts.flush
local concatnodes = nuts.concat
local slidenodes = nuts.slide -- ok here as we mess with prev links intermediately
@@ -981,7 +981,7 @@ end
local function cleanup(result)
local discarded = result.discarded
for i=1,#discarded do
- freenode(discarded[i])
+ flushnode(discarded[i])
end
result.discarded = { }
end
diff --git a/tex/context/base/mkiv/page-str.lua b/tex/context/base/mkiv/page-str.lua
index 164fc7051..a254e9d7d 100644
--- a/tex/context/base/mkiv/page-str.lua
+++ b/tex/context/base/mkiv/page-str.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['page-str'] = {
-- streams -> managers.streams
--- work in progresss .. unfinished
+-- work in progresss .. unfinished .. non-optimized
local concat, insert, remove = table.concat, table.insert, table.remove
@@ -20,11 +20,11 @@ local implement = interfaces.implement
local nodecodes = nodes.nodecodes
-local slide_nodelist = node.slide
-local write_node = node.write
-local free_node = node.free
-local copy_nodelist = node.copy_list
-local vpack_nodelist = node.vpack
+local slide_node_list = nodes.slide
+local write_node = nodes.write
+local flush_node = nodes.flush
+local copy_node_list = nodes.copy_list
+local vpack_node_list = nodes.vpack
local settings_to_array = utilities.parsers.settings_to_array
@@ -72,7 +72,7 @@ function streams.collect(head,where)
end
local last = dana[#dana]
if last then
- local tail = slide_nodelist(last)
+ local tail = slide_node_list(last)
tail.next, head.prev = head, tail
elseif last == false then
dana[#dana] = head
@@ -116,7 +116,7 @@ function streams.flush(name,copy) -- problem: we need to migrate afterwards
for i=1,dn do
local di = dana[i]
if di then
- write_node(copy_nodelist(di.list)) -- list, will be option
+ write_node(copy_node_list(di.list)) -- list, will be option
end
end
if copy then
@@ -131,7 +131,7 @@ function streams.flush(name,copy) -- problem: we need to migrate afterwards
if di then
write_node(di.list) -- list, will be option
di.list = nil
- free_node(di)
+ flush_node(di)
end
end
end
@@ -164,7 +164,7 @@ function streams.synchronize(list) -- this is an experiment !
local dana = data[name]
local slot = dana[m]
if slot then
- local vbox = vpack_nodelist(slot)
+ local vbox = vpack_node_list(slot)
local ht, dp = vbox.height, vbox.depth
if ht > height then
height = ht
@@ -201,11 +201,11 @@ function streams.synchronize(list) -- this is an experiment !
else
-- this is not yet ok as we also need to keep an eye on vertical spacing
-- so we might need to do some splitting or whatever
- local tail = vbox.list and slide_nodelist(vbox.list)
+ local tail = vbox.list and slide_node_list(vbox.list)
local n, delta = 0, delta_height -- for tracing
while delta > 0 do
-- we need to add some interline penalties
- local line = copy_nodelist(texgetbox("strutbox"))
+ local line = copy_node_list(texgetbox("strutbox"))
line.height, line.depth = strutht, strutdp
if tail then
tail.next, line.prev = line, tail
@@ -213,9 +213,9 @@ function streams.synchronize(list) -- this is an experiment !
tail = line
n, delta = n +1, delta - struthtdp
end
- dana[m] = vpack_nodelist(vbox.list)
+ dana[m] = vpack_node_list(vbox.list)
vbox.list = nil
- free_node(vbox)
+ flush_node(vbox)
if trace_flushing then
report_streams("slot %s:%s with delta (%p,%p) is compensated by %s lines",m,i,delta_height,delta_depth,n)
end
diff --git a/tex/context/base/mkiv/publ-imp-aps.mkvi b/tex/context/base/mkiv/publ-imp-aps.mkvi
index 5099c5d9f..89e12b3e0 100644
--- a/tex/context/base/mkiv/publ-imp-aps.mkvi
+++ b/tex/context/base/mkiv/publ-imp-aps.mkvi
@@ -710,6 +710,7 @@
\starttexdefinition unexpanded btx:aps:journal-volume-year
\btxdoif {journal} {
+ \btxspace
\btxstartstyleandcolor [aps:\s!list:journal]
% expandedjournal abbreviatedjournal
\btxflush{expandedjournal -> journal}
@@ -1020,7 +1021,6 @@
\italiccorrection
\endgroup
\texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:publisher-wherefrom-year}}
- \texdefinition{btx:aps:url}
\texdefinition{btx:aps:note}
\stopsetups
@@ -1037,11 +1037,10 @@
\btxdoif {organization} {
\btxspace
\btxflush{organization}
- \btxperiod
+ \btxcomma
}
\btxdoif {howpublished} {
- \btxspace
- \btxflush{howpublished}
+ \texdefinition{btx:aps:doi-url} {\btxspace\btxflush{howpublished}}
}
\btxleftparenthesis
\texdefinition{btx:aps:year}
diff --git a/tex/context/base/mkiv/scrn-hlp.lua b/tex/context/base/mkiv/scrn-hlp.lua
index 99c0565a8..8f6f6f746 100644
--- a/tex/context/base/mkiv/scrn-hlp.lua
+++ b/tex/context/base/mkiv/scrn-hlp.lua
@@ -8,27 +8,27 @@ if not modules then modules = { } end modules ['scrn-hlp'] = {
local tonumber = tonumber
-local help = { }
-interactions.help = help
+local help = { }
+interactions.help = help
-local context = context
-local implement = interfaces.implement
+local context = context
+local implement = interfaces.implement
-local formatters = string.formatters
+local formatters = string.formatters
-local a_help = attributes.private("help")
+local a_help = attributes.private("help")
-local copy_nodelist = node.copy_list
-local hpack_nodelist = node.hpack
+local copy_node_list = node.copy_list
+local hpack_node_list = node.hpack
-local register_list = nodes.pool.register
+local register_list = nodes.pool.register
-local texgetbox = tex.getbox
+local texgetbox = tex.getbox
-local nodecodes = nodes.nodecodes
+local nodecodes = nodes.nodecodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
local data, references = { }, { }
@@ -59,7 +59,7 @@ local function register(specification)
interactions.javascripts.setpreamble("HelpTexts",helpscript)
helpscript = false
end
- local b = copy_nodelist(texgetbox(box))
+ local b = copy_node_list(texgetbox(box))
register_list(b)
data[number] = b
if name and name ~= "" then
@@ -128,7 +128,7 @@ implement {
for i=1,#used do
local d = data[used[i]]
if d and not done[d] then
- local box = hpack_nodelist(copy_nodelist(d))
+ local box = hpack_node_list(copy_node_list(d))
context(false,box)
done[d] = true
else
diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua
index f1f5757b7..f8f29b483 100644
--- a/tex/context/base/mkiv/spac-ver.lua
+++ b/tex/context/base/mkiv/spac-ver.lua
@@ -97,7 +97,7 @@ local getsubtype = nuts.getsubtype
local getbox = nuts.getbox
local find_node_tail = nuts.tail
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local traverse_nodes = nuts.traverse
local traverse_nodes_id = nuts.traverse_id
local insert_node_before = nuts.insert_before
@@ -1299,7 +1299,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
trace_done("flushed due to forced " .. why,glue_data)
end
head = forced_skip(head,current,getfield(glue_data,"width") or 0,"before",trace)
- free_node(glue_data)
+ flush_node(glue_data)
else
local w = getfield(glue_data,"width")
if w ~= 0 then
@@ -1314,7 +1314,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
head = insert_node_before(head,current,glue_data)
else
-- report_vspacing("needs checking (%s): %p",skipcodes[getsubtype(glue_data)],w)
- free_node(glue_data)
+ flush_node(glue_data)
end
end
end
@@ -1574,7 +1574,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
trace_skip("force",sc,so,sp,current)
end
glue_order = so
- free_node(glue_data)
+ flush_node(glue_data)
head, current, glue_data = remove_node(head, current)
elseif glue_order == so then
-- is now exclusive, maybe support goback as combi, else why a set
@@ -1585,7 +1585,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then
trace_skip("largest",sc,so,sp,current)
end
- free_node(glue_data)
+ flush_node(glue_data)
head, current, glue_data = remove_node(head,current)
else
if trace then
@@ -1597,7 +1597,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then
trace_skip("goback",sc,so,sp,current)
end
- free_node(glue_data)
+ flush_node(glue_data)
head, current, glue_data = remove_node(head,current)
elseif sc == force then
-- last one counts, some day we can provide an accumulator and largest etc
@@ -1605,13 +1605,13 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then
trace_skip("force",sc,so,sp,current)
end
- free_node(glue_data)
+ flush_node(glue_data)
head, current, glue_data = remove_node(head, current)
elseif sc == penalty then
if trace then
trace_skip("penalty",sc,so,sp,current)
end
- free_node(glue_data)
+ flush_node(glue_data)
glue_data = nil
head, current = remove_node(head, current, true)
elseif sc == add then
@@ -1821,7 +1821,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
end
if force_glue then
head, tail = forced_skip(head,tail,getfield(glue_data,"width") or 0,"after",trace)
- free_node(glue_data)
+ flush_node(glue_data)
glue_data = nil
else
head, tail = insert_node_after(head,tail,glue_data)
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 814d9d80a..2c5d3bad0 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 0234cf08f..8c4f7a84b 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-lev.lua b/tex/context/base/mkiv/strc-lev.lua
index 1d60e3a8f..c06e209f6 100644
--- a/tex/context/base/mkiv/strc-lev.lua
+++ b/tex/context/base/mkiv/strc-lev.lua
@@ -35,6 +35,11 @@ local function definesectionlevels(category,list)
levels[category] = list
end
+local ctx_nostarthead = context.nostarthead
+local ctx_dostarthead = context.dostarthead
+local ctx_nostophead = context.nostophead
+local ctx_dostophead = context.dostophead
+
local function startsectionlevel(n,category,current)
category = category ~= "" and category or v_default
local lc = levels[category]
@@ -47,13 +52,13 @@ local function startsectionlevel(n,category,current)
end
level = level + 1
if not lc or level > #lc then
- context.nostarthead { f_two_colon(category,level) }
+ ctx_nostarthead { f_two_colon(category,level) }
else
local lcl = lc[level]
if n > #lcl then
n = #lcl
end
- context.dostarthead { lc[level][n] }
+ ctx_dostarthead { lc[level][n] }
end
insert(categories,{ category, n })
end
@@ -65,9 +70,9 @@ local function stopsectionlevel()
local n = top[2]
local lc = levels[category]
if not lc or level > #lc then
- context.nostophead { f_two_colon(category,level) }
+ ctx_nostophead { f_two_colon(category,level) }
else
- context.dostophead { lc[level][n] }
+ ctx_dostophead { lc[level][n] }
end
level = level - 1
else
diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua
index 6c2846fd1..c12cca2c2 100644
--- a/tex/context/base/mkiv/supp-box.lua
+++ b/tex/context/base/mkiv/supp-box.lua
@@ -47,7 +47,7 @@ local setnext = nuts.setnext
local setbox = nuts.setbox
local setlist = nuts.setlist
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local flush_list = nuts.flush_list
local copy_node = nuts.copy
local copy_list = nuts.copy_list
@@ -113,7 +113,7 @@ local function hyphenatedlist(head,usecolor)
if next then
setlink(tail,next)
end
- -- free_node(current)
+ -- flush_node(current)
elseif id == vlist_code or id == hlist_code then
hyphenatedlist(getlist(current))
end
@@ -331,7 +331,7 @@ implement {
else
tail = prev
end
- free_node(temp)
+ flush_node(temp)
end
-- done
setnext(tail)
@@ -408,7 +408,7 @@ local function setboxtonaturalwd(n)
local old = takebox(n)
local new = hpack(getlist(old))
setlist(old,nil)
- free_node(old)
+ flush_node(old)
setbox(n,new)
end
diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv
index d617c82db..745b37f79 100644
--- a/tex/context/base/mkiv/supp-box.mkiv
+++ b/tex/context/base/mkiv/supp-box.mkiv
@@ -2923,6 +2923,19 @@
\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \plusone} % not yet in i-*
\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \fontid\font} % not yet in i-*
+%D To complement lua (yet undocumented):
+
+\unexpanded\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup
+\unexpanded\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup
+
+\unexpanded\def\setvboxregister#1{\setbox#1\vbox}
+\unexpanded\def\sethboxregister#1{\setbox#1\hbox}
+
+\unexpanded\def\flushboxregister#1{\box\numexpr#1\relax}
+
+\unexpanded\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup
+\unexpanded\def\startvboxregister#1{\setbox#1\hbox\bgroup} \let\stopvboxregister\egroup
+
\protect \endinput
% a bit of test code:
diff --git a/tex/context/base/mkiv/syst-lua.lua b/tex/context/base/mkiv/syst-lua.lua
index 0cbcd6988..d35a5111a 100644
--- a/tex/context/base/mkiv/syst-lua.lua
+++ b/tex/context/base/mkiv/syst-lua.lua
@@ -10,92 +10,70 @@ local find, match = string.find, string.match
local tonumber = tonumber
local S, C, P, lpegmatch, lpegtsplitat = lpeg.S, lpeg.C, lpeg.P, lpeg.match, lpeg.tsplitat
+commands = commands or { }
+local commands = commands
+local context = context
+local implement = interfaces.implement
-commands = commands or { }
-local commands = commands
-
-local implement = interfaces.implement
+local protectedcs = context.protectedcs -- efficient
+local ctx_firstoftwoarguments = protectedcs.firstoftwoarguments
+local ctx_secondoftwoarguments = protectedcs.secondoftwoarguments
+local ctx_firstofoneargument = protectedcs.firstofoneargument
+local ctx_gobbleoneargument = protectedcs.gobbleoneargument
local two_strings = interfaces.strings[2]
-local context = context
------ csprint = context.sprint
-
-local prtcatcodes = tex.prtcatcodes
-
-implement { -- will b eoverloaded later
+implement { -- will be overloaded later
name = "writestatus",
arguments = two_strings,
actions = logs.status,
}
-local ctx_firstoftwoarguments = context.firstoftwoarguments -- context.constructcsonly("firstoftwoarguments" )
-local ctx_secondoftwoarguments = context.secondoftwoarguments -- context.constructcsonly("secondoftwoarguments")
-local ctx_firstofoneargument = context.firstofoneargument -- context.constructcsonly("firstofoneargument" )
-local ctx_gobbleoneargument = context.gobbleoneargument -- context.constructcsonly("gobbleoneargument" )
-
--- contextsprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments
--- contextsprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments
--- contextsprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments
--- contextsprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments
-
function commands.doifelse(b)
if b then
ctx_firstoftwoarguments()
- -- csprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments
else
ctx_secondoftwoarguments()
- -- csprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments
end
end
function commands.doifelsesomething(b)
if b and b ~= "" then
ctx_firstoftwoarguments()
- -- csprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments
else
ctx_secondoftwoarguments()
- -- csprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments
end
end
function commands.doif(b)
if b then
ctx_firstofoneargument()
--- context.__flushdirect(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments
else
ctx_gobbleoneargument()
--- context.__flushdirect(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments
end
end
function commands.doifsomething(b)
if b and b ~= "" then
ctx_firstofoneargument()
- -- context.__flushdirect(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments
else
ctx_gobbleoneargument()
- -- context.__flushdirect(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments
end
end
function commands.doifnot(b)
if b then
ctx_gobbleoneargument()
- -- csprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments
else
ctx_firstofoneargument()
- -- csprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments
end
end
function commands.doifnotthing(b)
if b and b ~= "" then
ctx_gobbleoneargument()
- -- csprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments
else
ctx_firstofoneargument()
- -- csprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments
end
end
diff --git a/tex/context/base/mkiv/tabl-tbl.mkiv b/tex/context/base/mkiv/tabl-tbl.mkiv
index 315844db3..426e83d1d 100644
--- a/tex/context/base/mkiv/tabl-tbl.mkiv
+++ b/tex/context/base/mkiv/tabl-tbl.mkiv
@@ -2520,4 +2520,34 @@
\definetabulate[tabulate] \setuptabulate[tabulate][\c!format=\v!none] % so no \v! here
+%D The following helpers are just there because we also have them at the \LUA\ end:
+%D
+%D \startbuffer
+%D \starttabulate[|l|c|r|]
+%D \tabulaterow {a,b,c}
+%D \tabulaterowbold{aa,bb,cc}
+%D \tabulaterowtype{aaa,bbb,ccc}
+%D \tabulaterowtyp {aaaa,bbbb,cccc}
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\def\tabl_tabulate_compact_row#1#2%
+ {\NC\tabl_tabulate_compact_step#1#2,\end,}
+
+\def\tabl_tabulate_compact_step#1#2#3,%
+ {\ifx#2\end
+ \NR
+ \expandafter\gobbleoneargument
+ \else
+ #1{#2#3}\NC
+ \expandafter\tabl_tabulate_compact_step
+ \fi#1}
+
+\unexpanded\def\tabulaterow {\tabl_tabulate_compact_row\relax}
+\unexpanded\def\tabulaterowbold{\tabl_tabulate_compact_row\bold}
+\unexpanded\def\tabulaterowtype{\tabl_tabulate_compact_row\type}
+\unexpanded\def\tabulaterowtyp {\tabl_tabulate_compact_row\typ}
+
\protect \endinput
diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua
index 937e2d816..f549d1cd6 100644
--- a/tex/context/base/mkiv/tabl-xtb.lua
+++ b/tex/context/base/mkiv/tabl-xtb.lua
@@ -28,78 +28,79 @@ this mechamism will be improved so that it can replace its older cousin.
local tonumber, next, rawget = tonumber, next, rawget
-local commands = commands
-local context = context
-local tex = tex
-
-local implement = interfaces.implement
-
-local texgetcount = tex.getcount
-local texsetcount = tex.setcount
-local texgetdimen = tex.getdimen
-local texsetdimen = tex.setdimen
-local texget = tex.get
-
-local format = string.format
-local concat = table.concat
-local points = number.points
-
-local todimen = string.todimen
-
-local context_beginvbox = context.beginvbox
-local context_endvbox = context.endvbox
-local context_blank = context.blank
-local context_nointerlineskip = context.nointerlineskip
-local context_dummyxcell = context.dummyxcell
-
-local variables = interfaces.variables
-
-local setmetatableindex = table.setmetatableindex
-local settings_to_hash = utilities.parsers.settings_to_hash
-
-local nuts = nodes.nuts -- here nuts gain hardly nothing
-local tonut = nuts.tonut
-local tonode = nuts.tonode
-
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getlist = nuts.getlist
-local getfield = nuts.getfield
-local getbox = nuts.getbox
-
-local setfield = nuts.setfield
-local setlink = nuts.setlink
-
-local copy_node_list = nuts.copy_list
-local hpack_node_list = nuts.hpack
-local flush_node_list = nuts.flush_list
-local takebox = nuts.takebox
-
-local nodepool = nuts.pool
-
-local new_glue = nodepool.glue
-local new_kern = nodepool.kern
-local new_hlist = nodepool.hlist
-
-local v_stretch = variables.stretch
-local v_normal = variables.normal
-local v_width = variables.width
-local v_height = variables.height
-local v_repeat = variables["repeat"]
-local v_max = variables.max
-local v_fixed = variables.fixed
------ v_auto = variables.auto
-local v_before = variables.before
-local v_after = variables.after
-local v_both = variables.both
-local v_samepage = variables.samepage
-local v_tight = variables.tight
-
-local xtables = { }
-typesetters.xtables = xtables
-
-local trace_xtable = false
-local report_xtable = logs.reporter("xtable")
+local commands = commands
+local context = context
+local ctxnode = context.flushnode
+
+local implement = interfaces.implement
+
+local tex = tex
+local texgetcount = tex.getcount
+local texsetcount = tex.setcount
+local texgetdimen = tex.getdimen
+local texsetdimen = tex.setdimen
+local texget = tex.get
+
+local format = string.format
+local concat = table.concat
+local points = number.points
+
+local todimen = string.todimen
+
+local ctx_beginvbox = context.beginvbox
+local ctx_endvbox = context.endvbox
+local ctx_blank = context.blank
+local ctx_nointerlineskip = context.nointerlineskip
+local ctx_dummyxcell = context.dummyxcell
+
+local variables = interfaces.variables
+
+local setmetatableindex = table.setmetatableindex
+local settings_to_hash = utilities.parsers.settings_to_hash
+
+local nuts = nodes.nuts -- here nuts gain hardly nothing
+local tonut = nuts.tonut
+local tonode = nuts.tonode
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getlist = nuts.getlist
+local getfield = nuts.getfield
+local getbox = nuts.getbox
+
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+
+local copy_node_list = nuts.copy_list
+local hpack_node_list = nuts.hpack
+local flush_node_list = nuts.flush_list
+local takebox = nuts.takebox
+
+local nodepool = nuts.pool
+
+local new_glue = nodepool.glue
+local new_kern = nodepool.kern
+local new_hlist = nodepool.hlist
+
+local v_stretch = variables.stretch
+local v_normal = variables.normal
+local v_width = variables.width
+local v_height = variables.height
+local v_repeat = variables["repeat"]
+local v_max = variables.max
+local v_fixed = variables.fixed
+----- v_auto = variables.auto
+local v_before = variables.before
+local v_after = variables.after
+local v_both = variables.both
+local v_samepage = variables.samepage
+local v_tight = variables.tight
+
+local xtables = { }
+typesetters.xtables = xtables
+
+local trace_xtable = false
+local report_xtable = logs.reporter("xtable")
trackers.register("xtable.construct", function(v) trace_xtable = v end)
@@ -920,29 +921,29 @@ local function inject(row,copy,package)
row[1] = copy_node_list(list)
end
if package then
- context_beginvbox()
- context(tonode(list))
- context(tonode(new_kern(row[2])))
- context_endvbox()
- context_nointerlineskip() -- figure out a better way
+ ctx_beginvbox()
+ ctxnode(tonode(list))
+ ctxnode(tonode(new_kern(row[2])))
+ ctx_endvbox()
+ ctx_nointerlineskip() -- figure out a better way
if row[4] then
-- nothing as we have a span
elseif row[5] then
if row[3] then
- context_blank { v_samepage, row[3] .. "sp" }
+ ctx_blank { v_samepage, row[3] .. "sp" }
else
- context_blank { v_samepage }
+ ctx_blank { v_samepage }
end
elseif row[3] then
- context_blank { row[3] .. "sp" } -- why blank ?
+ ctx_blank { row[3] .. "sp" } -- why blank ?
else
- context(tonode(new_glue(0)))
+ ctxnode(tonode(new_glue(0)))
end
else
- context(tonode(list))
- context(tonode(new_kern(row[2])))
+ ctxnode(tonode(list))
+ ctxnode(tonode(new_kern(row[2])))
if row[3] then
- context(tonode(new_glue(row[3])))
+ ctxnode(tonode(new_glue(row[3])))
end
end
end
@@ -999,7 +1000,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
local repeatheader = settings.header == v_repeat
local repeatfooter = settings.footer == v_repeat
if height and height > 0 then
- context_beginvbox()
+ ctx_beginvbox()
local bodystart = data.bodystart or 1
local bodystop = data.bodystop or #body
if bodystart > 0 and bodystart <= bodystop then
@@ -1015,7 +1016,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
inject(head[i],repeatheader)
end
if rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
if not repeatheader then
results[head_mode] = { }
@@ -1028,7 +1029,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
inject(more[i],true)
end
if rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
end
elseif headsize > 0 and repeatheader then -- following chunk gets head
@@ -1038,7 +1039,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
inject(head[i],true)
end
if rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
end
else -- following chunk gets nothing
@@ -1065,7 +1066,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
-- all is flushed and footer fits
if footsize > 0 then
if rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
for i=1,#foot do
inject(foot[i])
@@ -1079,7 +1080,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
-- todo: try to flush a few more lines
if repeatfooter and footsize > 0 then
if rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
for i=1,#foot do
inject(foot[i],true)
@@ -1105,7 +1106,7 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
end
data.bodystart = bodystart
data.bodystop = bodystop
- context_endvbox()
+ ctx_endvbox()
else
if method == variables.split then
-- maybe also a non float mode with header/footer repeat although
@@ -1114,35 +1115,35 @@ function xtables.flush(directives) -- todo split by size / no inbetween then ..
inject(head[i],false,true)
end
if #head > 0 and rowdistance > 0 then
- context_blank { rowdistance .. "sp" }
+ ctx_blank { rowdistance .. "sp" }
end
for i=1,#body do
inject(body[i],false,true)
end
if #foot > 0 and rowdistance > 0 then
- context_blank { rowdistance .. "sp" }
+ ctx_blank { rowdistance .. "sp" }
end
for i=1,#foot do
inject(foot[i],false,true)
end
else -- normal
- context_beginvbox()
+ ctx_beginvbox()
for i=1,#head do
inject(head[i])
end
if #head > 0 and rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
for i=1,#body do
inject(body[i])
end
if #foot > 0 and rowdistance > 0 then
- context(tonode(new_glue(rowdistance)))
+ ctxnode(tonode(new_glue(rowdistance)))
end
for i=1,#foot do
inject(foot[i])
end
- context_endvbox()
+ ctx_endvbox()
end
results[head_mode] = { }
results[body_mode] = { }
@@ -1199,7 +1200,7 @@ function xtables.finish_row()
end
if n > 0 then
for i=1,n do
- context_dummyxcell()
+ ctx_dummyxcell()
end
end
end
@@ -1260,19 +1261,20 @@ implement { name = "x_table_c", actions = function() con
do
local context = context
+ local ctxcore = context.core
- local startxtable = context.startxtable
- local stopxtable = context.stopxtable
+ local startxtable = ctxcore.startxtable
+ local stopxtable = ctxcore.stopxtable
local startcollecting = context.startcollecting
local stopcollecting = context.stopcollecting
- function context.startxtable(...)
+ function ctxcore.startxtable(...)
startcollecting()
startxtable(...)
end
- function context.stopxtable()
+ function ctxcore.stopxtable()
stopxtable()
stopcollecting()
end
diff --git a/tex/context/base/mkiv/trac-inf.lua b/tex/context/base/mkiv/trac-inf.lua
index 401fd01e7..a1d7fb0a0 100644
--- a/tex/context/base/mkiv/trac-inf.lua
+++ b/tex/context/base/mkiv/trac-inf.lua
@@ -183,6 +183,7 @@ end
function statistics.runtime()
stoptiming(statistics)
+ stoptiming(statistics) -- somehow we can start the timer twice, but where
return statistics.formatruntime(elapsedtime(statistics))
end
diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua
index e37a31902..93e6af7c2 100644
--- a/tex/context/base/mkiv/trac-vis.lua
+++ b/tex/context/base/mkiv/trac-vis.lua
@@ -94,8 +94,7 @@ local getdisc = nuts.getdisc
local hpack_nodes = nuts.hpack
local vpack_nodes = nuts.vpack
local copy_list = nuts.copy_list
-local free_node = nuts.free
-local free_node_list = nuts.flush_list
+local flush_node_list = nuts.flush_list
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local traverse_nodes = nuts.traverse
@@ -970,7 +969,7 @@ do
local function freed(cache)
local n = 0
for k, v in next, cache do
- free_node_list(v)
+ flush_node_list(v)
n = n + 1
end
if n == 0 then
diff --git a/tex/context/base/mkiv/typo-brk.lua b/tex/context/base/mkiv/typo-brk.lua
index 2c21b97d4..749c25a33 100644
--- a/tex/context/base/mkiv/typo-brk.lua
+++ b/tex/context/base/mkiv/typo-brk.lua
@@ -45,9 +45,9 @@ local setprev = nuts.setprev
local setboth = nuts.setboth
local setsubtype = nuts.setsubtype
-local copy_node = nuts.copy
-local copy_nodelist = nuts.copy_list
-local free_node = nuts.free
+local copy_node = nuts.copy_node
+local copy_node_list = nuts.copy_list
+local flush_node = nuts.flush_node
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local remove_node = nuts.remove
@@ -156,7 +156,7 @@ methods[6] = function(head,start,stop,settings,kern)
else
setprev(start)
setnext(stop)
- setdisc(d,start,nil,copy_nodelist(start))
+ setdisc(d,start,nil,copy_node_list(start))
end
stop = r
end
@@ -235,7 +235,7 @@ methods[5] = function(head,start,stop,settings) -- x => p q r
end
setdisc(start,left,right,middle)
setfield(start,"attr",attr) -- todo: critical only -- just a copy will do
- free_node(tmp)
+ flush_node(tmp)
insert_break(head,start,start,10000,10000)
end
return head, start
diff --git a/tex/context/base/mkiv/typo-chr.lua b/tex/context/base/mkiv/typo-chr.lua
index ae09db4f8..f6bcfde56 100644
--- a/tex/context/base/mkiv/typo-chr.lua
+++ b/tex/context/base/mkiv/typo-chr.lua
@@ -93,7 +93,7 @@ local glyph_code = nodecodes.glyph
local localpar_code = nodecodes.localpar
local texnest = tex.nest
-local free_node = node.free
+local flush_node = node.flush_node
local flush_list = node.flush_list
local settexattribute = tex.setattribute
@@ -134,7 +134,7 @@ local actions = {
remove = function(specification)
local n = pickup()
if n then
- free_node(n)
+ flush_node(n)
end
end,
push = function(specification)
diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua
index f31bb6a4e..dd49591f2 100644
--- a/tex/context/base/mkiv/typo-drp.lua
+++ b/tex/context/base/mkiv/typo-drp.lua
@@ -263,7 +263,7 @@ actions[v_default] = function(head,setting)
-- nodes.handlers.characters(g)
-- nodes.handlers.protectglyphs(g)
-- setchar(current,g.char)
--- nodes.free(g)
+-- nodes.flush_node(g)
-- can be a helper
if ca and ca > 0 then
diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua
index 711d095bb..bd6d749cc 100644
--- a/tex/context/base/mkiv/typo-fln.lua
+++ b/tex/context/base/mkiv/typo-fln.lua
@@ -53,8 +53,8 @@ local disc_code = nodecodes.disc
local kern_code = nodecodes.kern
local traverse_id = nuts.traverse_id
-local free_node_list = nuts.flush_list
-local free_node = nuts.flush_node
+local flush_node_list = nuts.flush_list
+local flush_node = nuts.flush_node
local copy_node_list = nuts.copy_list
local insert_node_after = nuts.insert_after
local remove_node = nuts.remove
@@ -264,7 +264,7 @@ actions[v_line] = function(head,setting)
end
end
setdisc(disc,pre,post,replace)
- free_node(disc)
+ flush_node(disc)
end
if linebreak == n then
if trace_firstlines then
@@ -278,7 +278,7 @@ actions[v_line] = function(head,setting)
start = getnext(start)
end
end
- free_node_list(temp)
+ flush_node_list(temp)
return head, true
end
diff --git a/tex/context/base/mkiv/typo-krn.lua b/tex/context/base/mkiv/typo-krn.lua
index e6072144b..5a42caeca 100644
--- a/tex/context/base/mkiv/typo-krn.lua
+++ b/tex/context/base/mkiv/typo-krn.lua
@@ -24,7 +24,7 @@ local tonut = nuts.tonut
-- check what is used
local find_node_tail = nuts.tail
-local free_node = nuts.free
+local flush_node = nuts.flush_node
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local end_of_math = nuts.end_of_math
@@ -410,7 +410,7 @@ function kerns.handler(head)
end
start = c
setfield(s,"components",nil)
- free_node(s)
+ flush_node(s)
c = getfield(start,"components")
end
end
diff --git a/tex/context/base/mkiv/typo-mar.lua b/tex/context/base/mkiv/typo-mar.lua
index 74f5c2eb9..dbf6602e7 100644
--- a/tex/context/base/mkiv/typo-mar.lua
+++ b/tex/context/base/mkiv/typo-mar.lua
@@ -63,7 +63,7 @@ local tonut = nuts.tonut
local hpack_nodes = nuts.hpack
local traverse_id = nuts.traverse_id
-local free_node_list = nuts.flush_list
+local flush_node_list = nuts.flush_list
local linked_nodes = nuts.linked
local getfield = nuts.getfield
@@ -248,7 +248,7 @@ function margins.save(t)
local si = store[i]
if si.name == name then
local s = remove(store,i)
- free_node_list(s.box)
+ flush_node_list(s.box)
end
end
else
@@ -256,7 +256,7 @@ function margins.save(t)
local si = store[i]
if si.name == name then
local s = remove(store,i)
- free_node_list(s.box)
+ flush_node_list(s.box)
end
end
end