summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/trac-deb.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/trac-deb.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/trac-deb.lua44
1 files changed, 35 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/context/base/trac-deb.lua b/Master/texmf-dist/tex/context/base/trac-deb.lua
index 87434a13d9d..fe167c343e2 100644
--- a/Master/texmf-dist/tex/context/base/trac-deb.lua
+++ b/Master/texmf-dist/tex/context/base/trac-deb.lua
@@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['trac-deb'] = {
license = "see context related readme files"
}
-local lpeg = lpeg
+local lpeg, status = lpeg, status
+
local lpegmatch = lpeg.match
local format, concat, match = string.format, table.concat, string.match
local tonumber, tostring = tonumber, tostring
@@ -94,20 +95,42 @@ end
function tracers.showlines(filename,linenumber,offset,errorstr)
local data = io.loaddata(filename)
+ if not data or data == "" then
+ local hash = url.hashed(filename)
+ if not hash.noscheme then
+ local ok, d, n = resolvers.loaders.byscheme(hash.scheme,filename)
+ if ok and n > 0 then
+ data = d
+ end
+ end
+ end
local lines = data and string.splitlines(data)
if lines and #lines > 0 then
- -- this does not work yet as we cannot access the last lua error
- -- table.print(status.list())
- -- this will be a plugin sequence
- local what, where = match(errorstr,"LuaTeX error <main (%a+) instance>:(%d+)")
- if what and where then
+ -- This does not work completely as we cannot access the last Lua error using
+ -- table.print(status.list()). This is on the agenda. Eventually we will
+ -- have a sequence of checks here (tex, lua, mp) at this end.
+ --
+ -- Actually, in 0.75+ the lua error message is even weirder as you can
+ -- get:
+ --
+ -- LuaTeX error [string "\directlua "]:3: unexpected symbol near '1' ...
+ --
+ -- <inserted text> \endgroup \directlua {
+ --
+ -- So there is some work to be done in the LuaTeX engine.
+ --
+ local what, where = match(errorstr,[[LuaTeX error <main (%a+) instance>:(%d+)]])
+ or match(errorstr,[[LuaTeX error %[string "\\(.-lua) "%]:(%d+)]]) -- buglet
+ if where then
-- lua error: linenumber points to last line
- local start, stop = "\\start" .. what .. "code", "\\stop" .. what .. "code"
+ local start = "\\startluacode"
+ local stop = "\\stopluacode"
+ local where = tonumber(where)
if lines[linenumber] == start then
local n = linenumber
for i=n,1,-1 do
if lines[i] == start then
- local n = i + tonumber(where)
+ local n = i + where
if n <= linenumber then
linenumber = n
end
@@ -134,7 +157,9 @@ function tracers.showlines(filename,linenumber,offset,errorstr)
end
function tracers.printerror(offset)
- local filename, linenumber = status.filename, tonumber(status.linenumber) or 0
+ local inputstack = resolvers.inputstack
+ local filename = inputstack[#inputstack] or status.filename
+ local linenumber = tonumber(status.linenumber) or 0
if not filename then
report_system("error not related to input file: %s ...",status.lasterrorstring)
elseif type(filename) == "number" then
@@ -144,6 +169,7 @@ function tracers.printerror(offset)
-- add a bit of spacing around our variant
texio.write_nl("\n")
local errorstr = status.lasterrorstring or "?"
+ -- inspect(status.list())
report_system("error on line %s in file %s: %s ...\n",linenumber,filename,errorstr) -- lua error?
texio.write_nl(tracers.showlines(filename,linenumber,offset,errorstr),"\n")
end