summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-basics-gen.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/generic/context/luatex/luatex-basics-gen.lua')
-rw-r--r--tex/generic/context/luatex/luatex-basics-gen.lua102
1 files changed, 71 insertions, 31 deletions
diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua
index 2a68b1c18..2be55ccea 100644
--- a/tex/generic/context/luatex/luatex-basics-gen.lua
+++ b/tex/generic/context/luatex/luatex-basics-gen.lua
@@ -97,6 +97,7 @@ local remapper = {
-- fea = "font feature files", -- no longer supported
pfb = "type1 fonts", -- needed for vector loading
afm = "afm",
+ enc = "enc files",
}
function resolvers.findfile(name,fileformat)
@@ -257,45 +258,84 @@ function caches.is_writable(path,name)
return fullname and file.is_writable(fullname)
end
-function caches.loaddata(paths,name)
- for i=1,#paths do
- local data = false
- local luaname, lucname = makefullname(paths[i],name)
- if lucname and not lfs.isfile(lucname) and type(caches.compile) == "function" then
- -- in case we used luatex and luajittex mixed ... lub or luc file
- texio.write(string.format("(compiling luc: %s)",lucname))
- data = loadfile(luaname)
- if data then
- data = data()
- end
- if data then
- caches.compile(data,luaname,lucname)
- return data
- end
- end
- if lucname and lfs.isfile(lucname) then -- maybe also check for size
+-- function caches.loaddata(paths,name)
+-- for i=1,#paths do
+-- local data = false
+-- local luaname, lucname = makefullname(paths[i],name)
+-- if lucname and not lfs.isfile(lucname) and type(caches.compile) == "function" then
+-- -- in case we used luatex and luajittex mixed ... lub or luc file
+-- texio.write(string.format("(compiling luc: %s)",lucname))
+-- data = loadfile(luaname)
+-- if data then
+-- data = data()
+-- end
+-- if data then
+-- caches.compile(data,luaname,lucname)
+-- return data
+-- end
+-- end
+-- if lucname and lfs.isfile(lucname) then -- maybe also check for size
+-- texio.write(string.format("(load luc: %s)",lucname))
+-- data = loadfile(lucname)
+-- if data then
+-- data = data()
+-- end
+-- if data then
+-- return data
+-- else
+-- texio.write(string.format("(loading failed: %s)",lucname))
+-- end
+-- end
+-- if luaname and lfs.isfile(luaname) then
+-- texio.write(string.format("(load lua: %s)",luaname))
+-- data = loadfile(luaname)
+-- if data then
+-- data = data()
+-- end
+-- if data then
+-- return data
+-- end
+-- end
+-- end
+-- end
+
+function caches.loaddata(readables,name,writable)
+ for i=1,#readables do
+ local path = readables[i]
+ local loader = false
+ local luaname, lucname = makefullname(path,name)
+ if lfs.isfile(lucname) then
texio.write(string.format("(load luc: %s)",lucname))
- data = loadfile(lucname)
- if data then
- data = data()
+ loader = loadfile(lucname)
+ end
+ if not loader and lfs.isfile(luaname) then
+ -- can be different paths when we read a file database from disk
+ local luacrap, lucname = makefullname(writable,name)
+ texio.write(string.format("(compiling luc: %s)",lucname))
+ if lfs.isfile(lucname) then
+ loader = loadfile(lucname)
end
- if data then
- return data
+ caches.compile(data,luaname,lucname)
+ if lfs.isfile(lucname) then
+ texio.write(string.format("(load luc: %s)",lucname))
+ loader = loadfile(lucname)
else
texio.write(string.format("(loading failed: %s)",lucname))
end
- end
- if luaname and lfs.isfile(luaname) then
- texio.write(string.format("(load lua: %s)",luaname))
- data = loadfile(luaname)
- if data then
- data = data()
- end
- if data then
- return data
+ if not loader then
+ texio.write(string.format("(load lua: %s)",luaname))
+ loader = loadfile(luaname)
+ else
+ texio.write(string.format("(loading failed: %s)",luaname))
end
end
+ if loader then
+ loader = loader()
+ collectgarbage("step")
+ return loader
+ end
end
+ return false
end
function caches.savedata(path,name,data)