From c0641b1563ce1b0219724e19c772bbc180e86c2a Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 14 Jun 2010 14:02:28 +0300 Subject: Sync with ConTeXt beta (beta 2010.06.14) Fixes several bugs, including math bugs. --- otfl-luat-dum.lua | 97 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 21 deletions(-) (limited to 'otfl-luat-dum.lua') diff --git a/otfl-luat-dum.lua b/otfl-luat-dum.lua index 3946b6f..0737762 100644 --- a/otfl-luat-dum.lua +++ b/otfl-luat-dum.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luat-dum'] = { - version = 1.001, + version = 1.100, comment = "companion to luatex-*.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -80,29 +80,80 @@ end -- usage as I don't want any dependency at all. Also, ConTeXt might have -- different needs and tricks added. +--~ containers.usecache = true + caches = { } ---~ containers.usecache = true +local writable, readables = nil, { } + +if not caches.namespace or caches.namespace == "" or caches.namespace == "context" then + caches.namespace = 'generic' +end + +do + + local cachepaths = kpse.expand_path('$TEXMFCACHE') or "" + + if cachepaths == "" then + cachepaths = kpse.expand_path('$VARTEXMF') + end + + if cachepaths == "" then + cachepaths = "." + end + + cachepaths = string.split(cachepaths,os.type == "windows" and ";" or ":") -function caches.setpath(category,subcategory) --- local root = kpse.var_value("TEXMFCACHE") or "" --- if root == "" then --- root = kpse.var_value("VARTEXMF") or "" --- end - local var = kpse.var_value("TEXMFVAR") - local root = var and (var .. "/luatex/generic/luaotfload/") or "" - if root ~= "" then - root = file.join(root,category) - lfs.mkdir(root) - root = file.join(root,subcategory) - lfs.mkdir(root) - return lfs.isdir(root) and root + for i=1,#cachepaths do + if file.iswritable(cachepaths[i]) then + writable = file.join(cachepaths[i],"luatex-cache") + lfs.mkdir(writable) + writable = file.join(writable,caches.namespace) + lfs.mkdir(writable) + break + end end + + for i=1,#cachepaths do + if file.isreadable(cachepaths[i]) then + readables[#readables+1] = file.join(cachepaths[i],"luatex-cache",caches.namespace) + end + end + + if not writable then + texio.write_nl("quiting: fix your writable cache path") + os.exit() + elseif #readables == 0 then + texio.write_nl("quiting: fix your readable cache path") + os.exit() + elseif #readables == 1 and readables[1] == writable then + texio.write(string.format("(using cache: %s)",writable)) + else + texio.write(string.format("(using write cache: %s)",writable)) + texio.write(string.format("(using read cache: %s)",table.concat(readables, " "))) + end + +end + +function caches.getwritablepath(category,subcategory) + local path = file.join(writable,category) + lfs.mkdir(path) + path = file.join(path,subcategory) + lfs.mkdir(path) + return path +end + +function caches.getreadablepaths(category,subcategory) + local t = { } + for i=1,#readables do + t[i] = file.join(readables[i],category,subcategory) + end + return t end local function makefullname(path,name) if path and path ~= "" then - name = "temp-" and name -- clash prevention + name = "temp-" .. name -- clash prevention return file.addsuffix(file.join(path,name),"lua") end end @@ -112,17 +163,21 @@ function caches.iswritable(path,name) return fullname and file.iswritable(fullname) end -function caches.loaddata(path,name) - local fullname = makefullname(path,name) - if fullname then - local data = loadfile(fullname) - return data and data() +function caches.loaddata(paths,name) + for i=1,#paths do + local fullname = makefullname(paths[i],name) + if fullname then + texio.write(string.format("(load: %s)",fullname)) + local data = loadfile(fullname) + return data and data() + end end end function caches.savedata(path,name,data) local fullname = makefullname(path,name) if fullname then + texio.write(string.format("(save: %s)",fullname)) table.tofile(fullname,data,'return',false,true,false) end end -- cgit v1.2.3