summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-12-11 23:25:49 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-12-11 23:25:49 +0100
commitf5180e94891872433c3c1ef068d5557c5969c993 (patch)
tree57f582921bc32b2562524f1546642f1c3c60a153 /scripts
parent16a45555ad3677155ea097a8153cf7e266879e13 (diff)
downloadluaotfload-f5180e94891872433c3c1ef068d5557c5969c993.tar.gz
[import] consider prefix variants when searching
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mkimport76
1 files changed, 46 insertions, 30 deletions
diff --git a/scripts/mkimport b/scripts/mkimport
index c25459b..132d026 100644
--- a/scripts/mkimport
+++ b/scripts/mkimport
@@ -36,9 +36,10 @@ local stringformat = string.format
-- config
-------------------------------------------------------------------------------
-local context_root = "/home/phg/context/tex/texmf-context"
-local our_prefix = "fontloader"
-local fontloader_subdir = "src/fontloader"
+local context_root = "/home/phg/context/tex/texmf-context"
+local our_prefix = "fontloader"
+local luatex_fonts_prefix = "luatex"
+local fontloader_subdir = "src/fontloader"
local origin_paths = {
context = "tex/context/base",
@@ -236,15 +237,17 @@ local derive_suffix = function (kind)
return ".lua"
end
-local pfxlen
-local strip_prefix = function (fname)
- if not pfxlen then pfxlen = #our_prefix end
- if #fname <= pfxlen + 2 then
+local pfxlen = { }
+local strip_prefix = function (fname, prefix)
+ prefix = prefix or our_prefix
+ if not pfxlen[prefix] then pfxlen[prefix] = #prefix end
+ local len = pfxlen[prefix]
+ if #fname <= len + 2 then
--- too short to accomodate prefix + basename
return
end
- if string.sub (fname, 1, pfxlen) == our_prefix then
- return string.sub (fname, pfxlen + 2)
+ if string.sub (fname, 1, len) == prefix then
+ return string.sub (fname, len + 2)
end
end
@@ -497,39 +500,52 @@ local search_paths = function (target)
end
local search_defs = function (target)
+ local variants = { target, --[[ unstripped ]] }
+ local tmp
+ tmp = strip_prefix (target)
+ if tmp then variants[#variants + 1] = tmp end
+ tmp = strip_prefix (target, luatex_fonts_prefix)
+ if tmp then variants[#variants + 1] = tmp end
+
+ local nvariants = #variants
+
for cat, defs in next, imports do
local ndefs = #defs
for i = 1, ndefs do
local def = defs[i]
- local dname = def.name
- if target == dname then
- local found = search_paths (target .. derive_suffix (def.kind))
- if found then return found end
- end
-
- local dkind = def.kind
- local dfull = derive_fullname (cat, dname, dkind)
- if derive_fullname (cat, target, dkind) == dfull then
- local found = search_paths (dfull)
- if found then return found end
- end
+ for i = 1, nvariants do
+ local variant = variants[i]
- local dours = def.ours
- if dours then
-
- local _, ourname = derive_ourname (dours, dkind)
- if target == dours then
- local found = search_paths (ourname)
+ local dname = def.name
+ if variant == dname then
+ local found = search_paths (variant .. derive_suffix (def.kind))
if found then return found end
end
- if target == ourname then
- local found = search_paths (ourname)
+ local dkind = def.kind
+ local dfull = derive_fullname (cat, dname, dkind)
+ if derive_fullname (cat, variant, dkind) == dfull then
+ local found = search_paths (dfull)
if found then return found end
end
- end
+ local dours = def.ours
+ if dours then
+
+ local _, ourname = derive_ourname (dours, dkind)
+ if variant == dours then
+ local found = search_paths (ourname)
+ if found then return found end
+ end
+
+ if variant == ourname then
+ local found = search_paths (ourname)
+ if found then return found end
+ end
+ end
+
+ end
end
end
return false