From 50476780411fb84f1f4d0dcb7cd865c1eba4141b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 20 Aug 2016 21:31:35 +0200 Subject: [fontloader] sync with Context as of 2016-08-29 --- src/fontloader/runtime/fontloader-basics-gen.lua | 100 ++++++++++++++++------- 1 file changed, 69 insertions(+), 31 deletions(-) (limited to 'src/fontloader/runtime/fontloader-basics-gen.lua') diff --git a/src/fontloader/runtime/fontloader-basics-gen.lua b/src/fontloader/runtime/fontloader-basics-gen.lua index 871e548..8ea93cc 100644 --- a/src/fontloader/runtime/fontloader-basics-gen.lua +++ b/src/fontloader/runtime/fontloader-basics-gen.lua @@ -258,45 +258,83 @@ 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 +-- 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 + loader = loadfile(lucname) 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() + 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) -- cgit v1.2.3