Attempt better maxdeadcycles handling

This commit is contained in:
Marcel Fabian Krüger 2021-11-21 16:11:49 +01:00
parent 8494bde0a5
commit fc21983b16

View File

@ -124,49 +124,60 @@ local do_terminal_input do
end end
end end
local errorvalues = tex.geterrorvalues() do
function callbacks.intercept_tex_error(mode, errortype) local errorvalues = tex.geterrorvalues()
errortype = errorvalues[errortype] local function intercept(mode, errortype)
if errortype == "eof" then errortype = errorvalues[errortype]
-- print('EOF', token.peek_next()) if errortype == "eof" then
token.put_next(token.create'ABD') -- print('EOF', token.peek_next())
token.put_next(token.create'ABD')
return 3
end
texio.write'.'
if mode == 0 then return 0 end
tex.showcontext()
if mode ~= 3 then
texio.write('logfile', tex.gethelptext() .. '\n')
return mode
end
repeat
texio.write_nl'? '
local line = io.read()
if not line then
tex.fatalerror'End of line encountered on terminal'
end
if line == "" then return 3 end
local first = line:sub(1,1):upper()
if first == 'H' then
texio.write(tex.gethelptext() or "Sorry, I don't know how to help in this situation.\n\z
Maybe you should try asking a human?")
elseif first == 'I' then
line = line:sub(2)
tex.runlocal(function()
tex.sprint(token.scan_token(), line)
end)
return 3
elseif first == 'Q' then texio.write'OK, entering \\batchmode...\n' return 0
elseif first == 'R' then texio.write'OK, entering \\nonstopmode...\n' return 1
elseif first == 'S' then texio.write'OK, entering \\scrollmode...\n' return 2
elseif first == 'X' then return -1
else
texio.write'Type <return> to proceed, S to scroll future error messages,\
\z R to run without stopping, Q to run quietly,\
\z I to insert something,\
\z H for help, X to quit.'
end
until false
return 3 return 3
end end
texio.write'.' function callbacks.intercept_tex_error(mode, errortype)
if mode == 0 then return 0 end local ret = intercept(mode, errortype)
tex.showcontext() if tex.deadcycles >= tex.maxdeadcycles then
if mode ~= 3 then tex.runtoks(function()
texio.write('logfile', tex.gethelptext() .. '\n') tex.sprint(1, '\\shipout\\box255')
return mode
end
repeat
texio.write_nl'? '
local line = io.read()
if not line then
tex.fatalerror'End of line encountered on terminal'
end
if line == "" then return 3 end
local first = line:sub(1,1):upper()
if first == 'H' then
texio.write(tex.gethelptext() or "Sorry, I don't know how to help in this situation.\n\z
Maybe you should try asking a human?")
elseif first == 'I' then
line = line:sub(2)
tex.runlocal(function()
tex.sprint(token.scan_token(), line)
end) end)
return 3
elseif first == 'Q' then texio.write'OK, entering \\batchmode...\n' return 0
elseif first == 'R' then texio.write'OK, entering \\nonstopmode...\n' return 1
elseif first == 'S' then texio.write'OK, entering \\scrollmode...\n' return 2
elseif first == 'X' then return -1
else
texio.write'Type <return> to proceed, S to scroll future error messages,\
\z R to run without stopping, Q to run quietly,\
\z I to insert something,\
\z H for help, X to quit.'
end end
until false return ret
return 3 end
end end
callbacks.__freeze'intercept_tex_error' callbacks.__freeze'intercept_tex_error'