summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-tex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-tex.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-tex.lua32
1 files changed, 20 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-tex.lua b/Master/texmf-dist/tex/context/base/data-tex.lua
index 6cb361699fa..f5c986d7708 100644
--- a/Master/texmf-dist/tex/context/base/data-tex.lua
+++ b/Master/texmf-dist/tex/context/base/data-tex.lua
@@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['data-tex'] = {
}
local char = string.char
+local insert, remove = table.insert, table.remove
local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
@@ -17,7 +18,7 @@ local resolvers = resolvers
local sequencers = utilities.sequencers
local methodhandler = resolvers.methodhandler
local splitlines = string.splitlines
-local utffiletype = unicode.filetype
+local utffiletype = utf.filetype
-- local fileprocessor = nil
-- local lineprocessor = nil
@@ -51,6 +52,10 @@ appendgroup(textlineactions,"after" ) -- user
local ctrl_d = char( 4) -- unix
local ctrl_z = char(26) -- windows
+resolvers.inputstack = resolvers.inputstack or { }
+
+local inputstack = resolvers.inputstack
+
function helpers.textopener(tag,filename,filehandle,coding)
local lines
local t_filehandle = type(filehandle)
@@ -61,22 +66,23 @@ function helpers.textopener(tag,filename,filehandle,coding)
elseif t_filehandle == "table" then
lines = filehandle
else
- lines = filehandle:read("*a")
+ lines = filehandle:read("*a") -- io.readall(filehandle) ... but never that large files anyway
+ -- lines = io.readall(filehandle)
filehandle:close()
end
if type(lines) == "string" then
local coding = coding or utffiletype(lines) -- so we can signal no regime
if trace_locating then
- report_tex("%s opener, '%s' opened using method '%s'",tag,filename,coding)
+ report_tex("%a opener: %a opened using method %a",tag,filename,coding)
end
if coding == "utf-16-be" then
- lines = unicode.utf16_to_utf8_be(lines)
+ lines = utf.utf16_to_utf8_be(lines)
elseif coding == "utf-16-le" then
- lines = unicode.utf16_to_utf8_le(lines)
+ lines = utf.utf16_to_utf8_le(lines)
elseif coding == "utf-32-be" then
- lines = unicode.utf32_to_utf8_be(lines)
+ lines = utf.utf32_to_utf8_be(lines)
elseif coding == "utf-32-le" then
- lines = unicode.utf32_to_utf8_le(lines)
+ lines = utf.utf32_to_utf8_le(lines)
else -- utf8 or unknown (could be a mkvi file)
local runner = textfileactions.runner
if runner then
@@ -85,22 +91,24 @@ function helpers.textopener(tag,filename,filehandle,coding)
lines = splitlines(lines)
end
elseif trace_locating then
- report_tex("%s opener, '%s' opened",tag,filename)
+ report_tex("%a opener: %a opened",tag,filename)
end
local noflines = #lines
if lines[noflines] == "" then -- maybe some special check is needed
lines[noflines] = nil
end
logs.show_open(filename)
+ insert(inputstack,filename)
return {
filename = filename,
noflines = noflines,
currentline = 0,
close = function()
if trace_locating then
- report_tex("%s closer, '%s' closed",tag,filename)
+ report_tex("%a closer: %a closed",tag,filename)
end
logs.show_close(filename)
+ remove(inputstack)
t = nil
end,
reader = function(self)
@@ -159,7 +167,7 @@ local function installhandler(namespace,what,where,func)
if where == "before" or where == "after" then
sequencers.appendaction(namespace,where,func)
else
- report_tex("installing input %s handlers in %s is not possible",what,tostring(where))
+ report_tex("installing input %a handlers in %a is not possible",what,tostring(where))
end
end
@@ -168,8 +176,8 @@ function resolvers.installinputfilehandler(...) installhandler(helpers.textfilea
-- local basename = file.basename
-- resolvers.installinputlinehandler(function(str,filename,linenumber,noflines)
--- report_tex("[lc] file: %s, line: %s of %s, length: %s",basename(filename),linenumber,noflines,#str)
+-- report_tex("[lc] file %a, line %a of %a, length %a",basename(filename),linenumber,noflines,#str)
-- end)
-- resolvers.installinputfilehandler(function(str,filename)
--- report_tex("[fc] file: %s, length: %s",basename(filename),#str)
+-- report_tex("[fc] file %a, length %a",basename(filename),#str)
-- end)