Some updates

This commit is contained in:
Marcel Krüger 2021-04-16 10:15:58 +02:00
parent a6d3b3cc0f
commit 7f370bc361
6 changed files with 53 additions and 50 deletions

View File

@ -63,18 +63,16 @@ local function get_outline()
return outline return outline
end end
local properties = node.direct.properties local properties = node.direct.properties
local immediateassignment = token.new(5, token.command_id'convert') local reset_deadcycles do
local global = token.new(0, token.command_id'prefix') local tokens = {
local deadcycles = token.new(8, token.command_id'set_page_property') token.primitive_tokens.global,
local zero_tok = token.create(0x30) token.primitive_tokens.deadcycles,token.create(0x30),
local relax = token.new(0, 0) token.primitive_tokens.relax,
local reset_deadcycles = {
immediateassignment,
global,
deadcycles,
zero_tok,
relax,
} }
function reset_deadcycles()
token.put_next(tokens)
end
end
token.luacmd("shipout", function() token.luacmd("shipout", function()
local pfile = get_pfile() local pfile = get_pfile()
local total_voffset, total_hoffset = tex.voffset + pdfvariable.vorigin, tex.hoffset + pdfvariable.horigin local total_voffset, total_hoffset = tex.voffset + pdfvariable.vorigin, tex.hoffset + pdfvariable.horigin
@ -95,8 +93,7 @@ token.luacmd("shipout", function()
local content = pfile:stream(nil, '', out) local content = pfile:stream(nil, '', out)
pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources%s%s%s%s>>]], parent, content, -math.ceil(to_bp(list.depth)), math.ceil(to_bp(list.width)), math.ceil(to_bp(list.height)), resources(pdfvariable.pageresources .. pdf.pageresources), annots, pdfvariable.pageattr, pdf.pageattributes)) pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources%s%s%s%s>>]], parent, content, -math.ceil(to_bp(list.depth)), math.ceil(to_bp(list.width)), math.ceil(to_bp(list.height)), resources(pdfvariable.pageresources .. pdf.pageresources), annots, pdfvariable.pageattr, pdf.pageattributes))
node.flush_list(list) node.flush_list(list)
token.put_next(reset_deadcycles) tex.runlocal(reset_deadcycles)
scan_token()
end, 'force', 'protected') end, 'force', 'protected')
local infodir = "" local infodir = ""
@ -226,7 +223,8 @@ function callbacks.stop_run()
local size = pfile:close() local size = pfile:close()
texio.write_nl("term", "(see the transcript file for additional information)") texio.write_nl("term", "(see the transcript file for additional information)")
-- TODO: Additional logging, epecially targeting the log file -- TODO: Additional logging, epecially targeting the log file
texio.write_nl("term and log", string.format(" %d words of node memory still in use:", status.nodestate.use)) texio.write_nl("term and log", " node memory still in use:")
-- texio.write_nl("term and log", string.format(" %d words of node memory still in use:", status.nodestate.use))
local by_type, by_sub = {}, {} local by_type, by_sub = {}, {}
for n, id, sub in node.traverse(node.usedlist()) do for n, id, sub in node.traverse(node.usedlist()) do
if id == whatsit_id then if id == whatsit_id then

View File

@ -103,9 +103,8 @@ local errorvalues = tex.geterrorvalues()
function callbacks.intercept_tex_error(mode, errortype) function callbacks.intercept_tex_error(mode, errortype)
errortype = errorvalues[errortype] errortype = errorvalues[errortype]
if errortype == "eof" then if errortype == "eof" then
tex.runlocal(function()token.put_next(token.create'tracingall')end) -- print('EOF', token.peek_next())
do_terminal_input() token.put_next(token.create'ABD')
tex.runlocal(token.skip_next)
return 3 return 3
end end
texio.write'.' texio.write'.'

View File

@ -121,6 +121,9 @@ tex_variable(count_code, scan_int, 'outputmode', 1) -- The "traditional" default
tex_variable(dimen_code, scan_dimen, 'pageheight', 0) tex_variable(dimen_code, scan_dimen, 'pageheight', 0)
tex_variable(dimen_code, scan_dimen, 'pagewidth', 0) tex_variable(dimen_code, scan_dimen, 'pagewidth', 0)
tex_variable(dimen_code, scan_dimen, 'hoffset', 0)
tex_variable(dimen_code, scan_dimen, 'voffset', 0)
tex_variable(count_code, scan_int, 'bodydirection', 0) tex_variable(count_code, scan_int, 'bodydirection', 0)
tex_variable(count_code, scan_int, 'pagedirection', 0) tex_variable(count_code, scan_int, 'pagedirection', 0)

View File

@ -190,6 +190,9 @@ token.luacmd("read", function(_, prefix)
end end
local macro = scan_csname(true) local macro = scan_csname(true)
local file = ifiles[id] local file = ifiles[id]
local tokens = {}
local balance = 0
repeat
local line local line
if file then if file then
line = file:reader() line = file:reader()
@ -198,7 +201,7 @@ token.luacmd("read", function(_, prefix)
ifiles[id] = nil ifiles[id] = nil
end end
else else
error[[FIXME: Ask the user for input]] line = io.stdin:read()
end end
local endlocal local endlocal
tex.runlocal(function() tex.runlocal(function()
@ -207,8 +210,6 @@ token.luacmd("read", function(_, prefix)
tex.print(line and line ~= "" and line or " ") tex.print(line and line ~= "" and line or " ")
tex.print(endlocal) tex.print(endlocal)
end) end)
local tokens = {}
local balance = 0
while true do while true do
local tok = token.scan_next() local tok = token.scan_next()
if tok == endlocal then break end if tok == endlocal then break end
@ -219,7 +220,7 @@ token.luacmd("read", function(_, prefix)
end end
tokens[#tokens+1] = tok tokens[#tokens+1] = tok
end end
if balance ~= 0 then error[[FIXME: Read additional input lines]] end until balance == 0
tex.runlocal(function() tex.runlocal(function()
tokens[#tokens+1] = rbrace tokens[#tokens+1] = rbrace
token.put_next(tokens) token.put_next(tokens)

View File

@ -68,7 +68,7 @@ end
local undefined_cmd = token.command_id'undefined_cs' local undefined_cmd = token.command_id'undefined_cs'
local lua_call_cmd = token.command_id'lua_call' local lua_call_cmd = token.command_id'lua_call'
local lua_value_cmd = token.command_id'lua_value' local lua_value_cmd = token.command_id'lua_value'
local lua_expandable_call_cmd = token.command_id'lua_expandable_call' local lua_protected_call_cmd = token.command_id'lua_protected_call'
local if_test_cmd = token.command_id'if_test' local if_test_cmd = token.command_id'if_test'
function token.luacmd(name, func, ...) function token.luacmd(name, func, ...)
local idx local idx
@ -78,10 +78,10 @@ function token.luacmd(name, func, ...)
idx = tok.index idx = tok.index
elseif cmd == lua_call_cmd then elseif cmd == lua_call_cmd then
idx = tok.index idx = tok.index
elseif cmd == lua_expandable_call_cmd then elseif cmd == lua_protected_call_cmd then
idx = tok.index idx = tok.index
elseif cmd == if_test_cmd and tok.index > 48 then elseif cmd == if_test_cmd and tok.index > 49 then
idx = tok.index - 48 idx = tok.index - 49
elseif ... == 'force' then elseif ... == 'force' then
idx = new_luafunction(name) idx = new_luafunction(name)
set_lua(name, idx, select(2, ...)) set_lua(name, idx, select(2, ...))
@ -106,6 +106,7 @@ if initex then
local prepared = lua.prepared_code local prepared = lua.prepared_code
prepared[1] = string.format("fixupluafunctions(%i)", predefined_luafunctions) prepared[1] = string.format("fixupluafunctions(%i)", predefined_luafunctions)
--[[
for i=0,0 do -- maybeFIXME: In practise only one language is preloaded in LuaTeX anyway for i=0,0 do -- maybeFIXME: In practise only one language is preloaded in LuaTeX anyway
-- for i=0,tex.count[19] do -- Sometimes catches reserved language ids which are not used yet -- for i=0,tex.count[19] do -- Sometimes catches reserved language ids which are not used yet
-- for i=0,lang.new():id()-1 do -- lang.new():id() is always 0 in luametatex?!? -- for i=0,lang.new():id()-1 do -- lang.new():id() is always 0 in luametatex?!?
@ -136,6 +137,7 @@ if initex then
end end
prepared[#prepared+1] = str prepared[#prepared+1] = str
end end
]]
for i=2,#prepared do for i=2,#prepared do
if type(prepared[i]) ~= 'string' then if type(prepared[i]) ~= 'string' then
prepared[i] = assert(prepared[i]()) prepared[i] = assert(prepared[i]())

View File

@ -273,7 +273,7 @@ nodehandler.math = ignore_node
nodehandler.kern = ignore_node nodehandler.kern = ignore_node
-- The following are only for frontend use: -- The following are only for frontend use:
nodehandler.boundary = ignore_node nodehandler.boundary = ignore_node
nodehandler.local_par = ignore_node nodehandler.par = ignore_node
nodehandler.penalty = ignore_node nodehandler.penalty = ignore_node
nodehandler.mark = ignore_node nodehandler.mark = ignore_node